26 #include "imstkDynamicalModel.h" 27 #include "imstkVectorizedState.h" 28 #include "imstkNonLinearSystem.h" 29 #include "imstkLogger.h" 34 class ReducedStVKForceModel;
35 class StVKReducedInternalForces;
41 class InternalForceModel;
49 std::string m_cubicPolynomialFilename;
50 std::string m_modesFileName;
53 double m_dampingMassCoefficient = 0.1;
54 double m_dampingStiffnessCoefficient = 0.01;
55 double m_dampingLaplacianCoefficient = 0.0;
56 double m_deformationCompliance = 1.0;
57 double m_gravity = 9.81;
59 int m_numberOfThreads = 4;
81 void configure(
const std::string& configFileName);
82 void configure(std::shared_ptr<ReducedStVKConfig> config = std::make_shared<ReducedStVKConfig>());
87 bool initialize()
override;
92 void setForceModelConfiguration(std::shared_ptr<ReducedStVKConfig> config);
93 std::shared_ptr<ReducedStVKConfig> getForceModelConfiguration()
const;
99 void setInternalForceModel(std::shared_ptr<vega::StVKReducedInternalForces> fm);
100 std::shared_ptr<imstk::InternalForceModel> getInternalForceModel()
const;
105 void setTimeIntegrator(std::shared_ptr<TimeIntegrator> timeIntegrator);
106 std::shared_ptr<TimeIntegrator> getTimeIntegrator()
const;
111 void loadInitialStates();
116 bool initializeForceModel();
121 bool initializeMassMatrix();
126 bool initializeDampingMatrix();
131 bool initializeTangentStiffness();
136 bool initializeGravityForce();
141 bool initializeExplicitExternalForces();
146 static void initializeEigenMatrixFromStdVector(
const std::vector<double>& v,
173 void updateDampingMatrix();
179 void updateMassMatrix();
184 void applyBoundaryConditions(
Matrixd& M,
const bool withCompliance =
false)
const;
185 void applyBoundaryConditions(Vectord& x)
const;
190 void updatePhysicsGeometry()
override;
195 void updateBodyStates(
const Vectord& solution,
const StateUpdateType updateType);
196 void updateBodyIntermediateStates(
const Vectord& solution,
const StateUpdateType updateType);
201 void updateBodyPreviousStates();
207 NonLinearSystem<Matrixd>::VectorFunctionType getFunction();
212 NonLinearSystem<Matrixd>::UpdateFunctionType getUpdateFunction();
213 NonLinearSystem<Matrixd>::UpdatePrevStateFunctionType getUpdatePrevStateFunction();
219 NonLinearSystem<Matrixd>::MatrixFunctionType getFunctionGradient();
224 Vectord& getContactForce();
239 m_updateType = updateType;
251 return m_fixedNodeIds;
257 virtual void setTimeStep(
const double timeStep);
262 virtual double getTimeStep()
const;
267 void setFixedSizeTimeStepping();
274 LOG(WARNING) <<
"Boundary conditions are not allowed to change";
275 m_implementFixedBC =
true;
277 void disableFixedBC()
280 m_implementFixedBC =
false;
282 bool isFixedBCImplemented()
const 284 return m_implementFixedBC;
290 void prolongate(
const Vectord& uReduced, Vectord& u)
const;
300 void project(
const Vectord& u, Vectord& uReduced)
const;
305 void readModalMatrix(
const std::string& fname);
307 std::shared_ptr<TaskNode> getSolveNode()
const {
return m_solveNode; }
309 std::shared_ptr<SolverBase> getSolver()
const {
return m_solver; }
310 void setSolver(std::shared_ptr<SolverBase> solver) { this->m_solver = solver; }
316 void initGraphEdges(std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink)
override;
319 std::shared_ptr<SolverBase> m_solver =
nullptr;
320 std::shared_ptr<vega::StVKReducedInternalForces> m_internalForceModel;
322 std::shared_ptr<TimeIntegrator> m_timeIntegrator;
326 std::shared_ptr<ReducedStVKConfig> m_config;
346 Vectord m_FgravityReduced;
350 std::shared_ptr<vega::VolumetricMesh> m_vegaPhysicsMesh;
359 bool m_damped =
false;
363 bool m_implementFixedBC =
false;
365 std::shared_ptr<kinematicState> m_initialStateReduced;
366 std::shared_ptr<kinematicState> m_previousStateReduced;
367 std::shared_ptr<kinematicState> m_currentStateReduced;
370 std::shared_ptr<TaskNode> m_solveNode =
nullptr;
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrixd
A dynamic size matrix of doubles.
Matrixd m_Keff
Tangent (derivative of internal force w.r.t displacements) stiffness matrix
Matrixd m_K
Damping coefficient matrix
std::vector< std::size_t > & getFixNodeIds()
Returns the unknown vectors.
std::shared_ptr< NonLinearSystem< Matrixd > > m_nonLinearSystem
Time integrator
std::shared_ptr< vega::ReducedStVKForceModel > m_forceModel
Mathematical model for intenal forces
std::shared_ptr< vega::ModalMatrix > m_modalMatrix
Nonlinear system resulting from TI and force model
std::vector< std::size_t > m_fixedNodeIds
Vega Laplacian damping matrix
Matrixd m_M
Matrices typical to a elastodynamics and 2nd order analogous systems.
Vectord m_FexplicitExternal
Vector of gravity forces
Vectord m_qSol
Vector of explicitly defined external forces
void setUpdateType(const StateUpdateType &updateType)
Set/Get the update type.
std::vector< double > m_massMatrix
Mesh used for Physics
This class stores the state of the unknown field variable in vectorized form.
Vectord & getUnknownVec()
Returns the unknown vectors.
Vectord m_qSolReduced
Vector of internal forces
Vectord m_Feff
Vector to maintain solution at each iteration of nonlinear solver
Vectord m_Finternal
Vector of effective forces
Vectord m_FexplicitExternalReduced
Vector of gravity forces
std::vector< double > m_stiffnessMatrix
Vega mass matrix
Vectord m_Fgravity
Vector of contact forces
StateUpdateType
Type of the update of the state of the body.
Vectord m_FcontactReduced
Vector to maintain solution at each iteration of nonlinear solver
std::vector< double > m_dampingMatrix
Vega Tangent stiffness matrix
Base class for mathematical model of the physics governing the dynamic object.
size_t m_numDOFReduced
Vector of explicitly defined external forces
void enableFixedBC()
Set the fixed BC implementation state.
Vectord m_Fcontact
integrator)