← Back to team overview

fenics team mailing list archive

Re: derived quantities and post processing

 

On Wed, Dec 19, 2007 at 05:53:15PM -0500, Gideon Simpson wrote:
> suppose I solve a PDE using dolfin and have my solution in
> 
> Function u;
> 
> Now suppose i want to do two things:
> 
> 1. I want to compute and plot the pointwise error in the l2 norm:  so  
> if I have a function u_exact, i want to compute
> 
> Function err = fabs(u-u_exact);

Arithmetic on Functions is only supported at the compiler stage (when
specifying forms). So to plot e = u - u_h, you need to do one of
two things:

1. Save u and u_h to file and then use some postprocessing program
like Paraview to plot the difference.

2. Define a form for projecting e onto some space and then plot the
projection

 a = v*e*dx
 L = v*(u - u_h)*dx

> 2. I want to compute the avg, min, max of the l2 error:  I gather I  
> can do this using a Form with a functional, but is that the only way?

L2 and other norms are simple, just define

 e = u - u_h
 M = e*e*dx

or

 M = e*e*dx + dot(grad(e), grad(e))*dx

etc.

Just as Ridg, I don't know how to do min, max as functionals. I guess
you just need to evaluate the error at enough points and take the max
and min.

What you could do would be to compute the linear form

 L = 1/w*e*v*dx

where v is a piecewise constant test function and w is a piecewise
constant Function that is equal to the cell volume on each element.
Then assemble L into a vector b and take the maximum of b, which would
give you the maximum of the average error on all elements. There might
be cancellation effects so you could also test against higher order
discontinuous basis functions.

-- 
Anders


References