www.mooseframework.org
Functions | Variables
Moose::SlepcSupport Namespace Reference

Functions

InputParameters getSlepcValidParams (InputParameters &params)
 
InputParameters getSlepcEigenProblemValidParams ()
 
void storeSlepcOptions (FEProblemBase &fe_problem, const InputParameters &params)
 
void storeSlepcEigenProblemOptions (EigenProblem &eigen_problem, const InputParameters &params)
 
void slepcSetOptions (EigenProblem &eigen_problem, const InputParameters &params)
 
void setSlepcEigenSolverTolerances (EigenProblem &eigen_problem, const InputParameters &params)
 
void setSlepcOutputOptions (EigenProblem &eigen_problem)
 
PetscErrorCode mooseSlepcEigenFormJacobianA (SNES snes, Vec x, Mat jac, Mat pc, void *ctx)
 
PetscErrorCode mooseSlepcEigenFormJacobianB (SNES snes, Vec x, Mat jac, Mat pc, void *ctx)
 
PetscErrorCode mooseSlepcEigenFormFunctionA (SNES snes, Vec x, Vec r, void *ctx)
 
PetscErrorCode mooseSlepcEigenFormFunctionB (SNES snes, Vec x, Vec r, void *ctx)
 
void setEigenProblemOptions (SolverParams &solver_params)
 
void setWhichEigenPairsOptions (SolverParams &solver_params)
 
void setEigenSolverOptions (SolverParams &solver_params, const InputParameters &params)
 
void moosePetscSNESFormJacobian (SNES, Vec x, Mat jac, Mat pc, void *ctx, Moose::KernelType type)
 
void moosePetscSNESFormFunction (SNES, Vec x, Vec r, void *ctx, Moose::KernelType type)
 

Variables

const int subspace_factor = 2
 

Function Documentation

InputParameters Moose::SlepcSupport::getSlepcEigenProblemValidParams ( )

Definition at line 71 of file SlepcSupport.C.

Referenced by validParams< Eigenvalue >().

72 {
74 
75  // We are solving a Non-Hermitian eigenvalue problem by default
76  MooseEnum eigen_problem_type("HERMITIAN NON_HERMITIAN GEN_HERMITIAN GEN_NON_HERMITIAN "
77  "GEN_INDEFINITE POS_GEN_NON_HERMITIAN "
78  "NON_HERMITIAN SLEPC_DEFAULT");
79  params.addParam<MooseEnum>(
80  "eigen_problem_type",
81  eigen_problem_type,
82  "Type of the eigenvalue problem we are solving "
83  "HERMITIAN: Hermitian "
84  "NON_HERMITIAN: Non-Hermitian "
85  "GEN_HERMITIAN: Generalized Hermitian "
86  "GEN_NON_HERMITIAN: Generalized Non-Hermitian "
87  "GEN_INDEFINITE: Generalized indefinite Hermitian "
88  "POS_GEN_NON_HERMITIAN: Generalized Non-Hermitian with positive (semi-)definite B "
89  "SLEPC_DEFAULT: Use whatever SLEPC has by default ");
90 
91  // Which eigenvalues are we interested in
92  MooseEnum which_eigen_pairs("LARGEST_MAGNITUDE SMALLEST_MAGNITUDE LARGEST_REAL SMALLEST_REAL "
93  "LARGEST_IMAGINARY SMALLEST_IMAGINARY TARGET_MAGNITUDE TARGET_REAL "
94  "TARGET_IMAGINARY ALL_EIGENVALUES "
95  "SMALLEST_MAGNITUDE SLEPC_DEFAULT");
96  params.addParam<MooseEnum>("which_eigen_pairs",
97  which_eigen_pairs,
98  "Which eigenvalue pairs to obtain from the solution "
99  "LARGEST_MAGNITUDE "
100  "SMALLEST_MAGNITUDE "
101  "LARGEST_REAL "
102  "SMALLEST_REAL "
103  "LARGEST_IMAGINARY "
104  "SMALLEST_IMAGINARY "
105  "TARGET_MAGNITUDE "
106  "TARGET_REAL "
107  "TARGET_IMAGINARY "
108  "ALL_EIGENVALUES "
109  "SLEPC_DEFAULT ");
110 
111  params.addParam<unsigned int>("n_eigen_pairs", 1, "The number of eigen pairs");
112  params.addParam<unsigned int>("n_basis_vectors", 3, "The dimension of eigen subspaces");
113 
114  params.addParam<Real>("eigen_tol", 1.0e-4, "Relative Tolerance for Eigen Solver");
115  params.addParam<unsigned int>("eigen_max_its", 10000, "Max Iterations for Eigen Solver");
116 
117  params.addParam<Real>("l_abs_tol", 1e-50, "Absolute Tolerances for Linear Solver");
118 
119  params.addParam<unsigned int>("free_power_iterations", 4, "The number of free power iterations");
120 
121  return params;
122 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
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...
InputParameters Moose::SlepcSupport::getSlepcValidParams ( InputParameters params)
Returns
InputParameters object containing the SLEPC related parameters

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

See also
EigenProblem

Definition at line 43 of file SlepcSupport.C.

Referenced by validParams< Eigenvalue >().

44 {
45  MooseEnum solve_type("POWER ARNOLDI KRYLOVSCHUR JACOBI_DAVIDSON "
46  "NONLINEAR_POWER MF_NONLINEAR_POWER "
47  "MONOLITH_NEWTON MF_MONOLITH_NEWTON");
48  params.set<MooseEnum>("solve_type") = solve_type;
49 
50  params.setDocString("solve_type",
51  "POWER: Power / Inverse / RQI "
52  "ARNOLDI: Arnoldi "
53  "KRYLOVSCHUR: Krylov-Schur "
54  "JACOBI_DAVIDSON: Jacobi-Davidson "
55  "NONLINEAR_POWER: Nonlinear Power "
56  "MF_NONLINEAR_POWER: Matrix-free Nonlinear Power "
57  "MONOLITH_NEWTON: Newton "
58  "MF_MONOLITH_NEWTON: Matrix-free Newton ");
59 
60  // When the eigenvalue problems is reformed as a coupled nonlinear system,
61  // we use part of Jacobian as the preconditioning matrix.
62  // Because the difference between the Jacobian and the preconditioning matrix is not small,
63  // the linear solver KSP can not reduce the residual much. After several tests,
64  // we find 1e-2 is a reasonable choice.
65  params.set<Real>("l_tol") = 1e-2;
66 
67  return params;
68 }
void setDocString(const std::string &name, const std::string &doc)
Set the doc string of a parameter.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
void Moose::SlepcSupport::moosePetscSNESFormFunction ( SNES  ,
Vec  x,
Vec  r,
void *  ctx,
Moose::KernelType  type 
)

Definition at line 497 of file SlepcSupport.C.

Referenced by mooseSlepcEigenFormFunctionA(), and mooseSlepcEigenFormFunctionB().

498 {
499  EigenProblem * eigen_problem = static_cast<EigenProblem *>(ctx);
500  NonlinearSystemBase & nl = eigen_problem->getNonlinearSystemBase();
501  System & sys = nl.system();
502 
503  PetscVector<Number> X_global(x, sys.comm()), R(r, sys.comm());
504 
505  // update local solution
506  X_global.localize(*sys.current_local_solution.get());
507 
508  R.zero();
509 
510  eigen_problem->computeResidualType(*sys.current_local_solution.get(), R, type);
511 
512  R.close();
513 }
NonlinearSystemBase & getNonlinearSystemBase()
static PetscErrorCode Vec x
PetscVector< Number > X_global(x, nl->comm())
NonlinearSystemBase * nl
Nonlinear system to be solved.
MatType type
virtual System & system() override
Get the reference to the libMesh system.
void computeResidualType(const NumericVector< Number > &soln, NumericVector< Number > &residual, Moose::KernelType type) override
Definition: EigenProblem.C:176
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: EigenProblem.h:32
static PetscErrorCode Vec Mat Mat void * ctx
void Moose::SlepcSupport::moosePetscSNESFormJacobian ( SNES  ,
Vec  x,
Mat  jac,
Mat  pc,
void *  ctx,
Moose::KernelType  type 
)

Definition at line 450 of file SlepcSupport.C.

Referenced by mooseSlepcEigenFormJacobianA(), and mooseSlepcEigenFormJacobianB().

452 {
453  EigenProblem * eigen_problem = static_cast<EigenProblem *>(ctx);
454  NonlinearSystemBase & nl = eigen_problem->getNonlinearSystemBase();
455  System & sys = nl.system();
456 
457  PetscVector<Number> X_global(x, sys.comm());
458 
459  // update local solution
460  X_global.localize(*sys.current_local_solution.get());
461 
462  PetscMatrix<Number> PC(pc, sys.comm());
463  PetscMatrix<Number> Jac(jac, sys.comm());
464 
465  // Set the dof maps
466  PC.attach_dof_map(sys.get_dof_map());
467  Jac.attach_dof_map(sys.get_dof_map());
468 
469  PC.zero();
470 
471  eigen_problem->computeJacobian(*sys.current_local_solution.get(), PC, type);
472 
473  PC.close();
474  if (jac != pc)
475  Jac.close();
476 }
static PetscErrorCode Vec Mat jac
NonlinearSystemBase & getNonlinearSystemBase()
PetscMatrix< Number > Jac(jac, nl->comm())
static PetscErrorCode Vec Mat Mat pc
static PetscErrorCode Vec x
PetscVector< Number > X_global(x, nl->comm())
NonlinearSystemBase * nl
Nonlinear system to be solved.
MatType type
virtual void computeJacobian(const NumericVector< Number > &soln, SparseMatrix< Number > &jacobian, Moose::KernelType kernel_type) override
Definition: EigenProblem.C:115
virtual System & system() override
Get the reference to the libMesh system.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: EigenProblem.h:32
static PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode Moose::SlepcSupport::mooseSlepcEigenFormFunctionA ( SNES  snes,
Vec  x,
Vec  r,
void *  ctx 
)

Definition at line 516 of file SlepcSupport.C.

Referenced by Moose::assemble_matrix().

517 {
519 
522 }
void moosePetscSNESFormFunction(SNES, Vec x, Vec r, void *ctx, Moose::KernelType type)
Definition: SlepcSupport.C:497
PetscFunctionBegin
static PetscErrorCode Vec x
PetscFunctionReturn(0)
static PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode Moose::SlepcSupport::mooseSlepcEigenFormFunctionB ( SNES  snes,
Vec  x,
Vec  r,
void *  ctx 
)

Definition at line 525 of file SlepcSupport.C.

Referenced by Moose::assemble_matrix().

526 {
528 
531 }
void moosePetscSNESFormFunction(SNES, Vec x, Vec r, void *ctx, Moose::KernelType type)
Definition: SlepcSupport.C:497
PetscFunctionBegin
static PetscErrorCode Vec x
PetscFunctionReturn(0)
static PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode Moose::SlepcSupport::mooseSlepcEigenFormJacobianA ( SNES  snes,
Vec  x,
Mat  jac,
Mat  pc,
void *  ctx 
)

Definition at line 479 of file SlepcSupport.C.

Referenced by Moose::assemble_matrix().

480 {
482 
485 }
static PetscErrorCode Vec Mat jac
PetscFunctionBegin
static PetscErrorCode Vec Mat Mat pc
static PetscErrorCode Vec x
PetscFunctionReturn(0)
void moosePetscSNESFormJacobian(SNES, Vec x, Mat jac, Mat pc, void *ctx, Moose::KernelType type)
Definition: SlepcSupport.C:450
static PetscErrorCode Vec Mat Mat void * ctx
PetscErrorCode Moose::SlepcSupport::mooseSlepcEigenFormJacobianB ( SNES  snes,
Vec  x,
Mat  jac,
Mat  pc,
void *  ctx 
)

Definition at line 488 of file SlepcSupport.C.

Referenced by Moose::assemble_matrix().

489 {
491 
494 }
static PetscErrorCode Vec Mat jac
PetscFunctionBegin
static PetscErrorCode Vec Mat Mat pc
static PetscErrorCode Vec x
PetscFunctionReturn(0)
void moosePetscSNESFormJacobian(SNES, Vec x, Mat jac, Mat pc, void *ctx, Moose::KernelType type)
Definition: SlepcSupport.C:450
static PetscErrorCode Vec Mat Mat void * ctx
void Moose::SlepcSupport::setEigenProblemOptions ( SolverParams solver_params)

Definition at line 226 of file SlepcSupport.C.

Referenced by slepcSetOptions().

227 {
228  switch (solver_params._eigen_problem_type)
229  {
232  break;
233 
235  Moose::PetscSupport::setSinglePetscOption("-eps_non_hermitian");
236  break;
237 
239  Moose::PetscSupport::setSinglePetscOption("-eps_gen_hermitian");
240  break;
241 
243  Moose::PetscSupport::setSinglePetscOption("-eps_gen_indefinite");
244  break;
245 
247  Moose::PetscSupport::setSinglePetscOption("-eps_gen_non_hermitian");
248  break;
249 
251  Moose::PetscSupport::setSinglePetscOption("-eps_pos_gen_non_hermitian");
252  break;
253 
255  break;
256 
257  default:
258  mooseError("Unknown eigen solver type \n");
259  }
260 }
Generalized Non-Hermitian.
Definition: MooseTypes.h:278
Generalized Hermitian indefinite.
Definition: MooseTypes.h:277
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
use whatever SLPEC has by default
Definition: MooseTypes.h:280
Generalized Non-Hermitian with positive (semi-)definite B.
Definition: MooseTypes.h:279
Moose::EigenProblemType _eigen_problem_type
Definition: SolverParams.h:31
Non-Hermitian.
Definition: MooseTypes.h:275
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:812
Generalized Hermitian.
Definition: MooseTypes.h:276
void Moose::SlepcSupport::setEigenSolverOptions ( SolverParams solver_params,
const InputParameters params 
)

Definition at line 352 of file SlepcSupport.C.

Referenced by slepcSetOptions().

353 {
354  // Avoid unused variable warnings when you have SLEPc but not PETSc-dev.
355  libmesh_ignore(params);
356 
357  switch (solver_params._eigen_solve_type)
358  {
359  case Moose::EST_POWER:
360  Moose::PetscSupport::setSinglePetscOption("-eps_type", "power");
361  break;
362 
363  case Moose::EST_ARNOLDI:
364  Moose::PetscSupport::setSinglePetscOption("-eps_type", "arnoldi");
365  break;
366 
368  Moose::PetscSupport::setSinglePetscOption("-eps_type", "krylovschur");
369  break;
370 
373  break;
374 
376 #if !SLEPC_VERSION_LESS_THAN(3, 7, 3) && !PETSC_VERSION_RELEASE
377  Moose::PetscSupport::setSinglePetscOption("-eps_type", "power");
378  Moose::PetscSupport::setSinglePetscOption("-eps_power_nonlinear", "1");
379  Moose::PetscSupport::setSinglePetscOption("-eps_target_magnitude", "");
380  Moose::PetscSupport::setSinglePetscOption("-st_type", "sinvert");
381 #else
382  mooseError("Nonlinear Inverse Power requires SLEPc 3.7.3 or higher");
383 #endif
384  break;
385 
387 #if !SLEPC_VERSION_LESS_THAN(3, 7, 3) && !PETSC_VERSION_RELEASE
388  Moose::PetscSupport::setSinglePetscOption("-eps_type", "power");
389  Moose::PetscSupport::setSinglePetscOption("-eps_power_nonlinear", "1");
390  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_mf_operator", "1");
391  Moose::PetscSupport::setSinglePetscOption("-eps_target_magnitude", "");
392  Moose::PetscSupport::setSinglePetscOption("-st_type", "sinvert");
393 #else
394  mooseError("Matrix-free nonlinear Inverse Power requires SLEPc 3.7.3 or higher");
395 #endif
396  break;
397 
399 #if !SLEPC_VERSION_LESS_THAN(3, 7, 3) && !PETSC_VERSION_RELEASE
400  Moose::PetscSupport::setSinglePetscOption("-eps_type", "power");
401  Moose::PetscSupport::setSinglePetscOption("-eps_power_nonlinear", "1");
402  Moose::PetscSupport::setSinglePetscOption("-eps_power_update", "1");
403  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_snes_max_it", "1");
404  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_ksp_rtol", "1e-2");
406  "-init_eps_max_it", stringify(params.get<unsigned int>("free_power_iterations")));
407  Moose::PetscSupport::setSinglePetscOption("-eps_target_magnitude", "");
408  Moose::PetscSupport::setSinglePetscOption("-st_type", "sinvert");
409 #else
410  mooseError("Newton-based eigenvalue solver requires SLEPc 3.7.3 or higher");
411 #endif
412  break;
413 
415 #if !SLEPC_VERSION_LESS_THAN(3, 7, 3) && !PETSC_VERSION_RELEASE
416  Moose::PetscSupport::setSinglePetscOption("-eps_type", "power");
417  Moose::PetscSupport::setSinglePetscOption("-eps_power_nonlinear", "1");
418  Moose::PetscSupport::setSinglePetscOption("-eps_power_update", "1");
419  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_mf_operator", "1");
420  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_snes_mf_operator", "1");
421  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_snes_max_it", "1");
422  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_ksp_rtol", "1e-2");
424  "-init_eps_max_it", stringify(params.get<unsigned int>("free_power_iterations")));
425  Moose::PetscSupport::setSinglePetscOption("-eps_target_magnitude", "");
426  Moose::PetscSupport::setSinglePetscOption("-st_type", "sinvert");
427 #else
428  mooseError("Matrix-free Newton-based eigenvalue solver requires SLEPc 3.7.3 or higher");
429 #endif
430  break;
431 
432  default:
433  mooseError("Unknown eigen solver type \n");
434  }
435 }
Newton-based eigen solver.
Definition: MooseTypes.h:265
Moose::EigenSolveType _eigen_solve_type
Definition: SolverParams.h:30
Matrix-free Newton-based eigen solver.
Definition: MooseTypes.h:266
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
Matrix-free nonlinear inverse power.
Definition: MooseTypes.h:264
Power / Inverse / RQI.
Definition: MooseTypes.h:259
Krylov-Schur.
Definition: MooseTypes.h:261
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66
Nonlinear inverse power.
Definition: MooseTypes.h:263
Jacobi-Davidson.
Definition: MooseTypes.h:262
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:812
void Moose::SlepcSupport::setSlepcEigenSolverTolerances ( EigenProblem eigen_problem,
const InputParameters params 
)

Definition at line 125 of file SlepcSupport.C.

Referenced by slepcSetOptions().

126 {
127  Moose::PetscSupport::setSinglePetscOption("-eps_tol", stringify(params.get<Real>("eigen_tol")));
128 
130  stringify(params.get<unsigned int>("eigen_max_its")));
131 
132  // if it is a nonlinear eigenvalue solver, we need to set tolerances for nonlinear solver and
133  // linear solver
134  if (eigen_problem.isNonlinearEigenvalueSolver())
135  {
136  // nonlinear solver tolerances
137  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_max_it",
138  stringify(params.get<unsigned int>("nl_max_its")));
139 
140  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_max_funcs",
141  stringify(params.get<unsigned int>("nl_max_funcs")));
142 
143  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_atol",
144  stringify(params.get<Real>("nl_abs_tol")));
145 
146  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_rtol",
147  stringify(params.get<Real>("nl_rel_tol")));
148 
149  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_stol",
150  stringify(params.get<Real>("nl_rel_step_tol")));
151 
152  // linear solver
153  Moose::PetscSupport::setSinglePetscOption("-eps_power_ksp_max_it",
154  stringify(params.get<unsigned int>("l_max_its")));
155 
156  Moose::PetscSupport::setSinglePetscOption("-eps_power_ksp_rtol",
157  stringify(params.get<Real>("l_tol")));
158 
159  Moose::PetscSupport::setSinglePetscOption("-eps_power_ksp_atol",
160  stringify(params.get<Real>("l_abs_tol")));
161  }
162  else
163  { // linear eigenvalue problem
164  // linear solver
166  stringify(params.get<unsigned int>("l_max_its")));
167 
168  Moose::PetscSupport::setSinglePetscOption("-st_ksp_rtol", stringify(params.get<Real>("l_tol")));
169 
171  stringify(params.get<Real>("l_abs_tol")));
172  }
173 }
virtual bool isNonlinearEigenvalueSolver()
Definition: EigenProblem.C:155
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:812
void Moose::SlepcSupport::setSlepcOutputOptions ( EigenProblem eigen_problem)

