From 4eb9f9caaba60c60ca8d8e0ccc1a905dbfc5f500 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Wed, 28 Sep 2016 16:59:57 +0100 Subject: [PATCH 1/2] ENH: wallDist - added option to evaluate every XXX steps --- .../fvMesh/wallDist/wallDist/wallDist.C | 30 ++++++++++++++++--- .../fvMesh/wallDist/wallDist/wallDist.H | 12 +++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index ae5be722b1..7d53f566b2 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 | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -98,7 +98,13 @@ Foam::wallDist::wallDist(const fvMesh& mesh, const word& patchTypeName) static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") .lookupOrDefault<Switch>("nRequired", false) ), - n_(volVectorField::null()) + n_(volVectorField::null()), + updateInterval_ + ( + static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") + .lookupOrDefault<label>("updateInterval", 1) + ), + requireUpdate_(true) { if (nRequired_) { @@ -146,7 +152,13 @@ Foam::wallDist::wallDist static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") .lookupOrDefault<Switch>("nRequired", false) ), - n_(volVectorField::null()) + n_(volVectorField::null()), + updateInterval_ + ( + static_cast<const fvSchemes&>(mesh).subDict(patchTypeName_ & "Dist") + .lookupOrDefault<label>("updateInterval", 1) + ), + requireUpdate_(true) { if (nRequired_) { @@ -185,8 +197,17 @@ const Foam::volVectorField& Foam::wallDist::n() const bool Foam::wallDist::movePoints() { - if (pdm_->movePoints()) + if ((mesh_.time().timeIndex() % updateInterval_) == 0) { + requireUpdate_ = true; + } + + if (requireUpdate_ && pdm_->movePoints()) + { + DebugInfo<< "Updating wall distance" << endl; + + requireUpdate_ = false; + if (nRequired_) { return pdm_->correct(y_, n_.ref()); @@ -206,6 +227,7 @@ bool Foam::wallDist::movePoints() void Foam::wallDist::updateMesh(const mapPolyMesh& mpm) { pdm_->updateMesh(mpm); + requireUpdate_ = true; movePoints(); } diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H index 9d4f0263b4..4cddaaa476 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.H @@ -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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,6 +37,10 @@ Description // Optional entry enabling the calculation // of the normal-to-wall field nRequired false; + + // Optional entry delaying wall distance update to every n steps + // Default is 1 (update every step) + updateInterval 5; } \endverbatim @@ -90,6 +94,12 @@ class wallDist //- Normal-to-wall field mutable tmp<volVectorField> n_; + //- Update wall distance every updateInterval_ steps + const label updateInterval_; + + //- Flag to indicate whether the wall distance requires updating + bool requireUpdate_; + // Private Member Functions -- GitLab From 3f308d58b44dbdb59c184e9329530e08440a14d2 Mon Sep 17 00:00:00 2001 From: Andrew Heather <a.heather@opencfd.co.uk> Date: Fri, 30 Sep 2016 11:47:38 +0100 Subject: [PATCH 2/2] ENH: wallDist - suppress calc if updateInterval is zero --- src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C index 7d53f566b2..d13c2bed1a 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDist/wallDist.C @@ -197,7 +197,11 @@ const Foam::volVectorField& Foam::wallDist::n() const bool Foam::wallDist::movePoints() { - if ((mesh_.time().timeIndex() % updateInterval_) == 0) + if + ( + (updateInterval_ != 0) + && ((mesh_.time().timeIndex() % updateInterval_) == 0) + ) { requireUpdate_ = true; } @@ -227,6 +231,11 @@ bool Foam::wallDist::movePoints() void Foam::wallDist::updateMesh(const mapPolyMesh& mpm) { pdm_->updateMesh(mpm); + + // Force update if performing topology change + // Note: needed? + // - field would have been mapped, so if using updateInterval option (!= 1) + // live with error associated of not updating and use mapped values? requireUpdate_ = true; movePoints(); } -- GitLab