https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Attributes | Private Attributes | List of all members
SlepcEigenSolverConfiguration Class Reference

#include <SlepcEigenSolverConfiguration.h>

Inheritance diagram for SlepcEigenSolverConfiguration:
[legend]

Public Member Functions

 SlepcEigenSolverConfiguration (EigenProblem &eigen_problem, libMesh::SlepcEigenSolver< libMesh::Number > &slepc_eigen_solver, const NonlinearEigenSystem &nl_eigen_sys)
 Constructur: get a reference to the SlepcEigenSolver variable to be able to manipulate it.
 
virtual void configure_solver () override
 
virtual void set_options_during_init ()
 
virtual void respond_to_solve_failure (unsigned int)
 

Static Public Member Functions

static std::string get_info ()
 
static void print_info (std::ostream &out_stream=libMesh::out)
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Public Attributes

std::map< std::string, Real > real_valued_data
 
std::map< std::string, int > int_valued_data
 
std::map< std::string, std::string > string_data
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 

Protected Member Functions

void increment_constructor_count (const std::string &name) noexcept
 
void increment_destructor_count (const std::string &name) noexcept
 

Static Protected Attributes

static Counts _counts
 
static Threads::atomic< unsigned int > _n_objects
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter
 

Private Attributes

EigenProblem & _eigen_problem
 
libMesh::SlepcEigenSolver< libMesh::Number > & _slepc_solver
 The slepc eigen solver object that we are configuring.
 
const NonlinearEigenSystem & _nl_eigen_sys
 The system that owns the SLEPc solver.
 

Detailed Description

Definition at line 26 of file SlepcEigenSolverConfiguration.h.

Constructor & Destructor Documentation

◆ SlepcEigenSolverConfiguration()

SlepcEigenSolverConfiguration::SlepcEigenSolverConfiguration ( EigenProblem &  eigen_problem,
libMesh::SlepcEigenSolver< libMesh::Number > &  slepc_eigen_solver,
const NonlinearEigenSystem &  nl_eigen_sys 
)

Constructur: get a reference to the SlepcEigenSolver variable to be able to manipulate it.

Constructor: get a reference to the SlepcEigenSolver variable to be able to manipulate it.

Definition at line 25 of file SlepcEigenSolverConfiguration.C.

30 _eigen_problem(eigen_problem),
31 _slepc_solver(slepc_eigen_solver),
32 _nl_eigen_sys(nl_eigen_sys)
33{
34}
libMesh::SlepcEigenSolver< libMesh::Number > & _slepc_solver
The slepc eigen solver object that we are configuring.
const NonlinearEigenSystem & _nl_eigen_sys
The system that owns the SLEPc solver.

Member Function Documentation

◆ configure_solver()

void SlepcEigenSolverConfiguration::configure_solver ( )
overridevirtual

Implements libMesh::SolverConfiguration.

Definition at line 37 of file SlepcEigenSolverConfiguration.C.

