diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlus.H b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/WallLocationYPlus.H similarity index 62% rename from src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlus.H rename to src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/WallLocationYPlus.H index 6dbd55d1ec..78b4e2e815 100644 --- a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlus.H +++ b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/WallLocationYPlus.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::FvWallInfoYPlus + Foam::WallLocationYPlus Description Holds information (coordinate and yStar) regarding nearest wall point. @@ -33,58 +33,60 @@ Description yStar to 1. SourceFiles - FvWallInfoYPlusI.H + WallLocationYPlusI.H \*---------------------------------------------------------------------------*/ -#ifndef FvWallInfoYPlus_H -#define FvWallInfoYPlus_H +#ifndef WallLocationYPlus_H +#define WallLocationYPlus_H -#include "FvWallInfoData.H" +#include "WallLocationData.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward declaration of classes +class transformer; + /*---------------------------------------------------------------------------*\ - Class FvWallInfoYPlusBase Declaration + Class WallLocationYPlus Declaration \*---------------------------------------------------------------------------*/ -template -class FvWallInfoYPlusBase +template +class WallLocationYPlus : - public FvWallInfoDataBase + public WallLocationData { public: - //- Class used to pass additional data in - class trackData - { - public: + // Public Classes - //- Cut off distance - scalar yPlusCutOff; - }; + //- Class used to pass additional data in + class trackData + { + public: + + //- Cut off distance + scalar yPlusCutOff; + }; protected: - 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, - // false otherwise. - template + // is nearer pt. Return true if w2 is closer to point, false + // otherwise. + template inline bool update ( - const point& pt, - const FvWallInfoYPlusBase& w2, + const point&, + const WallLocationYPlus& w2, const scalar tol, - TrackingData& td + TrackingYPlus& td ); @@ -93,28 +95,25 @@ public: // Constructors //- Construct null - inline FvWallInfoYPlusBase(); + inline WallLocationYPlus(); //- Inherit constructors - using FvWallInfoDataBase::FvWallInfoDataBase; + using WallLocationData::WallLocationData; }; -/*---------------------------------------------------------------------------*\ - Class FvWallInfoYPlus Declaration -\*---------------------------------------------------------------------------*/ +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template -class FvWallInfoYPlus -: - public FvWallInfoYPlusBase> +class wallPoint; + +template +class FvWallInfo; + +template<> +inline bool contiguous>>() { - public: - - using - FvWallInfoYPlusBase>:: - FvWallInfoYPlusBase; -}; + return true; +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -123,7 +122,7 @@ class FvWallInfoYPlus // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "FvWallInfoYPlusI.H" +#include "WallLocationYPlusI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlusI.H b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/WallLocationYPlusI.H similarity index 63% rename from src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlusI.H rename to src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/WallLocationYPlusI.H index d6a70da52e..b76214152a 100644 --- a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoYPlusI.H +++ b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/WallLocationYPlusI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,34 +23,29 @@ License \*---------------------------------------------------------------------------*/ -#include "FvWallInfoYPlus.H" +#include "WallLocationYPlus.H" -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -template -template -inline bool Foam::FvWallInfoYPlusBase::update +template +template +inline bool Foam::WallLocationYPlus::update ( const point& pt, - const FvWallInfoYPlusBase& w2, + const WallLocationYPlus& w2, const scalar tol, - TrackingData& td + TrackingYPlus& td ) { - FvWallInfoYPlusBase copy(*this); + WallLocationYPlus copy(*this); bool result = - FvWallInfoDataBase::update(pt, w2, tol, td); + WallLocationData::update(pt, w2, tol, td); - if (result) + if (result && sqrt(this->distSqr())/w2.data() >= td.yPlusCutOff) { - const scalar yPlus = sqrt(this->distSqr())/w2.data(); - - if (yPlus >= td.yPlusCutOff) - { - *this = copy; - result = false; - } + *this = copy; + result = false; } return result; @@ -59,10 +54,10 @@ inline bool Foam::FvWallInfoYPlusBase::update // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::FvWallInfoYPlusBase::FvWallInfoYPlusBase() +template +inline Foam::WallLocationYPlus::WallLocationYPlus() : - FvWallInfoDataBase() + WallLocationData() { // Important: The value of yStar where the meshWave does not come. this->data() = 1.0; diff --git a/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C b/src/MomentumTransportModels/momentumTransportModels/LES/LESdeltas/vanDriestDelta/vanDriestDelta.C index 32db9f17d1..8043d40190 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-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,7 +26,7 @@ License #include "vanDriestDelta.H" #include "wallFvPatch.H" #include "fvPatchDistWave.H" -#include "FvWallInfoYPlus.H" +#include "WallLocationYPlus.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -84,10 +84,10 @@ void Foam::LESModels::vanDriestDelta::calcDelta() volScalarField::New("y", mesh, dimensionedScalar(dimLength, great)) ); - FvWallInfoYPlus::trackData td; + WallLocationYPlus::trackData td; td.yPlusCutOff = yPlusCutOff_; - fvPatchDistWave::calculateAndCorrect + fvPatchDistWave::calculateAndCorrect ( mesh, mesh.boundaryMesh().findPatchIDs(), diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H index dc3abc3ebf..e2ec322a4c 100644 --- a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfo.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,8 +36,8 @@ SourceFiles #ifndef FvWallInfo_H #define FvWallInfo_H -#include "wallPoint.H" -#include "wallFace.H" +#include "fieldTypes.H" +#include "labelPair.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,26 +50,36 @@ class fvMesh; class transformer; /*---------------------------------------------------------------------------*\ - Class FvWallInfoBase Declaration + Class FvWallInfo Declaration \*---------------------------------------------------------------------------*/ -template -class FvWallInfoBase +template +class FvWallInfo : - public WallInfo::template type + public WallLocation { public: // Constructors //- Inherit constructors - using WallInfo::template type::type; + using WallLocation::WallLocation; // Member Functions // Needed by FvFaceCellWave + //- Check for identical geometrical data. Used for cyclics checking. + template + inline bool sameGeometry + ( + const fvMesh& mesh, + const FvWallInfo& w2, + const scalar tol, + TrackingData& td + ) const; + //- Transform across an interface template inline void transform @@ -87,7 +97,7 @@ public: const fvMesh&, const label thisCelli, const labelPair& neighbourPatchAndFacei, - const FvWallInfoBase& neighbourInfo, + const FvWallInfo& neighbourInfo, const scalar tol, TrackingData& td ); @@ -99,7 +109,7 @@ public: const fvMesh&, const labelPair& thisPatchAndFacei, const label neighbourCelli, - const FvWallInfoBase& neighbourInfo, + const FvWallInfo& neighbourInfo, const scalar tol, TrackingData& td ); @@ -110,27 +120,41 @@ public: ( const fvMesh&, const labelPair& thisPatchAndFacei, - const FvWallInfoBase& neighbourInfo, + const FvWallInfo& neighbourInfo, const scalar tol, TrackingData& td ); }; -/*---------------------------------------------------------------------------*\ - Class FvWallInfo Declaration -\*---------------------------------------------------------------------------*/ -template -class FvWallInfo -: - public FvWallInfoBase> +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +class wallPoint; + +template<> +inline bool contiguous>() { - public: + return true; +} - using - FvWallInfoBase>:: - FvWallInfoBase; -}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +class WallLocationData; + +#define DefineContiguousFvWallLocationDataType(Type, nullArg) \ + template<> \ + inline bool contiguous>>() \ + { \ + return true; \ + } + +DefineContiguousFvWallLocationDataType(bool, ); +DefineContiguousFvWallLocationDataType(label, ); +FOR_ALL_FIELD_TYPES(DefineContiguousFvWallLocationDataType); + +#undef DefineContiguousFvWallLocationDataType // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H deleted file mode 100644 index b9b778eee8..0000000000 --- a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoData.H +++ /dev/null @@ -1,208 +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::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/FvWallInfoI.H b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoI.H index 78b307b3a0..fb165a626c 100644 --- a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoI.H +++ b/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,9 +30,23 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template +template template -inline void Foam::FvWallInfoBase::transform +inline bool Foam::FvWallInfo::sameGeometry +( + const fvMesh& mesh, + const FvWallInfo& w2, + const scalar tol, + TrackingData& td +) const +{ + return WallLocation::sameGeometry(w2, tol, td); +} + + +template +template +inline void Foam::FvWallInfo::transform ( const fvPatch& patch, const label patchFacei, @@ -40,47 +54,41 @@ inline void Foam::FvWallInfoBase::transform TrackingData& td ) { - WallInfo::template type::transform - ( - patch.patch(), - patchFacei, - transform, - td - ); + WallLocation::transform(transform, td); } -template +template template -inline bool Foam::FvWallInfoBase::updateCell +inline bool Foam::FvWallInfo::updateCell ( const fvMesh& mesh, const label thisCelli, const labelPair& neighbourPatchAndFacei, - const FvWallInfoBase& neighbourWallInfo, + const FvWallInfo& neighbourWallInfo, const scalar tol, TrackingData& td ) { return - static_cast(*this).update + WallLocation::update ( mesh.C()[thisCelli], - static_cast(neighbourWallInfo), + neighbourWallInfo, tol, td ); } -template +template template -inline bool Foam::FvWallInfoBase::updateFace +inline bool Foam::FvWallInfo::updateFace ( const fvMesh& mesh, const labelPair& thisPatchAndFacei, const label neighbourCelli, - const FvWallInfoBase& neighbourWallInfo, + const FvWallInfo& neighbourWallInfo, const scalar tol, TrackingData& td ) @@ -89,25 +97,25 @@ inline bool Foam::FvWallInfoBase::updateFace const label thisFacei = thisPatchAndFacei.second(); return - static_cast(*this).update + WallLocation::update ( thisPatchi == -1 ? mesh.Cf()[thisFacei] : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - static_cast(neighbourWallInfo), + neighbourWallInfo, tol, td ); } -template +template template -inline bool Foam::FvWallInfoBase::updateFace +inline bool Foam::FvWallInfo::updateFace ( const fvMesh& mesh, const labelPair& thisPatchAndFacei, - const FvWallInfoBase& neighbourWallInfo, + const FvWallInfo& neighbourWallInfo, const scalar tol, TrackingData& td ) @@ -116,12 +124,12 @@ inline bool Foam::FvWallInfoBase::updateFace const label thisFacei = thisPatchAndFacei.second(); return - static_cast(*this).update + WallLocation::update ( thisPatchi == -1 ? mesh.Cf()[thisFacei] : mesh.Cf().boundaryField()[thisPatchi][thisFacei], - static_cast(neighbourWallInfo), + neighbourWallInfo, tol, td ); diff --git a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H index 96d4010bb8..1c8b6bc010 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H +++ b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWave.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,6 +40,8 @@ SourceFiles #include "volFields.H" #include "wallPoint.H" #include "wallFace.H" +#include "WallLocationData.H" +#include "FvWallInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -66,7 +68,7 @@ List getChangedPatchAndFaces // calculate/correct/calculateAndCorrect functions below. template < - class WallInfo, + class FvWallInfoType, class TrackingData, template class PatchField, class GeoMesh, @@ -114,10 +116,12 @@ label calculateAndCorrect GeometricField& distance ); -//- Calculate distance and additional data from patches +//- Calculate distance and additional data from patches, using an +// arbitrary wall location wave class template < - template class WallInfoData, + template class WallLocation, + class DataType, template class PatchField, class GeoMesh, class TrackingData = int @@ -128,17 +132,16 @@ label calculate const labelHashSet& patchIDs, const scalar minFaceFraction, GeometricField& distance, - GeometricField - ::dataType, PatchField, GeoMesh>& - data, - TrackingData& td = - FvFaceCellWave>::defaultTrackingData_ + GeometricField& data, + TrackingData& td = FvFaceCellWave::defaultTrackingData_ ); -//- Correct distance and additional data from patches +//- Correct distance and additional data from patches, using an +// arbitrary wall location wave class template < - template class WallInfoData, + template class WallLocation, + class DataType, template class PatchField, class GeoMesh, class TrackingData = int @@ -150,17 +153,16 @@ void correct const scalar minFaceFraction, const label nCorrections, GeometricField& distance, - GeometricField - ::dataType, PatchField, GeoMesh>& - data, - TrackingData& td = - FvFaceCellWave>::defaultTrackingData_ + GeometricField& data, + TrackingData& td = FvFaceCellWave::defaultTrackingData_ ); -//- Calculate and correct distance and additional data from patches +//- Calculate and correct distance and additional data from patches, using an +// arbitrary wall location wave class template < - template class WallInfoData, + template class WallLocation, + class DataType, template class PatchField, class GeoMesh, class TrackingData = int @@ -172,11 +174,64 @@ label calculateAndCorrect const scalar minFaceFraction, const label nCorrections, GeometricField& distance, - GeometricField - ::dataType, PatchField, GeoMesh>& - data, - TrackingData& td = - FvFaceCellWave>::defaultTrackingData_ + GeometricField& data, + TrackingData& td = FvFaceCellWave::defaultTrackingData_ +); + +//- Calculate distance and additional data from patches +template +< + class DataType, + template class PatchField, + class GeoMesh, + class TrackingData = int +> +label calculate +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const scalar minFaceFraction, + GeometricField& distance, + GeometricField& data, + TrackingData& td = FvFaceCellWave::defaultTrackingData_ +); + +//- Correct distance and additional data from patches +template +< + class DataType, + template class PatchField, + class GeoMesh, + class TrackingData = int +> +void correct +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const scalar minFaceFraction, + const label nCorrections, + GeometricField& distance, + GeometricField& data, + TrackingData& td = FvFaceCellWave::defaultTrackingData_ +); + +//- Calculate and correct distance and additional data from patches +template +< + class DataType, + template class PatchField, + class GeoMesh, + class TrackingData = int +> +label calculateAndCorrect +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const scalar minFaceFraction, + const label nCorrections, + GeometricField& distance, + GeometricField& data, + TrackingData& td = FvFaceCellWave::defaultTrackingData_ ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C index 64f201e1b5..cbfdbf9454 100644 --- a/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C +++ b/src/finiteVolume/fvMesh/wallDist/fvPatchDistWave/fvPatchDistWaveTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,21 +33,21 @@ namespace Foam namespace fvPatchDistWave { -template -const List& getInternalInfo +template +const List& getInternalInfo ( const volScalarField& distance, - FvFaceCellWave& wave + FvFaceCellWave& wave ) { return wave.cellInfo(); } -template -const List& getInternalInfo +template +const List& getInternalInfo ( const surfaceScalarField& distance, - FvFaceCellWave& wave + FvFaceCellWave& wave ) { return wave.internalFaceInfo(); @@ -61,7 +61,7 @@ const List& getInternalInfo template < - class WallInfo, + class FvWallInfoType, class TrackingData, template class PatchField, class GeoMesh, @@ -86,7 +86,7 @@ Foam::label Foam::fvPatchDistWave::wave if (!calculate && nCorrections == 0) return 0; // Initialise changedFacesInfo to face centres on patches - List changedFacesInfo(changedPatchAndFaces.size()); + List changedFacesInfo(changedPatchAndFaces.size()); forAll(changedPatchAndFaces, changedFacei) { const label patchi = @@ -95,7 +95,7 @@ Foam::label Foam::fvPatchDistWave::wave changedPatchAndFaces[changedFacei].second(); changedFacesInfo[changedFacei] = - WallInfo + FvWallInfoType ( data.boundaryField()[patchi][patchFacei] ..., mesh.boundaryMesh()[patchi][patchFacei], @@ -106,25 +106,25 @@ Foam::label Foam::fvPatchDistWave::wave } // 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()), - WallInfo() + FvWallInfoType() ) ); - List cellInfo(mesh.nCells()); + List cellInfo(mesh.nCells()); // Prevent hangs associated with generation of on-demand geometry mesh.C(); mesh.Cf(); // Do the wave - FvFaceCellWave wave + FvFaceCellWave wave ( mesh, internalFaceInfo, @@ -148,7 +148,7 @@ Foam::label Foam::fvPatchDistWave::wave } // Copy distances into field - const List& internalInfo = getInternalInfo(distance, wave); + const List& internalInfo = getInternalInfo(distance, wave); label nUnset = 0; forAll(internalInfo, internali) { @@ -276,7 +276,8 @@ Foam::label Foam::fvPatchDistWave::calculateAndCorrect template < - template class WallInfoData, + template class WallLocation, + class DataType, template class PatchField, class GeoMesh, class TrackingData @@ -287,14 +288,12 @@ Foam::label Foam::fvPatchDistWave::calculate const labelHashSet& patchIDs, const scalar minFaceFraction, GeometricField& distance, - GeometricField - ::dataType, PatchField, GeoMesh>& - data, + GeometricField& data, TrackingData& td ) { return - wave, TrackingData> + wave>, TrackingData> ( mesh, getChangedPatchAndFaces(mesh, patchIDs, minFaceFraction), @@ -308,7 +307,8 @@ Foam::label Foam::fvPatchDistWave::calculate template < - template class WallInfoData, + template class WallLocation, + class DataType, template class PatchField, class GeoMesh, class TrackingData @@ -320,13 +320,11 @@ void Foam::fvPatchDistWave::correct const scalar minFaceFraction, const label nCorrections, GeometricField& distance, - GeometricField - ::dataType, PatchField, GeoMesh>& - data, + GeometricField& data, TrackingData& td ) { - wave, TrackingData> + wave>, TrackingData> ( mesh, getChangedPatchAndFaces(mesh, patchIDs, minFaceFraction), @@ -340,7 +338,8 @@ void Foam::fvPatchDistWave::correct template < - template class WallInfoData, + template class WallLocation, + class DataType, template class PatchField, class GeoMesh, class TrackingData @@ -352,9 +351,7 @@ Foam::label Foam::fvPatchDistWave::calculateAndCorrect const scalar minFaceFraction, const label nCorrections, GeometricField& distance, - GeometricField - ::dataType, PatchField, GeoMesh>& - data, + GeometricField& data, TrackingData& td ) { @@ -362,7 +359,7 @@ Foam::label Foam::fvPatchDistWave::calculateAndCorrect getChangedPatchAndFaces(mesh, patchIDs, minFaceFraction); const label nUnset = - wave, TrackingData> + wave>, TrackingData> ( mesh, changedPatchAndFaces, @@ -372,7 +369,7 @@ Foam::label Foam::fvPatchDistWave::calculateAndCorrect data ); - wave, TrackingData> + wave>, TrackingData> ( mesh, changedPatchAndFaces, @@ -386,4 +383,110 @@ Foam::label Foam::fvPatchDistWave::calculateAndCorrect } +namespace Foam +{ +namespace fvPatchDistWave +{ + template + struct WallLocationDataType + { + template + using type = WallLocationData; + }; +} +} + + +template +< + class DataType, + template class PatchField, + class GeoMesh, + class TrackingData +> +Foam::label Foam::fvPatchDistWave::calculate +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const scalar minFaceFraction, + GeometricField& distance, + GeometricField& data, + TrackingData& td +) +{ + return + calculate::template type> + ( + mesh, + getChangedPatchAndFaces(mesh, patchIDs, minFaceFraction), + -1, + distance, + td, + data + ); +} + + +template +< + class DataType, + template class PatchField, + class GeoMesh, + class TrackingData +> +void Foam::fvPatchDistWave::correct +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const scalar minFaceFraction, + const label nCorrections, + GeometricField& distance, + GeometricField& data, + TrackingData& td +) +{ + correct::template type> + ( + mesh, + getChangedPatchAndFaces(mesh, patchIDs, minFaceFraction), + nCorrections, + distance, + td, + data + ); +} + + +template +< + class DataType, + template class PatchField, + class GeoMesh, + class TrackingData +> +Foam::label Foam::fvPatchDistWave::calculateAndCorrect +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const scalar minFaceFraction, + const label nCorrections, + GeometricField& distance, + GeometricField& data, + TrackingData& td +) +{ + return + calculateAndCorrect::template type> + ( + mesh, + patchIDs, + minFaceFraction, + nCorrections, + distance, + data, + td + ); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/meshWave/meshWavePatchDistMethod.C index ea0d6f750b..9937066b44 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-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,7 +27,6 @@ License #include "fvMesh.H" #include "volFields.H" #include "fvPatchDistWave.H" -#include "FvWallInfoData.H" #include "emptyFvPatchFields.H" #include "addToRunTimeSelectionTable.H" @@ -103,7 +102,7 @@ bool Foam::patchDistMethods::meshWave::correct y = dimensionedScalar(dimLength, great); const label nUnset = - fvPatchDistWave::calculateAndCorrect + fvPatchDistWave::calculateAndCorrect ( mesh_, patchIDs_, diff --git a/src/meshTools/patchDist/WallInfo/WallInfo.H b/src/meshTools/patchDist/WallInfo/WallInfo.H new file mode 100644 index 0000000000..db49f53675 --- /dev/null +++ b/src/meshTools/patchDist/WallInfo/WallInfo.H @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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::WallInfo + +Description + Holds information regarding nearest wall point. Used in wall distance + calculation. + +SourceFiles + WallInfoI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef WallInfo_H +#define WallInfo_H + +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class polyPatch; +class polyMesh; +class transformer; + +/*---------------------------------------------------------------------------*\ + Class WallInfo Declaration +\*---------------------------------------------------------------------------*/ + +template +class WallInfo +: + public WallLocation +{ +public: + + // Constructors + + //- Inherit constructors + using WallLocation::WallLocation; + + + // Member Functions + + // Needed by FaceCellWave + + //- Check for identical geometrical data. Used for cyclics checking. + template + inline bool sameGeometry + ( + const polyMesh& mesh, + const WallInfo& w2, + const scalar tol, + TrackingData& td + ) const; + + //- Transform across an interface + template + inline void transform + ( + const polyPatch& patch, + const label patchFacei, + const transformer& transform, + TrackingData& td + ); + + //- Influence of neighbouring face. + template + inline bool updateCell + ( + const polyMesh&, + const label thisCelli, + const label neighbourFacei, + const WallInfo& neighbourInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of neighbouring cell. + template + inline bool updateFace + ( + const polyMesh&, + const label thisFacei, + const label neighbourCelli, + const WallInfo& neighbourInfo, + const scalar tol, + TrackingData& td + ); + + //- Influence of different value on same face. + template + inline bool updateFace + ( + const polyMesh&, + const label thisFacei, + const WallInfo& neighbourInfo, + const scalar tol, + TrackingData& td + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +class wallPoint; + +template<> +inline bool contiguous>() +{ + return true; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +class WallLocationData; + +#define DefineContiguousWallLocationDataType(Type, nullArg) \ + template<> \ + inline bool contiguous>>() \ + { \ + return true; \ + } + +DefineContiguousWallLocationDataType(bool, ); +DefineContiguousWallLocationDataType(label, ); +FOR_ALL_FIELD_TYPES(DefineContiguousWallLocationDataType); + +#undef DefineContiguousWallLocationDataType + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "WallInfoI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/patchDist/WallInfo/WallInfoI.H b/src/meshTools/patchDist/WallInfo/WallInfoI.H new file mode 100644 index 0000000000..b00813e239 --- /dev/null +++ b/src/meshTools/patchDist/WallInfo/WallInfoI.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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 "WallInfo.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +template +inline bool Foam::WallInfo::sameGeometry +( + const polyMesh& mesh, + const WallInfo& w2, + const scalar tol, + TrackingData& td +) const +{ + return WallLocation::sameGeometry(w2, tol, td); +} + + +template +template +inline void Foam::WallInfo::transform +( + const polyPatch& patch, + const label patchFacei, + const transformer& transform, + TrackingData& td +) +{ + WallLocation::transform(transform, td); +} + + +template +template +inline bool Foam::WallInfo::updateCell +( + const polyMesh& mesh, + const label thisCelli, + const label neighbourFacei, + const WallInfo& neighbourWallInfo, + const scalar tol, + TrackingData& td +) +{ + return + WallLocation::update + ( + mesh.cellCentres()[thisCelli], + neighbourWallInfo, + tol, + td + ); +} + + +template +template +inline bool Foam::WallInfo::updateFace +( + const polyMesh& mesh, + const label thisFacei, + const label neighbourCelli, + const WallInfo& neighbourWallInfo, + const scalar tol, + TrackingData& td +) +{ + return + WallLocation::update + ( + mesh.faceCentres()[thisFacei], + neighbourWallInfo, + tol, + td + ); +} + + +template +template +inline bool Foam::WallInfo::updateFace +( + const polyMesh& mesh, + const label thisFacei, + const WallInfo& neighbourWallInfo, + const scalar tol, + TrackingData& td +) +{ + return + WallLocation::update + ( + mesh.faceCentres()[thisFacei], + neighbourWallInfo, + tol, + td + ); +} + + +// ************************************************************************* // diff --git a/src/meshTools/patchDist/WallLocation/WallLocationData.H b/src/meshTools/patchDist/WallLocation/WallLocationData.H new file mode 100644 index 0000000000..f89e10f1f3 --- /dev/null +++ b/src/meshTools/patchDist/WallLocation/WallLocationData.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2023 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::WallLocationData + +Description + Holds information regarding nearest wall point. Used in wall distance + calculation. + +SourceFiles + WallLocationDataI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef WallLocationData_H +#define WallLocationData_H + +#include "point.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class transformer; + +// Forward declaration of friend functions and operators +template +class WallLocationData; +template +Ostream& operator<<(Ostream&, const WallLocationData&); +template +Istream& operator>>(Istream&, WallLocationData&); + +/*---------------------------------------------------------------------------*\ + Class WallLocationData Declaration +\*---------------------------------------------------------------------------*/ + +template +class WallLocationData +: + public WallLocation +{ + // 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, false + // otherwise. + template + inline bool update + ( + const point& pt, + const WallLocationData& w2, + const scalar tol, + TrackingData& td + ); + + +public: + + // Public Typedefs + + //- The type of the stored data + typedef Type dataType; + + + // Constructors + + //- Construct null + inline WallLocationData(); + + //- Construct from data and other geometry + template + inline WallLocationData(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 FaceCellWave + + //- Transform across an interface + template + inline void transform + ( + const transformer& transform, + TrackingData& td + ); + + + // IOstream Operators + + friend Ostream& operator<< + ( + Ostream&, + const WallLocationData& + ); + friend Istream& operator>> + ( + Istream&, + WallLocationData& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "WallLocationDataI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H b/src/meshTools/patchDist/WallLocation/WallLocationDataI.H similarity index 52% rename from src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H rename to src/meshTools/patchDist/WallLocation/WallLocationDataI.H index 63a7a26dc1..edfb36bec4 100644 --- a/src/finiteVolume/fvMesh/wallDist/FvWallInfo/FvWallInfoDataI.H +++ b/src/meshTools/patchDist/WallLocation/WallLocationDataI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,22 +23,22 @@ License \*---------------------------------------------------------------------------*/ -#include "FvWallInfoData.H" +#include "WallLocationData.H" +#include "transformer.H" -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -template +template template -inline bool Foam::FvWallInfoDataBase::update +inline bool Foam::WallLocationData::update ( const point& pt, - const FvWallInfoDataBase& w2, + const WallLocationData& w2, const scalar tol, TrackingData& td ) { - const bool result = - FvWallInfoBase::update(pt, w2, tol, td); + const bool result = WallLocation::update(pt, w2, tol, td); if (result) { @@ -51,71 +51,63 @@ inline bool Foam::FvWallInfoDataBase::update // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::FvWallInfoDataBase::FvWallInfoDataBase() +template +inline Foam::WallLocationData::WallLocationData() : - FvWallInfoBase(), + WallLocation(), data_() {} -template +template template -inline Foam::FvWallInfoDataBase::FvWallInfoDataBase +inline Foam::WallLocationData::WallLocationData ( const Type& data, const Geometry& ... geometry ) : - FvWallInfoBase(geometry ...), + WallLocation(geometry ...), data_(data) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Type& -Foam::FvWallInfoDataBase::data() const +template +inline const Type& Foam::WallLocationData::data() const { return data_; } -template -inline Type& -Foam::FvWallInfoDataBase::data() +template +inline Type& Foam::WallLocationData::data() { return data_; } -template +template template -inline const Type& -Foam::FvWallInfoDataBase::data(TrackingData& td) const -{ - return data_; -} - - -template -template -inline void Foam::FvWallInfoDataBase::transform +inline const Type& Foam::WallLocationData::data +( + TrackingData& td +) const +{ + return data_; +} + + +template +template +inline void Foam::WallLocationData::transform ( - const fvPatch& patch, - const label patchFacei, const transformer& transform, TrackingData& td ) { - FvWallInfoBase::transform - ( - patch, - patchFacei, - transform, - td - ); + WallLocation::transform(transform, td); data_ = transform.transform(data_); } @@ -123,30 +115,26 @@ inline void Foam::FvWallInfoDataBase::transform // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -template +template Foam::Ostream& Foam::operator<< ( Ostream& os, - const FvWallInfoDataBase& w + const WallLocationData& w ) { - return os - << static_cast&>(w) - << token::SPACE - << w.data(); + return + os << static_cast(w) << token::SPACE << w.data(); } -template +template Foam::Istream& Foam::operator>> ( Istream& is, - FvWallInfoDataBase& w + WallLocationData& w ) { - return is - >> static_cast&>(w) - >> w.data_; + return is >> static_cast(w) >> w.data_; } diff --git a/src/meshTools/patchDist/wallFace/wallFace.H b/src/meshTools/patchDist/WallLocation/wallFace.H similarity index 60% rename from src/meshTools/patchDist/wallFace/wallFace.H rename to src/meshTools/patchDist/WallLocation/wallFace.H index e4473f274b..bad1c6b6be 100644 --- a/src/meshTools/patchDist/wallFace/wallFace.H +++ b/src/meshTools/patchDist/WallLocation/wallFace.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,24 +45,18 @@ namespace Foam { // Forward declaration of classes -class polyPatch; -class polyMesh; class transformer; // Forward declaration of friend functions and operators -template -class WallFaceBase; -template -Ostream& operator<<(Ostream&, const WallFaceBase&); -template -Istream& operator>>(Istream&, WallFaceBase&); +class wallFace; +Ostream& operator<<(Ostream&, const wallFace&); +Istream& operator>>(Istream&, wallFace&); /*---------------------------------------------------------------------------*\ - Class WallFaceBase Declaration + Class wallFace Declaration \*---------------------------------------------------------------------------*/ -template -class WallFaceBase +class wallFace { // Private Data @@ -77,12 +71,14 @@ protected: // Protected 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& pt, - const WallFaceBase& w2, + const wallFace& w2, const scalar tol, TrackingData& td ); @@ -93,10 +89,10 @@ public: // Constructors //- Construct null - inline WallFaceBase(); + inline wallFace(); //- Construct from face, distance - inline WallFaceBase + inline wallFace ( const face& f, const pointField& points, @@ -104,7 +100,7 @@ public: ); //- Construct from face, distance - inline WallFaceBase + inline wallFace ( const face& f, const pointField& points, @@ -131,7 +127,7 @@ public: // Needed by FaceCellWave - //- Check whether the WallFaceBase has been changed at all or still + //- Check whether the wallFace has been changed at all or still // contains original (invalid) value. template inline bool valid(TrackingData& td) const; @@ -141,8 +137,7 @@ public: template inline bool sameGeometry ( - const polyMesh&, - const WallFaceBase&, + const wallFace&, const scalar, TrackingData& td ) const; @@ -151,90 +146,29 @@ public: template inline void transform ( - const polyPatch& patch, - const label patchFacei, const transformer& transform, TrackingData& td ); - //- Influence of neighbouring face - template - inline bool updateCell - ( - const polyMesh&, - const label thisCelli, - const label neighbourFacei, - const WallFaceBase& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of neighbouring cell - template - inline bool updateFace - ( - const polyMesh&, - const label thisFacei, - const label neighbourCelli, - const WallFaceBase& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of different value on same face - template - inline bool updateFace - ( - const polyMesh&, - const label thisFacei, - const WallFaceBase& neighbourInfo, - const scalar tol, - TrackingData& td - ); - //- Test equality template inline bool equal ( - const WallFaceBase&, + const wallFace&, TrackingData& td ) const; // Member Operators - inline bool operator==(const WallFaceBase&) const; - inline bool operator!=(const WallFaceBase&) const; + inline bool operator==(const wallFace&) const; + inline bool operator!=(const wallFace&) const; // IOstream Operators - friend Ostream& operator<< - ( - Ostream&, - const WallFaceBase& - ); - - friend Istream& operator>> - ( - Istream&, - WallFaceBase& - ); -}; - -/*---------------------------------------------------------------------------*\ - Class wallFace Declaration -\*---------------------------------------------------------------------------*/ - -class wallFace -: - public WallFaceBase -{ - public: - - using WallFaceBase::WallFaceBase; - - template using type = WallFaceBase; + inline friend Ostream& operator<<(Ostream&, const wallFace&); + inline friend Istream& operator>>(Istream&, wallFace&); }; diff --git a/src/meshTools/patchDist/wallFace/wallFaceI.H b/src/meshTools/patchDist/WallLocation/wallFaceI.H similarity index 51% rename from src/meshTools/patchDist/wallFace/wallFaceI.H rename to src/meshTools/patchDist/WallLocation/wallFaceI.H index 08428b114a..0a5ab7825d 100644 --- a/src/meshTools/patchDist/wallFace/wallFaceI.H +++ b/src/meshTools/patchDist/WallLocation/wallFaceI.H @@ -29,12 +29,11 @@ License // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -template template -inline bool Foam::WallFaceBase::update +inline bool Foam::wallFace::update ( const point& pt, - const WallFaceBase& w2, + const wallFace& w2, const scalar tol, TrackingData& td ) @@ -74,16 +73,14 @@ inline bool Foam::WallFaceBase::update // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::WallFaceBase::WallFaceBase() +inline Foam::wallFace::wallFace() : points_(0), distSqr_(-great) {} -template -inline Foam::WallFaceBase::WallFaceBase +inline Foam::wallFace::wallFace ( const face& f, const pointField& points, @@ -95,8 +92,7 @@ inline Foam::WallFaceBase::WallFaceBase {} -template -inline Foam::WallFaceBase::WallFaceBase +inline Foam::wallFace::wallFace ( const face& f, const pointField& points, @@ -111,167 +107,76 @@ inline Foam::WallFaceBase::WallFaceBase // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Foam::pointField& Foam::WallFaceBase::points() const +inline const Foam::pointField& Foam::wallFace::points() const { return points_; } -template -inline Foam::pointField& Foam::WallFaceBase::points() +inline Foam::pointField& Foam::wallFace::points() { return points_; } -template -inline Foam::scalar Foam::WallFaceBase::distSqr() const +inline Foam::scalar Foam::wallFace::distSqr() const { return distSqr_; } -template -inline Foam::scalar& Foam::WallFaceBase::distSqr() +inline Foam::scalar& Foam::wallFace::distSqr() { return distSqr_; } -template template -inline Foam::scalar Foam::WallFaceBase::dist(TrackingData& td) const +inline Foam::scalar Foam::wallFace::dist(TrackingData& td) const { return valid(td) ? sqrt(distSqr_) : great; } -template template -inline bool Foam::WallFaceBase::valid(TrackingData& td) const +inline bool Foam::wallFace::valid(TrackingData& td) const { return distSqr_ > -small; } -template template -inline bool Foam::WallFaceBase::sameGeometry +inline bool Foam::wallFace::sameGeometry ( - const polyMesh&, - const WallFaceBase& w2, + const wallFace& w2, const scalar tol, TrackingData& td ) const { - scalar diff = mag(distSqr() - w2.distSqr()); + const scalar diff = mag(distSqr() - w2.distSqr()); - if (diff < small) - { - return true; - } - else - { - if ((distSqr() > small) && ((diff/distSqr()) < tol)) - { - return true; - } - else - { - return false; - } - } + return + diff < small + || ((distSqr() > small) && (diff/distSqr() < tol)); } -template template -inline void Foam::WallFaceBase::transform +inline void Foam::wallFace::transform ( - const polyPatch& patch, - const label patchFacei, const transformer& transform, TrackingData& td ) { + // Note that distSqr_ is not affected by crossing an interface transform.transformPosition(points_, points_); } -template template -inline bool Foam::WallFaceBase::updateCell +inline bool Foam::wallFace::equal ( - const polyMesh& mesh, - const label thisCelli, - const label neighbourFacei, - const WallFaceBase& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return - static_cast(*this).update - ( - mesh.cellCentres()[thisCelli], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool Foam::WallFaceBase::updateFace -( - const polyMesh& mesh, - const label thisFacei, - const label neighbourCelli, - const WallFaceBase& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return - static_cast(*this).update - ( - mesh.faceCentres()[thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool Foam::WallFaceBase::updateFace -( - const polyMesh& mesh, - const label thisFacei, - const WallFaceBase& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return - static_cast(*this).update - ( - mesh.faceCentres()[thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool Foam::WallFaceBase::equal -( - const WallFaceBase& rhs, + const wallFace& rhs, TrackingData& td ) const { @@ -281,20 +186,18 @@ inline bool Foam::WallFaceBase::equal // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template -inline bool Foam::WallFaceBase::operator== +inline bool Foam::wallFace::operator== ( - const Foam::WallFaceBase& rhs + const Foam::wallFace& rhs ) const { return points() == rhs.points(); } -template -inline bool Foam::WallFaceBase::operator!= +inline bool Foam::wallFace::operator!= ( - const Foam::WallFaceBase& rhs + const Foam::wallFace& rhs ) const { return !(*this == rhs); @@ -303,15 +206,13 @@ inline bool Foam::WallFaceBase::operator!= // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -template -Foam::Ostream& Foam::operator<<(Ostream& os, const WallFaceBase& w) +Foam::Ostream& Foam::operator<<(Ostream& os, const wallFace& w) { return os << w.points() << token::SPACE << w.distSqr(); } -template -Foam::Istream& Foam::operator>>(Istream& is, WallFaceBase& w) +Foam::Istream& Foam::operator>>(Istream& is, wallFace& w) { return is >> w.points() >> w.distSqr(); } diff --git a/src/meshTools/patchDist/wallPoint/wallPoint.H b/src/meshTools/patchDist/WallLocation/wallPoint.H similarity index 59% rename from src/meshTools/patchDist/wallPoint/wallPoint.H rename to src/meshTools/patchDist/WallLocation/wallPoint.H index f2d7ec7325..04a4e72cbf 100644 --- a/src/meshTools/patchDist/wallPoint/wallPoint.H +++ b/src/meshTools/patchDist/WallLocation/wallPoint.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,24 +45,18 @@ namespace Foam { // Forward declaration of classes -class polyPatch; -class polyMesh; class transformer; // Forward declaration of friend functions and operators -template -class WallPointBase; -template -Ostream& operator<<(Ostream&, const WallPointBase&); -template -Istream& operator>>(Istream&, WallPointBase&); +class wallPoint; +Ostream& operator<<(Ostream&, const wallPoint&); +Istream& operator>>(Istream&, wallPoint&); /*---------------------------------------------------------------------------*\ - Class WallPointBase Declaration + Class wallPoint Declaration \*---------------------------------------------------------------------------*/ -template -class WallPointBase +class wallPoint { // Private Data @@ -78,13 +72,13 @@ protected: // Protected Member Functions //- Evaluate distance to point. Update distSqr, origin from whomever - // is nearer pt. Return true if w2 is closer to point, - // false otherwise. + // is nearer pt. Return true if w2 is closer to point, false + // otherwise. template inline bool update ( const point&, - const WallPointBase& w2, + const wallPoint& w2, const scalar tol, TrackingData& td ); @@ -95,13 +89,13 @@ public: // Constructors //- Construct null - inline WallPointBase(); + inline wallPoint(); //- Construct from origin, distance - inline WallPointBase(const point& origin, const scalar distSqr); + inline wallPoint(const point& origin, const scalar distSqr); //- Construct from face, distance - inline WallPointBase + inline wallPoint ( const face& f, const pointField& ps, @@ -137,8 +131,7 @@ public: template inline bool sameGeometry ( - const polyMesh&, - const WallPointBase&, + const wallPoint&, const scalar, TrackingData& td ) const; @@ -147,102 +140,32 @@ public: template inline void transform ( - const polyPatch& patch, - const label patchFacei, const transformer& transform, TrackingData& td ); - //- Influence of neighbouring face. - template - inline bool updateCell - ( - const polyMesh&, - const label thisCelli, - const label neighbourFacei, - const WallPointBase& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of neighbouring cell. - template - inline bool updateFace - ( - const polyMesh&, - const label thisFacei, - const label neighbourCelli, - const WallPointBase& neighbourInfo, - const scalar tol, - TrackingData& td - ); - - //- Influence of different value on same face. - template - inline bool updateFace - ( - const polyMesh&, - const label thisFacei, - const WallPointBase& neighbourInfo, - const scalar tol, - TrackingData& td - ); - //- Same (like operator==) template inline bool equal ( - const WallPointBase&, + const wallPoint&, TrackingData& td ) const; // Member Operators - inline bool operator==(const WallPointBase&) const; - inline bool operator!=(const WallPointBase&) const; + inline bool operator==(const wallPoint&) const; + inline bool operator!=(const wallPoint&) const; // IOstream Operators - friend Ostream& operator<< - ( - Ostream&, - const WallPointBase& - ); - - friend Istream& operator>> - ( - Istream&, - WallPointBase& - ); + inline friend Ostream& operator<<(Ostream&, const wallPoint&); + inline friend Istream& operator>>(Istream&, wallPoint&); }; -/*---------------------------------------------------------------------------*\ - Class wallPoint Declaration -\*---------------------------------------------------------------------------*/ - -class wallPoint -: - public WallPointBase -{ - public: - - using WallPointBase::WallPointBase; - - template using type = WallPointBase; -}; - - -//- Data associated with wallPoint type are contiguous -template<> -inline bool contiguous() -{ - return true; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/meshTools/patchDist/wallPoint/wallPointI.H b/src/meshTools/patchDist/WallLocation/wallPointI.H similarity index 50% rename from src/meshTools/patchDist/wallPoint/wallPointI.H rename to src/meshTools/patchDist/WallLocation/wallPointI.H index e88bfff619..715d9e0788 100644 --- a/src/meshTools/patchDist/wallPoint/wallPointI.H +++ b/src/meshTools/patchDist/WallLocation/wallPointI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,18 +24,16 @@ License \*---------------------------------------------------------------------------*/ #include "wallPoint.H" -#include "polyMesh.H" #include "transformer.H" #include "SubField.H" // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -template template -inline bool Foam::WallPointBase::update +inline bool Foam::wallPoint::update ( const point& pt, - const WallPointBase& w2, + const wallPoint& w2, const scalar tol, TrackingData& td ) @@ -69,16 +67,14 @@ inline bool Foam::WallPointBase::update // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -inline Foam::WallPointBase::WallPointBase() +inline Foam::wallPoint::wallPoint() : origin_(point::max), distSqr_(-great) {} -template -inline Foam::WallPointBase::WallPointBase +inline Foam::wallPoint::wallPoint ( const point& origin, const scalar distSqr @@ -89,8 +85,7 @@ inline Foam::WallPointBase::WallPointBase {} -template -inline Foam::WallPointBase::WallPointBase +inline Foam::wallPoint::wallPoint ( const face& f, const pointField& points, @@ -105,86 +100,63 @@ inline Foam::WallPointBase::WallPointBase // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -inline const Foam::point& Foam::WallPointBase::origin() const +inline const Foam::point& Foam::wallPoint::origin() const { return origin_; } -template -inline Foam::point& Foam::WallPointBase::origin() +inline Foam::point& Foam::wallPoint::origin() { return origin_; } -template -inline Foam::scalar Foam::WallPointBase::distSqr() const +inline Foam::scalar Foam::wallPoint::distSqr() const { return distSqr_; } -template -inline Foam::scalar& Foam::WallPointBase::distSqr() +inline Foam::scalar& Foam::wallPoint::distSqr() { return distSqr_; } -template template -inline Foam::scalar Foam::WallPointBase::dist(TrackingData& td) const +inline Foam::scalar Foam::wallPoint::dist(TrackingData& td) const { return valid(td) ? sqrt(distSqr_) : great; } -template template -inline bool Foam::WallPointBase::valid(TrackingData& td) const +inline bool Foam::wallPoint::valid(TrackingData& td) const { return distSqr_ > -small; } -template template -inline bool Foam::WallPointBase::sameGeometry +inline bool Foam::wallPoint::sameGeometry ( - const polyMesh&, - const WallPointBase& w2, + const wallPoint& w2, const scalar tol, TrackingData& td ) const { - scalar diff = mag(distSqr() - w2.distSqr()); + const scalar diff = mag(distSqr() - w2.distSqr()); - if (diff < small) - { - return true; - } - else - { - if ((distSqr() > small) && ((diff/distSqr()) < tol)) - { - return true; - } - else - { - return false; - } - } + return + diff < small + || ((distSqr() > small) && (diff/distSqr() < tol)); } -template template -inline void Foam::WallPointBase::transform +inline void Foam::wallPoint::transform ( - const polyPatch& patch, - const label patchFacei, const transformer& transform, TrackingData& td ) @@ -194,79 +166,10 @@ inline void Foam::WallPointBase::transform } -template template -inline bool Foam::WallPointBase::updateCell +inline bool Foam::wallPoint::equal ( - const polyMesh& mesh, - const label thisCelli, - const label neighbourFacei, - const WallPointBase& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return - static_cast(*this).update - ( - mesh.cellCentres()[thisCelli], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool Foam::WallPointBase::updateFace -( - const polyMesh& mesh, - const label thisFacei, - const label neighbourCelli, - const WallPointBase& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return - static_cast(*this).update - ( - mesh.faceCentres()[thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool Foam::WallPointBase::updateFace -( - const polyMesh& mesh, - const label thisFacei, - const WallPointBase& neighbourWallInfo, - const scalar tol, - TrackingData& td -) -{ - return - static_cast(*this).update - ( - mesh.faceCentres()[thisFacei], - neighbourWallInfo, - tol, - td - ); -} - - -template -template -inline bool Foam::WallPointBase::equal -( - const WallPointBase& rhs, + const wallPoint& rhs, TrackingData& td ) const { @@ -276,20 +179,18 @@ inline bool Foam::WallPointBase::equal // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template -inline bool Foam::WallPointBase::operator== +inline bool Foam::wallPoint::operator== ( - const Foam::WallPointBase& rhs + const Foam::wallPoint& rhs ) const { return origin() == rhs.origin(); } -template -inline bool Foam::WallPointBase::operator!= +inline bool Foam::wallPoint::operator!= ( - const Foam::WallPointBase& rhs + const Foam::wallPoint& rhs ) const { return !(*this == rhs); @@ -298,15 +199,13 @@ inline bool Foam::WallPointBase::operator!= // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -template -Foam::Ostream& Foam::operator<<(Ostream& os, const WallPointBase& w) +inline Foam::Ostream& Foam::operator<<(Ostream& os, const wallPoint& w) { return os << w.origin() << token::SPACE << w.distSqr(); } -template -Foam::Istream& Foam::operator>>(Istream& is, WallPointBase& w) +inline Foam::Istream& Foam::operator>>(Istream& is, wallPoint& w) { return is >> w.origin() >> w.distSqr(); } diff --git a/src/meshTools/patchDist/patchDistWave/patchDistWave.C b/src/meshTools/patchDist/patchDistWave/patchDistWave.C index e60a213419..7fb641b9d2 100644 --- a/src/meshTools/patchDist/patchDistWave/patchDistWave.C +++ b/src/meshTools/patchDist/patchDistWave/patchDistWave.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,6 +26,7 @@ License #include "patchDistWave.H" #include "FaceCellWave.H" #include "wallPoint.H" +#include "WallInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,18 +73,18 @@ Foam::label Foam::patchDistWave::wave ) { // Initialise changedFacesInfo to face centres on patches - List changedFacesInfo(changedFaces.size()); + List> changedFacesInfo(changedFaces.size()); forAll(changedFaces, changedFacei) { const label facei = changedFaces[changedFacei]; changedFacesInfo[changedFacei] = - wallPoint(mesh.faceCentres()[facei], scalar(0)); + WallInfo(mesh.faceCentres()[facei], scalar(0)); } // Do calculate patch distance by 'growing' from faces. - List faceInfo(mesh.nFaces()), cellInfo(mesh.nCells()); - FaceCellWave wave + List> faceInfo(mesh.nFaces()), cellInfo(mesh.nCells()); + FaceCellWave> wave ( mesh, changedFaces,