--- /dev/null
+Changed: All functions `n_nonzero_elements()`, which are members of the
+SparseMatrix and SparsityPattern family of classes, now always return
+`std::uint64_t` instead of types::global_dof_index.
+<br>
+(Marc Fehling, 2022/04/04)
{
namespace types
{
+ /**
+ * Declare type of 64 bit integer used in the Epetra package of Trilinos.
+ */
+ using int64_type = long long int;
+
#ifdef DEAL_II_WITH_64BIT_INDICES
/**
* Declare type of integer used in the Epetra package of Trilinos.
*/
- using int_type = long long int;
+ using int_type = int64_type;
#else
/**
* Declare type of integer used in the Epetra package of Trilinos.
* returns the number of entries in the sparsity pattern; if any of the
* entries should happen to be zero, it is counted anyway.
*/
- size_type
+ std::uint64_t
n_nonzero_elements() const;
/**
* returns the number of entries in the sparsity pattern; if any of the
* entries should happen to be zero, it is counted anyway.
*/
- size_type
+ std::uint64_t
n_nonzero_elements() const;
/**
* Return the total number of nonzero elements of this matrix (summed
* over all MPI processes).
*/
- size_type
+ std::uint64_t
n_nonzero_elements() const;
/**
namespace TrilinosWrappers
{
/**
- * A helper function that queries the size of an Epetra_BlockMap object
- * and calls either the 32 or 64 bit function to get the number of global
- * elements in the map.
+ * A helper function that queries the size of an Epetra_BlockMap object. We
+ * always call the 64 bit function to get the number of global elements in the
+ * map.
*/
- inline TrilinosWrappers::types::int_type
+ inline TrilinosWrappers::types::int64_type
n_global_elements(const Epetra_BlockMap &map)
{
-# ifdef DEAL_II_WITH_64BIT_INDICES
return map.NumGlobalElements64();
-# else
- return map.NumGlobalElements();
-# endif
}
/**
}
/**
- * A helper function that finds the number of global entries by calling
- * either the 32 or 64 bit function.
+ * A helper function that finds the number of global entries. We always call
+ * the 64 bit function.
*/
- inline TrilinosWrappers::types::int_type
+ inline TrilinosWrappers::types::int64_type
n_global_entries(const Epetra_CrsGraph &graph)
{
-# ifdef DEAL_II_WITH_64BIT_INDICES
return graph.NumGlobalEntries64();
-# else
- return graph.NumGlobalEntries();
-# endif
}
/**
* Return the total number of nonzero elements of this matrix (summed
* over all MPI processes).
*/
- size_type
+ std::uint64_t
n_nonzero_elements() const;
/**
- inline SparseMatrix::size_type
+ inline std::uint64_t
SparseMatrix::n_nonzero_elements() const
{
-# ifndef DEAL_II_WITH_64BIT_INDICES
- return matrix->NumGlobalNonzeros();
-# else
- return matrix->NumGlobalNonzeros64();
-# endif
+ // Trilinos uses 64bit functions internally for attribute access, which
+ // return `long long`. They also offer 32bit variants that return `int`,
+ // however those call the 64bit version and convert the values to 32bit.
+ // There is no necessity in using the 32bit versions at all.
+ return static_cast<std::uint64_t>(matrix->NumGlobalNonzeros64());
}
/**
* Return the number of nonzero elements of this sparsity pattern.
*/
- size_type
+ std::uint64_t
n_nonzero_elements() const;
/**
- MatrixBase::size_type
+ std::uint64_t
MatrixBase::n_nonzero_elements() const
{
MatInfo mat_info;
const PetscErrorCode ierr = MatGetInfo(matrix, MAT_GLOBAL_SUM, &mat_info);
AssertThrow(ierr == 0, ExcPETScError(ierr));
- return static_cast<size_type>(mat_info.nz_used);
+ // MatInfo logs quantities as PetscLogDouble. So we need to cast it to match
+ // out interface.
+ return static_cast<std::uint64_t>(mat_info.nz_used);
}
return index_sets;
}
- BlockSparseMatrix::size_type
+ std::uint64_t
BlockSparseMatrix::n_nonzero_elements() const
{
- size_type n_nonzero = 0;
+ std::uint64_t n_nonzero = 0;
for (size_type rows = 0; rows < this->n_block_rows(); ++rows)
for (size_type cols = 0; cols < this->n_block_cols(); ++cols)
n_nonzero += this->block(rows, cols).n_nonzero_elements();
- BlockSparseMatrix::size_type
+ std::uint64_t
BlockSparseMatrix::n_nonzero_elements() const
{
- size_type n_nonzero = 0;
+ std::uint64_t n_nonzero = 0;
for (size_type rows = 0; rows < this->n_block_rows(); ++rows)
for (size_type cols = 0; cols < this->n_block_cols(); ++cols)
n_nonzero += this->block(rows, cols).n_nonzero_elements();
- SparsityPattern::size_type
+ std::uint64_t
SparsityPattern::n_nonzero_elements() const
{
- TrilinosWrappers::types::int_type nnz = n_global_entries(*graph);
+ TrilinosWrappers::types::int64_type nnz = n_global_entries(*graph);
- return static_cast<size_type>(nnz);
+ return static_cast<std::uint64_t>(nnz);
}