42 #ifndef TPETRA_RTIOP_HPP
43 #define TPETRA_RTIOP_HPP
45 #include "Tpetra_RTI.hpp"
46 #include "Tpetra_RTI_detail.hpp"
60 template <
class S,
class LO,
class GO,
class Node,
class Kernel>
63 RCP<const Import<LO,GO,Node> > _importer;
64 RCP<const Export<LO,GO,Node> > _exporter;
65 mutable RCP<MultiVector<S,LO,GO,Node> > _importMV, _exportMV;
66 RCP<const Map<LO,GO,Node> > _rangeMap, _domainMap;
67 mutable Kernel _kernel;
76 : _importer (importer), _exporter (exporter)
77 , _rangeMap (rangeMap), _domainMap (domainMap)
80 const char tfecfFuncName[] =
"KernelOp(kernel,domainMap,rangeMap,importer,exporter)";
81 if (_rangeMap ==
null) {
82 _rangeMap = _domainMap;
84 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
85 _domainMap ==
null || _rangeMap ==
null, std::runtime_error,
86 ": neither domainMap nor rangeMap may be specified null:\ndomainMap: "
87 << _domainMap <<
"\nrangeMap: " << _rangeMap <<
"\n");
88 #ifdef HAVE_TPETRA_DEBUG
89 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
90 _rangeMap->getNode() != _domainMap->getNode(), std::runtime_error,
91 ": all specified maps must have the same Node instance.");
92 if (_importer !=
null) {
93 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
94 ! _importer->getSourceMap ()->isSameAs (*_domainMap),
96 ": domain Map is not consistent with importer.");
97 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
98 _importer->getSourceMap ()->getNode () != _domainMap->getNode (),
100 ": all specified Maps must have the same Node instance.");
102 if (_exporter !=
null) {
103 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
104 ! _exporter->getTargetMap ()->isSameAs (*_rangeMap),
105 std::runtime_error,
": range Map is not consistent with importer.");
106 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
107 _exporter->getTargetMap ()->getNode () != _domainMap->getNode (),
109 ": all specified Maps must have the same Node instance.");
111 #endif // HAVE_TPETRA_DEBUG
114 RCP<const Map<LO,GO,Node> >
getDomainMap ()
const {
return _domainMap; }
115 RCP<const Map<LO,GO,Node> >
getRangeMap ()
const {
return _rangeMap; }
120 Teuchos::ETransp mode = Teuchos::NO_TRANS,
121 S alpha = Teuchos::ScalarTraits<S>::one (),
122 S beta = Teuchos::ScalarTraits<S>::zero ())
const
125 RCP<MultiVector<S,LO,GO,Node> > mvec_inout;
126 RCP<const MultiVector<S,LO,GO,Node> > mvec_in2;
128 if (_importer !=
null) {
129 if (_importMV !=
null && _importMV->getNumVectors () != numVectors) {
132 if (_importMV ==
null) {
133 _importMV = createMultiVector<S> (_importer->getTargetMap (), numVectors);
135 _importMV->doImport (X, *_importer,
INSERT);
136 mvec_in2 = _importMV;
139 mvec_in2 = rcpFromRef(X);
142 if (_exporter !=
null) {
143 if (_exportMV !=
null && _exportMV->getNumVectors () != numVectors) {
146 if (_exportMV ==
null) {
147 _exportMV = createMultiVector<S> (_exporter->getSourceMap (), numVectors);
149 mvec_inout = _exportMV;
152 mvec_inout = rcpFromRef (Y);
154 _kernel.setAlphaBeta (alpha, beta);
156 for (
size_t j=0; j < numVectors; ++j) {
157 RCP< Vector<S,LO,GO,Node> > vec_inout = mvec_inout->getVectorNonConst(j);
158 RCP< const Vector<S,LO,GO,Node> > vec_in2 = mvec_in2->getVector(j);
162 if (_exporter !=
null) {
169 template <
class S,
class LO,
class GO,
class Node,
class Kernel>
170 RCP<const KernelOp<S,LO,GO,Node,Kernel> >
178 importer, exporter) );
182 template <
class S,
class LO,
class GO,
class Node,
class Op>
184 public KernelOp<S,LO,GO,Node,Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S> >
192 :
KernelOp<S,LO,GO,Node,Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S> >(
Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S>(op), domainMap, rangeMap, importer, exporter ) {}
196 template <
class S,
class LO,
class GO,
class Node,
class Op>
197 RCP<const BinaryOp<S,LO,GO,Node,Op> >
205 importer, exporter) );
210 #endif // TPETRA_RTIOP_HPP