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 //
4 // Anasazi: Block Eigensolvers Package
5 // Copyright 2004 Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef ANASAZI_FACTORY_HPP
43 #define ANASAZI_FACTORY_HPP
44 
49 #include "AnasaziConfigDefs.hpp"
50 
55 #include "AnasaziLOBPCGSolMgr.hpp"
56 #include "AnasaziRTRSolMgr.hpp"
60 
61 #include <algorithm>
62 #include <string>
63 
69 namespace Anasazi {
70 
71 class Factory {
72 public:
73 
85  template<class ScalarType, class MV, class OP>
86  static
88  create ( const std::string& solverType,
91  using Teuchos::rcp;
92 
93  std::string type = solverType;
94  std::transform(type.begin(), type.end(), type.begin(), ::tolower);
95 
96  if (type == "block_davidson" || type == "block davidson")
97  return rcp(new BlockDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
98 
99  else if (type == "block_krylov_schur" || type == "block krylov schur")
100  return rcp(new BlockKrylovSchurSolMgr<ScalarType,MV,OP>(problem, pl));
101 
102  else if (type == "lobpcg")
103  return rcp(new LOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
104 
105  else if (type == "rtr")
106  return rcp(new RTRSolMgr<ScalarType,MV,OP>(problem, pl));
107 
108  else if (type == "simple_lobpcg" || type == "simple lobpcg")
109  return rcp(new SimpleLOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
110 
111  else
112  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
113  "Anasazi::Factory::create: Invalid solver type \"" << solverType << "\".");
114  }
115 
116  template<class MV, class OP>
117  static
119  create ( const std::string& solverType,
121  Teuchos::ParameterList &pl ) {
122  using Teuchos::rcp;
123  using ScalarType = double;
124 
125  std::string type = solverType;
126  std::transform(type.begin(), type.end(), type.begin(), ::tolower);
127 
128  if (type == "block_davidson" || type == "block davidson")
129  return rcp(new BlockDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
130 
131  else if (type == "block_krylov_schur" || type == "block krylov schur")
132  return rcp(new BlockKrylovSchurSolMgr<ScalarType,MV,OP>(problem, pl));
133 
134  else if (type == "generalized_davidson" || type == "generalized davidson")
135  return rcp(new GeneralizedDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
136 
137  else if (type == "lobpcg")
138  return rcp(new LOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
139 
140  else if (type == "rtr")
141  return rcp(new RTRSolMgr<ScalarType,MV,OP>(problem, pl));
142 
143  else if (type == "simple_lobpcg" || type == "simple lobpcg")
144  return rcp(new SimpleLOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
145 
146  else if (type == "TRACE_MIN" || type == "trace min")
147  return rcp(new Experimental::TraceMinSolMgr<ScalarType,MV,OP>(problem, pl));
148 
149  else if (type == "trace_min_davidson" || type == "trace min davidson")
151 
152  else
153  TEUCHOS_TEST_FOR_EXCEPTION( true, std::invalid_argument,
154  "Anasazi::Factory::create: Invalid solverType type \"" << solverType << "\".");
155  }
156 
158  template<class ScalarType, class MV, class OP>
159  static
161  create ( const std::string& solverType,
163  Teuchos::ParameterList &pl ) {
165  Teuchos::rcp_static_cast<Eigenproblem<ScalarType,MV,OP>>(problem);
166  return create(solverType, eproblem, pl);
167  }
168 };
169 
170 
171 } // end Anasazi namespace
172 
173 #endif /* ANASAZI_FACTORY_HPP */
174 
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.