11#ifndef INP_BCBASEDECK_H
12#define INP_BCBASEDECK_H
119 std::vector<size_t> pList = std::vector<size_t>(),
120 std::vector<size_t> pNotList = std::vector<size_t>(),
121 std::string timeFnType =
"",
122 std::vector<double> timeFnParams = std::vector<double>(),
123 std::string spatialFnType =
"",
124 std::vector<double> spatialFnParams = std::vector<double>(),
125 std::vector<size_t> direction = std::vector<size_t>(),
126 bool isDisplacementZero =
false)
158 bool isRegionActive =
false,
160 std::vector<size_t> pList = std::vector<size_t>(),
161 std::vector<size_t> pNotList = std::vector<size_t>(),
162 std::string timeFnType =
"",
163 std::vector<double> timeFnParams = std::vector<double>(),
164 std::string spatialFnType =
"",
165 std::vector<double> spatialFnParams = std::vector<double>(),
166 std::vector<size_t> direction = std::vector<size_t>(),
167 bool isDisplacementZero =
false,
168 std::string icType =
"",
169 std::vector<double> icVec = std::vector<double>()) {
173 if (isRegionActive) {
175 auto j_geom =
json({});
177 j[
"Region"] = {
"Geometry", j_geom};
180 if (pList.size() > 0) j[
"Particle_List"] = pList;
182 if (pNotList.size() > 0) j[
"Particle_Exclude_List"] = pNotList;
184 if (timeFnType !=
"") {
185 j[
"Time_Function"] = {
"Type", timeFnType};
186 if (timeFnParams.size() > 0)
187 j[
"Time_Function"] = {
"Parameters", timeFnParams};
190 if (spatialFnType !=
"") {
191 j[
"Spatial_Function"] = {
"Type", spatialFnType};
192 if (spatialFnParams.size() > 0)
193 j[
"Spatial_Function"] = {
"Parameters", spatialFnParams};
197 if (direction.size() > 0)
198 j[
"Direction"] = direction;
200 if (isDisplacementZero) {
201 j[
"Zero_Displacement"] =
true;
206 if (icType ==
"Constant_Velocity") {
207 j[icType][
"Velocity_Vector"] = icVec;
222 if (j.find(
"Region") != j.end()) {
225 if (j.find(
"Particle_List") != j.end())
228 if (j.find(
"Particle_Exclude_List") != j.end())
232 if (j.find(
"Particle_List") != j.end())
242 if (j.find(
"Particle_List") != j.end())
d_pList = j.value(
"Particle_List", std::vector<size_t>());
244 if (j.find(
"Particle_Exclude_List") != j.end())
245 d_pNotList = j.value(
"Particle_Exclude_List", std::vector<size_t>());
247 if (j.find(
"Time_Function") != j.end()) {
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>());
253 if (j.find(
"Spatial_Function") != j.end()) {
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>());
260 if (j.find(
"Direction") == j.end()) {
261 throw std::runtime_error(
"Direction must be specified for boundary condition");
265 d_direction = j.value(
"Direction", std::vector<size_t>());
267 if (j.find(
"Zero_Displacement") != j.end())
273 if (j.find(
"Constant_Velocity") != j.end()) {
275 d_icVec =
util::Point(j.at(
"Constant_Velocity").value(
"Velocity_Vector", std::vector<double>({0., 0., 0.})));
287 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
290 std::ostringstream oss;
291 oss << tabS <<
"------- BCBaseDeck --------" << std::endl << std::endl;
295 oss << tabS <<
"Region geometry info: " << std::endl;
299 oss << tabS <<
"Particle list = ["
300 << util::io::printStr<size_t>(
d_pList, 0) <<
"]" << std::endl;
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 = ["
310 oss << tabS <<
"Direction = [" << util::io::printStr<size_t>(
d_direction, 0)
313 oss << tabS << std::endl;
324 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
nlohmann::ordered_json json
void createGeomObject(const std::string &geom_type, const std::vector< double > ¶ms, const std::vector< std::string > &vec_type, const std::vector< std::string > &vec_flag, std::shared_ptr< geom::GeomObject > &obj, bool perform_check)
void readGeometry(const json &j, geom::GeomData &geomData)
void writeGeometry(json &j, const geom::GeomData &geomData)
Collection of methods and database related to input.
std::string getTabS(int nt)
Returns tab spaces of a given size.
Input data for geometrical objects.
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.
User-input data for particle neighbor search.
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.
std::vector< size_t > d_pList
List of particles (if any)
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
std::vector< size_t > d_pNotList
List of particles to not include (if any)
geom::GeomData d_regionGeomData
Region geometry (if any)
void readFromJson(const json &j, std::string type)
Reads from json object.
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.
std::vector< size_t > d_direction
List of dofs on which this bc will be applied.
std::string d_icType
Type.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
bool d_isDisplacementZero
Specify if this bc corresponds to zero displacement condition.
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.
BCBaseDeck(const json &j=json({}), std::string type="Force_BC")
Constructor.
bool d_isRegionActive
Flag that indicates if region-based application of boundary condition is active. So cases of 'region'...
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.
util::Point d_icVec
Initial velocity vector.
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.
A structure to represent 3d vectors.