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};
133
134// Define constants using smaller name and integer value (needed for bitwise operations).
135//
136constexpr auto BC_CMM = BoundaryConditionType::bType_CMM;
137constexpr auto iBC_CMM = static_cast<int>(BoundaryConditionType::bType_CMM);
138
139constexpr auto BC_cpl = BoundaryConditionType::bType_cpl;
140constexpr auto iBC_cpl = static_cast<int>(BoundaryConditionType::bType_cpl);
141
142constexpr auto BC_Dir = BoundaryConditionType::bType_Dir;
143constexpr auto iBC_Dir = static_cast<int>(BoundaryConditionType::bType_Dir);
144
145constexpr auto BC_fix = BoundaryConditionType::bType_fix;
146constexpr auto iBC_fix = static_cast<int>(BoundaryConditionType::bType_fix);
147
148constexpr auto BC_flat = BoundaryConditionType::bType_flat;
149constexpr auto iBC_flat = static_cast<int>(BoundaryConditionType::bType_flat);
150
151constexpr auto BC_free = BoundaryConditionType::bType_free;
152constexpr auto iBC_free = static_cast<int>(BoundaryConditionType::bType_free);
153
154constexpr auto BC_gen = BoundaryConditionType::bType_gen;
155constexpr auto iBC_gen = static_cast<int>(BoundaryConditionType::bType_gen);
156
157constexpr auto BC_hing = BoundaryConditionType::bType_hing;
158constexpr auto iBC_hing = static_cast<int>(BoundaryConditionType::bType_hing);
159
160constexpr auto BC_impD = BoundaryConditionType::bType_impD;
161constexpr auto iBC_impD = static_cast<int>(BoundaryConditionType::bType_impD);
162
163constexpr auto BC_Neu = BoundaryConditionType::bType_Neu;
164constexpr auto iBC_Neu = static_cast<int>(BoundaryConditionType::bType_Neu);
165
166constexpr auto BC_para = BoundaryConditionType::bType_para;
167constexpr auto iBC_para = static_cast<int>(BoundaryConditionType::bType_para);
168
169constexpr auto BC_RCR = BoundaryConditionType::bType_RCR;
170constexpr auto iBC_RCR = static_cast<int>(BoundaryConditionType::bType_RCR);
171
172constexpr auto BC_res = BoundaryConditionType::bType_res;
173constexpr auto iBC_res = static_cast<int>(BoundaryConditionType::bType_res);
174
175constexpr auto BC_Robin = BoundaryConditionType::bType_Robin;
176constexpr auto iBC_Robin = static_cast<int>(BoundaryConditionType::bType_Robin);
177
178constexpr auto BC_std = BoundaryConditionType::bType_std;
179constexpr auto iBC_std = static_cast<int>(BoundaryConditionType::bType_std);
180
181constexpr auto BC_symm = BoundaryConditionType::bType_symm;
182constexpr auto iBC_symm = static_cast<int>(BoundaryConditionType::bType_symm);
183
184constexpr auto BC_trac = BoundaryConditionType::bType_trac;
185constexpr auto iBC_trac = static_cast<int>(BoundaryConditionType::bType_trac);
186
187constexpr auto BC_undefNeu = BoundaryConditionType::bType_undefNeu;
188constexpr auto iBC_undefNeu = static_cast<int>(BoundaryConditionType::bType_undefNeu);
189
190constexpr auto BC_ustd = BoundaryConditionType::bType_ustd;
191constexpr auto iBC_ustd = static_cast<int>(BoundaryConditionType::bType_ustd);
192
193//-----------------------
194// ConstitutiveModelType
195//-----------------------
196// Constitutive model (isochoric) type for structure equation:
197//
198enum 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.
218extern const std::map<std::string,ConstitutiveModelType> constitutive_model_name_to_type;
219
220enum 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.
228extern 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//
239enum 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.
250extern const std::map<std::string,CplBCType> cplbc_name_to_type;
251
252/// @brief Element type replicating eType_NA, eType_PNT, etc.
253//
254enum 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
274extern const std::map<ElementType,std::string> element_type_to_string;
275extern const std::map<ElementType,int> element_type_to_elem_nonb;
276extern const std::map<ElementType,int> element_dimension;
277
278// Template for printing ElementType.
279/*
280template<typename T>
281std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
282{
283 return stream << static_cast<typename std::underlying_type<T>::type>(e);
284}
285*/
286
287/// @brief Types of equations that are included in this solver.
288///
289/// Fluid equation (Navier-Stokes), nonlinear structure (pure d), heat
290/// equation, linear elasticity, heat in fluid (advection-diffusion),
291/// fluid-structure-interaction, mesh motion, Shell mechanics,
292/// Coupled-Momentum-Method, Cardiac Electro-Physiology,
293/// Nonlinear structure (v-p), Stokes equations
294//
295enum class EquationType
296{
297 phys_NA = 200,
298 phys_fluid = 201,
299 phys_struct = 202, // nonlinear structure (pure d)
300 phys_heatS = 203,
301 phys_lElas = 204,
302 phys_heatF = 205,
303 phys_FSI = 206,
304 phys_mesh = 207, // solves a modified lElas for mesh motion; should be used with FSI
305 phys_shell = 208, // solves nonlinear thin shell mechanics (Kirchhoff-Love theory)
306 phys_CMM = 209,
307 phys_CEP = 210,
308 phys_ustruct = 211, // Nonlinear elastodynamics using mixed VMS-stabilized formulation
309 phys_stokes = 212
310};
311
312constexpr auto Equation_CMM = EquationType::phys_CMM;
313constexpr auto Equation_CEP = EquationType::phys_CEP;
314constexpr auto Equation_fluid = EquationType::phys_fluid;
315constexpr auto Equation_FSI = EquationType::phys_FSI;
316constexpr auto Equation_heatF = EquationType::phys_heatF;
317constexpr auto Equation_heatS = EquationType::phys_heatS;
318constexpr auto Equation_lElas = EquationType::phys_lElas;
319constexpr auto Equation_mesh = EquationType::phys_mesh;
320constexpr auto Equation_shell = EquationType::phys_shell;
321constexpr auto Equation_stokes = EquationType::phys_stokes;
322constexpr auto Equation_struct = EquationType::phys_struct;
323constexpr auto Equation_ustruct = EquationType::phys_ustruct;
324
325extern const std::map<std::string,EquationType> equation_name_to_type;
326
327enum class MeshGeneratorType
328{
329 RMSH_TETGEN = 1,
330 RMSH_MESHSIM = 2
331};
332
333/// Map for string to MeshGeneratorType.
334extern const std::map<std::string,MeshGeneratorType> mesh_generator_name_to_type;
335
336enum class OutputNameType
337{
338 outGrp_NA = 500,
339 outGrp_A = 501,
340 outGrp_Y = 502,
341 outGrp_D = 503,
342 outGrp_I = 504,
343 outGrp_WSS = 505,
344 outGrp_trac = 506,
345 outGrp_vort = 507,
346 outGrp_vortex = 508,
347 outGrp_stInv = 509,
348 outGrp_eFlx = 510,
349 outGrp_hFlx = 511,
350 outGrp_absV = 512,
351 outGrp_fN = 513,
352 outGrp_fA = 514,
353 outGrp_stress = 515,
354 outGrp_cauchy = 516,
355 outGrp_mises = 517,
356 outGrp_J = 518,
357 outGrp_F = 519,
358 outGrp_strain = 520,
359 outGrp_divV = 521,
360 outGrp_Visc = 522,
361 outGrp_fS = 523,
362 outGrp_C = 524,
363 outGrp_I1 = 525,
364
365 out_velocity = 599,
366 out_pressure = 598,
367 out_temperature = 597,
368 out_voltage = 596,
369 out_acceleration = 595,
370 out_displacement = 594,
371 out_integ =593,
372 out_WSS = 592,
373 out_traction = 591,
374 out_vorticity = 590,
375 out_vortex = 589,
376 out_strainInv = 588,
377 out_energyFlux = 587,
378 out_heatFlux = 586,
379 out_absVelocity = 585,
380 out_fibDir = 584,
381 out_fibAlign = 583,
382 out_stress = 582,
383 out_cauchy = 581,
384 out_mises = 580,
385 out_jacobian = 579,
386 out_defGrad = 578,
387 out_strain = 577,
388 out_divergence = 576,
389 out_viscosity = 575,
390 out_fibStrn = 574,
391 out_CGstrain = 573,
392 out_CGInv1 = 572
393};
394
395/// @brief Simulation output file types.
396//
397enum class OutputType
398{
399 boundary_integral,
400 spatial,
401 volume_integral
402};
403
404extern const std::map<std::string,OutputType> output_type_name_to_type;
405
406/// @brief Possible physical properties. Current maxNPror is 20.
407//
408enum class PhysicalProperyType
409{
410 NA = 0,
411 fluid_density = 1,
412 solid_density = 2,
413 elasticity_modulus = 3,
414 poisson_ratio = 4,
415 conductivity = 5,
416 f_x = 6, // internal force x
417 f_y = 7, // internal force y
418 f_z = 8, // internal force z
419 backflow_stab = 9, // stabilization coeff. for backflow divergence
420 source_term = 10, // external source
421 damping = 11,
422 shell_thickness = 12,
423 ctau_M = 13, // stabilization coeffs. for USTRUCT (momentum, continuity)
424 ctau_C = 14,
425 inverse_darcy_permeability = 15
426};
427
428enum class PreconditionerType
429{
430 PREC_NONE = 700,
431 PREC_FSILS = 701,
432 PREC_TRILINOS_DIAGONAL = 702,
433 PREC_TRILINOS_BLOCK_JACOBI = 703,
434 PREC_TRILINOS_ILU = 704,
435 PREC_TRILINOS_ILUT = 705,
436 PREC_TRILINOS_IC = 706,
437 PREC_TRILINOS_ICT = 707,
438 PREC_TRILINOS_ML = 708,
439 PREC_RCS = 709,
440 PREC_PETSC_JACOBI = 710,
441 PREC_PETSC_RCS = 711
442};
443
444extern const std::set<PreconditionerType> fsils_preconditioners;
445extern const std::set<PreconditionerType> petsc_preconditioners;
446extern const std::set<PreconditionerType> trilinos_preconditioners;
447extern const std::map<PreconditionerType, std::string> preconditioner_type_to_name;
448
449/// Map for preconditioner type string to PreconditionerType enum.
450extern const std::map<std::string,PreconditionerType> preconditioner_name_to_type;
451
452enum class SolverType
453{
454 lSolver_NA = 799,
455 lSolver_CG = 798,
456 lSolver_GMRES = 797,
457 lSolver_NS = 796,
458 lSolver_BICGS = 795
459};
460
461/// Map for solver type string to SolverType enum.
462extern const std::map<std::string,SolverType> solver_name_to_type;
463
464enum class FluidViscosityModelType
465{
466 viscType_CY = 697,
467 viscType_Cass = 696,
468 viscType_Const = 698,
469 viscType_NA = 699
470};
471
472/// Map for fluid viscosity model string to FluidViscosityModelType.
473extern const std::map<std::string,FluidViscosityModelType> fluid_viscosity_model_name_to_type;
474
475enum class SolidViscosityModelType
476{
477 viscType_NA = 695,
478 viscType_Newtonian = 694,
479 viscType_Potential = 693
480};
481
482/// Map for solid viscosity model string to SolidViscosityModelType.
483extern const std::map<std::string,SolidViscosityModelType> solid_viscosity_model_name_to_type;
484
485/// Template for printing enum class types as an int.
486template<typename T>
487std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::ostream>::type& stream, const T& e)
488{
489 return stream << static_cast<typename std::underlying_type<T>::type>(e);
490}
491
492//// Mechanical configurations
493enum class MechanicalConfigurationType
494{
495 reference, // reference configuration
496 old_timestep, // old timestep (n) configuration
497 new_timestep // new timestep (n+1) configuration
498};
499
500//-------------------
501// LinearAlgebraType
502//-------------------
503// The type of the numerical linear algebra library.
504//
505enum class LinearAlgebraType {
506 none,
507 fsils,
508 petsc,
509 trilinos
510};
511
512
513};
514
515#endif
516