1#ifndef DUNE_FEM_NONCONFORMITYLEVEL_HH
2#define DUNE_FEM_NONCONFORMITYLEVEL_HH
22 template <
class Gr
idPartType>
24 makeNonConformity(GridPartType& gridPart,
25 const int levelDifference,
26 const bool verbose =
false)
32 typedef typename GridPartType :: GridType GridType;
33 typedef typename GridPartType :: template Codim<0>::IteratorType IteratorType;
34 typedef typename GridPartType :: GridType :: template Codim<0>:: Entity EntityType;
35 typedef typename GridPartType :: IntersectionIteratorType IntersectionIteratorType;
38 const IteratorType endit = gridPart.template end<0> ();
41 GridType& grid = gridPart.grid();
44 const int gridsize = gridPart.indexSet().size(0);
47 const int levelAllowed = levelDifference - 1;
50 bool finished =
false;
55 for(IteratorType it = gridPart.template begin<0>();
59 const EntityType & en = *it;
61 const int enMarker = grid.getMark(en);
66 IntersectionIteratorType endnit = gridPart.iend(en);
67 for(IntersectionIteratorType nit = gridPart.ibegin(en);
70 const typename IntersectionIteratorType::Intersection &intersec = *nit;
72 if(intersec.neighbor())
74 int diff = std::abs(intersec.outside().level() - en.level());
75 assert( diff <= levelDifference );
76 if( diff > levelDifference )
78 std::cerr <<
"makeNonConformity: " << diff <<
" level difference to large! \n";
87 if( enMarker > 0 )
continue;
90 IntersectionIteratorType endnit = gridPart.iend(en);
91 for(IntersectionIteratorType nit = gridPart.ibegin(en);
94 const typename IntersectionIteratorType::Intersection &intersec = *nit;
95 if(intersec.neighbor())
97 assert( enMarker <= 0 );
98 EntityType nb = intersec.outside();
99 const int nbMarker = grid.getMark(nb);
100 const int levelDiff = nb.level() - en.level();
103 if(levelDiff > levelAllowed)
106 const int newMarker = std::max(enMarker,std::max(nbMarker,0));
108 finished = (enMarker == newMarker) ? finished :
false;
110 grid.mark(newMarker, en);
113 if( newMarker > 0 )
break;
115 else if( (levelDiff == 0) && (nbMarker > 0) )
118 const int newMarker = std::max(enMarker,0);
120 finished = (enMarker == newMarker) ? finished :
false;
122 grid.mark(newMarker, en);
125 if( newMarker > 0 )
break;
135 std::cerr <<
"makeNonConformity: Break Adaptation loop because not terminating! \n";
143 std::cout <<
"Making non-conformity level took ";
144 std::cout << timer.
elapsed() <<
" seconds. \n";
A simple stop watch.
Definition: timer.hh:43
double elapsed() const noexcept
Get elapsed user-time from last reset until now/last stop in seconds.
Definition: timer.hh:77
Dune namespace.
Definition: alignedallocator.hh:13