PolyFEM
Loading...
Searching...
No Matches
InertiaForm.cpp
Go to the documentation of this file.
1#include "InertiaForm.hpp"
2
5
6#include <cassert>
7
8namespace polyfem::solver
9{
11 const time_integrator::ImplicitTimeIntegrator &time_integrator)
12 : mass_(mass), time_integrator_(time_integrator)
13 {
14 assert(mass.size() != 0);
15 }
16
17 double InertiaForm::value_unweighted(const Eigen::VectorXd &x) const
18 {
19 const Eigen::VectorXd tmp = x - time_integrator_.x_tilde();
20 // FIXME: DBC on x tilde
21 const double prod = tmp.transpose() * mass_ * tmp;
22 const double energy = 0.5 * prod;
23 return energy;
24 }
25
26 void InertiaForm::first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const
27 {
28 gradv = mass_ * (x - time_integrator_.x_tilde());
29 }
30
31 void InertiaForm::second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const
32 {
33 hessian = mass_;
34 }
35} // namespace polyfem::solver
int x
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
Compute the first derivative of the value wrt x.
void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override
Compute the second derivative of the value wrt x.
InertiaForm(const StiffnessMatrix &mass, const time_integrator::ImplicitTimeIntegrator &time_integrator)
Construct a new Inertia Form object.
const time_integrator::ImplicitTimeIntegrator & time_integrator_
Time integrator.
const StiffnessMatrix & mass_
Mass matrix.
Implicit time integrator of a second order ODE (equivently a system of coupled first order ODEs).
virtual Eigen::VectorXd x_tilde() const =0
Compute the predicted solution to be used in the inertia term .
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:24