91 Parameter(
const std::string& name, T value,
bool required, std::vector<T> range = {}) :
92 value_(value), name_(name), required_(required)
98 std::string name()
const {
return name_; };
99 T value()
const {
return value_; };
100 T operator()()
const {
return value_; };
101 bool defined()
const {
return value_set_; };
106 std::ostringstream str_stream;
107 str_stream << value_;
108 return str_stream.str();
111 friend std::ostream& operator << (std::ostream& out,
const Parameter<T>& param)
113 out << param.value();
118 void set(
const std::string& name,
bool required, T value) {
120 required_ = required;
125 void set(
const std::string& str_value)
127 if (str_value ==
"") {
131 auto str = str_value;
132 std::string::iterator end_pos = std::remove(str.begin(), str.end(),
' ');
133 str.erase(end_pos, str.end());
135 std::istringstream str_stream(str);
136 if (!(str_stream >> value_)) {
137 std::istringstream str_stream(str);
138 if (!(str_stream >> std::boolalpha >> value_)) {
139 throw std::runtime_error(
"Incorrect value '" + str +
"' for '" + name_ +
"'.");
146 bool check_required_set()
155 std::string name_ =
"";
156 bool required_ =
false;
157 bool value_set_ =
false;
158 std::vector<T> range_;
170 VectorParameter(
const std::string& name,
const std::vector<T>& value,
bool required, std::vector<T> range = {}) :
171 value_(value), name_(name), required_(required)
177 std::string name()
const {
return name_; };
178 std::vector<T> value()
const {
return value_; };
179 bool defined()
const {
return value_set_; };
180 int size()
const {
return value_.size(); };
182 std::vector<T> operator()()
const {
return value_; };
183 const double& operator[](
const int i)
const {
return value_[i]; };
190 if constexpr (std::is_same<T, std::string>::value) {
191 for (
auto v : value_) {
192 str +=
" " + v +
" ";
195 for (
auto v : value_) {
196 str +=
" " + std::to_string(v);
205 for (
int i = 0; i < param.size(); i++) {
206 out << param.value_[i];
212 void set(
const std::string& name,
bool required,
const std::vector<T>& value)
215 required_ = required;
220 void set(
const std::string& str_value)
222 if (str_value ==
"") {
226 std::string error_msg =
"Improper vector format '" + str_value +
"' found in '" + name_ +
"'." +
" Vector format is: (x,y,z)";
227 std::regex sep(
"\\(|\\)|\\,");
228 auto str = std::regex_replace(str_value, sep,
" ");
230 if constexpr (std::is_same<T, std::string>::value) {
231 std::stringstream ssin(str);
233 while (ssin >> value) {
234 value_.push_back(value);
238 std::istringstream ssin(str);
239 while (ssin >> value) {
240 value_.push_back(value);
245 bool check_required_set()
253 std::vector<T> value_;
255 bool required_ =
false;
256 bool value_set_ =
false;
257 std::vector<T> range_;
275 void set_xml_element_name(
const std::string& name)
277 xml_element_name = name;
283 param.
set(name, required, value);
289 param.
set(name, required, value);
295 param.
set(name, required, value);
301 param.
set(name, required, value);
305 void set_parameter(
const std::string& name, std::initializer_list<std::string> value,
bool required,
308 param.
set(name, required, value);
314 param.
set(name, required, value);
320 param.
set(name, required, value);
328 throw std::runtime_error(
"Unknown " + xml_element_name +
" XML element '" + name +
"'.");
334 if (name ==
"Activation_functions") {
336 (*vec_param)->value_.clear();
337 (*vec_param)->set(value);
339 throw std::runtime_error(
"Activation_functions is not a VectorParameter<int>.");
343 else if (name ==
"Weights") {
345 (*vec_param)->value_.clear();
346 (*vec_param)->set(value);
348 throw std::runtime_error(
"Weights is not a VectorParameter<double>.");
353 std::visit([&](
auto&& p) ->
void {
365 throw std::runtime_error(
"Unknown " + xml_element_name +
" XML element '" + name +
"'.");
368 std::visit([value](
auto&& p) { p->set(value); },
params_map[name]);
374 bool unset_found =
false;
377 if (std::visit([](
auto&& p) {
378 return !p->check_required_set();
380 throw std::runtime_error(xml_element_name +
" XML element '" + key +
"' has not been set.");
388 std::map<std::string,std::string> params;
391 std::visit([¶ms](
auto&& p) {
392 params[p->name()] = p->svalue();
403 std::cout << key <<
": ";
404 std::visit([](
auto& p) {
405 std::cout << p->name_ << std::endl;
406 std::cout << p->svalue() << std::endl;
416 std::string xml_element_name =
"";
429 tinyxml2::XMLDocument document;
430 tinyxml2::XMLElement* root_element =
nullptr;
431 static std::string NAME;
445 bool defined()
const {
return value_set; };
446 void set_values(tinyxml2::XMLElement* con_model_params);
447 void print_parameters();
453 bool value_set =
false;
460 bool defined()
const {
return value_set; };
461 void set_values(tinyxml2::XMLElement* con_model_params);
462 void print_parameters();
467 bool value_set =
false;
477 bool defined()
const {
return value_set; };
478 void set_values(tinyxml2::XMLElement* con_model_params);
479 void print_parameters();
491 bool value_set =
false;
498 bool defined()
const {
return value_set; };
499 void set_values(tinyxml2::XMLElement* con_model_params);
500 void print_parameters();
506 bool value_set =
false;
513 bool defined()
const {
return value_set; };
514 void set_values(tinyxml2::XMLElement* con_model_params);
515 void print_parameters();
518 bool value_set =
false;
525 void set_values(tinyxml2::XMLElement* modl_params);
526 void print_parameters();
527 bool value_set =
false;
534 void set_values(tinyxml2::XMLElement* modl_params);
535 void print_parameters();
536 bool value_set =
false;
546 void print_parameters();
547 void set_values(tinyxml2::XMLElement* xml_elem);
574 bool defined()
const {
return value_set; };
575 void set_values(tinyxml2::XMLElement* con_model_params);
576 void print_parameters();
578 std::vector<CANNRowParameters*> rows;
580 bool value_set =
false;
589 void print_parameters();
591 bool defined()
const {
return value_set; };
592 void set_values(tinyxml2::XMLElement* modl_params);
596 static const std::string GUCCIONE_MODEL;
597 static const std::string HGO_MODEL;
598 static const std::string HOLZAPFEL_OGDEN_MODEL;
599 static const std::string HOLZAPFEL_OGDEN_MA_MODEL;
600 static const std::string LEE_SACKS;
601 static const std::string NEOHOOKEAN_MODEL;
602 static const std::string STVENANT_KIRCHHOFF_MODEL;
603 static const std::string CANN_MODEL;
618 bool value_set =
false;
629 bool defined()
const {
return value_set; };
630 void set_values(tinyxml2::XMLElement* xml_elem);
631 void print_parameters();
644 bool value_set =
false;
655 bool defined()
const {
return value_set; };
656 void set_values(tinyxml2::XMLElement* xml_elem);
664 bool value_set =
false;
676 static const std::string xml_element_name_;
678 bool defined()
const {
return value_set; };
679 void set_values(tinyxml2::XMLElement* xml_elem);
689 bool value_set =
false;
705 void print_parameters();
706 void set_values(tinyxml2::XMLElement* xml_elem);
741 static const std::string xml_element_name_;
743 void set_values(tinyxml2::XMLElement* xml_elem);
744 void print_parameters();
752 bool value_set =
false;
761 void print_parameters();
762 void set_values(tinyxml2::XMLElement* bc_params);
829 void print_parameters();
830 void set_values(tinyxml2::XMLElement* xml_elem);
837 std::vector<Parameter<bool>> output_list;
840 std::vector<Parameter<std::string>> alias_list;
857 void set_values(tinyxml2::XMLElement* xml_elem);
859 static const std::string xml_element_name_;
880 void set_values(tinyxml2::XMLElement* xml_elem);
897 bool defined()
const {
return value_set; };
898 void set_values(tinyxml2::XMLElement* xml_elemnt);
902 bool value_set =
false;
917 void print_parameters();
918 void set_values(tinyxml2::XMLElement* equation_params);
926 void print_parameters();
927 void set_values(tinyxml2::XMLElement* xml_elem);
940 void print_parameters();
941 void set_values(tinyxml2::XMLElement* xml_elem);
954 static const std::string CONSTANT_MODEL;
955 static const std::string CARREAU_YASUDA_MODEL;
956 static const std::string CASSONS_MODEL;
957 static const std::set<std::string> model_names;
959 void print_parameters();
960 void set_values(tinyxml2::XMLElement* xml_elem);
980 void print_parameters();
981 void set_values(tinyxml2::XMLElement* equation_params);
989 void print_parameters();
990 void set_values(tinyxml2::XMLElement* equation_params);
1001 static const std::string NEWTONIAN_MODEL;
1002 static const std::string POTENTIAL_MODEL;
1003 static const std::set<std::string> model_names;
1005 void print_parameters();
1006 void set_values(tinyxml2::XMLElement* xml_elem);
1023 void print_parameters();
1024 void set_values(tinyxml2::XMLElement* fsi_file);
1025 bool defined()
const {
return values_set_; };
1027 bool values_set_ =
false;
1042 void print_parameters();
1043 void set_values(tinyxml2::XMLElement* fsi_file);
1084 bool defined()
const {
return value_set; };
1085 void print_parameters();
1086 void set_values(tinyxml2::XMLElement* xml_elem);
1095 bool value_set =
false;
1105 bool defined()
const {
return value_set; };
1106 void print_parameters();
1107 void set_values(tinyxml2::XMLElement* xml_elem);
1113 bool value_set =
false;
1133 bool defined()
const {
return value_set; };
1134 void print_parameters();
1135 void set_values(tinyxml2::XMLElement* xml_elem);
1136 void validate()
const;
1142 bool value_set =
false;
1167 bool defined()
const {
return value_set; };
1168 void print_parameters();
1169 void set_values(tinyxml2::XMLElement* xml_elem);
1180 bool value_set =
false;
1203 void print_parameters();
1204 void set_values(tinyxml2::XMLElement* xml_elem,
bool from_external_xml =
false);
1287 bool values_set_ =
false;
1289 bool defined()
const {
return values_set_; };
1290 void print_parameters();
1291 double get_edge_size(
const std::string& name)
const {
return max_edge_sizes_.at(name); }
1292 bool has_edge_size(
const std::string& name)
const {
return max_edge_sizes_.count(name) == 1; }
1293 void set_values(tinyxml2::XMLElement* mesh_elem);
1296 std::map<std::string, double> max_edge_sizes_;
1315 void print_parameters();
1316 void set_values(tinyxml2::XMLElement* xml_elem);
1349 void print_parameters();
1350 void set_values(tinyxml2::XMLElement* xml_elem,
DomainParameters* default_domain=
nullptr);
1391 std::vector<BodyForceParameters*> body_forces;
1393 std::vector<BoundaryConditionParameters*> boundary_conditions;
1402 std::vector<DomainParameters*> domains;
1406 std::vector<OutputParameters*> outputs;
1448 void print_parameters();
1449 void set_values(tinyxml2::XMLElement* xml_element,
bool from_external_xml =
false);
1451 std::string xml_element_name;
1491 void print_parameters();
1492 void set_values(tinyxml2::XMLElement* xml_elem);
1533 void print_parameters();
1534 void set_values(tinyxml2::XMLElement* mesh_elem,
bool from_external_xml =
false);
1535 std::string get_name()
const {
return name.value(); };
1536 std::string get_path()
const {
return mesh_file_path.value(); };
1538 std::vector<FaceParameters*> face_parameters;
1550 std::vector<VectorParameter<double>> fiber_directions;
1586 void set_values(tinyxml2::XMLElement* xml_elem);
1604 void print_parameters();
1605 void set_values(tinyxml2::XMLElement* xml_elem);
1640 void print_parameters();
1641 void set_values(tinyxml2::XMLElement* mesh_elem);
1642 std::string get_name()
const {
return name.value(); };
1645 std::vector<URISFaceParameters*> URIS_face_parameters;
1669 static const std::set<std::string> constitutive_model_names;
1670 static const std::set<std::string> equation_names;
1671 static const std::string FSI_FILE;
1673 void get_logging_levels(
int& verbose,
int& warning,
int& debug);
1674 void print_parameters();
1675 void read_xml(std::string file_name);
1677 void set_contact_values(tinyxml2::XMLElement* root_element);
1678 void set_equation_values(tinyxml2::XMLElement* root_element);
1679 void set_mesh_values(tinyxml2::XMLElement* root_element);
1680 void set_precomputed_solution_values(tinyxml2::XMLElement* root_element);
1681 void set_projection_values(tinyxml2::XMLElement* root_element);
1682 void set_svzerodsolver_interface_values(tinyxml2::XMLElement* root_element);
1684 void set_RIS_projection_values(tinyxml2::XMLElement* root_element);
1685 void set_URIS_mesh_values(tinyxml2::XMLElement* root_element);
1690 std::vector<MeshParameters*> mesh_parameters;
1691 std::vector<EquationParameters*> equation_parameters;
1692 std::vector<ProjectionParameters*> projection_parameters;
1695 std::vector<RISProjectionParameters*> RIS_projection_parameters;
1696 std::vector<URISMeshParameters*> URIS_mesh_parameters;
Body force over a mesh using the "Add_BF" command.
Definition Parameters.h:702
static const std::string xml_element_name_
Define the XML element name for boundary condition parameters.
Definition Parameters.h:707
The BoundaryConditionParameters stores paramaters for various type of boundary conditions under the A...
Definition Parameters.h:758
static const std::string xml_element_name_
Define the XML element name for equation boundary condition parameters.
Definition Parameters.h:763
RCR values for Neumann BC type.
Definition Parameters.h:737
BoundaryConditionRCRParameters()
RCR values for Neumann BC type.
Definition Parameters.cpp:372
The CANNParameters class stores the parameters table rows for xml element "Constitutive_model type=CA...
Definition Parameters.h:570
CANNParameters()
Constructor for CANNParameters class. Initializes parameter table.
Definition Parameters.cpp:879
~CANNParameters()
Destructor for CANNParameters class. Deletes memory dynamically allocated to the rows of the table.
Definition Parameters.cpp:891
The CANNRowParameters class is used to store the parameters for each row of the CANN table for the xm...
Definition Parameters.h:542
static const std::string xml_element_name_
Process parameters for the "Add_row" xml element.
Definition Parameters.h:549
The ConstitutiveModelParameters class store parameters for various constitutive models.
Definition Parameters.h:586
void check_constitutive_model(const Parameter< std::string > &eq_type)
Check if a constitutive model is valid for the given equation.
Definition Parameters.cpp:991
static const std::map< std::string, std::string > constitutive_model_types
Supported constitutive model types and their aliases.
Definition Parameters.h:538
static const std::string xml_element_name_
Process parameters for various constitutive models.
Definition Parameters.h:593
Couple to reduced-order models.
Definition Parameters.h:623
static const std::string xml_element_name_
Couple to reduced-order models.
Definition Parameters.h:627
Coupling to GenBC.
Definition Parameters.h:649
static const std::string xml_element_name_
Coupling to GenBC.
Definition Parameters.h:653
The DirectionalDistributionParameters class stores directional distribution parameters for active str...
Definition Parameters.h:1127
static const std::string xml_element_name_
Define the XML element name for directional distribution parameters.
Definition Parameters.h:1131
The DomainParameters class stores parameters for the XML 'Domain' element to specify properties for s...
Definition Parameters.h:1197
static const std::string xml_element_name_
Define the XML element name for domain parameters.
Definition Parameters.h:1201
Definition Parameters.h:1099
static const std::string xml_element_name_
Define the XML element name for ECG leads parameters.
Definition Parameters.h:1103
The EquationParameters class stores parameters for the 'Add_equation' XML element used to specify an ...
Definition Parameters.h:1343
static const std::string xml_element_name_
Define the XML element name for equation parameters.
Definition Parameters.h:1347
The FaceParameters class is used to store parameters for the 'Add_face' XML element.
Definition Parameters.h:1487
static const std::string xml_element_name_
Process parameters for the 'Add_face' XML element.
Definition Parameters.h:1494
The FiberReinforcementStressParameters class stores fiber reinforcement stress parameters for the 'Fi...
Definition Parameters.h:1161
static const std::string xml_element_name_
Define the XML element name for fiber reinforcement stress parameters.
Definition Parameters.h:1165
Definition Parameters.h:923
Definition Parameters.h:937
Definition Parameters.h:914
Definition Parameters.h:948
static const std::string xml_element_name_
Process parameters for various fluid viscosity models.
Definition Parameters.h:952
The GeneralSimulationParameters class stores paramaters for the 'GeneralSimulationParameters' XML ele...
Definition Parameters.h:1444
void set_values(tinyxml2::XMLElement *xml_element, bool from_external_xml=false)
Set general parameters values from XML.
Definition Parameters.cpp:2395
GeneralSimulationParameters()
Process paramaters for the 'GeneralSimulationParameters' XML element.
Definition Parameters.cpp:2335
Definition Parameters.h:457
Definition Parameters.h:495
Definition Parameters.h:474
Definition Parameters.h:426
Definition Parameters.h:442
The LinearAlgebraParameters class stores parameters for the 'Linear_algebra' XML element.
Definition Parameters.h:1018
void check_input_parameters()
Check the validity of the input parameters.
Definition Parameters.cpp:3044
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:1020
The LinearSolverParameters class stores parameters for the 'LS' XML element.
Definition Parameters.h:1038
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:1045
The MeshParameters class is used to store paramaters for the 'Add_mesh' XML element.
Definition Parameters.h:1527
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1531
Definition Parameters.h:510
Definition Parameters.h:522
NeoHookeanParameters()
There are no parameters associated with a Neohookean model.
Definition Parameters.cpp:776
The OutputParameters class stores parameters for the Output XML element under Add_equation.
Definition Parameters.h:823
std::string get_alias_value(const std::string &name)
Get the value of an alias by name.
Definition Parameters.cpp:1219
bool get_output_value(const std::string &name)
Get the value of an output by name.
Definition Parameters.cpp:1231
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:827
The Parameter class template is used to store a named paramater and its scalar value as a basic type:...
Definition Parameters.h:87
void set(const std::string &name, bool required, T value)
Set the parameter name and value, and if it is required.
Definition Parameters.h:118
void set(const std::string &str_value)
Set the parameter value from a string.
Definition Parameters.h:125
std::string svalue()
Get the value of a parameter as a string.
Definition Parameters.h:104
Defines parameter name and value, and stores them in maps for settng values from XML.
Definition Parameters.h:270
void check_required()
Check if any required parameters have not been set.
Definition Parameters.h:372
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:281
void set_parameter_value_CANN(const std::string &name, const std::string &value)
set_parameter function to handle CANNRow
Definition Parameters.h:325
std::map< std::string, std::string > get_parameter_list()
Get the defined parameters as a map of strings.
Definition Parameters.h:386
void set_parameter_value(const std::string &name, const std::string &value)
Set the value of a paramter from a string.
Definition Parameters.h:362
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:414
void print_parameter_list()
Print the parameters.
Definition Parameters.h:400
The Parameters class stores parameter values read in from a solver input file.
Definition Parameters.h:1664
void read_xml(std::string file_name)
Set the simulation parameter values given in an XML format file.
Definition Parameters.cpp:151
The PrecomputedSolutionParameters class stores parameters for the 'Precomputed_solution' XML element ...
Definition Parameters.h:853
The ProjectionParameters class stores parameters for the 'Add_projection' XML element used for fluid-...
Definition Parameters.h:876
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:882
The RISProjectionParameters class stores parameters for the 'Add_RIS_projection' XML element used for...
Definition Parameters.h:1582
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1588
The RemesherParameters class stores parameters for the 'Remesher' XML element used for remeshing.
Definition Parameters.h:1282
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1286
Definition Parameters.h:977
Definition Parameters.h:995
static const std::string xml_element_name_
Process parameters for various solid viscosity models.
Definition Parameters.h:999
Definition Parameters.h:986
Definition Parameters.h:531
StVenantKirchhoffParameters()
There are no parameters associated with a StVenantKirchhoff model.
Definition Parameters.cpp:790
The StimulusParameters class stores parameters for 'Stimulus' XML element used to parameters for pace...
Definition Parameters.h:1078
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:1082
The URISFaceParameters class is used to store parameters for the 'Add_URIS_face' XML element.
Definition Parameters.h:1600
static const std::string xml_element_name_
Process parameters for the 'Add_URIS_face' XML element.
Definition Parameters.h:1607
The URISMeshParameters class is used to store paramaters for the 'Add_URIS_mesh' XML element.
Definition Parameters.h:1634
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1638
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition Parameters.h:893
static const std::string xml_element_name_
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition Parameters.h:896
The VectorParameter class template is used to store a named paramater and its vector of values as a b...
Definition Parameters.h:166
void set(const std::string &str_value)
Set the parameter value from a string.
Definition Parameters.h:220
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:212
std::string svalue()
Get the string representation of the parameter value.
Definition Parameters.h:186
Definition Parameters.h:672
struct to define a row of CANN model parameter table
Definition Parameters.h:261