Template Numerical Library: TNL::Matrices::HypreParCSRMatrix Class Reference

Template Numerical Library version\ main:0b2c40fb1

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
TNL::Matrices::HypreParCSRMatrix Class Reference
Wrappers for the Hypre library

Wrapper for Hypre's sequential CSR matrix. More...

`#include <TNL/Matrices/HypreParCSRMatrix.h>`

## Public Types
using | ColumnIndexesVectorType = Containers::Vector< IndexType, DeviceType, IndexType >
using | ColumnIndexesViewType = ColumnIndexesVectorType::ViewType
using | ConstColumnIndexesViewType = ColumnIndexesVectorType::ConstViewType
using | ConstSegmentsViewType = Algorithms::Segments::CSRView< DeviceType, std::add_const_t< IndexType > >
using | ConstValuesViewType = ValuesViewType::ConstViewType
using | DeviceType = HYPRE_Device
using | IndexType = HYPRE_Int
using | LocalRangeType = Containers::Subrange< IndexType >
using | MatrixType = HypreCSRMatrix
using | RealType = HYPRE_Real
using | SegmentsViewType = Algorithms::Segments::CSRView< DeviceType, IndexType >
using | ValuesViewType = Containers::VectorView< RealType, DeviceType, IndexType >
using | ValueType = RealType

## Public Member Functions
| HypreParCSRMatrix (const HypreParCSRMatrix &other)=delete
| HypreParCSRMatrix (hypre_ParCSRMatrix *handle, bool take_ownership=true)
| Convert Hypre's format to HypreParCSRMatrix.
| HypreParCSRMatrix (HypreParCSRMatrix &&other) noexcept
void | bind (hypre_ParCSRMatrix *handle, bool take_ownership=true)
| Convert Hypre's format to HypreParCSRMatrix.
void | bind (MPI_Comm communicator, IndexType global_num_rows, IndexType global_num_cols, LocalRangeType local_row_range, LocalRangeType local_col_range, hypre_CSRMatrix *diag, hypre_CSRMatrix *offd, IndexType *col_map_offd)
| Binds ParCSRMatrix to local diag and offd blocks.
IndexType | getColumns () const
MPI_Comm | getCommunicator () const
MatrixType | getDiagonalBlock ()
LocalRangeType | getLocalColumnRange () const
LocalRangeType | getLocalRowRange () const
HypreCSRMatrix | getMergedLocalMatrix () const
| Constructs a local matrix by merging the diagonal and off-diagonal blocks.
IndexType | getNonzeroElementsCount () const
MatrixType | getOffdiagonalBlock ()
Containers::VectorView< HYPRE_Int, HYPRE_Device, HYPRE_Int > | getOffdiagonalColumnsMapping ()
IndexType | getRows () const
| operator const hypre_ParCSRMatrix * () const noexcept
| operator HYPRE_ParCSRMatrix () const noexcept
| operator hypre_ParCSRMatrix * () noexcept
HypreParCSRMatrix & | operator= (const HypreParCSRMatrix &other)=delete
HypreParCSRMatrix & | operator= (HypreParCSRMatrix &&other) noexcept
void | reset ()
| Reset the matrix to empty state.

## Static Public Member Functions
static HypreParCSRMatrix | fromLocalBlocks (MPI_Comm communicator, IndexType global_num_rows, IndexType global_num_cols, LocalRangeType local_row_range, LocalRangeType local_col_range, hypre_CSRMatrix *local_A)
| Constructs a ParCSRMatrix from local blocks distributed across the processors in communicator.
static HypreParCSRMatrix | fromMasterRank (hypre_CSRMatrix *matrix, hypre_ParVector *x, hypre_ParVector *b)
| Constructs a ParCSRMatrix distributed across the processors in communicator from a CSRMatrix on rank 0.
static HypreParCSRMatrix | fromMasterRank (MPI_Comm communicator, IndexType *global_row_starts, IndexType *global_col_starts, hypre_CSRMatrix *matrix)
| Constructs a ParCSRMatrix distributed across the processors in communicator from a CSRMatrix on rank 0.
static HypreParCSRMatrix | wrapCSRMatrix (hypre_CSRMatrix *matrix)
| Wrap a global hypre_CSRMatrix into HypreParCSRMatrix.

## Protected Attributes
hypre_ParCSRMatrix * | m = nullptr
bool | owns_col_map_offd = true
bool | owns_diag = true
bool | owns_handle = true
bool | owns_offd = true

## Detailed Description

Wrapper for Hypre's sequential CSR matrix.

Links to upstream sources:

- https://github.com/hypre-space/hypre/blob/master/src/seq_mv/csr_matrix.h
- https://github.com/hypre-space/hypre/blob/master/src/seq_mv/csr_matrix.c
- https://github.com/hypre-space/hypre/blob/master/src/seq_mv/seq_mv.h (catch-all interface)

## Constructor & Destructor Documentation

## ◆ HypreParCSRMatrix()

TNL::Matrices::HypreParCSRMatrix::HypreParCSRMatrix | ( | hypre_ParCSRMatrix * | handle,
|  | bool | take_ownership = true )
| inlineexplicit

Convert Hypre's format to HypreParCSRMatrix.

Parameters

  handle | is the Hypre vector handle.
  take_ownership | indicates if the matrix should take ownership of the handle, i.e. whether to call hypre_CSRMatrixDestroy when it does not need it anymore.

## Member Function Documentation

## ◆ bind() [1/2]

void TNL::Matrices::HypreParCSRMatrix::bind | ( | hypre_ParCSRMatrix * | handle,
|  | bool | take_ownership = true )
| inline

Convert Hypre's format to HypreParCSRMatrix.

Parameters

  handle | is the Hypre vector handle.
  take_ownership | indicates if the matrix should take ownership of the handle, i.e. whether to call hypre_CSRMatrixDestroy when it does not need it anymore.

## ◆ bind() [2/2]

void TNL::Matrices::HypreParCSRMatrix::bind | ( | MPI_Comm | communicator,
|  | IndexType | global_num_rows,
|  | IndexType | global_num_cols,
|  | LocalRangeType | local_row_range,
|  | LocalRangeType | local_col_range,
|  | hypre_CSRMatrix * | diag,
|  | hypre_CSRMatrix * | offd,
|  | IndexType * | col_map_offd )
| inline

Binds ParCSRMatrix to local diag and offd blocks.

Parameters

  communicator | MPI communicator to associate with the matrix.
  global_num_rows | Global number of rows of the distributed matrix.
  global_num_cols | Global number of columns of the distributed matrix.
  local_row_range | The range [begin, end) of rows owned by the calling rank.
  local_col_range | The range [begin, end) of columns owned by the calling rank. For square matrices it should be equal to local_row_range.
  diag | The local diagonal matrix block owned by the calling rank.
  offd | The local off-diagonal matrix block owned by the calling rank.
  col_map_offd | Mapping of local-to-global indices for the columns in the off-diagonal block. It must be always a host pointer.

## ◆ fromLocalBlocks()

HypreParCSRMatrix TNL::Matrices::HypreParCSRMatrix::fromLocalBlocks | ( | MPI_Comm | communicator,
|  | IndexType | global_num_rows,
|  | IndexType | global_num_cols,
|  | LocalRangeType | local_row_range,
|  | LocalRangeType | local_col_range,
|  | hypre_CSRMatrix * | local_A )
| inlinestaticnodiscard

Constructs a ParCSRMatrix from local blocks distributed across the processors in communicator.

Parameters

  communicator | MPI communicator to associate with the matrix.
  global_num_rows | Global number of rows of the distributed matrix.
  global_num_cols | Global number of columns of the distributed matrix.
  local_row_range | The range [begin, end) of rows owned by the calling rank.
  local_col_range | The range [begin, end) of columns owned by the calling rank. For square matrices it should be equal to local_row_range.
  local_A | The local matrix block owned by the calling rank. The number of rows must match the size of local_row_range and the column indices must span the whole [0, global_cols) range.

## ◆ fromMasterRank() [1/2]

HypreParCSRMatrix TNL::Matrices::HypreParCSRMatrix::fromMasterRank | ( | hypre_CSRMatrix * | matrix,
|  | hypre_ParVector * | x,
|  | hypre_ParVector * | b )
| inlinestaticnodiscard

Constructs a ParCSRMatrix distributed across the processors in communicator from a CSRMatrix on rank 0.

Note
  This function can be used only for matrices allocated on the host.

Parameters

  matrix | Matrix allocated on the master rank to be distributed.
  x | The values of the vector are unused, but its distribution is used for the distribution of the matrix columns.
  b | The values of the vector are unused, but its distribution is used for the distribution of the matrix rows.

## ◆ fromMasterRank() [2/2]

HypreParCSRMatrix TNL::Matrices::HypreParCSRMatrix::fromMasterRank | ( | MPI_Comm | communicator,
|  | IndexType * | global_row_starts,
|  | IndexType * | global_col_starts,
|  | hypre_CSRMatrix * | matrix )
| inlinestaticnodiscard

Constructs a ParCSRMatrix distributed across the processors in communicator from a CSRMatrix on rank 0.

Note
  This function can be used only for matrices allocated on the host.

Parameters

  communicator | MPI communicator to associate with the matrix.
  global_row_starts | Array of nproc + 1 elements, where nproc is the number of ranks in the communicator.
  global_col_starts | Array of nproc + 1 elements, where nproc is the number of ranks in the communicator.
  matrix | Matrix allocated on the master rank to be distributed.

## ◆ wrapCSRMatrix()

HypreParCSRMatrix TNL::Matrices::HypreParCSRMatrix::wrapCSRMatrix | ( | hypre_CSRMatrix * | matrix | ) |
| inlinestaticnodiscard

Wrap a global hypre_CSRMatrix into HypreParCSRMatrix.

Each rank will get its own independent HypreParCSRMatrix with the MPI_COMM_SELF communicator. The data is not copied, but HypreParCSRMatrix keeps a non-owning reference.

The documentation for this class was generated from the following file:

- src/TNL/Matrices/HypreParCSRMatrix.h