3#ifndef DUNE_GRIDGLUE_MERGING_INTERSECTIONLIST_HH
4#define DUNE_GRIDGLUE_MERGING_INTERSECTIONLIST_HH 1
11#include <dune/common/fvector.hh>
20template<
typename L0,
typename L1>
43 virtual std::size_t
size()
const = 0;
96template<
typename P,
int I>
97struct IntersectionListLocal
101struct IntersectionListLocal<P, 0>
103 static std::size_t parents(
const P& p,
typename P::Index intersection)
104 {
return p.parents0(intersection); }
106 static typename P::Index parent(
const P& p,
typename P::Index intersection,
unsigned index)
107 {
return p.parent0(intersection, index); }
109 static typename P::Local0 corner(
const P& p,
typename P::Index intersection,
unsigned corner,
unsigned index)
110 {
return p.corner0(intersection, corner, index); }
114struct IntersectionListLocal<P, 1>
116 static std::size_t parents(
const P& p,
typename P::Index intersection)
117 {
return p.parents1(intersection); }
119 static typename P::Index parent(
const P& p,
typename P::Index intersection,
unsigned index)
120 {
return p.parent1(intersection, index); }
122 static typename P::Local1 corner(
const P& p,
typename P::Index intersection,
unsigned corner,
unsigned index)
123 {
return p.corner1(intersection, corner, index); }
132template<
typename Local0,
typename Local1>
147 {
return impl_->size(); }
158 static_assert(I == 0 or I == 1,
"I must be 0 or 1");
160 return Impl::IntersectionListLocal<Provider, I>::parents(*impl_, intersection);
171 Index
parent(Index intersection,
unsigned index = 0)
const
173 static_assert(I == 0 or I == 1,
"I must be 0 or 1");
175 return Impl::IntersectionListLocal<Provider, I>::parent(*impl_, intersection, index);
187 auto corner(Index intersection,
unsigned corner,
unsigned index = 0)
const
189 static_assert(I == 0 or I == 1,
"I must be 0 or 1");
191 return Impl::IntersectionListLocal<Provider, I>::corner(*impl_, intersection,
corner, index);
195 std::shared_ptr<Provider> impl_;
204template<
int dim0,
int dim1>
212 using Local0 = FieldVector<double, dim0>;
213 using Local1 = FieldVector<double, dim1>;
216 using Local = std::conditional_t< I == 0, Local0, Local1 >;
224 static constexpr int intersectionDim = dim0 < dim1 ? dim0 : dim1;
225 static constexpr int nVertices = intersectionDim + 1;
238 using Corners = std::array<Local<I>, nVertices>;
243 std::vector< Corners<0> >
corners0 = std::vector< Corners<0> >(1);
248 std::vector< Index >
parents0 = std::vector< Index >(1);
253 std::vector< Corners<1> >
corners1 = std::vector< Corners<1> >(1);
258 std::vector< Index >
parents1 = std::vector< Index >(1);
263 : intersections_(std::move(intersections))
266 auto& intersections()
267 {
return intersections_; }
269 std::size_t
size()
const override
270 {
return intersections_.size(); }
272 std::size_t
parents0(Index intersection)
const override
273 {
return intersections_[intersection].parents0.size(); }
275 std::size_t
parents1(Index intersection)
const override
276 {
return intersections_[intersection].parents1.size(); }
278 Index
parent0(Index intersection,
unsigned index)
const override
279 {
return intersections_[intersection].parents0[index]; }
281 Index
parent1(Index intersection,
unsigned index)
const override
282 {
return intersections_[intersection].parents1[index]; }
284 Local0
corner0(Index intersection,
unsigned corner,
unsigned index)
const override
285 {
return intersections_[intersection].corners0[index][corner]; }
287 Local1
corner1(Index intersection,
unsigned corner,
unsigned index)
const override
288 {
return intersections_[intersection].corners1[index][corner]; }
292 intersections_.clear();
296 std::vector<SimplicialIntersection> intersections_;
Definition: intersectionlist.hh:22
virtual std::size_t parents0(Index intersection) const =0
virtual Local1 corner1(Index intersection, unsigned corner, unsigned index) const =0
unsigned int Index
Definition: intersectionlist.hh:38
virtual std::size_t size() const =0
L0 Local0
Definition: intersectionlist.hh:28
virtual Local0 corner0(Index intersection, unsigned corner, unsigned index) const =0
L1 Local1
Definition: intersectionlist.hh:33
virtual Index parent1(Index intersection, unsigned index) const =0
virtual std::size_t parents1(Index intersection) const =0
virtual Index parent0(Index intersection, unsigned index) const =0
Definition: intersectionlist.hh:134
Index parent(Index intersection, unsigned index=0) const
Definition: intersectionlist.hh:171
auto corner(Index intersection, unsigned corner, unsigned index=0) const
Definition: intersectionlist.hh:187
std::size_t parents(Index intersection) const
Definition: intersectionlist.hh:156
std::size_t size() const
Definition: intersectionlist.hh:146
Definition: intersectionlist.hh:207
Local1 corner1(Index intersection, unsigned corner, unsigned index) const override
Definition: intersectionlist.hh:287
Local0 corner0(Index intersection, unsigned corner, unsigned index) const override
Definition: intersectionlist.hh:284
Index parent1(Index intersection, unsigned index) const override
Definition: intersectionlist.hh:281
std::size_t size() const override
Definition: intersectionlist.hh:269
std::size_t parents1(Index intersection) const override
Definition: intersectionlist.hh:275
Index parent0(Index intersection, unsigned index) const override
Definition: intersectionlist.hh:278
std::size_t parents0(Index intersection) const override
Definition: intersectionlist.hh:272
Definition: intersectionlist.hh:222
std::array< Local< I >, nVertices > Corners
Definition: intersectionlist.hh:238
std::vector< Index > parents1
Definition: intersectionlist.hh:258
std::vector< Index > parents0
Definition: intersectionlist.hh:248
std::vector< Corners< 1 > > corners1
Definition: intersectionlist.hh:253
std::vector< Corners< 0 > > corners0
Definition: intersectionlist.hh:243