PolyFEM
Loading...
Searching...
No Matches
MacroStrain.hpp
Go to the documentation of this file.
1#pragma once
2
6
7namespace polyfem
8{
9 namespace assembler
10 {
12 {
13 bool _is_active = false;
14 int _dim;
15 Eigen::VectorXi fixed_entry;
16 std::array<utils::ExpressionValue, 9> value;
17
18 public:
19 MacroStrainValue() = default;
20
21 bool is_active() const { return _is_active; }
22 int dim() const { return _dim; }
23 const Eigen::VectorXi &get_fixed_entry() const { return fixed_entry; }
24
25 void init(const int dim, const json &param)
26 {
27 _is_active = true;
28 _dim = dim;
29 fixed_entry = param["fixed_macro_strain"];
30 if (utils::is_param_valid(param, "linear_displacement_offset"))
31 {
32 json arg = param["linear_displacement_offset"];
33 assert(arg.is_array());
34#ifndef NDEBUG
35 for (const auto &a : arg)
36 assert(a.is_array());
37#endif
38 for (size_t i = 0; i < arg.size(); ++i)
39 {
40 for (size_t j = 0; j < arg[i].size(); ++j)
41 {
42 value[i * 3 + j].init(arg[i][j]);
43 value[i * 3 + j].set_unit_type("");
44 }
45 }
46 }
47 }
48
49 Eigen::MatrixXd eval(const double t) const
50 {
51 Eigen::MatrixXd strain(_dim, _dim);
52 for (int i = 0; i < _dim; i++)
53 for (int j = 0; j < _dim; j++)
54 strain(i, j) = eval(i, j, t);
55
56 return strain;
57 }
58
59 double eval(const int i, const int j, const double t) const
60 {
61 return value[i * 3 + j](0, 0, 0, t);
62 }
63 };
64 } // namespace assembler
65} // namespace polyfem
std::array< utils::ExpressionValue, 9 > value
Eigen::MatrixXd eval(const double t) const
const Eigen::VectorXi & get_fixed_entry() const
void init(const int dim, const json &param)
double eval(const int i, const int j, const double t) const
bool is_param_valid(const json &params, const std::string &key)
Determine if a key exists and is non-null in a json object.
nlohmann::json json
Definition Common.hpp:9