Go to the documentation of this file.
9 #ifndef DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
10 #define DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
16 #include <dune/common/deprecated.hh>
17 #include <dune/common/version.hh>
18 #include <dune/geometry/affinegeometry.hh>
19 #include <dune/geometry/referenceelements.hh>
22 #define ONLY_SIMPLEX_INTERSECTIONS
28 template<
typename P0,
typename P1>
29 class IntersectionIndexSet;
34 template<
typename P0,
typename P1>
35 class IntersectionData
38 typedef ::Dune::GridGlue::GridGlue<P0, P1>
GridGlue;
48 static constexpr
int dim() {
return GridGlue::template GridView<side>::Grid::dimension - GridGlue::template GridPatch<side>::codim; }
52 static constexpr
int mydim = dim<0>() < dim<1>() ? dim<0>() : dim<1>();
56 typename GridGlue::template GridView<side>::ctype,
mydim, GridGlue::template GridView<side>::dimension>;
58 using Grid0LocalGeometry DUNE_DEPRECATED_MSG(
"please use GridLocalGeometry<0> instead") =
GridLocalGeometry<0>;
59 using Grid1LocalGeometry DUNE_DEPRECATED_MSG(
"please use GridLocalGeometry<1> instead") =
GridLocalGeometry<1>;
63 typename GridGlue::template GridView<side>::ctype,
mydim, GridGlue::template GridView<side>::dimensionworld>;
65 using Grid0Geometry DUNE_DEPRECATED_MSG(
"please use GridGeometry<0> instead") =
GridGeometry<0>;
66 using Grid1Geometry DUNE_DEPRECATED_MSG(
"please use GridGeometry<1> instead") =
GridGeometry<1>;
69 using GridIndexType =
typename GridGlue::template GridView<side>::IndexSet::IndexType;
71 using Grid0IndexType DUNE_DEPRECATED_MSG(
"please use GridIndexType<0> instead") =
GridIndexType<0>;
72 using Grid1IndexType DUNE_DEPRECATED_MSG(
"please use GridIndexType<1> instead") =
GridIndexType<1>;
75 IntersectionData(
const GridGlue& glue,
unsigned int mergeindex,
unsigned int offset,
bool grid0local,
bool grid1local);
80 std::get<0>(sideData_).gridlocal =
false;
81 std::get<1>(sideData_).gridlocal =
false;
88 {
return *std::get<side>(sideData_).gridlocalgeom[parentId]; }
92 {
return *std::get<side>(sideData_).gridgeom; }
96 {
return std::get<side>(sideData_).gridlocal; }
100 {
return std::get<side>(sideData_).gridindices[parentId]; }
104 {
return std::get<side>(sideData_).gridindices.size(); }
108 void initializeGeometry(
const GridGlue& glue,
unsigned mergeindex);
123 std::vector< GridIndexType<side> > gridindices;
127 std::vector< std::unique_ptr< GridLocalGeometry<side> > > gridlocalgeom;
137 std::unique_ptr< GridGeometry<side> > gridgeom;
140 std::tuple< SideData<0>, SideData<1> > sideData_;
143 template<
typename P0,
typename P1>
145 void IntersectionData<P0, P1>::initializeGeometry(
const GridGlue& glue,
unsigned mergeindex)
147 auto& data = std::get<side>(sideData_);
149 const unsigned n_parents = glue.merger_->template parents<side>(mergeindex);
152 data.gridindices.resize(n_parents);
153 data.gridlocalgeom.resize(n_parents);
156 data.gridindices[0] = 0;
158 static constexpr
int nSimplexCorners = mydim + 1;
159 using ctype =
typename GridGlue::ctype;
164 static constexpr
int elementdim = GridGlue::template GridView<side>::template Codim<0>::Geometry::mydimension;
167 std::array<Dune::FieldVector< ctype, dim<side>() >, nSimplexCorners> corners_subEntity_local;
169 for (
unsigned int par = 0; par < n_parents; ++par) {
170 for (
int i = 0; i < nSimplexCorners; ++i)
171 corners_subEntity_local[i] = glue.merger_->template parentLocal<side>(mergeindex, i, par);
174 std::array<Dune::FieldVector<ctype, elementdim>, nSimplexCorners> corners_element_local;
176 if (data.gridlocal) {
177 data.gridindices[par] = glue.merger_->template parent<side>(mergeindex,par);
179 typename GridGlue::template GridPatch<side>::LocalGeometry
180 gridLocalGeometry = glue.template patch<side>().geometryLocal(data.gridindices[par]);
181 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
182 corners_element_local[i] = gridLocalGeometry.global(corners_subEntity_local[i]);
186 #ifdef ONLY_SIMPLEX_INTERSECTIONS
187 # if DUNE_VERSION_NEWER(DUNE_GEOMETRY, 2, 6)
188 const Dune::GeometryType type = Dune::GeometryTypes::simplex(mydim);
190 const Dune::GeometryType type(Dune::GeometryType::simplex, mydim);
193 #error Not Implemented
195 data.gridlocalgeom[par] = std::make_unique< GridLocalGeometry<side> >(type, corners_element_local);
199 typename GridGlue::template GridPatch<side>::Geometry
200 gridWorldGeometry = glue.template patch<side>().geometry(data.gridindices[par]);
203 std::array<Dune::FieldVector<ctype, GridGlue::template GridView<side>::dimensionworld>, nSimplexCorners> corners_global;
205 for (std::size_t i=0; i<corners_subEntity_local.size(); i++) {
206 corners_global[i] = gridWorldGeometry.global(corners_subEntity_local[i]);
209 data.gridgeom = std::make_unique< GridGeometry<side> >(type, corners_global);
216 template<
typename P0,
typename P1>
218 bool grid0local,
bool grid1local)
219 : index_(mergeindex+offset)
223 assert (0 <= mergeindex || mergeindex < glue.index__sz);
225 std::get<0>(sideData_).gridlocal = grid0local;
226 std::get<1>(sideData_).gridlocal = grid1local;
228 initializeGeometry<0>(glue, mergeindex);
229 initializeGeometry<1>(glue, mergeindex);
236 template<
typename P0,
typename P1,
int ins
ide,
int outs
ide>
248 using Geometry =
typename IntersectionData::template GridGeometry<inside>;
263 template<
typename P0,
typename P1,
int I,
int O>
285 typedef typename InsideGridView::Traits::template Codim<0>::Entity
InsideEntity;
286 typedef typename OutsideGridView::Traits::template Codim<0>::Entity
OutsideEntity;
316 glue_(glue), i_(i) {}
326 return glue_->template patch<I>().element(i_->template index<I>(parentId));
335 return glue_->template patch<O>().element(i_->template index<O>(parentId));
341 throw Dune::NotImplemented();
348 return i_->template localGeometry<I>(parentId);
355 return i_->template localGeometry<O>(parentId);
366 return i_->template geometry<I>();
377 return i_->template geometry<O>();
381 Dune::GeometryType
type()
const
383 #ifdef ONLY_SIMPLEX_INTERSECTIONS
384 # if DUNE_VERSION_NEWER(DUNE_GEOMETRY, 2, 6)
385 return Dune::GeometryTypes::simplex(
mydim);
387 static const Dune::GeometryType
type(Dune::GeometryType::simplex,
mydim);
391 #error Not Implemented
399 return i_->template local<I>();
405 if (g == 0 && i_->template local<O>()) {
406 return i_->template parents<O>();
407 }
else if (g == 1 && i_->template local<I>()) {
408 return i_->template parents<I>();
417 return glue_->template patch<I>().indexInInside(i_->template index<I>(parentId));
424 return glue_->template patch<O>().indexInInside(i_->template index<O>(parentId));
435 if (codimensionWorld == 0)
436 DUNE_THROW(Dune::Exception,
"There is no normal vector to a full-dimensional intersection");
437 else if (codimensionWorld == 1) {
439 const auto jacobianTransposed =
geometry().jacobianTransposed(local);
441 normal[0] = - jacobianTransposed[0][1];
442 normal[1] = jacobianTransposed[0][0];
443 }
else if (
mydim==2) {
444 normal[0] = (jacobianTransposed[0][1] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][1]);
445 normal[1] = - (jacobianTransposed[0][0] * jacobianTransposed[1][2] - jacobianTransposed[0][2] * jacobianTransposed[1][0]);
446 normal[2] = (jacobianTransposed[0][0] * jacobianTransposed[1][1] - jacobianTransposed[0][1] * jacobianTransposed[1][0]);
448 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for " <<
mydim <<
"-dimensional intersections yet");
450 DUNE_THROW(Dune::NotImplemented,
"Remote intersections don't implement the 'outerNormal' method for intersections with codim >= 2 yet");
462 normal /= normal.two_norm();
492 #ifdef QUICKHACK_INDEX
495 IndexType index()
const
519 #endif // DUNE_GRIDGLUE_ADAPTER_INTERSECTION_HH
Definition: gridglue.hh:35
const OutsideLocalGeometry & geometryInOutside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the outside() element.
Definition: intersection.hh:353
Traits::InsideGridView InsideGridView
Definition: intersection.hh:275
const GridGeometry< side > & geometry() const
Definition: intersection.hh:91
Traits::Geometry Geometry
Definition: intersection.hh:282
Definition: gridglue.hh:52
Traits::GlobalCoordinate GlobalCoordinate
Definition: intersection.hh:289
storage class for Dune::GridGlue::Intersection related data
Definition: gridglue.hh:43
static constexpr auto coorddim
dimension of the world space of the intersection
Definition: intersection.hh:292
typename IntersectionData::template GridLocalGeometry< outside > OutsideLocalGeometry
Definition: intersection.hh:246
typename GridGlue::ctype ctype
Definition: intersection.hh:256
bool conforming() const
Return true if intersection is conforming.
Definition: intersection.hh:339
Traits::LocalCoordinate LocalCoordinate
Definition: intersection.hh:288
static constexpr int mydim
Dimension of the intersection.
Definition: intersection.hh:52
IndexType index_
index of this intersection after GridGlue interface
Definition: intersection.hh:114
static constexpr int dimworld
export the world dimension This is the maximum of the extractors' world dimensions.
Definition: gridglue.hh:164
Central component of the module implementing the coupling of two grids.
static constexpr int outsidePatch
outside patch
Definition: intersection.hh:301
InsideGridView::Traits::template Codim< 0 >::Entity InsideEntity
Definition: intersection.hh:285
Traits::IntersectionData IntersectionData
Definition: intersection.hh:272
const GridLocalGeometry< side > & localGeometry(unsigned int parentId=0) const
Definition: intersection.hh:87
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:414
Traits::GridGlue GridGlue
Definition: intersection.hh:271
static constexpr int insidePatch
inside patch
Definition: intersection.hh:298
static constexpr int outsidePatch
Definition: intersection.hh:254
size_t neighbor(unsigned int g=0) const
Return number of embeddings into local grid0 (grid1) entities.
Definition: intersection.hh:403
bool inside(const Coordinate &x, const Field &epsilon)
Definition: projection_impl.hh:109
Traits::OutsideLocalGeometry OutsideLocalGeometry
Definition: intersection.hh:279
typename GridGlue::template GridView< side >::IndexSet::IndexType GridIndexType
Definition: intersection.hh:69
Intersection< P0, P1, O, I > flip() const
Return a copy of the intersection with inside and outside switched.
Definition: intersection.hh:487
Dune::FieldVector< ctype, mydim > LocalCoordinate
Definition: intersection.hh:257
IntersectionData()
Default Constructor.
Definition: intersection.hh:78
IndexType index(unsigned int parentId=0) const
Definition: intersection.hh:99
Traits::ctype ctype
Definition: intersection.hh:283
The intersection of two entities of the two patches of a GridGlue.
Definition: gridglue.hh:46
static constexpr auto mydim
Definition: intersection.hh:252
Intersection(const GridGlue *glue, const IntersectionData *i)
Constructor for a given Dataset.
Definition: intersection.hh:315
Traits::OutsideGeometry OutsideGeometry
Definition: intersection.hh:280
AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, GridGlue::template GridView< side >::dimension > GridLocalGeometry
Definition: intersection.hh:56
typename IntersectionData::template GridGeometry< outside > OutsideGeometry
Definition: intersection.hh:249
sequential adapter to couple two grids at specified close together boundaries
Definition: gridglue.hh:40
GridGlue::IndexType IndexType
Definition: intersection.hh:40
InsideEntity inside(unsigned int parentId=0) const
Return element on the inside of this intersection.
Definition: intersection.hh:323
OutsideGridView::Traits::template Codim< 0 >::Entity OutsideEntity
Definition: intersection.hh:286
static constexpr auto coorddim
Definition: intersection.hh:251
Traits::OutsideGridView OutsideGridView
Definition: intersection.hh:278
PromotionTraits< typename GridView< 0 >::ctype, typename GridView< 1 >::ctype >::PromotedType ctype
The type used for coordinates.
Definition: gridglue.hh:169
Dune::GeometryType type() const
Type of reference element for this intersection.
Definition: intersection.hh:381
static constexpr auto mydim
dimension of the intersection
Definition: intersection.hh:295
::Dune::GridGlue::GridGlue< P0, P1 > GridGlue
Definition: intersection.hh:38
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
Return an outer normal with the length of the integration element.
Definition: intersection.hh:470
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return a unit outer normal.
Definition: intersection.hh:459
Traits::InsideLocalGeometry InsideLocalGeometry
Definition: intersection.hh:276
OutsideEntity outside(unsigned int parentId=0) const
Return element on the outside of this intersection.
Definition: intersection.hh:332
bool local() const
Definition: intersection.hh:95
typename GridGlue::template GridView< inside > InsideGridView
Definition: intersection.hh:242
typename IntersectionData::template GridLocalGeometry< inside > InsideLocalGeometry
Definition: intersection.hh:245
const Geometry & geometry() const
Geometric information about this intersection as part of the inside grid.
Definition: intersection.hh:364
AffineGeometry< typename GridGlue::template GridView< side >::ctype, mydim, GridGlue::template GridView< side >::dimensionworld > GridGeometry
Definition: intersection.hh:63
GlobalCoordinate centerUnitOuterNormal() const
Unit outer normal at the center of the intersection.
Definition: intersection.hh:479
IndexType parents() const
Definition: intersection.hh:103
const OutsideGeometry & geometryOutside() const
Geometric information about this intersection as part of the outside grid.
Definition: intersection.hh:375
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: intersection.hh:431
IntersectionTraits< P0, P1, I, O > Traits
Definition: intersection.hh:269
static constexpr int coorddim
Dimension of the world space of the intersection.
Definition: intersection.hh:43
int indexInOutside(unsigned int parentId=0) const
Local number of codim 1 entity in outside() Entity where intersection is contained in.
Definition: intersection.hh:421
unsigned int IndexType
Definition: gridglue.hh:145
Dune::FieldVector< ctype, coorddim > GlobalCoordinate
Definition: intersection.hh:258
Definition: intersection.hh:237
typename GridGlue::template GridView< outside > OutsideGridView
Definition: intersection.hh:243
const InsideLocalGeometry & geometryInInside(unsigned int parentId=0) const
Geometric information about this intersection in local coordinates of the inside() element.
Definition: intersection.hh:346
typename IntersectionData::template GridGeometry< inside > Geometry
Definition: intersection.hh:248
static constexpr int insidePatch
Definition: intersection.hh:253