11#include <PeriDEMConfig.h>
29int main(
int argc,
char *argv[]) {
34 util::io::print(std::format(
"Initialized MPI. MPI size = {}, MPI rank = {}\n", mpiSize, mpiRank));
41 std::cout <<
"Syntax to run PeriDEM: PeriDEM -i <input file> -nThreads <number of threads>" << std::endl;
42 std::cout <<
"Example: PeriDEM -i input.json -nThreads 4" << std::endl;
46 unsigned int nThreads;
49 nThreads = std::thread::hardware_concurrency();
50 util::io::print(std::format(
"Running test with default number of threads = {}\n", nThreads));
57 std::cout <<
"PeriDEM"
58 <<
" (Version " << MAJOR_VERSION <<
"." << MINOR_VERSION <<
"."
59 << UPDATE_VERSION <<
")" << std::endl;
62 auto begin = steady_clock::now();
68 if (!std::filesystem::exists(filename)) {
69 throw std::runtime_error(
70 std::format(
"Input file {} does not exist.", filename));
72 std::ifstream f(filename);
73 auto j = json::parse(f);
74 auto deck = std::make_shared<inp::Input>(j);
76 if (deck->isPeriDEM()) {
80 std::cout <<
"PeriDEM model not found in input file.\n";
82 }
catch (
const std::exception &e) {
83 std::cerr <<
"PeriDEM error: " << e.what() << std::endl;
89 auto end = steady_clock::now();
91 std::cout <<
"Total simulation time (s) = "
int main(int argc, char *argv[])
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.