Definition at line 263 of file SlepcSupport.C.

Referenced by slepcSetOptions().

264 {
265  Moose::PetscSupport::setSinglePetscOption("-eps_monitor_conv");
267  switch (eigen_problem.solverParams()._eigen_solve_type)
268  {
271  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_monitor");
272  Moose::PetscSupport::setSinglePetscOption("-eps_power_ksp_monitor");
273  break;
274 
277  Moose::PetscSupport::setSinglePetscOption("-init_eps_monitor_conv");
278  Moose::PetscSupport::setSinglePetscOption("-init_eps_monitor");
279  Moose::PetscSupport::setSinglePetscOption("-eps_power_snes_monitor");
280  Moose::PetscSupport::setSinglePetscOption("-eps_power_ksp_monitor");
281  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_snes_monitor");
282  Moose::PetscSupport::setSinglePetscOption("-init_eps_power_ksp_monitor");
283  break;
284  case Moose::EST_POWER:
285  break;
286 
287  case Moose::EST_ARNOLDI:
288  break;
289 
291  break;
292 
294  break;
295  }
296 }
Newton-based eigen solver.
Definition: MooseTypes.h:265
Moose::EigenSolveType _eigen_solve_type
Definition: SolverParams.h:30
SolverParams & solverParams()
Get the solver parameters.
Matrix-free Newton-based eigen solver.
Definition: MooseTypes.h:266
Matrix-free nonlinear inverse power.
Definition: MooseTypes.h:264
Power / Inverse / RQI.
Definition: MooseTypes.h:259
Krylov-Schur.
Definition: MooseTypes.h:261
Nonlinear inverse power.
Definition: MooseTypes.h:263
Jacobi-Davidson.
Definition: MooseTypes.h:262
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:812
void Moose::SlepcSupport::setWhichEigenPairsOptions ( SolverParams solver_params)

