On Wed, 9 Aug 2017, Renato Poli wrote:

I have a GUI interface to the elements on the mesh.
I want to plot the solutions into each degree of freedom (a color
scale or so).
Is there an example that shows the best way to extract the solution
from the EquationSystem

This is sort of an underspecified question: the best way to extract
the solution from a System is "system.solution", but presumably that's
not exactly what you're asking.  By "extract" do you mean read each
single (local or ghosted) coefficient from that vector?
NumericVector::operator().  Serialize it onto one processor?  Create a
new NumericVector with ParallelType SERIAL and use operator=.
Serialize it into a std::vector?  NumericVector::localize().

and the global dof id of each vertex of each element?

A single vertex may have any number of DoF ids.

Imagine you're solving weakly coupled 2D phase decomposition with
fluid flow.  Your first system is Navier-Stokes with Q1Q0 elements
(stabilized, since those don't satisfy inf-sup because I chose an
awful mixed element for didactic reasons), so to it you first
add first-order Lagrange velocity variables u and v and then add
zeroth-order monomial pressure variable p.  The second system is
Cahn-Hilliard with a Bogner-Fox-Schmidt (HERMITE in libMesh)
concentration variable c.

Then, assuming you have a Node reference n for your vertex:

n.dof_number(/*sys=*/ 0, /*var=*/ 0, /*component=*/ 0)
will return the vertex value DoF index for u (which you can use as an
index to system1.solution if that DoF coefficient is owned by your
current processor)

n.dof_number(/*sys=*/ 0, /*var=*/ 1, /*component=*/ 0)
will return the vertex value DoF index for v

NOTHING will return the vertex value DoF index for p, because p is
discontinous and isn't uniquely defined at a vertex; if you want p
values then you need an Elem reference.

n.dof_number(/*sys=*/ 1, /*var=*/ 0, /*component=*/ 0)
will return the vertex value DoF index for c, but...

n.dof_number(/*sys=*/ 1, /*var=*/ 0, /*component=*/ 1)
will return the vertex x derivative DoF index for c, component=2 will
return the vertex y derivative, and component=3 will return the xy
mixed derivative.

Higher order C0-continuous elements aren't as weird as the
discontinuous or C1 elements, and have exactly one DoF at each vertex,
but they can also have DoFs (multiple DoFs, for p>2) on non-vertex
nodes and/or on elements too.  If you want an accurate plot for higher
order variables then you have to worry about those as well.

Hope that helps,

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Libmesh-users mailing list

Reply via email to