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>
42toXpetra(const Epetra_CrsGraph &graph);
43
44template <class GlobalOrdinal, class Node>
45XPETRA_DEPRECATED const Epetra_CrsGraph &
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 typename local_graph_type::HostMirror getLocalGraphHost() const {
271 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
272 TEUCHOS_UNREACHABLE_RETURN((typename local_graph_type::HostMirror()));
273 }
274#else
275#ifdef __GNUC__
276#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."
277#endif
278#endif
279
280#ifdef HAVE_XPETRA_TPETRA
283 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
285 }
286
287 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
289 "Epetra does not support getLocalDiagOffsets!");
290 }
291#else
292#ifdef __GNUC__
293#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."
294#endif
295
296#endif
297
300
302
304
305
307 std::string description() const { return std::string(""); }
308
311
313
315 //{@
316
319
323
327
331
335
336
338
339
343 "Xpetra::EpetraCrsGraph only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
344 }
345
347 RCP<const Epetra_CrsGraph> getEpetra_CrsGraph() const { return Teuchos::null; }
348
350
351 private:
352}; // EpetraCrsGraphT class
353
354// specialization on GO=int and Node=EpetraNode
355#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
356template <>
358 : public virtual CrsGraph<int, int, EpetraNode> {
359 typedef int LocalOrdinal;
360 typedef int GlobalOrdinal;
362
365
366#ifdef HAVE_XPETRA_TPETRA
369 typedef typename node_type::execution_space execution_space;
370#endif
371
372 public:
374
375
379
381 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
382 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true))) {}
383
385 // Definition not in cpp, so comment out
386 // EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null);
387
389 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)
390 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true))) {}
391
393 // Definition not in cpp, so comment out
394 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) {
395 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
396 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
397 }
398
399 // Constructor for fused import
402 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap = Teuchos::null,
403 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap = Teuchos::null,
404 const RCP<Teuchos::ParameterList> &params = Teuchos::null) {
405 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, *sourceGraph, tSourceGraph, "Xpetra::EpetraCrsGraphT() only accepts Xpetra::EpetraCrsGraphT as input arguments.");
406 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
407 RCP<const Epetra_CrsGraph> eSourceGraph = tSourceGraph.getEpetra_CrsGraph();
408
409 // NOTE: Unlike Tpetra, Epetra does not have a FusedTransfer for Graphs. So we do this the slow way
410 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, eSourceGraph->RowMap(), 0, false));
411 graph_->Import(*eSourceGraph, *tImporter.getEpetra_Import(), Insert);
412
413 const Epetra_BlockMap &myDomainMap = domainMap != Teuchos::null ? toEpetra<GlobalOrdinal, Node>(domainMap) : eSourceGraph->ColMap();
414 const Epetra_BlockMap &myRangeMap = rangeMap != Teuchos::null ? toEpetra<GlobalOrdinal, Node>(rangeMap) : toEpetra<LocalOrdinal, Node>(importer.getTargetMap());
415
416 graph_->FillComplete(myDomainMap, myRangeMap);
417 }
418
419#ifdef HAVE_XPETRA_TPETRA
422 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
423 const typename local_graph_type::row_map_type & /* rowPointers */,
424 const typename local_graph_type::entries_type::non_const_type & /* columnIndices */,
425 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
427 "Epetra does not support CrsGraph constructors using Kokkos Views!");
428 }
429
432 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
433 const local_graph_type & /* lclGraph */,
434 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
436 "Epetra does not support CrsGraph constructors using a local graph!");
437 }
438
440 EpetraCrsGraphT(const local_graph_type & /* lclGraph */,
441 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* rowMap */,
442 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
443 const Teuchos::RCP<const map_type> & /* domainMap */ = Teuchos::null,
444 const Teuchos::RCP<const map_type> & /* rangeMap */ = Teuchos::null,
445 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
447 "Epetra does not support CrsGraph constructors using a local graph!");
448 }
449#endif
450
452 virtual ~EpetraCrsGraphT() {}
453
455
457
458
461 XPETRA_MONITOR("EpetraCrsGraphT::insertGlobalIndices");
462
463 GlobalOrdinal *indices_rawPtr = const_cast<GlobalOrdinal *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
464 XPETRA_ERR_CHECK(graph_->InsertGlobalIndices(globalRow, indices.size(), indices_rawPtr));
465 }
466
468 void insertLocalIndices(const LocalOrdinal localRow, const ArrayView<const LocalOrdinal> &indices) {
469 XPETRA_MONITOR("EpetraCrsGraphT::insertLocalIndices");
470
471 int *indices_rawPtr = const_cast<int *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
472 XPETRA_ERR_CHECK(graph_->InsertMyIndices(localRow, indices.size(), indices_rawPtr));
473 }
474
477 XPETRA_MONITOR("EpetraCrsGraphT::removeLocalIndices");
478 graph_->RemoveMyIndices(localRow);
479 }
480
482 //** \warning This is an expert-only routine and should not be called from user code. */
483 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {
484 XPETRA_MONITOR("EpetraCrsGraphT::allocateAllIndies");
485
486 // Row offsets
487 // Unfortunately, we cannot do this in the same manner as column indices
488 // and values (see below). The problem is that Tpetra insists on using
489 // size_t, and Epetra uses int internally. So we only resize here, and
490 // will need to copy in setAllValues
491 rowptr.resize(getLocalNumRows() + 1);
492
493 int lowerOffset = 0;
494 bool ownMemory = false;
495
496 // Column indices
497 // Extract, resize, set colind
498 Epetra_IntSerialDenseVector &myColind = graph_->ExpertExtractIndices();
499 myColind.Resize(numNonZeros);
500 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
501 }
502
504 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {
505 XPETRA_MONITOR("EpetraCrsGraphT::setAllIndices");
506
507 // Check sizes
509 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
510 if (colind.size() > 0) {
511 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != graph_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
512 "An exception is thrown to let you know that you mismatched your pointers.");
513 }
514
515 // We have to make a copy here, it is unavoidable
516 // See comments in allocateAllIndices
517 const size_t N = getLocalNumRows();
518
519 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
520 myRowptr.Resize(N + 1);
521 for (size_t i = 0; i < N + 1; i++)
522 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
523 }
524
527 XPETRA_MONITOR("EpetraCrsGraphT::getAllIndices");
528
529 int lowerOffset = 0;
530 bool ownMemory = false;
531
532 const size_t n = getLocalNumRows();
533 const size_t nnz = getLocalNumEntries();
534
535 // Row offsets
536 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
537 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
538 rowptr.resize(n + 1);
539 for (size_t i = 0; i < n + 1; i++)
540 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
541
542 // Column indices
543 colind = Teuchos::arcp(graph_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
544 }
545
547
549
550
552 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {
553 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
554
555 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
556 bool doOptimizeStorage = true;
557 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
558 if (doOptimizeStorage) graph_->OptimizeStorage();
559 }
560
562 void fillComplete(const RCP<ParameterList> &params = null) {
563 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
564
565 graph_->FillComplete();
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
576 Teuchos::null,
578 Teuchos::null,
580 Teuchos::null) {
581 // Not optimized
582 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
583 graph_->OptimizeStorage();
584 }
585
587
589
590
593 XPETRA_MONITOR("EpetraCrsGraphT::getComm");
594 return toXpetra(graph_->Comm());
595 }
596
599 XPETRA_MONITOR("EpetraCrsGraphT::getRowMap");
600 return toXpetra<GlobalOrdinal, Node>(graph_->RowMap());
601 }
602
605 XPETRA_MONITOR("EpetraCrsGraphT::getColMap");
606 return toXpetra<GlobalOrdinal, Node>(graph_->ColMap());
607 }
608
611 XPETRA_MONITOR("EpetraCrsGraphT::getDomainMap");
612 return toXpetra<GlobalOrdinal, Node>(graph_->DomainMap());
613 }
614
617 XPETRA_MONITOR("EpetraCrsGraphT::getRangeMap");
618 return toXpetra<GlobalOrdinal, Node>(graph_->RangeMap());
619 }
620
623 XPETRA_MONITOR("EpetraCrsGraphT::getImporter");
624 return toXpetra<GlobalOrdinal, Node>(graph_->Importer());
625 }
626
629 XPETRA_MONITOR("EpetraCrsGraphT::getExporter");
630 return toXpetra<GlobalOrdinal, Node>(graph_->Exporter());
631 }
632
635 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumRows");
636 return graph_->NumGlobalRows64();
637 }
638
641 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumCols");
642 return graph_->NumGlobalCols64();
643 }
644
646 size_t getLocalNumRows() const {
647 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumRows");
648 return graph_->NumMyRows();
649 }
650
652 size_t getLocalNumCols() const {
653 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumCols");
654 return graph_->NumMyCols();
655 }
656
659 XPETRA_MONITOR("EpetraCrsGraphT::getIndexBase");
660 return (GlobalOrdinal)graph_->IndexBase64();
661 }
662
665 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumEntries");
666 return graph_->NumGlobalEntries64();
667 }
668
670 size_t getLocalNumEntries() const {
671 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumEntries");
672 return graph_->NumMyEntries();
673 }
674
676 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
677 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInGlobalRow");
678 return graph_->NumGlobalIndices(globalRow);
679 }
680
682 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
683 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInLocalRow");
684 return graph_->NumMyIndices(localRow);
685 }
686
689 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInGlobalRow");
690 return graph_->NumAllocatedGlobalIndices(globalRow);
691 }
692
695 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInLocalRow");
696 return graph_->NumAllocatedMyIndices(localRow);
697 }
698
701 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalMaxNumRowEntries");
702 return graph_->GlobalMaxNumIndices();
703 }
704
707 XPETRA_MONITOR("EpetraCrsGraphT::getLocalMaxNumRowEntries");
708 return graph_->MaxNumIndices();
709 }
710
712 bool hasColMap() const {
713 XPETRA_MONITOR("EpetraCrsGraphT::hasColMap");
714 return graph_->HaveColMap();
715 }
716
718 bool isLocallyIndexed() const {
719 XPETRA_MONITOR("EpetraCrsGraphT::isLocallyIndexed");
720 return graph_->IndicesAreLocal();
721 }
722
724 bool isGloballyIndexed() const {
725 XPETRA_MONITOR("EpetraCrsGraphT::isGloballyIndexed");
726 return graph_->IndicesAreGlobal();
727 }
728
730 bool isFillComplete() const {
731 XPETRA_MONITOR("EpetraCrsGraphT::isFillComplete");
732 return graph_->Filled();
733 }
734
736 bool isStorageOptimized() const {
737 XPETRA_MONITOR("EpetraCrsGraphT::isStorageOptimized");
738 return graph_->StorageOptimized();
739 }
740
743 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalRowView");
744
745 int numEntries;
746 GlobalOrdinal *eIndices;
747
748 XPETRA_ERR_CHECK(graph_->ExtractGlobalRowView(GlobalRow, numEntries, eIndices));
749 if (numEntries == 0) {
750 eIndices = NULL;
751 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
752
753 Indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
754 }
755
758 XPETRA_MONITOR("EpetraCrsGraphT::getLocalRowView");
759
760 int numEntries;
761 int *eIndices;
762
763 XPETRA_ERR_CHECK(graph_->ExtractMyRowView(LocalRow, numEntries, eIndices));
764 if (numEntries == 0) {
765 eIndices = NULL;
766 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
767
768 indices = ArrayView<const int>(eIndices, numEntries);
769 }
770
771#ifdef HAVE_XPETRA_TPETRA
772 typename local_graph_type::HostMirror getLocalGraphHost() const {
773 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
774
775 using local_graph_type_host = typename local_graph_type::HostMirror;
776
777 const int numRows = graph->NumMyRows();
778 const int nnz = graph->NumMyNonzeros();
779
780 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
781 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
782 int *colind = graph->ExpertExtractIndices().Values();
783
784 // Transform int* rowptr array to size_type* array
785 typename local_graph_type_host::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
786 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
788
789 // create Kokkos::Views
790 typename local_graph_type_host::entries_type kokkosColind(colind, nnz);
791
792 local_graph_type_host localGraph = local_graph_type_host(kokkosColind, kokkosRowPtr);
793
794 return localGraph;
795 }
796
798 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
799
800 const int numRows = graph->NumMyRows();
801 const int nnz = graph->NumMyNonzeros();
802
803 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
804 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
805 int *colind = graph->ExpertExtractIndices().Values();
806
807 // Transform int* rowptr array to size_type* array
808 typename local_graph_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
809 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
811
812 // create Kokkos::Views
813 typename local_graph_type::entries_type kokkosColind(colind, nnz);
814
815 local_graph_type localGraph = local_graph_type(kokkosColind, kokkosRowPtr);
816
817 return localGraph;
818 }
819
820 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
822 "Epetra does not support getLocalDiagOffsets!");
823 }
824#else
825#ifdef __GNUC__
826#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."
827#endif
828#endif
829
832
834
836
837
839 std::string description() const {
840 XPETRA_MONITOR("EpetraCrsGraphT::description");
841 return "NotImplemented";
842 }
843
846 XPETRA_MONITOR("EpetraCrsGraphT::describe");
847
848 out << "EpetraCrsGraphT::describe : Warning, verbosity level is ignored by this method." << std::endl;
849 const Epetra_BlockMap rowmap = graph_->RowMap();
850 if (rowmap.Comm().MyPID() == 0) out << "** EpetraCrsGraphT **\n\nrowmap" << std::endl;
851 rowmap.Print(out);
852 graph_->Print(out);
853 }
854
856
858 //{@
859
865
869 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
870
871 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
872 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
873
874 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
875 int err = graph_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
876 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
877 }
878
882 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
883
884 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
885 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
886
887 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
888 int err = graph_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
889 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
890 }
891
895 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
896
897 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
898 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
899
900 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
901 int err = graph_->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
902 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
903 }
904
908 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
909
910 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
911 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
912
913 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
914 int err = graph_->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
915 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
916 }
917
918
920
921
924 : graph_(graph) {
925 TEUCHOS_TEST_FOR_EXCEPTION(!graph->RowMap().GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraCrsGraphT: GlobalOrdinal mismatch.");
926 }
927
930
932
933 private:
935};
936
937#endif // specialization on Node=EpetraNode and GO=int
938
939// specialization on GO=long long and Node=EpetraNode
940#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
941template <>
943 : public virtual CrsGraph<int, long long, EpetraNode> {
944 typedef int LocalOrdinal;
945 typedef long long GlobalOrdinal;
947
950
951#ifdef HAVE_XPETRA_TPETRA
954 typedef typename node_type::execution_space execution_space;
955#endif
956
957 public:
959
960
964
966 EpetraCrsGraphT(const RCP<const map_type> &rowMap, size_t maxNumEntriesPerRow, const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null)
967 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), maxNumEntriesPerRow, true))) {}
968
970 // Definition not in cpp, so comment out
971 // EpetraCrsGraphT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &rowMap, const ArrayRCP< const size_t > &NumEntriesPerRowToAlloc, const RCP< ParameterList > &params=null);
972
974 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)
975 : graph_(Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), maxNumEntriesPerRow, true))) {}
976
978 // Definition not in cpp, so comment out
979 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) {
980 Teuchos::Array<int> numEntriesPerRowToAlloc(NumEntriesPerRowToAlloc.begin(), NumEntriesPerRowToAlloc.end()); // convert array of "size_t" to array of "int"
981 graph_ = Teuchos::rcp(new Epetra_CrsGraph(Copy, toEpetra<GlobalOrdinal, Node>(rowMap), toEpetra<GlobalOrdinal, Node>(colMap), numEntriesPerRowToAlloc.getRawPtr(), true));
982 }
983
984#ifdef HAVE_XPETRA_TPETRA
987 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
988 const typename local_graph_type::row_map_type & /* rowPointers */,
989 const typename local_graph_type::entries_type::non_const_type & /* columnIndices */,
990 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
992 "Epetra does not support CrsGraph constructors using Kokkos Views!");
993 }
994
997 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
998 const local_graph_type & /* lclGraph */,
999 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1001 "Epetra does not support CrsGraph constructors using a local graph!");
1002 }
1003
1005 EpetraCrsGraphT(const local_graph_type & /* lclGraph */,
1006 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* rowMap */,
1007 const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> & /* colMap */,
1008 const Teuchos::RCP<const map_type> & /* domainMap */ = Teuchos::null,
1009 const Teuchos::RCP<const map_type> & /* rangeMap */ = Teuchos::null,
1010 const RCP<Teuchos::ParameterList> & /* plist */ = Teuchos::null) {
1012 "Epetra does not support CrsGraph constructors using a local graph!");
1013 }
1014#endif
1015
1017 virtual ~EpetraCrsGraphT() {}
1018
1020
1022
1023
1026 XPETRA_MONITOR("EpetraCrsGraphT::insertGlobalIndices");
1027
1028 GlobalOrdinal *indices_rawPtr = const_cast<GlobalOrdinal *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
1029 XPETRA_ERR_CHECK(graph_->InsertGlobalIndices(globalRow, indices.size(), indices_rawPtr));
1030 }
1031
1034 XPETRA_MONITOR("EpetraCrsGraphT::insertLocalIndices");
1035
1036 int *indices_rawPtr = const_cast<int *>(indices.getRawPtr()); // there is no const in the Epetra interface :(
1037 XPETRA_ERR_CHECK(graph_->InsertMyIndices(localRow, indices.size(), indices_rawPtr));
1038 }
1039
1042 XPETRA_MONITOR("EpetraCrsGraphT::removeLocalIndices");
1043 graph_->RemoveMyIndices(localRow);
1044 }
1045
1047 //** \warning This is an expert-only routine and should not be called from user code. */
1048 void allocateAllIndices(size_t numNonZeros, ArrayRCP<size_t> &rowptr, ArrayRCP<LocalOrdinal> &colind) {
1049 XPETRA_MONITOR("EpetraCrsGraphT::allocateAllIndies");
1050
1051 // Row offsets
1052 // Unfortunately, we cannot do this in the same manner as column indices
1053 // and values (see below). The problem is that Tpetra insists on using
1054 // size_t, and Epetra uses int internally. So we only resize here, and
1055 // will need to copy in setAllValues
1056 rowptr.resize(getLocalNumRows() + 1);
1057
1058 int lowerOffset = 0;
1059 bool ownMemory = false;
1060
1061 // Column indices
1062 // Extract, resize, set colind
1063 Epetra_IntSerialDenseVector &myColind = graph_->ExpertExtractIndices();
1064 myColind.Resize(numNonZeros);
1065 colind = Teuchos::arcp(myColind.Values(), lowerOffset, numNonZeros, ownMemory);
1066 }
1067
1069 void setAllIndices(const ArrayRCP<size_t> &rowptr, const ArrayRCP<LocalOrdinal> &colind) {
1070 XPETRA_MONITOR("EpetraCrsGraphT::setAllIndices");
1071
1072 // Check sizes
1074 "An exception is thrown to let you know that the size of your rowptr array is incorrect.");
1075 if (colind.size() > 0) {
1076 TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != graph_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
1077 "An exception is thrown to let you know that you mismatched your pointers.");
1078 }
1079
1080 // We have to make a copy here, it is unavoidable
1081 // See comments in allocateAllIndices
1082 const size_t N = getLocalNumRows();
1083
1084 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
1085 myRowptr.Resize(N + 1);
1086 for (size_t i = 0; i < N + 1; i++)
1087 myRowptr[i] = Teuchos::as<int>(rowptr[i]);
1088 }
1089
1092 XPETRA_MONITOR("EpetraCrsGraphT::getAllIndices");
1093
1094 int lowerOffset = 0;
1095 bool ownMemory = false;
1096
1097 const size_t n = getLocalNumRows();
1098 const size_t nnz = getLocalNumEntries();
1099
1100 // Row offsets
1101 // We have to make a copy here, it is unavoidable (see comments in allocateAllValues)
1102 Epetra_IntSerialDenseVector &myRowptr = graph_->ExpertExtractIndexOffset();
1103 rowptr.resize(n + 1);
1104 for (size_t i = 0; i < n + 1; i++)
1105 (*const_cast<size_t *>(&rowptr[i])) = Teuchos::as<size_t>(myRowptr[i]);
1106
1107 // Column indices
1108 colind = Teuchos::arcp(graph_->ExpertExtractIndices().Values(), lowerOffset, nnz, ownMemory);
1109 }
1110
1112
1114
1115
1117 void fillComplete(const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &domainMap, const RCP<const Map<LocalOrdinal, GlobalOrdinal, Node>> &rangeMap, const RCP<ParameterList> &params = null) {
1118 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
1119
1120 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
1121 bool doOptimizeStorage = true;
1122 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1123 if (doOptimizeStorage) graph_->OptimizeStorage();
1124 }
1125
1127 void fillComplete(const RCP<ParameterList> &params = null) {
1128 XPETRA_MONITOR("EpetraCrsGraphT::fillComplete");
1129
1130 graph_->FillComplete();
1131 bool doOptimizeStorage = true;
1132 if (params != null && params->get("Optimize Storage", true) == false) doOptimizeStorage = false;
1133 if (doOptimizeStorage) graph_->OptimizeStorage();
1134 }
1135
1137 void
1141 Teuchos::null,
1143 Teuchos::null,
1145 Teuchos::null) {
1146 // Not optimized
1147 graph_->FillComplete(toEpetra<GlobalOrdinal, Node>(domainMap), toEpetra<GlobalOrdinal, Node>(rangeMap));
1148 graph_->OptimizeStorage();
1149 }
1150
1152
1154
1155
1158 XPETRA_MONITOR("EpetraCrsGraphT::getComm");
1159 return toXpetra(graph_->Comm());
1160 }
1161
1164 XPETRA_MONITOR("EpetraCrsGraphT::getRowMap");
1165 return toXpetra<GlobalOrdinal, Node>(graph_->RowMap());
1166 }
1167
1170 XPETRA_MONITOR("EpetraCrsGraphT::getColMap");
1171 return toXpetra<GlobalOrdinal, Node>(graph_->ColMap());
1172 }
1173
1176 XPETRA_MONITOR("EpetraCrsGraphT::getDomainMap");
1177 return toXpetra<GlobalOrdinal, Node>(graph_->DomainMap());
1178 }
1179
1182 XPETRA_MONITOR("EpetraCrsGraphT::getRangeMap");
1183 return toXpetra<GlobalOrdinal, Node>(graph_->RangeMap());
1184 }
1185
1188 XPETRA_MONITOR("EpetraCrsGraphT::getImporter");
1189 return toXpetra<GlobalOrdinal, Node>(graph_->Importer());
1190 }
1191
1194 XPETRA_MONITOR("EpetraCrsGraphT::getExporter");
1195 return toXpetra<GlobalOrdinal, Node>(graph_->Exporter());
1196 }
1197
1200 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumRows");
1201 return graph_->NumGlobalRows64();
1202 }
1203
1206 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumCols");
1207 return graph_->NumGlobalCols64();
1208 }
1209
1211 size_t getLocalNumRows() const {
1212 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumRows");
1213 return graph_->NumMyRows();
1214 }
1215
1217 size_t getLocalNumCols() const {
1218 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumCols");
1219 return graph_->NumMyCols();
1220 }
1221
1224 XPETRA_MONITOR("EpetraCrsGraphT::getIndexBase");
1225 return (GlobalOrdinal)graph_->IndexBase64();
1226 }
1227
1230 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalNumEntries");
1231 return graph_->NumGlobalEntries64();
1232 }
1233
1235 size_t getLocalNumEntries() const {
1236 XPETRA_MONITOR("EpetraCrsGraphT::getLocalNumEntries");
1237 return graph_->NumMyEntries();
1238 }
1239
1241 size_t getNumEntriesInGlobalRow(GlobalOrdinal globalRow) const {
1242 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInGlobalRow");
1243 return graph_->NumGlobalIndices(globalRow);
1244 }
1245
1247 size_t getNumEntriesInLocalRow(LocalOrdinal localRow) const {
1248 XPETRA_MONITOR("EpetraCrsGraphT::getNumEntriesInLocalRow");
1249 return graph_->NumMyIndices(localRow);
1250 }
1251
1254 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInGlobalRow");
1255 return graph_->NumAllocatedGlobalIndices(globalRow);
1256 }
1257
1260 XPETRA_MONITOR("EpetraCrsGraphT::getNumAllocatedEntriesInLocalRow");
1261 return graph_->NumAllocatedMyIndices(localRow);
1262 }
1263
1266 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalMaxNumRowEntries");
1267 return graph_->GlobalMaxNumIndices();
1268 }
1269
1272 XPETRA_MONITOR("EpetraCrsGraphT::getLocalMaxNumRowEntries");
1273 return graph_->MaxNumIndices();
1274 }
1275
1277 bool hasColMap() const {
1278 XPETRA_MONITOR("EpetraCrsGraphT::hasColMap");
1279 return graph_->HaveColMap();
1280 }
1281
1283 bool isLocallyIndexed() const {
1284 XPETRA_MONITOR("EpetraCrsGraphT::isLocallyIndexed");
1285 return graph_->IndicesAreLocal();
1286 }
1287
1289 bool isGloballyIndexed() const {
1290 XPETRA_MONITOR("EpetraCrsGraphT::isGloballyIndexed");
1291 return graph_->IndicesAreGlobal();
1292 }
1293
1295 bool isFillComplete() const {
1296 XPETRA_MONITOR("EpetraCrsGraphT::isFillComplete");
1297 return graph_->Filled();
1298 }
1299
1301 bool isStorageOptimized() const {
1302 XPETRA_MONITOR("EpetraCrsGraphT::isStorageOptimized");
1303 return graph_->StorageOptimized();
1304 }
1305
1308 XPETRA_MONITOR("EpetraCrsGraphT::getGlobalRowView");
1309
1310 int numEntries;
1311 GlobalOrdinal *eIndices;
1312
1313 XPETRA_ERR_CHECK(graph_->ExtractGlobalRowView(GlobalRow, numEntries, eIndices));
1314 if (numEntries == 0) {
1315 eIndices = NULL;
1316 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1317
1318 Indices = ArrayView<const GlobalOrdinal>(eIndices, numEntries);
1319 }
1320
1323 XPETRA_MONITOR("EpetraCrsGraphT::getLocalRowView");
1324
1325 int numEntries;
1326 int *eIndices;
1327
1328 XPETRA_ERR_CHECK(graph_->ExtractMyRowView(LocalRow, numEntries, eIndices));
1329 if (numEntries == 0) {
1330 eIndices = NULL;
1331 } // Cf. TEUCHOS_TEST_FOR_EXCEPT( p == 0 && size_in != 0 ) in Teuchos ArrayView constructor.
1332
1333 indices = ArrayView<const int>(eIndices, numEntries);
1334 }
1335
1336#ifdef HAVE_XPETRA_TPETRA
1337 typename local_graph_type::HostMirror getLocalGraphHost() const {
1338 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
1339
1340 using local_graph_type_host = typename local_graph_type::HostMirror;
1341
1342 const int numRows = graph->NumMyRows();
1343 const int nnz = graph->NumMyNonzeros();
1344
1345 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
1346 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
1347 int *colind = graph->ExpertExtractIndices().Values();
1348
1349 // Transform int* rowptr array to size_type* array
1350 typename local_graph_type_host::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1351 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1353
1354 // create Kokkos::Views
1355 typename local_graph_type_host::entries_type kokkosColind(colind, nnz);
1356
1357 local_graph_type_host localGraph = local_graph_type_host(kokkosColind, kokkosRowPtr);
1358
1359 return localGraph;
1360 }
1361
1363 RCP<Epetra_CrsGraph> graph = Teuchos::rcp_const_cast<Epetra_CrsGraph>(getEpetra_CrsGraph());
1364
1365 const int numRows = graph->NumMyRows();
1366 const int nnz = graph->NumMyNonzeros();
1367
1368 TEUCHOS_TEST_FOR_EXCEPTION(!graph->StorageOptimized(), std::runtime_error, "Xpetra::CrsGraph<>::getLocalGraph: Epetra_CrsGraph not StorageOptimized");
1369 const int *rowptr = graph->ExpertExtractIndexOffset().Values();
1370 int *colind = graph->ExpertExtractIndices().Values();
1371
1372 // Transform int* rowptr array to size_type* array
1373 typename local_graph_type::row_map_type::non_const_type kokkosRowPtr(Kokkos::ViewAllocateWithoutInitializing("local row map"), numRows + 1);
1374 for (size_t i = 0; i < kokkosRowPtr.size(); i++)
1376
1377 // create Kokkos::Views
1378 typename local_graph_type::entries_type kokkosColind(colind, nnz);
1379
1380 local_graph_type localGraph = local_graph_type(kokkosColind, kokkosRowPtr);
1381
1382 return localGraph;
1383 }
1384
1385 void getLocalDiagOffsets(const Kokkos::View<size_t *, typename Node::device_type, Kokkos::MemoryUnmanaged> &offsets) const {
1387 "Epetra does not support getLocalDiagOffsets!");
1388 }
1389#else
1390#ifdef __GNUC__
1391#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."
1392#endif
1393#endif
1394
1397
1399
1401
1402
1404 std::string description() const {
1405 XPETRA_MONITOR("EpetraCrsGraphT::description");
1406 return "NotImplemented";
1407 }
1408
1411 XPETRA_MONITOR("EpetraCrsGraphT::describe");
1412
1413 out << "EpetraCrsGraphT::describe : Warning, verbosity level is ignored by this method." << std::endl;
1414 const Epetra_BlockMap rowmap = graph_->RowMap();
1415 if (rowmap.Comm().MyPID() == 0) out << "** EpetraCrsGraphT **\n\nrowmap" << std::endl;
1416 rowmap.Print(out);
1417 graph_->Print(out);
1418 }
1419
1421
1423 //{@
1424
1427 XPETRA_MONITOR("EpetraCrsGraphT::getMap");
1429 }
1430
1434 XPETRA_MONITOR("EpetraCrsGraphT::doImport");
1435
1436 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1437 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1438
1439 RCP<const Epetra_CrsGraph> v = tSource.getEpetra_CrsGraph();
1440 int err = graph_->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1441 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1442 }
1443
1447 XPETRA_MONITOR("EpetraCrsGraphT::doExport");
1448
1449 XPETRA_DYNAMIC_CAST(const EpetraCrsGraphT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraCrsGraphT as input arguments.");
1450 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraCrsGraphT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1451
1452 RCP<const Epetra_CrsGraph> v = tDest.getEpetra_CrsGraph();
1453 int err = graph_->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1454 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
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 EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "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, *tExporter.getEpetra_Export(), 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 EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "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, *tExporter.getEpetra_Export(), toEpetra(CM));
1480 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1481 }
1482
1483
1485
1486
1489 : graph_(graph) {
1490 TEUCHOS_TEST_FOR_EXCEPTION(!graph->RowMap().GlobalIndicesIsType<GlobalOrdinal>(), std::runtime_error, "Xpetra::EpetraCrsGraphT: GlobalOrdinal mismatch.");
1491 }
1492
1495
1497
1498 private:
1500};
1501#endif // specialization on Node=EpetraNode and GO=int
1502
1503} // namespace Xpetra
1504
1505#endif // XPETRA_EPETRACRSGRAPH_HPP
Insert
Copy
#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
Kokkos::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)
TypeTo as(const TypeFrom &t)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
TypeTo asSafe(const TypeFrom &t)
basic_FancyOStream< char > FancyOStream
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)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
CombineMode
Xpetra::Combine Mode enumerable type.