/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "inversePointDistanceDiffusivity.H"
#include "surfaceFields.H"
#include "HashSet.H"
#include "pointEdgeDist.H"
#include "PointEdgeWave.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(inversePointDistanceDiffusivity, 0);
addToRunTimeSelectionTable
(
motionDiffusivity,
inversePointDistanceDiffusivity,
Istream
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::inversePointDistanceDiffusivity::inversePointDistanceDiffusivity
(
const fvMesh& mesh,
Istream& mdData
)
:
motionDiffusivity(mesh),
patchNames_(mdData)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::inversePointDistanceDiffusivity::~inversePointDistanceDiffusivity()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp
Foam::inversePointDistanceDiffusivity::operator()() const
{
tmp tfaceDiffusivity
(
new surfaceScalarField
(
IOobject
(
"faceDiffusivity",
mesh().time().name(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar(dimless, 1.0)
)
);
surfaceScalarField& faceDiffusivity = tfaceDiffusivity.ref();
const polyBoundaryMesh& bdry = mesh().poly().boundary();
const labelHashSet patchSet(bdry.patchSet(patchNames_));
label nPatchEdges = 0;
forAllConstIter(labelHashSet, patchSet, iter)
{
nPatchEdges += bdry[iter.key()].nEdges();
}
// Distance to wall on points and edges.
List pointWallDist(mesh().nPoints());
List edgeWallDist(mesh().nEdges());
pointEdgeDist::data pointEdgeData(mesh().points());
{
// Seeds
List seedInfo(nPatchEdges);
labelList seedPoints(nPatchEdges);
nPatchEdges = 0;
forAllConstIter(labelHashSet, patchSet, iter)
{
const polyPatch& patch = bdry[iter.key()];
const labelList& meshPoints = patch.meshPoints();
forAll(meshPoints, i)
{
const label pointi = meshPoints[i];
if (!pointWallDist[pointi].valid(pointEdgeData))
{
// Not yet seeded
seedInfo[nPatchEdges] = pointEdgeDist
(
mesh().points()[pointi],
0
);
seedPoints[nPatchEdges] = pointi;
pointWallDist[pointi] = seedInfo[nPatchEdges];
nPatchEdges++;
}
}
}
seedInfo.setSize(nPatchEdges);
seedPoints.setSize(nPatchEdges);
// Do calculations
PointEdgeWave
<
pointEdgeDist,
pointEdgeDist::data
> waveInfo
(
mesh(),
seedPoints,
seedInfo,
pointWallDist,
edgeWallDist,
mesh().globalData().nTotalPoints(),// max iterations
pointEdgeData
);
}
for (label facei=0; facei