PolyFEM
Loading...
Searching...
No Matches
TransientForm.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "AdjointForm.hpp"
4
5namespace polyfem::solver
6{
8 {
9 public:
10 TransientForm(const VariableToSimulationGroup &variable_to_simulations, const int time_steps, const double dt, const std::string &transient_integral_type, const std::vector<int> &steps, const std::shared_ptr<StaticForm> &obj) : AdjointForm(variable_to_simulations), time_steps_(time_steps), dt_(dt), steps_(steps), obj_(obj), transient_integral_type_(transient_integral_type) {}
11 virtual ~TransientForm() = default;
12
13 virtual Eigen::MatrixXd compute_adjoint_rhs(const Eigen::VectorXd &x, const State &state) const override;
14 virtual void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
15
16 void init(const Eigen::VectorXd &x) override;
17 bool is_step_valid(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override;
18 double max_step_size(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override;
19 void line_search_begin(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override;
20 void line_search_end() override;
21 void post_step(const polysolve::nonlinear::PostStepData &data) override;
22 void solution_changed(const Eigen::VectorXd &new_x) override;
23 bool is_step_collision_free(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override;
24
25 protected:
26 virtual double value_unweighted(const Eigen::VectorXd &x) const override;
27
29 double dt_;
30 std::vector<int> steps_;
31 std::shared_ptr<StaticForm> obj_;
32
33 private:
34 std::vector<double> get_transient_quadrature_weights() const;
36 };
37
39 {
40 public:
41 ProxyTransientForm(const VariableToSimulationGroup &variable_to_simulations, const int time_steps, const double dt, const std::string &transient_integral_type, const std::vector<int> &steps, const std::shared_ptr<StaticForm> &obj) : TransientForm(variable_to_simulations, time_steps, dt, transient_integral_type, steps, obj) {}
42 virtual ~ProxyTransientForm() = default;
43
44 Eigen::MatrixXd compute_adjoint_rhs(const Eigen::VectorXd &x, const State &state) const override;
45 void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
46
47 protected:
48 double value_unweighted(const Eigen::VectorXd &x) const override;
49
50 private:
51 double eval(const Eigen::VectorXd &y) const;
52 Eigen::VectorXd eval_grad(const Eigen::VectorXd &y) const;
53 };
54}
int y
int x
main class that contains the polyfem solver and all its state
Definition State.hpp:79
ProxyTransientForm(const VariableToSimulationGroup &variable_to_simulations, const int time_steps, const double dt, const std::string &transient_integral_type, const std::vector< int > &steps, const std::shared_ptr< StaticForm > &obj)
Eigen::VectorXd eval_grad(const Eigen::VectorXd &y) const
double eval(const Eigen::VectorXd &y) const
void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
Eigen::MatrixXd compute_adjoint_rhs(const Eigen::VectorXd &x, const State &state) const override
virtual double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
void solution_changed(const Eigen::VectorXd &new_x) override
Update cached fields upon a change in the solution.
double max_step_size(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override
Determine the maximum step size allowable between the current and next solution.
bool is_step_collision_free(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override
Checks if the step is collision free.
virtual void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
virtual ~TransientForm()=default
TransientForm(const VariableToSimulationGroup &variable_to_simulations, const int time_steps, const double dt, const std::string &transient_integral_type, const std::vector< int > &steps, const std::shared_ptr< StaticForm > &obj)
bool is_step_valid(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override
Determine if a step from solution x0 to solution x1 is allowed.
virtual Eigen::MatrixXd compute_adjoint_rhs(const Eigen::VectorXd &x, const State &state) const override
std::shared_ptr< StaticForm > obj_
void init(const Eigen::VectorXd &x) override
Initialize the form.
void line_search_begin(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
Initialize variables used during the line search.
std::vector< double > get_transient_quadrature_weights() const
void line_search_end() override
Clear variables used during the line search.
void post_step(const polysolve::nonlinear::PostStepData &data) override
Update fields after a step in the optimization.
A collection of VariableToSimulation.