10 #ifndef TPETRA_ROWGRAPH_DEF_HPP
11 #define TPETRA_ROWGRAPH_DEF_HPP
14 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
16 pack(
const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
17 Teuchos::Array<GlobalOrdinal>& exports,
18 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
19 size_t& constantNumPackets)
const {
21 typedef LocalOrdinal LO;
22 typedef GlobalOrdinal GO;
24 const char tfecfFuncName[] =
"packAndPrepare";
26 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
27 exportLIDs.size() != numPacketsPerLID.size(), std::runtime_error,
28 ": exportLIDs and numPacketsPerLID must have the same size.");
30 const map_type& srcMap = *(this->getRowMap());
31 constantNumPackets = 0;
38 size_t totalNumPackets = 0;
39 nonconst_global_inds_host_view_type row;
40 for (LO i = 0; i < exportLIDs.size(); ++i) {
42 size_t row_length = this->getNumEntriesInGlobalRow(GID);
43 numPacketsPerLID[i] = row_length;
44 totalNumPackets += row_length;
47 exports.resize(totalNumPackets);
51 size_t exportsOffset = 0;
52 for (LO i = 0; i < exportLIDs.size(); ++i) {
53 const GO GID = srcMap.getGlobalElement(exportLIDs[i]);
54 size_t row_length = this->getNumEntriesInGlobalRow(GID);
55 Kokkos::resize(row, row_length);
56 size_t check_row_length = 0;
57 this->getGlobalRowCopy(GID, row, check_row_length);
59 for (
size_t j = 0; j < row_length; ++j) {
60 exports[exportsOffset + j] = row[j];
62 exportsOffset += row.extent(0);
74 #define TPETRA_ROWGRAPH_INSTANT(LO, GO, NODE) \
75 template class RowGraph<LO, GO, NODE>;
77 #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.