16 namespace time_integrator
19 const Eigen::MatrixXd &x_prevs,
20 const Eigen::MatrixXd &v_prevs,
21 const Eigen::MatrixXd &a_prevs,
33 for (
int i = 0; i < n; i++)
46 assert(!state_path.empty());
48 const int ndof =
x_prev().size();
49 const int prev_steps =
x_prevs().size();
51 Eigen::MatrixXd tmp(ndof, prev_steps);
53 for (
int i = 0; i < prev_steps; ++i)
57 for (
int i = 0; i < prev_steps; ++i)
61 for (
int i = 0; i < prev_steps; ++i)
68 const std::string type = params.is_object() ? params[
"type"] : params;
70 std::shared_ptr<ImplicitTimeIntegrator> integrator;
71 if (type ==
"implict_euler" || type ==
"ImplicitEuler")
73 integrator = std::make_shared<ImplicitEuler>();
75 else if (type ==
"implict_newmark" || type ==
"ImplicitNewmark")
77 integrator = std::make_shared<ImplicitNewmark>();
81 integrator = std::make_shared<BDF>(type ==
"BDF" ? 1 : std::stoi(type.substr(3)));
85 logger().error(
"Unknown time integrator ({})", type);
86 throw std::runtime_error(fmt::format(
"Unknown time integrator ({})", type));
89 if (params.is_object())
90 integrator->set_parameters(params);
97 static const std::vector<std::string> names = {
98 std::string(
"ImplicitEuler"),
99 std::string(
"ImplicitNewmark"),
const std::deque< Eigen::VectorXd > & v_prevs() const
Get the (relevant) history of previous velocity value.
std::deque< Eigen::VectorXd > x_prevs_
Store the necessary previous values of the solution for single or multi-step integration.
static std::shared_ptr< ImplicitTimeIntegrator > construct_time_integrator(const json ¶ms)
Factory method for constructing implicit time integrators from the name of the integrator.
const Eigen::VectorXd & x_prev() const
Get the most recent previous solution value.
const std::deque< Eigen::VectorXd > & a_prevs() const
Get the (relevant) history of previous acceleration value.
virtual int max_steps() const
Get the maximum number of steps to use for integration.
const double & dt() const
Access the time step size.
std::deque< Eigen::VectorXd > a_prevs_
Store the necessary previous values of the acceleration for single or multi-step integration.
virtual void init(const Eigen::MatrixXd &x_prevs, const Eigen::MatrixXd &v_prevs, const Eigen::MatrixXd &a_prevs, double dt)
Initialize the time integrator with the previous values for , , and .
const std::deque< Eigen::VectorXd > & x_prevs() const
Get the (relevant) history of previous solution value.
std::deque< Eigen::VectorXd > v_prevs_
Store the necessary previous values of the velocity for single or multi-step integration.
static const std::vector< std::string > & get_time_integrator_names()
Get a vector of the names of possible ImplicitTimeIntegrators.
virtual void save_state(const std::string &state_path) const
Save the values of , , and .
double dt_
Time step size.
bool write_matrix(const std::string &path, const Mat &mat)
Writes a matrix to a file. Determines the file format based on the path's extension.
bool startswith(const std::string &str, const std::string &prefix)
spdlog::logger & logger()
Retrieves the current logger.