Skip to content

Commit 06c01f8

Browse files
committed
simplified ref stiffness computation
1 parent ad52d8a commit 06c01f8

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

include/material_models/J2Plasticity.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ class J2Plasticity : public MechModel {
2222
}
2323
n_mat = bulk_modulus.size();
2424

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

3632
// Allocate the member matrices/vectors for performance optimization
3733
sqrt_two_over_three = sqrt(2.0 / 3.0);

include/material_models/PseudoPlastic.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@ class PseudoPlastic : public MechModel {
3232
}
3333
n_mat = bulk_modulus.size();
3434

35-
Matrix<double, 6, 6> Pvol = Matrix<double, 6, 6>::Zero();
36-
Pvol.topLeftCorner(3, 3).setConstant(1.0 / 3.0); // volumetric projector
37-
const Matrix<double, 6, 6> I6 = Matrix<double, 6, 6>::Identity();
38-
const Matrix<double, 6, 6> Pdev = I6 - Pvol; // deviatoric projector
39-
40-
Matrix<double, 6, 6> Ce_sum = Matrix<double, 6, 6>::Zero();
41-
for (size_t i = 0; i < n_mat; ++i) {
42-
Ce_sum += 3.0 * bulk_modulus[i] * Pvol + 2.0 * shear_modulus[i] * Pdev;
43-
}
44-
kapparef_mat = Ce_sum / static_cast<double>(n_mat);
35+
const double Kbar = std::accumulate(bulk_modulus.begin(), bulk_modulus.end(), 0.0) / static_cast<double>(n_mat);
36+
const double Gbar = std::accumulate(shear_modulus.begin(), shear_modulus.end(), 0.0) / static_cast<double>(n_mat);
37+
const double lambdabar = Kbar - 2.0 * Gbar / 3.0;
38+
kapparef_mat.setZero();
39+
kapparef_mat.topLeftCorner(3, 3).setConstant(lambdabar);
40+
kapparef_mat.diagonal().array() += 2.0 * Gbar;
4541
}
4642

4743
void initializeInternalVariables(ptrdiff_t num_elements, int num_gauss_points) override

0 commit comments

Comments
 (0)