Hi Tomasz, On 25/10/16 11:25, Tomasz Salwa [RPG] wrote:
Dear all,
I would like to check the convergence of my solution as I refine the mesh.
Say, I have two solutions in CG1 space, f_coarse on mesh_coarse and f_fine on mesh_fine, which is a refined mesh_coarse. Can I map/interpolate/project f_fine onto mesh_coarse in Firedrake?
A few questions: How did you get the exact solution that you're checking convergence against? If it's analytic, can you just interpolate that expression on the different meshes? How did you get the refined mesh? Did you make it with a MeshHierarchy? In which case prolong and inject respectively transfer solution variables from coarse to fine and fine to coarse. If neither of those is true, you can interpolate the coordinates into a vector valued space of the same type as you solution field on the coarse mesh, get the data values, and evaluate your solution on the fine mesh at those points. You can then put these values back in a coarse function. Something like this, untested: mesh_coarse = ... mesh_fine = ... V = FunctionSpace(mesh_coarse, "CG", 2) Vf = FunctionSpace(mesh_fine, "CG", 2) coarse_points = Function(VectorFunctionSpace(mesh_coarse, "CG", 2)) coarse_points.interpolate(SpatialCoordinate(mesh_coarse)) fine_exact = Function(Vf) # Construct solution somehow. coarse_data = fine_exact.at(coarse_points.dat.data_ro) coarse_exact = Function(V) coarse_exact.dat.data[:] = coarse_data[:] # Now coarse_exact has the fine_exact solution interpolated on the coarse mesh. Cheers, Lawrence