118 Parameter(
const std::string& name, T value,
bool required, std::vector<T> range = {}) :
119 value_(value), name_(name), required_(required)
125 std::string name()
const {
return name_; };
126 T value()
const {
return value_; };
127 T operator()()
const {
return value_; };
128 bool defined()
const {
return value_set_; };
133 std::ostringstream str_stream;
134 str_stream << value_;
135 return str_stream.str();
138 friend std::ostream& operator << (std::ostream& out,
const Parameter<T>& param)
140 out << param.value();
145 void set(
const std::string& name,
bool required, T value) {
147 required_ = required;
152 void set(
const std::string& str_value)
154 if (str_value ==
"") {
158 auto str = str_value;
159 std::string::iterator end_pos = std::remove(str.begin(), str.end(),
' ');
160 str.erase(end_pos, str.end());
162 std::istringstream str_stream(str);
163 if (!(str_stream >> value_)) {
164 std::istringstream str_stream(str);
165 if (!(str_stream >> std::boolalpha >> value_)) {
166 throw std::runtime_error(
"Incorrect value '" + str +
"' for '" + name_ +
"'.");
173 bool check_required_set()
182 std::string name_ =
"";
183 bool required_ =
false;
184 bool value_set_ =
false;
185 std::vector<T> range_;
197 VectorParameter(
const std::string& name,
const std::vector<T>& value,
bool required, std::vector<T> range = {}) :
198 value_(value), name_(name), required_(required)
204 std::string name()
const {
return name_; };
205 std::vector<T> value()
const {
return value_; };
206 bool defined()
const {
return value_set_; };
207 int size()
const {
return value_.size(); };
209 std::vector<T> operator()()
const {
return value_; };
210 const double& operator[](
const int i)
const {
return value_[i]; };
217 if constexpr (std::is_same<T, std::string>::value) {
218 for (
auto v : value_) {
219 str +=
" " + v +
" ";
222 for (
auto v : value_) {
223 str +=
" " + std::to_string(v);
232 for (
int i = 0; i < param.size(); i++) {
233 out << param.value_[i];
239 void set(
const std::string& name,
bool required,
const std::vector<T>& value)
242 required_ = required;
247 void set(
const std::string& str_value)
249 if (str_value ==
"") {
253 std::string error_msg =
"Improper vector format '" + str_value +
"' found in '" + name_ +
"'." +
" Vector format is: (x,y,z)";
254 std::regex sep(
"\\(|\\)|\\,");
255 auto str = std::regex_replace(str_value, sep,
" ");
257 if constexpr (std::is_same<T, std::string>::value) {
258 std::stringstream ssin(str);
260 while (ssin >> value) {
261 value_.push_back(value);
265 std::istringstream ssin(str);
266 while (ssin >> value) {
267 value_.push_back(value);
272 bool check_required_set()
280 std::vector<T> value_;
282 bool required_ =
false;
283 bool value_set_ =
false;
284 std::vector<T> range_;
295 void set_xml_element_name(
const std::string& name)
297 xml_element_name = name;
303 param.
set(name, required, value);
309 param.
set(name, required, value);
315 param.
set(name, required, value);
321 param.
set(name, required, value);
325 void set_parameter(
const std::string& name, std::initializer_list<std::string> value,
bool required,
328 param.
set(name, required, value);
334 param.
set(name, required, value);
340 param.
set(name, required, value);
348 throw std::runtime_error(
"Unknown " + xml_element_name +
" XML element '" + name +
"'.");
351 std::visit([value](
auto&& p) { p->set(value); },
params_map[name]);
357 bool unset_found =
false;
360 if (std::visit([](
auto&& p) {
361 return !p->check_required_set();
363 throw std::runtime_error(xml_element_name +
" XML element '" + key +
"' has not been set.");
371 std::map<std::string,std::string> params;
374 std::visit([¶ms](
auto&& p) {
375 params[p->name()] = p->svalue();
386 std::cout << key <<
": ";
387 std::visit([](
auto& p) {
388 std::cout << p->name_ << std::endl;
389 std::cout << p->svalue() << std::endl;
399 std::string xml_element_name =
"";
413 bool defined()
const {
return value_set; };
414 void set_values(tinyxml2::XMLElement* con_model_params);
415 void print_parameters();
421 bool value_set =
false;
428 bool defined()
const {
return value_set; };
429 void set_values(tinyxml2::XMLElement* con_model_params);
430 void print_parameters();
435 bool value_set =
false;
445 bool defined()
const {
return value_set; };
446 void set_values(tinyxml2::XMLElement* con_model_params);
447 void print_parameters();
458 bool value_set =
false;
465 bool defined()
const {
return value_set; };
466 void set_values(tinyxml2::XMLElement* con_model_params);
467 void print_parameters();
473 bool value_set =
false;
480 bool defined()
const {
return value_set; };
481 void set_values(tinyxml2::XMLElement* con_model_params);
482 void print_parameters();
485 bool value_set =
false;
492 void set_values(tinyxml2::XMLElement* modl_params);
493 void print_parameters();
494 bool value_set =
false;
501 void set_values(tinyxml2::XMLElement* modl_params);
502 void print_parameters();
503 bool value_set =
false;
512 void print_parameters();
513 bool defined()
const {
return value_set; };
514 void set_values(tinyxml2::XMLElement* modl_params);
518 static const std::string GUCCIONE_MODEL;
519 static const std::string HGO_MODEL;
520 static const std::string LEE_SACKS;
521 static const std::string NEOHOOKEAN_MODEL;
522 static const std::string STVENANT_KIRCHHOFF_MODEL;
536 bool value_set =
false;
547 bool defined()
const {
return value_set; };
548 void set_values(tinyxml2::XMLElement* xml_elem);
549 void print_parameters();
562 bool value_set =
false;
573 bool defined()
const {
return value_set; };
574 void set_values(tinyxml2::XMLElement* xml_elem);
582 bool value_set =
false;
598 void print_parameters();
599 void set_values(tinyxml2::XMLElement* xml_elem);
634 static const std::string xml_element_name_;
636 void set_values(tinyxml2::XMLElement* xml_elem);
637 void print_parameters();
645 bool value_set =
false;
654 void print_parameters();
655 void set_values(tinyxml2::XMLElement* bc_params);
719 void print_parameters();
720 void set_values(tinyxml2::XMLElement* xml_elem);
727 std::vector<Parameter<bool>> output_list;
730 std::vector<Parameter<std::string>> alias_list;
746 void set_values(tinyxml2::XMLElement* xml_elem);
763 bool defined()
const {
return value_set; };
764 void set_values(tinyxml2::XMLElement* xml_elemnt);
768 bool value_set =
false;
783 void print_parameters();
784 void set_values(tinyxml2::XMLElement* equation_params);
792 void print_parameters();
793 void set_values(tinyxml2::XMLElement* xml_elem);
806 void print_parameters();
807 void set_values(tinyxml2::XMLElement* xml_elem);
820 static const std::string CONSTANT_MODEL;
821 static const std::string CARREAU_YASUDA_MODEL;
822 static const std::string CASSONS_MODEL;
823 static const std::set<std::string> model_names;
825 void print_parameters();
826 void set_values(tinyxml2::XMLElement* xml_elem);
842 void print_parameters();
843 void set_values(tinyxml2::XMLElement* fsi_file);
884 bool defined()
const {
return value_set; };
885 void print_parameters();
886 void set_values(tinyxml2::XMLElement* xml_elem);
895 bool value_set =
false;
905 bool defined()
const {
return value_set; };
906 void print_parameters();
907 void set_values(tinyxml2::XMLElement* xml_elem);
913 bool value_set =
false;
933 bool defined()
const {
return value_set; };
934 void print_parameters();
935 void set_values(tinyxml2::XMLElement* xml_elem);
943 bool value_set =
false;
966 void print_parameters();
967 void set_values(tinyxml2::XMLElement* xml_elem);
1046 bool values_set_ =
false;
1048 bool defined()
const {
return values_set_; };
1049 void print_parameters();
1050 double get_edge_size(
const std::string& name)
const {
return max_edge_sizes_.at(name); }
1051 bool has_edge_size(
const std::string& name)
const {
return max_edge_sizes_.count(name) == 1; }
1052 void set_values(tinyxml2::XMLElement* mesh_elem);
1055 std::map<std::string, double> max_edge_sizes_;
1074 void print_parameters();
1075 void set_values(tinyxml2::XMLElement* xml_elem);
1108 void print_parameters();
1109 void set_values(tinyxml2::XMLElement* xml_elem);
1141 std::vector<BodyForceParameters*> body_forces;
1143 std::vector<BoundaryConditionParameters*> boundary_conditions;
1150 std::vector<DomainParameters*> domains;
1154 std::vector<OutputParameters*> outputs;
1193 void print_parameters();
1194 void set_values(tinyxml2::XMLElement* xml_element);
1196 std::string xml_element_name;
1235 void print_parameters();
1236 void set_values(tinyxml2::XMLElement* xml_elem);
1277 void print_parameters();
1278 void set_values(tinyxml2::XMLElement* mesh_elem);
1279 std::string get_name()
const {
return name.value(); };
1280 std::string get_path()
const {
return mesh_file_path.value(); };
1282 std::vector<FaceParameters*> face_parameters;
1294 std::vector<VectorParameter<double>> fiber_directions;
1318 static const std::set<std::string> constitutive_model_names;
1319 static const std::set<std::string> equation_names;
1320 static const std::string FSI_FILE;
1322 void get_logging_levels(
int& verbose,
int& warning,
int& debug);
1323 void print_parameters();
1324 void read_xml(std::string file_name);
1326 void set_contact_values(tinyxml2::XMLElement* root_element);
1327 void set_equation_values(tinyxml2::XMLElement* root_element);
1328 void set_mesh_values(tinyxml2::XMLElement* root_element);
1329 void set_projection_values(tinyxml2::XMLElement* root_element);
1334 std::vector<MeshParameters*> mesh_parameters;
1335 std::vector<EquationParameters*> equation_parameters;
1336 std::vector<ProjectionParameters*> projection_parameters;
Body force over a mesh using the "Add_BF" command.
Definition: Parameters.h:595
static const std::string xml_element_name_
Define the XML element name for boundary condition parameters.
Definition: Parameters.h:600
The BoundaryConditionParameters stores paramaters for various type of boundary conditions under the A...
Definition: Parameters.h:651
static const std::string xml_element_name_
Define the XML element name for equation boundary condition parameters.
Definition: Parameters.h:656
RCR values for Neumann BC type.
Definition: Parameters.h:630
BoundaryConditionRCRParameters()
RCR values for Neumann BC type.
Definition: Parameters.cpp:309
The ConstitutiveModelParameters class store parameters for various constitutive models.
Definition: Parameters.h:509
static const std::map< std::string, std::string > constitutive_model_types
Supported constitutive model types and their aliases.
Definition: Parameters.h:523
static const std::string xml_element_name_
Process parameters for various constitutive models.
Definition: Parameters.h:515
Couple to reduced-order models.
Definition: Parameters.h:541
static const std::string xml_element_name_
Couple to reduced-order models.
Definition: Parameters.h:545
Coupling to GenBC.
Definition: Parameters.h:567
static const std::string xml_element_name_
Coupling to GenBC.
Definition: Parameters.h:571
The DomainParameters class stores parameters for the XML 'Domain' element to specify properties for s...
Definition: Parameters.h:960
static const std::string xml_element_name_
Define the XML element name for domain parameters.
Definition: Parameters.h:964
Definition: Parameters.h:899
static const std::string xml_element_name_
Define the XML element name for ECG leads parameters.
Definition: Parameters.h:903
The EquationParameters class stores parameters for the 'Add_equation' XML element used to specify an ...
Definition: Parameters.h:1102
static const std::string xml_element_name_
Define the XML element name for equation parameters.
Definition: Parameters.h:1106
The FaceParameters class is used to store parameters for the 'Add_face' XML element.
Definition: Parameters.h:1231
static const std::string xml_element_name_
Process parameters for the 'Add_face' XML element.
Definition: Parameters.h:1238
The FiberReinforcementStressParameters class stores fiber reinforcement stress parameters for the 'Fi...
Definition: Parameters.h:927
static const std::string xml_element_name_
Define the XML element name for fiber reinforcement stress parameters.
Definition: Parameters.h:931
The GeneralSimulationParameters class stores paramaters for the 'GeneralSimulationParameters' XML ele...
Definition: Parameters.h:1189
GeneralSimulationParameters()
Process paramaters for the 'GeneralSimulationParameters' XML element.
Definition: Parameters.cpp:1757
void set_values(tinyxml2::XMLElement *xml_element)
Set general parameters values from XML.
Definition: Parameters.cpp:1817
Definition: Parameters.h:425
Definition: Parameters.h:462
Definition: Parameters.h:442
Definition: Parameters.h:410
The LinearSolverParameters class stores parameters for the 'LS' XML element.
Definition: Parameters.h:838
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:845
The MeshParameters class is used to store paramaters for the 'Add_mesh' XML element.
Definition: Parameters.h:1271
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition: Parameters.h:1275
Definition: Parameters.h:477
Definition: Parameters.h:489
NeoHookeanParameters()
There are no parameters associated with a Neohookean model.
Definition: Parameters.cpp:692
The OutputParameters class stores parameters for the Output XML element under Add_equation.
Definition: Parameters.h:713
std::string get_alias_value(const std::string &name)
Get the value of an alias by name.
Definition: Parameters.cpp:949
bool get_output_value(const std::string &name)
Get the value of an output by name.
Definition: Parameters.cpp:961
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:717
The Parameter class template is used to store a named paramater and its scalar value as a basic type:...
Definition: Parameters.h:114
void set(const std::string &name, bool required, T value)
Set the parameter name and value, and if it is required.
Definition: Parameters.h:145
void set(const std::string &str_value)
Set the parameter value from a string.
Definition: Parameters.h:152
std::string svalue()
Get the value of a parameter as a string.
Definition: Parameters.h:131
Defines parameter name and value, and stores them in maps for settng values from XML.
Definition: Parameters.h:290
void check_required()
Check if any required parameters have not been set.
Definition: Parameters.h:355
void set_parameter(const std::string &name, const bool value, bool required, Parameter< bool > ¶m)
Set the name, default value and the parameter required flag.
Definition: Parameters.h:301
void set_parameter_value(const std::string &name, const std::string &value)
Set the value of a paramter from a string.
Definition: Parameters.h:345
std::map< std::string, std::variant< Parameter< bool > *, Parameter< double > *, Parameter< int > *, Parameter< std::string > *, VectorParameter< double > *, VectorParameter< int > *, VectorParameter< std::string > * > > params_map
Map used for storing parameters by name / Parameter template union.
Definition: Parameters.h:397
std::map< std::string, std::string > get_parameter_list()
Get the defined parameters as a map of strings.
Definition: Parameters.h:369
void print_parameter_list()
Print the parameters.
Definition: Parameters.h:383
The Parameters class stores parameter values read in from a solver input file.
Definition: Parameters.h:1313
void read_xml(std::string file_name)
Set the simulation parameter values given in an XML format file.
Definition: Parameters.cpp:141
The ProjectionParameters class stores parameters for the 'Add_projection' XML element used for fluid-...
Definition: Parameters.h:742
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition: Parameters.h:748
The RemesherParameters class stores parameters for the 'Remesher' XML element used for remeshing.
Definition: Parameters.h:1041
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition: Parameters.h:1045
Definition: Parameters.h:498
StVenantKirchhoffParameters()
There are no parameters associated with a StVenantKirchhoff model.
Definition: Parameters.cpp:706
The StimulusParameters class stores parameters for 'Stimulus' XML element used to parameters for pace...
Definition: Parameters.h:878
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:882
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition: Parameters.h:759
static const std::string xml_element_name_
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition: Parameters.h:762
The VectorParameter class template is used to store a named paramater and its vector of values as a b...
Definition: Parameters.h:193
void set(const std::string &str_value)
Set the parameter value from a string.
Definition: Parameters.h:247
void set(const std::string &name, bool required, const std::vector< T > &value)
Set the parameter name and value, and if it is required.
Definition: Parameters.h:239
std::string svalue()
Get the string representation of the parameter value.
Definition: Parameters.h:213
Definition: Parameters.h:789
Definition: Parameters.h:803
Definition: Parameters.h:780
Definition: Parameters.h:814
static const std::string xml_element_name_
Process parameters for various viscosity models.
Definition: Parameters.h:818