Creating a Mixed function space of 3 subspaces in C++

Asked by Pietro Maximoff

Hello

I'm trying to create a mixed function space with 3 subspaces but only 2 is being created.

V = VectorElement("CG", tetrahedron, 1)
TV = TensorElement("DG", tetrahedron, 1)
element = V * TV * TV

From a previous thread (https://answers.launchpad.net/dolfin/+question/164237), Johan said this reads as (V*TV)*V and therefore creates 2 subspaces. He gave a solution (but for Python). How do I do this in a ufl file in C++?

Thanks

P.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Pietro Maximoff
Solved:
Last query:
Last reply:
Revision history for this message
Martin Sandve Alnæs (martinal) said :
#1

MixedElement(U,V,W).

Martin
Den 3. feb. 2012 13.11 skrev "Pietro Maximoff" <
<email address hidden>> følgende:

> New question #186711 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/186711
>
> Hello
>
> I'm trying to create a mixed function space with 3 subspaces but only 2 is
> being created.
>
> V = VectorElement("CG", tetrahedron, 1)
> TV = TensorElement("DG", tetrahedron, 1)
> element = V * TV * TV
>
> >From a previous thread (
> https://answers.launchpad.net/dolfin/+question/164237), Johan said this
> reads as (V*TV)*V and therefore creates 2 subspaces. He gave a solution
> (but for Python). How do I do this in a ufl file in C++?
>
> Thanks
>
> P.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Revision history for this message
Johan Hake (johan-hake) said :
#2

On Friday February 3 2012 13:11:07 Pietro Maximoff wrote:
> New question #186711 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/186711
>
> Hello
>
> I'm trying to create a mixed function space with 3 subspaces but only 2 is
> being created.
>
> V = VectorElement("CG", tetrahedron, 1)
> TV = TensorElement("DG", tetrahedron, 1)
> element = V * TV * TV
>
> >From a previous thread
> >(https://answers.launchpad.net/dolfin/+question/164237), Johan said this
> >reads as (V*TV)*V and therefore creates 2 subspaces. He gave a solution
> >(but for Python). How do I do this in a ufl file in C++?

Same as with FunctionSpaces in the Python interface of DOLFIN. As a matter of
fact, a FunctionSpace has a ufl FiniteElement.

So, try:

  element = MixedElement([V, TV, TV])

All of this and much more can be found in:

  http://launchpad.net/fenics-book/trunk/final/+download/fenics-
manual-2011-10-31.pdf

Johan

Revision history for this message
Pietro Maximoff (segment-x) said :
#3

Thanks Martin and Johan. Works fine.

Thanks for the link, Johan.