Definition at line 299 of file SlepcSupport.C.

Referenced by slepcSetOptions().

300 {
301  switch (solver_params._which_eigen_pairs)
302  {
304  Moose::PetscSupport::setSinglePetscOption("-eps_largest_magnitude");
305  break;
306 
308  Moose::PetscSupport::setSinglePetscOption("-eps_smallest_magnitude");
309  break;
310 
312  Moose::PetscSupport::setSinglePetscOption("-eps_largest_real");
313  break;
314 
316  Moose::PetscSupport::setSinglePetscOption("-eps_smallest_real");
317  break;
318 
320  Moose::PetscSupport::setSinglePetscOption("-eps_largest_imaginary");
321  break;
322 
324  Moose::PetscSupport::setSinglePetscOption("-eps_smallest_imaginary");
325  break;
326 
328  Moose::PetscSupport::setSinglePetscOption("-eps_target_magnitude");
329  break;
330 
332  Moose::PetscSupport::setSinglePetscOption("-eps_target_real");
333  break;
334 
336  Moose::PetscSupport::setSinglePetscOption("-eps_target_imaginary");
337  break;
338 
341  break;
342 
344  break;
345 
346  default:
347  mooseError("Unknown type of WhichEigenPairs \n");
348  }
349 }
smallest magnitude
Definition: MooseTypes.h:289
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
target magnitude
Definition: MooseTypes.h:294
target imaginary
Definition: MooseTypes.h:296
Moose::WhichEigenPairs _which_eigen_pairs
Definition: SolverParams.h:32
smallest imaginary
Definition: MooseTypes.h:293
largest imaginary
Definition: MooseTypes.h:292
all eigenvalues
Definition: MooseTypes.h:297
use whatever we have in SLEPC
Definition: MooseTypes.h:298
largest magnitude
Definition: MooseTypes.h:288
void setSinglePetscOption(const std::string &name, const std::string &value="")
A wrapper function for dealing with different versions of PetscOptionsSetValue.
Definition: PetscSupport.C:812
void Moose::SlepcSupport::slepcSetOptions ( EigenProblem eigen_problem,
const InputParameters params 
)

