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

Apply "linewise" Dirichlet BC in 3D

0 votes

Hi,

I want to apply Dirichlet BCs along a line (x[0] = 0 and x[1] = 0) on a 3D geometry. So I tried :

mesh =  Mesh("My_3D_mesh.xml")
V = VectorFunctionSpace(mesh, "Lagrange", 1)

class MyLine(SubDomain):
  def inside(self, x, on_boundary):
    return near(x[0], 0., TOL) and near(x[1], 0., TOL) and on_boundary

myLine = MyLine()
bc = DirichletBC(V.sub(0), Constant((0.)),myLine,method="pointwise")

And I get the following error :

*** Error:   Unable to create Dirichlet boundary condition.
*** Reason:  Illegal value dimension (2), expecting (3).
*** Where:   This error was encountered inside DirichletBC.cpp.

What is wrong with my implementation ? Is there a way to apply such a boundary condition in 3D ?

Many thanks in advance !

Claire

closed with the note: solved !
asked Feb 4, 2016 by Claire L FEniCS User (2,120 points)
closed Feb 10, 2016 by Claire L

Your code works fine in fenics 1.6 using a UnitCubeMesh (i don't see anything wrong with your code. Maybe something is wrong with the mesh?).

My fault, I just found my mistake (!), my initial code was :

bc = DirichletBC(V, Constant((0.,0.)),myLine,method="pointwise")

Constant((0.,0.)) does not match dimension of V which is 3D !

Maybe I should delete this topic ?

...