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 interpolations = interpolations
interpolation = $(interpolations)/interpolation interpolation = $(interpolations)/interpolation
$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C $(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationBase.C
$(interpolations)/interpolationTable/tableReaders/tableReaders.C $(interpolations)/interpolationTable/tableReaders/tableReaders.C
$(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C $(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C

View File

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

View File

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

View File

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

View File

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

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef PatchToPatchInterpolation_H #ifndef Foam_PatchToPatchInterpolation_H
#define PatchToPatchInterpolation_H #define Foam_PatchToPatchInterpolation_H
#include "className.H" #include "className.H"
#include "labelList.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> template<class FromPatch, class ToPatch>
class PatchToPatchInterpolation class PatchToPatchInterpolation
: :
public PatchToPatchInterpolationName public PatchToPatchInterpolationBase
{ {
// Private data // Private Data
//- Reference to the source patch //- Reference to the source patch
const FromPatch& fromPatch_; const FromPatch& fromPatch_;
@ -84,34 +130,28 @@ class PatchToPatchInterpolation
intersection::direction dir_; 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_;
// Point addressing
//- Face into which each point of target patch is projected //- Face into which each point of target patch is projected
mutable labelList* pointAddressingPtr_; mutable std::unique_ptr<labelList> pointAddressingPtr_;
//- Weighting factors //- Weighting factors
mutable FieldField<Field, scalar>* pointWeightsPtr_; mutable std::unique_ptr<FieldField<Field, scalar>> pointWeightsPtr_;
//- Distance to intersection for patch points //- Distance to intersection for patch points
mutable scalarField* pointDistancePtr_; mutable std::unique_ptr<scalarField> pointDistancePtr_;
// Face addressing
// Face Addressing
//- Face into which each face centre of target patch is projected //- Face into which each face centre of target patch is projected
mutable labelList* faceAddressingPtr_; mutable std::unique_ptr<labelList> faceAddressingPtr_;
//- Weighting factors //- Weighting factors
mutable FieldField<Field, scalar>* faceWeightsPtr_; mutable std::unique_ptr<FieldField<Field, scalar>> faceWeightsPtr_;
//- Distance to intersection for patch face centres //- Distance to intersection for patch face centres
mutable scalarField* faceDistancePtr_; mutable std::unique_ptr<scalarField> faceDistancePtr_;
// Private Member Functions // Private Member Functions
@ -145,12 +185,6 @@ class PatchToPatchInterpolation
const FieldField<Field, scalar>& faceWeights() const; const FieldField<Field, scalar>& faceWeights() const;
// Private static data members
//- Direct hit tolerance
static const scalar directHitTol;
public: public:
// Constructors // Constructors
@ -171,21 +205,6 @@ public:
// Member Functions // 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 //- Return ype of intersection algorithm to use in projection
intersection::algorithm projectionAlgo() const intersection::algorithm projectionAlgo() const
{ {

View File

@ -25,14 +25,19 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "PointEdgeWave.H" #include "PatchToPatchInterpolation.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam 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 #ifndef Foam_blendedSchemeBase_H
#define blendedSchemeBase_H #define Foam_blendedSchemeBase_H
#include "className.H" #include "className.H"
#include "tmp.H" #include "tmp.H"
@ -57,12 +57,10 @@ class blendedSchemeBase
: :
public blendedSchemeBaseName public blendedSchemeBaseName
{ {
public: public:
//- Constructor //- Constructor
blendedSchemeBase() blendedSchemeBase() = default;
{}
//- Destructor //- Destructor
virtual ~blendedSchemeBase() = default; virtual ~blendedSchemeBase() = default;

View File

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

View File

@ -41,16 +41,6 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * 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 namespace Foam
{ {
template<class Type, class TrackingData> template<class Type, class TrackingData>
@ -145,7 +135,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateCell
{ {
if (changedCell_.set(celli)) 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)) 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)) 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) // Mark facei as visited and changed (both on list and on face itself)
changedFace_.set(facei); 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. // Mark facei as changed, both on list and on face itself.
changedFace_.set(facei); changedFace_.set(facei);
changedFaces_.append(facei); changedFaces_.push_back(facei);
} }
} }
@ -840,13 +830,13 @@ void Foam::FaceCellWave<Type, TrackingData>::handleExplicitConnections()
if (changedFace_.test(f0)) if (changedFace_.test(f0))
{ {
// f0 changed. Update information on f1. // f0 changed. Update information on f1.
changedBaffles_.append(taggedInfoType(f1, allFaceInfo_[f0])); changedBaffles_.push_back(taggedInfoType(f1, allFaceInfo_[f0]));
} }
if (changedFace_.test(f1)) if (changedFace_.test(f1))
{ {
// f1 changed. Update information on f0. // 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 TrackingData& td
) )
: :
mesh_(mesh), FaceCellWaveBase(mesh),
explicitConnections_(), explicitConnections_(),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo), allCellInfo_(allCellInfo),
td_(td), td_(td),
changedFace_(mesh_.nFaces(), false),
changedCell_(mesh_.nCells(), false),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
changedBaffles_(2*explicitConnections_.size()), changedBaffles_(2*explicitConnections_.size()),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()), hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_ hasCyclicAMIPatches_
( (
returnReduceOr(hasPatch<cyclicAMIPolyPatch>()) returnReduceOr(hasPatch<cyclicAMIPolyPatch>())
), ),
nEvals_(0), nEvals_(0)
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
{ {
if if
( (
@ -935,24 +920,19 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
TrackingData& td TrackingData& td
) )
: :
mesh_(mesh), FaceCellWaveBase(mesh),
explicitConnections_(), explicitConnections_(),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo), allCellInfo_(allCellInfo),
td_(td), td_(td),
changedFace_(mesh_.nFaces(), false),
changedCell_(mesh_.nCells(), false),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
changedBaffles_(2*explicitConnections_.size()), changedBaffles_(2*explicitConnections_.size()),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()), hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_ hasCyclicAMIPatches_
( (
returnReduceOr(hasPatch<cyclicAMIPolyPatch>()) returnReduceOr(hasPatch<cyclicAMIPolyPatch>())
), ),
nEvals_(0), nEvals_(0)
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
{ {
if if
( (
@ -980,8 +960,8 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
FatalErrorInFunction FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << nl << "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << nl << " maxIter:" << maxIter << nl
<< " nChangedCells:" << changedCells_.size() << nl << " nChangedCells:" << nChangedCells() << nl
<< " nChangedFaces:" << changedFaces_.size() << endl << " nChangedFaces:" << nChangedFaces() << endl
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -1001,15 +981,12 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
TrackingData& td TrackingData& td
) )
: :
mesh_(mesh), FaceCellWaveBase(mesh),
explicitConnections_(explicitConnections), explicitConnections_(explicitConnections),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
allCellInfo_(allCellInfo), allCellInfo_(allCellInfo),
td_(td), td_(td),
changedFace_(mesh_.nFaces(), false),
changedCell_(mesh_.nCells(), false),
changedFaces_(mesh_.nFaces()),
changedCells_(mesh_.nCells()),
changedBaffles_(2*explicitConnections_.size()), changedBaffles_(2*explicitConnections_.size()),
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()), hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
hasCyclicAMIPatches_ hasCyclicAMIPatches_
@ -1017,9 +994,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
handleCyclicAMI handleCyclicAMI
&& returnReduceOr(hasPatch<cyclicAMIPolyPatch>()) && returnReduceOr(hasPatch<cyclicAMIPolyPatch>())
), ),
nEvals_(0), nEvals_(0)
nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces())
{ {
if if
( (
@ -1047,8 +1022,8 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
FatalErrorInFunction FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << nl << "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << nl << " maxIter:" << maxIter << nl
<< " nChangedCells:" << changedCells_.size() << nl << " nChangedCells:" << nChangedCells() << nl
<< " nChangedFaces:" << changedFaces_.size() << endl << " nChangedFaces:" << nChangedFaces() << endl
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -1056,20 +1031,6 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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> template<class Type, class TrackingData>
Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell() Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
{ {
@ -1139,11 +1100,11 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
if (debug & 2) if (debug & 2)
{ {
Pout<< " Changed cells : " << changedCells_.size() << endl; Pout<< " Changed cells : " << nChangedCells() << endl;
} }
// Number of changedCells over all procs // 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) if (debug & 2)
{ {
Pout<< " Changed faces : " << changedFaces_.size() << endl; Pout<< " Changed faces : " << nChangedFaces() << endl;
} }
// Number of changedFaces over all procs // 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 | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,8 +47,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef FaceCellWave_H #ifndef Foam_FaceCellWave_H
#define FaceCellWave_H #define Foam_FaceCellWave_H
#include "bitSet.H" #include "bitSet.H"
#include "DynamicList.H" #include "DynamicList.H"
@ -65,10 +65,101 @@ class polyMesh;
class polyPatch; 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> template<class Type, class TrackingData = int>
class FaceCellWave class FaceCellWave
: :
public FaceCellWaveName public FaceCellWaveBase
{ {
protected: protected:
@ -87,20 +178,8 @@ protected:
typedef std::pair<label,Type> taggedInfoType; 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 // Protected Data
//- Reference to mesh
const polyMesh& mesh_;
//- Optional boundary faces that information should travel through //- Optional boundary faces that information should travel through
const labelPairList explicitConnections_; const labelPairList explicitConnections_;
@ -113,18 +192,6 @@ protected:
//- Additional data to be passed into container //- Additional data to be passed into container
TrackingData& td_; 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 // Information exchange for explicit baffle connections
// Max capacity = 2x number of explicit connections // Max capacity = 2x number of explicit connections
DynamicList<taggedInfoType> changedBaffles_; DynamicList<taggedInfoType> changedBaffles_;
@ -138,10 +205,6 @@ protected:
//- Number of evaluations //- Number of evaluations
label nEvals_; label nEvals_;
//- Number of unvisited cells/faces
label nUnvisitedCells_;
label nUnvisitedFaces_;
// Protected Member Functions // Protected Member Functions
@ -266,21 +329,6 @@ protected:
public: public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors // Constructors
//- Construct from mesh. //- Construct from mesh.
@ -290,7 +338,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
UList<Type>& allFaceInfo, UList<Type>& allFaceInfo,
UList<Type>& allCellInfo, UList<Type>& allCellInfo,
TrackingData& td = dummyTrackData_ TrackingData& td = FaceCellWaveBase::dummyTrackData_
); );
//- Construct from mesh and list of changed faces with the Type //- Construct from mesh and list of changed faces with the Type
@ -304,7 +352,7 @@ public:
UList<Type>& allFaceInfo, UList<Type>& allFaceInfo,
UList<Type>& allCellInfo, UList<Type>& allCellInfo,
const label maxIter, const label maxIter,
TrackingData& td = dummyTrackData_ TrackingData& td = FaceCellWaveBase::dummyTrackData_
); );
//- Construct from mesh and explicitly connected boundary faces //- Construct from mesh and explicitly connected boundary faces
@ -321,7 +369,7 @@ public:
UList<Type>& allFaceInfo, UList<Type>& allFaceInfo,
UList<Type>& allCellInfo, UList<Type>& allCellInfo,
const label maxIter, const label maxIter,
TrackingData& td = dummyTrackData_ TrackingData& td = FaceCellWaveBase::dummyTrackData_
); );
@ -334,40 +382,23 @@ public:
// Access // Access
//- Access allFaceInfo //- Access allFaceInfo
UList<Type>& allFaceInfo() UList<Type>& allFaceInfo() noexcept
{ {
return allFaceInfo_; return allFaceInfo_;
} }
//- Access allCellInfo //- Access allCellInfo
UList<Type>& allCellInfo() UList<Type>& allCellInfo() noexcept
{ {
return allCellInfo_; return allCellInfo_;
} }
//- Additional data to be passed into container //- Additional data to be passed into container
const TrackingData& data() const const TrackingData& data() const noexcept
{ {
return td_; 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 // Edit

View File

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

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,28 +31,6 @@ License
#include "globalMeshData.H" #include "globalMeshData.H"
#include "PatchTools.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 * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update info for edgeI, at position pt, with information from // Update info for edgeI, at position pt, with information from
@ -68,7 +47,7 @@ template
bool Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>:: bool Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
updateEdge updateEdge
( (
const label edgeI, const label edgei,
const label neighbourFacei, const label neighbourFacei,
const Type& neighbourInfo, const Type& neighbourInfo,
Type& edgeInfo Type& edgeInfo
@ -83,7 +62,7 @@ updateEdge
( (
mesh_, mesh_,
patch_, patch_,
edgeI, edgei,
neighbourFacei, neighbourFacei,
neighbourInfo, neighbourInfo,
propagationTol_, propagationTol_,
@ -92,10 +71,9 @@ updateEdge
if (propagate) if (propagate)
{ {
if (!changedEdge_[edgeI]) if (changedEdge_.set(edgei))
{ {
changedEdge_.set(edgeI); changedEdges_.push_back(edgei);
changedEdges_.append(edgeI);
} }
} }
@ -148,7 +126,7 @@ updateFace
{ {
if (changedFace_.set(facei)) if (changedFace_.set(facei))
{ {
changedFaces_.append(facei); changedFaces_.push_back(facei);
} }
} }
@ -185,7 +163,7 @@ syncEdges()
label patchEdgeI = patchEdges_[i]; label patchEdgeI = patchEdges_[i];
label coupledEdgeI = coupledEdges_[i]; label coupledEdgeI = coupledEdges_[i];
if (changedEdge_[patchEdgeI]) if (changedEdge_.test(patchEdgeI))
{ {
const Type& data = allEdgeInfo_[patchEdgeI]; const Type& data = allEdgeInfo_[patchEdgeI];
@ -266,10 +244,9 @@ syncEdges()
td_ td_
); );
if (!changedEdge_[patchEdgeI]) if (changedEdge_.set(patchEdgeI))
{ {
changedEdge_.set(patchEdgeI); changedEdges_.push_back(patchEdgeI);
changedEdges_.append(patchEdgeI);
} }
} }
} }
@ -301,18 +278,12 @@ PatchEdgeFaceWave
TrackingData& td TrackingData& td
) )
: :
mesh_(mesh), PatchEdgeFaceWaveBase(mesh, patch.nEdges(), patch.size()),
patch_(patch), patch_(patch),
allEdgeInfo_(allEdgeInfo), allEdgeInfo_(allEdgeInfo),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
td_(td), td_(td),
changedEdge_(patch_.nEdges()), nEvals_(0)
changedEdges_(patch_.size()),
changedFace_(patch_.size()),
changedFaces_(patch_.size()),
nEvals_(0),
nUnvisitedEdges_(patch_.nEdges()),
nUnvisitedFaces_(patch_.size())
{ {
// Calculate addressing between patch_ and mesh.globalData().coupledPatch() // Calculate addressing between patch_ and mesh.globalData().coupledPatch()
// for ease of synchronisation // for ease of synchronisation
@ -331,18 +302,18 @@ PatchEdgeFaceWave
{ {
FatalErrorInFunction FatalErrorInFunction
<< "size of edgeInfo work array is not equal to the number" << "size of edgeInfo work array is not equal to the number"
<< " of edges in the patch" << endl << " of edges in the patch" << nl
<< " edgeInfo :" << allEdgeInfo_.size() << endl << " edgeInfo :" << allEdgeInfo_.size() << nl
<< " patch.nEdges:" << patch_.nEdges() << " patch.nEdges:" << patch_.nEdges() << endl
<< exit(FatalError); << exit(FatalError);
} }
if (allFaceInfo_.size() != patch_.size()) if (allFaceInfo_.size() != patch_.size())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "size of edgeInfo work array is not equal to the number" << "size of edgeInfo work array is not equal to the number"
<< " of faces in the patch" << endl << " of faces in the patch" << nl
<< " faceInfo :" << allFaceInfo_.size() << endl << " faceInfo :" << allFaceInfo_.size() << nl
<< " patch.size:" << patch_.size() << " patch.size:" << patch_.size() << endl
<< exit(FatalError); << exit(FatalError);
} }
@ -352,7 +323,7 @@ PatchEdgeFaceWave
if (debug) if (debug)
{ {
Pout<< "Seed edges : " << changedEdges_.size() << endl; Pout<< "Seed edges : " << nChangedEdges() << endl;
} }
// Iterate until nothing changes // Iterate until nothing changes
@ -361,10 +332,10 @@ PatchEdgeFaceWave
if ((maxIter > 0) && (iter >= maxIter)) if ((maxIter > 0) && (iter >= maxIter))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Maximum number of iterations reached. Increase maxIter." << endl << "Maximum number of iterations reached. Increase maxIter." << nl
<< " maxIter:" << maxIter << endl << " maxIter:" << maxIter << nl
<< " changedEdges:" << changedEdges_.size() << endl << " changedEdges:" << nChangedEdges() << nl
<< " changedFaces:" << changedFaces_.size() << endl << " changedFaces:" << nChangedFaces() << endl
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -386,18 +357,12 @@ PatchEdgeFaceWave
TrackingData& td TrackingData& td
) )
: :
mesh_(mesh), PatchEdgeFaceWaveBase(mesh, patch.nEdges(), patch.size()),
patch_(patch), patch_(patch),
allEdgeInfo_(allEdgeInfo), allEdgeInfo_(allEdgeInfo),
allFaceInfo_(allFaceInfo), allFaceInfo_(allFaceInfo),
td_(td), td_(td),
changedEdge_(patch_.nEdges()), nEvals_(0)
changedEdges_(patch_.nEdges()),
changedFace_(patch_.size()),
changedFaces_(patch_.size()),
nEvals_(0),
nUnvisitedEdges_(patch_.nEdges()),
nUnvisitedFaces_(patch_.size())
{ {
// Calculate addressing between patch_ and mesh.globalData().coupledPatch() // Calculate addressing between patch_ and mesh.globalData().coupledPatch()
// for ease of synchronisation // for ease of synchronisation
@ -446,10 +411,9 @@ setEdgeInfo
// Mark edgeI as changed, both on list and on edge itself. // Mark edgeI as changed, both on list and on edge itself.
if (!changedEdge_[edgeI]) if (changedEdge_.set(edgeI))
{ {
changedEdge_.set(edgeI); changedEdges_.push_back(edgeI);
changedEdges_.append(edgeI);
} }
} }
} }
@ -468,10 +432,8 @@ faceToEdge()
changedEdges_.clear(); changedEdges_.clear();
changedEdge_ = false; changedEdge_ = false;
forAll(changedFaces_, changedFacei) for (const label facei : changedFaces_)
{ {
label facei = changedFaces_[changedFacei];
if (!changedFace_.test(facei)) if (!changedFace_.test(facei))
{ {
FatalErrorInFunction FatalErrorInFunction
@ -511,10 +473,10 @@ faceToEdge()
if (debug) 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(); const labelListList& edgeFaces = patch_.edgeFaces();
forAll(changedEdges_, changedEdgeI) for (const label edgei : changedEdges_)
{ {
label edgeI = changedEdges_[changedEdgeI]; if (!changedEdge_.test(edgei))
if (!changedEdge_[edgeI])
{ {
FatalErrorInFunction FatalErrorInFunction
<< "edge " << edgeI << "edge " << edgei
<< " not marked as having been changed" << nl << " not marked as having been changed" << nl
<< "This might be caused by multiple occurrences of the same" << "This might be caused by multiple occurrences of the same"
<< " seed edge." << abort(FatalError); << " seed edge." << abort(FatalError);
} }
const Type& neighbourWallInfo = allEdgeInfo_[edgeI]; const Type& neighbourWallInfo = allEdgeInfo_[edgei];
// Evaluate all connected faces // Evaluate all connected faces
const labelList& eFaces = edgeFaces[edgeI]; for (const label facei : edgeFaces[edgei])
forAll(eFaces, eFacei)
{ {
label facei = eFaces[eFacei];
Type& currentWallInfo = allFaceInfo_[facei]; Type& currentWallInfo = allFaceInfo_[facei];
if (!currentWallInfo.equal(neighbourWallInfo, td_)) if (!currentWallInfo.equal(neighbourWallInfo, td_))
@ -562,7 +519,7 @@ edgeToFace()
updateFace updateFace
( (
facei, facei,
edgeI, edgei,
neighbourWallInfo, neighbourWallInfo,
currentWallInfo currentWallInfo
); );
@ -572,10 +529,10 @@ edgeToFace()
if (debug) 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 | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef PatchEdgeFaceWave_H #ifndef Foam_PatchEdgeFaceWave_H
#define PatchEdgeFaceWave_H #define Foam_PatchEdgeFaceWave_H
#include "bitSet.H" #include "bitSet.H"
#include "scalarField.H" #include "scalarField.H"
@ -54,10 +54,105 @@ namespace Foam
class polyMesh; 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 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 // Private Data
//- Reference to mesh
const polyMesh& mesh_;
//- Reference to patch //- Reference to patch
const PrimitivePatchType& patch_; const PrimitivePatchType& patch_;
@ -102,26 +183,9 @@ class PatchEdgeFaceWave
//- Additional data to be passed into container //- Additional data to be passed into container
TrackingData& td_; 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 //- Number of evaluations
label nEvals_; label nEvals_;
//- Number of unvisited faces/edges
label nUnvisitedEdges_;
label nUnvisitedFaces_;
// Addressing between edges of patch_ and globalData.coupledPatch() // Addressing between edges of patch_ and globalData.coupledPatch()
labelList patchEdges_; labelList patchEdges_;
labelList coupledEdges_; labelList coupledEdges_;
@ -162,21 +226,6 @@ class PatchEdgeFaceWave
public: public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors // Constructors
//- Construct from patch, list of changed edges with the Type //- Construct from patch, list of changed edges with the Type
@ -194,7 +243,7 @@ public:
UList<Type>& allEdgeInfo, UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo, UList<Type>& allFaceInfo,
const label maxIter, const label maxIter,
TrackingData& td = dummyTrackData_ TrackingData& td = PatchEdgeFaceWaveBase::dummyTrackData_
); );
//- Construct from patch. //- Construct from patch.
@ -205,47 +254,30 @@ public:
const PrimitivePatchType& patch, const PrimitivePatchType& patch,
UList<Type>& allEdgeInfo, UList<Type>& allEdgeInfo,
UList<Type>& allFaceInfo, UList<Type>& allFaceInfo,
TrackingData& td = dummyTrackData_ TrackingData& td = PatchEdgeFaceWaveBase::dummyTrackData_
); );
// Member Functions // Member Functions
//- Access allEdgeInfo //- Access allEdgeInfo
UList<Type>& allEdgeInfo() const UList<Type>& allEdgeInfo() const noexcept
{ {
return allEdgeInfo_; return allEdgeInfo_;
} }
//- Access allFaceInfo //- Access allFaceInfo
UList<Type>& allFaceInfo() const UList<Type>& allFaceInfo() const noexcept
{ {
return allFaceInfo_; return allFaceInfo_;
} }
//- Additional data to be passed into container //- Additional data to be passed into container
const TrackingData& data() const const TrackingData& data() const noexcept
{ {
return td_; 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_ //- Copy initial data into allEdgeInfo_
void setEdgeInfo 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 #ifndef Foam_PointData_H
#define PointData_H #define Foam_PointData_H
#include "pointEdgePoint.H" #include "pointEdgePoint.H"
@ -77,7 +77,7 @@ public:
// Constructors // Constructors
//- Default construct //- Default construct
inline PointData(); PointData() = default;
//- Construct from origin, distance and data //- Construct from origin, distance and data
inline PointData inline PointData
@ -92,15 +92,35 @@ public:
// Access // Access
const DataType& data() const const DataType& data() const noexcept { return data_; }
{
return data_;
}
DataType& data()
{
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 // Needed by MeshWave
@ -157,29 +177,6 @@ public:
const scalar tol, const scalar tol,
TrackingData& td 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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class DataType>
inline Foam::PointData<DataType>::PointData()
:
pointEdgePoint()
{}
template<class DataType> template<class DataType>
inline Foam::PointData<DataType>::PointData inline Foam::PointData<DataType>::PointData
( (

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,8 +58,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef PointEdgeWave_H #ifndef Foam_PointEdgeWave_H
#define PointEdgeWave_H #define Foam_PointEdgeWave_H
#include "bitSet.H" #include "bitSet.H"
#include "scalarField.H" #include "scalarField.H"
@ -75,10 +75,100 @@ class polyMesh;
class polyPatch; 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> template<class Type, class TrackingData = int>
class PointEdgeWave 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 // Private Data
//- Reference to mesh
const polyMesh& mesh_;
//- Wall information for all points //- Wall information for all points
UList<Type>& allPointInfo_; UList<Type>& allPointInfo_;
@ -115,31 +191,12 @@ class PointEdgeWave
//- Additional data to be passed into container //- Additional data to be passed into container
TrackingData& td_; 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 //- Number of cyclic patches
label nCyclicPatches_; label nCyclicPatches_;
//- Number of evaluations //- Number of evaluations
label nEvals_; label nEvals_;
//- Number of unvisited edges/points
label nUnvisitedPoints_;
label nUnvisitedEdges_;
// Private Member Functions // Private Member Functions
@ -222,21 +279,6 @@ class PointEdgeWave
public: public:
// Static Functions
//- Access to tolerance
static scalar propagationTol()
{
return propagationTol_;
}
//- Change tolerance
static void setPropagationTol(const scalar tol)
{
propagationTol_ = tol;
}
// Constructors // Constructors
//- Construct from mesh, list of changed points with the Type //- Construct from mesh, list of changed points with the Type
@ -273,32 +315,23 @@ public:
// Member Functions // Member Functions
//- Access allPointInfo //- Access allPointInfo
UList<Type>& allPointInfo() const UList<Type>& allPointInfo() const noexcept
{ {
return allPointInfo_; return allPointInfo_;
} }
//- Access allEdgeInfo //- Access allEdgeInfo
UList<Type>& allEdgeInfo() const UList<Type>& allEdgeInfo() const noexcept
{ {
return allEdgeInfo_; return allEdgeInfo_;
} }
//- Additional data to be passed into container //- Additional data to be passed into container
const TrackingData& data() const const TrackingData& data() const noexcept
{ {
return td_; 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_ //- Copy initial data into allPointInfo_
void setPointInfo void setPointInfo
( (

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,14 +26,37 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "FaceCellWave.H" #include "PointEdgeWave.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam 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 | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef pointEdgePoint_H #ifndef Foam_pointEdgePoint_H
#define pointEdgePoint_H #define Foam_pointEdgePoint_H
#include "point.H" #include "point.H"
#include "label.H" #include "label.H"
@ -104,7 +104,7 @@ public:
// Constructors // Constructors
//- Default construct //- Default construct. Max point
inline pointEdgePoint(); inline pointEdgePoint();
//- Construct from origin, distance //- Construct from origin, distance
@ -115,24 +115,31 @@ public:
// Access // Access
const point& origin() const const point& origin() const noexcept { return origin_; }
{
return origin_;
}
point& origin()
{
return origin_;
}
scalar distSqr() const point& origin() noexcept { return origin_; }
{
return distSqr_;
}
scalar& distSqr()
{
return distSqr_;
}
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 // Needed by PointEdgeWave
@ -227,21 +234,6 @@ public:
//- Test for equality, with TrackingData //- Test for equality, with TrackingData
template<class TrackingData> template<class TrackingData>
inline bool equal(const pointEdgePoint&, TrackingData& td) const; 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 pointEdgePoint& rhs
) const ) 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 #ifndef Foam_treeDataPrimitivePatch_H
#define treeDataPrimitivePatch_H #define Foam_treeDataPrimitivePatch_H
#include "treeBoundBoxList.H" #include "treeBoundBoxList.H"
#include "volumeType.H" #include "volumeType.H"
@ -45,7 +45,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes // Forward Declarations
template<class Type> class indexedOctree; template<class Type> class indexedOctree;
@ -65,7 +65,7 @@ class treeDataPrimitivePatch
: :
public treeDataPrimitivePatchName public treeDataPrimitivePatchName
{ {
// Private data // Private Data
//- Underlying geometry //- Underlying geometry
const PatchType& patch_; const PatchType& patch_;

View File

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

View File

@ -96,7 +96,7 @@ Foam::OppositeFaceCellWave<Type, TrackingData>::OppositeFaceCellWave
0, //maxIter, 0, //maxIter,
td td
), ),
changedOppositeFaces_(this->mesh_.nCells()) OppositeFaceCellWaveBase(mesh)
{ {
// Iterate until nothing changes // Iterate until nothing changes
label iter = this->iterate(maxIter); label iter = this->iterate(maxIter);
@ -107,8 +107,8 @@ Foam::OppositeFaceCellWave<Type, TrackingData>::OppositeFaceCellWave
<< "Maximum number of iterations reached. Increase maxIter." << "Maximum number of iterations reached. Increase maxIter."
<< endl << endl
<< " maxIter:" << maxIter << endl << " maxIter:" << maxIter << endl
<< " nChangedCells:" << this->changedCells_.size() << endl << " nChangedCells:" << this->nChangedCells() << endl
<< " nChangedFaces:" << this->changedFaces_.size() << endl << " nChangedFaces:" << this->nChangedFaces() << endl
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -125,10 +125,8 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
DynamicList<label> oppositeFaceLabels; DynamicList<label> oppositeFaceLabels;
forAll(this->changedFaces_, changedFacei) for (const label facei : this->changedFaces_)
{ {
label facei = this->changedFaces_[changedFacei];
if (!this->changedFace_.test(facei)) if (!this->changedFace_.test(facei))
{ {
FatalErrorInFunction FatalErrorInFunction
@ -154,7 +152,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
if (oppositeFaceLabels.size()) if (oppositeFaceLabels.size())
{ {
label sz = this->changedCells_.size(); label sz = this->nChangedCells();
this->updateCell this->updateCell
( (
celli, celli,
@ -163,14 +161,14 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
this->propagationTol_, this->propagationTol_,
currentWallInfo currentWallInfo
); );
if (this->changedCells_.size() > sz) if (this->nChangedCells() > sz)
{ {
label oppFacei = -1; label oppFacei = -1;
if (oppositeFaceLabels.size() == 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()) if (oppositeFaceLabels.size())
{ {
label sz = this->changedCells_.size(); label sz = this->nChangedCells();
this->updateCell this->updateCell
( (
celli, celli,
@ -198,14 +196,14 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell()
this->propagationTol_, this->propagationTol_,
currentWallInfo2 currentWallInfo2
); );
if (this->changedCells_.size() > sz) if (this->nChangedCells() > sz)
{ {
label oppFacei = -1; label oppFacei = -1;
if (oppositeFaceLabels.size() == 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) if (debug & 2)
{ {
Pout<< " Changed cells : " << this->changedCells_.size() Pout<< " Changed cells : " << this->nChangedCells() << endl;
<< endl;
} }
// Sum changedCells over all procs // 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) if (debug & 2)
{ {
Pout<< " Changed faces : " << this->changedFaces_.size() Pout<< " Changed faces : " << this->nChangedFaces()
<< endl; << endl;
} }
// Sum changedFaces over all procs // 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 | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,8 +44,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef OppositeFaceCellWave_H #ifndef Foam_OppositeFaceCellWave_H
#define OppositeFaceCellWave_H #define Foam_OppositeFaceCellWave_H
#include "FaceCellWave.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 class OppositeFaceCellWave
: :
public FaceCellWave<Type, TrackingData>, public FaceCellWave<Type, TrackingData>,
public OppositeFaceCellWaveName public OppositeFaceCellWaveBase
{ {
protected: 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 // Protected Member Functions
//- Determine 'opposite' faces (= faces not sharing a vertex) on cell //- Determine 'opposite' faces (= faces not sharing a vertex) on cell
@ -107,7 +121,7 @@ public:
UList<Type>& allFaceInfo, UList<Type>& allFaceInfo,
UList<Type>& allCellInfo, UList<Type>& allCellInfo,
const label maxIter, const label maxIter,
TrackingData& td = FaceCellWave<Type, TrackingData>::dummyTrackData_ TrackingData& td = FaceCellWaveBase::dummyTrackData_
); );

View File

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