9 #ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
10 #define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
14 #include <dune/geometry/affinegeometry.hh>
17 #define ONLY_SIMPLEX_INTERSECTIONS
23 template<
typename P0,
typename P1>
24 class IntersectionIndexSet;
29 template<
typename P0,
typename P1>
33 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
42 static const int dim0 = GridGlue::Grid0View::Grid::dimension - GridGlue::Grid0Patch::codim;
43 static const int dim1 = GridGlue::Grid1View::Grid::dimension - GridGlue::Grid1Patch::codim;
47 enum {
mydim = (dim0<dim1) ? dim0 : dim1 };
49 typedef AffineGeometry<typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension>
51 typedef AffineGeometry<typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld>
53 typedef AffineGeometry<typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension>
55 typedef AffineGeometry<typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld>
62 IntersectionData(
const GridGlue& glue,
unsigned int mergeindex,
unsigned int offset,
bool grid0local,
bool grid1local);
105 template<
typename P0,
typename P1>
107 bool grid0local,
bool grid1local)
108 : index_(mergeindex+offset),
109 grid0local_(grid0local),
110 grid1local_(grid1local)
112 unsigned int n_grid0Parents = glue.merger_->template parents<0>(mergeindex);
113 unsigned int n_grid1Parents = glue.merger_->template parents<1>(mergeindex);
115 assert (0 <= n_grid0Parents || 0 <= n_grid1Parents);
131 const int nSimplexCorners =
mydim + 1;
135 assert (0 <= mergeindex || mergeindex < glue.index__sz);
140 const int elementdim = GridGlue::Grid0View::template Codim<0>::Geometry::mydimension;
143 std::array<Dune::FieldVector<ctype, dim0>, nSimplexCorners> corners_subEntity_local;
145 for (
unsigned int par = 0; par < n_grid0Parents; ++par) {
146 for (
int i = 0; i < nSimplexCorners; ++i)
147 corners_subEntity_local[i] = glue.merger_->template parentLocal<0>(mergeindex, i, par);
150 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
154 grid0indices_[par] = glue.merger_->template parent<0>(mergeindex,par);
156 typename GridGlue::Grid0Patch::LocalGeometry
157 grid0LocalGeometry = glue.template patch<0>().geometryLocal(
grid0indices_[par]);
158 typename GridGlue::Grid0Patch::Geometry grid0WorldGeometry1 = glue.template patch<0>().geometry(
grid0indices_[par]);
159 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
160 corners_element_local[i] = grid0LocalGeometry.global(corners_subEntity_local[i]);
164 #ifdef ONLY_SIMPLEX_INTERSECTIONS
165 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
167 #error Not Implemented
169 grid0localgeom_[par] = std::make_shared<Grid0LocalGeometry>(type, corners_element_local);
173 typename GridGlue::Grid0Patch::Geometry
174 grid0WorldGeometry = glue.template patch<0>().geometry(
grid0indices_[par]);
177 std::array<Dune::FieldVector<ctype, GridGlue::Grid0View::dimensionworld>, nSimplexCorners> corners_global;
179 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
180 corners_global[i] = grid0WorldGeometry.global(corners_subEntity_local[i]);
183 grid0geom_ = std::make_shared<Grid0Geometry>(type, corners_global);
192 const int elementdim = GridGlue::Grid1View::template Codim<0>::Geometry::mydimension;
195 std::array<Dune::FieldVector<ctype, dim1>, nSimplexCorners> corners_subEntity_local;
197 for (
unsigned int par = 0; par < n_grid1Parents; ++par) {
199 for (
int i = 0; i < nSimplexCorners; ++i)
200 corners_subEntity_local[i] = glue.merger_->template parentLocal<1>(mergeindex, i, par);
203 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
207 grid1indices_[par] = glue.merger_->template parent<1>(mergeindex, par);
209 typename GridGlue::Grid1Patch::LocalGeometry
210 grid1LocalGeometry = glue.template patch<1>().geometryLocal(
grid1indices_[par]);
212 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
213 corners_element_local[i] = grid1LocalGeometry.global(corners_subEntity_local[i]);
217 #ifdef ONLY_SIMPLEX_INTERSECTIONS
218 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
220 #error Not Implemented
222 grid1localgeom_[par] = std::make_shared<Grid1LocalGeometry>(type, corners_element_local);
226 typename GridGlue::Grid1Patch::Geometry
227 grid1WorldGeometry = glue.template patch<1>().geometry(
grid1indices_[par]);
230 std::array<Dune::FieldVector<ctype, GridGlue::Grid1View::dimensionworld>, nSimplexCorners> corners_global;
232 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
233 corners_global[i] = grid1WorldGeometry.global(corners_subEntity_local[i]);
236 grid1geom_ = std::make_shared<Grid1Geometry>(type, corners_global);
247 template<
typename P0,
typename P1,
int P>
250 template<
typename P0,
typename P1>
278 template<
typename P0,
typename P1>
310 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
313 template<
typename P0,
typename P1>
316 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
339 template<
typename P0,
typename P1>
342 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
369 template<
typename P0,
typename P1,
int I,
int O>
389 typedef typename Traits::ctype
ctype;
391 typedef typename InsideGridView::Traits::template Codim<0>::Entity
InsideEntity;
392 typedef typename OutsideGridView::Traits::template Codim<0>::Entity
OutsideEntity;
422 glue_(glue), i_(i) {}
432 return glue_->template patch<I>().element(
442 return glue_->template patch<O>().element(
449 throw Dune::NotImplemented();
489 Dune::GeometryType
type()
const
491 #ifdef ONLY_SIMPLEX_INTERSECTIONS
492 static const Dune::GeometryType
type(Dune::GeometryType::simplex,
mydim);
495 #error Not Implemented
521 return glue_->template patch<I>().indexInInside(
529 return glue_->template patch<O>().indexInInside(
541 if (codimensionWorld == 0)
542 DUNE_THROW(Dune::Exception,
"There is no normal vector to a full-dimensional intersection");
543 else if (codimensionWorld == 1) {
545 const auto jacobianTransposed =
geometry().jacobianTransposed(local);
547 normal[0] = - jacobianTransposed[0][1];
548 normal[1] = jacobianTransposed[0][0];
549 }
else if (
mydim==2) {
550 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
551 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
552 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
554 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for " <<
mydim <<
"-dimensional intersections yet");
556 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
568 normal /= normal.two_norm();
598 #ifdef QUICKHACK_INDEX
601 IndexType index()
const
610 friend class IntersectionIndexSet<P0,P1>;
Central component of the module implementing the coupling of two grids.
Definition: gridglue.hh:30
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:93
unsigned int IndexType
Definition: gridglue.hh:151
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:142
PromotionTraits< typename Grid0View::ctype, typename Grid1View::ctype >::PromotedType ctype
The type used for coordinates.
Definition: gridglue.hh:175
@ dimworld
export the world dimension : maximum of the two extractor world dimensions
Definition: gridglue.hh:168
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:123
storage class for Dune::GridGlue::Intersection related data
Definition: intersection.hh:31
GridGlue::IndexType IndexType
Definition: intersection.hh:35
AffineGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld > Grid1Geometry
Definition: intersection.hh:56
@ mydim
Definition: intersection.hh:47
std::vector< Grid0IndexType > grid0indices_
indices of the associated local grid0 entity
Definition: intersection.hh:73
std::vector< std::shared_ptr< Grid0LocalGeometry > > grid0localgeom_
Definition: intersection.hh:80
GridGlue::Grid0View::IndexSet::IndexType Grid0IndexType
Definition: intersection.hh:58
AffineGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension > Grid0LocalGeometry
Definition: intersection.hh:50
std::shared_ptr< Grid0Geometry > grid0geom_
Definition: intersection.hh:88
bool grid1local_
true if the associated grid1 entity is local
Definition: intersection.hh:74
std::vector< Grid1IndexType > grid1indices_
indices of the associated local grid1 entity
Definition: intersection.hh:75
GridGlue::Grid1View::IndexSet::IndexType Grid1IndexType
Definition: intersection.hh:59
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:33
IntersectionData()
Default Constructor.
Definition: intersection.hh:65
@ coorddim
Definition: intersection.hh:38
std::shared_ptr< Grid1Geometry > grid1geom_
Definition: intersection.hh:100
AffineGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld > Grid0Geometry
Definition: intersection.hh:52
IndexType index_
index of this intersection after GridGlue interface
Definition: intersection.hh:70
bool grid0local_
true if the associated grid0 entity is local
Definition: intersection.hh:72
std::vector< std::shared_ptr< Grid1LocalGeometry > > grid1localgeom_
Definition: intersection.hh:92
AffineGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension > Grid1LocalGeometry
Definition: intersection.hh:54
The intersection of two entities of the two patches of a GridGlue.
Definition: intersection.hh:371
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition: intersection.hh:385
bool conforming() const
Return true if intersection is conforming.
Definition: intersection.hh:447
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition: intersection.hh:391
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition: intersection.hh:593
Traits::GridGlue GridGlue
Definition: intersection.hh:377
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in.
Definition: intersection.hh:526
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:518
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition: intersection.hh:483
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() element.
Definition: intersection.hh:454
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition: intersection.hh:489
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition: intersection.hh:429
Traits::LocalCoordinate LocalCoordinate
Definition: intersection.hh:394
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return a unit outer normal.
Definition: intersection.hh:565
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() element.
Definition: intersection.hh:461
Traits::ctype ctype
Definition: intersection.hh:389
IntersectionTraits< P0, P1, I, O > Traits
Definition: intersection.hh:375
Traits::IntersectionData IntersectionData
Definition: intersection.hh:378
Traits::GlobalCoordinate GlobalCoordinate
Definition: intersection.hh:395
@ insidePatch
document the inside & outside patch
Definition: intersection.hh:404
@ outsidePatch
Definition: intersection.hh:405
@ coorddim
Dimension of the world space of the intersection.
Definition: intersection.hh:399
@ mydim
Dimension of the intersection.
Definition: intersection.hh:401
Traits::OutsideGeometry OutsideGeometry
Definition: intersection.hh:386
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition: intersection.hh:507
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition: intersection.hh:421
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition: intersection.hh:472
Traits::Geometry Geometry
Definition: intersection.hh:388
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition: intersection.hh:392
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition: intersection.hh:439
Traits::InsideLocalGeometry InsideLocalGeometry
Definition: intersection.hh:382
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: intersection.hh:537
Traits::OutsideGridView OutsideGridView
Definition: intersection.hh:384
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
Return an outer normal with the length of the integration element.
Definition: intersection.hh:576
Traits::InsideGridView InsideGridView
Definition: intersection.hh:381
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition: intersection.hh:585
Definition: intersection.hh:248
const IntersectionData< P0, P1 >::Grid0Geometry Geometry
Definition: intersection.hh:254
static bool local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:264
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:272
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:268
const IntersectionData< P0, P1 >::Grid0IndexType IndexType
Definition: intersection.hh:255
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:260
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:256
const IntersectionData< P0, P1 >::Grid0LocalGeometry LocalGeometry
Definition: intersection.hh:253
const IntersectionData< P0, P1 >::Grid1Geometry Geometry
Definition: intersection.hh:282
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:300
const IntersectionData< P0, P1 >::Grid1LocalGeometry LocalGeometry
Definition: intersection.hh:281
static IndexType local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:292
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:284
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:288
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:296
const IntersectionData< P0, P1 >::Grid1IndexType IndexType
Definition: intersection.hh:283
Definition: intersection.hh:311
const IntersectionData::Grid0Geometry Geometry
Definition: intersection.hh:324
const IntersectionData::Grid1Geometry OutsideGeometry
Definition: intersection.hh:325
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:335
const IntersectionData::Grid0LocalGeometry InsideLocalGeometry
Definition: intersection.hh:322
const IntersectionData::Grid1LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:323
GridGlue::Grid1View OutsideGridView
Definition: intersection.hh:320
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:336
GridGlue::ctype ctype
Definition: intersection.hh:334
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:316
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:317
GridGlue::Grid0View InsideGridView
Definition: intersection.hh:319
GridGlue::Grid0View OutsideGridView
Definition: intersection.hh:346
const IntersectionData::Grid0Geometry OutsideGeometry
Definition: intersection.hh:351
GridGlue::ctype ctype
Definition: intersection.hh:362
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:364
const IntersectionData::Grid0LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:349
const IntersectionData::Grid1Geometry Geometry
Definition: intersection.hh:350
GridGlue::Grid1View InsideGridView
Definition: intersection.hh:345
const IntersectionData::Grid1LocalGeometry InsideLocalGeometry
Definition: intersection.hh:348
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:363
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:343
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:342
const IntersectionData::Grid1IndexType InsideIndexType
Definition: intersection.hh:352
const IntersectionData::Grid0IndexType OutsideIndexType
Definition: intersection.hh:353