Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PackageC.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef PACKAGE_C_HPP
11 #define PACKAGE_C_HPP
12 
13 //
14 // Header file for Package C.
15 //
16 
17 #include "Common.hpp"
18 
19 namespace C {
20 
21  //
22  // This solver is independent of other solvers.
23  //
24  template<class MV, class OP, class NormType>
25  class Solver5 : public Common::LinearSolverTestBase<MV, OP, NormType> {
26  protected:
27  std::string name () const {
28  return "Solver5";
29  }
30 
31  public:
32  virtual ~Solver5 () {}
33 
34  void solve (MV& /* X */, const MV& /* B */ ) {
35  std::cout << this->name () << "::solve START" << std::endl;
36  std::cout << this->name () << "::solve END" << std::endl;
37  }
38  };
39 
40  //
41  // This solver is independent of other solvers.
42  //
43  template<class MV, class OP, class NormType>
44  class Solver6 : public Common::LinearSolverTestBase<MV, OP, NormType> {
45  protected:
46  std::string name () const {
47  return "Solver6";
48  }
49 
50  public:
51  virtual ~Solver6 () {}
52 
53  void solve (MV& /* X */, const MV& /* B */ ) {
54  std::cout << this->name () << "::solve START" << std::endl;
55  std::cout << this->name () << "::solve END" << std::endl;
56  }
57  };
58 
59  //
60  // Package C's solver factory.
61  //
62  template<class MV, class OP, class NormType>
63  class FactoryC : public Trilinos::Details::LinearSolverFactory<MV, OP, NormType> {
64  public:
66  getLinearSolver (const std::string& solverName)
67  {
69 
70  if (solverName == "5") {
72  }
73  else if (solverName == "6") {
75  }
76  else {
77  std::ostringstream err;
78  err << "C::FactoryC::getLinearSolver: Invalid solver name \""
79  << solverName << "\"";
80  throw std::invalid_argument (err.str ());
81  }
82  }
83  };
84 
85 } // namespace C
86 
87 #endif // PACKAGE_C_HPP
std::string name() const
Definition: PackageC.hpp:27
void solve(MV &, const MV &)
Solve the linear system(s) AX=B.
Definition: PackageC.hpp:34
Interface for a method for solving linear system(s) AX=B.
virtual ~Solver6()
Definition: PackageC.hpp:51
void solve(MV &, const MV &)
Solve the linear system(s) AX=B.
Definition: PackageC.hpp:53
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:66
virtual ~Solver5()
Definition: PackageC.hpp:32
std::string name() const
Definition: PackageC.hpp:46
Interface for a &quot;factory&quot; that creates solvers.
Smart reference counting pointer class for automatic garbage collection.