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

User-input data for particle neighbor search. More...

#include <bcBaseDeck.h>

Collaboration diagram for inp::BCBaseDeck:

Public Member Functions

 BCBaseDeck (const json &j=json({}), std::string type="Force_BC")
 Constructor.
 
 BCBaseDeck (bool isRegionActive, geom::GeomData regionGeomData=geom::GeomData(), std::vector< size_t > pList=std::vector< size_t >(), std::vector< size_t > pNotList=std::vector< size_t >(), std::string timeFnType="", std::vector< double > timeFnParams=std::vector< double >(), std::string spatialFnType="", std::vector< double > spatialFnParams=std::vector< double >(), std::vector< size_t > direction=std::vector< size_t >(), bool isDisplacementZero=false)
 Constructor.
 
void readFromJson (const json &j, std::string type)
 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 type="Foce_BC", bool isRegionActive=false, geom::GeomData regionGeomData=geom::GeomData(), std::vector< size_t > pList=std::vector< size_t >(), std::vector< size_t > pNotList=std::vector< size_t >(), std::string timeFnType="", std::vector< double > timeFnParams=std::vector< double >(), std::string spatialFnType="", std::vector< double > spatialFnParams=std::vector< double >(), std::vector< size_t > direction=std::vector< size_t >(), bool isDisplacementZero=false, std::string icType="", std::vector< double > icVec=std::vector< double >())
 Returns example JSON object for ModelDeck configuration.
 

Data Fields

std::string d_type
 Method for applying force. E.g., Force_BC, Displacement_BC, IC.
 
std::string d_selectionType
 Method for applying force e.g.
 
bool d_isRegionActive
 Flag that indicates if region-based application of boundary condition is active. So cases of 'region', 'region_with_include_list', 'region_with_exclude_list', and 'region_with_include_list_with_exclude_list' will have region-based application of boundary condition.
 
geom::GeomData d_regionGeomData
 Region geometry (if any)
 
std::vector< size_t > d_pList
 List of particles (if any)
 
std::vector< size_t > d_pNotList
 List of particles to not include (if any)
 
std::string d_timeFnType
 Name of the formula with respect to time.
 
std::string d_spatialFnType
 Name of the formula of with respect to spatial coordinate.
 
std::vector< size_t > d_direction
 List of dofs on which this bc will be applied.
 
std::vector< double > d_timeFnParams
 List of parameters for function wrt time.
 
std::vector< double > d_spatialFnParams
 List of parameters for function wrt spatial coordinate.
 
bool d_isDisplacementZero
 Specify if this bc corresponds to zero displacement condition.
 
std::string d_icType
 Type.
 
util::Point d_icVec
 Initial velocity vector.
 

Detailed Description

User-input data for particle neighbor search.

Definition at line 25 of file bcBaseDeck.h.

Constructor & Destructor Documentation

◆ BCBaseDeck() [1/2]

inp::BCBaseDeck::BCBaseDeck ( const json j = json({}),
std::string  type = "Force_BC" 
)
inline

Constructor.

Definition at line 109 of file bcBaseDeck.h.

109 {}), std::string type = "Force_BC") :
110 d_type(type), d_isRegionActive(false), d_isDisplacementZero(false) {
111 readFromJson(j, type);
112 };
void readFromJson(const json &j, std::string type)
Reads from json object.
Definition bcBaseDeck.h:217
bool d_isDisplacementZero
Specify if this bc corresponds to zero displacement condition.
Definition bcBaseDeck.h:98
bool d_isRegionActive
Flag that indicates if region-based application of boundary condition is active. So cases of 'region'...
Definition bcBaseDeck.h:45
std::string d_type
Method for applying force. E.g., Force_BC, Displacement_BC, IC.
Definition bcBaseDeck.h:27

◆ BCBaseDeck() [2/2]

inp::BCBaseDeck::BCBaseDeck ( bool  isRegionActive,
geom::GeomData  regionGeomData = geom::GeomData(),
std::vector< size_t >  pList = std::vector<size_t>(),
std::vector< size_t >  pNotList = std::vector<size_t>(),
std::string  timeFnType = "",
std::vector< double >  timeFnParams = std::vector<double>(),
std::string  spatialFnType = "",
std::vector< double >  spatialFnParams = std::vector<double>(),
std::vector< size_t >  direction = std::vector<size_t>(),
bool  isDisplacementZero = false 
)
inline

Constructor.

Definition at line 117 of file bcBaseDeck.h.

