I decided to use DoFTool::map_dofs_to_support_points(), so my code above 
will be like this:

DoFTools::map_dofs_to_support_points(MappingQ1<dim>, dof_handler,
                          std::vector<Point<dim>> all_nodes);
std::vector<double> principle_stress;
principle_stress.resize(dof_handler.n_dofs()); //suppose dofs = no_of_nodes 
here.
for (unsigned int i = 0; i != dof_handler.n_dofs(); ++i)
{
   Point<dim> p = all_nodes[i];
   Quadrature<dim> quad(p);
   FEValues<dim> fe_values (fe, quad, |update_gradient);

   ... ... //compute stress with fe_values.shape_grad(i, q)
   principle_stress[i] = ... ...
}

//output stress results
DataOut<dim> data_out;
data_out.attach_dof_handler(dof_handler);
data_out.add_data_vector(principle_stress,"principle stress")

But here I'm not sure whether the ordering of points in the vector 
"all_nodes" getting from using DoFTool::map_dofs_to_support_points() is the 
same with dof_indices of the dof_handler. If so, there is no problem with 
the above code. While if not so, the ordering of nodal stress solution 
would also be different from dof_handler, as a result, some stress is 
attached to wrong dofs by DataOut.

So which case is correct, could anyone give some explanations? 

Great thanks!

Best,
David.

On Sunday, May 22, 2016 at 7:43:38 PM UTC+8, David wrote:
>
> Hi, Daniel:
>
> Thank you for your help. But this seems not to be convenient. I am 
> thinking to run my code like the following (psuedocode)
>
> for (i=0; i != number_of_nodes; ++i){
>    Point<dim> pi = get_point_from_global_index(i);
>    Quadrature quad(pi);
>    FEValues<dim> fe_values (fe, quad, |update_gradients);
>    
>    ... ...//do some computations with fe_values.shape_grad(i, q)
> }
>
> In this way, I can easily run over all the triangulation nodes without 
> worrying about worrying about recomputation at some nodes if I instead run 
> over each cell.
> But the difficullty here that I can't find a function which can do the 
> same job as "get_point_from_global_index(i)", namely give me the point with 
> global node index i of the triangulation.
>
> Is there any function in dealii with this functionality? 
>
> Great thanks!
>
> Best, 
> David
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to