ENH: base classes for wave algorithms (manage non-templated parts)

ENH: use DynamicList instead of List + size for point wave

- consistent with previous updates for the other algorithms

STYLE: unique_ptr instead of raw pointer in wave algorithms
This commit is contained in:
Mark Olesen
2022-10-13 11:23:35 +02:00
committed by Andrew Heather
parent c33167dc0e
commit 5ec435aca3
32 changed files with 802 additions and 780 deletions

View File

@ -810,7 +810,7 @@ meshes/preservePatchTypes/preservePatchTypes.C
interpolations = interpolations
interpolation = $(interpolations)/interpolation
$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationBase.C
$(interpolations)/interpolationTable/tableReaders/tableReaders.C
$(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C

View File

@ -55,7 +55,7 @@ Description
class TemplateNameString##Name \
{ \
public: \
TemplateNameString##Name() {} \
TemplateNameString##Name() noexcept = default; \
ClassNameNoDebug(#TemplateNameString); \
}
@ -81,7 +81,7 @@ public: \
class TemplateNameString##Name \
{ \
public: \
TemplateNameString##Name() {} \
TemplateNameString##Name() noexcept = default; \
ClassName(#TemplateNameString); \
}

View File

@ -35,12 +35,6 @@ License
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class FromPatch, class ToPatch>
scalar PatchToPatchInterpolation<FromPatch, ToPatch>::projectionTol_ = 0.05;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class FromPatch, class ToPatch>
@ -48,15 +42,14 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
{
// Calculate pointWeights
pointWeightsPtr_ = new FieldField<Field, scalar>(toPatch_.nPoints());
FieldField<Field, scalar>& pointWeights = *pointWeightsPtr_;
pointWeightsPtr_.reset(new FieldField<Field, scalar>(toPatch_.nPoints()));
auto& pointWeights = *pointWeightsPtr_;
pointDistancePtr_ = new scalarField(toPatch_.nPoints(), GREAT);
scalarField& pointDistance = *pointDistancePtr_;
pointDistancePtr_.reset(new scalarField(toPatch_.nPoints(), GREAT));
auto& pointDistance = *pointDistancePtr_;
const pointField& fromPatchPoints = fromPatch_.localPoints();
const List<typename FromPatch::face_type>& fromPatchFaces =
fromPatch_.localFaces();
const auto& fromPatchFaces = fromPatch_.localFaces();
const pointField& toPatchPoints = toPatch_.localPoints();
const vectorField& projectionDirection = toPatch_.pointNormals();
@ -71,8 +64,8 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
List<objectHit> proj =
toPatch_.projectPoints(fromPatch_, projectionDirection, alg_, dir_);
pointAddressingPtr_ = new labelList(proj.size(), -1);
labelList& pointAddressing = *pointAddressingPtr_;
pointAddressingPtr_.reset(new labelList(proj.size(), -1));
auto& pointAddressing = *pointAddressingPtr_;
bool doWeights = false;
@ -80,8 +73,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
{
doWeights = false;
const typename FromPatch::face_type& hitFace =
fromPatchFaces[proj[pointi].hitObject()];
const auto& hitFace = fromPatchFaces[proj[pointi].hitObject()];
point hitPoint = Zero;
@ -229,7 +221,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
}
else
{
pointWeights.set(pointi, new scalarField(0));
pointWeights.set(pointi, new scalarField());
}
}
}
@ -238,11 +230,11 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcPointAddressing() const
template<class FromPatch, class ToPatch>
void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
{
faceWeightsPtr_ = new FieldField<Field, scalar>(toPatch_.size());
FieldField<Field, scalar>& faceWeights = *faceWeightsPtr_;
faceWeightsPtr_.reset(new FieldField<Field, scalar>(toPatch_.size()));
auto& faceWeights = *faceWeightsPtr_;
faceDistancePtr_ = new scalarField(toPatch_.size(), GREAT);
scalarField& faceDistance = *faceDistancePtr_;
faceDistancePtr_.reset(new scalarField(toPatch_.size(), GREAT));
auto& faceDistance = *faceDistancePtr_;
if (debug)
{
@ -250,7 +242,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
}
const pointField& fromPatchPoints = fromPatch_.points();
const typename FromPatch::FaceListType& fromPatchFaces = fromPatch_;
const auto& fromPatchFaces = fromPatch_;
const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();
vectorField fromPatchFaceCentres(fromPatchFaces.size());
@ -262,7 +254,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
}
const pointField& toPatchPoints = toPatch_.points();
const typename ToPatch::FaceListType& toPatchFaces = toPatch_;
const auto& toPatchFaces = toPatch_;
const vectorField& projectionDirection = toPatch_.faceNormals();
@ -275,8 +267,8 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
dir_
);
faceAddressingPtr_ = new labelList(proj.size(), -1);
labelList& faceAddressing = *faceAddressingPtr_;
faceAddressingPtr_.reset(new labelList(proj.size(), -1));
auto& faceAddressing = *faceAddressingPtr_;
forAll(faceAddressing, facei)
{
@ -285,8 +277,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
// A hit exists
faceAddressing[facei] = proj[facei].hitObject();
const typename FromPatch::face_type& hitFace =
fromPatchFaces[faceAddressing[facei]];
const auto& hitFace = fromPatchFaces[faceAddressing[facei]];
pointHit curHit =
hitFace.ray
@ -349,7 +340,7 @@ void PatchToPatchInterpolation<FromPatch, ToPatch>::calcFaceAddressing() const
}
else
{
faceWeights.set(facei, new scalarField(0));
faceWeights.set(facei, new scalarField());
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,15 +52,10 @@ PatchToPatchInterpolation<FromPatch, ToPatch>::pointInterpolate
<< abort(FatalError);
}
tmp<Field<Type>> tresult
(
new Field<Type>(toPatch_.nPoints(), Zero)
);
auto tresult = tmp<Field<Type>>::New(toPatch_.nPoints(), Zero);
auto& result = tresult.ref();
Field<Type>& result = tresult.ref();
const List<typename FromPatch::face_type>& fromPatchLocalFaces =
fromPatch_.localFaces();
const auto& fromPatchLocalFaces = fromPatch_.localFaces();
const FieldField<Field, scalar>& weights = pointWeights();
@ -116,12 +111,8 @@ PatchToPatchInterpolation<FromPatch, ToPatch>::faceInterpolate
<< abort(FatalError);
}
tmp<Field<Type>> tresult
(
new Field<Type>(toPatch_.size(), Zero)
);
Field<Type>& result = tresult.ref();
auto tresult = tmp<Field<Type>>::New(toPatch_.size(), Zero);
auto& result = tresult.ref();
const labelListList& fromPatchFaceFaces = fromPatch_.faceFaces();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,19 +27,12 @@ License
\*---------------------------------------------------------------------------*/
#include "PatchToPatchInterpolation.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class FromPatch, class ToPatch>
const scalar
PatchToPatchInterpolation<FromPatch, ToPatch>::directHitTol = 1e-5;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class FromPatch, class ToPatch>
@ -96,12 +90,12 @@ PatchToPatchInterpolation<FromPatch, ToPatch>::faceWeights() const
template<class FromPatch, class ToPatch>
void PatchToPatchInterpolation<FromPatch, ToPatch>::clearOut()
{
deleteDemandDrivenData(pointAddressingPtr_);
deleteDemandDrivenData(pointWeightsPtr_);
deleteDemandDrivenData(pointDistancePtr_);
deleteDemandDrivenData(faceAddressingPtr_);
deleteDemandDrivenData(faceWeightsPtr_);
deleteDemandDrivenData(faceDistancePtr_);
pointAddressingPtr_.reset(nullptr);
pointWeightsPtr_.reset(nullptr);
pointDistancePtr_.reset(nullptr);
faceAddressingPtr_.reset(nullptr);
faceWeightsPtr_.reset(nullptr);
faceDistancePtr_.reset(nullptr);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef PatchToPatchInterpolation_H
#define PatchToPatchInterpolation_H
#ifndef Foam_PatchToPatchInterpolation_H
#define Foam_PatchToPatchInterpolation_H
#include "className.H"
#include "labelList.H"
@ -54,10 +55,55 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PatchToPatchInterpolationName Declaration
Class PatchToPatchInterpolationBase Declaration
\*---------------------------------------------------------------------------*/
TemplateName(PatchToPatchInterpolation);
class PatchToPatchInterpolationBase
{
protected:
// Protected Static Data
//- Relative merge tolerance for projected points missing the target
// Expressed as the fraction of min involved edge size
static scalar projectionTol_;
//- Direct hit tolerance
static const scalar directHitTol;
public:
//- Runtime type information
ClassName("PatchToPatchInterpolation");
// Constructors
//- Default construct
PatchToPatchInterpolationBase() noexcept = default;
// Member Functions
//- Access to projection tolerance
static scalar projectionTol() noexcept
{
return projectionTol_;
}
//- Change propagation tolerance, return previous value
static scalar setProjectionTol(const scalar tol)
{
if (tol < -VSMALL)
{
FatalErrorInFunction << abort(FatalError);
}
scalar old(projectionTol_);
projectionTol_ = tol;
return old;
}
};
/*---------------------------------------------------------------------------*\
@ -67,9 +113,9 @@ TemplateName(PatchToPatchInterpolation);
template<class FromPatch, class ToPatch>
class PatchToPatchInterpolation
:
public PatchToPatchInterpolationName
public PatchToPatchInterpolationBase
{
// Private data
// Private Data
//- Reference to the source patch
const FromPatch& fromPatch_;
@ -84,34 +130,28 @@ class PatchToPatchInterpolation
intersection::direction dir_;
// Static data
// Point Addressing
//- Relative merge tolerance for projected points missing the target
// Expressed as the fraction of min involved edge size
static scalar projectionTol_;
//- Face into which each point of target patch is projected
mutable std::unique_ptr<labelList> pointAddressingPtr_;
//- Weighting factors
mutable std::unique_ptr<FieldField<Field, scalar>> pointWeightsPtr_;
//- Distance to intersection for patch points
mutable std::unique_ptr<scalarField> pointDistancePtr_;
// Point addressing
// Face Addressing
//- Face into which each point of target patch is projected
mutable labelList* pointAddressingPtr_;
//- Face into which each face centre of target patch is projected
mutable std::unique_ptr<labelList> faceAddressingPtr_;
//- Weighting factors
mutable FieldField<Field, scalar>* pointWeightsPtr_;
//- Weighting factors
mutable std::unique_ptr<FieldField<Field, scalar>> faceWeightsPtr_;
//- Distance to intersection for patch points
mutable scalarField* pointDistancePtr_;
// Face addressing
//- Face into which each face centre of target patch is projected
mutable labelList* faceAddressingPtr_;
//- Weighting factors
mutable FieldField<Field, scalar>* faceWeightsPtr_;
//- Distance to intersection for patch face centres
mutable scalarField* faceDistancePtr_;
//- Distance to intersection for patch face centres
mutable std::unique_ptr<scalarField> faceDistancePtr_;
// Private Member Functions
@ -145,12 +185,6 @@ class PatchToPatchInterpolation
const FieldField<Field, scalar>& faceWeights() const;
// Private static data members
//- Direct hit tolerance
static const scalar directHitTol;
public:
// Constructors
@ -171,21 +205,6 @@ public:
// Member Functions
//- Set the projection tolerance, returning the previous value
static scalar setProjectionTol(const scalar t)
{
if (t < -VSMALL)
{
FatalErrorInFunction
<< abort(FatalError);
}
scalar oldTol = projectionTol_;
projectionTol_ = t;
return oldTol;
}
//- Return ype of intersection algorithm to use in projection
intersection::algorithm projectionAlgo() const
{

View File

@ -25,14 +25,19 @@ License
\*---------------------------------------------------------------------------*/
#include "PointEdgeWave.H"
#include "PatchToPatchInterpolation.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(PointEdgeWaveName, 0);
defineTypeNameAndDebug(PatchToPatchInterpolationBase, 0);
}
Foam::scalar Foam::PatchToPatchInterpolationBase::projectionTol_ = 0.05;
const Foam::scalar Foam::PatchToPatchInterpolationBase::directHitTol = 1e-5;
// ************************************************************************* //

