3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
boundingboxtreeintersection.hh
Go to the documentation of this file.
1/*****************************************************************************
2 * See the file COPYING for full copying permissions. *
3 * *
4 * This program is free software: you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation, either version 3 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16 *****************************************************************************/
22#ifndef DUMUX_BOUNDING_BOX_TREE_INTERSECTION_HH
23#define DUMUX_BOUNDING_BOX_TREE_INTERSECTION_HH
24
25#include <dune/common/fvector.hh>
26#include <dune/common/promotiontraits.hh>
27
28namespace Dumux {
29
39template<class EntitySet0, class EntitySet1>
41{
42 enum { dimworld = EntitySet0::dimensionworld };
43 using ctype = typename Dune::PromotionTraits<typename EntitySet0::ctype, typename EntitySet1::ctype>::PromotedType;
44 using GlobalPosition = Dune::FieldVector<ctype, dimworld>;
45
46public:
47 template<class Corners>
48 explicit BoundingBoxTreeIntersection(std::size_t a,
49 std::size_t b,
50 Corners&& c)
51 : a_(a)
52 , b_(b)
53 , corners_(c.begin(), c.end())
54 {
55 static_assert(int(EntitySet0::dimensionworld) == int(EntitySet1::dimensionworld),
56 "Can only store intersections of entity sets with the same world dimension");
57 }
58
60 std::size_t first() const
61 { return a_; }
62
64 std::size_t second() const
65 { return b_; }
66
68 std::vector<GlobalPosition> corners() const
69 { return corners_; }
70
75 bool cornersMatch(const std::vector<GlobalPosition>& otherCorners) const
76 {
77 if (otherCorners.size() != corners_.size())
78 return false;
79
80 const auto eps = 1.5e-7*(corners_[1] - corners_[0]).two_norm();
81 for (int i = 0; i < corners_.size(); ++i)
82 if ((corners_[i] - otherCorners[i]).two_norm() > eps)
83 return false;
84
85 return true;
86 }
87
88private:
89 std::size_t a_, b_;
90 std::vector<GlobalPosition> corners_;
91};
92
93} // end namespace Dumux
94
95#endif
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
constexpr double eps
epsilon for checking direction of scvf normals
Definition: test_tpfafvgeometry_nonconforming.cc:44
An intersection object resulting from the intersection of two bounding box tree primitives.
Definition: boundingboxtreeintersection.hh:41
std::vector< GlobalPosition > corners() const
Get the corners of the intersection geometry.
Definition: boundingboxtreeintersection.hh:68
std::size_t first() const
Get the index of the intersecting entity belonging to this grid.
Definition: boundingboxtreeintersection.hh:60
std::size_t second() const
Get the index of the intersecting entity belonging to the other grid.
Definition: boundingboxtreeintersection.hh:64
bool cornersMatch(const std::vector< GlobalPosition > &otherCorners) const
Check if the corners of this intersection match with the given corners.
Definition: boundingboxtreeintersection.hh:75
BoundingBoxTreeIntersection(std::size_t a, std::size_t b, Corners &&c)
Definition: boundingboxtreeintersection.hh:48