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
49#include "AnasaziConfigDefs.hpp"
50
56#include "AnasaziRTRSolMgr.hpp"
60
61#include <algorithm>
62#include <string>
63
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
116 template<class MV, class OP>
117 static
118 Teuchos::RCP<SolverManager<double,MV,OP> >
119 create ( const std::string& solverType,
120 const Teuchos::RCP<Eigenproblem<double,MV,OP> > problem,
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
160 Teuchos::RCP<SolverManager<ScalarType,MV,OP> >
161 create ( const std::string& solverType,
162 const Teuchos::RCP<BasicEigenproblem<ScalarType,MV,OP> > &problem,
163 Teuchos::ParameterList &pl ) {
164 Teuchos::RCP<Eigenproblem<ScalarType,MV,OP>> eproblem =
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
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.