PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
time_int::Integrator Class Reference

#include <integrator.h>

Collaboration diagram for time_int::Integrator:

Public Member Functions

template<typename Model >
void integrate (Model &model)
 
template<typename Model >
void step (Model &model)
 

Detailed Description

Explicit integrator. The model is passed in; this class runs CD or Verlet using the model's named methods (IC, BCs, forces, output, checkStop) and ModelData kinematics accessors. It does not include PeriDEMModel.

Definition at line 34 of file integrator.h.

Member Function Documentation

◆ integrate()

template<typename Model >
void time_int::Integrator::integrate ( Model &  model)
inline

Definition at line 37 of file integrator.h.

37 {
38 if (model.currentStep() == 0) {
39 model.applyInitialCondition();
40 if (model.performOutput())
41 model.output();
42 }
43
44 model.setCurrentDt(model.timeStep());
45 model.applyDisplacementBC();
46 model.computeForces();
48
49 while (model.currentStep() < model.numTimeSteps()) {
50 model.log(std::format("{}: Time step: {}, time: {:8.6f}, steps completed = {}%\n",
51 model.d_name, model.currentStep(), model.d_time,
52 float(model.currentStep()) * 100. / model.numTimeSteps()),
53 2, model.d_n % model.d_infoN == 0, 3);
54
55 const auto t0 = std::chrono::steady_clock::now();
56 step(model);
57 const auto dt_ms = util::methods::timeDiff(t0, std::chrono::steady_clock::now());
58 model.appendKeyData("integrate_compute_time", dt_ms, true);
59 model.log(std::format(" Integration time (ms) = {}\n", dt_ms),
60 2, model.d_n % model.d_infoN == 0, 3);
61
62 if (model.shouldOutput())
63 model.output();
64 model.checkStop();
65 }
66
67 model.log(std::format(
68 "{}: Total compute time information (s) \n"
69 " {:22s} = {:8.2f} \n"
70 " {:22s} = {:8.2f} \n"
71 " {:22s} = {:8.2f} \n"
72 " {:22s} = {:8.2f} \n"
73 " {:22s} = {:8.2f} \n"
74 " {:22s} = {:8.2f} \n"
75 " {:22s} = {:8.2f} \n"
76 " {:22s} = {:8.0f} \n",
77 model.d_name,
78 "Time integration", model.getKeyData("integrate_compute_time") * 1.e-6,
79 "Peridynamics force", model.getKeyData("pd_compute_time") * 1.e-6,
80 "Contact force", model.getKeyData("contact_compute_time") * 1.e-6,
81 "Search tree update", model.getKeyData("tree_compute_time") * 1.e-6,
82 "External force", model.getKeyData("extf_compute_time") * 1.e-6,
83 "MPI ghost exchange", model.getKeyData("mpi_exchange_time") * 1.e-6,
84 "Contact neigh update",
85 model.getKeyData("contact_neigh_update_time") * 1.e-6,
86 "MPI ghost grains", model.getKeyData("mpi_ghost_grain_count")));
87 }
void step(Model &model)
Definition integrator.h:90
void applyRigidBodyConstraint(data::ModelData &data)
float timeDiff(std::chrono::steady_clock::time_point begin, std::chrono::steady_clock::time_point end, std::string unit="microseconds")
Returns difference between two times.
Definition vecMethods.h:304

References time_int::applyRigidBodyConstraint(), step(), and util::methods::timeDiff().

Referenced by PeriDEMModel::integrate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ step()

template<typename Model >
void time_int::Integrator::step ( Model &  model)
inline

Definition at line 90 of file integrator.h.

90 {
91 const auto &scheme = model.timeDiscretization();
92 model.setCurrentDt(model.timeStep());
93 if (scheme == "central_difference") {
95 model.advanceTime();
96 model.applyDisplacementBC();
97 model.computeForces();
99 } else if (scheme == "velocity_verlet") {
101 model.advanceTime();
102 model.applyDisplacementBC();
103 model.computeForces();
106 } else {
107 throw std::runtime_error("Unknown time discretization: " + scheme);
108 }
109 }
void updateVerletHalfKickAndDrift(data::ModelData &data)
void updateCentralDifference(data::ModelData &data)
void updateVerletSecondKick(data::ModelData &data)

References time_int::applyRigidBodyConstraint(), time_int::updateCentralDifference(), time_int::updateVerletHalfKickAndDrift(), and time_int::updateVerletSecondKick().

Referenced by integrate(), and PeriDEMModel::integrateStep().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: