42 #ifndef TPETRA_RTIOP_HPP
43 #define TPETRA_RTIOP_HPP
45 #include "Tpetra_RTI.hpp"
46 #include "Tpetra_RTI_detail.hpp"
53 template <
class S,
class LO,
class GO,
class Node,
class Kernel>
57 RCP< const Import<LO,GO,Node> > _importer;
58 RCP< const Export<LO,GO,Node> > _exporter;
59 mutable RCP< MultiVector<S,LO,GO,Node> > _importMV, _exportMV;
60 RCP< const Map<LO,GO,Node> > _rangeMap, _domainMap;
61 mutable Kernel _kernel;
68 : _importer(importer), _exporter(exporter)
69 , _rangeMap(rangeMap), _domainMap(domainMap)
72 std::string tfecfFuncName(
"KernelOp(kernel,domainMap,rangeMap,importer,exporter)");
73 if (_rangeMap == null) _rangeMap = _domainMap;
74 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( _domainMap == null || _rangeMap == null, std::runtime_error,
75 ":KernelOp(): neither domainMap nor rangeMap may be specified null:\ndomainMap: " << _domainMap <<
"\nrangeMap: " << _rangeMap <<
"\n");
76 #ifdef HAVE_TPETRA_DEBUG
77 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( _rangeMap->getNode() != _domainMap->getNode(), std::runtime_error,
": all specified maps must have the same node.");
78 if (_importer != null) {
79 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( !_importer->getSourceMap()->isSameAs(*_domainMap), std::runtime_error,
": domain map is not consistent with importer.");
80 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( _importer->getSourceMap()->getNode() != _domainMap->getNode(), std::runtime_error,
": all specified maps must have the same node.");
82 if (_exporter != null) {
83 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( !_exporter->getTargetMap()->isSameAs(*_rangeMap), std::runtime_error,
": range map is not consistent with importer.");
84 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( _exporter->getTargetMap()->getNode() != _domainMap->getNode(), std::runtime_error,
": all specified maps must have the same node.");
89 const RCP<const Map<LO,GO,Node> > &
getDomainMap()
const {
return _domainMap; }
91 const RCP<const Map<LO,GO,Node> > &
getRangeMap()
const {
return _rangeMap; }
95 Teuchos::ETransp mode = Teuchos::NO_TRANS,
96 S alpha = Teuchos::ScalarTraits<S>::one(),
97 S beta = Teuchos::ScalarTraits<S>::zero())
const
100 RCP< MultiVector<S,LO,GO,Node> > mvec_inout;
101 RCP< const MultiVector<S,LO,GO,Node> > mvec_in2;
103 if (_importer != null) {
104 if (_importMV != null && _importMV->getNumVectors() != numVectors) _importMV = null;
105 if (_importMV == null) _importMV = createMultiVector<S>(_importer->getTargetMap(), numVectors);
106 _importMV->doImport( X, *_importer,
INSERT );
107 mvec_in2 = _importMV;
110 mvec_in2 = rcpFromRef(X);
113 if (_exporter != null) {
114 if (_exportMV != null && _exportMV->getNumVectors() != numVectors) _exportMV = null;
115 if (_exportMV == null) _exportMV = createMultiVector<S>(_exporter->getSourceMap(), numVectors);
116 mvec_inout = _exportMV;
119 mvec_inout = rcpFromRef(Y);
121 _kernel.setAlphaBeta(alpha,beta);
123 for (
size_t j=0; j < numVectors; ++j)
125 RCP< Vector<S,LO,GO,Node> > vec_inout = mvec_inout->getVectorNonConst(j);
126 RCP< const Vector<S,LO,GO,Node> > vec_in2 = mvec_in2->getVector(j);
130 if (_exporter != null) {
137 template <
class S,
class LO,
class GO,
class Node,
class Kernel>
138 RCP< const KernelOp<S,LO,GO,Node,Kernel> >
149 template <
class S,
class LO,
class GO,
class Node,
class Op>
150 class BinaryOp :
public KernelOp<S,LO,GO,Node,Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S> >
158 :
KernelOp<S,LO,GO,Node,Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S> >(
Tpetra::RTI::detail::BinaryFunctorAdapterWithAlphaBeta<Op,S>(op), domainMap, rangeMap, importer, exporter ) {}
162 template <
class S,
class LO,
class GO,
class Node,
class Op>
163 RCP< const BinaryOp<S,LO,GO,Node,Op> >
177 #endif // TPETRA_RTIOP_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
size_t getNumVectors() const
Number of columns in the multivector.
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 ...
Tpetra::Operator wrapping a Kokkos kernel using the Tpetra Reduction/Transformation Interface...
Abstract interface for linear operators accepting Tpetra MultiVector objects.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
const RCP< const Map< LO, GO, Node > > & getDomainMap() const
Returns the Map associated with the domain of this operator, which must be compatible with X...
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.
const RCP< const Map< LO, GO, Node > > & getRangeMap() const
Returns the Map associated with the range of this operator, which must be compatible with Y...
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.
Describes a parallel distribution of objects over processes.
Tpetra::Operator wrapping a binary functor using the Tpetra Reduction/Transformation Interface...
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.
void doExport(const SrcDistObject &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export data into this object using an Export object ("forward mode").