Hello
I have a rectangular domain with a rectangular hole inside. I want to move the nodes located on the boundaries of the rectangular hole in the y-direction at every time step and subsequently I expect the boundaries of the hole to move in the y-direction.
I have followed the example provided in this topic:
https://fenicsproject.org/qa/11852/moving-dirichlet-bc-ale
Here is the geometry and mesh:
And this is my implementation:
from dolfin import *
import mshr
# Domain
domain = mshr.Rectangle(Point(0,0), Point(4,4))\
- mshr.Rectangle(Point(1,1), Point(3,3))
# Mesh
mesh = mshr.generate_mesh(domain, 20)
class lower_edge(SubDomain):
def inside(self, x, on_boundary):
return True if x[0]<= 3.0 and x[0]>= 1.0 and x[1] == 1.0 else False
class top_edge(SubDomain):
def inside(self, x, on_boundary):
return True if x[0]<= 3.0 and x[0]>= 1.0 and x[1] == 3.0 else False
class left_edge(SubDomain):
def inside(self, x, on_boundary):
return True if x[0]==1.0 and x[1]<= 3.0 and x[1]>= 1.0 else False
class right_edge(SubDomain):
def inside(self, x, on_boundary):
return True if x[0]==3.0 and x[1]<= 3.0 and x[1]>= 1.0 else False
lower_edge = lower_edge()
top_edge = top_edge()
left_edge = left_edge()
right_edge = right_edge()
# Subdomain marker
mf = MeshFunction("size_t", mesh, 2)
mf.set_all(0)
lower_edge.mark(mf, 1)
top_edge.mark(mf, 2)
left_edge.mark(mf, 3)
right_edge.mark(mf, 4)
# Define facet function over the new mesh
ff = FacetFunction("size_t", mesh)
ff.set_all(0)
lower_edge.mark(ff, 1)
top_edge.mark(ff, 2)
left_edge.mark(ff, 3)
right_edge.mark(ff, 4)
plot(ff, interactive=True)
# Extract boundary mesh
bmesh = BoundaryMesh(mesh, "exterior", True)
#plot(bmesh, interactive=True)
t = 0.0
for i in range(10):
t += 0.1
for x in bmesh.coordinates():
if lower_edge.inside(x, True):
x[0] += 0.0
x[1] += 0.05
if top_edge.inside(x, True):
x[0] += 0.0
x[1] += 0.05
if left_edge.inside(x, True):
x[0] += 0.0
x[1] += 0.05
if right_edge.inside(x, True):
x[0] += 0.0
x[1] += 0.05
ALE.move(mesh, bmesh)
plot(ff, interactive=True)
As mentioned in the code, I have added displacement (equal to 0.05) only in the y-direction to the nodes located at the boundaries of the hole at every time-step but this is what I get at the last time step:
It seems like the bottom and top boundaries of the internal hole, do not even move!! As I said I expect all 4 boundaries to move upward during the time as the nodes attached to these boundaries are moving upward.
Could you please help me fix this issue?
Best