Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Common.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 COMMON_HPP
11 #define COMMON_HPP
12 
13 //
14 // Header file for classes common to all "packages" in this example.
15 //
16 
19 #include <iostream>
20 #include <sstream>
21 
22 // Namespace for classes common to all "packages" in this example.
23 namespace Common {
24 
25  // Stub of a MultiVector (MV) class, templated on Scalar type (the
26  // type of its entries).
27  template<class Scalar>
28  class MultiVector {};
29 
30  // Stub of an Operator (OP) class, templated on Scalar type (the
31  // template parameter of the MultiVector specialization that it
32  // uses).
33  template<class Scalar>
34  class Operator {
35  public:
37 
38  void apply (MV& /* Y */, const MV& /* X */) {
39  std::cout << "Operator<" << typeid (Scalar).name () << ">::apply" << std::endl;
40  }
41  };
42 
43  // Base classes of Trilinos::Details::LinearSolver must implement
44  // all the pure virtual methods of that interface. This base class
45  // only exists to make the example more concise. Its subclasses
46  // must implement solve(), name(), and the virtual destructor.
47  template<class MV, class OP, class NormType>
48  class LinearSolverTestBase : public Trilinos::Details::LinearSolver<MV, OP, NormType> {
49  protected:
50  virtual std::string name () const = 0;
51 
52  public:
53  virtual ~LinearSolverTestBase () {}
54 
56  std::cout << this->name () << "::setMatrix" << std::endl;
57  A_ = A;
58  }
59 
61  std::cout << this->name () << "::getMatrix" << std::endl;
62  return A_; // this could be null if setMatrix wasn't called
63  }
64 
66  std::cout << this->name () << "::setParameters" << std::endl;
67  }
68 
69  void symbolic () {
70  std::cout << this->name () << "::symbolic" << std::endl;
71  }
72 
73  void numeric () {
74  std::cout << this->name () << "::numeric" << std::endl;
75  }
76 
77  private:
78  Teuchos::RCP<const OP> A_; // the matrix given to setMatrix
79  };
80 
81 } // namespace Common
82 
83 #endif // COMMON_HPP
virtual ~LinearSolverTestBase()
Definition: Common.hpp:53
Teuchos::RCP< const OP > getMatrix() const
Get a pointer to this solver&#39;s matrix.
Definition: Common.hpp:60
Interface for a method for solving linear system(s) AX=B.
Declaration and definition of linear solver factory, and &quot;factory of factories&quot;.
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:69
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:73
virtual std::string name() const =0
Teuchos::RCP< const OP > A_
Definition: Common.hpp:78
Declaration of linear solver interface.
MultiVector< Scalar > MV
Definition: Common.hpp:36
void apply(MV &, const MV &)
Definition: Common.hpp:38
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &)
Set this solver&#39;s parameters.
Definition: Common.hpp:65
void setMatrix(const Teuchos::RCP< const OP > &A)
Set the solver&#39;s matrix.
Definition: Common.hpp:55