11#ifndef ANASAZI_SIMPLE_LOBPCG_SOLMGR_HPP
12#define ANASAZI_SIMPLE_LOBPCG_SOLMGR_HPP
36#include "Teuchos_TimeMonitor.hpp"
37#include "Teuchos_FancyOStream.hpp"
72template<
class ScalarType,
class MV,
class OP>
77 typedef Teuchos::ScalarTraits<ScalarType> SCT;
78 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
79 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
100 Teuchos::ParameterList &
pl );
134 Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > problem_;
135 Teuchos::RCP<Teuchos::FancyOStream> osp_;
147template<
class ScalarType,
class MV,
class OP>
150 Teuchos::ParameterList &
pl ) :
163 TEUCHOS_TEST_FOR_EXCEPTION(problem_->getInitVec() == Teuchos::null,std::invalid_argument,
"Problem does not contain initial vectors to clone from.");
165 whch_ =
pl.get(
"Which",
"SR");
168 "SimpleLOBPCGSolMgr: \"Which\" parameter must be SM, LM, SR or LR.");
170 tol_ =
pl.get(
"Convergence Tolerance",tol_);
173 "SimpleLOBPCGSolMgr: \"Tolerance\" parameter must be strictly postiive.");
177 osProc_ =
pl.get(
"Output Processor", osProc_);
180 if (
pl.isParameter(
"Output Stream")) {
181 osp_ = Teuchos::getParameter<Teuchos::RCP<Teuchos::FancyOStream> >(
pl,
"Output Stream");
188 if (
pl.isParameter(
"Verbosity")) {
189 if (Teuchos::isParameterType<int>(
pl,
"Verbosity")) {
190 verb_ =
pl.get(
"Verbosity", verb_);
192 verb_ = (
int)Teuchos::getParameter<Anasazi::MsgType>(
pl,
"Verbosity");
197 blockSize_=
pl.get(
"Block Size",problem_->getNEV());
200 "SimpleLOBPCGSolMgr: \"Block Size\" parameter must be strictly positive.");
202 maxIters_ =
pl.get(
"Maximum Iterations",maxIters_);
208template<
class ScalarType,
class MV,
class OP>
217 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> >
max;
224 Teuchos::RCP<StatusTestResNorm<ScalarType,MV,OP> > norm
226 Teuchos::Array< Teuchos::RCP<StatusTest<ScalarType,MV,OP> > >
alltests;
229 Teuchos::RCP<StatusTestCombo<ScalarType,MV,OP> >
combo
234 Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> >
outputtest
237 Teuchos::RCP<SVQBOrthoManager<ScalarType,MV,OP> >
ortho
240 Teuchos::ParameterList
plist;
241 plist.set(
"Block Size",blockSize_);
242 plist.set(
"Full Ortho",
true);
248 if (problem_->getAuxVecs() != Teuchos::null) {
249 lobpcg_solver->setAuxVecs( Teuchos::tuple<Teuchos::RCP<const MV> >(problem_->getAuxVecs()) );
253 int nev = problem_->getNEV();
254 Teuchos::Array< Teuchos::RCP<MV> >
foundvecs;
255 Teuchos::Array< Teuchos::RCP< std::vector<MagnitudeType> > >
foundvals;
266 catch (
const std::exception &
e) {
271 problem_->setSolution(
sol);
276 if (norm->getStatus() ==
Passed) {
278 int num = norm->howMany();
282 "Anasazi::SimpleLOBPCGSolMgr::solve(): logic error.");
283 std::vector<int>
ind = norm->whichVecs();
301 Teuchos::RCP<std::vector<MagnitudeType> >
newvals = Teuchos::rcp(
new std::vector<MagnitudeType>(
num) );
303 for (
int i=0;
i<
num;
i++) {
304 (*newvals)[
i] =
all[
ind[
i]].realpart;
310 else if (
max != Teuchos::null &&
max->getStatus() ==
Passed) {
312 int num = norm->howMany();
313 std::vector<int>
ind = norm->whichVecs();
323 Teuchos::RCP<std::vector<MagnitudeType> >
newvals = Teuchos::rcp(
new std::vector<MagnitudeType>(
num) );
325 for (
int i=0;
i<
num;
i++) {
326 (*newvals)[
i] =
all[
ind[
i]].realpart;
335 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"Anasazi::SimpleLOBPCGSolMgr::solve(): solver returned without satisfy status test.");
346 sol.Evecs = MVT::Clone(*problem_->getInitVec(),
numfound);
349 sol.Evecs = Teuchos::null;
375 std::vector<int>
order(
sol.numVecs);
378 for (
int i=0;
i<
sol.numVecs;
i++) {
380 sol.Evals[
i].imagpart = MT::zero();
391#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
398 problem_->setSolution(
sol);
399 printer->stream(
Debug) <<
"Returning " <<
sol.numVecs <<
" eigenpairs to eigenproblem." << std::endl;
Basic implementation of the Anasazi::SortManager class.
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
Abstract base class which defines the interface required by an eigensolver and status test class to c...
Implementation of the locally-optimal block preconditioned conjugate gradient (LOBPCG) method.
Abstract class definition for Anasazi Output Managers.
Abstract class definition for Anasazi output stream.
Orthogonalization manager based on the SVQB technique described in "A Block Orthogonalization Procedu...
Pure virtual base class which describes the basic interface for a solver manager.
Class which provides internal utilities for the Anasazi solvers.
Status test for forming logical combinations of other status tests.
Status test for testing the number of iterations.
Special StatusTest for printing status tests.
A status test for testing the norm of the eigenvectors residuals.
Types and exceptions used within Anasazi solvers and interfaces.
An exception class parent to all Anasazi exceptions.
Anasazi's templated virtual class for constructing an operator that can interface with the OperatorTr...
Operator()
Default constructor.
The Anasazi::SimpleLOBPCGSolMgr provides a simple solver manager over the LOBPCG eigensolver.
ReturnType solve()
This method performs possibly repeated calls to the underlying eigensolver's iterate() routine until ...
const Eigenproblem< ScalarType, MV, OP > & getProblem() const
Return the eigenvalue problem.
SimpleLOBPCGSolMgr(const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > &problem, Teuchos::ParameterList &pl)
Basic constructor for SimpleLOBPCGSolMgr.
virtual ~SimpleLOBPCGSolMgr()
Destructor.
int getNumIters() const
Get the iteration count for the most recent call to solve().
The Anasazi::SolverManager is a templated virtual base class that defines the basic interface that an...
Status test for forming logical combinations of other status tests.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
ReturnType
Enumerated type used to pass back information from a solver manager.
Output managers remove the need for the eigensolver to know any information about the required output...