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

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

#include <bcDeck.h>

Collaboration diagram for inp::BCDeck:

Public Member Functions

 BCDeck (const json &j=json({}))
 Constructor.
 
 BCDeck (size_t nForceSets, size_t nDispSets=0, size_t nICSets=0, bool gravityActive=false, util::Point gravity=util::Point())
 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 (const json &given=json::object())
 Returns example JSON object for ModelDeck configuration.
 

Data Fields

std::vector< inp::BCBaseDeck > d_forceDeck
 Force loading deck.
 
std::vector< inp::BCBaseDeck > d_dispDeck
 Displacement loading deck.
 
std::vector< inp::BCBaseDeck > d_icDeck
 Initial condition deck.
 
bool d_gravityActive
 Gravity loading value.
 
util::Point d_gravity
 Gravity loading value.
 

Detailed Description

Structure to read and store test-related input data.

Definition at line 27 of file bcDeck.h.

Constructor & Destructor Documentation

◆ BCDeck() [1/2]

inp::BCDeck::BCDeck ( const json &  j = json({}))
inline

Constructor.

Definition at line 48 of file bcDeck.h.

48 {}))
49 : d_gravityActive(false) {
50 readFromJson(j);
51 };
void readFromJson(const json &j)
Reads from json object.
Definition bcDeck.h:111
bool d_gravityActive
Gravity loading value.
Definition bcDeck.h:39

◆ BCDeck() [2/2]

inp::BCDeck::BCDeck ( size_t  nForceSets,
size_t  nDispSets = 0,
size_t  nICSets = 0,
bool  gravityActive = false,
util::Point  gravity = util::Point() 
)
inline

Constructor.

Definition at line 56 of file bcDeck.h.

58 : d_gravityActive(gravityActive), d_gravity(gravity) {
59
60 d_forceDeck.resize(nForceSets);
61 d_dispDeck.resize(nDispSets);
62 d_icDeck.resize(nICSets);
63 };
std::vector< inp::BCBaseDeck > d_icDeck
Initial condition deck.
Definition bcDeck.h:36
std::vector< inp::BCBaseDeck > d_dispDeck
Displacement loading deck.
Definition bcDeck.h:33
std::vector< inp::BCBaseDeck > d_forceDeck
Force loading deck.
Definition bcDeck.h:30
util::Point d_gravity
Gravity loading value.
Definition bcDeck.h:42

References d_dispDeck, d_forceDeck, and d_icDeck.

Member Function Documentation

◆ getExampleJson()

static json inp::BCDeck::getExampleJson ( const json &  given = json::object())
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Returns the block with the given fields set

Each of the three kinds of set is asked for by its count. Naming Gravity is what turns gravity on; it is a force on every particle and so sits beside the force sets rather than replacing them.

Parameters
givenForce_BC_Sets, Displacement_BC_Sets, IC_Sets and Gravity
Returns
JSON object for this deck

Definition at line 79 of file bcDeck.h.

79 {
80 checkNames(given, {"Force_BC_Sets", "Displacement_BC_Sets", "IC_Sets",
81 "Gravity"});
82
83 const auto nForceSets = given.value("Force_BC_Sets", size_t(0));
84 const auto nDispSets = given.value("Displacement_BC_Sets", size_t(0));
85 const auto nICSets = given.value("IC_Sets", size_t(0));
86 const bool gravityActive = given.find("Gravity") != given.end();
87
88 if (nForceSets + nDispSets + nICSets == 0 and !gravityActive)
89 return json({});
90
91 auto j = json({});
92
93 if (gravityActive)
94 j["Force_BC"]["Gravity"] = given.at("Gravity");
95
96 if (nForceSets > 0)
97 j["Force_BC"]["Sets"] = nForceSets;
98
99 if (nDispSets > 0)
100 j["Displacement_BC"] = {{"Sets", nDispSets}};
101
102 if (nICSets > 0)
103 j["IC"] = {{"Sets", nICSets}};
104
105 return j;
106 }
nlohmann::ordered_json json
void checkNames(const json &given, const std::vector< std::string > &names)
Rejects a key that is not among those named.
Definition deckField.h:379

References inp::checkNames().

Referenced by anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), getInputJson(), and anonymous_namespace{testDeckRoundTrip.cpp}::testBCDeck().

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

◆ print()

void inp::BCDeck::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 200 of file bcDeck.h.

