Skip to content
Snippets Groups Projects
Commit 9ed4ef93 authored by mattijs's avatar mattijs
Browse files

ENH: wallDistance: optionally revert to previous. See #3215

parent cce6f886
No related branches found
No related tags found
No related merge requests found
......@@ -36,74 +36,128 @@ void Foam::nearWallDist::calculate()
{
const cellDistFuncs wallUtils(mesh_);
// Collect indices of wall patches
const volVectorField& cellCentres = mesh_.C();
DynamicList<label> wallPatchIDs(mesh_.boundary().size());
label nWalls = 0;
forAll(mesh_.boundary(), patchi)
if (cellDistFuncs::useCombinedWallPatch)
{
if (isA<wallFvPatch>(mesh_.boundary()[patchi]))
{
wallPatchIDs.append(patchi);
nWalls += mesh_.boundary()[patchi].size();
}
else
// Collect indices of wall patches
DynamicList<label> wallPatchIDs(mesh_.boundary().size());
label nWalls = 0;
forAll(mesh_.boundary(), patchi)
{
// Set distance to 0
operator[](patchi) = 0.0;
if (isA<wallFvPatch>(mesh_.boundary()[patchi]))
{
wallPatchIDs.append(patchi);
nWalls += mesh_.boundary()[patchi].size();
}
else
{
// Set distance to 0
operator[](patchi) = 0.0;
}
}
}
// Collect all mesh faces of wall patches
// Collect all mesh faces of wall patches
DynamicList<label> faceLabels(nWalls);
DynamicList<label> faceLabels(nWalls);
for (const label patchi : wallPatchIDs)
{
const fvPatch& patch = mesh_.boundary()[patchi];
const auto& pp = patch.patch();
forAll(patch, i)
for (const label patchi : wallPatchIDs)
{
faceLabels.append(pp.start()+i);
const fvPatch& patch = mesh_.boundary()[patchi];
const auto& pp = patch.patch();
forAll(patch, i)
{
faceLabels.append(pp.start()+i);
}
}
}
const uindirectPrimitivePatch wallPatch
(
UIndirectList<face>(mesh_.faces(), faceLabels),
mesh_.points()
);
const uindirectPrimitivePatch wallPatch
(
UIndirectList<face>(mesh_.faces(), faceLabels),
mesh_.points()
);
const volVectorField& cellCentres = mesh_.C();
DynamicList<label> neighbours;
nWalls = 0;
for (const label patchi : wallPatchIDs)
{
const fvPatch& patch = mesh_.boundary()[patchi];
const labelUList& faceCells = patch.patch().faceCells();
DynamicList<label> neighbours;
fvPatchScalarField& ypatch = operator[](patchi);
nWalls = 0;
for (const label patchi : wallPatchIDs)
forAll(patch, patchFacei)
{
// Get point connected neighbours (in wallPatch indices!)
wallUtils.getPointNeighbours(wallPatch, nWalls, neighbours);
label minFacei = -1;
ypatch[patchFacei] = wallUtils.smallestDist
(
cellCentres[faceCells[patchFacei]],
wallPatch,
neighbours,
minFacei
);
nWalls++;
}
}
}
else
{
const fvPatch& patch = mesh_.boundary()[patchi];
const labelUList& faceCells = patch.patch().faceCells();
// Get patch ids of walls
const labelHashSet wallPatchIDs(wallUtils.getPatchIDs<wallPolyPatch>());
fvPatchScalarField& ypatch = operator[](patchi);
// Size neighbours array for maximum possible
DynamicList<label> neighbours(wallUtils.maxPatchSize(wallPatchIDs));
forAll(patch, patchFacei)
{
// Get point connected neighbours (in wallPatch indices!)
wallUtils.getPointNeighbours(wallPatch, nWalls, neighbours);
label minFacei = -1;
ypatch[patchFacei] = wallUtils.smallestDist
(
cellCentres[faceCells[patchFacei]],
wallPatch,
neighbours,
minFacei
);
// Correct all cells with face on wall
nWalls++;
forAll(mesh_.boundary(), patchi)
{
fvPatchScalarField& ypatch = operator[](patchi);
const fvPatch& patch = mesh_.boundary()[patchi];
if (isA<wallFvPatch>(patch))
{
const polyPatch& pPatch = patch.patch();
const labelUList& faceCells = patch.faceCells();
// Check cells with face on wall
forAll(patch, patchFacei)
{
wallUtils.getPointNeighbours
(
pPatch,
patchFacei,
neighbours
);
label minFacei = -1;
ypatch[patchFacei] = wallUtils.smallestDist
(
cellCentres[faceCells[patchFacei]],
pPatch,
neighbours,
minFacei
);
}
}
else
{
ypatch = 0.0;
}
}
}
}
......
......@@ -235,27 +235,33 @@ void Foam::wallDistAddressing::correct(volScalarField& y)
{
cellToWallFace.reserve(nWalls);
//correctBoundaryFaceCells
//(
// patchSet,
// y,
// cellToWallFace
//);
//correctBoundaryPointCells
//(
// patchSet,
// y,
// cellToWallFace
//);
// Correct across multiple patches
correctBoundaryCells
(
patchIDs_,
true, // do point-connected cells as well
y,
cellToWallFace
);
if (cellDistFuncs::useCombinedWallPatch)
{
// Correct across multiple patches
correctBoundaryCells
(
patchIDs_,
true, // do point-connected cells as well
y,
cellToWallFace
);
}
else
{
// Optional backwards compatibility
correctBoundaryFaceCells
(
patchSet,
y,
cellToWallFace
);
correctBoundaryPointCells
(
patchSet,
y,
cellToWallFace
);
}
}
// Make sure boundary values are up to date
......
......@@ -30,6 +30,7 @@ License
#include "polyMesh.H"
#include "polyBoundaryMesh.H"
#include "uindirectPrimitivePatch.H"
#include "registerSwitch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -38,6 +39,16 @@ namespace Foam
defineTypeNameAndDebug(cellDistFuncs, 0);
}
bool Foam::cellDistFuncs::useCombinedWallPatch = true;
registerInfoSwitch
(
"useCombinedWallPatch",
bool,
Foam::cellDistFuncs::useCombinedWallPatch
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh)
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020,2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -79,8 +79,16 @@ class cellDistFuncs
public:
// Static Data Members
ClassName("cellDistFuncs");
//- Use combined-wall-patches wall distance v.s. v2406 per-patch
//- distance. Default is true
static bool useCombinedWallPatch;
// Constructors
//- Construct from mesh
......
......@@ -263,29 +263,35 @@ void Foam::patchDataWave<TransferType, TrackingData>::correct()
{
Map<label> nearestFace(2 * nWalls);
// Get distance and indices of nearest face
//correctBoundaryFaceCells
//(
// patchIDs_,
// distance_,
// nearestFace
//);
//correctBoundaryPointCells
//(
// patchIDs_,
// distance_,
// nearestFace
//);
// Correct across multiple patches
correctBoundaryCells
(
patchIDs_.sortedToc(),
true, // do point-connected cells as well
distance_,
nearestFace
);
if (cellDistFuncs::useCombinedWallPatch)
{
// Correct across multiple patches
correctBoundaryCells
(
patchIDs_.sortedToc(),
true, // do point-connected cells as well
distance_,
nearestFace
);
}
else
{
// Get distance and indices of nearest face
correctBoundaryFaceCells
(
patchIDs_,
distance_,
nearestFace
);
correctBoundaryPointCells
(
patchIDs_,
distance_,
nearestFace
);
}
// Transfer data from nearest face to cell
const List<TransferType>& faceInfo = waveInfo.allFaceInfo();
......
......@@ -204,28 +204,34 @@ void Foam::patchWave::correct()
{
Map<label> nearestFace(2*nPatch);
//correctBoundaryFaceCells
//(
// patchIDs_,
// distance_,
// nearestFace
//);
//correctBoundaryPointCells
//(
// patchIDs_,
// distance_,
// nearestFace
//);
// Correct across multiple patches
correctBoundaryCells
(
patchIDs_.sortedToc(),
true, // do point-connected cells as well
distance_,
nearestFace
);
if (cellDistFuncs::useCombinedWallPatch)
{
// Correct across multiple patches
correctBoundaryCells
(
patchIDs_.sortedToc(),
true, // do point-connected cells as well
distance_,
nearestFace
);
}
else
{
// Backwards compatible
correctBoundaryFaceCells
(
patchIDs_,
distance_,
nearestFace
);
correctBoundaryPointCells
(
patchIDs_,
distance_,
nearestFace
);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment