Tpetra parallel linear algebra  Version of the Day
Tpetra_CrsGraph_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Tpetra: Templated Linear Algebra Services Package
5 // Copyright (2008) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 
42 #ifndef TPETRA_CRSGRAPH_DECL_HPP
43 #define TPETRA_CRSGRAPH_DECL_HPP
44 
52 
53 #include "Tpetra_CrsGraph_fwd.hpp"
54 #include "Tpetra_CrsMatrix_fwd.hpp"
56 #include "Tpetra_DistObject.hpp"
57 #include "Tpetra_Exceptions.hpp"
58 #include "Tpetra_RowGraph.hpp"
59 #include "Tpetra_Util.hpp" // need this here for sort2
60 
61 #include "KokkosSparse_findRelOffset.hpp"
62 #include "Kokkos_DualView.hpp"
63 #include "Kokkos_StaticCrsGraph.hpp"
64 
65 #include "Teuchos_CommHelpers.hpp"
66 #include "Teuchos_Describable.hpp"
67 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
68 
69 #include <functional> // std::function
70 
71 namespace Tpetra {
72 
73 #ifndef DOXYGEN_SHOULD_SKIP_THIS
74  namespace Details {
75  // Forward declaration of an implementation detail of CrsGraph::clone.
76  template<class OutputCrsGraphType, class InputCrsGraphType>
77  class CrsGraphCopier {
78  public:
79  static Teuchos::RCP<OutputCrsGraphType>
80  clone (const InputCrsGraphType& graphIn,
81  const Teuchos::RCP<typename OutputCrsGraphType::node_type> nodeOut,
82  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
83  };
84  } // namespace Details
85 
86  namespace { // (anonymous)
87 
88  template<class ViewType>
89  struct UnmanagedView {
90  static_assert (Kokkos::is_view<ViewType>::value,
91  "ViewType must be a Kokkos::View specialization.");
92  // FIXME (mfh 02 Dec 2015) Right now, this strips away other
93  // memory traits. Christian will add an "AllTraits" enum which is
94  // the enum value of MemoryTraits<T>, that will help us fix this.
95  typedef Kokkos::View<typename ViewType::data_type,
96  typename ViewType::array_layout,
97  typename ViewType::device_type,
98  Kokkos::MemoryUnmanaged> type;
99  };
100 
101  } // namespace (anonymous)
102 #endif // DOXYGEN_SHOULD_SKIP_THIS
103 
112  struct RowInfo {
113  size_t localRow;
114  size_t allocSize;
115  size_t numEntries;
116  size_t offset1D;
117  };
118 
119  enum ELocalGlobal {
120  LocalIndices,
121  GlobalIndices
122  };
123 
124  namespace Details {
165  STORAGE_2D, //<! 2-D storage
166  STORAGE_1D_UNPACKED, //<! 1-D "unpacked" storage
167  STORAGE_1D_PACKED, //<! 1-D "packed" storage
168  STORAGE_UB //<! Invalid value; upper bound on enum values
169  };
170 
171 
181  public:
183  virtual bool isLowerTriangularImpl () const = 0;
184  virtual bool isUpperTriangularImpl () const = 0;
185  virtual size_t getGlobalNumDiagsImpl () const = 0;
186  virtual global_size_t getNodeNumDiagsImpl () const = 0;
187  };
188  } // namespace Details
189 
196 namespace Classes {
197 
256  template <class LocalOrdinal = ::Tpetra::Details::DefaultTypes::local_ordinal_type,
257  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
259  class CrsGraph :
260  public RowGraph<LocalOrdinal, GlobalOrdinal, Node>,
261  public DistObject<GlobalOrdinal,
262  LocalOrdinal,
263  GlobalOrdinal,
264  Node>,
265  public Teuchos::ParameterListAcceptorDefaultBase,
267  {
268  template <class S, class LO, class GO, class N>
269  friend class CrsMatrix;
270  template <class LO2, class GO2, class N2>
271  friend class CrsGraph;
272 
275 
276  public:
278  typedef LocalOrdinal local_ordinal_type;
280  typedef GlobalOrdinal global_ordinal_type;
282  typedef Node node_type;
283 
285  typedef typename Node::device_type device_type;
287  typedef typename device_type::execution_space execution_space;
288 
290  typedef Kokkos::StaticCrsGraph<LocalOrdinal,
291  Kokkos::LayoutLeft,
294  typedef local_graph_type LocalStaticCrsGraphType TPETRA_DEPRECATED;
295 
297  typedef typename local_graph_type::row_map_type t_RowPtrs TPETRA_DEPRECATED;
299  typedef typename local_graph_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED;
301  typedef typename local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED;
302 
309 
311 
312 
331  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
332  size_t maxNumEntriesPerRow,
333  ProfileType pftype = DynamicProfile,
334  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
335 
353  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
354  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
355  const ProfileType pftype = DynamicProfile,
356  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
357 
376  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
377  const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
378  const ProfileType pftype = DynamicProfile,
379  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
380 
402  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
403  const Teuchos::RCP<const map_type>& colMap,
404  const size_t maxNumEntriesPerRow,
405  const ProfileType pftype = DynamicProfile,
406  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
407 
426  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
427  const Teuchos::RCP<const map_type>& colMap,
428  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
429  ProfileType pftype = DynamicProfile,
430  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
431 
451  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
452  const Teuchos::RCP<const map_type>& colMap,
453  const Teuchos::ArrayRCP<const size_t>& numEntPerRow,
454  ProfileType pftype = DynamicProfile,
455  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
456 
476  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
477  const Teuchos::RCP<const map_type>& colMap,
478  const typename local_graph_type::row_map_type& rowPointers,
479  const typename local_graph_type::entries_type::non_const_type& columnIndices,
480  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
481 
501  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
502  const Teuchos::RCP<const map_type>& colMap,
503  const Teuchos::ArrayRCP<size_t> & rowPointers,
504  const Teuchos::ArrayRCP<LocalOrdinal> & columnIndices,
505  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
506 
525  CrsGraph (const Teuchos::RCP<const map_type>& rowMap,
526  const Teuchos::RCP<const map_type>& colMap,
527  const local_graph_type& lclGraph,
528  const Teuchos::RCP<Teuchos::ParameterList>& params);
529 
554  CrsGraph (const local_graph_type& lclGraph,
555  const Teuchos::RCP<const map_type>& rowMap,
556  const Teuchos::RCP<const map_type>& colMap,
557  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
558  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
559  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
560 
588  template<class Node2>
589  Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node2> >
590  clone (const Teuchos::RCP<Node2>& node2,
591  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const
592  {
593  typedef CrsGraph<LocalOrdinal, GlobalOrdinal, Node2> output_crs_graph_type;
594  typedef CrsGraph<LocalOrdinal, GlobalOrdinal, Node> input_crs_graph_type;
595  typedef ::Tpetra::Details::CrsGraphCopier<output_crs_graph_type, input_crs_graph_type> copier_type;
596  return copier_type::clone (*this, node2, params);
597  }
598 
600  virtual ~CrsGraph ();
601 
603 
605 
607  void
608  setParameterList (const Teuchos::RCP<Teuchos::ParameterList>& params) override;
609 
611  Teuchos::RCP<const Teuchos::ParameterList>
612  getValidParameters () const override;
613 
615 
617 
639  void
640  insertGlobalIndices (const GlobalOrdinal globalRow,
641  const Teuchos::ArrayView<const GlobalOrdinal>& indices);
642 
649  void
650  insertGlobalIndices (const GlobalOrdinal globalRow,
651  const LocalOrdinal numEnt,
652  const GlobalOrdinal inds[]);
653 
655 
669  void
670  insertLocalIndices (const LocalOrdinal localRow,
671  const Teuchos::ArrayView<const LocalOrdinal> &indices);
672 
679  void
680  insertLocalIndices (const LocalOrdinal localRow,
681  const LocalOrdinal numEnt,
682  const LocalOrdinal inds[]);
683 
685 
694  void removeLocalIndices (LocalOrdinal localRow);
695 
697 
699 
707  void globalAssemble ();
708 
727  void resumeFill (const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
728 
766  void
767  fillComplete (const Teuchos::RCP<const map_type> &domainMap,
768  const Teuchos::RCP<const map_type> &rangeMap,
769  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
770 
798  void
799  fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
800 
829  void
830  expertStaticFillComplete (const Teuchos::RCP<const map_type> & domainMap,
831  const Teuchos::RCP<const map_type> & rangeMap,
832  const Teuchos::RCP<const import_type> &importer=Teuchos::null,
833  const Teuchos::RCP<const export_type> &exporter=Teuchos::null,
834  const Teuchos::RCP<Teuchos::ParameterList> &params=Teuchos::null);
836 
838 
840  Teuchos::RCP<const Teuchos::Comm<int> > getComm() const override;
841 
843  Teuchos::RCP<node_type> getNode() const override;
844 
846  Teuchos::RCP<const map_type> getRowMap () const override;
847 
849  Teuchos::RCP<const map_type> getColMap () const override;
850 
852  Teuchos::RCP<const map_type> getDomainMap () const override;
853 
855  Teuchos::RCP<const map_type> getRangeMap () const override;
856 
858  Teuchos::RCP<const import_type> getImporter () const override;
859 
861  Teuchos::RCP<const export_type> getExporter () const override;
862 
864 
866  global_size_t getGlobalNumRows() const override;
867 
869 
872  global_size_t getGlobalNumCols() const override;
873 
875  size_t getNodeNumRows() const override;
876 
878 
880  size_t getNodeNumCols() const override;
881 
883  GlobalOrdinal getIndexBase() const override;
884 
886 
888  global_size_t getGlobalNumEntries() const override;
889 
899  size_t getNodeNumEntries() const override;
900 
902 
903  size_t
904  getNumEntriesInGlobalRow (GlobalOrdinal globalRow) const override;
905 
912  size_t
913  getNumEntriesInLocalRow (LocalOrdinal localRow) const override;
914 
934  size_t getNodeAllocationSize () const;
935 
943  size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const;
944 
952  size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const;
953 
962 
974  global_size_t getGlobalNumDiagsImpl () const override;
975 
982  size_t TPETRA_DEPRECATED getNodeNumDiags() const override;
983 
995  size_t getNodeNumDiagsImpl () const override;
996 
1010  size_t getGlobalMaxNumRowEntries () const override;
1011 
1016  size_t getNodeMaxNumRowEntries () const override;
1017 
1033  bool hasColMap () const override;
1034 
1046  bool isLowerTriangularImpl () const override;
1047 
1058  bool TPETRA_DEPRECATED isLowerTriangular () const override;
1059 
1071  bool isUpperTriangularImpl () const override;
1072 
1083  bool TPETRA_DEPRECATED isUpperTriangular () const override;
1084 
1086  bool isLocallyIndexed() const override;
1087 
1089  bool isGloballyIndexed() const override;
1090 
1092  bool isFillComplete() const override;
1093 
1095  bool isFillActive() const;
1096 
1104  bool isSorted() const;
1105 
1107 
1113  bool isStorageOptimized() const;
1114 
1116  ProfileType getProfileType() const;
1117 
1123  void
1124  getGlobalRowCopy (GlobalOrdinal GlobalRow,
1125  const Teuchos::ArrayView<GlobalOrdinal>& Indices,
1126  size_t& NumIndices) const override;
1127 
1135  void
1136  getLocalRowCopy (LocalOrdinal LocalRow,
1137  const Teuchos::ArrayView<LocalOrdinal>& indices,
1138  size_t& NumIndices) const override;
1139 
1150  void
1151  getGlobalRowView (const GlobalOrdinal gblRow,
1152  Teuchos::ArrayView<const GlobalOrdinal>& gblColInds) const override;
1153 
1156  bool supportsRowViews () const override;
1157 
1168  void
1169  getLocalRowView (const LocalOrdinal lclRow,
1170  Teuchos::ArrayView<const LocalOrdinal>& lclColInds) const override;
1171 
1173 
1175 
1177  std::string description () const override;
1178 
1181  void
1182  describe (Teuchos::FancyOStream& out,
1183  const Teuchos::EVerbosityLevel verbLevel =
1184  Teuchos::Describable::verbLevel_default) const override;
1185 
1187 
1189 
1190  virtual bool
1191  checkSizes (const SrcDistObject& source) override;
1192 
1193  virtual void
1194  copyAndPermute (const SrcDistObject& source,
1195  size_t numSameIDs,
1196  const Teuchos::ArrayView<const LocalOrdinal> &permuteToLIDs,
1197  const Teuchos::ArrayView<const LocalOrdinal> &permuteFromLIDs) override;
1198 
1199  virtual void
1200  packAndPrepare (const SrcDistObject& source,
1201  const Teuchos::ArrayView<const LocalOrdinal> &exportLIDs,
1202  Teuchos::Array<GlobalOrdinal> &exports,
1203  const Teuchos::ArrayView<size_t> & numPacketsPerLID,
1204  size_t& constantNumPackets,
1205  Distributor &distor) override;
1206 
1207  virtual void
1208  pack (const Teuchos::ArrayView<const LocalOrdinal>& exportLIDs,
1209  Teuchos::Array<GlobalOrdinal>& exports,
1210  const Teuchos::ArrayView<size_t>& numPacketsPerLID,
1211  size_t& constantNumPackets,
1212  Distributor& distor) const override;
1213 
1214  virtual void
1215  unpackAndCombine (const Teuchos::ArrayView<const LocalOrdinal> &importLIDs,
1216  const Teuchos::ArrayView<const GlobalOrdinal> &imports,
1217  const Teuchos::ArrayView<size_t> &numPacketsPerLID,
1218  size_t constantNumPackets,
1219  Distributor &distor,
1220  CombineMode CM) override;
1222 
1224 
1267  void
1268  getLocalDiagOffsets (const Kokkos::View<size_t*, device_type, Kokkos::MemoryUnmanaged>& offsets) const;
1269 
1279  void
1280  getLocalDiagOffsets (Teuchos::ArrayRCP<size_t>& offsets) const;
1281 
1304  void
1305  getNumEntriesPerLocalRowUpperBound (Teuchos::ArrayRCP<const size_t>& boundPerLocalRow,
1306  size_t& boundForAllLocalRows,
1307  bool& boundSameForAllLocalRows) const;
1308 
1317  void
1318  setAllIndices (const typename local_graph_type::row_map_type& rowPointers,
1319  const typename local_graph_type::entries_type::non_const_type& columnIndices);
1320 
1329  void
1330  setAllIndices (const Teuchos::ArrayRCP<size_t> & rowPointers,
1331  const Teuchos::ArrayRCP<LocalOrdinal> & columnIndices);
1332 
1340  Teuchos::ArrayRCP<const size_t> getNodeRowPtrs () const;
1341 
1343 
1345  Teuchos::ArrayRCP<const LocalOrdinal> getNodePackedIndices() const;
1346 
1357  void replaceColMap (const Teuchos::RCP<const map_type>& newColMap);
1358 
1378  void
1379  reindexColumns (const Teuchos::RCP<const map_type>& newColMap,
1380  const Teuchos::RCP<const import_type>& newImport = Teuchos::null,
1381  const bool sortIndicesInEachRow = true);
1382 
1396  void
1397  replaceDomainMapAndImporter (const Teuchos::RCP<const map_type>& newDomainMap,
1398  const Teuchos::RCP<const import_type>& newImporter);
1399 
1428  virtual void
1429  removeEmptyProcessesInPlace (const Teuchos::RCP<const map_type>& newMap) override;
1431 
1432  template<class ViewType, class OffsetViewType >
1433  struct pack_functor {
1434  typedef typename ViewType::execution_space execution_space;
1435  ViewType src;
1436  ViewType dest;
1437  OffsetViewType src_offset;
1438  OffsetViewType dest_offset;
1439  typedef typename OffsetViewType::non_const_value_type ScalarIndx;
1440 
1441  pack_functor(ViewType dest_, ViewType src_, OffsetViewType dest_offset_, OffsetViewType src_offset_):
1442  src(src_),dest(dest_),src_offset(src_offset_),dest_offset(dest_offset_) {};
1443 
1444  KOKKOS_INLINE_FUNCTION
1445  void operator() (size_t row) const {
1446  ScalarIndx i = src_offset(row);
1447  ScalarIndx j = dest_offset(row);
1448  const ScalarIndx k = dest_offset(row+1);
1449  for(;j<k;j++,i++) {
1450  dest(j) = src(i);
1451  }
1452  }
1453  };
1454 
1455  private:
1456  // Friend declaration for nonmember function.
1457  template<class CrsGraphType>
1458  friend Teuchos::RCP<CrsGraphType>
1459  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1460  const Import<typename CrsGraphType::local_ordinal_type,
1461  typename CrsGraphType::global_ordinal_type,
1462  typename CrsGraphType::node_type>& importer,
1463  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1464  typename CrsGraphType::global_ordinal_type,
1465  typename CrsGraphType::node_type> >& domainMap,
1466  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1467  typename CrsGraphType::global_ordinal_type,
1468  typename CrsGraphType::node_type> >& rangeMap,
1469  const Teuchos::RCP<Teuchos::ParameterList>& params);
1470 
1471  // Friend declaration for nonmember function.
1472  template<class CrsGraphType>
1473  friend Teuchos::RCP<CrsGraphType>
1474  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1475  const Import<typename CrsGraphType::local_ordinal_type,
1476  typename CrsGraphType::global_ordinal_type,
1477  typename CrsGraphType::node_type>& rowImporter,
1478  const Import<typename CrsGraphType::local_ordinal_type,
1479  typename CrsGraphType::global_ordinal_type,
1480  typename CrsGraphType::node_type>& domainImporter,
1481  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1482  typename CrsGraphType::global_ordinal_type,
1483  typename CrsGraphType::node_type> >& domainMap,
1484  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1485  typename CrsGraphType::global_ordinal_type,
1486  typename CrsGraphType::node_type> >& rangeMap,
1487  const Teuchos::RCP<Teuchos::ParameterList>& params);
1488 
1489 
1490  // Friend declaration for nonmember function.
1491  template<class CrsGraphType>
1492  friend Teuchos::RCP<CrsGraphType>
1493  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1494  const Export<typename CrsGraphType::local_ordinal_type,
1495  typename CrsGraphType::global_ordinal_type,
1496  typename CrsGraphType::node_type>& exporter,
1497  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1498  typename CrsGraphType::global_ordinal_type,
1499  typename CrsGraphType::node_type> >& domainMap,
1500  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1501  typename CrsGraphType::global_ordinal_type,
1502  typename CrsGraphType::node_type> >& rangeMap,
1503  const Teuchos::RCP<Teuchos::ParameterList>& params);
1504 
1505  // Friend declaration for nonmember function.
1506  template<class CrsGraphType>
1507  friend Teuchos::RCP<CrsGraphType>
1508  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
1509  const Export<typename CrsGraphType::local_ordinal_type,
1510  typename CrsGraphType::global_ordinal_type,
1511  typename CrsGraphType::node_type>& rowExporter,
1512  const Export<typename CrsGraphType::local_ordinal_type,
1513  typename CrsGraphType::global_ordinal_type,
1514  typename CrsGraphType::node_type>& domainExporter,
1515  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1516  typename CrsGraphType::global_ordinal_type,
1517  typename CrsGraphType::node_type> >& domainMap,
1518  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
1519  typename CrsGraphType::global_ordinal_type,
1520  typename CrsGraphType::node_type> >& rangeMap,
1521  const Teuchos::RCP<Teuchos::ParameterList>& params);
1522 
1523  public:
1539  void
1540  importAndFillComplete (Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >& destGraph,
1541  const import_type& importer,
1542  const Teuchos::RCP<const map_type>& domainMap,
1543  const Teuchos::RCP<const map_type>& rangeMap,
1544  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1545 
1561  void
1562  importAndFillComplete (Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >& destGraph,
1563  const import_type& rowImporter,
1564  const import_type& domainImporter,
1565  const Teuchos::RCP<const map_type>& domainMap,
1566  const Teuchos::RCP<const map_type>& rangeMap,
1567  const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1568 
1569 
1585  void
1586  exportAndFillComplete (Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >& destGraph,
1587  const export_type& exporter,
1588  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1589  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1590  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1591 
1607  void
1608  exportAndFillComplete (Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >& destGraph,
1609  const export_type& rowExporter,
1610  const export_type& domainExporter,
1611  const Teuchos::RCP<const map_type>& domainMap,
1612  const Teuchos::RCP<const map_type>& rangeMap,
1613  const Teuchos::RCP<Teuchos::ParameterList>& params) const;
1614 
1615 
1616  private:
1637  void
1638  transferAndFillComplete (Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >& destGraph,
1639  const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node>& rowTransfer,
1640  const Teuchos::RCP<const ::Tpetra::Details::Transfer<LocalOrdinal, GlobalOrdinal, Node> > & domainTransfer,
1641  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
1642  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
1643  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null) const;
1644 
1645  protected:
1646  // these structs are conveniences, to cut down on the number of
1647  // arguments to some of the methods below.
1648  struct SLocalGlobalViews {
1649  Teuchos::ArrayView<const GlobalOrdinal> ginds;
1650  Teuchos::ArrayView<const LocalOrdinal> linds;
1651  };
1652  struct SLocalGlobalNCViews {
1653  Teuchos::ArrayView<GlobalOrdinal> ginds;
1654  Teuchos::ArrayView<LocalOrdinal> linds;
1655  };
1656 
1657  bool indicesAreAllocated () const;
1658  void allocateIndices (const ELocalGlobal lg);
1659 
1661 
1662 
1672  void makeColMap (Teuchos::Array<int>& remotePIDs);
1673 
1690  std::pair<size_t, std::string> makeIndicesLocal ();
1691 
1700  void
1701  makeImportExport (Teuchos::Array<int>& remotePIDs,
1702  const bool useRemotePIDs);
1703 
1705 
1707 
1742  size_t
1743  insertIndices (RowInfo& rowInfo,
1744  const SLocalGlobalViews& newInds,
1745  const ELocalGlobal lg,
1746  const ELocalGlobal I);
1747 
1757  size_t
1758  insertGlobalIndicesImpl (const LocalOrdinal lclRow,
1759  const GlobalOrdinal inputGblColInds[],
1760  const size_t numInputInds);
1761 
1771  size_t
1772  insertGlobalIndicesImpl (const RowInfo& rowInfo,
1773  const GlobalOrdinal inputGblColInds[],
1774  const size_t numInputInds);
1775 
1776  void
1777  insertLocalIndicesImpl (const LocalOrdinal lclRow,
1778  const Teuchos::ArrayView<const LocalOrdinal>& gblColInds);
1779 
1791  void
1792  insertGlobalIndicesFiltered (const LocalOrdinal lclRow,
1793  const GlobalOrdinal gblColInds[],
1794  const LocalOrdinal numGblColInds);
1795 
1807  void
1808  insertGlobalIndicesIntoNonownedRows (const GlobalOrdinal gblRow,
1809  const GlobalOrdinal gblColInds[],
1810  const LocalOrdinal numGblColInds);
1811 
1816  static const bool useAtomicUpdatesByDefault =
1817 #ifdef KOKKOS_ENABLE_SERIAL
1818  ! std::is_same<execution_space, Kokkos::Serial>::value;
1819 #else
1820  true;
1821 #endif // KOKKOS_ENABLE_SERIAL
1822 
1824 
1826 
1828  bool isMerged () const;
1829 
1835  void setLocallyModified ();
1836 
1837  private:
1842  void
1843  sortAndMergeAllIndices (const bool sorted, const bool merged);
1844 
1845  // mfh 08 May 2017: I only restore "protected" here for backwards
1846  // compatibility.
1847  protected:
1856  size_t sortAndMergeRowIndices (const RowInfo& rowInfo,
1857  const bool sorted,
1858  const bool merged);
1860 
1870  void
1871  setDomainRangeMaps (const Teuchos::RCP<const map_type>& domainMap,
1872  const Teuchos::RCP<const map_type>& rangeMap);
1873 
1874  void staticAssertions() const;
1875  void clearGlobalConstants();
1876 
1877  public:
1880 
1909  void computeGlobalConstants (const bool computeLocalTriangularConstants);
1910 
1911  protected:
1946  void computeLocalConstants (const bool computeLocalTriangularConstants);
1947 
1950  RowInfo getRowInfo (const LocalOrdinal myRow) const;
1951 
1964  RowInfo getRowInfoFromGlobalRowIndex (const GlobalOrdinal gblRow) const;
1965 
1969  Teuchos::ArrayView<const LocalOrdinal>
1970  getLocalView (const RowInfo rowinfo) const;
1971 
1975  Teuchos::ArrayView<LocalOrdinal>
1976  getLocalViewNonConst (const RowInfo rowinfo);
1977 
1989  LocalOrdinal
1990  getLocalViewRawConst (const LocalOrdinal*& lclInds,
1991  LocalOrdinal& capacity,
1992  const RowInfo& rowInfo) const;
1993 
1994  private:
1995 
2002  Kokkos::View<const LocalOrdinal*, execution_space, Kokkos::MemoryUnmanaged>
2003  getLocalKokkosRowView (const RowInfo& rowInfo) const;
2004 
2011  Kokkos::View<LocalOrdinal*, execution_space, Kokkos::MemoryUnmanaged>
2012  getLocalKokkosRowViewNonConst (const RowInfo& rowInfo);
2013 
2020  Kokkos::View<const GlobalOrdinal*, execution_space, Kokkos::MemoryUnmanaged>
2021  getGlobalKokkosRowView (const RowInfo& rowInfo) const;
2022 
2023  protected:
2024 
2028  Teuchos::ArrayView<const GlobalOrdinal>
2029  getGlobalView (const RowInfo& rowinfo) const;
2030 
2034  Teuchos::ArrayView<GlobalOrdinal>
2035  getGlobalViewNonConst (const RowInfo& rowinfo);
2036 
2049  LocalOrdinal
2050  getGlobalViewRawConst (const GlobalOrdinal*& gblInds,
2051  LocalOrdinal& capacity,
2052  const RowInfo& rowInfo) const;
2053 
2054  public:
2063 
2064  protected:
2065  void fillLocalGraph (const Teuchos::RCP<Teuchos::ParameterList>& params);
2066 
2068  void checkInternalState () const;
2069 
2071  Teuchos::RCP<const map_type> rowMap_;
2073  Teuchos::RCP<const map_type> colMap_;
2075  Teuchos::RCP<const map_type> rangeMap_;
2077  Teuchos::RCP<const map_type> domainMap_;
2078 
2085  Teuchos::RCP<const import_type> importer_;
2086 
2092  Teuchos::RCP<const export_type> exporter_;
2093 
2096 
2101 
2106 
2111 
2116 
2121 
2124 
2150  typename Kokkos::View<const size_t*, execution_space>::HostMirror
2152 
2163 
2165 
2166 
2174  typename local_graph_type::entries_type::non_const_type k_lclInds1D_;
2175 
2177  typedef Kokkos::View<GlobalOrdinal*, execution_space> t_GlobalOrdinal_1D;
2178 
2187 
2212  typename local_graph_type::row_map_type::const_type k_rowPtrs_;
2213 
2215 
2227 
2239  Teuchos::ArrayRCP<Teuchos::Array<LocalOrdinal> > lclInds2D_;
2240 
2252  Teuchos::ArrayRCP<Teuchos::Array<GlobalOrdinal> > gblInds2D_;
2253 
2261  typedef typename Kokkos::View<size_t*, Kokkos::LayoutLeft, device_type>::HostMirror num_row_entries_type;
2262 
2263  // typedef Kokkos::View<
2264  // size_t*,
2265  // Kokkos::LayoutLeft,
2266  // Kokkos::Device<
2267  // typename Kokkos::View<
2268  // size_t*,
2269  // Kokkos::LayoutLeft,
2270  // device_type>::HostMirror::execution_space,
2271  // Kokkos::HostSpace> > num_row_entries_type;
2272 
2280 
2282 
2293 
2294  bool indicesAreAllocated_;
2295  bool indicesAreLocal_;
2296  bool indicesAreGlobal_;
2297  bool fillComplete_;
2298 
2312 
2314  std::map<GlobalOrdinal, std::vector<GlobalOrdinal> > nonlocals_;
2315 
2331 
2332  }; // class CrsGraph
2333 } // namespace Classes
2334 
2341  template <class LocalOrdinal, class GlobalOrdinal, class Node>
2342  Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
2343  createCrsGraph (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map,
2344  size_t maxNumEntriesPerRow = 0,
2345  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2346  {
2347  using Teuchos::rcp;
2349  return rcp (new graph_type (map, maxNumEntriesPerRow, DynamicProfile, params));
2350  }
2351 
2400  template<class CrsGraphType>
2401  Teuchos::RCP<CrsGraphType>
2402  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2403  const Import<typename CrsGraphType::local_ordinal_type,
2404  typename CrsGraphType::global_ordinal_type,
2405  typename CrsGraphType::node_type>& importer,
2406  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2407  typename CrsGraphType::global_ordinal_type,
2408  typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2409  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2410  typename CrsGraphType::global_ordinal_type,
2411  typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2412  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2413  {
2414  Teuchos::RCP<CrsGraphType> destGraph;
2415  sourceGraph->importAndFillComplete (destGraph,importer,domainMap, rangeMap, params);
2416  return destGraph;
2417  }
2418 
2469  template<class CrsGraphType>
2470  Teuchos::RCP<CrsGraphType>
2471  importAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2472  const Import<typename CrsGraphType::local_ordinal_type,
2473  typename CrsGraphType::global_ordinal_type,
2474  typename CrsGraphType::node_type>& rowImporter,
2475  const Import<typename CrsGraphType::local_ordinal_type,
2476  typename CrsGraphType::global_ordinal_type,
2477  typename CrsGraphType::node_type>& domainImporter,
2478  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2479  typename CrsGraphType::global_ordinal_type,
2480  typename CrsGraphType::node_type> >& domainMap,
2481  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2482  typename CrsGraphType::global_ordinal_type,
2483  typename CrsGraphType::node_type> >& rangeMap,
2484  const Teuchos::RCP<Teuchos::ParameterList>& params)
2485  {
2486  Teuchos::RCP<CrsGraphType> destGraph;
2487  sourceGraph->importAndFillComplete (destGraph,rowImporter,domainImporter, domainMap, rangeMap, params);
2488  return destGraph;
2489  }
2490 
2524  template<class CrsGraphType>
2525  Teuchos::RCP<CrsGraphType>
2526  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2527  const Export<typename CrsGraphType::local_ordinal_type,
2528  typename CrsGraphType::global_ordinal_type,
2529  typename CrsGraphType::node_type>& exporter,
2530  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2531  typename CrsGraphType::global_ordinal_type,
2532  typename CrsGraphType::node_type> >& domainMap = Teuchos::null,
2533  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2534  typename CrsGraphType::global_ordinal_type,
2535  typename CrsGraphType::node_type> >& rangeMap = Teuchos::null,
2536  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2537  {
2538  Teuchos::RCP<CrsGraphType> destGraph;
2539  sourceGraph->exportAndFillComplete (destGraph,exporter,domainMap, rangeMap, params);
2540  return destGraph;
2541  }
2542 
2576  template<class CrsGraphType>
2577  Teuchos::RCP<CrsGraphType>
2578  exportAndFillCompleteCrsGraph (const Teuchos::RCP<const CrsGraphType>& sourceGraph,
2579  const Export<typename CrsGraphType::local_ordinal_type,
2580  typename CrsGraphType::global_ordinal_type,
2581  typename CrsGraphType::node_type>& rowExporter,
2582  const Export<typename CrsGraphType::local_ordinal_type,
2583  typename CrsGraphType::global_ordinal_type,
2584  typename CrsGraphType::node_type>& domainExporter,
2585  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2586  typename CrsGraphType::global_ordinal_type,
2587  typename CrsGraphType::node_type> >& domainMap,
2588  const Teuchos::RCP<const Map<typename CrsGraphType::local_ordinal_type,
2589  typename CrsGraphType::global_ordinal_type,
2590  typename CrsGraphType::node_type> >& rangeMap,
2591  const Teuchos::RCP<Teuchos::ParameterList>& params)
2592  {
2593  Teuchos::RCP<CrsGraphType> destGraph;
2594  sourceGraph->exportAndFillComplete (destGraph,rowExporter,domainExporter,domainMap, rangeMap, params);
2595  return destGraph;
2596  }
2597 
2598  namespace Details {
2599 
2600  template<class LocalOrdinal,
2601  class GlobalOrdinal,
2602  class OutputNodeType,
2603  class InputNodeType>
2604  class CrsGraphCopier<CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType>,
2605  CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> > {
2606  public:
2607  typedef CrsGraph<LocalOrdinal, GlobalOrdinal, InputNodeType> input_crs_graph_type;
2608  typedef CrsGraph<LocalOrdinal, GlobalOrdinal, OutputNodeType> output_crs_graph_type;
2609 
2610  static Teuchos::RCP<output_crs_graph_type>
2611  clone (const input_crs_graph_type& graphIn,
2612  const Teuchos::RCP<OutputNodeType> &nodeOut,
2613  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null)
2614  {
2615  using Teuchos::arcp;
2616  using Teuchos::Array;
2617  using Teuchos::ArrayRCP;
2618  using Teuchos::ArrayView;
2619  using Teuchos::null;
2620  using Teuchos::outArg;
2621  using Teuchos::ParameterList;
2622  using Teuchos::parameterList;
2623  using Teuchos::RCP;
2624  using Teuchos::rcp;
2625  using Teuchos::REDUCE_MIN;
2626  using Teuchos::reduceAll;
2627  using Teuchos::sublist;
2628  using std::cerr;
2629  using std::endl;
2630  typedef LocalOrdinal LO;
2631  typedef GlobalOrdinal GO;
2632  typedef typename ArrayView<const GO>::size_type size_type;
2633  typedef ::Tpetra::Map<LO, GO, InputNodeType> input_map_type;
2634  typedef ::Tpetra::Map<LO, GO, OutputNodeType> output_map_type;
2635  const char prefix[] = "Tpetra::Details::CrsGraphCopier::clone: ";
2636 
2637  // Set parameters' default values.
2638  bool debug = false;
2639  bool fillCompleteClone = true;
2640  bool useLocalIndices = graphIn.hasColMap ();
2641  ProfileType pftype = StaticProfile;
2642  // If the user provided a ParameterList, get values from there.
2643  if (! params.is_null ()) {
2644  fillCompleteClone = params->get ("fillComplete clone", fillCompleteClone);
2645  useLocalIndices = params->get ("Locally indexed clone", useLocalIndices);
2646  if (params->get ("Static profile clone", true) == false) {
2647  pftype = DynamicProfile;
2648  }
2649  debug = params->get ("Debug", debug);
2650  }
2651 
2652  const Teuchos::Comm<int>& comm = * (graphIn.getRowMap ()->getComm ());
2653  const int myRank = comm.getRank ();
2654 
2655  TEUCHOS_TEST_FOR_EXCEPTION(
2656  ! graphIn.hasColMap () && useLocalIndices, std::runtime_error,
2657  prefix << "You asked clone() to use local indices (by setting the "
2658  "\"Locally indexed clone\" parameter to true), but the source graph "
2659  "does not yet have a column Map, so this is impossible.");
2660 
2661  if (debug) {
2662  std::ostringstream os;
2663  os << "Process " << myRank << ": Cloning row Map" << endl;
2664  cerr << os.str ();
2665  }
2666 
2667  RCP<const output_map_type> clonedRowMap =
2668  graphIn.getRowMap ()->template clone<OutputNodeType> (nodeOut);
2669 
2670  // Invoke the output graph's constructor, using the input graph's
2671  // upper bounds on the number of entries in each local row.
2672  RCP<output_crs_graph_type> clonedGraph; // returned by this function
2673  {
2674  ArrayRCP<const size_t> numEntriesPerRow;
2675  size_t numEntriesForAll = 0;
2676  bool boundSameForAllLocalRows = true;
2677 
2678  if (debug) {
2679  std::ostringstream os;
2680  os << "Process " << myRank << ": Getting per-row bounds" << endl;
2681  cerr << os.str ();
2682  }
2683  graphIn.getNumEntriesPerLocalRowUpperBound (numEntriesPerRow,
2684  numEntriesForAll,
2685  boundSameForAllLocalRows);
2686  if (debug) {
2687  std::ostringstream os;
2688  os << "Process " << myRank << ": numEntriesForAll = "
2689  << numEntriesForAll << endl;
2690  cerr << os.str ();
2691  }
2692 
2693  if (debug) {
2694  std::ostringstream os;
2695  os << "Process " << myRank << ": graphIn.getNodeMaxNumRowEntries() = "
2696  << graphIn.getNodeMaxNumRowEntries () << endl;
2697  cerr << os.str ();
2698  }
2699 
2700  RCP<ParameterList> graphparams;
2701  if (params.is_null ()) {
2702  graphparams = parameterList ("CrsGraph");
2703  } else {
2704  graphparams = sublist (params, "CrsGraph");
2705  }
2706  if (useLocalIndices) {
2707  RCP<const output_map_type> clonedColMap =
2708  graphIn.getColMap ()->template clone<OutputNodeType> (nodeOut);
2709  if (boundSameForAllLocalRows) {
2710  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap, clonedColMap,
2711  numEntriesForAll, pftype,
2712  graphparams));
2713  } else {
2714  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap, clonedColMap,
2715  numEntriesPerRow, pftype,
2716  graphparams));
2717  }
2718  } else {
2719  if (boundSameForAllLocalRows) {
2720  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap,
2721  numEntriesForAll, pftype,
2722  graphparams));
2723  } else {
2724  clonedGraph = rcp (new output_crs_graph_type (clonedRowMap,
2725  numEntriesPerRow,
2726  pftype, graphparams));
2727  }
2728  }
2729 
2730  if (debug) {
2731  std::ostringstream os;
2732  os << "Process " << myRank << ": Invoked output graph's constructor" << endl;
2733  cerr << os.str ();
2734  }
2735 
2736  // done with these
2737  numEntriesPerRow = null;
2738  numEntriesForAll = 0;
2739  }
2740 
2741  const input_map_type& inputRowMap = * (graphIn.getRowMap ());
2742  const size_type numRows =
2743  static_cast<size_type> (inputRowMap.getNodeNumElements ());
2744 
2745  bool failed = false;
2746 
2747  if (useLocalIndices) {
2748  const LO localMinLID = inputRowMap.getMinLocalIndex ();
2749  const LO localMaxLID = inputRowMap.getMaxLocalIndex ();
2750 
2751  if (graphIn.isLocallyIndexed ()) {
2752  if (numRows != 0) {
2753  try {
2754  ArrayView<const LO> linds;
2755  for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2756  graphIn.getLocalRowView (lrow, linds);
2757  if (linds.size () != 0) {
2758  clonedGraph->insertLocalIndices (lrow, linds);
2759  }
2760  }
2761  }
2762  catch (std::exception& e) {
2763  std::ostringstream os;
2764  os << "Process " << myRank << ": copying (reading local by view, "
2765  "writing local) indices into the output graph threw an "
2766  "exception: " << e.what () << endl;
2767  cerr << os.str ();
2768  failed = true;
2769  }
2770  }
2771  }
2772  else { // graphIn.isGloballyIndexed()
2773  TEUCHOS_TEST_FOR_EXCEPTION(
2774  ! graphIn.hasColMap () && useLocalIndices, std::invalid_argument,
2775  prefix << "You asked clone() to use local indices (by setting the "
2776  "\"Locally indexed clone\" parameter to true), but the source graph "
2777  "does not yet have a column Map, so this is impossible.");
2778 
2779  // The input graph has a column Map, but is globally indexed.
2780  // That's a bit weird, but we'll run with it. In this case,
2781  // getLocalRowView won't work, but getLocalRowCopy should
2782  // still work; it will just have to convert from global to
2783  // local indices internally.
2784 
2785  try {
2786  // Make space for getLocalRowCopy to put column indices.
2787  //
2788  // This is only a hint; we may have to resize in the loop
2789  // below. getNodeMaxNumRowEntries() may return nonsense if
2790  // fill is active. The key bool in CrsGraph is
2791  // haveLocalConstants_.
2792  size_t myMaxNumRowEntries =
2793  graphIn.isFillActive () ? static_cast<size_t> (0) :
2794  graphIn.getNodeMaxNumRowEntries ();
2795 
2796  Array<LO> linds (myMaxNumRowEntries);
2797 
2798  // Copy each row into the new graph, using local indices.
2799  for (LO lrow = localMinLID; lrow <= localMaxLID; ++lrow) {
2800  size_t theNumEntries = graphIn.getNumEntriesInLocalRow (lrow);
2801  if (theNumEntries > myMaxNumRowEntries) {
2802  myMaxNumRowEntries = theNumEntries;
2803  linds.resize (myMaxNumRowEntries);
2804  }
2805  graphIn.getLocalRowCopy (lrow, linds (), theNumEntries);
2806  if (theNumEntries != 0) {
2807  clonedGraph->insertLocalIndices (lrow, linds (0, theNumEntries));
2808  }
2809  }
2810  }
2811  catch (std::exception& e) {
2812  std::ostringstream os;
2813  os << "Process " << myRank << ": copying (reading local by copy, "
2814  "writing local) indices into the output graph threw an exception: "
2815  << e.what () << endl;
2816  cerr << os.str ();
2817  failed = true;
2818  }
2819  }
2820  }
2821  else { /* useGlobalIndices */
2822  if (numRows != 0) {
2823  const GlobalOrdinal localMinGID = inputRowMap.getMinGlobalIndex ();
2824  const GlobalOrdinal localMaxGID = inputRowMap.getMaxGlobalIndex ();
2825  const bool inputRowMapIsContiguous = inputRowMap.isContiguous ();
2826 
2827  if (graphIn.isGloballyIndexed ()) {
2828  ArrayView<const GlobalOrdinal> ginds;
2829 
2830  if (inputRowMapIsContiguous) {
2831  try {
2832  for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
2833  graphIn.getGlobalRowView (grow, ginds);
2834  if (ginds.size () != 0) {
2835  clonedGraph->insertGlobalIndices (grow, ginds);
2836  }
2837  }
2838  }
2839  catch (std::exception& e) {
2840  std::ostringstream os;
2841  os << "Process " << myRank << ": copying (reading global by view, "
2842  "writing global) indices into the output graph threw an "
2843  "exception: " << e.what () << endl;
2844  cerr << os.str ();
2845  failed = true;
2846  }
2847  }
2848  else { // input row Map is not contiguous
2849  try {
2850  ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
2851  for (size_type k = 0; k < numRows; ++k) {
2852  const GO grow = inputRowMapGIDs[k];
2853  graphIn.getGlobalRowView (grow, ginds);
2854  if (ginds.size () != 0) {
2855  clonedGraph->insertGlobalIndices (grow, ginds);
2856  }
2857  }
2858  }
2859  catch (std::exception& e) {
2860  std::ostringstream os;
2861  os << "Process " << myRank << ": copying (reading global by view, "
2862  "writing global) indices into the output graph threw an "
2863  "exception: " << e.what () << endl;
2864  cerr << os.str ();
2865  failed = true;
2866  }
2867  }
2868  }
2869  else { // graphIn.isLocallyIndexed()
2870  // Make space for getGlobalRowCopy to put column indices.
2871  //
2872  // This is only a hint; we may have to resize in the loop
2873  // below. getNodeMaxNumRowEntries() may return nonsense if
2874  // fill is active. The key bool in CrsGraph is
2875  // haveLocalConstants_.
2876  size_t myMaxNumRowEntries =
2877  graphIn.isFillActive () ? static_cast<size_t> (0) :
2878  graphIn.getNodeMaxNumRowEntries ();
2879 
2880  Array<GO> ginds (myMaxNumRowEntries);
2881 
2882  if (inputRowMapIsContiguous) {
2883  try {
2884  for (GO grow = localMinGID; grow <= localMaxGID; ++grow) {
2885  size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
2886  if (theNumEntries > myMaxNumRowEntries) {
2887  myMaxNumRowEntries = theNumEntries;
2888  ginds.resize (myMaxNumRowEntries);
2889  }
2890  graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
2891  if (theNumEntries != 0) {
2892  clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
2893  }
2894  }
2895  }
2896  catch (std::exception& e) {
2897  std::ostringstream os;
2898  os << "Process " << myRank << ": copying (reading global by copy, "
2899  "writing global) indices into the output graph threw an "
2900  "exception: " << e.what () << endl;
2901  cerr << os.str ();
2902  failed = true;
2903  }
2904  }
2905  else { // input row Map is not contiguous
2906  try {
2907  ArrayView<const GO> inputRowMapGIDs = inputRowMap.getNodeElementList ();
2908  for (size_type k = 0; k < numRows; ++k) {
2909  const GO grow = inputRowMapGIDs[k];
2910 
2911  size_t theNumEntries = graphIn.getNumEntriesInGlobalRow (grow);
2912  if (theNumEntries > myMaxNumRowEntries) {
2913  myMaxNumRowEntries = theNumEntries;
2914  ginds.resize (myMaxNumRowEntries);
2915  }
2916  graphIn.getGlobalRowCopy (grow, ginds (), theNumEntries);
2917  if (theNumEntries != 0) {
2918  clonedGraph->insertGlobalIndices (grow, ginds (0, theNumEntries));
2919  }
2920  }
2921  }
2922  catch (std::exception& e) {
2923  std::ostringstream os;
2924  os << "Process " << myRank << ": copying (reading global by copy, "
2925  "writing global) indices into the output graph threw an "
2926  "exception: " << e.what () << endl;
2927  cerr << os.str ();
2928  failed = true;
2929  }
2930  }
2931  }
2932  } // numRows != 0
2933  }
2934 
2935  if (debug) {
2936  std::ostringstream os;
2937  os << "Process " << myRank << ": copied entries" << endl;
2938  cerr << os.str ();
2939  }
2940 
2941  if (fillCompleteClone) {
2942  RCP<ParameterList> fillparams = params.is_null () ?
2943  parameterList ("fillComplete") :
2944  sublist (params, "fillComplete");
2945  try {
2946  RCP<const output_map_type> clonedRangeMap;
2947  RCP<const output_map_type> clonedDomainMap;
2948  if (! graphIn.getRangeMap ().is_null () &&
2949  graphIn.getRangeMap () != graphIn.getRowMap ()) {
2950  clonedRangeMap =
2951  graphIn.getRangeMap ()->template clone<OutputNodeType> (nodeOut);
2952  }
2953  else {
2954  clonedRangeMap = clonedRowMap;
2955  }
2956  if (! graphIn.getDomainMap ().is_null ()
2957  && graphIn.getDomainMap () != graphIn.getRowMap ()) {
2958  clonedDomainMap =
2959  graphIn.getDomainMap ()->template clone<OutputNodeType> (nodeOut);
2960  }
2961  else {
2962  clonedDomainMap = clonedRowMap;
2963  }
2964 
2965  if (debug) {
2966  std::ostringstream os;
2967  os << "Process " << myRank << ": About to call fillComplete on "
2968  "cloned graph" << endl;
2969  cerr << os.str ();
2970  }
2971  clonedGraph->fillComplete (clonedDomainMap, clonedRangeMap, fillparams);
2972  }
2973  catch (std::exception &e) {
2974  failed = true;
2975  std::ostringstream os;
2976  os << prefix << "Process " << myRank << ": Caught the following "
2977  "exception while calling fillComplete() on clone of type"
2978  << endl << Teuchos::typeName (*clonedGraph) << endl;
2979  cerr << os.str ();
2980  }
2981  }
2982 
2983  int lclSuccess = failed ? 0 : 1;
2984  int gblSuccess = 1;
2985  reduceAll<int, int> (comm, REDUCE_MIN, lclSuccess, outArg (gblSuccess));
2986  TEUCHOS_TEST_FOR_EXCEPTION(
2987  gblSuccess != 1, std::logic_error, prefix <<
2988  "Clone failed on at least one process.");
2989 
2990  if (debug) {
2991  std::ostringstream os;
2992  os << "Process " << myRank << ": Done with CrsGraph::clone" << endl;
2993  cerr << os.str ();
2994  }
2995  return clonedGraph;
2996  }
2997  };
2998 
2999  } // namespace Details
3000 } // namespace Tpetra
3001 
3002 #endif // TPETRA_CRSGRAPH_DECL_HPP
size_t getNodeNumDiagsImpl() const override
DO NOT CALL THIS METHOD; THIS IS NOT FOR USERS.
Teuchos::ArrayView< const GlobalOrdinal > getGlobalView(const RowInfo &rowinfo) const
Get a const, nonowned, globally indexed view of the locally owned row myRow, such that rowinfo = getR...
Base class for distributed Tpetra objects that support data redistribution.
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...
global_size_t getGlobalNumCols() const override
Returns the number of global columns in the graph.
void insertGlobalIndices(const GlobalOrdinal globalRow, const Teuchos::ArrayView< const GlobalOrdinal > &indices)
Insert global indices into the graph.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Node node_type
This class&#39; Kokkos Node type.
Node::device_type device_type
This class&#39; Kokkos device type.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
LocalOrdinal getLocalViewRawConst(const LocalOrdinal *&lclInds, LocalOrdinal &capacity, const RowInfo &rowInfo) const
Get a pointer to the local column indices of a locally owned row, using the result of getRowInfo...
void computeLocalConstants(const bool computeLocalTriangularConstants)
Compute local constants, if they have not yet been computed.
size_t nodeNumDiags_
Local number of (populated) diagonal entries.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
void getGlobalRowView(const GlobalOrdinal gblRow, Teuchos::ArrayView< const GlobalOrdinal > &gblColInds) const override
Get a const, non-persisting view of the given global row&#39;s global column indices, as a Teuchos::Array...
bool isLowerTriangularImpl() const override
DO NOT CALL THIS METHOD; THIS IS NOT FOR USERS.
::Tpetra::Details::EStorageStatus storageStatus_
Status of the graph&#39;s storage, when not in a fill-complete state.
void makeImportExport(Teuchos::Array< int > &remotePIDs, const bool useRemotePIDs)
Make the Import and Export objects, if needed.
size_t insertGlobalIndicesImpl(const LocalOrdinal lclRow, const GlobalOrdinal inputGblColInds[], const size_t numInputInds)
Insert global indices, using an input local row index.
t_GlobalOrdinal_1D k_gblInds1D_
Global column indices for all rows.
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
virtual void pack(const Teuchos::ArrayView< const LocalOrdinal > &exportLIDs, Teuchos::Array< GlobalOrdinal > &exports, const Teuchos::ArrayView< size_t > &numPacketsPerLID, size_t &constantNumPackets, Distributor &distor) const override
Pack this object&#39;s data for Import or Export.
size_t getNodeNumRows() const override
Returns the number of graph rows owned on the calling node.
bool isUpperTriangularImpl() const override
DO NOT CALL THIS METHOD; THIS IS NOT FOR USERS.
bool noRedundancies_
Whether the graph&#39;s indices are non-redundant (merged) in each row, on this process.
local_graph_type getLocalGraph() const
Get the local graph.
void getLocalRowCopy(LocalOrdinal LocalRow, const Teuchos::ArrayView< LocalOrdinal > &indices, size_t &NumIndices) const override
Get a copy of the given row, using local indices.
Teuchos::RCP< const map_type > getRangeMap() const override
Returns the Map associated with the domain of this graph.
Teuchos::RCP< const import_type > importer_
The Import from the domain Map to the column Map.
Teuchos::RCP< const map_type > getDomainMap() const override
Returns the Map associated with the domain of this graph.
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Tell the graph that you are done changing its structure.
Classes::Export< LocalOrdinal, GlobalOrdinal, Node > Export
Alias for Tpetra::Classes::Export.
static const bool useAtomicUpdatesByDefault
Whether transformLocalValues should use atomic updates by default.
Forward declaration of Tpetra::BlockCrsMatrix.
size_t getNodeNumEntries() const override
The local number of entries in the graph.
bool TPETRA_DEPRECATED isLowerTriangular() const override
Whether the graph is locally lower triangular.
Teuchos::ArrayView< const LocalOrdinal > getLocalView(const RowInfo rowinfo) const
Get a const, nonowned, locally indexed view of the locally owned row myRow, such that rowinfo = getRo...
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 > &params=Teuchos::null)
Nonmember CrsGraph constructor that fuses Export and fillComplete().
Teuchos::ArrayRCP< const LocalOrdinal > getNodePackedIndices() const
Get an Teuchos::ArrayRCP of the packed column-indices.
void insertGlobalIndicesIntoNonownedRows(const GlobalOrdinal gblRow, const GlobalOrdinal gblColInds[], const LocalOrdinal numGblColInds)
Implementation of insertGlobalIndices for nonowned rows.
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&#39;s data directly, using 1-D storage.
virtual void removeEmptyProcessesInPlace(const Teuchos::RCP< const map_type > &newMap) override
Remove processes owning zero rows from the Maps and their communicator.
Classes::Import< LocalOrdinal, GlobalOrdinal, Node > Import
Alias for Tpetra::Classes::Import.
void insertGlobalIndicesFiltered(const LocalOrdinal lclRow, const GlobalOrdinal gblColInds[], const LocalOrdinal numGblColInds)
Like insertGlobalIndices(), but with column Map filtering.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
void exportAndFillComplete(Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, 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 > &params=Teuchos::null) const
Export from this to the given destination graph, and make the result fill complete.
void setDomainRangeMaps(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap)
void checkInternalState() const
Throw an exception if the internal state is not consistent.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const override
Returns the current number of entries on this node in the specified global row.
Kokkos::View< const size_t *, execution_space >::HostMirror k_numAllocPerRow_
The maximum number of entries to allow in each locally owned row, per row.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
int local_ordinal_type
Default value of Scalar template parameter.
Classes::Map< LocalOrdinal, GlobalOrdinal, Node > Map
Alias for Tpetra::Classes::Map.
void globalAssemble()
Communicate nonlocal contributions to other processes.
bool upperTriangular_
Whether the graph is locally upper triangular.
An abstract interface for graphs accessed by rows.
bool TPETRA_DEPRECATED isUpperTriangular() const override
Whether the graph is locally upper triangular.
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 hasColMap() const override
Whether the graph has a column Map.
void computeGlobalConstants(const bool computeLocalTriangularConstants)
Compute global constants, if they have not yet been computed.
Implementation details of Tpetra.
bool isFillActive() const
Returns true if resumeFill() has been called and the graph is in edit mode.
Teuchos::RCP< const export_type > exporter_
The Export from the row Map to the range Map.
global_size_t globalMaxNumRowEntries_
Global maximum of the number of entries in each row.
bool supportsRowViews() const override
Whether this class implements getLocalRowView() and getGlobalRowView() (it does). ...
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
size_t global_size_t
Global size_t object.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, over all processes in the graph&#39;s communicator...
size_t numAllocForAllRows_
The maximum number of entries to allow in each locally owned row.
GlobalOrdinal getIndexBase() const override
Returns the index base for global indices for this graph.
Classes::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > CrsGraph
Alias for Tpetra::Classes::CrsGraph.
size_t getNodeNumCols() const override
Returns the number of columns connected to the locally owned rows of this graph.
RowInfo getRowInfo(const LocalOrdinal myRow) const
Get information about the locally owned row with local index myRow.
local_graph_type::row_map_type::non_const_type t_RowPtrsNC TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::row_map_type::non_const_type instead.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &params) override
Set the given list of parameters (must be nonnull).
bool haveGlobalConstants_
Whether all processes have computed global constants.
std::string description() const override
Return a one-line human-readable description of this object.
std::map< GlobalOrdinal, std::vector< GlobalOrdinal > > nonlocals_
Nonlocal data given to insertGlobalIndices.
friend class CrsGraph
Alias for Tpetra::Classes::CrsGraph.
local_graph_type::row_map_type::const_type k_rowPtrs_
Row offsets for "1-D" storage.
void makeColMap(Teuchos::Array< int > &remotePIDs)
Make and set the graph&#39;s column Map.
size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const
Current number of allocated entries in the given row on the calling (MPI) process, using a global row index.
global_size_t getGlobalNumEntries() const override
Returns the global number of entries in the graph.
virtual bool checkSizes(const SrcDistObject &source) override
Compare the source and target (this) objects for compatibility.
bool isSorted() const
Whether graph indices in all rows are known to be sorted.
void getLocalDiagOffsets(const Kokkos::View< size_t *, device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the graph.
size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const
Current number of allocated entries in the given row on the calling (MPI) process, using a local row index.
Sets up and executes a communication plan for a Tpetra DistObject.
CombineMode
Rule for combining data in an Import or Export.
size_t nodeMaxNumRowEntries_
Local maximum of the number of entries in each row.
size_t getNodeAllocationSize() const
The local number of indices allocated for the graph, over all rows on the calling (MPI) process...
bool isGloballyIndexed() const override
If graph indices are in the global range, this function returns true. Otherwise, this function return...
bool lowerTriangular_
Whether the graph is locally lower triangular.
::Tpetra::Export< LocalOrdinal, GlobalOrdinal, Node > export_type
The Export specialization used by this class.
size_t sortAndMergeRowIndices(const RowInfo &rowInfo, const bool sorted, const bool merged)
Sort and merge duplicate column indices in the given row.
Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, Node2 > > clone(const Teuchos::RCP< Node2 > &node2, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null) const
Create a cloned CrsGraph for a different Node type.
Forward declaration of Tpetra::CrsMatrix.
local_graph_type::row_map_type t_RowPtrs TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::row_map_type instead.
Abstract base class for objects that can be the source of an Import or Export operation.
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 > &params=Teuchos::null)
Perform a fillComplete on a graph that already has data, via setAllIndices().
local_graph_type::entries_type::non_const_type k_lclInds1D_
Local column indices for all rows.
void resumeFill(const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Resume fill operations.
void getLocalRowView(const LocalOrdinal lclRow, Teuchos::ArrayView< const LocalOrdinal > &lclColInds) const override
Get a const, non-persisting view of the given local row&#39;s local column indices, as a Teuchos::ArrayVi...
num_row_entries_type k_numRowEntries_
The number of local entries in each locally owned row.
local_graph_type lclGraph_
Local graph; only initialized after first fillComplete() call.
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
std::pair< size_t, std::string > makeIndicesLocal()
Convert column indices from global to local.
Teuchos::ArrayView< GlobalOrdinal > getGlobalViewNonConst(const RowInfo &rowinfo)
Get a nonconst, nonowned, globally indexed view of the locally owned row myRow, such that rowinfo = g...
Kokkos::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, execution_space > local_graph_type
The type of the part of the sparse graph on each MPI process.
global_size_t globalNumEntries_
Global number of entries in the graph.
Teuchos::RCP< node_type > getNode() const override
Returns the underlying node.
Teuchos::ArrayView< LocalOrdinal > getLocalViewNonConst(const RowInfo rowinfo)
Get a nonconst, nonowned, locally indexed view of the locally owned row myRow, such that rowinfo = ge...
::Tpetra::Import< LocalOrdinal, GlobalOrdinal, Node > import_type
The Import specialization used by this class.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const override
Returns the communicator.
Teuchos::RCP< const map_type > rangeMap_
The Map describing the range of the (matrix corresponding to the) graph.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const override
Get the number of entries in the given row (local index).
void replaceColMap(const Teuchos::RCP< const map_type > &newColMap)
Replace the graph&#39;s current column Map with the given Map.
bool isMerged() const
Whether duplicate column indices in each row have been merged.
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Teuchos::ArrayRCP< const size_t > getNodeRowPtrs() const
Get a host view of the row offsets.
bool haveLocalConstants_
Whether this process has computed local constants.
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.
virtual void copyAndPermute(const SrcDistObject &source, size_t numSameIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteToLIDs, const Teuchos::ArrayView< const LocalOrdinal > &permuteFromLIDs) override
Perform copies and permutations that are local to this process.
Teuchos::RCP< const map_type > getColMap() const override
Returns the Map that describes the column distribution in this graph.
global_size_t globalNumDiags_
Global number of (populated) diagonal entries.
Kokkos::View< size_t *, Kokkos::LayoutLeft, device_type >::HostMirror num_row_entries_type
The type of k_numRowEntries_ (see below).
virtual ~CrsGraph()
Destructor.
LocalOrdinal local_ordinal_type
This class&#39; first template parameter; the type of local indices.
void importAndFillComplete(Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, 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 > &params=Teuchos::null) const
Import from this to the given destination graph, and make the result fill complete.
bool isLocallyIndexed() const override
If graph indices are in the local range, this function returns true. Otherwise, this function returns...
void setLocallyModified()
Report that we made a local modification to its structure.
Stand-alone utility functions and macros.
void removeLocalIndices(LocalOrdinal localRow)
Remove all graph indices from the specified local row.
size_t insertIndices(RowInfo &rowInfo, const SLocalGlobalViews &newInds, const ELocalGlobal lg, const ELocalGlobal I)
Insert indices into the given row.
bool isFillComplete() const override
Returns true if fillComplete() has been called and the graph is in compute mode.
global_size_t getGlobalNumRows() const override
Returns the number of global rows in the graph.
local_graph_type::entries_type::non_const_type t_LocalOrdinal_1D TPETRA_DEPRECATED
DEPRECATED; use local_graph_type::entries_type::non_const_type instead.
Teuchos::RCP< const map_type > rowMap_
The Map describing the distribution of rows of the graph.
ProfileType pftype_
Whether the graph was allocated with static or dynamic profile.
RowInfo getRowInfoFromGlobalRowIndex(const GlobalOrdinal gblRow) const
Get information about the locally owned row with global index gblRow.
void insertLocalIndices(const LocalOrdinal localRow, const Teuchos::ArrayView< const LocalOrdinal > &indices)
Insert local indices into the graph.
bool haveGlobalConstants() const
Returns true if globalConstants have been computed; false otherwise.
global_size_t getGlobalNumDiagsImpl() const override
DO NOT CALL THIS METHOD; THIS IS NOT FOR USERS.
device_type::execution_space execution_space
This class&#39; Kokkos execution space.
local_graph_type LocalStaticCrsGraphType TPETRA_DEPRECATED
DEPRECATED; use local_graph_type (above) instead.
A parallel distribution of indices over processes.
bool indicesAreSorted_
Whether the graph&#39;s indices are sorted in each row, on this process.
Teuchos::ArrayRCP< Teuchos::Array< GlobalOrdinal > > gblInds2D_
Global column indices for all rows.
Teuchos::RCP< const export_type > getExporter() const override
Returns the exporter associated with this graph.
bool isStorageOptimized() const
Returns true if storage has been optimized.
Teuchos::RCP< const import_type > getImporter() const override
Returns the importer associated with this graph.
size_t getNodeMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, on this process.
Teuchos::RCP< const map_type > getRowMap() const override
Returns the Map that describes the row distribution in this graph.
global_size_t TPETRA_DEPRECATED getGlobalNumDiags() const override
Number of diagonal entries over all processes in the graph&#39;s communicator.
GlobalOrdinal global_ordinal_type
This class&#39; second template parameter; the type of global indices.
Teuchos::RCP< const map_type > colMap_
The Map describing the distribution of columns of the graph.
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.
Mix-in to avoid spurious deprecation warnings due to #2630.
EStorageStatus
Status of the graph&#39;s or matrix&#39;s storage, when not in a fill-complete state.
Forward declaration of Tpetra::CrsGraph.
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 > &params=Teuchos::null)
Nonmember function to create an empty CrsGraph given a row Map and the max number of entries allowed ...
Kokkos::View< GlobalOrdinal *, execution_space > t_GlobalOrdinal_1D
Type of the k_gblInds1D_ array of global column indices.
size_t TPETRA_DEPRECATED getNodeNumDiags() const override
Number of diagonal entries on the calling process.
Teuchos::ArrayRCP< Teuchos::Array< LocalOrdinal > > lclInds2D_
Local column indices for all rows.
ProfileType getProfileType() const
Returns true if the graph was allocated with static data structures.
bool sortGhostsAssociatedWithEachProcessor_
Whether to require makeColMap() (and therefore fillComplete()) to order column Map GIDs associated wi...
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 > &params=Teuchos::null)
Nonmember CrsGraph constructor that fuses Import and fillComplete().
LocalOrdinal getGlobalViewRawConst(const GlobalOrdinal *&gblInds, LocalOrdinal &capacity, const RowInfo &rowInfo) const
Get a pointer to the global column indices of a locally owned row, using the result of getRowInfoFrom...
void getGlobalRowCopy(GlobalOrdinal GlobalRow, const Teuchos::ArrayView< GlobalOrdinal > &Indices, size_t &NumIndices) const override
Get a copy of the given row, using global indices.