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 dim1 = GridGlue::Grid0View::Grid::dimension - GridGlue::Grid0Patch::codim;
49 static const int dim2 = GridGlue::Grid1View::Grid::dimension - GridGlue::Grid1Patch::codim;
53 enum {
mydim = (dim1<dim2) ? dim1 : dim2 };
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);
102 template<
typename P0,
typename P1>
104 bool grid0local,
bool grid1local)
105 :
index_(mergeindex+offset),
109 unsigned int n_grid0Parents = glue.merger_->template parents<0>(mergeindex);
110 unsigned int n_grid1Parents = glue.merger_->template parents<1>(mergeindex);
112 assert (0 <= n_grid0Parents || 0 <= n_grid1Parents);
128 const int nSimplexCorners =
mydim + 1;
132 assert (0 <= mergeindex || mergeindex < glue.index__sz);
137 const int elementdim = GridGlue::Grid0View::template Codim<0>::Geometry::mydimension;
140 std::array<Dune::FieldVector<ctype, dim1>, nSimplexCorners> corners_subEntity_local;
142 for (
unsigned int par = 0; par < n_grid0Parents; ++par) {
143 for (
int i = 0; i < nSimplexCorners; ++i)
144 corners_subEntity_local[i] = glue.merger_->template parentLocal<0>(mergeindex, i, par);
147 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
151 grid0indices_[par] = glue.merger_->template parent<0>(mergeindex,par);
153 typename GridGlue::Grid0Patch::LocalGeometry
154 grid0LocalGeometry = glue.template patch<0>().geometryLocal(
grid0indices_[par]);
155 typename GridGlue::Grid0Patch::Geometry grid0WorldGeometry1 = glue.template patch<0>().geometry(
grid0indices_[par]);
156 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
157 corners_element_local[i] = grid0LocalGeometry.global(corners_subEntity_local[i]);
161 #ifdef ONLY_SIMPLEX_INTERSECTIONS
162 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
164 #error Not Implemented
166 grid0localgeom_[par] = make_shared<Grid0LocalGeometry>(type, corners_element_local);
170 typename GridGlue::Grid0Patch::Geometry
171 grid0WorldGeometry = glue.template patch<0>().geometry(
grid0indices_[par]);
174 std::array<Dune::FieldVector<ctype, GridGlue::Grid0View::dimensionworld>, nSimplexCorners> corners_global;
176 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
177 corners_global[i] = grid0WorldGeometry.global(corners_subEntity_local[i]);
180 grid0geom_ = make_shared<Grid0Geometry>(type, corners_global);
189 const int elementdim = GridGlue::Grid1View::template Codim<0>::Geometry::mydimension;
192 std::array<Dune::FieldVector<ctype, dim2>, nSimplexCorners> corners_subEntity_local;
194 for (
unsigned int par = 0; par < n_grid1Parents; ++par) {
196 for (
int i = 0; i < nSimplexCorners; ++i)
197 corners_subEntity_local[i] = glue.merger_->template parentLocal<1>(mergeindex, i, par);
200 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
204 grid1indices_[par] = glue.merger_->template parent<1>(mergeindex, par);
206 typename GridGlue::Grid1Patch::LocalGeometry
207 grid1LocalGeometry = glue.template patch<1>().geometryLocal(
grid1indices_[par]);
209 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
210 corners_element_local[i] = grid1LocalGeometry.global(corners_subEntity_local[i]);
214 #ifdef ONLY_SIMPLEX_INTERSECTIONS
215 Dune::GeometryType type(Dune::GeometryType::simplex,
mydim);
217 #error Not Implemented
219 grid1localgeom_[par] = make_shared<Grid1LocalGeometry>(type, corners_element_local);
223 typename GridGlue::Grid1Patch::Geometry
224 grid1WorldGeometry = glue.template patch<1>().geometry(
grid1indices_[par]);
227 std::array<Dune::FieldVector<ctype, GridGlue::Grid1View::dimensionworld>, nSimplexCorners> corners_global;
229 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
230 corners_global[i] = grid1WorldGeometry.global(corners_subEntity_local[i]);
233 grid1geom_ = make_shared<Grid1Geometry>(type, corners_global);
244 template<
typename P0,
typename P1,
int P>
247 template<
typename P0,
typename P1>
255 return *i.grid0localgeom_[parentId];
259 return *i.grid0geom_;
263 return i.grid0local_;
267 return i.grid0indices_[parentId];
271 return i.grid0indices_.size();
275 template<
typename P0,
typename P1>
283 return *i.grid1localgeom_[parentId];
287 return *i.grid1geom_;
291 return i.grid1local_;
295 return i.grid1indices_[parentId];
299 return i.grid1indices_.size();
307 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
310 template<
typename P0,
typename P1>
313 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
336 template<
typename P0,
typename P1>
339 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
366 template<
typename P0,
typename P1,
int I,
int O>
386 typedef typename Traits::ctype
ctype;
388 typedef typename InsideGridView::Traits::template Codim<0>::Entity
InsideEntity;
391 typedef typename OutsideGridView::Traits::template Codim<0>::Entity
OutsideEntity;
415 glue_(glue), i_(i) {}
421 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) || DOXYGEN
429 return glue_->template patch<I>().element(
435 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 4) || DOXYGEN
443 return glue_->template patch<O>().element(
450 throw Dune::NotImplemented();
482 Dune::GeometryType
type()
const
484 #ifdef ONLY_SIMPLEX_INTERSECTIONS
485 static const Dune::GeometryType
type(Dune::GeometryType::simplex,
mydim);
488 #error Not Implemented
527 GlobalCoordinate
outerNormal(
const Dune::FieldVector<ctype, mydim> &local)
const
529 Dune::FieldVector<ctype, coorddim> normal;
534 if (codimension == 0)
536 DUNE_THROW(Dune::Exception,
"There is no normal vector to a full-dimensional intersection");
538 else if (codimension == 1) {
541 FieldMatrix<ctype, mydim,coorddim> jacobianTransposed =
geometry().jacobianTransposed(local);
543 normal[0] = - jacobianTransposed[0][1];
544 normal[1] = jacobianTransposed[0][0];
545 }
else if (mydim==2) {
546 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
547 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
548 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
550 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for " << mydim <<
"-dimensional intersections yet");
553 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
561 Dune::FieldVector<ctype, coorddim> normal =
outerNormal(local);
562 normal /= normal.two_norm();
578 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
581 return unitOuterNormal(GenericReferenceElements<ctype,mydim>::general(
type()).position(0,0));
590 #ifdef QUICKHACK_INDEX
593 IndexType index()
const
607 const GridGlue* glue_;
610 const IntersectionData* i_;
617 #endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
IntersectionTraits< P0, P1, I, O > Traits
Definition: intersection.hh:372
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:257
const IntersectionData< P0, P1 >::Grid0LocalGeometry LocalGeometry
Definition: intersection.hh:250
GridGlue::Grid1View OutsideGridView
Definition: intersection.hh:317
Dimension of the world space of the intersection.
Definition: intersection.hh:399
std::vector< Grid0IndexType > grid0indices_
indices of the associated local grid0 entity
Definition: intersection.hh:90
Traits::IntersectionData IntersectionData
Definition: intersection.hh:375
Dimension of the intersection.
Definition: intersection.hh:401
static bool local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:261
GridGlue::Grid0View OutsideGridView
Definition: intersection.hh:343
const IntersectionData::Grid1IndexType InsideIndexType
Definition: intersection.hh:349
contains customized geometry implementations for simplices
P0::GridView Grid0View
GridView of grid 0 (aka domain grid)
Definition: gridglue.hh:126
Definition: intersection.hh:44
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:47
std::vector< shared_ptr< Grid0LocalGeometry > > grid0localgeom_
Definition: intersection.hh:94
Traits::OutsideGeometry OutsideGeometry
Definition: intersection.hh:383
Traits::LocalCoordinate LocalCoordinate
Definition: intersection.hh:394
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:332
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition: intersection.hh:482
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() entity...
Definition: intersection.hh:455
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:297
bool conforming() const
Return true if intersection is conforming.
Definition: intersection.hh:448
GridGlue::Grid1View::IndexSet::IndexType Grid1IndexType
Definition: intersection.hh:76
Traits::GlobalCoordinate GlobalCoordinate
Definition: intersection.hh:395
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:511
Central component of the module implementing the coupling of two grids.
const IntersectionData::Grid1LocalGeometry InsideLocalGeometry
Definition: intersection.hh:345
const IntersectionData::Grid0Geometry OutsideGeometry
Definition: intersection.hh:348
const IntersectionData::Grid1LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:320
const IntersectionData< P0, P1 >::Grid0Geometry Geometry
Definition: intersection.hh:251
const IntersectionData< P0, P1 >::Grid1LocalGeometry LocalGeometry
Definition: intersection.hh:278
const IntersectionData::Grid0IndexType OutsideIndexType
Definition: intersection.hh:350
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition: intersection.hh:469
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:253
Traits::InsideLocalGeometry InsideLocalGeometry
Definition: intersection.hh:379
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition: intersection.hh:476
shared_ptr< Grid1Geometry > grid1geom_
Definition: intersection.hh:97
static IndexType parents(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:269
const IntersectionData< P0, P1 >::Grid0IndexType IndexType
Definition: intersection.hh:252
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:39
shared_ptr< Grid0Geometry > grid0geom_
Definition: intersection.hh:95
bool grid0local_
true if the associated grid0 entity is local
Definition: intersection.hh:89
P1::GridView Grid1View
GridView of grid 1 (aka target grid)
Definition: gridglue.hh:150
SimplexGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimensionworld > Grid0Geometry
Definition: intersection.hh:68
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition: intersection.hh:414
const IntersectionData::Grid1Geometry Geometry
Definition: intersection.hh:347
document the inside & outside patch
Definition: intersection.hh:404
Traits::InsideGridView InsideGridView
Definition: intersection.hh:378
GridGlue::Grid1View InsideGridView
Definition: intersection.hh:342
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:265
const IntersectionData::Grid1Geometry OutsideGeometry
Definition: intersection.hh:322
GridGlue::Grid0View InsideGridView
Definition: intersection.hh:316
InsideEntity inside(unsigned int parentId=0) const
Return EntityPointer to the Entity on the inside of this intersection.
Definition: intersection.hh:426
const IntersectionData::Grid0LocalGeometry InsideLocalGeometry
Definition: intersection.hh:319
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:340
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in...
Definition: intersection.hh:519
GlobalCoordinate unitOuterNormal(const Dune::FieldVector< ctype, mydim > &local) const
Return a unit outer normal.
Definition: intersection.hh:559
std::vector< Grid1IndexType > grid1indices_
indices of the associated local grid1 entity
Definition: intersection.hh:92
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition: intersection.hh:388
size_t neighbor(unsigned int g=0) const
For parallel computations: Return true if outside() entity exists locally.
Definition: intersection.hh:500
static IndexType index(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:293
const IntersectionData< P0, P1 >::Grid1IndexType IndexType
Definition: intersection.hh:280
Grid0View::ctype ctype
The type used for coordinates.
Definition: gridglue.hh:188
Definition: intersection.hh:53
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition: intersection.hh:382
Intersection< P0, P1, O, I > flip() const
Definition: intersection.hh:585
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() entity...
Definition: intersection.hh:462
const IntersectionData::Grid0Geometry Geometry
Definition: intersection.hh:321
SimplexGeometry< typename GridGlue::Grid0View::ctype, mydim, GridGlue::Grid0View::dimension > Grid0LocalGeometry
Definition: intersection.hh:66
SimplexGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimension > Grid1LocalGeometry
Definition: intersection.hh:70
InsideGridView::Traits::template Codim< 0 >::EntityPointer InsideEntityPointer
Definition: intersection.hh:389
GridGlue::ctype ctype
Definition: intersection.hh:331
export the world dimension : maximum of the two extractor world dimensions
Definition: gridglue.hh:181
Traits::GridGlue GridGlue
Definition: intersection.hh:374
Dune::GridGlue::IntersectionData< P0, P1 > IntersectionData
Definition: intersection.hh:314
GlobalCoordinate outerNormal(const Dune::FieldVector< ctype, mydim > &local) const
Return an outer normal (length not necessarily 1)
Definition: intersection.hh:527
GridGlue::ctype ctype
Definition: intersection.hh:359
GridGlue::IndexType IndexType
Definition: intersection.hh:41
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:50
static IndexType local(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:289
static LocalGeometry & localGeometry(const IntersectionData< P0, P1 > &i, unsigned int parentId=0)
Definition: intersection.hh:281
OutsideGridView::Traits::template Codim< 0 >::EntityPointer OutsideEntityPointer
Definition: intersection.hh:392
GlobalCoordinate integrationOuterNormal(const Dune::FieldVector< ctype, mydim > &local) const
Return an outer normal with the length of the integration element.
Definition: intersection.hh:567
const IntersectionData::Grid0LocalGeometry OutsideLocalGeometry
Definition: intersection.hh:346
Definition: gridglue.hh:33
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:313
SimplexGeometry< typename GridGlue::Grid1View::ctype, mydim, GridGlue::Grid1View::dimensionworld > Grid1Geometry
Definition: intersection.hh:72
static Geometry & geometry(const IntersectionData< P0, P1 > &i)
Definition: intersection.hh:285
Traits::OutsideGridView OutsideGridView
Definition: intersection.hh:381
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:333
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:360
Definition: intersection.hh:308
Definition: gridglue.hh:56
Traits::Geometry Geometry
Definition: intersection.hh:385
bool grid1local_
true if the associated grid1 entity is local
Definition: intersection.hh:91
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition: intersection.hh:391
const IntersectionData< P0, P1 >::Grid1Geometry Geometry
Definition: intersection.hh:279
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition: intersection.hh:576
OutsideEntity outside(unsigned int parentId=0) const
Return EntityPointer to the Entity on the outside of this intersection.
Definition: intersection.hh:440
Definition: intersection.hh:245
Definition: intersection.hh:405
Traits::ctype ctype
Definition: intersection.hh:386
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:339
unsigned int IndexType
Definition: gridglue.hh:164
GridGlue::Grid0View::IndexSet::IndexType Grid0IndexType
Definition: intersection.hh:75
std::vector< shared_ptr< Grid1LocalGeometry > > grid1localgeom_
Definition: intersection.hh:96
IntersectionData()
Default Constructor.
Definition: intersection.hh:82
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:361
This class is derived from BasicGeometry using tuned geometry traits.
Definition: simplexgeometry.hh:62
IndexType index_
index of this intersection after GridGlue interface
Definition: intersection.hh:87