Hello Mr.Bangerth. Thank you very much for your input and your help. I did 
implement the same loop actually in my code but i am getting a segmentation 
fault but i guess this is a minor issue that i cannot find. Maybe because 
it is my first code in c++ and using deal ii.

My debugger seems to not work properly. Maybe you can find the issue if i 
post some of the code:
This is my PointHistory class with old_stress included:

*  template <int dim,typename NumberType>*
*  class PointHistory*
*  {*
*  public:*
*    PointHistory()*
*    : old_stress(SymmetricTensor<2, dim,NumberType>())*
*    {}*

*    virtual ~PointHistory()*
*    {}*

*    // The first function is used to create a material object and to*
*    // initialize all tensors correctly: The second one updates the stored*
*    // values and stresses based on the current deformation measure*
*    // $\textrm{Grad}\mathbf{u}_{\textrm{n}}$.*
*    void setup_lqp (const Parameters::AllParameters &parameters)*
*    {*
*      material =*
*        
std::make_shared<Material_Compressible_Neo_Hook_One_Field_Pert<dim,NumberType>>(*
*          parameters.mu, parameters.nu);*
*      update_values(Tensor<2, dim,NumberType>());*
*    }*

*    void update_values(const Tensor<2, dim,NumberType> &Grad_u_n)*
*    {*
*      const Tensor<2, dim> F = 
Physics::Elasticity::Kinematics::F(Grad_u_n);*
*      const NumberType               det_F = determinant(F);*
*      const SymmetricTensor<2,dim,NumberType> C = 
Physics::Elasticity::Kinematics::C(F);*
*      old_stress = material->get_s_piola(det_F,C);*
*    }*

*    NumberType get_det_F() const*
*    {*
*      return material->get_det_F();*
*    }*

*    const SymmetricTensor<2, dim,NumberType> get_C() const*
*    {*
*      return material->get_C;*
*    }    *

*    // We offer an interface to retrieve certain data.*
*    // This is the strain energy:*
*/*     NumberType*
*    get_Psi(const NumberType                        &det_F,*
*            const SymmetricTensor<2,dim,NumberType> &b_bar) const*
*    {*
*      return material->get_Psi(det_F,b_bar);*
*    } */*

*    // Here are the kinetic variables. These are used in the material and*
*    // global tangent matrix and residual assembly operations:*
*    // First is the Kirchhoff stress:*
*    SymmetricTensor<2,dim,NumberType>*
*    get_s_piola(const NumberType                        &det_F,*
*            const SymmetricTensor<2,dim,NumberType> &C) const*
*    {*
*      return material->get_s_piola(det_F,C);*
*    }*

*    // And the tangent:*
*    SymmetricTensor<4,dim,NumberType>*
*    get_Jc(const Tensor<2, dim, NumberType> &F,*
*           const SymmetricTensor<2,dim,NumberType> &S,*
*           const Tensor<2, dim, NumberType> &F_inv,*
*           const NumberType &det_F,*
*           const SymmetricTensor<2,dim,NumberType> &C) const*
*    {*
*      return material->get_Jc(F,S,F_inv,det_F,C);*
*    }*

*    SymmetricTensor<2,dim,NumberType> old_stress;*

*    // In terms of member functions, this class stores for the quadrature*
*    // point it represents a copy of a material type in case different*
*    // materials are used in different regions of the domain, as well as 
the*
*    // inverse of the deformation gradient...*
*  private:*
*    std::shared_ptr< 
Material_Compressible_Neo_Hook_One_Field_Pert<dim,NumberType> > material;*
*  };*

I update my old_stress by using the update_values void like in step 44. 
And here is my output_results void:

*  template <int dim,typename NumberType>*
*  void Solid<dim,NumberType>::output_results() const*
*  {*
*    DataOut<dim> data_out;*
*    std::vector<DataComponentInterpretation::DataComponentInterpretation>*
*    data_component_interpretation(dim,*
*                                  
DataComponentInterpretation::component_is_part_of_vector);*

*    std::vector<std::string> solution_name(dim, "displacement");*
*    data_out.attach_dof_handler(dof_handler_ref);*
*    data_out.add_data_vector(solution_n,*
*                             solution_name,*
*                             DataOut<dim>::type_dof_data,*
*                             data_component_interpretation);*
*    Postprocessor<dim> postprocessor;*
*    data_out.add_data_vector(solution_n, postprocessor);*
*    Vector<double> norm_of_stress(triangulation.n_active_cells());*
*        for (auto &cell : triangulation.active_cell_iterators()){*
*          if (cell->is_locally_owned())*
*          {*
*            SymmetricTensor<2, dim> accumulated_stress;*
*            printf("\n cell owned\n");*
*            for (unsigned int q = 0; q < qf_cell.size(); ++q){*
*              std::cout<<q<<" ";*
*                  accumulated_stress +=*
*                    reinterpret_cast<PointHistory<dim,NumberType> 
*>(cell->user_pointer())[q].old_stress;*
*            }*
*          }*
*      } *

*    Vector<double> soln(solution_n.size());*
*    for (unsigned int i = 0; i < soln.size(); ++i)*
*      soln(i) = solution_n(i);*
*    MappingQEulerian<dim> q_mapping(degree, dof_handler_ref, soln);*
*    data_out.build_patches(q_mapping, degree);*

*    std::ostringstream filename;*
*    filename << "solution-" << time.get_timestep() << ".vtk";*

*    std::ofstream output(filename.str().c_str());*
*    data_out.write_vtk(output);*
*  }*

*}*


Wolfgang Bangerth schrieb am Freitag, 20. Mai 2022 um 02:02:33 UTC+2:

> On 5/19/22 00:47, BBah wrote:
> > 
> > i am just trying to put out the norm of the stresses like in step 18. Is 
> there 
> > a way to save my stress tensor for each cell and put it out ? In step 18 
> there 
> > is a loop through each cell and the locally owned are used to put out 
> the 
> > stresses. Is there a way to do the same with the workstream object ? 
> Been 
> > searching for a while for a solution but could not find one. Putting out 
> the 
> > strains is easy since the gradient of the displacements are saved but 
> how to 
> > do the same with the stresses ?
>
> BBah: What have you tried already? When you loop over all cells with 
> WorkStream, the WorkStream::run() function calls your 'worker' function 
> for 
> every cell. This is the place where you would create output.
>
> Alternatively, if all you want is to generate some output, just do it with 
> the 
> same loop as done in step-18. WorkStream is meant for cases where 
> something is 
> expensive and you want to do it in parallel, but outputting a couple of 
> numbers for each cell is not expensive.
>
> Best
> WB
>
> -- 
> ------------------------------------------------------------------------
> Wolfgang Bangerth email: bang...@colostate.edu
> www: http://www.math.colostate.edu/~bangerth/
>
>

-- 
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 dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/3e4f667a-4778-4f71-8e4a-65db64bac15dn%40googlegroups.com.

Reply via email to