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 class MacroStrainValue;
10 }
11}
12
13namespace polyfem::solver
14{
15 class NLHomoProblem : public NLProblem
16 {
17 public:
18 using typename FullNLProblem::Scalar;
19 using typename FullNLProblem::THessian;
20 using typename FullNLProblem::TVector;
21
22 NLHomoProblem(const int full_size,
23 const std::vector<int> &boundary_nodes,
24 const std::vector<mesh::LocalBoundary> &local_boundary,
25 const int n_boundary_samples,
26 const assembler::RhsAssembler &rhs_assembler,
27 const assembler::MacroStrainValue &macro_strain_constraint,
28 const State &state,
29 const double t, const std::vector<std::shared_ptr<Form>> &forms,
30 const bool solve_symmetric_macro_strain);
31 virtual ~NLHomoProblem() = default;
32
33 double value(const TVector &x) override;
34 void gradient(const TVector &x, TVector &gradv) override;
35 void hessian(const TVector &x, THessian &hessian) override;
36
37 void full_hessian_to_reduced_hessian(const THessian &full, THessian &reduced) const override;
38
39 int macro_reduced_size() const;
40
41 TVector full_to_reduced(const TVector &full, const Eigen::MatrixXd &disp_grad) const;
42 TVector full_to_reduced(const TVector &full) const override;
43 TVector full_to_reduced_grad(const TVector &full) const override;
44 TVector reduced_to_full(const TVector &reduced) const override;
45 TVector reduced_to_full_shape_derivative(const Eigen::MatrixXd &disp_grad, const TVector &adjoint_full) const;
46
47 TVector reduced_to_extended(const TVector &reduced, bool homogeneous = false) const;
48 TVector extended_to_reduced(const TVector &extended) const;
49 TVector extended_to_reduced_grad(const TVector &extended) const;
50 void extended_hessian_to_reduced_hessian(const THessian &extended, THessian &reduced) const;
51
52 Eigen::MatrixXd reduced_to_disp_grad(const TVector &reduced, bool homogeneous = false) const;
53
54 void set_fixed_entry(const Eigen::VectorXi &fixed_entry);
55
56 void init(const TVector &x0) override;
57 bool is_step_valid(const TVector &x0, const TVector &x1) override;
58 bool is_step_collision_free(const TVector &x0, const TVector &x1) override;
59 double max_step_size(const TVector &x0, const TVector &x1) override;
60
61 void line_search_begin(const TVector &x0, const TVector &x1) override;
62 void post_step(const polysolve::nonlinear::PostStepData &data) override;
63
64 void solution_changed(const TVector &new_x) override;
65
66 void init_lagging(const TVector &x) override;
67 void update_lagging(const TVector &x, const int iter_num) override;
68
69 void update_quantities(const double t, const TVector &x) override;
70
71 void add_form(const std::shared_ptr<Form> &form) { homo_forms.push_back(form); }
72 bool has_symmetry_constraint() const { return only_symmetric; }
73
74 protected:
75 Eigen::MatrixXd boundary_values() const override;
76
77 private:
78 void init_projection();
79 Eigen::MatrixXd constraint_grad() const;
80
81 TVector macro_full_to_reduced(const TVector &full) const;
82 Eigen::MatrixXd macro_full_to_reduced_grad(const Eigen::MatrixXd &full) const;
83 TVector macro_reduced_to_full(const TVector &reduced, bool homogeneous = false) const;
84
85 const State &state_;
86 const bool only_symmetric;
88
89 Eigen::VectorXi fixed_mask_;
90 Eigen::MatrixXd macro_mid_to_reduced_; // (dim*dim) x (dim*(dim+1)/2)
92
93 std::vector<std::shared_ptr<Form>> homo_forms;
94 };
95}
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
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
Eigen::MatrixXd boundary_values() const 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