13#ifndef dealii_trilinos_sparsity_pattern_h
14#define dealii_trilinos_sparsity_pattern_h
18#ifndef DEAL_II_TRILINOS_WITH_EPETRA
24#ifdef DEAL_II_TRILINOS_WITH_EPETRA
34# include <Epetra_FECrsGraph.h>
35# include <Epetra_Map.h>
36# include <Epetra_MpiComm.h>
47#ifdef DEAL_II_TRILINOS_WITH_EPETRA
125 <<
"You tried to access row " << arg1
126 <<
" of a distributed sparsity pattern, "
127 <<
" but only rows " << arg2 <<
" through " << arg3
128 <<
" are stored locally and can be accessed.");
249 <<
"Attempt to access element " << arg2 <<
" of row "
250 << arg1 <<
" which doesn't have that many elements.");
322 "Use the overload specifying the number of entries per row!")
371 "Use the overload specifying the number of entries per row!")
400 template <typename SparsityPatternType>
402 copy_from(const SparsityPatternType &nontrilinos_sparsity_pattern);
458 "Use the overload specifying the number of entries per row!")
463 "Use the overload specifying the MPI communicator and the number of entries per row!")
495 const
IndexSet &col_parallel_partitioning,
500 "Use the overload specifying the number of entries per row!")
502 const
IndexSet &col_parallel_partitioning,
506 "Use the overload specifying the MPI communicator and the number of entries per row!")
508 const
IndexSet &col_parallel_partitioning);
522 const
IndexSet &col_parallel_partitioning,
553 const
IndexSet &col_parallel_partitioning,
559 "Use the overload specifying the number of entries per row!")
561 const
IndexSet &col_parallel_partitioning,
566 "Use the overload specifying the MPI communicator and the number of entries per row!")
568 const
IndexSet &col_parallel_partitioning,
592 "Use the overload specifying the number of entries per row!")
597 "Use the overload specifying the MPI communicator and the number of entries per row!")
634 const
IndexSet &col_parallel_partitioning,
639 "Use the overload specifying the number of entries per row!")
642 const
IndexSet &col_parallel_partitioning,
646 "Use the overload specifying the MPI communicator and the number of entries per row!")
649 const
IndexSet &col_parallel_partitioning);
678 const
IndexSet &col_parallel_partitioning,
684 "Use the overload specifying the number of entries per row!")
687 const
IndexSet &col_parallel_partitioning,
692 "Use the overload specifying the MPI communicator and the number of entries per row!")
695 const
IndexSet &col_parallel_partitioning,
704 const
IndexSet &col_parallel_partitioning,
718 typename SparsityPatternType,
719 typename =
std::enable_if_t<!
std::is_integral_v<SparsityPatternType>>>
722 const
IndexSet &col_parallel_partitioning,
723 const SparsityPatternType &nontrilinos_sparsity_pattern,
724 const
MPI_Comm communicator = MPI_COMM_WORLD,
725 const
bool exchange_data = false);
736 typename SparsityPatternType,
737 typename =
std::enable_if_t<!
std::is_integral_v<SparsityPatternType>>>
740 const SparsityPatternType &nontrilinos_sparsity_pattern,
741 const
MPI_Comm communicator = MPI_COMM_WORLD,
742 const
bool exchange_data = false);
861 template <typename ForwardIterator>
864 ForwardIterator
begin,
866 const
bool indices_are_sorted = false);
871 const
bool indices_are_sorted = false) override;
885 const Epetra_FECrsGraph &
999 const
bool write_extended_trilinos_info = false) const;
1028 << "An error with error number " << arg1
1029 << " occurred while calling a Trilinos function");
1037 << "The entry with index <" << arg1 << ',' << arg2
1038 << "> does not exist.");
1048 << "You tried to access element (" << arg1 << '/' << arg2
1050 << " of a distributed matrix, but only
rows in range ["
1051 << arg3 << ',' << arg4
1052 << "] are stored locally and can be accessed.");
1060 << "You tried to access element (" << arg1 << '/' << arg2
1061 << ')' << " of a sparse matrix, but it appears to not"
1062 << " exist in the Trilinos sparsity pattern.");
1107 visit_present_row();
1112 inline Accessor::size_type
1113 Accessor::row()
const
1115 Assert(a_row < sparsity_pattern->n_rows(),
1116 ExcBeyondEndOfSparsityPattern());
1122 inline Accessor::size_type
1123 Accessor::column()
const
1125 Assert(a_row < sparsity_pattern->n_rows(),
1126 ExcBeyondEndOfSparsityPattern());
1127 return (*colnum_cache)[a_index];
1132 inline Accessor::size_type
1133 Accessor::index()
const
1135 Assert(a_row < sparsity_pattern->n_rows(),
1136 ExcBeyondEndOfSparsityPattern());
1145 : accessor(sp, row, index)
1150 inline Iterator::Iterator(
const Iterator &) =
default;
1155 Iterator::operator++()
1157 Assert(accessor.a_row < accessor.sparsity_pattern->n_rows(),
1164 if (accessor.a_index >= accessor.colnum_cache->size())
1166 accessor.a_index = 0;
1169 while (accessor.a_row < accessor.sparsity_pattern->n_rows())
1171 const auto row_length =
1172 accessor.sparsity_pattern->row_length(accessor.a_row);
1173 if (row_length == 0 ||
1174 !accessor.sparsity_pattern->row_is_stored_locally(
1181 accessor.visit_present_row();
1189 Iterator::operator++(
int)
1191 const Iterator old_state = *
this;
1198 inline const Accessor &
1199 Iterator::operator*()
const
1206 inline const Accessor *
1207 Iterator::operator->()
const
1215 Iterator::operator==(
const Iterator &other)
const
1217 return (accessor.a_row == other.accessor.a_row &&
1218 accessor.a_index == other.accessor.a_index);
1224 Iterator::operator!=(
const Iterator &other)
const
1226 return !(*
this == other);
1232 Iterator::operator<(
const Iterator &other)
const
1234 return (accessor.row() < other.accessor.row() ||
1235 (accessor.row() == other.accessor.row() &&
1236 accessor.index() < other.accessor.index()));
1295# ifndef DEAL_II_WITH_64BIT_INDICES
1297 end =
graph->RowMap().MaxMyGID() + 1;
1300 end =
graph->RowMap().MaxMyGID64() + 1;
1312 return graph->Filled();
1333 template <
typename ForwardIterator>
1336 ForwardIterator
begin,
1337 ForwardIterator
end,
1352 sizeof((*
begin) * 2));
1356 const_cast<std::decay_t<decltype(*
begin)
> *>(&*
begin));
1365 graph->InsertGlobalIndices(trilinos_row_index,
n_cols, col_index_ptr);
1373 ExcMessage(
"Attempted to write into off-processor matrix row " +
1375 " that has not been specified as being writable upon "
1376 "initialization."));
1382 ierr =
graph->InsertGlobalIndices(1,
1383 &trilinos_row_index,
1392 inline const Epetra_FECrsGraph &
std::shared_ptr< const std::vector< size_type > > colnum_cache
Accessor(const SparsityPattern *sparsity_pattern, const size_type row, const size_type index)
SparsityPattern * sparsity_pattern
bool operator==(const Iterator &) const
const Accessor & operator*() const
bool operator<(const Iterator &) const
Iterator(const SparsityPattern *sparsity_pattern, const size_type row, const size_type index)
bool operator!=(const Iterator &) const
const Accessor * operator->() const
Iterator(const Iterator &i)
IndexSet locally_owned_domain_indices() const
size_type row_length(const size_type row) const
std::unique_ptr< Epetra_FECrsGraph > graph
void add(const size_type i, const size_type j)
void print(std::ostream &out, const bool write_extended_trilinos_info=false) const
unsigned int max_entries_per_row() const
size_type bandwidth() const
void print_gnuplot(std::ostream &out) const
const_iterator end() const
MPI_Comm get_mpi_communicator() const
virtual void add_row_entries(const size_type &row, const ArrayView< const size_type > &columns, const bool indices_are_sorted=false) override
std::uint64_t n_nonzero_elements() const
friend class SparsityPatternIterators::Iterator
std::unique_ptr< Epetra_CrsGraph > nonlocal_graph
bool exists(const size_type i, const size_type j) const
const Epetra_Map & domain_partitioner() const
std::pair< size_type, size_type > local_range() const
::types::global_dof_index size_type
const Epetra_FECrsGraph & trilinos_sparsity_pattern() const
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)
bool is_compressed() const
void reinit(const size_type m, const size_type n, const size_type n_entries_per_row)
unsigned int local_size() const
void copy_from(const SparsityPattern &input_sparsity_pattern)
IndexSet locally_owned_range_indices() const
std::unique_ptr< Epetra_Map > column_space_map
const Epetra_Map & range_partitioner() const
friend class SparsityPatternIterators::Accessor
const_iterator begin() const
SparsityPatternIterators::Iterator const_iterator
bool in_local_range(const size_type index) const
std::size_t memory_consumption() const
bool row_is_stored_locally(const size_type i) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_DEPRECATED_WITH_COMMENT(comment)
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
static ::ExceptionBase & ExcAccessToNonPresentElement(size_type arg1, size_type arg2)
#define DeclException0(Exception0)
static ::ExceptionBase & ExcBeyondEndOfSparsityPattern()
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
static ::ExceptionBase & ExcInvalidIndexWithinRow(size_type arg1, size_type arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcIteratorPastEnd()
static ::ExceptionBase & ExcAccessToNonlocalRow(size_type arg1, size_type arg2, size_type arg3)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
static ::ExceptionBase & ExcInvalidIndex(size_type arg1, size_type arg2)
#define AssertIndexRange(index, range)
#define DeclException3(Exception3, type1, type2, type3, outsequence)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
unsigned int global_dof_index