Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
Common.hpp
Go to the documentation of this file.
1 #ifndef COMMON_HPP
2 #define COMMON_HPP
3 
4 //
5 // Header file for classes common to all "packages" in this example.
6 //
7 
10 #include <iostream>
11 #include <sstream>
12 
13 // Namespace for classes common to all "packages" in this example.
14 namespace Common {
15 
16  // Stub of a MultiVector (MV) class, templated on Scalar type (the
17  // type of its entries).
18  template<class Scalar>
19  class MultiVector {};
20 
21  // Stub of an Operator (OP) class, templated on Scalar type (the
22  // template parameter of the MultiVector specialization that it
23  // uses).
24  template<class Scalar>
25  class Operator {
26  public:
28 
29  void apply (MV& /* Y */, const MV& /* X */) {
30  std::cout << "Operator<" << typeid (Scalar).name () << ">::apply" << std::endl;
31  }
32  };
33 
34  // Base classes of Trilinos::Details::LinearSolver must implement
35  // all the pure virtual methods of that interface. This base class
36  // only exists to make the example more concise. Its subclasses
37  // must implement solve(), name(), and the virtual destructor.
38  template<class MV, class OP, class NormType>
39  class LinearSolverTestBase : public Trilinos::Details::LinearSolver<MV, OP, NormType> {
40  protected:
41  virtual std::string name () const = 0;
42 
43  public:
44  virtual ~LinearSolverTestBase () {}
45 
47  std::cout << this->name () << "::setMatrix" << std::endl;
48  A_ = A;
49  }
50 
52  std::cout << this->name () << "::getMatrix" << std::endl;
53  return A_; // this could be null if setMatrix wasn't called
54  }
55 
57  std::cout << this->name () << "::setParameters" << std::endl;
58  }
59 
60  void symbolic () {
61  std::cout << this->name () << "::symbolic" << std::endl;
62  }
63 
64  void numeric () {
65  std::cout << this->name () << "::numeric" << std::endl;
66  }
67 
68  private:
69  Teuchos::RCP<const OP> A_; // the matrix given to setMatrix
70  };
71 
72 } // namespace Common
73 
74 #endif // COMMON_HPP
Common::LinearSolverTestBase::setMatrix
void setMatrix(const Teuchos::RCP< const OP > &A)
Set the solver's matrix.
Definition: Common.hpp:46
Common::LinearSolverTestBase::getMatrix
Teuchos::RCP< const OP > getMatrix() const
Get a pointer to this solver's matrix.
Definition: Common.hpp:51
Common::LinearSolverTestBase::setParameters
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &)
Set this solver's parameters.
Definition: Common.hpp:56
Common::MultiVector
Definition: Common.hpp:19
Common::Operator
Definition: Common.hpp:25
Common::LinearSolverTestBase::numeric
void numeric()
Set up any part of the solve that depends on both the structure and the numerical values of the input...
Definition: Common.hpp:64
Common::LinearSolverTestBase::~LinearSolverTestBase
virtual ~LinearSolverTestBase()
Definition: Common.hpp:44
Common::LinearSolverTestBase::symbolic
void symbolic()
Set up any part of the solve that depends on the structure of the input matrix, but not its numerical...
Definition: Common.hpp:60
Common::LinearSolverTestBase
Definition: Common.hpp:39
Teuchos::RCP< const OP >
Common::Operator::MV
MultiVector< Scalar > MV
Definition: Common.hpp:27
Common
Definition: Common.hpp:14
Trilinos::Details::LinearSolver
Interface for a method for solving linear system(s) AX=B.
Definition: Trilinos_Details_LinearSolver.hpp:146
Trilinos_Details_LinearSolver.hpp
Declaration of linear solver interface.
Common::Operator::apply
void apply(MV &, const MV &)
Definition: Common.hpp:29
A
Definition: PackageA.cpp:3
Common::LinearSolverTestBase::name
virtual std::string name() const =0
Trilinos_Details_LinearSolverFactory.hpp
Declaration and definition of linear solver factory, and "factory of factories".
Common::LinearSolverTestBase::A_
Teuchos::RCP< const OP > A_
Definition: Common.hpp:69