From f18055687712f57e34989777fa5b11b22b34189d Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Tue, 24 Jan 2017 18:53:53 +0100 Subject: [PATCH] [intersection] Generalize geometryInOutside for non-conforming and adaptive grids --- .../foamgrid/foamgridintersections.hh | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/dune/foamgrid/foamgrid/foamgridintersections.hh b/dune/foamgrid/foamgrid/foamgridintersections.hh index 3b0cf86..6a54043 100644 --- a/dune/foamgrid/foamgrid/foamgridintersections.hh +++ b/dune/foamgrid/foamgrid/foamgridintersections.hh @@ -477,27 +477,20 @@ public: //! intersection of codimension 1 of this neighbor with element where iteration started. //! Here returned element is in LOCAL coordinates of neighbor - //! In the LevelIntersection we know that the intersection is conforming - LocalGeometry geometryInOutside (std::size_t neighborIndex = 0) const { - - // Get two vertices of the intersection - const auto refElement = ReferenceElements<double, dimgrid>::general(this->center_->type()); - - std::array<FoamGridEntityImp<0, dimgrid, dimworld>*, dimgrid> vtx; - - for (std::size_t idx = 0; idx < dimgrid; ++idx) - vtx[idx] = this->center_->vertex_[refElement.subEntity(this->facetIndex_, 1, idx, dimgrid)]; + //! In the LeafIntersection the intersection might be non-conforming + //! For surface grids with local non-conforming adaptivity the geometryInOutside is undefined + LocalGeometry geometryInOutside (std::size_t neighborIndex = 0) const + { + // Get reference element + const auto refElement = Dune::ReferenceElements<double, dimgrid>::general(this->center_->type()); + // Map the global position of the intersection vertices to the local position in the neighbor std::vector<FieldVector<double, dimgrid> > coordinates(dimgrid); - - // Find the intersection vertices in local numbering of the outside element - // That way we get the local orientation correctly. - const auto refElementOther = ReferenceElements<double, dimgrid>::general((*this->neighbor_)->type()); - - for (std::size_t j=0; j< dimgrid; j++) - for (int i=0; i<refElementOther.size(dimgrid); i++) - if (vtx[j] == (*this->neighbor_)->vertex_[refElementOther.subEntity(0, 0, i, dimgrid)]) - coordinates[j] = refElement.position(refElement.subEntity(0, 0, i, dimgrid), dimgrid); + for (std::size_t vIdx = 0; vIdx < dimgrid; ++vIdx) + { + const auto vIdxInElement = refElement.subEntity(this->facetIndex_, 1, vIdx, dimgrid); + coordinates[vIdx] = (*this->neighbor_)->globalToLocal(this->center_->vertex_[vIdxInElement]->pos_); + } geometryInOutside_ = std::make_shared<LocalGeometryImpl>(this->type(), coordinates); -- GitLab