Skip to content
Snippets Groups Projects
Commit ec7b8e09 authored by Jonathan Youett's avatar Jonathan Youett
Browse files

Clean up code using range-based for-loops

parent ab505b6d
Branches
No related tags found
No related merge requests found
...@@ -79,28 +79,21 @@ mark(const std::vector<RefinementIndicator<GridType>*>& refinementIndicators, ...@@ -79,28 +79,21 @@ mark(const std::vector<RefinementIndicator<GridType>*>& refinementIndicators,
Dune::LeafMultipleCodimMultipleGeomTypeMapper<GridType,P0Layout> p0Mapper(*grids[i]); Dune::LeafMultipleCodimMultipleGeomTypeMapper<GridType,P0Layout> p0Mapper(*grids[i]);
typename GridType::LeafGridView::template Codim<0>::Iterator eIt = grids[i]->template leafbegin<0>(); const auto& leafView = grids[i]->leafGridView();
typename GridType::LeafGridView::template Codim<0>::Iterator eEndIt = grids[i]->template leafend<0>();
for (; eIt!=eEndIt; ++eIt) { for (const auto& e : elements(leafView)) {
// Get set of shape functions // Get set of shape functions
const Dune::ReferenceElement<double,dim>& refElement const auto& refElement = Dune::ReferenceElements<field_type, dim>::general(e.type());
= Dune::ReferenceElements<double, dim>::general(eIt->type());
// Compute the maximum indicator of any subentity of this element // Compute the maximum indicator of any subentity of this element
double maxError = 0; field_type maxError = 0;
for (int codim=0; codim<=dim; codim++) for (int codim=0; codim<=dim; codim++)
for (int entity=0; entity<refElement.size(codim); entity++) for (int entity=0; entity<refElement.size(codim); entity++)
maxError = std::max(maxError, (*refinementIndicators[i]).value(*eIt, codim, entity)); maxError = std::max(maxError, (*refinementIndicators[i]).value(e, codim, entity));
// Store the max error in a map ordered by the error // Store the max error in a map ordered by the error
#if DUNE_VERSION_NEWER(DUNE_GRID,2,4) errorMap.insert(std::pair<field_type, std::pair<int,int> >(maxError, std::make_pair(i, p0Mapper.index(e))));
errorMap.insert(std::pair<double, std::pair<int,int> >(maxError, std::pair<int,int>(i, p0Mapper.index(*eIt))));
#else
// Store the max error in a map ordered by the error
errorMap.insert(std::pair<double, std::pair<int,int> >(maxError, std::pair<int,int>(i, p0Mapper.map(*eIt))));
#endif
minGridError[i] = std::min(minGridError[i], maxError); minGridError[i] = std::min(minGridError[i], maxError);
maxGridError[i] = std::max(maxGridError[i], maxError); maxGridError[i] = std::max(maxGridError[i], maxError);
...@@ -148,18 +141,10 @@ mark(const std::vector<RefinementIndicator<GridType>*>& refinementIndicators, ...@@ -148,18 +141,10 @@ mark(const std::vector<RefinementIndicator<GridType>*>& refinementIndicators,
for (size_t i=0; i<grids.size(); i++) { for (size_t i=0; i<grids.size(); i++) {
Dune::LeafMultipleCodimMultipleGeomTypeMapper<GridType,P0Layout> p0Mapper(*grids[i]); Dune::LeafMultipleCodimMultipleGeomTypeMapper<GridType,P0Layout> p0Mapper(*grids[i]);
assert(p0Mapper.size() == (int) refinedElements[i].size());
typename GridType::LeafGridView::template Codim<0>::Iterator eIt = grids[i]->template leafbegin<0>(); for (const auto& e : elements(grids[i]->leafGridView()))
typename GridType::LeafGridView::template Codim<0>::Iterator eEndIt = grids[i]->template leafend<0>(); if (refinedElements[i][p0Mapper.index(e)][0])
grids[i]->mark(1,e);
for (; eIt!=eEndIt; ++eIt)
#if DUNE_VERSION_NEWER(DUNE_GRID,2,4)
if (refinedElements[i][p0Mapper.index(*eIt)][0])
#else
if (refinedElements[i][p0Mapper.map(*eIt)][0])
#endif
grids[i]->mark(1,*eIt);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment