3#ifndef DUNE_MMESH_GRID_INTERSECTIONS_HH
4#define DUNE_MMESH_GRID_INTERSECTIONS_HH
6#include <unordered_set>
12#include <dune/mmesh/misc/twistutility.hh>
34template <
class Gr
idImp>
38 friend struct HostGridAccess<typename
std::remove_const<GridImp>
::type>;
40 enum { dim = GridImp::dimension };
42 enum { dimworld = GridImp::dimensionworld };
45 typedef typename GridImp::ctype ctype;
47 typedef typename GridImp::template HostGridEntity<0> HostGridEntity;
48 typedef typename GridImp::template HostGridEntity<1> HostLeafIntersection;
51 enum { dimension = GridImp::dimension };
52 enum { dimensionworld = GridImp::dimensionworld };
53 typedef typename GridImp::template Codim<1>::Geometry Geometry;
54 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
55 typedef typename GridImp::template Codim<1>::LocalGeometry::Implementation
57 typedef typename GridImp::template Codim<0>::Entity Entity;
58 typedef FieldVector<ctype, dimworld> NormalVector;
64 : mMesh_(mMesh), hostIntersection_(hostEntity, index) {}
67 HostLeafIntersection&& hostIntersection)
68 : mMesh_(mMesh), hostIntersection_(std::move(hostIntersection)) {}
72 return hostIntersection_ == other.hostIntersection_;
85 auto neighborHostEntity =
86 (hostIntersection_.first)->
neighbor(hostIntersection_.second);
92 auto neighborHostEntity =
93 (hostIntersection_.first)->
neighbor(hostIntersection_.second);
94 return mMesh_->getHostGrid().is_infinite(neighborHostEntity);
111 HostGridEntity cell = hostIntersection_.first;
112 const auto& facetIdx = hostIntersection_.second;
114 std::vector<std::size_t> vertices;
115 for (std::size_t i = 0; i < dim; ++i)
117 cell->vertex((facetIdx + i + 1) % (dim + 1))->info().id);
118 std::sort(vertices.begin(), vertices.end());
120 auto it = mMesh_->boundarySegments().find(vertices);
121 if (it == mMesh_->boundarySegments().end())
return 0;
129 if (it == mMesh_->boundaryIds().end())
return 0;
141 GeometryType
type()
const {
return GeometryTypes::simplex(dim - 1); }
149 return LocalGeometry(impl);
158 return LocalGeometry(impl);
164 Geometry
geometry()
const {
return Geometry(hostIntersection_); }
168 return MMeshImpl::cgalFacetToDuneFacet<dim, HostLeafIntersection>(
175 hostIntersection_.first->neighbor(hostIntersection_.second);
176 const auto& second = mMesh_->getHostGrid().mirror_index(
177 hostIntersection_.first, hostIntersection_.second);
178 HostLeafIntersection facetFromOutside({
neighbor, second});
179 return MMeshImpl::cgalFacetToDuneFacet<dim, HostLeafIntersection>(
185 const FieldVector<ctype, GridImp::dimension - 1>& local)
const {
190 template <
int d = dim>
192 const FieldVector<ctype, dim - 1>& local)
const {
193 HostGridEntity face = hostIntersection_.first;
194 const auto& edgeIdx = hostIntersection_.second;
196 const auto& p1 = face->vertex(face->cw(edgeIdx))->point();
197 const auto& p2 = face->vertex(face->ccw(edgeIdx))->point();
199 return NormalVector({p1.y() - p2.y(), -p1.x() + p2.x()});
202 template <
int d = dim>
204 const FieldVector<ctype, dim - 1>& local)
const {
205 HostGridEntity cell = hostIntersection_.first;
206 const auto& facetIdx = hostIntersection_.second;
208 const auto& p1 = cell->vertex((facetIdx + 1) % 4)->point();
209 const auto& p2 = cell->vertex((facetIdx + 2) % 4)->point();
210 const auto& p3 = cell->vertex((facetIdx + 3) % 4)->point();
212 return makeFieldVector((facetIdx % 2 == 0) ? CGAL::normal(p1, p2, p3)
213 : CGAL::normal(p1, p3, p2));
218 const FieldVector<ctype, GridImp::dimension - 1>& local)
const {
224 const HostLeafIntersection& getHostIntersection()
const {
225 return hostIntersection_;
230 const GridImp* mMesh_;
231 HostLeafIntersection hostIntersection_;
The implementation of entities in MMesh.
Definition: entity.hh:399
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: intersectioniterator.hh:28
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition: intersections.hh:35
bool conforming() const
Return true if this is a conforming intersection.
Definition: intersections.hh:135
std::size_t boundarySegmentIndex() const
return the boundary segment index
Definition: intersections.hh:110
Entity outside() const
Definition: intersections.hh:83
NormalVector centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: intersections.hh:102
LocalGeometry geometryInOutside() const
Definition: intersections.hh:155
bool boundary() const
return true if intersection is with boundary.
Definition: intersections.hh:91
GeometryType type() const
Geometry type of an intersection.
Definition: intersections.hh:141
bool equals(const MMeshLeafIntersection &other) const
returns true if the host entities are equal
Definition: intersections.hh:71
std::size_t boundaryId() const
return the boundary id
Definition: intersections.hh:127
FieldVector< ctype, GridImp::dimensionworld > outerNormal(const FieldVector< ctype, GridImp::dimension - 1 > &local) const
return outer normal
Definition: intersections.hh:184
bool neighbor() const
return true if across the edge an neighbor on this level exists
Definition: intersections.hh:107
Geometry geometry() const
Definition: intersections.hh:164
FieldVector< ctype, GridImp::dimensionworld > unitOuterNormal(const FieldVector< ctype, GridImp::dimension - 1 > &local) const
return unit outer normal
Definition: intersections.hh:217
int indexInOutside() const
local number of codim 1 entity in neighbor where intersection is contained
Definition: intersections.hh:173
int indexInInside() const
local number of codim 1 entity in self where intersection is contained in
Definition: intersections.hh:167
Entity inside() const
Definition: intersections.hh:77
LocalGeometry geometryInInside() const
Definition: intersections.hh:147
std::enable_if_t< d==2, NormalVector > integrationOuterNormal(const FieldVector< ctype, dim - 1 > &local) const
return outer normal multiplied by the integration element
Definition: intersections.hh:191
The MMeshLeafIterator class.
Helpers for conversion from CGAL::Point_x to DUNE::FieldVector.