svMultiPhysics
Loading...
Searching...
No Matches
Parameters.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef PARAMETERS_H
5#define PARAMETERS_H
6
7#include <any>
8#include <functional>
9#include <iostream>
10#include <map>
11#include <memory>
12#include <regex>
13#include <set>
14#include <sstream>
15#include <string>
16#include <tuple>
17#include <variant>
18#include <vector>
19
20#include "Vector.h"
21
22#include "Core/Exception.h"
23#include "tinyxml2.h"
24
25template<typename T>
26
27/// @brief The Parameter class template is used to store a named
28/// paramater and its scalar value as a basic type: bool, double,
29/// int and string.
30///
31/// The classes defined here are used to process svFSIplus simulation parameters read in
32/// from an Extensible Markup Language (XML) format file. XML is a simple text-based format
33/// for representing structured information.
34///
35/// An XML document is formed as an element tree. The XML tree starts at a root element and
36/// branches from the root to sub-elements. All elements can have sub-elements:
37///
38/// \code{.cpp}
39/// <svMultiPhysicsFile>
40/// <element>
41/// <subelement>.....</subelement>
42/// </element>
43/// </svMultiPhysicsFile>
44/// \endcode
45///
46/// The elements in the svFSIplus simulation file are represented by sections of
47/// related parameters. Sub-elements are refered to as sub-sections.
48///
49///-----------------
50/// Parameters class
51///-----------------
52/// The Parameters class is the top level class. It contains objects used to store
53/// parameters for the sections making up an XML simulation parameters file
54///
55/// 1) General (GeneralSimulationParameters)
56/// 2) Mesh (MeshParameters)
57/// 3) Equation (EquationParameters)
58/// 4) Projection (ProjectionParameters)
59/// 5) RIS Projection (RIS ProjectionParameters)
60///
61/// Each object contains methods to parse the XML file for the parameters defined for it.
62/// These section objects may also contain objects representing the sub-sections defined
63/// for each section.
64///
65///-----------------
66/// Section objects
67///-----------------
68/// Each section object contains objects representing parameters. A parameter's name and value
69/// is stored using either a Parameter and VectorParamater template objects. A parameter
70/// value is stored as a basic type: bool, double, int and string.
71///
72/// Parameter objects in a section class are named using the same XML element name with the 1st
73/// character lower case.
74///
75/// Example: GeneralSimulationParameters class
76///
77/// \code{.cpp}
78/// Parameter<bool> verbose; // <Verbose>
79/// Parameter<double> spectral_radius_of_infinite_time_step; // <Spectral_radius_of_infinite_time_step>
80/// Parameter<double> time_step_size; // <Time_step_size>
81/// \endcode
82///
83/// The name and default value for each parameter is defined in a section object's constructor.
84///
85/// Parameter values are set using the set_values() method which contains calls to tinyxml2
86/// to parse parameter values from an XML file.
87///
88/// Each section object inherits from the ParameterLists class. This class provides methods to
89/// store parameters in a map and process iterated over them for setting values and other operations.
91{
92 public:
93 Parameter() {};
94
95 Parameter(const std::string& name, T value, bool required, std::vector<T> range = {}) :
96 value_(value), name_(name), required_(required)
97 {
98 value_ = value;
99 range_ = range;
100 };
101
102 std::string name() const { return name_; };
103 T value() const { return value_; };
104 T operator()() const { return value_; };
105 bool defined() const { return value_set_; };
106
107 /// @brief Get the value of a parameter as a string.
108 std::string svalue()
109 {
110 std::ostringstream str_stream;
111 str_stream << value_;
112 return str_stream.str();
113 }
114
115 friend std::ostream& operator << (std::ostream& out, const Parameter<T>& param)
116 {
117 out << param.value();
118 return out;
119 }
120
121 /// @brief Set the parameter name and value, and if it is required.
122 void set(const std::string& name, bool required, T value) {
123 name_ = name;
124 required_ = required;
125 value_ = value;
126 }
127
128 /// @brief Set the parameter value from a string.
129 void set(const std::string& str_value)
130 {
131 if (str_value == "") {
132 value_ = T{0};
133 }
134
135 auto str = str_value;
136 std::string::iterator end_pos = std::remove(str.begin(), str.end(), ' ');
137 str.erase(end_pos, str.end());
138
139 std::istringstream str_stream(str);
140 if (!(str_stream >> value_)) {
141 std::istringstream str_stream(str);
142 if (!(str_stream >> std::boolalpha >> value_)) {
143 svmp::raise<svmp::ParseException>(SVMP_HERE, "Incorrect value '" + str + "' for '" + name_ + "'.");
144 }
145 }
146
147 value_set_ = true;
148 }
149
150 bool check_required_set()
151 {
152 if (!required_) {
153 return true;
154 }
155 return value_set_;
156 }
157
158 T value_ = T{0};
159 std::string name_ = "";
160 bool required_ = false;
161 bool value_set_ = false;
162 std::vector<T> range_;
163};
164
165/// @brief The VectorParameter class template is used to store a named
166/// paramater and its vector of values as a basic type: bool, double,
167/// int and string.
168template<typename T>
170{
171 public:
172 VectorParameter() {};
173
174 VectorParameter(const std::string& name, const std::vector<T>& value, bool required, std::vector<T> range = {}) :
175 value_(value), name_(name), required_(required)
176 {
177 value_ = value;
178 range_ = range;
179 };
180
181 std::string name() const { return name_; };
182 std::vector<T> value() const { return value_; };
183 bool defined() const { return value_set_; };
184 int size() const { return value_.size(); };
185
186 std::vector<T> operator()() const { return value_; };
187 const double& operator[](const int i) const { return value_[i]; };
188
189 /// @brief Get the string representation of the parameter value.
190 std::string svalue()
191 {
192 std::string str;
193
194 if constexpr (std::is_same<T, std::string>::value) {
195 for (auto v : value_) {
196 str += " " + v + " ";
197 }
198 } else {
199 for (auto v : value_) {
200 str += " " + std::to_string(v);
201 }
202 }
203
204 return str;
205 }
206
207 friend std::ostream& operator << (std::ostream& out, const VectorParameter<T>& param)
208 {
209 for (int i = 0; i < param.size(); i++) {
210 out << param.value_[i];
211 }
212 return out;
213 }
214
215 /// @brief Set the parameter name and value, and if it is required.
216 void set(const std::string& name, bool required, const std::vector<T>& value)
217 {
218 name_ = name;
219 required_ = required;
220 value_ = value;
221 }
222
223 /// @brief Set the parameter value from a string.
224 void set(const std::string& str_value)
225 {
226 if (str_value == "") {
227 return;
228 }
229
230 std::string error_msg = "Improper vector format '" + str_value + "' found in '" + name_ + "'." + " Vector format is: (x,y,z)";
231 std::regex sep("\\(|\\)|\\,");
232 auto str = std::regex_replace(str_value, sep, " ");
233
234 // If this is the first time this method is called, we clear any previous
235 // content of the vector of values. This means that, when the XML tag
236 // associated to this parameter is encoutered for the first time, the
237 // values given when declaring the parameter (see other overload of the
238 // set function) will be discarded. However, if the same XML tag is
239 // encountered again, the new values are appended, without discarding the
240 // previously encoutered ones.
241 if (!value_set_) {
242 value_.clear();
243 }
244
245 if constexpr (std::is_same<T, std::string>::value) {
246 std::stringstream ssin(str);
247 std::string value;
248 while (ssin >> value) {
249 value_.push_back(value);
250 }
251 } else {
252 T value;
253 std::istringstream ssin(str);
254 while (ssin >> value) {
255 value_.push_back(value);
256 }
257 }
258
259 value_set_ = true;
260 }
261
262 bool check_required_set()
263 {
264 if (!required_) {
265 return true;
266 }
267 return value_set_;
268 }
269
270 std::vector<T> value_;
271 std::string name_;
272 bool required_ = false;
273 bool value_set_ = false;
274 std::vector<T> range_;
275};
276
277/// @brief struct to define a row of CANN model parameter table
278struct CANNRow {
279 Parameter<int> invariant_index;
280 VectorParameter<int> activation_functions; // Fixed size (3 values)
281 VectorParameter<double> weights; // Fixed size (3 values)
282};
283
284/// @brief Defines parameter name and value, and stores them in
285/// maps for settng values from XML.
287{
288 public:
289
290 ParameterLists() { }
291
292 void set_xml_element_name(const std::string& name)
293 {
294 xml_element_name = name;
295 }
296
297 /// @brief Set the name, default value and the parameter required flag.
298 void set_parameter(const std::string& name, const bool value, bool required, Parameter<bool>& param)
299 {
300 param.set(name, required, value);
301 params_map[name] = &param;
302 }
303
304 void set_parameter(const std::string& name, const double value, bool required, Parameter<double>& param)
305 {
306 param.set(name, required, value);
307 params_map[name] = &param;
308 }
309
310 void set_parameter(const std::string& name, std::initializer_list<double> value, bool required, VectorParameter<double>& param)
311 {
312 param.set(name, required, value);
313 params_map[name] = &param;
314 }
315
316 void set_parameter(const std::string& name, std::initializer_list<int> value, bool required, VectorParameter<int>& param)
317 {
318 param.set(name, required, value);
319 params_map[name] = &param;
320 }
321
322 void set_parameter(const std::string& name, std::initializer_list<std::string> value, bool required,
324 {
325 param.set(name, required, value);
326 params_map[name] = &param;
327 }
328
329 void set_parameter(const std::string& name, const int value, bool required, Parameter<int>& param, std::vector<int> range = {})
330 {
331 param.set(name, required, value);
332 params_map[name] = &param;
333 }
334
335 void set_parameter(const std::string& name, const std::string& value, bool required, Parameter<std::string>& param)
336 {
337 param.set(name, required, value);
338 params_map[name] = &param;
339 }
340
341 /// @brief set_parameter function to handle CANNRow
342 void set_parameter_value_CANN(const std::string& name, const std::string& value)
343 {
344 if (params_map.count(name) == 0) {
345 svmp::raise<svmp::ParseException>(SVMP_HERE, "Unknown " + xml_element_name + " XML element '" + name + "'.");
346 }
347
348 auto& param_variant = params_map[name];
349
350 // Check for Activation_functions
351 if (name == "Activation_functions") {
352 if (auto* vec_param = std::get_if<VectorParameter<int>*>(&param_variant)) {
353 (*vec_param)->value_.clear(); // Clear the vector before setting
354 (*vec_param)->set(value); // Set the new value
355 } else {
356 svmp::raise<svmp::ParseException>(SVMP_HERE, "Activation_functions is not a VectorParameter<int>.");
357 }
358 }
359 // Check for Weights
360 else if (name == "Weights") {
361 if (auto* vec_param = std::get_if<VectorParameter<double>*>(&param_variant)) {
362 (*vec_param)->value_.clear(); // Clear the vector before setting
363 (*vec_param)->set(value); // Set the new value
364 } else {
365 svmp::raise<svmp::ParseException>(SVMP_HERE, "Weights is not a VectorParameter<double>.");
366 }
367 }
368 // Default: everything else
369 else {
370 std::visit([&](auto&& p) -> void {
371 p->set(value);
372 }, param_variant);
373 }
374 }
375
376
377
378 /// @brief Set the value of a paramter from a string.
379 void set_parameter_value(const std::string& name, const std::string& value)
380 {
381 if (params_map.count(name) == 0) {
382 svmp::raise<svmp::ParseException>(SVMP_HERE, "Unknown " + xml_element_name + " XML element '" + name + "'.");
383 }
384
385 std::visit([value](auto&& p) { p->set(value); }, params_map[name]);
386 }
387
388 /// @brief Check if any required parameters have not been set.
390 {
391 bool unset_found = false;
392
393 for (auto& [ key, param ] : params_map) {
394 if (std::visit([](auto&& p) {
395 return !p->check_required_set();
396 }, param)) {
397 svmp::raise<svmp::ParseException>(SVMP_HERE, xml_element_name + " XML element '" + key + "' has not been set.");
398 }
399 }
400 }
401
402 /// @brief Get the defined parameters as a map of strings.
403 std::map<std::string, std::string> get_parameter_list() const {
404 std::map<std::string,std::string> params;
405
406 for (auto& [ key, param ] : params_map) {
407 std::visit([&params](auto&& p) {
408 params[p->name()] = p->svalue();
409 }, param);
410 }
411
412 return params;
413 }
414
415 /// @brief Print the parameters.
417 {
418 for (auto& [ key, param ] : params_map) {
419 std::cout << key << ": ";
420 std::visit([](auto& p) {
421 std::cout << p->name_ << std::endl;
422 std::cout << p->svalue() << std::endl;
423 }, param);
424 }
425 }
426
427 /// @brief Map used for storing parameters by name / Parameter template union.
428 std::map<std::string, std::variant<Parameter<bool>*, Parameter<double>*, Parameter<int>*,
431
432 std::string xml_element_name = "";
433};
434
435//----------------------
436// IncludeParameterFile
437//----------------------
438// The IncludeParameterFile class is used to read and set the
439// root element of external XML file.
440//
442{
443 public:
444 IncludeParametersFile(const char* file_name);
445 tinyxml2::XMLDocument document;
446 tinyxml2::XMLElement* root_element = nullptr;
447 static std::string NAME;
448};
449
450//////////////////////////////////////////////////////////
451// ConstitutiveModelParameters //
452//////////////////////////////////////////////////////////
453
454// The following classes are used to store parameters for
455// various constitutive models.
456
458{
459 public:
461 bool defined() const { return value_set; };
462 void set_values(tinyxml2::XMLElement* con_model_params);
463 void print_parameters();
469 bool value_set = false;
470};
471
473{
474 public:
476 bool defined() const { return value_set; };
477 void set_values(tinyxml2::XMLElement* con_model_params);
478 void print_parameters();
483 bool value_set = false;
484};
485
486//---------------------
487// HolzapfelParameters
488//---------------------
490{
491 public:
493 bool defined() const { return value_set; };
494 void set_values(tinyxml2::XMLElement* con_model_params);
495 void print_parameters();
496
506
507 bool value_set = false;
508};
509
511{
512 public:
514 bool defined() const { return value_set; };
515 void set_values(tinyxml2::XMLElement* con_model_params);
516 void print_parameters();
521 Parameter<double> kappa;
522 bool value_set = false;
523};
524
526{
527 public:
529 bool defined() const { return value_set; };
530 void set_values(tinyxml2::XMLElement* con_model_params);
531 void print_parameters();
534 bool value_set = false;
535};
536
538{
539 public:
541 void set_values(tinyxml2::XMLElement* modl_params);
542 void print_parameters();
543 bool value_set = false;
544};
545
547{
548 public:
550 void set_values(tinyxml2::XMLElement* modl_params);
551 void print_parameters();
552 bool value_set = false;
553};
554
555/// @brief The CANNRowParameters class is used to store the parameters for
556/// each row of the CANN table for the xml element "Add_row"
558{
559 public:
561
562 void print_parameters();
563 void set_values(tinyxml2::XMLElement* xml_elem);
564
565 static const std::string xml_element_name_;
566
567 Parameter<std::string> row_name; // to identify each row
568 CANNRow row;
569
570};
571
572/// @brief The CANNParameters class stores the parameters table rows
573/// for xml element "Constitutive_model type=CANN". Each row is handled
574/// with xml element "Add_row"
575///
576/// \code {.xml}
577/// <Constitutive_model type="CANN">
578/// <Add_row row_name="1">
579/// <Invariant_num> 1 </Invariant_num>
580/// <Activation_functions> (1,1,1) </Activation_functions>
581/// <Weights> (1.0,1.0,1.0) </Weights>
582/// </Add_row>
583/// </Constitutive_model>
584/// \endcode
586{
587 public:
590 bool defined() const { return value_set; };
591 void set_values(tinyxml2::XMLElement* con_model_params);
592 void print_parameters();
593
594 std::vector<CANNRowParameters*> rows; // Store multiple rows
595
596 bool value_set = false;
597};
598
599/// @brief The ConstitutiveModelParameters class store parameters
600/// for various constitutive models.
602{
603 public:
605 void print_parameters();
607 bool defined() const { return value_set; };
608 void set_values(tinyxml2::XMLElement* modl_params);
609 static const std::string xml_element_name_;
610
611 // Model types supported.
612 static const std::string GUCCIONE_MODEL;
613 static const std::string HGO_MODEL;
614 static const std::string HOLZAPFEL_OGDEN_MODEL;
615 static const std::string HOLZAPFEL_OGDEN_MA_MODEL;
616 static const std::string LEE_SACKS;
617 static const std::string NEOHOOKEAN_MODEL;
618 static const std::string STVENANT_KIRCHHOFF_MODEL;
619 static const std::string CANN_MODEL;
620 static const std::map<std::string, std::string> constitutive_model_types;
621
622 // Constitutive model type.
624
625 GuccioneParameters guccione;
626 HolzapfelParameters holzapfel;
627 HolzapfelGasserOgdenParameters holzapfel_gasser_ogden;
628 LeeSacksParameters lee_sacks;
629 MooneyRivlinParameters mooney_rivlin;
630 NeoHookeanParameters neo_hookean;
631 StVenantKirchhoffParameters stvenant_kirchhoff;
632 CANNParameters cann;
633
634 bool value_set = false;
635};
636
637/// @brief Coupling to GenBC.
639{
640 public:
642
643 static const std::string xml_element_name_;
644
645 bool defined() const { return value_set; };
646 void set_values(tinyxml2::XMLElement* xml_elem);
647
648 // attributes.
650
651 // String parameters.
652 Parameter<std::string> zerod_code_file_path;
653
654 bool value_set = false;
655};
656
657//----------------------------------
658// svZeroDSolverInterfaceParameters
659//----------------------------------
660//
662{
663 public:
665
666 static const std::string xml_element_name_;
667
668 bool defined() const { return value_set; };
669 void set_values(tinyxml2::XMLElement* xml_elem);
670
671 Parameter<std::string> configuration_file;
672 Parameter<std::string> coupling_type;
673
674 Parameter<double> initial_flows;
675 Parameter<double> initial_pressures;
676
677 Parameter<std::string> shared_library;
678
679 bool value_set = false;
680};
681
682/// @brief Body force over a mesh using the "Add_BF" command.
683///
684/// \code {.xml}
685/// <Add_BF mesh="msh" >
686/// <Type> volumetric </Type>
687/// <Time_dependence> general </Time_dependence>
688/// <Temporal_and_spatial_values_file_path> bforce.dat </Temporal_and_spatial_values_file_path>
689/// </Add_BF>
690/// \endcode
692{
693 public:
695 void print_parameters();
696 void set_values(tinyxml2::XMLElement* xml_elem);
697 static const std::string xml_element_name_;
698
699 // Attributes.
700 Parameter<std::string> mesh_name;
701
702 // Boolean parameters.
703 Parameter<bool> ramp_function;
704
705 // Double parameters.
706 Parameter<double> value;
707
708 // String parameters.
709 Parameter<std::string> fourier_coefficients_file_path;
710 Parameter<std::string> spatial_values_file_path;
711 Parameter<std::string> temporal_and_spatial_values_file_path;
712 Parameter<std::string> temporal_values_file_path;
713 Parameter<std::string> time_dependence;
715};
716
717/// @brief RCR values for Neumann BC type.
718///
719/// \code {.xml}
720/// <RCR_values>
721/// <Proximal_resistance> 121.0 </Proximal_resistance>
722/// <Capacitance> 1.5e-5 </Capacitance>
723/// <Distal_resistance> 1212.0 </Distal_resistance>
724/// </RCR_values>
725/// \endcode
727{
728 public:
730
731 static const std::string xml_element_name_;
732
733 void set_values(tinyxml2::XMLElement* xml_elem);
734 void print_parameters();
735
736 Parameter<double> capacitance;
737 Parameter<double> distal_pressure;
738 Parameter<double> distal_resistance;
739 Parameter<double> initial_pressure;
740 Parameter<double> proximal_resistance;
741
742 bool value_set = false;
743};
744
745/// @brief svZeroDSolver coupling options under Add_BC (with Time_dependence Coupled).
746///
747/// \code {.xml}
748/// <Coupling_interface>
749/// <svZeroDSolver_block> LV_IN </svZeroDSolver_block>
750/// <Chamber_cap_surface> mesh/mesh-surfaces/endo_cap.vtp </Chamber_cap_surface>
751/// </Coupling_interface>
752/// \endcode
754{
755 public:
757
758 static const std::string xml_element_name_;
759
760 void set_values(tinyxml2::XMLElement* xml_elem);
761 void print_parameters();
762
763 Parameter<std::string> svzerod_solver_block;
764 Parameter<std::string> chamber_cap_surface;
765
766 bool value_set = false;
767};
768
769/// @brief The BoundaryConditionParameters stores paramaters for various
770/// type of boundary conditions under the Add_BC XML element.
772{
773 public:
775 void print_parameters();
776 void set_values(tinyxml2::XMLElement* bc_params);
777 static const std::string xml_element_name_;
778
779 // RCR parameters sub-element.
781
782 // svZeroDSolver coupling subsection (with Time_dependence Coupled).
783 CouplingInterfaceParameters coupling_interface;
784
785 // Add_BC name= attribute.
787
788 // Add_BC XML elements.
789 //
790 Parameter<bool> apply_along_normal_direction;
791 Parameter<std::string> bct_file_path;
792
793 Parameter<double> damping;
794 Parameter<double> distal_pressure;
795 VectorParameter<int> effective_direction;
796 Parameter<bool> follower_pressure_load;
797 Parameter<std::string> fourier_coefficients_file_path;
798
799 Parameter<bool> impose_flux;
800 Parameter<bool> impose_on_state_variable_integral;
801 Parameter<std::string> initial_displacements_file_path;
802
803 Parameter<double> penalty_parameter;
804 Parameter<double> penalty_parameter_normal;
805 Parameter<double> penalty_parameter_tangential;
806 Parameter<std::string> prestress_file_path;
808 Parameter<bool> ramp_function;
809
810 Parameter<std::string> cst_shell_bc_type;
811 Parameter<std::string> spatial_profile_file_path;
812 Parameter<std::string> spatial_values_file_path;
813 Parameter<double> stiffness;
814
815 Parameter<std::string> temporal_and_spatial_values_file_path;
816 Parameter<std::string> temporal_values_file_path;
817 Parameter<std::string> time_dependence;
818 Parameter<std::string> traction_values_file_path;
819 Parameter<double> traction_multiplier;
821
822 Parameter<bool> undeforming_neu_face;
823 Parameter<double> value;
824 Parameter<bool> weakly_applied;
825 Parameter<bool> zero_out_perimeter;
826
827 Parameter<double> resistance;
828};
829
830/// @brief The OutputParameters class stores parameters for the
831/// Output XML element under Add_equation.
832///
833/// \code {.xml}
834/// <Output type="Volume_integral" >
835/// <Temperature> true </Temperature>
836/// </Output>
837/// \endcode
839{
840 public:
842
843 static const std::string xml_element_name_;
844
845 void print_parameters();
846 void set_values(tinyxml2::XMLElement* xml_elem);
847 bool get_output_value(const std::string& name);
848 std::string get_alias_value(const std::string& name);
849
851
852 // List of output names.
853 std::vector<Parameter<bool>> output_list;
854
855 // List of alias output names.
856 std::vector<Parameter<std::string>> alias_list;
857};
858
859/// @brief The PrecomputedSolutionParameters class stores parameters for the
860/// 'Precomputed_solution' XML element used to read in the data from a precomputed solution
861/// for the simulation state
862/// \code {.xml}
863/// <Precomputed_solution>
864/// <Project_from_face> lumen_wall </Project_from_face>
865/// </Precomputed_solution>
866/// \endcode
867
869{
870 public:
872
873 void set_values(tinyxml2::XMLElement* xml_elem);
874
875 static const std::string xml_element_name_;
876
877 Parameter<std::string> field_name;
878 Parameter<std::string> file_path;
879 Parameter<double> time_step;
880 Parameter<bool> use_precomputed_solution;
881};
882
883/// @brief The ProjectionParameters class stores parameters for the
884/// 'Add_projection' XML element used for fluid-structure interaction
885/// simulations.
886/// \code {.xml}
887/// <Add_projection name="wall_inner" >
888/// <Project_from_face> lumen_wall </Project_from_face>
889/// </Add_projection>
890/// \endcode
892{
893 public:
895
896 void set_values(tinyxml2::XMLElement* xml_elem);
897
898 static const std::string xml_element_name_;
899
901
902 Parameter<std::string> project_from_face;
903 Parameter<double> projection_tolerance;
904};
905
906/// @brief The VariableWallPropsParameters class stores parameters for
907/// variable wall properties for the CMM equation.
909{
910 public:
912 static const std::string xml_element_name_;
913 bool defined() const { return value_set; };
914 void set_values(tinyxml2::XMLElement* xml_elemnt);
915
916 Parameter<std::string> mesh_name;
917 Parameter<std::string> wall_properties_file_path;
918 bool value_set = false;
919};
920
921
922//////////////////////////////////////////////////////////
923// FluidViscosity //
924//////////////////////////////////////////////////////////
925
926// The following classes are used to store parameters for
927// various fluid viscosity models.
928
930{
931 public:
933 void print_parameters();
934 void set_values(tinyxml2::XMLElement* equation_params);
935 Parameter<double> constant_value;
936};
937
939{
940 public:
942 void print_parameters();
943 void set_values(tinyxml2::XMLElement* xml_elem);
944
945 Parameter<double> limiting_high_shear_rate_viscosity;
946 Parameter<double> limiting_low_shear_rate_viscosity;
947 Parameter<double> power_law_index;
948 Parameter<double> shear_rate_tensor_multipler;
949 Parameter<double> shear_rate_tensor_exponent;
950};
951
953{
954 public:
956 void print_parameters();
957 void set_values(tinyxml2::XMLElement* xml_elem);
958 Parameter<double> asymptotic_viscosity;
959 Parameter<double> yield_stress;
960 Parameter<double> low_shear_rate_threshold;
961};
962
964{
965 public:
967
968 static const std::string xml_element_name_;
969
970 static const std::string CONSTANT_MODEL;
971 static const std::string CARREAU_YASUDA_MODEL;
972 static const std::string CASSONS_MODEL;
973 static const std::set<std::string> model_names;
974
975 void print_parameters();
976 void set_values(tinyxml2::XMLElement* xml_elem);
977
979
980 FluidViscosityNewtonianParameters newtonian_model;
981 FluidViscosityCarreauYasudaParameters carreau_yasuda_model;
983};
984
985//////////////////////////////////////////////////////////
986// SolidViscosity //
987//////////////////////////////////////////////////////////
988
989// The following classes are used to store parameters for
990// various solid viscosity models.
991
993{
994 public:
996 void print_parameters();
997 void set_values(tinyxml2::XMLElement* equation_params);
998 Parameter<double> constant_value;
999};
1000
1002{
1003 public:
1005 void print_parameters();
1006 void set_values(tinyxml2::XMLElement* equation_params);
1007 Parameter<double> constant_value;
1008};
1009
1011{
1012 public:
1014
1015 static const std::string xml_element_name_;
1016
1017 static const std::string NEWTONIAN_MODEL;
1018 static const std::string POTENTIAL_MODEL;
1019 static const std::set<std::string> model_names;
1020
1021 void print_parameters();
1022 void set_values(tinyxml2::XMLElement* xml_elem);
1023
1025
1026 SolidViscosityNewtonianParameters newtonian_model;
1027 SolidViscosityPotentialParameters potential_model;
1028};
1029
1030
1031/// @brief The LinearAlgebraParameters class stores parameters for
1032/// the 'Linear_algebra' XML element.
1034{
1035 public:
1036 static const std::string xml_element_name_;
1039 void print_parameters();
1040 void set_values(tinyxml2::XMLElement* fsi_file);
1041 bool defined() const { return values_set_; };
1042
1043 bool values_set_ = false;
1045
1046 Parameter<std::string> assembly;
1047 Parameter<std::string> configuration_file;
1048 Parameter<std::string> preconditioner;
1049};
1050
1051/// @brief The LinearSolverParameters class stores parameters for
1052/// the 'LS' XML element.
1054{
1055 public:
1057
1058 void print_parameters();
1059 void set_values(tinyxml2::XMLElement* fsi_file);
1060
1061 static const std::string xml_element_name_;
1062
1064
1065 Parameter<double> absolute_tolerance;
1066 Parameter<int> krylov_space_dimension;
1067
1068 Parameter<int> max_iterations;
1069 Parameter<int> ns_cg_max_iterations;
1070 Parameter<double> ns_cg_tolerance;
1071 Parameter<int> ns_gm_max_iterations;
1072 Parameter<double> ns_gm_tolerance;
1073
1074 //Parameter<std::string> preconditioner;
1075
1076 Parameter<double> tolerance;
1077
1078 LinearAlgebraParameters linear_algebra;
1079};
1080
1081/// @brief The StimulusParameters class stores parameters for
1082/// 'Stimulus' XML element used to parameters for
1083/// pacemaker cells.
1084///
1085/// \code {.xml}
1086/// <Stimulus type="Istim" >
1087/// <Amplitude> -52.0 </Amplitude>
1088/// <Start_time> 0.0 </Start_time>
1089/// <Duration> 1.0 </Duration>
1090/// <Cycle_length> 10000.0 </Cycle_length>
1091/// </Stimulus>
1092/// \endcode
1094{
1095 public:
1097
1098 static const std::string xml_element_name_;
1099
1100 bool defined() const { return value_set; };
1101 void print_parameters();
1102 void set_values(tinyxml2::XMLElement* xml_elem);
1103
1105
1106 Parameter<double> amplitude;
1107 Parameter<double> cycle_length;
1108 Parameter<double> duration;
1109 Parameter<double> start_time;
1110
1111 bool value_set = false;
1112};
1113
1115{
1116 public:
1118
1119 static const std::string xml_element_name_;
1120
1121 bool defined() const { return value_set; };
1122 void print_parameters();
1123 void set_values(tinyxml2::XMLElement* xml_elem);
1124
1125 Parameter<std::string> x_coords_file_path;
1126 Parameter<std::string> y_coords_file_path;
1127 Parameter<std::string> z_coords_file_path;
1128
1129 bool value_set = false;
1130};
1131
1132/// @brief The DirectionalDistributionParameters class stores directional
1133/// distribution parameters for active stress.
1134///
1135/// \code {.xml}
1136/// <Directional_distribution>
1137/// <Fiber_direction> 1.0 </Fiber_direction>
1138/// <Sheet_direction> 0.0 </Sheet_direction>
1139/// <Sheet_normal_direction> 0.0 </Sheet_normal_direction>
1140/// </Directional_distribution>
1141/// \endcode
1143{
1144 public:
1146
1147 static const std::string xml_element_name_;
1148
1149 bool defined() const { return value_set; };
1150 void print_parameters();
1151 void set_values(tinyxml2::XMLElement* xml_elem);
1152 void validate() const; // Validate directional fractions
1153
1154 Parameter<double> fiber_direction;
1155 Parameter<double> sheet_direction;
1156 Parameter<double> sheet_normal_direction;
1157
1158 bool value_set = false;
1159};
1160
1161/// @brief The FiberReinforcementStressParameters class stores fiber
1162/// reinforcement stress parameters for the 'Fiber_reinforcement_stress`
1163/// XML element.
1164///
1165/// \code {.xml}
1166/// <Fiber_reinforcement_stress type="Unsteady" >
1167/// <Temporal_values_file_path> fib_stress.dat </Temporal_values_file_path>
1168/// <Ramp_function> true </Ramp_function>
1169/// <Directional_distribution>
1170/// <Fiber_direction> 0.7 </Fiber_direction>
1171/// <Sheet_direction> 0.2 </Sheet_direction>
1172/// <Sheet_normal_direction> 0.1 </Sheet_normal_direction>
1173/// </Directional_distribution>
1174/// </Fiber_reinforcement_stress>
1175/// \endcode
1177{
1178 public:
1180
1181 static const std::string xml_element_name_;
1182
1183 bool defined() const { return value_set; };
1184 void print_parameters();
1185 void set_values(tinyxml2::XMLElement* xml_elem);
1186
1188
1189 Parameter<bool> ramp_function;
1190 Parameter<std::string> temporal_values_file_path;
1191 Parameter<double> value;
1192
1193 // Directional stress distribution parameters
1194 DirectionalDistributionParameters directional_distribution;
1195
1196 bool value_set = false;
1197};
1198
1199/// @brief Generic ionic model initial conditions parameters.
1201public:
1202 /// Constructor.
1204 const std::string &xml_element_name_,
1205 const std::vector<std::pair<std::string, double>> &states);
1206
1207 /// Return whether the parameters represented by this object were defined.
1208 bool defined() const { return value_set; }
1209
1210 /// Print the value of parameters.
1211 void print_parameters() const;
1212
1213 /// Set the value of parameters in this object from an XML element.
1214 void set_values(const tinyxml2::XMLElement *xml_elem);
1215
1216 /// Get the value of a parameter by label.
1217 double operator[](const std::string &label) const {
1218 return parameters.at(label).value();
1219 }
1220
1221 /// Name of the XML element for this object.
1222 const std::string xml_element_name;
1223
1224 /// Flag indicating whether these XML section represented by this object is
1225 /// required. It is set to true if the number of states provided to the
1226 /// constructor is greater than zero.
1227 const bool required;
1228
1229protected:
1230 /// Parameter instances underlying this object.
1231 std::map<std::string, Parameter<double>> parameters;
1232
1233 /// Flag indicating whether the values of the parameters stored in this
1234 /// object have been set.
1235 bool value_set = false;
1236};
1237
1238/// @brief Initial conditions parameters for a generic ionic model.
1239///
1240/// Bundles initial conditions for the model's ionic concentrations and gating
1241/// variables, represented by two instances of IonicInitialStateParameters.
1243public:
1244 /// Constructor.
1246 const std::string &xml_element_name_,
1247 const std::vector<std::pair<std::string, double>> &initial_X,
1248 const std::vector<std::pair<std::string, double>> &initial_Xg);
1249
1250 /// Return whether the parameters represented by this object were defined.
1251 bool defined() const { return value_set; }
1252
1253 /// Print the value of parameters.
1254 void print_parameters() const;
1255
1256 /// Set the values of parameters in this object from an XML element.
1257 void set_values(const tinyxml2::XMLElement *xml_elem);
1258
1259 /// Get the parameters for the state variables.
1263
1264 /// Get the parameters for the gating variables.
1268
1269 /// Name of the XML element for this object.
1270 const std::string xml_element_name;
1271
1272 /// Get the value of a scalar parameter by label.
1273 double get_scalar(const std::string &label) const {
1274 return parameters.at(label).value();
1275 }
1276
1277 /// Get the value of a vector parameter by label.
1278 Vector<double> get_vector(const std::string &label) const {
1279 auto param_value = vector_parameters.at(label).value();
1280
1281 Vector<double> param_vec(param_value.size());
1282 for (size_t i = 0; i < param_value.size(); ++i)
1283 param_vec[i] = param_value[i];
1284
1285 return param_vec;
1286 }
1287
1288protected:
1289 /// Add a new parameter to this object.
1290 void add_parameter(const std::string &label, double default_value,
1291 bool required) {
1292 set_parameter(label, default_value, required, parameters[label]);
1293 }
1294
1295 /// Add a new vector parameter to this object.
1296 void add_parameter(const std::string &label,
1297 std::initializer_list<double> default_value,
1298 bool required) {
1299 set_parameter(label, default_value, required, vector_parameters[label]);
1300 }
1301
1302 /// Parameters for the state variables.
1304
1305 /// Parameters for the gating variables.
1307
1308 /// Other parameters (i.e. other than initial conditions) are stored in a map
1309 /// as key-parameter pairs. Derived classes should add parameters to this map
1310 /// in their constructors by calling add_parameter.
1311 std::map<std::string, Parameter<double>> parameters;
1312
1313 /// Vector parameters are stored in a map as key-parameter pairs.
1314 std::map<std::string, VectorParameter<double>> vector_parameters;
1315
1316 /// Flag indicating whether the values of the parameters stored in this
1317 /// object have been set.
1318 bool value_set = false;
1319};
1320
1321/// @brief The DomainParameters class stores parameters for the XML
1322/// 'Domain' element to specify properties for solving equations.
1323///
1324/// \code {.xml}
1325/// <Domain id="1" >
1326/// <Equation> fluid </Equation>
1327/// <Density> 1.06 </Density>
1328/// <Viscosity model="Constant" >
1329/// <Value> 0.04 </Value>
1330/// </Viscosity>
1331/// <Backflow_stabilization_coefficient> 0.2 </Backflow_stabilization_coefficient>
1332/// </Domain>
1333/// \endcode
1335{
1336 public:
1338
1339 static const std::string xml_element_name_;
1340
1341 void print_parameters();
1342 void set_values(tinyxml2::XMLElement* xml_elem, bool from_external_xml = false);
1343
1344 // Parameters for sub-elements under the Domain element.
1345 ConstitutiveModelParameters constitutive_model;
1346 FiberReinforcementStressParameters fiber_reinforcement_stress;
1347 StimulusParameters stimulus;
1348 FluidViscosityParameters fluid_viscosity;
1349 SolidViscosityParameters solid_viscosity;
1350
1351 // Ionic model parameters.
1352 std::map<std::string, std::unique_ptr<IonicModelParameters>> ionic_models;
1353
1354 // Attributes.
1356
1357 Parameter<double> absolute_tolerance;
1358 VectorParameter<double> anisotropic_conductivity;
1359 Parameter<double> backflow_stabilization_coefficient;
1360
1361 Parameter<double> conductivity;
1362 //Parameter<std::string> constitutive_model_name;
1363 Parameter<double> continuity_stabilization_coefficient;
1364
1365 Parameter<double> density;
1366 Parameter<std::string> dilational_penalty_model;
1367
1368 Parameter<std::string> equation;
1369 Parameter<double> elasticity_modulus;
1370 Parameter<std::string> electrophysiology_model;
1371
1372 Parameter<double> feedback_parameter_for_stretch_activated_currents;
1373 Parameter<double> fluid_density;
1374 Parameter<double> force_x;
1375 Parameter<double> force_y;
1376 Parameter<double> force_z;
1377
1378 Parameter<std::string> include_xml;
1379 Parameter<double> isotropic_conductivity;
1380
1381 Parameter<double> mass_damping;
1382 Parameter<int> maximum_iterations;
1383 Parameter<double> momentum_stabilization_coefficient;
1384 Parameter<std::string> myocardial_zone;
1385
1386 Parameter<std::string> ode_solver;
1387 Parameter<double> penalty_parameter;
1388 Parameter<double> poisson_ratio;
1389 Parameter<double> relative_tolerance;
1390
1391 Parameter<double> shell_thickness;
1392 Parameter<double> solid_density;
1393 Parameter<double> source_term;
1394 Parameter<double> time_step_for_integration;
1395
1396 // Inverse of Darcy permeability. Default value of 0.0 for Navier-Stokes and non-zero for Navier-Stokes-Brinkman
1397 Parameter<double> inverse_darcy_permeability;
1398};
1399
1400/// @brief The RemesherParameters class stores parameters for the
1401/// 'Remesher' XML element used for remeshing.
1402///
1403/// \code {.xml}
1404/// <Remesher type="Tetgen" >
1405/// <Max_edge_size name="lumen" value="0.7"> </Max_edge_size>
1406/// <Max_edge_size name="wall" value="0.5"> </Max_edge_size>
1407/// <Min_dihedral_angle> 10.0 </Min_dihedral_angle>
1408/// <Max_radius_ratio> 1.1 </Max_radius_ratio>
1409/// <Remesh_frequency> 1000 </Remesh_frequency>
1410/// <Frequency_for_copying_data> 1 </Frequency_for_copying_data>
1411/// </Remesher>
1412/// \endcode
1414{
1415 public:
1417
1418 static const std::string xml_element_name_;
1419 bool values_set_ = false;
1420
1421 bool defined() const { return values_set_; };
1422 void print_parameters();
1423 double get_edge_size(const std::string& name) const { return max_edge_sizes_.at(name); }
1424 bool has_edge_size(const std::string& name) const { return max_edge_sizes_.count(name) == 1; }
1425 void set_values(tinyxml2::XMLElement* mesh_elem);
1426
1427 // Values given in the 'Max_edge_size' element.
1428 std::map<std::string, double> max_edge_sizes_;
1429
1431 Parameter<double> min_dihedral_angle;
1432 Parameter<double> max_radius_ratio;
1433 Parameter<int> remesh_frequency;
1434 Parameter<int> frequency_for_copying_data;
1435};
1436
1437/// @brief The ContactParameters class stores parameters for the 'Contact''
1438/// XML element used to specify parameter values for contact
1439/// computations.
1441{
1442 public:
1444
1445 static const std::string xml_element_name_;
1446
1447 void print_parameters();
1448 void set_values(tinyxml2::XMLElement* xml_elem);
1449
1450 Parameter<double> closest_gap_to_activate_penalty;
1451
1452 Parameter<double> desired_separation;
1453
1454 Parameter<double> min_norm_of_face_normals;
1455
1457
1458 Parameter<double> penalty_constant;
1459};
1460
1461/// @brief The EquationParameters class stores parameters for the 'Add_equation'
1462/// XML element used to specify an equation to be solved (e.g. fluid).
1463///
1464/// \code {.xml}
1465/// <Add_equation type="FSI" >
1466/// <Coupled> true </Coupled>
1467/// <Min_iterations> 1 </Min_iterations>
1468/// <Max_iterations> 1 </Max_iterations>
1469/// .
1470/// .
1471/// .
1472/// </Add_equation>
1473/// \endcode
1475{
1476 public:
1478
1479 static const std::string xml_element_name_;
1480
1481 void print_parameters();
1482 void set_values(tinyxml2::XMLElement* xml_elem, DomainParameters* default_domain=nullptr);
1483
1484 Parameter<double> backflow_stabilization_coefficient;
1485
1486 Parameter<double> conductivity;
1487 Parameter<double> continuity_stabilization_coefficient;
1488 Parameter<bool> coupled;
1489
1490 Parameter<double> density;
1491 Parameter<std::string> dilational_penalty_model;
1492
1493 Parameter<double> elasticity_modulus;
1494
1495 Parameter<std::string> include_xml;
1496 Parameter<std::string> initialize;
1497 Parameter<bool> initialize_rcr_from_flow;
1498
1499 Parameter<int> max_iterations;
1500 Parameter<int> min_iterations;
1501 Parameter<double> momentum_stabilization_coefficient;
1502
1503 Parameter<double> penalty_parameter;
1504 Parameter<double> poisson_ratio;
1505 Parameter<bool> prestress;
1506
1507 Parameter<double> source_term;
1508 Parameter<double> tolerance;
1509
1511 Parameter<bool> use_taylor_hood_type_basis;
1512
1513 // Explicit geometric coupling for FSI simulations: the fluid-structure equations
1514 // are solved to convergence using the mesh displacement from the previous time step,
1515 // and only then is the mesh equation solved.
1516 Parameter<bool> explicit_geometric_coupling;
1517
1518 // Inverse of Darcy permeability. Default value of 0.0 for Navier-Stokes and non-zero for Navier-Stokes-Brinkman
1519 Parameter<double> inverse_darcy_permeability;
1520
1521 // Sub-element parameters.
1522 //
1523 std::vector<BodyForceParameters*> body_forces;
1524
1525 std::vector<BoundaryConditionParameters*> boundary_conditions;
1526
1527 CoupleGenBCParameters couple_to_genBC;
1528
1529 svZeroDSolverInterfaceParameters svzerodsolver_interface_parameters;
1530
1531 DomainParameters* default_domain = nullptr;
1532
1533 std::vector<DomainParameters*> domains;
1534
1535 LinearSolverParameters linear_solver;
1536
1537 std::vector<OutputParameters*> outputs;
1538
1539 RemesherParameters remesher;
1540
1541 VariableWallPropsParameters variable_wall_properties;
1542
1543 FluidViscosityParameters fluid_viscosity;
1544
1545 SolidViscosityParameters solid_viscosity;
1546
1547 ECGLeadsParameters ecg_leads;
1548
1549};
1550
1551/// @brief The GeneralSimulationParameters class stores paramaters for the
1552/// 'GeneralSimulationParameters' XML element.
1553///
1554/// \code {.xml}
1555/// <GeneralSimulationParameters>
1556/// <Continue_previous_simulation> 0 </Continue_previous_simulation>
1557/// <Number_of_spatial_dimensions> 3 </Number_of_spatial_dimensions>
1558/// <Number_of_time_steps> 1 </Number_of_time_steps>
1559/// <Time_step_size> 1e-4 </Time_step_size>
1560/// <Spectral_radius_of_infinite_time_step> 0.50 </Spectral_radius_of_infinite_time_step>
1561/// <Searched_file_name_to_trigger_stop> STOP_SIM </Searched_file_name_to_trigger_stop>
1562/// <Save_results_to_VTK_format> true </Save_results_to_VTK_format>
1563/// <Name_prefix_of_saved_VTK_files> result </Name_prefix_of_saved_VTK_files>
1564/// <Increment_in_saving_VTK_files> 1 </Increment_in_saving_VTK_files>
1565/// <Start_saving_after_time_step> 1 </Start_saving_after_time_step>
1566/// <Increment_in_saving_restart_files> 1 </Increment_in_saving_restart_files>
1567/// <Convert_BIN_to_VTK_format> 0 </Convert_BIN_to_VTK_format>
1568/// <Verbose> 1 </Verbose>
1569/// <Warning> 0 </Warning>
1570/// <Debug> 0 </Debug>
1571/// <Simulation_requires_remeshing> true </Simulation_requires_remeshing>
1572/// </GeneralSimulationParameters>
1573/// \endcode
1575{
1576 public:
1578
1579 void print_parameters();
1580 void set_values(tinyxml2::XMLElement* xml_element, bool from_external_xml = false);
1581
1582 std::string xml_element_name;
1583
1584 Parameter<bool> check_ien_order;
1585 Parameter<bool> continue_previous_simulation;
1586 Parameter<bool> convert_bin_to_vtk_format;
1587 Parameter<bool> debug;
1588 Parameter<bool> overwrite_restart_file;
1589 Parameter<bool> save_averaged_results;
1590 Parameter<bool> save_results_to_vtk_format;
1591 Parameter<bool> simulation_requires_remeshing;
1592 Parameter<bool> start_averaging_from_zero;
1593 Parameter<bool> verbose;
1594 Parameter<bool> warning;
1595
1596 Parameter<double> spectral_radius_of_infinite_time_step;
1597 Parameter<double> time_step_size;
1598
1599 Parameter<std::string> include_xml;
1600 Parameter<int> increment_in_saving_restart_files;
1601 Parameter<int> increment_in_saving_vtk_files;
1602 Parameter<int> number_of_spatial_dimensions;
1603 Parameter<int> number_of_initialization_time_steps;
1604 Parameter<int> start_saving_after_time_step;
1605 Parameter<int> starting_time_step;
1606 Parameter<int> number_of_time_steps;
1607
1608 Parameter<std::string> name_prefix_of_saved_vtk_files;
1609 Parameter<std::string> restart_file_name;
1610 Parameter<std::string> searched_file_name_to_trigger_stop;
1611 Parameter<std::string> save_results_in_folder;
1612 Parameter<std::string> simulation_initialization_file_path;
1613};
1614
1615/// @brief The FaceParameters class is used to store parameters for the
1616/// 'Add_face' XML element.
1618{
1619 public:
1621
1622 void print_parameters();
1623 void set_values(tinyxml2::XMLElement* xml_elem);
1624
1625 static const std::string xml_element_name_;
1626
1627 Parameter<std::string> end_nodes_face_file_path;
1628 Parameter<std::string> face_file_path;
1630
1631 Parameter<double> quadrature_modifier_TRI3;
1632};
1633
1634/// @brief The MeshParameters class is used to store paramaters for the
1635/// 'Add_mesh' XML element.
1636///
1637/// \code {.xml}
1638/// <Add_mesh name="lumen" >
1639/// <Mesh_file_path> mesh/lumen/mesh-complete.mesh.vtu </Mesh_file_path>
1640///
1641/// <Add_face name="lumen_inlet">
1642/// <Face_file_path> mesh/lumen/mesh-surfaces/lumen_inlet.vtp </Face_file_path>
1643/// </Add_face>
1644///
1645/// <Add_face name="lumen_outlet">
1646/// <Face_file_path> mesh/lumen/mesh-surfaces/lumen_outlet.vtp </Face_file_path>
1647/// </Add_face>
1648///
1649/// <Add_face name="lumen_wall">
1650/// <Face_file_path> mesh/lumen/mesh-surfaces/lumen_wall.vtp </Face_file_path>
1651/// </Add_face>
1652///
1653/// <Domain> 0 </Domain>
1654///
1655/// </Add_mesh>
1656/// \endcode
1658{
1659 public:
1661
1662 static const std::string xml_element_name_;
1663
1664 void print_parameters();
1665 void set_values(tinyxml2::XMLElement* mesh_elem, bool from_external_xml = false);
1666 std::string get_name() const { return name.value(); };
1667 std::string get_path() const { return mesh_file_path.value(); };
1668
1669 std::vector<FaceParameters*> face_parameters;
1670
1671 // Add_mesh name=
1673
1674 // Parameters under Add_mesh
1675 //
1676 Parameter<int> domain_id;
1677 Parameter<std::string> domain_file_path;
1678
1679 VectorParameter<std::string> fiber_direction_file_paths;
1680 //Parameter<std::string> fiber_direction_file_path;
1681 std::vector<VectorParameter<double>> fiber_directions;
1682 //VectorParameter<double> fiber_direction;
1683
1684 Parameter<std::string> include_xml;
1685 Parameter<std::string> initial_displacements_file_path;
1686 Parameter<std::string> initial_pressures_file_path;
1687 Parameter<bool> initialize_rcr_from_flow;
1688 Parameter<std::string> initial_velocities_file_path;
1689
1690 Parameter<std::string> mesh_file_path;
1691 Parameter<double> mesh_scale_factor;
1692 Parameter<std::string> prestress_file_path;
1693
1694 Parameter<bool> set_mesh_as_fibers;
1695 Parameter<bool> set_mesh_as_shell;
1696
1697 Parameter<double> quadrature_modifier_TET4;
1698};
1699
1700//////////////////////////////////////////////////////////
1701// Resistive immersed surfaces method //
1702//////////////////////////////////////////////////////////
1703
1704/// @brief The RISProjectionParameters class stores parameters for the
1705/// 'Add_RIS_projection' XML element used for RIS valve simulations.
1706/// \code {.xml}
1707/// <Add_RIS_projection name="left_ris" >
1708/// <Project_from_face> right_ris </Project_from_face>
1709/// <Resistance> 1.e6 </Resistance>
1710/// </Add_RIS_projection>
1711/// \endcode
1713{
1714 public:
1716
1717 void set_values(tinyxml2::XMLElement* xml_elem);
1718
1719 static const std::string xml_element_name_;
1720
1722
1723 Parameter<std::string> project_from_face;
1724 Parameter<double> resistance;
1725 Parameter<double> projection_tolerance;
1726};
1727
1728/// @brief The URISFaceParameters class is used to store parameters for the
1729/// 'Add_URIS_face' XML element.
1731{
1732 public:
1734
1735 void print_parameters();
1736 void set_values(tinyxml2::XMLElement* xml_elem);
1737
1738 static const std::string xml_element_name_;
1739
1740 Parameter<std::string> name; // Name of the valve surface
1741
1742 Parameter<std::string> face_file_path; // File path for the valve surface
1743 Parameter<std::string> open_motion_file_path; // File path for the open motion of the valve
1744 Parameter<std::string> close_motion_file_path; // File path for the close motion of the valve
1745
1746};
1747
1748/// @brief The URISMeshParameters class is used to store paramaters for the
1749/// 'Add_URIS_mesh' XML element.
1750///
1751/// \code {.xml}
1752/// <Add_uris_mesh name="MV" >
1753/// <Add_uris_face name="LCC" >
1754/// <Face_file_path> meshes/uris_face.vtu </Face_file_path>
1755/// <Open_motion_file_path> meshes/uris_facemotion_open.dat </Open_motion_file_path>
1756/// <Close_motion_file_path> meshes/uris_facemotion_close.dat </Close_motion_file_path>
1757/// </Add_uris_face>
1758/// <Mesh_scale_factor> 1.0 </Mesh_scale_factor>
1759/// <Thickness> 0.25 </Thickness>
1760/// <Resistance> 1.0e5 </Resistance>
1761/// <Positive_flow_normal_file> meshes/normal.dat </Positive_flow_normal_file>
1762/// </Add_uris_mesh>
1763/// \endcode
1765{
1766 public:
1768
1769 static const std::string xml_element_name_;
1770
1771 void print_parameters();
1772 void set_values(tinyxml2::XMLElement* mesh_elem);
1773 std::string get_name() const { return name.value(); };
1774 // std::string get_path() const { return mesh_file_path.value(); };
1775
1776 std::vector<URISFaceParameters*> URIS_face_parameters;
1777
1778 // Add_mesh name
1779 Parameter<std::string> name; // Name of the valve mesh
1780
1781 // Parameters under Add_URIS_mesh
1782 Parameter<double> mesh_scale_factor; // Scale factor for the mesh
1783 Parameter<double> thickness; // Thickness of the valve
1784 Parameter<double> close_thickness; // Thickness of the valve when it is closed
1785 Parameter<double> resistance; // Resistance of the valve
1786 Parameter<bool> valve_starts_as_closed; // Whether the valve starts as closed
1787 Parameter<bool> invert_normal; // Whether to invert the valve surface normal vector
1788 Parameter<std::string> positive_flow_normal_file_path; // File path for the positive flow normal
1789 Parameter<bool> include_uris_velocity; // Whether to include the RIS velocity
1790};
1791
1792
1793
1794/// @brief The Parameters class stores parameter values read in from a solver input file.
1796
1797 public:
1798 Parameters();
1799
1800 static const std::set<std::string> constitutive_model_names;
1801 static const std::set<std::string> equation_names;
1802 static const std::string FSI_FILE;
1803
1804 void get_logging_levels(int& verbose, int& warning, int& debug);
1805 void print_parameters();
1806 void read_xml(std::string file_name);
1807
1808 void set_contact_values(tinyxml2::XMLElement* root_element);
1809 void set_equation_values(tinyxml2::XMLElement* root_element);
1810 void set_mesh_values(tinyxml2::XMLElement* root_element);
1811 void set_precomputed_solution_values(tinyxml2::XMLElement* root_element);
1812 void set_projection_values(tinyxml2::XMLElement* root_element);
1813 void set_svzerodsolver_interface_values(tinyxml2::XMLElement* root_element);
1814
1815 void set_RIS_projection_values(tinyxml2::XMLElement* root_element);
1816 void set_URIS_mesh_values(tinyxml2::XMLElement* root_element);
1817
1818 // Objects representing each parameter section of XML file.
1819 ContactParameters contact_parameters;
1820 GeneralSimulationParameters general_simulation_parameters;
1821 std::vector<MeshParameters*> mesh_parameters;
1822 std::vector<EquationParameters*> equation_parameters;
1823 std::vector<ProjectionParameters*> projection_parameters;
1824 PrecomputedSolutionParameters precomputed_solution_parameters;
1825
1826 std::vector<RISProjectionParameters*> RIS_projection_parameters;
1827 std::vector<URISMeshParameters*> URIS_mesh_parameters;
1828
1829};
1830
1831#endif
Body force over a mesh using the "Add_BF" command.
Definition Parameters.h:692
static const std::string xml_element_name_
Define the XML element name for boundary condition parameters.
Definition Parameters.h:697
The BoundaryConditionParameters stores paramaters for various type of boundary conditions under the A...
Definition Parameters.h:772
static const std::string xml_element_name_
Define the XML element name for equation boundary condition parameters.
Definition Parameters.h:777
RCR values for Neumann BC type.
Definition Parameters.h:727
BoundaryConditionRCRParameters()
RCR values for Neumann BC type.
Definition Parameters.cpp:439
The CANNParameters class stores the parameters table rows for xml element "Constitutive_model type=CA...
Definition Parameters.h:586
CANNParameters()
Constructor for CANNParameters class. Initializes parameter table.
Definition Parameters.cpp:975
~CANNParameters()
Destructor for CANNParameters class. Deletes memory dynamically allocated to the rows of the table.
Definition Parameters.cpp:987
The CANNRowParameters class is used to store the parameters for each row of the CANN table for the xm...
Definition Parameters.h:558
static const std::string xml_element_name_
Process parameters for the "Add_row" xml element.
Definition Parameters.h:565
The ConstitutiveModelParameters class store parameters for various constitutive models.
Definition Parameters.h:602
void check_constitutive_model(const Parameter< std::string > &eq_type)
Check if a constitutive model is valid for the given equation.
Definition Parameters.cpp:1083
static const std::map< std::string, std::string > constitutive_model_types
Supported constitutive model types and their aliases.
Definition Parameters.h:634
static const std::string xml_element_name_
Process parameters for various constitutive models.
Definition Parameters.h:609
The ContactParameters class stores parameters for the 'Contact'' XML element used to specify paramete...
Definition Parameters.h:1441
static const std::string xml_element_name_
Process parameters for the 'Contact' XML element used to specify parameters for contact computation.
Definition Parameters.h:1445
Coupling to GenBC.
Definition Parameters.h:639
static const std::string xml_element_name_
Coupling to GenBC.
Definition Parameters.h:643
svZeroDSolver coupling options under Add_BC (with Time_dependence Coupled).
Definition Parameters.h:754
The DirectionalDistributionParameters class stores directional distribution parameters for active str...
Definition Parameters.h:1143
static const std::string xml_element_name_
Define the XML element name for directional distribution parameters.
Definition Parameters.h:1147
The DomainParameters class stores parameters for the XML 'Domain' element to specify properties for s...
Definition Parameters.h:1335
static const std::string xml_element_name_
Define the XML element name for domain parameters.
Definition Parameters.h:1339
Definition Parameters.h:1115
static const std::string xml_element_name_
Define the XML element name for ECG leads parameters.
Definition Parameters.h:1119
The EquationParameters class stores parameters for the 'Add_equation' XML element used to specify an ...
Definition Parameters.h:1475
static const std::string xml_element_name_
Define the XML element name for equation parameters.
Definition Parameters.h:1479
The FaceParameters class is used to store parameters for the 'Add_face' XML element.
Definition Parameters.h:1618
static const std::string xml_element_name_
Process parameters for the 'Add_face' XML element.
Definition Parameters.h:1625
The FiberReinforcementStressParameters class stores fiber reinforcement stress parameters for the 'Fi...
Definition Parameters.h:1177
static const std::string xml_element_name_
Define the XML element name for fiber reinforcement stress parameters.
Definition Parameters.h:1181
Definition Parameters.h:939
Definition Parameters.h:953
Definition Parameters.h:930
Definition Parameters.h:964
static const std::string xml_element_name_
Process parameters for various fluid viscosity models.
Definition Parameters.h:968
The GeneralSimulationParameters class stores paramaters for the 'GeneralSimulationParameters' XML ele...
Definition Parameters.h:1575
void set_values(tinyxml2::XMLElement *xml_element, bool from_external_xml=false)
Set general parameters values from XML.
Definition Parameters.cpp:2562
GeneralSimulationParameters()
Process paramaters for the 'GeneralSimulationParameters' XML element.
Definition Parameters.cpp:2502
Definition Parameters.h:473
Definition Parameters.h:511
Definition Parameters.h:490
Definition Parameters.h:442
Generic ionic model initial conditions parameters.
Definition Parameters.h:1200
const bool required
Definition Parameters.h:1227
void set_values(const tinyxml2::XMLElement *xml_elem)
Set the value of parameters in this object from an XML element.
Definition Parameters.cpp:1616
bool value_set
Definition Parameters.h:1235
void print_parameters() const
Print the value of parameters.
Definition Parameters.cpp:1607
bool defined() const
Return whether the parameters represented by this object were defined.
Definition Parameters.h:1208
double operator[](const std::string &label) const
Get the value of a parameter by label.
Definition Parameters.h:1217
const std::string xml_element_name
Name of the XML element for this object.
Definition Parameters.h:1222
std::map< std::string, Parameter< double > > parameters
Parameter instances underlying this object.
Definition Parameters.h:1231
Initial conditions parameters for a generic ionic model.
Definition Parameters.h:1242
const IonicInitialStateParameters & get_initial_X() const
Get the parameters for the state variables.
Definition Parameters.h:1260
std::map< std::string, VectorParameter< double > > vector_parameters
Vector parameters are stored in a map as key-parameter pairs.
Definition Parameters.h:1314
IonicInitialStateParameters initial_X_parameters
Parameters for the state variables.
Definition Parameters.h:1303
double get_scalar(const std::string &label) const
Get the value of a scalar parameter by label.
Definition Parameters.h:1273
Vector< double > get_vector(const std::string &label) const
Get the value of a vector parameter by label.
Definition Parameters.h:1278
bool defined() const
Return whether the parameters represented by this object were defined.
Definition Parameters.h:1251
IonicInitialStateParameters initial_Xg_parameters
Parameters for the gating variables.
Definition Parameters.h:1306
void set_values(const tinyxml2::XMLElement *xml_elem)
Set the values of parameters in this object from an XML element.
Definition Parameters.cpp:1695
const std::string xml_element_name
Name of the XML element for this object.
Definition Parameters.h:1270
std::map< std::string, Parameter< double > > parameters
Definition Parameters.h:1311
bool value_set
Definition Parameters.h:1318
void add_parameter(const std::string &label, double default_value, bool required)
Add a new parameter to this object.
Definition Parameters.h:1290
void add_parameter(const std::string &label, std::initializer_list< double > default_value, bool required)
Add a new vector parameter to this object.
Definition Parameters.h:1296
void print_parameters() const
Print the value of parameters.
Definition Parameters.cpp:1663
const IonicInitialStateParameters & get_initial_Xg() const
Get the parameters for the gating variables.
Definition Parameters.h:1265
Definition Parameters.h:458
The LinearAlgebraParameters class stores parameters for the 'Linear_algebra' XML element.
Definition Parameters.h:1034
void check_input_parameters()
Check the validity of the input parameters.
Definition Parameters.cpp:3195
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:1036
The LinearSolverParameters class stores parameters for the 'LS' XML element.
Definition Parameters.h:1054
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:1061
The MeshParameters class is used to store paramaters for the 'Add_mesh' XML element.
Definition Parameters.h:1658
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1662
Definition Parameters.h:526
Definition Parameters.h:538
NeoHookeanParameters()
There are no parameters associated with a Neohookean model.
Definition Parameters.cpp:872
The OutputParameters class stores parameters for the Output XML element under Add_equation.
Definition Parameters.h:839
std::string get_alias_value(const std::string &name)
Get the value of an alias by name.
Definition Parameters.cpp:1245
bool get_output_value(const std::string &name)
Get the value of an output by name.
Definition Parameters.cpp:1257
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:843
The Parameter class template is used to store a named paramater and its scalar value as a basic type:...
Definition Parameters.h:91
void set(const std::string &name, bool required, T value)
Set the parameter name and value, and if it is required.
Definition Parameters.h:122
void set(const std::string &str_value)
Set the parameter value from a string.
Definition Parameters.h:129
std::string svalue()
Get the value of a parameter as a string.
Definition Parameters.h:108
Defines parameter name and value, and stores them in maps for settng values from XML.
Definition Parameters.h:287
void check_required()
Check if any required parameters have not been set.
Definition Parameters.h:389
void set_parameter(const std::string &name, const bool value, bool required, Parameter< bool > &param)
Set the name, default value and the parameter required flag.
Definition Parameters.h:298
void set_parameter_value_CANN(const std::string &name, const std::string &value)
set_parameter function to handle CANNRow
Definition Parameters.h:342
void set_parameter_value(const std::string &name, const std::string &value)
Set the value of a paramter from a string.
Definition Parameters.h:379
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:430
std::map< std::string, std::string > get_parameter_list() const
Get the defined parameters as a map of strings.
Definition Parameters.h:403
void print_parameter_list()
Print the parameters.
Definition Parameters.h:416
The Parameters class stores parameter values read in from a solver input file.
Definition Parameters.h:1795
void read_xml(std::string file_name)
Set the simulation parameter values given in an XML format file.
Definition Parameters.cpp:224
The PrecomputedSolutionParameters class stores parameters for the 'Precomputed_solution' XML element ...
Definition Parameters.h:869
The ProjectionParameters class stores parameters for the 'Add_projection' XML element used for fluid-...
Definition Parameters.h:892
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:898
The RISProjectionParameters class stores parameters for the 'Add_RIS_projection' XML element used for...
Definition Parameters.h:1713
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1719
The RemesherParameters class stores parameters for the 'Remesher' XML element used for remeshing.
Definition Parameters.h:1414
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1418
Definition Parameters.h:993
Definition Parameters.h:1011
static const std::string xml_element_name_
Process parameters for various solid viscosity models.
Definition Parameters.h:1015
Definition Parameters.h:1002
Definition Parameters.h:547
StVenantKirchhoffParameters()
There are no parameters associated with a StVenantKirchhoff model.
Definition Parameters.cpp:886
The StimulusParameters class stores parameters for 'Stimulus' XML element used to parameters for pace...
Definition Parameters.h:1094
static const std::string xml_element_name_
Define the XML element name for equation output parameters.
Definition Parameters.h:1098
The URISFaceParameters class is used to store parameters for the 'Add_URIS_face' XML element.
Definition Parameters.h:1731
static const std::string xml_element_name_
Process parameters for the 'Add_URIS_face' XML element.
Definition Parameters.h:1738
The URISMeshParameters class is used to store paramaters for the 'Add_URIS_mesh' XML element.
Definition Parameters.h:1765
static const std::string xml_element_name_
Define the XML element name for mesh parameters.
Definition Parameters.h:1769
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition Parameters.h:909
static const std::string xml_element_name_
The VariableWallPropsParameters class stores parameters for variable wall properties for the CMM equa...
Definition Parameters.h:912
The Vector template class is used for storing int and double data.
Definition Vector.h:24
The VectorParameter class template is used to store a named paramater and its vector of values as a b...
Definition Parameters.h:170
void set(const std::string &str_value)
Set the parameter value from a string.
Definition Parameters.h:224
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:216
std::string svalue()
Get the string representation of the parameter value.
Definition Parameters.h:190
Definition Parameters.h:662
struct to define a row of CANN model parameter table
Definition Parameters.h:278