diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H index 7be7ff41a501d7948f36dd4bb90e62a8bd2940c4..1ba9585ba04315bbbdbf666613886c2c897a113d 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H @@ -77,7 +77,6 @@ private: //- Disallow default bitwise assignment void operator=(const patchDistMethod&); - public: //- Runtime type information @@ -129,7 +128,7 @@ public: //- Return the patch types for y and n // These are fixedValue for the set provided otherwise zero-gradient template<class Type> - static inline wordList patchTypes + static wordList patchTypes ( const fvMesh& mesh, const labelHashSet& patchIDs @@ -166,30 +165,11 @@ public: } // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Static Functions * * * * * * * * * * * * * // - -template<class Type> -inline Foam::wordList Foam::patchDistMethod::patchTypes -( - const fvMesh& mesh, - const labelHashSet& patchIDs -) -{ - wordList yTypes - ( - mesh.boundary().size(), - zeroGradientFvPatchField<Type>::typeName - ); - - forAllConstIter(labelHashSet, patchIDs, iter) - { - yTypes[iter.key()] = fixedValueFvPatchField<Type>::typeName; - } - - return yTypes; -} - +#ifdef NoRepository +# include "patchDistMethodTemplates.C" +#endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index ae2ba96a1ff54f9f9d58cb0a3a642a05d16412bc..d66be01bf9bee7d93f779d1a8857d3d0f21bb828 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C @@ -44,20 +44,19 @@ void Foam::wallDist::constructn() const ( IOobject ( - "nWall", + "n" & patchTypeName_, mesh().time().timeName(), mesh() ), mesh(), - dimensionedVector("nWall", dimless, vector::zero), - patchDistMethod::patchTypes<vector>(mesh(), pdm_->patchIDs()) + dimensionedVector("n" & patchTypeName_, dimless, vector::zero), + patchDistMethod::patchTypes<vector>(mesh(), patchIDs_) ) ); - const labelHashSet& patchIDs = pdm_->patchIDs(); const fvPatchList& patches = mesh().boundary(); - forAllConstIter(labelHashSet, patchIDs, iter) + forAllConstIter(labelHashSet, patchIDs_, iter) { label patchi = iter.key(); n_().boundaryField()[patchi] == patches[patchi].nf(); @@ -67,33 +66,84 @@ void Foam::wallDist::constructn() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::wallDist::wallDist(const fvMesh& mesh) +Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName) : MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh), + patchIDs_(mesh.boundaryMesh().findPatchIDs<wallPolyPatch>()), + patchTypeName_(patchTypeName), pdm_ ( patchDistMethod::New ( - static_cast<const fvSchemes&>(mesh).subDict("wallDist"), + static_cast<const fvSchemes&>(mesh) + .subDict(patchTypeName_ & "Dist"), mesh, - mesh.boundaryMesh().findPatchIDs<wallPolyPatch>() + patchIDs_ ) ), y_ ( IOobject ( - "yWall", + "y" & patchTypeName_, mesh.time().timeName(), mesh ), mesh, - dimensionedScalar("yWall", dimLength, SMALL), - patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs()) + dimensionedScalar("y" & patchTypeName_, dimLength, SMALL), + patchDistMethod::patchTypes<scalar>(mesh, patchIDs_) ), nRequired_ ( - static_cast<const fvSchemes&>(mesh).subDict("wallDist") + static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") + .lookupOrDefault<Switch>("nRequired", false) + ), + n_(volVectorField::null()) +{ + if (nRequired_) + { + constructn(); + } + + movePoints(); +} + + +Foam::wallDist::wallDist +( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const word& patchTypeName +) +: + MeshObject<fvMesh, Foam::UpdateableMeshObject, wallDist>(mesh), + patchIDs_(patchIDs), + patchTypeName_(patchTypeName), + pdm_ + ( + patchDistMethod::New + ( + static_cast<const fvSchemes&>(mesh) + .subDict(patchTypeName_ & "Dist"), + mesh, + patchIDs_ + ) + ), + y_ + ( + IOobject + ( + "y" & patchTypeName_, + mesh.time().timeName(), + mesh + ), + mesh, + dimensionedScalar("y" & patchTypeName_, dimLength, SMALL), + patchDistMethod::patchTypes<scalar>(mesh, patchIDs_) + ), + nRequired_ + ( + static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") .lookupOrDefault<Switch>("nRequired", false) ), n_(volVectorField::null()) @@ -120,8 +170,8 @@ const Foam::volVectorField& Foam::wallDist::n() const if (isNull(n_())) { WarningIn("Foam::wallDist::n()") - << "n requested but 'nRequired' not specified in the wallDist " - "dictionary" << nl + << "n requested but 'nRequired' not specified in the " + << (patchTypeName_ & "Dist") << " dictionary" << nl << " Recalculating y and n fields." << endl; nRequired_ = true; diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H index a609c903b974fa9e63041c33149bb9deec3df7a1..9d4f0263b427ad44e4bb59fb692b39a60ac5adfc 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H @@ -55,7 +55,6 @@ SourceFiles #include "MeshObject.H" #include "patchDistMethod.H" -#include "fvMesh.H" #include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -73,6 +72,12 @@ class wallDist { // Private data + //- Set of patch IDs + const labelHashSet patchIDs_; + + //- Name for the patch set, e.g. "wall" + const word patchTypeName_; + //- Run-time selected method to generate the distance-to-wall field mutable autoPtr<patchDistMethod> pdm_; @@ -106,8 +111,20 @@ public: // Constructors - //- Construct from mesh - wallDist(const fvMesh& mesh); + //- Construct from mesh and optional patch type name + wallDist + ( + const fvMesh& mesh, + const word& patchTypeName = "wall" + ); + + //- Construct from mesh, patch IDs and optional patch type name + wallDist + ( + const fvMesh& mesh, + const labelHashSet& patchIDs, + const word& patchTypeName = "patch" + ); //- Destructor @@ -116,6 +133,12 @@ public: // Member Functions + //- Return the patchIDs + const labelHashSet& patchIDs() const + { + return patchIDs_; + } + //- Return reference to cached distance-to-wall field const volScalarField& y() const {