Skip to content
Snippets Groups Projects
Commit 559b34be authored by mattijs's avatar mattijs
Browse files

ENH: nearWallDist: cross patch boundaries. See #3215

parent 3d30bf45
Branches
Tags
No related merge requests found
......@@ -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.
......@@ -27,60 +27,83 @@ License
\*---------------------------------------------------------------------------*/
#include "nearWallDist.H"
#include "fvMesh.H"
#include "cellDistFuncs.H"
#include "wallFvPatch.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::nearWallDist::calculate()
{
cellDistFuncs wallUtils(mesh_);
const cellDistFuncs wallUtils(mesh_);
// Get patch ids of walls
labelHashSet wallPatchIDs(wallUtils.getPatchIDs<wallPolyPatch>());
// Collect indices of wall patches
// 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 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
forAll(patch, patchFacei)
{
wallUtils.getPointNeighbours(pPatch, patchFacei, neighbours);
const volVectorField& cellCentres = mesh_.C();
label minFacei = -1;
DynamicList<label> neighbours;
ypatch[patchFacei] = wallUtils.smallestDist
(
cellCentres[faceCells[patchFacei]],
pPatch,
neighbours,
minFacei
);
}
}
else
nWalls = 0;
for (const label patchi : wallPatchIDs)
{
const fvPatch& patch = mesh_.boundary()[patchi];
const labelUList& faceCells = patch.patch().faceCells();
fvPatchScalarField& ypatch = operator[](patchi);
forAll(patch, patchFacei)
{
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% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment