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