Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_FECrsGraph_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TPETRA_FECRSGRAPH_DECL_HPP
11 #define TPETRA_FECRSGRAPH_DECL_HPP
12 
15 
16 #include "Tpetra_ConfigDefs.hpp"
18 #include "Tpetra_CrsGraph_decl.hpp"
19 
20 namespace Tpetra {
88 
89  template <class LocalOrdinal,
90  class GlobalOrdinal,
91  class Node>
92  class FECrsGraph :
93  public CrsGraph<LocalOrdinal, GlobalOrdinal, Node>
94  {
97 
98  template <class S, class LO, class GO, class N>
99  friend class FECrsMatrix;
100  public:
103 
105  typedef LocalOrdinal local_ordinal_type;
107  typedef GlobalOrdinal global_ordinal_type;
109  typedef Node node_type;
110 
115 
118 
125 
127 
128 
152  FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
153  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
154  const size_t maxNumEntriesPerRow,
155  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
156  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
157  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
158  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
159 
186  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
187  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
188  const size_t maxNumEntriesPerRow,
189  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
190  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
191  const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
192  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
193  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
194 
218  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
219  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
220  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
221  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
222  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
223  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
224  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
225 
252  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
253  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
254  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
255  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
256  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
257  const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
258  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
259  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
260 
261 
287  FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
288  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
289  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
290  const size_t maxNumEntriesPerRow,
291  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
292  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
293  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
294  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
295 
323  FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
324  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
325  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
326  const size_t maxNumEntriesPerRow,
327  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
328  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
329  const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
330  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
331  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
332 
333 
357  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
358  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
359  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
360  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
361  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
362  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
363  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
364  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
365 
390  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
391  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
392  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
393  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
394  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
395  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
396  const Teuchos::RCP<const map_type> & ownedDomainMap = Teuchos::null,
397  const Teuchos::RCP<const map_type> & ownedRangeMap = Teuchos::null,
398  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
399 
402 
405 
407  FECrsGraph&
409 
411  FECrsGraph&
413 
423  virtual ~FECrsGraph () = default;
424 
426 
428  Teuchos::RCP<const Teuchos::ParameterList>
430  getValidParameters () const override;
431 
433 
435 
437  void endAssembly();
438  void endAssembly(const Teuchos::RCP<const map_type>& domainMap, const Teuchos::RCP<const map_type>& rangeMap);
439 
441  void beginAssembly();
442 
480  void
481  fillComplete (const Teuchos::RCP<const map_type>& ownedDomainMap,
482  const Teuchos::RCP<const map_type>& ownedRangeMap,
483  const Teuchos::RCP<Teuchos::ParameterList>& /* params */ = Teuchos::null) {
484  ownedDomainMap_ = ownedDomainMap;
485  ownedRangeMap_ = ownedRangeMap;
486  endFill();
487  }
488 
516  void
517  fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& /* params */ = Teuchos::null) {endFill();}
518 
519 
520  private:
521 
523  void endFill();
524  void endFill(const Teuchos::RCP<const map_type>& domainMap, const Teuchos::RCP<const map_type>& rangeMap);
525 
527  void beginFill();
528 
532  void doOwnedPlusSharedToOwned(const CombineMode CM=Tpetra::ADD);
533 
536  void doOwnedToOwnedPlusShared(const CombineMode CM=Tpetra::ADD);
537 
538  public:
540  void switchActiveCrsGraph();
542 
543  private:
544 
545  // Common core guts of the constructor (the colMap argument is Teuchos::null if we're globally-indexed)
546  void setup(const Teuchos::RCP<const map_type> & ownedRowMap, const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,const Teuchos::RCP<const map_type> & ownedPlusSharedColMap, const Teuchos::RCP<Teuchos::ParameterList>& params);
547 
548  // Template to avoid long type names...lazy.
549  // template<typename ViewType>
550  // Teuchos::RCP<const map_type> makeOwnedColMap (ViewType ownedGraphIndices);
551 
552  Teuchos::RCP<FE::FillState> fillState_;
553 
554  // This is whichever graph isn't currently active
555  Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > inactiveCrsGraph_;
556 
557  // This is in RCP to make shallow copies of the FECrsGraph work correctly
558  Teuchos::RCP<FE::WhichActive> activeCrsGraph_;
559 
560  // The importer between the rowmaps of the two graphs
561  Teuchos::RCP<const import_type> ownedRowsImporter_;
562 
563  // The domainMap to use in endFill() for the owned graph
564  Teuchos::RCP<const map_type> ownedDomainMap_;
565 
566  // The rangeMap to use in endFill() for the owned graph
567  Teuchos::RCP<const map_type> ownedRangeMap_;
568 
569  protected:
579  size_t
581  const global_ordinal_type inputGblColInds[],
582  const size_t numInputInds);
583 
593  size_t
594  insertGlobalIndicesImpl (const RowInfo& rowInfo,
595  const global_ordinal_type inputGblColInds[],
596  const size_t numInputInds,
597  std::function<void(const size_t, const size_t, const size_t)> fun =
598  std::function<void(const size_t, const size_t, const size_t)>());
599 
600  void
601  insertLocalIndicesImpl (const local_ordinal_type lclRow,
602  const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
603  std::function<void(const size_t, const size_t, const size_t)> fun =
604  std::function<void(const size_t, const size_t, const size_t)>());
605 
606  }; // class FECrsGraph
607 
608 
609 } // namespace Tpetra
610 
611 #endif // TPETRA_FECRSGRAPH_DECL_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
void endAssembly()
Migrates data to the owned mode.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_device_type local_graph_device_type
The type of the part of the sparse graph on each MPI process.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::device_type device_type
The Kokkos device type.
FECrsGraph(const Teuchos::RCP< const map_type > &ownedRowMap, const Teuchos::RCP< const map_type > &ownedPlusSharedRowMap, const size_t maxNumEntriesPerRow, const Teuchos::RCP< const import_type > &ownedPlusSharedToOwnedimporter=Teuchos::null, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &ownedRangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructorfor globally-indexed assembly specifying a single upper bound for the number of entries in...
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
The type of the part of the sparse graph on each MPI process.
Declaration of the Tpetra::CrsGraph class.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
FECrsGraph & operator=(const FECrsGraph< LocalOrdinal, GlobalOrdinal, Node > &)=delete
Copy assignment (forbidden).
void fillComplete(const Teuchos::RCP< const map_type > &ownedDomainMap, const Teuchos::RCP< const map_type > &ownedRangeMap, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Tell the graph that you are done changing its structure.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::execution_space execution_space
The Kokkos execution space.
Communication plan for data redistribution from a (possibly) multiply-owned to a uniquely-owned distr...
CombineMode
Rule for combining data in an Import or Export.
Sum new values.
typename device_type::execution_space execution_space
This class&#39; Kokkos execution space.
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 switchActiveCrsGraph()
Switches which CrsGraph is active (without migrating data)
CrsGraph< LocalOrdinal, GlobalOrdinal, Node > crs_graph_type
Parent class.
void fillComplete(const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Tell the graph that you are done changing its structure; set default domain and range Maps...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
A parallel distribution of indices over processes.
Forward declaration of Tpetra::FECrsGraph.
void beginAssembly()
Activates the owned+shared mode for assembly.
typename Node::device_type device_type
This class&#39; Kokkos device type.
LocalOrdinal local_ordinal_type
This class&#39; first template parameter; the type of local indices.
GlobalOrdinal global_ordinal_type
This class&#39; second template parameter; the type of global indices.
Node node_type
This class&#39; Kokkos Node type.
virtual ~FECrsGraph()=default
Destructor (virtual for memory safety of derived classes).