mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: eliminate code duplication in Circulator/ConstCirculator
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user