diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C index 7dc5e6a6913608573f0ccbb949dc4c0a64d17b4d..e0d7ee43d4d3f346cd31dbde27e4343dda2ee6d0 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,36 +52,8 @@ Foam::patchDistMethod::patchDistMethod // * * * * * * * * * * * * * * * * Selector * * * * * * * * * * * * * * * * // -Foam::autoPtr<Foam::patchDistMethod> Foam::patchDistMethod::New -( - const dictionary& dict, - const fvMesh& mesh, - const labelHashSet& patchIDs -) -{ - const word modelType(dict.get<word>("method")); - - Info<< "Selecting patchDistMethod " << modelType << endl; - - auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); - - if (!cstrIter.found()) - { - FatalIOErrorInLookup - ( - dict, - "patchDistMethod", - modelType, - *dictionaryConstructorTablePtr_ - ) << exit(FatalIOError); - } - - return cstrIter()(dict, mesh, patchIDs); -} - - - -Foam::autoPtr<Foam::patchDistMethod> Foam::patchDistMethod::New +Foam::autoPtr<Foam::patchDistMethod> +Foam::patchDistMethod::New ( const dictionary& dict, const fvMesh& mesh, @@ -89,7 +61,14 @@ Foam::autoPtr<Foam::patchDistMethod> Foam::patchDistMethod::New const word& defaultPatchDistMethod ) { - const word modelType(dict.getOrDefault("method", defaultPatchDistMethod)); + word modelType(defaultPatchDistMethod); + dict.readEntry + ( + "method", + modelType, + keyType::REGEX, + modelType.empty() // Mandatory if no default was provided + ); Info<< "Selecting patchDistMethod " << modelType << endl; auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H index 921a7e9e9cbd583dd147a0c66317b191e2a83361..00a248d32185e3993ef3a2395bd64277d7317070 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,7 +59,6 @@ class fvMesh; class patchDistMethod { - protected: // Protected Member Data @@ -70,9 +69,8 @@ protected: //- Set of patch IDs const labelHashSet patchIDs_; -private: - // Private Member Functions + // Protected Member Functions //- No copy construct patchDistMethod(const patchDistMethod&) = delete; @@ -114,19 +112,13 @@ public: // Selectors - static autoPtr<patchDistMethod> New - ( - const dictionary& dict, - const fvMesh& mesh, - const labelHashSet& patchIDs - ); - + // Use "method" from dictionary, or defaultPatchDistMethod static autoPtr<patchDistMethod> New ( const dictionary& dict, const fvMesh& mesh, const labelHashSet& patchIDs, - const word& defaultPatchDistMethod + const word& defaultPatchDistMethod = word::null ); diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index 76799e2d50ab37c5a1a126afcd23eda9a2f1eea3..6e417d37a416cfe49b37b34492809bc8e3772c62 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,7 @@ namespace Foam void Foam::wallDist::constructn() const { - n_ = tmp<volVectorField> + n_.reset ( new volVectorField ( @@ -77,49 +77,8 @@ Foam::wallDist::wallDist const word& patchTypeName ) : - MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh), - patchIDs_(patchIDs), - patchTypeName_(patchTypeName), - dict_ - ( - static_cast<const fvSchemes&>(mesh).subOrEmptyDict - ( - patchTypeName_ & "Dist" - ) - ), - pdm_ - ( - patchDistMethod::New - ( - dict_, - mesh, - patchIDs_ - ) - ), - y_ - ( - IOobject - ( - "y" & patchTypeName_, - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar("y" & patchTypeName_, dimLength, SMALL), - patchDistMethod::patchTypes<scalar>(mesh, patchIDs_) - ), - nRequired_(dict_.getOrDefault("nRequired", false)), - n_(volVectorField::null()), - updateInterval_(dict_.getOrDefault<label>("updateInterval", 1)), - requireUpdate_(true) -{ - if (nRequired_) - { - constructn(); - } - - movePoints(); -} + wallDist(mesh, word::null, patchIDs, patchTypeName) +{} Foam::wallDist::wallDist @@ -162,9 +121,9 @@ Foam::wallDist::wallDist dimensionedScalar("y" & patchTypeName_, dimLength, SMALL), patchDistMethod::patchTypes<scalar>(mesh, patchIDs_) ), - nRequired_(dict_.getOrDefault("nRequired", false)), n_(volVectorField::null()), updateInterval_(dict_.getOrDefault<label>("updateInterval", 1)), + nRequired_(dict_.getOrDefault("nRequired", false)), requireUpdate_(true) { if (nRequired_) diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H index 6135783d75036a24cf9361dd3304bd40122532ff..2166777d9b9359b0ac9791d4ee8ed1fc9d123a18 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H @@ -94,15 +94,15 @@ class wallDist //- Distance-to-wall field mutable volScalarField y_; - //- Flag to indicate if the distance-to-wall field is required - mutable bool nRequired_; - //- Normal-to-wall field mutable tmp<volVectorField> n_; //- Update wall distance every updateInterval_ steps const label updateInterval_; + //- Flag to indicate if the distance-to-wall field is required + mutable bool nRequired_; + //- Flag to indicate whether the wall distance requires updating bool requireUpdate_;