Subject: [FEniCS-dev] derived quantities and post processing

From: Gideon Simpson <[email-masked]>
Date: Wed, 19 Dec 2007 17:53:15 -0500

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);

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?

---

From: [email-masked] (Ridgway Scott)
Date: Wed, 19 Dec 2007 18:34:33 -0600 (CST)

>2. I want to compute the avg, min, max of the l2 error

Do you mean: the average, min and max of the *error*? The mean
is an integral, but I am not sure how to find the min and max
of a function as a form.

			Ridg Scott

---

From: Anders Logg <[email-masked]>
Date: Thu, 20 Dec 2007 09:49:48 +0100

> 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

> 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