PolyFEM
Loading...
Searching...
No Matches
SurfaceTractionForms.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
SpatialIntegralForms.hpp
"
4
5
#include <
polyfem/solver/forms/ContactForm.hpp
>
6
7
namespace
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
61
class
ProxyContactForceForm
:
public
StaticForm
62
{
63
public
:
64
ProxyContactForceForm
(
65
const
VariableToSimulationGroup
&variable_to_simulations,
66
const
State
&state,
67
const
double
dhat,
68
const
bool
quadratic_potential,
69
const
json
&args);
70
~ProxyContactForceForm
() =
default
;
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
80
collision_set_indicator_
.setZero();
81
build_collision_mesh
();
82
curr_x_
=
x
;
83
}
84
85
protected
:
86
void
build_collision_mesh
();
87
void
build_forward_collision_mesh
();
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
ContactForm.hpp
SpatialIntegralForms.hpp
x
int x
Definition
SplineBasis3d.cpp:55
polyfem::State
main class that contains the polyfem solver and all its state
Definition
State.hpp:79
polyfem::solver::ProxyContactForceForm
Definition
SurfaceTractionForms.hpp:62
polyfem::solver::ProxyContactForceForm::barrier_potential_
ipc::BarrierPotential barrier_potential_
Definition
SurfaceTractionForms.hpp:107
polyfem::solver::ProxyContactForceForm::collision_set_indicator_
Eigen::VectorXi collision_set_indicator_
Definition
SurfaceTractionForms.hpp:97
polyfem::solver::ProxyContactForceForm::broad_phase_method_
ipc::BroadPhaseMethod broad_phase_method_
Definition
SurfaceTractionForms.hpp:103
polyfem::solver::ProxyContactForceForm::get_or_compute_collision_set
const ipc::Collisions & get_or_compute_collision_set(const int time_step, const Eigen::MatrixXd &displaced_surface) const
Definition
SurfaceTractionForms.cpp:954
polyfem::solver::ProxyContactForceForm::collision_sets_
std::vector< std::shared_ptr< ipc::Collisions > > collision_sets_
Definition
SurfaceTractionForms.hpp:98
polyfem::solver::ProxyContactForceForm::value_unweighted_step
double value_unweighted_step(const int time_step, const Eigen::VectorXd &x) const override
Definition
SurfaceTractionForms.cpp:965
polyfem::solver::ProxyContactForceForm::curr_x_
Eigen::VectorXd curr_x_
Definition
SurfaceTractionForms.hpp:105
polyfem::solver::ProxyContactForceForm::state_
const State & state_
Definition
SurfaceTractionForms.hpp:90
polyfem::solver::ProxyContactForceForm::~ProxyContactForceForm
~ProxyContactForceForm()=default
polyfem::solver::ProxyContactForceForm::dhat_
const double dhat_
Definition
SurfaceTractionForms.hpp:101
polyfem::solver::ProxyContactForceForm::node_positions_
Eigen::MatrixXd node_positions_
Definition
SurfaceTractionForms.hpp:95
polyfem::solver::ProxyContactForceForm::boundary_ids_to_dof_
std::map< int, std::set< int > > boundary_ids_to_dof_
Definition
SurfaceTractionForms.hpp:92
polyfem::solver::ProxyContactForceForm::solution_changed_step
void solution_changed_step(const int time_step, const Eigen::VectorXd &x) override
Definition
SurfaceTractionForms.hpp:75
polyfem::solver::ProxyContactForceForm::compute_adjoint_rhs_step
Eigen::VectorXd compute_adjoint_rhs_step(const int time_step, const Eigen::VectorXd &x, const State &state) const override
Definition
SurfaceTractionForms.cpp:980
polyfem::solver::ProxyContactForceForm::build_forward_collision_mesh
void build_forward_collision_mesh()
polyfem::solver::ProxyContactForceForm::can_collide_cache_
Eigen::MatrixXi can_collide_cache_
Definition
SurfaceTractionForms.hpp:93
polyfem::solver::ProxyContactForceForm::compute_partial_gradient_step
void compute_partial_gradient_step(const int time_step, const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
Definition
SurfaceTractionForms.cpp:1016
polyfem::solver::ProxyContactForceForm::build_collision_mesh
void build_collision_mesh()
Definition
SurfaceTractionForms.cpp:828
polyfem::solver::ProxyContactForceForm::boundary_ids_
std::set< int > boundary_ids_
Definition
SurfaceTractionForms.hpp:91
polyfem::solver::ProxyContactForceForm::dmin_
const double dmin_
Definition
SurfaceTractionForms.hpp:102
polyfem::solver::ProxyContactForceForm::collision_mesh_
ipc::CollisionMesh collision_mesh_
Definition
SurfaceTractionForms.hpp:100
polyfem::solver::StaticForm
Definition
AdjointForm.hpp:50
polyfem::solver::VariableToSimulationGroup
A collection of VariableToSimulation.
Definition
VariableToSimulation.hpp:51
polyfem::solver
Definition
OptState.hpp:16
polyfem::json
nlohmann::json json
Definition
Common.hpp:9
src
polyfem
solver
forms
adjoint_forms
SurfaceTractionForms.hpp
Generated by
1.9.8