20#ifndef OPM_HYPRE_CPU_TRANSFERS_HPP
21#define OPM_HYPRE_CPU_TRANSFERS_HPP
23#include <opm/simulators/linalg/gpuistl/hypreinterface/HypreDataStructures.hpp>
24#include <opm/simulators/linalg/gpuistl/hypreinterface/HypreErrorHandling.hpp>
27#include <_hypre_utilities.h>
35 template <
typename VectorType>
38 std::vector<HYPRE_Real>& continuous_vector_values,
39 const std::vector<int>& local_hypre_to_local_dune)
42 for (
size_t i = 0; i < local_hypre_to_local_dune.size(); ++i) {
43 continuous_vector_values[i] =
v[local_hypre_to_local_dune[i]][0];
50 template <
typename VectorType>
53 const std::vector<HYPRE_Real>& continuous_vector_values,
54 const std::vector<int>& local_hypre_to_local_dune)
57 for (
size_t i = 0; i < local_hypre_to_local_dune.size(); ++i) {
58 v[local_hypre_to_local_dune[i]][0] = continuous_vector_values[i];
65template <
typename VectorType>
74 const int N =
static_cast<int>(
host_arrays.indices.size());
75 using T =
typename VectorType::field_type;
78#if HYPRE_USING_CUDA || HYPRE_USING_HIP
82 const T* values = &(
cpu_vec[0][0]);
105 const T* values = &(
cpu_vec[0][0]);
125template <
typename VectorType>
134 const int N =
static_cast<int>(
host_arrays.indices.size());
135 using T =
typename VectorType::field_type;
138#if HYPRE_USING_CUDA || HYPRE_USING_HIP
185template <
typename MatrixType>
196 using T =
typename MatrixType::field_type;
200#if HYPRE_USING_CUDA || HYPRE_USING_HIP
Unified interface for Hypre operations with both CPU and GPU data structures.
Definition HypreInterface.hpp:61
void transferCpuVectorToHypre(const VectorType &cpu_vec, HYPRE_IJVector hypre_vec, HypreHostDataArrays &host_arrays, const HypreDeviceDataArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer CPU vector to Hypre vector.
Definition HypreCpuTransfers.hpp:67
void setDuneVectorFromContinuousVector(VectorType &v, const std::vector< HYPRE_Real > &continuous_vector_values, const std::vector< int > &local_hypre_to_local_dune)
Distribute HYPRE vector values back to original vector positions.
Definition HypreCpuTransfers.hpp:52
void transferHypreToCpuVector(HYPRE_IJVector hypre_vec, VectorType &cpu_vec, HypreHostDataArrays &host_arrays, const HypreDeviceDataArrays &device_arrays, const ParallelInfo &par_info, bool use_gpu_backend)
Transfer Hypre vector to CPU vector.
Definition HypreCpuTransfers.hpp:127
void updateMatrixFromCpuMatrix(const MatrixType &cpu_matrix, HYPRE_IJMatrix hypre_matrix, const SparsityPattern &sparsity_pattern, const HypreHostDataArrays &host_arrays, const HypreDeviceDataArrays &device_arrays, bool use_gpu_backend)
Update Hypre matrix from CPU matrix Uses HYPRE_IJMatrixSetValues2 with pre-computed row_indexes,...
Definition HypreCpuTransfers.hpp:187
void setContinuousVectorForHypre(const VectorType &v, std::vector< HYPRE_Real > &continuous_vector_values, const std::vector< int > &local_hypre_to_local_dune)
Extract owned vector values in the order expected by HYPRE.
Definition HypreCpuTransfers.hpp:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
GPU device memory arrays for HYPRE operations with GPU backend.
Definition HypreDataStructures.hpp:137
Host arrays for HYPRE matrix and vector data transfers.
Definition HypreDataStructures.hpp:106
Parallel domain decomposition information for HYPRE-Dune interface.
Definition HypreDataStructures.hpp:37
Compressed Sparse Row (CSR) sparsity pattern for HYPRE matrix assembly.
Definition HypreDataStructures.hpp:86