PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
inp::TestDeck Struct Reference

Structure to read and store test-related input data. More...

#include <testDeck.h>

Collaboration diagram for inp::TestDeck:

Public Member Functions

 TestDeck (const json &j=json({}))
 Constructor.
 
 TestDeck (std::string testName, size_t particleIdCompressiveTest=0, size_t particleForceDirectionCompressiveTest=0)
 Constructor.
 
void readFromJson (const json &j)
 Reads from json object.
 
std::string printStr (int nt=0, int lvl=0) const
 Returns the string containing printable information about the object.
 
void print (int nt=0, int lvl=0) const
 Prints the information about the object.
 

Static Public Member Functions

static json getExampleJson (std::string testName="", size_t particleIdCompressiveTest=0, size_t particleForceDirectionCompressiveTest=0)
 Returns example JSON object for ModelDeck configuration.
 

Data Fields

std::string d_testName
 Specify test name (if any)
 
size_t d_particleIdCompressiveTest
 if it is a compressive test, specify wall id and direction
 
size_t d_particleForceDirectionCompressiveTest
 if it is a compressive test, specify force direction on wall
 

Detailed Description

Structure to read and store test-related input data.

Definition at line 25 of file testDeck.h.

Constructor & Destructor Documentation

◆ TestDeck() [1/2]

inp::TestDeck::TestDeck ( const json j = json({}))
inline

Constructor.

Definition at line 39 of file testDeck.h.

39 {}))
41 readFromJson(j);
42 };
size_t d_particleForceDirectionCompressiveTest
if it is a compressive test, specify force direction on wall
Definition testDeck.h:33
void readFromJson(const json &j)
Reads from json object.
Definition testDeck.h:76
std::string d_testName
Specify test name (if any)
Definition testDeck.h:27
size_t d_particleIdCompressiveTest
if it is a compressive test, specify wall id and direction
Definition testDeck.h:30

◆ TestDeck() [2/2]

inp::TestDeck::TestDeck ( std::string  testName,
size_t  particleIdCompressiveTest = 0,
size_t  particleForceDirectionCompressiveTest = 0 
)
inline

Constructor.

Definition at line 47 of file testDeck.h.

49 : d_testName(testName),
50 d_particleIdCompressiveTest(particleIdCompressiveTest),
51 d_particleForceDirectionCompressiveTest(particleForceDirectionCompressiveTest) {};

Member Function Documentation

◆ getExampleJson()

static json inp::TestDeck::getExampleJson ( std::string  testName = "",
size_t  particleIdCompressiveTest = 0,
size_t  particleForceDirectionCompressiveTest = 0 
)
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 57 of file testDeck.h.

58 {
59
60 if (testName == "")
61 return json({});
62
63 auto j = json({"Test_Name", testName});
64
65 if (testName == "Compressive_Test") {
66 j["Compressive_Test"] = json{{"Wall_Id", particleIdCompressiveTest},
67 {"Wall_Force_Direction", particleForceDirectionCompressiveTest}};
68 }
69
70 return j;
71 }
nlohmann::ordered_json json

◆ print()

void inp::TestDeck::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 118 of file testDeck.h.

118{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition testDeck.h:99

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::TestDeck::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 99 of file testDeck.h.

99 {
100 auto tabS = util::io::getTabS(nt);
101 std::ostringstream oss;
102 oss << tabS << "------- TestDeck --------" << std::endl << std::endl;
103 oss << tabS << "Test name = " << d_testName << std::endl;
104 oss << tabS << "Particle id for compressive test = " << d_particleIdCompressiveTest << std::endl;
105 oss << tabS << "Particle force direction for compressive test = " << d_particleForceDirectionCompressiveTest <<
106 std::endl;
107 oss << tabS << std::endl;
108
109 return oss.str();
110 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39

References d_particleForceDirectionCompressiveTest, d_particleIdCompressiveTest, d_testName, and util::io::getTabS().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFromJson()

void inp::TestDeck::readFromJson ( const json j)
inline

Reads from json object.

Definition at line 76 of file testDeck.h.

76 {
77 if (j.empty())
78 return;
79
80 d_testName = j.value("Test_Name", "");
81 const bool compressive =
82 d_testName == "Compressive_Test" || d_testName == "compressive_test";
83 if (compressive) {
84 if (j.find("Compressive_Test") == j.end())
85 throw std::runtime_error("Compressive test requires Compressive_Test section");
86
87 d_particleIdCompressiveTest = j.at("Compressive_Test").value("Wall_Id", 0);
88 d_particleForceDirectionCompressiveTest = j.at("Compressive_Test").value("Wall_Force_Direction", 0);
89 }
90 }

References d_particleForceDirectionCompressiveTest, d_particleIdCompressiveTest, and d_testName.

Field Documentation

◆ d_particleForceDirectionCompressiveTest

size_t inp::TestDeck::d_particleForceDirectionCompressiveTest

if it is a compressive test, specify force direction on wall

Definition at line 33 of file testDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_particleIdCompressiveTest

size_t inp::TestDeck::d_particleIdCompressiveTest

if it is a compressive test, specify wall id and direction

Definition at line 30 of file testDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_testName

std::string inp::TestDeck::d_testName

Specify test name (if any)

Definition at line 27 of file testDeck.h.

Referenced by printStr(), and readFromJson().


The documentation for this struct was generated from the following file: