Hi,
I’m working with a surface mesh mesh_H
and a finite element function f_H
defined on it, which is an interpolation of the smooth function f = sin(x) * y * z
. Here is my code:
f = sin(x)*y*z
sphere = Sphere((0,0,0),1).faces[0]
sphere.name = "sphere"
geo = OCCGeometry(sphere)
mesh_H = Mesh(geo.GenerateMesh(maxh=0.5))
# Draw(mesh_H)
V_H = H1(mesh_H, order=1)
f_H = GridFunction(V_H)
f_H.Set(f, definedon=mesh_H.Boundaries(".*"))
I then perform local refinement on mesh_H
to obtain a finer mesh mesh_h
:
mesh_h = Mesh(mesh_H.ngmesh.Copy())
ind = np.zeros(mesh_h.nface); ind[3] = 1
for el in mesh_h.Elements(BND):
mesh_h.SetRefinementFlag(el, ind[el.nr])
mesh_h.Refine(mark_surface_elements=True)
At this point, I want to interpolate the finite element function f_H
from the coarse mesh mesh_H
onto the refined mesh mesh_h
:
V_h = H1(mesh_h, order=1)
f_h = GridFunction(V_h)
f_h.Set(f_H, definedon=mesh_h.Boundaries(".*"))
print(Integrate(f_h, mesh_h, definedon=mesh_h.Boundaries('.*')))
However, this approach crashes the Jupyter kernel, though similar code works perfectly on a planar mesh. I have attached my example code for reference. Could you please advise on how to properly interpolate between coarse and fine meshes on a surface mesh?
Thanks in advance for your help!
test.ipynb (3.1 KB)