diff --git a/applications/test/Circulator/Test-Circulator.C b/applications/test/Circulator/Test-Circulator.C index 33e6e5702c..cc5adfd754 100644 --- a/applications/test/Circulator/Test-Circulator.C +++ b/applications/test/Circulator/Test-Circulator.C @@ -34,7 +34,6 @@ Description #include "ListOps.H" #include "face.H" #include "Circulator.H" -#include "ConstCirculator.H" using namespace Foam; @@ -58,21 +57,31 @@ int main(int argc, char *argv[]) face f(identity(4)); + // ConstCirculator foo; + // Info<< "size: " << foo.size() << nl; + ConstCirculator cStart(f); - if (cStart.size()) do + if (!cStart.empty()) { - Info<< "Iterate forwards over face (prev/curr/next) : " - << cStart.prev() << " / " << cStart() << " / " << cStart.next() + do + { + Info<< "Iterate forwards over face (prev/curr/next) : " + << cStart.prev() << " / " + << cStart.curr() << " / " + << cStart.next() << endl; + } while (cStart.circulate(CirculatorBase::CLOCKWISE)); + } - } while (cStart.circulate(CirculatorBase::CLOCKWISE)); - - if (cStart.size()) do + if (!cStart.empty()) { - Info<< "Iterate backwards over face : " << cStart() << endl; + do + { + Info<< "Iterate backwards over face : " << cStart() << endl; - } while (cStart.circulate(CirculatorBase::ANTICLOCKWISE)); + } while (cStart.circulate(CirculatorBase::ANTICLOCKWISE)); + } Info<< nl << nl << "Test non-const circulator" << nl << endl; @@ -89,15 +98,18 @@ int main(int argc, char *argv[]) } while (cStart2.circulate(CirculatorBase::CLOCKWISE)); - if (cStart2.size()) do + if (!cStart2.empty()) { - Info<< "Iterate forwards over face, adding 1 to each element : " - << cStart2(); + do + { + Info<< "Iterate forwards over face, adding 1 to each element : " + << cStart2(); - cStart2() += 1; + cStart2() += 1; - Info<< " -> " << cStart2() << endl; - } while (cStart2.circulate(CirculatorBase::CLOCKWISE)); + Info<< " -> " << cStart2() << endl; + } while (cStart2.circulate(CirculatorBase::CLOCKWISE)); + } Info<< "Face after : " << f << endl; @@ -139,11 +151,14 @@ int main(int argc, char *argv[]) face fZero; Circulator cZero(fZero); - if (cZero.size()) do + if (!cZero.empty()) { - Info<< "Iterate forwards over face : " << cZero() << endl; + do + { + Info<< "Iterate forwards over face : " << cZero() << endl; - } while (cZero.circulate(CirculatorBase::CLOCKWISE)); + } while (cZero.circulate(CirculatorBase::CLOCKWISE)); + } fZero = face(identity(5)); @@ -163,16 +178,19 @@ int main(int argc, char *argv[]) ConstCirculator circForward(f); ConstCirculator circBackward(f); - if (circForward.size() && circBackward.size()) do + if (circForward.size() && circBackward.size()) { - Info<< "Iterate over face forwards : " << circForward() - << ", backwards : " << circBackward() << endl; + do + { + Info<< "Iterate over face forwards : " << circForward() + << ", backwards : " << circBackward() << endl; + } + while + ( + circForward.circulate(CirculatorBase::CLOCKWISE), + circBackward.circulate(CirculatorBase::ANTICLOCKWISE) + ); } - while - ( - circForward.circulate(CirculatorBase::CLOCKWISE), - circBackward.circulate(CirculatorBase::ANTICLOCKWISE) - ); Info<< "\nEnd\n" << endl; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C index 6052fea233..f955d54deb 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C @@ -30,7 +30,7 @@ License #include "vectorTools.H" #include "triangle.H" #include "tetrahedron.H" -#include "ConstCirculator.H" +#include "Circulator.H" #include "DelaunayMeshTools.H" #include "OBJstream.H" @@ -195,20 +195,20 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating if (circ.size()) do { - const sideVolumeType volType = normalVolumeTypes[circ()]; + const sideVolumeType volType = normalVolumeTypes[circ.curr()]; const sideVolumeType nextVolType = normalVolumeTypes[circ.next()]; - const vector& normal = feNormals[circ()]; + const vector& normal = feNormals[circ.curr()]; const vector& nextNormal = feNormals[circ.next()]; vector normalDir = (normal ^ edDir); - normalDir *= circNormalDirs()/mag(normalDir); + normalDir *= circNormalDirs.curr()/mag(normalDir); vector nextNormalDir = (nextNormal ^ edDir); nextNormalDir *= circNormalDirs.next()/mag(nextNormalDir); -// Info<< " " << circ() << " " << circ.next() << nl -// << " " << circNormalDirs() << " " << circNormalDirs.next() +// Info<< " " << circ.curr() << " " << circ.next() << nl +// << " " << circNormalDirs.curr() << " " << circNormalDirs.next() // << nl // << " normals = " << normal << " " << nextNormal << nl // << " normalDirs = " << normalDir << " " << nextNormalDir << nl diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C index deabcf15d3..338a38669d 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,7 +32,7 @@ License #include "conformalVoronoiMesh.H" #include "cellShapeControl.H" #include "DelaunayMeshTools.H" -#include "ConstCirculator.H" +#include "Circulator.H" #include "backgroundMeshDecomposition.H" #include "autoPtr.H" #include "mapDistribute.H" @@ -238,7 +238,7 @@ void Foam::featurePointConformer::createMasterAndSlavePoints if (circ.size()) do { // const edgeStatus eStatusPrev = feMesh.getEdgeStatus(circ.prev()); - const edgeStatus eStatusCurr = feMesh.getEdgeStatus(circ()); + const edgeStatus eStatusCurr = feMesh.getEdgeStatus(circ.curr()); // const edgeStatus eStatusNext = feMesh.getEdgeStatus(circ.next()); // Info<< " Prev = " @@ -253,7 +253,7 @@ void Foam::featurePointConformer::createMasterAndSlavePoints // feature point label sign = getSign(eStatusCurr); - const vector n = sharedFaceNormal(feMesh, circ(), circ.next()); + const vector n = sharedFaceNormal(feMesh, circ.curr(), circ.next()); const vector pointMotionDirection = sign*0.5*ppDist*n; diff --git a/src/OpenFOAM/containers/Circulators/Circulator.H b/src/OpenFOAM/containers/Circulators/Circulator.H new file mode 100644 index 0000000000..d9fca35aeb --- /dev/null +++ b/src/OpenFOAM/containers/Circulators/Circulator.H @@ -0,0 +1,377 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::Circulator + +Description + Walks over a container as if it were circular. The container must have the + following members defined: + - size_type + - difference_type + - iterator / const_iterator + - reference / const_reference + + Examples + + \code + face f(identity(5)); + + // Construct Circulator from the face + Circulator circ(f); + + // If it has a size to iterate over, + // circulate around the list starting and finishing at the fulcrum. + if (!circ.empty()) + { + do + { + *circ += 1; + + Info<< "Iterate forwards over face : " << *circ << endl; + + } while (circ.circulate(CirculatorBase::FORWARD)); + } + \endcode + +SourceFiles + CirculatorI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_Circulator_H +#define Foam_Circulator_H + +#include // std::conditional + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class CirculatorBase Declaration +\*---------------------------------------------------------------------------*/ + +//- Template-invariant parts for circulators +class CirculatorBase +{ +public: + + // Public Data + + //- Direction type enumeration + enum direction + { + NONE, + CLOCKWISE, + ANTICLOCKWISE + }; + + + // Constructors + + //- Default construct + CirculatorBase() = default; +}; + + +/*---------------------------------------------------------------------------*\ + Class CirculatorIters Declaration +\*---------------------------------------------------------------------------*/ + +//- A pair of begin/end iterators used for implementing circular iteration +template +class CirculatorIters +: + public CirculatorBase +{ +public: + + // STL type definitions + + //- The type that can represent the size of Container + using size_type = typename Container::size_type; + + //- The type that represents difference between iterator objects + using difference_type = typename Container::difference_type; + + //- The container iterator type (const/non-const) + using iterator = typename std::conditional + < + Const, + typename Container::const_iterator, + typename Container::iterator + >::type; + + //- The reference type (const/non-const) + using reference = typename std::conditional + < + Const, + typename Container::const_reference, + typename Container::reference + >::type; + + +private: + + // Private Data + + //- The container beginning + iterator begin_; + + //- The container end + iterator end_; + + //- Random access iterator for traversing Container. + iterator iter_; + + //- Iterator holding location of the fulcrum (start and end) of + //- the container. + //- Used to decide when iterator should stop circulating the container + iterator fulcrum_; + + +protected: + + // Protected Member Functions + + //- Compare for equality + inline bool equal(const CirculatorIters& rhs); + + //- Move iterator forward + inline void increment(); + + //- Move iterator backward + inline void decrement(); + + +public: + + // Constructors + + //- Default construct + inline CirculatorIters(); + + //- Construct from begin/end iterators + inline CirculatorIters(const iterator& begin, const iterator& end); + + //- Copy construct + CirculatorIters(const CirculatorIters& rhs); + + + // Member Functions + + //- True if begin/end iterators are identical + inline bool empty() const; + + //- Return the range of the iterator pair + inline size_type size() const; + + //- The distance between the iterator and the fulcrum. + // This is equivalent to the number of rotations of the circulator + inline difference_type nRotations() const; + + //- Circulate around the list in the given direction + //- \return True if iterator has not yet reached the fulcrum + inline bool circulate + ( + const CirculatorBase::direction dir = CirculatorBase::NONE + ); + + //- Set the fulcrum to the current position of the iterator + inline void setFulcrumToIterator(); + + //- Set the iterator to the current position of the fulcrum + inline void setIteratorToFulcrum(); + + //- Dereference the current iterator + inline reference curr() const; + + //- Dereference the next iterator + inline reference next() const; + + //- Dereference the previous iterator + inline reference prev() const; + + + // Member Operators + + //- Assignment operator for circulators operating + //- on the same container type + inline void operator=(const CirculatorIters& rhs); + + //- Prefix increment the iterator. + // Wraps iterator to the begin if it reaches the end + inline CirculatorIters& operator++(); + + //- Postfix increment the iterator. + // Wraps iterator to the begin if it reaches the end + inline CirculatorIters operator++(int); + + //- Prefix decrement the iterator. + // Wraps iterator to the end if it reaches the beginning + inline CirculatorIters& operator--(); + + //- Postfix decrement the iterator. + // Wraps iterator to the end if it reaches the beginning + inline CirculatorIters operator--(int); + + //- Check for equality of this iterator with another iterator that + //- operate on the same container type + inline bool operator== + ( + const CirculatorIters& + ) const; + + //- Check for inequality of this iterator with another iterator that + //- operate on the same container type + inline bool operator!= + ( + const CirculatorIters& + ) const; + + //- Dereference the iterator. Same as curr() + inline reference operator*() const; + + //- Dereference the iterator. Same as curr() + inline reference operator()() const; + + //- Return the difference between this iterator and another iterator + //- that operate on the same container type + inline difference_type operator- + ( + const CirculatorIters& + ) const; +}; + + +/*---------------------------------------------------------------------------*\ + Class Circulator Declaration +\*---------------------------------------------------------------------------*/ + +template +class Circulator +: + public CirculatorIters +{ +public: + + // Constructors + + //- Default construct + Circulator() = default; + + //- Construct from begin/end of a container + explicit Circulator(Container& obj) + : + CirculatorIters(obj.begin(), obj.end()) + {} + + //- Construct from two iterators + Circulator + ( + const typename Container::iterator& begin, + const typename Container::iterator& end + ) + : + CirculatorIters(begin, end) + {} + + //- Copy construct + Circulator(const Circulator& rhs) = default; + + + // Member Operators + + //- Copy assignment + Circulator& operator= + ( + const Circulator& rhs + ) = default; +}; + + +/*---------------------------------------------------------------------------*\ + Class ConstCirculator Declaration +\*---------------------------------------------------------------------------*/ + +//- Like Foam::Circulator, but with const-access iterators +template +class ConstCirculator +: + public CirculatorIters +{ +public: + + // Constructors + + //- Default construct + ConstCirculator() = default; + + //- Construct from begin/end of a container + explicit ConstCirculator(const Container& obj) + : + CirculatorIters(obj.begin(), obj.end()) + {} + + //- Construct from two iterators + inline ConstCirculator + ( + const typename Container::const_iterator& begin, + const typename Container::const_iterator& end + ) + : + CirculatorIters(begin, end) + {} + + //- Copy construct + ConstCirculator(const ConstCirculator& rhs) = default; + + + // Member Operators + + //- Copy assignment + ConstCirculator& operator= + ( + const ConstCirculator& rhs + ) = default; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "CirculatorI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/Circulator/Circulator.H b/src/OpenFOAM/containers/Circulators/Circulator/Circulator.H deleted file mode 100644 index a60f781470..0000000000 --- a/src/OpenFOAM/containers/Circulators/Circulator/Circulator.H +++ /dev/null @@ -1,229 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2012-2015 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::Circulator - -Description - Walks over a container as if it were circular. The container must have the - following members defined: - - value_type - - size_type - - difference_type - - iterator - - reference - - Examples - - \code - face f(identity(5)); - - // Construct Circulator from the face - Circulator circ(f); - - // First check that the Circulator has a size to iterate over. - // Then circulate around the list starting and finishing at the fulcrum. - if (circ.size()) do - { - circ() += 1; - - Info<< "Iterate forwards over face : " << circ() << endl; - - } while (circ.circulate(CirculatorBase::CLOCKWISE)); - \endcode - -SourceFiles - CirculatorI.H - -\*---------------------------------------------------------------------------*/ - -#ifndef Circulator_H -#define Circulator_H - -#include "CirculatorBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - - -/*---------------------------------------------------------------------------*\ - Class Circulator Declaration -\*---------------------------------------------------------------------------*/ - -template -class Circulator -: - public CirculatorBase -{ - -protected: - - // Protected data - - //- Iterator pointing to the beginning of the container - typename ContainerType::iterator begin_; - - //- Iterator pointing to the end of the container - typename ContainerType::iterator end_; - - //- Random access iterator for traversing ContainerType. - typename ContainerType::iterator iter_; - - //- Iterator holding the location of the fulcrum (start and end) of - // the container. Used to decide when the iterator should stop - // circulating over the container - typename ContainerType::iterator fulcrum_; - - -public: - - // STL type definitions - - //- Type of values ContainerType contains. - typedef typename ContainerType::value_type value_type; - - //- The type that can represent the size of ContainerType - typedef typename ContainerType::size_type size_type; - - //- The type that can represent the difference between any two - // iterator objects. - typedef typename ContainerType::difference_type difference_type; - - //- Random access iterator for traversing ContainerType. - typedef typename ContainerType::iterator iterator; - - //- Type that can be used for storing into - // ContainerType::value_type objects. - typedef typename ContainerType::reference reference; - - - // Constructors - - //- Construct null - inline Circulator(); - - //- Construct from a container. - inline explicit Circulator(ContainerType& container); - - //- Construct from two iterators - inline Circulator(const iterator& begin, const iterator& end); - - //- Construct as copy - inline Circulator(const Circulator&); - - - //- Destructor - ~Circulator(); - - - // Member Functions - - //- Return the range of the iterator - inline size_type size() const; - - //- Circulate around the list in the given direction - inline bool circulate(const CirculatorBase::direction dir = NONE); - - //- Set the fulcrum to the current position of the iterator - inline void setFulcrumToIterator(); - - //- Set the iterator to the current position of the fulcrum - inline void setIteratorToFulcrum(); - - //- Return the distance between the iterator and the fulcrum. This is - // equivalent to the number of rotations of the Circulator. - inline difference_type nRotations() const; - - //- Dereference the next iterator and return - inline reference next() const; - - //- Dereference the previous iterator and return - inline reference prev() const; - - - // Member Operators - - //- Assignment operator for Circulators that operate on the same - // container type - inline void operator=(const Circulator&); - - //- Prefix increment. Increments the iterator. - // Sets the iterator to the beginning of the container if it reaches - // the end - inline Circulator& operator++(); - - //- Postfix increment. Increments the iterator. - // Sets the iterator to the beginning of the container if it reaches - // the end - inline Circulator operator++(int); - - //- Prefix decrement. Decrements the iterator. - // Sets the iterator to the end of the container if it reaches - // the beginning - inline Circulator& operator--(); - - //- Postfix decrement. Decrements the iterator. - // Sets the iterator to the end of the container if it reaches - // the beginning - inline Circulator operator--(int); - - //- Check for equality of this iterator with another iterator that - // operate on the same container type - inline bool operator==(const Circulator& c) const; - - //- Check for inequality of this iterator with another iterator that - // operate on the same container type - inline bool operator!=(const Circulator& c) const; - - //- Dereference the iterator and return - inline reference operator*() const; - - //- Dereference the iterator and return - inline reference operator()() const; - - //- Return the difference between this iterator and another iterator - // that operate on the same container type - inline difference_type operator- - ( - const Circulator& c - ) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "CirculatorI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/Circulator/CirculatorI.H b/src/OpenFOAM/containers/Circulators/Circulator/CirculatorI.H deleted file mode 100644 index 88aa28fe42..0000000000 --- a/src/OpenFOAM/containers/Circulators/Circulator/CirculatorI.H +++ /dev/null @@ -1,287 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::Circulator::Circulator() -: - CirculatorBase(), - begin_(0), - end_(0), - iter_(0), - fulcrum_(0) -{} - - -template -Foam::Circulator::Circulator(ContainerType& container) -: - CirculatorBase(), - begin_(container.begin()), - end_(container.end()), - iter_(begin_), - fulcrum_(begin_) -{} - - -template -Foam::Circulator::Circulator -( - const iterator& begin, - const iterator& end -) -: - CirculatorBase(), - begin_(begin), - end_(end), - iter_(begin), - fulcrum_(begin) -{} - - -template -Foam::Circulator::Circulator -( - const Circulator& rhs -) -: - CirculatorBase(), - begin_(rhs.begin_), - end_(rhs.end_), - iter_(rhs.iter_), - fulcrum_(rhs.fulcrum_) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::Circulator::~Circulator() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -typename Foam::Circulator::size_type -Foam::Circulator::size() const -{ - return end_ - begin_; -} - - -template -bool Foam::Circulator::circulate -( - const CirculatorBase::direction dir -) -{ - if (dir == CirculatorBase::CLOCKWISE) - { - operator++(); - } - else if (dir == CirculatorBase::ANTICLOCKWISE) - { - operator--(); - } - - return !(iter_ == fulcrum_); -} - - -template -void Foam::Circulator::setFulcrumToIterator() -{ - fulcrum_ = iter_; -} - - -template -void Foam::Circulator::setIteratorToFulcrum() -{ - iter_ = fulcrum_; -} - - -template -typename Foam::Circulator::difference_type -Foam::Circulator::nRotations() const -{ - return (iter_ - fulcrum_); -} - - -template -typename Foam::Circulator::reference -Foam::Circulator::next() const -{ - if (iter_ == end_ - 1) - { - return *begin_; - } - - return *(iter_ + 1); -} - - -template -typename Foam::Circulator::reference -Foam::Circulator::prev() const -{ - if (iter_ == begin_) - { - return *(end_ - 1); - } - - return *(iter_ - 1); -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template -void Foam::Circulator::operator= -( - const Circulator& rhs -) -{ - if (this == &rhs) - { - return; // Self-assignment is a no-op - } - - begin_ = rhs.begin_; - end_ = rhs.end_; - iter_ = rhs.iter_; - fulcrum_ = rhs.fulcrum_; -} - - -template -Foam::Circulator& -Foam::Circulator::operator++() -{ - ++iter_; - if (iter_ == end_) - { - iter_ = begin_; - } - - return *this; -} - - -template -Foam::Circulator -Foam::Circulator::operator++(int) -{ - Circulator tmp = *this; - ++(*this); - return tmp; -} - - -template -Foam::Circulator& -Foam::Circulator::operator--() -{ - if (iter_ == begin_) - { - iter_ = end_; - } - --iter_; - - return *this; -} - - -template -Foam::Circulator -Foam::Circulator::operator--(int) -{ - Circulator tmp = *this; - --(*this); - return tmp; -} - - -template -bool Foam::Circulator::operator== -( - const Circulator& c -) const -{ - return - ( - begin_ == c.begin_ - && end_ == c.end_ - && iter_ == c.iter_ - && fulcrum_ == c.fulcrum_ - ); -} - - -template -bool Foam::Circulator::operator!= -( - const Circulator& c -) const -{ - return !(*this == c); -} - - -template -typename Foam::Circulator::reference -Foam::Circulator::operator*() const -{ - return *iter_; -} - - -template -typename Foam::Circulator::reference -Foam::Circulator::operator()() const -{ - return operator*(); -} - - -template -typename Foam::Circulator::difference_type -Foam::Circulator::operator- -( - const Circulator& c -) const -{ - return iter_ - c.iter_; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/CirculatorBase.H b/src/OpenFOAM/containers/Circulators/CirculatorBase.H new file mode 100644 index 0000000000..7cec1b4541 --- /dev/null +++ b/src/OpenFOAM/containers/Circulators/CirculatorBase.H @@ -0,0 +1 @@ +#warning File removed - left for old dependency check only diff --git a/src/OpenFOAM/containers/Circulators/CirculatorBase/CirculatorBase.H b/src/OpenFOAM/containers/Circulators/CirculatorBase/CirculatorBase.H deleted file mode 100644 index 23e92b2886..0000000000 --- a/src/OpenFOAM/containers/Circulators/CirculatorBase/CirculatorBase.H +++ /dev/null @@ -1,80 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2012 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::CirculatorBase - -Description - Base class for circulators - -\*---------------------------------------------------------------------------*/ - -#ifndef CirculatorBase_H -#define CirculatorBase_H - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - - -/*---------------------------------------------------------------------------*\ - Class CirculatorBase Declaration -\*---------------------------------------------------------------------------*/ - -class CirculatorBase -{ -public: - - // Public data - - //- Direction type enumeration - enum direction - { - NONE, - CLOCKWISE, - ANTICLOCKWISE - }; - - - // Constructors - - //- Construct null - CirculatorBase() - {} - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/CirculatorI.H b/src/OpenFOAM/containers/Circulators/CirculatorI.H new file mode 100644 index 0000000000..649060ddbf --- /dev/null +++ b/src/OpenFOAM/containers/Circulators/CirculatorI.H @@ -0,0 +1,306 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2019-2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +bool Foam::CirculatorIters::equal +( + const CirculatorIters& rhs +) +{ + return + ( + begin_ == rhs.begin_ + && end_ == rhs.end_ + && iter_ == rhs.iter_ + && fulcrum_ == rhs.fulcrum_ + ); +} + + +template +void Foam::CirculatorIters::increment() +{ + ++iter_; + if (iter_ == end_) + { + iter_ = begin_; + } +} + + +template +void Foam::CirculatorIters::decrement() +{ + if (iter_ == begin_) + { + iter_ = end_; + } + --iter_; +} + + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CirculatorIters::CirculatorIters() +: + begin_(0), + end_(0), + iter_(0), + fulcrum_(0) +{} + + +template +Foam::CirculatorIters::CirculatorIters +( + const iterator& begin, + const iterator& end +) +: + begin_(begin), + end_(end), + iter_(begin_), + fulcrum_(begin_) +{} + + +template +Foam::CirculatorIters::CirculatorIters +( + const CirculatorIters& rhs +) +: + begin_(rhs.begin_), + end_(rhs.end_), + iter_(rhs.iter_), + fulcrum_(rhs.fulcrum_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::CirculatorIters::empty() const +{ + return (end_ == begin_); +} + + +template +typename Foam::CirculatorIters::size_type +Foam::CirculatorIters::size() const +{ + return (end_ - begin_); +} + + +template +typename Foam::CirculatorIters::difference_type +Foam::CirculatorIters::nRotations() const +{ + return (iter_ - fulcrum_); +} + + +template +bool Foam::CirculatorIters::circulate +( + const CirculatorBase::direction dir +) +{ + if (dir == CirculatorBase::CLOCKWISE) + { + increment(); + } + else if (dir == CirculatorBase::ANTICLOCKWISE) + { + decrement(); + } + + return !(iter_ == fulcrum_); +} + + +template +void Foam::CirculatorIters::setFulcrumToIterator() +{ + fulcrum_ = iter_; +} + + +template +void Foam::CirculatorIters::setIteratorToFulcrum() +{ + iter_ = fulcrum_; +} + + +template +typename Foam::CirculatorIters::reference +Foam::CirculatorIters::curr() const +{ + return *iter_; +} + + +template +typename Foam::CirculatorIters::reference +Foam::CirculatorIters::next() const +{ + if (iter_ == end_ - 1) + { + return *begin_; + } + + return *(iter_ + 1); +} + + +template +typename Foam::CirculatorIters::reference +Foam::CirculatorIters::prev() const +{ + if (iter_ == begin_) + { + return *(end_ - 1); + } + + return *(iter_ - 1); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +void Foam::CirculatorIters::operator= +( + const CirculatorIters& rhs +) +{ + if (this == &rhs) + { + return; // Self-assignment is a no-op + } + + begin_ = rhs.begin_; + end_ = rhs.end_; + iter_ = rhs.iter_; + fulcrum_ = rhs.fulcrum_; +} + + +template +Foam::CirculatorIters& +Foam::CirculatorIters::operator++() +{ + this->increment(); + return *this; +} + + +template +Foam::CirculatorIters +Foam::CirculatorIters::operator++(int) +{ + auto old(*this); + this->increment(); + return old; +} + + +template +Foam::CirculatorIters& +Foam::CirculatorIters::operator--() +{ + this->decrement(); + return *this; +} + + +template +Foam::CirculatorIters +Foam::CirculatorIters::operator--(int) +{ + auto old(*this); + this->decrement(); + return old; +} + + +template +bool Foam::CirculatorIters::operator== +( + const CirculatorIters& rhs +) const +{ + return this->equal(rhs); +} + + +template +bool Foam::CirculatorIters::operator!= +( + const CirculatorIters& rhs +) const +{ + return !this->equal(rhs); +} + + +template +typename Foam::CirculatorIters::reference +Foam::CirculatorIters::operator*() const +{ + return *iter_; +} + + +template +typename Foam::CirculatorIters::reference +Foam::CirculatorIters::operator()() const +{ + return *iter_; +} + + +template +typename Foam::CirculatorIters::difference_type +Foam::CirculatorIters::operator- +( + const CirculatorIters& rhs +) const +{ + return (iter_ - rhs.iter_); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/ConstCirculator.H b/src/OpenFOAM/containers/Circulators/ConstCirculator.H new file mode 100644 index 0000000000..dffac1a805 --- /dev/null +++ b/src/OpenFOAM/containers/Circulators/ConstCirculator.H @@ -0,0 +1,2 @@ +// Compatibility include +#include "Circulator.H" diff --git a/src/OpenFOAM/containers/Circulators/ConstCirculator/ConstCirculator.H b/src/OpenFOAM/containers/Circulators/ConstCirculator/ConstCirculator.H deleted file mode 100644 index 78b23d19f4..0000000000 --- a/src/OpenFOAM/containers/Circulators/ConstCirculator/ConstCirculator.H +++ /dev/null @@ -1,249 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2012-2015 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::ConstCirculator - -Description - Walks over a container as if it were circular. The container must have the - following members defined: - - value_type - - size_type - - difference_type - - const_iterator - - const_reference - - Examples: - - \code - face f(identity(5)); - - // Construct circulator from the face - ConstCirculator circ(f); - - // First check that the circulator has a size to iterate over. - // Then circulate around the list starting and finishing at the fulcrum. - if (circ.size()) do - { - Info<< "Iterate forwards over face : " << circ() << endl; - - } while (circ.circulate(CirculatorBase::CLOCKWISE)); - \endcode - - \code - face f(identity(5)); - - ConstCirculator circClockwise(f); - ConstCirculator circAnticlockwise(f); - - if (circClockwise.size() && circAnticlockwise.size()) do - { - Info<< "Iterate forward over face :" << circClockwise() << endl; - Info<< "Iterate backward over face:" << circAnticlockwise() << endl; - } - while - ( - circClockwise.circulate(CirculatorBase::CLOCKWISE), - circAnticlockwise.circulate(CirculatorBase::ANTICLOCKWISE) - ); - \endcode - -SourceFiles - ConstCirculatorI.H - -\*---------------------------------------------------------------------------*/ - -#ifndef ConstCirculator_H -#define ConstCirculator_H - -#include "CirculatorBase.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - - -/*---------------------------------------------------------------------------*\ - Class ConstCirculator Declaration -\*---------------------------------------------------------------------------*/ - -template -class ConstCirculator -: - public CirculatorBase -{ - -protected: - - // Protected data - - //- Iterator pointing to the beginning of the container - typename ContainerType::const_iterator begin_; - - //- Iterator pointing to the end of the container - typename ContainerType::const_iterator end_; - - //- Iterator - typename ContainerType::const_iterator iter_; - - //- Iterator holding the location of the fulcrum (start and end) of - // the container. Used to decide when the iterator should stop - // circulating over the container - typename ContainerType::const_iterator fulcrum_; - - -public: - - // STL type definitions - - //- Type of values ContainerType contains. - typedef typename ContainerType::value_type value_type; - - //- The type that can represent the size of ContainerType - typedef typename ContainerType::size_type size_type; - - //- The type that can represent the difference between any two - // iterator objects. - typedef typename ContainerType::difference_type difference_type; - - //- Random access iterator for traversing ContainerType. - typedef typename ContainerType::const_iterator const_iterator; - - //- Type that can be used for storing into - // const ContainerType::value_type objects. - typedef typename ContainerType::const_reference const_reference; - - - // Constructors - - //- Construct null - inline ConstCirculator(); - - //- Construct from a container. - inline explicit ConstCirculator(const ContainerType& container); - - //- Construct from two iterators - inline ConstCirculator - ( - const const_iterator& begin, - const const_iterator& end - ); - - //- Construct as copy - inline ConstCirculator(const ConstCirculator&); - - - //- Destructor - ~ConstCirculator(); - - - // Member Functions - - //- Return the range of the iterator - inline size_type size() const; - - //- Circulate around the list in the given direction - inline bool circulate(const CirculatorBase::direction dir = NONE); - - //- Set the fulcrum to the current position of the iterator - inline void setFulcrumToIterator(); - - //- Set the iterator to the current position of the fulcrum - inline void setIteratorToFulcrum(); - - //- Return the distance between the iterator and the fulcrum. This is - // equivalent to the number of rotations of the circulator. - inline difference_type nRotations() const; - - //- Dereference the next iterator and return - inline const_reference next() const; - - //- Dereference the previous iterator and return - inline const_reference prev() const; - - - // Member Operators - - //- Assignment operator for circulators that operate on the same - // container type - inline void operator=(const ConstCirculator&); - - //- Prefix increment. Increments the iterator. - // Sets the iterator to the beginning of the container if it reaches - // the end - inline ConstCirculator& operator++(); - - //- Postfix increment. Increments the iterator. - // Sets the iterator to the beginning of the container if it reaches - // the end - inline ConstCirculator operator++(int); - - //- Prefix decrement. Decrements the iterator. - // Sets the iterator to the end of the container if it reaches - // the beginning - inline ConstCirculator& operator--(); - - //- Postfix decrement. Decrements the iterator. - // Sets the iterator to the end of the container if it reaches - // the beginning - inline ConstCirculator operator--(int); - - //- Check for equality of this iterator with another iterator that - // operate on the same container type - inline bool operator==(const ConstCirculator& c) const; - - //- Check for inequality of this iterator with another iterator that - // operate on the same container type - inline bool operator!=(const ConstCirculator& c) const; - - //- Dereference the iterator and return - inline const_reference operator*() const; - - //- Dereference the iterator and return - inline const_reference operator()() const; - - //- Return the difference between this iterator and another iterator - // that operate on the same container type - inline difference_type operator- - ( - const ConstCirculator& c - ) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "ConstCirculatorI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/ConstCirculator/ConstCirculatorI.H b/src/OpenFOAM/containers/Circulators/ConstCirculator/ConstCirculatorI.H deleted file mode 100644 index fded93cc55..0000000000 --- a/src/OpenFOAM/containers/Circulators/ConstCirculator/ConstCirculatorI.H +++ /dev/null @@ -1,292 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "error.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::ConstCirculator::ConstCirculator() -: - CirculatorBase(), - begin_(0), - end_(0), - iter_(0), - fulcrum_(0) -{} - - -template -Foam::ConstCirculator::ConstCirculator -( - const ContainerType& container -) -: - CirculatorBase(), - begin_(container.begin()), - end_(container.end()), - iter_(begin_), - fulcrum_(begin_) -{} - - -template -Foam::ConstCirculator::ConstCirculator -( - const const_iterator& begin, - const const_iterator& end -) -: - CirculatorBase(), - begin_(begin), - end_(end), - iter_(begin), - fulcrum_(begin) -{} - - -template -Foam::ConstCirculator::ConstCirculator -( - const ConstCirculator& rhs -) -: - CirculatorBase(), - begin_(rhs.begin_), - end_(rhs.end_), - iter_(rhs.iter_), - fulcrum_(rhs.fulcrum_) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::ConstCirculator::~ConstCirculator() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -typename Foam::ConstCirculator::size_type -Foam::ConstCirculator::size() const -{ - return end_ - begin_; -} - - -template -bool Foam::ConstCirculator::circulate -( - const CirculatorBase::direction dir -) -{ - if (dir == CirculatorBase::CLOCKWISE) - { - operator++(); - } - else if (dir == CirculatorBase::ANTICLOCKWISE) - { - operator--(); - } - - return !(iter_ == fulcrum_); -} - - -template -void Foam::ConstCirculator::setFulcrumToIterator() -{ - fulcrum_ = iter_; -} - - -template -void Foam::ConstCirculator::setIteratorToFulcrum() -{ - iter_ = fulcrum_; -} - - -template -typename Foam::ConstCirculator::difference_type -Foam::ConstCirculator::nRotations() const -{ - return (iter_ - fulcrum_); -} - - -template -typename Foam::ConstCirculator::const_reference -Foam::ConstCirculator::next() const -{ - if (iter_ == end_ - 1) - { - return *begin_; - } - - return *(iter_ + 1); -} - - -template -typename Foam::ConstCirculator::const_reference -Foam::ConstCirculator::prev() const -{ - if (iter_ == begin_) - { - return *(end_ - 1); - } - - return *(iter_ - 1); -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template -void Foam::ConstCirculator::operator= -( - const ConstCirculator& rhs -) -{ - if (this == &rhs) - { - return; // Self-assignment is a no-op - } - - begin_ = rhs.begin_; - end_ = rhs.end_; - iter_ = rhs.iter_; - fulcrum_ = rhs.fulcrum_; -} - - -template -Foam::ConstCirculator& -Foam::ConstCirculator::operator++() -{ - ++iter_; - if (iter_ == end_) - { - iter_ = begin_; - } - - return *this; -} - - -template -Foam::ConstCirculator -Foam::ConstCirculator::operator++(int) -{ - ConstCirculator tmp = *this; - ++(*this); - return tmp; -} - - -template -Foam::ConstCirculator& -Foam::ConstCirculator::operator--() -{ - if (iter_ == begin_) - { - iter_ = end_; - } - --iter_; - - return *this; -} - - -template -Foam::ConstCirculator -Foam::ConstCirculator::operator--(int) -{ - ConstCirculator tmp = *this; - --(*this); - return tmp; -} - - -template -bool Foam::ConstCirculator::operator== -( - const ConstCirculator& c -) const -{ - return - ( - begin_ == c.begin_ - && end_ == c.end_ - && iter_ == c.iter_ - && fulcrum_ == c.fulcrum_ - ); -} - - -template -bool Foam::ConstCirculator::operator!= -( - const ConstCirculator& c -) const -{ - return !(*this == c); -} - - -template -typename Foam::ConstCirculator::const_reference -Foam::ConstCirculator::operator*() const -{ - return *iter_; -} - - -template -typename Foam::ConstCirculator::const_reference -Foam::ConstCirculator::operator()() const -{ - return operator*(); -} - - -template -typename Foam::ConstCirculator::difference_type -Foam::ConstCirculator::operator- -( - const ConstCirculator& c -) const -{ - return iter_ - c.iter_; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Circulators/ConstCirculatorI.H b/src/OpenFOAM/containers/Circulators/ConstCirculatorI.H new file mode 100644 index 0000000000..7cec1b4541 --- /dev/null +++ b/src/OpenFOAM/containers/Circulators/ConstCirculatorI.H @@ -0,0 +1 @@ +#warning File removed - left for old dependency check only diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index 314a325ada..0b47dc7000 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -30,7 +30,7 @@ License #include "triFace.H" #include "triPointRef.H" #include "mathematicalConstants.H" -#include "ConstCirculator.H" +#include "Circulator.H" #include // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -330,7 +330,7 @@ int Foam::face::compare(const face& a, const face& b) // Look forwards around the faces for a match do { - if (aCirc() != bCirc()) + if (*aCirc != *bCirc) { break; } @@ -358,7 +358,7 @@ int Foam::face::compare(const face& a, const face& b) // Look backwards around the faces for a match do { - if (aCirc() != bCirc()) + if (*aCirc != *bCirc) { break; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 27cda877c0..1bc1fc4336 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -36,7 +36,7 @@ License #include "Time.H" #include "transformList.H" #include "PstreamBuffers.H" -#include "ConstCirculator.H" +#include "Circulator.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -666,12 +666,12 @@ Foam::label Foam::processorPolyPatch::matchFace do { - const scalar diffSqr = magSqr(aPts[aCirc()] - bPts[bCirc()]); + const scalar diffSqr = magSqr(aPts[*aCirc] - bPts[*bCirc]); if (diffSqr < absTolSqr) { // Found a matching point. Set the fulcrum of b to the iterator - ConstCirculator bCirc2 = bCirc; + ConstCirculator bCirc2(bCirc); ++aCirc; bCirc2.setFulcrumToIterator(); @@ -689,7 +689,7 @@ Foam::label Foam::processorPolyPatch::matchFace do { - const scalar diffSqr2 = magSqr(aPts[aCirc()] - bPts[bCirc2()]); + const scalar diffSqr2 = magSqr(aPts[*aCirc] - bPts[*bCirc2]); if (diffSqr2 > absTolSqr) { diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H index 2be95bd9bc..3c30e16d9e 100644 --- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H +++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculator.H @@ -93,18 +93,18 @@ class edgeFaceCirculator //- The underlying mesh pointer const primitiveMesh* meshPtr_; - //- Current face - label faceLabel_; - - //- Current side of face + //- Is current side of face the owner side? bool ownerSide_; - //- Edge (between index and index+1 on faces[faceLabel_] - label index_; - //- Is boundary edge? bool isBoundaryEdge_; + //- Current face + label faceLabel_; + + //- Edge (between index and index+1 on faces[faceLabel_] + label index_; + //- Starting face so we know when to stop. Used when circulating over // internal edges. label startFaceLabel_; @@ -124,7 +124,7 @@ class edgeFaceCirculator //- Set faceLabel_ to be the other face on the cell that uses the edge. inline void otherFace(const label celli); - //- Construct null - this is also an end iterator + //- Default construct - this is also an end iterator inline edgeFaceCirculator(); diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H index 0ba77ae966..e85705d5e5 100644 --- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H +++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H @@ -100,10 +100,10 @@ void Foam::edgeFaceCirculator::otherFace(const label celli) Foam::edgeFaceCirculator::edgeFaceCirculator() : meshPtr_(nullptr), - faceLabel_(-1), ownerSide_(false), - index_(-1), isBoundaryEdge_(false), + faceLabel_(-1), + index_(-1), startFaceLabel_(0) {} @@ -120,8 +120,8 @@ Foam::edgeFaceCirculator::edgeFaceCirculator meshPtr_(&mesh), faceLabel_(faceLabel), ownerSide_(ownerSide), - index_(index), isBoundaryEdge_(isBoundaryEdge), + index_(index), startFaceLabel_(faceLabel_) {} @@ -129,10 +129,10 @@ Foam::edgeFaceCirculator::edgeFaceCirculator Foam::edgeFaceCirculator::edgeFaceCirculator(const edgeFaceCirculator& circ) : meshPtr_(circ.meshPtr_), - faceLabel_(circ.faceLabel_), ownerSide_(circ.ownerSide_), - index_(circ.index_), isBoundaryEdge_(circ.isBoundaryEdge_), + faceLabel_(circ.faceLabel_), + index_(circ.index_), startFaceLabel_(circ.startFaceLabel_) {} @@ -340,10 +340,10 @@ void Foam::edgeFaceCirculator::setCanonical() void Foam::edgeFaceCirculator::operator=(const edgeFaceCirculator& circ) { - faceLabel_ = circ.faceLabel_; ownerSide_ = circ.ownerSide_; - index_ = circ.index_; isBoundaryEdge_ = circ.isBoundaryEdge_; + faceLabel_ = circ.faceLabel_; + index_ = circ.index_; startFaceLabel_ = circ.startFaceLabel_; } @@ -422,25 +422,6 @@ Foam::edgeFaceCirculator::operator++() } -Foam::edgeFaceCirculator Foam::edgeFaceCirculator::begin() const -{ - edgeFaceCirculator iter - ( - *meshPtr_, - faceLabel_, - ownerSide_, - index_, - isBoundaryEdge_ - ); - - if (isBoundaryEdge_) - { - iter.setCanonical(); - } - return iter; -} - - Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const { edgeFaceCirculator iter @@ -460,6 +441,11 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const } +Foam::edgeFaceCirculator Foam::edgeFaceCirculator::begin() const +{ + return cbegin(); +} + const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::end() const { return edgeFaceCirculator();