37#include <fmt/format.h>
42#include <taskflow/taskflow/taskflow.hpp>
43#include <taskflow/taskflow/algorithm/for_each.hpp>
73 log(
" Compute forces \n", 2, dbg_condition, 3);
76 auto t1 = steady_clock::now();
78 tf::Taskflow taskflow;
80 taskflow.for_each_index(
81 (std::size_t) 0,
d_x.size(), (std::size_t) 1,
82 [
this](std::size_t i) { this->d_f[i] = util::Point(); }
85 executor.run(taskflow).get();
89 t1 = steady_clock::now();
96 t1 = steady_clock::now();
104 log(fmt::format(
" Avg time (ms): \n"
107 "peridynamics force",
size_t(
getKeyData(
"avg_peridynamics_force_time")),
109 2, dbg_condition, 3);
115 log(fmt::format(
" {:50s} = {:8d} \n",
116 "Force reset time (ms)",
117 size_t(force_reset_time)
119 2, dbg_condition, 3);
121 log(fmt::format(
" {:50s} = {:8d} \n",
122 "External force time (ms)",
125 2, dbg_condition, 3);
127 log(fmt::format(
" {:50s} = {:8d} \n",
128 "Peridynamics force time (ms)",
131 2, dbg_condition, 3);
137int main(
int argc,
char *argv[]) {
140 std::cout <<
"Peridynamics (PeriDEM)"
148 std::cout <<
"Syntax to run the app: ./Peridynamics -i <input file> -nThreads <number of threads>";
149 std::cout <<
"Example: ./Peridynamics -i input.yaml -nThreads 2";
153 unsigned int nThreads;
157 util::io::print(fmt::format(
"Running Peridynamics with number of threads = {}\n", nThreads));
163 std::string filename;
167 filename =
"./example/input_1.yaml";
168 util::io::print(fmt::format(
"Running Peridynamics with example input file = {}\n", filename));
172 auto begin = steady_clock::now();
178 if (deck->isPeriDEM()) {
180 deck->getModelDeck()->d_populateElementNodeConnectivity =
true;
188 auto end = steady_clock::now();
190 std::cout <<
"Total simulation time (s) = "
size_t const MINOR_VERSION
size_t const UPDATE_VERSION
size_t const MAJOR_VERSION
A class for discrete element particle simulation with peridynamic model
virtual void computeExternalForces()
Computes external/boundary condition forces.
DEMModel(inp::Input *deck, std::string modelName="DEMModel")
Constructor.
virtual void computePeridynamicForces()
Computes peridynamic forces.
void log(std::ostringstream &oss, int priority=0, bool check_condition=true, int override_priority=-1, bool screen_out=false)
Prints message if any of these two conditions are true.
virtual void run(inp::Input *deck)
Main driver to simulate.
double getKeyData(std::string key, bool issue_err=false)
Get data for a key.
size_t d_infoN
Print log step interval.
size_t d_n
Current time step.
std::vector< util::Point > d_x
Current positions of the nodes.
void appendKeyData(std::string key, double data, bool issue_err=false)
Append value to data associated with key.
Main model class to simulate peridynamics deformation of single particle.
Model(inp::Input *deck)
Constructor.
void computeForces() override
Compute forces.
Namespace to define peridynamics app for single particle deformation.
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
void log(std::ostringstream &oss, bool screen_out=false, int printMpiRank=print_default_mpi_rank)
Global method to log the message.
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.
unsigned int getNThreads()
Get number of threads to be used by taskflow.
void initNThreads(unsigned int nThreads=std::thread::hardware_concurrency())
Initializes MpiStatus struct.