Hi everyone

I'm trying to compute and output nodal stress and strain. Although there 
are already some helpful discussions, for example this 
<https://groups.google.com/forum/#!searchin/dealii/project$20stress$20and$20strain|sort:relevance/dealii/lvwwrT6zOFQ/C4r3JVAQAQAJ>
 
and this 
<https://groups.google.com/forum/#!searchin/dealii/output|sort:relevance/dealii/uME5kwaJIEU/s5EN7hutAAAJ>,
 
none of them addresses my problem.

I computed the stress and strain on the quadrature points in each cell and 
used FETools::compute_projection_from_quadrature_points_matrix 
<http://www.dealii.org/8.5.0/doxygen/deal.II/namespaceFETools.html#ab1a0545c897ee022029f8c5f2c252735>
 to 
extrapolate them to the vertices as in Step-18. Eventually I end up with a 
vector<vector<Vector<double>>> stressGlobal, whose size is 
dim*dim*outputHandler.n_dofs(). Note that the outputHandler is different 
from the dof handler I used to solve the linear elastic problem because its 
number of dofs equals the number of vertices in the triangulation, rather 
than dim times that.

I know that I must output the global_stress component by component as 
scalars. The problem is, given the DataOut object that is attached to the 
original DoFHandler, how do I write a specific component of stressGlobal to 
it?  Here is what I tried:

>
>   std::string fileName = "solution-";
>   fileName += ('0' + cycle);
>   fileName += ".vtu";
>   std::ofstream out(fileName.c_str());
>   DataOut<dim> data;
>   data.attach_dof_handler(this->dofHandler);
>   std::vector<std::string> solutionNames;
>   switch (dim)
>   {
>   case 2:
>     solutionNames.push_back ("x_displacement");
>     solutionNames.push_back ("y_displacement");
>     break;
>   case 3:
>     solutionNames.push_back ("x_displacement");
>     solutionNames.push_back ("y_displacement");
>     solutionNames.push_back ("z_displacement");
>     break;
>   default:
>     Assert(false, ExcNotImplemented());
>   }
>   data.add_data_vector(this->solution, solutionNames);
>   
>   data.clear_data_vectors();
>   data.attach_dof_handler(outputHandler);
>   data.add_data_vector(stressGlobal[0][0], "Sxx");
>   data.add_data_vector(stressGlobal[1][1], "Syy");
>   data.add_data_vector(stressGlobal[0][1], "Sxy");
>   data.build_patches();
>   data.write_vtu(out);


clear_data_vectors would erase the displacement data, which is wrong. But 
if I do not reattach the DataOut to the outputHandler, I would get an 
error: the size of the vector stressGlobal does not equal n_dofs of the 
original DoFHandler. There must be a easy fix to this, any suggestions?

In addition, I used a DofHandler<dim> outputHandler to extrapolate stress. 
If I want to output the strain as well, do I have to create another 
DofHandler ? (Because each DofHandler has only one dof on every node.)

I hope I made my point clear. Thank you in advance!

Jie


 

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