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() && arg.size() > 0 && arg[0].is_array());
34
35 for (size_t i = 0; i < arg.size(); ++i)
36 {
37 for (size_t j = 0; j < arg[i].size(); ++j)
38 {
39 value[i * 3 + j].init(arg[i][j]);
40 value[i * 3 + j].set_unit_type("");
41 }
42 }
43 }
44 }
45
46 Eigen::MatrixXd eval(const double t) const
47 {
48 Eigen::MatrixXd strain(_dim, _dim);
49 for (int i = 0; i < _dim; i++)
50 for (int j = 0; j < _dim; j++)
51 strain(i, j) = eval(i, j, t);
52
53 return strain;
54 }
55
56 double eval(const int i, const int j, const double t) const
57 {
58 return value[i * 3 + j](0,0,0,t);
59 }
60 };
61 }
62}
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