|
Anasazi
Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Anasazi: Block Eigensolvers Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef ANASAZI_TRACEMIN_SOLMGR_HPP 00030 #define ANASAZI_TRACEMIN_SOLMGR_HPP 00031 00038 #include "AnasaziConfigDefs.hpp" 00039 #include "AnasaziTypes.hpp" 00040 00041 #include "AnasaziEigenproblem.hpp" 00042 #include "AnasaziSolverUtils.hpp" 00043 00044 #include "AnasaziTraceMin.hpp" 00045 #include "AnasaziTraceMinBaseSolMgr.hpp" 00046 #include "AnasaziBasicSort.hpp" 00047 #include "AnasaziStatusTestResNorm.hpp" 00048 #include "AnasaziStatusTestWithOrdering.hpp" 00049 #include "AnasaziStatusTestCombo.hpp" 00050 #include "AnasaziStatusTestOutput.hpp" 00051 #include "AnasaziBasicOutputManager.hpp" 00052 #include "Teuchos_BLAS.hpp" 00053 #include "Teuchos_LAPACK.hpp" 00054 #include "Teuchos_TimeMonitor.hpp" 00055 #ifdef TEUCHOS_DEBUG 00056 # include <Teuchos_FancyOStream.hpp> 00057 #endif 00058 #ifdef HAVE_MPI 00059 #include <mpi.h> 00060 #endif 00061 00062 00063 namespace Anasazi { 00064 namespace Experimental { 00065 00066 template<class ScalarType, class MV, class OP> 00067 00100 class TraceMinSolMgr : public TraceMinBaseSolMgr<ScalarType,MV,OP> { 00101 00102 private: 00103 typedef MultiVecTraits<ScalarType,MV> MVT; 00104 typedef MultiVecTraitsExt<ScalarType,MV> MVText; 00105 typedef OperatorTraits<ScalarType,MV,OP> OPT; 00106 typedef Teuchos::ScalarTraits<ScalarType> SCT; 00107 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType; 00108 typedef Teuchos::ScalarTraits<MagnitudeType> MT; 00109 00110 public: 00111 00113 00114 00125 TraceMinSolMgr( const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > &problem, 00126 Teuchos::ParameterList &pl ); 00128 00129 private: 00130 00131 int maxits_; 00132 00133 // Test whether we have exceeded the maximum number of iterations 00134 bool exceededMaxIter() { return (this->iter_ >= maxits_); }; 00135 00136 // TraceMin does not restart, so this will always return false 00137 bool needToRestart(const Teuchos::RCP< TraceMinBase<ScalarType,MV,OP> > solver) { return false; }; 00138 00139 // TraceMin does not restart, so this will throw an exception 00140 bool performRestart(int &numRestarts, Teuchos::RCP< TraceMinBase<ScalarType,MV,OP> > solver) 00141 { TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Anasazi::TraceMinSolMgr::performRestart(): TraceMin does not perform restarts!"); }; 00142 00143 // Returns a new TraceMin solver object 00144 Teuchos::RCP< TraceMinBase<ScalarType,MV,OP> > createSolver( 00145 const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter, 00146 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &outputtest, 00147 const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho, 00148 Teuchos::ParameterList &plist 00149 ); 00150 }; 00151 00152 00154 // Constructor - accepts maximum iterations in addition to the other parameters of the abstract base class 00155 template<class ScalarType, class MV, class OP> 00156 TraceMinSolMgr<ScalarType,MV,OP>::TraceMinSolMgr( const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > &problem, Teuchos::ParameterList &pl ) : 00157 TraceMinBaseSolMgr<ScalarType,MV,OP>(problem,pl) 00158 { 00159 // Get the maximum number of iterations 00160 maxits_ = pl.get("Maximum Iterations", 100); 00161 TEUCHOS_TEST_FOR_EXCEPTION(maxits_ < 1, std::invalid_argument, "Anasazi::TraceMinSolMgr::constructor(): \"Maximum Iterations\" must be strictly positive."); 00162 00163 // block size: default is 2* nev() 00164 // TODO: Find out minimum value 00165 this->blockSize_ = pl.get("Block Size",2*this->problem_->getNEV()); 00166 TEUCHOS_TEST_FOR_EXCEPTION(this->blockSize_ < this->problem_->getNEV(), std::invalid_argument, 00167 "Anasazi::TraceMinSolMgr::constructor(): \"Block Size\" must be greater than or equal to the number of desired eigenpairs."); 00168 00169 // TraceMin does not restart, so the number of blocks and number of restart blocks will always be 1 00170 this->numBlocks_ = 1; 00171 this->numRestartBlocks_ = 1; 00172 00173 TEUCHOS_TEST_FOR_EXCEPTION(static_cast<ptrdiff_t>(this->numBlocks_)*this->blockSize_ + this->maxLocked_ > MVText::GetGlobalLength(*this->problem_->getInitVec()), 00174 std::invalid_argument, 00175 "Anasazi::TraceMinSolMgr::constructor(): Potentially impossible orthogonality requests. Reduce basis size or locking size."); 00176 00177 TEUCHOS_TEST_FOR_EXCEPTION(this->maxLocked_ + this->blockSize_ < this->problem_->getNEV(), std::invalid_argument, 00178 "Anasazi::TraceMinDavidsonSolMgr: Not enough storage space for requested number of eigenpairs."); 00179 } 00180 00181 00183 // Returns a new TraceMin solver object 00184 template <class ScalarType, class MV, class OP> 00185 Teuchos::RCP< TraceMinBase<ScalarType,MV,OP> > TraceMinSolMgr<ScalarType,MV,OP>::createSolver( 00186 const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter, 00187 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &outputtest, 00188 const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho, 00189 Teuchos::ParameterList &plist 00190 ) 00191 { 00192 return Teuchos::rcp( new TraceMin<ScalarType,MV,OP>(this->problem_,sorter,this->printer_,outputtest,ortho,plist) ); 00193 } 00194 00195 00196 }} // end Anasazi namespace 00197 00198 #endif /* ANASAZI_TRACEMIN_SOLMGR_HPP */
1.7.6.1