diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C index 617671bef48506fdd488806c357bc5caf9909971..c4c6432e116d8efcbbbfab05497efe378d9ccc40 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -77,6 +77,36 @@ Foam::autoPtr<Foam::patchDistMethod> Foam::patchDistMethod::New } + +Foam::autoPtr<Foam::patchDistMethod> Foam::patchDistMethod::New +( + const dictionary& dict, + const fvMesh& mesh, + const labelHashSet& patchIDs, + const word& defaultPatchDistMethod +) +{ + word patchDistMethodType = defaultPatchDistMethod; + dict.readIfPresent("method", patchDistMethodType); + + Info<< "Selecting patchDistMethod " << patchDistMethodType << endl; + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(patchDistMethodType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown patchDistMethodType type " + << patchDistMethodType << endl << endl + << "Valid patchDistMethod types are : " << endl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return cstrIter()(dict, mesh, patchIDs); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::patchDistMethod::~patchDistMethod() diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H index 6f23e3ae7efb815f9844c30be349105147e800e5..573a1a45399cd0271919e2ac479854a88bb209a6 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -118,6 +118,14 @@ public: const labelHashSet& patchIDs ); + static autoPtr<patchDistMethod> New + ( + const dictionary& dict, + const fvMesh& mesh, + const labelHashSet& patchIDs, + const word& defaultPatchDistMethod + ); + //- Destructor virtual ~patchDistMethod(); diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index cab438a468f5326372e47c6532d8c15824df9cc6..498daf163758f5705b633ce54c1f0a48bbd93be8 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,17 +68,28 @@ void Foam::wallDist::constructn() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName) +Foam::wallDist::wallDist +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const word& patchTypeName +) : MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh), - patchIDs_(mesh.boundaryMesh().findPatchIDs<wallPolyPatch>()), + patchIDs_(patchIDs), patchTypeName_(patchTypeName), + dict_ + ( + static_cast<const fvSchemes&>(mesh).subOrEmptyDict + ( + patchTypeName_ & "Dist" + ) + ), pdm_ ( patchDistMethod::New ( - static_cast<const fvSchemes&>(mesh) - .subDict(patchTypeName_ & "Dist"), + dict_, mesh, patchIDs_ ) @@ -95,17 +106,9 @@ Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName) dimensionedScalar("y" & patchTypeName_, dimLength, SMALL), patchDistMethod::patchTypes<scalar>(mesh, patchIDs_) ), - nRequired_ - ( - static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") - .lookupOrDefault<Switch>("nRequired", false) - ), + nRequired_(dict_.lookupOrDefault<Switch>("nRequired", false)), n_(volVectorField::null()), - updateInterval_ - ( - static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") - .lookupOrDefault<label>("updateInterval", 1) - ), + updateInterval_(dict_.lookupOrDefault<label>("updateInterval", 1)), requireUpdate_(true) { if (nRequired_) @@ -120,6 +123,7 @@ Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName) Foam::wallDist::wallDist ( const fvMesh& mesh, + const word& defaultPatchDistMethod, const labelHashSet& patchIDs, const word& patchTypeName ) @@ -127,14 +131,21 @@ Foam::wallDist::wallDist MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh), patchIDs_(patchIDs), patchTypeName_(patchTypeName), + dict_ + ( + static_cast<const fvSchemes&>(mesh).subOrEmptyDict + ( + patchTypeName_ & "Dist" + ) + ), pdm_ ( patchDistMethod::New ( - static_cast<const fvSchemes&>(mesh) - .subDict(patchTypeName_ & "Dist"), + dict_, mesh, - patchIDs_ + patchIDs_, + defaultPatchDistMethod ) ), y_ @@ -149,17 +160,9 @@ Foam::wallDist::wallDist dimensionedScalar("y" & patchTypeName_, dimLength, SMALL), patchDistMethod::patchTypes<scalar>(mesh, patchIDs_) ), - nRequired_ - ( - static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") - .lookupOrDefault<Switch>("nRequired", false) - ), + nRequired_(dict_.lookupOrDefault<Switch>("nRequired", false)), n_(volVectorField::null()), - updateInterval_ - ( - static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") - .lookupOrDefault<label>("updateInterval", 1) - ), + updateInterval_(dict_.lookupOrDefault<label>("updateInterval", 1)), requireUpdate_(true) { if (nRequired_) @@ -171,6 +174,17 @@ Foam::wallDist::wallDist } +Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName) +: + wallDist + ( + mesh, + mesh.boundaryMesh().findPatchIDs<wallPolyPatch>(), + patchTypeName + ) +{} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::wallDist::~wallDist() diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H index 5d0aa325fd88993a948e385d0f6f6ea4e78cc771..11a17c3d3328c3bc36afe1a44c4b2f18c5ba2c13 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H @@ -82,6 +82,9 @@ class wallDist //- Name for the patch set, e.g. "wall" const word patchTypeName_; + //- Construction dictionary + const dictionary dict_; + //- Run-time selected method to generate the distance-to-wall field mutable autoPtr<patchDistMethod> pdm_; @@ -121,21 +124,31 @@ public: // Constructors - //- Construct from mesh and optional patch type name + //- Construct from mesh, patch IDs and optional patch type name wallDist ( const fvMesh& mesh, - const word& patchTypeName = "wall" + const labelHashSet& patchIDs, + const word& patchTypeName = "patch" ); - //- Construct from mesh, patch IDs and optional patch type name + //- Construct from mesh, patch IDs, default patch distance method + // and optional patch type name wallDist ( const fvMesh& mesh, + const word& defaultPatchDistMethod, const labelHashSet& patchIDs, const word& patchTypeName = "patch" ); + //- Construct from mesh and optional patch type name + wallDist + ( + const fvMesh& mesh, + const word& patchTypeName = "wall" + ); + //- Destructor virtual ~wallDist(); diff --git a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C index d628d09563df40f00612cf0d83562d0a97990713..387bdbdbdaf60f068aafccc8c8e2893ec0d6e34a 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C +++ b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C @@ -30,6 +30,7 @@ License #include "surfaceInterpolate.H" #include "zeroGradientFvPatchFields.H" #include "wallDist.H" +#include "meshWavePatchDistMethod.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -72,12 +73,13 @@ Foam::inverseDistanceDiffusivity::~inverseDistanceDiffusivity() void Foam::inverseDistanceDiffusivity::correct() { faceDiffusivity_ = - 1.0 + dimensionedScalar("one", dimLength, 1) /fvc::interpolate ( wallDist::New ( mesh(), + patchDistMethods::meshWave::typeName, mesh().boundaryMesh().patchSet(patchNames_) ).y() );