Putting a Dirichlet condition on only one element of a vector function

Asked by Christopher Laing

Hello everyone,

I have a problem in which I define a vector function u, and then wish to restrict the space of solutions to those which have u[1]=c on a boundary, where c is a constant or some other expression.

Can this be done with the DirichletBC class, or must lagrange multiplier be used?

Cheers,

Christopher

Question information

Language:
English Edit question
Status:
Solved
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Solved by:
Garth Wells
Solved:
Last query:
Last reply:
Revision history for this message
Best Garth Wells (garth-wells) said :
#1

You can use subspaces. Take a look at the stokes-taylor-hood demo.

Revision history for this message
Christopher Laing (9e9o1k-chris) said :
#2

Hi Garth,

Thanks for the suggestion. I've taken a look at the demo, but it's unclear to me how I can use this.

In the stokes-taylor-hood demo, a MixedFunctionSpace is defined, consisting of a VectorFunctionSpace and a FunctionSpace. Dirichlet conditions are then imposed on each of the subspaces using W.sub(i). This I understand.

However, within the VectorFunctionSpace V, dirichlet conditions are imposed on each component of the vector on each Dirichlet boundary, e.g. the lines:

inflow = Expression(("-sin(x[1]*pi)", "0.0", "0.0"))
bc1 = DirichletBC(W.sub(0), inflow, right)

impose Dirichlet conditions on u[0], u[1] and u[2].

By contrast, I wish to impose conditions on one component only. For example, one condition might be "restrict solutions to those vectors whose second component is zero on the boundary, but allow the other two components to be determined by a boundary integral".

One thing that I had thought of was to create a nested function space, with a vector space defined as:

Q = FunctionSpace(mesh, "CG", 2)
V = MixedFunctionSpace([Q,Q,Q])

Then impose Dirichlet conditions on only (say) the second element of the solution using V.sub(1).

Is this a reasonable approach?

Revision history for this message
Christopher Laing (9e9o1k-chris) said :
#3

For clarity, by "nested function space", I was referring to the fact that, on top of this space V, I would require an extra space for a lagrange multiplier, e.g.

Q = FunctionSpace(mesh, "CG", 2)
V = MixedFunctionSpace([Q,Q,Q])
R = FunctionSpace(mesh, "R", 0)
W = V*R

Where R is the space containing the lagrange multiplier.

Sorry if that caused confusion, it's not terribly relevant to the problem at hand.

Revision history for this message
Christopher Laing (9e9o1k-chris) said :
#4

Sorry, I think I've just discovered what you meant.

From the FEniCS documentation on the SubSpace class:

"A typical example is the function space W = V x P for Stokes. Here, V = W[0] is the subspace for the velocity component and P = W[1] is the subspace for the pressure component. Furthermore, W[0][0] = V[0] is the first component of the velocity space etc."

I assume what you mean is that I can apply DirichletBC to V[1] only. I will test this and see how I get on.

Sorry for not looking harder before posting replies!

Revision history for this message
Christopher Laing (9e9o1k-chris) said :
#5

Thanks Garth Wells, that solved my question.