26 Eigen::VectorXi active_geom_nodes)
27 : dim_(varforms[0]->get_mesh().dimension()),
28 vertex_num_(varforms[0]->get_mesh().n_vertices()),
29 varforms_(std::move(varforms)),
30 diff_caches_(std::move(diff_caches)),
31 parametrization_(std::move(parametrizations)),
32 active_geom_nodes_(std::move(active_geom_nodes))
40 if (varform->get_problem().is_time_dependent())
42 log_and_throw_adjoint_error(
"Fail to construct dirichlet nodes variable to simulation. Reason: only quasistatic simulations supported.");
53 int v = varform.primary_space().space_in_node_to_node(v_in);
54 int tag = varform.get_mesh().get_node_id(v);
55 if (varform.get_problem().is_nodal_dirichlet_boundary(v, tag))
60 std::sort(tmp.begin(), tmp.end());
74 return "dirichlet-nodes";
86 if (varform.get() == &target)
113 Eigen::VectorXd term = Eigen::VectorXd::Zero(
para_out_dof());
115 for (
int si = 0; si <
varforms_.size(); ++si)
122 Eigen::VectorXd full_term;
144 logger().warn(
"Inverse eval is not implemented in {}; falling back to zero.",
name());
Eigen::VectorXd apply_jacobian(const Eigen::VectorXd &grad_full, const Eigen::VectorXd &x) const override
Apply jacobian for chain rule.
Eigen::VectorXd inverse_eval(const Eigen::VectorXd &y) const override
Eval x = f^-1 (y).
int inverse_size(int y_size) const override
Compute DOF of x given DOF of y.
Eigen::VectorXd eval(const Eigen::VectorXd &x) const override
Eval y = f(x).
std::vector< std::shared_ptr< DiffCache > > DiffCachePtrs
CompositeParametrization parametrization_
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.
ParameterType parameter_type() const override
std::string name() const override
DiffCachePtrs diff_caches_
void update(const Eigen::VectorXd &x) override
Update forward simulation varforms from optimization variables.
Eigen::VectorXi active_geom_nodes_
int inverse_dof() const override
Compute optimization variables dof.
std::vector< std::shared_ptr< varform::DifferentiableVarForm > > VarFormPtrs
Eigen::VectorXd compute_adjoint_term(const Eigen::VectorXd &x) const override
Compute adjoint contribution of objective gradient.
void update_state_variables(const Eigen::VectorXd &x, Eigen::VectorXd &state_variables) const override
Update varform variables from optimization variables.
Eigen::VectorXd inverse_eval() const override
Compute optimization variables from forward simulation varform::DifferentiableVarForm.
DirichletNodesVariableToSimulation(VarFormPtrs varforms, DiffCachePtrs diff_caches, CompositeParametrization parametrizations, Eigen::VectorXi active_geom_nodes)
Construct DirichletNodesVariableToSimulation.
bool affects_varform(const varform::DifferentiableVarForm &target) const override
Return true if current var2sim maps to target varform.
bool is_active_dirichlet_node_valid(const Eigen::VectorXi &active_dirichlet_nodes, const std::vector< std::shared_ptr< varform::DifferentiableVarForm > > &varforms, std::string &reason)
Validate active Dirichlet node ids selection given varforms.
Eigen::MatrixXd unflatten(const Eigen::VectorXd &x, int dim)
Unflatten rowwises, so every dim elements in x become a row.
spdlog::logger & logger()
Retrieves the current logger.
void log_and_throw_adjoint_error(const std::string &msg)
Eigen::MatrixXd get_adjoint_mat(const varform::DifferentiableVarForm &varform, const DiffCache &diff_cache, int type)
Get adjoint parameter nu or p.