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 Domain =
typename Grid::template Codim<0>::Geometry::GlobalCoordinate;
69 :
Super(grid->numBoundarySegments())
78 auto gv = grid_->leafGridView();
79 for (
auto const& e : elements(gv))
81 for (
auto const& segment : intersections(gv,e)) {
82 if (!segment.boundary())
85 auto n = segment.centerUnitOuterNormal();
86 auto index = segment.boundarySegmentIndex();
88 for (
int i = 0; i < dow; ++i) {
90 boundaryIds_[index] = ids[2*i];
92 boundaryIds_[index] = ids[2*i+1];
100 template <
class Indicator,
104 auto gv = grid_->leafGridView();
105 for (
auto const& e : elements(gv))
107 for (
auto const& segment : intersections(gv,e)) {
108 if (!segment.boundary())
111 auto index = segment.boundarySegmentIndex();
112 boundaryIds_[index] = indicator(segment.geometry().center());
123 auto gv = grid_->leafGridView();
124 for (
auto const& e : elements(gv))
126 for (
auto const& segment : intersections(gv,e)) {
127 if (!segment.boundary())
130 auto index = segment.boundarySegmentIndex();
131 if (pred(segment.geometry().center()))
132 boundaryIds_[index] = id;
139 using HasBoundaryId = decltype(std::declval<I>().
boundaryId());
144 if (!Dune::Std::is_detected<HasBoundaryId, Segment>::value)
147 auto gv = grid_->leafGridView();
148 for (
auto const& e : elements(gv))
150 for (
auto const& segment : intersections(gv,e)) {
151 if (!segment.boundary())
154 if constexpr (Dune::Std::is_detected<HasBoundaryId, Segment>::value) {
155 auto index = segment.boundarySegmentIndex();
156 boundaryIds_[index] = segment.boundaryId();
163 void setBoundaryIds(std::vector<I>
const& ids)
165 test_exit(ids.size() == boundaryIds_.size(),
"Number of boundary IDs does not match!");
166 std::copy(ids.begin(), ids.end(), boundaryIds_.begin());
170 std::shared_ptr<Grid> grid_;
171 using Super::boundaryIds_;
constexpr bool Functor
A Functor is a function F with signature Signature.
Definition: Concepts.hpp:134
void setPredicate(Predicate const &pred, BoundaryType id)
Set id for all boundary intersections with pred(center) == true.
Definition: BoundaryManager.hpp:121
constexpr bool Predicate
A predicate is a function that returns a boolean.
Definition: Concepts.hpp:142
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
void setIndicator(Indicator const &indicator)
Set indicator(center) for all boundary intersections.
Definition: BoundaryManager.hpp:102
void setBoxBoundary(std::array< BoundaryType, 2 *dow > const &ids)
Set boundary ids [left,right, front,back, bottom,top] for cube domains.
Definition: BoundaryManager.hpp:76
BoundaryType boundaryId(Intersection const &intersection) const
Return the stored boundary id for the given intersection.
Definition: BoundaryManager.hpp:23
BoundaryManager(std::shared_ptr< G > const &grid)
Definition: BoundaryManager.hpp:68
void setBoundaryId()
Set boundary ids as stored in the grid, e.g. read by grid reader.
Definition: BoundaryManager.hpp:142
Definition: BoundaryManager.hpp:14
Manage boundary ids of boundary segments in a grid.
Definition: BoundaryManager.hpp:52
void test_exit(bool condition, std::string const &str, Args &&... args)
test for condition and in case of failure print message and exit
Definition: Output.hpp:163