Faster copying to jacMatrix

This commit is contained in:
Tong Dong Qiu
2022-02-24 14:34:56 +01:00
parent 3797b7297d
commit 550ce92902

View File

@@ -574,13 +574,18 @@ namespace Opm
blockJacobiForGPUILU0_->endindices();
}
void copyMatToBlockJac(Matrix& mat, Matrix& blockJac)
void copyMatToBlockJac(const Matrix& mat, Matrix& blockJac)
{
auto rbegin = blockJac.begin();
auto rend = blockJac.end();
for (auto row = rbegin; row != rend; ++row) {
auto outerRow = mat.begin();
for (auto row = rbegin; row != rend; ++row, ++outerRow) {
auto outerCol = (*outerRow).begin();
for (auto col = (*row).begin(); col != (*row).end(); ++col) {
blockJac[row.index()][col.index()] = mat[row.index()][col.index()];
// outerRow is guaranteed to have all column entries that row has!
while(outerCol.index() < col.index()) ++outerCol;
assert(outerCol.index() == col.index());
*col = *outerCol; // copy nonzero block
}
}
}