24 const std::vector<std::shared_ptr<Form>> &forms,
25 const std::vector<std::shared_ptr<AugmentedLagrangianForm>> &penalty_forms)
27 full_size_(full_size),
29 penalty_forms_(penalty_forms)
39 const std::shared_ptr<utils::PeriodicBoundary> &periodic_bc,
41 const std::vector<std::shared_ptr<Form>> &forms,
42 const std::vector<std::shared_ptr<AugmentedLagrangianForm>> &penalty_forms)
44 full_size_(full_size),
45 periodic_bc_(periodic_bc),
47 penalty_forms_(penalty_forms)
63 f->constraint_nodes().begin(),
64 f->constraint_nodes().end());
85 f->update_quantities(t, full);
123 THessian full_hessian;
172 Eigen::MatrixXd result = Eigen::MatrixXd::Zero(
full_size(), 1);
176 const auto tmp = form->target(reduced);
184 template <
class FullMat,
class ReducedMat>
185 void NLProblem::full_to_reduced_aux(
const std::vector<int> &constraint_nodes,
const int full_size,
const int reduced_size,
const FullMat &full, ReducedMat &reduced)
const
197 assert(full.cols() == 1);
206 assert(std::is_sorted(constraint_nodes.begin(), constraint_nodes.end()));
210 for (
int i = 0; i < mid.size(); ++i)
212 if (k < constraint_nodes.size() && constraint_nodes[k] == i)
218 assert(j < reduced.size());
219 reduced(j++) = mid(i);
223 template <
class ReducedMat,
class FullMat>
224 void NLProblem::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
236 assert(reduced.cols() == 1);
239 assert(std::is_sorted(constraint_nodes.begin(), constraint_nodes.end()));
243 Eigen::MatrixXd mid(
reduced_size + constraint_nodes.size(), 1);
244 for (
int i = 0; i < mid.size(); ++i)
246 if (k < constraint_nodes.size() && constraint_nodes[k] == i)
253 mid(i) = reduced(j++);
259 template <
class FullMat,
class ReducedMat>
272 assert(full.cols() == 1);
283 for (
int i = 0; i < mid.size(); ++i)
285 if (k < constraint_nodes.size() && constraint_nodes[k] == i)
291 reduced(j++) = mid(i);
virtual double max_step_size(const TVector &x0, const TVector &x1) override
virtual void init_lagging(const TVector &x)
virtual void hessian(const TVector &x, THessian &hessian) override
virtual bool is_step_collision_free(const TVector &x0, const TVector &x1)
std::vector< std::shared_ptr< Form > > forms_
virtual void post_step(const polysolve::nonlinear::PostStepData &data) override
virtual void update_lagging(const TVector &x, const int iter_num)
virtual bool is_step_valid(const TVector &x0, const TVector &x1) override
virtual double value(const TVector &x) override
virtual void solution_changed(const TVector &new_x) override
virtual void gradient(const TVector &x, TVector &gradv) override
virtual void line_search_begin(const TVector &x0, const TVector &x1) override
const int full_size_
Size of the full problem.
void line_search_begin(const TVector &x0, const TVector &x1) override
void setup_constrain_nodes()
virtual bool is_step_valid(const TVector &x0, const TVector &x1) override
int reduced_size_
Size of the reduced problem.
virtual void post_step(const polysolve::nonlinear::PostStepData &data) override
virtual TVector full_to_reduced_grad(const TVector &full) const
NLProblem(const int full_size, const std::vector< std::shared_ptr< Form > > &forms, const std::vector< std::shared_ptr< AugmentedLagrangianForm > > &penalty_forms)
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)
virtual void gradient(const TVector &x, TVector &gradv) override
void init_lagging(const TVector &x) override
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
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_
virtual double value(const TVector &x) override
virtual double max_step_size(const TVector &x0, const TVector &x1) override
std::shared_ptr< utils::PeriodicBoundary > periodic_bc_
virtual void hessian(const TVector &x, THessian &hessian) override
std::vector< int > constraint_nodes_
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
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
void full_to_reduced_matrix(const int full_size, const int reduced_size, const std::vector< int > &removed_vars, const StiffnessMatrix &full, StiffnessMatrix &reduced)
Map a full size matrix to a reduced one by dropping rows and columns.