← Back to team overview

dolfin team mailing list archive

Re: Simple post-processing

 

Bartosz Sawicki wrote:
Hi there,

I'm just starting to learn Dolfin/FFC... projects. I'm impressed by
capacities it has, design and code quality. Thank you for such excellent
work.

Thanks!

At this moment I have one question, which probably shouldn't be sent
into dolfin-dev, but there are no other list (for users):

It is perfectly fine to send it here. (If the traffic should increase much, we could add a list dolfin-users.)

Is it possible to make simple post-processing using build-in features of
Dolfin?

Yes.

For example, I think about grad/rot/div operators. In the simpliest case
/demo/pde/poisson, discrete function u is computed. Having u, I would
like to compute also e=-grad(u). Of course, I can write own code
iterating over cells and calculate gradient, but it won't be very
elegant solution.
How would you solve such problem?

Define a form that projects whatever quantity you need to a suitable space. Say you want to compute the gradient of a piecewise linear function:

P1 = FiniteElement("Lagrange", ..., 1)
P0 = VectorElement("Lagrange", ..., 0)

v = TestFunction(P0)
w = TrialFunction(P0)
u = Function(P1)

a = dot(v, w)*dx
L = dot(v, grad(u))*dx

Then solve the system and w will be the L2-projection of the gradient of u (which will be exactly equal to the gradient of u since the gradient is in P0).

You might want to project to P1 if you want to plot the gradient since most postprocessing tools can only handle P1.

Note that you can also define functionals like the integral of u along the boundary, the average etc. (Use M instead of a, L in FFC.)

/Anders


Regards,

Bartosz Sawicki
Warsaw University of Technology


_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev


Follow ups

References