From a5f7fb6ad265ae846b9c85cf01b39433ca5b1a0a Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Tue, 22 Mar 2022 13:44:04 +0000 Subject: [PATCH] BUG: blendingFactor: fix DEShybrid blending-factor inconsistency (fixes #2419) --- src/functionObjects/field/Make/options | 2 + .../field/blendingFactor/blendingFactor.H | 50 ++++++------------- .../blendingFactor/blendingFactorTemplates.C | 17 +++++-- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/functionObjects/field/Make/options b/src/functionObjects/field/Make/options index a99cf3db84..cc5819e29c 100644 --- a/src/functionObjects/field/Make/options +++ b/src/functionObjects/field/Make/options @@ -14,6 +14,7 @@ EXE_INC = \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/schemes/lnInclude \ -I$(LIB_SRC)/transportModels/compressible/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ @@ -39,6 +40,7 @@ LIB_LIBS = \ -lcompressibleTransportModels \ -lincompressibleTurbulenceModels \ -lcompressibleTurbulenceModels \ + -lturbulenceModelSchemes \ -lchemistryModel \ -lreactionThermophysicalModels \ -lpairPatchAgglomeration diff --git a/src/functionObjects/field/blendingFactor/blendingFactor.H b/src/functionObjects/field/blendingFactor/blendingFactor.H index ba5e09aa36..c93cbc5fcd 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactor.H +++ b/src/functionObjects/field/blendingFactor/blendingFactor.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,26 +31,14 @@ Group grpFieldFunctionObjects Description - Computes the blending coefficient employed by blended divergence schemes, - giving an indicator as to which of the schemes is active across the domain. + Computes blending factor as an indicator about which + of the schemes is active across the domain. - Blended schemes combine contributions from two schemes, i.e. \f$\phi_1\f$ - and \f$\phi_2\f$, using a weight field, i.e. \f$w\f$, such that the - effective scheme value, i.e. \f$\phi_{eff}\f$, is computed as follows: - - \f[ - \phi_{eff} = w \phi_1 + (1 - w) \phi_2 - \f] - - The weight field, i.e. \f$w\f$, is surface field and converted to a volume - field for easier post-processing by setting the cell value to one minus - the minimum of the face values. - - This conversion leads to blending indicator field whose values mean: + Blending factor values mean: \verbatim 0 = scheme 0 1 = scheme 1 - 0-1 = a blend between scheme 0 and scheme 1 + 0-1 = a blending factor between scheme 0 and scheme 1 \endverbatim Operands: @@ -66,30 +54,28 @@ Usage \verbatim blendingFactor1 { - // Mandatory entries (unmodifiable) + // Mandatory entries type blendingFactor; libs (fieldFunctionObjects); - - // Mandatory (inherited) entry (runtime modifiable) field ; - // Optional entries (runtime modifiable) + // Optional entries phi phi; tolerance 0.001; - // Optional (inherited) entries + // Inherited entries ... } \endverbatim where the entries mean: \table - Property | Description | Type | Req'd | Deflt - type | Type name: blendingFactor | word | yes | - - libs | Library name: fieldFunctionObjects | word | yes | - - field | Name of the operand field | word | yes | - - phi | Name of flux field | word | no | phi - tolerance | Tolerance for number of blended cells | scalar | no | 0.001 + Property | Description | Type | Reqd | Deflt + type | Type name: blendingFactor | word | yes | - + libs | Library name: fieldFunctionObjects | word | yes | - + field | Name of the operand field | word | yes | - + phi | Name of flux field | word | no | phi + tolerance | Tolerance for number of blended cells | scalar | no | 0.001 \endtable The inherited entries are elaborated in: @@ -99,14 +85,6 @@ Usage Usage by the \c postProcess utility is not available. -See also - - Foam::functionObject - - Foam::functionObjects::fieldExpression - - Foam::functionObjects::fvMeshFunctionObject - - Foam::functionObjects::writeFile - - Foam::CoBlended - - ExtendedCodeGuide::functionObjects::field::blendingFactor - SourceFiles blendingFactor.C blendingFactorTemplates.C diff --git a/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C b/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C index 2eb39896c2..e238f4677e 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C +++ b/src/functionObjects/field/blendingFactor/blendingFactorTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,6 +30,7 @@ License #include "boundedConvectionScheme.H" #include "blendedSchemeBase.H" #include "fvcCellReduce.H" +#include "DEShybrid.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,12 +73,18 @@ void Foam::functionObjects::blendingFactor::calcBlendingFactor // Convert into vol field whose values represent the local face minima // Note: - // - factor applied to 1st scheme, and (1-factor) to 2nd scheme // - not using the store(...) mechanism due to need to correct BCs - volScalarField& indicator = - lookupObjectRef(resultName_); + auto& indicator = lookupObjectRef(resultName_); + + if (isA>(blendedScheme)) + { + indicator = fvc::cellReduce(factorf, minEqOp(), GREAT); + } + else + { + indicator = 1 - fvc::cellReduce(factorf, minEqOp(), GREAT); + } - indicator = 1 - fvc::cellReduce(factorf, minEqOp(), GREAT); indicator.correctBoundaryConditions(); }