127 : d_isRegionActive(isRegionActive), d_regionGeomData(regionGeomData),
128 d_pList(pList), d_pNotList(pNotList), d_timeFnType(timeFnType), d_timeFnParams(timeFnParams),
129 d_spatialFnType(spatialFnType), d_spatialFnParams(spatialFnParams),
130 d_direction(direction), d_isDisplacementZero(isDisplacementZero) {
131
132 // fix selection type
133 if (d_isRegionActive) {
134 d_selectionType = "region";
135 d_isRegionActive = true;
136 if (d_pList.size() > 0)
137 d_selectionType += "_with_include_list";
138
139 if (d_pNotList.size() > 0)
140 d_selectionType += "_with_exclude_list";
141 } else {
142 if (d_pList.size() > 0)
143 d_selectionType = "particle";
144 }
145
146 if (d_isRegionActive) {
147 // create a geometry object based on the data
149 }
150 };
void createGeomObject(const std::string &geom_type, const std::vector< double > &params, const std::vector< std::string > &vec_type, const std::vector< std::string > &vec_flag, std::shared_ptr< geom::GeomObject > &obj, bool perform_check)
std::vector< size_t > d_pList
List of particles (if any)
Definition bcBaseDeck.h:51
std::vector< size_t > d_pNotList
List of particles to not include (if any)
Definition bcBaseDeck.h:54
geom::GeomData d_regionGeomData
Region geometry (if any)
Definition bcBaseDeck.h:48
std::vector< double > d_timeFnParams
List of parameters for function wrt time.
Definition bcBaseDeck.h:92
std::vector< double > d_spatialFnParams
List of parameters for function wrt spatial coordinate.
Definition bcBaseDeck.h:95
std::vector< size_t > d_direction
List of dofs on which this bc will be applied.
Definition bcBaseDeck.h:89
std::string d_selectionType
Method for applying force e.g.
Definition bcBaseDeck.h:38
std::string d_timeFnType
Name of the formula with respect to time.
Definition bcBaseDeck.h:67
std::string d_spatialFnType
Name of the formula of with respect to spatial coordinate.
Definition bcBaseDeck.h:80

References geom::createGeomObject(), d_isRegionActive, d_pList, d_pNotList, d_regionGeomData, and d_selectionType.

Here is the call graph for this function:

Member Function Documentation

◆ getExampleJson()

static json inp::BCBaseDeck::getExampleJson ( std::string  type = "Foce_BC",
bool  isRegionActive = false,
geom::GeomData  regionGeomData = geom::GeomData(),
std::vector< size_t >  pList = std::vector<size_t>(),
std::vector< size_t >  pNotList = std::vector<size_t>(),
std::string  timeFnType = "",
std::vector< double >  timeFnParams = std::vector<double>(),
std::string  spatialFnType = "",
std::vector< double >  spatialFnParams = std::vector<double>(),
std::vector< size_t >  direction = std::vector<size_t>(),
bool  isDisplacementZero = false,
std::string  icType = "",
std::vector< double >  icVec = std::vector<double>() 
)
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 157 of file bcBaseDeck.h.

169 {
170
171 auto j = json({});
172
173 if (isRegionActive) {
174 // get json object for geometry
175 auto j_geom = json({});
176 geom::writeGeometry(j_geom, regionGeomData);
177 j["Region"] = {"Geometry", j_geom};
178 }
179
180 if (pList.size() > 0) j["Particle_List"] = pList;
181
182 if (pNotList.size() > 0) j["Particle_Exclude_List"] = pNotList;
183
184 if (timeFnType != "") {
185 j["Time_Function"] = {"Type", timeFnType};
186 if (timeFnParams.size() > 0)
187 j["Time_Function"] = {"Parameters", timeFnParams};
188 }
189
190 if (spatialFnType != "") {
191 j["Spatial_Function"] = {"Type", spatialFnType};
192 if (spatialFnParams.size() > 0)
193 j["Spatial_Function"] = {"Parameters", spatialFnParams};
194 }
195
196 if (type != "IC") {
197 if (direction.size() > 0)
198 j["Direction"] = direction;
199
200 if (isDisplacementZero) {
201 j["Zero_Displacement"] = true;
202 }
203 }
204
205 if (type == "IC") {
206 if (icType == "Constant_Velocity") {
207 j[icType]["Velocity_Vector"] = icVec;
208 }
209 }
210
211 return j;
212 }
nlohmann::ordered_json json
void writeGeometry(json &j, const geom::GeomData &geomData)

References geom::writeGeometry().

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

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

◆ print()

void inp::BCBaseDeck::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 324 of file bcBaseDeck.h.

