This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to change the mesh coordinate directly after some steps of calculation

0 votes

Hello All:

I want to apply a mechanical deformation in my phase field model.
e.g a small strain in x direction.

So I want to just apply this strain to the mesh while keeps all the dofs values on the nodes unchanged.

How to do it? Can I directly manipulate the coordinates of the mesh after some steps of calculation?

Thank you very much!
Best,
Sheng

asked Jun 4, 2014 by yinsheng008 FEniCS Novice (150 points)

ps: do I need also update the position of boundary? or the boundary is related to the nodes that I don't need to change?

1 Answer

+1 vote
 
Best answer

Hi, consider

from dolfin import *

mesh = UnitSquareMesh(3, 3)
# Mark boundaries of original mesh
bdry = FacetFunction('size_t', mesh, 0)
DomainBoundary().mark(bdry, 10)

# Function space for displacement u
V = VectorFunctionSpace(mesh, 'CG', 1)
# Shear displacement
u = interpolate(Expression(('0.25*x[1]', '0')), V)

plot(bdry, title='Initial', interactive=True)

# Move the mesh
mesh.move(u)
plot(bdry, title='Moved', interactive=True)

# Revert manually
x, y = mesh.coordinates()[:, 0], mesh.coordinates()[:, 1]
x -= 0.25*y
plot(bdry, title='And back', interactive=True) 

Mesh can also be rotated etc. See here.

answered Jun 4, 2014 by MiroK FEniCS Expert (80,920 points)
selected Jun 5, 2014 by yinsheng008

Thank you very much!

...