Skip to content
Snippets Groups Projects
Commit 2df11e36 authored by mattijs's avatar mattijs Committed by Mattijs Janssens
Browse files

ENH: nearWallDist: cross patch boundaries. See #3215

parent 04a0bb92
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -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,2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -27,60 +27,83 @@ License ...@@ -27,60 +27,83 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "nearWallDist.H" #include "nearWallDist.H"
#include "fvMesh.H"
#include "cellDistFuncs.H" #include "cellDistFuncs.H"
#include "wallFvPatch.H" #include "wallFvPatch.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::nearWallDist::calculate() void Foam::nearWallDist::calculate()
{ {
cellDistFuncs wallUtils(mesh_); const cellDistFuncs wallUtils(mesh_);
// Get patch ids of walls // Collect indices of wall patches
labelHashSet wallPatchIDs(wallUtils.getPatchIDs<wallPolyPatch>());
// Size neighbours array for maximum possible DynamicList<label> wallPatchIDs(mesh_.boundary().size());
label nWalls = 0;
DynamicList<label> neighbours(wallUtils.maxPatchSize(wallPatchIDs)); forAll(mesh_.boundary(), patchi)
{
if (isA<wallFvPatch>(mesh_.boundary()[patchi]))
{
wallPatchIDs.append(patchi);
nWalls += mesh_.boundary()[patchi].size();
}
else
{
// Set distance to 0
operator[](patchi) = 0.0;
}
}
// Correct all cells with face on wall // Collect all mesh faces of wall patches
const volVectorField& cellCentres = mesh_.C(); DynamicList<label> faceLabels(nWalls);
forAll(mesh_.boundary(), patchi) for (const label patchi : wallPatchIDs)
{ {
fvPatchScalarField& ypatch = operator[](patchi);
const fvPatch& patch = mesh_.boundary()[patchi]; const fvPatch& patch = mesh_.boundary()[patchi];
const auto& pp = patch.patch();
if (isA<wallFvPatch>(patch)) forAll(patch, i)
{ {
const polyPatch& pPatch = patch.patch(); faceLabels.append(pp.start()+i);
}
}
const labelUList& faceCells = patch.faceCells(); const uindirectPrimitivePatch wallPatch
(
UIndirectList<face>(mesh_.faces(), faceLabels),
mesh_.points()
);
// Check cells with face on wall const volVectorField& cellCentres = mesh_.C();
forAll(patch, patchFacei)
{
wallUtils.getPointNeighbours(pPatch, patchFacei, neighbours);
label minFacei = -1; DynamicList<label> neighbours;
ypatch[patchFacei] = wallUtils.smallestDist nWalls = 0;
( for (const label patchi : wallPatchIDs)
cellCentres[faceCells[patchFacei]], {
pPatch, const fvPatch& patch = mesh_.boundary()[patchi];
neighbours, const labelUList& faceCells = patch.patch().faceCells();
minFacei
); fvPatchScalarField& ypatch = operator[](patchi);
}
} forAll(patch, patchFacei)
else
{ {
ypatch = 0.0; // 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++;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment