@@ -22,16 +22,12 @@ class J2Plasticity : public MechModel {
22
22
}
23
23
n_mat = bulk_modulus.size ();
24
24
25
- Matrix<double , 6 , 6 > Pvol = Matrix<double , 6 , 6 >::Zero ();
26
- Pvol.topLeftCorner (3 , 3 ).setConstant (1.0 / 3.0 ); // volumetric projector
27
- const Matrix<double , 6 , 6 > I6 = Matrix<double , 6 , 6 >::Identity ();
28
- const Matrix<double , 6 , 6 > Pdev = I6 - Pvol; // deviatoric projector
29
-
30
- Matrix<double , 6 , 6 > Ce_sum = Matrix<double , 6 , 6 >::Zero ();
31
- for (size_t i = 0 ; i < n_mat; ++i) {
32
- Ce_sum += 3.0 * bulk_modulus[i] * Pvol + 2.0 * shear_modulus[i] * Pdev;
33
- }
34
- kapparef_mat = Ce_sum / static_cast <double >(n_mat);
25
+ const double Kbar = std::accumulate (bulk_modulus.begin (), bulk_modulus.end (), 0.0 ) / static_cast <double >(n_mat);
26
+ const double Gbar = std::accumulate (shear_modulus.begin (), shear_modulus.end (), 0.0 ) / static_cast <double >(n_mat);
27
+ const double lambdabar = Kbar - 2.0 * Gbar / 3.0 ;
28
+ kapparef_mat.setZero ();
29
+ kapparef_mat.topLeftCorner (3 , 3 ).setConstant (lambdabar);
30
+ kapparef_mat.diagonal ().array () += 2.0 * Gbar;
35
31
36
32
// Allocate the member matrices/vectors for performance optimization
37
33
sqrt_two_over_three = sqrt (2.0 / 3.0 );
0 commit comments