Dear dealii group,

I have a question regarding the computational efficiency of two styles of
codes. For example, when computing the residual of momentum balance, one
can realize d_epsilon \cdot sigma (the dot production between the test
function of strain and stress) by

1.  compute multiplications one by one and sum them up
for (const unsigned int i : fe_values_u_p.dof_indices())
{
for (unsigned int m=0; m<dim; ++m)
{
for (unsigned int n=0; n<dim; ++n)
{
cell_rhs(i) +=
fe_values_u_p.shape_grad_component(i,q,index_u.first_vector_component+m)[n]
 * stress[m][n] * fe_values_u_p.JxW(q); //solid stress
}

}
      }
2.  extract the tensor and compute the dot product directly

const SymmetricTensor<2,dim> bfem_i =
ShapeTools::elastic_strain_shape(fe_values,i,q);
for (const unsigned int i : fe_values_u_p.dof_indices())
{
cell_rhs(i) = contract2(bfem_i, stress) * fe_values_u_p.JxW(q);
}

Do both perform the same? or I should prevent the loop style in dealii to
speed up the computation?

Best,
Chenyi

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CANmBX4QdwnBiJx8yA1XTo%3DOkSuoqa7JjO4Hsc7os%3D9s-wSw_iA%40mail.gmail.com.

Reply via email to