View File

@ -1,38 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-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/>.
\*---------------------------------------------------------------------------*/
#include "PatchToPatchInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(PatchToPatchInterpolationName, 0);
}
// ************************************************************************* //

View File

@ -33,8 +33,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef blendedSchemeBase_H
#define blendedSchemeBase_H
#ifndef Foam_blendedSchemeBase_H
#define Foam_blendedSchemeBase_H
#include "className.H"
#include "tmp.H"
@ -57,12 +57,10 @@ class blendedSchemeBase
:
public blendedSchemeBaseName
{
public:
//- Constructor
blendedSchemeBase()
{}
blendedSchemeBase() = default;
//- Destructor
virtual ~blendedSchemeBase() = default;

View File

@ -69,19 +69,19 @@ meshTools/meshTools.C
algorithms = algorithms
pWave = $(algorithms)/PointEdgeWave
$(pWave)/PointEdgeWaveName.C
$(pWave)/PointEdgeWaveBase.C
$(pWave)/pointEdgePoint.C
patchWave = $(algorithms)/PatchEdgeFaceWave
$(patchWave)/PatchEdgeFaceWaveName.C
$(patchWave)/PatchEdgeFaceWaveBase.C
$(patchWave)/patchEdgeFaceInfo.C
$(patchWave)/patchPatchDist.C
$(patchWave)/patchEdgeFaceRegions.C
meshWave = $(algorithms)/MeshWave
$(meshWave)/MeshWaveName.C
$(meshWave)/FaceCellWaveName.C
$(meshWave)/MeshWaveBase.C
$(meshWave)/FaceCellWaveBase.C
regionSplit/regionSplit.C
@ -90,7 +90,7 @@ regionSplit/localPointRegion.C
regionSplit2D/regionSplit2D.C
indexedOctree/treeDataFace.C
indexedOctree/treeDataPrimitivePatchName.C
indexedOctree/treeDataPrimitivePatchBase.C
indexedOctree/treeDataTriSurface.C

View File

@ -41,16 +41,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type, class TrackingData>
const Foam::scalar Foam::FaceCellWave<Type, TrackingData>::geomTol_ = 1e-6;
template<class Type, class TrackingData>
Foam::scalar Foam::FaceCellWave<Type, TrackingData>::propagationTol_ = 0.01;
template<class Type, class TrackingData>
int Foam::FaceCellWave<Type, TrackingData>::dummyTrackData_ = 12345;
namespace Foam
{
template<class Type, class TrackingData>
@ -145,7 +135,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateCell
{
if (changedCell_.set(celli))
{
changedCells_.append(celli);
changedCells_.push_back(celli);
}
}
@ -193,7 +183,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace
{
if (changedFace_.set(facei))
{
changedFaces_.append(facei);
changedFaces_.push_back(facei);
}
}
@ -239,7 +229,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace
{
if (changedFace_.set(facei))
{
changedFaces_.append(facei);
changedFaces_.push_back(facei);
}
}
@ -333,7 +323,7 @@ void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
// Mark facei as visited and changed (both on list and on face itself)
changedFace_.set(facei);
changedFaces_.append(facei);
changedFaces_.push_back(facei);
}
@ -361,7 +351,7 @@ void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
// Mark facei as changed, both on list and on face itself.
changedFace_.set(facei);
changedFaces_.append(facei);
changedFaces_.push_back(facei);
}
}
@ -840,13 +830,13 @@ void Foam::FaceCellWave<Type, TrackingData>::handleExplicitConnections()
if (changedFace_.test(f0))
{
// f0 changed. Update information on f1.
changedBaffles_.append(taggedInfoType(f1, allFaceInfo_[f0]));
changedBaffles_.push_back(taggedInfoType(f1, allFaceInfo_[f0]));
}
if (changedFace_.test(f1))
{
// f1 changed. Update information on f0.
changedBaffles_.append(taggedInfoType(f0, allFaceInfo_[f1]));
changedBaffles_.push_back(taggedInfoType(f0, allFaceInfo_[f1]));
}
}
@ -887,24 +877,19 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
TrackingData& td
)
:
mesh_(mesh),
FaceCellWaveBase(mesh),
explicitConnections_(),
allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo),
td_(td),
changedFace_(mesh_.nFaces(), false),
changedCell_(mesh_.nCells(), false),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
changedBaffles_(2*explicitConnections_.size()),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_
(
returnReduceOr(hasPatch<cyclicAMIPolyPatch>())
),
nEvals_(0),
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
nEvals_(0)
{
if
(
@ -935,24 +920,19 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
TrackingData& td
)
:
mesh_(mesh),
FaceCellWaveBase(mesh),
explicitConnections_(),
allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo),
td_(td),
changedFace_(mesh_.nFaces(), false),
changedCell_(mesh_.nCells(), false),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
changedBaffles_(2*explicitConnections_.size()),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_
(
returnReduceOr(hasPatch<cyclicAMIPolyPatch>())
),
nEvals_(0),
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
nEvals_(0)
{
if
(
@ -980,8 +960,8 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << nl
<< " nChangedCells:" << changedCells_.size() << nl
<< " nChangedFaces:" << changedFaces_.size() << endl
<< " nChangedCells:" << nChangedCells() << nl
<< " nChangedFaces:" << nChangedFaces() << endl
<< exit(FatalError);
}
}
@ -1001,15 +981,12 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
TrackingData& td
)
:
mesh_(mesh),
FaceCellWaveBase(mesh),
explicitConnections_(explicitConnections),
allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo),
td_(td),
changedFace_(mesh_.nFaces(), false),
changedCell_(mesh_.nCells(), false),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
changedBaffles_(2*explicitConnections_.size()),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_
@ -1017,9 +994,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
handleCyclicAMI
&& returnReduceOr(hasPatch<cyclicAMIPolyPatch>())
),
nEvals_(0),
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
nEvals_(0)
{
if
(
@ -1047,8 +1022,8 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << nl
<< " nChangedCells:" << changedCells_.size() << nl
<< " nChangedFaces:" << changedFaces_.size() << endl
<< " nChangedCells:" << nChangedCells() << nl
<< " nChangedFaces:" << nChangedFaces() << endl
<< exit(FatalError);
}
}
@ -1056,20 +1031,6 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, class TrackingData>
Foam::label Foam::FaceCellWave<Type, TrackingData>::nUnvisitedCells() const
{
return nUnvisitedCells_;
}
template<class Type, class TrackingData>
Foam::label Foam::FaceCellWave<Type, TrackingData>::nUnvisitedFaces() const
{
return nUnvisitedFaces_;
}
template<class Type, class TrackingData>
Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
{
@ -1139,11 +1100,11 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
if (debug & 2)
{
Pout<< " Changed cells : " << changedCells_.size() << endl;
Pout<< " Changed cells : " << nChangedCells() << endl;
}
// Number of changedCells over all procs
return returnReduce(changedCells_.size(), sumOp<label>());
return returnReduce(nChangedCells(), sumOp<label>());
}
@ -1213,12 +1174,12 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
if (debug & 2)
{
Pout<< " Changed faces : " << changedFaces_.size() << endl;
Pout<< " Changed faces : " << nChangedFaces() << endl;
}
// Number of changedFaces over all procs
return returnReduce(changedFaces_.size(), sumOp<label>());
return returnReduce(nChangedFaces(), sumOp<label>());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,8 +47,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef FaceCellWave_H
#define FaceCellWave_H
#ifndef Foam_FaceCellWave_H
#define Foam_FaceCellWave_H
#include "bitSet.H"
#include "DynamicList.H"
@ -65,10 +65,101 @@ class polyMesh;
class polyPatch;
/*---------------------------------------------------------------------------*\
Class FaceCellWaveName Declaration
Class FaceCellWaveBase Declaration
\*---------------------------------------------------------------------------*/
TemplateName(FaceCellWave);
class FaceCellWaveBase
{
protected:
// Protected Static Data
static const scalar geomTol_;
static scalar propagationTol_;
// Protected Data
//- Reference to mesh
const polyMesh& mesh_;
//- Track if face has changed
bitSet changedFace_;
//- Track if cell has changed
bitSet changedCell_;
//- List of changed faces
DynamicList<label> changedFaces_;
//- List of changed cells
DynamicList<label> changedCells_;
//- Current count of unvisited faces
label nUnvisitedFaces_;
//- Current count of unvisited cells
label nUnvisitedCells_;
public:
//- Default trackData value (for default template argument)
static int dummyTrackData_;
//- Runtime type information
ClassName("FaceCellWave");
// Constructors
//- Construct with mesh reference and set initial sizes
FaceCellWaveBase(const polyMesh& mesh);
// Static Functions
//- Access to propagation tolerance
static scalar propagationTol() noexcept
{
return propagationTol_;
}
//- Change propagation tolerance, return previous value
static scalar setPropagationTol(const scalar tol) noexcept
{
scalar old(propagationTol_);
propagationTol_ = tol;
return old;
}
// Member Functions
//- Return access to the mesh
const polyMesh& mesh() const noexcept
{
return mesh_;
}
//- Current number of changed cells
label nChangedCells() const noexcept { return changedCells_.size(); }
//- Current number of changed faces
label nChangedFaces() const noexcept { return changedFaces_.size(); }
//- Get number of unvisited cells,
//- i.e. cells that were not (yet) reached from walking across mesh.
// This can happen from
// - not enough iterations done
// - a disconnected mesh
// - a mesh without walls in it
label nUnvisitedCells() const noexcept { return nUnvisitedCells_; }
//- Get number of unvisited faces
label nUnvisitedFaces() const noexcept { return nUnvisitedFaces_; }
};
/*---------------------------------------------------------------------------*\
@ -78,7 +169,7 @@ TemplateName(FaceCellWave);
template<class Type, class TrackingData = int>
class FaceCellWave
:
public FaceCellWaveName
public FaceCellWaveBase
{
protected:
@ -87,20 +178,8 @@ protected:
typedef std::pair<label,Type> taggedInfoType;
// Protected Static Data
static const scalar geomTol_;
static scalar propagationTol_;
//- Default trackdata value to satisfy default template argument.
static int dummyTrackData_;
// Protected Data
//- Reference to mesh
const polyMesh& mesh_;
//- Optional boundary faces that information should travel through
const labelPairList explicitConnections_;
@ -113,18 +192,6 @@ protected:
//- Additional data to be passed into container
TrackingData& td_;
//- Has face changed
bitSet changedFace_;
//- Has cell changed
bitSet changedCell_;
//- List of changed faces
DynamicList<label> changedFaces_;
// Cells that have changed
DynamicList<label> changedCells_;
// Information exchange for explicit baffle connections
// Max capacity = 2x number of explicit connections
DynamicList<taggedInfoType> changedBaffles_;
@ -138,10 +205,6 @@ protected:
//- Number of evaluations
label nEvals_;
//- Number of unvisited cells/faces
label nUnvisitedCells_;
label nUnvisitedFaces_;
// Protected Member Functions
@ -266,21 +329,6 @@ protected:
public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors
//- Construct from mesh.
@ -290,7 +338,7 @@ public:
const polyMesh& mesh,
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
TrackingData& td = dummyTrackData_
TrackingData& td = FaceCellWaveBase::dummyTrackData_
);
//- Construct from mesh and list of changed faces with the Type
@ -304,7 +352,7 @@ public:
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
TrackingData& td = FaceCellWaveBase::dummyTrackData_
);
//- Construct from mesh and explicitly connected boundary faces
@ -321,7 +369,7 @@ public:
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
TrackingData& td = FaceCellWaveBase::dummyTrackData_
);
@ -334,40 +382,23 @@ public:
// Access
//- Access allFaceInfo
UList<Type>& allFaceInfo()
UList<Type>& allFaceInfo() noexcept
{
return allFaceInfo_;
}
//- Access allCellInfo
UList<Type>& allCellInfo()
UList<Type>& allCellInfo() noexcept
{
return allCellInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
const TrackingData& data() const noexcept
{
return td_;
}
//- Access mesh
const polyMesh& mesh() const
{
return mesh_;
}
//- Get number of unvisited cells,
//- i.e. cells that were not (yet) reached from walking across mesh.
// This can happen from
// - not enough iterations done
// - a disconnected mesh
// - a mesh without walls in it
label nUnvisitedCells() const;
//- Get number of unvisited faces
label nUnvisitedFaces() const;
// Edit

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,14 +26,39 @@ License
\*---------------------------------------------------------------------------*/
#include "PatchEdgeFaceWave.H"
#include "FaceCellWave.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(PatchEdgeFaceWaveName, 0);
defineTypeNameAndDebug(FaceCellWaveBase, 0);
}
const Foam::scalar Foam::FaceCellWaveBase::geomTol_ = 1e-6;
Foam::scalar Foam::FaceCellWaveBase::propagationTol_ = 0.01;
int Foam::FaceCellWaveBase::dummyTrackData_ = 12345;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::FaceCellWaveBase::FaceCellWaveBase
(
const polyMesh& mesh
)
:
mesh_(mesh),
changedFace_(mesh_.nFaces()),
changedCell_(mesh_.nCells()),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces()),
nUnvisitedCells_(mesh_.nCells())
{}
// ************************************************************************* //

