Dune::Copasi
Loading...
Searching...
No Matches
has_single_geometry_type.hh
Go to the documentation of this file.
1#ifndef DUNE_COPASI_GRID_HAS_SINGLE_GEOMETRY_TYPE_HH
2#define DUNE_COPASI_GRID_HAS_SINGLE_GEOMETRY_TYPE_HH
3
4#include <dune-copasi-config.hh>
5
6#include <dune/grid/common/capabilities.hh>
7
8#include <dune/geometry/type.hh>
9
10#include <dune/common/exceptions.hh>
11
12namespace Dune::Copasi {
13
26template<class GridView>
27std::enable_if_t<Capabilities::hasSingleGeometryType<typename GridView::Grid>::v,
28 bool> constexpr has_single_geometry_type(const GridView& /*unused*/)
29{
30 return true;
31}
32
45template<class GridView>
46std::enable_if_t<not Capabilities::hasSingleGeometryType<typename GridView::Grid>::v,bool>
48{
49 if (grid_view.size(0) == 0) {
50 return true;
51 }
52 GeometryType gt = grid_view.template begin<0>()->geometry().type();
53 for (auto&& element : elements(grid_view)) {
54 if (gt != element.geometry().type()) {
55 return false;
56 }
57 }
58 return true;
59}
60
61} // namespace Dune::Copasi
62
63#endif // DUNE_COPASI_GRID_HAS_SINGLE_GEOMETRY_TYPE_HH
Definition axis_names.hh:7
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24
std::enable_if_t< Capabilities::hasSingleGeometryType< typename GridView::Grid >::v, bool > constexpr has_single_geometry_type(const GridView &)
Determines if grid view has a single geometry type.
Definition has_single_geometry_type.hh:28