PolyFEM
Loading...
Searching...
No Matches
ViscousDamping.hpp
Go to the documentation of this file.
1#pragma once
2
4
5// non linear NeoHookean material model
6namespace polyfem
7{
8 namespace assembler
9 {
11 {
12 public:
17
18 std::string name() const override { return "ViscousDamping"; }
19 std::map<std::string, ParamFunc> parameters() const override { return std::map<std::string, ParamFunc>(); }
20
21 ViscousDamping() = default;
22
23 // energy, gradient, and hessian used in newton method
24 double compute_energy(const NonLinearAssemblerData &data) const override;
25 virtual Eigen::MatrixXd assemble_hessian(const NonLinearAssemblerData &data) const override;
26 virtual Eigen::VectorXd assemble_gradient(const NonLinearAssemblerData &data) const override;
27
28 // sets material params
29 void add_multimaterial(const int index, const json &params, const Units &units) override;
30 void set_params(const double psi, const double phi)
31 {
32 damping_params_[0] = psi;
33 damping_params_[1] = phi;
34 }
35
37 const Eigen::MatrixXd &prev_grad_u_i,
38 Eigen::MatrixXd &stress,
39 Eigen::MatrixXd &result) const override;
40
42 const Eigen::MatrixXd &prev_grad_u_i,
43 Eigen::MatrixXd &result) const override;
44
45 static void compute_dstress_dpsi_dphi(const OptAssemblerData &data,
46 const Eigen::MatrixXd &prev_grad_u_i,
47 Eigen::MatrixXd &dstress_dpsi,
48 Eigen::MatrixXd &dstress_dphi);
49
50 double get_psi() const { return damping_params_[0]; }
51 double get_phi() const { return damping_params_[1]; }
52
53 bool is_valid() const { return (damping_params_[0] > 0) && (damping_params_[1] > 0); }
54
56
57 protected:
58 // material parameters controlling shear and bulk damping
59 // double psi_ = 0, phi_ = 0;
61
62 void compute_stress_aux(const Eigen::MatrixXd &F, const Eigen::MatrixXd &dFdt, Eigen::MatrixXd &dRdF, Eigen::MatrixXd &dRdFdot) const;
63 void compute_stress_grad_aux(const Eigen::MatrixXd &F, const Eigen::MatrixXd &dFdt, Eigen::MatrixXd &d2RdF2, Eigen::MatrixXd &d2RdFdFdot, Eigen::MatrixXd &d2RdFdot2) const;
64 };
65
67 {
68 public:
73
74 // energy, gradient, and hessian used in newton method
75 Eigen::MatrixXd assemble_hessian(const NonLinearAssemblerData &data) const override;
76 Eigen::VectorXd assemble_gradient(const NonLinearAssemblerData &data) const override;
77 };
78 } // namespace assembler
79} // namespace polyfem
double assemble_energy(const bool is_volume, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev) const override
virtual double compute_energy(const NonLinearAssemblerData &data) const =0
void assemble_gradient(const bool is_volume, const int n_basis, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev, Eigen::MatrixXd &rhs) const override
void assemble_hessian(const bool is_volume, const int n_basis, const bool project_to_psd, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &gbases, const AssemblyValsCache &cache, const double t, const double dt, const Eigen::MatrixXd &displacement, const Eigen::MatrixXd &displacement_prev, utils::MatrixCache &mat_cache, StiffnessMatrix &grad) const override
virtual Eigen::VectorXd assemble_gradient(const NonLinearAssemblerData &data) const override
void compute_stress_aux(const Eigen::MatrixXd &F, const Eigen::MatrixXd &dFdt, Eigen::MatrixXd &dRdF, Eigen::MatrixXd &dRdFdot) const
double compute_energy(const NonLinearAssemblerData &data) const override
static void compute_dstress_dpsi_dphi(const OptAssemblerData &data, const Eigen::MatrixXd &prev_grad_u_i, Eigen::MatrixXd &dstress_dpsi, Eigen::MatrixXd &dstress_dphi)
std::map< std::string, ParamFunc > parameters() const override
const DampingParameters & damping_params() const
std::string name() const override
void compute_stress_grad_aux(const Eigen::MatrixXd &F, const Eigen::MatrixXd &dFdt, Eigen::MatrixXd &d2RdF2, Eigen::MatrixXd &d2RdFdFdot, Eigen::MatrixXd &d2RdFdot2) const
virtual Eigen::MatrixXd assemble_hessian(const NonLinearAssemblerData &data) const override
void add_multimaterial(const int index, const json &params, const Units &units) override
void set_params(const double psi, const double phi)
void compute_stress_grad(const OptAssemblerData &data, const Eigen::MatrixXd &prev_grad_u_i, Eigen::MatrixXd &stress, Eigen::MatrixXd &result) const override
void compute_stress_prev_grad(const OptAssemblerData &data, const Eigen::MatrixXd &prev_grad_u_i, Eigen::MatrixXd &result) const override
Eigen::VectorXd assemble_gradient(const NonLinearAssemblerData &data) const override
Eigen::MatrixXd assemble_hessian(const NonLinearAssemblerData &data) const override
nlohmann::json json
Definition Common.hpp:9
std::array< double, 2 > DampingParameters