PolyFEM
Loading...
Searching...
No Matches
NLHomoProblem.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "NLProblem.hpp"
4
5namespace polyfem
6{
7 class State;
8 namespace assembler
9 {
10 class MacroStrainValue;
11 }
12} // namespace polyfem
13
14namespace polyfem::solver
15{
16 class NLHomoProblem : public NLProblem
17 {
18 public:
19 using typename FullNLProblem::Scalar;
20 using typename FullNLProblem::THessian;
21 using typename FullNLProblem::TVector;
22
23 NLHomoProblem(const int full_size,
24 const assembler::MacroStrainValue &macro_strain_constraint,
25 const State &state,
26 const double t,
27 const std::vector<std::shared_ptr<Form>> &forms,
28 const std::vector<std::shared_ptr<AugmentedLagrangianForm>> &penalty_forms,
29 const bool solve_symmetric_macro_strain);
30 virtual ~NLHomoProblem() = default;
31
32 double value(const TVector &x) override;
33 void gradient(const TVector &x, TVector &gradv) override;
34 void hessian(const TVector &x, THessian &hessian) override;
35
36 void full_hessian_to_reduced_hessian(const THessian &full, THessian &reduced) const override;
37
38 int macro_reduced_size() const;
39
40 TVector full_to_reduced(const TVector &full, const Eigen::MatrixXd &disp_grad) const;
41 TVector full_to_reduced(const TVector &full) const override;
42 TVector full_to_reduced_grad(const TVector &full) const override;
43 TVector reduced_to_full(const TVector &reduced) const override;
44 TVector reduced_to_full_shape_derivative(const Eigen::MatrixXd &disp_grad, const TVector &adjoint_full) const;
45
46 TVector reduced_to_extended(const TVector &reduced, bool homogeneous = false) const;
47 TVector extended_to_reduced(const TVector &extended) const;
48 TVector extended_to_reduced_grad(const TVector &extended) const;
49 void extended_hessian_to_reduced_hessian(const THessian &extended, THessian &reduced) const;
50
51 Eigen::MatrixXd reduced_to_disp_grad(const TVector &reduced, bool homogeneous = false) const;
52
53 void set_fixed_entry(const Eigen::VectorXi &fixed_entry);
54
55 void init(const TVector &x0) override;
56 bool is_step_valid(const TVector &x0, const TVector &x1) override;
57 bool is_step_collision_free(const TVector &x0, const TVector &x1) override;
58 double max_step_size(const TVector &x0, const TVector &x1) override;
59
60 void line_search_begin(const TVector &x0, const TVector &x1) override;
61 void post_step(const polysolve::nonlinear::PostStepData &data) override;
62
63 void solution_changed(const TVector &new_x) override;
64
65 void init_lagging(const TVector &x) override;
66 void update_lagging(const TVector &x, const int iter_num) override;
67
68 void update_quantities(const double t, const TVector &x) override;
69
70 void add_form(const std::shared_ptr<Form> &form) { homo_forms.push_back(form); }
71 bool has_symmetry_constraint() const { return only_symmetric; }
72
73 protected:
74 Eigen::MatrixXd constraint_values(const TVector &) const override;
75
76 private:
77 void init_projection();
78 Eigen::MatrixXd constraint_grad() const;
79
80 TVector macro_full_to_reduced(const TVector &full) const;
81 Eigen::MatrixXd macro_full_to_reduced_grad(const Eigen::MatrixXd &full) const;
82 TVector macro_reduced_to_full(const TVector &reduced, bool homogeneous = false) const;
83
84 const State &state_;
85 const bool only_symmetric;
87
88 Eigen::VectorXi fixed_mask_;
89 Eigen::MatrixXd macro_mid_to_reduced_; // (dim*dim) x (dim*(dim+1)/2)
91
92 std::vector<std::shared_ptr<Form>> homo_forms;
93 };
94} // namespace polyfem::solver
int x
main class that contains the polyfem solver and all its state
Definition State.hpp:79
std::vector< std::shared_ptr< Form > > & forms()
Eigen::MatrixXd reduced_to_disp_grad(const TVector &reduced, bool homogeneous=false) const
void gradient(const TVector &x, TVector &gradv) override
void init(const TVector &x0) override
void post_step(const polysolve::nonlinear::PostStepData &data) override
void set_fixed_entry(const Eigen::VectorXi &fixed_entry)
TVector macro_full_to_reduced(const TVector &full) const
bool is_step_valid(const TVector &x0, const TVector &x1) override
Eigen::MatrixXd constraint_values(const TVector &) const override
const assembler::MacroStrainValue & macro_strain_constraint_
void line_search_begin(const TVector &x0, const TVector &x1) override
void update_quantities(const double t, const TVector &x) override
TVector extended_to_reduced_grad(const TVector &extended) const
void hessian(const TVector &x, THessian &hessian) override
void init_lagging(const TVector &x) override
TVector reduced_to_extended(const TVector &reduced, bool homogeneous=false) const
TVector extended_to_reduced(const TVector &extended) const
virtual ~NLHomoProblem()=default
std::vector< std::shared_ptr< Form > > homo_forms
Eigen::MatrixXd constraint_grad() const
void full_hessian_to_reduced_hessian(const THessian &full, THessian &reduced) const override
TVector reduced_to_full_shape_derivative(const Eigen::MatrixXd &disp_grad, const TVector &adjoint_full) const
TVector reduced_to_full(const TVector &reduced) const override
Eigen::MatrixXd macro_full_to_reduced_grad(const Eigen::MatrixXd &full) const
double value(const TVector &x) override
TVector full_to_reduced(const TVector &full, const Eigen::MatrixXd &disp_grad) const
TVector full_to_reduced_grad(const TVector &full) const override
void solution_changed(const TVector &new_x) override
double max_step_size(const TVector &x0, const TVector &x1) override
void extended_hessian_to_reduced_hessian(const THessian &extended, THessian &reduced) const
bool is_step_collision_free(const TVector &x0, const TVector &x1) override
void add_form(const std::shared_ptr< Form > &form)
void update_lagging(const TVector &x, const int iter_num) override
TVector macro_reduced_to_full(const TVector &reduced, bool homogeneous=false) const