mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid weird cast workarounds for edgeFaceCirculator
- holding a pointer instead of a reference for edgeFaceCirculator simplifies overall handling.
This commit is contained in:
@ -63,8 +63,6 @@ $(csys)/coordinateRotation/EulerCoordinateRotation.C
|
|||||||
$(csys)/coordinateRotation/STARCDCoordinateRotation.C
|
$(csys)/coordinateRotation/STARCDCoordinateRotation.C
|
||||||
$(csys)/coordinateRotation/cylindrical.C
|
$(csys)/coordinateRotation/cylindrical.C
|
||||||
|
|
||||||
edgeFaceCirculator/edgeFaceCirculator.C
|
|
||||||
|
|
||||||
polyMeshZipUpCells/polyMeshZipUpCells.C
|
polyMeshZipUpCells/polyMeshZipUpCells.C
|
||||||
primitiveMeshGeometry/primitiveMeshGeometry.C
|
primitiveMeshGeometry/primitiveMeshGeometry.C
|
||||||
|
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
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 "edgeFaceCirculator.H"
|
|
||||||
#include "primitiveMesh.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
const Foam::primitiveMesh* const Foam::edgeFaceCirculator::endConstIterMeshPtr
|
|
||||||
= nullptr;
|
|
||||||
|
|
||||||
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::endConstIter
|
|
||||||
(
|
|
||||||
*Foam::edgeFaceCirculator::endConstIterMeshPtr, // primitiveMesh
|
|
||||||
-1, // faceLabel
|
|
||||||
false, // ownerSide
|
|
||||||
-1, // index
|
|
||||||
false // isBoundaryEdge
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -86,19 +86,10 @@ class primitiveMesh;
|
|||||||
|
|
||||||
class edgeFaceCirculator
|
class edgeFaceCirculator
|
||||||
{
|
{
|
||||||
// Static data members
|
// Private Member Data
|
||||||
|
|
||||||
//- End iterator primitiveMesh nullptr
|
//- The underlying mesh pointer
|
||||||
static const primitiveMesh* const endConstIterMeshPtr;
|
const primitiveMesh* meshPtr_;
|
||||||
|
|
||||||
//- End iterator
|
|
||||||
static const edgeFaceCirculator endConstIter;
|
|
||||||
|
|
||||||
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- Mesh
|
|
||||||
const primitiveMesh& mesh_;
|
|
||||||
|
|
||||||
//- Current face
|
//- Current face
|
||||||
label faceLabel_;
|
label faceLabel_;
|
||||||
@ -119,16 +110,21 @@ class edgeFaceCirculator
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- The underlying mesh
|
||||||
|
inline const primitiveMesh& mesh() const;
|
||||||
|
|
||||||
//- Set to end() iterator
|
//- Set to end() iterator
|
||||||
inline void setEnd();
|
inline void setEnd();
|
||||||
|
|
||||||
//- Check and set faceLabel_ and ownerSide_
|
//- Check and set faceLabel_ and ownerSide_
|
||||||
inline void setFace(const label facei, const label celli);
|
inline void setFace(const label facei, const label celli);
|
||||||
|
|
||||||
//- Set faceLabel_ to be the other face on the cell that uses the
|
//- Set faceLabel_ to be the other face on the cell that uses the edge.
|
||||||
// edge.
|
|
||||||
inline void otherFace(const label celli);
|
inline void otherFace(const label celli);
|
||||||
|
|
||||||
|
//- Construct null - this is also an end iterator
|
||||||
|
inline edgeFaceCirculator();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -145,7 +141,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
inline edgeFaceCirculator(const edgeFaceCirculator&);
|
inline edgeFaceCirculator(const edgeFaceCirculator& circ);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -159,8 +155,12 @@ public:
|
|||||||
const label v1
|
const label v1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Return the face label, -1 for end iterator
|
||||||
inline label faceLabel() const;
|
inline label faceLabel() const;
|
||||||
|
|
||||||
|
//- Return true if the face label corresponds to an internal face
|
||||||
|
inline bool isInternalFace() const;
|
||||||
|
|
||||||
inline bool ownerSide() const;
|
inline bool ownerSide() const;
|
||||||
|
|
||||||
inline label index() const;
|
inline label index() const;
|
||||||
@ -197,8 +197,8 @@ public:
|
|||||||
inline edgeFaceCirculator cbegin() const;
|
inline edgeFaceCirculator cbegin() const;
|
||||||
|
|
||||||
//- Iterator set to beyond the end of the walk.
|
//- Iterator set to beyond the end of the walk.
|
||||||
inline const edgeFaceCirculator& end() const;
|
inline const edgeFaceCirculator end() const;
|
||||||
inline const edgeFaceCirculator& cend() const;
|
inline const edgeFaceCirculator cend() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline const Foam::primitiveMesh& Foam::edgeFaceCirculator::mesh() const
|
||||||
|
{
|
||||||
|
return *meshPtr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::edgeFaceCirculator::setEnd()
|
void Foam::edgeFaceCirculator::setEnd()
|
||||||
{
|
{
|
||||||
faceLabel_ = -1;
|
faceLabel_ = -1;
|
||||||
@ -42,7 +48,7 @@ void Foam::edgeFaceCirculator::setFace
|
|||||||
{
|
{
|
||||||
faceLabel_ = facei;
|
faceLabel_ = facei;
|
||||||
|
|
||||||
if (!isBoundaryEdge_ && !mesh_.isInternalFace(facei))
|
if (!isBoundaryEdge_ && !mesh().isInternalFace(facei))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Edge is not defined as boundary edge but still walked to"
|
<< "Edge is not defined as boundary edge but still walked to"
|
||||||
@ -54,11 +60,11 @@ void Foam::edgeFaceCirculator::setFace
|
|||||||
|
|
||||||
void Foam::edgeFaceCirculator::otherFace(const label celli)
|
void Foam::edgeFaceCirculator::otherFace(const label celli)
|
||||||
{
|
{
|
||||||
const face& f = mesh_.faces()[faceLabel_];
|
const face& f = mesh().faces()[faceLabel_];
|
||||||
label v0 = f[index_];
|
label v0 = f[index_];
|
||||||
label v1 = f.nextLabel(index_);
|
label v1 = f.nextLabel(index_);
|
||||||
|
|
||||||
const cell& cFaces = mesh_.cells()[celli];
|
const cell& cFaces = mesh().cells()[celli];
|
||||||
|
|
||||||
forAll(cFaces, i)
|
forAll(cFaces, i)
|
||||||
{
|
{
|
||||||
@ -66,7 +72,7 @@ void Foam::edgeFaceCirculator::otherFace(const label celli)
|
|||||||
|
|
||||||
if (faceB != faceLabel_)
|
if (faceB != faceLabel_)
|
||||||
{
|
{
|
||||||
label fp = getMinIndex(mesh_.faces()[faceB], v0, v1);
|
label fp = getMinIndex(mesh().faces()[faceB], v0, v1);
|
||||||
|
|
||||||
if (fp >= 0)
|
if (fp >= 0)
|
||||||
{
|
{
|
||||||
@ -81,14 +87,24 @@ void Foam::edgeFaceCirculator::otherFace(const label celli)
|
|||||||
<< "Could not find next face stepping"
|
<< "Could not find next face stepping"
|
||||||
<< " through cell along edge." << endl
|
<< " through cell along edge." << endl
|
||||||
<< "face:" << faceLabel_ << " index in face:" << index_
|
<< "face:" << faceLabel_ << " index in face:" << index_
|
||||||
<< " edge:" << mesh_.points()[v0] << mesh_.points()[v1]
|
<< " edge:" << mesh().points()[v0] << mesh().points()[v1]
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Construct from components
|
Foam::edgeFaceCirculator::edgeFaceCirculator()
|
||||||
|
:
|
||||||
|
meshPtr_(nullptr),
|
||||||
|
faceLabel_(-1),
|
||||||
|
ownerSide_(false),
|
||||||
|
index_(-1),
|
||||||
|
isBoundaryEdge_(false),
|
||||||
|
startFaceLabel_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
Foam::edgeFaceCirculator::edgeFaceCirculator
|
Foam::edgeFaceCirculator::edgeFaceCirculator
|
||||||
(
|
(
|
||||||
const primitiveMesh& mesh,
|
const primitiveMesh& mesh,
|
||||||
@ -98,7 +114,7 @@ Foam::edgeFaceCirculator::edgeFaceCirculator
|
|||||||
const bool isBoundaryEdge
|
const bool isBoundaryEdge
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
meshPtr_(&mesh),
|
||||||
faceLabel_(faceLabel),
|
faceLabel_(faceLabel),
|
||||||
ownerSide_(ownerSide),
|
ownerSide_(ownerSide),
|
||||||
index_(index),
|
index_(index),
|
||||||
@ -107,10 +123,9 @@ Foam::edgeFaceCirculator::edgeFaceCirculator
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Construct copy
|
|
||||||
Foam::edgeFaceCirculator::edgeFaceCirculator(const edgeFaceCirculator& circ)
|
Foam::edgeFaceCirculator::edgeFaceCirculator(const edgeFaceCirculator& circ)
|
||||||
:
|
:
|
||||||
mesh_(circ.mesh_),
|
meshPtr_(circ.meshPtr_),
|
||||||
faceLabel_(circ.faceLabel_),
|
faceLabel_(circ.faceLabel_),
|
||||||
ownerSide_(circ.ownerSide_),
|
ownerSide_(circ.ownerSide_),
|
||||||
index_(circ.index_),
|
index_(circ.index_),
|
||||||
@ -158,6 +173,17 @@ Foam::label Foam::edgeFaceCirculator::faceLabel() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::edgeFaceCirculator::isInternalFace() const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
faceLabel_ >= 0
|
||||||
|
&& meshPtr_
|
||||||
|
&& meshPtr_->isInternalFace(faceLabel_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::edgeFaceCirculator::ownerSide() const
|
bool Foam::edgeFaceCirculator::ownerSide() const
|
||||||
{
|
{
|
||||||
return ownerSide_;
|
return ownerSide_;
|
||||||
@ -174,11 +200,11 @@ Foam::label Foam::edgeFaceCirculator::cellLabel() const
|
|||||||
{
|
{
|
||||||
if (ownerSide_)
|
if (ownerSide_)
|
||||||
{
|
{
|
||||||
return mesh_.faceOwner()[faceLabel_];
|
return mesh().faceOwner()[faceLabel_];
|
||||||
}
|
}
|
||||||
else if (mesh_.isInternalFace(faceLabel_))
|
else if (mesh().isInternalFace(faceLabel_))
|
||||||
{
|
{
|
||||||
return mesh_.faceNeighbour()[faceLabel_];
|
return mesh().faceNeighbour()[faceLabel_];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -189,7 +215,7 @@ Foam::label Foam::edgeFaceCirculator::cellLabel() const
|
|||||||
|
|
||||||
bool Foam::edgeFaceCirculator::sameOrder(const label v0, const label v1) const
|
bool Foam::edgeFaceCirculator::sameOrder(const label v0, const label v1) const
|
||||||
{
|
{
|
||||||
const face& f = mesh_.faces()[faceLabel_];
|
const face& f = mesh().faces()[faceLabel_];
|
||||||
|
|
||||||
label fp = getMinIndex(f, v0, v1);
|
label fp = getMinIndex(f, v0, v1);
|
||||||
|
|
||||||
@ -216,21 +242,21 @@ void Foam::edgeFaceCirculator::setCanonical()
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (mesh_.isInternalFace(faceLabel_))
|
if (mesh().isInternalFace(faceLabel_))
|
||||||
{
|
{
|
||||||
if (ownerSide_)
|
if (ownerSide_)
|
||||||
{
|
{
|
||||||
label celli = mesh_.faceNeighbour()[faceLabel_];
|
label celli = mesh().faceNeighbour()[faceLabel_];
|
||||||
otherFace(celli);
|
otherFace(celli);
|
||||||
// Maintain reverse direction of walking
|
// Maintain reverse direction of walking
|
||||||
ownerSide_ = (mesh_.faceOwner()[faceLabel_] == celli);
|
ownerSide_ = (mesh().faceOwner()[faceLabel_] == celli);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label celli = mesh_.faceOwner()[faceLabel_];
|
label celli = mesh().faceOwner()[faceLabel_];
|
||||||
otherFace(celli);
|
otherFace(celli);
|
||||||
// Maintain reverse direction of walking
|
// Maintain reverse direction of walking
|
||||||
ownerSide_ = (mesh_.faceOwner()[faceLabel_] == celli);
|
ownerSide_ = (mesh().faceOwner()[faceLabel_] == celli);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ownerSide_)
|
else if (ownerSide_)
|
||||||
@ -239,22 +265,22 @@ void Foam::edgeFaceCirculator::setCanonical()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
label celli = mesh_.faceOwner()[faceLabel_];
|
label celli = mesh().faceOwner()[faceLabel_];
|
||||||
otherFace(celli);
|
otherFace(celli);
|
||||||
// Maintain reverse direction of walking
|
// Maintain reverse direction of walking
|
||||||
ownerSide_ = (mesh_.faceOwner()[faceLabel_] == celli);
|
ownerSide_ = (mesh().faceOwner()[faceLabel_] == celli);
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (i >= 1000)
|
if (i >= 1000)
|
||||||
{
|
{
|
||||||
const face& f = mesh_.faces()[faceLabel_];
|
const face& f = mesh().faces()[faceLabel_];
|
||||||
|
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Walked " << i << " cells around edge "
|
<< "Walked " << i << " cells around edge "
|
||||||
<< mesh_.points()[f[index_]]
|
<< mesh().points()[f[index_]]
|
||||||
<< mesh_.points()[f.nextLabel(index_)]
|
<< mesh().points()[f.nextLabel(index_)]
|
||||||
<< " without reaching a boundary face."
|
<< " without reaching a boundary face."
|
||||||
<< " Are you sure this is a boundary edge?"
|
<< " Are you sure this is a boundary edge?"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -281,15 +307,15 @@ void Foam::edgeFaceCirculator::setCanonical()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mesh_.isInternalFace(faceLabel_))
|
if (!mesh().isInternalFace(faceLabel_))
|
||||||
{
|
{
|
||||||
const face& f = mesh_.faces()[faceLabel_];
|
const face& f = mesh().faces()[faceLabel_];
|
||||||
|
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Reached boundary face " << faceLabel_
|
<< "Reached boundary face " << faceLabel_
|
||||||
<< " when walking around internal edge "
|
<< " when walking around internal edge "
|
||||||
<< mesh_.points()[f[index_]]
|
<< mesh().points()[f[index_]]
|
||||||
<< mesh_.points()[f.nextLabel(index_)]
|
<< mesh().points()[f.nextLabel(index_)]
|
||||||
<< "." << endl
|
<< "." << endl
|
||||||
<< "Are you sure this is an internal edge?"
|
<< "Are you sure this is an internal edge?"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -360,10 +386,10 @@ Foam::edgeFaceCirculator::operator++()
|
|||||||
else if (ownerSide_)
|
else if (ownerSide_)
|
||||||
{
|
{
|
||||||
// Step to owner
|
// Step to owner
|
||||||
label celli = mesh_.faceOwner()[faceLabel_];
|
label celli = mesh().faceOwner()[faceLabel_];
|
||||||
otherFace(celli);
|
otherFace(celli);
|
||||||
// Maintain direction of walking
|
// Maintain direction of walking
|
||||||
ownerSide_ = (mesh_.faceOwner()[faceLabel_] != celli);
|
ownerSide_ = (mesh().faceOwner()[faceLabel_] != celli);
|
||||||
|
|
||||||
// Check for internal edge : ends on starting face.
|
// Check for internal edge : ends on starting face.
|
||||||
if (!isBoundaryEdge_ && faceLabel_ == startFaceLabel_)
|
if (!isBoundaryEdge_ && faceLabel_ == startFaceLabel_)
|
||||||
@ -371,13 +397,13 @@ Foam::edgeFaceCirculator::operator++()
|
|||||||
setEnd();
|
setEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mesh_.isInternalFace(faceLabel_))
|
else if (mesh().isInternalFace(faceLabel_))
|
||||||
{
|
{
|
||||||
// Step to neighbour
|
// Step to neighbour
|
||||||
label celli = mesh_.faceNeighbour()[faceLabel_];
|
label celli = mesh().faceNeighbour()[faceLabel_];
|
||||||
otherFace(celli);
|
otherFace(celli);
|
||||||
// Maintain direction of walking
|
// Maintain direction of walking
|
||||||
ownerSide_ = (mesh_.faceOwner()[faceLabel_] != celli);
|
ownerSide_ = (mesh().faceOwner()[faceLabel_] != celli);
|
||||||
|
|
||||||
// Check for internal edge : ends on starting face.
|
// Check for internal edge : ends on starting face.
|
||||||
if (!isBoundaryEdge_ && faceLabel_ == startFaceLabel_)
|
if (!isBoundaryEdge_ && faceLabel_ == startFaceLabel_)
|
||||||
@ -399,7 +425,7 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::begin() const
|
|||||||
{
|
{
|
||||||
edgeFaceCirculator iter
|
edgeFaceCirculator iter
|
||||||
(
|
(
|
||||||
mesh_,
|
*meshPtr_,
|
||||||
faceLabel_,
|
faceLabel_,
|
||||||
ownerSide_,
|
ownerSide_,
|
||||||
index_,
|
index_,
|
||||||
@ -418,7 +444,7 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const
|
|||||||
{
|
{
|
||||||
edgeFaceCirculator iter
|
edgeFaceCirculator iter
|
||||||
(
|
(
|
||||||
mesh_,
|
*meshPtr_,
|
||||||
faceLabel_,
|
faceLabel_,
|
||||||
ownerSide_,
|
ownerSide_,
|
||||||
index_,
|
index_,
|
||||||
@ -433,14 +459,14 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::edgeFaceCirculator& Foam::edgeFaceCirculator::end() const
|
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::end() const
|
||||||
{
|
{
|
||||||
return endConstIter;
|
return edgeFaceCirculator();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Foam::edgeFaceCirculator& Foam::edgeFaceCirculator::cend() const
|
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cend() const
|
||||||
{
|
{
|
||||||
return endConstIter;
|
return edgeFaceCirculator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user