Definition at line 438 of file SlepcSupport.C.

Referenced by Eigenvalue::execute().

439 {
441  setEigenSolverOptions(eigen_problem.solverParams(), params);
442  setEigenProblemOptions(eigen_problem.solverParams());
443  setWhichEigenPairsOptions(eigen_problem.solverParams());
444  setSlepcEigenSolverTolerances(eigen_problem, params);
445  setSlepcOutputOptions(eigen_problem);
447 }
void addPetscOptionsFromCommandline()
Definition: PetscSupport.C:217
SolverParams & solverParams()
Get the solver parameters.
void setEigenSolverOptions(SolverParams &solver_params, const InputParameters &params)
Definition: SlepcSupport.C:352
void setSlepcEigenSolverTolerances(EigenProblem &eigen_problem, const InputParameters &params)
Definition: SlepcSupport.C:125
void setWhichEigenPairsOptions(SolverParams &solver_params)
Definition: SlepcSupport.C:299
void setSlepcOutputOptions(EigenProblem &eigen_problem)
Definition: SlepcSupport.C:263
void petscSetOptions(FEProblemBase &problem)
A function for setting the PETSc options in PETSc from the options supplied to MOOSE.
Definition: PetscSupport.C:235
void setEigenProblemOptions(SolverParams &solver_params)
Definition: SlepcSupport.C:226
void Moose::SlepcSupport::storeSlepcEigenProblemOptions ( EigenProblem eigen_problem,
const InputParameters params 
)

