9 #ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
10 #define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
12 #include <dune/common/version.hh>
14 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
15 #include <dune/geometry/affinegeometry.hh>
21 #define ONLY_SIMPLEX_INTERSECTIONS
27 template<
typename P0,
typename P1>
28 class IntersectionIndexSet;
33 template<
typename P0,
typename P1>
34 class IntersectionData
37 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
46 static const int dim1 = GridGlue::Grid0View::Grid::dimension - GridGlue::Grid0Patch::codim;
47 static const int dim2 = GridGlue::Grid1View::Grid::dimension - GridGlue::Grid1Patch::codim;
51 enum {
mydim = (dim1<dim2) ? dim1 : dim2 };
53 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
54 typedef AffineGeometry<typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension>
56 typedef AffineGeometry<typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld>
58 typedef AffineGeometry<typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension>
60 typedef AffineGeometry<typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld>
77 IntersectionData(
const GridGlue& glue,
unsigned int mergeindex,
unsigned int offset,
bool grid0local,
bool grid1local);
100 template<
typename P0,
typename P1>
102 bool grid0local,
bool grid1local)
103 :
index_(mergeindex+offset),
107 unsigned int n_grid0Parents = glue.merger_->template parents<0>(mergeindex);
108 unsigned int n_grid1Parents = glue.merger_->template parents<1>(mergeindex);
110 assert (0 <= n_grid0Parents || 0 <= n_grid1Parents);
126 const int nSimplexCorners =
mydim + 1;
130 assert (0 <= mergeindex || mergeindex < glue.index__sz);
135 const int elementdim = GridGlue::Grid0View::template Codim<0>::Geometry::mydimension;
138 Dune::array<Dune::FieldVector<ctype, dim1>, nSimplexCorners> corners_subEntity_local;
140 for (
unsigned int par = 0; par < n_grid0Parents; ++par) {
141 for (
int i = 0; i < nSimplexCorners; ++i)
142 corners_subEntity_local[i] = glue.merger_->template parentLocal<0>(mergeindex, i, par);
145 Dune::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
149 grid0indices_[par] = glue.merger_->template parent<0>(mergeindex,par);
151 typename GridGlue::Grid0Patch::LocalGeometry
152 grid0LocalGeometry = glue.template patch<0>().geometryLocal(
grid0indices_[par]);
153 typename GridGlue::Grid0Patch::Geometry grid0WorldGeometry1 = glue.template patch<0>().geometry(
grid0indices_[par]);
154 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
155 corners_element_local[i] = grid0LocalGeometry.global(corners_subEntity_local[i]);
159 #ifdef ONLY_SIMPLEX_INTERSECTIONS
160 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
162 #error Not Implemented
164 grid0localgeom_[par] = make_shared<Grid0LocalGeometry>(type, corners_element_local);
168 typename GridGlue::Grid0Patch::Geometry
169 grid0WorldGeometry = glue.template patch<0>().geometry(
grid0indices_[par]);
172 Dune::array<Dune::FieldVector<ctype, GridGlue::Grid0View::dimensionworld>, nSimplexCorners> corners_global;
174 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
175 corners_global[i] = grid0WorldGeometry.global(corners_subEntity_local[i]);
178 grid0geom_ = make_shared<Grid0Geometry>(type, corners_global);
187 const int elementdim = GridGlue::Grid1View::template Codim<0>::Geometry::mydimension;
190 Dune::array<Dune::FieldVector<ctype, dim2>, nSimplexCorners> corners_subEntity_local;
192 for (
unsigned int par = 0; par < n_grid1Parents; ++par) {
194 for (
int i = 0; i < nSimplexCorners; ++i)
195 corners_subEntity_local[i] = glue.merger_->template parentLocal<1>(mergeindex, i, par);
198 Dune::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
202 grid1indices_[par] = glue.merger_->template parent<1>(mergeindex, par);
204 typename GridGlue::Grid1Patch::LocalGeometry
205 grid1LocalGeometry = glue.template patch<1>().geometryLocal(
grid1indices_[par]);
207 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
208 corners_element_local[i] = grid1LocalGeometry.global(corners_subEntity_local[i]);
212 #ifdef ONLY_SIMPLEX_INTERSECTIONS
213 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
215 #error Not Implemented
217 grid1localgeom_[par] = make_shared<Grid1LocalGeometry>(type, corners_element_local);
221 typename GridGlue::Grid1Patch::Geometry
222 grid1WorldGeometry = glue.template patch<1>().geometry(
grid1indices_[par]);
225 Dune::array<Dune::FieldVector<ctype, GridGlue::Grid1View::dimensionworld>, nSimplexCorners> corners_global;
227 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
228 corners_global[i] = grid1WorldGeometry.global(corners_subEntity_local[i]);
231 grid1geom_ = make_shared<Grid1Geometry>(type, corners_global);
242 template<
typename P0,
typename P1,
int P>
245 template<
typename P0,
typename P1>
253 return *i.grid0localgeom_[parentId];
257 return *i.grid0geom_;
261 return i.grid0local_;
265 return i.grid0indices_[parentId];
269 return i.grid0indices_.size();
273 template<
typename P0,
typename P1>
281 return *i.grid1localgeom_[parentId];
285 return *i.grid1geom_;
289 return i.grid1local_;
293 return i.grid1indices_[parentId];
297 return i.grid1indices_.size();
305 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
308 template<
typename P0,
typename P1>
311 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
334 template<
typename P0,
typename P1>
337 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
364 template<
typename P0,
typename P1,
int I,
int O>
384 typedef typename Traits::ctype
ctype;
386 typedef typename InsideGridView::Traits::template Codim<0>::Entity
InsideEntity;
389 typedef typename OutsideGridView::Traits::template Codim<0>::Entity
OutsideEntity;
413 glue_(glue), i_(i) {}
419 InsideEntityPointer
inside(
unsigned int parentId = 0)
const
422 return glue_->template patch<I>().element(
428 OutsideEntityPointer
outside(
unsigned int parentId = 0)
const
431 return glue_->template patch<O>().element(
438 assert(
false &&
"not implemented");
470 Dune::GeometryType
type()
const
472 #ifdef ONLY_SIMPLEX_INTERSECTIONS
473 static const Dune::GeometryType
type(Dune::GeometryType::simplex,
mydim);
476 #error Not Implemented
515 GlobalCoordinate
outerNormal(
const Dune::FieldVector<ctype, mydim> &local)
const
517 Dune::FieldVector<ctype, coorddim> normal;
522 if (codimension == 0)
524 DUNE_THROW(Dune::Exception,
"There is no normal vector to a full-dimensional intersection");
526 else if (codimension == 1) {
529 FieldMatrix<ctype, mydim,coorddim> jacobianTransposed =
geometry().jacobianTransposed(local);
531 normal[0] = - jacobianTransposed[0][1];
532 normal[1] = jacobianTransposed[0][0];
533 }
else if (mydim==2) {
534 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
535 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
536 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
538 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for " << mydim <<
"-dimensional intersections yet");
541 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
549 Dune::FieldVector<ctype, coorddim> normal =
outerNormal(local);
550 normal /= normal.two_norm();
566 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
569 return unitOuterNormal(GenericReferenceElements<ctype,mydim>::general(
type()).position(0,0));
578 #ifdef QUICKHACK_INDEX
581 IndexType index()
const
595 const GridGlue* glue_;
598 const IntersectionData* i_;
605 #endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
IntersectionTraits< P0, P1, I, O > Traits
Definition: intersection.hh:370
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:255
const IntersectionData< P0, P1 >::Grid0LocalGeometry LocalGeometry
Definition: intersection.hh:248
GridGlue::Grid1View OutsideGridView
Definition: intersection.hh:315
Dimension of the world space of the intersection.
Definition: intersection.hh:397
std::vector< Grid0IndexType > grid0indices_
indices of the associated local grid0 entity
Definition: intersection.hh:88
Traits::IntersectionData IntersectionData
Definition: intersection.hh:373
Dimension of the intersection.
Definition: intersection.hh:399
static bool local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:259
GridGlue::Grid0View OutsideGridView
Definition: intersection.hh:341
const IntersectionData::Grid1IndexType InsideIndexType
Definition: intersection.hh:347
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:127
Definition: intersection.hh:42
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:48
std::vector< shared_ptr< Grid0LocalGeometry > > grid0localgeom_
Definition: intersection.hh:92
Traits::OutsideGeometry OutsideGeometry
Definition: intersection.hh:381
Traits::LocalCoordinate LocalCoordinate
Definition: intersection.hh:392
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:330
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition: intersection.hh:470
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() entity...
Definition: intersection.hh:443
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:295
bool conforming() const
Return true if intersection is conforming.
Definition: intersection.hh:436
GridGlue::Grid1View::IndexSet::IndexType Grid1IndexType
Definition: intersection.hh:74
Traits::GlobalCoordinate GlobalCoordinate
Definition: intersection.hh:393
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:499
This class is derived from BasicGeometry using tuned geometry traits.
Definition: simplexgeometry.hh:61
const IntersectionData::Grid1LocalGeometry InsideLocalGeometry
Definition: intersection.hh:343
const IntersectionData::Grid0Geometry OutsideGeometry
Definition: intersection.hh:346
const IntersectionData::Grid1LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:318
const IntersectionData< P0, P1 >::Grid0Geometry Geometry
Definition: intersection.hh:249
const IntersectionData< P0, P1 >::Grid1LocalGeometry LocalGeometry
Definition: intersection.hh:276
const IntersectionData::Grid0IndexType OutsideIndexType
Definition: intersection.hh:348
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition: intersection.hh:457
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:251
Traits::InsideLocalGeometry InsideLocalGeometry
Definition: intersection.hh:377
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition: intersection.hh:464
shared_ptr< Grid1Geometry > grid1geom_
Definition: intersection.hh:95
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:267
const IntersectionData< P0, P1 >::Grid0IndexType IndexType
Definition: intersection.hh:250
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:37
Definition: gridglue.hh:34
shared_ptr< Grid0Geometry > grid0geom_
Definition: intersection.hh:93
bool grid0local_
true if the associated grid0 entity is local
Definition: intersection.hh:87
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:151
SimplexGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld > Grid0Geometry
Definition: intersection.hh:66
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition: intersection.hh:412
InsideEntityPointer inside(unsigned int parentId=0) const
Return EntityPointer to the Entity on the inside of this intersection.
Definition: intersection.hh:419
const IntersectionData::Grid1Geometry Geometry
Definition: intersection.hh:345
document the inside & outside patch
Definition: intersection.hh:402
Traits::InsideGridView InsideGridView
Definition: intersection.hh:376
GridGlue::Grid1View InsideGridView
Definition: intersection.hh:340
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:263
const IntersectionData::Grid1Geometry OutsideGeometry
Definition: intersection.hh:320
GridGlue::Grid0View InsideGridView
Definition: intersection.hh:314
const IntersectionData::Grid0LocalGeometry InsideLocalGeometry
Definition: intersection.hh:317
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:338
Central component of the module implementing the coupling of two grids.
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in...
Definition: intersection.hh:507
GlobalCoordinate unitOuterNormal(const Dune::FieldVector< ctype, mydim > &local) const
Return a unit outer normal.
Definition: intersection.hh:547
std::vector< Grid1IndexType > grid1indices_
indices of the associated local grid1 entity
Definition: intersection.hh:90
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition: intersection.hh:386
size_t neighbor(unsigned int g=0) const
For parallel computations: Return true if outside() entity exists locally.
Definition: intersection.hh:488
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:291
const IntersectionData< P0, P1 >::Grid1IndexType IndexType
Definition: intersection.hh:278
Grid0View::ctype ctype
The type used for coordinates.
Definition: gridglue.hh:189
Definition: intersection.hh:51
OutsideEntityPointer outside(unsigned int parentId=0) const
Return EntityPointer to the Entity on the outside of this intersection.
Definition: intersection.hh:428
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition: intersection.hh:380
Intersection< P0, P1, O, I > flip() const
Definition: intersection.hh:573
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() entity...
Definition: intersection.hh:450
const IntersectionData::Grid0Geometry Geometry
Definition: intersection.hh:319
SimplexGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension > Grid0LocalGeometry
Definition: intersection.hh:64
SimplexGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension > Grid1LocalGeometry
Definition: intersection.hh:68
InsideGridView::Traits::template Codim< 0 >::EntityPointer InsideEntityPointer
Definition: intersection.hh:387
GridGlue::ctype ctype
Definition: intersection.hh:329
export the world dimension : maximum of the two extractor world dimensions
Definition: gridglue.hh:182
Traits::GridGlue GridGlue
Definition: intersection.hh:372
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:312
GlobalCoordinate outerNormal(const Dune::FieldVector< ctype, mydim > &local) const
Return an outer normal (length not necessarily 1)
Definition: intersection.hh:515
GridGlue::ctype ctype
Definition: intersection.hh:357
GridGlue::IndexType IndexType
Definition: intersection.hh:39
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:51
static IndexType local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:287
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:279
OutsideGridView::Traits::template Codim< 0 >::EntityPointer OutsideEntityPointer
Definition: intersection.hh:390
GlobalCoordinate integrationOuterNormal(const Dune::FieldVector< ctype, mydim > &local) const
Return an outer normal with the length of the integration element.
Definition: intersection.hh:555
const IntersectionData::Grid0LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:344
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:311
SimplexGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld > Grid1Geometry
Definition: intersection.hh:70
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:283
Traits::OutsideGridView OutsideGridView
Definition: intersection.hh:379
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:331
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:358
Definition: intersection.hh:306
Definition: gridglue.hh:57
Traits::Geometry Geometry
Definition: intersection.hh:383
contains customized geometry implementations for simplices
bool grid1local_
true if the associated grid1 entity is local
Definition: intersection.hh:89
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition: intersection.hh:389
const IntersectionData< P0, P1 >::Grid1Geometry Geometry
Definition: intersection.hh:277
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition: intersection.hh:564
Definition: intersection.hh:243
Definition: intersection.hh:403
Traits::ctype ctype
Definition: intersection.hh:384
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:337
unsigned int IndexType
Definition: gridglue.hh:165
GridGlue::Grid0View::IndexSet::IndexType Grid0IndexType
Definition: intersection.hh:73
std::vector< shared_ptr< Grid1LocalGeometry > > grid1localgeom_
Definition: intersection.hh:94
IntersectionData()
Default Constructor.
Definition: intersection.hh:80
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:359
IndexType index_
index of this intersection after GridGlue interface
Definition: intersection.hh:85