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>
24 template<
class Gr
id >
25 struct HostGridAccess;
35 template<
class Gr
idImp>
40 friend struct HostGridAccess< typename
std::remove_const< GridImp >
::type >;
42 enum {dim=GridImp::dimension};
44 enum {dimworld=GridImp::dimensionworld};
47 typedef typename GridImp::ctype ctype;
49 typedef typename GridImp::template HostGridEntity<0> HostGridEntity;
50 typedef typename GridImp::template HostGridEntity<1> HostLeafIntersection;
53 enum {dimension=GridImp::dimension};
54 enum {dimensionworld=GridImp::dimensionworld};
55 typedef typename GridImp::template Codim<1>::Geometry Geometry;
56 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
57 typedef typename GridImp::template Codim<1>::LocalGeometry::Implementation LocalGeometryImpl;
58 typedef typename GridImp::template Codim<0>::Entity Entity;
59 typedef FieldVector<ctype, dimworld> NormalVector;
65 const HostGridEntity& hostEntity,
68 , hostIntersection_(hostEntity, index)
72 HostLeafIntersection&& hostIntersection)
74 , hostIntersection_(std::move(hostIntersection))
80 return hostIntersection_ == other.hostIntersection_;
93 auto neighborHostEntity = (hostIntersection_.first)->
neighbor(hostIntersection_.second);
99 auto neighborHostEntity = (hostIntersection_.first)->
neighbor(hostIntersection_.second);
100 return mMesh_->getHostGrid().is_infinite(neighborHostEntity);
120 HostGridEntity cell = hostIntersection_.first;
121 const auto& facetIdx = hostIntersection_.second;
123 std::vector< std::size_t > vertices;
124 for( std::size_t i = 0; i < dim; ++i )
125 vertices.push_back( cell->vertex( (facetIdx+i+1)%(dim+1) )->info().id );
126 std::sort(vertices.begin(), vertices.end());
128 auto it = mMesh_->boundarySegments().find( vertices );
129 if( it == mMesh_->boundarySegments().end() )
139 if( it == mMesh_->boundaryIds().end() )
153 return GeometryTypes::simplex(dim-1);
163 return LocalGeometry( impl );
172 return LocalGeometry( impl );
179 return Geometry( hostIntersection_ );
184 return MMeshImpl::cgalFacetToDuneFacet<dim, HostLeafIntersection>( hostIntersection_ );
189 const auto&
neighbor = hostIntersection_.first->neighbor( hostIntersection_.second );
190 const auto& second = mMesh_->getHostGrid().mirror_index( hostIntersection_.first, hostIntersection_.second );
191 HostLeafIntersection facetFromOutside ( {
neighbor, second } );
192 return MMeshImpl::cgalFacetToDuneFacet<dim, HostLeafIntersection>( facetFromOutside );
196 FieldVector<ctype, GridImp::dimensionworld>
outerNormal (
const FieldVector<ctype, GridImp::dimension-1>& local)
const {
201 template<
int d = dim >
202 typename std::enable_if_t< d == 2, NormalVector >
205 HostGridEntity face = hostIntersection_.first;
206 const auto& edgeIdx = hostIntersection_.second;
208 const auto& p1 = face->vertex( face->cw ( edgeIdx ) )->point();
209 const auto& p2 = face->vertex( face->ccw( edgeIdx ) )->point();
211 return NormalVector ( { p1.y() - p2.y(), - p1.x() + p2.x() } );
214 template<
int d = dim >
215 typename std::enable_if_t< d == 3, NormalVector >
218 HostGridEntity cell = hostIntersection_.first;
219 const auto& facetIdx = hostIntersection_.second;
221 const auto& p1 = cell->vertex( (facetIdx+1)%4 )->point();
222 const auto& p2 = cell->vertex( (facetIdx+2)%4 )->point();
223 const auto& p3 = cell->vertex( (facetIdx+3)%4 )->point();
225 return makeFieldVector(
226 ( facetIdx % 2 == 0) ?
227 CGAL::normal(p1, p2, p3) :
228 CGAL::normal(p1, p3, p2)
233 FieldVector<ctype, GridImp::dimensionworld>
unitOuterNormal (
const FieldVector<ctype, GridImp::dimension-1>& local)
const {
239 const HostLeafIntersection& getHostIntersection()
const
241 return hostIntersection_;
246 const GridImp* mMesh_;
247 HostLeafIntersection hostIntersection_;
The implementation of entities in MMesh.
Definition: entity.hh:448
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: intersectioniterator.hh:30
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition: intersections.hh:37
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:203
bool conforming() const
Return true if this is a conforming intersection.
Definition: intersections.hh:146
std::size_t boundarySegmentIndex() const
return the boundary segment index
Definition: intersections.hh:118
Entity outside() const
Definition: intersections.hh:91
NormalVector centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: intersections.hh:108
LocalGeometry geometryInOutside() const
Definition: intersections.hh:168
FieldVector< ctype, GridImp::dimensionworld > unitOuterNormal(const FieldVector< ctype, GridImp::dimension-1 > &local) const
return unit outer normal
Definition: intersections.hh:233
bool boundary() const
return true if intersection is with boundary.
Definition: intersections.hh:98
GeometryType type() const
Geometry type of an intersection.
Definition: intersections.hh:152
bool equals(const MMeshLeafIntersection &other) const
returns true if the host entities are equal
Definition: intersections.hh:78
FieldVector< ctype, GridImp::dimensionworld > outerNormal(const FieldVector< ctype, GridImp::dimension-1 > &local) const
return outer normal
Definition: intersections.hh:196
std::size_t boundaryId() const
return the boundary id
Definition: intersections.hh:136
bool neighbor() const
return true if across the edge an neighbor on this level exists
Definition: intersections.hh:113
Geometry geometry() const
Definition: intersections.hh:177
int indexInOutside() const
local number of codim 1 entity in neighbor where intersection is contained
Definition: intersections.hh:188
int indexInInside() const
local number of codim 1 entity in self where intersection is contained in
Definition: intersections.hh:183
Entity inside() const
Definition: intersections.hh:85
LocalGeometry geometryInInside() const
Definition: intersections.hh:160
The MMeshLeafIterator class.
Helpers for conversion from CGAL::Point_x to DUNE::FieldVector.