NimbleSM
NimbleSM is a solid mechanics simulation code for dynamic systems
Loading...
Searching...
No Matches
nimble::BoundaryCondition Class Reference

#include <nimble_boundary_condition.h>

Public Types

enum  Boundary_Condition_Type {
  UNDEFINED = 0 , INITIAL_VELOCITY = 1 , PRESCRIBED_VELOCITY = 2 , PRESCRIBED_DISPLACEMENT = 3 ,
  PRESCRIBED_TRACTION = 4
}
 

Public Member Functions

 BoundaryCondition ()
 
virtual ~BoundaryCondition ()
 
bool Initialize (int dim, std::string bc_string, std::map< int, std::string > const &node_set_names, std::map< int, std::string > const &side_set_names)
 

Public Attributes

int dim_ {0}
 
std::string node_set_name_ {"unknown"}
 
int node_set_id_ {-1}
 
std::string side_set_name_ {"unknown"}
 
int side_set_id_ {-1}
 
int coordinate_ {-1}
 
double magnitude_ {0.0}
 
Boundary_Condition_Type bc_type_ {UNDEFINED}
 
bool has_expression_ {false}
 
std::string expression_string_ {""}
 
ExpressionParsing::BoundaryConditionFunctor expression_
 

Member Enumeration Documentation

◆ Boundary_Condition_Type

Enumerator
UNDEFINED 
INITIAL_VELOCITY 
PRESCRIBED_VELOCITY 
PRESCRIBED_DISPLACEMENT 
PRESCRIBED_TRACTION 
63 {
64 UNDEFINED = 0,
69 };
@ PRESCRIBED_VELOCITY
Definition nimble_boundary_condition.h:66
@ PRESCRIBED_DISPLACEMENT
Definition nimble_boundary_condition.h:67
@ UNDEFINED
Definition nimble_boundary_condition.h:64
@ PRESCRIBED_TRACTION
Definition nimble_boundary_condition.h:68
@ INITIAL_VELOCITY
Definition nimble_boundary_condition.h:65

Constructor & Destructor Documentation

◆ BoundaryCondition()

nimble::BoundaryCondition::BoundaryCondition ( )
inline
71{}

◆ ~BoundaryCondition()

virtual nimble::BoundaryCondition::~BoundaryCondition ( )
inlinevirtual
73{}

Member Function Documentation

◆ Initialize()

bool nimble::BoundaryCondition::Initialize ( int dim,
std::string bc_string,
std::map< int, std::string > const & node_set_names,
std::map< int, std::string > const & side_set_names )
71{
72 bool is_valid = true;
73
74 dim_ = dim;
75 std::string bc_type_string("undefined");
76 std::string coordinate_string("undefined");
77 std::stringstream ss(bc_string);
78 ss >> bc_type_string;
79
80 if (bc_type_string == "initial_velocity") {
82 } else if (bc_type_string == "prescribed_velocity") {
84 } else if (bc_type_string == "prescribed_displacement") {
86 } else if (bc_type_string == "prescribed_traction") {
88 } else {
89 throw std::invalid_argument(
90 "Error processing boundary condition, unknown boundary condition "
91 "type: " +
92 bc_type_string);
93 }
94
95 bool const is_neumann_bc = bc_type_ == PRESCRIBED_TRACTION;
96
97 if (is_neumann_bc == true) {
98 ss >> side_set_name_;
99 } else {
100 ss >> node_set_name_;
101 }
102 ss >> coordinate_string;
103
104 // figure out if magnitude is a double or an expression (check for quotes)
105 int num_quotes = std::count(bc_string.begin(), bc_string.end(), '"');
106 if (num_quotes == 2) {
107 has_expression_ = true;
108 size_t first_pos = bc_string.find('"');
109 size_t last_pos = bc_string.rfind('"');
110 expression_string_ = bc_string.substr(first_pos + 1, last_pos - first_pos - 1);
111 expression_ = ExpressionParsing::BoundaryConditionFunctor(expression_string_);
112 } else if (num_quotes == 0) {
113 has_expression_ = false;
114 ss >> magnitude_; // DJL valgrind complains about this
115 } else {
116 throw std::invalid_argument("Error processing boundary condition, illegal number of quotes: " + bc_string);
117 }
118
119 std::transform(bc_type_string.begin(), bc_type_string.end(), bc_type_string.begin(), ::tolower);
120 std::transform(coordinate_string.begin(), coordinate_string.end(), coordinate_string.begin(), ::tolower);
121
122 // If id is -1, then either
123 // 1) no nodes/sides on this processor belong to the node/side set, or
124 // 2) the node/side set doesn't exist at all.
125 if (is_neumann_bc == true) {
126 side_set_id_ = find_name_id(side_set_names, side_set_name_);
127 if (side_set_id_ == -1) is_valid = false;
128 } else {
129 node_set_id_ = find_name_id(node_set_names, node_set_name_);
130 if (node_set_id_ == -1) is_valid = false;
131 }
132
133 if (coordinate_string == "x") {
134 coordinate_ = 0;
135 } else if (coordinate_string == "y") {
136 coordinate_ = 1;
137 } else if (coordinate_string == "z") {
138 coordinate_ = 2;
139 } else {
140 throw std::invalid_argument("Error processing boundary condition, unknown coordinate: " + coordinate_string);
141 }
142
143 return is_valid;
144}
std::string node_set_name_
Definition nimble_boundary_condition.h:97
bool has_expression_
Definition nimble_boundary_condition.h:104
std::string expression_string_
Definition nimble_boundary_condition.h:105
int dim_
Definition nimble_boundary_condition.h:96
int side_set_id_
Definition nimble_boundary_condition.h:100
double magnitude_
Definition nimble_boundary_condition.h:102
int coordinate_
Definition nimble_boundary_condition.h:101
std::string side_set_name_
Definition nimble_boundary_condition.h:99
ExpressionParsing::BoundaryConditionFunctor expression_
Definition nimble_boundary_condition.h:106
Boundary_Condition_Type bc_type_
Definition nimble_boundary_condition.h:103
int node_set_id_
Definition nimble_boundary_condition.h:98

Member Data Documentation

◆ bc_type_

Boundary_Condition_Type nimble::BoundaryCondition::bc_type_ {UNDEFINED}
103{UNDEFINED};

◆ coordinate_

int nimble::BoundaryCondition::coordinate_ {-1}
101{-1};

◆ dim_

int nimble::BoundaryCondition::dim_ {0}
96{0};

◆ expression_

ExpressionParsing::BoundaryConditionFunctor nimble::BoundaryCondition::expression_

◆ expression_string_

std::string nimble::BoundaryCondition::expression_string_ {""}
105{""};

◆ has_expression_

bool nimble::BoundaryCondition::has_expression_ {false}
104{false};

◆ magnitude_

double nimble::BoundaryCondition::magnitude_ {0.0}
102{0.0};

◆ node_set_id_

int nimble::BoundaryCondition::node_set_id_ {-1}
98{-1};

◆ node_set_name_

std::string nimble::BoundaryCondition::node_set_name_ {"unknown"}
97{"unknown"};

◆ side_set_id_

int nimble::BoundaryCondition::side_set_id_ {-1}
100{-1};

◆ side_set_name_

std::string nimble::BoundaryCondition::side_set_name_ {"unknown"}
99{"unknown"};

The documentation for this class was generated from the following files: