www.mooseframework.org
Classes | Functions
Moose::PetscSupport Namespace Reference

Classes

class  ComputeLineSearchObjectWrapper
 Wrapper of the libmesh ComputeLineSearchObject. More...
 
class  PetscOptions
 A struct for storing the various types of petsc options and values. More...
 

Functions

void petscSetOptions (FEProblemBase &problem)
 A function for setting the PETSc options in PETSc from the options supplied to MOOSE. More...
 
void petscSetKSPDefaults (FEProblemBase &problem, KSP ksp)
 Set the default options for a KSP. More...
 
template<typename T >
void setLinearSolverDefaults (FEProblemBase &problem, LinearSolver< T > &linear_solver)
 Set the defaults for a libMesh LinearSolver. More...
 
void petscSetDefaults (FEProblemBase &problem)
 Sets the default options for PETSc. More...
 
void petscSetupDM (NonlinearSystemBase &nl)
 
PetscErrorCode petscSetupOutput (CommandLine *cmd_line)
 
void outputNorm (libMesh::Real old_norm, libMesh::Real norm, bool use_color=false)
 Helper function for outputing the norm values with/without color. More...
 
PetscErrorCode petscLinearMonitor (KSP, PetscInt its, PetscReal rnorm, void *void_ptr)
 Helper function for displaying the linear residual during PETSC solve. More...
 
void storePetscOptions (FEProblemBase &fe_problem, const InputParameters &params)
 Stores the PETSc options supplied from the InputParameters with MOOSE. More...
 
std::set< std::string > getPetscValidLineSearches ()
 Returns the valid petsc line search options as a set of strings. More...
 
InputParameters getPetscValidParams ()
 Returns the PETSc options that are common between Executioners and Preconditioners. More...
 
MultiMooseEnum getCommonPetscFlags ()
 A helper function to produce a MultiMooseEnum with commonly used PETSc single options (flags) More...
 
MultiMooseEnum getCommonPetscKeys ()
 A helper function to produce a MultiMooseEnum with commonly used PETSc iname options (keys in key-value pairs) More...
 
void setSinglePetscOption (const std::string &name, const std::string &value="")
 A wrapper function for dealing with different versions of PetscOptionsSetValue. More...
 
void addPetscOptionsFromCommandline ()
 
void colorAdjacencyMatrix (PetscScalar *adjacency_matrix, unsigned int size, unsigned int colors, std::vector< unsigned int > &vertex_colors, const char *coloring_algorithm)
 This method takes an adjacency matrix, and a desired number of colors and applies a graph coloring algorithm to produce a coloring. More...
 
std::string stringify (const LineSearchType &t)
 
std::string stringify (const MffdType &t)
 
void setSolverOptions (SolverParams &solver_params)
 
PetscErrorCode petscConverged (KSP ksp, PetscInt n, PetscReal rnorm, KSPConvergedReason *reason, void *ctx)
 
PetscErrorCode petscNonlinearConverged (SNES snes, PetscInt it, PetscReal xnorm, PetscReal snorm, PetscReal fnorm, SNESConvergedReason *reason, void *ctx)
 
PCSide getPetscPCSide (Moose::PCSideType pcs)
 
KSPNormType getPetscKSPNormType (Moose::MooseKSPNormType kspnorm)
 
void petscSetDefaultKSPNormType (FEProblemBase &problem, KSP ksp)
 
void petscSetDefaultPCSide (FEProblemBase &problem, KSP ksp)
 

Function Documentation

◆ addPetscOptionsFromCommandline()

void Moose::PetscSupport::addPetscOptionsFromCommandline ( )

Definition at line 215 of file PetscSupport.C.

Referenced by petscSetOptions(), and Moose::SlepcSupport::slepcSetOptions().

216 {
217  // commandline options always win
218  // the options from a user commandline will overwrite the existing ones if any conflicts
219  { // Get any options specified on the command-line
220  int argc;
221  char ** args;
222 
223  PetscGetArgs(&argc, &args);
224 #if PETSC_VERSION_LESS_THAN(3, 7, 0)
225  PetscOptionsInsert(&argc, &args, NULL);
226 #else
227  PetscOptionsInsert(PETSC_NULL, &argc, &args, NULL);
228 #endif
229  }
230 }

◆ colorAdjacencyMatrix()

void Moose::PetscSupport::colorAdjacencyMatrix ( PetscScalar *  adjacency_matrix,
unsigned int  size,
unsigned int  colors,
std::vector< unsigned int > &  vertex_colors,
const char *  coloring_algorithm 
)

This method takes an adjacency matrix, and a desired number of colors and applies a graph coloring algorithm to produce a coloring.

The coloring is returned as a vector of unsigned integers indicating which color or group each vextex in the adjacency matrix belongs to.

Definition at line 903 of file PetscSupport.C.

908 {
909  // Mat A will be a dense matrix from the incoming data structure
910  Mat A;
911  MatCreate(MPI_COMM_SELF, &A);
912  MatSetSizes(A, size, size, size, size);
913  MatSetType(A, MATSEQDENSE);
914  // PETSc requires a non-const data array to populate the matrix
915  MatSeqDenseSetPreallocation(A, adjacency_matrix);
916  MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
917  MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
918 
919  // Convert A to a sparse matrix
920  MatConvert(A,
921  MATAIJ,
922 #if PETSC_VERSION_LESS_THAN(3, 7, 0)
923  MAT_REUSE_MATRIX,
924 #else
925  MAT_INPLACE_MATRIX,
926 #endif
927  &A);
928 
929  ISColoring iscoloring;
930 #if PETSC_VERSION_LESS_THAN(3, 5, 0)
931  MatGetColoring(A, coloring_algorithm, &iscoloring);
932 #else
933  MatColoring mc;
934  MatColoringCreate(A, &mc);
935  MatColoringSetType(mc, coloring_algorithm);
936  MatColoringSetMaxColors(mc, static_cast<PetscInt>(colors));
937 
938  // Petsc normally colors by distance two (neighbors of neighbors), we just want one
939  MatColoringSetDistance(mc, 1);
940  MatColoringSetFromOptions(mc);
941  MatColoringApply(mc, &iscoloring);
942 #endif
943 
944  PetscInt nn;
945  IS * is;
946  ISColoringGetIS(iscoloring, &nn, &is);
947 
948  if (nn > static_cast<PetscInt>(colors))
949  throw std::runtime_error("Not able to color with designated number of colors");
950 
951  for (int i = 0; i < nn; i++)
952  {
953  PetscInt isize;
954  const PetscInt * indices;
955  ISGetLocalSize(is[i], &isize);
956  ISGetIndices(is[i], &indices);
957  for (int j = 0; j < isize; j++)
958  {
959  mooseAssert(indices[j] < static_cast<PetscInt>(vertex_colors.size()), "Index out of bounds");
960  vertex_colors[indices[j]] = i;
961  }
962  ISRestoreIndices(is[i], &indices);
963  }
964 
965  MatDestroy(&A);
966 #if !PETSC_VERSION_LESS_THAN(3, 5, 0)
967  MatColoringDestroy(&mc);
968 #endif
969  ISColoringDestroy(&iscoloring);
970 }
static PetscErrorCode Mat * A

