Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
remainder
example
SolverFactory
PackageC.hpp
Go to the documentation of this file.
1
#ifndef PACKAGE_C_HPP
2
#define PACKAGE_C_HPP
3
4
//
5
// Header file for Package C.
6
//
7
8
#include "
Common.hpp
"
9
10
namespace
C
{
11
12
//
13
// This solver is independent of other solvers.
14
//
15
template
<
class
MV,
class
OP,
class
NormType>
16
class
Solver5
:
public
Common::LinearSolverTestBase
<MV, OP, NormType> {
17
protected
:
18
std::string
name
()
const
{
19
return
"Solver5"
;
20
}
21
22
public
:
23
virtual
~Solver5
() {}
24
25
void
solve
(MV&
/* X */
,
const
MV&
/* B */
) {
26
std::cout << this->
name
() <<
"::solve START"
<< std::endl;
27
std::cout << this->
name
() <<
"::solve END"
<< std::endl;
28
}
29
};
30
31
//
32
// This solver is independent of other solvers.
33
//
34
template
<
class
MV,
class
OP,
class
NormType>
35
class
Solver6
:
public
Common::LinearSolverTestBase
<MV, OP, NormType> {
36
protected
:
37
std::string
name
()
const
{
38
return
"Solver6"
;
39
}
40
41
public
:
42
virtual
~Solver6
() {}
43
44
void
solve
(MV&
/* X */
,
const
MV&
/* B */
) {
45
std::cout << this->
name
() <<
"::solve START"
<< std::endl;
46
std::cout << this->
name
() <<
"::solve END"
<< std::endl;
47
}
48
};
49
50
//
51
// Package C's solver factory.
52
//
53
template
<
class
MV,
class
OP,
class
NormType>
54
class
FactoryC
:
public
Trilinos::Details::LinearSolverFactory
<MV, OP, NormType> {
55
public
:
56
Teuchos::RCP<Trilinos::Details::LinearSolver<MV, OP, NormType>
>
57
getLinearSolver
(
const
std::string& solverName)
58
{
59
typedef
Trilinos::Details::LinearSolver<MV, OP, NormType>
solver_type;
60
61
if
(solverName ==
"5"
) {
62
return
Teuchos::RCP<solver_type>
(
new
Solver5<MV, OP, NormType>
());
63
}
64
else
if
(solverName ==
"6"
) {
65
return
Teuchos::RCP<solver_type>
(
new
Solver6<MV, OP, NormType>
());
66
}
67
else
{
68
std::ostringstream err;
69
err <<
"C::FactoryC::getLinearSolver: Invalid solver name \""
70
<< solverName <<
"\""
;
71
throw
std::invalid_argument (err.str ());
72
}
73
}
74
};
75
76
}
// namespace C
77
78
#endif // PACKAGE_C_HPP
C
Definition:
PackageC.cpp:3
C::Solver6::name
std::string name() const
Definition:
PackageC.hpp:37
C::Solver6::~Solver6
virtual ~Solver6()
Definition:
PackageC.hpp:42
C::Solver6::solve
void solve(MV &, const MV &)
Solve the linear system(s) AX=B.
Definition:
PackageC.hpp:44
C::FactoryC::getLinearSolver
Teuchos::RCP< Trilinos::Details::LinearSolver< MV, OP, NormType > > getLinearSolver(const std::string &solverName)
Get an instance of a solver from a particular package.
Definition:
PackageC.hpp:57
C::Solver5::~Solver5
virtual ~Solver5()
Definition:
PackageC.hpp:23
Common.hpp
Common::LinearSolverTestBase
Definition:
Common.hpp:39
C::Solver5::solve
void solve(MV &, const MV &)
Solve the linear system(s) AX=B.
Definition:
PackageC.hpp:25
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition:
Teuchos_RCPDecl.hpp:429
Trilinos::Details::LinearSolverFactory
Interface for a "factory" that creates solvers.
Definition:
Trilinos_Details_LinearSolverFactory.hpp:235
Trilinos::Details::LinearSolver
Interface for a method for solving linear system(s) AX=B.
Definition:
Trilinos_Details_LinearSolver.hpp:146
C::Solver5::name
std::string name() const
Definition:
PackageC.hpp:18
C::Solver6
Definition:
PackageC.hpp:35
C::FactoryC
Definition:
PackageC.hpp:54
C::Solver5
Definition:
PackageC.hpp:16
Generated by
1.8.16