42 #ifndef TPETRA_ROWGRAPH_DEF_HPP
43 #define TPETRA_ROWGRAPH_DEF_HPP
46 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
49 pack (
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
50 Teuchos::Array<GlobalOrdinal>& exports,
51 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
52 size_t& constantNumPackets)
const
55 typedef LocalOrdinal LO;
56 typedef GlobalOrdinal GO;
58 const char tfecfFuncName[] =
"packAndPrepare";
60 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
61 exportLIDs.size() != numPacketsPerLID.size(), std::runtime_error,
62 ": exportLIDs and numPacketsPerLID must have the same size.");
64 const map_type& srcMap = * (this->getRowMap ());
65 constantNumPackets = 0;
72 size_t totalNumPackets = 0;
73 nonconst_global_inds_host_view_type row;
74 for (LO i = 0; i < exportLIDs.size (); ++i) {
76 size_t row_length = this->getNumEntriesInGlobalRow (GID);
77 numPacketsPerLID[i] = row_length;
78 totalNumPackets += row_length;
81 exports.resize (totalNumPackets);
85 size_t exportsOffset = 0;
86 for (LO i = 0; i < exportLIDs.size (); ++i) {
87 const GO GID = srcMap.getGlobalElement (exportLIDs[i]);
88 size_t row_length = this->getNumEntriesInGlobalRow (GID);
89 Kokkos::resize(row,row_length);
90 size_t check_row_length = 0;
91 this->getGlobalRowCopy (GID, row, check_row_length);
93 for (
size_t j=0; j<row_length; ++j) {
94 exports[exportsOffset+j] = row[j];
96 exportsOffset += row.extent(0);
108 #define TPETRA_ROWGRAPH_INSTANT(LO,GO,NODE) \
109 template class RowGraph< LO , GO , NODE >;
111 #endif // TPETRA_ROWGRAPH_DEF_HPP
virtual void pack(const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< GlobalOrdinal > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets) const
Pack this object's data for Import or Export.
global_ordinal_type getGlobalElement(local_ordinal_type localIndex) const
The global index corresponding to the given local index.