mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-03 12:47:42 -06:00
Cleanup sparse matrix iteration patterns
Improves readability and consistency of sparse matrix element access. This is as a preparation work for a new matrix from dune-istl. * Use begin and end creator iterators accounting that they may be different types. * Use iterator arithmetic instead of row implementation details. * Use sparseRange idiom to loop over the row sparsity pattern. * Avoid taking mutable references of rows, given that a matrix may return proxy objects. * Do not assign an non-zero numeric value to the jacobian during its pattern creation. * Include missing header for block vectors
This commit is contained in:
1 parent
1eecc8eea6
commit
524e37a534
9 files changed
+42
-49
No files matched your search
@@ -41,14 +41,14 @@ init(const int num_conn, const std::vector<std::size_t>& cells)
|
||||
duneB_.setSize(1, num_conn, num_conn);
|
||||
duneC_.setSize(1, num_conn, num_conn);
|
||||
|
||||
for (auto row = duneD_.createbegin(),
|
||||
end = duneD_.createend(); row != end; ++row) {
|
||||
auto endD = duneD_.createend();
|
||||
for (auto row = duneD_.createbegin(); row != endD; ++row) {
|
||||
// Add nonzeros for diagonal
|
||||
row.insert(row.index());
|
||||
}
|
||||
|
||||
for (auto row = duneB_.createbegin(),
|
||||
end = duneB_.createend(); row != end; ++row) {
|
||||
auto endB = duneB_.createend();
|
||||
for (auto row = duneB_.createbegin(); row != endB; ++row) {
|
||||
for (int con = 0 ; con < num_conn; ++con) {
|
||||
row.insert(con);
|
||||
}
|
||||
@@ -56,8 +56,8 @@ init(const int num_conn, const std::vector<std::size_t>& cells)
|
||||
|
||||
// make the C^T matrix
|
||||
// TODO: let us see whether we should change the naming of DuneC_
|
||||
for (auto row = duneC_.createbegin(),
|
||||
end = duneC_.createend(); row != end; ++row) {
|
||||
auto endC = duneC_.createend();
|
||||
for (auto row = duneC_.createbegin(); row != endC; ++row) {
|
||||
for (int con = 0; con < num_conn; ++con) {
|
||||
row.insert(con);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user