11#include <PeriDEMConfig.h>
28int main(
int argc,
char *argv[]) {
33 util::io::print(std::format(
"Initialized MPI. MPI size = {}, MPI rank = {}\n", mpiSize, mpiRank));
40 std::cout <<
"Syntax to run PeriDEM: PeriDEM -i <input file> -nThreads <number of threads>" << std::endl;
41 std::cout <<
"Example: PeriDEM -i input.json -nThreads 4" << std::endl;
45 unsigned int nThreads;
48 nThreads = std::thread::hardware_concurrency();
49 util::io::print(std::format(
"Running test with default number of threads = {}\n", nThreads));
56 std::cout <<
"PeriDEM"
57 <<
" (Version " << MAJOR_VERSION <<
"." << MINOR_VERSION <<
"."
58 << UPDATE_VERSION <<
")" << std::endl;
61 auto begin = steady_clock::now();
65 if (!std::filesystem::exists(filename)) {
66 throw std::runtime_error(std::format(
"Input file {} does not exist.", filename));
68 std::ifstream f(filename);
69 auto j = json::parse(f);
70 auto deck = std::make_shared<inp::Input>(j);
73 if (deck->isPeriDEM()) {
77 std::cout <<
"PeriDEM model not found in input file.\n";
81 auto end = steady_clock::now();
83 std::cout <<
"Total simulation time (s) = "
void run(std::shared_ptr< inp::Input > &deck)
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
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.
const MpiStatus * getMpiStatus()
Returns pointer to MpiStatus struct.
void initMpi(int argc=0, char *argv[]=nullptr)
Initializes MPI and also creates MpiStatus struct.
int mpiSize()
Get size (number) of processors.
int mpiRank()
get rank (id) of this processor
void finalizeMpi()
Call MPI_Finalize if this process initialized MPI.