PolyFEM
Loading...
Searching...
No Matches
OgdenElasticity.cpp
Go to the documentation of this file.
1#include "OgdenElasticity.hpp"
2
4
5namespace polyfem::assembler
6{
8 : alphas_("alphas"), mus_("mus"), Ds_("Ds")
9 {
10 }
11
12 void UnconstrainedOgdenElasticity::add_multimaterial(const int index, const json &params, const Units &units)
13 {
14 // TODO check me
15 alphas_.add_multimaterial(index, params, "");
16 mus_.add_multimaterial(index, params, units.stress());
17 Ds_.add_multimaterial(index, params, units.stress());
18 assert(alphas_.size() == mus_.size());
19 assert(alphas_.size() == Ds_.size());
20 }
21
22 std::map<std::string, Assembler::ParamFunc> UnconstrainedOgdenElasticity::parameters() const
23 {
24 std::map<std::string, ParamFunc> res;
25 const auto &alphas = this->alphas();
26 const auto &mus = this->mus();
27 const auto &Ds = this->Ds();
28
29 for (int i = 0; i < alphas.size(); ++i)
30 res[fmt::format("alpha_{}", i)] = [&alphas, i](const RowVectorNd &, const RowVectorNd &p, double t, int e) {
31 return alphas[i](p, t, e);
32 };
33
34 for (int i = 0; i < mus.size(); ++i)
35 res[fmt::format("mu_{}", i)] = [&mus, i](const RowVectorNd &, const RowVectorNd &p, double t, int e) {
36 return mus[i](p, t, e);
37 };
38
39 for (int i = 0; i < Ds.size(); ++i)
40 res[fmt::format("D_{}", i)] = [&Ds, i](const RowVectorNd &, const RowVectorNd &p, double t, int e) {
41 return Ds[i](p, t, e);
42 };
43 return res;
44 }
45
46 // =========================================================================
47
49 : coefficients_("c"), expoenents_("m"), bulk_modulus_("k")
50 {
51 }
52
53 void IncompressibleOgdenElasticity::add_multimaterial(const int index, const json &params, const Units &units)
54 {
55 coefficients_.add_multimaterial(index, params, units.stress());
56 expoenents_.add_multimaterial(index, params, "");
57 bulk_modulus_.add_multimaterial(index, params, units.stress());
58 assert(coefficients_.size() == expoenents_.size());
59 }
60
61 std::map<std::string, Assembler::ParamFunc> IncompressibleOgdenElasticity::parameters() const
62 {
63 std::map<std::string, ParamFunc> res;
64
65 const auto &coefficients = this->coefficients();
66 const auto &expoenents = this->expoenents();
67 const auto &k = this->bulk_modulus();
68
69 for (int i = 0; i < coefficients.size(); ++i)
70 res[fmt::format("c_{}", i)] = [&coefficients, i](const RowVectorNd &, const RowVectorNd &p, double t, int e) {
71 return coefficients[i](p, t, e);
72 };
73
74 for (int i = 0; i < expoenents.size(); ++i)
75 res[fmt::format("m_{}", i)] = [&expoenents, i](const RowVectorNd &, const RowVectorNd &p, double t, int e) {
76 return expoenents[i](p, t, e);
77 };
78
79 res["k"] = [&k](const RowVectorNd &, const RowVectorNd &p, double t, int e) {
80 return k(p, t, e);
81 };
82
83 return res;
84 }
85} // namespace polyfem::assembler
std::string stress() const
Definition Units.hpp:25
void add_multimaterial(const int index, const json &params, const std::string &unit_type)
Definition MatParams.cpp:28
void add_multimaterial(const int index, const json &params, const std::string &unit_type)
Definition MatParams.cpp:65
void add_multimaterial(const int index, const json &params, const Units &units) override
const GenericMatParam & bulk_modulus() const
Bulk modulus.
std::map< std::string, ParamFunc > parameters() const override
const GenericMatParams & coefficients() const
Coefficient of nth term, where n can range from 1 to 6.
const GenericMatParams & expoenents() const
Exponent of nth term, where n can range from 1 to 6.
std::map< std::string, ParamFunc > parameters() const override
void add_multimaterial(const int index, const json &params, const Units &units) override
Used for test only.
nlohmann::json json
Definition Common.hpp:9
Eigen::Matrix< double, 1, Eigen::Dynamic, Eigen::RowMajor, 1, 3 > RowVectorNd
Definition Types.hpp:13