Loading [MathJax]/extensions/tex2jax.js
PolyFEM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeriodicContactForm.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ContactForm.hpp"
4
5namespace polyfem
6{
7 class State;
8
9 namespace solver {
10 class PeriodicMeshToMesh;
11 }
12}
13
14namespace polyfem::solver
15{
19 {
20 public:
24 PeriodicContactForm(const ipc::CollisionMesh &periodic_collision_mesh,
25 const Eigen::VectorXi &tiled_to_single,
26 const double dhat,
27 const double avg_mass,
28 const bool use_area_weighting,
30 const bool use_physical_barrier,
32 const bool is_time_dependent,
33 const bool enable_shape_derivatives,
34 const ipc::BroadPhaseMethod broad_phase_method,
35 const double ccd_tolerance,
36 const int ccd_max_iterations);
37
38 void init(const Eigen::VectorXd &x) override;
39
40 void force_periodic_shape_derivative(const State& state, const PeriodicMeshToMesh &periodic_mesh_map, const Eigen::VectorXd &periodic_mesh_representation, const ipc::NormalCollisions &contact_set, const Eigen::VectorXd &solution, const Eigen::VectorXd &adjoint_sol, Eigen::VectorXd &term);
41
42 Eigen::VectorXd single_to_tiled(const Eigen::VectorXd &x) const;
43 Eigen::VectorXd tiled_to_single_grad(const Eigen::VectorXd &grad) const;
44
45 protected:
49 double value_unweighted(const Eigen::VectorXd &x) const override;
50
54 void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
55
59 void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override;
60
61 public:
65 void update_quantities(const double t, const Eigen::VectorXd &x) override;
66
71 double max_step_size(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override;
72
76 void line_search_begin(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override;
77
80 void solution_changed(const Eigen::VectorXd &new_x) override;
81
85 void post_step(const polysolve::nonlinear::PostStepData &data) override;
86
89 bool is_step_collision_free(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override;
90
93 void update_barrier_stiffness(const Eigen::VectorXd &x, const Eigen::MatrixXd &grad_energy) override;
94
95 private:
96 void update_projection() const;
97
98 const Eigen::VectorXi tiled_to_single_;
99 const int n_single_dof_;
101 };
102}
int x
main class that contains the polyfem solver and all its state
Definition State.hpp:79
Form representing the contact potential and forces.
bool use_physical_barrier() const
Get use_physical_barrier.
bool use_area_weighting() const
Get use_area_weighting.
bool use_adaptive_barrier_stiffness() const
Get use_adaptive_barrier_stiffness.
bool use_improved_max_operator() const
Get use_improved_max_operator.
Form representing the contact potential and forces on a periodic mesh This form has a different input...
void post_step(const polysolve::nonlinear::PostStepData &data) override
Update fields after a step in the optimization.
Eigen::VectorXd single_to_tiled(const Eigen::VectorXd &x) const
void solution_changed(const Eigen::VectorXd &new_x) override
Update cached fields upon a change in the solution.
bool is_step_collision_free(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override
Checks if the step is collision free.
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the contact barrier potential value.
void line_search_begin(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) override
Initialize variables used during the line search.
void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override
Compute the second derivative of the value wrt x.
double max_step_size(const Eigen::VectorXd &x0, const Eigen::VectorXd &x1) const override
Determine the maximum step size allowable between the current and next solution.
void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
Compute the first derivative of the value wrt x.
void init(const Eigen::VectorXd &x) override
Initialize the form.
void force_periodic_shape_derivative(const State &state, const PeriodicMeshToMesh &periodic_mesh_map, const Eigen::VectorXd &periodic_mesh_representation, const ipc::NormalCollisions &contact_set, const Eigen::VectorXd &solution, const Eigen::VectorXd &adjoint_sol, Eigen::VectorXd &term)
Eigen::VectorXd tiled_to_single_grad(const Eigen::VectorXd &grad) const
void update_quantities(const double t, const Eigen::VectorXd &x) override
Update time-dependent fields.
void update_barrier_stiffness(const Eigen::VectorXd &x, const Eigen::MatrixXd &grad_energy) override
Update the barrier stiffness based on the current elasticity energy.
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:22