AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
BoundarySubset.hpp
1#pragma once
2
3#include <functional>
4
5#include <amdis/Boundary.hpp>
6#include <amdis/BoundaryManager.hpp>
7#include <amdis/ContextGeometry.hpp>
8#include <amdis/common/Concepts.hpp>
9#include <amdis/common/ConceptsBase.hpp>
10
11namespace AMDiS
12{
14
22 template <class IS>
24 {
25 using Domain = typename IS::GlobalCoordinate;
26
27 public:
28 using Intersection = IS;
29
32 : predicate_([](Intersection const& is) -> bool { return is.boundary(); })
33 {}
34
36 template <class G>
37 BoundarySubset(std::shared_ptr<BoundaryManager<G>> const& boundaryManager, BoundaryType id)
38 : predicate_([boundaryManager, id](Intersection const& is) -> bool {
39 return is.boundary() && boundaryManager->boundaryId(is) == id;
40 })
41 {}
42
44 template <class G>
46 : BoundarySubset{Dune::stackobject_to_shared_ptr(boundaryManager), id}
47 {}
48
50 template <class Predicate,
51 REQUIRES(Concepts::Functor<Predicate, bool(Domain)>)>
53 : predicate_([predicate](Intersection const& is) -> bool {
54 return predicate(is.geometry().center());
55 })
56 {}
57
59 bool operator()(Intersection const& is) const
60 {
61 return predicate_(is);
62 }
63
64 protected:
65 std::function<bool(Intersection const&)> predicate_;
66 };
67
68 template <class Grid>
69 BoundarySubset(std::shared_ptr<BoundaryManager<Grid>>, BoundaryType)
70 -> BoundarySubset<typename Grid::LeafIntersection>;
71
72 template <class Grid>
73 BoundarySubset(BoundaryManager<Grid>&, BoundaryType)
74 -> BoundarySubset<typename Grid::LeafIntersection>;
75
76
77 template <class I>
78 struct Impl::ContextTagType<BoundarySubset<I>>
79 {
80 using type = I;
81 };
82
83} // end namespace AMDiS
Manage boundary ids of boundary segments in a grid.
Definition: BoundaryManager.hpp:54
Class defining a subset of a domain boundary.
Definition: BoundarySubset.hpp:24
BoundarySubset()
Default constructor. Uses a predicate that returns true on the complete boundary.
Definition: BoundarySubset.hpp:31
BoundarySubset(std::shared_ptr< BoundaryManager< G > > const &boundaryManager, BoundaryType id)
Use a boundary manager and id to determine a subset.
Definition: BoundarySubset.hpp:37
BoundarySubset(BoundaryManager< G > &boundaryManager, BoundaryType id)
Use a boundary manager and id to determine a subset.
Definition: BoundarySubset.hpp:45
bool operator()(Intersection const &is) const
Return true if intersection is on boundary segment.
Definition: BoundarySubset.hpp:59
BoundarySubset(Predicate &&predicate)
Use a predicate of the form bool(GlobalCoordinate) to determine a subset.
Definition: BoundarySubset.hpp:52
constexpr bool Predicate
A predicate is a function that returns a boolean.
Definition: Concepts.hpp:141
constexpr bool Functor
A Functor is a function F with signature Signature.
Definition: Concepts.hpp:133