ENH: eliminate code duplication in Circulator/ConstCirculator

This commit is contained in:
Mark Olesen 2022-03-07 09:22:58 +01:00
parent c1eb5413d5
commit 47cd988296
17 changed files with 768 additions and 1214 deletions

View File

@ -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<face> foo;
// Info<< "size: " << foo.size() << nl;
ConstCirculator<face> 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<face> 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<face> circForward(f);
ConstCirculator<face> 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;

View File

@ -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

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/>.
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<face> 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 <type_traits> // 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 Container, bool Const>
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<Container, Const>& 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<Container, Const>& 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<Container, Const>& rhs);
//- Prefix increment the iterator.
// Wraps iterator to the begin if it reaches the end
inline CirculatorIters<Container, Const>& operator++();
//- Postfix increment the iterator.
// Wraps iterator to the begin if it reaches the end
inline CirculatorIters<Container, Const> operator++(int);
//- Prefix decrement the iterator.
// Wraps iterator to the end if it reaches the beginning
inline CirculatorIters<Container, Const>& operator--();
//- Postfix decrement the iterator.
// Wraps iterator to the end if it reaches the beginning
inline CirculatorIters<Container, Const> operator--(int);
//- Check for equality of this iterator with another iterator that
//- operate on the same container type
inline bool operator==
(
const CirculatorIters<Container, Const>&
) const;
//- Check for inequality of this iterator with another iterator that
//- operate on the same container type
inline bool operator!=
(
const CirculatorIters<Container, Const>&
) 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<Container, Const>&
) const;
};
/*---------------------------------------------------------------------------*\
Class Circulator Declaration
\*---------------------------------------------------------------------------*/
template<class Container>
class Circulator
:
public CirculatorIters<Container, false>
{
public:
// Constructors
//- Default construct
Circulator() = default;
//- Construct from begin/end of a container
explicit Circulator(Container& obj)
:
CirculatorIters<Container, false>(obj.begin(), obj.end())
{}
//- Construct from two iterators
Circulator
(
const typename Container::iterator& begin,
const typename Container::iterator& end
)
:
CirculatorIters<Container, false>(begin, end)
{}
//- Copy construct
Circulator(const Circulator<Container>& rhs) = default;
// Member Operators
//- Copy assignment
Circulator<Container>& operator=
(
const Circulator<Container>& rhs
) = default;
};
/*---------------------------------------------------------------------------*\
Class ConstCirculator Declaration
\*---------------------------------------------------------------------------*/
//- Like Foam::Circulator, but with const-access iterators
template<class Container>
class ConstCirculator
:
public CirculatorIters<Container, true>
{
public:
// Constructors
//- Default construct
ConstCirculator() = default;
//- Construct from begin/end of a container
explicit ConstCirculator(const Container& obj)
:
CirculatorIters<Container, true>(obj.begin(), obj.end())
{}
//- Construct from two iterators
inline ConstCirculator
(
const typename Container::const_iterator& begin,
const typename Container::const_iterator& end
)
:
CirculatorIters<Container, true>(begin, end)
{}
//- Copy construct
ConstCirculator(const ConstCirculator<Container>& rhs) = default;
// Member Operators
//- Copy assignment
ConstCirculator<Container>& operator=
(
const ConstCirculator<Container>& rhs
) = default;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CirculatorI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
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<face> 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 ContainerType>
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<ContainerType>&);
//- 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<ContainerType>&);
//- Prefix increment. Increments the iterator.
// Sets the iterator to the beginning of the container if it reaches
// the end
inline Circulator<ContainerType>& operator++();
//- Postfix increment. Increments the iterator.
// Sets the iterator to the beginning of the container if it reaches
// the end
inline Circulator<ContainerType> operator++(int);
//- Prefix decrement. Decrements the iterator.
// Sets the iterator to the end of the container if it reaches
// the beginning
inline Circulator<ContainerType>& operator--();
//- Postfix decrement. Decrements the iterator.
// Sets the iterator to the end of the container if it reaches
// the beginning
inline Circulator<ContainerType> operator--(int);
//- Check for equality of this iterator with another iterator that
// operate on the same container type
inline bool operator==(const Circulator<ContainerType>& c) const;
//- Check for inequality of this iterator with another iterator that
// operate on the same container type
inline bool operator!=(const Circulator<ContainerType>& 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<ContainerType>& c
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CirculatorI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ContainerType>
Foam::Circulator<ContainerType>::Circulator()
:
CirculatorBase(),
begin_(0),
end_(0),
iter_(0),
fulcrum_(0)
{}
template<class ContainerType>
Foam::Circulator<ContainerType>::Circulator(ContainerType& container)
:
CirculatorBase(),
begin_(container.begin()),
end_(container.end()),
iter_(begin_),
fulcrum_(begin_)
{}
template<class ContainerType>
Foam::Circulator<ContainerType>::Circulator
(
const iterator& begin,
const iterator& end
)
:
CirculatorBase(),
begin_(begin),
end_(end),
iter_(begin),
fulcrum_(begin)
{}
template<class ContainerType>
Foam::Circulator<ContainerType>::Circulator
(
const Circulator<ContainerType>& rhs
)
:
CirculatorBase(),
begin_(rhs.begin_),
end_(rhs.end_),
iter_(rhs.iter_),
fulcrum_(rhs.fulcrum_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ContainerType>
Foam::Circulator<ContainerType>::~Circulator()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ContainerType>
typename Foam::Circulator<ContainerType>::size_type
Foam::Circulator<ContainerType>::size() const
{
return end_ - begin_;
}
template<class ContainerType>
bool Foam::Circulator<ContainerType>::circulate
(
const CirculatorBase::direction dir
)
{
if (dir == CirculatorBase::CLOCKWISE)
{
operator++();
}
else if (dir == CirculatorBase::ANTICLOCKWISE)
{
operator--();
}
return !(iter_ == fulcrum_);
}
template<class ContainerType>
void Foam::Circulator<ContainerType>::setFulcrumToIterator()
{
fulcrum_ = iter_;
}
template<class ContainerType>
void Foam::Circulator<ContainerType>::setIteratorToFulcrum()
{
iter_ = fulcrum_;
}
template<class ContainerType>
typename Foam::Circulator<ContainerType>::difference_type
Foam::Circulator<ContainerType>::nRotations() const
{
return (iter_ - fulcrum_);
}
template<class ContainerType>
typename Foam::Circulator<ContainerType>::reference
Foam::Circulator<ContainerType>::next() const
{
if (iter_ == end_ - 1)
{
return *begin_;
}
return *(iter_ + 1);
}
template<class ContainerType>
typename Foam::Circulator<ContainerType>::reference
Foam::Circulator<ContainerType>::prev() const
{
if (iter_ == begin_)
{
return *(end_ - 1);
}
return *(iter_ - 1);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class ContainerType>
void Foam::Circulator<ContainerType>::operator=
(
const Circulator<ContainerType>& rhs
)
{
if (this == &rhs)
{
return; // Self-assignment is a no-op
}
begin_ = rhs.begin_;
end_ = rhs.end_;
iter_ = rhs.iter_;
fulcrum_ = rhs.fulcrum_;
}
template<class ContainerType>
Foam::Circulator<ContainerType>&
Foam::Circulator<ContainerType>::operator++()
{
++iter_;
if (iter_ == end_)
{
iter_ = begin_;
}
return *this;
}
template<class ContainerType>
Foam::Circulator<ContainerType>
Foam::Circulator<ContainerType>::operator++(int)
{
Circulator<ContainerType> tmp = *this;
++(*this);
return tmp;
}
template<class ContainerType>
Foam::Circulator<ContainerType>&
Foam::Circulator<ContainerType>::operator--()
{
if (iter_ == begin_)
{
iter_ = end_;
}
--iter_;
return *this;
}
template<class ContainerType>
Foam::Circulator<ContainerType>
Foam::Circulator<ContainerType>::operator--(int)
{
Circulator<ContainerType> tmp = *this;
--(*this);
return tmp;
}
template<class ContainerType>
bool Foam::Circulator<ContainerType>::operator==
(
const Circulator<ContainerType>& c
) const
{
return
(
begin_ == c.begin_
&& end_ == c.end_
&& iter_ == c.iter_
&& fulcrum_ == c.fulcrum_
);
}
template<class ContainerType>
bool Foam::Circulator<ContainerType>::operator!=
(
const Circulator<ContainerType>& c
) const
{
return !(*this == c);
}
template<class ContainerType>
typename Foam::Circulator<ContainerType>::reference
Foam::Circulator<ContainerType>::operator*() const
{
return *iter_;
}
template<class ContainerType>
typename Foam::Circulator<ContainerType>::reference
Foam::Circulator<ContainerType>::operator()() const
{
return operator*();
}
template<class ContainerType>
typename Foam::Circulator<ContainerType>::difference_type
Foam::Circulator<ContainerType>::operator-
(
const Circulator<ContainerType>& c
) const
{
return iter_ - c.iter_;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
#warning File removed - left for old dependency check only

View File

@ -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 <http://www.gnu.org/licenses/>.
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
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Container, bool Const>
bool Foam::CirculatorIters<Container, Const>::equal
(
const CirculatorIters<Container, Const>& rhs
)
{
return
(
begin_ == rhs.begin_
&& end_ == rhs.end_
&& iter_ == rhs.iter_
&& fulcrum_ == rhs.fulcrum_
);
}
template<class Container, bool Const>
void Foam::CirculatorIters<Container, Const>::increment()
{
++iter_;
if (iter_ == end_)
{
iter_ = begin_;
}
}
template<class Container, bool Const>
void Foam::CirculatorIters<Container, Const>::decrement()
{
if (iter_ == begin_)
{
iter_ = end_;
}
--iter_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>::CirculatorIters()
:
begin_(0),
end_(0),
iter_(0),
fulcrum_(0)
{}
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>::CirculatorIters
(
const iterator& begin,
const iterator& end
)
:
begin_(begin),
end_(end),
iter_(begin_),
fulcrum_(begin_)
{}
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>::CirculatorIters
(
const CirculatorIters<Container, Const>& rhs
)
:
begin_(rhs.begin_),
end_(rhs.end_),
iter_(rhs.iter_),
fulcrum_(rhs.fulcrum_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Container, bool Const>
bool Foam::CirculatorIters<Container, Const>::empty() const
{
return (end_ == begin_);
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::size_type
Foam::CirculatorIters<Container, Const>::size() const
{
return (end_ - begin_);
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::difference_type
Foam::CirculatorIters<Container, Const>::nRotations() const
{
return (iter_ - fulcrum_);
}
template<class Container, bool Const>
bool Foam::CirculatorIters<Container, Const>::circulate
(
const CirculatorBase::direction dir
)
{
if (dir == CirculatorBase::CLOCKWISE)
{
increment();
}
else if (dir == CirculatorBase::ANTICLOCKWISE)
{
decrement();
}
return !(iter_ == fulcrum_);
}
template<class Container, bool Const>
void Foam::CirculatorIters<Container, Const>::setFulcrumToIterator()
{
fulcrum_ = iter_;
}
template<class Container, bool Const>
void Foam::CirculatorIters<Container, Const>::setIteratorToFulcrum()
{
iter_ = fulcrum_;
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::reference
Foam::CirculatorIters<Container, Const>::curr() const
{
return *iter_;
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::reference
Foam::CirculatorIters<Container, Const>::next() const
{
if (iter_ == end_ - 1)
{
return *begin_;
}
return *(iter_ + 1);
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::reference
Foam::CirculatorIters<Container, Const>::prev() const
{
if (iter_ == begin_)
{
return *(end_ - 1);
}
return *(iter_ - 1);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Container, bool Const>
void Foam::CirculatorIters<Container, Const>::operator=
(
const CirculatorIters<Container, Const>& rhs
)
{
if (this == &rhs)
{
return; // Self-assignment is a no-op
}
begin_ = rhs.begin_;
end_ = rhs.end_;
iter_ = rhs.iter_;
fulcrum_ = rhs.fulcrum_;
}
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>&
Foam::CirculatorIters<Container, Const>::operator++()
{
this->increment();
return *this;
}
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>
Foam::CirculatorIters<Container, Const>::operator++(int)
{
auto old(*this);
this->increment();
return old;
}
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>&
Foam::CirculatorIters<Container, Const>::operator--()
{
this->decrement();
return *this;
}
template<class Container, bool Const>
Foam::CirculatorIters<Container, Const>
Foam::CirculatorIters<Container, Const>::operator--(int)
{
auto old(*this);
this->decrement();
return old;
}
template<class Container, bool Const>
bool Foam::CirculatorIters<Container, Const>::operator==
(
const CirculatorIters<Container, Const>& rhs
) const
{
return this->equal(rhs);
}
template<class Container, bool Const>
bool Foam::CirculatorIters<Container, Const>::operator!=
(
const CirculatorIters<Container, Const>& rhs
) const
{
return !this->equal(rhs);
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::reference
Foam::CirculatorIters<Container, Const>::operator*() const
{
return *iter_;
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::reference
Foam::CirculatorIters<Container, Const>::operator()() const
{
return *iter_;
}
template<class Container, bool Const>
typename Foam::CirculatorIters<Container, Const>::difference_type
Foam::CirculatorIters<Container, Const>::operator-
(
const CirculatorIters<Container, Const>& rhs
) const
{
return (iter_ - rhs.iter_);
}
// ************************************************************************* //

View File

@ -0,0 +1,2 @@
// Compatibility include
#include "Circulator.H"

View File

@ -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 <http://www.gnu.org/licenses/>.
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<face> 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<face> circClockwise(f);
ConstCirculator<face> 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 ContainerType>
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<ContainerType>&);
//- 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<ContainerType>&);
//- Prefix increment. Increments the iterator.
// Sets the iterator to the beginning of the container if it reaches
// the end
inline ConstCirculator<ContainerType>& operator++();
//- Postfix increment. Increments the iterator.
// Sets the iterator to the beginning of the container if it reaches
// the end
inline ConstCirculator<ContainerType> operator++(int);
//- Prefix decrement. Decrements the iterator.
// Sets the iterator to the end of the container if it reaches
// the beginning
inline ConstCirculator<ContainerType>& operator--();
//- Postfix decrement. Decrements the iterator.
// Sets the iterator to the end of the container if it reaches
// the beginning
inline ConstCirculator<ContainerType> operator--(int);
//- Check for equality of this iterator with another iterator that
// operate on the same container type
inline bool operator==(const ConstCirculator<ContainerType>& c) const;
//- Check for inequality of this iterator with another iterator that
// operate on the same container type
inline bool operator!=(const ConstCirculator<ContainerType>& 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<ContainerType>& c
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "ConstCirculatorI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "error.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ContainerType>
Foam::ConstCirculator<ContainerType>::ConstCirculator()
:
CirculatorBase(),
begin_(0),
end_(0),
iter_(0),
fulcrum_(0)
{}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>::ConstCirculator
(
const ContainerType& container
)
:
CirculatorBase(),
begin_(container.begin()),
end_(container.end()),
iter_(begin_),
fulcrum_(begin_)
{}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>::ConstCirculator
(
const const_iterator& begin,
const const_iterator& end
)
:
CirculatorBase(),
begin_(begin),
end_(end),
iter_(begin),
fulcrum_(begin)
{}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>::ConstCirculator
(
const ConstCirculator<ContainerType>& rhs
)
:
CirculatorBase(),
begin_(rhs.begin_),
end_(rhs.end_),
iter_(rhs.iter_),
fulcrum_(rhs.fulcrum_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ContainerType>
Foam::ConstCirculator<ContainerType>::~ConstCirculator()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::size_type
Foam::ConstCirculator<ContainerType>::size() const
{
return end_ - begin_;
}
template<class ContainerType>
bool Foam::ConstCirculator<ContainerType>::circulate
(
const CirculatorBase::direction dir
)
{
if (dir == CirculatorBase::CLOCKWISE)
{
operator++();
}
else if (dir == CirculatorBase::ANTICLOCKWISE)
{
operator--();
}
return !(iter_ == fulcrum_);
}
template<class ContainerType>
void Foam::ConstCirculator<ContainerType>::setFulcrumToIterator()
{
fulcrum_ = iter_;
}
template<class ContainerType>
void Foam::ConstCirculator<ContainerType>::setIteratorToFulcrum()
{
iter_ = fulcrum_;
}
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::difference_type
Foam::ConstCirculator<ContainerType>::nRotations() const
{
return (iter_ - fulcrum_);
}
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::const_reference
Foam::ConstCirculator<ContainerType>::next() const
{
if (iter_ == end_ - 1)
{
return *begin_;
}
return *(iter_ + 1);
}
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::const_reference
Foam::ConstCirculator<ContainerType>::prev() const
{
if (iter_ == begin_)
{
return *(end_ - 1);
}
return *(iter_ - 1);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class ContainerType>
void Foam::ConstCirculator<ContainerType>::operator=
(
const ConstCirculator<ContainerType>& rhs
)
{
if (this == &rhs)
{
return; // Self-assignment is a no-op
}
begin_ = rhs.begin_;
end_ = rhs.end_;
iter_ = rhs.iter_;
fulcrum_ = rhs.fulcrum_;
}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>&
Foam::ConstCirculator<ContainerType>::operator++()
{
++iter_;
if (iter_ == end_)
{
iter_ = begin_;
}
return *this;
}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>
Foam::ConstCirculator<ContainerType>::operator++(int)
{
ConstCirculator<ContainerType> tmp = *this;
++(*this);
return tmp;
}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>&
Foam::ConstCirculator<ContainerType>::operator--()
{
if (iter_ == begin_)
{
iter_ = end_;
}
--iter_;
return *this;
}
template<class ContainerType>
Foam::ConstCirculator<ContainerType>
Foam::ConstCirculator<ContainerType>::operator--(int)
{
ConstCirculator<ContainerType> tmp = *this;
--(*this);
return tmp;
}
template<class ContainerType>
bool Foam::ConstCirculator<ContainerType>::operator==
(
const ConstCirculator<ContainerType>& c
) const
{
return
(
begin_ == c.begin_
&& end_ == c.end_
&& iter_ == c.iter_
&& fulcrum_ == c.fulcrum_
);
}
template<class ContainerType>
bool Foam::ConstCirculator<ContainerType>::operator!=
(
const ConstCirculator<ContainerType>& c
) const
{
return !(*this == c);
}
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::const_reference
Foam::ConstCirculator<ContainerType>::operator*() const
{
return *iter_;
}
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::const_reference
Foam::ConstCirculator<ContainerType>::operator()() const
{
return operator*();
}
template<class ContainerType>
typename Foam::ConstCirculator<ContainerType>::difference_type
Foam::ConstCirculator<ContainerType>::operator-
(
const ConstCirculator<ContainerType>& c
) const
{
return iter_ - c.iter_;
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
#warning File removed - left for old dependency check only

View File

@ -30,7 +30,7 @@ License
#include "triFace.H"
#include "triPointRef.H"
#include "mathematicalConstants.H"
#include "ConstCirculator.H"
#include "Circulator.H"
#include <algorithm>
// * * * * * * * * * * * * * * 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;
}

View File

@ -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<face> bCirc2 = bCirc;
ConstCirculator<face> 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)
{

View File

@ -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();

View File

@ -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();