42 #ifndef TPETRA_CRSGRAPH_DECL_HPP
43 #define TPETRA_CRSGRAPH_DECL_HPP
56 #include "Tpetra_DistObject.hpp"
57 #include "Tpetra_Exceptions.hpp"
58 #include "Tpetra_RowGraph.hpp"
61 #include "KokkosSparse_findRelOffset.hpp"
62 #include "Kokkos_DualView.hpp"
63 #include "Kokkos_StaticCrsGraph.hpp"
64 #include "Kokkos_UnorderedMap.hpp"
66 #include "Teuchos_CommHelpers.hpp"
67 #include "Teuchos_Describable.hpp"
68 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
76 template<
class LocalOrdinal,
class GlobalOrdinal,
class Node>
class crsGraph_Swap_Tester;
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
82 template<
class OutputCrsGraphType,
class InputCrsGraphType>
83 class CrsGraphCopier {
85 static Teuchos::RCP<OutputCrsGraphType>
86 clone (
const InputCrsGraphType& graphIn,
87 const Teuchos::RCP<typename OutputCrsGraphType::node_type> nodeOut,
88 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
90 #endif // TPETRA_ENABLE_DEPRECATED_CODE
92 template<
class LO,
class GO,
class NT>
95 CrsGraph<LO, GO, NT>& graph,
96 const Teuchos::ArrayView<
const typename CrsGraph<LO,GO,NT>::packet_type>& imports,
97 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
98 const Teuchos::ArrayView<const LO>& importLIDs,
99 size_t constantNumPackets,
100 Distributor & distor,
106 template<
class ViewType>
107 struct UnmanagedView {
108 static_assert (Kokkos::is_view<ViewType>::value,
109 "ViewType must be a Kokkos::View specialization.");
113 typedef Kokkos::View<
typename ViewType::data_type,
114 typename ViewType::array_layout,
115 typename ViewType::device_type,
116 Kokkos::MemoryUnmanaged> type;
120 #endif // DOXYGEN_SHOULD_SKIP_THIS
189 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
190 class HasDeprecatedMethods2630_WarningThisClassIsNotForUsers {
200 virtual ~HasDeprecatedMethods2630_WarningThisClassIsNotForUsers () =
default;
201 virtual bool isLowerTriangularImpl ()
const = 0;
202 virtual bool isUpperTriangularImpl ()
const = 0;
203 virtual size_t getGlobalNumDiagsImpl ()
const = 0;
206 #endif // TPETRA_ENABLE_DEPRECATED_CODE
267 template <
class LocalOrdinal,
271 public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
276 public Teuchos::ParameterListAcceptorDefaultBase
277 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
278 ,
public ::Tpetra::Details::HasDeprecatedMethods2630_WarningThisClassIsNotForUsers
279 #endif // TPETRA_ENABLE_DEPRECATED_CODE
281 template <
class S,
class LO,
class GO,
class N>
283 template <
class LO2,
class GO2,
class N2>
285 template <
class LO,
class GO,
class N>
311 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
315 typedef typename local_graph_type::row_map_type t_RowPtrs TPETRA_DEPRECATED;
317 typedef typename local_graph_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED;
319 typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED;
320 #endif // TPETRA_ENABLE_DEPRECATED_CODE
350 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
351 const size_t maxNumEntriesPerRow,
352 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
353 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
372 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
373 const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
374 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
375 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
395 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
396 const Teuchos::ArrayView<const size_t>& numEntPerRow,
397 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
398 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
400 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
403 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
404 const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
406 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
407 #endif // TPETRA_ENABLE_DEPRECATED_CODE
430 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
431 const Teuchos::RCP<const map_type>& colMap,
432 const size_t maxNumEntriesPerRow,
433 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
434 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
454 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
455 const Teuchos::RCP<const map_type>& colMap,
456 const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
457 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
458 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
479 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
480 const Teuchos::RCP<const map_type>& colMap,
481 const Teuchos::ArrayView<const size_t>& numEntPerRow,
482 const ProfileType pftype = TPETRA_DEFAULT_PROFILE_TYPE,
483 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
485 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
488 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
489 const Teuchos::RCP<const map_type>& colMap,
490 const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
492 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
493 #endif // TPETRA_ENABLE_DEPRECATED_CODE
515 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
516 const Teuchos::RCP<const map_type>& colMap,
517 const typename local_graph_type::row_map_type& rowPointers,
518 const typename local_graph_type::entries_type::non_const_type& columnIndices,
519 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
541 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
542 const Teuchos::RCP<const map_type>& colMap,
543 const Teuchos::ArrayRCP<size_t>& rowPointers,
544 const Teuchos::ArrayRCP<local_ordinal_type>& columnIndices,
545 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
565 CrsGraph (
const Teuchos::RCP<const map_type>& rowMap,
566 const Teuchos::RCP<const map_type>& colMap,
568 const Teuchos::RCP<Teuchos::ParameterList>& params);
595 const Teuchos::RCP<const map_type>& rowMap,
596 const Teuchos::RCP<const map_type>& colMap,
597 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
598 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
599 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
651 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
652 template<
class Node2>
653 Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node2> > TPETRA_DEPRECATED
654 clone (
const Teuchos::RCP<Node2>& node2,
655 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const
659 typedef ::Tpetra::Details::CrsGraphCopier<output_crs_graph_type, input_crs_graph_type> copier_type;
660 return copier_type::clone (*
this, node2, params);
688 setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& params)
override;
691 Teuchos::RCP<const Teuchos::ParameterList>
721 const Teuchos::ArrayView<const global_ordinal_type>& indices);
751 const Teuchos::ArrayView<const local_ordinal_type>& indices);
808 resumeFill (
const Teuchos::RCP<Teuchos::ParameterList>& params =
849 fillComplete (
const Teuchos::RCP<const map_type>& domainMap,
850 const Teuchos::RCP<const map_type>& rangeMap,
851 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
881 fillComplete (
const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
913 const Teuchos::RCP<const map_type>& rangeMap,
914 const Teuchos::RCP<const import_type>& importer =
916 const Teuchos::RCP<const export_type>& exporter =
918 const Teuchos::RCP<Teuchos::ParameterList>& params =
925 Teuchos::RCP<const Teuchos::Comm<int> >
getComm()
const override;
927 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
928 TPETRA_DEPRECATED Teuchos::RCP<node_type> getNode()
const override;
930 #endif // TPETRA_ENABLE_DEPRECATED_CODE
933 Teuchos::RCP<const map_type>
getRowMap ()
const override;
936 Teuchos::RCP<const map_type>
getColMap ()
const override;
939 Teuchos::RCP<const map_type>
getDomainMap ()
const override;
942 Teuchos::RCP<const map_type>
getRangeMap ()
const override;
945 Teuchos::RCP<const import_type>
getImporter ()
const override;
948 Teuchos::RCP<const export_type>
getExporter ()
const override;
1079 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1095 size_t TPETRA_DEPRECATED getNodeNumDiags ()
const override;
1121 size_t getNodeNumDiagsImpl ()
const override;
1133 bool TPETRA_DEPRECATED isLowerTriangular ()
const override;
1145 bool TPETRA_DEPRECATED isUpperTriangular ()
const override;
1158 bool isLowerTriangularImpl ()
const override;
1171 bool isUpperTriangularImpl ()
const override;
1172 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1226 const Teuchos::ArrayView<global_ordinal_type>& gblColInds,
1227 size_t& numColInds)
const override;
1238 const Teuchos::ArrayView<local_ordinal_type>& lclColInds,
1239 size_t& numColInds)
const override;
1253 Teuchos::ArrayView<const global_ordinal_type>& gblColInds)
const override;
1271 Teuchos::ArrayView<const local_ordinal_type>& lclColInds)
const override;
1283 describe (Teuchos::FancyOStream& out,
1284 const Teuchos::EVerbosityLevel verbLevel =
1285 Teuchos::Describable::verbLevel_default)
const override;
1303 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1305 #else // TPETRA_ENABLE_DEPRECATED_CODE
1307 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1309 const size_t numSameIDs,
1316 applyCrsPadding (
const Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>& padding);
1318 Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1321 const Teuchos::ArrayView<const local_ordinal_type> &permuteToLIDs,
1322 const Teuchos::ArrayView<const local_ordinal_type> &permuteFromLIDs);
1324 Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1326 const size_t numSameIDs,
1332 Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1333 computeCrsPadding (
const Teuchos::ArrayView<const local_ordinal_type>& importLIDs,
1334 const Teuchos::ArrayView<size_t>& numPacketsPerLID);
1336 Kokkos::UnorderedMap<local_ordinal_type, size_t, device_type>
1339 Kokkos::DualView<
size_t*,
1343 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1345 #else // TPETRA_ENABLE_DEPRECATED_CODE
1347 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1353 Kokkos::DualView<
size_t*,
1355 size_t& constantNumPackets,
1359 pack (
const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1360 Teuchos::Array<global_ordinal_type>& exports,
1361 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1362 size_t& constantNumPackets,
1366 packFillActive (
const Teuchos::ArrayView<const local_ordinal_type>& exportLIDs,
1367 Teuchos::Array<global_ordinal_type>& exports,
1368 const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1369 size_t& constantNumPackets,
1377 Kokkos::DualView<
size_t*,
1379 size_t& constantNumPackets,
1383 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
1385 #else // TPETRA_ENABLE_DEPRECATED_CODE
1387 #endif // TPETRA_ENABLE_DEPRECATED_CODE
1392 Kokkos::DualView<
size_t*,
1394 const size_t constantNumPackets,
1445 getLocalDiagOffsets (
const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets)
const;
1483 size_t& boundForAllLocalRows,
1484 bool& boundSameForAllLocalRows)
const;
1495 setAllIndices (
const typename local_graph_type::row_map_type& rowPointers,
1496 const typename local_graph_type::entries_type::non_const_type& columnIndices);
1507 setAllIndices (
const Teuchos::ArrayRCP<size_t> & rowPointers,
1508 const Teuchos::ArrayRCP<local_ordinal_type> & columnIndices);
1534 void replaceColMap (
const Teuchos::RCP<const map_type>& newColMap);
1557 const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1558 const bool sortIndicesInEachRow =
true);
1575 const Teuchos::RCP<const import_type>& newImporter);
1609 template<
class ViewType,
class OffsetViewType >
1610 struct pack_functor {
1614 OffsetViewType src_offset;
1615 OffsetViewType dest_offset;
1616 typedef typename OffsetViewType::non_const_value_type ScalarIndx;
1618 pack_functor(ViewType dest_, ViewType src_, OffsetViewType dest_offset_, OffsetViewType src_offset_):
1619 src(src_),dest(dest_),src_offset(src_offset_),dest_offset(dest_offset_) {};
1621 KOKKOS_INLINE_FUNCTION
1622 void operator() (
size_t row)
const {
1623 ScalarIndx i = src_offset(row);
1624 ScalarIndx j = dest_offset(row);
1625 const ScalarIndx k = dest_offset(row+1);
1634 template<
class CrsGraphType>
1635 friend Teuchos::RCP<CrsGraphType>
1636 importAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1637 const Import<
typename CrsGraphType::local_ordinal_type,
1638 typename CrsGraphType::global_ordinal_type,
1639 typename CrsGraphType::node_type>& importer,
1640 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1641 typename CrsGraphType::global_ordinal_type,
1642 typename CrsGraphType::node_type> >& domainMap,
1643 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1644 typename CrsGraphType::global_ordinal_type,
1645 typename CrsGraphType::node_type> >& rangeMap,
1646 const Teuchos::RCP<Teuchos::ParameterList>& params);
1649 template<
class CrsGraphType>
1650 friend Teuchos::RCP<CrsGraphType>
1651 importAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1652 const Import<
typename CrsGraphType::local_ordinal_type,
1653 typename CrsGraphType::global_ordinal_type,
1654 typename CrsGraphType::node_type>& rowImporter,
1655 const Import<
typename CrsGraphType::local_ordinal_type,
1656 typename CrsGraphType::global_ordinal_type,
1657 typename CrsGraphType::node_type>& domainImporter,
1658 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1659 typename CrsGraphType::global_ordinal_type,
1660 typename CrsGraphType::node_type> >& domainMap,
1661 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1662 typename CrsGraphType::global_ordinal_type,
1663 typename CrsGraphType::node_type> >& rangeMap,
1664 const Teuchos::RCP<Teuchos::ParameterList>& params);
1668 template<
class CrsGraphType>
1669 friend Teuchos::RCP<CrsGraphType>
1670 exportAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1671 const Export<
typename CrsGraphType::local_ordinal_type,
1672 typename CrsGraphType::global_ordinal_type,
1673 typename CrsGraphType::node_type>& exporter,
1674 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1675 typename CrsGraphType::global_ordinal_type,
1676 typename CrsGraphType::node_type> >& domainMap,
1677 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1678 typename CrsGraphType::global_ordinal_type,
1679 typename CrsGraphType::node_type> >& rangeMap,
1680 const Teuchos::RCP<Teuchos::ParameterList>& params);
1683 template<
class CrsGraphType>
1684 friend Teuchos::RCP<CrsGraphType>
1685 exportAndFillCompleteCrsGraph (
const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1686 const Export<
typename CrsGraphType::local_ordinal_type,
1687 typename CrsGraphType::global_ordinal_type,
1688 typename CrsGraphType::node_type>& rowExporter,
1689 const Export<
typename CrsGraphType::local_ordinal_type,
1690 typename CrsGraphType::global_ordinal_type,
1691 typename CrsGraphType::node_type>& domainExporter,
1692 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1693 typename CrsGraphType::global_ordinal_type,
1694 typename CrsGraphType::node_type> >& domainMap,
1695 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
1696 typename CrsGraphType::global_ordinal_type,
1697 typename CrsGraphType::node_type> >& rangeMap,
1698 const Teuchos::RCP<Teuchos::ParameterList>& params);
1700 template<
class LO,
class GO,
class NT>
1703 CrsGraph<LO, GO, NT>& graph,
1704 const Teuchos::ArrayView<
const typename CrsGraph<LO,GO,NT>::packet_type>& imports,
1705 const Teuchos::ArrayView<const size_t>& numPacketsPerLID,
1706 const Teuchos::ArrayView<const LO>& importLIDs,
1707 size_t constantNumPackets,
1708 Distributor & distor,
1728 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1730 const Teuchos::RCP<const map_type>& domainMap,
1731 const Teuchos::RCP<const map_type>& rangeMap,
1732 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
1750 importAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1753 const Teuchos::RCP<const map_type>& domainMap,
1754 const Teuchos::RCP<const map_type>& rangeMap,
1755 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
1774 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1776 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1777 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1778 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
1796 exportAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1799 const Teuchos::RCP<const map_type>& domainMap,
1800 const Teuchos::RCP<const map_type>& rangeMap,
1801 const Teuchos::RCP<Teuchos::ParameterList>& params)
const;
1826 transferAndFillComplete (Teuchos::RCP<CrsGraph<local_ordinal_type, global_ordinal_type, Node> >& destGraph,
1827 const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node>& rowTransfer,
1828 const Teuchos::RCP<const ::Tpetra::Details::Transfer<local_ordinal_type, global_ordinal_type, Node> > & domainTransfer,
1829 const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1830 const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1831 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
const;
1836 struct SLocalGlobalViews {
1837 Teuchos::ArrayView<const global_ordinal_type> ginds;
1838 Teuchos::ArrayView<const local_ordinal_type> linds;
1840 struct SLocalGlobalNCViews {
1841 Teuchos::ArrayView<global_ordinal_type> ginds;
1842 Teuchos::ArrayView<local_ordinal_type> linds;
1845 bool indicesAreAllocated ()
const;
1846 void allocateIndices (
const ELocalGlobal lg);
1860 void makeColMap (Teuchos::Array<int>& remotePIDs);
1890 const bool useRemotePIDs);
1932 const SLocalGlobalViews& newInds,
1933 const ELocalGlobal lg,
1934 const ELocalGlobal I);
1948 const size_t numInputInds);
1962 const size_t numInputInds,
1963 std::function<
void(
const size_t,
const size_t,
const size_t)> fun =
1964 std::function<
void(
const size_t,
const size_t,
const size_t)>());
1968 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
1969 std::function<
void(
const size_t,
const size_t,
const size_t)> fun =
1970 std::function<
void(
const size_t,
const size_t,
const size_t)>());
1989 const Teuchos::ArrayView<const local_ordinal_type>& indices,
1990 std::function<
void(
const size_t,
const size_t,
const size_t)> fun)
const;
1993 findGlobalIndices(
const RowInfo& rowInfo,
1994 const Teuchos::ArrayView<const global_ordinal_type>& indices,
1995 std::function<
void(
const size_t,
const size_t,
const size_t)> fun)
const;
2034 #ifdef KOKKOS_ENABLE_SERIAL
2035 ! std::is_same<execution_space, Kokkos::Serial>::value;
2038 #endif // KOKKOS_ENABLE_SERIAL
2060 sortAndMergeAllIndices (
const bool sorted,
const bool merged);
2089 const Teuchos::RCP<const map_type>& rangeMap);
2091 void staticAssertions()
const;
2092 void clearGlobalConstants();
2186 Teuchos::ArrayView<const local_ordinal_type>
2192 Teuchos::ArrayView<local_ordinal_type>
2209 const RowInfo& rowInfo)
const;
2219 Kokkos::View<const local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2220 getLocalKokkosRowView (
const RowInfo& rowInfo)
const;
2228 Kokkos::View<local_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2229 getLocalKokkosRowViewNonConst (
const RowInfo& rowInfo);
2237 Kokkos::View<const global_ordinal_type*, execution_space, Kokkos::MemoryUnmanaged>
2238 getGlobalKokkosRowView (
const RowInfo& rowInfo)
const;
2245 Teuchos::ArrayView<const global_ordinal_type>
2251 Teuchos::ArrayView<global_ordinal_type>
2269 const RowInfo& rowInfo)
const;
2288 void fillLocalGraph (
const Teuchos::RCP<Teuchos::ParameterList>& params);
2382 typename Kokkos::View<const size_t*, execution_space>::HostMirror
2471 Teuchos::ArrayRCP<Teuchos::Array<local_ordinal_type> >
lclInds2D_;
2484 Teuchos::ArrayRCP<Teuchos::Array<global_ordinal_type> >
gblInds2D_;
2526 bool indicesAreAllocated_;
2527 bool indicesAreLocal_;
2528 bool indicesAreGlobal_;
2545 typedef typename std::map<global_ordinal_type, std::vector<global_ordinal_type> > nonlocals_type;
2574 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
2575 Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2577 size_t maxNumEntriesPerRow = 0,
2578 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2582 return rcp (
new graph_type (map, maxNumEntriesPerRow, DynamicProfile, params));
2633 template<
class CrsGraphType>
2634 Teuchos::RCP<CrsGraphType>
2636 const Import<
typename CrsGraphType::local_ordinal_type,
2637 typename CrsGraphType::global_ordinal_type,
2638 typename CrsGraphType::node_type>& importer,
2639 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2640 typename CrsGraphType::global_ordinal_type,
2641 typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2642 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2643 typename CrsGraphType::global_ordinal_type,
2644 typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2645 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2647 Teuchos::RCP<CrsGraphType> destGraph;
2648 sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2702 template<
class CrsGraphType>
2703 Teuchos::RCP<CrsGraphType>
2705 const Import<
typename CrsGraphType::local_ordinal_type,
2706 typename CrsGraphType::global_ordinal_type,
2707 typename CrsGraphType::node_type>& rowImporter,
2708 const Import<
typename CrsGraphType::local_ordinal_type,
2709 typename CrsGraphType::global_ordinal_type,
2710 typename CrsGraphType::node_type>& domainImporter,
2711 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2712 typename CrsGraphType::global_ordinal_type,
2713 typename CrsGraphType::node_type> >& domainMap,
2714 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2715 typename CrsGraphType::global_ordinal_type,
2716 typename CrsGraphType::node_type> >& rangeMap,
2717 const Teuchos::RCP<Teuchos::ParameterList>& params)
2719 Teuchos::RCP<CrsGraphType> destGraph;
2720 sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2757 template<
class CrsGraphType>
2758 Teuchos::RCP<CrsGraphType>
2760 const Export<
typename CrsGraphType::local_ordinal_type,
2761 typename CrsGraphType::global_ordinal_type,
2762 typename CrsGraphType::node_type>& exporter,
2763 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2764 typename CrsGraphType::global_ordinal_type,
2765 typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2766 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2767 typename CrsGraphType::global_ordinal_type,
2768 typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2769 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2771 Teuchos::RCP<CrsGraphType> destGraph;
2772 sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2809 template<
class CrsGraphType>
2810 Teuchos::RCP<CrsGraphType>
2812 const Export<
typename CrsGraphType::local_ordinal_type,
2813 typename CrsGraphType::global_ordinal_type,
2814 typename CrsGraphType::node_type>& rowExporter,
2815 const Export<
typename CrsGraphType::local_ordinal_type,
2816 typename CrsGraphType::global_ordinal_type,
2817 typename CrsGraphType::node_type>& domainExporter,
2818 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2819 typename CrsGraphType::global_ordinal_type,
2820 typename CrsGraphType::node_type> >& domainMap,
2821 const Teuchos::RCP<
const Map<
typename CrsGraphType::local_ordinal_type,
2822 typename CrsGraphType::global_ordinal_type,
2823 typename CrsGraphType::node_type> >& rangeMap,
2824 const Teuchos::RCP<Teuchos::ParameterList>& params)
2826 Teuchos::RCP<CrsGraphType> destGraph;
2827 sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
2831 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
2833 template<
class LocalOrdinal,
2834 class GlobalOrdinal,
2835 class OutputNodeType,
2836 class InputNodeType>
2837 class CrsGraphCopier<CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType>,
2838 CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> > {
2840 typedef CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> input_crs_graph_type;
2841 typedef CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType> output_crs_graph_type;
2843 static Teuchos::RCP<output_crs_graph_type> TPETRA_DEPRECATED
2844 clone (
const input_crs_graph_type& graphIn,
2845 const Teuchos::RCP<OutputNodeType> &nodeOut,
2846 const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2848 using Teuchos::arcp;
2849 using Teuchos::Array;
2850 using Teuchos::ArrayRCP;
2851 using Teuchos::ArrayView;
2852 using Teuchos::null;
2853 using Teuchos::outArg;
2854 using Teuchos::ParameterList;
2855 using Teuchos::parameterList;
2858 using Teuchos::REDUCE_MIN;
2859 using Teuchos::reduceAll;
2860 using Teuchos::sublist;
2863 typedef LocalOrdinal LO;
2864 typedef GlobalOrdinal GO;
2865 typedef typename ArrayView<const GO>::size_type size_type;
2866 typedef ::Tpetra::Map<LO, GO, InputNodeType> input_map_type;
2867 typedef ::Tpetra::Map<LO, GO, OutputNodeType> output_map_type;
2868 const char prefix[] =
"Tpetra::Details::CrsGraphCopier::clone: ";
2872 bool fillCompleteClone =
true;
2873 bool useLocalIndices = graphIn.hasColMap ();
2876 if (! params.is_null ()) {
2877 fillCompleteClone = params->get (
"fillComplete clone", fillCompleteClone);
2878 useLocalIndices = params->get (
"Locally indexed clone", useLocalIndices);
2879 if (params->get (
"Static profile clone",
true) ==
false) {
2880 pftype = DynamicProfile;
2882 debug = params->get (
"Debug", debug);
2885 const Teuchos::Comm<int>& comm = * (graphIn.getRowMap ()->getComm ());
2886 const int myRank = comm.getRank ();
2888 TEUCHOS_TEST_FOR_EXCEPTION
2889 (! graphIn.hasColMap () && useLocalIndices, std::runtime_error,
2890 prefix <<
"You asked clone() to use local indices (by setting the "
2891 "\"Locally indexed clone\" parameter to true), but the source graph "
2892 "does not yet have a column Map, so this is impossible.");
2895 std::ostringstream os;
2896 os <<
"Process " << myRank <<
": Cloning row Map" << endl;
2900 RCP<const output_map_type> clonedRowMap =
2901 graphIn.getRowMap ()->template clone<OutputNodeType> (nodeOut);
2905 RCP<output_crs_graph_type> clonedGraph;
2907 ArrayRCP<const size_t> numEntriesPerRow;
2908 size_t numEntriesForAll = 0;
2909 bool boundSameForAllLocalRows =
true;
2912 std::ostringstream os;
2913 os <<
"Process " << myRank <<
": Getting per-row bounds" << endl;
2916 graphIn.getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
2918 boundSameForAllLocalRows);
2920 std::ostringstream os;
2921 os <<
"Process " << myRank <<
": numEntriesForAll = "
2922 << numEntriesForAll << endl;
2927 std::ostringstream os;
2928 os <<
"Process " << myRank <<
": graphIn.getNodeMaxNumRowEntries() = "
2929 << graphIn.getNodeMaxNumRowEntries () << endl;
2933 RCP<ParameterList> graphparams;
2934 if (params.is_null ()) {
2935 graphparams = parameterList (
"CrsGraph");
2937 graphparams = sublist (params,
"CrsGraph");
2939 if (useLocalIndices) {
2940 RCP<const output_map_type> clonedColMap =
2941 graphIn.getColMap ()->template clone<OutputNodeType> (nodeOut);
2942 if (boundSameForAllLocalRows) {
2943 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap, clonedColMap,
2944 numEntriesForAll, pftype,
2947 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap, clonedColMap,
2948 numEntriesPerRow (), pftype,
2952 if (boundSameForAllLocalRows) {
2953 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap,
2954 numEntriesForAll, pftype,
2957 clonedGraph = rcp (
new output_crs_graph_type (clonedRowMap,
2958 numEntriesPerRow (),
2959 pftype, graphparams));
2964 std::ostringstream os;
2965 os <<
"Process " << myRank <<
": Invoked output graph's constructor" << endl;
2970 numEntriesPerRow = null;
2971 numEntriesForAll = 0;
2974 const input_map_type& inputRowMap = * (graphIn.getRowMap ());
2975 const size_type numRows =
2976 static_cast<size_type
> (inputRowMap.getNodeNumElements ());
2978 bool failed =
false;
2980 if (useLocalIndices) {
2981 const LO localMinLID = inputRowMap.getMinLocalIndex ();
2982 const LO localMaxLID = inputRowMap.getMaxLocalIndex ();
2984 if (graphIn.isLocallyIndexed ()) {
2987 ArrayView<const LO> linds;
2988 for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2989 graphIn.getLocalRowView (lrow, linds);
2990 if (linds.size () != 0) {
2991 clonedGraph->insertLocalIndices (lrow, linds);
2995 catch (std::exception& e) {
2996 std::ostringstream os;
2997 os <<
"Process " << myRank <<
": copying (reading local by view, "
2998 "writing local) indices into the output graph threw an "
2999 "exception: " << e.what () << endl;
3006 TEUCHOS_TEST_FOR_EXCEPTION(
3007 ! graphIn.hasColMap () && useLocalIndices, std::invalid_argument,
3008 prefix <<
"You asked clone() to use local indices (by setting the "
3009 "\"Locally indexed clone\" parameter to true), but the source graph "
3010 "does not yet have a column Map, so this is impossible.");
3025 size_t myMaxNumRowEntries =
3026 graphIn.isFillActive () ?
static_cast<size_t> (0) :
3027 graphIn.getNodeMaxNumRowEntries ();
3029 Array<LO> linds (myMaxNumRowEntries);
3032 for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
3033 size_t theNumEntries = graphIn.getNumEntriesInLocalRow (lrow);
3034 if (theNumEntries > myMaxNumRowEntries) {
3035 myMaxNumRowEntries = theNumEntries;
3036 linds.resize (myMaxNumRowEntries);
3038 graphIn.getLocalRowCopy (lrow, linds (), theNumEntries);
3039 if (theNumEntries != 0) {
3040 clonedGraph->insertLocalIndices (lrow, linds (0, theNumEntries));
3044 catch (std::exception& e) {
3045 std::ostringstream os;
3046 os <<
"Process " << myRank <<
": copying (reading local by copy, "
3047 "writing local) indices into the output graph threw an exception: "
3048 << e.what () << endl;
3056 const GlobalOrdinal localMinGID = inputRowMap.getMinGlobalIndex ();
3057 const GlobalOrdinal localMaxGID = inputRowMap.getMaxGlobalIndex ();
3058 const bool inputRowMapIsContiguous = inputRowMap.isContiguous ();
3060 if (graphIn.isGloballyIndexed ()) {
3061 ArrayView<const GlobalOrdinal> ginds;
3063 if (inputRowMapIsContiguous) {
3065 for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
3066 graphIn.getGlobalRowView (grow, ginds);
3067 if (ginds.size () != 0) {
3068 clonedGraph->insertGlobalIndices (grow, ginds);
3072 catch (std::exception& e) {
3073 std::ostringstream os;
3074 os <<
"Process " << myRank <<
": copying (reading global by view, "
3075 "writing global) indices into the output graph threw an "
3076 "exception: " << e.what () << endl;
3083 ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
3084 for (size_type k = 0; k < numRows; ++k) {
3085 const GO grow = inputRowMapGIDs[k];
3086 graphIn.getGlobalRowView (grow, ginds);
3087 if (ginds.size () != 0) {
3088 clonedGraph->insertGlobalIndices (grow, ginds);
3092 catch (std::exception& e) {
3093 std::ostringstream os;
3094 os <<
"Process " << myRank <<
": copying (reading global by view, "
3095 "writing global) indices into the output graph threw an "
3096 "exception: " << e.what () << endl;
3109 size_t myMaxNumRowEntries =
3110 graphIn.isFillActive () ?
static_cast<size_t> (0) :
3111 graphIn.getNodeMaxNumRowEntries ();
3113 Array<GO> ginds (myMaxNumRowEntries);
3115 if (inputRowMapIsContiguous) {
3117 for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
3118 size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
3119 if (theNumEntries > myMaxNumRowEntries) {
3120 myMaxNumRowEntries = theNumEntries;
3121 ginds.resize (myMaxNumRowEntries);
3123 graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
3124 if (theNumEntries != 0) {
3125 clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
3129 catch (std::exception& e) {
3130 std::ostringstream os;
3131 os <<
"Process " << myRank <<
": copying (reading global by copy, "
3132 "writing global) indices into the output graph threw an "
3133 "exception: " << e.what () << endl;
3140 ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
3141 for (size_type k = 0; k < numRows; ++k) {
3142 const GO grow = inputRowMapGIDs[k];
3144 size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
3145 if (theNumEntries > myMaxNumRowEntries) {
3146 myMaxNumRowEntries = theNumEntries;
3147 ginds.resize (myMaxNumRowEntries);
3149 graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
3150 if (theNumEntries != 0) {
3151 clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
3155 catch (std::exception& e) {
3156 std::ostringstream os;
3157 os <<
"Process " << myRank <<
": copying (reading global by copy, "
3158 "writing global) indices into the output graph threw an "
3159 "exception: " << e.what () << endl;
3169 std::ostringstream os;
3170 os <<
"Process " << myRank <<
": copied entries" << endl;
3174 if (fillCompleteClone) {
3175 RCP<ParameterList> fillparams = params.is_null () ?
3176 parameterList (
"fillComplete") :
3177 sublist (params,
"fillComplete");
3179 RCP<const output_map_type> clonedRangeMap;
3180 RCP<const output_map_type> clonedDomainMap;
3181 if (! graphIn.getRangeMap ().is_null () &&
3182 graphIn.getRangeMap () != graphIn.getRowMap ()) {
3184 graphIn.getRangeMap ()->template clone<OutputNodeType> (nodeOut);
3187 clonedRangeMap = clonedRowMap;
3189 if (! graphIn.getDomainMap ().is_null ()
3190 && graphIn.getDomainMap () != graphIn.getRowMap ()) {
3192 graphIn.getDomainMap ()->template clone<OutputNodeType> (nodeOut);
3195 clonedDomainMap = clonedRowMap;
3199 std::ostringstream os;
3200 os <<
"Process " << myRank <<
": About to call fillComplete on "
3201 "cloned graph" << endl;
3204 clonedGraph->fillComplete (clonedDomainMap, clonedRangeMap, fillparams);
3206 catch (std::exception &e) {
3208 std::ostringstream os;
3209 os << prefix <<
"Process " << myRank <<
": Caught the following "
3210 "exception while calling fillComplete() on clone of type"
3211 << endl << Teuchos::typeName (*clonedGraph) << endl;
3216 int lclSuccess = failed ? 0 : 1;
3218 reduceAll<int, int> (comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
3219 TEUCHOS_TEST_FOR_EXCEPTION
3220 (gblSuccess != 1, std::logic_error,
3221 prefix <<
"Clone failed on at least one process.");
3224 std::ostringstream os;
3225 os <<
"Process " << myRank <<
": Done with CrsGraph::clone" << endl;
3232 #endif // TPETRA_ENABLE_DEPRECATED_CODE
3236 #endif // TPETRA_CRSGRAPH_DECL_HPP
Teuchos::ArrayRCP< Teuchos::Array< local_ordinal_type > > lclInds2D_
Local column indices for all rows.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
void setDomainRangeMaps(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap)
Teuchos::RCP< const map_type > getRowMap() const override
Returns the Map that describes the row distribution in this graph.
void setAllIndices(const typename local_graph_type::row_map_type &rowPointers, const typename local_graph_type::entries_type::non_const_type &columnIndices)
Set the graph's data directly, using 1-D storage.
size_t nodeMaxNumRowEntries_
Local maximum of the number of entries in each row.
bool indicesAreSorted_
Whether the graph's indices are sorted in each row, on this process.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
::Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization used by this class.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
Teuchos::RCP< const map_type > rangeMap_
The Map describing the range of the (matrix corresponding to the) graph.
Teuchos::RCP< const map_type > getColMap() const override
Returns the Map that describes the column distribution in this graph.
GO global_ordinal_type
The type of the graph's global indices.
An abstract interface for graphs accessed by rows.
size_t getNodeMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, on this process.
void insertGlobalIndicesFiltered(const local_ordinal_type lclRow, const global_ordinal_type gblColInds[], const local_ordinal_type numGblColInds)
Like insertGlobalIndices(), but with column Map filtering.
bool lowerTriangular_
Whether the graph is locally lower triangular.
size_t nodeNumDiags_
Local number of (populated) diagonal entries.
bool sortGhostsAssociatedWithEachProcessor_
Whether to require makeColMap() (and therefore fillComplete()) to order column Map GIDs associated wi...
size_t insertGlobalIndicesImpl(const local_ordinal_type lclRow, const global_ordinal_type inputGblColInds[], const size_t numInputInds)
Insert global indices, using an input local row index.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Resume fill operations.
bool haveGlobalConstants_
Whether all processes have computed global constants.
void expertStaticFillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const import_type > &importer=Teuchos::null, const Teuchos::RCP< const export_type > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Perform a fillComplete on a graph that already has data, via setAllIndices().
Teuchos::RCP< const import_type > getImporter() const override
Returns the importer associated with this graph.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the graph.
Kokkos::View< global_ordinal_type *, execution_space > t_GlobalOrdinal_1D
Type of the k_gblInds1D_ array of global column indices.
t_GlobalOrdinal_1D k_gblInds1D_
Global column indices for all rows.
void insertGlobalIndices(const global_ordinal_type globalRow, const Teuchos::ArrayView< const global_ordinal_type > &indices)
Insert global indices into the graph.
size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const override
Get the number of entries in the given row (local index).
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
bool isIdenticalTo(const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > &graph) const
Create a cloned CrsGraph for a different Node type.
bool isMerged() const
Whether duplicate column indices in each row have been merged.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
Forward declaration of Tpetra::BlockCrsMatrix.
global_size_t globalNumDiags_
Global number of (populated) diagonal entries.
Teuchos::RCP< const map_type > getDomainMap() const override
Returns the Map associated with the domain of this graph.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, over all processes in the graph's communicator...
void getLocalRowView(const local_ordinal_type lclRow, Teuchos::ArrayView< const local_ordinal_type > &lclColInds) const override
Get a const, non-persisting view of the given local row's local column indices, as a Teuchos::ArrayVi...
virtual ~CrsGraph()=default
Destructor (virtual for memory safety of derived classes).
bool noRedundancies_
Whether the graph's indices are non-redundant (merged) in each row, on this process.
bool upperTriangular_
Whether the graph is locally upper triangular.
Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > createCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember function to create an empty CrsGraph given a row Map and the max number of entries allowed ...
size_t findLocalIndices(const RowInfo &rowInfo, const Teuchos::ArrayView< const local_ordinal_type > &indices, std::function< void(const size_t, const size_t, const size_t)> fun) const
Finds indices in the given row.
size_t getNumAllocatedEntriesInGlobalRow(global_ordinal_type globalRow) const
Current number of allocated entries in the given row on the calling (MPI) process, using a global row index.
std::pair< size_t, std::string > makeIndicesLocal()
Convert column indices from global to local.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
bool hasColMap() const override
Whether the graph has a column Map.
bool isGloballyIndexed() const override
Whether the graph's column indices are stored as global indices.
void exportAndFillComplete(Teuchos::RCP< CrsGraph< local_ordinal_type, global_ordinal_type, Node > > &destGraph, const export_type &exporter, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Export from this to the given destination graph, and make the result fill complete.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
bool isStorageOptimized() const
Returns true if storage has been optimized.
bool haveLocalConstants_
Whether this process has computed local constants.
::Tpetra::Details::EStorageStatus storageStatus_
Status of the graph's storage, when not in a fill-complete state.
std::string description() const override
Return a one-line human-readable description of this object.
local_ordinal_type getLocalViewRawConst(const local_ordinal_type *&lclInds, local_ordinal_type &capacity, const RowInfo &rowInfo) const
Get a pointer to the local column indices of a locally owned row, using the result of getRowInfo...
void makeColMap(Teuchos::Array< int > &remotePIDs)
Make and set the graph's column Map.
Teuchos::RCP< const export_type > getExporter() const override
Returns the exporter associated with this graph.
void getNumEntriesPerLocalRowUpperBound(Teuchos::ArrayRCP< const size_t > &boundPerLocalRow, size_t &boundForAllLocalRows, bool &boundSameForAllLocalRows) const
Get an upper bound on the number of entries that can be stored in each row.
size_t global_size_t
Global size_t object.
size_t getNodeNumEntries() const override
The local number of entries in the graph.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
node_type node_type
This class' Kokkos Node type.
void reindexColumns(const Teuchos::RCP< const map_type > &newColMap, const Teuchos::RCP< const import_type > &newImport=Teuchos::null, const bool sortIndicesInEachRow=true)
Reindex the column indices in place, and replace the column Map. Optionally, replace the Import objec...
Teuchos::RCP< CrsGraphType > importAndFillCompleteCrsGraph(const Teuchos::RCP< const CrsGraphType > &sourceGraph, const Import< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &importer, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsGraph constructor that fuses Import and fillComplete().
void makeImportExport(Teuchos::Array< int > &remotePIDs, const bool useRemotePIDs)
Make the Import and Export objects, if needed.
size_t sortAndMergeRowIndices(const RowInfo &rowInfo, const bool sorted, const bool merged)
Sort and merge duplicate column indices in the given row.
void insertLocalIndices(const local_ordinal_type localRow, const Teuchos::ArrayView< const local_ordinal_type > &indices)
Insert local indices into the graph.
void getGlobalRowCopy(global_ordinal_type gblRow, const Teuchos::ArrayView< global_ordinal_type > &gblColInds, size_t &numColInds) const override
Get a copy of the given row, using global indices.
bool isSorted() const
Whether graph indices in all rows are known to be sorted.
Teuchos::RCP< const map_type > rowMap_
The Map describing the distribution of rows of the graph.
Teuchos::RCP< const import_type > importer_
The Import from the domain Map to the column Map.
num_row_entries_type k_numRowEntries_
The number of local entries in each locally owned row.
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
global_size_t getGlobalNumRows() const override
Returns the number of global rows in the graph.
Teuchos::ArrayView< const global_ordinal_type > getGlobalView(const RowInfo &rowinfo) const
Get a const, nonowned, globally indexed view of the locally owned row myRow, such that rowinfo = getR...
Kokkos::View< size_t *, Kokkos::LayoutLeft, device_type >::HostMirror num_row_entries_type
The type of k_numRowEntries_ (see below).
void setLocallyModified()
Report that we made a local modification to its structure.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
local_graph_type::entries_type::non_const_type k_lclInds1D_
Local column indices for all rows.
Teuchos::ArrayView< local_ordinal_type > getLocalViewNonConst(const RowInfo &rowinfo)
Get a nonconst, nonowned, locally indexed view of the locally owned row myRow, such that rowinfo = ge...
size_t getNodeNumRows() const override
Returns the number of graph rows owned on the calling node.
ProfileType getProfileType() const
Returns true if the graph was allocated with static data structures.
void checkInternalState() const
Throw an exception if the internal state is not consistent.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
local_graph_type lclGraph_
Local graph; only initialized after first fillComplete() call.
Sets up and executes a communication plan for a Tpetra DistObject.
local_graph_type::row_map_type::const_type k_rowPtrs_
Row offsets for "1-D" storage.
Kokkos::View< const size_t *, execution_space >::HostMirror k_numAllocPerRow_
The maximum number of entries to allow in each locally owned row, per row.
CombineMode
Rule for combining data in an Import or Export.
Teuchos::RCP< const export_type > exporter_
The Export from the row Map to the range Map.
void insertGlobalIndicesIntoNonownedRows(const global_ordinal_type gblRow, const global_ordinal_type gblColInds[], const local_ordinal_type numGblColInds)
Implementation of insertGlobalIndices for nonowned rows.
bool isFillComplete() const override
Whether fillComplete() has been called and the graph is in compute mode.
size_t getNumAllocatedEntriesInLocalRow(local_ordinal_type localRow) const
Current number of allocated entries in the given row on the calling (MPI) process, using a local row index.
void computeLocalConstants(const bool computeLocalTriangularConstants)
Compute local constants, if they have not yet been computed.
Teuchos::ArrayRCP< const size_t > getNodeRowPtrs() const
Get a host view of the row offsets.
void swap(CrsGraph< local_ordinal_type, global_ordinal_type, Node > &graph)
Swaps the data from *this with the data and maps from graph.
void globalAssemble()
Communicate nonlocal contributions to other processes.
CrsGraphType::global_ordinal_type getGlobalNumDiags(const CrsGraphType &G)
Number of populated diagonal entries in the given sparse graph, over all processes in the graph's (MP...
Teuchos::ArrayRCP< Teuchos::Array< global_ordinal_type > > gblInds2D_
Global column indices for all rows.
typename device_type::execution_space execution_space
This class' Kokkos execution space.
RowInfo getRowInfoFromGlobalRowIndex(const global_ordinal_type gblRow) const
Get information about the locally owned row with global index gblRow.
Forward declaration of Tpetra::CrsMatrix.
Abstract base class for objects that can be the source of an Import or Export operation.
void removeLocalIndices(local_ordinal_type localRow)
Remove all graph indices from the specified local row.
size_t getNodeAllocationSize() const
The local number of indices allocated for the graph, over all rows on the calling (MPI) process...
LO local_ordinal_type
The type of the graph's local indices.
global_size_t globalNumEntries_
Global number of entries in the graph.
Teuchos::ArrayView< global_ordinal_type > getGlobalViewNonConst(const RowInfo &rowinfo)
Get a nonconst, nonowned, globally indexed view of the locally owned row myRow, such that rowinfo = g...
ProfileType pftype_
Whether the graph was allocated with static or dynamic profile.
Teuchos::RCP< const map_type > getRangeMap() const override
Returns the Map associated with the domain of this graph.
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the graph's current column Map with the given Map.
void getGlobalRowView(const global_ordinal_type gblRow, Teuchos::ArrayView< const global_ordinal_type > &gblColInds) const override
Get a const, non-persisting view of the given global row's global column indices, as a Teuchos::Array...
global_size_t getGlobalNumCols() const override
Returns the number of global columns in the graph.
RowInfo getRowInfo(const local_ordinal_type myRow) const
Get information about the locally owned row with local index myRow.
size_t getNodeNumCols() const override
Returns the number of columns connected to the locally owned rows of this graph.
void replaceDomainMapAndImporter(const Teuchos::RCP< const map_type > &newDomainMap, const Teuchos::RCP< const import_type > &newImporter)
Replace the current domain Map and Import with the given parameters.
bool supportsRowViews() const override
Whether this class implements getLocalRowView() and getGlobalRowView() (it does). ...
typename dist_object_type::buffer_device_type buffer_device_type
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
void computeGlobalConstants(const bool computeLocalTriangularConstants)
Compute global constants, if they have not yet been computed.
Teuchos::ArrayView< const local_ordinal_type > getLocalView(const RowInfo &rowinfo) const
Get a const, nonowned, locally indexed view of the locally owned row myRow, such that rowinfo = getRo...
local_ordinal_type getGlobalViewRawConst(const global_ordinal_type *&gblInds, local_ordinal_type &capacity, const RowInfo &rowInfo) const
Get a pointer to the global column indices of a locally owned row, using the result of getRowInfoFrom...
CrsGraph & operator=(const CrsGraph< local_ordinal_type, global_ordinal_type, node_type > &)=default
Assignment operator (default).
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > ¶ms) override
Set the given list of parameters (must be nonnull).
size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const override
Returns the current number of entries on this node in the specified global row.
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Tell the graph that you are done changing its structure.
typename node_type::device_type device_type
This class' Kokkos device type.
bool isLocallyIndexed() const override
Whether the graph's column indices are stored as local indices.
::Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization used by this class.
Stand-alone utility functions and macros.
Teuchos::ArrayRCP< const local_ordinal_type > getNodePackedIndices() const
Get an Teuchos::ArrayRCP of the packed column-indices.
void unpackCrsGraphAndCombine(CrsGraph< LO, GO, NT > &sourceGraph, const Teuchos::ArrayView< const typename CrsGraph< LO, GO, NT >::packet_type > &imports, const Teuchos::ArrayView< const size_t > &numPacketsPerLID, const Teuchos::ArrayView< const LO > &importLIDs, size_t constantNumPackets, Distributor &distor, CombineMode combineMode)
Unpack the imported column indices and combine into graph.
bool isFillActive() const
Whether resumeFill() has been called and the graph is in edit mode.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
Returns the communicator.
void importAndFillComplete(Teuchos::RCP< CrsGraph< local_ordinal_type, global_ordinal_type, Node > > &destGraph, const import_type &importer, const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null) const
Import from this to the given destination graph, and make the result fill complete.
global_size_t globalMaxNumRowEntries_
Global maximum of the number of entries in each row.
static const bool useAtomicUpdatesByDefault
Whether transformLocalValues should use atomic updates by default.
local_graph_type getLocalGraph() const
Get the local graph.
size_t insertIndices(RowInfo &rowInfo, const SLocalGlobalViews &newInds, const ELocalGlobal lg, const ELocalGlobal I)
Insert indices into the given row.
global_size_t getGlobalNumEntries() const override
Returns the global number of entries in the graph.
Kokkos::Device< typename device_type::execution_space, buffer_memory_space > buffer_device_type
size_t numAllocForAllRows_
The maximum number of entries to allow in each locally owned row.
Base class for distributed Tpetra objects that support data redistribution.
global_ordinal_type packet_type
Type of each entry of the DistObject communication buffer.
Teuchos::RCP< const map_type > colMap_
The Map describing the distribution of columns of the graph.
global_ordinal_type getIndexBase() const override
Returns the index base for global indices for this graph.
virtual void pack(const Teuchos::ArrayView< const local_ordinal_type > &exportLIDs, Teuchos::Array< global_ordinal_type > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Distributor &distor) const override
Pack this object's data for Import or Export.
void getLocalRowCopy(local_ordinal_type lclRow, const Teuchos::ArrayView< local_ordinal_type > &lclColInds, size_t &numColInds) const override
Get a copy of the given row, using local indices.
EStorageStatus
Status of the graph's or matrix's storage, when not in a fill-complete state.
Forward declaration of Tpetra::CrsGraph.
Teuchos::RCP< CrsGraphType > exportAndFillCompleteCrsGraph(const Teuchos::RCP< const CrsGraphType > &sourceGraph, const Export< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > &exporter, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &domainMap=Teuchos::null, const Teuchos::RCP< const Map< typename CrsGraphType::local_ordinal_type, typename CrsGraphType::global_ordinal_type, typename CrsGraphType::node_type > > &rangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember CrsGraph constructor that fuses Export and fillComplete().
nonlocals_type nonlocals_
Nonlocal data given to insertGlobalIndices.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Print this object to the given output stream with the given verbosity level.