On Mon, 5 Jun 2006, David Knezevic wrote:
> In an application I am iterating over the nodes of a mesh and I want
> to find the value of the solution at each node (I am using Lagrange
> I would like to use the node id number to index directly into the
> global solution vector, but the difficulty is that I have 3 variables
> in this system. Is there a simple way to do this?
Not only is it not simple, for many common combinations of geometric
and finite element it's not possible, even with Lagrange elements.
Take a mixed biquadratic pressure / bilinear velocity element, for
example - how do you get the pressure DoF index at the midedge nodes?
You can't, because pressure DoFs are only on vertex nodes.
If you're certain that the node you're looking at has the degree of
freedom you're looking for, then it's possible to extract the global
degree of freedom number directly from the node - I've had to put some
such ugly hacks in system_projection.C, I think.
But the best solution is usually to first iterate over elements, then
iterate over the local nodes on each element. Presumably you're
putting the results of your per-node calculations into some vector
which you can also use to avoid working on the same node twice. Once
you've got an element associated with each node you're working on, you
can then use dof_indices() and FEInterface::shape() to build variable
values that will be correct regardless of finite element and geometric