Anasazi Version of the Day
Loading...
Searching...
No Matches
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
48
49#include "AnasaziConfigDefs.hpp"
50
56#include "AnasaziRTRSolMgr.hpp"
60
61#include <algorithm>
62#include <string>
63
67
68
69namespace Anasazi {
70
71class Factory {
72public:
73
85 template<class ScalarType, class MV, class OP>
86 static
87 Teuchos::RCP<SolverManager<ScalarType,MV,OP> >
88 create ( const std::string& solverType,
89 const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > problem,
90 Teuchos::ParameterList &pl ) {
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 return Teuchos::null;
116 }
117
118 template<class MV, class OP>
119 static
120 Teuchos::RCP<SolverManager<double,MV,OP> >
121 create ( const std::string& solverType,
122 const Teuchos::RCP<Eigenproblem<double,MV,OP> > problem,
123 Teuchos::ParameterList &pl ) {
124 using Teuchos::rcp;
125 using ScalarType = double;
126
127 std::string type = solverType;
128 std::transform(type.begin(), type.end(), type.begin(), ::tolower);
129
130 if (type == "block_davidson" || type == "block davidson")
131 return rcp(new BlockDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
132
133 else if (type == "block_krylov_schur" || type == "block krylov schur")
134 return rcp(new BlockKrylovSchurSolMgr<ScalarType,MV,OP>(problem, pl));
135
136 else if (type == "generalized_davidson" || type == "generalized davidson")
137 return rcp(new GeneralizedDavidsonSolMgr<ScalarType,MV,OP>(problem, pl));
138
139 else if (type == "lobpcg")
140 return rcp(new LOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
141
142 else if (type == "rtr")
143 return rcp(new RTRSolMgr<ScalarType,MV,OP>(problem, pl));
144
145 else if (type == "simple_lobpcg" || type == "simple lobpcg")
146 return rcp(new SimpleLOBPCGSolMgr<ScalarType,MV,OP>(problem, pl));
147
148 else if (type == "TRACE_MIN" || type == "trace min")
149 return rcp(new Experimental::TraceMinSolMgr<ScalarType,MV,OP>(problem, pl));
150
151 else if (type == "trace_min_davidson" || type == "trace min davidson")
153
154 else
155 TEUCHOS_TEST_FOR_EXCEPTION( true, std::invalid_argument,
156 "Anasazi::Factory::create: Invalid solverType type \"" << solverType << "\".");
157
158 return Teuchos::null;
159 }
160
162 template<class ScalarType, class MV, class OP>
163 static
164 Teuchos::RCP<SolverManager<ScalarType,MV,OP> >
165 create ( const std::string& solverType,
166 const Teuchos::RCP<BasicEigenproblem<ScalarType,MV,OP> > &problem,
167 Teuchos::ParameterList &pl ) {
168 Teuchos::RCP<Eigenproblem<ScalarType,MV,OP>> eproblem =
169 Teuchos::rcp_static_cast<Eigenproblem<ScalarType,MV,OP>>(problem);
170 return create(solverType, eproblem, pl);
171 }
172};
173
174
175} // end Anasazi namespace
176
177#endif /* ANASAZI_FACTORY_HPP */
178
Basic implementation of the Anasazi::Eigenproblem class.
The Anasazi::BlockDavidsonSolMgr provides a solver manager for the BlockDavidson eigensolver.
The Anasazi::BlockKrylovSchurSolMgr class provides a user interface for the block Krylov-Schur eigens...
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
The Anasazi::GeneralizedDavidsonSolMgr provides a solver manager for the GeneralizedDavidson eigensol...
The Anasazi::LOBPCGSolMgr provides a powerful solver manager for the LOBPCG eigensolver.
The Anasazi::RTRSolMgr provides a simple solver manager over the IRTR eigensolvers.
The Anasazi::SimpleLOBPCGSolMgr provides a simple solver manager over the LOBPCG eigensolver.
The Anasazi::TraceMinDavidsonSolMgr provides a solver manager for the TraceMinDavidson eigensolver wi...
The Anasazi::TraceMinSolMgr provides a solver manager for the TraceMin eigensolver with a constant su...
This provides a basic implementation for defining standard or generalized eigenvalue problems.
The BlockDavidsonSolMgr provides a powerful solver manager over the BlockDavidson eigensolver.
The Anasazi::BlockKrylovSchurSolMgr provides a flexible solver manager over the BlockKrylovSchur eige...
This class defines the interface required by an eigensolver and status test class to compute solution...
The Anasazi::TraceMinDavidsonSolMgr provides a flexible solver manager over the TraceMinDavidson eige...
The Anasazi::TraceMinSolMgr provides a flexible solver manager over the TraceMin eigensolver.
This provides a factory to build Anasazi solvers using parameter lists.
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.
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.
Solver Manager for GeneralizedDavidson.
User interface for the LOBPCG eigensolver.
The Anasazi::RTRSolMgr provides a simple solver manager over the RTR eigensolver. For more informatio...
The Anasazi::SimpleLOBPCGSolMgr provides a simple solver manager over the LOBPCG eigensolver.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.