View File

@ -28,13 +28,6 @@ License
#include "MeshWave.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type, class TrackingData>
int Foam::MeshWave<Type, TrackingData>::dummyTrackData_ = 12345;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Iterate, propagating changedFacesInfo across mesh, until no change (or
@ -92,7 +85,4 @@ Foam::MeshWave<Type, TrackingData>::MeshWave
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef MeshWave_H
#define MeshWave_H
#ifndef Foam_MeshWave_H
#define Foam_MeshWave_H
#include "FaceCellWave.H"
@ -61,12 +61,6 @@ class MeshWave
:
public MeshWaveName
{
// Private Static Data
//- Default trackdata value to satisfy default template argument.
static int dummyTrackData_;
// Private Data
//- Wall information for all faces
@ -102,7 +96,7 @@ public:
const labelList& initialChangedFaces,
const List<Type>& changedFacesInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
TrackingData& td = FaceCellWaveBase::dummyTrackData_
);
//- Construct from mesh, list of changed faces with the Type
@ -116,26 +110,26 @@ public:
const List<Type>& changedFacesInfo,
const List<Type>& allCellInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
TrackingData& td = FaceCellWaveBase::dummyTrackData_
);
// Member Functions
//- Get allFaceInfo
const List<Type>& allFaceInfo() const
const List<Type>& allFaceInfo() const noexcept
{
return allFaceInfo_;
}
//- Get allCellInfo
const List<Type>& allCellInfo() const
const List<Type>& allCellInfo() const noexcept
{
return allCellInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
const TrackingData& data() const noexcept
{
return calc_.data();
}
@ -147,20 +141,20 @@ public:
return calc_.iterate(maxIter);
}
//- Number of unvisited cells, i.e. cells that were not (yet)
//- reached from walking across mesh.
//
// This can happen from
// - not enough iterations done
// - a disconnected mesh
// - a mesh without walls in it
label nUnvisitedCells() const
//- Current number of changed cells
label nChangedCells() const noexcept { return calc_.nChangedCells(); }
//- Current number of changed faces
label nChangedFaces() const noexcept { return calc_.nChangedFaces(); }
//- Number of unvisited cells
label nUnvisitedCells() const noexcept
{
return calc_.nUnvisitedCells();
}
//- Number of unvisited faces
label nUnvisitedFaces() const
label nUnvisitedFaces() const noexcept
{
return calc_.nUnvisitedFaces();
}

