3#include <polysolve/nonlinear/Problem.hpp>
4#include <wmtk/Types.hpp>
6namespace wmtk::optimization {
11 using typename polysolve::nonlinear::Problem::Scalar;
12 using typename polysolve::nonlinear::Problem::THessian;
13 using typename polysolve::nonlinear::Problem::TVector;
24 TVector initial_position()
const;
26 double value(
const TVector& x)
override;
27 void gradient(
const TVector& x, TVector& gradv)
override;
28 void hessian(
const TVector& x, THessian& hessian)
override
30 log_and_throw_error(
"Sparse functions do not exist, use dense solver");
32 void hessian(
const TVector& x, MatrixXd& hessian)
override;
34 void solution_changed(
const TVector& new_x)
override {}
37 std::vector<std::array<double, 4>> m_cells;
43 using typename polysolve::nonlinear::Problem::Scalar;
44 using typename polysolve::nonlinear::Problem::THessian;
45 using typename polysolve::nonlinear::Problem::TVector;
59 const std::array<Vector2d, 3>& pts,
62 const double weight = 1);
64 TVector initial_position()
const;
66 double value(
const TVector& x)
override;
67 void gradient(
const TVector& x, TVector& gradv)
override;
68 void hessian(
const TVector& x, THessian& hessian)
override
70 log_and_throw_error(
"Sparse functions do not exist, use dense solver");
72 void hessian(
const TVector& x, MatrixXd& hessian)
override;
74 void solution_changed(
const TVector& new_x)
override {}
77 local_mass_and_stiffness(
const std::array<Vector2d, 3>& pts,
double& M, Vector3d& L_w);
80 uniform_mass_and_stiffness(
const std::array<Vector2d, 3>& pts,
double& M, Vector3d& L_w);
117 using typename polysolve::nonlinear::Problem::Scalar;
118 using typename polysolve::nonlinear::Problem::THessian;
119 using typename polysolve::nonlinear::Problem::TVector;
136 const double weight = 1);
138 TVector initial_position()
const;
140 double value(
const TVector& x)
override;
141 void gradient(
const TVector& x, TVector& gradv)
override;
142 void hessian(
const TVector& x, THessian& hessian)
override
144 log_and_throw_error(
"Sparse functions do not exist, use dense solver");
146 void hessian(
const TVector& x, MatrixXd& hessian)
override;
148 void solution_changed(
const TVector& new_x)
override {}
155 const MatrixXi& tris,
156 Eigen::SparseMatrix<double>& M,
157 Eigen::SparseMatrix<double>& L_w);
174 const Eigen::SparseMatrix<double>& M_glob,
175 const Eigen::SparseMatrix<double>& L_w_glob,
186 const Eigen::SparseMatrix<double>& L_w_glob,
187 std::vector<size_t>& adj);
189 static void uniform_mass_and_stiffness(
const MatrixXd& pts,
double& M, VectorXd& L_w);
Definition DirichletEnergy.hpp:41
Vector3d m_LTML_row
Definition DirichletEnergy.hpp:109
Vector3d m_L_w_row
Definition DirichletEnergy.hpp:97
std::array< Vector2d, 3 > m_pts
Definition DirichletEnergy.hpp:87
Definition DirichletEnergy.hpp:115
static void adjacency_from_stiffness(const size_t vid, const Eigen::SparseMatrix< double > &L_w_glob, std::vector< size_t > &adj)
Get the adjacency for vid from the global stiffness matrix.
Definition DirichletEnergy.cpp:235
VectorXd m_LTML_row
Definition DirichletEnergy.hpp:217
static void extract_local_mass_and_stiffness(const size_t vid, const Eigen::SparseMatrix< double > &M_glob, const Eigen::SparseMatrix< double > &L_w_glob, double &M_loc, VectorXd &L_w_loc)
Extract the mass and stiffness for local optimization from the global mass and stiffness matrices.
Definition DirichletEnergy.cpp:202
VectorXd m_L_w_row
Definition DirichletEnergy.hpp:205
MatrixXd m_pts
Definition DirichletEnergy.hpp:196
static void global_mass_and_stiffness(const MatrixXd &pts, const MatrixXi &tris, Eigen::SparseMatrix< double > &M, Eigen::SparseMatrix< double > &L_w)
Construct mass and stiffness for all vertices using IGL.
Definition DirichletEnergy.cpp:192
Definition DirichletEnergy.hpp:9