Hi,
I am using DOLFIN version: 1.7.0dev. I try to introduce a small and localized perturbation in a 3D mesh near point p
which is on the surface of the meshed volume. In a first step I need to refine the mesh in the neighbourhood of point p
:
p = Point(x0, y0, z0)
for i in range(1):
print("marking for refinement")
# Mark cells for refinement
cell_markers = CellFunction("bool", mesh)
for c in cells(mesh):
if c.midpoint().distance(p) < 0.1:
cell_markers[c] = True
else:
cell_markers[c] = False
# Refine mesh
mesh = refine(mesh, cell_markers)
In a second step I define the perturbation and move the mesh :
lpx = 0.01
lpy = 0.01
class MyExpression1(Expression):
def eval(self, value, x):
value[0] = lpx*exp(-((x[0]-x0)**2.+(x[1]-y0)**2.+(x[2]-z0)**2.)/lpx**2)
value[1] = -lpy*exp(-((x[0]-x0)**2.+(x[1]-y0)**2.+(x[2]-z0)**2.)/lpy**2)
value[2] = 0
def value_shape(self):
return (3,)
u3D = interpolate(MyExpression1(),V)
mesh.move(u3D)
But I get the following error :
*** Error: Unable to interpolate function values at vertices.
*** Reason: Non-matching mesh.
*** Where: This error was encountered inside Function.cpp.
Is it possible to combine functions refine
and move
on a mesh ?
Many thanks in advance for your help !
Claire