Hello all,
If I create a function from a mixed space and I want to define two new functions from the linear combinations of the subfunctions, how do I do this? I want to be able to compute the sensitivity with respect to the original function. I tried:
element = FiniteElement("CG", mesh.ufl_cell(), 1)
mixed_element = MixedElement([element,element])
V = FunctionSpace(mesh,mixed_element)
func = Function(V)
singleVspace = V.sub(0).collapse()
Wp = Function(singleVspace)
Wm = Function(singleVspace)
assigner0 = FunctionAssigner(singleVspace, V.sub(0))
assigner1 = FunctionAssigner(singleVspace, V.sub(1))
assigner0.assign(Wp, func.sub(0))
assigner1.assign(Wm, func.sub(1))
Wa = Wp - Wm
Wb = Wp + Wm
but after trying to compute a gradient with respect to the function func, i get an error:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to create function.
*** Reason: Cannot be created from subspace. Consider collapsing the function space.
*** Where: This error was encountered inside Function.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset: 8060a84e8ada0df018772497534092727b06bd56
*** -------------------------------------------------------------------------
Any help is appreciated!