-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
linear_constitutive_model_data.cc
36 lines (30 loc) · 1.17 KB
/
linear_constitutive_model_data.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "drake/multibody/fem/linear_constitutive_model_data.h"
#include "drake/common/autodiff.h"
namespace drake {
namespace multibody {
namespace fem {
namespace internal {
template <typename T, int num_locations>
LinearConstitutiveModelData<T, num_locations>::LinearConstitutiveModelData() {
/* Initialize data members to be consistent with the deformation gradient
which is initialized to the identity matrix. This achieves the same result
as invoking `UpdateFromDeformationGradient()` but is slightly more
efficient.*/
strain_.fill(Matrix3<T>::Zero());
trace_strain_.fill(0.0);
}
template <typename T, int num_locations>
void LinearConstitutiveModelData<
T, num_locations>::UpdateFromDeformationGradient() {
const std::array<Matrix3<T>, num_locations>& F = this->deformation_gradient();
for (int i = 0; i < num_locations; ++i) {
strain_[i] = 0.5 * (F[i] + F[i].transpose()) - Matrix3<T>::Identity();
trace_strain_[i] = strain_[i].trace();
}
}
template class LinearConstitutiveModelData<double, 1>;
template class LinearConstitutiveModelData<AutoDiffXd, 1>;
} // namespace internal
} // namespace fem
} // namespace multibody
} // namespace drake