Correct handling of overlapping NNC and EDITNNC#6875
Conversation
| || directVerticalNeighbors(*cartDims, cartesianToActive, cellIdx1, cellIdx2); | ||
| }; | ||
|
|
||
| auto alreadyAssigned = [outputNnc = &this->outputNnc_] |
There was a problem hiding this comment.
why capture as pointer? capture as ref, ie, [&outputNnc = this->outputNnc_]
|
In draft mode until how to handle this is decided in #6865 |
|
I don't think this correct if the value in EDITNNC is not 0. Because we apply and internalize EDITNNC for an input NNC in OPM/opm-common#5025, we will reapply the value in EDITNNC in the EDIT section another time in Transmissibility::applyEditNncToGridTrans. Note that there we apply one factor that incorporates all EDITNNC internalized from the GRID/EDIT section and specified in the SCHEDULE section. I don't have the complete picture, yet, but maybe we should not apply EDITNNC to input NNCs in opm-common and always internalize. Then all NNCs are treated equal. Not sure whether we need to do something addtional for output, though, |
| } | ||
|
|
||
| if (isNumAquConn(cc1, cc2) || ! isDirectNeighbours(cc1, cc2)) { | ||
| if (isNumAquConn(cc1, cc2) || (! isDirectNeighbours(cc1, cc2) && ! alreadyAssigned(cc1, cc2))) { |
There was a problem hiding this comment.
I am not sure what this change does and whether it is correct.
For each cell pair in (at least) CpGrid there is only one intersection, even if there is an explicitly specified NNC and one that is created because of the grid topology. (Because of this and the additional output of those NNCs, we substract the transmissibility of the explicitly specified NNC below).
If I understand this change correctly. then `alreadyAssigned returns true if there was an NNC in the deck for this cell pair. Doesn't this mean that the transmissibility of an NNC created by the topology of the grid is not output at all if there was also an explicit NNC in the deck?
There was a problem hiding this comment.
In master using the test case in OPM/opm-tests#1502 (i.e., internally the generated NNC has a value of 0.10000000E+01) with:
NNC 1 1 1 2 1 2 6666, EDITNNCR 1 1 1 2 1 2 9999 -> TRANNNC 0.99990000E+04 0.33330000E+04
NNC 1 1 1 2 1 2 6666, EDITNNC 1 1 1 2 1 2 10 -> TRANNNC 0.66661000E+05 0.10000000E+01
Here in EclGenericWriter_impl.hpp the total transmissibility is assigned, and with this PR we avoid writing duplicated values, i.e., with these PRs:
NNC 1 1 1 2 1 2 6666, EDITNNCR 1 1 1 2 1 2 9999 -> TRANNNC 0.99990000E+04
NNC 1 1 1 2 1 2 6666, EDITNNC 1 1 1 2 1 2 10 -> TRANNNC 0.66760000E+04
On a related note I still think EDITNNC/EDITNNCR should be applied only to internally generated NNCs and not the ones given in the deck using the keyword NNC. I would be happy to update the code in different PRs if that is the case.
9d698d5 to
b7e8718
Compare
|
Marking the PR as ready to review. Two decks are added to the tests for these OPM/opm-tests#1502 (planning on adding them to the regression tests prior merging). |
|
jenkins build this please. |
blattms
left a comment
There was a problem hiding this comment.
I am not finished (transmissibility is missing), but I need a break.
The logic during output is now really complicated and has a lot of (linear) searches in it. This might degrade performance quite a bit and we might need to find a better way.
| if (level == 0) { | ||
| auto candidate = std::lower_bound(nncData.begin(), nncData.end(), | ||
| NNCdata { originCartIdxIn, originCartIdxOut, 0.0 }); | ||
| const auto transMlt = transMult.getRegionMultiplierNNC(originCartIdxIn, originCartIdxOut); |
There was a problem hiding this comment.
This might be expensive please only do it if we found a matching nnc.
There was a problem hiding this comment.
Looking at other places where getRegionMultiplierNNC is called (e.g., here), then we also do not check for matching nncs, but instead this is done once inside the method.
| } | ||
| } | ||
| if (foundNncEditr) { | ||
| break; |
There was a problem hiding this comment.
I don't understand this break. Where is the connection to editNNC below, that is skipped.
If this is needed then please add a comment.
| break; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I think we should prevent this linear search. It would take a lot of time.
Do you see a way?
There was a problem hiding this comment.
Not really, but this search happens only once before writing the INIT and looping for nncData, then after updating all binary search as you suggested, then having this linear search should be fine.
|
jenkins build this please |
|
Sorry somehow github messed my comments made on multiple lines. |
|
benchmark please |
882b99f to
c7aa24a
Compare
|
Thanks @blattms for your review, I have updated the PR and tried to answer your comments. Let me know if this need further changes. |
|
jenkins build this please |
|
I think we will need to investigate the currently failing regression tests once @daavid00 is back:
In addition we might want to add further regression tests before merging. |
blattms
left a comment
There was a problem hiding this comment.
🙈 my fault. Should have added the opm-common companion PR when calling jenkins.
I am running jenkins another time in opm-common and will merge if this succeeds as expected.
Avoid writing twice to the
INITtheNNCTRANS.Before merging, adding this deck to the regression tests:
OPM/opm-tests#1502
Depends on OPM/opm-common#5025
Closes #6865
Closes OPM/opm-common#3470