diff --git a/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C index 1d71084000..0667f27b73 100644 --- a/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C +++ b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ License #include "vanDriestDelta.H" #include "wallFvPatch.H" -#include "wallDistData.H" +#include "patchDistWave.H" #include "wallPointYPlus.H" #include "addToRunTimeSelectionTable.H" @@ -81,7 +81,20 @@ void Foam::LESModels::vanDriestDelta::calcDelta() scalar cutOff = wallPointYPlus::yPlusCutOff; wallPointYPlus::yPlusCutOff = 500; - wallDistData y(mesh, ystar); + volScalarField y + ( + volScalarField::New("y", mesh, dimensionedScalar(dimLength, great)) + ); + patchDistWave::wave + ( + mesh, + mesh.boundaryMesh().findPatchIDs(), + ystar.boundaryField(), + y.primitiveFieldRef(), + y.boundaryFieldRef(), + ystar.primitiveFieldRef(), + ystar.boundaryFieldRef() + ); wallPointYPlus::yPlusCutOff = cutOff; delta_ = min diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 588a1f0acc..0782322555 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -43,7 +43,6 @@ $(derivedFvPatches)/regionCoupled/regionCoupledWallFvPatch.C wallDist = fvMesh/wallDist $(wallDist)/wallPointYPlus/wallPointYPlus.C -$(wallDist)/nearWallDist/nearWallDistNoSearch.C $(wallDist)/nearWallDist/nearWallDist.C $(wallDist)/wallDist/wallDist.C $(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C diff --git a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C index 8216cd0281..26af2b2e4a 100644 --- a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,70 +25,10 @@ License #include "nearWallDist.H" #include "fvMesh.H" -#include "cellDistFuncs.H" +#include "patchDistFuncs.H" #include "wallFvPatch.H" #include "surfaceFields.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::nearWallDist::calculate() -{ - cellDistFuncs wallUtils(mesh_); - - // Get patch ids of walls - labelHashSet wallPatchIDs(wallUtils.getPatchIDs()); - - // Size neighbours array for maximum possible - - labelList neighbours(wallUtils.maxPatchSize(wallPatchIDs)); - - - // Correct all cells with face on wall - - const volVectorField& cellCentres = mesh_.C(); - - forAll(mesh_.boundary(), patchi) - { - fvPatchScalarField& ypatch = operator[](patchi); - - const fvPatch& patch = mesh_.boundary()[patchi]; - - if (isA(patch)) - { - const polyPatch& pPatch = patch.patch(); - - const labelUList& faceCells = patch.faceCells(); - - // Check cells with face on wall - forAll(patch, patchFacei) - { - label nNeighbours = wallUtils.getPointNeighbours - ( - pPatch, - patchFacei, - neighbours - ); - - label minFacei = -1; - - ypatch[patchFacei] = wallUtils.smallestDist - ( - cellCentres[faceCells[patchFacei]], - pPatch, - nNeighbours, - neighbours, - minFacei - ); - } - } - else - { - ypatch = 0.0; - } - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::nearWallDist::nearWallDist(const Foam::fvMesh& mesh) @@ -96,12 +36,17 @@ Foam::nearWallDist::nearWallDist(const Foam::fvMesh& mesh) volScalarField::Boundary ( mesh.boundary(), - mesh.V(), // Dummy internal field, + volScalarField::Internal::null(), calculatedFvPatchScalarField::typeName ), mesh_(mesh) { - calculate(); + patchDistFuncs::correctBoundaryFaceFaceCells + ( + mesh_, + mesh_.boundaryMesh().findPatchIDs(), + *this + ); } @@ -117,10 +62,8 @@ void Foam::nearWallDist::correct() { if (mesh_.topoChanging()) { - const DimensionedField& V = mesh_.V(); - const fvBoundaryMesh& bnd = mesh_.boundary(); + this->setSize(mesh_.boundary().size()); - this->setSize(bnd.size()); forAll(*this, patchi) { this->set @@ -129,14 +72,19 @@ void Foam::nearWallDist::correct() fvPatchField::New ( calculatedFvPatchScalarField::typeName, - bnd[patchi], - V + mesh_.boundary()[patchi], + volScalarField::Internal::null() ) ); } } - calculate(); + patchDistFuncs::correctBoundaryFaceFaceCells + ( + mesh_, + mesh_.boundaryMesh().findPatchIDs(), + *this + ); } diff --git a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.H b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.H index bd82e432af..4208c7e293 100644 --- a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,12 +59,6 @@ class nearWallDist const fvMesh& mesh_; - // Private Member Functions - - //- Do all calculations - void calculate(); - - public: // Constructors @@ -82,6 +76,7 @@ public: // Member Functions + //- Access the wall distances const volScalarField::Boundary& y() const { return *this; diff --git a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDistNoSearch.C b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDistNoSearch.C deleted file mode 100644 index 5057ee1168..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDistNoSearch.C +++ /dev/null @@ -1,114 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 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 "nearWallDistNoSearch.H" -#include "fvMesh.H" -#include "wallFvPatch.H" -#include "surfaceFields.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::nearWallDistNoSearch::doAll() -{ - const volVectorField& cellCentres = mesh_.C(); - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - fvPatchScalarField& ypatch = operator[](patchi); - - if (isA(patches[patchi])) - { - const labelUList& faceCells = patches[patchi].faceCells(); - - const fvPatchVectorField& patchCentres - = cellCentres.boundaryField()[patchi]; - - const fvsPatchVectorField& Apatch - = mesh_.Sf().boundaryField()[patchi]; - - const fvsPatchScalarField& magApatch - = mesh_.magSf().boundaryField()[patchi]; - - forAll(patchCentres, facei) - { - ypatch[facei] = - ( - Apatch[facei] & - ( - patchCentres[facei] - - cellCentres[faceCells[facei]] - ) - )/magApatch[facei]; - } - } - else - { - ypatch = 0.0; - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::nearWallDistNoSearch::nearWallDistNoSearch(const Foam::fvMesh& mesh) -: - volScalarField::Boundary - ( - mesh.boundary(), - mesh.V(), // Dummy internal field - calculatedFvPatchScalarField::typeName - ), - mesh_(mesh) -{ - doAll(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::nearWallDistNoSearch::~nearWallDistNoSearch() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::nearWallDistNoSearch::correct() -{ - if (mesh_.changing()) - { - // Update size of Boundary - forAll(mesh_.boundary(), patchi) - { - operator[](patchi).setSize(mesh_.boundary()[patchi].size()); - } - } - - doAll(); -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDistNoSearch.H b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDistNoSearch.H deleted file mode 100644 index b7751bca0b..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDistNoSearch.H +++ /dev/null @@ -1,105 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 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 . - -Class - Foam::nearWallDistNoSearch - -Description - Distance calculation for cells with face on a wall. Does not search - anything, just takes normal component of distance. - -SourceFiles - nearWallDistNoSearch.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nearWallDistNoSearch_H -#define nearWallDistNoSearch_H - -#include "volFields.H" - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -class fvMesh; - -/*---------------------------------------------------------------------------*\ - Class nearWallDistNoSearch Declaration -\*---------------------------------------------------------------------------*/ - -class nearWallDistNoSearch -: - public volScalarField::Boundary -{ - // Private Data - - //- Reference to mesh - const fvMesh& mesh_; - - - // Private Member Functions - - //- Do all calculations. - void doAll(); - - -public: - - // Constructors - - //- Construct from components - nearWallDistNoSearch(const fvMesh& mesh); - - //- Disallow default bitwise copy construction - nearWallDistNoSearch(const nearWallDistNoSearch&) = delete; - - - //- Destructor - virtual ~nearWallDistNoSearch(); - - - // Member Functions - - //- Correct for mesh geom/topo changes - virtual void correct(); - - - // Member Operators - - //- Disallow default bitwise assignment - void operator=(const nearWallDistNoSearch&) = delete; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C index 08088071a4..2149e32f42 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,8 +26,7 @@ License #include "meshWavePatchDistMethod.H" #include "fvMesh.H" #include "volFields.H" -#include "patchWave.H" -#include "patchDataWave.H" +#include "patchDistWave.H" #include "wallPointData.H" #include "emptyFvPatchFields.H" #include "addToRunTimeSelectionTable.H" @@ -53,8 +52,7 @@ Foam::patchDistMethods::meshWave::meshWave ) : patchDistMethod(mesh, patchIDs), - correctWalls_(dict.lookupOrDefault("correctWalls", true)), - nUnset_(0) + correctWalls_(dict.lookupOrDefault("correctWalls", true)) {} @@ -66,8 +64,7 @@ Foam::patchDistMethods::meshWave::meshWave ) : patchDistMethod(mesh, patchIDs), - correctWalls_(correctWalls), - nUnset_(0) + correctWalls_(correctWalls) {} @@ -77,32 +74,18 @@ bool Foam::patchDistMethods::meshWave::correct(volScalarField& y) { y = dimensionedScalar(dimLength, great); - // Calculate distance starting from patch faces - patchWave wave(mesh_, patchIDs_, correctWalls_); + const label nUnset = + patchDistWave::wave + ( + mesh_, + patchIDs_, + y.primitiveFieldRef(), + correctWalls_ + ); - // Transfer cell values from wave into y - y.transfer(wave.distance()); - - // Transfer values on patches into boundaryField of y - volScalarField::Boundary& ybf = y.boundaryFieldRef(); - - forAll(ybf, patchi) - { - if (!isA(ybf[patchi])) - { - scalarField& waveFld = wave.patchDistance()[patchi]; - - ybf[patchi].transfer(waveFld); - } - } - - // Update coupled and transform BCs y.correctBoundaryConditions(); - // Transfer number of unset values - nUnset_ = wave.nUnset(); - - return nUnset_ > 0; + return nUnset > 0; } @@ -114,55 +97,24 @@ bool Foam::patchDistMethods::meshWave::correct { y = dimensionedScalar(dimLength, great); - // Collect pointers to data on patches - UPtrList patchData(mesh_.boundaryMesh().size()); - - volVectorField::Boundary& nbf = n.boundaryFieldRef(); - - forAll(nbf, patchi) - { - patchData.set(patchi, &nbf[patchi]); - } - - // Do mesh wave - patchDataWave> wave - ( - mesh_, - patchIDs_, - patchData, - correctWalls_ - ); - - // Transfer cell values from wave into y and n - y.transfer(wave.distance()); - - n.transfer(wave.cellData()); - - // Transfer values on patches into boundaryField of y and n - volScalarField::Boundary& ybf = y.boundaryFieldRef(); - - forAll(ybf, patchi) - { - scalarField& waveFld = wave.patchDistance()[patchi]; - - if (!isA(ybf[patchi])) - { - ybf[patchi].transfer(waveFld); - - vectorField& wavePatchData = wave.patchData()[patchi]; - - nbf[patchi].transfer(wavePatchData); - } - } + const label nUnset = + patchDistWave::wave, fvPatchField> + ( + mesh_, + patchIDs_, + n.boundaryField(), + y.primitiveFieldRef(), + y.boundaryFieldRef(), + n.primitiveFieldRef(), + n.boundaryFieldRef(), + correctWalls_ + ); // Update coupled and transform BCs y.correctBoundaryConditions(); n.correctBoundaryConditions(); - // Transfer number of unset values - nUnset_ = wave.nUnset(); - - return nUnset_ > 0; + return nUnset > 0; } diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H index ed4cddf90c..af20834302 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,9 +80,6 @@ class meshWave //- Do accurate distance calculation for near-wall cells. const bool correctWalls_; - //- Number of unset cells and faces. - mutable label nUnset_; - public: @@ -118,11 +115,6 @@ public: // Member Functions - label nUnset() const - { - return nUnset_; - } - //- Correct the given distance-to-patch field virtual bool correct(volScalarField& y); diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.C deleted file mode 100644 index 50691d7eed..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.C +++ /dev/null @@ -1,128 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 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 "wallDistData.H" -#include "patchDataWave.H" -#include "wallPolyPatch.H" -#include "emptyFvPatchFields.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::wallDistData::wallDistData -( - const Foam::fvMesh& mesh, - GeometricField& field, - const bool correctWalls -) -: - volScalarField - ( - IOobject - ( - "y", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar(dimLength, great) - ), - cellDistFuncs(mesh), - field_(field), - correctWalls_(correctWalls), - nUnset_(0) -{ - correct(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::wallDistData::~wallDistData() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::wallDistData::correct() -{ - const polyMesh& mesh = cellDistFuncs::mesh(); - - // - // Fill data on wall patches with initial values - // - - // Get patchids of walls - labelHashSet wallPatchIDs(getPatchIDs()); - - // Collect pointers to data on patches - UPtrList> patchData(mesh.boundaryMesh().size()); - - typename GeometricField:: - Boundary& fieldBf = field_.boundaryFieldRef(); - - forAll(fieldBf, patchi) - { - patchData.set(patchi, &fieldBf[patchi]); - } - - // Do mesh wave - patchDataWave wave - ( - mesh, - wallPatchIDs, - patchData, - correctWalls_ - ); - - // Transfer cell values from wave into *this and field_ - transfer(wave.distance()); - - field_.transfer(wave.cellData()); - - typename GeometricField:: - Boundary& bf = boundaryFieldRef(); - - // Transfer values on patches into boundaryField of *this and field_ - forAll(bf, patchi) - { - scalarField& waveFld = wave.patchDistance()[patchi]; - - if (!isA(boundaryField()[patchi])) - { - bf[patchi].transfer(waveFld); - Field& wavePatchData = wave.patchData()[patchi]; - fieldBf[patchi].transfer(wavePatchData); - } - } - - // Transfer number of unset values - nUnset_ = wave.nUnset(); -} - - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.H deleted file mode 100644 index 093e5a27ba..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/wallDistData/wallDistData.H +++ /dev/null @@ -1,144 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 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 . - -Class - Foam::wallDistData - -Description - Wall distance calculation. Like wallDist but also transports extra - data (template argument). - - Used for e.g reflection vector calculation or vanDriest damping. - - Templated on two parameters: - - TransferType: type of overall data transported - (e.g. wallPointData\) - -SourceFiles - wallDistData.C - -\*---------------------------------------------------------------------------*/ - -#ifndef wallDistData_H -#define wallDistData_H - -#include "cellDistFuncs.H" -#include "volFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class wallDistData Declaration -\*---------------------------------------------------------------------------*/ - -template -class wallDistData -: - public volScalarField, - public cellDistFuncs -{ - typedef typename TransferType::dataType Type; - - - // Private Member Data - - //- Reference to field whose data to use (on walls) and update - // (every cell and non-wall face) - GeometricField& field_; - - //- Do accurate distance calculation for near-wall cells. - bool correctWalls_; - - //- Number of unset cells and faces. - label nUnset_; - - -public: - - // Constructors - - //- Construct from mesh and flag whether or not to correct wall. - // Calculate for all cells. correctWalls : correct wall (face&point) - // cells for correct distance, searching neighbours. - wallDistData - ( - const fvMesh& mesh, - GeometricField&, - bool correctWalls = true - ); - - //- Disallow default bitwise copy construction - wallDistData(const wallDistData&) = delete; - - - //- Destructor - virtual ~wallDistData(); - - - // Member Functions - - const volScalarField& y() const - { - return *this; - } - - label nUnset() const - { - return nUnset_; - } - - //- Access field - const GeometricField& data() const - { - return field_; - } - - //- Correct for mesh geom/topo changes - virtual void correct(); - - - // Member Operators - - //- Disallow default bitwise assignment - void operator=(const wallDistData&) = delete; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "wallDistData.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C index 7d5177a74a..bf6e656547 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C +++ b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,8 @@ License #include "inverseDistanceDiffusivity.H" #include "addToRunTimeSelectionTable.H" -#include "patchWave.H" +#include "patchDistWave.H" +#include "wallPoint.H" #include "HashSet.H" #include "surfaceInterpolate.H" #include "zeroGradientFvPatchFields.H" @@ -72,14 +73,13 @@ Foam::tmp Foam::inverseDistanceDiffusivity::y() const if (patchSet.size()) { - return tmp - ( - new scalarField(patchWave(mesh(), patchSet, false).distance()) - ); + tmp tY(new scalarField(mesh().nCells())); + patchDistWave::wave(mesh(), patchSet, tY.ref(), false); + return tY; } else { - return tmp(new scalarField(mesh().nCells(), 1.0)); + return tmp(new scalarField(mesh().nCells(), 1)); } } diff --git a/src/fvMotionSolver/motionDiffusivity/inverseVolume/inverseVolumeDiffusivity.C b/src/fvMotionSolver/motionDiffusivity/inverseVolume/inverseVolumeDiffusivity.C index 844da54829..b6e7f4b000 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseVolume/inverseVolumeDiffusivity.C +++ b/src/fvMotionSolver/motionDiffusivity/inverseVolume/inverseVolumeDiffusivity.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "inverseVolumeDiffusivity.H" -#include "patchWave.H" #include "HashSet.H" #include "surfaceInterpolate.H" #include "zeroGradientFvPatchFields.H" diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/pointData/pointData.H b/src/mesh/snappyHexMesh/snappyHexMeshDriver/pointData/pointData.H index ac267dccbc..ad0f74d79e 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/pointData/pointData.H +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/pointData/pointData.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,7 +26,7 @@ Class Description Variant of pointEdgePoint with some transported additional data. - WIP - should be templated on data like wallDistData. + WIP - should be templated on data like wallPointData. Passive vector v_ is not a coordinate (so no enterDomain/leaveDomain transformation needed) diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 5565c0731e..a875ad053a 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -44,9 +44,8 @@ cellClassification/cellInfo.C cellQuality/cellQuality.C -cellDist/cellDistFuncs.C -cellDist/patchWave/patchWave.C -cellDist/wallPoint/wallPoint.C +patchDist/patchDistFuncs/patchDistFuncs.C +patchDist/wallPoint/wallPoint.C cellFeatures/cellFeatures.C diff --git a/src/meshTools/algorithms/MeshWave/FaceCellWave.H b/src/meshTools/algorithms/MeshWave/FaceCellWave.H index a2ed872cc7..95c62612f0 100644 --- a/src/meshTools/algorithms/MeshWave/FaceCellWave.H +++ b/src/meshTools/algorithms/MeshWave/FaceCellWave.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -343,6 +343,12 @@ public: return td_; } + //- Additional data to be passed into container + TrackingData& data() + { + return td_; + } + //- Access mesh const polyMesh& mesh() const { diff --git a/src/meshTools/algorithms/MeshWave/MeshWave.H b/src/meshTools/algorithms/MeshWave/MeshWave.H index 4e6d4edc50..157a029bf4 100644 --- a/src/meshTools/algorithms/MeshWave/MeshWave.H +++ b/src/meshTools/algorithms/MeshWave/MeshWave.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -131,6 +131,12 @@ public: return calc_.data(); } + //- Additional data to be passed into container + TrackingData& data() + { + return calc_.data(); + } + //- Iterate until no changes or maxIter reached. Returns actual // number of iterations. label iterate(const label maxIter) diff --git a/src/meshTools/cellDist/cellDistFuncs.C b/src/meshTools/cellDist/cellDistFuncs.C deleted file mode 100644 index f80cd6039e..0000000000 --- a/src/meshTools/cellDist/cellDistFuncs.C +++ /dev/null @@ -1,382 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 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 "cellDistFuncs.H" -#include "polyMesh.H" -#include "wallPolyPatch.H" -#include "polyBoundaryMesh.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -defineTypeNameAndDebug(cellDistFuncs, 0); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// Find val in first nElems elements of elems. -Foam::label Foam::cellDistFuncs::findIndex -( - const label nElems, - const labelList& elems, - const label val -) -{ - for (label i = 0; i < nElems; i++) - { - if (elems[i] == val) - { - return i; - } - } - return -1; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh) -: - mesh_(mesh) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs -( - const wordReList& patchNames -) const -{ - return mesh().boundaryMesh().patchSet(patchNames, false); -} - - -// Return smallest true distance from p to any of wallFaces. -// Note that even if normal hits face we still check other faces. -// Note that wallFaces is untruncated and we explicitly pass in size. -Foam::scalar Foam::cellDistFuncs::smallestDist -( - const point& p, - const polyPatch& patch, - const label nWallFaces, - const labelList& wallFaces, - label& minFacei -) const -{ - const pointField& points = patch.points(); - - scalar minDist = great; - minFacei = -1; - - for (label wallFacei = 0; wallFacei < nWallFaces; wallFacei++) - { - label patchFacei = wallFaces[wallFacei]; - - pointHit curHit = patch[patchFacei].nearestPoint(p, points); - - if (curHit.distance() < minDist) - { - minDist = curHit.distance(); - minFacei = patch.start() + patchFacei; - } - } - - return minDist; -} - - -// Get point neighbours of facei (including facei). Returns number of faces. -// Note: does not allocate storage but does use linear search to determine -// uniqueness. For polygonal faces this might be quite inefficient. -Foam::label Foam::cellDistFuncs::getPointNeighbours -( - const primitivePatch& patch, - const label patchFacei, - labelList& neighbours -) const -{ - label nNeighbours = 0; - - // Add myself - neighbours[nNeighbours++] = patchFacei; - - // Add all face neighbours - const labelList& faceNeighbours = patch.faceFaces()[patchFacei]; - - forAll(faceNeighbours, faceNeighbourI) - { - neighbours[nNeighbours++] = faceNeighbours[faceNeighbourI]; - } - - // Remember part of neighbours that contains edge-connected faces. - label nEdgeNbs = nNeighbours; - - - // Add all point-only neighbours by linear searching in edge neighbours. - // Assumes that point-only neighbours are not using multiple points on - // face. - - const face& f = patch.localFaces()[patchFacei]; - - forAll(f, fp) - { - label pointi = f[fp]; - - const labelList& pointNbs = patch.pointFaces()[pointi]; - - forAll(pointNbs, nbI) - { - label facei = pointNbs[nbI]; - - // Check for facei in edge-neighbours part of neighbours - if (findIndex(nEdgeNbs, neighbours, facei) == -1) - { - neighbours[nNeighbours++] = facei; - } - } - } - - - if (debug) - { - // Check for duplicates - - // Use hashSet to determine nbs. - labelHashSet nbs(4*f.size()); - - forAll(f, fp) - { - const labelList& pointNbs = patch.pointFaces()[f[fp]]; - - forAll(pointNbs, i) - { - nbs.insert(pointNbs[i]); - } - } - - // Subtract ours. - for (label i = 0; i < nNeighbours; i++) - { - label nb = neighbours[i]; - - if (!nbs.found(nb)) - { - SeriousErrorInFunction - << "getPointNeighbours : patchFacei:" << patchFacei - << " verts:" << f << endl; - - forAll(f, fp) - { - SeriousErrorInFunction - << "point:" << f[fp] << " pointFaces:" - << patch.pointFaces()[f[fp]] << endl; - } - - for (label i = 0; i < nNeighbours; i++) - { - SeriousErrorInFunction - << "fast nbr:" << neighbours[i] - << endl; - } - - FatalErrorInFunction - << "Problem: fast pointNeighbours routine included " << nb - << " which is not in proper neighbour list " << nbs.toc() - << abort(FatalError); - } - nbs.erase(nb); - } - - if (nbs.size()) - { - FatalErrorInFunction - << "Problem: fast pointNeighbours routine did not find " - << nbs.toc() << abort(FatalError); - } - } - - return nNeighbours; -} - - -// size of largest patch (out of supplied subset of patches) -Foam::label Foam::cellDistFuncs::maxPatchSize -( - const labelHashSet& patchIDs -) const -{ - label maxSize = 0; - - forAll(mesh().boundaryMesh(), patchi) - { - if (patchIDs.found(patchi)) - { - const polyPatch& patch = mesh().boundaryMesh()[patchi]; - - maxSize = Foam::max(maxSize, patch.size()); - } - } - return maxSize; -} - - -// sum of patch sizes (out of supplied subset of patches) -Foam::label Foam::cellDistFuncs::sumPatchSize -( - const labelHashSet& patchIDs -) -const -{ - label sum = 0; - - forAll(mesh().boundaryMesh(), patchi) - { - if (patchIDs.found(patchi)) - { - const polyPatch& patch = mesh().boundaryMesh()[patchi]; - - sum += patch.size(); - } - } - return sum; -} - - -// Gets nearest wall for cells next to wall -void Foam::cellDistFuncs::correctBoundaryFaceCells -( - const labelHashSet& patchIDs, - scalarField& wallDistCorrected, - Map