117 Parameter(
const std::string& name, T value,
bool required, std::vector<T> range = {}) :
118 value_(value), name_(name), required_(required)
124 std::string name()
const {
return name_; };
125 T value()
const {
return value_; };
126 T operator()()
const {
return value_; };
127 bool defined()
const {
return value_set_; };
132 std::ostringstream str_stream;
133 str_stream << value_;
134 return str_stream.str();
137 friend std::ostream& operator << (std::ostream& out,
const Parameter<T>& param)
139 out << param.value();
144 void set(
const std::string& name,
bool required, T value) {
146 required_ = required;
151 void set(
const std::string& str_value)
153 if (str_value ==
"") {
157 auto str = str_value;
158 std::string::iterator end_pos = std::remove(str.begin(), str.end(),
' ');
159 str.erase(end_pos, str.end());
161 std::istringstream str_stream(str);
162 if (!(str_stream >> value_)) {
163 std::istringstream str_stream(str);
164 if (!(str_stream >> std::boolalpha >> value_)) {
165 throw std::runtime_error(
"Incorrect value '" + str +
"' for '" + name_ +
"'.");
172 bool check_required_set()
181 std::string name_ =
"";
182 bool required_ =
false;
183 bool value_set_ =
false;
184 std::vector<T> range_;
196 VectorParameter(
const std::string& name,
const std::vector<T>& value,
bool required, std::vector<T> range = {}) :
197 value_(value), name_(name), required_(required)
203 std::string name()
const {
return name_; };
204 std::vector<T> value()
const {
return value_; };
205 bool defined()
const {
return value_set_; };
206 int size()
const {
return value_.size(); };
208 std::vector<T> operator()()
const {
return value_; };
209 const double& operator[](
const int i)
const {
return value_[i]; };
216 if constexpr (std::is_same<T, std::string>::value) {
217 for (
auto v : value_) {
218 str +=
" " + v +
" ";
221 for (
auto v : value_) {
222 str +=
" " + std::to_string(v);
231 for (
int i = 0; i < param.size(); i++) {
232 out << param.value_[i];
238 void set(
const std::string& name,
bool required,
const std::vector<T>& value)
241 required_ = required;
246 void set(
const std::string& str_value)
248 if (str_value ==
"") {
252 std::string error_msg =
"Improper vector format '" + str_value +
"' found in '" + name_ +
"'." +
" Vector format is: (x,y,z)";
253 std::regex sep(
"\\(|\\)|\\,");
254 auto str = std::regex_replace(str_value, sep,
" ");
256 if constexpr (std::is_same<T, std::string>::value) {
257 std::stringstream ssin(str);
259 while (ssin >> value) {
260 value_.push_back(value);
264 std::istringstream ssin(str);
265 while (ssin >> value) {
266 value_.push_back(value);
271 bool check_required_set()
279 std::vector<T> value_;
281 bool required_ =
false;
282 bool value_set_ =
false;
283 std::vector<T> range_;
294 void set_xml_element_name(
const std::string& name)
296 xml_element_name = name;
302 param.
set(name, required, value);
308 param.
set(name, required, value);
314 param.
set(name, required, value);
320 param.
set(name, required, value);
324 void set_parameter(
const std::string& name, std::initializer_list<std::string> value,
bool required,
327 param.
set(name, required, value);
333 param.
set(name, required, value);
339 param.
set(name, required, value);
347 throw std::runtime_error(
"Unknown " + xml_element_name +
" XML element '" + name +
"'.");
350 std::visit([value](
auto&& p) { p->set(value); },
params_map[name]);
356 bool unset_found =
false;
359 if (std::visit([](
auto&& p) {
360 return !p->check_required_set();
362 throw std::runtime_error(xml_element_name +
" XML element '" + key +
"' has not been set.");
370 std::map<std::string,std::string> params;
373 std::visit([¶ms](
auto&& p) {
374 params[p->name()] = p->svalue();
385 std::cout << key <<
": ";
386 std::visit([](
auto& p) {
387 std::cout << p->name_ << std::endl;
388 std::cout << p->svalue() << std::endl;
398 std::string xml_element_name =
"";
412 bool defined()
const {
return value_set; };
413 void set_values(tinyxml2::XMLElement* con_model_params);
414 void print_parameters();
420 bool value_set =
false;
427 bool defined()
const {
return value_set; };
428 void set_values(tinyxml2::XMLElement* con_model_params);
429 void print_parameters();
434 bool value_set =
false;
444 bool defined()
const {
return value_set; };
445 void set_values(tinyxml2::XMLElement* con_model_params);
446 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 HOLZAPFEL_OGDEN_MODEL;
521 static const std::string HOLZAPFEL_OGDEN_MA_MODEL;
522 static const std::string LEE_SACKS;
523 static const std::string NEOHOOKEAN_MODEL;
524 static const std::string STVENANT_KIRCHHOFF_MODEL;
538 bool value_set =
false;
549 bool defined()
const {
return value_set; };
550 void set_values(tinyxml2::XMLElement* xml_elem);
551 void print_parameters();
564 bool value_set =
false;
575 bool defined()
const {
return value_set; };
576 void set_values(tinyxml2::XMLElement* xml_elem);
584 bool value_set =
false;
597 static const std::string xml_element_name_;
599 bool defined()
const {
return value_set; };
600 void set_values(tinyxml2::XMLElement* xml_elem);
605 bool value_set =
false;
620 void print_parameters();
621 void set_values(tinyxml2::XMLElement* xml_elem);
656 static const std::string xml_element_name_;
658 void set_values(tinyxml2::XMLElement* xml_elem);
659 void print_parameters();
667 bool value_set =
false;
676 void print_parameters();
677 void set_values(tinyxml2::XMLElement* bc_params);
741 void print_parameters();
742 void set_values(tinyxml2::XMLElement* xml_elem);
749 std::vector<Parameter<bool>> output_list;
752 std::vector<Parameter<std::string>> alias_list;
768 void set_values(tinyxml2::XMLElement* xml_elem);
785 bool defined()
const {
return value_set; };
786 void set_values(tinyxml2::XMLElement* xml_elemnt);
790 bool value_set =
false;
805 void print_parameters();
806 void set_values(tinyxml2::XMLElement* equation_params);
814 void print_parameters();
815 void set_values(tinyxml2::XMLElement* xml_elem);
828 void print_parameters();
829 void set_values(tinyxml2::XMLElement* xml_elem);
842 static const std::string CONSTANT_MODEL;
843 static const std::string CARREAU_YASUDA_MODEL;
844 static const std::string CASSONS_MODEL;
845 static const std::set<std::string> model_names;
847 void print_parameters();
848 void set_values(tinyxml2::XMLElement* xml_elem);
868 void print_parameters();
869 void set_values(tinyxml2::XMLElement* equation_params);
877 void print_parameters();
878 void set_values(tinyxml2::XMLElement* equation_params);
889 static const std::string NEWTONIAN_MODEL;
890 static const std::string POTENTIAL_MODEL;
891 static const std::set<std::string> model_names;
893 void print_parameters();
894 void set_values(tinyxml2::XMLElement* xml_elem);
911 void print_parameters();
912 void set_values(tinyxml2::XMLElement* fsi_file);
913 bool defined()
const {
return values_set_; };
915 bool values_set_ =
false;
930 void print_parameters();
931 void set_values(tinyxml2::XMLElement* fsi_file);
972 bool defined()
const {
return value_set; };
973 void print_parameters();
974 void set_values(tinyxml2::XMLElement* xml_elem);
983 bool value_set =
false;
993 bool defined()
const {
return value_set; };
994 void print_parameters();
995 void set_values(tinyxml2::XMLElement* xml_elem);
1001 bool value_set =
false;
1021 bool defined()
const {
return value_set; };
1022 void print_parameters();
1023 void set_values(tinyxml2::XMLElement* xml_elem);
1031 bool value_set =
false;
1054 void print_parameters();
1055 void set_values(tinyxml2::XMLElement* xml_elem);
1137 bool values_set_ =
false;
1139 bool defined()
const {
return values_set_; };
1140 void print_parameters();
1141 double get_edge_size(
const std::string& name)
const {
return max_edge_sizes_.at(name); }
1142 bool has_edge_size(
const std::string& name)
const {
return max_edge_sizes_.count(name) == 1; }
1143 void set_values(tinyxml2::XMLElement* mesh_elem);
1146 std::map<std::string, double> max_edge_sizes_;
1165 void print_parameters();
1166 void set_values(tinyxml2::XMLElement* xml_elem);
1199 void print_parameters();
1200 void set_values(tinyxml2::XMLElement* xml_elem);
1235 std::vector<BodyForceParameters*> body_forces;
1237 std::vector<BoundaryConditionParameters*> boundary_conditions;
1245 std::vector<DomainParameters*> domains;
1249 std::vector<OutputParameters*> outputs;
1290 void print_parameters();
1291 void set_values(tinyxml2::XMLElement* xml_element);
1293 std::string xml_element_name;
1336 void print_parameters();
1337 void set_values(tinyxml2::XMLElement* xml_elem);
1378 void print_parameters();
1379 void set_values(tinyxml2::XMLElement* mesh_elem);
1380 std::string get_name()
const {
return name.value(); };
1381 std::string get_path()
const {
return mesh_file_path.value(); };
1383 std::vector<FaceParameters*> face_parameters;
1395 std::vector<VectorParameter<double>> fiber_directions;
1419 static const std::set<std::string> constitutive_model_names;
1420 static const std::set<std::string> equation_names;
1421 static const std::string FSI_FILE;
1423 void get_logging_levels(
int& verbose,
int& warning,
int& debug);
1424 void print_parameters();
1425 void read_xml(std::string file_name);
1427 void set_contact_values(tinyxml2::XMLElement* root_element);
1428 void set_equation_values(tinyxml2::XMLElement* root_element);
1429 void set_mesh_values(tinyxml2::XMLElement* root_element);
1430 void set_projection_values(tinyxml2::XMLElement* root_element);
1435 std::vector<MeshParameters*> mesh_parameters;
1436 std::vector<EquationParameters*> equation_parameters;
1437 std::vector<ProjectionParameters*> projection_parameters;
Body force over a mesh using the "Add_BF" command.
Definition: Parameters.h:617
static const std::string xml_element_name_
Define the XML element name for boundary condition parameters.
Definition: Parameters.h:622
The BoundaryConditionParameters stores paramaters for various type of boundary conditions under the A...
Definition: Parameters.h:673
static const std::string xml_element_name_
Define the XML element name for equation boundary condition parameters.
Definition: Parameters.h:678
RCR values for Neumann BC type.
Definition: Parameters.h:652
BoundaryConditionRCRParameters()
RCR values for Neumann BC type.
Definition: Parameters.cpp:315
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:525
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:543
static const std::string xml_element_name_
Couple to reduced-order models.
Definition: Parameters.h:547
Coupling to GenBC.
Definition: Parameters.h:569
static const std::string xml_element_name_
Coupling to GenBC.
Definition: Parameters.h:573
Definition: Parameters.h:593
The DomainParameters class stores parameters for the XML 'Domain' element to specify properties for s...
Definition: Parameters.h:1048
static const std::string xml_element_name_
Define the XML element name for domain parameters.
Definition: Parameters.h:1052
Definition: Parameters.h:987
static const std::string xml_element_name_
Define the XML element name for ECG leads parameters.
Definition: Parameters.h:991
The EquationParameters class stores parameters for the 'Add_equation' XML element used to specify an ...
Definition: Parameters.h:1193
static const std::string xml_element_name_
Define the XML element name for equation parameters.
Definition: Parameters.h:1197
The FaceParameters class is used to store parameters for the 'Add_face' XML element.
Definition: Parameters.h:1332
static const std::string xml_element_name_
Process parameters for the 'Add_face' XML element.
Definition: Parameters.h:1339
The FiberReinforcementStressParameters class stores fiber reinforcement stress parameters for the 'Fi...
Definition: Parameters.h:1015
static const std::string xml_element_name_
Define the XML element name for fiber reinforcement stress parameters.
Definition: Parameters.h:1019
Definition: Parameters.h:811
Definition: Parameters.h:825
Definition: Parameters.h:802
Definition: Parameters.h:836
static const std::string xml_element_name_
Process parameters for various fluid viscosity models.
Definition: Parameters.h:840
The GeneralSimulationParameters class stores paramaters for the 'GeneralSimulationParameters' XML ele...
Definition: Parameters.h:1286
GeneralSimulationParameters()
Process paramaters for the 'GeneralSimulationParameters' XML element.
Definition: Parameters.cpp:1966
void set_values(tinyxml2::XMLElement *xml_element)
Set general parameters values from XML.
Definition: Parameters.cpp:2029
Definition: Parameters.h:424
Definition: Parameters.h:462
Definition: Parameters.h:441
Definition: Parameters.h:409
The LinearAlgebraParameters class stores parameters for the 'Linear_algebra' XML element.
Definition: Parameters.h:906
void check_input_parameters()
Check the validity of the input parameters.
Definition: Parameters.cpp:2438
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:908
The LinearSolverParameters class stores parameters for the 'LS' XML element.
Definition: Parameters.h:926
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:933
The MeshParameters class is used to store paramaters for the 'Add_mesh' XML element.
Definition: Parameters.h:1372
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition: Parameters.h:1376
Definition: Parameters.h:477
Definition: Parameters.h:489
NeoHookeanParameters()
There are no parameters associated with a Neohookean model.
Definition: Parameters.cpp:710
The OutputParameters class stores parameters for the Output XML element under Add_equation.
Definition: Parameters.h:735
std::string get_alias_value(const std::string &name)
Get the value of an alias by name.
Definition: Parameters.cpp:1009
bool get_output_value(const std::string &name)
Get the value of an output by name.
Definition: Parameters.cpp:1021
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:739
The Parameter class template is used to store a named paramater and its scalar value as a basic type:...
Definition: Parameters.h:113
void set(const std::string &name, bool required, T value)
Set the parameter name and value, and if it is required.
Definition: Parameters.h:144
void set(const std::string &str_value)
Set the parameter value from a string.
Definition: Parameters.h:151
std::string svalue()
Get the value of a parameter as a string.
Definition: Parameters.h:130
Defines parameter name and value, and stores them in maps for settng values from XML.
Definition: Parameters.h:289
void check_required()
Check if any required parameters have not been set.
Definition: Parameters.h:354
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:300
void set_parameter_value(const std::string &name, const std::string &value)
Set the value of a paramter from a string.
Definition: Parameters.h:344
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:396
std::map< std::string, std::string > get_parameter_list()
Get the defined parameters as a map of strings.
Definition: Parameters.h:368
void print_parameter_list()
Print the parameters.
Definition: Parameters.h:382
The Parameters class stores parameter values read in from a solver input file.
Definition: Parameters.h:1414
void read_xml(std::string file_name)
Set the simulation parameter values given in an XML format file.
Definition: Parameters.cpp:147
The ProjectionParameters class stores parameters for the 'Add_projection' XML element used for fluid-...
Definition: Parameters.h:764
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition: Parameters.h:770
The RemesherParameters class stores parameters for the 'Remesher' XML element used for remeshing.
Definition: Parameters.h:1132
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition: Parameters.h:1136
Definition: Parameters.h:865
Definition: Parameters.h:883
static const std::string xml_element_name_
Process parameters for various solid viscosity models.
Definition: Parameters.h:887
Definition: Parameters.h:874
Definition: Parameters.h:498
StVenantKirchhoffParameters()
There are no parameters associated with a StVenantKirchhoff model.
Definition: Parameters.cpp:724
The StimulusParameters class stores parameters for 'Stimulus' XML element used to parameters for pace...
Definition: Parameters.h:966
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition: Parameters.h:970
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition: Parameters.h:781
static const std::string xml_element_name_
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition: Parameters.h:784
The VectorParameter class template is used to store a named paramater and its vector of values as a b...
Definition: Parameters.h:192
void set(const std::string &str_value)
Set the parameter value from a string.
Definition: Parameters.h:246
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:238
std::string svalue()
Get the string representation of the parameter value.
Definition: Parameters.h:212