← Back to team overview

dolfin team mailing list archive

Re: new Function design

 

On Tue, Oct 21, 2008 at 08:35:45PM +0100, Garth N. Wells wrote:
> 
> 
> Anders Logg wrote:
> > On Tue, Oct 21, 2008 at 06:01:53PM +0100, Garth N. Wells wrote:
> >>
> >> Anders Logg wrote:
> >>> On Tue, Oct 21, 2008 at 04:45:01PM +0100, Garth N. Wells wrote:
> >>>> I have a few questions and thoughts regarding the new Function design
> >>>>
> >>>> * It's not clear to me what the intention is with user-defined 
> >>>> functions. The functions Function::interpolate(...) never call eval(..), 
> >>>> so they can't pick up user-defined values. Should Function::interpolate 
> >>>> test for the presence of a GenericVector to decide whether or not the 
> >>>> Function is discrete or user-defined?
> >>> Yes, sorry. I've missed this. I'll fix it.
> >>>
> >>>> * It would be useful to declare user-defined functions without 
> >>>> associating a FunctionSpace. If we want to interpolate the function, a 
> >>>> FunctionSpace must then be provided. Anyone see any problems with this?
> >>> The reasoning here is that all Functions must always be associated
> >>> with a FunctionSpace so that they may be correctly interpreted in
> >>> forms and correctly plotted. When a Function is created in PyDOLFIN,
> >>> it must always be associated with a certain FiniteElement (and in a
> >>> while FunctionSpace). It would simplify the handling of Functions if
> >>> they are always associated with a FunctionSpace.
> >>>
> >> I agree that is makes life simple if every function has a space, but it 
> >> is a bit clunky for declaring user-defined functions. The forms must be 
> >> declared first to extract the finite element to create the function 
> >> space. Could look nasty when a lot of functions are involved.
> >>
> >> We have a function Function::interpolate which takes a function space V 
> >> as an argument and it interpolates the function u in V. What if we 
> >> permit undefined function spaces (which perhaps only have a domain)? We 
> >> would then interpolate the user defined function u in the provided space V.
> >>
> >> Garth
> > 
> > Are user-defined functions ever used without being related to a
> > particular element/function space?
> > 
> 
> No, but one user-defined function can be used with different elements.

That would be accomplished by sending different function spaces to the constructor:

  f = MyFunction(V)
  g = MyFunction(W)

> > It don't think it will be very clumsy. The clumsy thing will be to (in
> > C++) get from something compiled by a form compiler to a FunctionSpace.
> > 
> > If we can make that operation smooth, then creating (user-defined)
> > functions will be very simple and convenient. One just needs to supply
> > the variable V holding the function space.
> > 
> > The current way of extracting function space data from the form is not
> > very nice (in C++).
> 
> Agree.
> 
>   What would be the optimal way to initialize a
> > FunctionSpace in C++? We could think of extending the code generation
> > to generate code that makes this convenient.
> > 
> 
> Yes, FFC could generate some simple code to help with the creation of a 
> FunctionSpace.
> 
> In the old Function design there was an a function
> 
>      void interpolate(double* coefficients,
>                       const ufc::cell& ufc_cell,
>                       const FiniteElement& finite_element,
>                       Cell& cell, int facet=-1);
> 
> which says: given a Function u defined on its own element (or perhaps no 
> element), interpolate u on finite_element. Do we still need this style 
> of interface to check the finite element expected by the form during 
> assembly matches the finite element of the provided Function? Also this 
> way we deal with user-defined functions without a basis. What I don't 
> know is how to attach a finite element to a FunctionSpace after the 
> FunctionSpace has been created, which would be need for a user-defined 
> function without a finite element to become a discrete function.
> 
> Garth

This is not needed anymore since a function is always interpolated
(locally) to its own space which is always defined. But I've added a
new function that allows a function to be interpolated to any other
space (globally), so far assuming that the meshes are the same.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References