1#ifndef DUNE_FEMPY_PY_DEFAULT_MARKING_HH
2#define DUNE_FEMPY_PY_DEFAULT_MARKING_HH
6#include <dune/geometry/referenceelements.hh>
14 namespace GridAdaptation
24 template <
class Gr
id,
class Indicator>
27 mark( Grid& grid, Indicator& indicator,
28 const double refineTolerance,
const double coarsenTolerance,
29 int minLevel = 0,
int maxLevel = -1,
30 const bool markNeighbors =
false )
33 typename Indicator::RangeType value;
35 std::array< int, 2 > sumMarks = {{ 0,0 }};
37 int& refMarked = sumMarks[ 0 ];
38 int& crsMarked = sumMarks[ 1 ];
41 maxLevel = std::numeric_limits<int>::max();
43 const auto& gridPart = indicator.space().gridPart();
45 for (
const auto &e : indicator.space())
47 if (!e.isLeaf())
continue;
51 if (marked==1)
continue;
53 localIndicator.bind(e);
54 const auto ¢er = Dune::referenceElement< typename Grid::ctype, Grid::dimension>( e.type() ).position(0,0);
55 localIndicator.evaluate(center,value);
57 const int level = e.level();
58 if (eta>refineTolerance && level<maxLevel)
63 const auto iEnd = gridPart.iend( e );
64 for(
auto it = gridPart.ibegin( e ); it != iEnd; ++it )
66 const auto& intersection = *it;
67 if( intersection.neighbor() )
69 const auto& outside = intersection.outside();
70 if (outside.level()<maxLevel)
77 else if (eta<coarsenTolerance && level>minLevel)
83 grid.comm().sum( sumMarks.data(), 2 );
84 return std::make_pair( refMarked, crsMarked );
Dune::Fem::Double abs(const Dune::Fem::Double &a)
Definition: double.hh:942
Definition: bindguard.hh:11
const GridEntityAccess< Entity >::GridEntityType & gridEntity(const Entity &entity)
Definition: gridpart.hh:412
typename Impl::ConstLocalFunction< GridFunction >::Type ConstLocalFunction
Definition: const.hh:604
static std::pair< int, int > mark(Grid &grid, Indicator &indicator, const double refineTolerance, const double coarsenTolerance, int minLevel=0, int maxLevel=-1, const bool markNeighbors=false)
Definition: marking/default.hh:27
Definition: marking/default.hh:17
static const int coarsen
Definition: marking/default.hh:20
static const int keep
Definition: marking/default.hh:19
static const int refine
Definition: marking/default.hh:18