wells: slightly optimize it

this is done by only calculating intensive quantities for elements
which actually are pierced by wells. on SPE1 this lead to a
performance improvement of about 2% on my machine. (3.50 vs 3.57
seconds.)
This commit is contained in:
Andreas Lauser 2014-08-14 19:23:07 +02:00
parent 6528a88e90
commit a883247e0b

View File

@ -77,6 +77,9 @@ public:
const Grid &grid = simulator_.gridManager().grid(); const Grid &grid = simulator_.gridManager().grid();
const GridView gridView = simulator_.gridManager().gridView(); const GridView gridView = simulator_.gridManager().gridView();
elemIsInAWell_.resize(simulator_.model().elementMapper().size());
std::fill(elemIsInAWell_.begin(), elemIsInAWell_.end(), false);
// create the wells // create the wells
for (size_t deckWellIdx = 0; deckWellIdx < deckSchedule->numWells(); ++deckWellIdx) { for (size_t deckWellIdx = 0; deckWellIdx < deckSchedule->numWells(); ++deckWellIdx) {
Opm::WellConstPtr deckWell = deckSchedule->getWells()[deckWellIdx]; Opm::WellConstPtr deckWell = deckSchedule->getWells()[deckWellIdx];
@ -120,6 +123,9 @@ public:
&& ijk[1] == completion->getJ() && ijk[1] == completion->getJ()
&& ijk[2] == completion->getK()) && ijk[2] == completion->getK())
{ {
int globalElemIdx = simulator_.model().elementMapper().map(*elemIt);
elemIsInAWell_[globalElemIdx] = true;
well->addDof(elemCtx, dofIdx); well->addDof(elemCtx, dofIdx);
well->setRadius(elemCtx, dofIdx, 0.5*completion->getDiameter()); well->setRadius(elemCtx, dofIdx, 0.5*completion->getDiameter());
} }
@ -384,6 +390,10 @@ public:
if (elemIt->partitionType() != Dune::InteriorEntity) if (elemIt->partitionType() != Dune::InteriorEntity)
continue; continue;
int globalElemIdx = simulator_.model().elementMapper().map(*elemIt);
if (!elemIsInAWell_[globalElemIdx])
continue;
elemCtx.updateStencil(*elemIt); elemCtx.updateStencil(*elemIt);
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
@ -480,6 +490,7 @@ protected:
const Simulator &simulator_; const Simulator &simulator_;
std::vector<std::shared_ptr<Well> > wells_; std::vector<std::shared_ptr<Well> > wells_;
std::vector<bool> elemIsInAWell_;
std::map<std::string, int> wellNameToIndex_; std::map<std::string, int> wellNameToIndex_;
}; };
} // namespace Ewoms } // namespace Ewoms