PolyFEM
Loading...
Searching...
No Matches
NeoHookeanElasticityAutodiff.hpp
Go to the documentation of this file.
1#pragma once
2
5
7namespace polyfem::assembler
8{
9 class NeoHookeanAutodiff : public GenericElastic<NeoHookeanAutodiff>
10 {
11 public:
12 std::string name() const override { return "NeoHookeanAutodiff"; }
13 // Used only for testing, no need to output
14 std::map<std::string, ParamFunc> parameters() const override { return std::map<std::string, ParamFunc>(); }
15
17
18 // sets material params
19 void add_multimaterial(const int index, const json &params, const Units &units) override;
20
21 template <typename T>
23 const RowVectorNd &p,
24 const double t,
25 const int el_id,
26 const DefGradMatrix<T> &def_grad) const
27 {
28 double lambda, mu;
29 params_.lambda_mu(p, p, t, el_id, lambda, mu);
30
31 const T log_det_j = log(polyfem::utils::determinant(def_grad));
32 const T val = mu / 2 * ((def_grad * def_grad.transpose()).trace() - size() - 2 * log_det_j) + lambda / 2 * log_det_j * log_det_j;
33
34 return val;
35 }
36
37 private:
39 };
40} // namespace polyfem::assembler
double val
Definition Assembler.cpp:86
void lambda_mu(double px, double py, double pz, double x, double y, double z, double t, int el_id, double &lambda, double &mu) const
void add_multimaterial(const int index, const json &params, const Units &units) override
std::map< std::string, ParamFunc > parameters() const override
T elastic_energy(const RowVectorNd &p, const double t, const int el_id, const DefGradMatrix< T > &def_grad) const
Used for test only.
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > DefGradMatrix
T determinant(const Eigen::Matrix< T, rows, cols, option, maxRow, maxCol > &mat)
nlohmann::json json
Definition Common.hpp:9
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13