dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #14689
Coefficient initialization for functionals
Hi!
Me and Peter Brune ran into an issue with coefficient initialization for
functionals, specifically that the mesh is missing.
In the lift-drag demo in DOLFIN you have:
Function p(Vp, "../pressure.xml.gz");
FacetNormal n;
If you do:
Lift::Functional L(p, n);
then this works fine.
And that is equivalent to doing:
Lift::Functional L;
L.p = p;
L.n = n;
which also works fine.
However, if you switch the order:
Lift::Functional L;
L.n = n;
L.p = p;
then you get a dolfin_error with:
what(): *** Error: Unable to extract mesh from form (no mesh found).
from:
Lift::Form_0_Coefficient_n::create_function_space
(it's trying to do something like this: new
Form_0_FunctionSpace_0(form.mesh()); without the form having a mesh)
We suggest to solve this by requiring a mesh argument for Functional
initialization. What do you think?
For now we've solved this by re-ordering the arguments to our functional
(to give the coefficient with a function space as the first argument),
but you could have cases where none of the coefficients have a function
space at the time of the functional initialization.
Johan
Follow ups