cache the remaining element iterator dereferences

they were forgotten in a place or two. With this, ebos' performance
using ALUGrid is comparable to its performance using a "raw"
Dune::CpGrid.

(also, make the naming of the local variable for the element more
consistent, i.e., replace 'entity' by 'elem' for the few places where
'entity' was used.)
This commit is contained in:
Andreas Lauser
2015-01-21 15:56:07 +01:00
parent 2cfe491008
commit a8b093e372
2 changed files with 18 additions and 15 deletions
+7 -7
View File
@@ -97,15 +97,15 @@ public:
auto elemIt = gridView.template begin</*codim=*/ 0>();
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
for (; elemIt != elemEndIt; ++elemIt) {
const auto& entity = *elemIt;
const auto& elem = *elemIt;
#if DUNE_VERSION_NEWER(DUNE_COMMON, 2,4)
int elemIdx = elementMapper.index( entity );
int elemIdx = elementMapper.index(elem);
#else
int elemIdx = elementMapper.map( entity );
int elemIdx = elementMapper.map(elem);
#endif
// get the geometry of the current element
const auto& geom = entity.geometry();
const auto& geom = elem.geometry();
// compute the axis specific "centroids" used for the
// transmissibilities
@@ -154,9 +154,9 @@ public:
// compute the transmissibilities for all intersections
elemIt = gridView.template begin</*codim=*/ 0>();
for (; elemIt != elemEndIt; ++elemIt) {
const auto& entity = *elemIt;
auto isIt = gridView.ibegin( entity );
const auto& isEndIt = gridView.iend( entity );
const auto& elem = *elemIt;
auto isIt = gridView.ibegin(elem);
const auto& isEndIt = gridView.iend(elem);
for (; isIt != isEndIt; ++ isIt) {
// store intersection, this might be costly
const auto& intersection = *isIt;
+11 -8
View File
@@ -64,6 +64,8 @@ class EclWellManager
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
typedef typename GridView::template Codim<0>::Entity Element;
typedef Ewoms::EclPeacemanWell<TypeTag> Well;
typedef std::map<int, std::pair<const Opm::Completion*, std::shared_ptr<Well> > > WellCompletionsMap;
@@ -372,10 +374,11 @@ public:
auto elemIt = simulator_.gridManager().gridView().template begin</*codim=*/0>();
const auto &elemEndIt = simulator_.gridManager().gridView().template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
if (elemIt->partitionType() != Dune::InteriorEntity)
const Element& elem = *elemIt;
if (elem.partitionType() != Dune::InteriorEntity)
continue;
elemCtx.updateStencil(*elemIt);
elemCtx.updateStencil(elem);
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
for (size_t wellIdx = 0; wellIdx < wells_.size(); ++wellIdx)
@@ -555,11 +558,11 @@ protected:
const auto elemEndIt = gridView.template end</*codim=*/0>();
std::set<std::shared_ptr<Well> > wells;
for (; elemIt != elemEndIt; ++elemIt) {
const auto& entity = *elemIt;
if (entity.partitionType() != Dune::InteriorEntity)
const auto& elem = *elemIt;
if (elem.partitionType() != Dune::InteriorEntity)
continue; // non-local entities need to be skipped
elemCtx.updateStencil( entity );
elemCtx.updateStencil(elem);
for (int dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++ dofIdx) {
int globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
int cartesianDofIdx = cartesianCellId[globalDofIdx];
@@ -635,11 +638,11 @@ protected:
const auto elemEndIt = gridView.template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
const auto& entity = *elemIt;
if (entity.partitionType() != Dune::InteriorEntity)
const auto& elem = *elemIt;
if (elem.partitionType() != Dune::InteriorEntity)
continue; // non-local entities need to be skipped
elemCtx.updateStencil( entity );
elemCtx.updateStencil(elem);
for (int dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++ dofIdx) {
int globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0);
int cartesianDofIdx = cartesianCellId[globalDofIdx];