Effort to make the code documentation better.

This commit is contained in:
Markus Blatt 2023-04-12 16:39:25 +02:00
parent 1bb2cbd646
commit 83e05e7ba3

View File

@ -180,6 +180,10 @@ bool is_neighbor(const EclipseGrid& grid, std::size_t g1, std::size_t g2) {
void NNC::load_editr(const EclipseGrid& grid, const Deck& deck) {
// Will contain EDITNNCR data in reverse order to be able
// use unique to only keep the last one from the data file.
// For that we sort it later. This sort is stable and hence
// entries for the cell pairs will be consecutive and the last
// entry that was specified in the data file will come first and
// will kept by std::unique.
std::deque<NNCdata> nnc_editr;
const auto& keyword_list = deck.getKeywordList<ParserKeywords::EDITNNCR>();
@ -214,12 +218,15 @@ bool is_neighbor(const EclipseGrid& grid, std::size_t g1, std::size_t g2) {
return;
}
// Make the entries unique (i.e. only one entry for each index pair)
// the entry surviving should be last one (i.e. later enrtries overwrite previous entries)
// Will keep the insertion order of entries for same cell pair.
// Sort the deck to make entries for the same cell pair consecutive.
// Will keep the insertion order of entries for same cell pair as sort
// is stable.
std::sort(nnc_editr.begin(), nnc_editr.end());
// remove duplicates (based on only cell1 and cell2 members
// remove duplicates (based on only cell1 and cell2 members)
// recall that entries for the same cell pairs are consecutive after
// the sort above, and that the last entry specified in the data file
// comes first in the deck (because we used emplace_front, and sort is stable)
auto equality = [](const NNCdata& d1, const NNCdata& d2){
return d1.cell1 == d2.cell1 && d1.cell2 == d2.cell2;
};
@ -237,9 +244,10 @@ bool is_neighbor(const EclipseGrid& grid, std::size_t g1, std::size_t g2) {
// NNCs are left untouched as they are also needed for
// grid construction. Transmissibilities are overwritten
// in the simulator by EDITNNCR
// in the simulator by EDITNNCR, anyway.
// Create new container to not use excess memory
// and convert to std::vector
m_editr = {nnc_editr.begin(), nnc_editr.end()};
}