PolyFEM
Loading...
Searching...
No Matches
AMIPSForm.hpp
Go to the documentation of this file.
1#pragma once
2
7#include <memory>
8#include <utility>
9
10namespace polyfem
11{
12 namespace legacy
13 {
14 class State;
15 }
16 namespace assembler
17 {
18 class Assembler;
19 }
20} // namespace polyfem
21
22namespace polyfem::solver
23{
27 {
28 public:
29 MinJacobianForm(const VariableToSimulationGroup &variable_to_simulation, std::shared_ptr<const legacy::State> state)
30 : AdjointForm(variable_to_simulation),
31 state_(std::move(state))
32 {
33 }
34
35 virtual std::string name() const override { return "min-jacobian"; }
36
37 double value_unweighted(const Eigen::VectorXd &x) const override;
38 void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
39
40 private:
41 std::shared_ptr<const legacy::State> state_;
42 };
43
44 class AMIPSForm : public AdjointForm
45 {
46 public:
47 AMIPSForm(const VariableToSimulationGroup &variable_to_simulation, std::shared_ptr<const legacy::State> state);
48
49 virtual std::string name() const override { return "AMIPS"; }
50
51 double value_unweighted(const Eigen::VectorXd &x) const override;
52 void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
53 bool is_step_valid(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override;
54
55 private:
56 Eigen::VectorXd get_updated_mesh_nodes(const Eigen::VectorXd &x) const
57 {
58 Eigen::VectorXd X = X_rest;
60 return X;
61 }
62
63 std::shared_ptr<const legacy::State> state_;
64
65 Eigen::VectorXd X_rest;
66 Eigen::MatrixXi F;
67 std::vector<polyfem::basis::ElementBases> init_geom_bases_;
69 // amips_energy_ is actually owned exclusively by this class.
70 std::shared_ptr<assembler::Assembler> amips_energy_;
71 };
72} // namespace polyfem::solver
int x
Caches basis evaluation and geometric mapping at every element.
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
virtual std::string name() const override
Definition AMIPSForm.hpp:49
bool is_step_valid(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override
Determine if a step from solution x0 to solution x1 is allowed.
Eigen::VectorXd get_updated_mesh_nodes(const Eigen::VectorXd &x) const
Definition AMIPSForm.hpp:56
std::vector< polyfem::basis::ElementBases > init_geom_bases_
Definition AMIPSForm.hpp:67
void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
std::shared_ptr< assembler::Assembler > amips_energy_
Definition AMIPSForm.hpp:70
assembler::AssemblyValsCache init_ass_vals_cache_
Definition AMIPSForm.hpp:68
std::shared_ptr< const legacy::State > state_
Definition AMIPSForm.hpp:63
const VariableToSimulationGroup variable_to_simulations_
Compute the minimum jacobian of the mesh elements, not differentiable polygon elements not supported!
Definition AMIPSForm.hpp:27
virtual std::string name() const override
Definition AMIPSForm.hpp:35
void compute_partial_gradient(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
MinJacobianForm(const VariableToSimulationGroup &variable_to_simulation, std::shared_ptr< const legacy::State > state)
Definition AMIPSForm.hpp:29
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
Definition AMIPSForm.cpp:81
std::shared_ptr< const legacy::State > state_
Definition AMIPSForm.hpp:41
void compute_state_variable(ParameterType type, const legacy::State &target, const Eigen::VectorXd &x, Eigen::VectorXd &state_variable) const
polyfem::legacy::State State
Definition Remesher.hpp:19