51 const auto& gpuMatrix = op.getmat();
53 const auto nonZeros = gpuMatrix.getNonZeroValues().asStdVector();
54 const auto rowIndices = gpuMatrix.getRowIndices().asStdVector();
55 const auto columnIndices = gpuMatrix.getColumnIndices().asStdVector();
57 const auto numberOfNonZeroes = gpuMatrix.nonzeroes();
58 const auto N = gpuMatrix.N();
60 Dune::BCRSMatrix<BlockType> matrix(N, N, numberOfNonZeroes, Dune::BCRSMatrix<BlockType>::row_wise);
61 for (
auto row = matrix.createbegin(); row != matrix.createend(); ++row) {
62 for (
auto j = rowIndices[row.index()]; j != rowIndices[row.index() + 1]; ++j) {
63 const auto columnIndex = columnIndices[j];
64 row.insert(columnIndex);
68 for (std::size_t i = 0; i < N; ++i) {
69 for (
auto j = rowIndices[i]; j != rowIndices[i + 1]; ++j) {
70 const auto columnIndex = columnIndices[j];
72 BlockType blockMatrix;
73 constexpr static auto rows = BlockType::rows;
75 for (std::size_t k = 0; k < rows; ++k) {
76 for (std::size_t l = 0; l < rows; ++l) {
77 blockMatrix[k][l] = nonZeros[j * rows * rows + k * rows + l];
80 matrix[i][columnIndex] = blockMatrix;
Dune::BCRSMatrix< BlockType > makeCPUMatrix(const Operator &op)
Utility functions for GPU preconditioner creation.
Definition gpu_preconditioner_utils.hpp:47