svFSIplus
consts.h
1 /**
2  * Copyright (c) Stanford University, The Regents of the University of California, and others.
3  *
4  * All Rights Reserved.
5  *
6  * See Copyright-SimVascular.txt for additional details.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject
14  * to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef CONSTS_H
33 #define CONSTS_H
34 
35 #include <iostream>
36 #include <limits>
37 #include <map>
38 #include <type_traits>
39 
40 // The enums here replicate the PARAMETERs defined
41 // in CONSTS.f.
42 
43 namespace consts {
44 
45 const double pi = 3.1415926535897932384626;
46 
47 const int maxNSD = 3;
48 
49 const int maxNProp = 20;
50 
51 const int maxOutput = 5;
52 
53 /// Use inf numeric values to represent a value that is not set.
54 const int int_inf = std::numeric_limits<int>::infinity();
55 const double double_inf = std::numeric_limits<double>::infinity();
56 
57 template<typename T>
58 int enum_int(T value)
59 {
60  return static_cast<int>(value);
61 }
62 
63 
64 /// Check if a value is set to infinity.
65 template<typename T>
66 bool present(T value)
67 {
68  return (value != std::numeric_limits<T>::infinity());
69 }
70 
71 /// @brief Body force types: volumetric (default), traction, Neumann
72 /// (pressure based), time dependence (steady, unsteady, spatially
73 /// varying, general)
74 enum class BodyForceType
75 {
76  bfType_vol = 0,
77  bfType_trac = 1,
78  bfType_Neu = 2,
79  bfType_std = 3,
80  bfType_ustd = 4,
81  bfType_spl = 5,
82  bfType_gen = 6
83 };
84 
85 /// @brief Boundary conditions type.
86 ///
87 /// BC types are stored as bitwise values.
88 ///
89 /// boundary conditions types. Items of this list can be combined
90 ///
91 /// - BCs from imposing perspective can be Neu/Dir/per
92 ///
93 /// - BCs time dependence can be std/ustd/cpl/gen/res
94 ///
95 /// - BCs spatial distribution can be flat/para/ud
96 ///
97 /// - Beside these nodes at the boundary perimeter can be set to
98 /// zero and flux through surface can be assigned instead of nodal
99 /// values.
100 ///
101 /// - Dirichlet, Neumann, Traction, CMM, Robin, steady, unsteady,
102 /// coupled, general (combination of ud/ustd), resistance, imposed
103 /// flux, zero out perimeter, impose BC on the integral of state
104 /// variable or D (instead of Y), flat profile, parabolic profile,
105 /// user defined profile, backflow stabilization, BCs for shells
106 /// (fixed, hinged, free, symmetric), undeforming Neu, RCR-Neu
108 {
109  bType_Dir = 0, // Dirichlet
110  bType_Neu = 1, // Neumann
111  bType_trac = 2, // Traction
112  bType_CMM = 3, // CMM
113  bType_Robin = 4, // RObin
114  bType_std = 5, // steady
115  bType_ustd = 6, // unsteady
116  bType_cpl = 7, // coupled
117  bType_gen = 8, // general
118  bType_res = 9, // resistance
119  bType_flx = 10, // imposed flux
120  bType_zp = 11, // zero out perimeter
121  bType_impD = 12, // impose BC on the integral of state variable or D (instead of Y)
122  bType_flat =13, // flat profile
123  bType_para = 14, // parabolic profile
124  bType_ud = 15, // user defined profile
125  bType_bfs = 16, // backflow stabilization
126  bType_fix = 17, // shell fixed
127  bType_hing = 18, // shell hinged
128  bType_free = 19, // shell free
129  bType_symm = 20, // shell symmetric
130  bType_undefNeu = 21, // undeforming Neu
131  bType_RCR = 22 // RCR-Neu
132 };
133 
134 // Define constants using smaller name and integer value (needed for bitwise operations).
135 //
136 constexpr auto BC_CMM = BoundaryConditionType::bType_CMM;
137 constexpr auto iBC_CMM = static_cast<int>(BoundaryConditionType::bType_CMM);
138 
139 constexpr auto BC_cpl = BoundaryConditionType::bType_cpl;
140 constexpr auto iBC_cpl = static_cast<int>(BoundaryConditionType::bType_cpl);
141 
142 constexpr auto BC_Dir = BoundaryConditionType::bType_Dir;
143 constexpr auto iBC_Dir = static_cast<int>(BoundaryConditionType::bType_Dir);
144 
145 constexpr auto BC_fix = BoundaryConditionType::bType_fix;
146 constexpr auto iBC_fix = static_cast<int>(BoundaryConditionType::bType_fix);
147 
148 constexpr auto BC_flat = BoundaryConditionType::bType_flat;
149 constexpr auto iBC_flat = static_cast<int>(BoundaryConditionType::bType_flat);
150 
151 constexpr auto BC_free = BoundaryConditionType::bType_free;
152 constexpr auto iBC_free = static_cast<int>(BoundaryConditionType::bType_free);
153 
154 constexpr auto BC_gen = BoundaryConditionType::bType_gen;
155 constexpr auto iBC_gen = static_cast<int>(BoundaryConditionType::bType_gen);
156 
157 constexpr auto BC_hing = BoundaryConditionType::bType_hing;
158 constexpr auto iBC_hing = static_cast<int>(BoundaryConditionType::bType_hing);
159 
160 constexpr auto BC_impD = BoundaryConditionType::bType_impD;
161 constexpr auto iBC_impD = static_cast<int>(BoundaryConditionType::bType_impD);
162 
163 constexpr auto BC_Neu = BoundaryConditionType::bType_Neu;
164 constexpr auto iBC_Neu = static_cast<int>(BoundaryConditionType::bType_Neu);
165 
166 constexpr auto BC_para = BoundaryConditionType::bType_para;
167 constexpr auto iBC_para = static_cast<int>(BoundaryConditionType::bType_para);
168 
169 constexpr auto BC_RCR = BoundaryConditionType::bType_RCR;
170 constexpr auto iBC_RCR = static_cast<int>(BoundaryConditionType::bType_RCR);
171 
172 constexpr auto BC_res = BoundaryConditionType::bType_res;
173 constexpr auto iBC_res = static_cast<int>(BoundaryConditionType::bType_res);
174 
175 constexpr auto BC_Robin = BoundaryConditionType::bType_Robin;
176 constexpr auto iBC_Robin = static_cast<int>(BoundaryConditionType::bType_Robin);
177 
178 constexpr auto BC_std = BoundaryConditionType::bType_std;
179 constexpr auto iBC_std = static_cast<int>(BoundaryConditionType::bType_std);
180 
181 constexpr auto BC_symm = BoundaryConditionType::bType_symm;
182 constexpr auto iBC_symm = static_cast<int>(BoundaryConditionType::bType_symm);
183 
184 constexpr auto BC_trac = BoundaryConditionType::bType_trac;
185 constexpr auto iBC_trac = static_cast<int>(BoundaryConditionType::bType_trac);
186 
187 constexpr auto BC_undefNeu = BoundaryConditionType::bType_undefNeu;
188 constexpr auto iBC_undefNeu = static_cast<int>(BoundaryConditionType::bType_undefNeu);
189 
190 constexpr auto BC_ustd = BoundaryConditionType::bType_ustd;
191 constexpr auto iBC_ustd = static_cast<int>(BoundaryConditionType::bType_ustd);
192 
193 //-----------------------
194 // ConstitutiveModelType
195 //-----------------------
196 // Constitutive model (isochoric) type for structure equation:
197 //
198 enum class ConstitutiveModelType
199 {
200  stIso_NA = 600,
201  stIso_StVK = 601,
202  stIso_mStVK = 602,
203  stIso_nHook = 603,
204  stIso_MR = 604,
205  stIso_HGO = 605,
206  stIso_lin = 606,
207  stIso_Gucci = 607,
208  stIso_HO = 608,
209  stIso_HO_ma = 610,
210  stIso_LS = 611,
211  stVol_NA = 650,
212  stVol_Quad = 651,
213  stVol_ST91 = 652,
214  stVol_M94 = 653
215 };
216 
217 /// @brief Map for constitutive_model string to ConstitutiveModelType.
218 extern const std::map<std::string,ConstitutiveModelType> constitutive_model_name_to_type;
219 
220 enum class ContactModelType
221 {
222  cntctM_NA = 800,
223  cntctM_penalty = 801,
224  cntctM_potential = 802
225 };
226 
227 /// @brief Map for model type string to ContactModelType.
228 extern const std::map<std::string,ContactModelType> contact_model_name_to_type;
229 
230 /// @brief Differenty type of coupling for cplBC.
231 ///
232 /// \code {.f}
233 /// INTEGER(KIND=IKIND), PARAMETER :: cplBC_NA = 400, cplBC_I = 401,
234 /// cplBC_SI = 402, cplBC_E = 403
235 //
236 /// INTEGER(KIND=IKIND), PARAMETER :: cplBC_Dir = 66112, cplBC_Neu = 66113
237 /// \endcode
238 //
239 enum class CplBCType
240 {
241  cplBC_NA = 400,
242  cplBC_Dir = 66112, // Dirichlet type coupling
243  cplBC_E = 403, // explicit
244  cplBC_I = 401, // implicit
245  cplBC_Neu = 66113, // Neumann type coupling
246  cplBC_SI = 402, // semi-implicit
247 };
248 
249 /// @brief Map for cplBC type to CplBCType.
250 extern const std::map<std::string,CplBCType> cplbc_name_to_type;
251 
252 /// @brief Element type replicating eType_NA, eType_PNT, etc.
253 //
254 enum class ElementType
255 {
256  NA = 100,
257  PNT = 101,
258  LIN1 = 102,
259  LIN2 = 103,
260  TRI3 = 104,
261  TRI6 = 105,
262  QUD4 = 106,
263  QUD8 = 107,
264  QUD9 = 108,
265  TET4 = 109,
266  TET10 = 110,
267  HEX8 = 111,
268  HEX20 = 112,
269  HEX27 = 113,
270  WDG = 114,
271  NRB = 115
272 };
273 
274 extern const std::map<ElementType,int> element_type_to_elem_nonb;
275 
276 // Template for printing ElementType.
277 /*
278 template<typename T>
279 std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
280 {
281  return stream << static_cast<typename std::underlying_type<T>::type>(e);
282 }
283 */
284 
285 /// @brief Types of equations that are included in this solver.
286 ///
287 /// Fluid equation (Navier-Stokes), nonlinear structure (pure d), heat
288 /// equation, linear elasticity, heat in fluid (advection-diffusion),
289 /// fluid-structure-interaction, mesh motion, Shell mechanics,
290 /// Coupled-Momentum-Method, Cardiac Electro-Physiology,
291 /// Nonlinear structure (v-p), Stokes equations
292 //
293 enum class EquationType
294 {
295  phys_NA = 200,
296  phys_fluid = 201,
297  phys_struct = 202, // nonlinear structure (pure d)
298  phys_heatS = 203,
299  phys_lElas = 204,
300  phys_heatF = 205,
301  phys_FSI = 206,
302  phys_mesh = 207, // solves a modified lElas for mesh motion; should be used with FSI
303  phys_shell = 208, // solves nonlinear thin shell mechanics (Kirchhoff-Love theory)
304  phys_CMM = 209,
305  phys_CEP = 210,
306  phys_ustruct = 211, // Nonlinear elastodynamics using mixed VMS-stabilized formulation
307  phys_stokes = 212
308 };
309 
310 constexpr auto Equation_CMM = EquationType::phys_CMM;
311 constexpr auto Equation_CEP = EquationType::phys_CEP;
312 constexpr auto Equation_fluid = EquationType::phys_fluid;
313 constexpr auto Equation_FSI = EquationType::phys_FSI;
314 constexpr auto Equation_heatF = EquationType::phys_heatF;
315 constexpr auto Equation_heatS = EquationType::phys_heatS;
316 constexpr auto Equation_lElas = EquationType::phys_lElas;
317 constexpr auto Equation_mesh = EquationType::phys_mesh;
318 constexpr auto Equation_shell = EquationType::phys_shell;
319 constexpr auto Equation_stokes = EquationType::phys_stokes;
320 constexpr auto Equation_struct = EquationType::phys_struct;
321 constexpr auto Equation_ustruct = EquationType::phys_ustruct;
322 
323 extern const std::map<std::string,EquationType> equation_name_to_type;
324 
325 enum class MeshGeneratorType
326 {
327  RMSH_TETGEN = 1,
328  RMSH_MESHSIM = 2
329 };
330 
331 /// Map for string to MeshGeneratorType.
332 extern const std::map<std::string,MeshGeneratorType> mesh_generator_name_to_type;
333 
334 enum class OutputType
335 {
336  outGrp_NA = 500,
337  outGrp_A = 501,
338  outGrp_Y = 502,
339  outGrp_D = 503,
340  outGrp_I = 504,
341  outGrp_WSS = 505,
342  outGrp_trac = 506,
343  outGrp_vort = 507,
344  outGrp_vortex = 508,
345  outGrp_stInv = 509,
346  outGrp_eFlx = 510,
347  outGrp_hFlx = 511,
348  outGrp_absV = 512,
349  outGrp_fN = 513,
350  outGrp_fA = 514,
351  outGrp_stress = 515,
352  outGrp_cauchy = 516,
353  outGrp_mises = 517,
354  outGrp_J = 518,
355  outGrp_F = 519,
356  outGrp_strain = 520,
357  outGrp_divV = 521,
358  outGrp_Visc = 522,
359  outGrp_fS = 523,
360  outGrp_C = 524,
361  outGrp_I1 = 525,
362 
363  out_velocity = 599,
364  out_pressure = 598,
365  out_temperature = 597,
366  out_voltage = 596,
367  out_acceleration = 595,
368  out_displacement = 594,
369  out_integ =593,
370  out_WSS = 592,
371  out_traction = 591,
372  out_vorticity = 590,
373  out_vortex = 589,
374  out_strainInv = 588,
375  out_energyFlux = 587,
376  out_heatFlux = 586,
377  out_absVelocity = 585,
378  out_fibDir = 584,
379  out_fibAlign = 583,
380  out_stress = 582,
381  out_cauchy = 581,
382  out_mises = 580,
383  out_jacobian = 579,
384  out_defGrad = 578,
385  out_strain = 577,
386  out_divergence = 576,
387  out_viscosity = 575,
388  out_fibStrn = 574,
389  out_CGstrain = 573,
390  out_CGInv1 = 572
391 };
392 
393 /// @brief Possible physical properties. Current maxNPror is 20.
394 //
396 {
397  NA = 0,
398  fluid_density = 1,
399  solid_density = 2,
400  solid_viscosity = 3,
401  elasticity_modulus = 4,
402  poisson_ratio = 5,
403  conductivity = 6,
404  f_x = 7, // internal force x
405  f_y = 8, // internal force y
406  f_z = 9, // internal force z
407  backflow_stab = 10, // stabilization coeff. for backflow divergence
408  source_term = 11, // external source
409  damping = 12,
410  shell_thickness = 13,
411  ctau_M = 14, // stabilization coeffs. for USTRUCT (momentum, continuity)
412  ctau_C = 15
413 };
414 
415 enum class PreconditionerType
416 {
417  PREC_NONE = 700,
418  PREC_FSILS = 701,
419  PREC_TRILINOS_DIAGONAL = 702,
420  PREC_TRILINOS_BLOCK_JACOBI = 703,
421  PREC_TRILINOS_ILU = 704,
422  PREC_TRILINOS_ILUT = 705,
423  PREC_TRILINOS_IC = 706,
424  PREC_TRILINOS_ICT = 707,
425  PREC_TRILINOS_ML = 708,
426  PREC_RCS = 709
427 };
428 
429 /// Map for preconditioner type string to pair (PreconditionerType enum, bool(true if Trilinos precondition)).
430 using PreconditionerMapType = std::pair<PreconditionerType,bool>;
431 //extern const std::map<std::string,PreconditionerType> preconditioner_name_to_type;
432 extern const std::map<std::string,PreconditionerMapType> preconditioner_name_to_type;
433 
434 enum class SolverType
435 {
436  lSolver_NA = 799,
437  lSolver_CG = 798,
438  lSolver_GMRES = 797,
439  lSolver_NS = 796,
440  lSolver_BICGS = 795
441 };
442 
443 /// Map for solver type string to SolverType enum.
444 extern const std::map<std::string,SolverType> solver_name_to_type;
445 
446 enum class FluidViscosityModelType
447 {
448  viscType_CY = 697,
449  viscType_Cass = 696,
450  viscType_Const = 698,
451  viscType_NA = 699
452 };
453 
454 /// Map for fluid viscosity model string to FluidViscosityModelType.
455 extern const std::map<std::string,FluidViscosityModelType> fluid_viscosity_model_name_to_type;
456 
457 /// Template for printing enum class types as an int.
458 template<typename T>
459 std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
460 {
461  return stream << static_cast<typename std::underlying_type<T>::type>(e);
462 }
463 
464 };
465 
466 #endif
467 
Definition: consts.cpp:34
CplBCType
Differenty type of coupling for cplBC.
Definition: consts.h:240
const std::map< std::string, ContactModelType > contact_model_name_to_type
Map for contact model string name to ContacteModelType.
Definition: consts.cpp:107
const std::map< std::string, FluidViscosityModelType > fluid_viscosity_model_name_to_type
Map for fluid viscosity model string to FluidViscosityModelType.
Definition: consts.cpp:117
std::pair< PreconditionerType, bool > PreconditionerMapType
Map for preconditioner type string to pair (PreconditionerType enum, bool(true if Trilinos preconditi...
Definition: consts.h:430
const std::map< std::string, EquationType > equation_name_to_type
Map equation name to a type.
Definition: consts.cpp:162
BoundaryConditionType
Boundary conditions type.
Definition: consts.h:108
const std::map< std::string, MeshGeneratorType > mesh_generator_name_to_type
Map for string to MeshGeneratorType.
Definition: consts.cpp:202
const std::map< std::string, PreconditionerMapType > preconditioner_name_to_type
Map for preconditioner type string to PreconditionerType enum.
Definition: consts.cpp:209
BodyForceType
Body force types: volumetric (default), traction, Neumann (pressure based), time dependence (steady,...
Definition: consts.h:75
EquationType
Types of equations that are included in this solver.
Definition: consts.h:294
const int int_inf
Use inf numeric values to represent a value that is not set.
Definition: consts.h:54
bool present(T value)
Check if a value is set to infinity.
Definition: consts.h:66
std::ostream & operator<<(typename std::enable_if< std::is_enum< T >::value, std::ostream >::type &stream, const T &e)
Template for printing enum class types as an int.
Definition: consts.h:459
const std::map< std::string, CplBCType > cplbc_name_to_type
Map for cplBC type to CplBCType.
Definition: consts.cpp:154
PhysicalProperyType
Possible physical properties. Current maxNPror is 20.
Definition: consts.h:396
ElementType
Element type replicating eType_NA, eType_PNT, etc.
Definition: consts.h:255
const std::map< std::string, ConstitutiveModelType > constitutive_model_name_to_type
Map for constitutive_model string to ConstitutiveModelType.
Definition: consts.cpp:64
const std::map< ElementType, int > element_type_to_elem_nonb
Reproduces the 'SELECT CASE (lMeType)' statements in the Fortran 'PARTMSH' subroutine.
Definition: consts.cpp:40
const std::map< std::string, SolverType > solver_name_to_type
Map solver type string to SolverType enum.
Definition: consts.cpp:235