6#include <dune/common/hybridutilities.hh>
7#include <dune/common/std/type_traits.hh>
9#include <amdis/Boundary.hpp>
10#include <amdis/common/Concepts.hpp>
22 template <
class Intersection>
25 return boundaryIds_[intersection.boundarySegmentIndex()];
28 std::vector<BoundaryType>
const& boundaryIds()
const
34 std::vector<BoundaryType> boundaryIds_;
59 enum { dim = Grid::dimension };
60 enum { dow = Grid::dimensionworld };
62 using Segment =
typename Grid::LevelGridView::Intersection;
63 using SegmentImpl =
typename Grid::LevelGridView::Intersection::Implementation;
64 using Domain =
typename Grid::template Codim<0>::Geometry::GlobalCoordinate;
70 :
Super(grid->numBoundarySegments())
84 auto gv = grid_->leafGridView();
85 for (
auto const& e : elements(gv))
87 for (
auto const& segment : intersections(gv,e)) {
88 if (!segment.boundary())
91 auto n = segment.centerUnitOuterNormal();
92 auto index = segment.boundarySegmentIndex();
94 for (
int i = 0; i < dow; ++i) {
96 boundaryIds_[index] = ids[2*i];
98 boundaryIds_[index] = ids[2*i+1];
106 template <
class Indicator,
110 auto gv = grid_->leafGridView();
111 for (
auto const& e : elements(gv))
113 for (
auto const& segment : intersections(gv,e)) {
114 if (!segment.boundary())
117 auto index = segment.boundarySegmentIndex();
118 boundaryIds_[index] = indicator(segment.geometry().center());
125 template <
class Predicate,
129 auto gv = grid_->leafGridView();
130 for (
auto const& e : elements(gv))
132 for (
auto const& segment : intersections(gv,e)) {
133 if (!segment.boundary())
136 auto index = segment.boundarySegmentIndex();
137 if (pred(segment.geometry().center()))
138 boundaryIds_[index] =
id;
145 using HasBoundaryId =
decltype(std::declval<I>().boundaryId());
150 if (!Dune::Std::is_detected<HasBoundaryId, SegmentImpl>::value)
153 auto gv = grid_->leafGridView();
154 for (
auto const& e : elements(gv))
156 for (
auto const& segment : intersections(gv,e)) {
157 if (!segment.boundary())
160 if constexpr (Dune::Std::is_detected<HasBoundaryId, SegmentImpl>::value) {
161 auto index = segment.boundarySegmentIndex();
162 boundaryIds_[index] = segment.impl().boundaryId();
169 void setBoundaryIds(std::vector<I>
const& ids)
171 test_exit(ids.size() == boundaryIds_.size(),
"Number of boundary IDs does not match!");
172 std::copy(ids.begin(), ids.end(), boundaryIds_.begin());
176 std::shared_ptr<Grid> grid_;
177 using Super::boundaryIds_;
Definition BoundaryManager.hpp:15
BoundaryType boundaryId(Intersection const &intersection) const
Return the stored boundary id for the given intersection.
Definition BoundaryManager.hpp:23
Manage boundary ids of boundary segments in a grid.
Definition BoundaryManager.hpp:54
void setBoundaryId()
Set boundary ids as stored in the grid, e.g. read by grid reader.
Definition BoundaryManager.hpp:148
BoundaryManager(std::shared_ptr< G > const &grid)
Definition BoundaryManager.hpp:69
void setIndicator(Indicator const &indicator)
Set indicator(center) for all boundary intersections.
Definition BoundaryManager.hpp:108
void setPredicate(Predicate const &pred, BoundaryType id)
Set id for all boundary intersections with pred(center) == true.
Definition BoundaryManager.hpp:127
void setBoxBoundary(std::array< BoundaryType, 2 *dow > const &ids)
Set boundary ids [left,right, front,back, bottom,top] for cube domains.
Definition BoundaryManager.hpp:82
constexpr bool Functor
A Functor is a function F with signature Signature.
Definition Concepts.hpp:133