← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Automatically interpolate user-defined functions on assignment

 

On Fri, Mar 13, 2009 at 10:22:37AM +0100, Martin Sandve Alnæs wrote:
> On Fri, Mar 13, 2009 at 10:11 AM, Garth N. Wells <gnw20@xxxxxxxxx> wrote:
> >
> >
> > Martin Sandve Alnæs wrote:
> >>
> >> On Thu, Mar 12, 2009 at 11:05 PM, Garth N. Wells <gnw20@xxxxxxxxx> wrote:
> >>>
> >>> Anders Logg wrote:
> >>>> It seems it wouldn't be anymore difficult than what we have now. For
> >>>> example, the Poisson demo would be
> >>>>
> >>>>  UnitSquare mesh(32, 32);
> >>>>  PoissonFunctionSpace V(mesh);
> >>>>
> >>>>  PoissonBilinearForm a(V, V);
> >>>>  PoissonLinearForm L(V);
> >>>>  Source f(V);
> >>>>  L.f = f; // without side effect
> >>>>
> >>> That's OK, but if you have >5 coefficients with >5 different functions
> >>> spaces, it's not nice.
> >>
> >> This feature will without doubt lead to many users writing code where
> >> function spaces are duplicated. If you have a form where more than one
> >> coefficient shares same function space, you shouldn't use this feature.
> >> Even if it is well documented, people don't generally read documentation
> >> until things break.
> >>
> >> If we strictly require that functions have function spaces, we can instead
> >> check that the form coefficient function spaces match the given function
> >> in "L.f = f;". Then your problem is reduced to runtime "typechecking".
> >>
> >
> > The problem is the number of lines a user must program, and having
> > intelligible names for the spaces.
> 
> The Form/FunctionSpace code generation in wrote and placed
> in dolfin_utils/ produces names like this from .ufl files:
> 
>     PoissonBilinearForm::TrialSpace V(mesh);
>     PoissonLinearForm::CoefficientSpace_f F(mesh);
>     PoissonLinearForm::CoefficientSpace_g G(mesh);
> 
>     PoissonBilinearForm a(V, V);
>     PoissonLinearForm L(V);

This will be used by FFC once the UFL transition is in place.

I think this is simple enough to require that a Function always has a
FunctionSpace.

> And after working a bit with this I wrote the following:
> 
> // Suggestions for improvement to naming conventions:
> //  Poisson::BilinearForm::TrialSpace V(mesh);
> //  Poisson::BilinearForm::CoefficientSpace_f F(mesh);
> //  Poisson::CoefficientSpace_f F(mesh);
> //  Poisson::CoefficientSpace_g G(mesh);
> //
> //  Poisson::BilinearForm a(V, V);
> //  Poisson::LinearForm L(V);

This looks good and we actually used this naming convention a while
back (nested namespaces), but I think it was removed because of some
problems with SWIG. Now that these are only used from the C++ side
(JIT compilation just uses UFC), we could change back.

-- 
Anders


> Here "Poisson" is the prefix taken from "Poisson.ufl",
> PoissonBilinearForm is a typedef to PoissonForm_a
> such that any number of forms can be defined in each file,
> and "g" in PoissonLinearForm::CoefficientSpace_g is
> the name of the variable holding the Function in the .ufl file
> (g = Function(...)).
> 
> I find this acceptable to work with.
> 
> Martin
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev

Attachment: signature.asc
Description: Digital signature


References