|
Unified interface for Hypre operations with both CPU and GPU data structures. More...
Detailed DescriptionUnified interface for Hypre operations with both CPU and GPU data structures. This namespace provides utilities for working with Hypre resources and transferring data between CPU/GPU data structures and Hypre handles. It handles type detection and automatically chooses the most efficient transfer method:
Supports four use cases:
Function Documentation◆ computeRowIndexes()
template<typename MatrixType >
Compute row indexes for HYPRE_IJMatrixSetValues2. Chooses the appropriate row index computation method based on owner_first and matrix type.
References computeRowIndexesWithMappingCpu(), and Opm::gpuistl::HypreInterface::computeRowIndexesWithMappingGpu(). Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ computeRowIndexesWithMappingCpu() [1/2]
template<typename MatrixType >
Referenced by computeRowIndexes(). ◆ computeRowIndexesWithMappingCpu() [2/2]
template<typename MatrixType >
Compute row indexes for CPU matrix with ownership mapping. Creates row_indexes that point directly into the FULL matrix data, enabling using the original matrix data without any data copying. This is necessary for some cases where ghost rows can come before all owned rows. Example with local_dune_to_local_hypre = [-1, 0, -1, 1]: Original matrix data (with gaps for ghost rows): Row 0 (ghost): {_, _} at positions 0-1 (skipped) Row 1 (owned): {1.0, 2.0} at positions 2-3 Row 2 (ghost): {_} at position 4 (skipped) Row 3 (owned): {3.0} at position 5 Resulting row_indexes: {2, 5} This tells HYPRE that Row 0 data starts at position 2, Row 1 data starts at position 5
◆ createAMGSolver()
Create Hypre solver (BoomerAMG) Create Hypre BoomerAMG solver.
References OPM_HYPRE_SAFE_CALL. Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ createMatrix()
template<typename CommType >
Create Hypre matrix.
References OPM_HYPRE_SAFE_CALL. Referenced by Opm::getMatrixRowColoring(), and Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ createVector()
template<typename CommType >
Create Hypre vector.
References OPM_HYPRE_SAFE_CALL. Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ destroyMatrix()
Destroy Hypre matrix.
References OPM_HYPRE_SAFE_CALL. Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::~HyprePreconditioner(). ◆ destroySolver()
Destroy Hypre solver.
References OPM_HYPRE_SAFE_CALL. Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::~HyprePreconditioner(). ◆ destroyVector()
Destroy Hypre vector.
References OPM_HYPRE_SAFE_CALL. Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::~HyprePreconditioner(). ◆ getHypreErrorMessage()
Get a descriptive error message for a Hypre error code.
Referenced by hypreSafeCall(). ◆ getMatrixValues()
Get matrix values from Hypre matrix. Retrieves the values from a Hypre matrix for verification or debugging purposes.
References OPM_HYPRE_SAFE_CALL. ◆ hypreSafeCall()
Safe call wrapper for Hypre functions. Checks the return code from Hypre functions and throws a HypreError if an error occurred.
References getHypreErrorMessage(). ◆ initialize()
Initialize the Hypre library and set memory/execution policy.
References OPM_HYPRE_SAFE_CALL. Referenced by Dune::CartesianIndexMapper< Dune::ALUGrid< 3, 3, Dune::cube, Dune::nonconforming > >::GlobalIndexDataHandle::GlobalIndexDataHandle(), Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(), Opm::CopyRestrictProlong< Grid, Container >::prolongLocal(), and Opm::CopyRestrictProlong< Grid, Container >::restrictLocal(). ◆ setContinuousVectorForHypre()
template<typename VectorType >
Extract owned vector values in the order expected by HYPRE. Referenced by transferCpuVectorToHypre(). ◆ setDuneVectorFromContinuousVector()
template<typename VectorType >
Distribute HYPRE vector values back to original vector positions. Referenced by transferHypreToCpuVector(). ◆ setSolverParameters()
Set solver parameters from property tree.
References Opm::PropertyTree::get(), and HYPRE_SAFE_CALL. Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ setupHypreParallelInfo()
template<typename CommType , typename MatrixType >
Setup parallel information for Hypre (automatically detects serial/parallel)
References setupHypreParallelInfoParallel(), and setupHypreParallelInfoSerial(). Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ setupHypreParallelInfoParallel()
template<typename CommType , typename MatrixType >
Create mappings between Dune and HYPRE indexing for parallel decomposition. This function interfaces between Dune's distributed matrix representation and HYPRE's global indexing requirements. Note that Dune uses local indices with owner/ghost classification, while HYPRE requires globally consistent indices for all DOFs. Index System Overview:Dune Local Indices: Each MPI process has local DOFs indexed 0..N_local-1, where:
HYPRE Global Indices: All DOFs across all processes have unique global indices:
Index Mappings Created:
Algorithm Steps:
Example (2 processes, 3 DOFs each):Process 0: Dune local [0,1,2] → owned=[0,1], ghost=[2 from P1]
Process 1: Dune local [0,1,2] → owned=[1,2], ghost=[0 from P0]
References Opm::linalg::HypreInterface::ParallelInfo::dof_offset, Opm::linalg::HypreInterface::ParallelInfo::local_dune_to_global_hypre, Opm::linalg::HypreInterface::ParallelInfo::local_dune_to_local_hypre, Opm::linalg::HypreInterface::ParallelInfo::local_hypre_to_local_dune, Opm::linalg::HypreInterface::ParallelInfo::N_owned, and Opm::linalg::HypreInterface::ParallelInfo::owner_first. Referenced by setupHypreParallelInfo(). ◆ setupHypreParallelInfoSerial()
Setup parallel information for Hypre in serial case.
References Opm::linalg::HypreInterface::ParallelInfo::dof_offset, Opm::linalg::HypreInterface::ParallelInfo::local_dune_to_global_hypre, Opm::linalg::HypreInterface::ParallelInfo::local_dune_to_local_hypre, Opm::linalg::HypreInterface::ParallelInfo::local_hypre_to_local_dune, Opm::linalg::HypreInterface::ParallelInfo::N_owned, and Opm::linalg::HypreInterface::ParallelInfo::owner_first. Referenced by setupHypreParallelInfo(). ◆ setupSparsityPattern()
template<typename MatrixType >
Setup sparsity pattern from matrix (automatically detects CPU/GPU type)
References setupSparsityPatternFromCpuMatrix(), and Opm::gpuistl::HypreInterface::setupSparsityPatternFromGpuMatrix(). Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::HyprePreconditioner(). ◆ setupSparsityPatternFromCpuMatrix()
template<typename MatrixType >
Setup sparsity pattern from CPU matrix (BCRSMatrix)
References Opm::linalg::HypreInterface::SparsityPattern::cols, Opm::linalg::HypreInterface::ParallelInfo::local_dune_to_global_hypre, Opm::linalg::HypreInterface::ParallelInfo::local_dune_to_local_hypre, Opm::linalg::HypreInterface::ParallelInfo::N_owned, Opm::linalg::HypreInterface::SparsityPattern::ncols, Opm::linalg::HypreInterface::SparsityPattern::nnz, and Opm::linalg::HypreInterface::SparsityPattern::rows. Referenced by setupSparsityPattern(). ◆ transferCpuVectorToHypre()
template<typename VectorType >
Transfer CPU vector to Hypre vector. References Opm::linalg::HypreInterface::HostDataArrays::continuous_vector_values, Opm::linalg::HypreInterface::HostDataArrays::indices, Opm::linalg::HypreInterface::ParallelInfo::local_hypre_to_local_dune, OPM_HYPRE_SAFE_CALL, Opm::linalg::HypreInterface::ParallelInfo::owner_first, setContinuousVectorForHypre(), and Opm::gpuistl::HypreInterface::transferCpuVectorToHypre(). Referenced by transferVectorToHypre(). ◆ transferHypreToCpuVector()
template<typename VectorType >
Transfer Hypre vector to CPU vector. References Opm::linalg::HypreInterface::HostDataArrays::continuous_vector_values, Opm::linalg::HypreInterface::HostDataArrays::indices, Opm::linalg::HypreInterface::ParallelInfo::local_hypre_to_local_dune, OPM_HYPRE_SAFE_CALL, Opm::linalg::HypreInterface::ParallelInfo::owner_first, setDuneVectorFromContinuousVector(), and Opm::gpuistl::HypreInterface::transferHypreToCpuVector(). Referenced by transferVectorFromHypre(). ◆ transferVectorFromHypre()
template<typename VectorType >
Transfer vector from Hypre to any vector type (CPU or GPU) References transferHypreToCpuVector(). Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::apply(). ◆ transferVectorToHypre()
template<typename VectorType >
Transfer vector to Hypre from any vector type (CPU or GPU) References transferCpuVectorToHypre(). Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::apply(). ◆ updateMatrixFromCpuMatrix()
template<typename MatrixType >
Update Hypre matrix from CPU matrix Uses HYPRE_IJMatrixSetValues2 with pre-computed row_indexes, which allows us to use the original CPU matrix data (with potential ghost values) directly. References Opm::linalg::HypreInterface::SparsityPattern::cols, Opm::linalg::HypreInterface::SparsityPattern::ncols, OPM_HYPRE_SAFE_CALL, Opm::linalg::HypreInterface::HostDataArrays::row_indexes, Opm::linalg::HypreInterface::SparsityPattern::rows, and Opm::gpuistl::HypreInterface::updateMatrixFromCpuMatrix(). Referenced by updateMatrixValues(). ◆ updateMatrixValues()
template<typename MatrixType >
Update matrix values in Hypre. References updateMatrixFromCpuMatrix(). Referenced by Opm::linalg::HyprePreconditioner< M, X, Y, Comm >::update(). |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||