Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_StridedEpetraOperator.hpp
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 
10 #ifndef __Teko_StridedEpetraOperator_hpp__
11 #define __Teko_StridedEpetraOperator_hpp__
12 
13 // Epetra includes
14 #include "Epetra_Operator.h"
15 
16 // Teuchos includes
17 #include "Teuchos_RCP.hpp"
18 
19 #include "Thyra_LinearOpBase.hpp"
20 
21 // Teko includes
22 #include "Teko_BlockedReordering.hpp"
23 #include "Teko_EpetraOperatorWrapper.hpp"
24 #include "Teko_StridedMappingStrategy.hpp"
25 
26 namespace Teko {
27 namespace Epetra {
28 
29 class StridedEpetraOperator : public EpetraOperatorWrapper {
30  public:
31  enum eNormType { Inf, One, Frobenius };
32 
33  StridedEpetraOperator(int numVars, const Teuchos::RCP<const Epetra_Operator> &content,
34  const std::string &label = "<ANYM>");
35  StridedEpetraOperator(const std::vector<int> &vars,
36  const Teuchos::RCP<const Epetra_Operator> &content,
37  const std::string &label = "<ANYM>");
38 
39  virtual void SetContent(const std::vector<int> &vars,
40  const Teuchos::RCP<const Epetra_Operator> &content);
41 
42  virtual void RebuildOps() { BuildBlockedOperator(); }
43 
44  virtual const Teuchos::RCP<const Epetra_Operator> GetContent() const { return fullContent_; }
45 
46  // virtual const Teuchos::RCP<Epetra_Operator> GetContent()
47  // { return fullContent_; }
48 
49  const Teuchos::RCP<const Epetra_Operator> GetBlock(int i, int j) const;
50 
54  void Reorder(const BlockReorderManager &brm);
55 
57  void RemoveReording();
58 
61  virtual void WriteBlocks(const std::string &prefix) const;
62 
70  virtual std::string PrintNorm(const eNormType &nrmType = Frobenius, const char newline = '\n');
71 
72  // functions overloading Epetra_Operator
74 
75  // destructor
76  virtual ~StridedEpetraOperator() {}
77 
78  // attribute set methods
79 
80  // don't use transpose...ever!
81  virtual int SetUseTranspose(bool /* useTranspose */) { return -1; }
82 
83  virtual int ApplyInverse(const Epetra_MultiVector & /* X */, Epetra_MultiVector & /* Y */) const {
84  TEUCHOS_ASSERT(false);
85  return -1;
86  }
87 
88  virtual double NormInf() const {
89  TEUCHOS_ASSERT(false);
90  return 0.0;
91  }
92 
93  // attribute access functions
94  virtual bool UseTranspose() const { return false; }
95  virtual bool HasNormInf() const { return false; }
96  virtual const Epetra_Comm &Comm() const { return fullContent_->Comm(); }
97 
99  bool testAgainstFullOperator(int count, double tol) const;
100 
101  protected:
102  // gooey center of this shell
103  Teuchos::RCP<const Epetra_Operator> fullContent_;
104  Teuchos::RCP<StridedMappingStrategy> stridedMapping_;
105  Teuchos::RCP<Thyra::LinearOpBase<double> > stridedOperator_;
106  Teuchos::RCP<const BlockReorderManager> reorderManager_;
107 
108  std::string label_;
109 
110  void BuildBlockedOperator();
111 };
112 
113 } // end namespace Epetra
114 } // end namespace Teko
115 
116 #endif