Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AnasaziFactory.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Anasazi: Block Eigensolvers Package
4 //
5 // Copyright 2004 NTESS and the Anasazi contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ANASAZI_FACTORY_HPP
11 #define ANASAZI_FACTORY_HPP
12 
17 #include "AnasaziConfigDefs.hpp"
18 
23 #include "AnasaziLOBPCGSolMgr.hpp"
24 #include "AnasaziRTRSolMgr.hpp"
28 
29 #include <algorithm>
30 #include <string>
31 
37 namespace Anasazi {
38 
39 class Factory {
40 public:
41 
53  template<class ScalarType, class MV, class OP>
54  static
56  create ( const std::string& solverType,
59  using Teuchos::rcp;
60 
61  std::string type = solverType;
62  std::transform(type.begin(), type.end(), type.begin(), ::tolower);
63 
64  if (type == "block_davidson" || type == "block davidson")
65  return rcp(new BlockDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
66 
67  else if (type == "block_krylov_schur" || type == "block krylov schur")
68  return rcp(new BlockKrylovSchurSolMgr<ScalarType,MV,OP>(problem, pl));
69 
70  else if (type == "lobpcg")
71  return rcp(new LOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
72 
73  else if (type == "rtr")
74  return rcp(new RTRSolMgr<ScalarType,MV,OP>(problem, pl));
75 
76  else if (type == "simple_lobpcg" || type == "simple lobpcg")
77  return rcp(new SimpleLOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
78 
79  else
80  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
81  "Anasazi::Factory::create: Invalid solver type \"" << solverType << "\".");
82 
83  return Teuchos::null;
84  }
85 
86  template<class MV, class OP>
87  static
89  create ( const std::string& solverType,
92  using Teuchos::rcp;
93  using ScalarType = double;
94 
95  std::string type = solverType;
96  std::transform(type.begin(), type.end(), type.begin(), ::tolower);
97 
98  if (type == "block_davidson" || type == "block davidson")
99  return rcp(new BlockDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
100 
101  else if (type == "block_krylov_schur" || type == "block krylov schur")
102  return rcp(new BlockKrylovSchurSolMgr<ScalarType,MV,OP>(problem, pl));
103 
104  else if (type == "generalized_davidson" || type == "generalized davidson")
105  return rcp(new GeneralizedDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
106 
107  else if (type == "lobpcg")
108  return rcp(new LOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
109 
110  else if (type == "rtr")
111  return rcp(new RTRSolMgr<ScalarType,MV,OP>(problem, pl));
112 
113  else if (type == "simple_lobpcg" || type == "simple lobpcg")
114  return rcp(new SimpleLOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
115 
116  else if (type == "TRACE_MIN" || type == "trace min")
117  return rcp(new Experimental::TraceMinSolMgr<ScalarType,MV,OP>(problem, pl));
118 
119  else if (type == "trace_min_davidson" || type == "trace min davidson")
121 
122  else
123  TEUCHOS_TEST_FOR_EXCEPTION( true, std::invalid_argument,
124  "Anasazi::Factory::create: Invalid solverType type \"" << solverType << "\".");
125 
126  return Teuchos::null;
127  }
128 
130  template<class ScalarType, class MV, class OP>
131  static
133  create ( const std::string& solverType,
135  Teuchos::ParameterList &pl ) {
137  Teuchos::rcp_static_cast<Eigenproblem<ScalarType,MV,OP>>(problem);
138  return create(solverType, eproblem, pl);
139  }
140 };
141 
142 
143 } // end Anasazi namespace
144 
145 #endif /* ANASAZI_FACTORY_HPP */
146 
This class defines the interface required by an eigensolver and status test class to compute solution...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static Teuchos::RCP< SolverManager< ScalarType, MV, OP > > create(const std::string &solverType, const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > problem, Teuchos::ParameterList &pl)
Create an instance of Anasazi::SolverManager given the string name of the solver type.
The Anasazi::RTRSolMgr provides a simple solver manager over the RTR eigensolver. For more informatio...
The Anasazi::TraceMinSolMgr provides a solver manager for the TraceMin eigensolver with a constant su...
The Anasazi::LOBPCGSolMgr provides a powerful solver manager for the LOBPCG eigensolver.
The Anasazi::BlockKrylovSchurSolMgr provides a flexible solver manager over the BlockKrylovSchur eige...
The Anasazi::BlockDavidsonSolMgr provides a solver manager for the BlockDavidson eigensolver.
Basic implementation of the Anasazi::Eigenproblem class.
The Anasazi::GeneralizedDavidsonSolMgr provides a solver manager for the GeneralizedDavidson eigensol...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
The Anasazi::SimpleLOBPCGSolMgr provides a simple solver manager over the LOBPCG eigensolver.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
The Anasazi::TraceMinSolMgr provides a flexible solver manager over the TraceMin eigensolver.
The Anasazi::SimpleLOBPCGSolMgr provides a simple solver manager over the LOBPCG eigensolver.
The Anasazi::TraceMinDavidsonSolMgr provides a flexible solver manager over the TraceMinDavidson eige...
The Anasazi::TraceMinDavidsonSolMgr provides a solver manager for the TraceMinDavidson eigensolver wi...
This provides a basic implementation for defining standard or generalized eigenvalue problems...
static Teuchos::RCP< SolverManager< ScalarType, MV, OP > > create(const std::string &solverType, const Teuchos::RCP< BasicEigenproblem< ScalarType, MV, OP > > &problem, Teuchos::ParameterList &pl)
Specialize create for BasicEigenproblem type.
The Anasazi::RTRSolMgr provides a simple solver manager over the IRTR eigensolvers.
The BlockDavidsonSolMgr provides a powerful solver manager over the BlockDavidson eigensolver...
The Anasazi::BlockKrylovSchurSolMgr class provides a user interface for the block Krylov-Schur eigens...
Solver Manager for GeneralizedDavidson.
This provides a factory to build Anasazi solvers using parameter lists.
User interface for the LOBPCG eigensolver.