From 019c272a11e6cd205e0c188e9a8286813514ae15 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 27 Jan 2015 13:15:06 +0100 Subject: [PATCH] ECL grid manager: make the cartesianCellId() method take an integer and return one the fact that this is implemented via a std::vector is an implementation detail which should not be visible to the outside of this class. --- applications/ebos/eclproblem.hh | 31 ++++++++++++----------------- applications/ebos/eclwellmanager.hh | 10 +++++----- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/applications/ebos/eclproblem.hh b/applications/ebos/eclproblem.hh index 3dc193541..7ec36affd 100644 --- a/applications/ebos/eclproblem.hh +++ b/applications/ebos/eclproblem.hh @@ -526,12 +526,12 @@ public: if (!deck->hasKeyword("PVTNUM")) return 0; - const auto &cartesianCellId = this->simulator().gridManager().cartesianCellId(); + const auto& gridManager = this->simulator().gridManager(); // this is quite specific to the ECFV discretization. But so is everything in an // ECL deck, i.e., we don't need to care here... int compressedDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx); - int cartesianDofIdx = cartesianCellId[compressedDofIdx]; + int cartesianDofIdx = gridManager.cartesianCellId(compressedDofIdx); return deck->getKeyword("PVTNUM")->getIntData()[cartesianDofIdx] - 1; } @@ -662,9 +662,9 @@ private: void readMaterialParameters_() { - auto deck = this->simulator().gridManager().deck(); - auto eclState = this->simulator().gridManager().eclState(); - const auto &cartesianCellId = this->simulator().gridManager().cartesianCellId(); + const auto &gridManager = this->simulator().gridManager(); + auto deck = gridManager.deck(); + auto eclState = gridManager.eclState(); size_t numDof = this->model().numGridDof(); @@ -689,7 +689,7 @@ private: permzData = eclState->getDoubleGridProperty("PERMZ")->getData(); for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) { - int cartesianElemIdx = cartesianCellId[dofIdx]; + int cartesianElemIdx = gridManager.cartesianCellId(dofIdx); intrinsicPermeability_[dofIdx] = 0.0; intrinsicPermeability_[dofIdx][0][0] = permxData[cartesianElemIdx]; intrinsicPermeability_[dofIdx][1][1] = permyData[cartesianElemIdx]; @@ -712,7 +712,7 @@ private: eclState->getDoubleGridProperty("PORO")->getData(); for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) { - int cartesianElemIdx = cartesianCellId[dofIdx]; + int cartesianElemIdx = gridManager.cartesianCellId(dofIdx); porosity_[dofIdx] = poroData[cartesianElemIdx]; } } @@ -726,10 +726,8 @@ private: const std::vector &ntgData = eclState->getDoubleGridProperty("NTG")->getData(); - for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) { - int cartesianElemIdx = cartesianCellId[dofIdx]; - porosity_[dofIdx] *= ntgData[cartesianElemIdx]; - } + for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) + porosity_[dofIdx] *= ntgData[gridManager.cartesianCellId(dofIdx)]; } // apply the MULTPV keyword to the porosity @@ -737,10 +735,8 @@ private: const std::vector &multpvData = eclState->getDoubleGridProperty("MULTPV")->getData(); - for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) { - int cartesianElemIdx = cartesianCellId[dofIdx]; - porosity_[dofIdx] *= multpvData[cartesianElemIdx]; - } + for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) + porosity_[dofIdx] *= multpvData[gridManager.cartesianCellId(dofIdx)]; } //////////////////////////////// @@ -802,7 +798,7 @@ private: materialParamTableIdx_.resize(numDof); for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) { - int cartesianElemIdx = cartesianCellId[dofIdx]; + int cartesianElemIdx = gridManager.cartesianCellId(dofIdx); // make sure that all values are in the correct range assert(1 <= satnumData[dofIdx]); @@ -849,7 +845,6 @@ private: { const auto deck = this->simulator().gridManager().deck(); const auto &gridManager = this->simulator().gridManager(); - const auto &cartesianCellId = gridManager.cartesianCellId(); if (!deck->hasKeyword("SWAT") || !deck->hasKeyword("SGAS")) @@ -903,7 +898,7 @@ private: for (size_t dofIdx = 0; dofIdx < numDof; ++dofIdx) { auto &dofFluidState = initialFluidStates_[dofIdx]; - size_t cartesianDofIdx = cartesianCellId[dofIdx]; + size_t cartesianDofIdx = gridManager.cartesianCellId(dofIdx); assert(0 <= cartesianDofIdx); assert(cartesianDofIdx <= numCartesianCells); diff --git a/applications/ebos/eclwellmanager.hh b/applications/ebos/eclwellmanager.hh index 4165843be..e84219d46 100644 --- a/applications/ebos/eclwellmanager.hh +++ b/applications/ebos/eclwellmanager.hh @@ -534,7 +534,7 @@ protected: void updateWellTopology_(int reportStepIdx, const WellCompletionsMap& wellCompletions) { auto& model = simulator_.model(); - const auto& cartesianCellId = simulator_.gridManager().cartesianCellId(); + const auto& gridManager = simulator_.gridManager(); // first, remove all wells from the reservoir model.clearAuxiliaryModules(); @@ -557,7 +557,7 @@ protected: elemCtx.updateStencil(elem); for (int dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++ dofIdx) { int globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); - int cartesianDofIdx = cartesianCellId[globalDofIdx]; + int cartesianDofIdx = gridManager.cartesianCellId(globalDofIdx); if (wellCompletions.count(cartesianDofIdx) == 0) // the current DOF is not contained in any well, so we must skip @@ -635,8 +635,8 @@ protected: // associate the well completions with grid cells and register them in the // Peaceman well object - const GridView gridView = simulator_.gridManager().gridView(); - const auto& cartesianCellId = simulator_.gridManager().cartesianCellId(); + const auto& gridManager = simulator_.gridManager(); + const GridView gridView = gridManager.gridView(); ElementContext elemCtx(simulator_); auto elemIt = gridView.template begin(); @@ -650,7 +650,7 @@ protected: elemCtx.updateStencil(elem); for (int dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++ dofIdx) { int globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); - int cartesianDofIdx = cartesianCellId[globalDofIdx]; + int cartesianDofIdx = gridManager.cartesianCellId(globalDofIdx); if (wellCompletions.count(cartesianDofIdx) == 0) // the current DOF is not contained in any well, so we must skip