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  twoparticle_demo::Model
 Main model class to handle demo two-particle test implementation. Goal is to show that it is easy to specialize the DEMModel class for different scenarios. More...
 

Namespaces

namespace  twoparticle_demo
 Namespace to define demo app for two-particle tests.
 

Functions

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

Function Documentation

◆ main()

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

Definition at line 375 of file main.cpp.

375 {
376
377 // print program version
378 std::cout << "TwoParticle_Demo (PeriDEM)"
379 << " (Version " << MAJOR_VERSION << "." << MINOR_VERSION << "."
380 << UPDATE_VERSION << ")" << std::endl << std::flush;
381
382 util::io::InputParser input(argc, argv);
383
384 if (input.cmdOptionExists("-h")) {
385 // print help
386 std::cout << "Syntax to run the app: ./TwoParticle_Demo -i <input file> -nThreads <number of threads>";
387 std::cout << "Example: ./TwoParticle_Demo -i input.yaml -nThreads 2";
388 }
389
390 // read input arguments
391 unsigned int nThreads;
392 if (input.cmdOptionExists("-nThreads")) nThreads = std::stoi(input.getCmdOption("-nThreads"));
393 else {
394 nThreads = 2;
395 util::io::print(fmt::format("Running TwoParticle_Demo with number of threads = {}\n", nThreads));
396 }
397 // set number of threads
399 util::io::print(fmt::format("Number of threads = {}\n", util::parallel::getNThreads()));
400
401 std::string filename;
402 if (input.cmdOptionExists("-i"))
403 filename = input.getCmdOption("-i");
404 else {
405 filename = "./example/input_0.yaml";
406 util::io::print(fmt::format("Running TwoParticle_Demo with example input file = {}\n", filename));
407 }
408
409 // current time
410 auto begin = steady_clock::now();
411
412 // create deck
413 auto *deck = new inp::Input(filename);
414
415 // check which model to run
416 if (deck->isPeriDEM()) {
417 // ensure two variables in the deck are set
418 deck->getModelDeck()->d_populateElementNodeConnectivity = true;
419
420 // simulate model
421 twoparticle_demo::Model dem(deck);
422 dem.run(deck);
423 }
424
425 // get time elapsed
426 auto end = steady_clock::now();
427
428 std::cout << "Total simulation time (s) = "
429 << util::methods::timeDiff(begin, end, "seconds")
430 << std::endl;
431}
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 handle demo two-particle test implementation. Goal is to show that it is easy to ...
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(), twoparticle_demo::Model::run(), util::methods::timeDiff(), and UPDATE_VERSION.

Here is the call graph for this function: