11#ifndef INP_BCBASEDECK_H
12#define INP_BCBASEDECK_H
120 std::vector<size_t> pList = std::vector<size_t>(),
121 std::vector<size_t> pNotList = std::vector<size_t>(),
122 std::string timeFnType =
"",
123 std::vector<double> timeFnParams = std::vector<double>(),
124 std::string spatialFnType =
"",
125 std::vector<double> spatialFnParams = std::vector<double>(),
126 std::vector<size_t> direction = std::vector<size_t>(),
127 bool isDisplacementZero =
false)
162 static const std::vector<Field<BCBaseDeck>> &
fields() {
163 static const std::vector<Field<BCBaseDeck>> f = {
164 field<BCBaseDeck, std::vector<size_t>>(
166 "Particles the condition applies to", {},
167 [](
const std::vector<size_t> &v) {
return !v.empty(); }),
170 "Particles the condition does not apply to", {},
171 [](
const std::vector<size_t> &v) {
return !v.empty(); }),
174 "Components the condition acts on, counted from one", {},
175 [](
const std::vector<size_t> &v) {
return !v.empty(); }),
176 field<BCBaseDeck, bool>(
178 "Hold the displacement at zero", {},
179 [](
const bool &v) {
return v; }),
189 static const std::vector<Field<BCBaseDeck>> f = {
191 "Time dependence of the condition"),
192 field<BCBaseDeck, std::vector<double>>(
194 "Parameters of the time dependence", {},
195 [](
const std::vector<double> &v) {
return !v.empty(); }),
205 static const std::vector<Field<BCBaseDeck>> f = {
207 "Spatial dependence of the condition"),
208 field<BCBaseDeck, std::vector<double>>(
210 "Parameters of the spatial dependence", {},
211 [](
const std::vector<double> &v) {
return !v.empty(); }),
235 const std::vector<std::string> extra = {
236 "Type",
"Time_Function",
"Spatial_Function",
"IC_Type",
"IC_Vector"};
239 const auto type = given.value(
"Type", std::string(
"Force_BC"));
243 if (region !=
nullptr) {
244 auto j_geom =
json({});
247 j[
"Region"] =
json{{
"Geometry", j_geom}};
251 json{{
"Particle_List",
252 given.value(
"Particle_List", std::vector<size_t>())},
253 {
"Particle_Exclude_List",
254 given.value(
"Particle_Exclude_List", std::vector<size_t>())}};
256 fieldsGiven[
"Direction"] =
257 given.value(
"Direction", std::vector<size_t>());
258 fieldsGiven[
"Zero_Displacement"] =
259 given.value(
"Zero_Displacement",
false);
263 if (given.find(
"Time_Function") != given.end())
267 if (given.find(
"Spatial_Function") != given.end())
268 j[
"Spatial_Function"] =
272 const auto icType = given.value(
"IC_Type", std::string());
273 if (icType ==
"Constant_Velocity")
274 j[icType][
"Velocity_Vector"] =
275 given.value(
"IC_Vector", std::vector<double>());
299 if (j.find(
"Region") != j.end()) {
302 if (j.find(
"Particle_List") != j.end())
305 if (j.find(
"Particle_Exclude_List") != j.end())
309 if (j.find(
"Particle_List") != j.end())
321 if (j.find(
"Time_Function") != j.end())
324 if (j.find(
"Spatial_Function") != j.end())
327 if (type !=
"IC" && j.find(
"Direction") == j.end())
328 throw std::runtime_error(
329 "Direction must be specified for boundary condition");
333 if (j.find(
"Constant_Velocity") != j.end()) {
335 d_icVec =
util::Point(j.at(
"Constant_Velocity").value(
"Velocity_Vector", std::vector<double>({0., 0., 0.})));
347 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
350 std::ostringstream oss;
351 oss << tabS <<
"------- BCBaseDeck --------" << std::endl << std::endl;
355 oss << tabS <<
"Region geometry info: " << std::endl;
359 oss << tabS <<
"Particle list = ["
360 << util::io::printStr<size_t>(
d_pList, 0) <<
"]" << std::endl;
362 oss << tabS <<
"Particle excluded list = ["
363 << util::io::printStr<size_t>(
d_pNotList, 0) <<
"]" << std::endl;
364 oss << tabS <<
"Time function type = " <<
d_timeFnType << std::endl;
365 oss << tabS <<
"Time function parameters = ["
366 << util::io::printStr<double>(
d_timeFnParams, 0) <<
"]" << std::endl;
367 oss << tabS <<
"Spatial function type = " <<
d_spatialFnType << std::endl;
368 oss << tabS <<
"Spatial function parameters = ["
370 oss << tabS <<
"Direction = [" << util::io::printStr<size_t>(
d_direction, 0)
373 oss << tabS << std::endl;
384 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.
Field< Deck > field(T Deck::*m, std::string key, T def, std::string doc, Accepts< T > accepts={}, std::function< bool(const T &)> emitIf=[](const T &) { return true;})
Declares a field that maps one key to one member.
void readFields(Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
Reads every field of the table from the block.
json applyGiven(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
The default block with the given keys replaced.
void checkKeys(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
Rejects a key that no field declares.
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.
static json getExampleJson(const std::string &)=delete
Rejects a value given where a set of named values is expected.
static const std::vector< Field< BCBaseDeck > > & spatialFunctionFields()
The fields of the Spatial_Function sub-block.
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.
static json getExampleJson(const json &given=json::object(), const geom::GeomData *region=nullptr)
Returns example JSON object for ModelDeck configuration.
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.
static const std::vector< Field< BCBaseDeck > > & timeFunctionFields()
The fields of the Time_Function sub-block.
static const std::vector< Field< BCBaseDeck > > & fields()
The fields of the block itself.
bool d_isDisplacementZero
Specify if this bc corresponds to zero displacement condition.
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.
static json getExampleJson(const char *)=delete
Rejects a value given where a set of named values is expected.
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.