1#ifndef DUNE_FEM_MARKING_MAXIMUM_HH
2#define DUNE_FEM_MARKING_MAXIMUM_HH
8#include <dune/geometry/referenceelements.hh>
10#include <dune/grid/common/rangegenerators.hh>
11#include <dune/fem/gridpart/common/gridpart.hh>
12#include <dune/fem/function/localfunction/const.hh>
14#include <dune/fem/marking/default.hh>
25 template <
class Gr
id,
class Indicator>
28 maximumMarking( Grid& grid,
const Indicator& indicator,
29 double theta,
int maxLevel = -1)
31 using Marker = GridAdaptation::Marker;
39 for(
const auto &element : elements( grid.leafGridView() ) )
40 maxError =
max( maxError, localError( element ) );
41 maxError = grid.comm().max( maxError );
43 ConstLocalFunction< Indicator > localIndicator( indicator );
44 typename Indicator :: RangeType value;
46 for (
const auto &e : indicator.space())
48 if (!e.isLeaf())
continue;
49 const auto &gridEntity = Dune::Fem::gridEntity(e);
50 localIndicator.bind(e);
51 const auto& center = Dune::referenceElement< typename Grid::ctype, Grid::dimension>( e.type() ).position(0,0);
52 localIndicator.evaluate(center,value);
53 double eta = value[0];
54 if( eta > theta*maxError )
56 if (e.level()<maxLevel)
57 refMarked += grid.mark(Marker::refine, gridEntity);
59 grid.mark(Marker::keep, gridEntity);
62 return std::make_pair( grid.comm().sum(refMarked), grid.comm().sum(crsMarked) );
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13