PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
Integrator.h
Go to the documentation of this file.
1
8
9#ifndef PBAT_SIM_ALGORITHM_NEWTON_INTEGRATOR_H
10#define PBAT_SIM_ALGORITHM_NEWTON_INTEGRATOR_H
11
12#include "Config.h"
13#include "pbat/Aliases.h"
15#include "pbat/io/Archive.h"
19#include "pbat/sim/contact/MultibodyTetrahedralMeshSystem.h"
21
22#ifdef PBAT_USE_SUITESPARSE
23 #include <Eigen/CholmodSupport>
24#else
25 #include <Eigen/SparseCholesky>
26#endif // PBAT_USE_SUITESPARSE
27#include <memory>
28#include <optional>
29#include <vector>
30
32
37{
38 public:
39 static auto constexpr kDims = 3;
40 static auto constexpr kOrder = 1;
41
43 using IndexType = Index;
47 kDims,
50 IndexType>;
52 Eigen::SparseMatrix<ScalarType, Eigen::ColMajor, IndexType>;
53#ifdef PBAT_USE_SUITESPARSE
54 using DecompositionType =
55 Eigen::CholmodDecomposition<HessianMatrixType, Eigen::Upper>;
57#else
59 Eigen::SimplicialLDLT<HessianMatrixType, Eigen::Upper>;
60#endif // PBAT_USE_SUITESPARSE
65 Integrator(Integrator const& other);
70 Integrator(Integrator&& other) noexcept = default;
76 Integrator& operator=(Integrator const& other);
82 Integrator& operator=(Integrator&& other) noexcept = default;
88 Integrator(Config config, MeshSystemType meshSystem, ElastoDynamicsType elastoDynamics);
93 void Step(std::optional<io::Archive> archive = std::nullopt);
98 [[maybe_unused]] auto GetElastoDynamics() const -> ElastoDynamicsType const&
99 {
100 return mElastoDynamics;
101 }
102
106 [[maybe_unused]] auto GetElastoDynamics() -> ElastoDynamicsType& { return mElastoDynamics; }
111 [[maybe_unused]] auto GetMeshSystem() const -> MeshSystemType const& { return mMeshes; }
116 [[maybe_unused]] auto GetMeshSystem() -> MeshSystemType& { return mMeshes; }
121 [[maybe_unused]] auto GetConfig() const -> Config const& { return mConfig; }
126 [[maybe_unused]] auto GetConfig() -> Config& { return mConfig; }
127
128 protected:
132 void AssembleHessian(ScalarType bt2);
136 void ApplyConfig();
137
138 private:
139 Config mConfig;
141 mMeshes;
142 ElastoDynamicsType mElastoDynamics;
145 std::vector<Eigen::Triplet<ScalarType, IndexType>>
146 mTriplets;
147 std::unique_ptr<DecompositionType> mInverseHessian;
148 HessianMatrixType mHessian;
149 Eigen::Vector<ScalarType, Eigen::Dynamic> mGrad;
150};
151
152} // namespace pbat::sim::algorithm::newton
153
154#endif // PBAT_SIM_ALGORITHM_NEWTON_INTEGRATOR_H
(De)serializer
Header file for the Newton integrator's configuration.
Header file for the Finite Element Elasto-Dynamics module.
Header file for line search algorithms.
Stable Neo-Hookean smith2018snh hyperelastic energy.
Tetrahedron finite element.
static auto constexpr kOrder
Shape function order.
Definition Integrator.h:40
Index IndexType
Integer index type.
Definition Integrator.h:43
Integrator(Integrator &&other) noexcept=default
Move constructor.
contact::MultibodyTetrahedralMeshSystem< IndexType > MeshSystemType
Mesh system type.
Definition Integrator.h:44
Integrator & operator=(Integrator const &other)
Copy assignment operator.
Definition Integrator.cpp:20
auto GetConfig() const -> Config const &
Get the Config object.
Definition Integrator.h:121
auto GetElastoDynamics() const -> ElastoDynamicsType const &
Get the Elasto Dynamics object.
Definition Integrator.h:98
auto GetMeshSystem() const -> MeshSystemType const &
Get the Mesh System object.
Definition Integrator.h:111
auto GetMeshSystem() -> MeshSystemType &
Get the Mesh System object.
Definition Integrator.h:116
Eigen::SimplicialLDLT< HessianMatrixType, Eigen::Upper > DecompositionType
Hessian decomposition type.
Definition Integrator.h:58
Eigen::SparseMatrix< ScalarType, Eigen::ColMajor, IndexType > HessianMatrixType
Hessian matrix type.
Definition Integrator.h:51
void ApplyConfig()
Apply the current configuration to the integrator.
Definition Integrator.cpp:226
dynamics::FemElastoDynamics< fem::Tetrahedron< 1 >, kDims, physics::StableNeoHookeanEnergy< kDims >, ScalarType, IndexType > ElastoDynamicsType
Elasto-dynamics type.
Definition Integrator.h:45
void AssembleHessian(ScalarType bt2)
Assemble the Hessian matrix.
Definition Integrator.cpp:138
auto GetConfig() -> Config &
Get the Config object.
Definition Integrator.h:126
void Step(std::optional< io::Archive > archive=std::nullopt)
Perform a single time step of the Newton integrator.
Definition Integrator.cpp:49
auto GetElastoDynamics() -> ElastoDynamicsType &
Get the Elasto Dynamics object.
Definition Integrator.h:106
Integrator(Integrator const &other)
Copy constructor.
Definition Integrator.cpp:7
static auto constexpr kDims
Number of spatial dimensions.
Definition Integrator.h:39
Integrator & operator=(Integrator &&other) noexcept=default
Move assignment operator.
Scalar ScalarType
Floating point scalar type.
Definition Integrator.h:42
Header file for Newton's method for optimization.
typename detail::Tetrahedron< Order > Tetrahedron
Tetrahedron finite element.
Definition Tetrahedron.h:38
Namespace for Newton simulation algorithms.
Definition Config.cpp:8
std::ptrdiff_t Index
Index type.
Definition Aliases.h:17
double Scalar
Scalar type.
Definition Aliases.h:18
Newton's method for optimization.
Definition Newton.h:27
Definition StableNeoHookeanEnergy.h:23
Newton integrator configuration.
Definition Config.h:25
Multibody Tetrahedral Mesh System.
Definition MultibodyTetrahedralMeshSystem.h:26
Finite Element Elasto-Dynamics initial value problem with Dirichlet boundary conditions using BDF (ba...
Definition FemElastoDynamics.h:54