38{
40 {
41 // Set custom monitors for SNES and KSP
43 // Let us remove extra "eps_power" from SNES since users do not like it
44 LibmeshPetscCallA(_eigen_problem.comm().get(),
46 // Let us hook up a customize PC if users ask. Users still can use PETSc options to override
47 // this setting
49 LibmeshPetscCallA(_eigen_problem.comm().get(),
51 // Let set a default PC side. I would like to have the setting be consistent with
52 // what we do in regular nonlinear executioner. Petsc options are able to override
53 // this setting
54 LibmeshPetscCallA(
57 // A customized stopping test for nonlinear free power iterations.
58 // Nonlinear power iterations need to be marked as converged in EPS to
59 // retrieve solution from SLEPc EPS.
60 LibmeshPetscCallA(_eigen_problem.comm().get(),
61 EPSSetStoppingTestFunction(_slepc_solver.eps(),
64 NULL));
65
66 // Remove all SLEPc monitors.
67 LibmeshPetscCallA(_eigen_problem.comm().get(), EPSMonitorCancel(_slepc_solver.eps()));
68 // A customized EPS monitor in moose. We need to print only eigenvalue
69 LibmeshPetscCallA(
71 EPSMonitorSet(
73 }
74
75 // The default BV type (BVMAT) stores the basis in a single dense matrix and does not support
76 // Kokkos vectors, so store the basis as individual vectors instead unless the user chose a type
77 const auto comm = _eigen_problem.comm().get();
78 EPS eps = _slepc_solver.eps();
79 const char * prefix = nullptr;
80 LibmeshPetscCallA(comm, EPSGetOptionsPrefix(eps, &prefix));
81 PetscBool bv_type_set = PETSC_FALSE;
82 LibmeshPetscCallA(comm, PetscOptionsHasName(nullptr, prefix, "-bv_type", &bv_type_set));
83 if (!bv_type_set)
84 {
85 const auto & solution =
86 cast_ref<const libMesh::PetscVector<libMesh::Number> &>(_nl_eigen_sys.solution());
87 PetscBool is_kokkos = PETSC_FALSE;
88 LibmeshPetscCallA(comm,
89 PetscObjectTypeCompareAny(
90 (PetscObject)solution.vec(), &is_kokkos, VECSEQKOKKOS, VECMPIKOKKOS, ""));
91 if (is_kokkos)
92 {
93 BV bv;
94 LibmeshPetscCallA(comm, EPSGetBV(eps, &bv));
95 LibmeshPetscCallA(comm, BVSetType(bv, BVVECS));
96 }
97 }
98}
bool isNonlinearEigenvalueSolver(unsigned int eigen_sys_num) const
virtual void initPetscOutputAndSomeSolverSettings() override
Hook up monitors for SNES and KSP.
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.
bool _customized_pc_for_eigen
unsigned int number() const
Gets the number of this system.
NumericVector< Number > & solution()
Definition SystemBase.h:215
const Parallel::Communicator & comm() const
PetscErrorCode mooseSlepcEPSSNESKSPSetPCSide(FEProblemBase &problem, EPS eps)
Allow users to specify PC side.
PetscErrorCode mooseSlepcEPSSNESSetCustomizePC(EPS eps)
Attach a customized PC.
PetscErrorCode mooseSlepcEPSSNESSetUpOptionPrefix(EPS eps)
Get rid of prefix "-eps_power" for SNES, KSP, PC, etc.
PetscErrorCode mooseSlepcEPSMonitor(EPS eps, PetscInt its, PetscInt nconv, PetscScalar *eigr, PetscScalar *eigi, PetscReal *errest, PetscInt nest, void *mctx)
A customized solver monitor to print out eigenvalue.
PetscErrorCode mooseSlepcStoppingTest(EPS eps, PetscInt its, PetscInt max_it, PetscInt nconv, PetscInt nev, EPSConvergedReason *reason, void *ctx)
A customized convergence checker.
int eps(unsigned int i, unsigned int j)
2D version

Member Data Documentation

◆ _eigen_problem

EigenProblem& SlepcEigenSolverConfiguration::_eigen_problem
private

Definition at line 39 of file SlepcEigenSolverConfiguration.h.

Referenced by configure_solver().

◆ _nl_eigen_sys

const NonlinearEigenSystem& SlepcEigenSolverConfiguration::_nl_eigen_sys
private

The system that owns the SLEPc solver.

Definition at line 47 of file SlepcEigenSolverConfiguration.h.

Referenced by configure_solver().

◆ _slepc_solver

libMesh::SlepcEigenSolver<libMesh::Number>& SlepcEigenSolverConfiguration::_slepc_solver
private

The slepc eigen solver object that we are configuring.

Definition at line 44 of file SlepcEigenSolverConfiguration.h.

Referenced by configure_solver().


The documentation for this class was generated from the following files: