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