/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023-2024 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 .
\*---------------------------------------------------------------------------*/
#include "FaceCellWave.H"
#include "wallDistAddressing.H"
#include "wallPointAddressing.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFields.H"
#include "wallPolyPatch.H"
#include "patchDistMethod.H"
#include "OBJstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(wallDistAddressing, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::wallDistAddressing::getValues
(
const FaceCellWave& wave,
const List& allCellInfo,
const List& allFaceInfo,
volScalarField& y
) const
{
// Extract volField. See patchWave::getValues
label nIllegal = 0;
forAll(allCellInfo, celli)
{
const scalar dist = allCellInfo[celli].distSqr();
if (allCellInfo[celli].valid(wave.data()))
{
y[celli] = Foam::sqrt(dist);
}
else
{
y[celli] = dist;
++nIllegal;
}
}
// Copy boundary values
auto& bfld = y.boundaryFieldRef();
for (auto& pfld : bfld)
{
scalarField patchField(pfld.size(), Zero);
forAll(pfld, patchFacei)
{
const label meshFacei = pfld.patch().start() + patchFacei;
const scalar dist = allFaceInfo[meshFacei].distSqr();
if (allFaceInfo[meshFacei].valid(wave.data()))
{
// Adding SMALL to avoid problems with /0 in the turbulence
// models
patchField[patchFacei] = Foam::sqrt(dist) + SMALL;
}
else
{
patchField[patchFacei] = dist;
++nIllegal;
}
}
pfld = patchField;
}
return nIllegal;
}
void Foam::wallDistAddressing::addItem
(
const label item,
const labelPair& data,
label& untransformi,
label& transformi,
labelPairList& transformedWallInfo
)
{
const auto& gt = mesh_.globalData().globalTransforms();
if (gt.transformIndex(data) == gt.nullTransformIndex())
{
// Store item and global index of untransformed data
const label proci = gt.processor(data);
const label index = gt.index(data);
untransformedItems_[untransformi] = item;
untransformedSlots_[untransformi++] =
globalWallsPtr_().toGlobal(proci, index);
}
else
{
// Store item and transformed data
transformedItems_[transformi] = item;
transformedWallInfo[transformi++] = data;
}
}
void Foam::wallDistAddressing::correct(volScalarField& y)
{
y = dimensionedScalar("yWall", dimLength, GREAT);
const auto& C = mesh_.C();
const auto& gt = mesh_.globalData().globalTransforms();
label nWalls = 0;
for (const label patchi : patchIDs_)
{
nWalls += C.boundaryField()[patchi].size();
}
globalWallsPtr_.reset(new globalIndex(nWalls));
const globalIndex& globalWalls = globalWallsPtr_();
DynamicList