opm-simulators
cpr_amg_operations.hpp
1 /*
2  Copyright 2025 Equinor ASA
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef OPM_GPU_CPR_AMG_OPERATIONS_HPP
20 #define OPM_GPU_CPR_AMG_OPERATIONS_HPP
21 
22 #include <opm/simulators/linalg/gpuistl/GpuSparseMatrixWrapper.hpp>
23 #include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
24 
25 #include <cstddef>
26 
27 namespace Opm::gpuistl::detail
28 {
29 
38 template <typename T, bool transpose>
39 void getQuasiImpesWeights(const GpuSparseMatrixWrapper<T>& matrix,
40  std::size_t pressureVarIndex,
41  GpuVector<T>& weights,
42  const GpuVector<int>& diagonalIndices);
43 
52 template <typename T, bool transpose>
53 void calculateCoarseEntries(const GpuSparseMatrixWrapper<T>& fineMatrix,
54  GpuSparseMatrixWrapper<T>& coarseMatrix,
55  const GpuVector<T>& weights,
56  std::size_t pressureVarIndex);
57 
58 
67 template <typename T, bool transpose>
68 void restrictVector(const GpuVector<T>& fine,
69  GpuVector<T>& coarse,
70  const GpuVector<T>& weights,
71  std::size_t pressureVarIndex);
72 
81 template <typename T, bool transpose>
82 void prolongateVector(const GpuVector<T>& coarse,
83  GpuVector<T>& fine,
84  const GpuVector<T>& weights,
85  std::size_t pressureVarIndex);
86 
87 } // namespace Opm::gpuistl::detail
88 
89 #endif // OPM_GPU_CPR_AMG_OPERATIONS_HPP
void calculateCoarseEntries(const GpuSparseMatrixWrapper< T > &fineMatrix, GpuSparseMatrixWrapper< T > &coarseMatrix, const GpuVector< T > &weights, std::size_t pressureVarIndex)
Calculates the coarse level matrix entries based on the fine level matrix and weights.
void restrictVector(const GpuVector< T > &fine, GpuVector< T > &coarse, const GpuVector< T > &weights, std::size_t pressureVarIndex)
Restricts a fine level vector to a coarse level vector based on pressure index.
void getQuasiImpesWeights(const GpuSparseMatrixWrapper< T > &matrix, std::size_t pressureVarIndex, GpuVector< T > &weights, const GpuVector< int > &diagonalIndices)
Calculates quasi-IMPES weights for CPR preconditioner on GPU.
void prolongateVector(const GpuVector< T > &coarse, GpuVector< T > &fine, const GpuVector< T > &weights, std::size_t pressureVarIndex)
Prolongs a coarse level vector to a fine level vector based on pressure index.
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading...
Definition: autotuner.hpp:29