From 1cec56fa68206d7555dc98f0e26a1541c2564cfc Mon Sep 17 00:00:00 2001 From: Tong Dong Qiu Date: Thu, 24 Feb 2022 16:03:08 +0100 Subject: [PATCH] Use implicit mode to build jacMatrix Fix print variable --- opm/simulators/linalg/ISTLSolverEbos.hpp | 33 +++++-------------- .../linalg/bda/opencl/openclSolverBackend.cpp | 2 +- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/opm/simulators/linalg/ISTLSolverEbos.hpp b/opm/simulators/linalg/ISTLSolverEbos.hpp index 8a2f653e2..acb59fbc9 100644 --- a/opm/simulators/linalg/ISTLSolverEbos.hpp +++ b/opm/simulators/linalg/ISTLSolverEbos.hpp @@ -520,10 +520,7 @@ namespace Opm typedef typename Matrix::size_type size_type; size_type numCells = grid.size( 0 ); - blockJacobiForGPUILU0_.reset(new Matrix(numCells, numCells, Matrix::random)); - - std::vector> pattern; - pattern.resize(numCells); + blockJacobiForGPUILU0_.reset(new Matrix(numCells, numCells, 8, 0.4, Matrix::implicit)); const auto& lid = grid.localIdSet(); const auto& gridView = grid.leafGridView(); @@ -533,14 +530,14 @@ namespace Opm //Loop over cells for (; elemIt != elemEndIt; ++elemIt) { - const auto& elem = *elemIt; size_type idx = lid.id(elem); - pattern[idx].insert(idx); + blockJacobiForGPUILU0_->entry(idx, idx) = 0.0; // Add well non-zero connections - for (auto wc = wellConnectionsGraph_[idx].begin(); wc!=wellConnectionsGraph_[idx].end(); ++wc) - pattern[idx].insert(*wc); + for (auto wc = wellConnectionsGraph_[idx].begin(); wc!=wellConnectionsGraph_[idx].end(); ++wc) { + blockJacobiForGPUILU0_->entry(idx, *wc) = 0.0; + } int locPart = cell_part[idx]; @@ -553,25 +550,13 @@ namespace Opm { size_type nid = lid.id(is->outside()); int nabPart = cell_part[nid]; - if (locPart == nabPart) - pattern[idx].insert(nid); + if (locPart == nabPart) { + blockJacobiForGPUILU0_->entry(idx, nid) = 0.0; + } } - - blockJacobiForGPUILU0_->setrowsize(idx, pattern[idx].size()); } } - blockJacobiForGPUILU0_->endrowsizes(); - for (size_type dofId = 0; dofId < numCells; ++dofId) - { - auto nabIdx = pattern[dofId].begin(); - auto endNab = pattern[dofId].end(); - for (; nabIdx != endNab; ++nabIdx) - { - blockJacobiForGPUILU0_->addindex(dofId, *nabIdx); - } - } - - blockJacobiForGPUILU0_->endindices(); + blockJacobiForGPUILU0_->compress(); } void copyMatToBlockJac(const Matrix& mat, Matrix& blockJac) diff --git a/opm/simulators/linalg/bda/opencl/openclSolverBackend.cpp b/opm/simulators/linalg/bda/opencl/openclSolverBackend.cpp index cb537e3c6..57abba963 100644 --- a/opm/simulators/linalg/bda/opencl/openclSolverBackend.cpp +++ b/opm/simulators/linalg/bda/opencl/openclSolverBackend.cpp @@ -399,7 +399,7 @@ void openclSolverBackend::initialize(std::shared_ptr } std::ostringstream out; - out << "Initializing GPU, matrix size: " << N << " blocks, nnzb: " << nnzb << "\n"; + out << "Initializing GPU, matrix size: " << Nb << " blockrows, nnzb: " << nnzb << "\n"; if (useJacMatrix) { out << "Blocks in ILU matrix: " << jac_nnzb << "\n"; }