dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #11172
Re: Behaviour of Function::vector() on instance of Function subclass
On Tue, Dec 16, 2008 at 02:41:01PM +0000, Garth N. Wells wrote:
>
>
> Anders Logg wrote:
> > On Tue, Dec 16, 2008 at 02:19:38PM +0000, Garth N. Wells wrote:
> >>
> >> Anders Logg wrote:
> >>> On Tue, Dec 16, 2008 at 02:20:22PM +0100, Martin Sandve Alnæs wrote:
> >>>> If I subclass Function and implement eval, then
> >>>> call vector() on an object of my class, a vector
> >>>> is created but initialized to zero. I would rather
> >>>> expect that the function is evaluated in the function space:
> >>>>
> >>>> GenericVector& Function::vector()
> >>>> {
> >>>> // Initialize vector of dofs if not initialized
> >>>> if (!_vector)
> >>>> + {
> >>>> init();
> >>>> + interpolate(*_vector, *_function_space);
> >>>> + }
> >>>>
> >>>> dolfin_assert(_vector);
> >>>> return *_vector;
> >>>> }
> >>> Looks like a good idea. Can you add it?
> >>>
> >>>> But I'm not sure what kind of side effects this can have on other code?
> >>>>
> >>>> Martin
> >>> I don't think it will have more side effects than what we have now
> >>> when we just create a zero vector.
> >>>
> >> Interpolate is tricky because not all functions (e.g. DG) are
> >> interpolated sensibly. This issue pops up in the VTK io.
> >>
> >> Garth
> >
> > I don't think that's a problem here. The interpolation will be into
> > the appropriate function space, which for a DG function is a DG space,
> > so for DG0, the vector will contain one value for each cell.
> >
>
> DG(k), k > 0 is the problem.
>
> Garth
Same thing there. The interpolation is element by element and all
values are inserted into the vector.
The only problem I see is if you're having an expression that is
multi-valued at the facets, but that seems unlikely.
--
Anders
Attachment:
signature.asc
Description: Digital signature
References