Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_EpetraCrsGraph.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Xpetra: A linear algebra interface package
4//
5// Copyright 2012 NTESS and the Xpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef XPETRA_EPETRACRSGRAPH_HPP
11#define XPETRA_EPETRACRSGRAPH_HPP
12
13/* this file is automatically generated - do not edit (see script/epetra.py) */
14
16#include "Xpetra_Exceptions.hpp"
17
18#include "Xpetra_CrsGraph.hpp"
19
22#include "Xpetra_EpetraMap.hpp"
24
25#include <Epetra_CrsGraph.h>
26
27#if defined(XPETRA_ENABLE_DEPRECATED_CODE)
28#ifdef __GNUC__
29#if defined(Xpetra_SHOW_DEPRECATED_WARNINGS)
30#warning "The header file Trilinos/packages/xpetra/src/CrsGraph/Xpetra_EpetraCrsGraph.hpp is deprecated."
31#endif
32#endif
33#else
34#error "The header file Trilinos/packages/xpetra/src/CrsGraph/Xpetra_EpetraCrsGraph.hpp is deprecated."
35#endif
36
37namespace Xpetra {
38
39// TODO: move that elsewhere
40template <class GlobalOrdinal, class Node>
41XPETRA_DEPRECATED RCP<const CrsGraph<int, GlobalOrdinal, Node>>
42toXpetra(const Epetra_CrsGraph &graph);
43
44template <class GlobalOrdinal, class Node>
45XPETRA_DEPRECATED const Epetra_CrsGraph &
46toEpetra(const RCP<const CrsGraph<int, GlobalOrdinal, Node>> &graph);
47
48template <class GlobalOrdinal, class Node>
49class XPETRA_DEPRECATED EpetraCrsGraphT
50 : public CrsGraph<int, GlobalOrdinal, Node> {
51 typedef int LocalOrdinal;
52
55
56#ifdef HAVE_XPETRA_TPETRA
61 typedef typename node_type::execution_space execution_space;
62#endif
63
64 public:
66
67
68 EpetraCrsGraphT(const RCP<const map_type> &rowMap, const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
70 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
71 }
72
74 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
76 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
77 }
78
80 EpetraCrsGraphT(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP<Teuchos::ParameterList> &plist = null) {
82 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
83 }
84
86 // Definition not in cpp, so comment out
87 EpetraCrsGraphT(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, const RCP<ParameterList> &params = null) {
89 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
90 }
91
92 // Constructor for fused import
95 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap = Teuchos::null,
96 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap = Teuchos::null,
97 const RCP<Teuchos::ParameterList> &params = Teuchos::null) {
99 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
100 }
101
102#ifdef HAVE_XPETRA_TPETRA
105 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
106 const typename local_graph_type::row_map_type &rowPointers,
107 const typename local_graph_type::entries_type::non_const_type &columnIndices,
108 const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
110 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
111 }
112
115 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
116 const local_graph_type &lclGraph,
117 const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
119 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
120 }
121
124 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap,
125 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
126 const Teuchos::RCP<const map_type> &domainMap = Teuchos::null,
127 const Teuchos::RCP<const map_type> &rangeMap = Teuchos::null,
128 const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
130 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
131 }
132#endif
133
135 virtual ~EpetraCrsGraphT() {}
136
138
140
141
143 void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &indices) {}
144
146 void insertLocalIndices(const LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &indices) {}
147
150
152 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {}
153
155 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {}
156
159
161
163
164
166 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {}
167
169 void fillComplete(const RCP<ParameterList> &params = null) {}
170
172 void
176 Teuchos::null,
178 Teuchos::null,
180 Teuchos::null) {}
181
183
185
186
189 return Teuchos::null;
190 }
191
194
197
200
203
206
209
211 global_size_t getGlobalNumRows() const { return 0; }
212
214 global_size_t getGlobalNumCols() const { return 0; }
215
217 size_t getLocalNumRows() const { return 0; }
218
220 size_t getLocalNumCols() const { return 0; }
221
223 GlobalOrdinal getIndexBase() const { return 0; }
224
226 global_size_t getGlobalNumEntries() const { return 0; }
227
229 size_t getLocalNumEntries() const { return 0; }
230
232 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const { return 0; }
233
235 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { return 0; }
236
238 size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const { return 0; }
239
241 size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const { return 0; }
242
244 size_t getGlobalMaxNumRowEntries() const { return 0; }
245
247 size_t getLocalMaxNumRowEntries() const { return 0; }
248
250 bool hasColMap() const { return false; }
251
253 bool isLocallyIndexed() const { return false; }
254
256 bool isGloballyIndexed() const { return false; }
257
259 bool isFillComplete() const { return false; }
260
262 bool isStorageOptimized() const { return false; }
263
265 void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &Indices) const {}
266
269
270#ifdef HAVE_XPETRA_TPETRA
271#if KOKKOS_VERSION >= 40799
272 typename local_graph_type::host_mirror_type getLocalGraphHost() const {
274 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
275 TEUCHOS_UNREACHABLE_RETURN((typename local_graph_type::host_mirror_type()));
276 }
277#else
278 typename local_graph_type::HostMirror getLocalGraphHost() const {
280 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
281 TEUCHOS_UNREACHABLE_RETURN((typename local_graph_type::HostMirror()));
282 }
283#endif
284#else
285#ifdef __GNUC__
286#warning "Xpetra Kokkos interface for CrsGraph is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
287#endif
288#endif
289
290#ifdef HAVE_XPETRA_TPETRA
293 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
295 }
296
297 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
299 "Epetra does not support getLocalDiagOffsets!");
300 }
301#else
302#ifdef __GNUC__
303#warning "Xpetra Kokkos interface for CrsGraph is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
304#endif
305
306#endif
307
310
312
314
315
317 std::string description() const { return std::string(""); }
318
321
323
325 //{@
326
329
333
337
341
346
348
349
353 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
354 }
355
357 RCP<const Epetra_CrsGraph> getEpetra_CrsGraph() const { return Teuchos::null; }
358
360
361 private:
362}; // EpetraCrsGraphT class
363
364// specialization on GO=int and Node=EpetraNode
365#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
366template <>
368 : public virtual CrsGraph<int, int, EpetraNode> {
369 typedef int LocalOrdinal;
370 typedef int GlobalOrdinal;
372
375
376#ifdef HAVE_XPETRA_TPETRA
379 typedef typename node_type::execution_space execution_space;
380#endif
381
382 public:
384
385
388 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), 0, false))) {}
389
391 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
392 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true))) {}
393
395 // Definition not in cpp, so comment out
396 // EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null);
397
399 EpetraCrsGraphT(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP<Teuchos::ParameterList> & /* plist */ = null)
400 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true))) {}
401
403 // Definition not in cpp, so comment out
404 EpetraCrsGraphT(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, const RCP<ParameterList> & /* params */ = null) {
405 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
406 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
407 }
408
409 // Constructor for fused import
412 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap = Teuchos::null,
413 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap = Teuchos::null,
414 const RCP<Teuchos::ParameterList> &params = Teuchos::null) {
415 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, *sourceGraph, tSourceGraph, "Xpetra::EpetraCrsGraphT() only accepts Xpetra::EpetraCrsGraphT as input arguments.");
416 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
417 RCP<const Epetra_CrsGraph> eSourceGraph = tSourceGraph.getEpetra_CrsGraph();
418
419 // NOTE: Unlike Tpetra, Epetra does not have a FusedTransfer for Graphs. So we do this the slow way
420 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, eSourceGraph->RowMap(), 0, false));
421 graph_->Import(*eSourceGraph, *tImporter.getEpetra_Import(), Insert);
422
423 const Epetra_BlockMap &myDomainMap = domainMap != Teuchos::null ? toEpetra<GlobalOrdinal, Node>(domainMap) : eSourceGraph->ColMap();
424 const Epetra_BlockMap &myRangeMap = rangeMap != Teuchos::null ? toEpetra<GlobalOrdinal, Node>(rangeMap) : toEpetra<LocalOrdinal, Node>(importer.getTargetMap());
425
426 graph_->FillComplete(myDomainMap, myRangeMap);
427 }
428
429#ifdef HAVE_XPETRA_TPETRA
432 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
433 const typename local_graph_type::row_map_type & /* rowPointers */,
434 const typename local_graph_type::entries_type::non_const_type & /* columnIndices */,
435 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
437 "Epetra does not support CrsGraph constructors using Kokkos Views!");
438 }
439
442 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
443 const local_graph_type & /* lclGraph */,
444 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
446 "Epetra does not support CrsGraph constructors using a local graph!");
447 }
448
450 EpetraCrsGraphT(const local_graph_type & /* lclGraph */,
451 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* rowMap */,
452 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
453 const Teuchos::RCP<const map_type> & /* domainMap */ = Teuchos::null,
454 const Teuchos::RCP<const map_type> & /* rangeMap */ = Teuchos::null,
455 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
457 "Epetra does not support CrsGraph constructors using a local graph!");
458 }
459#endif
460
462 virtual ~EpetraCrsGraphT() {}
463
465
467
468
471 XPETRA_MONITOR("EpetraCrsGraphT::insertGlobalIndices");
472
473 GlobalOrdinal *indices_rawPtr = const_cast<GlobalOrdinal *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
474 XPETRA_ERR_CHECK(graph_->InsertGlobalIndices(globalRow, indices.size(), indices_rawPtr));
475 }
476
478 void insertLocalIndices(const LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &indices) {
479 XPETRA_MONITOR("EpetraCrsGraphT::insertLocalIndices");
480
481 int *indices_rawPtr = const_cast<int *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
482 XPETRA_ERR_CHECK(graph_->InsertMyIndices(localRow, indices.size(), indices_rawPtr));
483 }
484
487 XPETRA_MONITOR("EpetraCrsGraphT::removeLocalIndices");
488 graph_->RemoveMyIndices(localRow);
489 }
490
492 //** \warning This is an expert-only routine and should not be called from user code. */
493 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {
494 XPETRA_MONITOR("EpetraCrsGraphT::allocateAllIndies");
495
496 // Row offsets
497 // Unfortunately, we cannot do this in the same manner as column indices
498 // and values (see below). The problem is that Tpetra insists on using
499 // size_t, and Epetra uses int internally. So we only resize here, and
500 // will need to copy in setAllValues
501 rowptr.resize(getLocalNumRows() + 1);
502
503 int lowerOffset = 0;
504 bool ownMemory = false;
505
506 // Column indices
507 // Extract, resize, set colind
508 Epetra_IntSerialDenseVector &myColind = graph_->ExpertExtractIndices();
509 myColind.Resize(numNonZeros);
510 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
511 }
512
514 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {
515 XPETRA_MONITOR("EpetraCrsGraphT::setAllIndices");
516
517 // Check sizes
519 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
520 if (colind.size() > 0) {
521 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != graph_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
522 "An exception is thrown to let you know that you mismatched your pointers.");
523 }
524
525 // We have to make a copy here, it is unavoidable
526 // See comments in allocateAllIndices
527 const size_t N = getLocalNumRows();
528
529 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
530 myRowptr.Resize(N + 1);
531 for (size_t i = 0; i < N + 1; i++)
532 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
533 }
534
537 XPETRA_MONITOR("EpetraCrsGraphT::getAllIndices");
538
539 int lowerOffset = 0;
540 bool ownMemory = false;
541
542 const size_t n = getLocalNumRows();
543 const size_t nnz = getLocalNumEntries();
544
545 // Row offsets
546 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
547 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
548 rowptr.resize(n + 1);
549 for (size_t i = 0; i < n + 1; i++)
550 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
551
552 // Column indices
553 colind = Teuchos::arcp(graph_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
554 }
555
557
559
560
562 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {
563 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
564
565 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
566 bool doOptimizeStorage = true;
567 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
568 if (doOptimizeStorage) graph_->OptimizeStorage();
569 }
570
572 void fillComplete(const RCP<ParameterList> &params = null) {
573 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
574
575 graph_->FillComplete();
576 bool doOptimizeStorage = true;
577 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
578 if (doOptimizeStorage) graph_->OptimizeStorage();
579 }
580
582 void
586 Teuchos::null,
588 Teuchos::null,
590 Teuchos::null) {
591 // Not optimized
592 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
593 graph_->OptimizeStorage();
594 }
595
597
599
600
603 XPETRA_MONITOR("EpetraCrsGraphT::getComm");
604 return toXpetra(graph_->Comm());
605 }
606
609 XPETRA_MONITOR("EpetraCrsGraphT::getRowMap");
610 return toXpetra<GlobalOrdinal, Node>(graph_->RowMap());
611 }
612
615 XPETRA_MONITOR("EpetraCrsGraphT::getColMap");
616 return toXpetra<GlobalOrdinal, Node>(graph_->ColMap());
617 }
618
621 XPETRA_MONITOR("EpetraCrsGraphT::getDomainMap");
622 return toXpetra<GlobalOrdinal, Node>(graph_->DomainMap());
623 }
624
627 XPETRA_MONITOR("EpetraCrsGraphT::getRangeMap");
628 return toXpetra<GlobalOrdinal, Node>(graph_->RangeMap());
629 }
630
633 XPETRA_MONITOR("EpetraCrsGraphT::getImporter");
634 return toXpetra<GlobalOrdinal, Node>(graph_->Importer());
635 }
636
639 XPETRA_MONITOR("EpetraCrsGraphT::getExporter");
640 return toXpetra<GlobalOrdinal, Node>(graph_->Exporter());
641 }
642
645 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumRows");
646 return graph_->NumGlobalRows64();
647 }
648
651 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumCols");
652 return graph_->NumGlobalCols64();
653 }
654
656 size_t getLocalNumRows() const {
657 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumRows");
658 return graph_->NumMyRows();
659 }
660
662 size_t getLocalNumCols() const {
663 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumCols");
664 return graph_->NumMyCols();
665 }
666
669 XPETRA_MONITOR("EpetraCrsGraphT::getIndexBase");
670 return (GlobalOrdinal)graph_->IndexBase64();
671 }
672
675 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumEntries");
676 return graph_->NumGlobalEntries64();
677 }
678
680 size_t getLocalNumEntries() const {
681 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumEntries");
682 return graph_->NumMyEntries();
683 }
684
686 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
687 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInGlobalRow");
688 return graph_->NumGlobalIndices(globalRow);
689 }
690
692 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
693 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInLocalRow");
694 return graph_->NumMyIndices(localRow);
695 }
696
699 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInGlobalRow");
700 return graph_->NumAllocatedGlobalIndices(globalRow);
701 }
702
705 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInLocalRow");
706 return graph_->NumAllocatedMyIndices(localRow);
707 }
708
711 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalMaxNumRowEntries");
712 return graph_->GlobalMaxNumIndices();
713 }
714
717 XPETRA_MONITOR("EpetraCrsGraphT::getLocalMaxNumRowEntries");
718 return graph_->MaxNumIndices();
719 }
720
722 bool hasColMap() const {
723 XPETRA_MONITOR("EpetraCrsGraphT::hasColMap");
724 return graph_->HaveColMap();
725 }
726
728 bool isLocallyIndexed() const {
729 XPETRA_MONITOR("EpetraCrsGraphT::isLocallyIndexed");
730 return graph_->IndicesAreLocal();
731 }
732
734 bool isGloballyIndexed() const {
735 XPETRA_MONITOR("EpetraCrsGraphT::isGloballyIndexed");
736 return graph_->IndicesAreGlobal();
737 }
738
740 bool isFillComplete() const {
741 XPETRA_MONITOR("EpetraCrsGraphT::isFillComplete");
742 return graph_->Filled();
743 }
744
746 bool isStorageOptimized() const {
747 XPETRA_MONITOR("EpetraCrsGraphT::isStorageOptimized");
748 return graph_->StorageOptimized();
749 }
750
753 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalRowView");
754
755 int numEntries;
756 GlobalOrdinal *eIndices;
757
758 XPETRA_ERR_CHECK(graph_->ExtractGlobalRowView(GlobalRow, numEntries, eIndices));
759 if (numEntries == 0) {
760 eIndices = NULL;
761 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
762
763 Indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
764 }
765
768 XPETRA_MONITOR("EpetraCrsGraphT::getLocalRowView");
769
770 int numEntries;
771 int *eIndices;
772
773 XPETRA_ERR_CHECK(graph_->ExtractMyRowView(LocalRow, numEntries, eIndices));
774 if (numEntries == 0) {
775 eIndices = NULL;
776 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
777
778 indices = ArrayView<const int>(eIndices, numEntries);
779 }
780
781#ifdef HAVE_XPETRA_TPETRA
782#if KOKKOS_VERSION >= 40799
783 typename local_graph_type::host_mirror_type getLocalGraphHost() const {
784#else
785 typename local_graph_type::HostMirror getLocalGraphHost() const {
786#endif
787 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
788
789#if KOKKOS_VERSION >= 40799
790 using local_graph_type_host = typename local_graph_type::host_mirror_type;
791#else
792 using local_graph_type_host = typename local_graph_type::HostMirror;
793#endif
794
795 const int numRows = graph->NumMyRows();
796 const int nnz = graph->NumMyNonzeros();
797
798 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
799 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
800 int *colind = graph->ExpertExtractIndices().Values();
801
802 // Transform int* rowptr array to size_type* array
803 typename local_graph_type_host::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
804 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
805 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type_host::row_map_type::value_type>(rowptr[i]);
806
807 // create Kokkos::Views
808 typename local_graph_type_host::entries_type kokkosColind(colind, nnz);
809
810 local_graph_type_host localGraph = local_graph_type_host(kokkosColind, kokkosRowPtr);
811
812 return localGraph;
813 }
814
816 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
817
818 const int numRows = graph->NumMyRows();
819 const int nnz = graph->NumMyNonzeros();
820
821 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
822 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
823 int *colind = graph->ExpertExtractIndices().Values();
824
825 // Transform int* rowptr array to size_type* array
826 typename local_graph_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
827 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
828 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type::row_map_type::value_type>(rowptr[i]);
829
830 // create Kokkos::Views
831 typename local_graph_type::entries_type kokkosColind(colind, nnz);
832
833 local_graph_type localGraph = local_graph_type(kokkosColind, kokkosRowPtr);
834
835 return localGraph;
836 }
837
838 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
840 "Epetra does not support getLocalDiagOffsets!");
841 }
842#else
843#ifdef __GNUC__
844#warning "Xpetra Kokkos interface for CrsGraph is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
845#endif
846#endif
847
850
852
854
855
857 std::string description() const {
858 XPETRA_MONITOR("EpetraCrsGraphT::description");
859 return "NotImplemented";
860 }
861
864 XPETRA_MONITOR("EpetraCrsGraphT::describe");
865
866 out << "EpetraCrsGraphT::describe : Warning, verbosity level is ignored by this method." << std::endl;
867 const Epetra_BlockMap rowmap = graph_->RowMap();
868 if (rowmap.Comm().MyPID() == 0) out << "** EpetraCrsGraphT **\n\nrowmap" << std::endl;
869 rowmap.Print(out);
870 graph_->Print(out);
871 }
872
874
876 //{@
877
880 XPETRA_MONITOR("EpetraCrsGraphT::getMap");
881 return toXpetra<GlobalOrdinal, Node>(graph_->Map());
882 }
883
887 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
888
889 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
890 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
891
892 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
893 int err = graph_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
894 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
895 }
896
900 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
901
902 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
903 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
904
905 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
906 int err = graph_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
907 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
908 }
909
913 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
914
915 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
916 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
917
918 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
919 int err = graph_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
920 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
921 }
922
926 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
927
928 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
929 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
930
931 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
932 int err = graph_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
933 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
934 }
936
938
939
942 : graph_(graph) {
943 TEUCHOS_TEST_FOR_EXCEPTION(!graph->RowMap().GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraCrsGraphT: GlobalOrdinal mismatch.");
944 }
945
948
950
951 private:
953};
954
955#endif // specialization on Node=EpetraNode and GO=int
956
957// specialization on GO=long long and Node=EpetraNode
958#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
959template <>
961 : public virtual CrsGraph<int, long long, EpetraNode> {
962 typedef int LocalOrdinal;
963 typedef long long GlobalOrdinal;
965
968
969#ifdef HAVE_XPETRA_TPETRA
972 typedef typename node_type::execution_space execution_space;
973#endif
974
975 public:
977
978
981 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), 0, false))) {}
982
984 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
985 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true))) {}
986
988 // Definition not in cpp, so comment out
989 // EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null);
990
992 EpetraCrsGraphT(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP<Teuchos::ParameterList> & /* plist */ = null)
993 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true))) {}
994
996 // Definition not in cpp, so comment out
997 EpetraCrsGraphT(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap, const ArrayRCP<const size_t> &NumEntriesPerRowToAlloc, const RCP<ParameterList> & /* params */ = null) {
998 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
999 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
1000 }
1001
1002#ifdef HAVE_XPETRA_TPETRA
1005 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1006 const typename local_graph_type::row_map_type & /* rowPointers */,
1007 const typename local_graph_type::entries_type::non_const_type & /* columnIndices */,
1008 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1010 "Epetra does not support CrsGraph constructors using Kokkos Views!");
1011 }
1012
1015 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1016 const local_graph_type & /* lclGraph */,
1017 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1019 "Epetra does not support CrsGraph constructors using a local graph!");
1020 }
1021
1023 EpetraCrsGraphT(const local_graph_type & /* lclGraph */,
1024 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* rowMap */,
1025 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1026 const Teuchos::RCP<const map_type> & /* domainMap */ = Teuchos::null,
1027 const Teuchos::RCP<const map_type> & /* rangeMap */ = Teuchos::null,
1028 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1030 "Epetra does not support CrsGraph constructors using a local graph!");
1031 }
1032#endif
1033
1035 virtual ~EpetraCrsGraphT() {}
1036
1038
1040
1041
1044 XPETRA_MONITOR("EpetraCrsGraphT::insertGlobalIndices");
1045
1046 GlobalOrdinal *indices_rawPtr = const_cast<GlobalOrdinal *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
1047 XPETRA_ERR_CHECK(graph_->InsertGlobalIndices(globalRow, indices.size(), indices_rawPtr));
1048 }
1049
1052 XPETRA_MONITOR("EpetraCrsGraphT::insertLocalIndices");
1053
1054 int *indices_rawPtr = const_cast<int *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
1055 XPETRA_ERR_CHECK(graph_->InsertMyIndices(localRow, indices.size(), indices_rawPtr));
1056 }
1057
1060 XPETRA_MONITOR("EpetraCrsGraphT::removeLocalIndices");
1061 graph_->RemoveMyIndices(localRow);
1062 }
1063
1065 //** \warning This is an expert-only routine and should not be called from user code. */
1066 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {
1067 XPETRA_MONITOR("EpetraCrsGraphT::allocateAllIndies");
1068
1069 // Row offsets
1070 // Unfortunately, we cannot do this in the same manner as column indices
1071 // and values (see below). The problem is that Tpetra insists on using
1072 // size_t, and Epetra uses int internally. So we only resize here, and
1073 // will need to copy in setAllValues
1074 rowptr.resize(getLocalNumRows() + 1);
1075
1076 int lowerOffset = 0;
1077 bool ownMemory = false;
1078
1079 // Column indices
1080 // Extract, resize, set colind
1081 Epetra_IntSerialDenseVector &myColind = graph_->ExpertExtractIndices();
1082 myColind.Resize(numNonZeros);
1083 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1084 }
1085
1087 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {
1088 XPETRA_MONITOR("EpetraCrsGraphT::setAllIndices");
1089
1090 // Check sizes
1092 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1093 if (colind.size() > 0) {
1094 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != graph_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
1095 "An exception is thrown to let you know that you mismatched your pointers.");
1096 }
1097
1098 // We have to make a copy here, it is unavoidable
1099 // See comments in allocateAllIndices
1100 const size_t N = getLocalNumRows();
1101
1102 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
1103 myRowptr.Resize(N + 1);
1104 for (size_t i = 0; i < N + 1; i++)
1105 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1106 }
1107
1110 XPETRA_MONITOR("EpetraCrsGraphT::getAllIndices");
1111
1112 int lowerOffset = 0;
1113 bool ownMemory = false;
1114
1115 const size_t n = getLocalNumRows();
1116 const size_t nnz = getLocalNumEntries();
1117
1118 // Row offsets
1119 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
1120 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
1121 rowptr.resize(n + 1);
1122 for (size_t i = 0; i < n + 1; i++)
1123 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1124
1125 // Column indices
1126 colind = Teuchos::arcp(graph_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1127 }
1128
1130
1132
1133
1135 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {
1136 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
1137
1138 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
1139 bool doOptimizeStorage = true;
1140 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1141 if (doOptimizeStorage) graph_->OptimizeStorage();
1142 }
1143
1145 void fillComplete(const RCP<ParameterList> &params = null) {
1146 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
1147
1148 graph_->FillComplete();
1149 bool doOptimizeStorage = true;
1150 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1151 if (doOptimizeStorage) graph_->OptimizeStorage();
1152 }
1153
1155 void
1159 Teuchos::null,
1161 Teuchos::null,
1163 Teuchos::null) {
1164 // Not optimized
1165 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
1166 graph_->OptimizeStorage();
1167 }
1168
1170
1172
1173
1176 XPETRA_MONITOR("EpetraCrsGraphT::getComm");
1177 return toXpetra(graph_->Comm());
1178 }
1179
1182 XPETRA_MONITOR("EpetraCrsGraphT::getRowMap");
1183 return toXpetra<GlobalOrdinal, Node>(graph_->RowMap());
1184 }
1185
1188 XPETRA_MONITOR("EpetraCrsGraphT::getColMap");
1189 return toXpetra<GlobalOrdinal, Node>(graph_->ColMap());
1190 }
1191
1194 XPETRA_MONITOR("EpetraCrsGraphT::getDomainMap");
1195 return toXpetra<GlobalOrdinal, Node>(graph_->DomainMap());
1196 }
1197
1200 XPETRA_MONITOR("EpetraCrsGraphT::getRangeMap");
1201 return toXpetra<GlobalOrdinal, Node>(graph_->RangeMap());
1202 }
1203
1206 XPETRA_MONITOR("EpetraCrsGraphT::getImporter");
1207 return toXpetra<GlobalOrdinal, Node>(graph_->Importer());
1208 }
1209
1212 XPETRA_MONITOR("EpetraCrsGraphT::getExporter");
1213 return toXpetra<GlobalOrdinal, Node>(graph_->Exporter());
1214 }
1215
1218 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumRows");
1219 return graph_->NumGlobalRows64();
1220 }
1221
1224 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumCols");
1225 return graph_->NumGlobalCols64();
1226 }
1227
1229 size_t getLocalNumRows() const {
1230 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumRows");
1231 return graph_->NumMyRows();
1232 }
1233
1235 size_t getLocalNumCols() const {
1236 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumCols");
1237 return graph_->NumMyCols();
1238 }
1239
1242 XPETRA_MONITOR("EpetraCrsGraphT::getIndexBase");
1243 return (GlobalOrdinal)graph_->IndexBase64();
1244 }
1245
1248 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumEntries");
1249 return graph_->NumGlobalEntries64();
1250 }
1251
1253 size_t getLocalNumEntries() const {
1254 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumEntries");
1255 return graph_->NumMyEntries();
1256 }
1257
1259 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
1260 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInGlobalRow");
1261 return graph_->NumGlobalIndices(globalRow);
1262 }
1263
1265 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
1266 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInLocalRow");
1267 return graph_->NumMyIndices(localRow);
1268 }
1269
1272 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInGlobalRow");
1273 return graph_->NumAllocatedGlobalIndices(globalRow);
1274 }
1275
1278 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInLocalRow");
1279 return graph_->NumAllocatedMyIndices(localRow);
1280 }
1281
1284 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalMaxNumRowEntries");
1285 return graph_->GlobalMaxNumIndices();
1286 }
1287
1290 XPETRA_MONITOR("EpetraCrsGraphT::getLocalMaxNumRowEntries");
1291 return graph_->MaxNumIndices();
1292 }
1293
1295 bool hasColMap() const {
1296 XPETRA_MONITOR("EpetraCrsGraphT::hasColMap");
1297 return graph_->HaveColMap();
1298 }
1299
1301 bool isLocallyIndexed() const {
1302 XPETRA_MONITOR("EpetraCrsGraphT::isLocallyIndexed");
1303 return graph_->IndicesAreLocal();
1304 }
1305
1307 bool isGloballyIndexed() const {
1308 XPETRA_MONITOR("EpetraCrsGraphT::isGloballyIndexed");
1309 return graph_->IndicesAreGlobal();
1310 }
1311
1313 bool isFillComplete() const {
1314 XPETRA_MONITOR("EpetraCrsGraphT::isFillComplete");
1315 return graph_->Filled();
1316 }
1317
1319 bool isStorageOptimized() const {
1320 XPETRA_MONITOR("EpetraCrsGraphT::isStorageOptimized");
1321 return graph_->StorageOptimized();
1322 }
1323
1326 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalRowView");
1327
1328 int numEntries;
1329 GlobalOrdinal *eIndices;
1330
1331 XPETRA_ERR_CHECK(graph_->ExtractGlobalRowView(GlobalRow, numEntries, eIndices));
1332 if (numEntries == 0) {
1333 eIndices = NULL;
1334 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1335
1336 Indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
1337 }
1338
1341 XPETRA_MONITOR("EpetraCrsGraphT::getLocalRowView");
1342
1343 int numEntries;
1344 int *eIndices;
1345
1346 XPETRA_ERR_CHECK(graph_->ExtractMyRowView(LocalRow, numEntries, eIndices));
1347 if (numEntries == 0) {
1348 eIndices = NULL;
1349 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1350
1351 indices = ArrayView<const int>(eIndices, numEntries);
1352 }
1353
1354#ifdef HAVE_XPETRA_TPETRA
1355#if KOKKOS_VERSION >= 40799
1356 typename local_graph_type::host_mirror_type getLocalGraphHost() const {
1357#else
1358 typename local_graph_type::HostMirror getLocalGraphHost() const {
1359#endif
1360 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
1361
1362#if KOKKOS_VERSION >= 40799
1363 using local_graph_type_host = typename local_graph_type::host_mirror_type;
1364#else
1365 using local_graph_type_host = typename local_graph_type::HostMirror;
1366#endif
1367
1368 const int numRows = graph->NumMyRows();
1369 const int nnz = graph->NumMyNonzeros();
1370
1371 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
1372 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
1373 int *colind = graph->ExpertExtractIndices().Values();
1374
1375 // Transform int* rowptr array to size_type* array
1376 typename local_graph_type_host::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1377 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1378 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type_host::row_map_type::value_type>(rowptr[i]);
1379
1380 // create Kokkos::Views
1381 typename local_graph_type_host::entries_type kokkosColind(colind, nnz);
1382
1383 local_graph_type_host localGraph = local_graph_type_host(kokkosColind, kokkosRowPtr);
1384
1385 return localGraph;
1386 }
1387
1389 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
1390
1391 const int numRows = graph->NumMyRows();
1392 const int nnz = graph->NumMyNonzeros();
1393
1394 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
1395 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
1396 int *colind = graph->ExpertExtractIndices().Values();
1397
1398 // Transform int* rowptr array to size_type* array
1399 typename local_graph_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1400 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1401 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type::row_map_type::value_type>(rowptr[i]);
1402
1403 // create Kokkos::Views
1404 typename local_graph_type::entries_type kokkosColind(colind, nnz);
1405
1406 local_graph_type localGraph = local_graph_type(kokkosColind, kokkosRowPtr);
1407
1408 return localGraph;
1409 }
1410
1411 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
1413 "Epetra does not support getLocalDiagOffsets!");
1414 }
1415#else
1416#ifdef __GNUC__
1417#warning "Xpetra Kokkos interface for CrsGraph is enabled (HAVE_XPETRA_KOKKOS_REFACTOR) but Tpetra is disabled. The Kokkos interface needs Tpetra to be enabled, too."
1418#endif
1419#endif
1420
1423
1425
1427
1428
1430 std::string description() const {
1431 XPETRA_MONITOR("EpetraCrsGraphT::description");
1432 return "NotImplemented";
1433 }
1434
1437 XPETRA_MONITOR("EpetraCrsGraphT::describe");
1438
1439 out << "EpetraCrsGraphT::describe : Warning, verbosity level is ignored by this method." << std::endl;
1440 const Epetra_BlockMap rowmap = graph_->RowMap();
1441 if (rowmap.Comm().MyPID() == 0) out << "** EpetraCrsGraphT **\n\nrowmap" << std::endl;
1442 rowmap.Print(out);
1443 graph_->Print(out);
1444 }
1445
1447
1449 //{@
1450
1453 XPETRA_MONITOR("EpetraCrsGraphT::getMap");
1454 return toXpetra<GlobalOrdinal, Node>(graph_->Map());
1455 }
1456
1460 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
1461
1462 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1463 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1464
1465 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
1466 int err = graph_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1467 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1468 }
1469
1473 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
1474
1475 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1476 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1477
1478 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
1479 int err = graph_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1480 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1481 }
1482
1486 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
1487
1488 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1489 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1490
1491 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
1492 int err = graph_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1493 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1494 }
1495
1499 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
1500
1501 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1502 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1503
1504 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
1505 int err = graph_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1506 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1507 }
1509
1511
1512
1515 : graph_(graph) {
1516 TEUCHOS_TEST_FOR_EXCEPTION(!graph->RowMap().GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraCrsGraphT: GlobalOrdinal mismatch.");
1517 }
1518
1521
1523
1524 private:
1526};
1527#endif // specialization on Node=EpetraNode and GO=int
1528
1529} // namespace Xpetra
1530
1531#endif // XPETRA_EPETRACRSGRAPH_HPP
Insert
#define XPETRA_MONITOR(funcName)
#define XPETRA_ERR_CHECK(arg)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
virtual void Print(std::ostream &os) const
const Epetra_Comm & Comm() const
virtual int MyPID() const=0
int Resize(int Length_in)
size_type size() const
T * getRawPtr() const
void resize(const size_type n, const T &val=T())
iterator begin() const
iterator end() const
size_type size() const
T * getRawPtr() const
static const EVerbosityLevel verbLevel_default
typename local_graph_device_type::HostMirror local_graph_host_type
KokkosSparse::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_device_type
KokkosSparse::StaticCrsGraph< LocalOrdinal, Kokkos::LayoutLeft, device_type, void, size_t > local_graph_type
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this graph.
global_size_t getGlobalNumRows() const
Returns the number of global rows in the graph.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=null)
Constructor specifying column Map and fixed number of entries for each row.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices)
Insert local indices into the graph.
EpetraCrsGraphT(const Teuchos::RCP< Epetra_CrsGraph > &graph)
EpetraCrsGraphT constructor to wrap a Epetra_CrsGraph object.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this graph.
void fillComplete(const RCP< ParameterList > &params=null)
Signal that data entry is complete.
RCP< const Epetra_CrsGraph > getEpetra_CrsGraph() const
Get the underlying Epetra graph.
EpetraCrsGraphT(const local_graph_type &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const Teuchos::RCP< const map_type > &=Teuchos::null, const Teuchos::RCP< const map_type > &=Teuchos::null, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const
Returns the importer associated with this graph.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in the graph.
void doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
bool isGloballyIndexed() const
Whether column indices are stored using global indices on the calling process.
size_t getLocalNumEntries() const
Returns the local number of entries in the graph.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const
Return a const, nonpersisting view of global indices in the given row.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this graph.
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 doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
void allocateAllIndices(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
size_t getGlobalMaxNumRowEntries() const
Maximum number of entries in all rows over all processes.
bool isFillComplete() const
Whether fillComplete() has been called and the graph is in compute mode.
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void removeLocalIndices(LocalOrdinal localRow)
Remove all graph indices from the specified local row.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &=null)
size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of allocated entries on this node in the specified local row.
EpetraCrsGraphT(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
size_t getLocalMaxNumRowEntries() const
Maximum number of entries in all rows owned by the calling process.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void setAllIndices(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind)
Sets the 1D pointer arrays of the graph.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const
Return a const, nonpersisting view of local indices in the given row.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
void getLocalDiagOffsets(const Kokkos::View< size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this graph.
void computeGlobalConstants()
Force the computation of global constants if we don't have them.
EpetraCrsGraphT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap)
Constructor for empty DynamicProfile graph (no space is preallocated).
std::string description() const
Return a simple one-line description of this object.
RCP< const Comm< int > > getComm() const
Returns the communicator.
bool isLocallyIndexed() const
Whether column indices are stored using local indices on the calling process.
bool hasColMap() const
Whether the graph has a column Map.
void getAllIndices(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind) const
Gets the 1D pointer arrays of the graph.
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=null)
Signal that data entry is complete, specifying domain and range maps.
EpetraCrsGraphT(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &sourceGraph, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const RCP< Teuchos::ParameterList > &params=Teuchos::null)
local_graph_type::HostMirror getLocalGraphHost() const
Get the local graph.
void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices)
Insert global indices into the graph.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const local_graph_type &, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
size_t getLocalNumRows() const
Returns the number of graph rows owned on the calling node.
bool isStorageOptimized() const
Returns true if storage has been optimized.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const typename local_graph_type::row_map_type &, const typename local_graph_type::entries_type::non_const_type &, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the domain of this graph.
RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const
Returns the exporter associated with this graph.
void expertStaticFillComplete(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Expert version of fillComplete.
size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of allocated entries for this node in the specified global row .
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this graph.
size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of allocated entries on this node in the specified local row.
bool isStorageOptimized() const
Returns true if storage has been optimized.
bool isFillComplete() const
Whether fillComplete() has been called and the graph is in compute mode.
void computeGlobalConstants()
Force the computation of global constants if we don't have them.
global_size_t getGlobalNumCols() const
Returns the number of global columns in the graph.
void doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this graph.
EpetraCrsGraphT(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying fixed number of entries for each row.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices)
Insert local indices into the graph.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this graph.
EpetraCrsGraphT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap)
Constructor for empty DynamicProfile graph (no space is preallocated).
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
void getAllIndices(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind) const
Gets the 1D pointer arrays of the graph.
void setAllIndices(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind)
Sets the 1D pointer arrays of the graph.
RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const
Returns the importer associated with this graph.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the domain of this graph.
void expertStaticFillComplete(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Expert version of fillComplete.
size_t getGlobalMaxNumRowEntries() const
Maximum number of entries in all rows over all processes.
local_graph_type::HostMirror getLocalGraphHost() const
Get the local graph.
RCP< const Epetra_CrsGraph > getEpetra_CrsGraph() const
Get the underlying Epetra graph.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const typename local_graph_type::row_map_type &, const typename local_graph_type::entries_type::non_const_type &, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
EpetraCrsGraphT(const Teuchos::RCP< Epetra_CrsGraph > &graph)
EpetraCrsGraphT constructor to wrap a Epetra_CrsGraph object.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this graph.
global_size_t getGlobalNumRows() const
Returns the number of global rows in the graph.
size_t getLocalMaxNumRowEntries() const
Maximum number of entries in all rows owned by the calling process.
size_t getLocalNumEntries() const
Returns the local number of entries in the graph.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
std::string description() const
Return a simple one-line description of this object.
RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const
Returns the exporter associated with this graph.
void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices)
Insert global indices into the graph.
bool isGloballyIndexed() const
Whether column indices are stored using global indices on the calling process.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &=null)
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const
Return a const, nonpersisting view of global indices in the given row.
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in the graph.
GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this graph.
RCP< const Comm< int > > getComm() const
Returns the communicator.
bool isLocallyIndexed() const
Whether column indices are stored using local indices on the calling process.
bool hasColMap() const
Whether the graph has a column Map.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &=null)
Constructor specifying column Map and fixed number of entries for each row.
size_t getLocalNumRows() const
Returns the number of graph rows owned on the calling node.
void fillComplete(const RCP< ParameterList > &params=null)
Signal that data entry is complete.
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=null)
Signal that data entry is complete, specifying domain and range maps.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_type local_graph_type
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const
Return a const, nonpersisting view of local indices in the given row.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this graph.
void allocateAllIndices(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind)
Allocates and returns ArrayRCPs of the Crs arrays — This is an Xpetra-only routine.
size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of allocated entries for this node in the specified global row .
EpetraCrsGraphT(const local_graph_type &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const Teuchos::RCP< const map_type > &=Teuchos::null, const Teuchos::RCP< const map_type > &=Teuchos::null, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
void getLocalDiagOffsets(const Kokkos::View< size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const local_graph_type &, const RCP< Teuchos::ParameterList > &=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
void doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void removeLocalIndices(LocalOrdinal localRow)
Remove all graph indices from the specified local row.
size_t getLocalNumRows() const
Returns the number of graph rows owned on the calling node.
EpetraCrsGraphT(const Teuchos::RCP< Epetra_CrsGraph > &graph)
EpetraCrsGraphT constructor to wrap a Epetra_CrsGraph object.
void setAllIndices(const ArrayRCP< size_t > &rowptr, const ArrayRCP< LocalOrdinal > &colind)
Sets the 1D pointer arrays of the graph.
void doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void fillComplete(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const RCP< ParameterList > &params=null)
Signal that data entry is complete, specifying domain and range maps.
size_t getLocalNumEntries() const
Returns the local number of entries in the graph.
size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of entries on this node in the specified global row.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const local_graph_type &lclGraph, const RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const
Returns the current number of allocated entries for this node in the specified global row .
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.
EpetraCrsGraphT(const RCP< const map_type > &rowMap, const RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor for empty DynamicProfile graph (no space is preallocated).
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getColMap() const
Returns the Map that describes the column distribution in this graph.
void allocateAllIndices(size_t numNonZeros, ArrayRCP< size_t > &rowptr, ArrayRCP< LocalOrdinal > &colind)
Allocates the 1D pointer arrays of the graph.
void expertStaticFillComplete(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap, const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap, const Teuchos::RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > &importer=Teuchos::null, const Teuchos::RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > &exporter=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Expert version of fillComplete.
bool hasColMap() const
Whether the graph has a column Map.
void doImport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
GlobalOrdinal getIndexBase() const
Returns the index base for global indices for this graph.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, size_t maxNumEntriesPerRow, const Teuchos::RCP< Teuchos::ParameterList > &plist=null)
Constructor specifying column Map and fixed number of entries for each row.
bool isFillComplete() const
Whether fillComplete() has been called and the graph is in compute mode.
global_size_t getGlobalNumRows() const
Returns the number of global rows in the graph.
typename Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_type local_graph_type
EpetraCrsGraphT(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &sourceGraph, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &domainMap=Teuchos::null, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rangeMap=Teuchos::null, const RCP< Teuchos::ParameterList > &params=Teuchos::null)
bool isLocallyIndexed() const
Whether column indices are stored using local indices on the calling process.
void fillComplete(const RCP< ParameterList > &params=null)
Signal that data entry is complete.
bool isGloballyIndexed() const
Whether column indices are stored using global indices on the calling process.
size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of entries on this node in the specified local row.
size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const
Returns the current number of allocated entries on this node in the specified local row.
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRangeMap() const
Returns the Map associated with the domain of this graph.
local_graph_type::HostMirror getLocalGraphHost() const
Get the local graph.
Map< LocalOrdinal, GlobalOrdinal, Node > map_type
The specialization of Map used by this class.
void computeGlobalConstants()
Force the computation of global constants if we don't have them.
global_size_t getGlobalNumEntries() const
Returns the global number of entries in the graph.
RCP< const Comm< int > > getComm() const
Returns the communicator.
typename Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_device_type local_graph_device_type
node_type::execution_space execution_space
RCP< const Import< LocalOrdinal, GlobalOrdinal, Node > > getImporter() const
Returns the importer associated with this graph.
void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView< const GlobalOrdinal > &indices)
Insert global indices into the graph.
EpetraCrsGraphT(const local_graph_type &lclGraph, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &rangeMap=Teuchos::null, const RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
std::string description() const
Return a simple one-line description of this object.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null)
local_graph_type getLocalGraphDevice() const
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
RCP< const Epetra_CrsGraph > getEpetra_CrsGraph() const
Get the underlying Epetra graph.
void removeLocalIndices(LocalOrdinal localRow)
Remove all graph indices from the specified local row.
size_t getGlobalMaxNumRowEntries() const
Maximum number of entries in all rows over all processes.
size_t getLocalMaxNumRowEntries() const
Maximum number of entries in all rows owned by the calling process.
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getRowMap() const
Returns the Map that describes the row distribution in this graph.
void insertLocalIndices(const LocalOrdinal localRow, const ArrayView< const LocalOrdinal > &indices)
Insert local indices into the graph.
global_size_t getGlobalNumCols() const
Returns the number of global columns in the graph.
void getLocalRowView(LocalOrdinal LocalRow, ArrayView< const LocalOrdinal > &indices) const
Return a const, nonpersisting view of local indices in the given row.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::node_type node_type
void getLocalDiagOffsets(const Kokkos::View< size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged > &offsets) const
EpetraCrsGraphT(const RCP< const map_type > &rowMap, size_t maxNumEntriesPerRow, const RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying fixed number of entries for each row.
size_t getLocalNumCols() const
Returns the number of columns connected to the locally owned rows of this graph.
virtual ~EpetraCrsGraphT()
Destructor.
RCP< const Export< LocalOrdinal, GlobalOrdinal, Node > > getExporter() const
Returns the exporter associated with this graph.
void getAllIndices(ArrayRCP< const size_t > &rowptr, ArrayRCP< const LocalOrdinal > &colind) const
Gets the 1D pointer arrays of the graph.
typename Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_host_type local_graph_host_type
void doExport(const DistObject< GlobalOrdinal, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getDomainMap() const
Returns the Map associated with the domain of this graph.
EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &colMap, const typename local_graph_type::row_map_type &rowPointers, const typename local_graph_type::entries_type::non_const_type &columnIndices, const RCP< Teuchos::ParameterList > &plist=Teuchos::null)
Constructor specifying column Map, number of entries in each row and column indices in each row.
bool isStorageOptimized() const
Returns true if storage has been optimized.
void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView< const GlobalOrdinal > &Indices) const
Return a const, nonpersisting view of global indices in the given row.
Exception throws when you call an unimplemented method of Xpetra.
Exception throws to report errors in the internal logical of the program.
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const =0
The Target Map used to construct this Import object.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
size_t global_size_t
Global size_t object.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
CombineMode
Xpetra::Combine Mode enumerable type.