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