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 if (_importer != null) {
90 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
91 ! _importer->getSourceMap ()->isSameAs (*_domainMap),
93 ": domain Map is not consistent with importer.");
95 if (_exporter != null) {
96 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
97 ! _exporter->getTargetMap ()->isSameAs (*_rangeMap),
98 std::runtime_error,
": range Map is not consistent with importer.");
100 #endif // HAVE_TPETRA_DEBUG
103 RCP<const Map<LO,GO,Node> >
getDomainMap ()
const {
return _domainMap; }
104 RCP<const Map<LO,GO,Node> >
getRangeMap ()
const {
return _rangeMap; }
109 Teuchos::ETransp mode = Teuchos::NO_TRANS,
110 S alpha = Teuchos::ScalarTraits<S>::one (),
111 S beta = Teuchos::ScalarTraits<S>::zero ())
const
114 RCP<MultiVector<S,LO,GO,Node> > mvec_inout;
115 RCP<const MultiVector<S,LO,GO,Node> > mvec_in2;
117 if (_importer != null) {
118 if (_importMV != null && _importMV->getNumVectors () != numVectors) {
121 if (_importMV == null) {
122 _importMV = createMultiVector<S> (_importer->getTargetMap (), numVectors);
124 _importMV->doImport (X, *_importer,
INSERT);
125 mvec_in2 = _importMV;
128 mvec_in2 = rcpFromRef(X);
131 if (_exporter != null) {
132 if (_exportMV != null && _exportMV->getNumVectors () != numVectors) {
135 if (_exportMV == null) {
136 _exportMV = createMultiVector<S> (_exporter->getSourceMap (), numVectors);
138 mvec_inout = _exportMV;
141 mvec_inout = rcpFromRef (Y);
143 _kernel.setAlphaBeta (alpha, beta);
145 for (
size_t j=0; j < numVectors; ++j) {
146 RCP< Vector<S,LO,GO,Node> > vec_inout = mvec_inout->getVectorNonConst(j);
147 RCP< const Vector<S,LO,GO,Node> > vec_in2 = mvec_in2->getVector(j);
151 if (_exporter != null) {
158 template <
class S,
class LO,
class GO,
class Node,
class Kernel>
159 RCP<const KernelOp<S,LO,GO,Node,Kernel> >
167 importer, exporter) );
171 template <
class S,
class LO,
class GO,
class Node,
class Op>
173 public KernelOp<S,LO,GO,Node,Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S> >
181 :
KernelOp<S,LO,GO,Node,Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S> >(
Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S>(op), domainMap, rangeMap, importer, exporter ) {}
185 template <
class S,
class LO,
class GO,
class Node,
class Op>
186 RCP<const BinaryOp<S,LO,GO,Node,Op> >
194 importer, exporter) );
199 #endif // TPETRA_RTIOP_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
RCP< const BinaryOp< S, LO, GO, Node, Op > > binaryOp(Op op, const RCP< const Map< LO, GO, Node > > &domainMap, const RCP< const Map< LO, GO, Node > > &rangeMap=null, const RCP< const Import< LO, GO, Node > > &importer=null, const RCP< const Export< LO, GO, Node > > &exporter=null)
Non-member constructor for a Tpetra::RTI::BinaryOp object.
KernelOp(Kernel kernel, const RCP< const Map< LO, GO, Node > > &domainMap, const RCP< const Map< LO, GO, Node > > &rangeMap, const RCP< const Import< LO, GO, Node > > &importer, const RCP< const Export< LO, GO, Node > > &exporter)
Constructor.
size_t getNumVectors() const
Number of columns in the multivector.
RCP< const Map< LO, GO, Node > > getDomainMap() const
The Map associated with the domain of this operator, which must be compatible with X...
One or more distributed dense vectors.
void binary_transform(Vector< S1, LO, GO, Node > &vec_inout, const Vector< S2, LO, GO, Node > &vec_in2, OP op)
pass vec_inout and vec_in2 data pointers to op, then execute via node parallel_for ...
Insert new values that don't currently exist.
Operator wrapping a Kokkos (Classic) kernel using RTI.
Abstract interface for operators (e.g., matrices and preconditioners).
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
Sum new values into existing values.
void apply(const MultiVector< S, LO, GO, Node > &X, MultiVector< S, LO, GO, Node > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, S alpha=Teuchos::ScalarTraits< S >::one(), S beta=Teuchos::ScalarTraits< S >::zero()) const
Computes the operator-multivector application.
RCP< const Map< LO, GO, Node > > getRangeMap() const
The Map associated with the range of this operator, which must be compatible with Y...
void doExport(const SrcDistObject &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, const CombineMode CM, const bool restrictedMode=false)
Export data into this object using an Export object ("forward mode").
RCP< const KernelOp< S, LO, GO, Node, Kernel > > kernelOp(Kernel kernel, const RCP< const Map< LO, GO, Node > > &domainMap, const RCP< const Map< LO, GO, Node > > &rangeMap=null, const RCP< const Import< LO, GO, Node > > &importer=null, const RCP< const Export< LO, GO, Node > > &exporter=null)
Non-member constructor for a Tpetra::RTI::KernelOp object.
Tpetra::Operator wrapping a binary functor using the Tpetra Reduction/Transformation Interface...