Definition at line 176 of file SlepcSupport.C.

Referenced by Eigenvalue::Eigenvalue().

177 {
178  const std::string & eigen_problem_type = params.get<MooseEnum>("eigen_problem_type");
179  if (!eigen_problem_type.empty())
180  eigen_problem.solverParams()._eigen_problem_type =
181  Moose::stringToEnum<Moose::EigenProblemType>(eigen_problem_type);
182  else
183  mooseError("Have to specify a valid eigen problem type");
184 
185  const std::string & which_eigen_pairs = params.get<MooseEnum>("which_eigen_pairs");
186  if (!which_eigen_pairs.empty())
187  eigen_problem.solverParams()._which_eigen_pairs =
188  Moose::stringToEnum<Moose::WhichEigenPairs>(which_eigen_pairs);
189 
190  // Set necessary parametrs used in EigenSystem::solve(),
191  // i.e. the number of requested eigenpairs nev and the number
192  // of basis vectors ncv used in the solution algorithm. Note that
193  // ncv >= nev must hold and ncv >= 2*nev is recommended
194  unsigned int n_eigen_pairs = params.get<unsigned int>("n_eigen_pairs");
195  unsigned int n_basis_vectors = params.get<unsigned int>("n_basis_vectors");
196 
197  eigen_problem.setNEigenPairsRequired(n_eigen_pairs);
198 
199  eigen_problem.es().parameters.set<unsigned int>("eigenpairs") = n_eigen_pairs;
200 
201  // If the subspace dimension is too small, we increase it automatically
202  if (subspace_factor * n_eigen_pairs > n_basis_vectors)
203  {
204  n_basis_vectors = subspace_factor * n_eigen_pairs;
205  mooseWarning("Number of subspaces in Eigensolver is changed by moose because the value you set "
206  "is too small");
207  }
208 
209  eigen_problem.es().parameters.set<unsigned int>("basis vectors") = n_basis_vectors;
210 }
SolverParams & solverParams()
Get the solver parameters.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
virtual EquationSystems & es() override
virtual void setNEigenPairsRequired(unsigned int n_eigen_pairs)
Definition: EigenProblem.h:44
Moose::EigenProblemType _eigen_problem_type
Definition: SolverParams.h:31
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
Moose::WhichEigenPairs _which_eigen_pairs
Definition: SolverParams.h:32
const int subspace_factor
Definition: SlepcSupport.C:40
void mooseWarning(Args &&...args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:194
void Moose::SlepcSupport::storeSlepcOptions ( FEProblemBase fe_problem,
const InputParameters params 
)

Definition at line 213 of file SlepcSupport.C.

Referenced by Eigenvalue::Eigenvalue().

214 {
215  if (!(dynamic_cast<EigenProblem *>(&fe_problem)))
216  return;
217 
218  if (params.isParamValid("solve_type"))
219  {
220  fe_problem.solverParams()._eigen_solve_type =
221  Moose::stringToEnum<Moose::EigenSolveType>(params.get<MooseEnum>("solve_type"));
222  }
223 }
Moose::EigenSolveType _eigen_solve_type
Definition: SolverParams.h:30
SolverParams & solverParams()
Get the solver parameters.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37

Variable Documentation

const int Moose::SlepcSupport::subspace_factor = 2

Definition at line 40 of file SlepcSupport.C.