template <typename Number>
class Vector;
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
class SparseMatrix;
} // namespace TpetraWrappers
# endif
{
namespace TpetraWrappers
{
- template <typename NodeType>
+ template <typename MemorySpace>
class SparsityPattern;
} // namespace TpetraWrappers
} // namespace LinearAlgebra
* SparseMatrix::resume_fill() first. Once you finish modifying
* the matrix, you must call SparseMatrix::compress() again.
*/
- template <typename Number,
- typename NodeType =
- Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
+ template <typename Number, typename MemorySpace = dealii::MemorySpace::Host>
class SparseMatrix : public Subscriptor
{
public:
*/
using value_type = Number;
+ /**
+ * Typedef for the NodeType
+ */
+ using NodeType = Tpetra::KokkosCompat::KokkosDeviceWrapperNode<
+ typename MemorySpace::kokkos_space::execution_space,
+ typename MemorySpace::kokkos_space>;
+
/**
* Typedef for Tpetra::CrsMatrix
*/
using MatrixType =
- Tpetra::CrsMatrix<Number, int, dealii::types::signed_global_dof_index>;
+ Tpetra::CrsMatrix<Number,
+ int,
+ dealii::types::signed_global_dof_index,
+ NodeType>;
/**
* Typedef for Tpetra::Map
*/
- using MapType = Tpetra::Map<int, dealii::types::signed_global_dof_index>;
+ using MapType =
+ Tpetra::Map<int, dealii::types::signed_global_dof_index, NodeType>;
/**
* Typedef for Tpetra::CrsGraph
*/
using GraphType =
- Tpetra::CrsGraph<int, dealii::types::signed_global_dof_index>;
+ Tpetra::CrsGraph<int, dealii::types::signed_global_dof_index, NodeType>;
/**
* @name Constructors and initialization.
/**
* Generate a matrix from a TpetraWrappers::SparsityPattern object.
*/
- SparseMatrix(const SparsityPattern<NodeType> &sparsity_pattern);
+ SparseMatrix(const SparsityPattern<MemorySpace> &sparsity_pattern);
/**
* Move constructor. Create a new sparse matrix by stealing the internal
* data of the `other` object.
*/
- SparseMatrix(SparseMatrix<Number, NodeType> &&other) noexcept;
+ SparseMatrix(SparseMatrix<Number, MemorySpace> &&other) noexcept;
/**
* Copy constructor is deleted.
*/
- SparseMatrix(const SparseMatrix<Number, NodeType> &) = delete;
+ SparseMatrix(const SparseMatrix<Number, MemorySpace> &) = delete;
/**
* operator= is deleted.
*/
- SparseMatrix<Number, NodeType> &
- operator=(const SparseMatrix<Number, NodeType> &) = delete;
+ SparseMatrix<Number, MemorySpace> &
+ operator=(const SparseMatrix<Number, MemorySpace> &) = delete;
/**
* Move assignment operator.
*/
- SparseMatrix<Number, NodeType> &
- operator=(SparseMatrix<Number, NodeType> &&other) noexcept;
+ SparseMatrix<Number, MemorySpace> &
+ operator=(SparseMatrix<Number, MemorySpace> &&other) noexcept;
/**
* Destructor. Made virtual so that one can use pointers to objects of
* processors in order to avoid a dead lock.
*/
void
- reinit(const SparsityPattern<NodeType> &sparsity_pattern);
+ reinit(const SparsityPattern<MemorySpace> &sparsity_pattern);
/** @} */
/**
/**
* Add @p value to the element (<i>i,j</i>).
- * Just as the respective call in deal.II SparseMatrix<Number, NodeType>
- * class. Moreover, if <tt>value</tt> is not a finite number an exception
- * is thrown.
+ * Just as the respective call in deal.II SparseMatrix<Number,
+ * MemorySpace> class. Moreover, if <tt>value</tt> is not a finite number
+ * an exception is thrown.
*
* @note When add is called on a compressed matrix, the matrix is set
* back to an uncompressed state.
/**
* Add an array of values given by <tt>values</tt> in the given global
* matrix row at columns specified by col_indices in the sparse matrix.
- * Just as the respective call in deal.II SparseMatrix<Number, NodeType>
- * class. The optional parameter <tt>elide_zero_values</tt> can be used to
- * specify whether zero values should be added anyway or these should be
- * filtered away and only non-zero data is added.
- * The default value is <tt>true</tt>, i.e., zero values won't be added
- * into the matrix.
+ * Just as the respective call in deal.II SparseMatrix<Number,
+ * MemorySpace> class. The optional parameter <tt>elide_zero_values</tt>
+ * can be used to specify whether zero values should be added anyway or
+ * these should be filtered away and only non-zero data is added. The
+ * default value is <tt>true</tt>, i.e., zero values won't be added into
+ * the matrix.
*
* @note When add is called on a compressed matrix, the matrix is set
* back to an uncompressed state.
/* ------------------------- Inline functions ---------------------- */
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline void
- SparseMatrix<Number, NodeType>::add(const size_type i,
- const size_type j,
- const TrilinosScalar value)
+ SparseMatrix<Number, MemorySpace>::add(const size_type i,
+ const size_type j,
+ const TrilinosScalar value)
{
add(i, 1, &j, &value, false);
}
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline dealii::types::signed_global_dof_index
- SparseMatrix<Number, NodeType>::m() const
+ SparseMatrix<Number, MemorySpace>::m() const
{
return matrix->getRowMap()->getGlobalNumElements();
}
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline dealii::types::signed_global_dof_index
- SparseMatrix<Number, NodeType>::n() const
+ SparseMatrix<Number, MemorySpace>::n() const
{
// If the matrix structure has not been fixed (i.e., we did not have a
// sparsity pattern), it does not know about the number of columns, so we
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline bool
- SparseMatrix<Number, NodeType>::is_compressed() const
+ SparseMatrix<Number, MemorySpace>::is_compressed() const
{
return compressed;
}
- template <typename Number, typename NodeType>
- inline const Tpetra::
- CrsMatrix<Number, int, types::signed_global_dof_index> &
- SparseMatrix<Number, NodeType>::trilinos_matrix() const
+ template <typename Number, typename MemorySpace>
+ inline const Tpetra::CrsMatrix<
+ Number,
+ int,
+ types::signed_global_dof_index,
+ typename SparseMatrix<Number, MemorySpace>::NodeType> &
+ SparseMatrix<Number, MemorySpace>::trilinos_matrix() const
{
return *matrix;
}
- template <typename Number, typename NodeType>
- inline Tpetra::CrsMatrix<Number, int, types::signed_global_dof_index> &
- SparseMatrix<Number, NodeType>::trilinos_matrix()
+ template <typename Number, typename MemorySpace>
+ inline Tpetra::CrsMatrix<
+ Number,
+ int,
+ types::signed_global_dof_index,
+ typename SparseMatrix<Number, MemorySpace>::NodeType> &
+ SparseMatrix<Number, MemorySpace>::trilinos_matrix()
{
return *matrix;
}
- template <typename Number, typename NodeType>
- inline Teuchos::RCP<
- const Tpetra::CrsMatrix<Number, int, types::signed_global_dof_index>>
- SparseMatrix<Number, NodeType>::trilinos_rcp() const
+ template <typename Number, typename MemorySpace>
+ inline Teuchos::RCP<const Tpetra::CrsMatrix<
+ Number,
+ int,
+ types::signed_global_dof_index,
+ typename SparseMatrix<Number, MemorySpace>::NodeType>>
+ SparseMatrix<Number, MemorySpace>::trilinos_rcp() const
{
return matrix.getConst();
}
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline Teuchos::RCP<
- Tpetra::CrsMatrix<Number, int, types::signed_global_dof_index>>
- SparseMatrix<Number, NodeType>::trilinos_rcp()
+ Tpetra::CrsMatrix<Number,
+ int,
+ types::signed_global_dof_index,
+ typename SparseMatrix<Number, MemorySpace>::NodeType>>
+ SparseMatrix<Number, MemorySpace>::trilinos_rcp()
{
return matrix;
}
// Actually, it does not even matter how many threads there are, but
// only if we use an MPI compiler or a standard compiler. So, even one
// thread on a configuration with MPI will still get a parallel interface.
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix()
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix()
: column_space_map(Utilities::Trilinos::internal::make_rcp<MapType>(
0,
0,
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix(
- const SparsityPattern<NodeType> &sparsity_pattern)
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix(
+ const SparsityPattern<MemorySpace> &sparsity_pattern)
: matrix(Utilities::Trilinos::internal::make_rcp<MatrixType>(
sparsity_pattern.trilinos_sparsity_pattern()))
{
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix(
- SparseMatrix<Number, NodeType> &&other) noexcept
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix(
+ SparseMatrix<Number, MemorySpace> &&other) noexcept
: column_space_map(std::move(other.column_space_map))
, matrix(std::move(other.matrix))
, compressed(std::move(other.compressed))
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType> &
- SparseMatrix<Number, NodeType>::operator=(
- SparseMatrix<Number, NodeType> &&other) noexcept
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace> &
+ SparseMatrix<Number, MemorySpace>::operator=(
+ SparseMatrix<Number, MemorySpace> &&other) noexcept
{
column_space_map = std::move(other.column_space_map);
matrix = std::move(other.matrix);
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
template <typename SparsityPatternType>
void
- SparseMatrix<Number, NodeType>::reinit(
+ SparseMatrix<Number, MemorySpace>::reinit(
const SparsityPatternType &sparsity_pattern)
{
reinit_matrix<Number, NodeType, SparsityPatternType>(
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::reinit(
- const SparsityPattern<NodeType> &sparsity_pattern)
+ SparseMatrix<Number, MemorySpace>::reinit(
+ const SparsityPattern<MemorySpace> &sparsity_pattern)
{
column_space_map.reset();
matrix.reset();
// Constructors and initialization using an IndexSet description:
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix(
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix(
const IndexSet ¶llel_partitioning,
const MPI_Comm communicator,
const unsigned int n_max_entries_per_row)
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix(
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix(
const IndexSet ¶llel_partitioning,
const MPI_Comm communicator,
const std::vector<unsigned int> &n_entries_per_row)
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix(
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const MPI_Comm communicator,
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType>::SparseMatrix(
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace>::SparseMatrix(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const MPI_Comm communicator,
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
template <typename SparsityPatternType>
inline void
- SparseMatrix<Number, NodeType>::reinit(
+ SparseMatrix<Number, MemorySpace>::reinit(
const IndexSet ¶llel_partitioning,
const SparsityPatternType &sparsity_pattern,
const MPI_Comm communicator,
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
template <typename SparsityPatternType>
void
- SparseMatrix<Number, NodeType>::reinit(
+ SparseMatrix<Number, MemorySpace>::reinit(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
// Information on the matrix
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline unsigned int
- SparseMatrix<Number, NodeType>::local_size() const
+ SparseMatrix<Number, MemorySpace>::local_size() const
{
return matrix->getLocalNumRows();
}
- template <typename Number, typename NodeType>
- inline std::pair<typename SparseMatrix<Number, NodeType>::size_type,
- typename SparseMatrix<Number, NodeType>::size_type>
- SparseMatrix<Number, NodeType>::local_range() const
+ template <typename Number, typename MemorySpace>
+ inline std::pair<typename SparseMatrix<Number, MemorySpace>::size_type,
+ typename SparseMatrix<Number, MemorySpace>::size_type>
+ SparseMatrix<Number, MemorySpace>::local_range() const
{
size_type begin, end;
begin = matrix->getRowMap()->getMinLocalIndex();
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
inline size_t
- SparseMatrix<Number, NodeType>::n_nonzero_elements() const
+ SparseMatrix<Number, MemorySpace>::n_nonzero_elements() const
{
return matrix->getGlobalNumEntries();
}
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
MPI_Comm
- SparseMatrix<Number, NodeType>::get_mpi_communicator() const
+ SparseMatrix<Number, MemorySpace>::get_mpi_communicator() const
{
return Utilities::Trilinos::teuchos_comm_to_mpi_comm(matrix->getComm());
}
// Modifying entries
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType> &
- SparseMatrix<Number, NodeType>::operator=(const double d)
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace> &
+ SparseMatrix<Number, MemorySpace>::operator=(const double d)
{
(void)d;
Assert(d == 0, ExcScalarAssignmentOnlyForZeroValue());
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType> &
- SparseMatrix<Number, NodeType>::operator*=(const Number a)
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace> &
+ SparseMatrix<Number, MemorySpace>::operator*=(const Number a)
{
matrix->scale(a);
return *this;
- template <typename Number, typename NodeType>
- SparseMatrix<Number, NodeType> &
- SparseMatrix<Number, NodeType>::operator/=(const Number a)
+ template <typename Number, typename MemorySpace>
+ SparseMatrix<Number, MemorySpace> &
+ SparseMatrix<Number, MemorySpace>::operator/=(const Number a)
{
Assert(a != 0, ExcDivideByZero());
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::add(const size_type row,
- const size_type n_cols,
- const size_type *col_indices,
- const TrilinosScalar *values,
- const bool elide_zero_values,
- const bool /*col_indices_are_sorted*/)
+ SparseMatrix<Number, MemorySpace>::add(
+ const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const TrilinosScalar *values,
+ const bool elide_zero_values,
+ const bool /*col_indices_are_sorted*/)
{
AssertIndexRange(row, this->m());
// Multiplications
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::vmult(Vector<Number> &dst,
- const Vector<Number> &src) const
+ SparseMatrix<Number, MemorySpace>::vmult(Vector<Number> &dst,
+ const Vector<Number> &src) const
{
Assert(&src != &dst, ExcSourceEqualsDestination());
Assert(matrix->isFillComplete(), ExcMatrixNotCompressed());
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::Tvmult(Vector<Number> &dst,
- const Vector<Number> &src) const
+ SparseMatrix<Number, MemorySpace>::Tvmult(Vector<Number> &dst,
+ const Vector<Number> &src) const
{
Assert(&src != &dst, ExcSourceEqualsDestination());
Assert(matrix->isFillComplete(), ExcMatrixNotCompressed());
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::vmult_add(Vector<Number> &dst,
- const Vector<Number> &src) const
+ SparseMatrix<Number, MemorySpace>::vmult_add(
+ Vector<Number> &dst,
+ const Vector<Number> &src) const
{
Assert(&src != &dst, ExcSourceEqualsDestination());
Assert(matrix->isFillComplete(), ExcMatrixNotCompressed());
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::Tvmult_add(Vector<Number> &dst,
- const Vector<Number> &src) const
+ SparseMatrix<Number, MemorySpace>::Tvmult_add(
+ Vector<Number> &dst,
+ const Vector<Number> &src) const
{
Assert(&src != &dst, ExcSourceEqualsDestination());
Assert(matrix->isFillComplete(), ExcMatrixNotCompressed());
}
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::print(
+ SparseMatrix<Number, MemorySpace>::print(
std::ostream &out,
const bool print_detailed_trilinos_information) const
{
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::compress(
+ SparseMatrix<Number, MemorySpace>::compress(
[[maybe_unused]] VectorOperation::values operation)
{
if (!compressed)
}
}
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
void
- SparseMatrix<Number, NodeType>::resume_fill()
+ SparseMatrix<Number, MemorySpace>::resume_fill()
{
if (compressed)
{
{
namespace TpetraWrappers
{
- template <typename NodeType>
+ template <typename MemorySpace>
class SparsityPattern;
- template <typename Number, typename NodeType>
+ template <typename Number, typename MemorySpace>
class SparseMatrix;
namespace SparsityPatternIterators
{
- template <typename NodeType>
+ template <typename MemorySpace>
class Iterator;
}
} // namespace TpetraWrappers
*
* @ingroup TrilinosWrappers
*/
- template <typename NodeType =
- Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
+ template <typename MemorySpace = dealii::MemorySpace::Host>
class Accessor
{
public:
*/
using size_type = dealii::types::signed_global_dof_index;
+ /**
+ * Typedef for the NodeType
+ */
+ using NodeType = Tpetra::KokkosCompat::KokkosDeviceWrapperNode<
+ typename MemorySpace::kokkos_space::execution_space,
+ typename MemorySpace::kokkos_space>;
+
/**
* Constructor.
*/
- Accessor(const SparsityPattern<NodeType> *sparsity_pattern,
- const size_type row,
- const size_type index);
+ Accessor(const SparsityPattern<MemorySpace> *sparsity_pattern,
+ const size_type row,
+ const size_type index);
/**
* Row number of the element represented by this object.
/**
* The matrix accessed.
*/
- SparsityPattern<NodeType> *sparsity_pattern;
+ SparsityPattern<MemorySpace> *sparsity_pattern;
/**
* Current row number.
visit_present_row();
// Make enclosing class a friend.
- friend class Iterator<NodeType>;
+ friend class Iterator<MemorySpace>;
};
/**
* TrilinosWrappers::SparsityPattern. Access to individual elements of the
* sparsity pattern is handled by the Accessor class in this namespace.
*/
- template <typename NodeType =
- Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
+ template <typename MemorySpace = dealii::MemorySpace::Host>
class Iterator
{
public:
*/
using size_type = size_t;
+ /**
+ * Typedef for the NodeType
+ */
+ using NodeType = Tpetra::KokkosCompat::KokkosDeviceWrapperNode<
+ typename MemorySpace::kokkos_space::execution_space,
+ typename MemorySpace::kokkos_space>;
+
/**
* Constructor. Create an iterator into the matrix @p matrix for the
* given row and the index within it.
*/
- Iterator(const SparsityPattern<NodeType> *sparsity_pattern,
- const size_type row,
- const size_type index);
+ Iterator(const SparsityPattern<MemorySpace> *sparsity_pattern,
+ const size_type row,
+ const size_type index);
/**
* Copy constructor.
*/
- Iterator(const Iterator<NodeType> &i);
+ Iterator(const Iterator<MemorySpace> &i);
/**
* Prefix increment.
*/
- Iterator<NodeType> &
+ Iterator<MemorySpace> &
operator++();
/**
/**
* Dereferencing operator.
*/
- const Accessor<NodeType> &
+ const Accessor<MemorySpace> &
operator*() const;
/**
* Dereferencing operator.
*/
- const Accessor<NodeType> *
+ const Accessor<MemorySpace> *
operator->() const;
/**
* position.
*/
bool
- operator==(const Iterator<NodeType> &) const;
+ operator==(const Iterator<MemorySpace> &) const;
/**
* Inverse of <tt>==</tt>.
*/
bool
- operator!=(const Iterator<NodeType> &) const;
+ operator!=(const Iterator<MemorySpace> &) const;
/**
* Comparison operator. Result is true if either the first row number is
* smaller.
*/
bool
- operator<(const Iterator<NodeType> &) const;
+ operator<(const Iterator<MemorySpace> &) const;
/**
* Exception
/**
* Store an object of the accessor class.
*/
- Accessor<NodeType> accessor;
+ Accessor<MemorySpace> accessor;
- friend class TpetraWrappers::SparsityPattern<NodeType>;
+ friend class TpetraWrappers::SparsityPattern<MemorySpace>;
};
} // namespace SparsityPatternIterators
* This class has many similarities to the DynamicSparsityPattern, since it
* can dynamically add elements to the pattern without any memory being
* previously reserved for it. However, it also has a method
- * SparsityPattern<NodeType>::compress(), that finalizes the pattern and
+ * SparsityPattern<MemorySpace>::compress(), that finalizes the pattern and
* enables its use with Trilinos sparse matrices.
*
* @ingroup TrilinosWrappers
* @ingroup Sparsity
*/
- template <typename NodeType =
- Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>
+ template <typename MemorySpace = dealii::MemorySpace::Host>
class SparsityPattern : public SparsityPatternBase
{
public:
*/
using size_type = dealii::types::signed_global_dof_index;
+ /**
+ * Typedef for the NodeType
+ */
+ using NodeType = Tpetra::KokkosCompat::KokkosDeviceWrapperNode<
+ typename MemorySpace::kokkos_space::execution_space,
+ typename MemorySpace::kokkos_space>;
+
/**
* Declare an alias for the iterator class.
*/
- using const_iterator = SparsityPatternIterators::Iterator<NodeType>;
+ using const_iterator = SparsityPatternIterators::Iterator<MemorySpace>;
/**
* Typedef for Tpetra::Map
using GraphType =
Tpetra::CrsGraph<int, dealii::types::signed_global_dof_index, NodeType>;
+
/**
* @name Basic constructors and initialization
*/
* Move constructor. Create a new sparse matrix by stealing the internal
* data.
*/
- SparsityPattern(SparsityPattern<NodeType> &&other) noexcept;
+ SparsityPattern(SparsityPattern<MemorySpace> &&other) noexcept;
/**
* Copy constructor. Sets the calling sparsity pattern to be the same as
* the input sparsity pattern.
*/
- SparsityPattern(const SparsityPattern<NodeType> &input_sparsity_pattern);
+ SparsityPattern(
+ const SparsityPattern<MemorySpace> &input_sparsity_pattern);
/**
* Destructor. Made virtual so that one can use pointers to this class.
* input sparsity pattern.
*/
void
- copy_from(const SparsityPattern<NodeType> &input_sparsity_pattern);
+ copy_from(const SparsityPattern<MemorySpace> &input_sparsity_pattern);
/**
* Copy function from one of the deal.II sparsity patterns. If used in
* the compiler. Use copy_from() instead if you know that you really want
* to copy a sparsity pattern with non-trivial content.
*/
- SparsityPattern<NodeType> &
- operator=(const SparsityPattern<NodeType> &input_sparsity_pattern);
+ SparsityPattern<MemorySpace> &
+ operator=(const SparsityPattern<MemorySpace> &input_sparsity_pattern);
/**
* Release all memory and return to a state just like after having called
* each m row. Since we know the number of elements in the sparsity
* pattern exactly in this case, we can already allocate the right amount
* of memory, which makes the creation process by the respective
- * SparsityPattern<NodeType>::reinit call considerably faster. However,
+ * SparsityPattern<MemorySpace>::reinit call considerably faster. However,
* this is a rather unusual situation, since knowing the number of entries
* in each row is usually connected to knowing the indices of nonzero
* entries, which the sparsity pattern is designed to describe.
Teuchos::RCP<GraphType> nonlocal_graph;
// TODO: currently only for double
- friend class SparseMatrix<double, NodeType>;
- friend class SparsityPatternIterators::Accessor<NodeType>;
- friend class SparsityPatternIterators::Iterator<NodeType>;
+ friend class SparseMatrix<double, MemorySpace>;
+ friend class SparsityPatternIterators::Accessor<MemorySpace>;
+ friend class SparsityPatternIterators::Iterator<MemorySpace>;
};
namespace SparsityPatternIterators
{
- template <typename NodeType>
- inline Accessor<NodeType>::Accessor(const SparsityPattern<NodeType> *sp,
- const size_type row,
- const size_type index)
- : sparsity_pattern(const_cast<SparsityPattern<NodeType> *>(sp))
+ template <typename MemorySpace>
+ inline Accessor<MemorySpace>::Accessor(
+ const SparsityPattern<MemorySpace> *sp,
+ const size_type row,
+ const size_type index)
+ : sparsity_pattern(const_cast<SparsityPattern<MemorySpace> *>(sp))
, a_row(row)
, a_index(index)
{
- template <typename NodeType>
- inline typename Accessor<NodeType>::size_type
- Accessor<NodeType>::row() const
+ template <typename MemorySpace>
+ inline typename Accessor<MemorySpace>::size_type
+ Accessor<MemorySpace>::row() const
{
Assert(a_row < sparsity_pattern->n_rows(),
ExcBeyondEndOfSparsityPattern());
- template <typename NodeType>
- inline typename Accessor<NodeType>::size_type
- Accessor<NodeType>::column() const
+ template <typename MemorySpace>
+ inline typename Accessor<MemorySpace>::size_type
+ Accessor<MemorySpace>::column() const
{
Assert(a_row < sparsity_pattern->n_rows(),
ExcBeyondEndOfSparsityPattern());
- template <typename NodeType>
- inline typename Accessor<NodeType>::size_type
- Accessor<NodeType>::index() const
+ template <typename MemorySpace>
+ inline typename Accessor<MemorySpace>::size_type
+ Accessor<MemorySpace>::index() const
{
Assert(a_row < sparsity_pattern->n_rows(),
ExcBeyondEndOfSparsityPattern());
- template <typename NodeType>
- inline Iterator<NodeType>::Iterator(const SparsityPattern<NodeType> *sp,
- const size_type row,
- const size_type index)
+ template <typename MemorySpace>
+ inline Iterator<MemorySpace>::Iterator(
+ const SparsityPattern<MemorySpace> *sp,
+ const size_type row,
+ const size_type index)
: accessor(sp, row, index)
{}
- template <typename NodeType>
- inline Iterator<NodeType>::Iterator(const Iterator<NodeType> &) = default;
+ template <typename MemorySpace>
+ inline Iterator<MemorySpace>::Iterator(const Iterator<MemorySpace> &) =
+ default;
- template <typename NodeType>
- inline Iterator<NodeType> &
- Iterator<NodeType>::operator++()
+ template <typename MemorySpace>
+ inline Iterator<MemorySpace> &
+ Iterator<MemorySpace>::operator++()
{
Assert(accessor.a_row < accessor.sparsity_pattern->n_rows(),
ExcIteratorPastEnd());
- template <typename NodeType>
- inline Iterator<NodeType>
- Iterator<NodeType>::operator++(int)
+ template <typename MemorySpace>
+ inline Iterator<MemorySpace>
+ Iterator<MemorySpace>::operator++(int)
{
- const Iterator<NodeType> old_state = *this;
+ const Iterator<MemorySpace> old_state = *this;
++(*this);
return old_state;
}
- template <typename NodeType>
- inline const Accessor<NodeType> &
- Iterator<NodeType>::operator*() const
+ template <typename MemorySpace>
+ inline const Accessor<MemorySpace> &
+ Iterator<MemorySpace>::operator*() const
{
return accessor;
}
- template <typename NodeType>
- inline const Accessor<NodeType> *
- Iterator<NodeType>::operator->() const
+ template <typename MemorySpace>
+ inline const Accessor<MemorySpace> *
+ Iterator<MemorySpace>::operator->() const
{
return &accessor;
}
- template <typename NodeType>
+ template <typename MemorySpace>
inline bool
- Iterator<NodeType>::operator==(const Iterator<NodeType> &other) const
+ Iterator<MemorySpace>::operator==(
+ const Iterator<MemorySpace> &other) const
{
return (accessor.a_row == other.accessor.a_row &&
accessor.a_index == other.accessor.a_index);
- template <typename NodeType>
+ template <typename MemorySpace>
inline bool
- Iterator<NodeType>::operator!=(const Iterator<NodeType> &other) const
+ Iterator<MemorySpace>::operator!=(
+ const Iterator<MemorySpace> &other) const
{
return !(*this == other);
}
- template <typename NodeType>
+ template <typename MemorySpace>
inline bool
- Iterator<NodeType>::operator<(const Iterator<NodeType> &other) const
+ Iterator<MemorySpace>::operator<(const Iterator<MemorySpace> &other) const
{
return (accessor.row() < other.accessor.row() ||
(accessor.row() == other.accessor.row() &&
- template <typename NodeType>
- inline typename SparsityPattern<NodeType>::const_iterator
- SparsityPattern<NodeType>::begin() const
+ template <typename MemorySpace>
+ inline typename SparsityPattern<MemorySpace>::const_iterator
+ SparsityPattern<MemorySpace>::begin() const
{
const size_type first_valid_row = this->local_range().first;
return const_iterator(this, first_valid_row, 0);
- template <typename NodeType>
- inline typename SparsityPattern<NodeType>::const_iterator
- SparsityPattern<NodeType>::end() const
+ template <typename MemorySpace>
+ inline typename SparsityPattern<MemorySpace>::const_iterator
+ SparsityPattern<MemorySpace>::end() const
{
return const_iterator(this, n_rows(), 0);
}
- template <typename NodeType>
- inline typename SparsityPattern<NodeType>::const_iterator
- SparsityPattern<NodeType>::begin(const size_type r) const
+ template <typename MemorySpace>
+ inline typename SparsityPattern<MemorySpace>::const_iterator
+ SparsityPattern<MemorySpace>::begin(const size_type r) const
{
AssertIndexRange(r, n_rows());
if (row_length(r) > 0)
- template <typename NodeType>
- inline typename SparsityPattern<NodeType>::const_iterator
- SparsityPattern<NodeType>::end(const size_type r) const
+ template <typename MemorySpace>
+ inline typename SparsityPattern<MemorySpace>::const_iterator
+ SparsityPattern<MemorySpace>::end(const size_type r) const
{
AssertIndexRange(r, n_rows());
- template <typename NodeType>
+ template <typename MemorySpace>
inline bool
- SparsityPattern<NodeType>::in_local_range(const size_type index) const
+ SparsityPattern<MemorySpace>::in_local_range(const size_type index) const
{
const TrilinosWrappers::types::int_type begin =
graph->getRowMap()->getMinGlobalIndex();
- template <typename NodeType>
+ template <typename MemorySpace>
inline bool
- SparsityPattern<NodeType>::is_compressed() const
+ SparsityPattern<MemorySpace>::is_compressed() const
{
return graph->isFillComplete();
}
- template <typename NodeType>
+ template <typename MemorySpace>
inline bool
- SparsityPattern<NodeType>::empty() const
+ SparsityPattern<MemorySpace>::empty() const
{
return ((n_rows() == 0) && (n_cols() == 0));
}
- template <typename NodeType>
+ template <typename MemorySpace>
inline void
- SparsityPattern<NodeType>::add(const size_type i, const size_type j)
+ SparsityPattern<MemorySpace>::add(const size_type i, const size_type j)
{
add_entries(i, &j, &j + 1);
}
- template <typename NodeType>
+ template <typename MemorySpace>
template <typename ForwardIterator>
inline void
- SparsityPattern<NodeType>::add_entries(const size_type row,
- ForwardIterator begin,
- ForwardIterator end,
- const bool /*indices_are_sorted*/)
+ SparsityPattern<MemorySpace>::add_entries(const size_type row,
+ ForwardIterator begin,
+ ForwardIterator end,
+ const bool /*indices_are_sorted*/)
{
if (begin == end)
return;
AssertDimension(*col_index_ptr_end, *end);
TrilinosWrappers::types::int_type trilinos_row_index = row;
+ // TODO: The following line creates an array by copying the entries.
+ // Perhaps there is a way to only create a 'view' of these arrays
+ // and pass that to Tpetra?
Teuchos::Array<long long> array(col_index_ptr_begin, col_index_ptr_end);
if (row_is_stored_locally(row))
- template <typename NodeType>
+ template <typename MemorySpace>
inline Teuchos::RCP<
- Tpetra::CrsGraph<int, dealii::types::signed_global_dof_index, NodeType>>
- SparsityPattern<NodeType>::trilinos_sparsity_pattern() const
+ Tpetra::CrsGraph<int,
+ dealii::types::signed_global_dof_index,
+ typename SparsityPattern<MemorySpace>::NodeType>>
+ SparsityPattern<MemorySpace>::trilinos_sparsity_pattern() const
{
return graph;
}
- template <typename NodeType>
+ template <typename MemorySpace>
inline IndexSet
- SparsityPattern<NodeType>::locally_owned_domain_indices() const
+ SparsityPattern<MemorySpace>::locally_owned_domain_indices() const
{
return IndexSet(graph->getDomainMap().getConst());
}
- template <typename NodeType>
+ template <typename MemorySpace>
inline IndexSet
- SparsityPattern<NodeType>::locally_owned_range_indices() const
+ SparsityPattern<MemorySpace>::locally_owned_range_indices() const
{
return IndexSet(graph->getRangeMap().getConst());
}
{
namespace SparsityPatternIterators
{
- template <typename NodeType>
+ template <typename MemorySpace>
void
- Accessor<NodeType>::visit_present_row()
+ Accessor<MemorySpace>::visit_present_row()
{
// if we are asked to visit the past-the-end line, then simply
// release all our caches and go on with life
// even matter how many threads there are, but only if we use an MPI
// compiler or a standard compiler. So, even one thread on a configuration
// with MPI will still get a parallel interface.
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern()
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern()
{
column_space_map = Utilities::Trilinos::internal::make_rcp<MapType>(
TrilinosWrappers::types::int_type(0),
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const size_type m,
const size_type n,
const size_type n_entries_per_row)
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const size_type m,
const size_type n,
const std::vector<size_type> &n_entries_per_row)
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
- SparsityPattern<NodeType> &&other) noexcept
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
+ SparsityPattern<MemorySpace> &&other) noexcept
: SparsityPatternBase(std::move(other))
, column_space_map(std::move(other.column_space_map))
, graph(std::move(other.graph))
// Copy function only works if the sparsity pattern is empty.
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
- const SparsityPattern<NodeType> &input_sparsity)
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
+ const SparsityPattern<MemorySpace> &input_sparsity)
: SparsityPatternBase(input_sparsity)
, column_space_map(Utilities::Trilinos::internal::make_rcp<MapType>(
0,
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const IndexSet ¶llel_partitioning,
const MPI_Comm communicator,
const size_type n_entries_per_row)
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const IndexSet ¶llel_partitioning,
const MPI_Comm communicator,
const std::vector<size_type> &n_entries_per_row)
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const MPI_Comm communicator,
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const MPI_Comm communicator,
- template <typename NodeType>
- SparsityPattern<NodeType>::SparsityPattern(
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace>::SparsityPattern(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const IndexSet &writable_rows,
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(const size_type m,
- const size_type n,
- const size_type n_entries_per_row)
+ SparsityPattern<MemorySpace>::reinit(const size_type m,
+ const size_type n,
+ const size_type n_entries_per_row)
{
reinit(complete_index_set(m),
complete_index_set(n),
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(
+ SparsityPattern<MemorySpace>::reinit(
const size_type m,
const size_type n,
const std::vector<size_type> &n_entries_per_row)
namespace
{
- template <typename NodeType>
- using size_type = typename SparsityPattern<NodeType>::size_type;
+ template <typename MemorySpace>
+ using size_type = typename SparsityPattern<MemorySpace>::size_type;
- template <typename NodeType>
+ template <typename MemorySpace>
using MapType =
- Tpetra::Map<int, dealii::types::signed_global_dof_index, NodeType>;
+ Tpetra::Map<int,
+ dealii::types::signed_global_dof_index,
+ typename SparsityPattern<MemorySpace>::NodeType>;
- template <typename NodeType>
+ template <typename MemorySpace>
using GraphType =
- Tpetra::CrsGraph<int, dealii::types::signed_global_dof_index, NodeType>;
+ Tpetra::CrsGraph<int,
+ dealii::types::signed_global_dof_index,
+ typename SparsityPattern<MemorySpace>::NodeType>;
- template <typename NodeType>
+ template <typename MemorySpace>
void
- reinit_sp(const Teuchos::RCP<MapType<NodeType>> &row_map,
- const Teuchos::RCP<MapType<NodeType>> &col_map,
- const size_type<NodeType> n_entries_per_row,
- Teuchos::RCP<MapType<NodeType>> &column_space_map,
- Teuchos::RCP<GraphType<NodeType>> &graph,
- Teuchos::RCP<GraphType<NodeType>> &nonlocal_graph)
+ reinit_sp(const Teuchos::RCP<MapType<MemorySpace>> &row_map,
+ const Teuchos::RCP<MapType<MemorySpace>> &col_map,
+ const size_type<MemorySpace> n_entries_per_row,
+ Teuchos::RCP<MapType<MemorySpace>> &column_space_map,
+ Teuchos::RCP<GraphType<MemorySpace>> &graph,
+ Teuchos::RCP<GraphType<MemorySpace>> &nonlocal_graph)
{
Assert(row_map->isOneToOne(),
ExcMessage("Row map must be 1-to-1, i.e., no overlap between "
// columns as well. If we use a recent Trilinos version, we can also
// require building a non-local graph which gives us thread-safe
// initialization.
- graph = Utilities::Trilinos::internal::make_rcp<GraphType<NodeType>>(
+ graph = Utilities::Trilinos::internal::make_rcp<GraphType<MemorySpace>>(
row_map, row_map, n_entries_per_row);
}
- template <typename NodeType>
+ template <typename MemorySpace>
void
- reinit_sp(const Teuchos::RCP<MapType<NodeType>> &row_map,
- const Teuchos::RCP<MapType<NodeType>> &col_map,
- const std::vector<size_type<NodeType>> &n_entries_per_row,
- Teuchos::RCP<MapType<NodeType>> &column_space_map,
- Teuchos::RCP<GraphType<NodeType>> &graph,
- Teuchos::RCP<GraphType<NodeType>> &nonlocal_graph)
+ reinit_sp(const Teuchos::RCP<MapType<MemorySpace>> &row_map,
+ const Teuchos::RCP<MapType<MemorySpace>> &col_map,
+ const std::vector<size_type<MemorySpace>> &n_entries_per_row,
+ Teuchos::RCP<MapType<MemorySpace>> &column_space_map,
+ Teuchos::RCP<GraphType<MemorySpace>> &graph,
+ Teuchos::RCP<GraphType<MemorySpace>> &nonlocal_graph)
{
Assert(row_map->isOneToOne(),
ExcMessage("Row map must be 1-to-1, i.e., no overlap between "
ExcMessage(
"You are requesting to store more elements than global ordinal type allows."));
- graph = Utilities::Trilinos::internal::make_rcp<GraphType<NodeType>>(
+ graph = Utilities::Trilinos::internal::make_rcp<GraphType<MemorySpace>>(
row_map, col_map, local_entries_per_row);
}
- template <typename SparsityPatternType, typename NodeType>
+ template <typename SparsityPatternType, typename MemorySpace>
void
- reinit_sp(const Teuchos::RCP<MapType<NodeType>> &row_map,
- const Teuchos::RCP<MapType<NodeType>> &col_map,
- const SparsityPatternType &sp,
- [[maybe_unused]] const bool exchange_data,
- Teuchos::RCP<MapType<NodeType>> &column_space_map,
- Teuchos::RCP<GraphType<NodeType>> &graph,
- Teuchos::RCP<GraphType<NodeType>> &nonlocal_graph)
+ reinit_sp(const Teuchos::RCP<MapType<MemorySpace>> &row_map,
+ const Teuchos::RCP<MapType<MemorySpace>> &col_map,
+ const SparsityPatternType &sp,
+ [[maybe_unused]] const bool exchange_data,
+ Teuchos::RCP<MapType<MemorySpace>> &column_space_map,
+ Teuchos::RCP<GraphType<MemorySpace>> &graph,
+ Teuchos::RCP<GraphType<MemorySpace>> &nonlocal_graph)
{
nonlocal_graph.reset();
graph.reset();
AssertDimension(sp.n_cols(), col_map->getGlobalNumElements());
column_space_map =
- Utilities::Trilinos::internal::make_rcp<MapType<NodeType>>(*col_map);
+ Utilities::Trilinos::internal::make_rcp<MapType<MemorySpace>>(
+ *col_map);
Assert(row_map->isContiguous() == true,
ExcMessage(
"This function only works if the row map is contiguous."));
- const size_type<NodeType> first_row = row_map->getMinGlobalIndex(),
- last_row = row_map->getMaxGlobalIndex() + 1;
+ const size_type<MemorySpace> first_row = row_map->getMinGlobalIndex(),
+ last_row =
+ row_map->getMaxGlobalIndex() + 1;
Teuchos::Array<size_t> n_entries_per_row(last_row - first_row);
- for (size_type<NodeType> row = first_row; row < last_row; ++row)
+ for (size_type<MemorySpace> row = first_row; row < last_row; ++row)
n_entries_per_row[row - first_row] = sp.row_length(row);
AssertThrow(
"with 'local ordinate = long long' "));
if (row_map->getComm()->getSize() > 1)
- graph = Utilities::Trilinos::internal::make_rcp<GraphType<NodeType>>(
- row_map, n_entries_per_row());
+ graph =
+ Utilities::Trilinos::internal::make_rcp<GraphType<MemorySpace>>(
+ row_map, n_entries_per_row());
else
- graph = Utilities::Trilinos::internal::make_rcp<GraphType<NodeType>>(
- row_map, col_map, n_entries_per_row());
+ graph =
+ Utilities::Trilinos::internal::make_rcp<GraphType<MemorySpace>>(
+ row_map, col_map, n_entries_per_row());
AssertDimension(sp.n_rows(), graph->getGlobalNumRows());
AssertDimension(sp.n_cols(), graph->getGlobalNumEntries());
std::vector<TrilinosWrappers::types::int_type> row_indices;
- for (size_type<NodeType> row = first_row; row < last_row; ++row)
+ for (size_type<MemorySpace> row = first_row; row < last_row; ++row)
{
const TrilinosWrappers::types::int_type row_length =
sp.row_length(row);
} // namespace
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(const IndexSet ¶llel_partitioning,
- const MPI_Comm communicator,
- const size_type n_entries_per_row)
+ SparsityPattern<MemorySpace>::reinit(const IndexSet ¶llel_partitioning,
+ const MPI_Comm communicator,
+ const size_type n_entries_per_row)
{
SparsityPatternBase::resize(parallel_partitioning.size(),
parallel_partitioning.size());
Teuchos::RCP<MapType> map =
parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(
+ reinit_sp<MemorySpace>(
map, map, n_entries_per_row, column_space_map, graph, nonlocal_graph);
}
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(
+ SparsityPattern<MemorySpace>::reinit(
const IndexSet ¶llel_partitioning,
const MPI_Comm communicator,
const std::vector<size_type> &n_entries_per_row)
parallel_partitioning.size());
Teuchos::RCP<MapType> map =
parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(
+ reinit_sp<MemorySpace>(
map, map, n_entries_per_row, column_space_map, graph, nonlocal_graph);
}
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(const IndexSet &row_parallel_partitioning,
- const IndexSet &col_parallel_partitioning,
- const MPI_Comm communicator,
- const size_type n_entries_per_row)
+ SparsityPattern<MemorySpace>::reinit(
+ const IndexSet &row_parallel_partitioning,
+ const IndexSet &col_parallel_partitioning,
+ const MPI_Comm communicator,
+ const size_type n_entries_per_row)
{
SparsityPatternBase::resize(row_parallel_partitioning.size(),
col_parallel_partitioning.size());
row_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
Teuchos::RCP<MapType> col_map =
col_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(row_map,
- col_map,
- n_entries_per_row,
- column_space_map,
- graph,
- nonlocal_graph);
+ reinit_sp<MemorySpace>(row_map,
+ col_map,
+ n_entries_per_row,
+ column_space_map,
+ graph,
+ nonlocal_graph);
}
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(
+ SparsityPattern<MemorySpace>::reinit(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const MPI_Comm communicator,
row_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
Teuchos::RCP<MapType> col_map =
col_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(row_map,
- col_map,
- n_entries_per_row,
- column_space_map,
- graph,
- nonlocal_graph);
+ reinit_sp<MemorySpace>(row_map,
+ col_map,
+ n_entries_per_row,
+ column_space_map,
+ graph,
+ nonlocal_graph);
}
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::reinit(const IndexSet &row_parallel_partitioning,
- const IndexSet &col_parallel_partitioning,
- const IndexSet &writable_rows,
- const MPI_Comm communicator,
- const size_type n_entries_per_row)
+ SparsityPattern<MemorySpace>::reinit(
+ const IndexSet &row_parallel_partitioning,
+ const IndexSet &col_parallel_partitioning,
+ const IndexSet &writable_rows,
+ const MPI_Comm communicator,
+ const size_type n_entries_per_row)
{
SparsityPatternBase::resize(row_parallel_partitioning.size(),
col_parallel_partitioning.size());
row_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
Teuchos::RCP<MapType> col_map =
col_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(row_map,
- col_map,
- n_entries_per_row,
- column_space_map,
- graph,
- nonlocal_graph);
+ reinit_sp<MemorySpace>(row_map,
+ col_map,
+ n_entries_per_row,
+ column_space_map,
+ graph,
+ nonlocal_graph);
IndexSet nonlocal_partitioner = writable_rows;
AssertDimension(nonlocal_partitioner.size(),
- template <typename NodeType>
+ template <typename MemorySpace>
template <typename SparsityPatternType>
void
- SparsityPattern<NodeType>::reinit(
+ SparsityPattern<MemorySpace>::reinit(
const IndexSet &row_parallel_partitioning,
const IndexSet &col_parallel_partitioning,
const SparsityPatternType &nontrilinos_sparsity_pattern,
row_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
Teuchos::RCP<MapType> col_map =
col_parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(row_map,
- col_map,
- nontrilinos_sparsity_pattern,
- exchange_data,
- column_space_map,
- graph,
- nonlocal_graph);
+ reinit_sp<SparsityPatternType, MemorySpace>(row_map,
+ col_map,
+ nontrilinos_sparsity_pattern,
+ exchange_data,
+ column_space_map,
+ graph,
+ nonlocal_graph);
}
- template <typename NodeType>
+ template <typename MemorySpace>
template <typename SparsityPatternType>
void
- SparsityPattern<NodeType>::reinit(
+ SparsityPattern<MemorySpace>::reinit(
const IndexSet ¶llel_partitioning,
const SparsityPatternType &nontrilinos_sparsity_pattern,
const MPI_Comm communicator,
parallel_partitioning.size());
Teuchos::RCP<MapType> map =
parallel_partitioning.make_tpetra_map_rcp(communicator, false);
- reinit_sp(map,
- map,
- nontrilinos_sparsity_pattern,
- exchange_data,
- column_space_map,
- graph,
- nonlocal_graph);
+ reinit_sp<SparsityPatternType, MemorySpace>(map,
+ map,
+ nontrilinos_sparsity_pattern,
+ exchange_data,
+ column_space_map,
+ graph,
+ nonlocal_graph);
}
- template <typename NodeType>
- SparsityPattern<NodeType> &
- SparsityPattern<NodeType>::operator=(const SparsityPattern<NodeType> &)
+ template <typename MemorySpace>
+ SparsityPattern<MemorySpace> &
+ SparsityPattern<MemorySpace>::operator=(
+ const SparsityPattern<MemorySpace> &)
{
Assert(false, ExcNotImplemented());
return *this;
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::copy_from(const SparsityPattern<NodeType> &sp)
+ SparsityPattern<MemorySpace>::copy_from(
+ const SparsityPattern<MemorySpace> &sp)
{
SparsityPatternBase::resize(sp.n_rows(), sp.n_cols());
column_space_map =
- template <typename NodeType>
+ template <typename MemorySpace>
template <typename SparsityPatternType>
void
- SparsityPattern<NodeType>::copy_from(const SparsityPatternType &sp)
+ SparsityPattern<MemorySpace>::copy_from(const SparsityPatternType &sp)
{
SparsityPatternBase::resize(sp.n_rows(), sp.n_cols());
Teuchos::RCP<MapType> rows =
0,
Utilities::Trilinos::tpetra_comm_self());
- reinit_sp(
+ reinit_sp<SparsityPatternType, MemorySpace>(
rows, columns, sp, false, column_space_map, graph, nonlocal_graph);
}
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::clear()
+ SparsityPattern<MemorySpace>::clear()
{
SparsityPatternBase::resize(0, 0);
// When we clear the matrix, reset
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::compress()
+ SparsityPattern<MemorySpace>::compress()
{
Assert(column_space_map.get(), ExcInternalError());
if (nonlocal_graph.get() != nullptr)
- template <typename NodeType>
+ template <typename MemorySpace>
bool
- SparsityPattern<NodeType>::row_is_stored_locally(const size_type i) const
+ SparsityPattern<MemorySpace>::row_is_stored_locally(const size_type i) const
{
return graph->getRowMap()->getLocalElement(i) !=
Teuchos::OrdinalTraits<int>::invalid();
- template <typename NodeType>
+ template <typename MemorySpace>
bool
- SparsityPattern<NodeType>::exists(const size_type i,
- const size_type j) const
+ SparsityPattern<MemorySpace>::exists(const size_type i,
+ const size_type j) const
{
if (!row_is_stored_locally(i))
return false;
- template <typename NodeType>
- typename SparsityPattern<NodeType>::size_type
- SparsityPattern<NodeType>::bandwidth() const
+ template <typename MemorySpace>
+ typename SparsityPattern<MemorySpace>::size_type
+ SparsityPattern<MemorySpace>::bandwidth() const
{
size_type local_b = 0;
for (int i = 0; i < static_cast<int>(local_size()); ++i)
- template <typename NodeType>
+ template <typename MemorySpace>
unsigned int
- SparsityPattern<NodeType>::local_size() const
+ SparsityPattern<MemorySpace>::local_size() const
{
return graph->getLocalNumRows();
}
- template <typename NodeType>
- std::pair<typename SparsityPattern<NodeType>::size_type,
- typename SparsityPattern<NodeType>::size_type>
- SparsityPattern<NodeType>::local_range() const
+ template <typename MemorySpace>
+ std::pair<typename SparsityPattern<MemorySpace>::size_type,
+ typename SparsityPattern<MemorySpace>::size_type>
+ SparsityPattern<MemorySpace>::local_range() const
{
const size_type begin = graph->getRowMap()->getMinGlobalIndex();
const size_type end = graph->getRowMap()->getMaxGlobalIndex() + 1;
- template <typename NodeType>
+ template <typename MemorySpace>
std::uint64_t
- SparsityPattern<NodeType>::n_nonzero_elements() const
+ SparsityPattern<MemorySpace>::n_nonzero_elements() const
{
return graph->getGlobalNumEntries();
}
- template <typename NodeType>
+ template <typename MemorySpace>
unsigned int
- SparsityPattern<NodeType>::max_entries_per_row() const
+ SparsityPattern<MemorySpace>::max_entries_per_row() const
{
return graph->getLocalMaxNumRowEntries();
}
- template <typename NodeType>
- typename SparsityPattern<NodeType>::size_type
- SparsityPattern<NodeType>::row_length(const size_type row) const
+ template <typename MemorySpace>
+ typename SparsityPattern<MemorySpace>::size_type
+ SparsityPattern<MemorySpace>::row_length(const size_type row) const
{
Assert(row < (size_type)n_rows(), ExcInternalError());
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::add_row_entries(
+ SparsityPattern<MemorySpace>::add_row_entries(
const dealii::types::global_dof_index &row,
const ArrayView<const dealii::types::global_dof_index> &columns,
const bool indices_are_sorted)
- template <typename NodeType>
- Teuchos::RCP<const MapType<NodeType>>
- SparsityPattern<NodeType>::domain_partitioner() const
+ template <typename MemorySpace>
+ Teuchos::RCP<const MapType<MemorySpace>>
+ SparsityPattern<MemorySpace>::domain_partitioner() const
{
return graph->getDomainMap();
}
- template <typename NodeType>
- Teuchos::RCP<const MapType<NodeType>>
- SparsityPattern<NodeType>::range_partitioner() const
+ template <typename MemorySpace>
+ Teuchos::RCP<const MapType<MemorySpace>>
+ SparsityPattern<MemorySpace>::range_partitioner() const
{
return graph->getRangeMap();
}
- template <typename NodeType>
+ template <typename MemorySpace>
MPI_Comm
- SparsityPattern<NodeType>::get_mpi_communicator() const
+ SparsityPattern<MemorySpace>::get_mpi_communicator() const
{
return Utilities::Trilinos::teuchos_comm_to_mpi_comm(
graph->getRangeMap()->getComm());
- template <typename NodeType>
+ template <typename MemorySpace>
Teuchos::RCP<const Teuchos::Comm<int>>
- SparsityPattern<NodeType>::get_teuchos_mpi_communicator() const
+ SparsityPattern<MemorySpace>::get_teuchos_mpi_communicator() const
{
return graph->getRangeMap()->getComm();
}
// As of now, no particularly neat
// output is generated in case of
// multiple processors.
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::print(
+ SparsityPattern<MemorySpace>::print(
std::ostream &out,
const bool write_extended_trilinos_info) const
{
- template <typename NodeType>
+ template <typename MemorySpace>
void
- SparsityPattern<NodeType>::print_gnuplot(std::ostream &out) const
+ SparsityPattern<MemorySpace>::print_gnuplot(std::ostream &out) const
{
Assert(graph->isFillComplete() == true, ExcInternalError());
for (dealii::types::signed_global_dof_index row = 0; row < local_size();
}
// TODO: Implement!
- template <typename NodeType>
+ template <typename MemorySpace>
std::size_t
- SparsityPattern<NodeType>::memory_consumption() const
+ SparsityPattern<MemorySpace>::memory_consumption() const
{
Assert(false, ExcNotImplemented());
return 0;
# ifndef DOXYGEN
// explicit instantiations
- template class SparsityPattern<
- Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>;
+ template class SparsityPattern<dealii::MemorySpace::Host>;
template void
- SparsityPattern<Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>::
- copy_from(const dealii::SparsityPattern &);
+ SparsityPattern<dealii::MemorySpace::Host>::copy_from(
+ const dealii::SparsityPattern &);
template void
- SparsityPattern<Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>::
- copy_from(const dealii::DynamicSparsityPattern &);
+ SparsityPattern<dealii::MemorySpace::Host>::copy_from(
+ const dealii::DynamicSparsityPattern &);
template void
- SparsityPattern<Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>::
- reinit(const IndexSet &,
- const dealii::SparsityPattern &,
- const MPI_Comm,
- bool);
+ SparsityPattern<dealii::MemorySpace::Host>::reinit(
+ const IndexSet &,
+ const dealii::SparsityPattern &,
+ const MPI_Comm,
+ bool);
template void
- SparsityPattern<Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>::
- reinit(const IndexSet &,
- const dealii::DynamicSparsityPattern &,
- const MPI_Comm,
- bool);
+ SparsityPattern<dealii::MemorySpace::Host>::reinit(
+ const IndexSet &,
+ const dealii::DynamicSparsityPattern &,
+ const MPI_Comm,
+ bool);
template void
- SparsityPattern<Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>::
- reinit(const IndexSet &,
- const IndexSet &,
- const dealii::SparsityPattern &,
- const MPI_Comm,
- bool);
+ SparsityPattern<dealii::MemorySpace::Host>::reinit(
+ const IndexSet &,
+ const IndexSet &,
+ const dealii::SparsityPattern &,
+ const MPI_Comm,
+ bool);
template void
- SparsityPattern<Tpetra::KokkosClassic::DefaultNode::DefaultNodeType>::
- reinit(const IndexSet &,
- const IndexSet &,
- const dealii::DynamicSparsityPattern &,
- const MPI_Comm,
- bool);
+ SparsityPattern<dealii::MemorySpace::Host>::reinit(
+ const IndexSet &,
+ const IndexSet &,
+ const dealii::DynamicSparsityPattern &,
+ const MPI_Comm,
+ bool);
# endif
} // namespace TpetraWrappers