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 //
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_FECRSGRAPH_DECL_HPP
43 #define TPETRA_FECRSGRAPH_DECL_HPP
44 
52 
54 #include "Tpetra_CrsGraph_decl.hpp"
55 
56 namespace Tpetra {
76 
77  template <class LocalOrdinal,
78  class GlobalOrdinal,
79  class Node>
80  class FECrsGraph :
81  public CrsGraph<LocalOrdinal, GlobalOrdinal, Node>
82  {
85 
86  template <class S, class LO, class GO, class N>
87  friend class FECrsMatrix;
88  public:
91 
93  typedef LocalOrdinal local_ordinal_type;
95  typedef GlobalOrdinal global_ordinal_type;
97  typedef Node node_type;
98 
103 
106 
113 
115 
116 
140  FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
141  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
142  const size_t maxNumEntriesPerRow,
143  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
144  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
145  const Teuchos::RCP<const map_type> & rangeMap = Teuchos::null,
146  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
147 
171  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
172  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
173  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
174  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
175  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
176  const Teuchos::RCP<const map_type> & rangeMap = Teuchos::null,
177  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
178 
179 
205  FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
206  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
207  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
208  const size_t maxNumEntriesPerRow,
209  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
210  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
211  const Teuchos::RCP<const map_type> & rangeMap = Teuchos::null,
212  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
213 
214 
238  FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
239  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
240  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
241  const Kokkos::DualView<const size_t*, execution_space>& numEntPerRow,
242  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter = Teuchos::null,
243  const Teuchos::RCP<const map_type> & domainMap = Teuchos::null,
244  const Teuchos::RCP<const map_type> & rangeMap = Teuchos::null,
245  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
246 
249 
252 
254  FECrsGraph&
256 
258  FECrsGraph&
260 
270  virtual ~FECrsGraph () = default;
271 
273 
275 
277  void endFill();
278 
280  void beginFill();
281 
319  void
320  fillComplete (const Teuchos::RCP<const map_type>& domainMap,
321  const Teuchos::RCP<const map_type>& rangeMap,
322  const Teuchos::RCP<Teuchos::ParameterList>& /* params */ = Teuchos::null) {
323  domainMap_ = domainMap;
324  rangeMap_ = rangeMap;
325  endFill();
326  }
327 
355  void
356  fillComplete (const Teuchos::RCP<Teuchos::ParameterList>& /* params */ = Teuchos::null) {endFill();}
357 
358 
359  private:
363  void doOwnedPlusSharedToOwned(const CombineMode CM=Tpetra::ADD);
364 
367  void doOwnedToOwnedPlusShared(const CombineMode CM=Tpetra::ADD);
368 
369  public:
371  void switchActiveCrsGraph();
373 
374  private:
375 
376  // Common core guts of the constructor (the colMap argument is Teuchos::null if we're globally-indexed)
377  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);
378 
379  // Enum for activity
380  enum FEWhichActive
381  {
382  FE_ACTIVE_OWNED,
383  FE_ACTIVE_OWNED_PLUS_SHARED
384  };
385 
386 
387  // This is whichever multivector isn't currently active
388  Teuchos::RCP<CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > inactiveCrsGraph_;
389  // This is in RCP to make shallow copies of the FECrsGraph work correctly
390  Teuchos::RCP<FEWhichActive> activeCrsGraph_;
391 
392  // The importer between the rowmaps of the two graphs
393  Teuchos::RCP<const import_type> importer_;
394 
395  // The domainMap to use in endFill(), if provided
396  Teuchos::RCP<const map_type> domainMap_;
397 
398  // The rangeMap to use in endFill(), if provided
399  Teuchos::RCP<const map_type> rangeMap_;
400 
401 
402  }; // class FECrsGraph
403 
404 
405 } // namespace Tpetra
406 
407 #endif // TPETRA_FECRSGRAPH_DECL_HPP
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Kokkos::StaticCrsGraph< local_ordinal_type, Kokkos::LayoutLeft, device_type > local_graph_type
The type of the part of the sparse graph on each MPI process.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::device_type device_type
The Kokkos device type.
void endFill()
Migrates data to the owned mode.
Declaration of the Tpetra::CrsGraph class.
CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_type local_graph_type
The type of the part of the sparse graph on each MPI process.
FECrsGraph & operator=(const FECrsGraph< LocalOrdinal, GlobalOrdinal, Node > &)=delete
Copy assignment (forbidden).
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...
void beginFill()
Activates the owned+shared mode for assembly. This can only be called once.
CombineMode
Rule for combining data in an Import or Export.
Sum new values into existing values.
typename device_type::execution_space execution_space
This class&#39; Kokkos execution space.
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.
typename Node::device_type device_type
This class&#39; Kokkos device type.
void fillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< Teuchos::ParameterList > &=Teuchos::null)
Tell the graph that you are done changing its structure.
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).
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 > &rangeMap=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...