Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #ifdef MOOSE_MFEM_ENABLED 11 : 12 : #pragma once 13 : 14 : #include "MFEMEigensolverBase.h" 15 : 16 : /** 17 : * Class for the Hypre LOBPCG eigensolver 18 : */ 19 : class MFEMHypreLOBPCG : public Moose::MFEM::EigensolverBase 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : 24 : MFEMHypreLOBPCG(const InputParameters & parameters); 25 : 26 : /// Sets the mass matrix for the eigensolver 27 13 : virtual void SetMassMatrix(mfem::Operator & mass) override { _eigensolver->SetMassMatrix(mass); } 28 : 29 : /// Solves the eigenvalue problem 30 13 : virtual void Solve() override { _eigensolver->Solve(); } 31 : 32 : /// Retrieves the computed eigenvalues 33 26 : virtual void GetEigenvalues(mfem::Array<mfem::real_t> & eigenvalues) const override 34 : { 35 26 : _eigensolver->GetEigenvalues(eigenvalues); 36 26 : } 37 : 38 : /// Retrieves the computed eigenvector corresponding to the given index 39 78 : virtual const mfem::HypreParVector & GetEigenvector(int index) const override 40 : { 41 78 : return _eigensolver->GetEigenvector(index); 42 : } 43 : 44 : /// Override in derived classes to construct and set the solver options. 45 : virtual void ConstructSolver() override; 46 : 47 : protected: 48 : /// Sets the operator for the eigensolver and propagates it to the preconditioner. 49 13 : virtual void SetOperatorImpl(mfem::Operator & op) override 50 : { 51 13 : if (_preconditioner) 52 13 : _preconditioner->SetOperator(op); 53 13 : _eigensolver->SetOperator(op); 54 13 : } 55 : 56 : /// Eigensolver to be used for the problem 57 : std::unique_ptr<mfem::HypreLOBPCG> _eigensolver; 58 : }; 59 : 60 : #endif