Xpetra_TpetraOperator.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_TPETRAOPERATOR_HPP
47 #define XPETRA_TPETRAOPERATOR_HPP
48 
50 
51 #include <Tpetra_Operator.hpp>
52 
53 #include "Xpetra_Map.hpp"
54 #include "Xpetra_TpetraMap.hpp"
55 #include "Xpetra_MultiVector.hpp"
56 #include "Xpetra_TpetraMultiVector.hpp"
57 #include "Xpetra_Operator.hpp"
58 
59 #include "Xpetra_Utils.hpp"
60 
61 namespace Xpetra {
62 
63  template <class Scalar,
64  class LocalOrdinal,
65  class GlobalOrdinal,
67  class TpetraOperator : public Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > {
68  public:
70 
73  XPETRA_MONITOR("TpetraOperator::getDomainMap()");
74  return toXpetra(op_->getDomainMap());
75  }
76 
79  XPETRA_MONITOR("TpetraOperator::getRangeMap()");
80  return toXpetra(op_->getRangeMap());
81  }
82 
84 
89  virtual void
93  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
94  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const {
95  op_->apply(toTpetra(X), toTpetra(Y), mode, alpha, beta);
96  }
97 
99  virtual bool hasTransposeApply() const {
100  return op_->hasTransposeApply();
101  }
102 
104 
106 
107 
109  std::string description() const { XPETRA_MONITOR("TpetraOperator::description"); return op_->description(); }
110 
113  XPETRA_MONITOR("TpetraOperator::describe"); op_->describe(out, verbLevel);
114  }
115 
117 
119 
120 
122  TpetraOperator(const Teuchos::RCP<Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node> > &op) : op_(op) { } //TODO removed const
123 
126 
128 
129  private:
132 
133  }; // TpetraOperator class
134 
135 
136 
137 #if ((!defined(HAVE_TPETRA_INST_SERIAL)) && (!defined(HAVE_TPETRA_INST_INT_INT)) && defined(HAVE_XPETRA_EPETRA))
138  // specialization for Tpetra Map on EpetraNode and GO=int
139  template <>
140  class TpetraOperator<double, int, int, EpetraNode>
141  : public Operator< double, int, int, EpetraNode > {
142  public:
143  typedef double Scalar;
144  typedef int GlobalOrdinal;
145  typedef int LocalOrdinal;
146  typedef EpetraNode Node;
147 
149 
152  return Teuchos::null;
153  }
154 
157  return Teuchos::null;
158  }
159 
161 
166  virtual void
171  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const { }
172 
174  virtual bool hasTransposeApply() const { return false; }
175 
177 
179 
180 
182  std::string description() const { return std::string(""); }
183 
186 
188 
190 
191 
193  TpetraOperator(const Teuchos::RCP<Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node> > &op) { }
194 
197 
198 
200 
201  }; // TpetraOperator class
202 #endif
203 
204 
205 #if ((!defined(HAVE_TPETRA_INST_SERIAL)) && (!defined(HAVE_TPETRA_INST_INT_LONG_LONG)) && defined(HAVE_XPETRA_EPETRA))
206  // specialization for Tpetra Map on EpetraNode and GO=int
207  template <>
208  class TpetraOperator<double, int, long long, EpetraNode>
209  : public Operator< double, int, long long, EpetraNode > {
210  public:
211  typedef double Scalar;
212  typedef long long GlobalOrdinal;
213  typedef int LocalOrdinal;
214  typedef EpetraNode Node;
215 
217 
220  return Teuchos::null;
221  }
222 
225  return Teuchos::null;
226  }
227 
229 
234  virtual void
239  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const { }
240 
242  virtual bool hasTransposeApply() const { return false; }
243 
245 
247 
248 
250  std::string description() const { return std::string(""); }
251 
254 
256 
258 
259 
261  TpetraOperator(const Teuchos::RCP<Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node> > &op) { }
262 
266 
267  }; // TpetraOperator class
268 #endif
269 
270 
271 } // Xpetra namespace
272 
273 #define XPETRA_TPETRAOPERATOR_SHORT
274 #endif // XPETRA_TPETRAOPERATOR_HPP
Xpetra::TpetraOperator
Definition: Xpetra_TpetraOperator.hpp:67
Xpetra_MultiVector.hpp
Kokkos::Compat::KokkosSerialWrapperNode
Definition: Kokkos_SerialNode.hpp:57
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::Node
EpetraNode Node
Definition: Xpetra_TpetraOperator.hpp:214
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::hasTransposeApply
virtual bool hasTransposeApply() const
Whether this operator supports applying the transpose or conjugate transpose.
Definition: Xpetra_TpetraOperator.hpp:242
Xpetra
Xpetra namespace
Definition: Xpetra_BlockedCrsMatrix.hpp:88
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::getRangeMap
virtual Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
The Map associated with the range of this operator, which must be compatible with Y....
Definition: Xpetra_TpetraOperator.hpp:224
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::description
std::string description() const
A simple one-line description of this object.
Definition: Xpetra_TpetraOperator.hpp:250
Xpetra::TpetraOperator::describe
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
Definition: Xpetra_TpetraOperator.hpp:112
Xpetra::Operator
Definition: Xpetra_Operator.hpp:64
Xpetra::TpetraOperator< double, int, int, EpetraNode >::getRangeMap
virtual Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
The Map associated with the range of this operator, which must be compatible with Y....
Definition: Xpetra_TpetraOperator.hpp:156
Xpetra::toTpetra
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
Definition: Xpetra_TpetraCrsGraph_decl.hpp:378
Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, KokkosClassic::DefaultNode::DefaultNodeType >
Xpetra::TpetraOperator< double, int, int, EpetraNode >::LocalOrdinal
int LocalOrdinal
Definition: Xpetra_TpetraOperator.hpp:145
Xpetra::TpetraOperator::hasTransposeApply
virtual bool hasTransposeApply() const
Whether this operator supports applying the transpose or conjugate transpose.
Definition: Xpetra_TpetraOperator.hpp:99
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::TpetraOperator
TpetraOperator(const Teuchos::RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &op)
TpetraOperator constructor to wrap a Tpetra::Operator object.
Definition: Xpetra_TpetraOperator.hpp:261
Teuchos::NO_TRANS
NO_TRANS
Xpetra::toXpetra
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
Definition: Xpetra_EpetraCrsGraph.cpp:168
Xpetra::TpetraOperator< double, int, int, EpetraNode >::getDomainMap
virtual Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
The Map associated with the domain of this operator, which must be compatible with X....
Definition: Xpetra_TpetraOperator.hpp:151
Xpetra::TpetraOperator::apply
virtual void apply(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Computes the operator-multivector application.
Definition: Xpetra_TpetraOperator.hpp:90
Xpetra::TpetraOperator::getRangeMap
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
The Map associated with the range of this operator, which must be compatible with Y....
Definition: Xpetra_TpetraOperator.hpp:78
Teuchos::EVerbosityLevel
EVerbosityLevel
Xpetra_Utils.hpp
Teuchos::RCP
Xpetra::TpetraOperator< double, int, int, EpetraNode >::apply
virtual void apply(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Computes the operator-multivector application.
Definition: Xpetra_TpetraOperator.hpp:167
Xpetra::TpetraOperator::TpetraOperator
TpetraOperator(const Teuchos::RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &op)
TpetraOperator constructor to wrap a Tpetra::Operator object.
Definition: Xpetra_TpetraOperator.hpp:122
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::LocalOrdinal
int LocalOrdinal
Definition: Xpetra_TpetraOperator.hpp:213
Xpetra::TpetraOperator< double, int, int, EpetraNode >::TpetraOperator
TpetraOperator(const Teuchos::RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &op)
TpetraOperator constructor to wrap a Tpetra::Operator object.
Definition: Xpetra_TpetraOperator.hpp:193
Xpetra::TpetraOperator< double, int, int, EpetraNode >::hasTransposeApply
virtual bool hasTransposeApply() const
Whether this operator supports applying the transpose or conjugate transpose.
Definition: Xpetra_TpetraOperator.hpp:174
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::GlobalOrdinal
long long GlobalOrdinal
Definition: Xpetra_TpetraOperator.hpp:212
Xpetra_Operator.hpp
Teuchos::basic_FancyOStream
Xpetra::TpetraOperator< double, int, int, EpetraNode >::GlobalOrdinal
int GlobalOrdinal
Definition: Xpetra_TpetraOperator.hpp:144
Teuchos::ScalarTraits
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::describe
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
Definition: Xpetra_TpetraOperator.hpp:253
Xpetra::TpetraOperator< double, int, int, EpetraNode >::Node
EpetraNode Node
Definition: Xpetra_TpetraOperator.hpp:146
Xpetra::TpetraOperator< double, int, int, EpetraNode >::description
std::string description() const
A simple one-line description of this object.
Definition: Xpetra_TpetraOperator.hpp:182
Xpetra::TpetraOperator< double, int, int, EpetraNode >::getOperator
RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getOperator()
Gets the operator out.
Definition: Xpetra_TpetraOperator.hpp:196
Xpetra::TpetraOperator< double, int, int, EpetraNode >::describe
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
Definition: Xpetra_TpetraOperator.hpp:185
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::getDomainMap
virtual Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
The Map associated with the domain of this operator, which must be compatible with X....
Definition: Xpetra_TpetraOperator.hpp:219
Xpetra_TpetraConfigDefs.hpp
Xpetra::TpetraOperator::getDomainMap
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
The Map associated with the domain of this operator, which must be compatible with X....
Definition: Xpetra_TpetraOperator.hpp:72
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::Scalar
double Scalar
Definition: Xpetra_TpetraOperator.hpp:211
Xpetra::TpetraOperator::getOperator
RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getOperator()
Gets the operator out.
Definition: Xpetra_TpetraOperator.hpp:125
Xpetra::TpetraOperator< double, int, int, EpetraNode >::Scalar
double Scalar
Definition: Xpetra_TpetraOperator.hpp:143
Teuchos::Describable::verbLevel_default
static const EVerbosityLevel verbLevel_default
Xpetra::TpetraOperator::op_
RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > op_
The Tpetra::Operator which this class wraps.
Definition: Xpetra_TpetraOperator.hpp:131
XPETRA_MONITOR
#define XPETRA_MONITOR(funcName)
Definition: Xpetra_ConfigDefs.hpp:132
Teuchos::ETransp
ETransp
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::apply
virtual void apply(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &X, Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Computes the operator-multivector application.
Definition: Xpetra_TpetraOperator.hpp:235
Xpetra::TpetraOperator::description
std::string description() const
A simple one-line description of this object.
Definition: Xpetra_TpetraOperator.hpp:109
Xpetra::TpetraOperator< double, int, long long, EpetraNode >::getOperator
RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getOperator()
Gets the operator out.
Definition: Xpetra_TpetraOperator.hpp:264