200{ 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 bcDeck.h:162

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::BCDeck::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 162 of file bcDeck.h.

162 {
163 auto tabS = util::io::getTabS(nt);
164 std::ostringstream oss;
165 oss << tabS << "------- BCDeck --------" << std::endl << std::endl;
166 oss << tabS << "Force loading deck size = " << d_forceDeck.size() << std::endl;
167 oss << tabS << "Force loading data:" << std::endl;
168 for (size_t i = 0; i < d_forceDeck.size(); i++) {
169 oss << tabS << "Force data for set = " << i << std::endl;
170 oss << d_forceDeck[i].printStr(nt + 1, lvl);
171 }
172
173 oss << tabS << "Displacement loading deck size = " << d_dispDeck.size() << std::endl;
174 oss << tabS << "Displacement loading data:" << std::endl;
175 for (size_t i = 0; i < d_dispDeck.size(); i++) {
176 oss << tabS << "Displacement data for set = " << i << std::endl;
177 oss << d_dispDeck[i].printStr(nt + 1, lvl);
178 }
179
180 oss << tabS << "Initial condition deck size = " << d_icDeck.size() << std::endl;
181 oss << tabS << "Initial condition data:" << std::endl;
182 for (size_t i = 0; i < d_icDeck.size(); i++) {
183 oss << tabS << "Initial condition for set = " << i << std::endl;
184 oss << d_icDeck[i].printStr(nt + 1, lvl);
185 }
186
187 oss << tabS << "Gravity loading active = " << d_gravityActive << std::endl;
188 oss << tabS << "Gravity loading value = " << d_gravity.printStr(0, 0) << std::endl;
189 oss << tabS << std::endl;
190
191 return oss.str();
192 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition point.h:94

References d_dispDeck, d_forceDeck, d_gravity, d_gravityActive, d_icDeck, util::io::getTabS(), and util::Point::printStr().

Referenced by print().

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

◆ readFromJson()

void inp::BCDeck::readFromJson ( const json &  j)
inline

Reads from json object.

Definition at line 111 of file bcDeck.h.

111 {
112
113 if (j.empty())
114 return;
115
116 // gravity
117 if (j.find("Force_BC") != j.end()) {
118 if (j.at("Force_BC").find("Gravity") != j.at("Force_BC").end()) {
119 d_gravityActive = true;
120 d_gravity = util::Point(j.at("Force_BC").value("Gravity", std::vector<double>({0., 0., 0.})));
121 }
122 }
123
124 // process Force_BC
125 d_forceDeck.clear();
126 d_dispDeck.clear();
127 d_icDeck.clear();
128 for (auto tag : std::vector<std::string>({"Force_BC", "Displacement_BC", "IC"})) {
129 if (j.find(tag) == j.end())
130 continue;
131
132 auto nSets = j.at(tag).value("Sets", 0);
133
134 for (size_t i = 0; i < nSets; i++) {
135
136 auto set = j.at(tag).at("Set_" + std::to_string(i + 1));
137
138 if (tag == "Force_BC") {
139 inp::BCBaseDeck bcData;
140 bcData.readFromJson(set, tag);
141 d_forceDeck.push_back(bcData);
142 } else if (tag == "Displacement_BC") {
143 inp::BCBaseDeck bcData;
144 bcData.readFromJson(set, tag);
145 d_dispDeck.push_back(bcData);
146 } else if (tag == "IC") {
147 inp::BCBaseDeck icData;
148 icData.readFromJson(set, tag);
149 d_icDeck.push_back(icData);
150 }
151 } // loop over sets
152 } // loop over tag
153 }
User-input data for particle neighbor search.
Definition bcBaseDeck.h:26
void readFromJson(const json &j, std::string type)
Reads from json object.
Definition bcBaseDeck.h:294
A structure to represent 3d vectors.
Definition point.h:30

References d_dispDeck, d_forceDeck, d_gravity, d_gravityActive, d_icDeck, and inp::BCBaseDeck::readFromJson().

Here is the call graph for this function:

Field Documentation

◆ d_dispDeck

std::vector<inp::BCBaseDeck> inp::BCDeck::d_dispDeck

Displacement loading deck.

Definition at line 33 of file bcDeck.h.

Referenced by BCDeck(), printStr(), and readFromJson().

◆ d_forceDeck

std::vector<inp::BCBaseDeck> inp::BCDeck::d_forceDeck

Force loading deck.

Definition at line 30 of file bcDeck.h.

Referenced by BCDeck(), printStr(), and readFromJson().

◆ d_gravity

util::Point inp::BCDeck::d_gravity

Gravity loading value.

Definition at line 42 of file bcDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_gravityActive

bool inp::BCDeck::d_gravityActive

Gravity loading value.

Definition at line 39 of file bcDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_icDeck

std::vector<inp::BCBaseDeck> inp::BCDeck::d_icDeck

Initial condition deck.

Definition at line 36 of file bcDeck.h.

Referenced by BCDeck(), printStr(), and readFromJson().


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