19#ifdef DEAL_II_WITH_TRILINOS
27# include <Epetra_Export.h>
91 graph = std::make_unique<Epetra_FECrsGraph>(View,
95 graph->FillComplete();
121 , column_space_map(std::move(
other.column_space_map))
122 , graph(std::move(
other.graph))
123 , nonlocal_graph(std::move(
other.nonlocal_graph))
136 new Epetra_FECrsGraph(View, *column_space_map, *column_space_map, 0))
141 "Copy constructor only works for empty sparsity patterns."));
247 std::unique_ptr<Epetra_Map> & column_space_map,
248 std::unique_ptr<Epetra_FECrsGraph> &graph,
249 std::unique_ptr<Epetra_CrsGraph> & nonlocal_graph)
252 ExcMessage(
"Row map must be 1-to-1, i.e., no overlap between "
253 "the maps of different processors."));
255 ExcMessage(
"Column map must be 1-to-1, i.e., no overlap between "
256 "the maps of different processors."));
258 nonlocal_graph.reset();
260 column_space_map = std::make_unique<Epetra_Map>(
col_map);
265 static_cast<std::uint64_t
>(std::numeric_limits<int>::max()),
266 ExcMessage(
"The TrilinosWrappers use Epetra internally which "
267 "uses 'signed int' to represent local indices. "
268 "Therefore, only 2,147,483,647 nonzero matrix "
269 "entries can be stored on a single process, "
270 "but you are requesting more than that. "
271 "If possible, use more MPI processes."));
282 if (
row_map.Comm().NumProc() > 1)
283 graph = std::make_unique<Epetra_FECrsGraph>(
292 graph = std::make_unique<Epetra_FECrsGraph>(
302 std::unique_ptr<Epetra_Map> & column_space_map,
303 std::unique_ptr<Epetra_FECrsGraph> &graph,
304 std::unique_ptr<Epetra_CrsGraph> & nonlocal_graph)
307 ExcMessage(
"Row map must be 1-to-1, i.e., no overlap between "
308 "the maps of different processors."));
310 ExcMessage(
"Column map must be 1-to-1, i.e., no overlap between "
311 "the maps of different processors."));
314 nonlocal_graph.reset();
319 column_space_map = std::make_unique<Epetra_Map>(
col_map);
333 static_cast<std::uint64_t
>(std::numeric_limits<int>::max()),
334 ExcMessage(
"The TrilinosWrappers use Epetra internally which "
335 "uses 'signed int' to represent local indices. "
336 "Therefore, only 2,147,483,647 nonzero matrix "
337 "entries can be stored on a single process, "
338 "but you are requesting more than that. "
339 "If possible, use more MPI processes."));
341 if (
row_map.Comm().NumProc() > 1)
342 graph = std::make_unique<Epetra_FECrsGraph>(
351 graph = std::make_unique<Epetra_FECrsGraph>(
357 template <
typename SparsityPatternType>
363 std::unique_ptr<Epetra_Map> & column_space_map,
364 std::unique_ptr<Epetra_FECrsGraph> &graph,
365 std::unique_ptr<Epetra_CrsGraph> & nonlocal_graph)
367 nonlocal_graph.reset();
375 column_space_map = std::make_unique<Epetra_Map>(
col_map);
379 "This function only works if the row map is contiguous."));
389 static_cast<int>(
sp.row_length(row));
394 static_cast<std::uint64_t
>(std::numeric_limits<int>::max()),
395 ExcMessage(
"The TrilinosWrappers use Epetra internally which "
396 "uses 'signed int' to represent local indices. "
397 "Therefore, only 2,147,483,647 nonzero matrix "
398 "entries can be stored on a single process, "
399 "but you are requesting more than that. "
400 "If possible, use more MPI processes."));
402 if (
row_map.Comm().NumProc() > 1)
403 graph = std::make_unique<Epetra_FECrsGraph>(
Copy,
408 graph = std::make_unique<Epetra_FECrsGraph>(
413 std::vector<TrilinosWrappers::types::int_type> row_indices;
425 row_indices.resize(row_length, -1);
430 for (
int col = 0; col < row_length;)
432 row_indices[col++] = p->column();
433 if (col < row_length)
437 graph->Epetra_CrsGraph::InsertGlobalIndices(row,
442 for (size_type row = 0; row <
sp.n_rows(); ++row)
449 row_indices.resize(row_length, -1);
454 for (
int col = 0; col < row_length;)
456 row_indices[col++] = p->column();
457 if (col < row_length)
462 graph->InsertGlobalIndices(1,
469 const auto &range_map =
470 static_cast<const Epetra_Map &
>(graph->RangeMap());
471 int ierr = graph->GlobalAssemble(*column_space_map, range_map,
true);
474 ierr = graph->OptimizeStorage();
583 "The set of writable rows passed to this method does not "
584 "contain the locally owned rows, which is not allowed."));
601 template <
typename SparsityPatternType>
627 template <
typename SparsityPatternType>
668 graph = std::make_unique<Epetra_FECrsGraph>(*
sp.graph);
670 if (
sp.nonlocal_graph.get() !=
nullptr)
678 template <
typename SparsityPatternType>
707 graph = std::make_unique<Epetra_FECrsGraph>(View,
711 graph->FillComplete();
767 const auto &range_map =
768 static_cast<const Epetra_Map &
>(
graph->RangeMap());
777 catch (
const int error_code)
782 "The Epetra_CrsGraph::OptimizeStorage() function "
783 "has thrown an error with code " +
784 std::to_string(error_code) +
785 ". You will have to look up the exact meaning of this error "
786 "in the Trilinos source code, but oftentimes, this function "
787 "throwing an error indicates that you are trying to allocate "
788 "more than 2,147,483,647 nonzero entries in the sparsity "
789 "pattern on the local process; this will not work because "
790 "Epetra indexes entries with a simple 'signed int'."));
808 return graph->RowMap().LID(
833 if (
graph->Filled() ==
false)
931 std::pair<SparsityPattern::size_type, SparsityPattern::size_type>
948 return static_cast<std::uint64_t
>(nnz);
956 int nnz =
graph->MaxNumIndices();
958 return static_cast<unsigned int>(nnz);
997 const auto &domain_map =
998 static_cast<const Epetra_Map &
>(
graph->DomainMap());
1008 const auto &range_map =
1009 static_cast<const Epetra_Map &
>(
graph->RangeMap());
1019 dynamic_cast<const Epetra_MpiComm *
>(&
graph->RangeMap().Comm());
1048 for (
int i = 0; i <
graph->NumMyRows(); ++i)
1055 <<
") " << std::endl;
1083 out <<
static_cast<int>(
1086 << -
static_cast<int>(
1113 const ::SparsityPattern &,
1118 const ::DynamicSparsityPattern &,
1126 const ::SparsityPattern &,
1132 const ::DynamicSparsityPattern &,
value_type * data() const noexcept
virtual void resize(const size_type rows, const size_type cols)
std::shared_ptr< const std::vector< size_type > > colnum_cache
SparsityPattern * sparsity_pattern
size_type row_length(const size_type row) const
std::unique_ptr< Epetra_FECrsGraph > graph
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
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
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_sorted=false)
bool is_compressed() const
unsigned int local_size() const
void copy_from(const SparsityPattern &input_sparsity_pattern)
std::unique_ptr< Epetra_Map > column_space_map
const Epetra_Map & range_partitioner() const
const_iterator begin() const
std::size_t memory_consumption() const
SparsityPattern & operator=(const SparsityPattern &input_sparsity_pattern)
bool row_is_stored_locally(const size_type i) const
void reinit(const size_type m, const size_type n, const size_type n_entries_per_row=0)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
IndexSet complete_index_set(const IndexSet::size_type N)
types::global_dof_index size_type
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
TrilinosWrappers::types::int_type n_global_rows(const Epetra_CrsGraph &graph)
TrilinosWrappers::types::int_type min_my_gid(const Epetra_BlockMap &map)
TrilinosWrappers::types::int64_type n_global_entries(const Epetra_CrsGraph &graph)
TrilinosWrappers::types::int64_type n_global_elements(const Epetra_BlockMap &map)
TrilinosWrappers::types::int_type max_my_gid(const Epetra_BlockMap &map)
TrilinosWrappers::types::int_type n_global_cols(const Epetra_CrsGraph &graph)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
const Epetra_Comm & comm_self()
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)