324{ 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 bcBaseDeck.h:287

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::BCBaseDeck::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 287 of file bcBaseDeck.h.

287 {
288
289 auto tabS = util::io::getTabS(nt);
290 std::ostringstream oss;
291 oss << tabS << "------- BCBaseDeck --------" << std::endl << std::endl;
292 oss << tabS << "Selection type = " << d_selectionType << std::endl;
293 oss << tabS << "Is region active = " << d_isRegionActive << std::endl;
294 if (d_regionGeomData.d_geom_p != nullptr) {
295 oss << tabS << "Region geometry info: " << std::endl;
296 oss << d_regionGeomData.printStr(nt + 1, lvl);
297 }
298 if (!d_pList.empty())
299 oss << tabS << "Particle list = ["
300 << util::io::printStr<size_t>(d_pList, 0) << "]" << std::endl;
301 if (!d_pNotList.empty())
302 oss << tabS << "Particle excluded list = ["
303 << util::io::printStr<size_t>(d_pNotList, 0) << "]" << std::endl;
304 oss << tabS << "Time function type = " << d_timeFnType << std::endl;
305 oss << tabS << "Time function parameters = ["
306 << util::io::printStr<double>(d_timeFnParams, 0) << "]" << std::endl;
307 oss << tabS << "Spatial function type = " << d_spatialFnType << std::endl;
308 oss << tabS << "Spatial function parameters = ["
309 << util::io::printStr<double>(d_spatialFnParams, 0) << "]" << std::endl;
310 oss << tabS << "Direction = [" << util::io::printStr<size_t>(d_direction, 0)
311 << "]" << std::endl;
312 oss << tabS << "Is displacement zero = " << d_isDisplacementZero << std::endl;
313 oss << tabS << std::endl;
314
315 return oss.str();
316 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39
std::shared_ptr< geom::GeomObject > d_geom_p
Zone geometry.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.

References d_direction, geom::GeomData::d_geom_p, d_isDisplacementZero, d_isRegionActive, d_pList, d_pNotList, d_regionGeomData, d_selectionType, d_spatialFnParams, d_spatialFnType, d_timeFnParams, d_timeFnType, util::io::getTabS(), and geom::GeomData::printStr().

Referenced by print().

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

◆ readFromJson()

void inp::BCBaseDeck::readFromJson ( const json j,
std::string  type 
)
inline

Reads from json object.

Definition at line 217 of file bcBaseDeck.h.

217 {
218 if (j.empty())
219 return;
220
221 // fix selection type
222 if (j.find("Region") != j.end()) {
223 d_selectionType = "region";
224 d_isRegionActive = true;
225 if (j.find("Particle_List") != j.end())
226 d_selectionType += "_with_include_list";
227
228 if (j.find("Particle_Exclude_List") != j.end())
229 d_selectionType += "_with_exclude_list";
230 } else {
231 d_isRegionActive = false;
232 if (j.find("Particle_List") != j.end())
233 d_selectionType = "particle";
234 }
235
236 if (d_isRegionActive) {
237 geom::readGeometry(j.at("Region").at("Geometry"), d_regionGeomData);
238 // create a geometry object based on the data
240 }
241
242 if (j.find("Particle_List") != j.end()) d_pList = j.value("Particle_List", std::vector<size_t>());
243
244 if (j.find("Particle_Exclude_List") != j.end())
245 d_pNotList = j.value("Particle_Exclude_List", std::vector<size_t>());
246
247 if (j.find("Time_Function") != j.end()) {
248 d_timeFnType = j.at("Time_Function").value("Type", "");
249 if (j.at("Time_Function").find("Parameters") != j.at("Time_Function").end())
250 d_timeFnParams = j.at("Time_Function").value("Parameters", std::vector<double>());
251 }
252
253 if (j.find("Spatial_Function") != j.end()) {
254 d_spatialFnType = j.at("Spatial_Function").value("Type", "");
255 if (j.at("Spatial_Function").find("Parameters") != j.at("Spatial_Function").end())
256 d_spatialFnParams = j.at("Spatial_Function").value("Parameters", std::vector<double>());
257 }
258
259 if (type != "IC") {
260 if (j.find("Direction") == j.end()) {
261 throw std::runtime_error("Direction must be specified for boundary condition");
262 return;
263 }
264
265 d_direction = j.value("Direction", std::vector<size_t>());
266
267 if (j.find("Zero_Displacement") != j.end())
268 d_isDisplacementZero = j.at("Zero_Displacement");
269 }
270
271 // if it is initial condition
272 if (type == "IC") {
273 if (j.find("Constant_Velocity") != j.end()) {
274 d_icType = "Constant_Velocity";
275 d_icVec = util::Point(j.at("Constant_Velocity").value("Velocity_Vector", std::vector<double>({0., 0., 0.})));
276 }
277 }
278 }
void readGeometry(const json &j, geom::GeomData &geomData)
std::string d_icType
Type.
Definition bcBaseDeck.h:101
util::Point d_icVec
Initial velocity vector.
Definition bcBaseDeck.h:104
A structure to represent 3d vectors.
Definition point.h:30

References geom::createGeomObject(), d_direction, d_icType, d_icVec, d_isDisplacementZero, d_isRegionActive, d_pList, d_pNotList, d_regionGeomData, d_selectionType, d_spatialFnParams, d_spatialFnType, d_timeFnParams, d_timeFnType, and geom::readGeometry().

Referenced by inp::BCDeck::readFromJson().

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

Field Documentation

◆ d_direction

std::vector<size_t> inp::BCBaseDeck::d_direction

List of dofs on which this bc will be applied.

E.g. if bc is only applied on x-component, d_direction will be 1. If bc is applied on x- and y-component, d_direction will be vector with elements 1 and 2.

Definition at line 89 of file bcBaseDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_icType

std::string inp::BCBaseDeck::d_icType

Type.

Definition at line 101 of file bcBaseDeck.h.

Referenced by readFromJson().

◆ d_icVec

util::Point inp::BCBaseDeck::d_icVec

Initial velocity vector.

Definition at line 104 of file bcBaseDeck.h.

Referenced by readFromJson().

◆ d_isDisplacementZero

bool inp::BCBaseDeck::d_isDisplacementZero

Specify if this bc corresponds to zero displacement condition.

Definition at line 98 of file bcBaseDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_isRegionActive

bool inp::BCBaseDeck::d_isRegionActive

Flag that indicates if region-based application of boundary condition is active. So cases of 'region', 'region_with_include_list', 'region_with_exclude_list', and 'region_with_include_list_with_exclude_list' will have region-based application of boundary condition.

Definition at line 45 of file bcBaseDeck.h.

Referenced by BCBaseDeck(), loading::needToComputeDof(), printStr(), and readFromJson().

◆ d_pList

std::vector<size_t> inp::BCBaseDeck::d_pList

List of particles (if any)

Definition at line 51 of file bcBaseDeck.h.

Referenced by BCBaseDeck(), loading::needToComputeDof(), loading::needToProcessParticle(), printStr(), and readFromJson().

◆ d_pNotList

std::vector<size_t> inp::BCBaseDeck::d_pNotList

List of particles to not include (if any)

Definition at line 54 of file bcBaseDeck.h.

Referenced by BCBaseDeck(), loading::needToComputeDof(), loading::needToProcessParticle(), printStr(), and readFromJson().

◆ d_regionGeomData

geom::GeomData inp::BCBaseDeck::d_regionGeomData

Region geometry (if any)

Definition at line 48 of file bcBaseDeck.h.

Referenced by BCBaseDeck(), loading::needToComputeDof(), printStr(), and readFromJson().

◆ d_selectionType

std::string inp::BCBaseDeck::d_selectionType

Method for applying force e.g.

  • particle: provides global id of particle to which force should be applied
  • wall: provides global id of wall to which force should be applied
  • region: provides area within which all nodes of any particle will get this force

Definition at line 38 of file bcBaseDeck.h.

Referenced by BCBaseDeck(), loading::needToComputeDof(), loading::needToProcessParticle(), printStr(), and readFromJson().

◆ d_spatialFnParams

std::vector<double> inp::BCBaseDeck::d_spatialFnParams

List of parameters for function wrt spatial coordinate.

Definition at line 95 of file bcBaseDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_spatialFnType

std::string inp::BCBaseDeck::d_spatialFnType

Name of the formula of with respect to spatial coordinate.

List of allowed values are:

  • "" (none)
  • constant
  • hat_x
  • hat_y
  • sin
  • rotation

Definition at line 80 of file bcBaseDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_timeFnParams

std::vector<double> inp::BCBaseDeck::d_timeFnParams

List of parameters for function wrt time.

Definition at line 92 of file bcBaseDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_timeFnType

std::string inp::BCBaseDeck::d_timeFnType

Name of the formula with respect to time.

List of allowed values are:

  • "" (none)
  • constant
  • linear
  • linear_step
  • linear_slow_fast
  • rotation

Definition at line 67 of file bcBaseDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_type

std::string inp::BCBaseDeck::d_type

Method for applying force. E.g., Force_BC, Displacement_BC, IC.

Definition at line 27 of file bcBaseDeck.h.


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