Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_DiagnosticLinearOp.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teko: A package for block and physics based preconditioning
4 //
5 // Copyright 2010 NTESS and the Teko contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
16 #ifndef __Teko_DiagnosticLinearOp_hpp__
17 #define __Teko_DiagnosticLinearOp_hpp__
18 
19 #include <iostream>
20 
21 #include "Teko_Utilities.hpp"
22 #include "Teko_ImplicitLinearOp.hpp"
23 
24 #include "Teuchos_Time.hpp"
25 
26 namespace Teko {
27 
33  public:
38  DiagnosticLinearOp(const Teuchos::RCP<std::ostream> &ostrm, const ModifiableLinearOp &A,
39  const std::string &diagnosticString);
40 
45  DiagnosticLinearOp(const Teuchos::RCP<std::ostream> &ostrm, const LinearOp &A,
46  const std::string &diagnosticString);
47 
52  DiagnosticLinearOp(const Teuchos::RCP<std::ostream> &ostrm, const LinearOp &fwdOp,
53  const ModifiableLinearOp &A, const std::string &diagnosticString);
54 
57  virtual ~DiagnosticLinearOp();
58 
60 
61 
63  virtual VectorSpace range() const { return wrapOpA_lo_->range(); }
64 
66  virtual VectorSpace domain() const { return wrapOpA_lo_->domain(); }
67 
80  virtual void implicitApply(const MultiVector &x, MultiVector &y, const double alpha = 1.0,
81  const double beta = 0.0) const;
83 
84  virtual void describe(Teuchos::FancyOStream &out_arg,
85  const Teuchos::EVerbosityLevel verbLevel) const {
86  wrapOpA_lo_->describe(out_arg, verbLevel);
87  }
88 
89  int numApplications() const { return timer_.numCalls(); }
90  double totalTime() const { return timer_.totalElapsedTime(); }
91 
92  ModifiableLinearOp getModifiableOp() const { return wrapOpA_; }
93 
94  void setLinearOp(const LinearOp &lo) {
95  wrapOpA_lo_ = lo;
96  wrapOpA_ = Teuchos::null;
97  }
98 
99  LinearOp getLinearOp() const { return wrapOpA_lo_; }
100 
101  void setForwardOp(const Teko::LinearOp &lo) { fwdOp_ = lo; }
102 
103  /* Get the residual norm. Used purely for testing.
104  */
105  double getResidualNorm() const { return residualNorm_; }
106 
107  protected:
108  // fundamental operators to use
109  Teuchos::RCP<std::ostream> outputStream_;
110  ModifiableLinearOp wrapOpA_;
111  LinearOp wrapOpA_lo_;
112  LinearOp fwdOp_;
113  std::string diagString_;
114 
115  mutable double residualNorm_; // for testing purposes
116  mutable Teuchos::Time timer_;
117 
118  private:
119  // hide me!
121  DiagnosticLinearOp(const DiagnosticLinearOp &);
122 };
123 
137 inline ModifiableLinearOp createDiagnosticLinearOp(const Teuchos::RCP<std::ostream> &os,
138  const ModifiableLinearOp &A,
139  const std::string &label) {
140  return Teuchos::rcp(new DiagnosticLinearOp(os, A, label));
141 }
142 
156 inline ModifiableLinearOp createDiagnosticLinearOp(const Teuchos::RCP<std::ostream> &os,
157  const LinearOp &A, const std::string &label) {
158  return Teuchos::rcp(new DiagnosticLinearOp(os, A, label));
159 }
160 
175 inline ModifiableLinearOp createDiagnosticLinearOp(const Teuchos::RCP<std::ostream> &os,
176  const Teko::LinearOp &fwdOp,
177  const ModifiableLinearOp &A,
178  const std::string &label) {
179  return Teuchos::rcp(new DiagnosticLinearOp(os, fwdOp, A, label));
180 }
181 
182 } // end namespace Teko
183 
184 #endif
virtual void implicitApply(const MultiVector &x, MultiVector &y, const double alpha=1.0, const double beta=0.0) const
Perform a matrix vector multiply with this operator.
virtual VectorSpace domain() const
Domain space of this operator.
ModifiableLinearOp createDiagnosticLinearOp(const Teuchos::RCP< std::ostream > &os, const LinearOp &A, const std::string &label)
Constructor method for building DiagnosticLinearOp.
virtual ~DiagnosticLinearOp()
Destructor prints out timing information about this operator.
DiagnosticLinearOp(const Teuchos::RCP< std::ostream > &ostrm, const ModifiableLinearOp &A, const std::string &diagnosticString)
This constructor explicitly takes the linear operator that needs to be wrapped and a string for outpu...
A virtual class that simplifies the construction of custom operators.
ModifiableLinearOp createDiagnosticLinearOp(const Teuchos::RCP< std::ostream > &os, const ModifiableLinearOp &A, const std::string &label)
Constructor method for building DiagnosticLinearOp.
This linear operator prints diagnostics about operator application and creation times. It is useful for debugging problems and determining bottle necks.
virtual VectorSpace range() const
Range space of this operator.
ModifiableLinearOp createDiagnosticLinearOp(const Teuchos::RCP< std::ostream > &os, const Teko::LinearOp &fwdOp, const ModifiableLinearOp &A, const std::string &label)
Constructor method for building DiagnosticLinearOp.