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/subscriptor.h> 25 # include <deal.II/base/index_set.h> 26 # include <deal.II/lac/exceptions.h> 32 # include <deal.II/base/std_cxx11/shared_ptr.h> 34 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
35 # include <Epetra_FECrsGraph.h> 36 # include <Epetra_Map.h> 37 # ifdef DEAL_II_WITH_MPI 38 # include <Epetra_MpiComm.h> 41 # include "Epetra_SerialComm.h" 43 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
46 DEAL_II_NAMESPACE_OPEN
116 <<
"You tried to access row " << arg1
117 <<
" of a distributed sparsity pattern, " 118 <<
" but only rows " << arg2 <<
" through " << arg3
119 <<
" are stored locally and can be accessed.");
233 <<
"Attempt to access element " << arg2
234 <<
" of row " << arg1
235 <<
" which doesn't have that many elements.");
318 const std::vector<size_type> &n_entries_per_row);
358 const std::vector<size_type> &n_entries_per_row);
372 template<
typename SparsityPatternType>
374 copy_from (
const SparsityPatternType &nontrilinos_sparsity_pattern);
424 const size_type n_entries_per_row = 0) DEAL_II_DEPRECATED;
439 const
std::vector<
size_type> &n_entries_per_row) DEAL_II_DEPRECATED;
460 const Epetra_Map &col_parallel_partitioning,
461 const
size_type n_entries_per_row = 0) DEAL_II_DEPRECATED;
477 const Epetra_Map &col_parallel_partitioning,
478 const
std::vector<
size_type> &n_entries_per_row) DEAL_II_DEPRECATED;
497 reinit (const Epetra_Map ¶llel_partitioning,
498 const
size_type n_entries_per_row = 0) DEAL_II_DEPRECATED;
513 reinit (const Epetra_Map ¶llel_partitioning,
514 const
std::vector<
size_type> &n_entries_per_row) DEAL_II_DEPRECATED;
535 reinit (const Epetra_Map &row_parallel_partitioning,
536 const Epetra_Map &col_parallel_partitioning,
537 const
size_type n_entries_per_row = 0) DEAL_II_DEPRECATED;
553 reinit (const Epetra_Map &row_parallel_partitioning,
554 const Epetra_Map &col_parallel_partitioning,
555 const
std::vector<
size_type> &n_entries_per_row) DEAL_II_DEPRECATED;
567 template<typename SparsityPatternType>
569 reinit (const Epetra_Map &row_parallel_partitioning,
570 const Epetra_Map &col_parallel_partitioning,
571 const SparsityPatternType &nontrilinos_sparsity_pattern,
572 const
bool exchange_data = false) DEAL_II_DEPRECATED;
584 template<typename SparsityPatternType>
586 reinit (const Epetra_Map ¶llel_partitioning,
587 const SparsityPatternType &nontrilinos_sparsity_pattern,
588 const
bool exchange_data = false) DEAL_II_DEPRECATED;
607 const MPI_Comm &communicator = MPI_COMM_WORLD,
621 const MPI_Comm &communicator,
639 const
IndexSet &col_parallel_partitioning,
640 const MPI_Comm &communicator = MPI_COMM_WORLD,
655 const
IndexSet &col_parallel_partitioning,
656 const MPI_Comm &communicator,
686 const
IndexSet &col_parallel_partitioning,
688 const MPI_Comm &communicator = MPI_COMM_WORLD,
708 const MPI_Comm &communicator = MPI_COMM_WORLD,
723 const MPI_Comm &communicator,
744 const
IndexSet &col_parallel_partitioning,
745 const MPI_Comm &communicator = MPI_COMM_WORLD,
775 const
IndexSet &col_parallel_partitioning,
777 const MPI_Comm &communicator = MPI_COMM_WORLD,
786 const
IndexSet &col_parallel_partitioning,
787 const MPI_Comm &communicator,
799 template<typename SparsityPatternType>
802 const
IndexSet &col_parallel_partitioning,
803 const SparsityPatternType &nontrilinos_sparsity_pattern,
804 const MPI_Comm &communicator = MPI_COMM_WORLD,
805 const
bool exchange_data = false);
815 template<typename SparsityPatternType>
818 const SparsityPatternType &nontrilinos_sparsity_pattern,
819 const MPI_Comm &communicator = MPI_COMM_WORLD,
820 const
bool exchange_data = false);
928 template <typename ForwardIterator>
930 ForwardIterator
begin,
932 const
bool indices_are_sorted = false);
1075 const
bool write_extended_trilinos_info = false) const;
1103 << "An error with error number " << arg1
1104 << " occurred while calling a Trilinos function");
1111 << "The entry with index <" << arg1 << ',' << arg2
1112 << "> does not exist.");
1124 << "You tried to access element (" << arg1
1125 << "/" << arg2 << ")"
1126 << " of a distributed matrix, but only rows "
1127 << arg3 << " through " << arg4
1128 << " are stored locally and can be accessed.");
1135 << "You tried to access element (" << arg1
1136 << "/" << arg2 << ")"
1137 << " of a sparse matrix, but it appears to not"
1138 << " exist in the Trilinos sparsity pattern.");
1183 sparsity_pattern(const_cast<SparsityPattern *>(sp)),
1187 visit_present_row ();
1194 Accessor::row()
const 1196 Assert (a_row < sparsity_pattern->
n_rows(), ExcBeyondEndOfSparsityPattern());
1204 Accessor::column()
const 1206 Assert (a_row < sparsity_pattern->
n_rows(), ExcBeyondEndOfSparsityPattern());
1207 return (*colnum_cache)[a_index];
1214 Accessor::index()
const 1216 Assert (a_row < sparsity_pattern->
n_rows(), ExcBeyondEndOfSparsityPattern());
1227 accessor(sp, row, index)
1232 Iterator::Iterator(
const Iterator &i)
1234 accessor(i.accessor)
1241 Iterator::operator++ ()
1243 Assert (accessor.a_row < accessor.sparsity_pattern->n_rows(),
1252 if (accessor.a_index >= accessor.colnum_cache->size())
1254 accessor.a_index = 0;
1257 while ((accessor.a_row < accessor.sparsity_pattern->n_rows())
1259 (accessor.sparsity_pattern->row_length(accessor.a_row) == 0))
1262 accessor.visit_present_row();
1271 Iterator::operator++ (
int)
1273 const Iterator old_state = *
this;
1282 Iterator::operator* ()
const 1291 Iterator::operator-> ()
const 1300 Iterator::operator == (
const Iterator &other)
const 1302 return (accessor.a_row == other.accessor.a_row &&
1303 accessor.a_index == other.accessor.a_index);
1310 Iterator::operator != (
const Iterator &other)
const 1312 return ! (*
this == other);
1319 Iterator::operator < (
const Iterator &other)
const 1321 return (accessor.row() < other.accessor.row() ||
1322 (accessor.row() == other.accessor.row() &&
1323 accessor.index() < other.accessor.index()));
1385 TrilinosWrappers::types::int_type
begin,
end;
1386 #ifndef DEAL_II_WITH_64BIT_INDICES 1388 end =
graph->RowMap().MaxMyGID()+1;
1391 end =
graph->RowMap().MaxMyGID64()+1;
1394 return ((index >= static_cast<size_type>(
begin)) &&
1395 (index < static_cast<size_type>(
end)));
1404 return graph->Filled();
1428 template <
typename ForwardIterator>
1432 ForwardIterator
begin,
1433 ForwardIterator
end,
1447 Assert (
sizeof(TrilinosWrappers::types::int_type) ==
1451 TrilinosWrappers::types::int_type *col_index_ptr =
1452 (TrilinosWrappers::types::int_type *)(&*
begin);
1456 if (
graph->RowMap().LID(static_cast<TrilinosWrappers::types::int_type>(row)) != -1)
1457 ierr =
graph->InsertGlobalIndices (row,
n_cols, col_index_ptr);
1463 Assert (
nonlocal_graph->RowMap().LID(static_cast<TrilinosWrappers::types::int_type>(row)) != -1,
1464 ExcMessage(
"Attempted to write into off-processor matrix row " 1465 "that has not be specified as being writable upon " 1470 ierr =
graph->InsertGlobalIndices
1471 (1, (TrilinosWrappers::types::int_type *)&row,
n_cols, col_index_ptr);
1479 const Epetra_FECrsGraph &
1491 return IndexSet(static_cast<const Epetra_Map &>(
graph->DomainMap()));
1500 return IndexSet(static_cast<const Epetra_Map &>(
graph->RangeMap()));
1507 DEAL_II_NAMESPACE_CLOSE
1510 #endif // DEAL_II_WITH_TRILINOS static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
unsigned int local_size() const
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcBeyondEndOfSparsityPattern()
::types::global_dof_index size_type
void print(std::ostream &out, const bool write_extended_trilinos_info=false) const
static ::ExceptionBase & ExcAccessToNonPresentElement(size_type arg1, size_type arg2)
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()
bool operator==(const Iterator &) const
std_cxx11::shared_ptr< Epetra_FECrsGraph > graph
size_type n_nonzero_elements() const
std_cxx11::shared_ptr< Epetra_CrsGraph > nonlocal_graph
#define AssertThrow(cond, exc)
void add(const size_type i, const size_type j)
::types::global_dof_index size_type
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)
const_iterator begin() const
bool exists(const size_type i, const size_type j) const
static ::ExceptionBase & ExcTrilinosError(int arg1)
SparsityPattern * sparsity_pattern
std_cxx11::shared_ptr< Epetra_Map > column_space_map
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcInvalidIndex(size_type arg1, size_type arg2)
#define DeclException1(Exception1, type1, outsequence)
std_cxx11::shared_ptr< const std::vector< size_type > > colnum_cache
MPI_Comm get_mpi_communicator() const
#define Assert(cond, exc)
const Accessor & operator*() const
void copy_from(const SparsityPattern &input_sparsity_pattern)
static ::ExceptionBase & ExcInvalidIndexWithinRow(size_type arg1, size_type arg2)
#define DeclException0(Exception0)
size_type bandwidth() const
std::size_t memory_consumption() const
const Epetra_Comm & trilinos_communicator() const 1
const Epetra_Map & domain_partitioner() const 1
::types::global_dof_index size_type
void print_gnuplot(std::ostream &out) const
const_iterator end() const
bool is_compressed() const
SparsityPatternIterators::Iterator const_iterator
unsigned int max_entries_per_row() const
bool operator<(const Iterator &) const
static ::ExceptionBase & ExcIteratorPastEnd()
const Epetra_Map & range_partitioner() const 1
bool operator!=(const Iterator &) const
SparsityPattern & operator=(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)
const Epetra_Map & col_partitioner() const 1
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
const Accessor * operator->() const
static ::ExceptionBase & ExcNotImplemented()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
bool in_local_range(const size_type index) const
const Epetra_Map & row_partitioner() const 1
void reinit(const size_type m, const size_type n, const size_type n_entries_per_row=0)
IndexSet locally_owned_domain_indices() const
virtual ~SparsityPattern()
std::pair< size_type, size_type > local_range() const
Accessor(const SparsityPattern *sparsity_pattern, const size_type row, const size_type index)