◆ getCommonPetscFlags()

MultiMooseEnum Moose::PetscSupport::getCommonPetscFlags ( )

A helper function to produce a MultiMooseEnum with commonly used PETSc single options (flags)

Definition at line 857 of file PetscSupport.C.

Referenced by getPetscValidParams(), validParams< AddFieldSplitAction >(), and validParams< Split >().

858 {
859  return MultiMooseEnum(
860  "-dm_moose_print_embedding -dm_view -ksp_converged_reason -ksp_gmres_modifiedgramschmidt "
861  "-ksp_monitor -ksp_monitor_snes_lg-snes_ksp_ew -ksp_snes_ew -snes_converged_reason "
862  "-snes_ksp -snes_ksp_ew -snes_linesearch_monitor -snes_mf -snes_mf_operator -snes_monitor "
863  "-snes_test_display -snes_view",
864  "",
865  true);
866 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...

◆ getCommonPetscKeys()

MultiMooseEnum Moose::PetscSupport::getCommonPetscKeys ( )

A helper function to produce a MultiMooseEnum with commonly used PETSc iname options (keys in key-value pairs)

Definition at line 869 of file PetscSupport.C.

Referenced by getPetscValidParams(), and validParams< AddFieldSplitAction >().

870 {
871  return MultiMooseEnum("-ksp_atol -ksp_gmres_restart -ksp_max_it -ksp_pc_side -ksp_rtol "
872  "-ksp_type -mat_fd_coloring_err -mat_fd_type -mat_mffd_type "
873  "-pc_asm_overlap -pc_factor_levels "
874  "-pc_factor_mat_ordering_type -pc_hypre_boomeramg_grid_sweeps_all "
875  "-pc_hypre_boomeramg_max_iter "
876  "-pc_hypre_boomeramg_strong_threshold -pc_hypre_type -pc_type -snes_atol "
877  "-snes_linesearch_type "
878  "-snes_ls -snes_max_it -snes_rtol -snes_type -sub_ksp_type -sub_pc_type",
879  "",
880  true);
881 }
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...

◆ getPetscKSPNormType()

KSPNormType Moose::PetscSupport::getPetscKSPNormType ( Moose::MooseKSPNormType  kspnorm)

Definition at line 511 of file PetscSupport.C.

Referenced by petscSetDefaultKSPNormType().

512 {
513  switch (kspnorm)
514  {
515  case Moose::KSPN_NONE:
516  return KSP_NORM_NONE;
518  return KSP_NORM_PRECONDITIONED;
520  return KSP_NORM_UNPRECONDITIONED;
521  case Moose::KSPN_NATURAL:
522  return KSP_NORM_NATURAL;
523  case Moose::KSPN_DEFAULT:
524  return KSP_NORM_DEFAULT;
525  default:
526  mooseError("Unknown KSP norm type requested.");
527  break;
528  }
529 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
Use whatever we have in PETSc.
Definition: MooseTypes.h:436

◆ getPetscPCSide()

PCSide Moose::PetscSupport::getPetscPCSide ( Moose::PCSideType  pcs)

Definition at line 494 of file PetscSupport.C.

Referenced by petscSetDefaultPCSide().

495 {
496  switch (pcs)
497  {
498  case Moose::PCS_LEFT:
499  return PC_LEFT;
500  case Moose::PCS_RIGHT:
501  return PC_RIGHT;
503  return PC_SYMMETRIC;
504  default:
505  mooseError("Unknown PC side requested.");
506  break;
507  }
508 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ getPetscValidLineSearches()

std::set< std::string > Moose::PetscSupport::getPetscValidLineSearches ( )

Returns the valid petsc line search options as a set of strings.

Definition at line 816 of file PetscSupport.C.

Referenced by validParams< Executioner >().

817 {
818 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
819  return {"default", "cubic", "quadratic", "none", "basic", "basicnonorms"};
820 #else
821  return {"default", "shell", "none", "basic", "l2", "bt", "cp"};
822 #endif
823 }

◆ getPetscValidParams()

InputParameters Moose::PetscSupport::getPetscValidParams ( )

Returns the PETSc options that are common between Executioners and Preconditioners.

Returns
InputParameters object containing the PETSc related parameters

The output of this function should be added to the the parameters object of the overarching class

See also
CreateExecutionerAction

Definition at line 826 of file PetscSupport.C.

Referenced by validParams< Executioner >(), and validParams< MoosePreconditioner >().

827 {
829 
830  MooseEnum solve_type("PJFNK JFNK NEWTON FD LINEAR");
831  params.addParam<MooseEnum>("solve_type",
832  solve_type,
833  "PJFNK: Preconditioned Jacobian-Free Newton Krylov "
834  "JFNK: Jacobian-Free Newton Krylov "
835  "NEWTON: Full Newton Solve "
836  "FD: Use finite differences to compute Jacobian "
837  "LINEAR: Solving a linear problem");
838 
839  MooseEnum mffd_type("wp ds", "wp");
840  params.addParam<MooseEnum>("mffd_type",
841  mffd_type,
842  "Specifies the finite differencing type for "
843  "Jacobian-free solve types. Note that the "
844  "default is wp (for Walker and Pernice).");
845 
846  params.addParam<MultiMooseEnum>(
847  "petsc_options", getCommonPetscFlags(), "Singleton PETSc options");
848  params.addParam<MultiMooseEnum>(
849  "petsc_options_iname", getCommonPetscKeys(), "Names of PETSc name/value pairs");
850  params.addParam<std::vector<std::string>>(
851  "petsc_options_value",
852  "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\"");
853  return params;
854 }
MultiMooseEnum getCommonPetscKeys()
A helper function to produce a MultiMooseEnum with commonly used PETSc iname options (keys in key-val...
Definition: PetscSupport.C:869
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
MultiMooseEnum getCommonPetscFlags()
A helper function to produce a MultiMooseEnum with commonly used PETSc single options (flags) ...
Definition: PetscSupport.C:857
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:32
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...

◆ outputNorm()

void Moose::PetscSupport::outputNorm ( libMesh::Real  old_norm,
libMesh::Real  norm,
bool  use_color = false 
)

Helper function for outputing the norm values with/without color.

◆ petscConverged()

PetscErrorCode Moose::PetscSupport::petscConverged ( KSP  ksp,
PetscInt  n,
PetscReal  rnorm,
KSPConvergedReason *  reason,
void *  ctx 
)

Definition at line 281 of file PetscSupport.C.

Referenced by petscSetKSPDefaults().

282 {
283  // Cast the context pointer coming from PETSc to an FEProblemBase& and
284  // get a reference to the System from it.
285  FEProblemBase & problem = *static_cast<FEProblemBase *>(ctx);
286 
287  // Let's be nice and always check PETSc error codes.
288  PetscErrorCode ierr = 0;
289 
290  // We want the default behavior of the KSPDefaultConverged test, but
291  // we don't want PETSc to die in that function with a CHKERRQ
292  // call... that is probably extremely unlikely/impossible, but just
293  // to be on the safe side, we push a different error handler before
294  // calling KSPDefaultConverged().
295  ierr = PetscPushErrorHandler(PetscReturnErrorHandler, /*void* ctx=*/PETSC_NULL);
296  CHKERRABORT(problem.comm().get(), ierr);
297 
298 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
299  // Prior to PETSc 3.0.0, you could call KSPDefaultConverged with a NULL context
300  // pointer, as it was unused.
301  KSPDefaultConverged(ksp, n, rnorm, reason, PETSC_NULL);
302 #elif PETSC_VERSION_LESS_THAN(3, 5, 0)
303  // As of PETSc 3.0.0, you must call KSPDefaultConverged with a
304  // non-NULL context pointer which must be created with
305  // KSPDefaultConvergedCreate(), and destroyed with
306  // KSPDefaultConvergedDestroy().
307  void * default_ctx = NULL;
308  KSPDefaultConvergedCreate(&default_ctx);
309  KSPDefaultConverged(ksp, n, rnorm, reason, default_ctx);
310  KSPDefaultConvergedDestroy(default_ctx);
311 #else
312  // As of PETSc 3.5.0, use KSPConvergedDefaultXXX
313  void * default_ctx = NULL;
314  KSPConvergedDefaultCreate(&default_ctx);
315  KSPConvergedDefault(ksp, n, rnorm, reason, default_ctx);
316  KSPConvergedDefaultDestroy(default_ctx);
317 #endif
318 
319  // Pop the Error handler we pushed on the stack to go back
320  // to default PETSc error handling behavior.
321  ierr = PetscPopErrorHandler();
322  CHKERRABORT(problem.comm().get(), ierr);
323 
324  // Get tolerances from the KSP object
325  PetscReal rtol = 0.;
326  PetscReal atol = 0.;
327  PetscReal dtol = 0.;
328  PetscInt maxits = 0;
329  ierr = KSPGetTolerances(ksp, &rtol, &atol, &dtol, &maxits);
330  CHKERRABORT(problem.comm().get(), ierr);
331 
332  // Now do some additional MOOSE-specific tests...
333  std::string msg;
334  MooseLinearConvergenceReason moose_reason =
335  problem.checkLinearConvergence(msg, n, rnorm, rtol, atol, dtol, maxits);
336 
337  switch (moose_reason)
338  {
340  *reason = KSP_CONVERGED_RTOL;
341  break;
342 
343  case MOOSE_CONVERGED_ITS:
344  *reason = KSP_CONVERGED_ITS;
345  break;
346 
348 #if PETSC_VERSION_LESS_THAN(3, 4, 0)
349  // Report divergence due to exceeding the divergence tolerance.
350  *reason = KSP_DIVERGED_DTOL;
351 #else
352  // KSP_DIVERGED_NANORINF was added in PETSc 3.4.0.
353  *reason = KSP_DIVERGED_NANORINF;
354 #endif
355  break;
356 #if !PETSC_VERSION_LESS_THAN(3, 6, 0) // A new convergence enum in PETSc 3.6
358  *reason = KSP_DIVERGED_PCSETUP_FAILED;
359  break;
360 #endif
361  default:
362  {
363  // If it's not either of the two specific cases we handle, just go
364  // with whatever PETSc decided in KSPDefaultConverged.
365  break;
366  }
367  }
368 
369  return 0;
370 }
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseLinearConvergenceReason
virtual MooseLinearConvergenceReason checkLinearConvergence(std::string &msg, const PetscInt n, const Real rnorm, const Real rtol, const Real atol, const Real dtol, const PetscInt maxits)
Check for convergence of the linear solution.
PetscInt n
ierr
static PetscErrorCode Vec Mat Mat void * ctx

◆ petscLinearMonitor()

PetscErrorCode Moose::PetscSupport::petscLinearMonitor ( KSP  ,
PetscInt  its,
PetscReal  rnorm,
void *  void_ptr 
)

Helper function for displaying the linear residual during PETSC solve.

◆ petscNonlinearConverged()

PetscErrorCode Moose::PetscSupport::petscNonlinearConverged ( SNES  snes,
PetscInt  it,
PetscReal  xnorm,
PetscReal  snorm,
PetscReal  fnorm,
SNESConvergedReason *  reason,
void *  ctx 
)

Definition at line 373 of file PetscSupport.C.

Referenced by petscSetDefaults().

380 {
381  FEProblemBase & problem = *static_cast<FEProblemBase *>(ctx);
383 
384  // Let's be nice and always check PETSc error codes.
385  PetscErrorCode ierr = 0;
386 
387  // Temporary variables to store SNES tolerances. Usual C-style would be to declare
388  // but not initialize these... but it bothers me to leave anything uninitialized.
389  PetscReal atol = 0.; // absolute convergence tolerance
390  PetscReal rtol = 0.; // relative convergence tolerance
391  PetscReal stol = 0.; // convergence (step) tolerance in terms of the norm of the change in the
392  // solution between steps
393  PetscInt maxit = 0; // maximum number of iterations
394  PetscInt maxf = 0; // maximum number of function evaluations
395 
396  // Ask the SNES object about its tolerances.
397  ierr = SNESGetTolerances(snes, &atol, &rtol, &stol, &maxit, &maxf);
398  CHKERRABORT(problem.comm().get(), ierr);
399 
400  // Get current number of function evaluations done by SNES.
401  PetscInt nfuncs = 0;
402  ierr = SNESGetNumberFunctionEvals(snes, &nfuncs);
403  CHKERRABORT(problem.comm().get(), ierr);
404 
405  // Whether or not to force SNESSolve() take at least one iteration regardless of the initial
406  // residual norm
407  PetscBool force_iteration = PETSC_FALSE;
408 #if !PETSC_VERSION_LESS_THAN(3, 8, 4)
409  ierr = SNESGetForceIteration(snes, &force_iteration);
410  CHKERRABORT(problem.comm().get(), ierr);
411 #endif
412 
413 // See if SNESSetFunctionDomainError() has been called. Note:
414 // SNESSetFunctionDomainError() and SNESGetFunctionDomainError()
415 // were added in different releases of PETSc.
416 #if !PETSC_VERSION_LESS_THAN(3, 3, 0)
417  PetscBool domainerror;
418  ierr = SNESGetFunctionDomainError(snes, &domainerror);
419  CHKERRABORT(problem.comm().get(), ierr);
420  if (domainerror)
421  {
422  *reason = SNES_DIVERGED_FUNCTION_DOMAIN;
423  return 0;
424  }
425 #endif
426 
427  // Error message that will be set by the FEProblemBase.
428  std::string msg;
429 
430  // xnorm: 2-norm of current iterate
431  // snorm: 2-norm of current step
432  // fnorm: 2-norm of function at current iterate
433  MooseNonlinearConvergenceReason moose_reason =
434  problem.checkNonlinearConvergence(msg,
435  it,
436  xnorm,
437  snorm,
438  fnorm,
439  rtol,
440  stol,
441  atol,
442  nfuncs,
443  maxf,
444  force_iteration,
445  system._initial_residual_before_preset_bcs,
446  std::numeric_limits<Real>::max());
447 
448  if (msg.length() > 0)
449  PetscInfo(snes, msg.c_str());
450 
451  switch (moose_reason)
452  {
454  *reason = SNES_CONVERGED_ITERATING;
455  break;
456 
458  *reason = SNES_CONVERGED_FNORM_ABS;
459  break;
460 
462  *reason = SNES_CONVERGED_FNORM_RELATIVE;
463  break;
464 
466 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
467  *reason = SNES_CONVERGED_PNORM_RELATIVE;
468 #else
469  *reason = SNES_CONVERGED_SNORM_RELATIVE;
470 #endif
471  break;
472 
474  *reason = SNES_DIVERGED_FUNCTION_COUNT;
475  break;
476 
478  *reason = SNES_DIVERGED_FNORM_NAN;
479  break;
480 
482 #if PETSC_VERSION_LESS_THAN(3, 2, 0)
483  *reason = SNES_DIVERGED_LS_FAILURE;
484 #else
485  *reason = SNES_DIVERGED_LINE_SEARCH;
486 #endif
487  break;
488  }
489 
490  return 0;
491 }
NonlinearSystemBase & getNonlinearSystemBase()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Nonlinear system to be solved.
nl system()
MooseNonlinearConvergenceReason
Definition: FEProblemBase.h:89
ierr
static PetscErrorCode Vec Mat Mat void * ctx
virtual MooseNonlinearConvergenceReason checkNonlinearConvergence(std::string &msg, const PetscInt it, const Real xnorm, const Real snorm, const Real fnorm, const Real rtol, const Real stol, const Real abstol, const PetscInt nfuncs, const PetscInt max_funcs, const PetscBool force_iteration, const Real initial_residual_before_preset_bcs, const Real div_threshold)
Check for converence of the nonlinear solution.

◆ petscSetDefaultKSPNormType()

void Moose::PetscSupport::petscSetDefaultKSPNormType ( FEProblemBase problem,
KSP  ksp 
)

Definition at line 532 of file PetscSupport.C.

Referenced by petscSetKSPDefaults().

533 {
535 
536  KSPSetNormType(ksp, getPetscKSPNormType(nl.getMooseKSPNormType()));
537 }
KSPNormType getPetscKSPNormType(Moose::MooseKSPNormType kspnorm)
Definition: PetscSupport.C:511
NonlinearSystemBase & getNonlinearSystemBase()
NonlinearSystemBase * nl
Nonlinear system to be solved.
Moose::MooseKSPNormType getMooseKSPNormType()

◆ petscSetDefaultPCSide()

void Moose::PetscSupport::petscSetDefaultPCSide ( FEProblemBase problem,
KSP  ksp 
)

Definition at line 540 of file PetscSupport.C.

Referenced by petscSetKSPDefaults().

541 {
543 
544 #if PETSC_VERSION_LESS_THAN(3, 2, 0)
545  // pc_side is NOT set, PETSc will make the decision
546  // PETSc 3.1.x-
548  KSPSetPreconditionerSide(ksp, getPetscPCSide(nl.getPCSide()));
549 #else
550  // PETSc 3.2.x+
552  KSPSetPCSide(ksp, getPetscPCSide(nl.getPCSide()));
553 #endif
554 }
NonlinearSystemBase & getNonlinearSystemBase()
Moose::PCSideType getPCSide()
NonlinearSystemBase * nl
Nonlinear system to be solved.
PCSide getPetscPCSide(Moose::PCSideType pcs)
Definition: PetscSupport.C:494
Use whatever we have in PETSc.
Definition: MooseTypes.h:424

◆ petscSetDefaults()

void Moose::PetscSupport::petscSetDefaults ( FEProblemBase problem)

Sets the default options for PETSc.

Definition at line 598 of file PetscSupport.C.

Referenced by FEProblemBase::initPetscOutput(), and Moose::setSolverDefaults().

599 {
600  // dig out Petsc solver
602  PetscNonlinearSolver<Number> * petsc_solver =
603  dynamic_cast<PetscNonlinearSolver<Number> *>(nl.nonlinearSolver());
604  SNES snes = petsc_solver->snes();
605  KSP ksp;
606  SNESGetKSP(snes, &ksp);
607 
608  SNESSetMaxLinearSolveFailures(snes, 1000000);
609 
610 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
611  // PETSc 2.3.3-
612  SNESSetConvergenceTest(snes, petscNonlinearConverged, &problem);
613 #else
614  // PETSc 3.0.0+
615 
616  // In 3.0.0, the context pointer must actually be used, and the
617  // final argument to KSPSetConvergenceTest() is a pointer to a
618  // routine for destroying said private data context. In this case,
619  // we use the default context provided by PETSc in addition to
620  // a few other tests.
621  {
622  auto ierr = SNESSetConvergenceTest(snes, petscNonlinearConverged, &problem, PETSC_NULL);
623  CHKERRABORT(nl.comm().get(), ierr);
624  }
625 #endif
626 
627  petscSetKSPDefaults(problem, ksp);
628 }
NonlinearSystemBase & getNonlinearSystemBase()
virtual NonlinearSolver< Number > * nonlinearSolver()=0
void petscSetKSPDefaults(FEProblemBase &problem, KSP ksp)
Set the default options for a KSP.
Definition: PetscSupport.C:557
NonlinearSystemBase * nl
Nonlinear system to be solved.
ierr
PetscErrorCode petscNonlinearConverged(SNES snes, PetscInt it, PetscReal xnorm, PetscReal snorm, PetscReal fnorm, SNESConvergedReason *reason, void *ctx)
Definition: PetscSupport.C:373

◆ petscSetKSPDefaults()

void Moose::PetscSupport::petscSetKSPDefaults ( FEProblemBase problem,
KSP  ksp 
)

Set the default options for a KSP.

Definition at line 557 of file PetscSupport.C.

Referenced by petscSetDefaults(), and setLinearSolverDefaults().

558 {
560 
561 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
562  // PETSc 2.3.3-
563  KSPSetConvergenceTest(ksp, petscConverged, &problem);
564 #else
565  // PETSc 3.0.0+
566 
567  // In 3.0.0, the context pointer must actually be used, and the
568  // final argument to KSPSetConvergenceTest() is a pointer to a
569  // routine for destroying said private data context. In this case,
570  // we use the default context provided by PETSc in addition to
571  // a few other tests.
572  {
573  PetscErrorCode ierr = KSPSetConvergenceTest(ksp, petscConverged, &problem, PETSC_NULL);
574  CHKERRABORT(nl.comm().get(), ierr);
575  }
576 #endif
577 
578  auto & es = problem.es();
579 
580  PetscReal rtol = es.parameters.get<Real>("linear solver tolerance");
581  PetscReal atol = es.parameters.get<Real>("linear solver absolute step tolerance");
582 
583  // MOOSE defaults this to -1 for some dumb reason
584  if (atol < 0)
585  atol = 1e-50;
586 
587  PetscReal maxits = es.parameters.get<unsigned int>("linear solver maximum iterations");
588 
589  // 1e100 is because we don't use divtol currently
590  KSPSetTolerances(ksp, rtol, atol, 1e100, maxits);
591 
592  petscSetDefaultPCSide(problem, ksp);
593 
594  petscSetDefaultKSPNormType(problem, ksp);
595 }
NonlinearSystemBase & getNonlinearSystemBase()
void petscSetDefaultKSPNormType(FEProblemBase &problem, KSP ksp)
Definition: PetscSupport.C:532
PetscErrorCode petscConverged(KSP ksp, PetscInt n, PetscReal rnorm, KSPConvergedReason *reason, void *ctx)
Definition: PetscSupport.C:281
virtual EquationSystems & es() override
NonlinearSystemBase * nl
Nonlinear system to be solved.
ierr
void petscSetDefaultPCSide(FEProblemBase &problem, KSP ksp)
Definition: PetscSupport.C:540

◆ petscSetOptions()

void Moose::PetscSupport::petscSetOptions ( FEProblemBase problem)

A function for setting the PETSc options in PETSc from the options supplied to MOOSE.

Definition at line 233 of file PetscSupport.C.

Referenced by Moose::SlepcSupport::slepcSetOptions(), and FEProblemBase::solve().

234 {
235  // Reference to the options stored in FEPRoblem
236  PetscOptions & petsc = problem.getPetscOptions();
237 
238  if (petsc.inames.size() != petsc.values.size())
239  mooseError("PETSc names and options are not the same length");
240 
241 #if PETSC_VERSION_LESS_THAN(3, 7, 0)
242  PetscOptionsClear();
243 #else
244  PetscOptionsClear(PETSC_NULL);
245 #endif
246 
247  setSolverOptions(problem.solverParams());
248 
249  // Add any additional options specified in the input file
250  for (const auto & flag : petsc.flags)
251  setSinglePetscOption(flag.rawName().c_str());
252  for (unsigned int i = 0; i < petsc.inames.size(); ++i)
253  setSinglePetscOption(petsc.inames[i], petsc.values[i]);
254 
255  // set up DM which is required if use a field split preconditioner
258 
260 }
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
void addPetscOptionsFromCommandline()
Definition: PetscSupport.C:215
SolverParams & solverParams()
Get the solver parameters.
NonlinearSystemBase & getNonlinearSystemBase()
bool haveFieldSplitPreconditioner() const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
void setSolverOptions(SolverParams &solver_params)
Definition: PetscSupport.C:124
void petscSetupDM(NonlinearSystemBase &nl)
Definition: PetscSupport.C:168
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:884

◆ petscSetupDM()

void Moose::PetscSupport::petscSetupDM ( NonlinearSystemBase nl)

Definition at line 168 of file PetscSupport.C.

Referenced by petscSetOptions().

169 {
170 #if !PETSC_VERSION_LESS_THAN(3, 3, 0)
171  PetscErrorCode ierr;
172  PetscBool ismoose;
173  DM dm = PETSC_NULL;
174 
175  // Initialize the part of the DM package that's packaged with Moose; in the PETSc source tree this
176  // call would be in DMInitializePackage()
178  CHKERRABORT(nl.comm().get(), ierr);
179  // Create and set up the DM that will consume the split options and deal with block matrices.
180  PetscNonlinearSolver<Number> * petsc_solver =
181  dynamic_cast<PetscNonlinearSolver<Number> *>(nl.nonlinearSolver());
182  SNES snes = petsc_solver->snes();
183  // if there exists a DMMoose object, not to recreate a new one
184  ierr = SNESGetDM(snes, &dm);
185  CHKERRABORT(nl.comm().get(), ierr);
186  if (dm)
187  {
188  ierr = PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose);
189  CHKERRABORT(nl.comm().get(), ierr);
190  if (ismoose)
191  return;
192  }
193  ierr = DMCreateMoose(nl.comm().get(), nl, &dm);
194  CHKERRABORT(nl.comm().get(), ierr);
195  ierr = DMSetFromOptions(dm);
196  CHKERRABORT(nl.comm().get(), ierr);
197  ierr = DMSetUp(dm);
198  CHKERRABORT(nl.comm().get(), ierr);
199  ierr = SNESSetDM(snes, dm);
200  CHKERRABORT(nl.comm().get(), ierr);
201  ierr = DMDestroy(&dm);
202  CHKERRABORT(nl.comm().get(), ierr);
203 // We temporarily comment out this updating function because
204 // we lack an approach to check if the problem
205 // structure has been changed from the last iteration.
206 // The indices will be rebuilt for every timestep.
207 // TODO: figure out a way to check the structure changes of the
208 // matrix
209 // ierr = SNESSetUpdate(snes,SNESUpdateDMMoose);
210 // CHKERRABORT(nl.comm().get(),ierr);
211 #endif
212 }
virtual NonlinearSolver< Number > * nonlinearSolver()=0
PetscBool ismoose
PetscErrorCode DMCreateMoose(MPI_Comm, NonlinearSystemBase &, DM *)
NonlinearSystemBase * nl
ierr
PetscErrorCode DMMooseRegisterAll()

◆ petscSetupOutput()

PetscErrorCode Moose::PetscSupport::petscSetupOutput ( CommandLine cmd_line)

Definition at line 263 of file PetscSupport.C.

Referenced by MooseApp::executeExecutioner().

264 {
265  char code[10] = {45, 45, 109, 111, 111, 115, 101};
266  int argc = cmd_line->argc();
267  char ** argv = cmd_line->argv();
268  for (int i = 0; i < argc; i++)
269  {
270  std::string arg(argv[i]);
271  if (arg == std::string(code, 10))
272  {
274  break;
275  }
276  }
277  return 0;
278 }
int argc()
Definition: CommandLine.h:76
static void petscSetupOutput()
Output string for setting up PETSC output.
Definition: Console.C:647
char ** argv()
Definition: CommandLine.h:77

◆ setLinearSolverDefaults()

template<typename T >
void Moose::PetscSupport::setLinearSolverDefaults ( FEProblemBase problem,
LinearSolver< T > &  linear_solver 
)

Set the defaults for a libMesh LinearSolver.

Used in explicit solves

Definition at line 76 of file PetscSupport.h.

Referenced by ActuallyExplicitEuler::meshChanged().

77 {
78  petscSetKSPDefaults(problem, libMesh::cast_ref<PetscLinearSolver<T> &>(linear_solver).ksp());
79 }
void petscSetKSPDefaults(FEProblemBase &problem, KSP ksp)
Set the default options for a KSP.
Definition: PetscSupport.C:557

◆ setSinglePetscOption()

void Moose::PetscSupport::setSinglePetscOption ( const std::string &  name,
const std::string &  value = "" 
)

A wrapper function for dealing with different versions of PetscOptionsSetValue.

This is not generally called from MOOSE code, it is instead intended to be called by stuff in MOOSE::PetscSupport.

Definition at line 884 of file PetscSupport.C.

Referenced by petscSetOptions(), Moose::SlepcSupport::setEigenProblemOptions(), Moose::SlepcSupport::setEigenSolverOptions(), Moose::SlepcSupport::setSlepcEigenSolverTolerances(), Moose::SlepcSupport::setSlepcOutputOptions(), setSolverOptions(), and Moose::SlepcSupport::setWhichEigenPairsOptions().

885 {
886  PetscErrorCode ierr;
887 
888 #if PETSC_VERSION_LESS_THAN(3, 7, 0)
889  ierr = PetscOptionsSetValue(name.c_str(), value == "" ? PETSC_NULL : value.c_str());
890 #else
891  // PETSc 3.7.0 and later version. First argument is the options
892  // database to use, NULL indicates the default global database.
893  ierr = PetscOptionsSetValue(PETSC_NULL, name.c_str(), value == "" ? PETSC_NULL : value.c_str());
894 #endif
895 
896  // Not convenient to use the usual error checking macro, because we
897  // don't have a specific communicator in this helper function.
898  if (ierr)
899  mooseError("Error setting PETSc option: ", name);
900 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
ierr

◆ setSolverOptions()

void Moose::PetscSupport::setSolverOptions ( SolverParams solver_params)

Definition at line 124 of file PetscSupport.C.

Referenced by petscSetOptions().

125 {
126  // set PETSc options implied by a solve type
127  switch (solver_params._type)
128  {
129  case Moose::ST_PJFNK:
130  setSinglePetscOption("-snes_mf_operator");
131  setSinglePetscOption("-mat_mffd_type", stringify(solver_params._mffd_type));
132  break;
133 
134  case Moose::ST_JFNK:
135  setSinglePetscOption("-snes_mf");
136  setSinglePetscOption("-mat_mffd_type", stringify(solver_params._mffd_type));
137  break;
138 
139  case Moose::ST_NEWTON:
140  break;
141 
142  case Moose::ST_FD:
143  setSinglePetscOption("-snes_fd");
144  break;
145 
146  case Moose::ST_LINEAR:
147  setSinglePetscOption("-snes_type", "ksponly");
148  setSinglePetscOption("-snes_monitor_cancel");
149  break;
150  }
151 
152  Moose::LineSearchType ls_type = solver_params._line_search;
153  if (ls_type == Moose::LS_NONE)
154  ls_type = Moose::LS_BASIC;
155 
156  if (ls_type != Moose::LS_DEFAULT && ls_type != Moose::LS_CONTACT)
157  {
158 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
159  setSinglePetscOption("-snes_type", "ls");
160  setSinglePetscOption("-snes_ls", stringify(ls_type));
161 #else
162  setSinglePetscOption("-snes_linesearch_type", stringify(ls_type));
163 #endif
164  }
165 }
Full Newton Solve.
Definition: MooseTypes.h:446
Moose::LineSearchType _line_search
Definition: SolverParams.h:21
Solving a linear problem.
Definition: MooseTypes.h:448
Moose::MffdType _mffd_type
Definition: SolverParams.h:22
LineSearchType
Type of the line search.
Definition: MooseTypes.h:524
std::string stringify(const MffdType &t)
Definition: PetscSupport.C:109
Jacobian-Free Newton Krylov.
Definition: MooseTypes.h:445
Moose::SolveType _type
Definition: SolverParams.h:20
Use finite differences to compute Jacobian.
Definition: MooseTypes.h:447
Preconditioned Jacobian-Free Newton Krylov.
Definition: MooseTypes.h:444
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:884

◆ storePetscOptions()

void Moose::PetscSupport::storePetscOptions ( FEProblemBase fe_problem,
const InputParameters params 
)

Stores the PETSc options supplied from the InputParameters with MOOSE.

"-log_summary" cannot be used in the input file. This option needs to be set when PETSc is initialized which happens before the parser is even created. We'll throw an error if somebody attempts to add this option later.

"-log_summary" cannot be used in the input file. This option needs to be set when PETSc is initialized which happens before the parser is even created. We'll throw an error if somebody attempts to add this option later.

Definition at line 631 of file PetscSupport.C.

Referenced by SetupPreconditionerAction::act(), and Executioner::Executioner().

632 {
633  // Note: Options set in the Preconditioner block will override those set in the Executioner block
634  if (params.isParamValid("solve_type") && !params.isParamValid("_use_eigen_value"))
635  {
636  // Extract the solve type
637  const std::string & solve_type = params.get<MooseEnum>("solve_type");
638  fe_problem.solverParams()._type = Moose::stringToEnum<Moose::SolveType>(solve_type);
639  }
640 
641  if (params.isParamValid("line_search"))
642  {
643  MooseEnum line_search = params.get<MooseEnum>("line_search");
644  if (fe_problem.solverParams()._line_search == Moose::LS_INVALID || line_search != "default")
645  {
646  Moose::LineSearchType enum_line_search =
647  Moose::stringToEnum<Moose::LineSearchType>(line_search);
648  fe_problem.solverParams()._line_search = enum_line_search;
649  if (enum_line_search == LS_CONTACT)
650  {
651  NonlinearImplicitSystem * nl_system =
652  dynamic_cast<NonlinearImplicitSystem *>(&fe_problem.getNonlinearSystemBase().system());
653  if (!nl_system)
654  mooseError("You've requested a line search but you must be solving an EigenProblem. "
655  "These two things are not consistent.");
656  PetscNonlinearSolver<Real> * petsc_nonlinear_solver =
657  dynamic_cast<PetscNonlinearSolver<Real> *>(nl_system->nonlinear_solver.get());
658  if (!petsc_nonlinear_solver)
659  mooseError("Currently the contact line search is only implemented through Petsc, so you "
660  "must use Petsc as your non-linear solver.");
661  petsc_nonlinear_solver->linesearch_object =
662  libmesh_make_unique<ComputeLineSearchObjectWrapper>(fe_problem);
663  }
664  }
665  }
666 
667  if (params.isParamValid("mffd_type"))
668  {
669  MooseEnum mffd_type = params.get<MooseEnum>("mffd_type");
670  fe_problem.solverParams()._mffd_type = Moose::stringToEnum<Moose::MffdType>(mffd_type);
671  }
672 
673  // The parameters contained in the Action
674  const MultiMooseEnum & petsc_options = params.get<MultiMooseEnum>("petsc_options");
675  const MultiMooseEnum & petsc_options_inames = params.get<MultiMooseEnum>("petsc_options_iname");
676  const std::vector<std::string> & petsc_options_values =
677  params.get<std::vector<std::string>>("petsc_options_value");
678 
679  // A reference to the PetscOptions object that contains the settings that will be used in the
680  // solve
682 
683  // Update the PETSc single flags
684  for (const auto & option : petsc_options)
685  {
692  if (option == "-log_summary")
693  mooseError("The PETSc option \"-log_summary\" can only be used on the command line. Please "
694  "remove it from the input file");
695 
696  // Warn about superseded PETSc options (Note: -snes is not a REAL option, but people used it in
697  // their input files)
698  else
699  {
700  std::string help_string;
701  if (option == "-snes" || option == "-snes_mf" || option == "-snes_mf_operator")
702  help_string = "Please set the solver type through \"solve_type\".";
703  else if (option == "-ksp_monitor")
704  help_string = "Please use \"Outputs/print_linear_residuals=true\"";
705 
706  if (help_string != "")
707  mooseWarning("The PETSc option ",
708  std::string(option),
709  " should not be used directly in a MOOSE input file. ",
710  help_string);
711  }
712 
713  // Update the stored items, but do not create duplicates
714  if (!po.flags.contains(option))
715  po.flags.push_back(option);
716  }
717 
718  // Check that the name value pairs are sized correctly
719  if (petsc_options_inames.size() != petsc_options_values.size())
720  mooseError("PETSc names and options are not the same length");
721 
722  // Setup the name value pairs
723  bool boomeramg_found = false;
724  bool strong_threshold_found = false;
725 #if !PETSC_VERSION_LESS_THAN(3, 7, 0)
726  bool superlu_dist_found = false;
727  bool fact_pattern_found = false;
728  bool tiny_pivot_found = false;
729 #endif
730  std::string pc_description = "";
731  for (unsigned int i = 0; i < petsc_options_inames.size(); i++)
732  {
733  // Do not add duplicate settings
734  if (find(po.inames.begin(), po.inames.end(), petsc_options_inames[i]) == po.inames.end())
735  {
736 #if !PETSC_VERSION_LESS_THAN(3, 9, 0)
737  if (petsc_options_inames[i] == "-pc_factor_mat_solver_package")
738  po.inames.push_back("-pc_factor_mat_solver_type");
739  else
740  po.inames.push_back(petsc_options_inames[i]);
741 #else
742  if (petsc_options_inames[i] == "-pc_factor_mat_solver_type")
743  po.inames.push_back("-pc_factor_mat_solver_package");
744  else
745  po.inames.push_back(petsc_options_inames[i]);
746 #endif
747  po.values.push_back(petsc_options_values[i]);
748 
749  // Look for a pc description
750  if (petsc_options_inames[i] == "-pc_type" || petsc_options_inames[i] == "-pc_sub_type" ||
751  petsc_options_inames[i] == "-pc_hypre_type")
752  pc_description += petsc_options_values[i] + ' ';
753 
754  // This special case is common enough that we'd like to handle it for the user.
755  if (petsc_options_inames[i] == "-pc_hypre_type" && petsc_options_values[i] == "boomeramg")
756  boomeramg_found = true;
757  if (petsc_options_inames[i] == "-pc_hypre_boomeramg_strong_threshold")
758  strong_threshold_found = true;
759 #if !PETSC_VERSION_LESS_THAN(3, 7, 0)
760  if ((petsc_options_inames[i] == "-pc_factor_mat_solver_package" ||
761  petsc_options_inames[i] == "-pc_factor_mat_solver_type") &&
762  petsc_options_values[i] == "superlu_dist")
763  superlu_dist_found = true;
764  if (petsc_options_inames[i] == "-mat_superlu_dist_fact")
765  fact_pattern_found = true;
766  if (petsc_options_inames[i] == "-mat_superlu_dist_replacetinypivot")
767  tiny_pivot_found = true;
768 #endif
769  }
770  else
771  {
772  for (unsigned int j = 0; j < po.inames.size(); j++)
773  if (po.inames[j] == petsc_options_inames[i])
774  po.values[j] = petsc_options_values[i];
775  }
776  }
777 
778  // When running a 3D mesh with boomeramg, it is almost always best to supply a strong threshold
779  // value
780  // We will provide that for the user here if they haven't supplied it themselves.
781  if (boomeramg_found && !strong_threshold_found && fe_problem.mesh().dimension() == 3)
782  {
783  po.inames.push_back("-pc_hypre_boomeramg_strong_threshold");
784  po.values.push_back("0.7");
785  pc_description += "strong_threshold: 0.7 (auto)";
786  }
787 
788 #if !PETSC_VERSION_LESS_THAN(3, 7, 0)
789  // In PETSc-3.7.{0--4}, there is a bug when using superlu_dist, and we have to use
790  // SamePattern_SameRowPerm, otherwise we use whatever we have in PETSc
791  if (superlu_dist_found && !fact_pattern_found)
792  {
793  po.inames.push_back("-mat_superlu_dist_fact");
794 #if PETSC_VERSION_LESS_THAN(3, 7, 5)
795  po.values.push_back("SamePattern_SameRowPerm");
796  pc_description += "mat_superlu_dist_fact: SamePattern_SameRowPerm ";
797 #else
798  po.values.push_back("SamePattern");
799  pc_description += "mat_superlu_dist_fact: SamePattern ";
800 #endif
801  }
802 
803  // restore this superlu option
804  if (superlu_dist_found && !tiny_pivot_found)
805  {
806  po.inames.push_back("-mat_superlu_dist_replacetinypivot");
807  po.values.push_back("1");
808  pc_description += " mat_superlu_dist_replacetinypivot: true ";
809  }
810 #endif
811  // Set Preconditioner description
812  po.pc_description = pc_description;
813 }
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
SolverParams & solverParams()
Get the solver parameters.
NonlinearSystemBase & getNonlinearSystemBase()
Moose::LineSearchType _line_search
Definition: SolverParams.h:21
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:220
A struct for storing the various types of petsc options and values.
Definition: PetscSupport.h:41
Moose::MffdType _mffd_type
Definition: SolverParams.h:22
LineSearchType
Type of the line search.
Definition: MooseTypes.h:524
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimsension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh m...
Definition: MooseMesh.C:2099
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:32
Moose::SolveType _type
Definition: SolverParams.h:20
virtual System & system() override
Get the reference to the libMesh system.
virtual MooseMesh & mesh() override
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
means not set
Definition: MooseTypes.h:526
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

◆ stringify() [1/2]

std::string Moose::PetscSupport::stringify ( const LineSearchType t)

Definition at line 73 of file PetscSupport.C.

Referenced by setSolverOptions().

74 {
75  switch (t)
76  {
77  case LS_BASIC:
78  return "basic";
79  case LS_DEFAULT:
80  return "default";
81  case LS_NONE:
82  return "none";
83 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
84  case LS_CUBIC:
85  return "cubic";
86  case LS_QUADRATIC:
87  return "quadratic";
88  case LS_BASICNONORMS:
89  return "basicnonorms";
90 #else
91  case LS_SHELL:
92  return "shell";
93  case LS_L2:
94  return "l2";
95  case LS_BT:
96  return "bt";
97  case LS_CP:
98  return "cp";
99  case LS_CONTACT:
100  return "contact";
101 #endif
102  case LS_INVALID:
103  mooseError("Invalid LineSearchType");
104  }
105  return "";
106 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
means not set
Definition: MooseTypes.h:526

◆ stringify() [2/2]

std::string Moose::PetscSupport::stringify ( const MffdType t)

Definition at line 109 of file PetscSupport.C.

110 {
111  switch (t)
112  {
113  case MFFD_WP:
114  return "wp";
115  case MFFD_DS:
116  return "ds";
117  case MFFD_INVALID:
118  mooseError("Invalid MffdType");
119  }
120  return "";
121 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
means not set
Definition: MooseTypes.h:550