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

ALE.move class and mesh displacement

0 votes

Dear all,

I am using the class ALE in order to move my mesh according to new boundaries at each time step:

ALE.move(mesh, new_boundary)

Now, I would like to access the resulting displacement to compute the velocity of the mesh movement, and set this velocity as DC boundary condition for the next time step of the simulation. As it says in the documentation the resulting displacement is "encapsulated in Expression subclass MeshDisplacement". My question is how I can access this displacement and use it to compute the velocity. I tried something like this:

V = VectorFunctionSpace(mesh, 'CG', 1)
u_mesh = Function(V)
displ = ALE.move(mesh, new_boundary)
u_mesh = displ/dt
bcu = DirichletBC(V, u_mesh, subdomain_wall, 1)

But it fails in the calculation of u_mesh. I would like to know how to use displ to compute u_mesh.
Many thanks in advance for your help and suggestions!

Sebastiano

asked Jan 20, 2016 by Sebastiano FEniCS Novice (220 points)

1 Answer

+1 vote
 
Best answer

Hi, consider

from dolfin import *
import numpy as np

dt = 0.5
mesh = UnitSquareMesh(4, 4)
bmesh = RectangleMesh(Point(1, 1), Point(2, 2), 4, 4)
bmesh = BoundaryMesh(bmesh, 'exterior')
u = ALE.move(mesh, bmesh)

# Velocity as function
V = VectorFunctionSpace(mesh, 'CG', 1)
v = interpolate(u, V)
v.vector()[:] /= dt 
bcf = DirichletBC(V, v, 'on_boundary')

# Velocity as expression
class Velocity(Expression):
    def __init__(self, u, dt):
        self.u = u
        self.dt = dt
    def eval_cell(self, value, x, cell):
        self.u.eval_cell(value, x, cell)
        value /= dt
    def value_shape(self):
        return (2, )

v = Velocity(u, dt)
bcg = DirichletBC(V, v, 'on_boundary')

# Check
f = bcf.get_boundary_values() 
g = bcg.get_boundary_values()
assert len(set(g.keys())-set(f.keys())) == 0
assert all(near(f[key], g[key]) for key in f)
answered Jan 22, 2016 by MiroK FEniCS Expert (80,920 points)
selected Feb 3, 2016 by Sebastiano

Many thanks for your answer. The movement and the boundary condition work as expected now. I have just a question regarding the movement of the mesh.
Using the ALE.move does intend that the mesh is also smoothed after the movement? Or I have to use:

mesh.smooth(num_smooth)

after ALE.move?
Many thanks.

Hi, move according to the boundary mesh uses smoothing. See here.

...