9 #ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
10 #define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
14 #include <dune/common/version.hh>
16 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
17 #include <dune/geometry/affinegeometry.hh>
23 #define ONLY_SIMPLEX_INTERSECTIONS
29 template<
typename P0,
typename P1>
30 class IntersectionIndexSet;
35 template<
typename P0,
typename P1>
36 class IntersectionData
39 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
48 static const int dim0 = GridGlue::Grid0View::Grid::dimension - GridGlue::Grid0Patch::codim;
49 static const int dim1 = GridGlue::Grid1View::Grid::dimension - GridGlue::Grid1Patch::codim;
53 enum {
mydim = (dim0<dim1) ? dim0 : dim1 };
55 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
56 typedef AffineGeometry<typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension>
58 typedef AffineGeometry<typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld>
60 typedef AffineGeometry<typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension>
62 typedef AffineGeometry<typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld>
79 IntersectionData(
const GridGlue& glue,
unsigned int mergeindex,
unsigned int offset,
bool grid0local,
bool grid1local);
122 template<
typename P0,
typename P1>
124 bool grid0local,
bool grid1local)
125 :
index_(mergeindex+offset),
129 unsigned int n_grid0Parents = glue.merger_->template parents<0>(mergeindex);
130 unsigned int n_grid1Parents = glue.merger_->template parents<1>(mergeindex);
132 assert (0 <= n_grid0Parents || 0 <= n_grid1Parents);
148 const int nSimplexCorners =
mydim + 1;
152 assert (0 <= mergeindex || mergeindex < glue.index__sz);
157 const int elementdim = GridGlue::Grid0View::template Codim<0>::Geometry::mydimension;
160 std::array<Dune::FieldVector<ctype, dim0>, nSimplexCorners> corners_subEntity_local;
162 for (
unsigned int par = 0; par < n_grid0Parents; ++par) {
163 for (
int i = 0; i < nSimplexCorners; ++i)
164 corners_subEntity_local[i] = glue.merger_->template parentLocal<0>(mergeindex, i, par);
167 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
171 grid0indices_[par] = glue.merger_->template parent<0>(mergeindex,par);
173 typename GridGlue::Grid0Patch::LocalGeometry
174 grid0LocalGeometry = glue.template patch<0>().geometryLocal(
grid0indices_[par]);
175 typename GridGlue::Grid0Patch::Geometry grid0WorldGeometry1 = glue.template patch<0>().geometry(
grid0indices_[par]);
176 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
177 corners_element_local[i] = grid0LocalGeometry.global(corners_subEntity_local[i]);
181 #ifdef ONLY_SIMPLEX_INTERSECTIONS
182 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
184 #error Not Implemented
186 grid0localgeom_[par] = make_shared<Grid0LocalGeometry>(type, corners_element_local);
190 typename GridGlue::Grid0Patch::Geometry
191 grid0WorldGeometry = glue.template patch<0>().geometry(
grid0indices_[par]);
194 std::array<Dune::FieldVector<ctype, GridGlue::Grid0View::dimensionworld>, nSimplexCorners> corners_global;
196 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
197 corners_global[i] = grid0WorldGeometry.global(corners_subEntity_local[i]);
200 grid0geom_ = make_shared<Grid0Geometry>(type, corners_global);
209 const int elementdim = GridGlue::Grid1View::template Codim<0>::Geometry::mydimension;
212 std::array<Dune::FieldVector<ctype, dim1>, nSimplexCorners> corners_subEntity_local;
214 for (
unsigned int par = 0; par < n_grid1Parents; ++par) {
216 for (
int i = 0; i < nSimplexCorners; ++i)
217 corners_subEntity_local[i] = glue.merger_->template parentLocal<1>(mergeindex, i, par);
220 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
224 grid1indices_[par] = glue.merger_->template parent<1>(mergeindex, par);
226 typename GridGlue::Grid1Patch::LocalGeometry
227 grid1LocalGeometry = glue.template patch<1>().geometryLocal(
grid1indices_[par]);
229 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
230 corners_element_local[i] = grid1LocalGeometry.global(corners_subEntity_local[i]);
234 #ifdef ONLY_SIMPLEX_INTERSECTIONS
235 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
237 #error Not Implemented
239 grid1localgeom_[par] = make_shared<Grid1LocalGeometry>(type, corners_element_local);
243 typename GridGlue::Grid1Patch::Geometry
244 grid1WorldGeometry = glue.template patch<1>().geometry(
grid1indices_[par]);
247 std::array<Dune::FieldVector<ctype, GridGlue::Grid1View::dimensionworld>, nSimplexCorners> corners_global;
249 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
250 corners_global[i] = grid1WorldGeometry.global(corners_subEntity_local[i]);
253 grid1geom_ = make_shared<Grid1Geometry>(type, corners_global);
264 template<
typename P0,
typename P1,
int P>
267 template<
typename P0,
typename P1>
275 return *i.grid0localgeom_[parentId];
279 return *i.grid0geom_;
283 return i.grid0local_;
287 return i.grid0indices_[parentId];
291 return i.grid0indices_.size();
295 template<
typename P0,
typename P1>
303 return *i.grid1localgeom_[parentId];
307 return *i.grid1geom_;
311 return i.grid1local_;
315 return i.grid1indices_[parentId];
319 return i.grid1indices_.size();
327 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
330 template<
typename P0,
typename P1>
333 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
356 template<
typename P0,
typename P1>
359 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
386 template<
typename P0,
typename P1,
int I,
int O>
406 typedef typename Traits::ctype
ctype;
408 typedef typename InsideGridView::Traits::template Codim<0>::Entity
InsideEntity;
411 typedef typename OutsideGridView::Traits::template Codim<0>::Entity
OutsideEntity;
442 glue_(glue), i_(i) {}
448 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) || DOXYGEN
456 return glue_->template patch<I>().element(
462 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) || DOXYGEN
470 return glue_->template patch<O>().element(
477 throw Dune::NotImplemented();
517 Dune::GeometryType
type()
const
519 #ifdef ONLY_SIMPLEX_INTERSECTIONS
520 static const Dune::GeometryType
type(Dune::GeometryType::simplex, mydim);
523 #error Not Implemented
567 GlobalCoordinate normal;
569 if (codimensionWorld == 0)
570 DUNE_THROW(Dune::Exception,
"There is no normal vector to a full-dimensional intersection");
571 else if (codimensionWorld == 1) {
573 const auto jacobianTransposed =
geometry().jacobianTransposed(local);
575 normal[0] = - jacobianTransposed[0][1];
576 normal[1] = jacobianTransposed[0][0];
577 }
else if (mydim==2) {
578 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
579 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
580 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
582 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for " << mydim <<
"-dimensional intersections yet");
584 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
596 normal /= normal.two_norm();
615 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
618 return unitOuterNormal(GenericReferenceElements<ctype,mydim>::general(
type()).position(0,0));
630 #ifdef QUICKHACK_INDEX
633 IndexType index()
const
647 const GridGlue* glue_;
650 const IntersectionData* i_;
657 #endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:50
const IntersectionData< P0, P1 >::Grid1Geometry Geometry
Definition: intersection.hh:299
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:273
std::vector< shared_ptr< Grid0LocalGeometry > > grid0localgeom_
Definition: intersection.hh:97
InsideGridView::Traits::template Codim< 0 >::EntityPointer InsideEntityPointer
Definition: intersection.hh:409
bool grid0local_
true if the associated grid0 entity is local
Definition: intersection.hh:89
const IntersectionData::Grid0Geometry Geometry
Definition: intersection.hh:341
GridGlue::Grid0View OutsideGridView
Definition: intersection.hh:363
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:277
Definition: intersection.hh:265
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition: intersection.hh:517
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:150
GridGlue::Grid1View OutsideGridView
Definition: intersection.hh:337
GridGlue::Grid0View::IndexSet::IndexType Grid0IndexType
Definition: intersection.hh:75
Traits::IntersectionData IntersectionData
Definition: intersection.hh:395
Traits::GridGlue GridGlue
Definition: intersection.hh:394
Definition: gridglue.hh:56
std::vector< shared_ptr< Grid1LocalGeometry > > grid1localgeom_
Definition: intersection.hh:109
GridGlue::ctype ctype
Definition: intersection.hh:379
Dimension of the world space of the intersection.
Definition: intersection.hh:419
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:305
Definition: gridglue.hh:33
Traits::Geometry Geometry
Definition: intersection.hh:405
Traits::OutsideGeometry OutsideGeometry
Definition: intersection.hh:403
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:39
shared_ptr< Grid0Geometry > grid0geom_
Definition: intersection.hh:105
Definition: intersection.hh:53
std::vector< Grid0IndexType > grid0indices_
indices of the associated local grid0 entity
Definition: intersection.hh:90
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:353
static bool local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:281
shared_ptr< Grid1Geometry > grid1geom_
Definition: intersection.hh:117
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:380
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:360
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:289
Grid0View::ctype ctype
The type used for coordinates.
Definition: gridglue.hh:188
Traits::ctype ctype
Definition: intersection.hh:406
document the inside & outside patch
Definition: intersection.hh:424
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() element...
Definition: intersection.hh:489
SimplexGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld > Grid0Geometry
Definition: intersection.hh:68
GridGlue::Grid1View::IndexSet::IndexType Grid1IndexType
Definition: intersection.hh:76
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition: intersection.hh:411
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:333
const IntersectionData::Grid1IndexType InsideIndexType
Definition: intersection.hh:369
const IntersectionData::Grid1LocalGeometry InsideLocalGeometry
Definition: intersection.hh:365
Dimension of the intersection.
Definition: intersection.hh:421
std::vector< Grid1IndexType > grid1indices_
indices of the associated local grid1 entity
Definition: intersection.hh:92
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:285
const IntersectionData< P0, P1 >::Grid1LocalGeometry LocalGeometry
Definition: intersection.hh:298
const IntersectionData::Grid0IndexType OutsideIndexType
Definition: intersection.hh:370
const IntersectionData< P0, P1 >::Grid0Geometry Geometry
Definition: intersection.hh:271
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:47
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition: intersection.hh:535
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() element...
Definition: intersection.hh:482
const IntersectionData< P0, P1 >::Grid1IndexType IndexType
Definition: intersection.hh:300
const IntersectionData::Grid1LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:340
const IntersectionData::Grid0Geometry OutsideGeometry
Definition: intersection.hh:368
static IndexType local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:309
contains customized geometry implementations for simplices
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:301
const IntersectionData< P0, P1 >::Grid0IndexType IndexType
Definition: intersection.hh:272
GridGlue::Grid1View InsideGridView
Definition: intersection.hh:362
export the world dimension : maximum of the two extractor world dimensions
Definition: gridglue.hh:181
SimplexGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension > Grid0LocalGeometry
Definition: intersection.hh:66
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:334
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:317
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return a unit outer normal.
Definition: intersection.hh:593
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition: intersection.hh:408
Definition: intersection.hh:328
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
Return an outer normal with the length of the integration element.
Definition: intersection.hh:604
Traits::InsideGridView InsideGridView
Definition: intersection.hh:398
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in...
Definition: intersection.hh:554
Traits::OutsideGridView OutsideGridView
Definition: intersection.hh:401
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition: intersection.hh:625
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition: intersection.hh:613
GridGlue::IndexType IndexType
Definition: intersection.hh:41
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:352
unsigned int IndexType
Definition: gridglue.hh:164
const IntersectionData::Grid1Geometry OutsideGeometry
Definition: intersection.hh:342
GridGlue::Grid0View InsideGridView
Definition: intersection.hh:336
Definition: intersection.hh:44
OutsideGridView::Traits::template Codim< 0 >::EntityPointer OutsideEntityPointer
Definition: intersection.hh:412
const IntersectionData::Grid1Geometry Geometry
Definition: intersection.hh:367
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition: intersection.hh:467
SimplexGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld > Grid1Geometry
Definition: intersection.hh:72
const IntersectionData< P0, P1 >::Grid0LocalGeometry LocalGeometry
Definition: intersection.hh:270
SimplexGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension > Grid1LocalGeometry
Definition: intersection.hh:70
IntersectionTraits< P0, P1, I, O > Traits
Definition: intersection.hh:392
bool conforming() const
Return true if intersection is conforming.
Definition: intersection.hh:475
Central component of the module implementing the coupling of two grids.
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:313
GridGlue::ctype ctype
Definition: intersection.hh:351
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition: intersection.hh:441
bool grid1local_
true if the associated grid1 entity is local
Definition: intersection.hh:91
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition: intersection.hh:500
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:381
Traits::InsideLocalGeometry InsideLocalGeometry
Definition: intersection.hh:399
Traits::GlobalCoordinate GlobalCoordinate
Definition: intersection.hh:415
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition: intersection.hh:511
const IntersectionData::Grid0LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:366
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition: intersection.hh:402
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:126
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition: intersection.hh:453
Definition: intersection.hh:425
const IntersectionData::Grid0LocalGeometry InsideLocalGeometry
Definition: intersection.hh:339
IndexType index_
index of this intersection after GridGlue interface
Definition: intersection.hh:87
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: intersection.hh:565
int indexInInside(unsigned int parentId=0) const
Local number of codim 1 entity in the inside() Entity where intersection is contained in...
Definition: intersection.hh:546
This class is derived from BasicGeometry using tuned geometry traits.
Definition: simplexgeometry.hh:61
IntersectionData()
Default Constructor.
Definition: intersection.hh:82
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:359
Traits::LocalCoordinate LocalCoordinate
Definition: intersection.hh:414