STYLE: update code style for point-smoothing

This commit is contained in:
Mark Olesen
2025-01-08 14:53:03 +01:00
parent 0a99702f9e
commit d072ad0e3f
12 changed files with 115 additions and 235 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,20 +61,11 @@ void Foam::displacementPointSmoothingMotionSolver::markAffectedFaces
labelHashSet& affectedFaces
)
{
PackedBoolList affectedPoints(mesh().nPoints(), false);
bitSet affectedPoints(mesh().nPoints());
forAllConstIter(labelHashSet, changedFaces, iter)
for (const label facei : changedFaces)
{
const label faceI(iter.key());
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
{
const label pointI(fPoints[fPointI]);
affectedPoints[pointI] = true;
}
affectedPoints.set(mesh().faces()[facei]);
}
syncTools::syncPointList
@ -85,20 +76,11 @@ void Foam::displacementPointSmoothingMotionSolver::markAffectedFaces
0U
);
forAll(affectedPoints, pointI)
for (const label pointi : affectedPoints)
{
if (affectedPoints[pointI])
for (const label celli : mesh().pointCells()[pointi])
{
const labelList& pCells(mesh().pointCells()[pointI]);
forAll(pCells, pointCellI)
{
const label cellI(pCells[pointCellI]);
const labelList& cFaces(mesh().cells()[cellI]);
affectedFaces.insert(cFaces);
}
affectedFaces.insert(mesh().cells()[celli]);
}
}
}
@ -108,7 +90,7 @@ bool Foam::displacementPointSmoothingMotionSolver::relax()
{
if
(
(relaxationFactors_.size() == 0)
relaxationFactors_.empty()
|| (relaxationFactors_.size() == 1 && relaxationFactors_[0] == 1.0)
)
{
@ -125,17 +107,12 @@ bool Foam::displacementPointSmoothingMotionSolver::relax()
// -1 indicates a point which is not to be moved
// 0 is the starting value for a moving point
labelList relaxationLevel(mesh().nPoints(), -1);
forAllConstIter(labelHashSet, affectedFaces, iter)
for (const label facei : affectedFaces)
{
const label faceI(iter.key());
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
for (const label pointi : mesh().faces()[facei])
{
const label pointI(fPoints[fPointI]);
relaxationLevel[pointI] = 0;
relaxationLevel[pointi] = 0;
}
}
@ -196,32 +173,18 @@ bool Foam::displacementPointSmoothingMotionSolver::relax()
markAffectedFaces(markedFaces, affectedFaces);
// Increase relaxation and check convergence
PackedBoolList pointsToRelax(mesh().nPoints(), false);
bitSet pointsToRelax(mesh().nPoints());
complete = true;
forAllConstIter(labelHashSet, affectedFaces, iter)
for (const label facei : affectedFaces)
{
const label faceI(iter.key());
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
{
const label pointI(fPoints[fPointI]);
pointsToRelax[pointI] = true;
}
pointsToRelax.set(mesh().faces()[facei]);
}
forAll(pointsToRelax, pointI)
for (const label pointi : pointsToRelax)
{
if
(
pointsToRelax[pointI]
&& (relaxationLevel[pointI] < relaxationFactors_.size() - 1)
)
if (relaxationLevel[pointi] < relaxationFactors_.size() - 1)
{
++ relaxationLevel[pointI];
++ relaxationLevel[pointi];
complete = false;
}
}
@ -241,17 +204,15 @@ bool Foam::displacementPointSmoothingMotionSolver::relax()
// Check for convergence
bool converged(true);
forAll(mesh().faces(), faceI)
forAll(mesh().faces(), facei)
{
const face& fPoints(mesh().faces()[faceI]);
const face& fPoints(mesh().faces()[facei]);
forAll(fPoints, fPointI)
for (const label pointi : fPoints)
{
const label pointI(fPoints[fPointI]);
if (relaxationLevel[pointI] > 0)
if (relaxationLevel[pointi] > 0)
{
facesToMove_.insert(faceI);
facesToMove_.insert(facei);
converged = false;
@ -319,7 +280,7 @@ displacementPointSmoothingMotionSolver
pointSmoother_(pointSmoother::New(mesh, coeffDict())),
nPointSmootherIter_
(
readLabel(coeffDict().lookup("nPointSmootherIter"))
coeffDict().get<label>("nPointSmootherIter")
),
relaxedPoints_(mesh.points())
{
@ -352,7 +313,7 @@ displacementPointSmoothingMotionSolver
),
nPointSmootherIter_
(
readLabel(coeffDict().lookup("nPointSmootherIter"))
coeffDict().get<label>("nPointSmootherIter")
),
relaxedPoints_(mesh.points())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,20 +66,11 @@ void Foam::displacementSmartPointSmoothingMotionSolver::markAffectedFaces
labelHashSet& affectedFaces
)
{
PackedBoolList affectedPoints(mesh().nPoints(), false);
bitSet affectedPoints(mesh().nPoints());
forAllConstIter(labelHashSet, changedFaces, iter)
for (const label facei : changedFaces)
{
const label faceI(iter.key());
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
{
const label pointI(fPoints[fPointI]);
affectedPoints[pointI] = true;
}
affectedPoints.set(mesh().faces()[facei]);
}
syncTools::syncPointList
@ -90,20 +81,11 @@ void Foam::displacementSmartPointSmoothingMotionSolver::markAffectedFaces
0U
);
forAll(affectedPoints, pointI)
for (const label pointi : affectedPoints)
{
if (affectedPoints[pointI])
for (const label celli : mesh().pointCells()[pointi])
{
const labelList& pCells(mesh().pointCells()[pointI]);
forAll(pCells, pointCellI)
{
const label cellI(pCells[pointCellI]);
const labelList& cFaces(mesh().cells()[cellI]);
affectedFaces.insert(cFaces);
}
affectedFaces.insert(mesh().cells()[celli]);
}
}
}
@ -113,7 +95,7 @@ bool Foam::displacementSmartPointSmoothingMotionSolver::relax()
{
if
(
(relaxationFactors_.size() == 0)
relaxationFactors_.empty()
|| (relaxationFactors_.size() == 1 && relaxationFactors_[0] == 1.0)
)
{
@ -130,17 +112,11 @@ bool Foam::displacementSmartPointSmoothingMotionSolver::relax()
// -1 indicates a point which is not to be moved
// 0 is the starting value for a moving point
labelList relaxationLevel(mesh().nPoints(), -1);
forAllConstIter(labelHashSet, affectedFaces, iter)
for (const label facei : affectedFaces)
{
const label faceI(iter.key());
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
for (const label pointi : mesh().faces()[facei])
{
const label pointI(fPoints[fPointI]);
relaxationLevel[pointI] = 0;
relaxationLevel[pointi] = 0;
}
}
@ -242,29 +218,16 @@ bool Foam::displacementSmartPointSmoothingMotionSolver::relax()
}
// Increase relaxation and check convergence
PackedBoolList pointsToRelax(mesh().nPoints(), false);
bitSet pointsToRelax(mesh().nPoints());
complete = true;
forAllConstIter(labelHashSet, affectedFaces, iter)
for (const label facei : affectedFaces)
{
const label faceI(iter.key());
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
{
const label pointI(fPoints[fPointI]);
pointsToRelax[pointI] = true;
}
pointsToRelax.set(mesh().faces()[facei]);
}
forAll(pointsToRelax, pointI)
for (const label pointI : pointsToRelax)
{
if
(
pointsToRelax[pointI]
&& (relaxationLevel[pointI] < relaxationFactors_.size() - 1)
)
if (relaxationLevel[pointI] < relaxationFactors_.size() - 1)
{
++ relaxationLevel[pointI];
@ -287,17 +250,13 @@ bool Foam::displacementSmartPointSmoothingMotionSolver::relax()
// Check for convergence
bool converged(true);
forAll(mesh().faces(), faceI)
forAll(mesh().faces(), facei)
{
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
for (const label pointi : mesh().faces()[facei])
{
const label pointI(fPoints[fPointI]);
if (relaxationLevel[pointI] > 0)
if (relaxationLevel[pointi] > 0)
{
facesToMove_.insert(faceI);
facesToMove_.insert(facei);
converged = false;
@ -404,7 +363,7 @@ displacementSmartPointSmoothingMotionSolver
pointSmoother_(pointSmoother::New(mesh, coeffDict())),
nPointSmootherIter_
(
readLabel(coeffDict().lookup("nPointSmootherIter"))
coeffDict().get<label>("nPointSmootherIter")
),
relaxedPoints_(mesh.points())
{
@ -448,7 +407,7 @@ displacementSmartPointSmoothingMotionSolver
),
nPointSmootherIter_
(
readLabel(coeffDict().lookup("nPointSmootherIter"))
coeffDict().get<label>("nPointSmootherIter")
),
relaxedPoints_(mesh.points())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021,2024 OpenCFD Ltd.
Copyright (C) 2021,2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -752,9 +752,9 @@ hexMeshSmootherMotionSolver
pointSmoother_(pointSmoother::New(mesh, coeffDict())),
nPointSmootherIter_
(
readLabel(coeffDict().lookup("nPointSmootherIter"))
coeffDict().get<label>("nPointSmootherIter")
),
relaxationFactors_(coeffDict().lookup("relaxationFactors")),
relaxationFactors_(coeffDict().get<scalarList>("relaxationFactors")),
relaxationLevel_(mesh.nPoints(), 0),
relaxedPoints_(mesh.points()),
//surfacesDict_(coeffDict().subDict("geometry")),
@ -885,9 +885,9 @@ hexMeshSmootherMotionSolver
//),
nPointSmootherIter_
(
readLabel(coeffDict().lookup("nPointSmootherIter"))
coeffDict().get<label>("nPointSmootherIter")
),
relaxationFactors_(coeffDict().lookup("relaxationFactors")),
relaxationFactors_(coeffDict().get<scalarList>("relaxationFactors")),
relaxationLevel_(mesh.nPoints(), 0),
relaxedPoints_(mesh.points()),
//surfacesDict_(coeffDict().subDict("geometry")),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -283,10 +283,4 @@ Foam::cellPointConnectivity::cellPointConnectivity(const polyMesh& mesh)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellPointConnectivity::~cellPointConnectivity()
{}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef cellPointConnectivity_H
#define cellPointConnectivity_H
#ifndef Foam_cellPointConnectivity_H
#define Foam_cellPointConnectivity_H
#include "polyMesh.H"
#include "MeshObject.H"
@ -56,7 +56,7 @@ class cellPointConnectivity
:
public MoveableMeshObject<polyMesh>
{
// Private data
// Private Data
//- Reference to the polyMesh
const polyMesh& mesh_;
@ -70,11 +70,11 @@ class cellPointConnectivity
// Private Member Functions
//- Disallow default bitwise copy construct
cellPointConnectivity(const cellPointConnectivity&);
//- No copy construct
cellPointConnectivity(const cellPointConnectivity&) = delete;
//- Disallow default bitwise assignment
void operator=(const cellPointConnectivity&);
//- No copy assignment
void operator=(const cellPointConnectivity&) = delete;
//- Generate the connectivity
void generateCellPointConnectivity(label cellI);
@ -89,11 +89,11 @@ public:
// Constructors
//- Construct an IOobject and a polymesh
cellPointConnectivity(const polyMesh&);
explicit cellPointConnectivity(const polyMesh&);
//- Destructor
~cellPointConnectivity();
~cellPointConnectivity() = default;
// Member Functions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -118,7 +118,7 @@ geometricElementTransformPointSmoother
pointSmoother(mesh, dict),
transformationParameter_
(
readScalar(dict.lookup("transformationParameter"))
dict.get<scalar>("transformationParameter")
)
{}
@ -168,10 +168,8 @@ void Foam::pointSmoothers::geometricElementTransformPointSmoother::calculate
pointField transformedPoints(currentPoints);
// Calculate the internal transformations
forAllConstIter(labelHashSet, cellsToMove, iter)
for (const label cellI : cellsToMove)
{
const label cellI(iter.key());
const cell& cFaces
(
mesh().cells()[cellI]

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,33 +65,19 @@ bool Foam::pointSmoother::isInternalOrProcessorFace(const label faceI) const
}
Foam::autoPtr<Foam::PackedBoolList> Foam::pointSmoother::pointsToMove
Foam::bitSet Foam::pointSmoother::pointsToMove
(
const labelList& facesToMove,
const bool moveInternalFaces
) const
{
autoPtr<PackedBoolList> markerPtr
(
new PackedBoolList(mesh().nPoints(), false)
);
bitSet marker(mesh().nPoints());
PackedBoolList& marker(markerPtr());
forAll(facesToMove, faceToMoveI)
for (const label facei : facesToMove)
{
const label faceI(facesToMove[faceToMoveI]);
if (moveInternalFaces || !isInternalOrProcessorFace(faceI))
if (moveInternalFaces || !isInternalOrProcessorFace(facei))
{
const face& fPoints(mesh().faces()[faceI]);
forAll(fPoints, fPointI)
{
const label pointI(fPoints[fPointI]);
marker[pointI] = true;
}
marker.set(mesh().faces()[facei]);
}
}
@ -103,7 +89,7 @@ Foam::autoPtr<Foam::PackedBoolList> Foam::pointSmoother::pointsToMove
0U
);
return markerPtr;
return marker;
}
@ -139,19 +125,20 @@ Foam::pointSmoother::New
{
Info<< "Selecting pointSmoother type " << pointSmootherType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->find(pointSmootherType);
auto* ctorPtr = dictionaryConstructorTable(pointSmootherType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
if (!ctorPtr)
{
FatalErrorIn("pointSmoother::New")
<< "Unknown " << typeName << " type "
<< pointSmootherType << endl << endl
<< "Valid " << typeName << " types are : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
FatalIOErrorInLookup
(
dict,
typeName,
pointSmootherType,
*dictionaryConstructorTablePtr_
) << exit(FatalIOError);
}
return cstrIter()(mesh, dict);
return autoPtr<pointSmoother>(ctorPtr(mesh, dict));
}
@ -162,18 +149,12 @@ Foam::pointSmoother::New
const dictionary& dict
)
{
word pointSmootherType(dict.lookup(typeName));
word pointSmootherType(dict.get<word>(typeName));
return New(pointSmootherType, mesh, dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pointSmoother::~pointSmoother()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::pointSmoother::update
@ -203,7 +184,7 @@ void Foam::pointSmoother::update
);
// Note: do not want to apply boundary conditions whilst smoothing so
// disable for now
// disable for now
//// Take over boundary values
//for (auto& ppf : pointDisplacement.boundaryFieldRef())
//{
@ -247,7 +228,7 @@ Foam::tmp<Foam::scalarField> Foam::pointSmoother::faceQuality
)
);
//return max(tortho, scalar(0.0));
// tortho.ref().clamp_min(0);
return tortho;
}
@ -276,7 +257,7 @@ Foam::tmp<Foam::scalarField> Foam::pointSmoother::cellQuality
const auto& faceOrtho = tfaceOrtho();
// Min over cells
tmp<scalarField> tortho(new scalarField(mesh().nCells(), GREAT));
auto tortho = tmp<scalarField>::New(mesh().nCells(), GREAT);
auto& ortho = tortho.ref();
const auto& own = mesh().faceOwner();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,12 +36,12 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef pointSmoother_H
#define pointSmoother_H
#ifndef Foam_pointSmoother_H
#define Foam_pointSmoother_H
#include "polyMeshGeometry.H"
#include "runTimeSelectionTables.H"
#include "PackedBoolList.H"
#include "bitSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,7 +56,7 @@ class pointSmoother
{
private:
// Private data
// Private Data
//- Reference to the polyMesh
const polyMesh& mesh_;
@ -67,11 +67,11 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
pointSmoother(const pointSmoother&);
//- No copy construct
pointSmoother(const pointSmoother&) = delete;
//- Disallow default bitwise assignment
void operator=(const pointSmoother&);
//- No copy assignment
void operator=(const pointSmoother&) = delete;
protected:
@ -81,8 +81,8 @@ protected:
//- Test if the given face is internal or on a processor boundary
bool isInternalOrProcessorFace(const label faceI) const;
//- Get a boolean list of the points to be moved
autoPtr<PackedBoolList> pointsToMove
//- Get list of the points to be moved
bitSet pointsToMove
(
const labelList& facesToMove,
const bool moveInternalFaces
@ -150,13 +150,13 @@ public:
//- Destructor
virtual ~pointSmoother();
virtual ~pointSmoother() = default;
// Member Functions
// Access the mesh
const polyMesh& mesh() const
//- Access the mesh
const polyMesh& mesh() const noexcept
{
return mesh_;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,20 +39,15 @@ void Foam::pointSmoother::reset
const bool resetInternalFaces
) const
{
autoPtr<PackedBoolList> resetPointsPtr
bitSet resetPoints
(
pointsToMove(facesToMove, resetInternalFaces)
);
const PackedBoolList& resetPoints(resetPointsPtr);
forAll(resetPoints, pointI)
for (const label pointi: resetPoints)
{
if (resetPoints[pointI])
{
weights[pointI] = pTraits<weightType>::zero;
pointDisplacement[pointI] = vector::zero;
}
weights[pointi] = pTraits<weightType>::zero;
pointDisplacement[pointi] = vector::zero;
}
}
@ -81,22 +76,16 @@ void Foam::pointSmoother::average
vector::zero
);
autoPtr<PackedBoolList> averagePointsPtr
bitSet averagePoints
(
pointsToMove(facesToMove, true)
);
const PackedBoolList& averagePoints(averagePointsPtr);
forAll(averagePoints, pointI)
for (const label pointi : averagePoints)
{
if
(
averagePoints[pointI]
&& weights[pointI] != pTraits<weightType>::zero
)
if (weights[pointi] != pTraits<weightType>::zero)
{
pointDisplacement[pointI] /= weights[pointI];
pointDisplacement[pointi] /= weights[pointi];
}
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2024-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,6 @@ License
#include "dummyTransform.H"
#include "ReadFields.H"
#include "surfaceFields.H"
#include "PackedBoolList.H"
#include "fvMeshTools.H"
#include "cellSetOption.H"
#include "cellBitSet.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,7 +61,6 @@ License
#include "faceSet.H"
#include "topoDistanceData.H"
#include "FaceCellWave.H"
#include "PackedBoolList.H"
// Leak path
#include "shortestPathSet.H"
@ -2778,7 +2777,7 @@ Foam::labelList Foam::meshRefinement::countEdgeFaces
// Match pp edges to coupled edges
labelList patchEdges;
labelList coupledEdges;
PackedBoolList sameEdgeOrientation;
bitSet sameEdgeOrientation;
PatchTools::matchEdges
(
pp,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1652,7 +1652,7 @@ void Foam::meshRefinement::selectIntersectedFaces
// // // Match pp edges to coupled edges
// // labelList patchEdges;
// // labelList coupledEdges;
// // PackedBoolList sameEdgeOrientation;
// // bitSet sameEdgeOrientation;
// // PatchTools::matchEdges
// // (
// // pp,