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
59 typedef typename node_type::execution_space execution_space;
60#endif
61
62 public:
64
65
66 EpetraCrsGraphT(const RCP<const map_type> &rowMap, const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
68 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
69 }
70
72 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
74 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
75 }
76
78 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) {
80 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
81 }
82
84 // Definition not in cpp, so comment out
85 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) {
87 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
88 }
89
90 // Constructor for fused import
93 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap = Teuchos::null,
94 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap = Teuchos::null,
95 const RCP<Teuchos::ParameterList> &params = Teuchos::null) {
97 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
98 }
99
100#ifdef HAVE_XPETRA_TPETRA
103 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
104 const typename local_graph_type::row_map_type &rowPointers,
105 const typename local_graph_type::entries_type::non_const_type &columnIndices,
106 const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
108 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
109 }
110
113 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
114 const local_graph_type &lclGraph,
115 const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
117 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
118 }
119
122 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rowMap,
123 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &colMap,
124 const Teuchos::RCP<const map_type> &domainMap = Teuchos::null,
125 const Teuchos::RCP<const map_type> &rangeMap = Teuchos::null,
126 const RCP<Teuchos::ParameterList> &plist = Teuchos::null) {
128 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
129 }
130#endif
131
133 virtual ~EpetraCrsGraphT() {}
134
136
138
139
141 void insertGlobalIndices(GlobalOrdinal globalRow, const ArrayView<const GlobalOrdinal> &indices) {}
142
144 void insertLocalIndices(const LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &indices) {}
145
148
150 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {}
151
153 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {}
154
157
159
161
162
164 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {}
165
167 void fillComplete(const RCP<ParameterList> &params = null) {}
168
170 void
174 Teuchos::null,
176 Teuchos::null,
178 Teuchos::null) {}
179
181
183
184
187 return Teuchos::null;
188 }
189
192
195
198
201
204
207
209 global_size_t getGlobalNumRows() const { return 0; }
210
212 global_size_t getGlobalNumCols() const { return 0; }
213
215 size_t getLocalNumRows() const { return 0; }
216
218 size_t getLocalNumCols() const { return 0; }
219
221 GlobalOrdinal getIndexBase() const { return 0; }
222
224 global_size_t getGlobalNumEntries() const { return 0; }
225
227 size_t getLocalNumEntries() const { return 0; }
228
230 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const { return 0; }
231
233 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const { return 0; }
234
236 size_t getNumAllocatedEntriesInGlobalRow(GlobalOrdinal globalRow) const { return 0; }
237
239 size_t getNumAllocatedEntriesInLocalRow(LocalOrdinal localRow) const { return 0; }
240
242 size_t getGlobalMaxNumRowEntries() const { return 0; }
243
245 size_t getLocalMaxNumRowEntries() const { return 0; }
246
248 bool hasColMap() const { return false; }
249
251 bool isLocallyIndexed() const { return false; }
252
254 bool isGloballyIndexed() const { return false; }
255
257 bool isFillComplete() const { return false; }
258
260 bool isStorageOptimized() const { return false; }
261
263 void getGlobalRowView(GlobalOrdinal GlobalRow, ArrayView<const GlobalOrdinal> &Indices) const {}
264
267
268#ifdef HAVE_XPETRA_TPETRA
269#if KOKKOS_VERSION >= 40799
270 typename local_graph_type::host_mirror_type getLocalGraphHost() const {
272 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
273 TEUCHOS_UNREACHABLE_RETURN((typename local_graph_type::host_mirror_type()));
274 }
275#else
276 typename local_graph_type::HostMirror getLocalGraphHost() const {
278 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
279 TEUCHOS_UNREACHABLE_RETURN((typename local_graph_type::HostMirror()));
280 }
281#endif
282#else
283#ifdef __GNUC__
284#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."
285#endif
286#endif
287
288#ifdef HAVE_XPETRA_TPETRA
291 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
293 }
294
295 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
297 "Epetra does not support getLocalDiagOffsets!");
298 }
299#else
300#ifdef __GNUC__
301#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."
302#endif
303
304#endif
305
308
310
312
313
315 std::string description() const { return std::string(""); }
316
319
321
323 //{@
324
327
331
335
339
344
346
347
351 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
352 }
353
355 RCP<const Epetra_CrsGraph> getEpetra_CrsGraph() const { return Teuchos::null; }
356
358
359 private:
360}; // EpetraCrsGraphT class
361
362// specialization on GO=int and Node=EpetraNode
363#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
364template <>
366 : public virtual CrsGraph<int, int, EpetraNode> {
367 typedef int LocalOrdinal;
368 typedef int GlobalOrdinal;
370
373
374#ifdef HAVE_XPETRA_TPETRA
377 typedef typename node_type::execution_space execution_space;
378#endif
379
380 public:
382
383
386 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), 0, false))) {}
387
389 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
390 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true))) {}
391
393 // Definition not in cpp, so comment out
394 // EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null);
395
397 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)
398 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true))) {}
399
401 // Definition not in cpp, so comment out
402 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) {
403 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
404 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
405 }
406
407 // Constructor for fused import
410 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap = Teuchos::null,
411 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap = Teuchos::null,
412 const RCP<Teuchos::ParameterList> &params = Teuchos::null) {
413 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, *sourceGraph, tSourceGraph, "Xpetra::EpetraCrsGraphT() only accepts Xpetra::EpetraCrsGraphT as input arguments.");
414 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
415 RCP<const Epetra_CrsGraph> eSourceGraph = tSourceGraph.getEpetra_CrsGraph();
416
417 // NOTE: Unlike Tpetra, Epetra does not have a FusedTransfer for Graphs. So we do this the slow way
418 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, eSourceGraph->RowMap(), 0, false));
419 graph_->Import(*eSourceGraph, *tImporter.getEpetra_Import(), Insert);
420
421 const Epetra_BlockMap &myDomainMap = domainMap != Teuchos::null ? toEpetra<GlobalOrdinal, Node>(domainMap) : eSourceGraph->ColMap();
422 const Epetra_BlockMap &myRangeMap = rangeMap != Teuchos::null ? toEpetra<GlobalOrdinal, Node>(rangeMap) : toEpetra<LocalOrdinal, Node>(importer.getTargetMap());
423
424 graph_->FillComplete(myDomainMap, myRangeMap);
425 }
426
427#ifdef HAVE_XPETRA_TPETRA
430 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
431 const typename local_graph_type::row_map_type & /* rowPointers */,
432 const typename local_graph_type::entries_type::non_const_type & /* columnIndices */,
433 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
435 "Epetra does not support CrsGraph constructors using Kokkos Views!");
436 }
437
440 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
441 const local_graph_type & /* lclGraph */,
442 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
444 "Epetra does not support CrsGraph constructors using a local graph!");
445 }
446
448 EpetraCrsGraphT(const local_graph_type & /* lclGraph */,
449 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* rowMap */,
450 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
451 const Teuchos::RCP<const map_type> & /* domainMap */ = Teuchos::null,
452 const Teuchos::RCP<const map_type> & /* rangeMap */ = Teuchos::null,
453 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
455 "Epetra does not support CrsGraph constructors using a local graph!");
456 }
457#endif
458
460 virtual ~EpetraCrsGraphT() {}
461
463
465
466
469 XPETRA_MONITOR("EpetraCrsGraphT::insertGlobalIndices");
470
471 GlobalOrdinal *indices_rawPtr = const_cast<GlobalOrdinal *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
472 XPETRA_ERR_CHECK(graph_->InsertGlobalIndices(globalRow, indices.size(), indices_rawPtr));
473 }
474
476 void insertLocalIndices(const LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &indices) {
477 XPETRA_MONITOR("EpetraCrsGraphT::insertLocalIndices");
478
479 int *indices_rawPtr = const_cast<int *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
480 XPETRA_ERR_CHECK(graph_->InsertMyIndices(localRow, indices.size(), indices_rawPtr));
481 }
482
485 XPETRA_MONITOR("EpetraCrsGraphT::removeLocalIndices");
486 graph_->RemoveMyIndices(localRow);
487 }
488
490 //** \warning This is an expert-only routine and should not be called from user code. */
491 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {
492 XPETRA_MONITOR("EpetraCrsGraphT::allocateAllIndies");
493
494 // Row offsets
495 // Unfortunately, we cannot do this in the same manner as column indices
496 // and values (see below). The problem is that Tpetra insists on using
497 // size_t, and Epetra uses int internally. So we only resize here, and
498 // will need to copy in setAllValues
499 rowptr.resize(getLocalNumRows() + 1);
500
501 int lowerOffset = 0;
502 bool ownMemory = false;
503
504 // Column indices
505 // Extract, resize, set colind
506 Epetra_IntSerialDenseVector &myColind = graph_->ExpertExtractIndices();
507 myColind.Resize(numNonZeros);
508 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
509 }
510
512 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {
513 XPETRA_MONITOR("EpetraCrsGraphT::setAllIndices");
514
515 // Check sizes
517 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
518 if (colind.size() > 0) {
519 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != graph_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
520 "An exception is thrown to let you know that you mismatched your pointers.");
521 }
522
523 // We have to make a copy here, it is unavoidable
524 // See comments in allocateAllIndices
525 const size_t N = getLocalNumRows();
526
527 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
528 myRowptr.Resize(N + 1);
529 for (size_t i = 0; i < N + 1; i++)
530 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
531 }
532
535 XPETRA_MONITOR("EpetraCrsGraphT::getAllIndices");
536
537 int lowerOffset = 0;
538 bool ownMemory = false;
539
540 const size_t n = getLocalNumRows();
541 const size_t nnz = getLocalNumEntries();
542
543 // Row offsets
544 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
545 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
546 rowptr.resize(n + 1);
547 for (size_t i = 0; i < n + 1; i++)
548 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
549
550 // Column indices
551 colind = Teuchos::arcp(graph_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
552 }
553
555
557
558
560 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {
561 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
562
563 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
564 bool doOptimizeStorage = true;
565 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
566 if (doOptimizeStorage) graph_->OptimizeStorage();
567 }
568
570 void fillComplete(const RCP<ParameterList> &params = null) {
571 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
572
573 graph_->FillComplete();
574 bool doOptimizeStorage = true;
575 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
576 if (doOptimizeStorage) graph_->OptimizeStorage();
577 }
578
580 void
584 Teuchos::null,
586 Teuchos::null,
588 Teuchos::null) {
589 // Not optimized
590 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
591 graph_->OptimizeStorage();
592 }
593
595
597
598
601 XPETRA_MONITOR("EpetraCrsGraphT::getComm");
602 return toXpetra(graph_->Comm());
603 }
604
607 XPETRA_MONITOR("EpetraCrsGraphT::getRowMap");
608 return toXpetra<GlobalOrdinal, Node>(graph_->RowMap());
609 }
610
613 XPETRA_MONITOR("EpetraCrsGraphT::getColMap");
614 return toXpetra<GlobalOrdinal, Node>(graph_->ColMap());
615 }
616
619 XPETRA_MONITOR("EpetraCrsGraphT::getDomainMap");
620 return toXpetra<GlobalOrdinal, Node>(graph_->DomainMap());
621 }
622
625 XPETRA_MONITOR("EpetraCrsGraphT::getRangeMap");
626 return toXpetra<GlobalOrdinal, Node>(graph_->RangeMap());
627 }
628
631 XPETRA_MONITOR("EpetraCrsGraphT::getImporter");
632 return toXpetra<GlobalOrdinal, Node>(graph_->Importer());
633 }
634
637 XPETRA_MONITOR("EpetraCrsGraphT::getExporter");
638 return toXpetra<GlobalOrdinal, Node>(graph_->Exporter());
639 }
640
643 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumRows");
644 return graph_->NumGlobalRows64();
645 }
646
649 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumCols");
650 return graph_->NumGlobalCols64();
651 }
652
654 size_t getLocalNumRows() const {
655 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumRows");
656 return graph_->NumMyRows();
657 }
658
660 size_t getLocalNumCols() const {
661 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumCols");
662 return graph_->NumMyCols();
663 }
664
667 XPETRA_MONITOR("EpetraCrsGraphT::getIndexBase");
668 return (GlobalOrdinal)graph_->IndexBase64();
669 }
670
673 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumEntries");
674 return graph_->NumGlobalEntries64();
675 }
676
678 size_t getLocalNumEntries() const {
679 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumEntries");
680 return graph_->NumMyEntries();
681 }
682
684 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
685 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInGlobalRow");
686 return graph_->NumGlobalIndices(globalRow);
687 }
688
690 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
691 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInLocalRow");
692 return graph_->NumMyIndices(localRow);
693 }
694
697 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInGlobalRow");
698 return graph_->NumAllocatedGlobalIndices(globalRow);
699 }
700
703 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInLocalRow");
704 return graph_->NumAllocatedMyIndices(localRow);
705 }
706
709 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalMaxNumRowEntries");
710 return graph_->GlobalMaxNumIndices();
711 }
712
715 XPETRA_MONITOR("EpetraCrsGraphT::getLocalMaxNumRowEntries");
716 return graph_->MaxNumIndices();
717 }
718
720 bool hasColMap() const {
721 XPETRA_MONITOR("EpetraCrsGraphT::hasColMap");
722 return graph_->HaveColMap();
723 }
724
726 bool isLocallyIndexed() const {
727 XPETRA_MONITOR("EpetraCrsGraphT::isLocallyIndexed");
728 return graph_->IndicesAreLocal();
729 }
730
732 bool isGloballyIndexed() const {
733 XPETRA_MONITOR("EpetraCrsGraphT::isGloballyIndexed");
734 return graph_->IndicesAreGlobal();
735 }
736
738 bool isFillComplete() const {
739 XPETRA_MONITOR("EpetraCrsGraphT::isFillComplete");
740 return graph_->Filled();
741 }
742
744 bool isStorageOptimized() const {
745 XPETRA_MONITOR("EpetraCrsGraphT::isStorageOptimized");
746 return graph_->StorageOptimized();
747 }
748
751 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalRowView");
752
753 int numEntries;
754 GlobalOrdinal *eIndices;
755
756 XPETRA_ERR_CHECK(graph_->ExtractGlobalRowView(GlobalRow, numEntries, eIndices));
757 if (numEntries == 0) {
758 eIndices = NULL;
759 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
760
761 Indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
762 }
763
766 XPETRA_MONITOR("EpetraCrsGraphT::getLocalRowView");
767
768 int numEntries;
769 int *eIndices;
770
771 XPETRA_ERR_CHECK(graph_->ExtractMyRowView(LocalRow, numEntries, eIndices));
772 if (numEntries == 0) {
773 eIndices = NULL;
774 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
775
776 indices = ArrayView<const int>(eIndices, numEntries);
777 }
778
779#ifdef HAVE_XPETRA_TPETRA
780#if KOKKOS_VERSION >= 40799
781 typename local_graph_type::host_mirror_type getLocalGraphHost() const {
782#else
783 typename local_graph_type::HostMirror getLocalGraphHost() const {
784#endif
785 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
786
787#if KOKKOS_VERSION >= 40799
788 using local_graph_type_host = typename local_graph_type::host_mirror_type;
789#else
790 using local_graph_type_host = typename local_graph_type::HostMirror;
791#endif
792
793 const int numRows = graph->NumMyRows();
794 const int nnz = graph->NumMyNonzeros();
795
796 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
797 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
798 int *colind = graph->ExpertExtractIndices().Values();
799
800 // Transform int* rowptr array to size_type* array
801 typename local_graph_type_host::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
802 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
803 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type_host::row_map_type::value_type>(rowptr[i]);
804
805 // create Kokkos::Views
806 typename local_graph_type_host::entries_type kokkosColind(colind, nnz);
807
808 local_graph_type_host localGraph = local_graph_type_host(kokkosColind, kokkosRowPtr);
809
810 return localGraph;
811 }
812
814 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
815
816 const int numRows = graph->NumMyRows();
817 const int nnz = graph->NumMyNonzeros();
818
819 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
820 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
821 int *colind = graph->ExpertExtractIndices().Values();
822
823 // Transform int* rowptr array to size_type* array
824 typename local_graph_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
825 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
826 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type::row_map_type::value_type>(rowptr[i]);
827
828 // create Kokkos::Views
829 typename local_graph_type::entries_type kokkosColind(colind, nnz);
830
831 local_graph_type localGraph = local_graph_type(kokkosColind, kokkosRowPtr);
832
833 return localGraph;
834 }
835
836 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
838 "Epetra does not support getLocalDiagOffsets!");
839 }
840#else
841#ifdef __GNUC__
842#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."
843#endif
844#endif
845
848
850
852
853
855 std::string description() const {
856 XPETRA_MONITOR("EpetraCrsGraphT::description");
857 return "NotImplemented";
858 }
859
862 XPETRA_MONITOR("EpetraCrsGraphT::describe");
863
864 out << "EpetraCrsGraphT::describe : Warning, verbosity level is ignored by this method." << std::endl;
865 const Epetra_BlockMap rowmap = graph_->RowMap();
866 if (rowmap.Comm().MyPID() == 0) out << "** EpetraCrsGraphT **\n\nrowmap" << std::endl;
867 rowmap.Print(out);
868 graph_->Print(out);
869 }
870
872
874 //{@
875
878 XPETRA_MONITOR("EpetraCrsGraphT::getMap");
879 return toXpetra<GlobalOrdinal, Node>(graph_->Map());
880 }
881
885 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
886
887 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
888 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
889
890 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
891 int err = graph_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
892 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
893 }
894
898 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
899
900 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
901 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
902
903 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
904 int err = graph_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
905 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
906 }
907
911 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
912
913 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
914 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
915
916 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
917 int err = graph_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
918 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
919 }
920
924 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
925
926 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
927 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
928
929 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
930 int err = graph_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
931 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
932 }
934
936
937
940 : graph_(graph) {
941 TEUCHOS_TEST_FOR_EXCEPTION(!graph->RowMap().GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraCrsGraphT: GlobalOrdinal mismatch.");
942 }
943
946
948
949 private:
951};
952
953#endif // specialization on Node=EpetraNode and GO=int
954
955// specialization on GO=long long and Node=EpetraNode
956#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
957template <>
959 : public virtual CrsGraph<int, long long, EpetraNode> {
960 typedef int LocalOrdinal;
961 typedef long long GlobalOrdinal;
963
966
967#ifdef HAVE_XPETRA_TPETRA
970 typedef typename node_type::execution_space execution_space;
971#endif
972
973 public:
975
976
979 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), 0, false))) {}
980
982 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
983 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true))) {}
984
986 // Definition not in cpp, so comment out
987 // EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null);
988
990 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)
991 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true))) {}
992
994 // Definition not in cpp, so comment out
995 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) {
996 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
997 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
998 }
999
1000#ifdef HAVE_XPETRA_TPETRA
1003 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1004 const typename local_graph_type::row_map_type & /* rowPointers */,
1005 const typename local_graph_type::entries_type::non_const_type & /* columnIndices */,
1006 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1008 "Epetra does not support CrsGraph constructors using Kokkos Views!");
1009 }
1010
1013 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1014 const local_graph_type & /* lclGraph */,
1015 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1017 "Epetra does not support CrsGraph constructors using a local graph!");
1018 }
1019
1021 EpetraCrsGraphT(const local_graph_type & /* lclGraph */,
1022 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* rowMap */,
1023 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1024 const Teuchos::RCP<const map_type> & /* domainMap */ = Teuchos::null,
1025 const Teuchos::RCP<const map_type> & /* rangeMap */ = Teuchos::null,
1026 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1028 "Epetra does not support CrsGraph constructors using a local graph!");
1029 }
1030#endif
1031
1033 virtual ~EpetraCrsGraphT() {}
1034
1036
1038
1039
1042 XPETRA_MONITOR("EpetraCrsGraphT::insertGlobalIndices");
1043
1044 GlobalOrdinal *indices_rawPtr = const_cast<GlobalOrdinal *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
1045 XPETRA_ERR_CHECK(graph_->InsertGlobalIndices(globalRow, indices.size(), indices_rawPtr));
1046 }
1047
1050 XPETRA_MONITOR("EpetraCrsGraphT::insertLocalIndices");
1051
1052 int *indices_rawPtr = const_cast<int *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
1053 XPETRA_ERR_CHECK(graph_->InsertMyIndices(localRow, indices.size(), indices_rawPtr));
1054 }
1055
1058 XPETRA_MONITOR("EpetraCrsGraphT::removeLocalIndices");
1059 graph_->RemoveMyIndices(localRow);
1060 }
1061
1063 //** \warning This is an expert-only routine and should not be called from user code. */
1064 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {
1065 XPETRA_MONITOR("EpetraCrsGraphT::allocateAllIndies");
1066
1067 // Row offsets
1068 // Unfortunately, we cannot do this in the same manner as column indices
1069 // and values (see below). The problem is that Tpetra insists on using
1070 // size_t, and Epetra uses int internally. So we only resize here, and
1071 // will need to copy in setAllValues
1072 rowptr.resize(getLocalNumRows() + 1);
1073
1074 int lowerOffset = 0;
1075 bool ownMemory = false;
1076
1077 // Column indices
1078 // Extract, resize, set colind
1079 Epetra_IntSerialDenseVector &myColind = graph_->ExpertExtractIndices();
1080 myColind.Resize(numNonZeros);
1081 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1082 }
1083
1085 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {
1086 XPETRA_MONITOR("EpetraCrsGraphT::setAllIndices");
1087
1088 // Check sizes
1090 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1091 if (colind.size() > 0) {
1092 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != graph_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
1093 "An exception is thrown to let you know that you mismatched your pointers.");
1094 }
1095
1096 // We have to make a copy here, it is unavoidable
1097 // See comments in allocateAllIndices
1098 const size_t N = getLocalNumRows();
1099
1100 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
1101 myRowptr.Resize(N + 1);
1102 for (size_t i = 0; i < N + 1; i++)
1103 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1104 }
1105
1108 XPETRA_MONITOR("EpetraCrsGraphT::getAllIndices");
1109
1110 int lowerOffset = 0;
1111 bool ownMemory = false;
1112
1113 const size_t n = getLocalNumRows();
1114 const size_t nnz = getLocalNumEntries();
1115
1116 // Row offsets
1117 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
1118 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
1119 rowptr.resize(n + 1);
1120 for (size_t i = 0; i < n + 1; i++)
1121 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1122
1123 // Column indices
1124 colind = Teuchos::arcp(graph_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1125 }
1126
1128
1130
1131
1133 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {
1134 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
1135
1136 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
1137 bool doOptimizeStorage = true;
1138 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1139 if (doOptimizeStorage) graph_->OptimizeStorage();
1140 }
1141
1143 void fillComplete(const RCP<ParameterList> &params = null) {
1144 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
1145
1146 graph_->FillComplete();
1147 bool doOptimizeStorage = true;
1148 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1149 if (doOptimizeStorage) graph_->OptimizeStorage();
1150 }
1151
1153 void
1157 Teuchos::null,
1159 Teuchos::null,
1161 Teuchos::null) {
1162 // Not optimized
1163 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
1164 graph_->OptimizeStorage();
1165 }
1166
1168
1170
1171
1174 XPETRA_MONITOR("EpetraCrsGraphT::getComm");
1175 return toXpetra(graph_->Comm());
1176 }
1177
1180 XPETRA_MONITOR("EpetraCrsGraphT::getRowMap");
1181 return toXpetra<GlobalOrdinal, Node>(graph_->RowMap());
1182 }
1183
1186 XPETRA_MONITOR("EpetraCrsGraphT::getColMap");
1187 return toXpetra<GlobalOrdinal, Node>(graph_->ColMap());
1188 }
1189
1192 XPETRA_MONITOR("EpetraCrsGraphT::getDomainMap");
1193 return toXpetra<GlobalOrdinal, Node>(graph_->DomainMap());
1194 }
1195
1198 XPETRA_MONITOR("EpetraCrsGraphT::getRangeMap");
1199 return toXpetra<GlobalOrdinal, Node>(graph_->RangeMap());
1200 }
1201
1204 XPETRA_MONITOR("EpetraCrsGraphT::getImporter");
1205 return toXpetra<GlobalOrdinal, Node>(graph_->Importer());
1206 }
1207
1210 XPETRA_MONITOR("EpetraCrsGraphT::getExporter");
1211 return toXpetra<GlobalOrdinal, Node>(graph_->Exporter());
1212 }
1213
1216 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumRows");
1217 return graph_->NumGlobalRows64();
1218 }
1219
1222 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumCols");
1223 return graph_->NumGlobalCols64();
1224 }
1225
1227 size_t getLocalNumRows() const {
1228 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumRows");
1229 return graph_->NumMyRows();
1230 }
1231
1233 size_t getLocalNumCols() const {
1234 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumCols");
1235 return graph_->NumMyCols();
1236 }
1237
1240 XPETRA_MONITOR("EpetraCrsGraphT::getIndexBase");
1241 return (GlobalOrdinal)graph_->IndexBase64();
1242 }
1243
1246 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumEntries");
1247 return graph_->NumGlobalEntries64();
1248 }
1249
1251 size_t getLocalNumEntries() const {
1252 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumEntries");
1253 return graph_->NumMyEntries();
1254 }
1255
1257 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
1258 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInGlobalRow");
1259 return graph_->NumGlobalIndices(globalRow);
1260 }
1261
1263 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
1264 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInLocalRow");
1265 return graph_->NumMyIndices(localRow);
1266 }
1267
1270 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInGlobalRow");
1271 return graph_->NumAllocatedGlobalIndices(globalRow);
1272 }
1273
1276 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInLocalRow");
1277 return graph_->NumAllocatedMyIndices(localRow);
1278 }
1279
1282 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalMaxNumRowEntries");
1283 return graph_->GlobalMaxNumIndices();
1284 }
1285
1288 XPETRA_MONITOR("EpetraCrsGraphT::getLocalMaxNumRowEntries");
1289 return graph_->MaxNumIndices();
1290 }
1291
1293 bool hasColMap() const {
1294 XPETRA_MONITOR("EpetraCrsGraphT::hasColMap");
1295 return graph_->HaveColMap();
1296 }
1297
1299 bool isLocallyIndexed() const {
1300 XPETRA_MONITOR("EpetraCrsGraphT::isLocallyIndexed");
1301 return graph_->IndicesAreLocal();
1302 }
1303
1305 bool isGloballyIndexed() const {
1306 XPETRA_MONITOR("EpetraCrsGraphT::isGloballyIndexed");
1307 return graph_->IndicesAreGlobal();
1308 }
1309
1311 bool isFillComplete() const {
1312 XPETRA_MONITOR("EpetraCrsGraphT::isFillComplete");
1313 return graph_->Filled();
1314 }
1315
1317 bool isStorageOptimized() const {
1318 XPETRA_MONITOR("EpetraCrsGraphT::isStorageOptimized");
1319 return graph_->StorageOptimized();
1320 }
1321
1324 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalRowView");
1325
1326 int numEntries;
1327 GlobalOrdinal *eIndices;
1328
1329 XPETRA_ERR_CHECK(graph_->ExtractGlobalRowView(GlobalRow, numEntries, eIndices));
1330 if (numEntries == 0) {
1331 eIndices = NULL;
1332 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1333
1334 Indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
1335 }
1336
1339 XPETRA_MONITOR("EpetraCrsGraphT::getLocalRowView");
1340
1341 int numEntries;
1342 int *eIndices;
1343
1344 XPETRA_ERR_CHECK(graph_->ExtractMyRowView(LocalRow, numEntries, eIndices));
1345 if (numEntries == 0) {
1346 eIndices = NULL;
1347 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1348
1349 indices = ArrayView<const int>(eIndices, numEntries);
1350 }
1351
1352#ifdef HAVE_XPETRA_TPETRA
1353#if KOKKOS_VERSION >= 40799
1354 typename local_graph_type::host_mirror_type getLocalGraphHost() const {
1355#else
1356 typename local_graph_type::HostMirror getLocalGraphHost() const {
1357#endif
1358 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
1359
1360#if KOKKOS_VERSION >= 40799
1361 using local_graph_type_host = typename local_graph_type::host_mirror_type;
1362#else
1363 using local_graph_type_host = typename local_graph_type::HostMirror;
1364#endif
1365
1366 const int numRows = graph->NumMyRows();
1367 const int nnz = graph->NumMyNonzeros();
1368
1369 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
1370 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
1371 int *colind = graph->ExpertExtractIndices().Values();
1372
1373 // Transform int* rowptr array to size_type* array
1374 typename local_graph_type_host::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1375 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1376 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type_host::row_map_type::value_type>(rowptr[i]);
1377
1378 // create Kokkos::Views
1379 typename local_graph_type_host::entries_type kokkosColind(colind, nnz);
1380
1381 local_graph_type_host localGraph = local_graph_type_host(kokkosColind, kokkosRowPtr);
1382
1383 return localGraph;
1384 }
1385
1387 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
1388
1389 const int numRows = graph->NumMyRows();
1390 const int nnz = graph->NumMyNonzeros();
1391
1392 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
1393 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
1394 int *colind = graph->ExpertExtractIndices().Values();
1395
1396 // Transform int* rowptr array to size_type* array
1397 typename local_graph_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1398 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1399 kokkosRowPtr(i) = Teuchos::asSafe<typename local_graph_type::row_map_type::value_type>(rowptr[i]);
1400
1401 // create Kokkos::Views
1402 typename local_graph_type::entries_type kokkosColind(colind, nnz);
1403
1404 local_graph_type localGraph = local_graph_type(kokkosColind, kokkosRowPtr);
1405
1406 return localGraph;
1407 }
1408
1409 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
1411 "Epetra does not support getLocalDiagOffsets!");
1412 }
1413#else
1414#ifdef __GNUC__
1415#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."
1416#endif
1417#endif
1418
1421
1423
1425
1426
1428 std::string description() const {
1429 XPETRA_MONITOR("EpetraCrsGraphT::description");
1430 return "NotImplemented";
1431 }
1432
1435 XPETRA_MONITOR("EpetraCrsGraphT::describe");
1436
1437 out << "EpetraCrsGraphT::describe : Warning, verbosity level is ignored by this method." << std::endl;
1438 const Epetra_BlockMap rowmap = graph_->RowMap();
1439 if (rowmap.Comm().MyPID() == 0) out << "** EpetraCrsGraphT **\n\nrowmap" << std::endl;
1440 rowmap.Print(out);
1441 graph_->Print(out);
1442 }
1443
1445
1447 //{@
1448
1451 XPETRA_MONITOR("EpetraCrsGraphT::getMap");
1452 return toXpetra<GlobalOrdinal, Node>(graph_->Map());
1453 }
1454
1458 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
1459
1460 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1461 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1462
1463 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
1464 int err = graph_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1465 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1466 }
1467
1471 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
1472
1473 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1474 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1475
1476 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
1477 int err = graph_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1478 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1479 }
1480
1484 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
1485
1486 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1487 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1488
1489 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
1490 int err = graph_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1491 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1492 }
1493
1497 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
1498
1499 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1500 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1501
1502 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
1503 int err = graph_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1504 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1505 }
1507
1509
1510
1513 : graph_(graph) {
1514 TEUCHOS_TEST_FOR_EXCEPTION(!graph->RowMap().GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraCrsGraphT: GlobalOrdinal mismatch.");
1515 }
1516
1519
1521
1522 private:
1524};
1525#endif // specialization on Node=EpetraNode and GO=int
1526
1527} // namespace Xpetra
1528
1529#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
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.
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node >::local_graph_type local_graph_type
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.
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.
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.
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.