26 std::string
name()
const override {
return "AMIPS"; }
27 std::map<std::string, ParamFunc>
parameters()
const override;
40 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3>
AutoDiffGradMat;
42 const double power = 2. /
size();
48 standard = get_standard<2, T>(
size(), rest_pose);
50 standard = get_standard<3, T>(
size(), rest_pose);
53 def_grad = def_grad * standard;
58 return T(std::nan(
""));
61 const T powJ = pow(det, power);
62 const double weight =
weight_(p, t, el_id);
63 const T base_energy = (def_grad.transpose() * def_grad).trace() / powJ;
64 const double normalization =
normalized_(p, t, el_id) != 0 ?
size() : 1;
65 return T(weight) * pow(base_energy / T(normalization),
power_(p, t, el_id));
75 template <
int dimt,
class T>
78 Eigen::Matrix<double, dimt, dimt> standard(dim, dim);
81 standard.setIdentity();
87 0.5, std::sqrt(3) / 2;
90 0.5, std::sqrt(3) / 2., 0,
91 0.5, 0.5 / std::sqrt(3), std::sqrt(2. / 3.);
92 standard = standard.inverse().transpose().eval();
95 Eigen::Matrix<T, dimt, dimt> res(dim, dim);
96 for (
int i = 0; i < dim; ++i)
98 for (
int j = 0; j < dim; ++j)
100 res(i, j) = T(standard(i, j));
108 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3>
gradient(
112 const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> &
F)
const override;
114 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 9, 9>
hessian(
118 const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> &
F)
const override;
static Eigen::Matrix< T, dimt, dimt > get_standard(const int dim, const bool use_rest_pose)
std::string name() const override
void add_multimaterial(const int index, const json ¶ms, const Units &units, const io::ResourceIO &resources) override
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > gradient(const RowVectorNd &p, const double t, const int el_id, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > &F) const override
GenericMatParam normalized_
GenericMatParam use_rest_pose_
bool allow_inversion() const override
bool use_rest_pose(const RowVectorNd &p, const double t, const int el_id) const
bool real_def_grad(const RowVectorNd &p, const double t, const int el_id) const override
T elastic_energy(const RowVectorNd &p, const double t, const int el_id, DefGradMatrix< T > &def_grad) const
std::map< std::string, ParamFunc > parameters() const override
Read-only interface to a hierarchical collection of simulation resources.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > DefGradMatrix
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > AutoDiffGradMat
T determinant(const Eigen::Matrix< T, rows, cols, option, maxRow, maxCol > &mat)
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd