Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
solver_config.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
15 #include <variant>
16 #include <vector>
17 
18 #include "mfem.hpp"
20 #include "smith/numerics/block_preconditioner.hpp"
21 
22 namespace smith {
23 
27 enum class TimestepMethod
28 {
29  QuasiStatic,
31  // options for first order ODEs
33  SDIRK33,
34  ForwardEuler,
35  RK2,
36  RK3SSP,
37  RK4,
40  SDIRK23,
41  SDIRK34,
43  // options for second order ODEs
44  //
45  // note: we don't have a way to communicate
46  // parameters to the TimestepMethod,
47  // right now, so Newmark implies
48  // (beta = 0.25, gamma = 0.5)
49  Newmark,
50  HHTAlpha,
51  WBZAlpha,
55  FoxGoodwin
56 };
57 
63 {
71 
80 
91 };
92 
97 
100 };
101 
102 // _linear_solvers_start
104 enum class LinearSolver
105 {
106  CG,
107  GMRES,
108  SuperLU,
109  Strumpack,
110  PetscCG,
111  PetscGMRES,
112  None
113 };
114 // _linear_solvers_end
115 
117 inline std::string linearName(const LinearSolver& s)
118 {
119  switch (s) {
120  case LinearSolver::CG:
121  return "CG";
122  case LinearSolver::GMRES:
123  return "GMRES";
125  return "SuperLU";
127  return "Strumpack";
129  return "PetscCG";
131  return "PetscGMRES";
132  case LinearSolver::None:
133  return "None";
134  }
135  // This cannot happen, but GCC doesn't know that
136  return "UNKNOWN";
137 }
138 
140 inline std::ostream& operator<<(std::ostream& os, LinearSolver s) { return os << linearName(s); }
141 
143 inline std::map<std::string, LinearSolver> linearSolverMap = {
144  {"CG", LinearSolver::CG}, {"GMRES", LinearSolver::GMRES},
145  {"SuperLU", LinearSolver::SuperLU}, {"Strumpack", LinearSolver::Strumpack},
146  {"PetscCG", LinearSolver::PetscCG}, {"PetscGMRES", LinearSolver::PetscGMRES},
147  {"None", LinearSolver::None},
148 };
149 
150 // Add a custom list of strings? conduit node?
151 // Arbitrary string (e.g. json) to define parameters?
152 
153 // _nonlinear_solvers_start
155 enum class NonlinearSolver
156 {
157  Newton,
158  LBFGS,
160  TrustRegion,
161  KINFullStep,
163  KINPicard,
164  PetscNewton,
168 };
169 // _nonlinear_solvers_end
170 
172 inline std::string nonlinearName(const NonlinearSolver& s)
173 {
174  switch (s) {
176  return "Newton";
178  return "LBFGS";
180  return "NewtonLineSearch";
182  return "TrustRegion";
184  return "KINFullStep";
186  return "KINBacktrackingLineSearch";
188  return "KINPicard";
190  return "PetscNewton";
192  return "PetscNewtonBacktracking";
194  return "PetscNewtonCriticalPoint";
196  return "PetscTrustRegion";
197  }
198  // This cannot happen, but GCC doesn't know that
199  return "UNKNOWN";
200 }
201 
203 inline std::ostream& operator<<(std::ostream& os, NonlinearSolver s) { return os << nonlinearName(s); }
204 
206 inline std::map<std::string, NonlinearSolver> nonlinearSolverMap = {
207  {"Newton", NonlinearSolver::Newton},
208  {"LBFGS", NonlinearSolver::LBFGS},
209  {"NewtonLineSearch", NonlinearSolver::NewtonLineSearch},
210  {"TrustRegion", NonlinearSolver::TrustRegion},
211  {"KINFullStep", NonlinearSolver::KINFullStep},
212  {"KINBacktrackingLineSearch", NonlinearSolver::KINBacktrackingLineSearch},
213  {"KINPicard", NonlinearSolver::KINPicard},
214  {"PetscNewton", NonlinearSolver::PetscNewton},
215  {"PetscNewtonBacktracking", NonlinearSolver::PetscNewtonBacktracking},
216  {"PetscNewtonCriticalPoint", NonlinearSolver::PetscNewtonCriticalPoint},
217  {"PetscTrustRegion", NonlinearSolver::PetscTrustRegion},
218 };
219 
223 enum class AMGXSolver
224 {
225  AMG,
226  PCGF,
227  CG,
228  PCG,
229  PBICGSTAB,
230  BICGSTAB,
231  FGMRES,
232  JACOBI_L1,
233  GS,
234  POLYNOMIAL,
236  BLOCK_JACOBI,
237  MULTICOLOR_GS,
239 };
240 
244 struct AMGXOptions {
256  bool verbose = false;
257 };
258 
266  int relax_type = 88; // l1-hybrid symmetric Gauss-Seidel smoother
271  3; // geometric dimension of problem, used to set more robust options for systems such as elasticity
272 };
273 
277 enum class PetscPCType
278 {
279  JACOBI,
280  JACOBI_L1,
281  JACOBI_ROWSUM,
282  JACOBI_ROWMAX,
283  PBJACOBI,
284  BJACOBI,
285  LU,
286  ILU,
287  CHOLESKY,
288  SVD,
289  ASM,
291  GASM,
293  GAMG,
294  HMG,
295  NONE,
296 };
297 
299 inline std::string petscPCName(const PetscPCType& s)
300 {
301  switch (s) {
302  case PetscPCType::JACOBI:
303  return "JACOBI";
305  return "JACOBI_L1";
307  return "JACOBI_ROWSUM";
309  return "JACOBI_ROWMAX";
311  return "PBJACOBI";
313  return "BJACOBI";
314  case PetscPCType::LU:
315  return "LU";
316  case PetscPCType::ILU:
317  return "ILU";
319  return "CHOLESKY";
320  case PetscPCType::SVD:
321  return "SVD";
322  case PetscPCType::ASM:
323  return "ASM";
324  case PetscPCType::GASM:
325  return "GASM";
326  case PetscPCType::GAMG:
327  return "GAMG";
328  case PetscPCType::HMG:
329  return "HMG";
330  case PetscPCType::NONE:
331  return "NONE";
332  }
333  // This cannot happen, but GCC doesn't know that
334  return "UNKNOWN";
335 }
336 
338 inline std::ostream& operator<<(std::ostream& os, PetscPCType s) { return os << petscPCName(s); }
339 
340 // _preconditioners_start
342 enum class Preconditioner
343 {
344  HypreJacobi,
345  HypreL1Jacobi,
347  HypreAMG,
348  HypreILU,
349  AMGX,
350  Petsc,
351  AMGFContact,
352  BlockDiagonal,
354  BlockSchur,
355  None
356 };
357 // _preconditioners_end
358 
360 inline std::string preconditionerName(Preconditioner p)
361 {
362  switch (p) {
364  return "HypreJacobi";
366  return "HypreL1Jacobi";
368  return "HypreGaussSeidel";
370  return "HypreAMG";
372  return "HypreILU";
374  return "AMGX";
376  return "Petsc";
378  return "AMGFContact";
380  return "BlockDiagonal";
382  return "BlockTriangular";
384  return "BlockSchur";
386  return "None";
387  }
388  // This cannot happen, but GCC doesn't know that
389  return "UNKNOWN";
390 }
391 
393 inline std::ostream& operator<<(std::ostream& os, Preconditioner p) { return os << preconditionerName(p); }
394 
396 inline std::map<std::string, Preconditioner> preconditionerMap = {
397  {"HypreJacobi", Preconditioner::HypreJacobi},
398  {"HypreL1Jacobi", Preconditioner::HypreL1Jacobi},
399  {"HypreGaussSeidel", Preconditioner::HypreGaussSeidel},
400  {"HypreAMG", Preconditioner::HypreAMG},
401  {"HypreILU", Preconditioner::HypreILU},
402  {"AMGX", Preconditioner::AMGX},
403  {"Petsc", Preconditioner::Petsc},
404  {"AMGFContact", Preconditioner::AMGFContact},
405  {"BlockDiagonal", Preconditioner::BlockDiagonal},
406  {"BlockTriangular", Preconditioner::BlockTriangular},
407  {"BlockSchur", Preconditioner::BlockSchur},
408  {"None", Preconditioner::None},
409 };
410 
411 // _linear_options_start
416 
419 
422 
425 
428 
430  double relative_tol = 1.0e-8;
431 
433  double absolute_tol = 1.0e-12;
434 
436  int max_iterations = 300;
437 
439  int print_level = 0;
440 
443 
445  std::vector<LinearSolverOptions> sub_block_linear_solver_options = {};
446 
449 
452 
455 };
456 // _linear_options_end
457 
460 {
461  NEVER,
462  WHEN_INDEFINITE,
463  WHEN_INDEFINITE_OR_BOUNDARY,
464  ALWAYS
465 };
466 
467 // _nonlinear_options_start
472 
474  double relative_tol = 1.0e-8;
475 
477  double absolute_tol = 1.0e-12;
478 
480  int min_iterations = 0;
481 
483  int max_iterations = 20;
484 
487 
489  int print_level = 0;
490 
492  double trust_region_scaling = 0.1;
493 
495  SubSpaceOptions subspace_option = SubSpaceOptions::NEVER;
496 
498  int num_leftmost = 1;
499 };
500 // _nonlinear_options_end
501 
502 } // namespace smith
503 
504 // std::format support for Smith solver enums
505 namespace std {
506 template <>
509 
510 template <>
513 
514 template <>
517 
518 template <>
521 } // namespace std
Shared helpers for C++ standard formatting support in Smith.
Accelerator functionality.
Definition: smith.cpp:36
std::map< std::string, Preconditioner > preconditionerMap
string->value matching for optionally entering options as string in command line
std::string nonlinearName(const NonlinearSolver &s)
Convert nonlinear linear solver enums to their string names.
SubSpaceOptions
Enumerated options for when to use trust-region subspace solver.
std::map< std::string, LinearSolver > linearSolverMap
string->value matching for optionally entering options as string in command line
std::string linearName(const LinearSolver &s)
Convert linear solver enums to their string names.
LinearSolver
Linear solution method indicator.
Preconditioner
The type of preconditioner to be used.
std::map< std::string, NonlinearSolver > nonlinearSolverMap
string->value matching for optionally entering options as string in command line
std::ostream & operator<<(std::ostream &out, DoF dof)
stream output for DoF
SchurApproxType
Selects how the (1,1) Schur operator is approximated.
BlockTriangularType
Selects the block triangular sweep used by BlockTriangularPreconditioner.
BlockSchurType
Selects the block Schur preconditioner variant.
std::string petscPCName(const PetscPCType &s)
Convert Petsc preconditioner enums to their string names.
TimestepMethod
Timestep method of a solver.
PetscPCType
Preconditioner types supported by PETSc.
AMGXSolver
Solver types supported by AMGX.
NonlinearSolver
Nonlinear solver method indicator.
std::string preconditionerName(Preconditioner p)
Convert preconditioner enums to their string names.
DirichletEnforcementMethod
this enum describes which way to enforce the time-varying constraint u(t) == U(t)
Stores the configuration information for an AMGFContact preconditioner.
int relax_type
The amg relaxation type.
int dim_systems_options
amg DimSystemsOptions
Stores the information required to configure a NVIDIA AMGX preconditioner.
AMGXSolver solver
The solver algorithm.
bool verbose
Whether to display statistics from AMGX.
AMGXSolver smoother
The smoother algorithm.
Parameters for an iterative linear solution scheme.
int preconditioner_print_level
Debugging print level for the preconditioner.
int max_iterations
Maximum number of iterations.
double relative_tol
Relative tolerance.
int print_level
Debugging print level for the linear solver.
AMGFContactOptions amgfcontact_options
AMGFContact Options, used for Preconditioner::AMGFContact.
Preconditioner preconditioner
PreconditionerOptions selection.
SchurApproxType schur_approx_type
Schur approximation type.
PetscPCType petsc_preconditioner
PETSc preconditioner type.
std::vector< LinearSolverOptions > sub_block_linear_solver_options
Subblock linear solver options for block preconditioners.
BlockSchurType block_schur_type
Block Schur preconditioner factorization type.
double absolute_tol
Absolute tolerance.
AMGXOptions amgx_options
AMGX Options, used for Preconditioner::AMGX.
BlockTriangularType block_triangular_type
Block Triangular Preconditioner factorization type.
LinearSolver linear_solver
Linear solver selection.
Nonlinear solution scheme parameters.
int min_iterations
Minimum number of iterations.
int max_iterations
Maximum number of iterations.
double trust_region_scaling
Scaling for the initial trust region size.
int max_line_search_iterations
Maximum line search cutbacks.
double relative_tol
Relative tolerance.
int print_level
Debug print level.
int num_leftmost
Number of extra leftmost eigenvector to be stored between solves.
double absolute_tol
Absolute tolerance.
NonlinearSolver nonlin_solver
Nonlinear solver selection.
SubSpaceOptions subspace_option
Option for how when the subspace solver should be utilized within trust-region solver.
A timestep and boundary condition enforcement method for a dynamic solver.
TimestepMethod timestepper
The timestepping method to be applied.
DirichletEnforcementMethod enforcement_method
The essential boundary enforcement method to use.
Formatter that renders values through operator<<.
Definition: format.hpp:32