16 #ifndef dealii_trilinos_sparsity_pattern_h 17 # define dealii_trilinos_sparsity_pattern_h 20 # include <deal.II/base/config.h> 22 # ifdef DEAL_II_WITH_TRILINOS 24 # include <deal.II/base/index_set.h> 25 # include <deal.II/base/subscriptor.h> 27 # include <deal.II/lac/exceptions.h> 29 # include <Epetra_FECrsGraph.h> 30 # include <Epetra_Map.h> 35 # ifdef DEAL_II_WITH_MPI 36 # include <Epetra_MpiComm.h> 39 # include <Epetra_SerialComm.h> 43 DEAL_II_NAMESPACE_OPEN
118 <<
"You tried to access row " << arg1
119 <<
" of a distributed sparsity pattern, " 120 <<
" but only rows " << arg2 <<
" through " << arg3
121 <<
" are stored locally and can be accessed.");
242 <<
"Attempt to access element " << arg2 <<
" of row " 243 << arg1 <<
" which doesn't have that many elements.");
325 const std::vector<size_type> &n_entries_per_row);
371 const std::vector<size_type> &n_entries_per_row);
385 template <
typename SparsityPatternType>
387 copy_from(
const SparsityPatternType &nontrilinos_sparsity_pattern);
457 const std::vector<size_type> &n_entries_per_row);
479 const Epetra_Map &col_parallel_partitioning,
497 const Epetra_Map & col_parallel_partitioning,
498 const std::vector<size_type> &n_entries_per_row);
518 reinit(
const Epetra_Map ¶llel_partitioning,
535 reinit(
const Epetra_Map & parallel_partitioning,
536 const std::vector<size_type> &n_entries_per_row);
558 reinit(
const Epetra_Map &row_parallel_partitioning,
559 const Epetra_Map &col_parallel_partitioning,
577 reinit(
const Epetra_Map & row_parallel_partitioning,
578 const Epetra_Map & col_parallel_partitioning,
579 const std::vector<size_type> &n_entries_per_row);
591 template <
typename SparsityPatternType>
592 DEAL_II_DEPRECATED
void 593 reinit(
const Epetra_Map & row_parallel_partitioning,
594 const Epetra_Map & col_parallel_partitioning,
595 const SparsityPatternType &nontrilinos_sparsity_pattern,
596 const bool exchange_data =
false);
608 template <
typename SparsityPatternType>
609 DEAL_II_DEPRECATED
void 610 reinit(
const Epetra_Map & parallel_partitioning,
611 const SparsityPatternType &nontrilinos_sparsity_pattern,
612 const bool exchange_data =
false);
631 const MPI_Comm &communicator = MPI_COMM_WORLD,
645 const MPI_Comm & communicator,
646 const std::vector<size_type> &n_entries_per_row);
663 const IndexSet &col_parallel_partitioning,
664 const MPI_Comm &communicator = MPI_COMM_WORLD,
679 const IndexSet & col_parallel_partitioning,
680 const MPI_Comm & communicator,
681 const std::vector<size_type> &n_entries_per_row);
710 const IndexSet &col_parallel_partitioning,
712 const MPI_Comm &communicator = MPI_COMM_WORLD,
732 const MPI_Comm &communicator = MPI_COMM_WORLD,
747 const MPI_Comm & communicator,
748 const std::vector<size_type> &n_entries_per_row);
768 const IndexSet &col_parallel_partitioning,
769 const MPI_Comm &communicator = MPI_COMM_WORLD,
799 const IndexSet &col_parallel_partitioning,
801 const MPI_Comm &communicator = MPI_COMM_WORLD,
810 const IndexSet & col_parallel_partitioning,
811 const MPI_Comm & communicator,
812 const std::vector<size_type> &n_entries_per_row);
823 template <
typename SparsityPatternType>
826 const IndexSet & col_parallel_partitioning,
827 const SparsityPatternType &nontrilinos_sparsity_pattern,
828 const MPI_Comm & communicator = MPI_COMM_WORLD,
829 const bool exchange_data =
false);
839 template <
typename SparsityPatternType>
842 const SparsityPatternType &nontrilinos_sparsity_pattern,
843 const MPI_Comm & communicator = MPI_COMM_WORLD,
844 const bool exchange_data =
false);
896 std::pair<size_type, size_type>
975 template <
typename ForwardIterator>
978 ForwardIterator
begin,
980 const bool indices_are_sorted =
false);
991 const Epetra_FECrsGraph &
1142 print(std::ostream &out,
1143 const bool write_extended_trilinos_info =
false)
const;
1172 <<
"An error with error number " << arg1
1173 <<
" occurred while calling a Trilinos function");
1181 <<
"The entry with index <" << arg1 <<
',' << arg2
1182 <<
"> does not exist.");
1189 "You are attempting an operation on two sparsity patterns that " 1190 "are the same object, but the operation requires that the " 1191 "two objects are in fact different.");
1201 <<
"You tried to access element (" << arg1 <<
"/" << arg2
1203 <<
" of a distributed matrix, but only rows " << arg3
1204 <<
" through " << arg4
1205 <<
" are stored locally and can be accessed.");
1213 <<
"You tried to access element (" << arg1 <<
"/" << arg2
1215 <<
" of a sparse matrix, but it appears to not" 1216 <<
" exist in the Trilinos sparsity pattern.");
1230 std::unique_ptr<Epetra_FECrsGraph>
graph;
1255 const size_type row,
1256 const size_type index)
1261 visit_present_row();
1266 inline Accessor::size_type
1267 Accessor::row()
const 1269 Assert(a_row < sparsity_pattern->n_rows(),
1270 ExcBeyondEndOfSparsityPattern());
1276 inline Accessor::size_type
1277 Accessor::column()
const 1279 Assert(a_row < sparsity_pattern->n_rows(),
1280 ExcBeyondEndOfSparsityPattern());
1281 return (*colnum_cache)[a_index];
1286 inline Accessor::size_type
1287 Accessor::index()
const 1289 Assert(a_row < sparsity_pattern->n_rows(),
1290 ExcBeyondEndOfSparsityPattern());
1297 const size_type row,
1298 const size_type index)
1299 : accessor(sp, row, index)
1304 inline Iterator::Iterator(
const Iterator &) =
default;
1309 Iterator::operator++()
1311 Assert(accessor.a_row < accessor.sparsity_pattern->n_rows(),
1318 if (accessor.a_index >= accessor.colnum_cache->size())
1320 accessor.a_index = 0;
1323 while (accessor.a_row < accessor.sparsity_pattern->n_rows())
1325 const auto row_length =
1326 accessor.sparsity_pattern->row_length(accessor.a_row);
1327 if (row_length == 0 ||
1328 !accessor.sparsity_pattern->row_is_stored_locally(
1335 accessor.visit_present_row();
1343 Iterator::operator++(
int)
1359 inline const Accessor *Iterator::operator->()
const 1367 Iterator::operator==(
const Iterator &other)
const 1369 return (accessor.a_row == other.accessor.a_row &&
1370 accessor.a_index == other.accessor.a_index);
1376 Iterator::operator!=(
const Iterator &other)
const 1378 return !(*
this == other);
1384 Iterator::operator<(
const Iterator &other)
const 1386 return (accessor.row() < other.accessor.row() ||
1387 (accessor.row() == other.accessor.row() &&
1388 accessor.index() < other.accessor.index()));
1398 const size_type first_valid_row = this->local_range().first;
1444 SparsityPattern::in_local_range(
const size_type index)
const 1446 TrilinosWrappers::types::int_type
begin,
end;
1447 # ifndef DEAL_II_WITH_64BIT_INDICES 1448 begin = graph->RowMap().MinMyGID();
1449 end = graph->RowMap().MaxMyGID() + 1;
1451 begin = graph->RowMap().MinMyGID64();
1452 end = graph->RowMap().MaxMyGID64() + 1;
1455 return ((index >= static_cast<size_type>(
begin)) &&
1456 (index < static_cast<size_type>(
end)));
1464 return graph->Filled();
1485 template <
typename ForwardIterator>
1488 ForwardIterator begin,
1489 ForwardIterator end,
1503 Assert(
sizeof(TrilinosWrappers::types::int_type) ==
sizeof((*
begin) * 2),
1506 TrilinosWrappers::types::int_type *col_index_ptr =
1507 reinterpret_cast<TrilinosWrappers::types::int_type *
>(
1508 const_cast<typename std::decay<decltype(*begin)>::type *
>(&*
begin));
1511 TrilinosWrappers::types::int_type trilinos_row_index = row;
1515 if (row_is_stored_locally(row))
1517 graph->InsertGlobalIndices(trilinos_row_index,
n_cols, col_index_ptr);
1518 else if (nonlocal_graph.get() !=
nullptr)
1523 Assert(nonlocal_graph->RowMap().LID(
1524 static_cast<TrilinosWrappers::types::int_type>(row)) != -1,
1525 ExcMessage(
"Attempted to write into off-processor matrix row " 1526 "that has not be specified as being writable upon " 1528 ierr = nonlocal_graph->InsertGlobalIndices(trilinos_row_index,
1533 ierr = graph->InsertGlobalIndices(1,
1534 &trilinos_row_index,
1543 inline const Epetra_FECrsGraph &
1544 SparsityPattern::trilinos_sparsity_pattern()
const 1552 SparsityPattern::locally_owned_domain_indices()
const 1554 return IndexSet(graph->DomainMap());
1560 SparsityPattern::locally_owned_range_indices()
const 1562 return IndexSet(graph->RangeMap());
1569 DEAL_II_NAMESPACE_CLOSE
1572 # endif // DEAL_II_WITH_TRILINOS static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
const Epetra_Map & domain_partitioner() const
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)
unsigned int local_size() const
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcBeyondEndOfSparsityPattern()
#define AssertDimension(dim1, dim2)
SparsityPatternBase::const_iterator const_iterator
void print(std::ostream &out, const bool write_extended_trilinos_info=false) const
std::shared_ptr< const std::vector< size_type > > colnum_cache
static ::ExceptionBase & ExcAccessToNonPresentElement(size_type arg1, size_type arg2)
::types::global_dof_index size_type
size_type row_length(const size_type row) const
IndexSet locally_owned_range_indices() const
const Epetra_FECrsGraph & trilinos_sparsity_pattern() const
static ::ExceptionBase & ExcSourceEqualsDestination()
const Epetra_Map & row_partitioner() const
bool operator==(const Iterator &) const
size_type n_nonzero_elements() const
const Epetra_Map & col_partitioner() const
#define AssertThrow(cond, exc)
void add(const size_type i, const size_type j)
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)
SymmetricTensor< rank_, dim, Number > operator*(const SymmetricTensor< rank_, dim, Number > &t, const Number &factor)
std::unique_ptr< Epetra_CrsGraph > nonlocal_graph
const_iterator begin() const
bool exists(const size_type i, const size_type j) const
static ::ExceptionBase & ExcTrilinosError(int arg1)
SparsityPattern * sparsity_pattern
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcInvalidIndex(size_type arg1, size_type arg2)
::types::global_dof_index size_type
#define DeclException1(Exception1, type1, outsequence)
MPI_Comm get_mpi_communicator() const
std::unique_ptr< Epetra_Map > column_space_map
virtual ~SparsityPattern() override=default
SparsityPatternBase::size_type size_type
#define Assert(cond, exc)
const Accessor & operator*() const
#define DeclExceptionMsg(Exception, defaulttext)
static ::ExceptionBase & ExcInvalidIndexWithinRow(size_type arg1, size_type arg2)
#define DeclException0(Exception0)
size_type bandwidth() const
void add(const size_type i, const size_type j)
std::size_t memory_consumption() const
void print_gnuplot(std::ostream &out) const
const_iterator end() const
bool is_compressed() const
unsigned int max_entries_per_row() const
bool operator<(const Iterator &) const
static ::ExceptionBase & ExcIteratorPastEnd()
bool operator!=(const Iterator &) const
unsigned int global_dof_index
SparsityPattern & operator=(const SparsityPattern &input_sparsity_pattern)
MatrixTableIterators::Iterator< TransposeTable< T >, Constness, MatrixTableIterators::Storage::column_major > Iterator
bool is_compressed() const
void copy_from(const SparsityPattern &input_sparsity_pattern)
Iterator(const SparsityPattern *sparsity_pattern, const size_type row, const size_type index)
static ::ExceptionBase & ExcAccessToNonlocalRow(size_type arg1, size_type arg2, size_type arg3)
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
const Accessor * operator->() const
const Epetra_Comm & trilinos_communicator() const
static ::ExceptionBase & ExcNotImplemented()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
bool in_local_range(const size_type index) const
void reinit(const size_type m, const size_type n, const size_type n_entries_per_row=0)
IndexSet locally_owned_domain_indices() const
const Epetra_Map & range_partitioner() const
unsigned int row_length(const size_type row) const
std::pair< size_type, size_type > local_range() const
std::unique_ptr< Epetra_FECrsGraph > graph
::types::global_dof_index size_type
Accessor(const SparsityPattern *sparsity_pattern, const size_type row, const size_type index)
bool row_is_stored_locally(const size_type i) const