simple question on mesh_snap_boundary

Asked by Xiaoxian Liu on 2013-01-25

Hi all,

I explored the usage of "mesh_snap_boundary" with the following simple code:

### Beginning of code
print mesh.coordinates()

class LeftRegion(SubDomain):
 def inside(self, x, on_boundary):
  return True if x[0]<=0.5 else False
 def snap(self, x):
  if x[0]<=0.5+DOLFIN_EPS: x[0]=0.5*(x[0]-0); x[1]=x[1]

left = LeftRegion()
print mesh.coordinates()
### End of code

I simply want to push the vertices on the left side of the unit square towards y-axis by a factor of 0.5, so [0.5, y] should become [0.25, y]. However, the output of the code above is, after "snapping",

[[ 0. 0. ]
 [ 0.25 0. ]
 [ 1. 0. ]
 [ 0. 0.5 ]
 [ 0.375 0.5 ]
 [ 1. 0.5 ]
 [ 0. 1. ]
 [ 0.25 1. ]
 [ 1. 1. ]]

Could anyone tell me why the center vertex became [0.375, 0.5], rather than [0.25, 0.5]?

Thanks a lot!

Question information

English Edit question
DOLFIN Edit question
No assignee Edit question
Last query:
Last reply:
Jan Blechta (blechta) said : #1

Mesh.snap_boundary() method snaps only boundary vertices of mesh and interior vertices are subjet to harmonic smoothing unless you turn it off by calling
  mesh.snap_boundary(left, False)

So if you want to move interior vertices either you can do it by writting into mesh.coordinates().

You could also do
  submesh = SubMesh(mesh, left)
where displacement is instance of Function with appropriate shape. But I'm not sure whether harmonic smoothing can be turned on/off in Mesh.move() method.

Can you help with this problem?

Provide an answer of your own, or ask Xiaoxian Liu for more information if necessary.

To post a message you must log in.