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

type introspection - how to check if a function is generated using a MixedFunctionSpace

+1 vote

I am doing some simulation of multi field problem. Right now I am trying to unify the uni field problem and multi field problem. Therefore I have to do some introspection to determine the type of problem.

More Specifically:

How can I easily know whether my function is a generated by a MixedFunctionSpace?

Thanks a lot!

asked Jan 9, 2016 by truemerlin FEniCS Novice (410 points)

1 Answer

+2 votes

Hi, consider

from dolfin import *

mesh = UnitSquareMesh(10, 10)

V = VectorFunctionSpace(mesh, 'CG', 1)
Q = FunctionSpace(mesh, 'CG', 1)
W = MixedFunctionSpace([V, Q])
B = FunctionSpace(mesh, 'BDM', 1)

fs = map(Function, (V, Q, W, B))

for f in fs:
    print f, f.function_space().ufl_element().family() == 'Mixed'
answered Jan 11, 2016 by MiroK FEniCS Expert (80,920 points)

Thanks! It did work!

It seems this ufl_element() method contains really a lot of informations.

I should play with that a little bit.

A small change also works! Just do f.ufl_element().family()

...