PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
main.cpp File Reference
#include <PeriDEMConfig.h>
#include "model/dem/demModel.h"
#include "material/materialUtil.h"
#include "particle/baseParticle.h"
#include "util/function.h"
#include "util/geomObjects.h"
#include "util/matrix.h"
#include "util/methods.h"
#include "util/point.h"
#include "inp/pdecks/contactDeck.h"
#include "rw/reader.h"
#include "util/geom.h"
#include "util/randomDist.h"
#include "util/parallelUtil.h"
#include "inp/decks/materialDeck.h"
#include "inp/decks/modelDeck.h"
#include "inp/decks/outputDeck.h"
#include "inp/decks/restartDeck.h"
#include "rw/vtkParticleWriter.h"
#include "rw/vtkParticleReader.h"
#include "fe/elemIncludes.h"
#include "fe/meshUtil.h"
#include <fmt/format.h>
#include <fstream>
#include <iostream>
#include <random>
#include <taskflow/taskflow/taskflow.hpp>
#include <taskflow/taskflow/algorithm/for_each.hpp>
Include dependency graph for main.cpp:

Go to the source code of this file.

Data Structures

class  peridynamics::Model
 Main model class to simulate peridynamics deformation of single particle. More...
 

Namespaces

namespace  peridynamics
 Namespace to define peridynamics app for single particle deformation.
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 137 of file main.cpp.

137 {
138
139 // print program version
140 std::cout << "Peridynamics (PeriDEM)"
141 << " (Version " << MAJOR_VERSION << "." << MINOR_VERSION << "."
142 << UPDATE_VERSION << ")" << std::endl << std::flush;
143
144 util::io::InputParser input(argc, argv);
145
146 if (input.cmdOptionExists("-h")) {
147 // print help
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";
150 }
151
152 // read input arguments
153 unsigned int nThreads;
154 if (input.cmdOptionExists("-nThreads")) nThreads = std::stoi(input.getCmdOption("-nThreads"));
155 else {
156 nThreads = 2;
157 util::io::print(fmt::format("Running Peridynamics with number of threads = {}\n", nThreads));
158 }
159 // set number of threads
161 util::io::print(fmt::format("Number of threads = {}\n", util::parallel::getNThreads()));
162
163 std::string filename;
164 if (input.cmdOptionExists("-i"))
165 filename = input.getCmdOption("-i");
166 else {
167 filename = "./example/input_1.yaml";
168 util::io::print(fmt::format("Running Peridynamics with example input file = {}\n", filename));
169 }
170
171 // current time
172 auto begin = steady_clock::now();
173
174 // create deck
175 auto *deck = new inp::Input(filename);
176
177 // check which model to run
178 if (deck->isPeriDEM()) {
179 // ensure two variables in the deck are set
180 deck->getModelDeck()->d_populateElementNodeConnectivity = true;
181
182 // simulate model
183 peridynamics::Model dem(deck);
184 dem.run(deck);
185 }
186
187 // get time elapsed
188 auto end = steady_clock::now();
189
190 std::cout << "Total simulation time (s) = "
191 << util::methods::timeDiff(begin, end, "seconds")
192 << std::endl;
193}
size_t const MINOR_VERSION
size_t const UPDATE_VERSION
size_t const MAJOR_VERSION
A class to read input file.
Definition input.h:61
Main model class to simulate peridynamics deformation of single particle.
Definition main.cpp:55
Input command line argument parser.
Definition io.h:355
void print(const T &msg, int nt=print_default_tab, int printMpiRank=print_default_mpi_rank)
Prints formatted information.
Definition io.h:108
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 methods.h:304
unsigned int getNThreads()
Get number of threads to be used by taskflow.
void initNThreads(unsigned int nThreads=std::thread::hardware_concurrency())
Initializes MpiStatus struct.

References util::io::InputParser::cmdOptionExists(), util::io::InputParser::getCmdOption(), util::parallel::getNThreads(), util::parallel::initNThreads(), MAJOR_VERSION, MINOR_VERSION, util::io::print(), model::DEMModel::run(), util::methods::timeDiff(), and UPDATE_VERSION.

Here is the call graph for this function: