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 (size_t nForceSets=0, size_t nDispSets=0, size_t nICSets=0, bool gravityActive=false, util::Point gravity=util::Point())
 Returns example JSON object for ModelDeck configuration.
 

Data Fields

std::vector< inp::BCBaseDeckd_forceDeck
 Force loading deck.
 
std::vector< inp::BCBaseDeckd_dispDeck
 Displacement loading deck.
 
std::vector< inp::BCBaseDeckd_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:105
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 ( size_t  nForceSets = 0,
size_t  nDispSets = 0,
size_t  nICSets = 0,
bool  gravityActive = false,
util::Point  gravity = util::Point() 
)
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 69 of file bcDeck.h.

70 {
71
72 if (nForceSets + nDispSets + nICSets == 0 and !gravityActive)
73 return json({});
74
75 auto j = json({});
76
77 if (gravityActive) j["Force_BC"] = {{"Gravity", gravity.toVec()}};
78
79 if (nForceSets > 0) {
80 j["Force_BC"] = {{"Sets", nForceSets}};
81 // add empty objects for each set
82 // for (size_t i = 0; i < nForceSets; i++) j.at("Force_BC")["Set_" + std::to_string(i + 1)] = json({});
83 }
84
85 if (nDispSets > 0) {
86 j["Displacement_BC"] = {{"Sets", nDispSets}};
87 // add empty objects for each set
88 // for (size_t i = 0; i < nDispSets; i++)
89 // j.at("Displacement_BC") = json{{"Set_" + std::to_string(i + 1), ""}};
90 }
91
92 if (nICSets > 0) {
93 j["IC"] = {{"Sets", nICSets}};
94 // add empty objects for each set
95 // for (size_t i = 0; i < nICSets; i++)
96 // j.at("IC") = json{{"Set_" + std::to_string(i + 1), ""}};
97 }
98
99 return j;
100 }
nlohmann::ordered_json json
std::vector< double > toVec() const
Returns coordinate in stl form.
Definition point.h:118

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(), and getInputJson().

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 194 of file bcDeck.h.

194{ 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:156

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 156 of file bcDeck.h.

156 {
157 auto tabS = util::io::getTabS(nt);
158 std::ostringstream oss;
159 oss << tabS << "------- BCDeck --------" << std::endl << std::endl;
160 oss << tabS << "Force loading deck size = " << d_forceDeck.size() << std::endl;
161 oss << tabS << "Force loading data:" << std::endl;
162 for (size_t i = 0; i < d_forceDeck.size(); i++) {
163 oss << tabS << "Force data for set = " << i << std::endl;
164 oss << d_forceDeck[i].printStr(nt + 1, lvl);
165 }
166
167 oss << tabS << "Displacement loading deck size = " << d_dispDeck.size() << std::endl;
168 oss << tabS << "Displacement loading data:" << std::endl;
169 for (size_t i = 0; i < d_dispDeck.size(); i++) {
170 oss << tabS << "Displacement data for set = " << i << std::endl;
171 oss << d_dispDeck[i].printStr(nt + 1, lvl);
172 }
173
174 oss << tabS << "Initial condition deck size = " << d_icDeck.size() << std::endl;
175 oss << tabS << "Initial condition data:" << std::endl;
176 for (size_t i = 0; i < d_icDeck.size(); i++) {
177 oss << tabS << "Initial condition for set = " << i << std::endl;
178 oss << d_icDeck[i].printStr(nt + 1, lvl);
179 }
180
181 oss << tabS << "Gravity loading active = " << d_gravityActive << std::endl;
182 oss << tabS << "Gravity loading value = " << d_gravity.printStr(0, 0) << std::endl;
183 oss << tabS << std::endl;
184
185 return oss.str();
186 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39
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 105 of file bcDeck.h.

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