From 5f05697f0a1611df9d176080c1fa85de0d21acbf Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Fri, 25 May 2012 15:24:24 +0000 Subject: [PATCH] Replace static loop over the codimension by a dynamic one. Because we can, and code gets much simpler that way. [[Imported from SVN: r375]] --- dune/subgrid/subgrid.hh | 46 ++++++++++------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/dune/subgrid/subgrid.hh b/dune/subgrid/subgrid.hh index ce58b9c..03ffd46 100644 --- a/dune/subgrid/subgrid.hh +++ b/dune/subgrid/subgrid.hh @@ -32,39 +32,6 @@ namespace Dune { - -//! helper class to mark the subentities of marked elements -template <class HostGridType, int codim> -class SubGridHelpers { - public: - - static void markSubEntities(const typename HostGridType::template Codim<0>::Entity& entity, - std::vector<std::vector<bool> > entityFields[], - const HostGridType* hostGrid) - { - /** \todo dim should really be the dimension of the SubGrid */ - const int dim = HostGridType::dimension; - const int level = entity.level(); - - for (int i=0; i<entity.template count<codim>(); i++) - entityFields[dim-codim][level][hostGrid->levelIndexSet(level).subIndex(entity,i, codim)] = true; - - SubGridHelpers<HostGridType,codim-1>::markSubEntities(entity, entityFields, hostGrid); - } -}; - -// Specialization to stop the recursion -template <class HostGridType> -class SubGridHelpers<HostGridType,0> { - public: - - static void markSubEntities( - const typename HostGridType::template Codim<0>::Entity& entity, - std::vector<std::vector<bool> > entityFields[], - const HostGridType* hostGrid) - {} -}; - // General write~ and readHostGrid methods to circumvent interface ambiguities template <typename HostGridType> bool writeHostGrid(HostGridType& hostgrid, std::string filename) @@ -1007,8 +974,17 @@ class SubGrid : { // Do nothing if this element is not marked - if (entities_[dim][i][hostgrid_->levelIndexSet(i).index(*eIt)]) - SubGridHelpers<HostGridType, dim>::markSubEntities(*eIt, entities_, hostgrid_); + if (entities_[dim][i][hostgrid_->levelIndexSet(i).index(*eIt)]) { + + for (size_t codim=1; codim<=dim; codim++) { + size_t nSubEntities = GenericReferenceElements<ctype,dim>::general(eIt->type()).size(codim); + + for (size_t j=0; j<nSubEntities; j++) + entities_[dim-codim][i][hostgrid_->levelIndexSet(i).subIndex(*eIt,j, codim)] = true; + } + + } + } } -- GitLab