PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
testPeriDEMLib.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2024 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#include "testPeriDEMLib.h"
12
13// PeriDEM includes
14#include "inp/input.h" // Input class
15#include "model/dem/demModel.h" // Model class
17#include "util/methods.h"
18#include "util/io.h"
19#include <fmt/format.h>
20#include <fstream>
21#include <string>
22
23std::string test::testPeriDEM(std::string filepath) {
24
25 // current time
26 auto begin = steady_clock::now();
27
28 // read input data
29 auto *deck = new inp::Input(filepath + "/input.yaml");
30 deck->getOutputDeck()->d_path = filepath + "/out/";
31 std::cout << "filepath = " << deck->getOutputDeck()->d_path << "\n";
32
33 // check which model to run
34 if (deck->isPeriDEM()) {
35 model::DEMModel dem(deck);
36 dem.run(deck);
37 } else {
38 std::cout << "PeriDEM model not found in input file.\n";
39 return "PeriDEM not found in input file";
40 }
41
42 // get time elapsed
43 auto end = steady_clock::now();
44 double elapsed_secs = util::methods::timeDiff(begin, end, "seconds");
45
46 std::cout << "Total simulation time = " << elapsed_secs
47 << " (seconds)" << std::endl;
48
49 return "pass";
50}
A class to read input file.
Definition input.h:61
A class for discrete element particle simulation with peridynamic model
Definition demModel.h:32
virtual void run(inp::Input *deck)
Main driver to simulate.
Definition demModel.cpp:68
std::string testPeriDEM(std::string filepath)
Tests PeriDEM model class.
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