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

How to constraint only one component of the vector field using boundary conditions?

+13 votes

Is there a way to constraint only say the 3rd component of a vector field at the boundary?
For example, I can fix all the components of a 3-dimensional vector field by doing :

bc1 = DirichletBC(V, (0, 0 ,0), boundary)

But is there a way to say constraint only the 3rd component and not the other components ?

Thanks!!

asked Apr 29, 2014 by lee FEniCS User (1,170 points)

Regarding this, the V1.5 interface has changed slightly so this would be

std::vector< std::size_t > sub{2};
bc1 = DirichletBC(*(V.extract_sub_space(sub)), Constant(0), boundary);

1 Answer

+12 votes
 
Best answer

Try

bc1 = DirichletBC(V.sub(2), Constant(0), boundary)
answered Apr 29, 2014 by Øyvind Evju FEniCS Expert (17,700 points)
selected Apr 29, 2014 by Marie E. Rognes
How to constraint only one component in DG method
...