← Back to team overview

dolfin team mailing list archive

Re: Coefficient initialization for functionals

 

On Wednesday 12 August 2009 01:48:35 pm Johan Jansson wrote:
> 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.

This looks like another argument to force a Function to have a FunctionSpace.

Johan

>   Johan
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


References