From afee2a5f07786effdc9016a399fab97074d39d32 Mon Sep 17 00:00:00 2001 From: henrij22 <96132706+henrij22@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:50:17 +0200 Subject: [PATCH] Intersection in progress --- .clang-format | 2 +- .../nurbspatchgeometrylocalview.hh | 4 +- dune/iga/hierarchicpatch/patchgrid.hh | 36 +-- dune/iga/hierarchicpatch/patchgridentity.hh | 50 +-- dune/iga/hierarchicpatch/patchgridgeometry.hh | 10 +- .../hierarchicpatch/patchgridintersections.hh | 8 +- dune/iga/nurbsbasis.hh | 34 +- dune/iga/oldStuff/nurbsbasis.hh | 34 +- dune/iga/test/gridteststrimmed.cpp | 53 ++- dune/iga/test/testnurbsbasis.cpp | 2 +- dune/iga/test/testutillities.cpp | 3 - dune/iga/trimmer/CMakeLists.txt | 1 + .../trimmer/defaulttrimmer/createentities.hh | 12 +- .../trimmer/defaulttrimmer/elementtrimdata.hh | 8 +- .../trimmer/defaulttrimmer/entitycontainer.hh | 2 +- dune/iga/trimmer/defaulttrimmer/idset.hh | 8 +- .../patchgridhierarchiciterator.hh | 6 +- .../defaulttrimmer/patchgridindexsets.hh | 30 +- .../patchgridintersectioniterator.hh | 224 ++++++++++--- .../defaulttrimmer/patchgridintersections.hh | 94 +++--- .../defaulttrimmer/patchgridleafiterator.hh | 8 +- .../defaulttrimmer/patchgridleveliterator.hh | 14 +- .../defaulttrimmer/referenceelement.hh | 16 +- .../trimmer/defaulttrimmer/trimmedentity.hh | 26 +- .../defaulttrimmer/trimmedlocalgeometry.hh | 32 +- dune/iga/trimmer/defaulttrimmer/trimmer.hh | 43 ++- .../trimmingutils/indextransformations.hh | 5 +- dune/iga/trimmer/entityvariant.hh | 303 ------------------ .../patchgridhierarchiciterator.hh | 10 +- .../identitytrimmer/patchgridindexsets.hh | 34 +- .../patchgridintersectioniterator.hh | 14 +- .../identitytrimmer/patchgridleafiterator.hh | 8 +- .../identitytrimmer/patchgridleveliterator.hh | 8 +- .../identitytrimmer/patchgridlocalgeometry.hh | 8 +- dune/iga/trimmer/identitytrimmer/trimmer.hh | 18 +- dune/iga/trimmer/intersectionvariants.hh | 301 ----------------- dune/iga/trimmer/localgeometryvariant.hh | 8 +- 37 files changed, 512 insertions(+), 965 deletions(-) delete mode 100644 dune/iga/trimmer/entityvariant.hh delete mode 100644 dune/iga/trimmer/intersectionvariants.hh diff --git a/.clang-format b/.clang-format index 3d169b26..8f5f01fa 100644 --- a/.clang-format +++ b/.clang-format @@ -9,7 +9,7 @@ AllowAllParametersOfDeclarationOnNextLine: false AlwaysBreakTemplateDeclarations: Yes AllowShortLoopsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None +AllowShortFunctionsOnASingleLine: Empty ColumnLimit: 120 QualifierAlignment: Left ConstructorInitializerAllOnOneLineOrOnePerLine: true diff --git a/dune/iga/geometrykernel/nurbspatchgeometrylocalview.hh b/dune/iga/geometrykernel/nurbspatchgeometrylocalview.hh index 6d0a82c1..acaf3033 100644 --- a/dune/iga/geometrykernel/nurbspatchgeometrylocalview.hh +++ b/dune/iga/geometrykernel/nurbspatchgeometrylocalview.hh @@ -87,8 +87,8 @@ namespace GeometryKernel { std::conditional_t::LocalParameterSpaceGeometry>; - //! if we have codim==0, then the Jacobian in the parameter space of the grid entity itself is a DiagonalMatrix, - //! and + // if we have codim==0, then the Jacobian in the parameter space of the grid entity itself is a DiagonalMatrix, + // and // Coordinates in a single knot span differ from coordinates on the B-spline patch // by an affine transformation. This transformation is stored in the diagonal entries. // If trimming is disabled the Jacobian in the parameter space of subentities (edges or surfaces) is a diff --git a/dune/iga/hierarchicpatch/patchgrid.hh b/dune/iga/hierarchicpatch/patchgrid.hh index bf280e8c..c8a44e86 100644 --- a/dune/iga/hierarchicpatch/patchgrid.hh +++ b/dune/iga/hierarchicpatch/patchgrid.hh @@ -87,7 +87,7 @@ class PatchGrid : public GridDefaultImplementation::GlobalIdSet; friend GridFamily_::LocalIdSet; - //! type of the used GridFamily for this grid + // type of the used GridFamily for this grid public: using GridFamily = GridFamily_; @@ -116,7 +116,7 @@ private: public: using Trimmer = typename GridFamily::Trimmer; - //! The type used to store coordinates, inherited from the Trimmer + // The type used to store coordinates, inherited from the Trimmer using ctype = typename Trimmer::ctype; friend Trimmer; @@ -143,7 +143,7 @@ public: // The Interface Methods //********************************************************** - //! the Traits + // the Traits using Traits = typename GridFamily::Traits; using ParameterSpaceGrid = typename Trimmer::ParameterSpaceGrid; @@ -178,49 +178,49 @@ public: return trimmer_->maxLevel(); } - //! Iterator to first entity of given codim on level + // Iterator to first entity of given codim on level template typename Traits::template Codim::LevelIterator lbegin(int level) const { return LevelIteratorImpl(this, level); } - //! one past the end on this level + // one past the end on this level template typename Traits::template Codim::LevelIterator lend(int level) const { return LevelIteratorImpl(this, level, true); } - //! Iterator to first entity of given codim on level + // Iterator to first entity of given codim on level template typename Traits::template Codim::template Partition::LevelIterator lbegin(int level) const { return LevelIteratorImpl(this, level); } - //! one past the end on this level + // one past the end on this level template typename Traits::template Codim::template Partition::LevelIterator lend(int level) const { return LevelIteratorImpl(this, level, true); } - //! Iterator to first leaf entity of given codim + // Iterator to first leaf entity of given codim template typename Traits::template Codim::LeafIterator leafbegin() const { return LeafIteratorImpl(this); } - //! one past the end of the sequence of leaf entities + // one past the end of the sequence of leaf entities template typename Traits::template Codim::LeafIterator leafend() const { return LeafIteratorImpl(this, true); } - //! Iterator to first leaf entity of given codim + // Iterator to first leaf entity of given codim template typename Traits::template Codim::template Partition::LeafIterator leafbegin() const { return LeafIteratorImpl(this); } - //! one past the end of the sequence of leaf entities + // one past the end of the sequence of leaf entities template typename Traits::template Codim::template Partition::LeafIterator leafend() const { return LeafIteratorImpl(this, true); @@ -239,17 +239,17 @@ public: return trimmer_->parameterSpaceGrid().numBoundarySegments(); } - //! number of leaf entities per codim in this process + // number of leaf entities per codim in this process [[nodiscard]] int size(int codim) const { return leafIndexSet().size(codim); } - //! number of entities per level, codim and geometry type in this process + // number of entities per level, codim and geometry type in this process int size(int level, GeometryType type) const { return levelIndexSet(level).size(type); } - //! number of leaf entities per codim and geometry type in this process + // number of leaf entities per codim and geometry type in this process int size(GeometryType type) const { return leafIndexSet().size(type); } @@ -401,7 +401,7 @@ public: return trimmer_->paramterSpaceGrid().preAdapt(); } - //! Triggers the grid refinement process + // Triggers the grid refinement process bool adapt() { return trimmer_->paramterSpaceGrid().adapt(); } @@ -465,7 +465,7 @@ public: // End of Interface Methods // ********************************************************** - //! Returns the hostgrid this PatchGrid lives in + // Returns the hostgrid this PatchGrid lives in const ParameterSpaceGrid& parameterSpaceGrid() const { return trimmer_->parameterSpaceGrid(); } @@ -473,7 +473,7 @@ public: return trimmer_->parameterSpaceGrid(); } - //! Returns the hostgrid entity encapsulated in given PatchGrid entity + // Returns the hostgrid entity encapsulated in given PatchGrid entity template requires(GridFamily::template hasHostEntity) const typename GridFamily::TrimmerTraits::template Codim::ParameterSpaceGridEntity& getHostEntity( @@ -500,7 +500,7 @@ private: std::unique_ptr trimmer_; private: - //! @todo Please doc me ! + // @todo Please doc me ! Communication ccobj; }; // end Class PatchGrid diff --git a/dune/iga/hierarchicpatch/patchgridentity.hh b/dune/iga/hierarchicpatch/patchgridentity.hh index 8fb2e65f..40ed696f 100644 --- a/dune/iga/hierarchicpatch/patchgridentity.hh +++ b/dune/iga/hierarchicpatch/patchgridentity.hh @@ -68,7 +68,7 @@ public: typedef typename GridImp::template Codim::Geometry Geometry; - //! The type of the EntitySeed interface class + // The type of the EntitySeed interface class typedef typename GridImp::template Codim::EntitySeed EntitySeed; PatchGridEntity() @@ -97,7 +97,7 @@ public: PatchGridEntity& operator=(const PatchGridEntity& original) { if (this != &original) { - patchGrid_ = original.patchGrid_; + patchGrid_ = original.patchGrid_; localEntity_ = original.localEntity_; } return *this; @@ -105,7 +105,7 @@ public: PatchGridEntity& operator=(PatchGridEntity&& original) noexcept { if (this != &original) { - patchGrid_ = original.patchGrid_; + patchGrid_ = original.patchGrid_; localEntity_ = std::move(original.localEntity_); } return *this; @@ -115,17 +115,17 @@ public: return getLocalEntity() == other.getLocalEntity(); } - //! returns true if father entity exists + // returns true if father entity exists bool hasFather() const { return localEntity_.hasFather(); } - //! Create EntitySeed + // Create EntitySeed EntitySeed seed() const { return patchGrid_->trimmer_->seed(*this); } - //! level of this element + // level of this element int level() const { return localEntity_.level(); } @@ -142,7 +142,7 @@ public: return localEntity_.subEntities(cc); } - //! geometry of this entity + // geometry of this entity Geometry geometry() const { auto geo = typename Geometry::Implementation( localEntity_.geometry(), patchGrid_->patchGeometries_[this->level()].template localView()); @@ -194,16 +194,16 @@ public: typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry; - //! The Iterator over intersections on this level + // The Iterator over intersections on this level typedef typename GridImp::GridFamily::LevelIntersectionIterator LevelIntersectionIterator; - //! The Iterator over intersections on the leaf level + // The Iterator over intersections on the leaf level typedef typename GridImp::GridFamily::LeafIntersectionIterator LeafIntersectionIterator; - //! Iterator over descendants of the entity + // Iterator over descendants of the entity typedef typename GridImp::GridFamily::HierarchicIterator HierarchicIterator; - //! The type of the EntitySeed interface class + // The type of the EntitySeed interface class typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed; typedef typename GridImp::Trimmer::TrimmerTraits::template Codim<0>::ParameterSpaceGridEntitySeed ParameterSpaceGridEntitySeed; @@ -253,17 +253,17 @@ public: return localEntity_ == other.localEntity_; } - //! returns true if father entity exists + // returns true if father entity exists [[nodiscard]] bool hasFather() const { return localEntity_.hasFather(); } - //! Create EntitySeed + // Create EntitySeed [[nodiscard]] EntitySeed seed() const { return patchGrid_->trimmer_->seed(*this); } - //! Level of this element + // Level of this element [[nodiscard]] int level() const { return getLocalEntity().level(); } @@ -273,7 +273,7 @@ public: return getLocalEntity().partitionType(); } - //! Geometry of this entity + // Geometry of this entity [[nodiscard]] Geometry geometry() const { static_assert(std::is_same_v< decltype(patchGrid_->patchGeometries_[this->level()].template localView<0, Trimmer>()), @@ -298,33 +298,33 @@ public: return PatchGridEntity(patchGrid_, localEntity_.template subEntity(i)); } - //! First level intersection + // First level intersection [[nodiscard]] LevelIntersectionIterator ilevelbegin() const { return patchGrid_->trimmer_->ilevelbegin(*this); } - //! Reference to one past the last neighbor + // Reference to one past the last neighbor LevelIntersectionIterator ilevelend() const { return patchGrid_->trimmer_->ilevelend(*this); } - //! First leaf intersection + // First leaf intersection LeafIntersectionIterator ileafbegin() const { return patchGrid_->trimmer_->ileafbegin(*this); } - //! Reference to one past the last leaf intersection + // Reference to one past the last leaf intersection LeafIntersectionIterator ileafend() const { return patchGrid_->trimmer_->ileafend(*this); } - //! returns true if Entity has NO children + // returns true if Entity has NO children bool isLeaf() const { return localEntity_.isLeaf(); } - //! Inter-level access to father element on coarser grid. - //! Assumes that meshes are nested. + // Inter-level access to father element on coarser grid. + // Assumes that meshes are nested. typename GridImp::template Codim<0>::Entity father() const { return PatchGridEntity(patchGrid_, localEntity_.father()); } @@ -350,12 +350,12 @@ public: return HierarchicIterator(patchGrid_, *this, maxLevel); } - //! Returns iterator to one past the last son + // Returns iterator to one past the last son HierarchicIterator hend(int maxLevel) const { return HierarchicIterator(patchGrid_, *this, maxLevel, true); } - //! @todo Please doc me ! + // @todo Please doc me ! bool wasRefined() const { if (patchGrid_->adaptationStep != GridImp::adaptDone) return false; @@ -365,7 +365,7 @@ public: return patchGrid_->refinementMark_[level][index]; } - //! @todo Please doc me ! + // @todo Please doc me ! bool mightBeCoarsened() const { return true; } diff --git a/dune/iga/hierarchicpatch/patchgridgeometry.hh b/dune/iga/hierarchicpatch/patchgridgeometry.hh index 32b40abd..193e3227 100644 --- a/dune/iga/hierarchicpatch/patchgridgeometry.hh +++ b/dune/iga/hierarchicpatch/patchgridgeometry.hh @@ -41,7 +41,7 @@ public: using ParameterSpaceGeometry = typename Trimmer::template Codim::LocalParameterSpaceGeometry; // using LocalGeometryInParameterSpace = typename ReferenceElementType::template Codim::Geometry; - //! type of the LocalView of the patch geometry + // type of the LocalView of the patch geometry using GeometryLocalView = typename GeometryKernel::NURBSPatch::template GeometryLocalView; @@ -63,12 +63,12 @@ public: return geometryLocalView_.affine(); } - //! return the number of corners of this element. Corners are numbered 0...n-1 + // return the number of corners of this element. Corners are numbered 0...n-1 [[nodiscard]] int corners() const { return geometryLocalView_.corners(); } - //! access to coordinates of corners. Index is the number of the corner + // access to coordinates of corners. Index is the number of the corner [[nodiscard]] GlobalCoordinate corner(int i) const { return geometryLocalView_.corner(i); } @@ -96,7 +96,7 @@ public: return geometryLocalView_.local(global); } - //! Returns true if the point is in the current element + // Returns true if the point is in the current element [[nodiscard]] bool checkInside(const FieldVector& local) const { return geometryLocalView_.checkInside(local); } @@ -105,7 +105,7 @@ public: return geometryLocalView_.integrationElement(local); } - //! The Jacobian matrix of the mapping from the reference element to this element + // The Jacobian matrix of the mapping from the reference element to this element [[nodiscard]] JacobianInverseTransposed jacobianInverseTransposed(const FieldVector& local) const { // std::cout<<"jacobianInverseTransposed(local)\n"<; - using MatrixHelper = MultiLinearGeometryTraits::MatrixHelper; + using LocalCoordinate = FieldVector; + using MatrixHelper = MultiLinearGeometryTraits::MatrixHelper; public: typedef typename GridImp::template Codim<1>::Geometry Geometry; @@ -326,7 +328,7 @@ public: // auto refElement = referenceElement(inside().geometry()); // const int indexInInside = this->indexInInside(); // const typename LocalGeometry::GlobalCoordinate& refNormal = refElement.integrationOuterNormal(indexInInside); - const auto refNormal2 = parameterSpaceIntersection.outerNormal(local); + const auto refNormal2 = parameterSpaceIntersection.outerNormal(local); J.mv(refNormal2, res); diff --git a/dune/iga/nurbsbasis.hh b/dune/iga/nurbsbasis.hh index a34e2939..ef2f681b 100644 --- a/dune/iga/nurbsbasis.hh +++ b/dune/iga/nurbsbasis.hh @@ -61,7 +61,7 @@ class NurbsLocalBasis }; public: - //! @brief export type traits for function signature + // @brief export type traits for function signature using Traits = LocalBasisTraits, R, 1, FieldVector, FieldMatrix>; /** @brief Constructor with a given B-spline patch @@ -97,7 +97,7 @@ public: out[i][0][j] *= scaling_[j][j]; } - //! @brief Evaluate all shape functions and derivatives of any degree + // @brief Evaluate all shape functions and derivatives of any degree inline void partial(const typename std::array& order, const typename Traits::DomainType& in, std::vector& out) const { FieldVector globalIn = offset_; @@ -275,12 +275,12 @@ public: li_[i] = LocalKey(subEntity[i], codim[i], index[i]); } - //! number of coefficients + // number of coefficients [[nodiscard]] std::size_t size() const { return std::accumulate(sizes_.begin(), sizes_.end(), 1, std::multiplies<>()); } - //! get i'th index + // get i'th index [[nodiscard]] const LocalKey& localKey(std::size_t i) const { return li_[i]; } @@ -300,7 +300,7 @@ template class NurbsLocalInterpolation { public: - //! @brief Local interpolation of a function + // @brief Local interpolation of a function template void interpolate(const F& f, std::vector& out) const { DUNE_THROW(NotImplemented, "NurbsLocalInterpolation::interpolate"); @@ -506,7 +506,7 @@ public: using Node = NurbsNode; - //! Type of created tree node index set. \deprecated + // Type of created tree node index set. \deprecated static constexpr size_type maxMultiIndexSize = 1; static constexpr size_type minMultiIndexSize = 1; static constexpr size_type multiIndexBufferSize = 1; @@ -536,18 +536,18 @@ public: std::ranges::transform(uniqueKnotVector_, elements_.begin(), [](auto& v) { return v.size() - 1; }); } - //! Initialize the global indices + // Initialize the global indices void initializeIndices() { createUntrimmedNodeIndices(); createTrimmedNodeIndices(); } - //! Obtain the grid view that the basis is defined on + // Obtain the grid view that the basis is defined on const GridView& gridView() const { return gridView_; } - //! Update the stored grid view, to be called if the grid has changed + // Update the stored grid view, to be called if the grid has changed void update(const GridView& gv) { gridView_ = gv; } @@ -559,19 +559,19 @@ public: return Node{this}; } - //! Return number of possible values for next position in multi index + // Return number of possible values for next position in multi index template [[nodiscard]] size_type size(const SizePrefix prefix) const { assert(prefix.empty() || prefix.size() == 1); return (prefix.empty()) ? size() : 0; } - //! Get the total dimension of the space spanned by this basis + // Get the total dimension of the space spanned by this basis [[nodiscard]] size_type dimension() const { return size(); } - //! Get the maximal number of DOFs associated to node for any element + // Get the maximal number of DOFs associated to node for any element [[nodiscard]] size_type maxNodeSize() const { size_type result = 1; for (int i = 0; i < dim; i++) @@ -653,13 +653,13 @@ public: return result; } - //! @brief Total number of B-spline basis functions + // @brief Total number of B-spline basis functions [[nodiscard]] unsigned int size() const { // assert(!std::isnan(cachedSize_)); return computeOriginalSize(); } - //! @brief Number of shape functions in one direction + // @brief Number of shape functions in one direction [[nodiscard]] unsigned int sizePerDirection(size_t d) const { return patchData_.knotSpans[d].size() - patchData_.degree[d] - 1; } @@ -695,7 +695,7 @@ public: } } - //! @brief Evaluate Derivatives of all B-spline basis functions + // @brief Evaluate Derivatives of all B-spline basis functions void partial(const std::array& order, const FieldVector& in, std::vector>& out, const std::array& currentKnotSpan) const { @@ -759,7 +759,7 @@ public: finiteElement_(*preBasis) { } - //! Return current element, throw if unbound + // Return current element, throw if unbound const Element& element() const { return element_; } @@ -772,7 +772,7 @@ public: return finiteElement_; } - //! Bind to element. + // Bind to element. void bind(const Element& e) { element_ = e; auto elementIndex = preBasis_->gridView().indexSet().index(e); diff --git a/dune/iga/oldStuff/nurbsbasis.hh b/dune/iga/oldStuff/nurbsbasis.hh index 2f19ea77..86ccafa5 100644 --- a/dune/iga/oldStuff/nurbsbasis.hh +++ b/dune/iga/oldStuff/nurbsbasis.hh @@ -59,7 +59,7 @@ class NurbsLocalBasis }; public: - //! @brief export type traits for function signature + // @brief export type traits for function signature using Traits = LocalBasisTraits, R, 1, FieldVector, FieldMatrix>; /** @brief Constructor with a given B-spline patch @@ -95,7 +95,7 @@ public: out[i][0][j] *= scaling_[j][j]; } - //! @brief Evaluate all shape functions and derivatives of any degree + // @brief Evaluate all shape functions and derivatives of any degree inline void partial(const typename std::array& order, const typename Traits::DomainType& in, std::vector& out) const { FieldVector globalIn = offset_; @@ -273,12 +273,12 @@ public: li_[i] = LocalKey(subEntity[i], codim[i], index[i]); } - //! number of coefficients + // number of coefficients [[nodiscard]] std::size_t size() const { return std::accumulate(sizes_.begin(), sizes_.end(), 1, std::multiplies<>()); } - //! get i'th index + // get i'th index [[nodiscard]] const LocalKey& localKey(std::size_t i) const { return li_[i]; } @@ -298,7 +298,7 @@ template class NurbsLocalInterpolation { public: - //! @brief Local interpolation of a function + // @brief Local interpolation of a function template void interpolate(const F& f, std::vector& out) const { DUNE_THROW(NotImplemented, "NurbsLocalInterpolation::interpolate"); @@ -504,7 +504,7 @@ public: using Node = NurbsNode; - //! Type of created tree node index set. \deprecated + // Type of created tree node index set. \deprecated static constexpr size_type maxMultiIndexSize = 1; static constexpr size_type minMultiIndexSize = 1; static constexpr size_type multiIndexBufferSize = 1; @@ -529,16 +529,16 @@ public: prepareForTrim(); } - //! Initialize the global indices + // Initialize the global indices void initializeIndices() { } - //! Obtain the grid view that the basis is defined on + // Obtain the grid view that the basis is defined on const GridView& gridView() const { return gridView_; } - //! Update the stored grid view, to be called if the grid has changed + // Update the stored grid view, to be called if the grid has changed void update(const GridView& gv) { gridView_ = gv; } @@ -550,19 +550,19 @@ public: return Node{this}; } - //! Return number of possible values for next position in multi index + // Return number of possible values for next position in multi index template [[nodiscard]] size_type size(const SizePrefix prefix) const { assert(prefix.empty() || prefix.size() == 1); return (prefix.empty()) ? size() : 0; } - //! Get the total dimension of the space spanned by this basis + // Get the total dimension of the space spanned by this basis [[nodiscard]] size_type dimension() const { return size(); } - //! Get the maximal number of DOFs associated to node for any element + // Get the maximal number of DOFs associated to node for any element [[nodiscard]] size_type maxNodeSize() const { size_type result = 1; for (int i = 0; i < dim; i++) @@ -642,13 +642,13 @@ public: return result; } - //! @brief Total number of B-spline basis functions + // @brief Total number of B-spline basis functions [[nodiscard]] unsigned int size() const { assert(!std::isnan(cachedSize_)); return cachedSize_; } - //! @brief Number of shape functions in one direction + // @brief Number of shape functions in one direction [[nodiscard]] unsigned int sizePerDirection(size_t d) const { return patchData_.knotSpans[d].size() - patchData_.degree[d] - 1; } @@ -683,7 +683,7 @@ public: } } - //! @brief Evaluate Derivatives of all B-spline basis functions + // @brief Evaluate Derivatives of all B-spline basis functions void partial(const std::array& order, const FieldVector& in, std::vector>& out, const std::array& currentKnotSpan) const { @@ -740,7 +740,7 @@ public: finiteElement_(*preBasis) { } - //! Return current element, throw if unbound + // Return current element, throw if unbound const Element& element() const { return element_; } @@ -753,7 +753,7 @@ public: return finiteElement_; } - //! Bind to element. + // Bind to element. void bind(const Element& e) { element_ = e; auto elementIndex = e.impl().getDirectIndexInPatch(); diff --git a/dune/iga/test/gridteststrimmed.cpp b/dune/iga/test/gridteststrimmed.cpp index 356c3eec..8b9b2649 100644 --- a/dune/iga/test/gridteststrimmed.cpp +++ b/dune/iga/test/gridteststrimmed.cpp @@ -25,6 +25,7 @@ #include #include #include +#include using namespace Dune; using namespace Dune::IGANEW; @@ -118,25 +119,43 @@ auto myGridCheck(G& grid) { static_assert(G::dimension == 2); - auto gv = grid.leafGridView(); - for (int eleIdx = 0; const auto& ele : elements(gv)) { - // std::cout << "Element " << eleIdx << std::endl; - const int numCorners = ele.subEntities(2); - const int numCorners2 = ele.geometry().corners(); + auto testGV = [&](const GV& gv){ + for (int eleIdx = 0; const auto& ele : elements(gv)) { + std::cout << "Element " << eleIdx << std::endl; + const int numCorners = ele.subEntities(2); + const int numCorners2 = ele.geometry().corners(); - t.check(numCorners == numCorners2) << "Ele: " << eleIdx << " Corners from geometry not the same as subEntities(2)"; + t.check(numCorners == numCorners2) << "Ele: " << eleIdx << " Corners from geometry not the same as subEntities(2)"; - // Check if conrers from corner and center from subentity are the same - for (auto c : Dune::range(numCorners)) { - auto corner = ele.geometry().corner(c); - auto corner2 = ele.template subEntity<2>(c).geometry().center(); - t.check(FloatCmp::eq(corner, corner2)) - << "Ele: " << eleIdx << " Corner(i) from the element is not the same as subentity(i)"; + // Check if conrers from corner and center from subentity are the same + for (auto c : Dune::range(numCorners)) { + auto corner = ele.geometry().corner(c); + auto corner2 = ele.template subEntity<2>(c).geometry().center(); + t.check(FloatCmp::eq(corner, corner2)) + << "Ele: " << eleIdx << " Corner(i) from the element is not the same as subentity(i)"; + } + + // Intersections + int intersectionCount{0}; + for (const auto& intersection : intersections(gv, ele)) { + ++intersectionCount; + } + const int numEdges = ele.subEntities(1); + + std::cout << "Intersection Count: " << intersectionCount << "\t"; + std::cout << "Edges Count: " << numEdges << std::endl; + + t.check(intersectionCount == numEdges) << "There should be as many edges as intersections"; + + ++eleIdx; + std::cout << std::endl; } + }; + + testGV(grid.levelGridView(grid.maxLevel())); + testGV(grid.leafGridView()); + - ++eleIdx; - // std::cout << std::endl; - } return t; } @@ -147,7 +166,7 @@ auto thoroughGridCheck(auto& grid) { auto gvTest = [&](GV&& gv) { TestSuite tl; - //using GV = std::remove_cvref_t; + // using GV = std::remove_cvref_t; tl.subTest(checkUniqueEdges(gv)); tl.subTest(checkUniqueSurfaces(gv)); @@ -181,7 +200,7 @@ auto thoroughGridCheck(auto& grid) { } t.subTest(gvTest(grid.leafGridView())); - gridcheck(grid); + //gridcheck(grid); t.subTest(myGridCheck(grid)); // try { diff --git a/dune/iga/test/testnurbsbasis.cpp b/dune/iga/test/testnurbsbasis.cpp index 5c24171f..50c29318 100644 --- a/dune/iga/test/testnurbsbasis.cpp +++ b/dune/iga/test/testnurbsbasis.cpp @@ -62,7 +62,7 @@ auto testNurbsBasis() { Dune::TestSuite test(TestSuite::ThrowPolicy::AlwaysThrow); - //! Test code for VTKWriter, please uncomment to inspect the remaining errors + // Test code for VTKWriter, please uncomment to inspect the remaining errors Dune::RefinementIntervals refinementIntervals1(subSampling); SubsamplingVTKWriter vtkWriter(gridView, refinementIntervals1); diff --git a/dune/iga/test/testutillities.cpp b/dune/iga/test/testutillities.cpp index 92953406..6810e517 100644 --- a/dune/iga/test/testutillities.cpp +++ b/dune/iga/test/testutillities.cpp @@ -23,7 +23,6 @@ auto testTransformations() { using Transformations = Dune::IGANEW::DefaultTrim::Transformations; - for (const auto i : Dune::range(4u)) { t.check(Transformations::mapToDune(2, i) == vertexIndexMapping[i]); t.check(Transformations::mapToDune(1, i) == edgeIndexMapping[i]); @@ -32,7 +31,6 @@ auto testTransformations() { constexpr std::array vertexIndexBackMapping = {0u, 1u, 2u, 3u}; constexpr std::array edgeIndexBackMapping = {3u, 1u, 0u, 2u}; - for (const auto i : Dune::range(4u)) { t.check(Transformations::mapToTrimmer(2, i) == vertexIndexBackMapping[i]); t.check(Transformations::mapToTrimmer(1, i) == edgeIndexBackMapping[i]); @@ -49,7 +47,6 @@ int main(int argc, char** argv) try { Dune::MPIHelper::instance(argc, argv); Dune::TestSuite t("", Dune::TestSuite::ThrowPolicy::ThrowOnRequired); - t.report(); return t.exit(); diff --git a/dune/iga/trimmer/CMakeLists.txt b/dune/iga/trimmer/CMakeLists.txt index e38832d3..dda0c251 100644 --- a/dune/iga/trimmer/CMakeLists.txt +++ b/dune/iga/trimmer/CMakeLists.txt @@ -8,6 +8,7 @@ add_subdirectory(identitytrimmer) # install headers set(HEADERS concepts.hh + localgeometryvariant.hh ) install(FILES ${HEADERS} diff --git a/dune/iga/trimmer/defaulttrimmer/createentities.hh b/dune/iga/trimmer/defaulttrimmer/createentities.hh index fb1de796..c2ccad54 100644 --- a/dune/iga/trimmer/defaulttrimmer/createentities.hh +++ b/dune/iga/trimmer/defaulttrimmer/createentities.hh @@ -107,7 +107,7 @@ void TrimmerImpl::createAndSaveElementInfo( .trimmedIndexInLvl = trimmedElementIndex, .hostIndexInLvl = indexSet.index(ele), .lvl = newLevel, - .trimmed = trimmed, + .trimmed = trimmed, .id = elementId, .hostSeed = ele.seed(), .fatherId = fatherId, @@ -144,7 +144,7 @@ void TrimmerImpl::collectElementEdges(int level, cons auto edge = ele.template subEntity<1>(localEdgeIndex); EntityInfo<1> edgeInfo{.indexInLvlStorage = indexSet.index(edge), .lvl = level, - .trimmed = false, + .trimmed = false, .id = edgeId, .hostSeed = edge.seed()}; entityContainer_.idToEdgeInfoMap.insert({edgeId, edgeInfo}); @@ -175,7 +175,7 @@ void TrimmerImpl::collectElementEdges(int level, cons auto edge = ele.template subEntity<1>(localEdgeIndex); EntityInfo<1> edgeInfo{.indexInLvlStorage = entityContainer_.edgeCount.back()++, .lvl = level, - .trimmed = true, + .trimmed = true, .id = edgeId, .hostSeed = edge.seed(), .trimInfo = edgeOfTrimmedElement}; @@ -213,7 +213,7 @@ void TrimmerImpl::collectElementEdges(int level, cons EntityInfo<1> edgeInfo{.indexInLvlStorage = entityContainer_.edgeCount.back()++, .lvl = level, - .trimmed = true, + .trimmed = true, .id = edgeId, .trimInfo = edgeOfTrimmedElement}; entityContainer_.idToEdgeInfoMap.insert({edgeId, edgeInfo}); @@ -263,7 +263,7 @@ void TrimmerImpl::collectElementVertices(int level, c auto vertex = ele.template subEntity<2>(localVertexIndex); EntityInfo<2> vertexInfo{.indexInLvlStorage = indexSet.index(vertex), .lvl = level, - .trimmed = false, + .trimmed = false, .id = vertexId, .hostSeed = vertex.seed()}; entityContainer_.idToVertexInfoMap.back().insert({vertexId, vertexInfo}); @@ -274,7 +274,7 @@ void TrimmerImpl::collectElementVertices(int level, c elementVertexIndices.emplace_back(vertexId); EntityInfo<2> vertexInfo{.indexInLvlStorage = entityContainer_.vertexCount.back()++, .lvl = level, - .trimmed = true, + .trimmed = true, .id = vertexId, .trimInfo = vertex}; entityContainer_.idToVertexInfoMap.back().insert({vertexId, vertexInfo}); diff --git a/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh b/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh index eabec646..88bd9b17 100644 --- a/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh +++ b/dune/iga/trimmer/defaulttrimmer/elementtrimdata.hh @@ -66,10 +66,12 @@ struct ElementTrimDataImpl hostEntity_(hostEntity) { } - // Delete default constructor + // Delete default constructor, I think its implicitly delted anyway or not viable at least ElementTrimDataImpl() = delete; - // ElementTrimDataImpl(const ElementTrimDataImpl& other) = delete; - // ElementTrimDataImpl& operator=(const ElementTrimDataImpl& other) = delete; + + bool operator==(const ElementTrimDataImpl& other) const { + return hostEntity_ == other.hostEntity_; + } void addEdge(int idx) { edges_.emplace_back(EdgeInfo{.isHost = true, .isTrimmed = false, .idx = idx}); diff --git a/dune/iga/trimmer/defaulttrimmer/entitycontainer.hh b/dune/iga/trimmer/defaulttrimmer/entitycontainer.hh index 6588e299..df763032 100644 --- a/dune/iga/trimmer/defaulttrimmer/entitycontainer.hh +++ b/dune/iga/trimmer/defaulttrimmer/entitycontainer.hh @@ -204,7 +204,7 @@ struct VectorEntityContainer template using EntityInteratorImpl = typename std::tuple_element_t::iterator; - //! The lists of vertices, edges, elements for each level + // The lists of vertices, edges, elements for each level EntityImps entityImps_; std::map> globalEdgesIdOfElementsMap_; diff --git a/dune/iga/trimmer/defaulttrimmer/idset.hh b/dune/iga/trimmer/defaulttrimmer/idset.hh index acb5fe65..a6f4222e 100644 --- a/dune/iga/trimmer/defaulttrimmer/idset.hh +++ b/dune/iga/trimmer/defaulttrimmer/idset.hh @@ -20,18 +20,18 @@ class PatchGridGlobalIdSet : public IdSet using UntrimmedParameterSpaceGrid = typename Trimmer::UntrimmedParameterSpaceGrid; public: - //! constructor stores reference to a grid + // constructor stores reference to a grid PatchGridGlobalIdSet() = default; explicit PatchGridGlobalIdSet(const GridImp& g) : grid_(&g) { } // PatchGridGlobalIdSet(const GridImp& g, const std::vector& trimmingCurves) : grid_(&g) {} - //! define the type used for persistent indices + // define the type used for persistent indices using IdType = typename Trimmer::TrimmerTraits::GlobalIdSetId; using PersistentIndexType = typename Trimmer::TrimmerTraits::PersistentIndexType; - //! get id of an entity + // get id of an entity /* We use the remove_const to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -42,7 +42,7 @@ public: return e.impl().getLocalEntity().id(); } - //! get id of subEntity + // get id of subEntity IdType subId(const typename std::remove_const::type::Traits::template Codim<0>::Entity& e, int i, int codim) const { diff --git a/dune/iga/trimmer/defaulttrimmer/patchgridhierarchiciterator.hh b/dune/iga/trimmer/defaulttrimmer/patchgridhierarchiciterator.hh index c960bd27..a3d261e6 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchgridhierarchiciterator.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchgridhierarchiciterator.hh @@ -32,7 +32,7 @@ public: typedef typename GridImp::template Codim<0>::Entity Entity; - //! the default Constructor + // the default Constructor explicit PatchGridHierarchicIterator(const GridImp* parameterSpaceGrid, const Entity& startEntity, int maxLevel) : parameterSpaceGrid_(parameterSpaceGrid), maxLevel_{maxLevel} // , hostHierarchicIterator_(startEntity.impl().getHostEntity().hbegin(maxLevel)) @@ -67,13 +67,13 @@ public: // ++descendantLocalIndex_; } - //! dereferencing + // dereferencing Entity dereference() const { auto realEntity = typename Entity::Implementation{parameterSpaceGrid_, *currentEntityPtr_}; return Entity{std::move(realEntity)}; } - //! equality + // equality bool equals(const PatchGridHierarchicIterator& i) const { // if the iterators point to the different entities they are not equal, // But if we are nullptr by construction (end iterator) and the incremented iterator also becomes a nullptr due to diff --git a/dune/iga/trimmer/defaulttrimmer/patchgridindexsets.hh b/dune/iga/trimmer/defaulttrimmer/patchgridindexsets.hh index 709337d7..e094b5e3 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchgridindexsets.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchgridindexsets.hh @@ -27,7 +27,7 @@ public: constexpr static int dim = GridImp::dimension; - //! get index of an entity + // get index of an entity template int index(const typename GridImp::Traits::template Codim::Entity& e) const { // DUNE_THROW(NotImplemented, "Indices index"); @@ -35,7 +35,7 @@ public: return e.impl().getLocalEntity().index(); } - //! get index of subEntity of a codim 0 entity + // get index of subEntity of a codim 0 entity template int subIndex(const typename GridImp::Traits::template Codim::Entity& e, int i, int codim) const { // @todo Trim, the subindeces are wrong! @@ -44,7 +44,7 @@ public: return e.impl().getLocalEntity().subIndex(i, codim); } - //! get number of entities of given codim, type and on this level + // get number of entities of given codim, type and on this level std::size_t size(int codim) const { // @todo Trim,coun trimmed elements! // DUNE_THROW(NotImplemented, "size not implemented"); @@ -52,7 +52,7 @@ public: return grid_->trimmer().entityContainer_.size(codim, level_); } - //! get number of entities of given codim, type and on this level + // get number of entities of given codim, type and on this level std::size_t size(GeometryType type) const { // @todo Trim, count cube and none types i.e. full and trimmed elements // DUNE_THROW(NotImplemented, "size not implemented"); @@ -70,11 +70,11 @@ public: bool contains(const EntityType& e) const { if constexpr (EntityType::codimension == 0) return grid_->parameterSpaceGrid().levelIndexSet(level_).contains( - grid_->template getHostEntity(e).getHostEntity()); + grid_->template getHostEntity(e).getHostEntity()); else { if (not e.impl().isTrimmed()) return grid_->parameterSpaceGrid().levelIndexSet(level_).contains( - grid_->template getHostEntity(e).getHostEntity()); + grid_->template getHostEntity(e).getHostEntity()); return grid_->trimmer().entityContainer_.contains(e, level_); } } @@ -108,12 +108,12 @@ public: */ constexpr static int dim = std::remove_const::type::dimension; - //! constructor stores reference to a grid and level + // constructor stores reference to a grid and level explicit PatchGridLeafIndexSet(const GridImp& grid) : grid_(&grid) { } - //! get index of an entity + // get index of an entity /* We use the RemoveConst to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -126,7 +126,7 @@ public: grid_->template getHostEntity(e).getHostEntity()); } - //! get index of subEntity of a codim 0 entity + // get index of subEntity of a codim 0 entity /* We use the RemoveConst to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -141,7 +141,7 @@ public: codim); } - //! get number of entities of given type + // get number of entities of given type std::size_t size(GeometryType type) const { // @todo Trim, count cube and none types i.e. full and trimmed elements // DUNE_THROW(NotImplemented, "size not implemented"); @@ -149,7 +149,7 @@ public: return grid_->trimmer().entityContainer_.size(type, grid_->maxLevel()); } - //! get number of entities of given codim + // get number of entities of given codim std::size_t size(int codim) const { // DUNE_THROW(NotImplemented, "size not implemented"); // return {}; @@ -190,15 +190,15 @@ private: typedef typename std::remove_const::type::ParameterSpaceGrid ParameterSpaceGrid; public: - //! define the type used for persistent local ids + // define the type used for persistent local ids typedef typename ParameterSpaceGrid::Traits::LocalIdSet::IdType IdType; - //! constructor stores reference to a grid + // constructor stores reference to a grid PatchGridLocalIdSet(const GridImp& g) : grid_(&g) { } - //! get id of an entity + // get id of an entity /* We use the remove_const to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -217,7 +217,7 @@ public: return grid_->parameterSpaceGrid().globalIdSet().id(e.impl().getHostEntity().getHostEntity()); } - //! get id of subEntity + // get id of subEntity /* * We use the remove_const to extract the Type from the mutable class, * because the const class is not instantiated yet. diff --git a/dune/iga/trimmer/defaulttrimmer/patchgridintersectioniterator.hh b/dune/iga/trimmer/defaulttrimmer/patchgridintersectioniterator.hh index 4d23b1c4..6615c8d0 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchgridintersectioniterator.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchgridintersectioniterator.hh @@ -13,6 +13,136 @@ namespace Dune::IGANEW::DefaultTrim { +namespace Impl { + + enum class PositionToken + { + Begin, + End + }; + + enum IntersectionIteratorType + { + Level, + Leaf + }; + + namespace IntersectionTraits { + template + using Intersection = std::conditional_t; + + template + using ParameterSpaceIntersection = + std::conditional_t; + + template + using ParameterSpaceIntersectionIterator = + std::conditional_t; + + template + using TrimInfo = typename GridImp::Trimmer::ElementTrimData; + + } // namespace IntersectionTraits + + template + struct TrimmedIntersectionIterator + { + using Intersection = IntersectionTraits::Intersection; + using ParameterSpaceIntersection = IntersectionTraits::ParameterSpaceIntersection; + using TrimInfo = IntersectionTraits::TrimInfo; + + TrimmedIntersectionIterator() = default; + + TrimmedIntersectionIterator(const GridImp* parameterSpaceGrid, const TrimInfo& trimInfo, PositionToken pos) + : parameterSpaceGrid_(parameterSpaceGrid), + trimData_(trimInfo), + maxIterator_(trimInfo.size(1)), + iterator_(pos == PositionToken::Begin ? 0 : maxIterator_) {} + + bool equals(const TrimmedIntersectionIterator& other) const { + return trimData_ == other.trimData_ and iterator_ == other.iterator_; + } + + void increment() { + ++iterator_; + } + Intersection dereference() const { + return Intersection{}; + } + + private: + const GridImp* parameterSpaceGrid_{}; + std::optional trimData_{}; + + unsigned int maxIterator_{}; + unsigned int iterator_{}; + }; + + template + struct HostIntersectionIterator + { + using Intersection = IntersectionTraits::Intersection; + using ParameterSpaceIntersection = IntersectionTraits::ParameterSpaceIntersection; + using ParameterSpaceIntersectionIterator = IntersectionTraits::ParameterSpaceIntersectionIterator; + + HostIntersectionIterator() = default; + + HostIntersectionIterator(const GridImp* parameterSpaceGrid, const ParameterSpaceIntersectionIterator& hostIterator) + : parameterSpaceGrid_(parameterSpaceGrid), + hostIterator_(hostIterator) {} + + bool equals(const HostIntersectionIterator& other) const { + return hostIterator_ == other.hostIterator_; + } + + void increment() { + ++hostIterator_; + } + Intersection dereference() const { + auto parameterspaceIntersection = ParameterSpaceIntersection(parameterSpaceGrid_, *hostIterator_); + auto realIntersection = typename Intersection::Implementation(parameterSpaceGrid_, parameterspaceIntersection); + return Intersection(realIntersection); + } + + private: + const GridImp* parameterSpaceGrid_{}; + ParameterSpaceIntersectionIterator hostIterator_{}; + }; + + template + struct IntersectionIteratorVariant + { + auto visit(auto&& lambda) const { + return std::visit(lambda, impl_); + } + auto visit(auto&& lambda) { + return std::visit(lambda, impl_); + } + + template + explicit IntersectionIteratorVariant(const Implementation& impl) + : impl_(impl) {} + IntersectionIteratorVariant() = default; + + void increment() { + visit([](auto& impl) { impl.increment(); }); + } + auto dereference() const { + return visit([](const auto& impl) { return impl.dereference(); }); + } + + bool equals(const IntersectionIteratorVariant& other) const { + return visit([&](const T& impl) { return impl.equals(std::get(other.impl_)); }); + } + + private: + std::variant, HostIntersectionIterator> impl_{}; + }; +} // namespace Impl + /** @brief Iterator over all element neighbors * @ingroup PatchGrid * Mesh entities of codimension 0 ("elements") allow to visit all neighbors, where @@ -24,99 +154,95 @@ namespace Dune::IGANEW::DefaultTrim { template class PatchGridLeafIntersectionIterator { - constexpr static int dim = GridImp::dimension; - + constexpr static int dim = GridImp::dimension; constexpr static int dimworld = GridImp::dimensionworld; - - // The type used to store coordinates typedef typename GridImp::ctype ctype; - typedef typename GridImp::ParameterSpaceGrid::LeafGridView::IntersectionIterator HostLeafIntersectionIterator; - using ParameterSpaceLeafIntersection = typename GridImp::Trimmer::TrimmerTraits::ParameterSpaceLeafIntersection; - using LeafIntersection = typename GridImp::Traits::LeafIntersection; + using ParameterSpaceIntersectionIterator = typename GridImp::ParameterSpaceGrid::LeafGridView::IntersectionIterator; + using ParameterSpaceLeafIntersection = typename GridImp::Trimmer::TrimmerTraits::ParameterSpaceLeafIntersection; + using LeafIntersection = typename GridImp::Traits::LeafIntersection; + using TrimInfo = typename GridImp::Trimmer::ElementTrimData; public: - typedef Dune::Intersection > Intersection; + using Intersection = Dune::Intersection>; + using IteratorImpl = Impl::IntersectionIteratorVariant; + using PositionToken = Impl::PositionToken; PatchGridLeafIntersectionIterator() = default; - PatchGridLeafIntersectionIterator(const GridImp* parameterSpaceGrid, const HostLeafIntersectionIterator& hostIterator) - : parameterSpaceGrid_(parameterSpaceGrid), - hostIterator_(hostIterator) { - } + PatchGridLeafIntersectionIterator(const GridImp* parameterSpaceGrid, + const ParameterSpaceIntersectionIterator& hostIterator) + : underlyingIterator_{Impl::HostIntersectionIterator(parameterSpaceGrid, hostIterator)} {} + + PatchGridLeafIntersectionIterator(const GridImp* parameterSpaceGrid, const TrimInfo& trimInfo, PositionToken position) + : underlyingIterator_{ + Impl::TrimmedIntersectionIterator(parameterSpaceGrid, trimInfo, position)} {} - //! equality + // equality bool equals(const PatchGridLeafIntersectionIterator& other) const { - return hostIterator_ == other.hostIterator_; + return underlyingIterator_.equals(other.underlyingIterator_); } - //! prefix increment + // prefix increment void increment() { - ++hostIterator_; + underlyingIterator_.increment(); } - //! @brief dereferencing + // @brief dereferencing LeafIntersection dereference() const { - auto parameterspaceIntersection = ParameterSpaceLeafIntersection(parameterSpaceGrid_, *hostIterator_); - auto realIntersection = typename LeafIntersection::Implementation(parameterSpaceGrid_, parameterspaceIntersection); - return LeafIntersection(realIntersection); + return underlyingIterator_.dereference(); } private: - //********************************************************** - // private data - //********************************************************** - - const GridImp* parameterSpaceGrid_ = nullptr; - HostLeafIntersectionIterator hostIterator_ = {}; + IteratorImpl underlyingIterator_{}; }; - template class PatchGridLevelIntersectionIterator { - constexpr static int dim = GridImp::dimension; - + constexpr static int dim = GridImp::dimension; constexpr static int dimworld = GridImp::dimensionworld; - - // The type used to store coordinates typedef typename GridImp::ctype ctype; - typedef typename GridImp::ParameterSpaceGrid::LevelGridView::IntersectionIterator HostLevelIntersectionIterator; - using ParameterSpaceLevelIntersection = typename GridImp::Trimmer::TrimmerTraits::ParameterSpaceLevelIntersection; - using LevelIntersection = typename GridImp::Traits::LevelIntersection; + using ParameterSpaceIntersectionIterator = typename GridImp::ParameterSpaceGrid::LevelGridView::IntersectionIterator; + using ParameterSpaceLevelIntersection = typename GridImp::Trimmer::TrimmerTraits::ParameterSpaceLevelIntersection; + using LevelIntersection = typename GridImp::Traits::LevelIntersection; + using TrimInfo = typename GridImp::Trimmer::ElementTrimData; public: using Intersection = Dune::Intersection>; + using IteratorImpl = Impl::IntersectionIteratorVariant; + + using PositionToken = Impl::PositionToken; PatchGridLevelIntersectionIterator() = default; PatchGridLevelIntersectionIterator(const GridImp* parameterSpaceGrid, - const HostLevelIntersectionIterator& hostIterator) - : parameterSpaceGrid_(parameterSpaceGrid), - hostIterator_(hostIterator) { - } + const ParameterSpaceIntersectionIterator& hostIterator) + : underlyingIterator_{Impl::HostIntersectionIterator(parameterSpaceGrid, hostIterator)} {} + + PatchGridLevelIntersectionIterator(const GridImp* parameterSpaceGrid, const TrimInfo& trimInfo, + PositionToken position) + : underlyingIterator_{ + Impl::TrimmedIntersectionIterator(parameterSpaceGrid, trimInfo, position)} {} - //! equality - bool equals(const PatchGridLevelIntersectionIterator& other) const { - return hostIterator_ == other.hostIterator_; + // equality + bool equals(const PatchGridLevelIntersectionIterator& other) const { + return underlyingIterator_.equals(other.underlyingIterator_); } - //! prefix increment + // prefix increment void increment() { - ++hostIterator_; + underlyingIterator_.increment(); } - //! @brief dereferencing + // @brief dereferencing LevelIntersection dereference() const { - auto parameterspaceIntersection = ParameterSpaceLevelIntersection(parameterSpaceGrid_, *hostIterator_); - auto realIntersection = typename LevelIntersection::Implementation(parameterSpaceGrid_, parameterspaceIntersection); - return LevelIntersection(realIntersection); + return underlyingIterator_.dereference(); } private: - const GridImp* parameterSpaceGrid_ = nullptr; - HostLevelIntersectionIterator hostIterator_ = {}; + IteratorImpl underlyingIterator_{}; }; } // namespace Dune::IGANEW::DefaultTrim diff --git a/dune/iga/trimmer/defaulttrimmer/patchgridintersections.hh b/dune/iga/trimmer/defaulttrimmer/patchgridintersections.hh index 18803dd8..82b4b14a 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchgridintersections.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchgridintersections.hh @@ -3,11 +3,14 @@ #pragma once - /** \file * @brief The TrimmedPatchGridLeafIntersection and TrimmedLevelIntersection classes */ +// @todo same as gridintersection, one variant that forwards everything to hostEntity and one trimmed one +// @todo Also make this for leaf and level the same + + namespace Dune::IGANEW::DefaultTrim { // External forward declarations @@ -69,7 +72,7 @@ public: } using IdType = typename GridImp::GridFamily::TrimmerTraits::GlobalIdSetId; - //! returns the inside entity + // returns the inside entity ParameterSpaceGridEntity inside() const { // DUNE_THROW(NotImplemented, "inside not implemented"); auto hostId = patchGrid_->trimmer().parameterSpaceGrid().globalIdSet().id(hostIntersection_.inside()); @@ -77,8 +80,8 @@ public: return patchGrid_->trimmer().entityContainer_.template entity<0>(elementId, patchGrid_->maxLevel()); } - //! return Entity on the outside of this intersection - //! (that is the neighboring Entity) + // return Entity on the outside of this intersection + // (that is the neighboring Entity) ParameterSpaceGridEntity outside() const { // DUNE_THROW(NotImplemented, "outside not implemented"); auto hostId = patchGrid_->trimmer().parameterSpaceGrid().globalIdSet().id(hostIntersection_.outside()); @@ -86,7 +89,7 @@ public: return patchGrid_->trimmer().entityContainer_.template entity<0>(elementId, patchGrid_->maxLevel()); } - //! return true if intersection is with boundary. + // return true if intersection is with boundary. [[nodiscard]] bool boundary() const { return hostIntersection_.boundary(); } @@ -98,43 +101,43 @@ public: * It is scaled to have unit length. */ NormalVector centerUnitOuterNormal() const { DUNE_THROW(NotImplemented, "centerUnitOuterNormal not implemented"); - //! @todo compute jacobian create normal by cross-product, the cross-product has to take into account the normal - //! points away from the inside element + // @todo compute jacobian create normal by cross-product, the cross-product has to take into account the normal + // points away from the inside element } - //! return true if across the edge an neighbor on this level exists + // return true if across the edge an neighbor on this level exists bool neighbor() const { return hostIntersection_.neighbor(); } - //! return the boundary segment index + // return the boundary segment index size_t boundarySegmentIndex() const { return 0; // This is not implmented in SubGrid } - //! Return true if this is a conforming intersection + // Return true if this is a conforming intersection bool conforming() const { return hostIntersection_.conforming(); } - //! Geometry type of an intersection + // Geometry type of an intersection GeometryType type() const { return hostIntersection_.type(); } - //! @todo this function should return how this inersection resides in the inside host element. - //! Therefore, this function should provide this intersection and maps to the 0..1 space + // @todo this function should return how this inersection resides in the inside host element. + // Therefore, this function should provide this intersection and maps to the 0..1 space LocalGeometry geometryInInside() const { return hostIntersection_.geometryInInside(); } - //! Same as above + // Same as above LocalGeometry geometryInOutside() const { return hostIntersection_.geometryInOutside(); } - //! geometry of the intersection this geometry should map into the knotspan domain + // geometry of the intersection this geometry should map into the knotspan domain using TrimmedParameterSpaceGeometry = typename GridImp::Trimmer::TrimmerTraits::template Codim<1>::TrimmedParameterSpaceGeometry; using LocalParameterSpaceGeometry = @@ -144,35 +147,32 @@ public: return hostIntersection_.geometry(); } - //! local number of codim 1 entity in self where intersection is contained in + // local number of codim 1 entity in self where intersection is contained in int indexInInside() const { return hostIntersection_.indexInInside(); } - //! local number of codim 1 entity in neighbor where intersection is contained + // local number of codim 1 entity in neighbor where intersection is contained int indexInOutside() const { return hostIntersection_.indexInOutside(); - } - //! return outer normal + // return outer normal FieldVector outerNormal(const LocalCoordinate& local) const { return hostIntersection_.outerNormal(local); } - //! return outer normal multiplied by the integration element + // return outer normal multiplied by the integration element FieldVector integrationOuterNormal(const LocalCoordinate& local) const { return hostIntersection_.integrationOuterNormal(local); - } - //! return unit outer normal + // return unit outer normal FieldVector unitOuterNormal(const LocalCoordinate& local) const { return hostIntersection_.unitOuterNormal(local); } private: - const GridImp* patchGrid_{nullptr}; IntersectionGeometry geo; }; @@ -201,7 +201,6 @@ class TrimmedLevelIntersection using MatrixHelper = MultiLinearGeometryTraits::MatrixHelper; public: - typedef typename GridImp::ctype ctype; using LocalCoordinate = FieldVector; @@ -224,23 +223,23 @@ public: } using IdType = typename GridImp::GridFamily::TrimmerTraits::GlobalIdSetId; - //! return Entity on the inside of this intersection - //! (that is the Entity where we started this Iterator) + // return Entity on the inside of this intersection + // (that is the Entity where we started this Iterator) [[nodiscard]] ParameterSpaceGridEntity inside() const { // DUNE_THROW(NotImplemented, "inside not implemented"); auto hostId = patchGrid_->trimmer().parameterSpaceGrid().globalIdSet().id(hostIntersection_.inside()); IdType elementId = {.entityIdType = IdType::EntityIdType::host, .id = hostId}; - //! @todo Don't contruct this on the fly? + // @todo Don't contruct this on the fly? return patchGrid_->trimmer().entityContainer_.template entity<0>(elementId, hostIntersection_.inside().level()); } - //! return Entity on the outside of this intersection - //! (that is the neighboring Entity) + // return Entity on the outside of this intersection + // (that is the neighboring Entity) [[nodiscard]] ParameterSpaceGridEntity outside() const { // DUNE_THROW(NotImplemented, "outside not implemented"); auto hostId = patchGrid_->trimmer().parameterSpaceGrid().globalIdSet().id(hostIntersection_.outside()); IdType elementId = {.entityIdType = IdType::EntityIdType::host, .id = hostId}; - //! @todo Don't contruct this on the fly?trim + // @todo Don't contruct this on the fly?trim return patchGrid_->trimmer().entityContainer_.template entity<0>(elementId, hostIntersection_.outside().level()); } @@ -263,44 +262,44 @@ public: return hostIntersection_.centerUnitOuterNormal(); } - //! return true if across the edge an neighbor on this level exists + // return true if across the edge an neighbor on this level exists [[nodiscard]] bool neighbor() const { return hostIntersection_.neighbor(); } - //! return the boundary segment index + // return the boundary segment index [[nodiscard]] size_t boundarySegmentIndex() const { return 0; // This is not implmented in SubGrid return hostIntersection_.boundarySegmentIndex(); } - //! Return true if this is a conforming intersection, within one patch we are always conforming + // Return true if this is a conforming intersection, within one patch we are always conforming [[nodiscard]] bool conforming() const { return true; } - //! Geometry type of an intersection + // Geometry type of an intersection [[nodiscard]] GeometryType type() const { return GeometryTypes::line; } - //! intersection of codimension 1 of this neighbor with element where - //! iteration started. - //! Here returned element is in LOCAL coordinates of the element - //! where iteration started. + // intersection of codimension 1 of this neighbor with element where + // iteration started. + // Here returned element is in LOCAL coordinates of the element + // where iteration started. [[nodiscard]] LocalGeometry geometryInInside() const { return hostIntersection_.geometryInInside(); } - //! intersection of codimension 1 of this neighbor with element where iteration started. - //! Here returned element is in LOCAL coordinates of neighbor + // intersection of codimension 1 of this neighbor with element where iteration started. + // Here returned element is in LOCAL coordinates of neighbor [[nodiscard]] LocalGeometry geometryInOutside() const { return hostIntersection_.geometryInOutside(); } - //! intersection of codimension 1 of this neighbor with element where iteration started. - //! Here returned element is in GLOBAL coordinates of the element where iteration started. + // intersection of codimension 1 of this neighbor with element where iteration started. + // Here returned element is in GLOBAL coordinates of the element where iteration started. using TrimmedParameterSpaceGeometry = typename GridImp::Trimmer::TrimmerTraits::template Codim<1>::TrimmedParameterSpaceGeometry; using LocalParameterSpaceGeometry = @@ -310,27 +309,27 @@ public: return hostIntersection_.geometry(); } - //! local number of codim 1 entity in self where intersection is contained in + // local number of codim 1 entity in self where intersection is contained in [[nodiscard]] int indexInInside() const { return hostIntersection_.indexInInside(); } - //! local number of codim 1 entity in neighbor where intersection is contained + // local number of codim 1 entity in neighbor where intersection is contained [[nodiscard]] int indexInOutside() const { return hostIntersection_.indexInOutside(); } - //! return outer normal + // return outer normal [[nodiscard]] FieldVector outerNormal(const LocalCoordinate& local) const { return hostIntersection_.outerNormal(local); } - //! return outer normal multiplied by the integration element + // return outer normal multiplied by the integration element [[nodiscard]] FieldVector integrationOuterNormal(const LocalCoordinate& local) const { return hostIntersection_.integrationOuterNormal(local); } - //! return unit outer normal + // return unit outer normal [[nodiscard]] FieldVector unitOuterNormal(const LocalCoordinate& local) const { return hostIntersection_.integrationOuterNormal(local); } @@ -338,7 +337,6 @@ public: private: const GridImp* patchGrid_; HostLevelIntersection hostIntersection_; - }; } // namespace Dune::IGANEW::DefaultTrim diff --git a/dune/iga/trimmer/defaulttrimmer/patchgridleafiterator.hh b/dune/iga/trimmer/defaulttrimmer/patchgridleafiterator.hh index b9f15e48..fb1d773a 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchgridleafiterator.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchgridleafiterator.hh @@ -31,7 +31,7 @@ public: typedef typename GridImp::template Codim::Entity Entity; PatchGridLeafIterator() = default; - //! @todo Please doc me ! + // @todo Please doc me ! // template requires (codim!=0) // explicit PatchGridLeafIterator(const GridImp* patchGrid) // : patchGrid_(patchGrid), @@ -60,13 +60,13 @@ public: parameterSpaceLeafIterator(patchGrid_->trimmer().entityContainer_.template end(patchGrid_->maxLevel())) { } - //! prefix increment + // prefix increment void increment() { ++parameterSpaceLeafIterator; } using GlobalIdSetId = typename GridImp::GridFamily::TrimmerTraits::GlobalIdSetId; - //! dereferencing + // dereferencing Entity dereference() const { if constexpr (codim == 0) { // auto parameterSpaceEntity= ParameterSpaceGridEntity{patchGrid_, *parameterSpaceLeafIterator,id_}; @@ -88,7 +88,7 @@ public: } } - //! equality + // equality bool equals(const PatchGridLeafIterator& i) const { return parameterSpaceLeafIterator == i.parameterSpaceLeafIterator; } diff --git a/dune/iga/trimmer/defaulttrimmer/patchgridleveliterator.hh b/dune/iga/trimmer/defaulttrimmer/patchgridleveliterator.hh index 460e6581..36e50dea 100644 --- a/dune/iga/trimmer/defaulttrimmer/patchgridleveliterator.hh +++ b/dune/iga/trimmer/defaulttrimmer/patchgridleveliterator.hh @@ -28,15 +28,9 @@ public: typedef typename GridImp::template Codim::Entity Entity; typedef typename GridImp::Trimmer::template Codim::ParameterSpaceGridEntity ParameterSpaceGridEntity; - //! Constructor + // Constructor PatchGridLevelIterator() = default; - // template requires (codim!=0) - // explicit PatchGridLevelIterator(const GridImp* patchGrid, int level) - // : patchGrid_(patchGrid), - // parameterSpaceLevelIterator(patchGrid->parameterSpaceGrid().levelGridView(level).template begin()) {} - // template requires (codim==0) explicit PatchGridLevelIterator(const GridImp* patchGrid, int level) : patchGrid_(patchGrid), parameterSpaceLevelIterator(patchGrid_->trimmer().entityContainer_.template begin(level)) { @@ -59,14 +53,14 @@ public: parameterSpaceLevelIterator(patchGrid_->trimmer().entityContainer_.template end(level)) { } - //! prefix increment + // prefix increment void increment() { ++parameterSpaceLevelIterator; } using GlobalIdSetId = typename GridImp::GridFamily::TrimmerTraits::GlobalIdSetId; using ElementTrimData = typename GridImp::Trimmer::ElementTrimData; - //! dereferencing + // dereferencing Entity dereference() const { if constexpr (codim == 0) { // auto parameterSpaceEntity= ParameterSpaceGridEntity{patchGrid_, *parameterSpaceLevelIterator,id_}; @@ -88,7 +82,7 @@ public: // } } - //! equality + // equality bool equals(const PatchGridLevelIterator& i) const { return parameterSpaceLevelIterator == i.parameterSpaceLevelIterator; } diff --git a/dune/iga/trimmer/defaulttrimmer/referenceelement.hh b/dune/iga/trimmer/defaulttrimmer/referenceelement.hh index e6ebdf25..ce69c7a3 100644 --- a/dune/iga/trimmer/defaulttrimmer/referenceelement.hh +++ b/dune/iga/trimmer/defaulttrimmer/referenceelement.hh @@ -39,10 +39,10 @@ namespace IGANEW { class TrimmedReferenceElement { public: - //! The dimension of the reference element. + // The dimension of the reference element. static constexpr int mydimension = dim; static constexpr int dimension = mydimension; - //! The coordinate field type. + // The coordinate field type. using Trimmer = typename GridImp::Trimmer; using ctype = typename Trimmer::ctype; using ParameterSpaceGrid = YaspGrid>; @@ -52,16 +52,16 @@ namespace IGANEW { template struct Codim { - //! type of geometry embedding a subentity into the reference element + // type of geometry embedding a subentity into the reference element using Geometry = TrimmedLocalGeometryImpl; }; - //! The coordinate field type. + // The coordinate field type. using CoordinateField = ctype; - //! The coordinate type. + // The coordinate type. using Coordinate = Dune::FieldVector; /** @brief Type used for volume */ @@ -447,18 +447,18 @@ namespace IGANEW { } } - //! Compares for equality with another reference element. + // Compares for equality with another reference element. bool operator==(const TrimmedReferenceElement& r) const { // @todo, just check if the triangulations cooincide return trimData_ == r.trimData_; } - //! Compares for inequality with another reference element. + // Compares for inequality with another reference element. bool operator!=(const TrimmedReferenceElement& r) const { return not(*this == r); } - //! Yields a hash value suitable for storing the reference element a in hash table + // Yields a hash value suitable for storing the reference element a in hash table friend std::size_t hash_value(const TrimmedReferenceElement& r) { // @todo, this is not needed maybe return hash_value(ReferenceElements::cube()); diff --git a/dune/iga/trimmer/defaulttrimmer/trimmedentity.hh b/dune/iga/trimmer/defaulttrimmer/trimmedentity.hh index 502ad012..6e37e5f9 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmedentity.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmedentity.hh @@ -139,7 +139,7 @@ public: return entityInfo_.id == other.entityInfo_.id; } - //! returns true if father entity exists + // returns true if father entity exists template requires(codim_ == 0) [[nodiscard]] bool hasFather() const { @@ -150,7 +150,7 @@ public: // return hostEntity_.hasFather(); } - //! Create EntitySeed + // Create EntitySeed [[nodiscard]] ParameterSpaceGridEntitySeed seed() const { DUNE_THROW(NotImplemented, " seed"); if constexpr (codim_ == 0) @@ -158,7 +158,7 @@ public: return {}; } - //! Level of this element + // Level of this element [[nodiscard]] int level() const { return entityInfo_.lvl; } @@ -166,11 +166,11 @@ public: /** @brief The partition type for parallel computing */ [[nodiscard]] PartitionType partitionType() const { if constexpr (codim_ == 0) - return hostEntity_.partitionType(); + return hostEntity_.partitionType(); DUNE_THROW(NotImplemented, "partitionType not implemented for codim!=0 objects"); } - //! Geometry of this entity + // Geometry of this entity [[nodiscard]] LocalParameterSpaceGeometry geometry() const { if (not isTrimmed()) return hostEntity_.geometry(); @@ -214,7 +214,7 @@ public: return entity; } - //! First level intersection + // First level intersection template requires(codim_ == 0) [[nodiscard]] decltype(auto) ilevelbegin() const { @@ -223,36 +223,36 @@ public: return hostEntity_.ilevelbegin(); } - //! Reference to one past the last neighbor + // Reference to one past the last neighbor template requires(codim_ == 0) decltype(auto) ilevelend() const { return hostEntity_.ilevelend(); } - //! First leaf intersection + // First leaf intersection template requires(codim_ == 0) decltype(auto) ileafbegin() const { return hostEntity_.ileafbegin(); } - //! Reference to one past the last leaf intersection + // Reference to one past the last leaf intersection template requires(codim_ == 0) decltype(auto) ileafend() const { return hostEntity_.ileafend(); } - //! returns true if Entity has NO children + // returns true if Entity has NO children template requires(codim_ == 0) bool isLeaf() const { return hostEntity_.isLeaf(); } - //! Inter-level access to father element on coarser grid. - //! Assumes that meshes are nested. + // Inter-level access to father element on coarser grid. + // Assumes that meshes are nested. template requires(codim_ == 0) decltype(auto) father() const { @@ -284,7 +284,7 @@ public: // template // requires(codim_ == 0) decltype(auto) hbegin(int maxLevel) const { return hostEntity_.hbegin(maxLevel); } // - // //! Returns iterator to one past the last son + // // Returns iterator to one past the last son // template // requires(codim_ == 0) decltype(auto) hend(int maxLevel) const { return hostEntity_.hend(maxLevel); } diff --git a/dune/iga/trimmer/defaulttrimmer/trimmedlocalgeometry.hh b/dune/iga/trimmer/defaulttrimmer/trimmedlocalgeometry.hh index 63cf977e..8ddf6e35 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmedlocalgeometry.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmedlocalgeometry.hh @@ -46,7 +46,7 @@ public: using JacobianInverse = FieldMatrix; using Volume = ctype; - //! type of the LocalView of the patch geometry + // type of the LocalView of the patch geometry using GeometryLocalView = typename GeometryKernel::NURBSPatch::template GeometryLocalView; @@ -71,7 +71,7 @@ public: return true; } - //! return the number of corners of this element. Corners are numbered 0...n-1 + // return the number of corners of this element. Corners are numbered 0...n-1 [[nodiscard]] int corners() const { return trimData_.size(2); } @@ -80,7 +80,7 @@ public: return hostGeometry_.center(); } - //! access to coordinates of corners. Index is the number of the corner + // access to coordinates of corners. Index is the number of the corner GlobalCoordinate corner(int i) const { auto vData = trimData_.vertex(i); if (vData.isHost) { @@ -108,7 +108,7 @@ public: return hostGeometry_.local(global); } - //! Returns true if the point is in the current element + // Returns true if the point is in the current element // @todo bool checkInside(const LocalCoordinate& local) const { return true; @@ -118,7 +118,7 @@ public: return hostGeometry_.volume(); } - //! The Jacobian matrix of the mapping from the reference element to this element + // The Jacobian matrix of the mapping from the reference element to this element // @todo not yet implemented [[nodiscard]] JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate& local) const { DUNE_THROW(Dune::NotImplemented, "jacobianInverseTransposed() not yet implemented"); @@ -152,7 +152,7 @@ public: using JacobianInverse = FieldMatrix; using Volume = ctype; - //! type of the LocalView of the patch geometry + // type of the LocalView of the patch geometry using GeometryLocalView = typename GeometryKernel::NURBSPatch::template GeometryLocalView; @@ -163,8 +163,8 @@ public: } bool operator==(const TrimmedLocalGeometryImpl& b) const { - return Dune::FloatCmp::eq(b.patchGeometry.corner(0) == this->patchGeometry.corner(0)) - and Dune::FloatCmp::eq(b.patchGeometry.corner(1) == this->patchGeometry.corner(1)); + return Dune::FloatCmp::eq(b.patchGeometry.corner(0) == this->patchGeometry.corner(0)) and + Dune::FloatCmp::eq(b.patchGeometry.corner(1) == this->patchGeometry.corner(1)); }; /** @brief Return the element type identifier @@ -182,7 +182,7 @@ public: return patchGeometry.degree()[0] == 1; } - //! return the number of corners of this element. Corners are numbered 0...n-1 + // return the number of corners of this element. Corners are numbered 0...n-1 [[nodiscard]] int corners() const { return patchGeometry.corners(); } @@ -191,7 +191,7 @@ public: return patchGeometry.center(); } - //! access to coordinates of corners. Index is the number of the corner + // access to coordinates of corners. Index is the number of the corner GlobalCoordinate corner(int i) const { return patchGeometry.corner(i); } @@ -214,7 +214,7 @@ public: return patchGeometry.local(global); } - //! Returns true if the point is in the current element + // Returns true if the point is in the current element // @todo bool checkInside(const LocalCoordinate& local) const { return true; @@ -224,7 +224,7 @@ public: return patchGeometry.volume(); } - //! The Jacobian matrix of the mapping from the reference element to this element + // The Jacobian matrix of the mapping from the reference element to this element // @todo not yet implemented [[nodiscard]] JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate& local) const { DUNE_THROW(Dune::NotImplemented, "jacobianInverseTransposed() not yet implemented"); @@ -279,7 +279,7 @@ public: return true; } - //! return the number of corners of this element. Corners are numbered 0...n-1 + // return the number of corners of this element. Corners are numbered 0...n-1 [[nodiscard]] int corners() const { return 1; } @@ -288,7 +288,7 @@ public: return pos_; } - //! access to coordinates of corners. Index is the number of the corner + // access to coordinates of corners. Index is the number of the corner [[nodiscard]] GlobalCoordinate corner(int i) const { return pos_; } @@ -311,7 +311,7 @@ public: DUNE_THROW(Dune::NotImplemented, "not yet implemented"); } - //! Returns true if the point is in the current element + // Returns true if the point is in the current element // @todo bool checkInside(const LocalCoordinate& local) const { return true; @@ -321,7 +321,7 @@ public: return 1; } - //! The Jacobian matrix of the mapping from the reference element to this element + // The Jacobian matrix of the mapping from the reference element to this element // @todo not yet implemented [[nodiscard]] JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate& local) const { DUNE_THROW(Dune::NotImplemented, "jacobianInverseTransposed() not yet implemented"); diff --git a/dune/iga/trimmer/defaulttrimmer/trimmer.hh b/dune/iga/trimmer/defaulttrimmer/trimmer.hh index b911fbdd..081c30cf 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmer.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmer.hh @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -415,32 +414,46 @@ namespace DefaultTrim { template using Entity = typename GridFamily::Traits::template Codim::Entity; - //! First level intersection + // First level intersection [[nodiscard]] PatchGridLevelIntersectionIterator ilevelbegin(const Entity<0>& ent) const { + using IntersectionIterator = PatchGridLevelIntersectionIterator; + auto& localEntity = ent.impl().getLocalEntity(); - return PatchGridLevelIntersectionIterator( - grid_, parameterSpaceGrid().levelGridView(ent.level()).ibegin(ent.impl().getLocalEntity().getHostEntity())); + if (not localEntity.isTrimmed()) + return IntersectionIterator( + grid_, parameterSpaceGrid().levelGridView(ent.level()).ibegin(localEntity.getHostEntity())); + return IntersectionIterator(grid_, localEntity.trimData_.value(), IntersectionIterator::PositionToken::Begin); } - //! Reference to one past the last neighbor + // Reference to one past the last neighbor PatchGridLevelIntersectionIterator ilevelend(const Entity<0>& ent) const { + using IntersectionIterator = PatchGridLevelIntersectionIterator; + auto& localEntity = ent.impl().getLocalEntity(); - return PatchGridLevelIntersectionIterator( - grid_, parameterSpaceGrid().levelGridView(ent.level()).iend(ent.impl().getLocalEntity().getHostEntity())); + if (not localEntity.isTrimmed()) + return IntersectionIterator(grid_, + parameterSpaceGrid().levelGridView(ent.level()).iend(localEntity.getHostEntity())); + return IntersectionIterator(grid_, localEntity.trimData_.value(), IntersectionIterator::PositionToken::End); } - //! First leaf intersection + // First leaf intersection PatchGridLeafIntersectionIterator ileafbegin(const Entity<0>& ent) const { + using IntersectionIterator = PatchGridLeafIntersectionIterator; + auto& localEntity = ent.impl().getLocalEntity(); - return PatchGridLeafIntersectionIterator( - grid_, parameterSpaceGrid().leafGridView().ibegin(ent.impl().getLocalEntity().getHostEntity())); + if (not localEntity.isTrimmed()) + return IntersectionIterator(grid_, parameterSpaceGrid().leafGridView().ibegin(localEntity.getHostEntity())); + return IntersectionIterator(grid_, localEntity.trimData_.value(), IntersectionIterator::PositionToken::Begin); } - //! Reference to one past the last leaf intersection + // Reference to one past the last leaf intersection PatchGridLeafIntersectionIterator ileafend(const Entity<0>& ent) const { + using IntersectionIterator = PatchGridLeafIntersectionIterator; + auto& localEntity = ent.impl().getLocalEntity(); - return PatchGridLeafIntersectionIterator( - grid_, parameterSpaceGrid().leafGridView().iend(ent.impl().getLocalEntity().getHostEntity())); + if (not localEntity.isTrimmed()) + return IntersectionIterator(grid_, parameterSpaceGrid().leafGridView().iend(localEntity.getHostEntity())); + return IntersectionIterator(grid_, localEntity.trimData_.value(), IntersectionIterator::PositionToken::End); } template @@ -611,7 +624,7 @@ namespace DefaultTrim { return elementTrimDatas; } - //! compute the grid indices and ids + // compute the grid indices and ids void update(GridImp* grid) { grid_ = grid; localIdSet_->update(); @@ -660,7 +673,7 @@ namespace DefaultTrim { EntityContainer entityContainer_; - //! Our set of level indices + // Our set of level indices std::vector> levelIndexSets_; std::unique_ptr leafIndexSet_; diff --git a/dune/iga/trimmer/defaulttrimmer/trimmingutils/indextransformations.hh b/dune/iga/trimmer/defaulttrimmer/trimmingutils/indextransformations.hh index 86ae0dec..9ab10286 100644 --- a/dune/iga/trimmer/defaulttrimmer/trimmingutils/indextransformations.hh +++ b/dune/iga/trimmer/defaulttrimmer/trimmingutils/indextransformations.hh @@ -64,7 +64,7 @@ private: } template - static U vertexIndexToTrimmer(U index) { + static U vertexIndexToTrimmer(U index) { switch (index) { case 0: case 1: @@ -79,7 +79,7 @@ private: } template -static U edgeIndexToTrimmer(U index) { + static U edgeIndexToTrimmer(U index) { switch (index) { case 0: return 2; @@ -93,6 +93,5 @@ static U edgeIndexToTrimmer(U index) { DUNE_THROW(Dune::IOError, "index out of bounds"); } } - }; } // namespace Dune::IGANEW::DefaultTrim \ No newline at end of file diff --git a/dune/iga/trimmer/entityvariant.hh b/dune/iga/trimmer/entityvariant.hh deleted file mode 100644 index d8faafc4..00000000 --- a/dune/iga/trimmer/entityvariant.hh +++ /dev/null @@ -1,303 +0,0 @@ -// SPDX-FileCopyrightText: 2023 The Ikarus Developers mueller@ibb.uni-stuttgart.de -// SPDX-License-Identifier: LGPL-2.1-or-later -#pragma once - -// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root -// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception - -#pragma once - -/** \file - * @brief The GridEntityVariant class - */ -#include - -#include "dune/iga/hierarchicpatch/patchgridfwd.hh" - -namespace Dune::IGANEW::Trim { - -//********************************************************************** -// -// --GridEntityVariant -// --Entity -// -/** @brief The implementation of entities in a PatchGrid - * @ingroup PatchGrid - * - * A Grid is a container of grid entities. An entity is parametrized by the codimension. - * An entity of codimension c in dimension d is a d-c dimensional object. - * - */ -// template -// class GridEntityVariant { -// -// public: -// using TrimmerType = TrimmerType_; -// -// auto visit(auto&& lambda) const { return std::visit(lambda, impl_); } -// -// template -// GridEntityVariant(const Implementation& impl) : impl_(impl) {} -// -// GridEntityVariant() = default; -// GridEntityVariant(const GridEntityVariant& other) = default; -// template -// requires(!std::is_same_v) GridEntityVariant& operator=( -// const Implementation& impl) { -// impl_ = impl; -// return *this; -// }; -// GridEntityVariant(GridEntityVariant&& other) noexcept = default; -// GridEntityVariant& operator=(const GridEntityVariant& other) = default; -// GridEntityVariant& operator=(GridEntityVariant&& other) noexcept = default; -// -// bool equals(const GridEntityVariant& other) const { -// -// return hostEntity_ == other.hostEntity_; -// } -// -// //! returns true if father entity exists -// bool hasFather() const { -// return visit([](const auto& impl) { return impl.hasFather(); }); -// } -// -// //! Create EntitySeed -// auto seed() const { -// return visit([](const auto& impl) { return impl.seed(); }); -// } -// -// //! level of this element -// int level() const { -// return visit([](const auto& impl) { return impl.level(); }); -// } -// -// /** @brief The partition type for parallel computing -// */ -// PartitionType partitionType() const { -// return visit([](const auto& impl) { return impl.partitionType(); }); -// } -// -// /** @brief Return the number of subEntities of codimension codim. -// */ -// unsigned int subEntities(unsigned int cc) const { -// return visit([](const auto& impl) { return impl.subEntities(cc); }); -// } -// -// using ParameterSpaceGeometry = typename TrimmerType::template LocalParameterSpaceGeometry; -// -// -// //! geometry of this entity -// auto geometry() const { -// return visit([](const auto& impl) { return impl.geometry(); }); -// } -// -// ParameterSpaceGridEntity hostEntity_; -// -// private: -// const GridImp* patchGrid_; -// }; - -//*********************** -// -// --GridEntityVariant -// -//*********************** -/** @brief Specialization for codim-0-entities. - * @ingroup PatchGrid - * - * This class embodies the topological parts of elements of the grid. - * It has an extended interface compared to the general entity class. - * For example, Entities of codimension 0 allow to visit all neighbors. - */ -template -class ParameterSpaceGridEntityVariant -{ -public: - using TrimmerType = TrimmerType_; - using LocalParameterSpaceGeometry = typename TrimmerType::template LocalParameterSpaceGeometry; - - auto visit(auto&& lambda) const { - return std::visit(lambda, impl_); - } - - template - ParameterSpaceGridEntityVariant(const Implementation& impl) - : impl_(impl) { - } - - ParameterSpaceGridEntityVariant() = default; - ParameterSpaceGridEntityVariant(const ParameterSpaceGridEntityVariant& other) = default; - template - requires(!std::is_same_v) - ParameterSpaceGridEntityVariant& operator=(const Implementation& impl) { - impl_ = impl; - return *this; - }; - ParameterSpaceGridEntityVariant(ParameterSpaceGridEntityVariant&& other) noexcept = default; - ParameterSpaceGridEntityVariant& operator=(const ParameterSpaceGridEntityVariant& other) = default; - ParameterSpaceGridEntityVariant& operator=(ParameterSpaceGridEntityVariant&& other) noexcept = default; - - [[nodiscard]] bool equals(const ParameterSpaceGridEntityVariant& other) const { - return *this == other; - } - - //! returns true if father entity exists - [[nodiscard]] bool hasFather() const { - return visit([](const auto& impl) { return impl.hasFather(); }); - } - - //! Create EntitySeed - [[nodiscard]] auto seed() const { - return visit([](const auto& impl) { return impl.seed(); }); - } - - //! Level of this element - [[nodiscard]] int level() const { - return visit([](const auto& impl) { return impl.level(); }); - } - - /** @brief The partition type for parallel computing */ - [[nodiscard]] PartitionType partitionType() const { - return visit([](const auto& impl) { return impl.partitionType(); }); - } - - //! Geometry of this entity - [[nodiscard]] decltype(auto) geometry() const { - return visit([](const auto& impl) { return LocalParameterSpaceGeometry(impl.geometry()); }); - } - - /** @brief Return the number of subEntities of codimension codim. - */ - [[nodiscard]] unsigned int subEntities(unsigned int codim) const { - return visit([&](const auto& impl) { return impl.subEntities(codim); }); - } - - /** @brief Provide access to sub entity i of given codimension. Entities - * are numbered 0 ... subEntities(cc)-1 - */ - template - requires(codim_ == 0) - [[nodiscard]] decltype(auto) subEntity(int i) const { - return visit([&](const auto& impl) { return impl.template subEntity(i); }); - } - - //! First level intersection - template - requires(codim_ == 0) - [[nodiscard]] decltype(auto) ilevelbegin() const { - return visit([](const auto& impl) { return impl.ilevelbegin(); }); - } - - //! Reference to one past the last neighbor - template - requires(codim_ == 0) - decltype(auto) ilevelend() const { - return visit([](const auto& impl) { return impl.ilevelend(); }); - } - - //! First leaf intersection - template - requires(codim_ == 0) - decltype(auto) ileafbegin() const { - return visit([](const auto& impl) { return impl.ileafbegin(); }); - } - - //! Reference to one past the last leaf intersection - template - requires(codim_ == 0) - decltype(auto) ileafend() const { - return visit([](const auto& impl) { return impl.ileafend(); }); - } - - //! returns true if Entity has NO children - template - requires(codim_ == 0) - bool isLeaf() const { - return visit([](const auto& impl) { return impl.isLeaf(); }); - } - - //! Inter-level access to father element on coarser grid. - //! Assumes that meshes are nested. - template - requires(codim_ == 0) - decltype(auto) father() const { - return visit([](const auto& impl) { return impl.father(); }); - } - - /** @brief Location of this element relative to the reference element element of the father. - * This is sufficient to interpolate all dofs in conforming case. - * Nonconforming may require access to neighbors of father and - * computations with local coordinates. - * On the fly case is somewhat inefficient since dofs are visited several times. - * If we store interpolation matrices, this is tolerable. We assume that on-the-fly - * implementation of numerical algorithms is only done for simple discretizations. - * Assumes that meshes are nested. - */ - template - requires(codim_ == 0) - decltype(auto) geometryInFather() const { - return visit([](const auto& impl) { return impl.geometryInFather(); }); - } - - /** @brief Inter-level access to son elements on higher levels<=maxlevel. - * This is provided for sparsely stored nested unstructured meshes. - * Returns iterator to first son. - */ - template - requires(codim_ == 0) - decltype(auto) hbegin(int maxLevel) const { - return visit([&](const auto& impl) { return impl.hbegin(maxLevel); }); - } - - //! Returns iterator to one past the last son - template - requires(codim_ == 0) - decltype(auto) hend(int maxLevel) const { - return visit([&](const auto& impl) { return impl.hend(maxLevel); }); - } - - //! @todo Please doc me ! - template - requires(codim_ == 0) - bool wasRefined() const { - return visit([](const auto& impl) { return impl.wasRefined(); }); - } - - //! @todo Please doc me ! - template - requires(codim_ == 0) - - bool mightBeCoarsened() const { - return visit([](const auto& impl) { return impl.mightBeCoarsened(); }); - } - - // ///////////////////////////////////////// - // Internal stuff - // ///////////////////////////////////////// - - // private: - const auto& untrimmedHostEntity() const { - if (std::holds_alternative(impl_)) - return std::get(impl_); - else - return std::get(impl_).untrimmedHostEntity(); - } - - std::variant impl_; -}; - -template typename TrimmerType, - template class GridEntityVariant> -auto referenceElement( - const GridEntityVariant>& entity) { - return TrimmerType::referenceElement(entity); -} - -template typename TrimmerType, - template class GridEntityVariant> -auto referenceElement( - const Entity, GridEntityVariant>& entity) { - return referenceElement(entity.impl()); -} - -} // namespace Dune::IGANEW::Trim diff --git a/dune/iga/trimmer/identitytrimmer/patchgridhierarchiciterator.hh b/dune/iga/trimmer/identitytrimmer/patchgridhierarchiciterator.hh index 2ed265c0..14a52e35 100644 --- a/dune/iga/trimmer/identitytrimmer/patchgridhierarchiciterator.hh +++ b/dune/iga/trimmer/identitytrimmer/patchgridhierarchiciterator.hh @@ -30,32 +30,32 @@ public: typedef typename GridImp::template Codim<0>::Entity Entity; - //! the default Constructor + // the default Constructor explicit PatchGridHierarchicIterator(const GridImp* parameterSpaceGrid, const Entity& startEntity, int maxLevel) : parameterSpaceGrid_(parameterSpaceGrid), hostHierarchicIterator_(startEntity.impl().getHostEntity().hbegin(maxLevel)) { } - //! @todo Please doc me ! + // @todo Please doc me ! explicit PatchGridHierarchicIterator(const GridImp* parameterSpaceGrid, const Entity& startEntity, int maxLevel, [[maybe_unused]] bool endDummy) : parameterSpaceGrid_(parameterSpaceGrid), hostHierarchicIterator_(startEntity.impl().getHostEntity().hend(maxLevel)) { } - //! @todo Please doc me ! + // @todo Please doc me ! void increment() { ++hostHierarchicIterator_; } - //! dereferencing + // dereferencing Entity dereference() const { return Entity{ {parameterSpaceGrid_, *hostHierarchicIterator_} }; } - //! equality + // equality bool equals(const PatchGridHierarchicIterator& i) const { return hostHierarchicIterator_ == i.hostHierarchicIterator_; } diff --git a/dune/iga/trimmer/identitytrimmer/patchgridindexsets.hh b/dune/iga/trimmer/identitytrimmer/patchgridindexsets.hh index 5c26cf33..62531f23 100644 --- a/dune/iga/trimmer/identitytrimmer/patchgridindexsets.hh +++ b/dune/iga/trimmer/identitytrimmer/patchgridindexsets.hh @@ -26,28 +26,28 @@ public: constexpr static int dim = GridImp::dimension; - //! get index of an entity + // get index of an entity template int index(const typename GridImp::Traits::template Codim::Entity& e) const { return grid_->parameterSpaceGrid().levelIndexSet(level_).template index( grid_->template getHostEntity(e)); } - //! get index of subEntity of a codim 0 entity + // get index of subEntity of a codim 0 entity template int subIndex(const typename GridImp::Traits::template Codim::Entity& e, int i, int codim) const { // @todo Trim, the subindeces are wrong! return grid_->parameterSpaceGrid().levelIndexSet(level_).subIndex(grid_->template getHostEntity(e), i, codim); } - //! get number of entities of given codim, type and on this level + // get number of entities of given codim, type and on this level std::size_t size(int codim) const { // @todo Trim,coun trimmed elements! return grid_->parameterSpaceGrid().levelIndexSet(level_).size(codim); } - //! get number of entities of given codim, type and on this level + // get number of entities of given codim, type and on this level std::size_t size(GeometryType type) const { // @todo Trim, count cube and none types i.e. full and trimmed elements @@ -96,12 +96,12 @@ public: */ constexpr static int dim = std::remove_const::type::dimension; - //! constructor stores reference to a grid and level + // constructor stores reference to a grid and level explicit PatchGridLeafIndexSet(const GridImp& grid) : grid_(&grid) { } - //! get index of an entity + // get index of an entity /* We use the RemoveConst to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -111,7 +111,7 @@ public: return grid_->parameterSpaceGrid().leafIndexSet().template index(grid_->template getHostEntity(e)); } - //! get index of subEntity of a codim 0 entity + // get index of subEntity of a codim 0 entity /* We use the RemoveConst to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -123,13 +123,13 @@ public: return grid_->parameterSpaceGrid().leafIndexSet().subIndex(grid_->template getHostEntity(e), i, codim); } - //! get number of entities of given type + // get number of entities of given type std::size_t size(GeometryType type) const { // @todo Trim, count cube and none types i.e. full and trimmed elements return grid_->parameterSpaceGrid().leafIndexSet().size(type); } - //! get number of entities of given codim + // get number of entities of given codim std::size_t size(int codim) const { return grid_->parameterSpaceGrid().leafIndexSet().size(codim); } @@ -163,15 +163,15 @@ class PatchGridGlobalIdSet typedef typename std::remove_const::type::ParameterSpaceGrid ParameterSpaceGrid; public: - //! constructor stores reference to a grid + // constructor stores reference to a grid explicit PatchGridGlobalIdSet(const GridImp& g) : grid_(&g) { } - //! define the type used for persistent indices + // define the type used for persistent indices typedef typename ParameterSpaceGrid::Traits::GlobalIdSet::IdType IdType; - //! get id of an entity + // get id of an entity /* We use the remove_const to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -182,7 +182,7 @@ public: return grid_->parameterSpaceGrid().globalIdSet().id(e.impl().getHostEntity()); } - //! get id of subEntity + // get id of subEntity /* */ @@ -209,15 +209,15 @@ private: typedef typename std::remove_const::type::ParameterSpaceGrid ParameterSpaceGrid; public: - //! define the type used for persistent local ids + // define the type used for persistent local ids typedef typename ParameterSpaceGrid::Traits::LocalIdSet::IdType IdType; - //! constructor stores reference to a grid + // constructor stores reference to a grid PatchGridLocalIdSet(const GridImp& g) : grid_(&g) { } - //! get id of an entity + // get id of an entity /* We use the remove_const to extract the Type from the mutable class, because the const class is not instantiated yet. @@ -228,7 +228,7 @@ public: return grid_->parameterSpaceGrid().localIdSet().id(e.impl().getHostEntity()); } - //! get id of subEntity + // get id of subEntity /* * We use the remove_const to extract the Type from the mutable class, * because the const class is not instantiated yet. diff --git a/dune/iga/trimmer/identitytrimmer/patchgridintersectioniterator.hh b/dune/iga/trimmer/identitytrimmer/patchgridintersectioniterator.hh index 123e5d3b..ea2b3dee 100644 --- a/dune/iga/trimmer/identitytrimmer/patchgridintersectioniterator.hh +++ b/dune/iga/trimmer/identitytrimmer/patchgridintersectioniterator.hh @@ -44,17 +44,17 @@ public: hostIterator_(hostIterator) { } - //! equality + // equality bool equals(const PatchGridLeafIntersectionIterator& other) const { return hostIterator_ == other.hostIterator_; } - //! prefix increment + // prefix increment void increment() { ++hostIterator_; } - //! @brief dereferencing + // @brief dereferencing Intersection dereference() const { return PatchGridLeafIntersection(parameterSpaceGrid_, *hostIterator_); } @@ -68,7 +68,7 @@ private: HostLeafIntersectionIterator hostIterator_ = {}; }; -//! @todo Please doc me ! +// @todo Please doc me ! template class PatchGridLevelIntersectionIterator { @@ -93,17 +93,17 @@ public: hostIterator_(hostIterator) { } - //! equality + // equality bool equals(const PatchGridLevelIntersectionIterator& other) const { return hostIterator_ == other.hostIterator_; } - //! prefix increment + // prefix increment void increment() { ++hostIterator_; } - //! @brief dereferencing + // @brief dereferencing Intersection dereference() const { return PatchGridLevelIntersection(parameterSpaceGrid_, *hostIterator_); } diff --git a/dune/iga/trimmer/identitytrimmer/patchgridleafiterator.hh b/dune/iga/trimmer/identitytrimmer/patchgridleafiterator.hh index 92e8535b..4f09b7e4 100644 --- a/dune/iga/trimmer/identitytrimmer/patchgridleafiterator.hh +++ b/dune/iga/trimmer/identitytrimmer/patchgridleafiterator.hh @@ -26,7 +26,7 @@ public: typedef typename GridImp::template Codim::Entity Entity; PatchGridLeafIterator() = default; - //! @todo Please doc me ! + // @todo Please doc me ! explicit PatchGridLeafIterator(const GridImp* patchGrid) : patchGrid_(patchGrid), hostLeafIterator_(patchGrid->parameterSpaceGrid().leafGridView().template begin()) { @@ -41,19 +41,19 @@ public: hostLeafIterator_(patchGrid->parameterSpaceGrid().leafGridView().template end()) { } - //! prefix increment + // prefix increment void increment() { ++hostLeafIterator_; } - //! dereferencing + // dereferencing Entity dereference() const { return Entity{ {patchGrid_, *hostLeafIterator_} }; } - //! equality + // equality bool equals(const PatchGridLeafIterator& i) const { return hostLeafIterator_ == i.hostLeafIterator_; } diff --git a/dune/iga/trimmer/identitytrimmer/patchgridleveliterator.hh b/dune/iga/trimmer/identitytrimmer/patchgridleveliterator.hh index 5f7d8d88..ccaf02fd 100644 --- a/dune/iga/trimmer/identitytrimmer/patchgridleveliterator.hh +++ b/dune/iga/trimmer/identitytrimmer/patchgridleveliterator.hh @@ -25,7 +25,7 @@ public: typedef typename GridImp::template Codim::Entity Entity; - //! Constructor + // Constructor PatchGridLevelIterator() = default; explicit PatchGridLevelIterator(const GridImp* patchGrid, int level) : patchGrid_(patchGrid), @@ -42,19 +42,19 @@ public: hostLevelIterator_(patchGrid->parameterSpaceGrid().levelGridView(level).template end()) { } - //! prefix increment + // prefix increment void increment() { ++hostLevelIterator_; } - //! dereferencing + // dereferencing Entity dereference() const { return Entity{ {patchGrid_, *hostLevelIterator_} }; } - //! equality + // equality bool equals(const PatchGridLevelIterator& i) const { return hostLevelIterator_ == i.hostLevelIterator_; } diff --git a/dune/iga/trimmer/identitytrimmer/patchgridlocalgeometry.hh b/dune/iga/trimmer/identitytrimmer/patchgridlocalgeometry.hh index c3e66b2e..97e32844 100644 --- a/dune/iga/trimmer/identitytrimmer/patchgridlocalgeometry.hh +++ b/dune/iga/trimmer/identitytrimmer/patchgridlocalgeometry.hh @@ -66,12 +66,12 @@ public: return localGeometry_.affine(); } - //! return the number of corners of this element. Corners are numbered 0...n-1 + // return the number of corners of this element. Corners are numbered 0...n-1 [[nodiscard]] int corners() const { return localGeometry_.corners(); } - //! access to coordinates of corners. Index is the number of the corner + // access to coordinates of corners. Index is the number of the corner GlobalCoordinate corner(int i) const { return localGeometry_.corner(i); } @@ -94,7 +94,7 @@ public: return localGeometry_.local(global); } - //! Returns true if the point is in the current element + // Returns true if the point is in the current element bool checkInside(const FieldVector& local) const { return localGeometry_.checkInside(local); } @@ -103,7 +103,7 @@ public: return localGeometry_.integrationElement(local); } - //! The Jacobian matrix of the mapping from the reference element to this element + // The Jacobian matrix of the mapping from the reference element to this element [[nodiscard]] JacobianInverseTransposed jacobianInverseTransposed(const FieldVector& local) const { return localGeometry_.jacobianInverseTransposed(local); } diff --git a/dune/iga/trimmer/identitytrimmer/trimmer.hh b/dune/iga/trimmer/identitytrimmer/trimmer.hh index 3a8d4ceb..4e312215 100644 --- a/dune/iga/trimmer/identitytrimmer/trimmer.hh +++ b/dune/iga/trimmer/identitytrimmer/trimmer.hh @@ -198,25 +198,25 @@ namespace IdentityTrim { template using Entity = typename GridFamily::Traits::template Codim::Entity; - //! First level intersection + // First level intersection [[nodiscard]] PatchGridLevelIntersectionIterator ilevelbegin(const Entity<0>& ent) const { return PatchGridLevelIntersectionIterator( grid_, parameterSpaceGrid().levelGridView(ent.level()).ibegin(ent.impl().getHostEntity())); } - //! Reference to one past the last neighbor + // Reference to one past the last neighbor PatchGridLevelIntersectionIterator ilevelend(const Entity<0>& ent) const { return PatchGridLevelIntersectionIterator( grid_, parameterSpaceGrid().levelGridView(ent.level()).iend(ent.impl().getHostEntity())); } - //! First leaf intersection + // First leaf intersection PatchGridLeafIntersectionIterator ileafbegin(const Entity<0>& ent) const { return PatchGridLeafIntersectionIterator( grid_, parameterSpaceGrid().leafGridView().ibegin(ent.impl().getHostEntity())); } - //! Reference to one past the last leaf intersection + // Reference to one past the last leaf intersection PatchGridLeafIntersectionIterator ileafend(const Entity<0>& ent) const { return PatchGridLeafIntersectionIterator( grid_, parameterSpaceGrid().leafGridView().iend(ent.impl().getHostEntity())); @@ -355,7 +355,7 @@ namespace IdentityTrim { protected: protected: - //! compute the grid indices and ids + // compute the grid indices and ids void update(GridImp* grid) { grid_ = grid; localIdSet_->update(); @@ -385,16 +385,16 @@ namespace IdentityTrim { return parameterSpaceGrid().maxLevel(); } - //! Our set of level indices + // Our set of level indices std::vector> levelIndexSets_; - //! @todo Please doc me ! + // @todo Please doc me ! std::unique_ptr leafIndexSet_; - //! @todo Please doc me ! + // @todo Please doc me ! std::unique_ptr globalIdSet_; - //! @todo Please doc me ! + // @todo Please doc me ! std::unique_ptr localIdSet_; std::unique_ptr parameterSpaceGrid_; ///< The parameter space grid. diff --git a/dune/iga/trimmer/intersectionvariants.hh b/dune/iga/trimmer/intersectionvariants.hh deleted file mode 100644 index 126c8b27..00000000 --- a/dune/iga/trimmer/intersectionvariants.hh +++ /dev/null @@ -1,301 +0,0 @@ -// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root -// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception - -#pragma once - -/** \file - * @brief The TrimmedPatchGridLeafIntersection and PatchGridLevelIntersection classes - */ - -namespace Dune::IGANEW::Trim { - -// External forward declarations -template -struct HostGridAccess; - -/** @brief An intersection with a leaf neighbor element - * \ingroup PatchGrid - * Mesh entities of codimension 0 ("elements") allow to visit all neighbors, where - * a neighbor is an entity of codimension 0 which has a common entity of codimension 1 - * These neighbors are accessed via a IntersectionIterator. This allows the implement - * non-matching meshes. The number of neighbors may be different from the number - * of an element! - */ -template -class IntersectionVariant -{ - using ctype = std::common_type_t; - using FirstElement = std::tuple_element_t<0, std::tuple>; - static constexpr int mydimension = FirstElement::mydimension; - static constexpr int coorddimension = FirstElement::coorddimension; - - using LocalCoordinate = FieldVector; - -public: - auto visit(auto&& lambda) const { - return std::visit(lambda, impl_); - } - - template - IntersectionVariant(const Implementation& impl) - : impl_(impl) { - } - - IntersectionVariant() = default; - IntersectionVariant(const IntersectionVariant& other) = default; - template - requires(!std::is_same_v) - IntersectionVariant& operator=(const Implementation& impl) { - impl_ = impl; - return *this; - }; - IntersectionVariant(IntersectionVariant&& other) noexcept = default; - IntersectionVariant& operator=(const IntersectionVariant& other) = default; - IntersectionVariant& operator=(IntersectionVariant&& other) noexcept = default; - - // bool equals(const TrimmedPatchGridLeafIntersection& other) const { return parameterSpaceIntersection == - // other.parameterSpaceIntersection; } - - //! return Entity on the inside of this intersection - //! (that is the Entity where we started this Iterator) - auto inside() const { - return visit([](const auto& impl) { return impl.inside(); }); - } - - //! return Entity on the outside of this intersection - //! (that is the neighboring Entity) - auto outside() const { - return visit([](const auto& impl) { return impl.outside(); }); - } - - //! return true if intersection is with boundary. - [[nodiscard]] bool boundary() const { - return visit([](const auto& impl) { return impl.boundary(); }); - } - - /** @brief Return unit outer normal (length == 1) - * - * The returned vector is the normal at the center() of the - * intersection's geometry. - * It is scaled to have unit length. */ - auto centerUnitOuterNormal() const { - return visit([](const auto& impl) { return impl.centerUnitOuterNormal(); }); - } - - //! return true if across the edge an neighbor on this level exists - bool neighbor() const { - return visit([](const auto& impl) { return impl.neighbor(); }); - } - - //! return the boundary segment index - size_t boundarySegmentIndex() const { - return visit([](const auto& impl) { return impl.boundarySegmentIndex(); }); - } - - //! Return true if this is a conforming intersection - bool conforming() const { - return visit([](const auto& impl) { return impl.conforming(); }); - } - - //! Geometry type of an intersection - GeometryType type() const { - return visit([](const auto& impl) { return impl.type(); }); - } - - auto geometryInInside() const { - return visit([](const auto& impl) { return impl.geometryInInside(); }); - } - - //! intersection of codimension 1 of this neighbor with element where iteration started. - //! Here returned element is in LOCAL coordinates of neighbor - auto geometryInOutside() const { - return visit([](const auto& impl) { return impl.geometryInOutside(); }); - } - - //! intersection of codimension 1 of this neighbor with element where iteration started. - //! Here returned element is in GLOBAL coordinates of the element where iteration started. - auto geometry() const { - return visit([](const auto& impl) { return impl.geometry(); }); - } - - //! local number of codim 1 entity in self where intersection is contained in - int indexInInside() const { - return visit([](const auto& impl) { return impl.indexInInside(); }); - } - - //! local number of codim 1 entity in neighbor where intersection is contained - int indexInOutside() const { - return visit([](const auto& impl) { return impl.indexInOutside(); }); - } - - //! return outer normal - auto outerNormal(const LocalCoordinate& local) const { - return visit([&](const auto& impl) { return impl.outerNormal(local); }); - } - - //! return outer normal multiplied by the integration element - auto integrationOuterNormal(const LocalCoordinate& local) const { - return visit([&](const auto& impl) { return impl.integrationOuterNormal(local); }); - } - - //! return unit outer normal - auto unitOuterNormal(const LocalCoordinate& local) const { - return visit([&](const auto& impl) { return impl.unitOuterNormal(local); }); - } - -private: - std::variant impl_; -}; -// -// template -// class PatchGridLevelIntersection { -// friend typename GridImp::Traits::LevelIntersectionIterator; -// -// friend struct HostGridAccess::type>; -// -// constexpr static int dim = GridImp::dimension; -// constexpr static int mydim = GridImp::dimension - 1; -// -// constexpr static int dimworld = GridImp::dimensionworld; -// -// using Trimmer = typename GridImp::Trimmer; -// -// // The type used to store coordinates -// typedef typename GridImp::ctype ctype; -// -// typedef typename GridImp::GridFamily::LevelIntersection HostLevelIntersection; -// -// using LocalCoordinate = FieldVector; -// -// using MatrixHelper = typename MultiLinearGeometryTraits::MatrixHelper; -// -// public: -// typedef typename GridImp::template Codim<1>::Geometry Geometry; -// typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry; -// typedef typename GridImp::template Codim<0>::Entity Entity; -// typedef FieldVector NormalVector; -// -// PatchGridLevelIntersection() = default; -// -// PatchGridLevelIntersection(const GridImp* identityGrid, const HostLevelIntersection& hostIntersection) -// : patchGrid_(identityGrid), parameterSpaceIntersection(hostIntersection) {} -// -// PatchGridLevelIntersection(const GridImp* identityGrid, HostLevelIntersection&& hostIntersection) -// : patchGrid_(identityGrid), parameterSpaceIntersection(std::move(hostIntersection)) {} -// -// [[nodiscard]] bool equals(const PatchGridLevelIntersection& other) const { -// return parameterSpaceIntersection == other.parameterSpaceIntersection; -// } -// -// //! return Entity on the inside of this intersection -// //! (that is the Entity where we started this Iterator) -// [[nodiscard]] Entity inside() const { -// return PatchGridEntity<0, dim, GridImp>(patchGrid_, parameterSpaceIntersection.inside()); -// } -// -// //! return Entity on the outside of this intersection -// //! (that is the neighboring Entity) -// [[nodiscard]] Entity outside() const { -// return PatchGridEntity<0, dim, GridImp>(patchGrid_, parameterSpaceIntersection.outside()); -// } -// -// /** @brief return true if intersection is with boundary. -// */ -// [[nodiscard]] bool boundary() const { return parameterSpaceIntersection.boundary(); } -// -// /** @brief Return unit outer normal (length == 1) -// * -// * The returned vector is the normal at the center() of the -// * intersection's geometry. -// * It is scaled to have unit length. */ -// NormalVector centerUnitOuterNormal() const { -// LocalCoordinate localcenter; -// localcenter = 0.5; -// return this->unitOuterNormal(localcenter); -// } -// -// //! return true if across the edge an neighbor on this level exists -// [[nodiscard]] bool neighbor() const { return parameterSpaceIntersection.neighbor(); } -// -// //! return the boundary segment index -// [[nodiscard]] size_t boundarySegmentIndex() const { return parameterSpaceIntersection.boundarySegmentIndex(); } -// -// //! Return true if this is a conforming intersection -// [[nodiscard]] bool conforming() const { return parameterSpaceIntersection.conforming(); } -// -// //! Geometry type of an intersection -// [[nodiscard]] GeometryType type() const { return parameterSpaceIntersection.type(); } -// -// //! intersection of codimension 1 of this neighbor with element where -// //! iteration started. -// //! Here returned element is in LOCAL coordinates of the element -// //! where iteration started. -// [[nodiscard]] LocalGeometry geometryInInside() const { -// auto localGeometry = typename -// LocalGeometry::Implementation::LocalGeometry(parameterSpaceIntersection.geometryInInside()); return -// LocalGeometry(typename LocalGeometry::Implementation(localGeometry)); -// } -// -// //! intersection of codimension 1 of this neighbor with element where iteration started. -// //! Here returned element is in LOCAL coordinates of neighbor -// [[nodiscard]] LocalGeometry geometryInOutside() const { -// auto localGeometry = typename -// LocalGeometry::Implementation::LocalGeometry(parameterSpaceIntersection.geometryInOutside()); return -// LocalGeometry(typename LocalGeometry::Implementation(localGeometry)); -// } -// -// //! intersection of codimension 1 of this neighbor with element where iteration started. -// //! Here returned element is in GLOBAL coordinates of the element where iteration started. -// [[nodiscard]] Geometry geometry() const { -// // @todo trim does this make sense? -// auto geo = typename Geometry::Implementation( -// parameterSpaceIntersection.geometry(), -// patchGrid_->patchGeometries_[inside().level()].template localView<1, Trimmer>()); -// return Geometry(geo); -// } -// -// //! local number of codim 1 entity in self where intersection is contained in -// [[nodiscard]] int indexInInside() const { return parameterSpaceIntersection.indexInInside(); } -// -// //! local number of codim 1 entity in neighbor where intersection is contained -// [[nodiscard]] int indexInOutside() const { return parameterSpaceIntersection.indexInOutside(); } -// -// //! return outer normal -// [[nodiscard]] FieldVector outerNormal(const LocalCoordinate& local) const { -// const auto globalInPatch = geometryInInside().global(local); -// FieldMatrix J = inside().geometry().jacobianInverseTransposed(globalInPatch); -// FieldVector res; -// auto refElement = referenceElement(inside().geometry()); -// const int indexInInside = this->indexInInside(); -// const typename LocalGeometry::GlobalCoordinate& refNormal = refElement.integrationOuterNormal(indexInInside); -// const auto refNormal2 = parameterSpaceIntersection.outerNormal(local); -// // std::cout<<"refNormal"< integrationOuterNormal(const LocalCoordinate& local) const { -// const ctype detJ = this->geometry().integrationElement(local); -// FieldVector res = unitOuterNormal(local); -// -// res *= detJ; -// return res; -// } -// -// //! return unit outer normal -// [[nodiscard]] FieldVector unitOuterNormal(const LocalCoordinate& local) const { -// FieldVector res = outerNormal(local); -// res /= res.two_norm(); -// return res; -// } -// -// private: -// const GridImp* patchGrid_; -// -// HostLevelIntersection parameterSpaceIntersection; -// }; - -} // namespace Dune::IGANEW::Trim diff --git a/dune/iga/trimmer/localgeometryvariant.hh b/dune/iga/trimmer/localgeometryvariant.hh index 087bddee..cf870a7e 100644 --- a/dune/iga/trimmer/localgeometryvariant.hh +++ b/dune/iga/trimmer/localgeometryvariant.hh @@ -58,12 +58,12 @@ public: return visit([](const auto& impl) { return impl.affine(); }); } - //! return the number of corners of this element. Corners are numbered 0...n-1 + // return the number of corners of this element. Corners are numbered 0...n-1 [[nodiscard]] int corners() const { return visit([](const auto& impl) { return impl.corners(); }); } - //! access to coordinates of corners. Index is the number of the corner + // access to coordinates of corners. Index is the number of the corner auto corner(int i) const { return visit([&](const auto& impl) { return impl.corner(i); }); } @@ -90,7 +90,7 @@ public: return visit([&](const auto& impl) { return impl.local(global); }); } - //! Returns true if the point is in the current element + // Returns true if the point is in the current element bool checkInside(const auto& local) const { return visit([&](const auto& impl) { return impl.checkInside(local); }); } @@ -99,7 +99,7 @@ public: return visit([&](const auto& impl) { return impl.integrationElement(local); }); } - //! The Jacobian matrix of the mapping from the reference element to this element + // The Jacobian matrix of the mapping from the reference element to this element [[nodiscard]] auto jacobianInverseTransposed(const auto& local) const { return visit([&](const auto& impl) { return impl.jacobianInverseTransposed(local); }); }