PolyFEM
Loading...
Searching...
No Matches
CompositeForm.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "AdjointForm.hpp"
6
7namespace polyfem::solver
8{
10 {
12 public:
13 CompositeForm(const VariableToSimulationGroup &variable_to_simulations, const std::vector<std::shared_ptr<AdjointForm>> &forms) : AdjointForm(variable_to_simulations), forms_(forms) {}
14 CompositeForm(const std::vector<std::shared_ptr<AdjointForm>> &forms) : AdjointForm(forms[0]->get_variable_to_simulations()), forms_(forms) {}
15 virtual ~CompositeForm() {}
16
17 virtual int n_objs() const final { return forms_.size(); }
18
19 virtual Eigen::MatrixXd compute_reduced_adjoint_rhs(const Eigen::VectorXd &x, const State &state) const override final;
20 virtual void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override final;
21
22 virtual double compose(const Eigen::VectorXd &inputs) const = 0;
23 virtual Eigen::VectorXd compose_grad(const Eigen::VectorXd &inputs) const = 0;
24
25 Eigen::VectorXd get_inputs(const Eigen::VectorXd &x) const;
26
27 virtual double value_unweighted(const Eigen::VectorXd &x) const final override;
28 virtual void init(const Eigen::VectorXd &x) final override;
29 virtual bool is_step_valid(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const final override;
30 virtual double max_step_size(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const final override;
31 virtual void line_search_begin(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) final override;
32 virtual void line_search_end() final override;
33 virtual void post_step(const polysolve::nonlinear::PostStepData &data) final override;
34 virtual void solution_changed(const Eigen::VectorXd &new_x) final override;
35 virtual bool is_step_collision_free(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const final override;
36
37 private:
38 std::vector<std::shared_ptr<AdjointForm>> forms_;
39 };
40} // namespace polyfem::solver
int x
main class that contains the polyfem solver and all its state
Definition State.hpp:79
const VariableToSimulationGroup & get_variable_to_simulations() const
virtual void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override final
std::vector< std::shared_ptr< AdjointForm > > forms_
CompositeForm(const std::vector< std::shared_ptr< AdjointForm > > &forms)
virtual bool is_step_valid(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const final override
Determine if a step from solution x0 to solution x1 is allowed.
virtual double compose(const Eigen::VectorXd &inputs) const =0
virtual void init(const Eigen::VectorXd &x) final override
Initialize the form.
virtual double value_unweighted(const Eigen::VectorXd &x) const final override
Compute the value of the form.
virtual double max_step_size(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const final override
Determine the maximum step size allowable between the current and next solution.
Eigen::VectorXd get_inputs(const Eigen::VectorXd &x) const
CompositeForm(const VariableToSimulationGroup &variable_to_simulations, const std::vector< std::shared_ptr< AdjointForm > > &forms)
virtual Eigen::MatrixXd compute_reduced_adjoint_rhs(const Eigen::VectorXd &x, const State &state) const override final
virtual int n_objs() const final
virtual void post_step(const polysolve::nonlinear::PostStepData &data) final override
Update fields after a step in the optimization.
virtual Eigen::VectorXd compose_grad(const Eigen::VectorXd &inputs) const =0
virtual bool is_step_collision_free(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const final override
Checks if the step is collision free.
virtual void line_search_begin(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) final override
Initialize variables used during the line search.
virtual void solution_changed(const Eigen::VectorXd &new_x) final override
Update cached fields upon a change in the solution.
virtual void line_search_end() final override
Clear variables used during the line search.
A collection of VariableToSimulation.