Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_TpetraCrsGraph_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_TPETRACRSGRAPH_DECL_HPP
47 #define XPETRA_TPETRACRSGRAPH_DECL_HPP
48 
49 /* this file is automatically generated - do not edit (see script/tpetra.py) */
50 
52 #include "Xpetra_Exceptions.hpp"
53 
54 #include "Tpetra_CrsGraph.hpp"
55 
56 #include "Xpetra_CrsGraph.hpp"
60 #include "Xpetra_Utils.hpp"
61 
62 namespace Xpetra {
63 
64 template <class LocalOrdinal,
65  class GlobalOrdinal,
66  class Node = Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
68  : public CrsGraph<LocalOrdinal, GlobalOrdinal, Node> {
69 #undef XPETRA_TPETRACRSGRAPH_SHORT
71  // The following typedef is used by the XPETRA_DYNAMIC_CAST() macro.
75  typedef Map map_type;
76 
78 
79  public:
81 
82 
84  TpetraCrsGraph(const RCP<const Map>& rowMap, size_t maxNumEntriesPerRow, const RCP<ParameterList>& params = null);
85 
87  TpetraCrsGraph(const RCP<const Map>& rowMap, const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc, const RCP<ParameterList>& params = null);
88 
90  TpetraCrsGraph(const RCP<const Map>& rowMap, const RCP<const Map>& colMap, size_t maxNumEntriesPerRow, const RCP<ParameterList>& params = null);
91 
93  TpetraCrsGraph(const RCP<const Map>& rowMap, const RCP<const Map>& colMap, const ArrayRCP<const size_t>& NumEntriesPerRowToAlloc, const RCP<ParameterList>& params = null);
94 
95  // Constructor for fused import
96  TpetraCrsGraph(const RCP<const CrsGraph>& sourceGraph,
97  const Import& importer,
98  const RCP<const Map>& domainMap = Teuchos::null,
99  const RCP<const Map>& rangeMap = Teuchos::null,
100  const RCP<Teuchos::ParameterList>& params = Teuchos::null);
101 
121  TpetraCrsGraph(const Teuchos::RCP<const Map>& rowMap,
122  const Teuchos::RCP<const Map>& colMap,
123  const typename local_graph_type::row_map_type& rowPointers,
124  const typename local_graph_type::entries_type::non_const_type& columnIndices,
125  const Teuchos::RCP<Teuchos::ParameterList>& plist = Teuchos::null);
126 
151  TpetraCrsGraph(const local_graph_type& lclGraph,
152  const Teuchos::RCP<const map_type>& rowMap,
153  const Teuchos::RCP<const map_type>& colMap,
154  const Teuchos::RCP<const map_type>& domainMap = Teuchos::null,
155  const Teuchos::RCP<const map_type>& rangeMap = Teuchos::null,
156  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
157 
176  TpetraCrsGraph(const Teuchos::RCP<const Map>& rowMap,
177  const Teuchos::RCP<const Map>& colMap,
178  const local_graph_type& lclGraph,
179  const Teuchos::RCP<Teuchos::ParameterList>& params);
180 
181  TpetraCrsGraph(const Teuchos::RCP<const Map>& rowMap,
182  const Teuchos::RCP<const Map>& colMap,
183  const Teuchos::ArrayRCP<size_t>& rowPointers,
184  const Teuchos::ArrayRCP<LocalOrdinal>& columnIndices,
185  const Teuchos::RCP<Teuchos::ParameterList>& params = Teuchos::null);
186 
188  virtual ~TpetraCrsGraph();
189 
191 
192 
194  void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal>& indices);
195 
197  void insertLocalIndices(const LocalOrdinal localRow, const ArrayView<const LocalOrdinal>& indices);
198 
200  void removeLocalIndices(LocalOrdinal localRow);
201 
203  void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t>& rowptr, ArrayRCP<LocalOrdinal>& colind);
204 
206  void setAllIndices(const ArrayRCP<size_t>& rowptr, const ArrayRCP<LocalOrdinal>& colind);
207 
209  void getAllIndices(ArrayRCP<const size_t>& rowptr, ArrayRCP<const LocalOrdinal>& colind) const;
210 
212 
214 
215 
217  void fillComplete(const RCP<const Map>& domainMap, const RCP<const Map>& rangeMap, const RCP<ParameterList>& params = null);
218 
220  void fillComplete(const RCP<ParameterList>& params = null);
221 
223  void
224  expertStaticFillComplete(const Teuchos::RCP<const map_type>& domainMap,
225  const Teuchos::RCP<const map_type>& rangeMap,
226  const Teuchos::RCP<const Import>& importer =
227  Teuchos::null,
228  const Teuchos::RCP<const Export>& exporter =
229  Teuchos::null,
230  const Teuchos::RCP<Teuchos::ParameterList>& params =
231  Teuchos::null);
233 
235 
237 
238 
240  RCP<const Comm<int> > getComm() const;
241 
243  RCP<const Map> getRowMap() const;
244 
246  RCP<const Map> getColMap() const;
247 
249  RCP<const Map> getDomainMap() const;
250 
252  RCP<const Map> getRangeMap() const;
253 
255  RCP<const Import> getImporter() const;
256 
258  RCP<const Export> getExporter() const;
259 
262 
265 
267  size_t getLocalNumRows() const;
268 
270  size_t getLocalNumCols() const;
271 
273  GlobalOrdinal getIndexBase() const;
274 
277 
279  size_t getLocalNumEntries() const;
280 
282  size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const;
283 
285  size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const;
286 
288  size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const;
289 
291  size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const;
292 
294  size_t getGlobalMaxNumRowEntries() const;
295 
297  size_t getLocalMaxNumRowEntries() const;
298 
300  bool hasColMap() const;
301 
303  bool isLocallyIndexed() const;
304 
306  bool isGloballyIndexed() const;
307 
309  bool isFillComplete() const;
310 
312  bool isStorageOptimized() const;
313 
315  void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal>& Indices) const;
316 
318  void getLocalRowView(LocalOrdinal LocalRow, ArrayView<const LocalOrdinal>& indices) const;
319 
321  typename local_graph_type::HostMirror getLocalGraphHost() const;
322 
325 
327  void getLocalDiagOffsets(const Kokkos::View<size_t*, typename Node::device_type, Kokkos::MemoryUnmanaged>& offsets) const;
328 
330  void computeGlobalConstants();
331 
333 
335 
336 
338  std::string description() const;
339 
341  void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
342 
344 
346 
347 
349  ArrayRCP<const size_t> getNodeRowPtrs() const;
350 
352 
354  //{@
355 
357  Teuchos::RCP<const Map> getMap() const;
358 
361  const Import& importer, CombineMode CM);
362 
365  const Import& importer, CombineMode CM);
366 
369  const Export& exporter, CombineMode CM);
370 
373  const Export& exporter, CombineMode CM);
374 
375  // @}
376 
378 
379 
381  TpetraCrsGraph(const Teuchos::RCP<Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >& graph);
382 
384  RCP<const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > getTpetra_CrsGraph() const;
385 
387 
388  private:
389  RCP<Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > graph_;
390 }; // TpetraCrsGraph class
391 
392 // TODO: move that elsewhere
393 template <class LocalOrdinal, class GlobalOrdinal, class Node>
394 RCP<const CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
395 toXpetra(RCP<const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > graph) { // TODO: return TpetraCrsGraph instead of CrsGraph
396  // typedef TpetraCrsGraph<LocalOrdinal, GlobalOrdinal, Node> TpetraCrsGraphClass;
397  // XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tGraph, "toTpetra");
398  if (graph.is_null()) {
399  return Teuchos::null;
400  }
401  RCP<Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> > tGraph =
402  Teuchos::rcp_const_cast<Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >(graph);
404 }
405 
406 template <class LocalOrdinal, class GlobalOrdinal, class Node>
407 RCP<const Tpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node> >
409  typedef TpetraCrsGraph<LocalOrdinal, GlobalOrdinal, Node> TpetraCrsGraphClass;
410  XPETRA_RCP_DYNAMIC_CAST(const TpetraCrsGraphClass, graph, tpetraCrsGraph, "toTpetra");
411  return tpetraCrsGraph->getTpetra_CrsGraph();
412 }
413 
414 } // namespace Xpetra
415 
416 #endif // XPETRA_TPETRACRSGRAPH_DECL_HPP
void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices)
Insert local indices into the graph.
TpetraExport< LocalOrdinal, GlobalOrdinal, Node > TpetraExportClass
bool isGloballyIndexed() const
Whether column indices are stored using global indices on the calling process.
TpetraImport< LocalOrdinal, GlobalOrdinal, Node > TpetraImportClass
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import &importer, CombineMode CM)
Export.
Kokkos::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_type
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
local_graph_type::HostMirror getLocalGraphHost() const
Access the local KokkosSparse::StaticCrsGraph data for host use.
RCP< const Map > getDomainMap() const
Returns the Map associated with the domain of this graph.
RCP< Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > graph_
void expertStaticFillComplete(const Teuchos::RCP< const map_type > &domainMap, const Teuchos::RCP< const map_type > &rangeMap, const Teuchos::RCP< const Import > &importer=Teuchos::null, const Teuchos::RCP< const Export > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Expert version of fillComplete.
RCP< const Map > getColMap() const
Returns the Map that describes the column distribution in this graph.
void computeGlobalConstants()
Force the computation of global constants if we don&#39;t have them.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsGraph() const
Get the underlying Tpetra graph.
TpetraCrsGraph< LocalOrdinal, GlobalOrdinal, Node > TpetraCrsGraphClass
GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this graph.
RCP< const Import > getImporter() const
Returns the importer associated with this graph.
void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices)
Insert global indices into the graph.
bool isStorageOptimized() const
Returns true if storage has been optimized.
size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of allocated entries on this node in the specified local row...
RCP< const Comm< int > > getComm() const
Returns the communicator.
TpetraCrsGraph(const RCP< const Map > &rowMap, size_t maxNumEntriesPerRow, const RCP< ParameterList > &params=null)
Constructor specifying fixed number of entries for each row.
RCP< const Export > getExporter() const
Returns the exporter associated with this graph.
bool isFillComplete() const
Whether fillComplete() has been called and the graph is in compute mode.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const
Return a const, nonpersisting view of local indices in the given row.
global_size_t getGlobalNumRows() const
Returns the number of global rows in the graph.
void doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Import &importer, CombineMode CM)
Import.
size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of allocated entries for this node in the specified global row ...
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
Teuchos::RCP< const Map > getMap() const
Implements DistObject interface.
void allocateAllIndices(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind)
Allocates the 1D pointer arrays of the graph.
void getAllIndices(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind) const
Gets the 1D pointer arrays of the graph.
local_graph_type getLocalGraphDevice() const
Access the local KokkosSparse::StaticCrsGraph data for device use.
size_t getLocalNumEntries() const
Returns the local number of entries in the graph.
virtual ~TpetraCrsGraph()
Destructor.
size_t global_size_t
Global size_t object.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const
Return a const, nonpersisting view of global indices in the given row.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in the graph.
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
size_t getGlobalMaxNumRowEntries() const
Maximum number of entries in all rows over all processes.
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
size_t getLocalMaxNumRowEntries() const
Maximum number of entries in all rows owned by the calling process.
void getLocalDiagOffsets(const Kokkos::View< size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
Get offsets of the diagonal entries in the matrix.
bool hasColMap() const
Whether the graph has a column Map.
bool isLocallyIndexed() const
Whether column indices are stored using local indices on the calling process.
void fillComplete(const RCP< const Map > &domainMap, const RCP< const Map > &rangeMap, const RCP< ParameterList > &params=null)
Signal that data entry is complete, specifying domain and range maps.
global_size_t getGlobalNumCols() const
Returns the number of global columns in the graph.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_type local_graph_type
void removeLocalIndices(LocalOrdinal localRow)
Remove all graph indices from the specified local row.
CombineMode
Xpetra::Combine Mode enumerable type.
std::string description() const
Return a simple one-line description of this object.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void setAllIndices(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind)
Sets the 1D pointer arrays of the graph.
RCP< const Map > getRowMap() const
Returns the Map that describes the row distribution in this graph.
RCP< const Map > getRangeMap() const
Returns the Map associated with the domain of this graph.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this graph.
ArrayRCP< const size_t > getNodeRowPtrs() const
Get an ArrayRCP of the row-offsets.
size_t getLocalNumRows() const
Returns the number of graph rows owned on the calling node.