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

Periodic BC with Vector Function Space

0 votes

Dear all,
I'm working on a problem that requires the application of periodic BC. In my problem, I implemented an incompressible Neo Hookean material through a mixed formulation and my unknown is a vectorial unknown, the nodal displacements. I would apply periodic BC to the "vertical" boundary of a rectangle.

I have a couple of questions:
- is it possible to apply a periodic BC to a VectorFunctionSpace using the procedure as explained in demo_periodic.py?
- does periodic BC work in mixed formulation (I red something about this but I didn't understand enough)?

Here you can find some code lines to better explain what I implemented.

# Create the geometry and the mesh
mesh = UnitSquareMesh(600,19)
# Create rectangle from square
x = mesh.coordinates()[:,0]
y = mesh.coordinates()[:,1]
def init(m) :
   return [0 for i in range(m)]
x_bar = init(len(x))
y_bar = init(len(x))
for k in range(len(x)) :
   y_bar[k] = y[k]*0.24
   x_bar[k] = x[k]*20
xy_bar_coor = np.array([x_bar, y_bar]).transpose()
mesh.coordinates()[:] = xy_bar_coor
# Define periodic boundary condition at the extremities
class PeriodicBoundary(SubDomain):
   def inside(self,x,on_boundary) :
   # x[0] = 0 is the reference boundary
      return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)
   #map x[0] = 0 to x[0] = 0
   def map(self,x,y) :
      y[0] = x[0] - 20
      y[1] = x[1]
pbc = PeriodicBoundary()
# Create function space
P2 = VectorFunctionSpace(mesh, "CG", 2, constrained_domain = PeriodicBoundary())
P1 = FunctionSpace(mesh, "CG", 1)
V = MixedFunctionSpace([P1,P2])
# Dirichlet BC
class X(SubDomain):
  def inside(self, x, on_boundary):
     return near(x[0],0.0,0.001) 
class Y(SubDomain):
  def inside(self, x, on_boundary):
     return near(x[1],0.0,0.001) 
 class XX(SubDomain):
  def inside(self, x, on_boundary):
     return near(x[0],20.0,0.001) 
 x = X()
 y = Y()
 xx = XX()
 zero = Constant(0.0)
 bc1 = DirichletBC(V.sub(1).sub(0), zero_scalar, X())
 bc2 = DirichletBC(V.sub(1).sub(1), zero_scalar, Y())
 bc3 = DirichletBC(V.sub(1).sub(0), zero_scalar, XX())
 bc = [bc1, bc2, bc3]
 #Energy formulation and variational form
 #Solve

Should this code work?
I hope I've been enough clear and I really thank you in advance for your help,

James

asked Dec 29, 2013 by James FEniCS Novice (120 points)

1 Answer

+1 vote

Hi,

Periodic boundary conditions work for any combination of mixed continuous Lagrange spaces. I think your code should work, but I would recommend simplifying the mesh scaling with the much faster

x = mesh.coordinates()
x[:, 0] = x[:, 0]*20
x[:, 1] = x[:, 1]*0.24

or use RectangleMesh(0, 0, 20, 0.24, 600, 19)

answered Dec 30, 2013 by mikael-mortensen FEniCS Expert (29,340 points)
edited Dec 30, 2013 by mikael-mortensen

Hi Mikael,
with a short delay, I thank you very much for both the answer to the question and the advice about using mesh commands.

James

...