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