|
PolyFEM
|
Maps to dirichlet boundary. More...
#include <DirichletNodesVariableToSimulation.hpp>
Public Types | |
| using | StatePtrs = std::vector< std::shared_ptr< legacy::State > > |
| using | DiffCachePtrs = std::vector< std::shared_ptr< DiffCache > > |
Public Member Functions | |
| DirichletNodesVariableToSimulation (StatePtrs states, DiffCachePtrs diff_caches, CompositeParametrization parametrizations, Eigen::VectorXi active_geom_nodes) | |
| Construct DirichletNodesVariableToSimulation. | |
| std::string | name () const override |
| ParameterType | parameter_type () const override |
| bool | affect_state (const legacy::State &target) const override |
| Return true if current var2sim maps to target state. | |
| void | update (const Eigen::VectorXd &x) override |
| Update forward simulation states from optimization variables. | |
| void | update_state_variables (const Eigen::VectorXd &x, Eigen::VectorXd &state_variables) const override |
| Update state variables from optimization variables. | |
| Eigen::VectorXd | compute_adjoint_term (const Eigen::VectorXd &x) const override |
| Compute adjoint contribution of objective gradient. | |
| int | inverse_dof () const override |
| Compute optimization variables dof. | |
| Eigen::VectorXd | inverse_eval () const override |
| Compute optimization variables from forward simulation legacy::State. | |
| Eigen::VectorXd | apply_parametrization_jacobian (const Eigen::VectorXd &term, const Eigen::VectorXd &x) const override |
| Apply parametrization jacobian to compute the gradient w.r.t. | |
Public Member Functions inherited from polyfem::solver::VariableToSimulation | |
| virtual | ~VariableToSimulation ()=default |
Private Member Functions | |
| int | para_out_dof () const |
Private Attributes | |
| int | dim_ |
| int | vertex_num_ |
| StatePtrs | states_ |
| DiffCachePtrs | diff_caches_ |
| CompositeParametrization | parametrization_ |
| Eigen::VectorXi | active_geom_nodes_ |
Maps to dirichlet boundary.
Maps one boundary solution to one boundary. Only support static problem.
Example 1: Suppose one boundary selection contains 3 vertices at x=0, this var2sim will map 3 solution (displacement xyz) to their respective vertices.
Definition at line 20 of file DirichletNodesVariableToSimulation.hpp.
| using polyfem::solver::DirichletNodesVariableToSimulation::DiffCachePtrs = std::vector<std::shared_ptr<DiffCache> > |
Definition at line 24 of file DirichletNodesVariableToSimulation.hpp.
| using polyfem::solver::DirichletNodesVariableToSimulation::StatePtrs = std::vector<std::shared_ptr<legacy::State> > |
Definition at line 23 of file DirichletNodesVariableToSimulation.hpp.
| polyfem::solver::DirichletNodesVariableToSimulation::DirichletNodesVariableToSimulation | ( | StatePtrs | states, |
| DiffCachePtrs | diff_caches, | ||
| CompositeParametrization | parametrizations, | ||
| Eigen::VectorXi | active_geom_nodes | ||
| ) |
Construct DirichletNodesVariableToSimulation.
| [in] | states | Shared ptr to all forward sim states. |
| [in] | diff_caches | Shared ptr to all diff caches. |
| [in] | parametrizations | Parametrizations. |
| [in] | actice_dimensions | Vector of active dimensions per mesh node. Empty implies all active. |
| [in] | active_geom_nodes | Input vertex indices. Empty implies all nodal Dirichlet vertices. |
| std::runtime_error | Throw if input is invalid. |
Definition at line 22 of file DirichletNodesVariableToSimulation.cpp.
References active_geom_nodes_, diff_caches_, polyfem::solver::is_active_dirichlet_node_valid(), polyfem::log_and_throw_adjoint_error(), states_, and vertex_num_.
|
overridevirtual |
Return true if current var2sim maps to target state.
Implements polyfem::solver::VariableToSimulation.
Definition at line 82 of file DirichletNodesVariableToSimulation.cpp.
References states_.
|
overridevirtual |
Apply parametrization jacobian to compute the gradient w.r.t.
to optimization variables.
| term | Gradient w.r.t. to full inherent dof (Ex. all vertices for shape var2sim) |
| x | Optimization variables. |
Implements polyfem::solver::VariableToSimulation.
Definition at line 156 of file DirichletNodesVariableToSimulation.cpp.
References polyfem::log_and_throw_adjoint_error(), and name().
|
overridevirtual |
Compute adjoint contribution of objective gradient.
See arXiv:2205.13643.
Let objective function be J and optimization variable be x. This method computes all adjoint related terms in dJ/dx. For static case (E.q. 11), it's the second term. For dynamic case (E.q. 15), it's everything except ∂qJ.
| x[in] | Optimization variables. |
Implements polyfem::solver::VariableToSimulation.
Definition at line 119 of file DirichletNodesVariableToSimulation.cpp.
References active_geom_nodes_, polyfem::solver::CompositeParametrization::apply_jacobian(), diff_caches_, dim_, polyfem::solver::AdjointTools::dJ_dirichlet_static_adjoint_term(), polyfem::get_adjoint_mat(), para_out_dof(), parametrization_, states_, vertex_num_, and x.
|
overridevirtual |
Compute optimization variables dof.
| std::runtime_error | Throw if not implemented. |
Implements polyfem::solver::VariableToSimulation.
Definition at line 145 of file DirichletNodesVariableToSimulation.cpp.
References polyfem::solver::CompositeParametrization::inverse_size(), para_out_dof(), and parametrization_.
|
overridevirtual |
Compute optimization variables from forward simulation legacy::State.
| std::runtime_error | Throw if not implemented. |
Implements polyfem::solver::VariableToSimulation.
Definition at line 150 of file DirichletNodesVariableToSimulation.cpp.
References polyfem::solver::CompositeParametrization::inverse_eval(), polyfem::logger(), name(), para_out_dof(), and parametrization_.
|
overridevirtual |
Implements polyfem::solver::VariableToSimulation.
Definition at line 72 of file DirichletNodesVariableToSimulation.cpp.
Referenced by apply_parametrization_jacobian(), inverse_eval(), and update().
|
private |
Definition at line 162 of file DirichletNodesVariableToSimulation.cpp.
References active_geom_nodes_, and dim_.
Referenced by compute_adjoint_term(), inverse_dof(), inverse_eval(), update(), and update_state_variables().
|
overridevirtual |
Implements polyfem::solver::VariableToSimulation.
Definition at line 77 of file DirichletNodesVariableToSimulation.cpp.
References polyfem::solver::DirichletBC.
|
overridevirtual |
Update forward simulation states from optimization variables.
| [in] | x | Optimization variables. |
Implements polyfem::solver::VariableToSimulation.
Definition at line 94 of file DirichletNodesVariableToSimulation.cpp.
References active_geom_nodes_, dim_, polyfem::solver::CompositeParametrization::eval(), polyfem::log_and_throw_adjoint_error(), name(), para_out_dof(), parametrization_, states_, polyfem::utils::unflatten(), x, and y.
|
overridevirtual |
Update state variables from optimization variables.
Compared to update() this method update abstract state variables instead of writing directly to state.
| [in] | x | Optimization variables. |
| [out] | state_variables | Abstract state variables update dst. |
Implements polyfem::solver::VariableToSimulation.
Definition at line 113 of file DirichletNodesVariableToSimulation.cpp.
References polyfem::solver::CompositeParametrization::eval(), para_out_dof(), parametrization_, and x.
|
private |
Definition at line 58 of file DirichletNodesVariableToSimulation.hpp.
Referenced by compute_adjoint_term(), DirichletNodesVariableToSimulation(), para_out_dof(), and update().
|
private |
Definition at line 54 of file DirichletNodesVariableToSimulation.hpp.
Referenced by compute_adjoint_term(), and DirichletNodesVariableToSimulation().
|
private |
Definition at line 50 of file DirichletNodesVariableToSimulation.hpp.
Referenced by compute_adjoint_term(), para_out_dof(), and update().
|
private |
Definition at line 55 of file DirichletNodesVariableToSimulation.hpp.
Referenced by compute_adjoint_term(), inverse_dof(), inverse_eval(), update(), and update_state_variables().
|
private |
Definition at line 53 of file DirichletNodesVariableToSimulation.hpp.
Referenced by affect_state(), compute_adjoint_term(), DirichletNodesVariableToSimulation(), and update().
|
private |
Definition at line 51 of file DirichletNodesVariableToSimulation.hpp.
Referenced by compute_adjoint_term(), and DirichletNodesVariableToSimulation().