[firedrake] Concatenation of function spaces?
Lawrence Mitchell
lawrence.mitchell at imperial.ac.uk
Fri Jul 24 11:42:36 BST 2015
> On 24 Jul 2015, at 11:25, Justin Chang <jychang48 at gmail.com> wrote:
>
> Thanks for the responses guys. However, I am running into issues regarding
> Dirichlet bcs for P2/P0 elements. Attached is the code:
>
> I am trying to apply homogeneous boundary conditions in the P0 space, and
> when I looked at the documentation online it said to use DirichletBC(Q,
> <value>, <boundary_id>, method="geometric")
> but I am getting these kinds of errors:
Aha, this is a simple problem. When you define a MixedFunctionSpace and then want to apply boundary conditions on a part of the space, you must define the boundary condition on an indexed subspace, rather than the original space.
That is:
V = ...
Q = ...
W = V*Q
bc = DirichletBC(W.sub(1), ...)
rather than
bc = DirichletBC(Q, ...)
This is in the documentation (http://firedrakeproject.org/variational-problems.html#incorporating-boundary-conditions) but maybe not clearly enough.
Making this change, and your code runs fine.
I note in passing, that the DirichletBC constructor can take a list of boundary ids as well as just a single id. So, since all the boundary condition values are the same you can replace your six separate BC objects by:
bcs = DirichletBC(W.sub(1), 0, (1, 2, 3, 4, 5, 6), method="geometric")
Cheers,
Lawrence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mailman.ic.ac.uk/pipermail/firedrake/attachments/20150724/97c20c6a/attachment.sig>
More information about the firedrake
mailing list