PolyFEM
Loading...
Searching...
No Matches
SpatialIntegralForms.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "AdjointForm.hpp"
4
5namespace polyfem::solver
6{
8 {
9 public:
10 SpatialIntegralForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : StaticForm(variable_to_simulations), state_(state)
11 {
12 }
13
14 std::string name() const override { return "spatial_integral"; }
15
16 const State &get_state() { return state_; }
17
19
20 Eigen::VectorXd compute_adjoint_rhs_step(const int time_step, const Eigen::VectorXd &x, const State &state) const override;
21 double value_unweighted_step(const int time_step, const Eigen::VectorXd &x) const override;
22 void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
23
24 protected:
26
27 const State &state_;
29 std::set<int> ids_;
30 };
31
33 {
34 public:
35 ElasticEnergyForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
36 {
38
39 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
40 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
41 }
42
43 std::string name() const override { return "elastic_energy"; }
44
45 void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
46
47 protected:
49 };
50
52 {
53 public:
54 StressNormForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
55 {
57
58 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
59 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
60
61 if (args["power"] > 0)
62 in_power_ = args["power"];
63 }
64
65 std::string name() const override { return "stress_norm"; }
66
67 void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
68
69 protected:
71
72 private:
73 int in_power_ = 2;
74 };
75
77 {
78 public:
79 ComplianceForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
80 {
82
83 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
84 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
85 }
86
87 std::string name() const override { return "compliance"; }
88
89 void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
90
91 protected:
93 };
94
96 {
97 public:
98 PositionForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
99 {
101
102 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
103 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
104
105 set_dim(args["dim"]);
106 }
107
108 void set_dim(const int dim) { dim_ = dim; }
109
110 protected:
112
113 private:
114 int dim_ = 0;
115 };
116
118 {
119 public:
120 AccelerationForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
121 {
123
124 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
125 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
126
127 set_dim(args["dim"].get<int>());
128 }
129
130 void set_dim(const int dim) { dim_ = dim; }
131
132 protected:
134
135 private:
136 int dim_ = 0;
137 };
138
140 {
141 public:
142 KineticForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
143 {
145
146 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
147 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
148 }
149
150 protected:
152 };
153
155 {
156 public:
157 StressForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
158 {
160
161 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
162 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
163
164 dimensions_ = args["dimensions"].get<std::vector<int>>();
165 }
166
167 std::string name() const override { return "stress"; }
168
169 void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
170
171 protected:
173
174 std::vector<int> dimensions_;
175 };
176
178 {
179 public:
180 VolumeForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
181 {
183
184 auto tmp_ids = args["volume_selection"].get<std::vector<int>>();
185 ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
186 }
187
188 protected:
190 };
191} // namespace polyfem::solver
int x
main class that contains the polyfem solver and all its state
Definition State.hpp:79
AccelerationForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
IntegrableFunctional get_integral_functional() const override
IntegrableFunctional get_integral_functional() const override
ComplianceForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
std::string name() const override
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
IntegrableFunctional get_integral_functional() const override
ElasticEnergyForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
KineticForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
IntegrableFunctional get_integral_functional() const override
PositionForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
IntegrableFunctional get_integral_functional() const override
void set_integral_type(const SpatialIntegralType type)
Eigen::VectorXd compute_adjoint_rhs_step(const int time_step, const Eigen::VectorXd &x, const State &state) const override
double value_unweighted_step(const int time_step, const Eigen::VectorXd &x) const override
virtual IntegrableFunctional get_integral_functional() const =0
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
SpatialIntegralForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
IntegrableFunctional get_integral_functional() const override
std::string name() const override
StressForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
StressNormForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
std::string name() const override
IntegrableFunctional get_integral_functional() const override
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
A collection of VariableToSimulation.
IntegrableFunctional get_integral_functional() const override
VolumeForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args)
nlohmann::json json
Definition Common.hpp:9