Hi!
I have a sequence of meshings of the sphere, and wish to calculate the error between two consecutive solutions. Find below my attempt:
from dolfin import *
from mshr import *
import numpy as np
x_h=SpatialCoordinate(coarse_mesh)
r_h=sqrt(inner(x_h,x_h))
n=x_h/r_h
N=CellNormal(coarse_mesh)
J=(1.0/r_h)**2*abs(inner(N,n))
x=x_h/sqrt(dot(x_h,x_h))
f_fine=project(solution_fine,coarse_functionspace)
f_cors=project(solution_course,coarse_functionspace)
f_cors.set_allow_extrapolation(True)
f_fine.set_allow_extrapolation(True)
e_h=f_fine-f_cors
return(sqrt(assemble(e_h**2*J*dx(domain=coarse),form_compiler_parameters = {"quadrature_degree": 5})))
here coarse_mesh is the coarser mesh, coarse_functionspace is a functionspace over the mesh of the same type as fine_functionspace, and solution_fine and solution_course are two solutions from each mesh. It works for the coarsest two meshes but fails for the finer… I get the error:
Error: Unable to evaluate function at point.
The point is not inside the domain. Consider calling "Function::set_allow_extrapolation(true)" on this Function to allow extrapolation.
Changing around which domain I integrate over and such yields other errors, for instance changing the integration domain to the finer mesh and extrapolating the coarse solution gets me
Error: Unable to create mesh entity.
Reason: Mesh entity index -1 out of range [0, 320] for entity of dimension 2.
I also get a lot of “Applying str() to a metadata value of type set, don’t know if this is safe.”, how do I get rid of that?
So, any suggestions?