← Back to team overview

dolfin team mailing list archive

Re: Arithmetic operations on Functions

 

On Mon, Mar 31, 2008 at 02:42:14PM +0200, Kristen Kaasbjerg wrote:
> Anders Logg wrote:
> > On Mon, Mar 31, 2008 at 02:26:45PM +0200, Kristen Kaasbjerg wrote:
> >   
> >> Hi,
> >>
> >> I would like to plot a function that is the difference between a 
> >> DiscreteFunction and a UserFunction. Can this be done in any smart ways ?
> >>
> >> The only way I can think of is to create a new user defined function 
> >> that contains the two Functions above, which does the subtraction in the 
> >> eval function, and then save this function to vtk format.
> >> This, however, will call the eval method of the DiscreteFunction which 
> >> includes cell searching etc. Just sounds a bit cumbersome to me when the 
> >> mesh contains say 500.000 elements.
> >>
> >> Kristen
> >>     
> >
> > I would recommend to project the difference to an appropriate finite
> > element space and then plot the projection.
> >
> >   
> Ok, are there any examples around that illustrate how to do this ?
> 
> Kristen

v = TestFunction(...)
u = TrialFunction(...)
f = Function(...)
g = Function(...)

a = v*u*dx
L = v*(f - g)*dx

-- 
Anders


Follow ups

References