From e367295e99561d262cbff98e004d705d0ee9df87 Mon Sep 17 00:00:00 2001 From: Jonathan Youett <youett@math.fu-berlin.de> Date: Fri, 15 Apr 2016 16:13:17 +0200 Subject: [PATCH] Cleanup using 'auto' and range-based for-loops --- dune/fufem/functions/deformationfunction.hh | 32 ++++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/dune/fufem/functions/deformationfunction.hh b/dune/fufem/functions/deformationfunction.hh index 28e1fd8d..9e8200ea 100644 --- a/dune/fufem/functions/deformationfunction.hh +++ b/dune/fufem/functions/deformationfunction.hh @@ -147,7 +147,7 @@ public: Base::evaluate(hostEntity,corner,y); return; } - const typename GridView::Grid::LevelGridView::IndexSet& indexSet = this->gridView_->grid().levelIndexSet(hostEntity.level()); + const auto& indexSet = this->gridView_->grid().levelIndexSet(hostEntity.level()); int idx = indexSet.subIndex(hostEntity, corner,dim); y = hostEntity.geometry().corner(corner) + this->deformation_[fineIndex_[hostEntity.level()][idx]]; @@ -183,45 +183,43 @@ private: for (int i=maxLevel; i>=0; i--) { fineIndex_[i].resize(grid.size(i,dim),-1); - const typename GridView::Grid::LevelGridView::IndexSet& levelIndex = grid.levelIndexSet(i); + const auto& levelIndex = grid.levelIndexSet(i); int fineLevel = (i==maxLevel) ? i : (i+1); - const typename GridView::Grid::LevelGridView::IndexSet& fineIndex = grid.levelIndexSet(fineLevel); + const auto& fineIndex = grid.levelIndexSet(fineLevel); - LevelElementIterator eIt = grid.levelView(i).template begin<0>(); - LevelElementIterator eEndIt = grid.levelView(i).template end<0>(); - - for (; eIt != eEndIt; ++eIt) { + const auto& lv = grid.levelGridView(i); + for (const auto& e: elements(lv)) { // all vertices of leaf elements are leaf - if (eIt->isLeaf()) { + if (e.isLeaf()) { - const Dune::ReferenceElement<ctype,dim>& ref - = Dune::ReferenceElements<ctype, dim>::general(eIt->type()); + const auto& ref + = Dune::ReferenceElements<ctype, dim>::general(e.type()); for (int j=0; j<ref.size(dim); j++) - fineIndex_[i][levelIndex.subIndex(*eIt,j,dim)] = leafIndex.subIndex(*eIt,j,dim); + fineIndex_[i][levelIndex.subIndex(e,j,dim)] = leafIndex.subIndex(e,j,dim); continue; } // Get local finite element - const FEType& coarseBaseSet = p1FECache.get(eIt->type()); + const FEType& coarseBaseSet = p1FECache.get(e.type()); const size_t numCoarseBaseFct = coarseBaseSet.localBasis().size(); // preallocate vector for function evaluations std::vector<Dune::FieldVector<field_type,1> > values(numCoarseBaseFct); - HierarchicIterator fIt = eIt->hbegin(i+1); - HierarchicIterator fEndIt = eIt->hend(i+1); + HierarchicIterator fIt = e.hbegin(i+1); + HierarchicIterator fEndIt = e.hend(i+1); for (; fIt != fEndIt; ++fIt) { if (fIt->level()==i) continue; - const Dune::ReferenceElement<ctype,dim>& fineRefElement + const auto& fineRefElement = Dune::ReferenceElements<ctype, dim>::general(fIt->type()); - const typename EntityType::LocalGeometry& fGeometryInFather = fIt->geometryInFather(); + const auto& fGeometryInFather = fIt->geometryInFather(); // Get local finite element const FEType& fineBaseSet = p1FECache.get(fIt->type()); @@ -246,7 +244,7 @@ private: if (values[k] > 0.9999) { const Dune::LocalKey& coarseKey = coarseBaseSet.localCoefficients().localKey(k); - int globalCoarse = levelIndex.subIndex(*eIt, coarseKey.subEntity(), dim); + int globalCoarse = levelIndex.subIndex(e, coarseKey.subEntity(), dim); fineIndex_[i][globalCoarse] = globalLeaf; } } -- GitLab