32 template <
class Gr
idView>
33 std::pair<Dune::FieldVector<typename GridView::ctype,GridView::dimensionworld>,
37 using ctype =
typename GridView::ctype;
38 int const dim = GridView::dimensionworld;
41 high(std::numeric_limits<ctype>::lowest());
43 for (
auto const& cell: Dune::elements(gv))
45 auto const& geo = cell.geometry();
46 for (
int i=0; i<geo.corners(); ++i)
48 auto x = geo.corner(i);
54 return std::make_pair(low,high);
69 template <
class Gr
idView>
70 std::unique_ptr<typename GridView::Grid>
createCoverGrid(GridView
const& gv,
double volumeRatio=10)
72 using Grid =
typename GridView::Grid;
78 auto d = box.second - box.first;
82 auto& maxh = *std::max_element(h.begin(),h.end());
83 auto& minh = *std::min_element(h.begin(),h.end());
91 std::unique_ptr<Grid> grid = createCuboid<Grid>(box.first,d,h);
100 for (
auto const& cell: Dune::elements(gv))
102 auto x = cell.geometry().center();
103 auto const covercell =
findCell(grid->leafGridView(),x);
104 if (covercell.geometry().volume() > volumeRatio*cell.geometry().volume())
106 grid->mark(1,covercell);
This file contains various utility functions that augment the basic functionality of Dune.
std::unique_ptr< typename GridView::Grid > createCoverGrid(GridView const &gv, double volumeRatio=10)
Creates a cartesian structured grid occupying the bounding box of the given grid view.
Cell< GridView > findCell(GridView const &gv, GlobalPosition< GridView > global)
Returns a cell of the given grid containing the specified global coordinate.
std::pair< Dune::FieldVector< typename GridView::ctype, GridView::dimensionworld >, Dune::FieldVector< typename GridView::ctype, GridView::dimensionworld > > boundingBox(GridView const &gv)
Computes a the bounding box of the given grid view.
Dune::FieldVector< T, n > max(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise maximum.
Dune::FieldVector< T, n > min(Dune::FieldVector< T, n > x, Dune::FieldVector< T, n > const &y)
Componentwise minimum.