diff --git a/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C index 3eb3d84f38..5d482ac9ef 100644 --- a/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C +++ b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C @@ -26,7 +26,7 @@ License #include "vanDriestDelta.H" #include "wallFvPatch.H" #include "fvPatchDistWave.H" -#include "fvWallPointYPlus.H" +#include "FvWallInfoYPlus.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -51,11 +51,11 @@ void Foam::LESModels::vanDriestDelta::calcDelta() const volScalarField& nu = tnu(); tmp nuSgs = momentumTransportModel_.nut(); - volScalarField ystar + volScalarField yStar ( IOobject ( - "ystar", + "yStar", mesh.time().constant(), mesh ), @@ -64,7 +64,7 @@ void Foam::LESModels::vanDriestDelta::calcDelta() ); const fvPatchList& patches = mesh.boundary(); - volScalarField::Boundary& ystarBf = ystar.boundaryFieldRef(); + volScalarField::Boundary& yStarBf = yStar.boundaryFieldRef(); forAll(patches, patchi) { @@ -74,32 +74,33 @@ void Foam::LESModels::vanDriestDelta::calcDelta() const scalarField& nuw = nu.boundaryField()[patchi]; const scalarField& nuSgsw = nuSgs().boundaryField()[patchi]; - ystarBf[patchi] = + yStarBf[patchi] = nuw/sqrt((nuw + nuSgsw)*mag(Uw.snGrad()) + vSmall); } } - fvWallPointYPlus::trackData td; - td.yPlusCutOff = yPlusCutOff_; volScalarField y ( volScalarField::New("y", mesh, dimensionedScalar(dimLength, great)) ); - fvPatchDistWave::wave + + FvWallInfoYPlus::trackData td; + td.yPlusCutOff = yPlusCutOff_; + + fvPatchDistWave::calculateAndCorrect ( mesh, mesh.boundaryMesh().findPatchIDs(), - ystar.boundaryField(), + 2, // <-- roughly equivalent to old point-cell corrections y, - ystar, - true, + yStar, td ); delta_ = min ( static_cast(geometricDelta_()), - (kappa_/Cdelta_)*((scalar(1) + small) - exp(-y/ystar/Aplus_))*y + (kappa_/Cdelta_)*((scalar(1) + small) - exp(-y/yStar/Aplus_))*y ); } diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 4c941ac8cc..00cb4c9f63 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -46,6 +46,7 @@ $(meshWave)/FvFaceCellWaveName.C wallDist = fvMesh/wallDist +$(wallDist)/fvPatchDistWave/fvPatchDistWave.C $(wallDist)/nearWallDist/nearWallDist.C $(wallDist)/wallDist/wallDist.C $(wallDist)/patchDistMethods/patchDistMethod/patchDistMethod.C diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPoint/fvWallPoint.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H similarity index 77% rename from src/finiteVolume/fvMesh/wallDist/fvWallPoint/fvWallPoint.H rename to src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H index 1d3445bbc9..dc3abc3ebf 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPoint/fvWallPoint.H +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H @@ -22,22 +22,22 @@ License along with OpenFOAM. If not, see . Class - Foam::fvWallPoint + Foam::FvWallInfo Description Holds information regarding nearest wall point. Used in wall distance calculation. SourceFiles - fvWallPointI.H - fvWallPoint.C + FvWallInfoI.H \*---------------------------------------------------------------------------*/ -#ifndef fvWallPoint_H -#define fvWallPoint_H +#ifndef FvWallInfo_H +#define FvWallInfo_H #include "wallPoint.H" +#include "wallFace.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,21 +49,21 @@ class fvPatch; class fvMesh; class transformer; - /*---------------------------------------------------------------------------*\ - Class fvWallPoint Declaration + Class FvWallInfoBase Declaration \*---------------------------------------------------------------------------*/ -class fvWallPoint +template +class FvWallInfoBase : - public wallPoint + public WallInfo::template type { public: // Constructors //- Inherit constructors - using wallPoint::wallPoint; + using WallInfo::template type::type; // Member Functions @@ -87,7 +87,7 @@ public: const fvMesh&, const label thisCelli, const labelPair& neighbourPatchAndFacei, - const fvWallPoint& neighbourInfo, + const FvWallInfoBase& neighbourInfo, const scalar tol, TrackingData& td ); @@ -99,7 +99,7 @@ public: const fvMesh&, const labelPair& thisPatchAndFacei, const label neighbourCelli, - const fvWallPoint& neighbourInfo, + const FvWallInfoBase& neighbourInfo, const scalar tol, TrackingData& td ); @@ -110,19 +110,27 @@ public: ( const fvMesh&, const labelPair& thisPatchAndFacei, - const fvWallPoint& neighbourInfo, + const FvWallInfoBase& neighbourInfo, const scalar tol, TrackingData& td ); }; +/*---------------------------------------------------------------------------*\ + Class FvWallInfo Declaration +\*---------------------------------------------------------------------------*/ -//- Data associated with fvWallPoint type are contiguous -template<> -inline bool contiguous() +template +class FvWallInfo +: + public FvWallInfoBase> { - return true; -} + public: + + using + FvWallInfoBase>:: + FvWallInfoBase; +}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -131,7 +139,7 @@ inline bool contiguous() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "fvWallPointI.H" +#include "FvWallInfoI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H new file mode 100644 index 0000000000..b9b778eee8 --- /dev/null +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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::FvWallInfoData + +Description + Holds information (coordinate and normal) regarding nearest wall point. + + Is like FvWallInfo but transfer extra (passive) data. + Used e.g. in wall distance calculation with wall reflection vectors. + +SourceFiles + FvWallInfoDataI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef FvWallInfoData_H +#define FvWallInfoData_H + +#include "FvWallInfo.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators +template +class FvWallInfoDataBase; + +template +Istream& operator>> +( + Istream&, + FvWallInfoDataBase& +); + +template +Ostream& operator<< +( + Ostream&, + const FvWallInfoDataBase& +); + + +/*---------------------------------------------------------------------------*\ + Class FvWallInfoDataBase Declaration +\*---------------------------------------------------------------------------*/ + +template +class FvWallInfoDataBase +: + public FvWallInfoBase +{ + // Private Data + + //- Data at nearest wall center + Type data_; + + +protected: + + // Protected Member Functions + + //- Evaluate distance to point. Update distSqr, origin from whomever + // is nearer pt. Return true if w2 is closer to point. + template + inline bool update + ( + const point&, + const FvWallInfoDataBase& w2, + const scalar tol, + TrackingData& td + ); + + +public: + + friend class FvWallInfoBase; + + + typedef Type dataType; + + + // Constructors + + //- Construct null + inline FvWallInfoDataBase(); + + //- Construct from data and other geometry + template + inline FvWallInfoDataBase + ( + const Type& data, + const Geometry& ... geometry + ); + + + // Member Functions + + // Access + + inline const Type& data() const; + + inline Type& data(); + + template + inline const Type& data(TrackingData& td) const; + + + // Needed by meshWave + + //- Transform across an interface + template + inline void transform + ( + const fvPatch& patch, + const label patchFacei, + const transformer& transform, + TrackingData& td + ); + + + // IOstream Operators + + friend Ostream& operator<< + ( + Ostream&, + const FvWallInfoDataBase& + ); + + friend Istream& operator>> + ( + Istream&, + FvWallInfoDataBase& + ); +}; + + +/*---------------------------------------------------------------------------*\ + Class FvWallInfoData Declaration +\*---------------------------------------------------------------------------*/ + +template +class FvWallInfoData +: + public FvWallInfoDataBase> +{ + public: + + using + FvWallInfoDataBase>:: + FvWallInfoDataBase; +}; + + +#define DefineFvWallInfoType(Type, nullArg) \ + \ + template \ + using CAT(FvWallInfo, CAPITALIZE(Type)) = FvWallInfoData; \ + \ + template<> \ + inline bool contiguous>() \ + { \ + return contiguous>(); \ + } + +DefineFvWallInfoType(bool, nullArg) +DefineFvWallInfoType(label, nullArg) +FOR_ALL_FIELD_TYPES(DefineFvWallInfoType); + +#undef DefineFvWallInfoType + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "FvWallInfoDataI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H new file mode 100644 index 0000000000..63a7a26dc1 --- /dev/null +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 "FvWallInfoData.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +template +inline bool Foam::FvWallInfoDataBase::update +( + const point& pt, + const FvWallInfoDataBase& w2, + const scalar tol, + TrackingData& td +) +{ + const bool result = + FvWallInfoBase::update(pt, w2, tol, td); + + if (result) + { + data_ = w2.data(); + } + + return result; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::FvWallInfoDataBase::FvWallInfoDataBase() +: + FvWallInfoBase(), + data_() +{} + + +template +template +inline Foam::FvWallInfoDataBase::FvWallInfoDataBase +( + const Type& data, + const Geometry& ... geometry +) +: + FvWallInfoBase(geometry ...), + data_(data) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline const Type& +Foam::FvWallInfoDataBase::data() const +{ + return data_; +} + + +template +inline Type& +Foam::FvWallInfoDataBase::data() +{ + return data_; +} + + +template +template +inline const Type& +Foam::FvWallInfoDataBase::data(TrackingData& td) const +{ + return data_; +} + + +template +template +inline void Foam::FvWallInfoDataBase::transform +( + const fvPatch& patch, + const label patchFacei, + const transformer& transform, + TrackingData& td +) +{ + FvWallInfoBase::transform + ( + patch, + patchFacei, + transform, + td + ); + + data_ = transform.transform(data_); +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const FvWallInfoDataBase& w +) +{ + return os + << static_cast&>(w) + << token::SPACE + << w.data(); +} + + +template +Foam::Istream& Foam::operator>> +( + Istream& is, + FvWallInfoDataBase& w +) +{ + return is + >> static_cast&>(w) + >> w.data_; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPoint/fvWallPointI.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoI.H similarity index 72% rename from src/finiteVolume/fvMesh/wallDist/fvWallPoint/fvWallPointI.H rename to src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoI.H index 2d496081a5..78b307b3a0 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPoint/fvWallPointI.H +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoI.H @@ -23,15 +23,16 @@ License \*---------------------------------------------------------------------------*/ -#include "fvWallPoint.H" +#include "FvWallInfo.H" #include "fvMesh.H" #include "volFields.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template template -inline void Foam::fvWallPoint::transform +inline void Foam::FvWallInfoBase::transform ( const fvPatch& patch, const label patchFacei, @@ -39,39 +40,47 @@ inline void Foam::fvWallPoint::transform TrackingData& td ) { - wallPoint::transform(patch.patch(), patchFacei, transform, td); + WallInfo::template type::transform + ( + patch.patch(), + patchFacei, + transform, + td + ); } +template template -inline bool Foam::fvWallPoint::updateCell +inline bool Foam::FvWallInfoBase::updateCell ( const fvMesh& mesh, const label thisCelli, const labelPair& neighbourPatchAndFacei, - const fvWallPoint& neighbourWallInfo, + const FvWallInfoBase& neighbourWallInfo, const scalar tol, TrackingData& td ) { return - this->update + static_cast(*this).update ( mesh.C()[thisCelli], - neighbourWallInfo, + static_cast(neighbourWallInfo), tol, td ); } +template template -inline bool Foam::fvWallPoint::updateFace +inline bool Foam::FvWallInfoBase::updateFace ( const fvMesh& mesh, const labelPair& thisPatchAndFacei, const label neighbourCelli, - const fvWallPoint& neighbourWallInfo, + const FvWallInfoBase& neighbourWallInfo, const scalar tol, TrackingData& td ) @@ -80,24 +89,25 @@ inline bool Foam::fvWallPoint::updateFace const label thisFacei = thisPatchAndFacei.second(); return - this->update + static_cast(*this).update ( thisPatchi == -1 ? mesh.Cf()[thisFacei] : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - neighbourWallInfo, + static_cast(neighbourWallInfo), tol, td ); } +template template -inline bool Foam::fvWallPoint::updateFace +inline bool Foam::FvWallInfoBase::updateFace ( const fvMesh& mesh, const labelPair& thisPatchAndFacei, - const fvWallPoint& neighbourWallInfo, + const FvWallInfoBase& neighbourWallInfo, const scalar tol, TrackingData& td ) @@ -106,12 +116,12 @@ inline bool Foam::fvWallPoint::updateFace const label thisFacei = thisPatchAndFacei.second(); return - this->update + static_cast(*this).update ( thisPatchi == -1 ? mesh.Cf()[thisFacei] : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - neighbourWallInfo, + static_cast(neighbourWallInfo), tol, td ); diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPointYPlus/fvWallPointYPlus.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlus.H similarity index 53% rename from src/finiteVolume/fvMesh/wallDist/fvWallPointYPlus/fvWallPointYPlus.H rename to src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlus.H index e5aa9bd4aa..6dbd55d1ec 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPointYPlus/fvWallPointYPlus.H +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlus.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::fvWallPointYPlus + Foam::FvWallInfoYPlus Description Holds information (coordinate and yStar) regarding nearest wall point. @@ -32,33 +32,29 @@ Description the damping function becomes 1, since y gets initialised to great and yStar to 1. - Note: should feed the additional argument (yPlusCutoff) through as a - template argument into FvFaceCellWave - SourceFiles - fvWallPointYPlusI.H - fvWallPointYPlus.C + FvWallInfoYPlusI.H \*---------------------------------------------------------------------------*/ -#ifndef fvWallPointYPlus_H -#define fvWallPointYPlus_H +#ifndef FvWallInfoYPlus_H +#define FvWallInfoYPlus_H -#include "fvWallPointData.H" +#include "FvWallInfoData.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - /*---------------------------------------------------------------------------*\ - Class fvWallPointYPlus Declaration + Class FvWallInfoYPlusBase Declaration \*---------------------------------------------------------------------------*/ -class fvWallPointYPlus +template +class FvWallInfoYPlusBase : - public fvWallPointData + public FvWallInfoDataBase { public: @@ -72,9 +68,12 @@ public: }; -private: +protected: - // Private Member Functions + friend class FvWallInfoBase; + + + // Protected Member Functions //- Evaluate distance to point. Update distSqr, origin from whomever // is nearer pt. Return true if w2 is closer to point, @@ -83,7 +82,7 @@ private: inline bool update ( const point& pt, - const fvWallPointYPlus& w2, + const FvWallInfoYPlusBase& w2, const scalar tol, TrackingData& td ); @@ -94,68 +93,28 @@ public: // Constructors //- Construct null - inline fvWallPointYPlus(); + inline FvWallInfoYPlusBase(); - //- Construct from origin, yStar, distance - inline fvWallPointYPlus - ( - const point& origin, - const scalar yStar, - const scalar distSqr - ); - - - // Member Functions - - // Needed by FvFaceCellWave - - //- Influence of neighbouring face. - // Calls update(...) with cellCentre of celli - template - inline bool updateCell - ( - const fvMesh& mesh, - const label thisCelli, - const labelPair& neighbourPatchAndFacei, - const fvWallPointYPlus& neighbourWallInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of neighbouring cell. - // Calls update(...) with faceCentre of facei - template - inline bool updateFace - ( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const label neighbourCelli, - const fvWallPointYPlus& neighbourWallInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of different value on same face. - // Merge new and old info. - // Calls update(...) with faceCentre of facei - template - inline bool updateFace - ( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const fvWallPointYPlus& neighbourWallInfo, - const scalar tol, - TrackingData& td - ); + //- Inherit constructors + using FvWallInfoDataBase::FvWallInfoDataBase; }; -//- Data associated with pointEdgePoint type as contiguous as underlying type -template<> -inline bool contiguous() +/*---------------------------------------------------------------------------*\ + Class FvWallInfoYPlus Declaration +\*---------------------------------------------------------------------------*/ + +template +class FvWallInfoYPlus +: + public FvWallInfoYPlusBase> { - return contiguous>(); -} + public: + + using + FvWallInfoYPlusBase>:: + FvWallInfoYPlusBase; +}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -164,7 +123,7 @@ inline bool contiguous() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "fvWallPointYPlusI.H" +#include "FvWallInfoYPlusI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/patchDist/wallPoint/wallPoint.C b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlusI.H similarity index 54% rename from src/meshTools/patchDist/wallPoint/wallPoint.C rename to src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlusI.H index c5e4fdcae7..d6a70da52e 100644 --- a/src/meshTools/patchDist/wallPoint/wallPoint.C +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlusI.H @@ -23,18 +23,50 @@ License \*---------------------------------------------------------------------------*/ -#include "wallPoint.H" +#include "FvWallInfoYPlus.H" -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::wallPoint& wDist) +template +template +inline bool Foam::FvWallInfoYPlusBase::update +( + const point& pt, + const FvWallInfoYPlusBase& w2, + const scalar tol, + TrackingData& td +) { - return os << wDist.origin() << token::SPACE << wDist.distSqr(); + FvWallInfoYPlusBase copy(*this); + + bool result = + FvWallInfoDataBase::update(pt, w2, tol, td); + + if (result) + { + const scalar yPlus = sqrt(this->distSqr())/w2.data(); + + if (yPlus >= td.yPlusCutOff) + { + *this = copy; + result = false; + } + } + + return result; } -Foam::Istream& Foam::operator>>(Foam::Istream& is, Foam::wallPoint& wDist) + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline Foam::FvWallInfoYPlusBase::FvWallInfoYPlusBase() +: + FvWallInfoDataBase() { - return is >> wDist.origin() >> wDist.distSqr(); + // Important: The value of yStar where the meshWave does not come. + this->data() = 1.0; } + // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointData.C b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.C similarity index 64% rename from src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointData.C rename to src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.C index 3f1597f660..5bb37e65cc 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointData.C +++ b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.C @@ -23,42 +23,39 @@ License \*---------------------------------------------------------------------------*/ -#include "fvWallPointData.H" +#include "fvPatchDistWave.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -template -Ostream& operator<< +Foam::List Foam::fvPatchDistWave::getChangedPatchAndFaces ( - Ostream& os, - const fvWallPointData& wDist + const fvMesh& mesh, + const labelHashSet& patchIDs ) { - return os - << static_cast(wDist) - << token::SPACE - << wDist.data(); -} + label nChangedFaces = 0; + forAllConstIter(labelHashSet, patchIDs, iter) + { + nChangedFaces += mesh.boundary()[iter.key()].size(); + } + List changedPatchAndFaces(nChangedFaces); + label changedFacei = 0; -template -Istream& operator>> -( - Istream& is, - fvWallPointData& wDist -) -{ - return is >> static_cast(wDist) >> wDist.data_; + forAllConstIter(labelHashSet, patchIDs, iter) + { + const label patchi = iter.key(); + const fvPatch& patch = mesh.boundary()[patchi]; + + forAll(patch, patchFacei) + { + changedPatchAndFaces[changedFacei] = labelPair(patchi, patchFacei); + changedFacei++; + } + } + + return changedPatchAndFaces; } -// ************************************************************************* // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H index 6993606702..4554f348a8 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H +++ b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H @@ -38,6 +38,8 @@ SourceFiles #include "FvFaceCellWave.H" #include "volFields.H" +#include "wallPoint.H" +#include "wallFace.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,74 +50,126 @@ namespace fvPatchDistWave // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//- Set initial set of changed faces -template -void setChangedFaces +//- Get initial set of changed faces +List getChangedPatchAndFaces ( const fvMesh& mesh, - const labelHashSet& patchIDs, - List& changedPatchAndFaces, - List& faceDist, - const InitialPatchData& ... initialPatchData + const labelHashSet& patchIDs ); -//- Copy FvFaceCellWave values into the cell fields +//- Wave distance (and maybe additional) data from faces. If nCorrections is +// negative (-1) then the wave propagates through the entire mesh and all +// values are calculated. If nCorrections is positive, then this many wave +// steps are computed and the result is corrected only on cells and faces that +// the wave reaches. Don't use this directly. Use +// calculate/correct/calculateAndCorrect functions below. template < - class PatchPointType, + class WallInfo, class TrackingData, - class DataType, - class DataMethod + template class PatchField, + class GeoMesh, + class ... DataType > -label getCellValues -( - FvFaceCellWave& waveInfo, - Field& cellValues, - DataMethod method, - const DataType& stabiliseValue = pTraits::zero -); - -//- Copy FvFaceCellWave values into the patch field-fields -template -< - class PatchPointType, - class TrackingData, - class DataType, - class DataMethod -> -label getPatchValues -( - FvFaceCellWave& wave, - GeometricBoundaryField& valuesBf, - DataMethod method, - const DataType& stabiliseValue = pTraits::zero -); - -//- Wave distance data from the patches to the cells and other patch faces -template label wave ( const fvMesh& mesh, - const labelHashSet& patchIDs, - volScalarField& distance, - bool correct = true, - TrackingData& td = FvFaceCellWave::defaultTrackingData_ + const List& changedPatchAndFaces, + const label nCorrections, + GeometricField& distance, + TrackingData& td, + GeometricField& ... data ); -//- Wave distance and auxiliary data from the patches to the cells and other -// patch faces -template -label wave +//- Calculate distance data from patches +template class PatchField, class GeoMesh> +label calculate ( const fvMesh& mesh, const labelHashSet& patchIDs, - const GeometricBoundaryField - & - initialPatchData, - volScalarField& distance, - VolField& data, - bool correct = true, - TrackingData& td = FvFaceCellWave::defaultTrackingData_ + GeometricField& distance +); + +//- Correct distance data from patches +template class PatchField, class GeoMesh> +void correct +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance +); + +//- Calculate and correct distance data from patches +template class PatchField, class GeoMesh> +label calculateAndCorrect +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance +); + +//- Calculate distance and additional data from patches +template +< + template class WallInfoData, + template class PatchField, + class GeoMesh, + class TrackingData = int +> +label calculate +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + GeometricField& distance, + GeometricField + ::dataType, PatchField, GeoMesh>& + data, + TrackingData& td = + FvFaceCellWave>::defaultTrackingData_ +); + +//- Correct distance and additional data from patches +template +< + template class WallInfoData, + template class PatchField, + class GeoMesh, + class TrackingData = int +> +void correct +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance, + GeometricField + ::dataType, PatchField, GeoMesh>& + data, + TrackingData& td = + FvFaceCellWave>::defaultTrackingData_ +); + +//- Calculate and correct distance and additional data from patches +template +< + template class WallInfoData, + template class PatchField, + class GeoMesh, + class TrackingData = int +> +label calculateAndCorrect +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance, + GeometricField + ::dataType, PatchField, GeoMesh>& + data, + TrackingData& td = + FvFaceCellWave>::defaultTrackingData_ ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C index 5ad2f7cbe3..bf642d0e58 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C +++ b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C @@ -24,319 +24,353 @@ License \*---------------------------------------------------------------------------*/ #include "fvPatchDistWave.H" -#include "patchDistFuncs.H" +#include "FvWallInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template -void Foam::fvPatchDistWave::setChangedFaces +namespace Foam +{ +namespace fvPatchDistWave +{ + +template +const List& getInternalInfo ( - const fvMesh& mesh, - const labelHashSet& patchIDs, - List& changedPatchAndFaces, - List& changedFacesInfo, - const InitialPatchData& ... initialPatchData + const volScalarField& distance, + FvFaceCellWave& wave ) { - label nChangedFaces = 0; - forAllConstIter(labelHashSet, patchIDs, iter) - { - nChangedFaces += mesh.boundary()[iter.key()].size(); - } - - changedPatchAndFaces.resize(nChangedFaces); - changedFacesInfo.resize(nChangedFaces); - - label changedFacei = 0; - - forAllConstIter(labelHashSet, patchIDs, iter) - { - const label patchi = iter.key(); - - const fvPatch& patch = mesh.boundary()[patchi]; - - forAll(patch.Cf(), patchFacei) - { - changedPatchAndFaces[changedFacei] = {patchi, patchFacei}; - - changedFacesInfo[changedFacei] = - PatchPointType - ( - patch.Cf()[patchFacei], - initialPatchData[patchi][patchFacei] ..., - scalar(0) - ); - - changedFacei++; - } - } + return wave.cellInfo(); } +template +const List& getInternalInfo +( + const surfaceScalarField& distance, + FvFaceCellWave& wave +) +{ + return wave.internalFaceInfo(); +} + +} +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template < - class PatchPointType, + class WallInfo, class TrackingData, - class DataType, - class DataMethod + template class PatchField, + class GeoMesh, + class ... DataType > -Foam::label Foam::fvPatchDistWave::getCellValues -( - FvFaceCellWave& waveInfo, - Field& cellValues, - DataMethod method, - const DataType& stabiliseValue -) -{ - const List& cellInfo = waveInfo.cellInfo(); - - label nInvalid = 0; - - forAll(cellInfo, celli) - { - cellValues[celli] = - (cellInfo[celli].*method)(waveInfo.data()) - + stabiliseValue; - - nInvalid += !cellInfo[celli].valid(waveInfo.data()); - } - - return nInvalid; -} - - -template -< - class PatchPointType, - class TrackingData, - class DataType, - class DataMethod -> -Foam::label Foam::fvPatchDistWave::getPatchValues -( - FvFaceCellWave& waveInfo, - GeometricBoundaryField& valuesBf, - DataMethod method, - const DataType& stabiliseValue -) -{ - const List>& patchFaceInfo = waveInfo.patchFaceInfo(); - - label nInvalid = 0; - - forAll(valuesBf, patchi) - { - forAll(valuesBf[patchi], patchFacei) - { - valuesBf[patchi][patchFacei] = - (patchFaceInfo[patchi][patchFacei].*method)(waveInfo.data()) - + stabiliseValue; - - nInvalid += - !patchFaceInfo[patchi][patchFacei].valid(waveInfo.data()); - } - } - - return nInvalid; -} - - -template Foam::label Foam::fvPatchDistWave::wave ( const fvMesh& mesh, - const labelHashSet& patchIDs, - volScalarField& distance, - const bool correct, - TrackingData& td + const List& changedPatchAndFaces, + const label nCorrections, + GeometricField& distance, + TrackingData& td, + GeometricField& ... data ) { + // If the number of corrections is less than 0 (i.e., -1) then this is a + // calculation across the entire mesh. Otherwise it is a correction for the + // cells/faces near the changed faces. + const bool calculate = nCorrections < 0; + + // Quick return if no corrections + if (!calculate && nCorrections == 0) return 0; + // Initialise changedFacesInfo to face centres on patches - List changedPatchAndFaces; - List changedFacesInfo; - setChangedFaces - ( - mesh, - patchIDs, - changedPatchAndFaces, - changedFacesInfo - ); + List changedFacesInfo(changedPatchAndFaces.size()); + forAll(changedPatchAndFaces, changedFacei) + { + const label patchi = + changedPatchAndFaces[changedFacei].first(); + const label patchFacei = + changedPatchAndFaces[changedFacei].second(); + + changedFacesInfo[changedFacei] = + WallInfo + ( + data.boundaryField()[patchi][patchFacei] ..., + mesh.boundaryMesh()[patchi][patchFacei], + mesh.points(), + mesh.Cf().boundaryField()[patchi][patchFacei], + scalar(0) + ); + } // Do calculate patch distance by 'growing' from faces. - List internalFaceInfo(mesh.nInternalFaces()); - List> patchFaceInfo + List internalFaceInfo(mesh.nInternalFaces()); + List> patchFaceInfo ( - FvFaceCellWave::template - sizesListList>> + FvFaceCellWave::template + sizesListList>> ( - FvFaceCellWave::template + FvFaceCellWave::template listListSizes(mesh.boundary()), - PatchPointType() + WallInfo() ) ); - List cellInfo(mesh.nCells()); - FvFaceCellWave wave + List cellInfo(mesh.nCells()); + + // Do the wave + FvFaceCellWave wave ( mesh, - changedPatchAndFaces, - changedFacesInfo, internalFaceInfo, patchFaceInfo, cellInfo, - mesh.globalData().nTotalCells() + 1, // max iterations td ); - - // Copy distance into return field - const label nUnset = - getCellValues - ( - wave, - distance.primitiveFieldRef(), - &PatchPointType::template dist - ) - + getPatchValues - ( - wave, - distance.boundaryFieldRef(), - &PatchPointType::template dist, - small - ); - - // Correct patch cells for true distance - if (correct) + wave.setFaceInfo(changedPatchAndFaces, changedFacesInfo); + if (calculate) { - Map nearestFace(2*changedFacesInfo.size()); - patchDistFuncs::correctBoundaryFaceCells - ( - mesh, - patchIDs, - distance.primitiveFieldRef(), - nearestFace - ); - patchDistFuncs::correctBoundaryPointCells - ( - mesh, - patchIDs, - distance.primitiveFieldRef(), - nearestFace - ); + // Calculation. Wave to completion. + wave.iterate(mesh.globalData().nTotalCells() + 1); + } + else + { + // Correction. Wave the specified number of times then stop. We care + // about cell values, so avoid the final cellToFace by doing n - 1 + // iterations than a final faceToCell. + wave.iterate(nCorrections - 1); + wave.faceToCell(); + } + + // Copy distances into field + const List& internalInfo = getInternalInfo(distance, wave); + label nUnset = 0; + forAll(internalInfo, internali) + { + const bool valid = internalInfo[internali].valid(td); + + if (calculate || valid) + { + nUnset += !valid; + + distance.primitiveFieldRef()[internali] = + internalInfo[internali].dist(td); + + std::initializer_list + {( + data.primitiveFieldRef()[internali] = + internalInfo[internali].data(td), + nil() + ) ... }; + } + } + forAll(patchFaceInfo, patchi) + { + forAll(patchFaceInfo[patchi], patchFacei) + { + const bool valid = patchFaceInfo[patchi][patchFacei].valid(td); + + if (calculate || valid) + { + nUnset += !valid; + + distance.boundaryFieldRef()[patchi][patchFacei] = + patchFaceInfo[patchi][patchFacei].dist(td) + small; + + std::initializer_list + {( + data.boundaryFieldRef()[patchi][patchFacei] = + patchFaceInfo[patchi][patchFacei].data(td), + nil() + ) ... }; + } + } } return nUnset; } -template -Foam::label Foam::fvPatchDistWave::wave +template class PatchField, class GeoMesh> +Foam::label Foam::fvPatchDistWave::calculate ( const fvMesh& mesh, const labelHashSet& patchIDs, - const GeometricBoundaryField - & - initialPatchData, - volScalarField& distance, - VolField& data, - const bool correct, + GeometricField& distance +) +{ + return + wave> + ( + mesh, + getChangedPatchAndFaces(mesh, patchIDs), + -1, + distance, + FvFaceCellWave>::defaultTrackingData_ + ); +} + + +template class PatchField, class GeoMesh> +void Foam::fvPatchDistWave::correct +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance +) +{ + wave> + ( + mesh, + getChangedPatchAndFaces(mesh, patchIDs), + nCorrections, + distance, + FvFaceCellWave>::defaultTrackingData_ + ); +} + + +template class PatchField, class GeoMesh> +Foam::label Foam::fvPatchDistWave::calculateAndCorrect +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance +) +{ + const List changedPatchAndFaces = + getChangedPatchAndFaces(mesh, patchIDs); + + const label nUnset = + wave> + ( + mesh, + changedPatchAndFaces, + -1, + distance, + FvFaceCellWave>::defaultTrackingData_ + ); + + wave> + ( + mesh, + changedPatchAndFaces, + nCorrections, + distance, + FvFaceCellWave>::defaultTrackingData_ + ); + + return nUnset; +} + + +template +< + template class WallInfoData, + template class PatchField, + class GeoMesh, + class TrackingData +> +Foam::label Foam::fvPatchDistWave::calculate +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + GeometricField& distance, + GeometricField + ::dataType, PatchField, GeoMesh>& + data, TrackingData& td ) { - // Initialise changedFacesInfo to face centres on patches - List changedPatchAndFaces; - List changedFacesInfo; - setChangedFaces - ( - mesh, - patchIDs, - changedPatchAndFaces, - changedFacesInfo, - initialPatchData - ); - - // Do calculate patch distance by 'growing' from faces. - List internalFaceInfo(mesh.nInternalFaces()); - List> patchFaceInfo - ( - FvFaceCellWave::template - sizesListList>> + return + wave, TrackingData> ( - FvFaceCellWave::template - listListSizes(mesh.boundary()), - PatchPointType() - ) - ); - List cellInfo(mesh.nCells()); - FvFaceCellWave wave + mesh, + getChangedPatchAndFaces(mesh, patchIDs), + -1, + distance, + td, + data + ); +} + + +template +< + template class WallInfoData, + template class PatchField, + class GeoMesh, + class TrackingData +> +void Foam::fvPatchDistWave::correct +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance, + GeometricField + ::dataType, PatchField, GeoMesh>& + data, + TrackingData& td +) +{ + wave, TrackingData> ( mesh, - changedPatchAndFaces, - changedFacesInfo, - internalFaceInfo, - patchFaceInfo, - cellInfo, - mesh.globalData().nTotalCells() + 1, // max iterations - td + getChangedPatchAndFaces(mesh, patchIDs), + nCorrections, + distance, + td, + data ); +} + + +template +< + template class WallInfoData, + template class PatchField, + class GeoMesh, + class TrackingData +> +Foam::label Foam::fvPatchDistWave::calculateAndCorrect +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const label nCorrections, + GeometricField& distance, + GeometricField + ::dataType, PatchField, GeoMesh>& + data, + TrackingData& td +) +{ + const List changedPatchAndFaces = + getChangedPatchAndFaces(mesh, patchIDs); - // Copy distance into return field const label nUnset = - getCellValues - ( - wave, - distance.primitiveFieldRef(), - &PatchPointType::template dist - ) - + getPatchValues - ( - wave, - distance.boundaryFieldRef(), - &PatchPointType::template dist, - small - ); - - // Copy data into the return field - getCellValues - ( - wave, - data.primitiveFieldRef(), - &PatchPointType::template data - ); - getPatchValues - ( - wave, - data.boundaryFieldRef(), - &PatchPointType::template data - ); - - // Correct patch cells for true distance - if (correct) - { - Map nearestPatchAndFace(2*changedFacesInfo.size()); - patchDistFuncs::correctBoundaryFaceCells + wave, TrackingData> ( mesh, - patchIDs, - distance.primitiveFieldRef(), - nearestPatchAndFace - ); - patchDistFuncs::correctBoundaryPointCells - ( - mesh, - patchIDs, - distance.primitiveFieldRef(), - nearestPatchAndFace + getChangedPatchAndFaces(mesh, patchIDs), + -1, + distance, + td, + data ); - // Transfer data from nearest face to cell - forAllConstIter(Map, nearestPatchAndFace, iter) - { - const label celli = iter.key(); - const label patchi = iter().first(); - const label patchFacei = iter().second(); - data.primitiveFieldRef()[celli] = - wave.patchFaceInfo()[patchi][patchFacei].data(); - } - } + wave, TrackingData> + ( + mesh, + changedPatchAndFaces, + nCorrections, + distance, + td, + data + ); return nUnset; } diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointData.H b/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointData.H deleted file mode 100644 index 3a09916a52..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointData.H +++ /dev/null @@ -1,248 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 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::fvWallPointData - -Description - Holds information (coordinate and normal) regarding nearest wall point. - - Is like fvWallPoint but transfer extra (passive) data. - Used e.g. in wall distance calculation with wall reflection vectors. - -SourceFiles - fvWallPointDataI.H - fvWallPointData.C - -\*---------------------------------------------------------------------------*/ - -#ifndef fvWallPointData_H -#define fvWallPointData_H - -#include "fvWallPoint.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -template class fvWallPointData; - -// Forward declaration of friend functions and operators - -template -Istream& operator>>(Istream&, fvWallPointData&); - -template -Ostream& operator<<(Ostream&, const fvWallPointData&); - - -/*---------------------------------------------------------------------------*\ - Class fvWallPointData Declaration -\*---------------------------------------------------------------------------*/ - -template -class fvWallPointData -: - public fvWallPoint -{ - // Private Data - - //- Data at nearest wall center - Type data_; - - - // Private Member Functions - - //- Evaluate distance to point. Update distSqr, origin from whomever - // is nearer pt. Return true if w2 is closer to point, - // false otherwise. - template - inline bool update - ( - const point&, - const fvWallPointData& w2, - const scalar tol, - TrackingData& td - ); - - -public: - - typedef Type dataType; - - - // Constructors - - //- Construct null - inline fvWallPointData(); - - //- Construct from origin, normal, distance - inline fvWallPointData - ( - const point& origin, - const Type& data, - const scalar distSqr - ); - - - // Member Functions - - // Access - - inline const Type& data() const; - - inline Type& data(); - - template - inline const Type& data(TrackingData& td) const; - - - // Needed by meshWave - - //- Transform across an interface - template - inline void transform - ( - const fvPatch& patch, - const label patchFacei, - const transformer& transform, - TrackingData& td - ); - - //- Influence of neighbouring face. - // Calls update(...) with cellCentre of celli - template - inline bool updateCell - ( - const fvMesh& mesh, - const label thisCelli, - const labelPair& neighbourPatchAndFacei, - const fvWallPointData& neighbourWallInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of neighbouring cell. - // Calls update(...) with faceCentre of facei - template - inline bool updateFace - ( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const label neighbourCelli, - const fvWallPointData& neighbourWallInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of different value on same face. - // Merge new and old info. - // Calls update(...) with faceCentre of facei - template - inline bool updateFace - ( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const fvWallPointData& neighbourWallInfo, - const scalar tol, - TrackingData& td - ); - - - // IOstream Operators - - friend Ostream& operator<< - ( - Ostream&, - const fvWallPointData& - ); - - friend Istream& operator>> - ( - Istream&, - fvWallPointData& - ); -}; - - -//- Data associated with fvWallPointData type are contiguous. List the usual -// ones. - -template<> -inline bool contiguous>() -{ - return contiguous(); -} -template<> -inline bool contiguous>() -{ - return contiguous(); -} -template<> -inline bool contiguous>() -{ - return contiguous(); -} -template<> -inline bool contiguous>() -{ - return contiguous(); -} -template<> -inline bool contiguous>() -{ - return contiguous(); -} -template<> -inline bool contiguous>() -{ - return contiguous(); -} -template<> -inline bool contiguous>() -{ - return contiguous(); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "fvWallPointData.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "fvWallPointDataI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointDataI.H b/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointDataI.H deleted file mode 100644 index 167733dfea..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPointData/fvWallPointDataI.H +++ /dev/null @@ -1,217 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 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 "fvWallPointData.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template -template -inline bool fvWallPointData::update -( - const point& pt, - const fvWallPointData& w2, - const scalar tol, - TrackingData& td -) -{ - scalar dist2 = magSqr(pt - w2.origin()); - - if (valid(td)) - { - scalar diff = distSqr() - dist2; - - if (diff < 0) - { - // already nearer to pt - return false; - } - - if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol))) - { - // don't propagate small changes - return false; - } - } - - // Either *this is not yet valid or w2 is closer - { - // current not yet set so use any value - distSqr() = dist2; - origin() = w2.origin(); - data_ = w2.data(); - - return true; - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -inline fvWallPointData::fvWallPointData() -: - fvWallPoint(), - data_() -{} - - -template -inline fvWallPointData::fvWallPointData -( - const point& origin, - const Type& data, - const scalar distSqr -) -: - fvWallPoint(origin, distSqr), - data_(data) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline const Type& fvWallPointData::data() const -{ - return data_; -} - - -template -inline Type& fvWallPointData::data() -{ - return data_; -} - - -template -template -inline const Type& fvWallPointData::data(TrackingData& td) const -{ - return data_; -} - - -template -template -inline void Foam::fvWallPointData::transform -( - const fvPatch& patch, - const label patchFacei, - const transformer& transform, - TrackingData& td -) -{ - fvWallPoint::transform(patch, patchFacei, transform, td); - data_ = transform.transform(data_); -} - - -template -template -inline bool fvWallPointData::updateCell -( - const fvMesh& mesh, - const label thisCelli, - const labelPair& neighbourPatchAndFacei, - const fvWallPointData& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return update - ( - mesh.C()[thisCelli], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool fvWallPointData::updateFace -( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const label neighbourCelli, - const fvWallPointData& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - const label thisPatchi = thisPatchAndFacei.first(); - const label thisFacei = thisPatchAndFacei.second(); - - return update - ( - thisPatchi == -1 - ? mesh.Cf()[thisFacei] - : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool fvWallPointData::updateFace -( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const fvWallPointData& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - const label thisPatchi = thisPatchAndFacei.first(); - const label thisFacei = thisPatchAndFacei.second(); - - return update - ( - thisPatchi == -1 - ? mesh.Cf()[thisFacei] - : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -// ************************************************************************* // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/fvWallPointYPlus/fvWallPointYPlusI.H b/src/finiteVolume/fvMesh/wallDist/fvWallPointYPlus/fvWallPointYPlusI.H deleted file mode 100644 index 025dcb027e..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/fvWallPointYPlus/fvWallPointYPlusI.H +++ /dev/null @@ -1,187 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 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 "fvWallPointYPlus.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// Update this with w2 if w2 nearer to pt. -template -inline bool fvWallPointYPlus::update -( - const point& pt, - const fvWallPointYPlus& w2, - const scalar tol, - TrackingData& td -) -{ - scalar dist2 = magSqr(pt - w2.origin()); - - if (valid(td)) - { - scalar diff = distSqr() - dist2; - - if (diff < 0) - { - // already nearer to pt - return false; - } - - if ((diff < small) || ((distSqr() > small) && (diff/distSqr() < tol))) - { - // don't propagate small changes - return false; - } - } - - - // Either *this is not yet valid or w2 is closer - { - // only propagate if interesting (i.e. y+ < 100) - scalar yPlus = Foam::sqrt(dist2)/w2.data(); - - if (yPlus < td.yPlusCutOff) - { - // update with new values - distSqr() = dist2; - origin() = w2.origin(); - data() = w2.data(); - - return true; - } - else - { - return false; - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -inline fvWallPointYPlus::fvWallPointYPlus() -: - fvWallPointData() -{ - // Important: The value of yStar where the meshWave does not come. - data() = 1.0; -} - - -inline fvWallPointYPlus::fvWallPointYPlus -( - const point& origin, - const scalar yStar, - const scalar distSqr -) -: - fvWallPointData(origin, yStar, distSqr) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline bool fvWallPointYPlus::updateCell -( - const fvMesh& mesh, - const label thisCelli, - const labelPair& neighbourPatchAndFacei, - const fvWallPointYPlus& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return update - ( - mesh.C()[thisCelli], - neighbourWallInfo, - tol, - td - ); -} - - -template -inline bool fvWallPointYPlus::updateFace -( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const label neighbourCelli, - const fvWallPointYPlus& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - const label thisPatchi = thisPatchAndFacei.first(); - const label thisFacei = thisPatchAndFacei.second(); - - return update - ( - thisPatchi == -1 - ? mesh.Cf()[thisFacei] - : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -template -inline bool fvWallPointYPlus::updateFace -( - const fvMesh& mesh, - const labelPair& thisPatchAndFacei, - const fvWallPointYPlus& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - const label thisPatchi = thisPatchAndFacei.first(); - const label thisFacei = thisPatchAndFacei.second(); - - return update - ( - thisPatchi == -1 - ? mesh.Cf()[thisFacei] - : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -// ************************************************************************* // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C index db1ae0a9f2..0b55805354 100644 --- a/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/nearWallDist/nearWallDist.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "nearWallDist.H" -#include "patchDistFuncs.H" +#include "fvPatchDistWave.H" #include "wallPolyPatch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -39,12 +39,24 @@ namespace Foam void Foam::nearWallDist::correct() { - patchDistFuncs::correctBoundaryFaceFaceCells + volScalarField yVf(volScalarField::New("y", mesh(), dimLength)); + + fvPatchDistWave::correct ( mesh(), mesh().boundaryMesh().findPatchIDs(), - y_ + 2, + yVf ); + + forAll(y_, patchi) + { + const labelUList& faceCells = mesh().boundary()[patchi].faceCells(); + forAll(y_[patchi], patchFacei) + { + y_[patchi][patchFacei] = yVf[faceCells[patchFacei]]; + } + } } diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C index cee1c61de4..2437170b37 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C @@ -27,7 +27,7 @@ License #include "fvMesh.H" #include "volFields.H" #include "fvPatchDistWave.H" -#include "fvWallPointData.H" +#include "FvWallInfoData.H" #include "emptyFvPatchFields.H" #include "addToRunTimeSelectionTable.H" @@ -52,7 +52,7 @@ Foam::patchDistMethods::meshWave::meshWave ) : patchDistMethod(mesh, patchIDs), - correctWalls_(dict.lookupOrDefault("correctWalls", true)) + nCorrectors_(dict.lookupOrDefault