View File

@ -31,7 +31,7 @@ License
namespace Foam
{
defineTypeNameAndDebug(MeshWaveName, 0);
defineTypeNameAndDebug(MeshWaveName, 0);
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,28 +31,6 @@ License
#include "globalMeshData.H"
#include "PatchTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::scalar Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
propagationTol_ = 0.01;
template
<
class PrimitivePatchType,
class Type,
class TrackingData
>
Foam::label
Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
dummyTrackData_ = 12345;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update info for edgeI, at position pt, with information from
@ -68,7 +47,7 @@ template
bool Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
updateEdge
(
const label edgeI,
const label edgei,
const label neighbourFacei,
const Type& neighbourInfo,
Type& edgeInfo
@ -83,7 +62,7 @@ updateEdge
(
mesh_,
patch_,
edgeI,
edgei,
neighbourFacei,
neighbourInfo,
propagationTol_,
@ -92,10 +71,9 @@ updateEdge
if (propagate)
{
if (!changedEdge_[edgeI])
if (changedEdge_.set(edgei))
{
changedEdge_.set(edgeI);
changedEdges_.append(edgeI);
changedEdges_.push_back(edgei);
}
}
@ -148,7 +126,7 @@ updateFace
{
if (changedFace_.set(facei))
{
changedFaces_.append(facei);
changedFaces_.push_back(facei);
}
}
@ -185,7 +163,7 @@ syncEdges()
label patchEdgeI = patchEdges_[i];
label coupledEdgeI = coupledEdges_[i];
if (changedEdge_[patchEdgeI])
if (changedEdge_.test(patchEdgeI))
{
const Type& data = allEdgeInfo_[patchEdgeI];
@ -266,10 +244,9 @@ syncEdges()
td_
);
if (!changedEdge_[patchEdgeI])
if (changedEdge_.set(patchEdgeI))
{
changedEdge_.set(patchEdgeI);
changedEdges_.append(patchEdgeI);
changedEdges_.push_back(patchEdgeI);
}
}
}
@ -301,18 +278,12 @@ PatchEdgeFaceWave
TrackingData& td
)
:
mesh_(mesh),
PatchEdgeFaceWaveBase(mesh, patch.nEdges(), patch.size()),
patch_(patch),
allEdgeInfo_(allEdgeInfo),
allFaceInfo_(allFaceInfo),
td_(td),
changedEdge_(patch_.nEdges()),
changedEdges_(patch_.size()),
changedFace_(patch_.size()),
changedFaces_(patch_.size()),
nEvals_(0),
nUnvisitedEdges_(patch_.nEdges()),
nUnvisitedFaces_(patch_.size())
nEvals_(0)
{
// Calculate addressing between patch_ and mesh.globalData().coupledPatch()
// for ease of synchronisation
@ -331,18 +302,18 @@ PatchEdgeFaceWave
{
FatalErrorInFunction
<< "size of edgeInfo work array is not equal to the number"
<< " of edges in the patch" << endl
<< " edgeInfo :" << allEdgeInfo_.size() << endl
<< " patch.nEdges:" << patch_.nEdges()
<< " of edges in the patch" << nl
<< " edgeInfo :" << allEdgeInfo_.size() << nl
<< " patch.nEdges:" << patch_.nEdges() << endl
<< exit(FatalError);
}
if (allFaceInfo_.size() != patch_.size())
{
FatalErrorInFunction
<< "size of edgeInfo work array is not equal to the number"
<< " of faces in the patch" << endl
<< " faceInfo :" << allFaceInfo_.size() << endl
<< " patch.size:" << patch_.size()
<< " of faces in the patch" << nl
<< " faceInfo :" << allFaceInfo_.size() << nl
<< " patch.size:" << patch_.size() << endl
<< exit(FatalError);
}
@ -352,7 +323,7 @@ PatchEdgeFaceWave
if (debug)
{
Pout<< "Seed edges : " << changedEdges_.size() << endl;
Pout<< "Seed edges : " << nChangedEdges() << endl;
}
// Iterate until nothing changes
@ -361,10 +332,10 @@ PatchEdgeFaceWave
if ((maxIter > 0) && (iter >= maxIter))
{
FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << endl
<< " maxIter:" << maxIter << endl
<< " changedEdges:" << changedEdges_.size() << endl
<< " changedFaces:" << changedFaces_.size() << endl
<< "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << nl
<< " changedEdges:" << nChangedEdges() << nl
<< " changedFaces:" << nChangedFaces() << endl
<< exit(FatalError);
}
}
@ -386,18 +357,12 @@ PatchEdgeFaceWave
TrackingData& td
)
:
mesh_(mesh),
PatchEdgeFaceWaveBase(mesh, patch.nEdges(), patch.size()),
patch_(patch),
allEdgeInfo_(allEdgeInfo),
allFaceInfo_(allFaceInfo),
td_(td),
changedEdge_(patch_.nEdges()),
changedEdges_(patch_.nEdges()),
changedFace_(patch_.size()),
changedFaces_(patch_.size()),
nEvals_(0),
nUnvisitedEdges_(patch_.nEdges()),
nUnvisitedFaces_(patch_.size())
nEvals_(0)
{
// Calculate addressing between patch_ and mesh.globalData().coupledPatch()
// for ease of synchronisation
@ -446,10 +411,9 @@ setEdgeInfo
// Mark edgeI as changed, both on list and on edge itself.
if (!changedEdge_[edgeI])
if (changedEdge_.set(edgeI))
{
changedEdge_.set(edgeI);
changedEdges_.append(edgeI);
changedEdges_.push_back(edgeI);
}
}
}
@ -468,10 +432,8 @@ faceToEdge()
changedEdges_.clear();
changedEdge_ = false;
forAll(changedFaces_, changedFacei)
for (const label facei : changedFaces_)
{
label facei = changedFaces_[changedFacei];
if (!changedFace_.test(facei))
{
FatalErrorInFunction
@ -511,10 +473,10 @@ faceToEdge()
if (debug)
{
Pout<< "Changed edges : " << changedEdges_.size() << endl;
Pout<< "Changed edges : " << nChangedEdges() << endl;
}
return returnReduce(changedEdges_.size(), sumOp<label>());
return returnReduce(nChangedEdges(), sumOp<label>());
}
@ -533,28 +495,23 @@ edgeToFace()
const labelListList& edgeFaces = patch_.edgeFaces();
forAll(changedEdges_, changedEdgeI)
for (const label edgei : changedEdges_)
{
label edgeI = changedEdges_[changedEdgeI];
if (!changedEdge_[edgeI])
if (!changedEdge_.test(edgei))
{
FatalErrorInFunction
<< "edge " << edgeI
<< "edge " << edgei
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurrences of the same"
<< " seed edge." << abort(FatalError);
}
const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
const Type& neighbourWallInfo = allEdgeInfo_[edgei];
// Evaluate all connected faces
const labelList& eFaces = edgeFaces[edgeI];
forAll(eFaces, eFacei)
for (const label facei : edgeFaces[edgei])
{
label facei = eFaces[eFacei];
Type& currentWallInfo = allFaceInfo_[facei];
if (!currentWallInfo.equal(neighbourWallInfo, td_))
@ -562,7 +519,7 @@ edgeToFace()
updateFace
(
facei,
edgeI,
edgei,
neighbourWallInfo,
currentWallInfo
);
@ -572,10 +529,10 @@ edgeToFace()
if (debug)
{
Pout<< "Changed faces : " << changedFaces_.size() << endl;
Pout<< "Changed faces : " << nChangedFaces() << endl;
}
return returnReduce(changedFaces_.size(), sumOp<label>());
return returnReduce(nChangedFaces(), sumOp<label>());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef PatchEdgeFaceWave_H
#define PatchEdgeFaceWave_H
#ifndef Foam_PatchEdgeFaceWave_H
#define Foam_PatchEdgeFaceWave_H
#include "bitSet.H"
#include "scalarField.H"
@ -54,10 +54,105 @@ namespace Foam
class polyMesh;
/*---------------------------------------------------------------------------*\
Class PatchEdgeFaceWaveName Declaration
Class PatchEdgeFaceWaveBase Declaration
\*---------------------------------------------------------------------------*/
TemplateName(PatchEdgeFaceWave);
class PatchEdgeFaceWaveBase
{
protected:
// Protected Static Data
//- Relative tolerance.
// Stop propagation if relative changes less than this tolerance
// (responsibility for checking this is up to Type implementation)
static scalar propagationTol_;
// Protected Data
//- Reference to mesh
const polyMesh& mesh_;
//- Track if edge has changed
bitSet changedEdge_;
//- Track if face has changed
bitSet changedFace_;
//- List of changed edges
DynamicList<label> changedEdges_;
//- List of changed faces
DynamicList<label> changedFaces_;
//- Number of unvisited edges
label nUnvisitedEdges_;
//- Number of unvisited faces
label nUnvisitedFaces_;
public:
//- Default trackData value (for default template argument)
static label dummyTrackData_;
//- Runtime type information
ClassName("PatchEdgeFaceWave");
// Constructors
//- Construct with mesh reference and set initial sizes
PatchEdgeFaceWaveBase
(
const polyMesh& mesh,
const label nEdges,
const label nFaces
);
// Static Functions
//- Access to propagation tolerance
static scalar propagationTol() noexcept
{
return propagationTol_;
}
//- Change propagation tolerance, return previous value
static scalar setPropagationTol(const scalar tol) noexcept
{
scalar old(propagationTol_);
propagationTol_ = tol;
return old;
}
// Member Functions
//- Return access to the mesh
const polyMesh& mesh() const noexcept { return mesh_; }
//- Current number of changed edges
label nChangedEdges() const noexcept { return changedEdges_.size(); }
//- Current number of changed faces
label nChangedFaces() const noexcept { return changedFaces_.size(); }
//- Number of unvisited faces, i.e. faces that were not (yet)
//- reached from walking across patch.
//
// This can happen from
// - not enough iterations done
// - a disconnected patch
// - a patch without walls in it
label nUnvisitedFaces() const noexcept { return nUnvisitedFaces_; }
label nUnvisitedEdges() const noexcept { return nUnvisitedEdges_; }
};
/*---------------------------------------------------------------------------*\
@ -72,24 +167,10 @@ template
>
class PatchEdgeFaceWave
:
public PatchEdgeFaceWaveName
public PatchEdgeFaceWaveBase
{
// Private Static Data
//- Relative tolerance.
// Stop propagation if relative changes less than this tolerance
// (responsibility for checking this is up to Type implementation)
static scalar propagationTol_;
//- Default trackdata value to satisfy default template argument.
static label dummyTrackData_;
// Private Data
//- Reference to mesh
const polyMesh& mesh_;
//- Reference to patch
const PrimitivePatchType& patch_;
@ -102,26 +183,9 @@ class PatchEdgeFaceWave
//- Additional data to be passed into container
TrackingData& td_;
//- Has edge changed
bitSet changedEdge_;
//- List of changed edges
DynamicList<label> changedEdges_;
//- Has face changed
bitSet changedFace_;
//- List of changed faces
DynamicList<label> changedFaces_;
//- Number of evaluations
label nEvals_;
//- Number of unvisited faces/edges
label nUnvisitedEdges_;
label nUnvisitedFaces_;
// Addressing between edges of patch_ and globalData.coupledPatch()
labelList patchEdges_;
labelList coupledEdges_;
@ -162,21 +226,6 @@ class PatchEdgeFaceWave
public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors
//- Construct from patch, list of changed edges with the Type
@ -194,7 +243,7 @@ public:
UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo,
const label maxIter,
TrackingData& td = dummyTrackData_
TrackingData& td = PatchEdgeFaceWaveBase::dummyTrackData_
);
//- Construct from patch.
@ -205,47 +254,30 @@ public:
const PrimitivePatchType& patch,
UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo,
TrackingData& td = dummyTrackData_
TrackingData& td = PatchEdgeFaceWaveBase::dummyTrackData_
);
// Member Functions
//- Access allEdgeInfo
UList<Type>& allEdgeInfo() const
UList<Type>& allEdgeInfo() const noexcept
{
return allEdgeInfo_;
}
//- Access allFaceInfo
UList<Type>& allFaceInfo() const
UList<Type>& allFaceInfo() const noexcept
{
return allFaceInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
const TrackingData& data() const noexcept
{
return td_;
}
//- Number of unvisited faces, i.e. faces that were not (yet)
//- reached from walking across patch.
//
// This can happen from
// - not enough iterations done
// - a disconnected patch
// - a patch without walls in it
label nUnvisitedFaces() const
{
return nUnvisitedFaces_;
}
label nUnvisitedEdges() const
{
return nUnvisitedEdges_;
}
//- Copy initial data into allEdgeInfo_
void setEdgeInfo
(

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 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/>.
\*---------------------------------------------------------------------------*/
#include "PatchEdgeFaceWave.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(PatchEdgeFaceWaveBase, 0);
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::scalar Foam::PatchEdgeFaceWaveBase::propagationTol_ = 0.01;
Foam::label Foam::PatchEdgeFaceWaveBase::dummyTrackData_ = 12345;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PatchEdgeFaceWaveBase::PatchEdgeFaceWaveBase
(
const polyMesh& mesh,
const label nEdges,
const label nFaces
)
:
mesh_(mesh),
changedEdge_(nEdges),
changedFace_(nFaces),
changedEdges_(nEdges),
changedFaces_(nFaces),
nUnvisitedEdges_(nEdges),
nUnvisitedFaces_(nFaces)
{}
// ************************************************************************* //

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef PointData_H
#define PointData_H
#ifndef Foam_PointData_H
#define Foam_PointData_H
#include "pointEdgePoint.H"
@ -77,7 +77,7 @@ public:
// Constructors
//- Default construct
inline PointData();
PointData() = default;
//- Construct from origin, distance and data
inline PointData
@ -90,17 +90,37 @@ public:
// Member Functions
// Access
// Access
const DataType& data() const
{
return data_;
}
DataType& data()
{
return data_;
}
const DataType& data() const noexcept { return data_; }
DataType& data() noexcept { return data_; }
// Member Operators
//- Test for equality
inline bool operator==(const PointData<DataType>&) const;
//- Test for inequality
inline bool operator!=(const PointData<DataType>&) const;
// IOstream Operators
friend Ostream& operator<< <DataType>
(
Ostream&,
const PointData<DataType>&
);
friend Istream& operator>> <DataType>
(
Istream&,
PointData<DataType>&
);
// Wave Methods
// Needed by MeshWave
@ -157,29 +177,6 @@ public:
const scalar tol,
TrackingData& td
);
// Member Operators
//- Test for equality
inline bool operator==(const PointData<DataType>&) const;
//- Test for inequality
inline bool operator!=(const PointData<DataType>&) const;
// IOstream Operators
friend Ostream& operator<< <DataType>
(
Ostream&,
const PointData<DataType>&
);
friend Istream& operator>> <DataType>
(
Istream&,
PointData<DataType>&
);
};

View File

@ -31,13 +31,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class DataType>
inline Foam::PointData<DataType>::PointData()
:
pointEdgePoint()
{}
template<class DataType>
inline Foam::PointData<DataType>::PointData
(

View File

@ -39,12 +39,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type, class TrackingData>
Foam::scalar Foam::PointEdgeWave<Type, TrackingData>::propagationTol_ = 0.01;
template<class Type, class TrackingData>
int Foam::PointEdgeWave<Type, TrackingData>::dummyTrackData_ = 12345;
namespace Foam
{
//- Reduction class. If x and y are not equal assign value.
@ -154,7 +148,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::transform
// Update info for pointi, at position pt, with information from
// neighbouring edge.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - changedPoint_, changedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
template<class Type, class TrackingData>
bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
@ -182,10 +176,9 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
if (propagate)
{
if (!changedPoint_[pointi])
if (changedPoint_.set(pointi))
{
changedPoint_[pointi] = true;
changedPoints_[nChangedPoints_++] = pointi;
changedPoints_.push_back(pointi);
}
}
@ -201,7 +194,7 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
// Update info for pointi, at position pt, with information from
// same point.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - changedPoint_, changedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
template<class Type, class TrackingData>
bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
@ -227,10 +220,9 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
if (propagate)
{
if (!changedPoint_[pointi])
if (changedPoint_.set(pointi))
{
changedPoint_[pointi] = true;
changedPoints_[nChangedPoints_++] = pointi;
changedPoints_.push_back(pointi);
}
}
@ -243,15 +235,15 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
}
// Update info for edgeI, at position pt, with information from
// Update info for edgei, at position pt, with information from
// neighbouring point.
// Updates:
// - changedEdge_, changedEdges_, nChangedEdges_,
// - changedEdge_, changedEdges_,
// - statistics: nEvals_, nUnvisitedEdge_
template<class Type, class TrackingData>
bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
(
const label edgeI,
const label edgei,
const label neighbourPointi,
const Type& neighbourInfo,
Type& edgeInfo
@ -265,7 +257,7 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
edgeInfo.updateEdge
(
mesh_,
edgeI,
edgei,
neighbourPointi,
neighbourInfo,
propagationTol_,
@ -274,10 +266,9 @@ bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
if (propagate)
{
if (!changedEdge_[edgeI])
if (changedEdge_.set(edgei))
{
changedEdge_[edgeI] = true;
changedEdges_[nChangedEdges_++] = edgeI;
changedEdges_.push_back(edgei);
}
}
@ -297,11 +288,11 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::countPatchType() const
{
label nPatches = 0;
forAll(mesh_.boundaryMesh(), patchi)
for (const polyPatch& p : mesh_.boundaryMesh())
{
if (isA<PatchType>(mesh_.boundaryMesh()[patchi]))
if (isA<PatchType>(p))
{
nPatches++;
++nPatches;
}
}
return nPatches;
@ -338,7 +329,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
forAll(neighbPoints, thisPointi)
{
label meshPointi = procPatch.meshPoints()[thisPointi];
if (changedPoint_[meshPointi])
if (changedPoint_.test(meshPointi))
{
patchInfo.append(allPointInfo_[meshPointi]);
thisPoints.append(thisPointi);
@ -431,10 +422,8 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
DynamicList<label> nbrPoints;
DynamicList<label> thisPoints;
forAll(mesh_.boundaryMesh(), patchi)
for (const polyPatch& patch : mesh_.boundaryMesh())
{
const polyPatch& patch = mesh_.boundaryMesh()[patchi];
const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(patch);
if (cpp)
@ -460,7 +449,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
label nbrPointi = pairs[pairI][1];
label meshPointi = meshPoints[nbrPointi];
if (changedPoint_[meshPointi])
if (changedPoint_.test(meshPointi))
{
nbrInfo.append(allPointInfo_[meshPointi]);
nbrPoints.append(nbrPointi);
@ -483,7 +472,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
//if (debug)
//{
// Pout<< "Cyclic patch " << patchi << ' ' << patch.name()
// Pout<< "Cyclic patch " << patch.index() << ' ' << patch.name()
// << " Changed : " << nbrInfo.size()
// << endl;
//}
@ -586,17 +575,16 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
}
// Update database of changed points
if (!changedPoint_[meshPointi])
if (changedPoint_.set(meshPointi))
{
changedPoint_[meshPointi] = true;
changedPoints_[nChangedPoints_++] = meshPointi;
changedPoints_.push_back(meshPointi);
}
}
}
}
// Sum changedPoints over all procs
return returnReduce(nChangedPoints_, sumOp<label>());
return returnReduce(nChangedPoints(), sumOp<label>());
}
@ -618,20 +606,13 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
TrackingData& td
)
:
mesh_(mesh),
PointEdgeWaveBase(mesh),
allPointInfo_(allPointInfo),
allEdgeInfo_(allEdgeInfo),
td_(td),
changedPoint_(mesh_.nPoints(), false),
changedPoints_(mesh_.nPoints()),
nChangedPoints_(0),
changedEdge_(mesh_.nEdges(), false),
changedEdges_(mesh_.nEdges()),
nChangedEdges_(0),
nCyclicPatches_(countPatchType<cyclicPolyPatch>()),
nEvals_(0),
nUnvisitedPoints_(mesh_.nPoints()),
nUnvisitedEdges_(mesh_.nEdges())
nEvals_(0)
{
if (allPointInfo_.size() != mesh_.nPoints())
{
@ -659,7 +640,7 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
if (debug)
{
Info<< typeName << ": Seed points : "
<< returnReduce(nChangedPoints_, sumOp<label>()) << endl;
<< returnReduce(nChangedPoints(), sumOp<label>()) << endl;
}
// Iterate until nothing changes
@ -669,9 +650,9 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
{
FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << endl
<< " maxIter:" << maxIter << endl
<< " nChangedPoints:" << nChangedPoints_ << endl
<< " nChangedEdges:" << nChangedEdges_ << endl
<< " maxIter:" << maxIter << nl
<< " nChangedPoints:" << nChangedPoints() << nl
<< " nChangedEdges:" << nChangedEdges() << endl
<< exit(FatalError);
}
}
@ -686,39 +667,18 @@ Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
TrackingData& td
)
:
mesh_(mesh),
PointEdgeWaveBase(mesh),
allPointInfo_(allPointInfo),
allEdgeInfo_(allEdgeInfo),
td_(td),
changedPoint_(mesh_.nPoints(), false),
changedPoints_(mesh_.nPoints()),
nChangedPoints_(0),
changedEdge_(mesh_.nEdges(), false),
changedEdges_(mesh_.nEdges()),
nChangedEdges_(0),
nCyclicPatches_(countPatchType<cyclicPolyPatch>()),
nEvals_(0),
nUnvisitedPoints_(mesh_.nPoints()),
nUnvisitedEdges_(mesh_.nEdges())
nEvals_(0)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type, TrackingData>::nUnvisitedPoints() const
{
return nUnvisitedPoints_;
}
template<class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type, TrackingData>::nUnvisitedEdges() const
{
return nUnvisitedEdges_;
}
// Copy point information into member data
template<class Type, class TrackingData>
void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
@ -744,10 +704,9 @@ void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
// Mark pointi as changed, both on list and on point itself.
if (!changedPoint_[pointi])
if (changedPoint_.set(pointi))
{
changedPoint_[pointi] = true;
changedPoints_[nChangedPoints_++] = pointi;
changedPoints_.push_back(pointi);
}
}
@ -760,29 +719,22 @@ void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
template<class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
{
for
(
label changedEdgeI = 0;
changedEdgeI < nChangedEdges_;
changedEdgeI++
)
for (const label edgei : changedEdges_)
{
label edgeI = changedEdges_[changedEdgeI];
if (!changedEdge_[edgeI])
if (!changedEdge_.test(edgei))
{
FatalErrorInFunction
<< "edge " << edgeI
<< "edge " << edgei
<< " not marked as having been changed" << nl
<< "This might be caused by multiple occurrences of the same"
<< " seed point." << abort(FatalError);
}
const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
const Type& neighbourWallInfo = allEdgeInfo_[edgei];
// Evaluate all connected points (= edge endpoints)
const edge& e = mesh_.edges()[edgeI];
const edge& e = mesh_.edges()[edgei];
forAll(e, eI)
{
@ -793,7 +745,7 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
updatePoint
(
e[eI],
edgeI,
edgei,
neighbourWallInfo,
currentWallInfo
);
@ -801,11 +753,11 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
}
// Reset status of edge
changedEdge_[edgeI] = false;
changedEdge_.unset(edgei);
}
// Handled all changed edges by now
nChangedEdges_ = 0;
changedEdges_.clear();
if (nCyclicPatches_ > 0)
{
@ -820,11 +772,11 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
//if (debug)
//{
// Pout<< "Changed points : " << nChangedPoints_ << endl;
// Pout<< "Changed points : " << nChangedPoints() << nl;
//}
// Sum changedPoints over all procs
return returnReduce(nChangedPoints_, sumOp<label>());
return returnReduce(nChangedPoints(), sumOp<label>());
}
@ -834,16 +786,9 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
{
const labelListList& pointEdges = mesh_.pointEdges();
for
(
label changedPointi = 0;
changedPointi < nChangedPoints_;
changedPointi++
)
for (const label pointi : changedPoints_)
{
label pointi = changedPoints_[changedPointi];
if (!changedPoint_[pointi])
if (!changedPoint_.test(pointi))
{
FatalErrorInFunction
<< "Point " << pointi
@ -856,18 +801,15 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
// Evaluate all connected edges
const labelList& edgeLabels = pointEdges[pointi];
forAll(edgeLabels, edgeLabelI)
for (const label edgei : pointEdges[pointi])
{
label edgeI = edgeLabels[edgeLabelI];
Type& currentWallInfo = allEdgeInfo_[edgeI];
Type& currentWallInfo = allEdgeInfo_[edgei];
if (!currentWallInfo.equal(neighbourWallInfo, td_))
{
updateEdge
(
edgeI,
edgei,
pointi,
neighbourWallInfo,
currentWallInfo
@ -876,19 +818,19 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
}
// Reset status of point
changedPoint_[pointi] = false;
changedPoint_.unset(pointi);
}
// Handled all changed points by now
nChangedPoints_ = 0;
changedPoints_.clear();
//if (debug)
//{
// Pout<< "Changed edges : " << nChangedEdges_ << endl;
// Pout<< "Changed edges : " << nChangedEdges() << endl;
//}
// Sum changedEdges over all procs
return returnReduce(nChangedEdges_, sumOp<label>());
return returnReduce(nChangedEdges(), sumOp<label>());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,8 +58,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef PointEdgeWave_H
#define PointEdgeWave_H
#ifndef Foam_PointEdgeWave_H
#define Foam_PointEdgeWave_H
#include "bitSet.H"
#include "scalarField.H"
@ -75,10 +75,100 @@ class polyMesh;
class polyPatch;
/*---------------------------------------------------------------------------*\
Class PointEdgeWaveName Declaration
Class PointEdgeWaveBase Declaration
\*---------------------------------------------------------------------------*/
TemplateName(PointEdgeWave);
class PointEdgeWaveBase
{
protected:
// Protected Static Data
//- Relative tolerance.
// Stop propagation if relative changes less than this tolerance
// (responsibility for checking this is up to Type implementation)
static scalar propagationTol_;
// Protected Data
//- Reference to mesh
const polyMesh& mesh_;
//- Track if point has changed
bitSet changedPoint_;
//- Track if edge has changed
bitSet changedEdge_;
//- List of changed points
DynamicList<label> changedPoints_;
//- List of changed edges
DynamicList<label> changedEdges_;
//- Number of unvisited points
label nUnvisitedPoints_;
//- Number of unvisited edges
label nUnvisitedEdges_;
public:
//- Default trackData value (for default template argument)
static int dummyTrackData_;
//- Runtime type information
ClassName("PointEdgeWave");
// Constructors
//- Construct with mesh reference and set initial sizes
PointEdgeWaveBase(const polyMesh& mesh);
// Static Functions
//- Access to propagation tolerance
static scalar propagationTol() noexcept
{
return propagationTol_;
}
//- Change propagation tolerance, return previous value
static scalar setPropagationTol(const scalar tol) noexcept
{
scalar old(propagationTol_);
propagationTol_ = tol;
return old;
}
// Member Functions
//- Return access to the mesh
const polyMesh& mesh() const noexcept { return mesh_; }
//- Current number of changed points
label nChangedPoints() const noexcept { return changedPoints_.size(); }
//- Current number of changed edges
label nChangedEdges() const noexcept { return changedEdges_.size(); }
//- Number of unvisited edges,
//- i.e. edges that were not (yet) reached from walking across mesh.
// This can happen from
// - not enough iterations done
// - a disconnected mesh
// - a mesh without walls in it
label nUnvisitedEdges() const noexcept { return nUnvisitedEdges_; }
//- Get number of unvisited points
label nUnvisitedPoints() const noexcept { return nUnvisitedPoints_; }
};
/*---------------------------------------------------------------------------*\
@ -88,24 +178,10 @@ TemplateName(PointEdgeWave);
template<class Type, class TrackingData = int>
class PointEdgeWave
:
public PointEdgeWaveName
public PointEdgeWaveBase
{
// Private Static Data
//- Relative tolerance. Stop propagation if relative changes
// less than this tolerance (responsibility for checking this is
// up to Type implementation)
static scalar propagationTol_;
//- Default trackdata value to satisfy default template argument.
static int dummyTrackData_;
// Private Data
//- Reference to mesh
const polyMesh& mesh_;
//- Wall information for all points
UList<Type>& allPointInfo_;
@ -115,31 +191,12 @@ class PointEdgeWave
//- Additional data to be passed into container
TrackingData& td_;
//- Has point changed
bitSet changedPoint_;
//- List of changed points
labelList changedPoints_;
//- Number of changed points
label nChangedPoints_;
//- Edges that have changed
bitSet changedEdge_;
labelList changedEdges_;
label nChangedEdges_;
//- Number of cyclic patches
label nCyclicPatches_;
//- Number of evaluations
label nEvals_;
//- Number of unvisited edges/points
label nUnvisitedPoints_;
label nUnvisitedEdges_;
// Private Member Functions
@ -222,21 +279,6 @@ class PointEdgeWave
public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors
//- Construct from mesh, list of changed points with the Type
@ -273,32 +315,23 @@ public:
// Member Functions
//- Access allPointInfo
UList<Type>& allPointInfo() const
UList<Type>& allPointInfo() const noexcept
{
return allPointInfo_;
}
//- Access allEdgeInfo
UList<Type>& allEdgeInfo() const
UList<Type>& allEdgeInfo() const noexcept
{
return allEdgeInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
const TrackingData& data() const noexcept
{
return td_;
}
//- Number of unvisited edges, i.e. edges that were not (yet)
// reached from walking across mesh. This can happen from
// - not enough iterations done
// - a disconnected mesh
// - a mesh without walls in it
label nUnvisitedEdges() const;
label nUnvisitedPoints() const;
//- Copy initial data into allPointInfo_
void setPointInfo
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,14 +26,37 @@ License
\*---------------------------------------------------------------------------*/
#include "FaceCellWave.H"
#include "PointEdgeWave.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(FaceCellWaveName, 0);
defineTypeNameAndDebug(PointEdgeWaveBase, 0);
}
Foam::scalar Foam::PointEdgeWaveBase::propagationTol_ = 0.01;
int Foam::PointEdgeWaveBase::dummyTrackData_ = 12345;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PointEdgeWaveBase::PointEdgeWaveBase
(
const polyMesh& mesh
)
:
mesh_(mesh),
changedPoint_(mesh_.nPoints()),
changedEdge_(mesh_.nEdges()),
changedPoints_(mesh_.nPoints()),
changedEdges_(mesh_.nEdges()),
nUnvisitedPoints_(mesh_.nPoints()),
nUnvisitedEdges_(mesh_.nEdges())
{}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef pointEdgePoint_H
#define pointEdgePoint_H
#ifndef Foam_pointEdgePoint_H
#define Foam_pointEdgePoint_H
#include "point.H"
#include "label.H"
@ -104,7 +104,7 @@ public:
// Constructors
//- Default construct
//- Default construct. Max point
inline pointEdgePoint();
//- Construct from origin, distance
@ -113,26 +113,33 @@ public:
// Member Functions
// Access
// Access
const point& origin() const
{
return origin_;
}
point& origin()
{
return origin_;
}
const point& origin() const noexcept { return origin_; }
scalar distSqr() const
{
return distSqr_;
}
scalar& distSqr()
{
return distSqr_;
}
point& origin() noexcept { return origin_; }
scalar distSqr() const noexcept { return distSqr_; }
scalar& distSqr() noexcept { return distSqr_; }
// Member Operators
//- Test for equality
inline bool operator==(const pointEdgePoint&) const;
//- Test for inequality
inline bool operator!=(const pointEdgePoint&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const pointEdgePoint&);
friend Istream& operator>>(Istream&, pointEdgePoint&);
// Wave Methods
// Needed by PointEdgeWave
@ -227,21 +234,6 @@ public:
//- Test for equality, with TrackingData
template<class TrackingData>
inline bool equal(const pointEdgePoint&, TrackingData& td) const;
// Member Operators
//- Test for equality
inline bool operator==(const pointEdgePoint&) const;
//- Test for inequality
inline bool operator!=(const pointEdgePoint&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const pointEdgePoint&);
friend Istream& operator>>(Istream&, pointEdgePoint&);
};

View File

@ -295,7 +295,7 @@ inline bool Foam::pointEdgePoint::operator==
const pointEdgePoint& rhs
) const
{
return origin_ == rhs.origin_ && distSqr_ == rhs.distSqr_;
return distSqr_ == rhs.distSqr_ && origin_ == rhs.origin_;
}

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef treeDataPrimitivePatch_H
#define treeDataPrimitivePatch_H
#ifndef Foam_treeDataPrimitivePatch_H
#define Foam_treeDataPrimitivePatch_H
#include "treeBoundBoxList.H"
#include "volumeType.H"
@ -45,7 +45,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward Declarations
template<class Type> class indexedOctree;
@ -65,7 +65,7 @@ class treeDataPrimitivePatch
:
public treeDataPrimitivePatchName
{
// Private data
// Private Data
//- Underlying geometry
const PatchType& patch_;

View File

@ -4,6 +4,6 @@ CuthillMcKeeRenumber/CuthillMcKeeRenumber.C
randomRenumber/randomRenumber.C
springRenumber/springRenumber.C
structuredRenumber/structuredRenumber.C
structuredRenumber/OppositeFaceCellWaveName.C
structuredRenumber/OppositeFaceCellWaveBase.C
LIB = $(FOAM_LIBBIN)/librenumberMethods

View File

@ -96,7 +96,7 @@ Foam::OppositeFaceCellWave<Type, TrackingData>::OppositeFaceCellWave
0, //maxIter,
td
),
changedOppositeFaces_(this->mesh_.nCells())
OppositeFaceCellWaveBase(mesh)
{
// Iterate until nothing changes
label iter = this->iterate(maxIter);
@ -107,8 +107,8 @@ Foam::OppositeFaceCellWave<Type, TrackingData>::OppositeFaceCellWave
<< "Maximum number of iterations reached. Increase maxIter."
<< endl
<< " maxIter:" << maxIter << endl
<< " nChangedCells:" << this->changedCells_.size() << endl
<< " nChangedFaces:" << this->changedFaces_.size() << endl
<< " nChangedCells:" << this->nChangedCells() << endl
<< " nChangedFaces:" << this->nChangedFaces() << endl
<< exit(FatalError);
}
}
@ -125,10 +125,8 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
DynamicList<label> oppositeFaceLabels;
forAll(this->changedFaces_, changedFacei)
for (const label facei : this->changedFaces_)
{
label facei = this->changedFaces_[changedFacei];
if (!this->changedFace_.test(facei))
{
FatalErrorInFunction
@ -154,7 +152,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
if (oppositeFaceLabels.size())
{
label sz = this->changedCells_.size();
label sz = this->nChangedCells();
this->updateCell
(
celli,
@ -163,14 +161,14 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
this->propagationTol_,
currentWallInfo
);
if (this->changedCells_.size() > sz)
if (this->nChangedCells() > sz)
{
label oppFacei = -1;
if (oppositeFaceLabels.size() == 1)
{
oppFacei = oppositeFaceLabels[0];
oppFacei = oppositeFaceLabels.front();
}
changedOppositeFaces_.append(oppFacei);
changedOppositeFaces_.push_back(oppFacei);
}
}
}
@ -189,7 +187,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
if (oppositeFaceLabels.size())
{
label sz = this->changedCells_.size();
label sz = this->nChangedCells();
this->updateCell
(
celli,
@ -198,14 +196,14 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
this->propagationTol_,
currentWallInfo2
);
if (this->changedCells_.size() > sz)
if (this->nChangedCells() > sz)
{
label oppFacei = -1;
if (oppositeFaceLabels.size() == 1)
{
oppFacei = oppositeFaceLabels[0];
oppFacei = oppositeFaceLabels.front();
}
changedOppositeFaces_.append(oppFacei);
changedOppositeFaces_.push_back(oppFacei);
}
}
}
@ -220,12 +218,11 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
if (debug & 2)
{
Pout<< " Changed cells : " << this->changedCells_.size()
<< endl;
Pout<< " Changed cells : " << this->nChangedCells() << endl;
}
// Sum changedCells over all procs
return returnReduce(this->changedCells_.size(), sumOp<label>());
return returnReduce(this->nChangedCells(), sumOp<label>());
}
@ -292,12 +289,12 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::cellToFace()
if (debug & 2)
{
Pout<< " Changed faces : " << this->changedFaces_.size()
Pout<< " Changed faces : " << this->nChangedFaces()
<< endl;
}
// Sum changedFaces over all procs
return returnReduce(this->changedFaces_.size(), sumOp<label>());
return returnReduce(this->nChangedFaces(), sumOp<label>());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef OppositeFaceCellWave_H
#define OppositeFaceCellWave_H
#ifndef Foam_OppositeFaceCellWave_H
#define Foam_OppositeFaceCellWave_H
#include "FaceCellWave.H"
@ -55,10 +55,31 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class OppositeFaceCellWaveName Declaration
Class OppositeFaceCellWaveBase Declaration
\*---------------------------------------------------------------------------*/
TemplateName(OppositeFaceCellWave);
class OppositeFaceCellWaveBase
{
protected:
// Protected Data
//- For every entry in changedCells (i.e. the cell front) gives
// the face that it needs to transfer to
DynamicList<label> changedOppositeFaces_;
public:
//- Runtime type information
ClassName("OppositeFaceCellWave");
// Constructors
//- Construct with mesh reference (for sizing)
OppositeFaceCellWaveBase(const polyMesh& mesh);
};
/*---------------------------------------------------------------------------*\
@ -69,17 +90,10 @@ template<class Type, class TrackingData = int>
class OppositeFaceCellWave
:
public FaceCellWave<Type, TrackingData>,
public OppositeFaceCellWaveName
public OppositeFaceCellWaveBase
{
protected:
// Protected Data
//- For every entry in changedCells (i.e. the cell front) gives
// the face that it needs to transfer to
DynamicList<label> changedOppositeFaces_;
// Protected Member Functions
//- Determine 'opposite' faces (= faces not sharing a vertex) on cell
@ -107,7 +121,7 @@ public:
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
const label maxIter,
TrackingData& td = FaceCellWave<Type, TrackingData>::dummyTrackData_
TrackingData& td = FaceCellWaveBase::dummyTrackData_
);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,13 +27,25 @@ License
\*---------------------------------------------------------------------------*/
#include "OppositeFaceCellWave.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(OppositeFaceCellWaveName, 0);
defineTypeNameAndDebug(OppositeFaceCellWaveBase, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::OppositeFaceCellWaveBase::OppositeFaceCellWaveBase
(
const polyMesh& mesh
)
:
changedOppositeFaces_(mesh.nCells())
{}
// ************************************************************************* //