From 5dff7076ceb114643a784e2598741484b0d06375 Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Fri, 9 Jan 2015 21:41:21 +0000 Subject: [PATCH] wallDist: moved patchTypes into patchDistMethod --- .../advectionDiffusionPatchDistMethod.C | 85 +++++++------------ .../patchDistMethod/patchDistMethod.H | 41 ++++++++- .../fvMesh/wallDist/wallDist/wallDist.C | 26 +----- .../fvMesh/wallDist/wallDist/wallDist.H | 5 -- 4 files changed, 72 insertions(+), 85 deletions(-) diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C index caf45bdf4b2..85100b39ecc 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C @@ -67,8 +67,8 @@ Foam::patchDistMethods::advectionDiffusion::advectionDiffusion ) ), epsilon_(coeffs_.lookupOrDefault<scalar>("epsilon", 0.1)), - maxIter_(coeffs_.lookupOrDefault<int>("maxIter", 10)), - tolerance_(coeffs_.lookupOrDefault<scalar>("tolerance", 1e-3)) + tolerance_(coeffs_.lookupOrDefault<scalar>("tolerance", 1e-3)), + maxIter_(coeffs_.lookupOrDefault<int>("maxIter", 10)) {} @@ -79,30 +79,6 @@ bool Foam::patchDistMethods::advectionDiffusion::correct(volScalarField& y) return correct(y, const_cast<volVectorField&>(volVectorField::null())); } -namespace Foam -{ -template<class Type> -wordList 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; -} -} - bool Foam::patchDistMethods::advectionDiffusion::correct ( @@ -112,36 +88,38 @@ bool Foam::patchDistMethods::advectionDiffusion::correct { pdmPredictor_->correct(y); + volVectorField ny + ( + IOobject + ( + "ny", + mesh_.time().timeName(), + mesh_ + ), + mesh_, + dimensionedVector("nWall", dimless, vector::zero), + patchTypes<vector>(mesh_, patchIDs_) + ); + + const fvPatchList& patches = mesh_.boundary(); + + forAllConstIter(labelHashSet, patchIDs_, iter) + { + label patchi = iter.key(); + ny.boundaryField()[patchi] == -patches[patchi].nf(); + } + int iter = 0; scalar initialResidual = 0; do { - volVectorField ny - ( - IOobject - ( - "ny", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedVector("nWall", dimless, vector::zero), - patchTypes<vector>(mesh_, patchIDs_) - ); - - const fvPatchList& patches = mesh_.boundary(); - - forAllConstIter(labelHashSet, patchIDs_, iter) - { - label patchi = iter.key(); - ny.boundaryField()[patchi] == -patches[patchi].nf(); - } - ny = fvc::grad(y); ny /= (mag(ny) + SMALL); + surfaceVectorField nf(fvc::interpolate(ny)); nf /= (mag(nf) + SMALL); + surfaceScalarField yPhi("yPhi", mesh_.Sf() & nf); fvScalarMatrix yEqn @@ -155,15 +133,14 @@ bool Foam::patchDistMethods::advectionDiffusion::correct yEqn.relax(); initialResidual = yEqn.solve().initialResidual(); - - // Only calculate n if the field is defined - if (notNull(n)) - { - n = -ny; - } - } while (initialResidual > tolerance_ && ++iter < maxIter_); + // Only calculate n if the field is defined + if (notNull(n)) + { + n = -ny; + } + return true; } diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H index 27b6036d75a..7be7ff41a50 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/patchDistMethod/patchDistMethod.H @@ -39,9 +39,10 @@ SourceFiles #include "HashSet.H" #include "volFieldsFwd.H" #include "mapPolyMesh.H" +#include "fixedValueFvPatchFields.H" +#include "zeroGradientFvPatchFields.H" #include "runTimeSelectionTables.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -66,7 +67,6 @@ protected: //- Set of patch IDs const labelHashSet patchIDs_; - private: // Private Member Functions @@ -124,6 +124,18 @@ public: virtual ~patchDistMethod(); + // Static Functions + + //- 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 + ( + const fvMesh& mesh, + const labelHashSet& patchIDs + ); + + // Member Functions //- Return the patchIDs @@ -154,6 +166,31 @@ 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; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index f704aba4436..d5c9e31b4e1 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C @@ -25,8 +25,6 @@ License #include "wallDist.H" #include "wallPolyPatch.H" -#include "fixedValueFvPatchFields.H" -#include "zeroGradientFvPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -36,26 +34,6 @@ namespace Foam } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template<class Type> -Foam::wordList Foam::wallDist::patchTypes(const labelHashSet& patchIDs) const -{ - wordList yTypes - ( - mesh().boundary().size(), - zeroGradientFvPatchField<Type>::typeName - ); - - forAllConstIter(labelHashSet, patchIDs, iter) - { - yTypes[iter.key()] = fixedValueFvPatchField<Type>::typeName; - } - - return yTypes; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::wallDist::wallDist(const fvMesh& mesh) @@ -80,7 +58,7 @@ Foam::wallDist::wallDist(const fvMesh& mesh) ), mesh, dimensionedScalar("yWall", dimLength, SMALL), - patchTypes<scalar>(pdm_->patchIDs()) + patchDistMethod::patchTypes<scalar>(mesh, pdm_->patchIDs()) ), n_(NULL) { @@ -98,7 +76,7 @@ Foam::wallDist::wallDist(const fvMesh& mesh) ), mesh, dimensionedVector("nWall", dimless, vector::zero), - patchTypes<vector>(pdm_->patchIDs()) + patchDistMethod::patchTypes<vector>(mesh, pdm_->patchIDs()) ) ); diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H index 60dfc804490..683a8c095fa 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H @@ -68,11 +68,6 @@ class wallDist // Private Member Functions - //- Return the patch types for y and n - // These are fixedValue for the set provided otherwise zero-gradient - template<class Type> - wordList patchTypes(const labelHashSet& patchIDs) const; - //- Disallow default bitwise copy construct wallDist(const wallDist&); -- GitLab