PolyFEM
Loading...
Searching...
No Matches
SurfaceTractionForms.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7namespace polyfem::solver
8{
9 // class TractionNormForm : public SpatialIntegralForm
10 // {
11 // public:
12 // TractionNormForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : SpatialIntegralForm(variable_to_simulations, state, args)
13 // {
14 // set_integral_type(SpatialIntegralType::Surface);
15
16 // auto tmp_ids = args["surface_selection"].get<std::vector<int>>();
17 // ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
18
19 // if (args["power"] > 0)
20 // in_power_ = args["power"];
21 // }
22
23 // protected:
24 // IntegrableFunctional get_integral_functional() const override;
25
26 // private:
27 // int in_power_ = 2;
28 // };
29
30 // class TrueContactForceForm : public StaticForm
31 // {
32 // public:
33 // TrueContactForceForm(const VariableToSimulationGroup &variable_to_simulations, const State &state, const json &args) : StaticForm(variable_to_simulations), state_(state)
34 // {
35 // auto tmp_ids = args["surface_selection"].get<std::vector<int>>();
36 // ids_ = std::set(tmp_ids.begin(), tmp_ids.end());
37
38 // build_active_nodes();
39 // }
40 // ~TrueContactForceForm() = default;
41
42 // const State &get_state() { return state_; }
43
44 // double value_unweighted_step(const int time_step, const Eigen::VectorXd &x) const override;
45 // Eigen::VectorXd compute_adjoint_rhs_step(const int time_step, const Eigen::VectorXd &x, const State &state) const override;
46 // Eigen::VectorXd compute_adjoint_rhs_step_prev(const int time_step, const Eigen::VectorXd &x, const State &state) const override;
47 // virtual void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
48
49 // void build_active_nodes();
50
51 // protected:
52 // const State &state_;
53 // std::set<int> ids_;
54 // Eigen::VectorXi active_nodes_;
55 // StiffnessMatrix active_nodes_mat_;
56 // int dim_;
57
58 // double dhat_, epsv_, friction_coefficient_;
59 // };
60
62 {
63 public:
65 const VariableToSimulationGroup &variable_to_simulations,
66 const State &state,
67 const double dhat,
68 const bool quadratic_potential,
69 const json &args);
71
72 double value_unweighted_step(const int time_step, const Eigen::VectorXd &x) const override;
73 Eigen::VectorXd compute_adjoint_rhs_step(const int time_step, const Eigen::VectorXd &x, const State &state) const override;
74 void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
75 void solution_changed_step(const int time_step, const Eigen::VectorXd &x) override
76 {
77 if (curr_x_.size() > 0 && (curr_x_ - x).norm() < 1e-8)
78 return;
79
82 curr_x_ = x;
83 }
84
85 protected:
88 const ipc::Collisions &get_or_compute_collision_set(const int time_step, const Eigen::MatrixXd &displaced_surface) const;
89
90 const State &state_;
91 std::set<int> boundary_ids_;
92 std::map<int, std::set<int>> boundary_ids_to_dof_;
93 Eigen::MatrixXi can_collide_cache_;
94
95 Eigen::MatrixXd node_positions_;
96
97 mutable Eigen::VectorXi collision_set_indicator_;
98 std::vector<std::shared_ptr<ipc::Collisions>> collision_sets_;
99
100 ipc::CollisionMesh collision_mesh_;
101 const double dhat_;
102 const double dmin_ = 0;
103 ipc::BroadPhaseMethod broad_phase_method_;
104
105 Eigen::VectorXd curr_x_;
106
107 ipc::BarrierPotential barrier_potential_;
108 };
109
110} // namespace polyfem::solver
int x
main class that contains the polyfem solver and all its state
Definition State.hpp:79
const ipc::Collisions & get_or_compute_collision_set(const int time_step, const Eigen::MatrixXd &displaced_surface) const
std::vector< std::shared_ptr< ipc::Collisions > > collision_sets_
double value_unweighted_step(const int time_step, const Eigen::VectorXd &x) const override
std::map< int, std::set< int > > boundary_ids_to_dof_
void solution_changed_step(const int time_step, const Eigen::VectorXd &x) override
Eigen::VectorXd compute_adjoint_rhs_step(const int time_step, const Eigen::VectorXd &x, const State &state) const override
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
A collection of VariableToSimulation.
nlohmann::json json
Definition Common.hpp:9