2#include "OgdenElasticity.hpp"
4#include <polyfem/autogen/auto_eigs.hpp>
6namespace polyfem::assembler
9 T UnconstrainedOgdenElasticity::elastic_energy(
13 const DefGradMatrix<T> &def_grad) const
15 Eigen::Matrix<T, Eigen::Dynamic, 1, 0, 3, 1> eigs;
19 // No need to symmetrize F to compute eigen values analytically
20 autogen::eigs_2d<T>(def_grad, eigs);
25 // Symmetrize F to compute eigen values analytically
26 autogen::eigs_3d<T>(def_grad.transpose() * def_grad, eigs);
27 eigs = sqrt(eigs.array());
30 const T J = utils::determinant(def_grad);
31 const T Jdenom = pow(J, -1. / size());
33 for (long i = 0; i < eigs.size(); ++i)
34 eigs(i) = eigs(i) * Jdenom;
37 for (long N = 0; N < alphas_.size(); ++N)
39 auto tmp = T(-size());
40 const double alpha = alphas_[N](p, t, el_id);
41 const double mu = mus_[N](p, t, el_id);
43 for (long i = 0; i < eigs.size(); ++i)
44 tmp += pow(eigs(i), alpha);
46 val += 2 * mu / (alpha * alpha) * tmp;
49 for (long N = 0; N < Ds_.size(); ++N)
51 const double D = Ds_[N](p, t, el_id);
53 val += 1. / D * pow(J - T(1), 2 * (N + 1));
60 T IncompressibleOgdenElasticity::elastic_energy(
64 const DefGradMatrix<T> &def_grad) const
66 Eigen::Matrix<T, Eigen::Dynamic, 1, 0, 3, 1> eigs;
68 const T J = polyfem::utils::determinant(def_grad);
69 const T log_J = log(J);
71 const auto F_tilde = def_grad / pow(J, 1.0 / size());
72 const auto C_tilde = F_tilde * F_tilde.transpose();
75 autogen::eigs_2d<T>(C_tilde, eigs);
77 autogen::eigs_3d<T>(C_tilde, eigs);
80 eigs = sqrt(eigs.array());
83 for (long i = 0; i < num_terms(); ++i)
85 const double c = coefficients_[i](p, t, el_id);
86 const double m = expoenents_[i](p, t, el_id);
88 auto tmp = T(-size());
89 for (long j = 0; j < eigs.size(); ++j)
90 tmp += pow(eigs(j), m);
92 val += c / (m * m) * tmp;
94 val += 0.5 * bulk_modulus_(p, t, el_id) * log_J * log_J;
98} // namespace polyfem::assembler