← Back to team overview

dolfin team mailing list archive

Re: [HG] Merge.

 

On Tue, Sep 19, 2006 at 12:43:00PM +0200, Johan Jansson wrote:
> On Tue, Sep 19, 2006 at 09:15:51AM +0200, Anders Logg wrote:
> > Sounds very interesting. What does the interpolation do? Can you
> > interpolate/project between two given functions?
> > 
> > /Anders
> > 
> 
> You can interpolate between two given functions (the target needs to
> be a DiscreteFunction). It uses the same interpolation functionality
> as the assemble functions, so it has the same capabilities as
> that. The primary reason for adding this interface is to be able to
> interpolate an initial value given by a UserFunction to a
> DiscreteFunction. But it should also work for interpolating a
> quadratic solution to a linear finite element space for example, as
> far as I can see.

It looks a little strange:

void Function::interpolate(Function& ftarget)
{
  // Delegate function call
  f->interpolate(ftarget);
}

Here ftarget is the target for the interpolation, so ftarget = P(*this).

But then in DiscreteFunction::interpolate()

void DiscreteFunction::interpolate(Function& fsource)
{                                             ~~~~~~
  Vector& x = vector();
              ~~~~~~~~~
  ...
      x(nodes[i]) = coefficients[i];
      ~~~~~~~~~~~~~
}

So it seems that ftarget is actually the source.

> I want to add projection too, but that probably has to go via
> PyDOLFIN.

It seems that this will only work when the old interpolate() function
works, and that one only works when interpolating onto a restriction
of the global space. It won't work between different types of
functions defined by different elements or on different meshes.

Another thing: do you need to do the interpolation from initial values
explicitly? I made a fix previously so you can define say u0 as a
user function, but then you can do

  u0 = u1;

and u0 becomes a discrete function. Then the interpolation is not needed.

/Anders


Follow ups

References