From e28bed59e2e086f6b08d4bfeb5e8af5a6e220ed4 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Fri, 25 Mar 2022 14:58:31 +0000 Subject: [PATCH] BUG: DEShybrid: store the factor field on the mesh (fixes #2425) The blendingFactor function object overwrites the DEShybrid:Factor field internally when blendedSchemeBase debug flag is active. However, users are allowed to write out the original DEShybrid:Factor field by executing the writeObjects function object before any blendingFactor function object execution. --- .../schemes/DEShybrid/DEShybrid.H | 64 +++++++++++++------ .../field/blendingFactor/blendingFactor.H | 7 ++ 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H index 015b6122d3..9a19dee379 100644 --- a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H +++ b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -226,32 +226,60 @@ class DEShybrid ) ); - const volScalarField factor + + const word factorName(IOobject::scopedName(typeName, "Factor")); + const fvMesh& mesh = this->mesh(); + + const IOobject factorIO ( - IOobject - ( - typeName + ":Factor", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - max(sigmaMax_*tanh(pow(A, CH1_)), sigmaMin_) + factorName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE ); if (blendedSchemeBaseName::debug) { - factor.write(); - } + auto* factorPtr = mesh.getObjectPtr(factorName); - return tmp - ( - new surfaceScalarField + if (!factorPtr) + { + factorPtr = + new volScalarField + ( + factorIO, + mesh, + dimensionedScalar(dimless, Zero) + ); + + const_cast(mesh).objectRegistry::store(factorPtr); + } + + auto& factor = *factorPtr; + + factor = max(sigmaMax_*tanh(pow(A, CH1_)), sigmaMin_); + + return tmp::New ( vf.name() + "BlendingFactor", fvc::interpolate(factor) - ) - ); + ); + } + else + { + const volScalarField factor + ( + factorIO, + max(sigmaMax_*tanh(pow(A, CH1_)), sigmaMin_) + ); + + return tmp::New + ( + vf.name() + "BlendingFactor", + fvc::interpolate(factor) + ); + } } diff --git a/src/functionObjects/field/blendingFactor/blendingFactor.H b/src/functionObjects/field/blendingFactor/blendingFactor.H index c93cbc5fcd..841994e144 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactor.H +++ b/src/functionObjects/field/blendingFactor/blendingFactor.H @@ -85,6 +85,13 @@ Usage Usage by the \c postProcess utility is not available. +Note + - The \c blendingFactor function object overwrites the \c DEShybrid:Factor + field internally when \c blendedSchemeBase debug flag is active. + However, users are allowed to write out the original \c DEShybrid:Factor + field by executing the \c writeObjects function object before + any \c blendingFactor function object execution. + SourceFiles blendingFactor.C blendingFactorTemplates.C