| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Stokhos Package |
| 4 |
// |
| 5 |
// Copyright 2009 NTESS and the Stokhos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef TPETRA_CRSMATRIX_UQ_PCE_DEF_HPP |
| 11 |
#define TPETRA_CRSMATRIX_UQ_PCE_DEF_HPP |
| 12 |
|
| 13 |
// Specializations of some Tpetra::CrsMatrix methods for UQ::PCE |
| 14 |
|
| 15 |
#include "Tpetra_CrsMatrix_def.hpp" |
| 16 |
|
| 17 |
// These are macros; the code isn't compiled here, so we don't need to |
| 18 |
// say here what namespace the code is in. We _do_ need to put the |
| 19 |
// code in the correct namespace when we use the macro. |
| 20 |
|
| 21 |
#define TPETRA_CRSMATRIX_UQ_PCE_SPEC(Scalar,LocalOrdinal,GlobalOrdinal,Node) \ |
| 22 |
template<> \ |
| 23 |
Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > \ |
| 24 |
CrsMatrix<Scalar , LocalOrdinal, GlobalOrdinal, Node>:: \ |
| 25 |
getColumnMapMultiVector (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& X_domainMap, \ |
| 26 |
const bool force) const \ |
| 27 |
{ \ |
| 28 |
using Teuchos::null; \ |
| 29 |
using Teuchos::RCP; \ |
| 30 |
using Teuchos::rcp; \ |
| 31 |
\ |
| 32 |
TEUCHOS_TEST_FOR_EXCEPTION( \ |
| 33 |
! this->hasColMap (), std::runtime_error, "Tpetra::CrsMatrix::getColumn" \ |
| 34 |
"MapMultiVector: You may only call this method if the matrix has a " \ |
| 35 |
"column Map. If the matrix does not yet have a column Map, you should " \ |
| 36 |
"first call fillComplete (with domain and range Map if necessary)."); \ |
| 37 |
\ |
| 38 |
TEUCHOS_TEST_FOR_EXCEPTION( \ |
| 39 |
! this->getGraph ()->isFillComplete (), std::runtime_error, "Tpetra::" \ |
| 40 |
"CrsMatrix::getColumnMapMultiVector: You may only call this method if " \ |
| 41 |
"this matrix's graph is fill complete."); \ |
| 42 |
\ |
| 43 |
const size_t numVecs = X_domainMap.getNumVectors (); \ |
| 44 |
RCP<const import_type> importer = this->getGraph ()->getImporter (); \ |
| 45 |
RCP<const map_type> colMap = this->getColMap (); \ |
| 46 |
\ |
| 47 |
RCP<MV> X_colMap; \ |
| 48 |
\ |
| 49 |
if (! importer.is_null () || force) { \ |
| 50 |
if (importMV_.is_null () || \ |
| 51 |
importMV_->getNumVectors () != numVecs || \ |
| 52 |
(Kokkos::dimension_scalar(*importMV_) != \ |
| 53 |
Kokkos::dimension_scalar(X_domainMap))) { \ |
| 54 |
X_colMap = rcp (new MV (colMap, numVecs)); \ |
| 55 |
importMV_ = X_colMap; \ |
| 56 |
} \ |
| 57 |
else { \ |
| 58 |
X_colMap = importMV_; \ |
| 59 |
} \ |
| 60 |
} \ |
| 61 |
return X_colMap; \ |
| 62 |
} \ |
| 63 |
\ |
| 64 |
template <> \ |
| 65 |
Teuchos::RCP<MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> > \ |
| 66 |
CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>:: \ |
| 67 |
getRowMapMultiVector (const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& Y_rangeMap, \ |
| 68 |
const bool force) const \ |
| 69 |
{ \ |
| 70 |
using Teuchos::null; \ |
| 71 |
using Teuchos::RCP; \ |
| 72 |
using Teuchos::rcp; \ |
| 73 |
\ |
| 74 |
TEUCHOS_TEST_FOR_EXCEPTION( \ |
| 75 |
! this->getGraph ()->isFillComplete (), std::runtime_error, "Tpetra::" \ |
| 76 |
"CrsMatrix::getRowMapMultiVector: You may only call this method if this " \ |
| 77 |
"matrix's graph is fill complete."); \ |
| 78 |
\ |
| 79 |
const size_t numVecs = Y_rangeMap.getNumVectors (); \ |
| 80 |
RCP<const export_type> exporter = this->getGraph ()->getExporter (); \ |
| 81 |
RCP<const map_type> rowMap = this->getRowMap (); \ |
| 82 |
\ |
| 83 |
RCP<MV> Y_rowMap; \ |
| 84 |
\ |
| 85 |
if (! exporter.is_null () || force) { \ |
| 86 |
if (exportMV_.is_null () || \ |
| 87 |
exportMV_->getNumVectors () != numVecs || \ |
| 88 |
(Kokkos::dimension_scalar(*exportMV_) != \ |
| 89 |
Kokkos::dimension_scalar(Y_rangeMap))) { \ |
| 90 |
Y_rowMap = rcp (new MV (rowMap, numVecs)); \ |
| 91 |
exportMV_ = Y_rowMap; \ |
| 92 |
} \ |
| 93 |
else { \ |
| 94 |
Y_rowMap = exportMV_; \ |
| 95 |
} \ |
| 96 |
} \ |
| 97 |
return Y_rowMap; \ |
| 98 |
} |
| 99 |
|
| 100 |
#endif // STOKHOS_TPETRA_UQ_PCE_DEF_HPP |