PolyFEM
Loading...
Searching...
No Matches
NLProblem.hpp
Go to the documentation of this file.
1#pragma once
2
6
7namespace polyfem::solver
8{
9 class NLProblem : public FullNLProblem
10 {
11 public:
12 using typename FullNLProblem::Scalar;
13 using typename FullNLProblem::THessian;
14 using typename FullNLProblem::TVector;
15
16 protected:
18 const int full_size,
19 const std::vector<std::shared_ptr<Form>> &forms,
20 const std::vector<std::shared_ptr<AugmentedLagrangianForm>> &penalty_forms);
21
22 public:
23 NLProblem(const int full_size,
24 const std::shared_ptr<utils::PeriodicBoundary> &periodic_bc,
25 const double t,
26 const std::vector<std::shared_ptr<Form>> &forms,
27 const std::vector<std::shared_ptr<AugmentedLagrangianForm>> &penalty_forms);
28 virtual ~NLProblem() = default;
29
30 virtual double value(const TVector &x) override;
31 virtual void gradient(const TVector &x, TVector &gradv) override;
32 virtual void hessian(const TVector &x, THessian &hessian) override;
33
34 virtual bool is_step_valid(const TVector &x0, const TVector &x1) override;
35 virtual bool is_step_collision_free(const TVector &x0, const TVector &x1) override;
36 virtual double max_step_size(const TVector &x0, const TVector &x1) override;
37 void line_search_begin(const TVector &x0, const TVector &x1) override;
38 virtual void post_step(const polysolve::nonlinear::PostStepData &data) override;
39
40 void solution_changed(const TVector &new_x) override;
41
42 void init_lagging(const TVector &x) override;
43 void update_lagging(const TVector &x, const int iter_num) override;
44
45 // --------------------------------------------------------------------
46
47 virtual void update_quantities(const double t, const TVector &x);
48
49 int full_size() const { return full_size_; }
50 int reduced_size() const { return reduced_size_; }
51
54
55 virtual TVector full_to_reduced(const TVector &full) const;
56 virtual TVector full_to_reduced_grad(const TVector &full) const;
57 virtual void full_hessian_to_reduced_hessian(const THessian &full, THessian &reduced) const;
58 virtual TVector reduced_to_full(const TVector &reduced) const;
59
60 protected:
61 virtual Eigen::MatrixXd constraint_values(const TVector &reduced) const;
62
63 std::vector<int> constraint_nodes_;
64
65 const int full_size_;
67
68 std::shared_ptr<utils::PeriodicBoundary> periodic_bc_;
69
70 enum class CurrentSize
71 {
74 };
76 int current_size() const
77 {
79 }
80
81 double t_;
82
83 private:
84 std::vector<std::shared_ptr<AugmentedLagrangianForm>> penalty_forms_;
85
87
88 template <class FullMat, class ReducedMat>
89 void full_to_reduced_aux(const std::vector<int> &constraint_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const;
90
91 template <class ReducedMat, class FullMat>
92 void reduced_to_full_aux(const std::vector<int> &constraint_nodes, const int full_size, const int reduced_size, const ReducedMat &reduced, const Eigen::MatrixXd &rhs, FullMat &full) const;
93
94 template <class FullMat, class ReducedMat>
95 void full_to_reduced_aux_grad(const std::vector<int> &constraint_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const;
96 };
97} // namespace polyfem::solver
int x
std::vector< std::shared_ptr< Form > > & forms()
const int full_size_
Size of the full problem.
Definition NLProblem.hpp:65
void line_search_begin(const TVector &x0, const TVector &x1) override
Definition NLProblem.cpp:88
virtual bool is_step_valid(const TVector &x0, const TVector &x1) override
Definition NLProblem.cpp:98
int reduced_size_
Size of the reduced problem.
Definition NLProblem.hpp:66
virtual void post_step(const polysolve::nonlinear::PostStepData &data) override
virtual TVector full_to_reduced_grad(const TVector &full) const
virtual Eigen::MatrixXd constraint_values(const TVector &reduced) const
virtual TVector full_to_reduced(const TVector &full) const
virtual void update_quantities(const double t, const TVector &x)
Definition NLProblem.cpp:80
virtual void gradient(const TVector &x, TVector &gradv) override
void init_lagging(const TVector &x) override
Definition NLProblem.cpp:70
virtual bool is_step_collision_free(const TVector &x0, const TVector &x1) override
virtual TVector reduced_to_full(const TVector &reduced) const
void update_lagging(const TVector &x, const int iter_num) override
Definition NLProblem.cpp:75
virtual void full_hessian_to_reduced_hessian(const THessian &full, THessian &reduced) const
void full_to_reduced_aux(const std::vector< int > &constraint_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const
std::vector< std::shared_ptr< AugmentedLagrangianForm > > penalty_forms_
Definition NLProblem.hpp:84
virtual double value(const TVector &x) override
virtual double max_step_size(const TVector &x0, const TVector &x1) override
Definition NLProblem.cpp:93
virtual ~NLProblem()=default
std::shared_ptr< utils::PeriodicBoundary > periodic_bc_
Definition NLProblem.hpp:68
virtual void hessian(const TVector &x, THessian &hessian) override
std::vector< int > constraint_nodes_
Definition NLProblem.hpp:63
void solution_changed(const TVector &new_x) override
void reduced_to_full_aux(const std::vector< int > &constraint_nodes, const int full_size, const int reduced_size, const ReducedMat &reduced, const Eigen::MatrixXd &rhs, FullMat &full) const
CurrentSize current_size_
Current size of the problem (either full or reduced size)
Definition NLProblem.hpp:75
void full_to_reduced_aux_grad(const std::vector< int > &constraint_nodes, const int full_size, const int reduced_size, const FullMat &full, ReducedMat &reduced) const