Commit b251dd15 by Jigyasa Watwani

MWE for moving the mesh with prescribed velocity and then remeshing selectively

parent e9ee584d
Showing with 35 additions and 0 deletions
import dolfin as df
Nx = 5
L = 1
mesh = df.IntervalMesh(Nx, 0, L)
print(mesh.coordinates()[:, 0])
def refine_mesh(mesh):
cell_markers = df.MeshFunction("bool", mesh, mesh.topology().dim())
for cell in df.cells(mesh):
if cell.h()>0.3:
cell_markers[cell] = True
mesh = df.refine(mesh, cell_markers)
return mesh
for steps in range(1, 3):
# define a function space within the loop since mesh is changing
FS = df.FunctionSpace(mesh, 'P', 1)
v = df.Function(FS)
v = df.project(df.Expression('x[0]*x[0]', degree=1), FS)
# move the mesh
dr = df.project(v * steps, FS)
df.ALE.move(mesh, dr)
# refine the mesh selectively wherever a certain criteria is fulfilled
mesh = refine_mesh(mesh)
print(mesh.coordinates()[:, 0])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment