Loading [MathJax]/extensions/tex2jax.js
PolyFEM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ALSolver.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <polysolve/nonlinear/Solver.hpp>
6#include <polyfem/Common.hpp>
7
8#include <Eigen/Core>
9
10#include <functional>
11#include <vector>
12
13namespace polyfem::solver
14{
16 {
17 using NLSolver = polysolve::nonlinear::Solver;
18
19 public:
21 const std::vector<std::shared_ptr<AugmentedLagrangianForm>> &alagr_form,
22 const double initial_al_weight,
23 const double scaling,
24 const double max_al_weight,
25 const double eta_tol,
26 const std::function<void(const Eigen::VectorXd &)> &update_barrier_stiffness);
27 virtual ~ALSolver() = default;
28
29 void solve_al(NLProblem &nl_problem, Eigen::MatrixXd &sol,
30 std::shared_ptr<polysolve::nonlinear::Solver> nl_solver)
31 {
32 solve_al(nl_problem, sol, json{}, json{}, 1, nl_solver);
33 }
34
35 void solve_al(NLProblem &nl_problem, Eigen::MatrixXd &sol,
36 const json &nl_solver_params,
37 const json &linear_solver,
38 const double characteristic_length,
39 std::shared_ptr<polysolve::nonlinear::Solver> nl_solver = nullptr);
40
41 void solve_reduced(NLProblem &nl_problem, Eigen::MatrixXd &sol,
42 std::shared_ptr<polysolve::nonlinear::Solver> nl_solver)
43 {
44 solve_al(nl_problem, sol, json{}, json{}, 1, nl_solver);
45 }
46
47 void solve_reduced(NLProblem &nl_problem, Eigen::MatrixXd &sol,
48 const json &nl_solver_params,
49 const json &linear_solver,
50 const double characteristic_length,
51 std::shared_ptr<polysolve::nonlinear::Solver> nl_solver = nullptr);
52
53 std::function<void(const double)> post_subsolve = [](const double) {};
54
55 protected:
56 std::vector<std::shared_ptr<AugmentedLagrangianForm>> alagr_forms;
57 const double initial_al_weight;
58 const double scaling;
59 const double max_al_weight;
60 const double eta_tol;
61
62 // TODO: replace this with a member function
63 std::function<void(const Eigen::VectorXd &)> update_barrier_stiffness;
64 };
65} // namespace polyfem::solver
void solve_reduced(NLProblem &nl_problem, Eigen::MatrixXd &sol, std::shared_ptr< polysolve::nonlinear::Solver > nl_solver)
Definition ALSolver.hpp:41
const double max_al_weight
Definition ALSolver.hpp:59
std::vector< std::shared_ptr< AugmentedLagrangianForm > > alagr_forms
Definition ALSolver.hpp:56
polysolve::nonlinear::Solver NLSolver
Definition ALSolver.hpp:17
std::function< void(const Eigen::VectorXd &)> update_barrier_stiffness
Definition ALSolver.hpp:63
std::function< void(const double)> post_subsolve
Definition ALSolver.hpp:53
const double initial_al_weight
Definition ALSolver.hpp:57
virtual ~ALSolver()=default
void solve_al(NLProblem &nl_problem, Eigen::MatrixXd &sol, std::shared_ptr< polysolve::nonlinear::Solver > nl_solver)
Definition ALSolver.hpp:29
nlohmann::json json
Definition Common.hpp:9