/*! Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + \beta \cdot Y\f$. However, the details of operation vary according to the values of \c alpha and \c beta. Specifically - if <tt>beta == 0</tt>, apply() <b>must</b> overwrite \c Y, so that any values in \c Y (including NaNs) are ignored. - if <tt>alpha == 0</tt>, apply() <b>may</b> short-circuit the operator, so that any values in \c X (including NaNs) are ignored. */ 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 { op_->apply(toTpetra(X), toTpetra(Y), mode, alpha, beta); }
//! Export. void doExport(const DistObject<GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node> &dest, const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM) { XPETRA_MONITOR("TpetraCrsGraph::doExport"); XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, dest, tDest, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() RCP< const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > v = tDest.getTpetra_CrsGraph(); graph_->doExport(*v, toTpetra(importer), toTpetra(CM)); }
//! Import. void doImport(const DistObject<GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node> &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM) { XPETRA_MONITOR("TpetraCrsGraph::doImport"); XPETRA_DYNAMIC_CAST(const TpetraCrsGraphClass, source, tSource, "Xpetra::TpetraCrsGraph::doImport only accept Xpetra::TpetraCrsGraph as input arguments.");//TODO: remove and use toTpetra() RCP< const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> > v = tSource.getTpetra_CrsGraph(); //graph_->doImport(toTpetraCrsGraph(source), *tImporter.getTpetra_Import(), toTpetra(CM)); graph_->doImport(*v, toTpetra(importer), toTpetra(CM)); }
//! Constructor with Tpetra-defined contiguous uniform distribution. TpetraMap (global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node = defaultArgNode()) : map_ (Teuchos::rcp (new Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > (numGlobalElements, indexBase, comm, toTpetra(lg), node))) {}
//! Copy constructor. TpetraExport(const Export< LocalOrdinal, GlobalOrdinal, Node > &rhs) : export_(Teuchos::rcp(new Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(rhs)))) { }
//! Constructor (with list of parameters). TpetraExport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target, const Teuchos::RCP< Teuchos::ParameterList > &plist) : export_(Teuchos::rcp(new Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(source), toTpetra(target), plist))) { }
//! Replaces the current domainMap and importer with the user-specified objects. void replaceDomainMapAndImporter(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >& newDomainMap, Teuchos::RCP<const Import<LocalOrdinal,GlobalOrdinal,Node> > & newImporter) { XPETRA_MONITOR("TpetraCrsMatrix::replaceDomainMapAndImporter"); XPETRA_DYNAMIC_CAST( const TpetraImportClass , *newImporter, tImporter, "Xpetra::TpetraCrsMatrix::replaceDomainMapAndImporter only accepts Xpetra::TpetraImport."); RCP<const Tpetra::Import<LocalOrdinal,GlobalOrdinal,Node> > myImport = tImporter.getTpetra_Import(); mtx_->replaceDomainMapAndImporter( toTpetra(newDomainMap),myImport); }
//! Signal that data entry is complete, specifying domain and range maps. void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > ¶ms=null) { XPETRA_MONITOR("TpetraCrsMatrix::fillComplete"); mtx_->fillComplete(toTpetra(domainMap), toTpetra(rangeMap), params); }
//! Constructor with Tpetra-defined contiguous uniform distribution. TpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=KokkosClassic::Details::getNode<Node>()) : map_(Teuchos::rcp(new Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node >(numGlobalElements, indexBase, comm, toTpetra(lg), node))) { }
//! True if and only if map is identical to this Map. bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("TpetraMap::isSameAs"); return map_->isSameAs(toTpetra(map)); }
//! True if and only if map is compatible with this Map. bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("TpetraMap::isCompatible"); return map_->isCompatible(toTpetra(map)); }
//! Copy constructor. TpetraImport(const Import< LocalOrdinal, GlobalOrdinal, Node > &import) : import_(Teuchos::rcp(new Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(import)))) { }
//! Construct an Import from the source and target Maps. TpetraImport(const Teuchos::RCP< const map_type > &source, const Teuchos::RCP< const map_type > &target) : import_(Teuchos::rcp(new Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node >(toTpetra(source), toTpetra(target)))) { }
void Jacobi( Scalar omega, const Xpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> & Dinv, const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>& A, const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>& B, Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>& C, bool call_FillComplete_on_result = true, bool doOptimizeStorage = true) { if(C.getRowMap()->isSameAs(*A.getRowMap()) == false) { std::string msg = "XpetraExt::MatrixMatrix::Jacobi: row map of C is not same as row map of A"; throw(Xpetra::Exceptions::RuntimeError(msg)); } else if(C.getRowMap()->isSameAs(*B.getRowMap()) == false) { std::string msg = "XpetraExt::MatrixMatrix::Jacobi: row map of C is not same as row map of B"; throw(Xpetra::Exceptions::RuntimeError(msg)); } if (!A.isFillComplete()) throw(Xpetra::Exceptions::RuntimeError("A is not fill-completed")); if (!B.isFillComplete()) throw(Xpetra::Exceptions::RuntimeError("B is not fill-completed")); bool haveMultiplyDoFillComplete = call_FillComplete_on_result && doOptimizeStorage; if (C.getRowMap()->lib() == Xpetra::UseEpetra) { #ifndef HAVE_XPETRA_EPETRAEXT throw(Xpetra::Exceptions::RuntimeError("Xpetra::MatrixMatrix::Jacobi requires EpetraExt to be compiled.")); #else throw(Xpetra::Exceptions::RuntimeError("Xpetra::MatrixMatrix::Jacobi requires you to use an Epetra-compatible data type.")); #endif } else if (C.getRowMap()->lib() == Xpetra::UseTpetra) { #ifdef HAVE_XPETRA_TPETRA const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> & tpA = Xpetra::MatrixMatrix::Op2TpetraCrs(A); const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> & tpB = Xpetra::MatrixMatrix::Op2TpetraCrs(B); Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> & tpC = Xpetra::MatrixMatrix::Op2NonConstTpetraCrs(C); const RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > & tpD = toTpetra(Dinv); Tpetra::MatrixMatrix::Jacobi(omega,*tpD,tpA,tpB,tpC,haveMultiplyDoFillComplete); #else throw(Xpetra::Exceptions::RuntimeError("Xpetra must be compiled with Tpetra.")); #endif } if(call_FillComplete_on_result && !haveMultiplyDoFillComplete) { RCP<Teuchos::ParameterList> params = rcp(new Teuchos::ParameterList()); params->set("Optimize Storage",doOptimizeStorage); C.fillComplete(B.getDomainMap(),B.getRangeMap(),params); } // transfer striding information RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> > rcpA = Teuchos::rcp_const_cast<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> >(Teuchos::rcpFromRef(A)); RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> > rcpB = Teuchos::rcp_const_cast<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> >(Teuchos::rcpFromRef(B)); C.CreateView("stridedMaps", rcpA, false, rcpB, false); // TODO use references instead of RCPs } // end Jacobi