diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H index f7166470af..be2fe747ad 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactor.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,6 +88,8 @@ SourceFiles #include "OFstream.H" #include "Switch.H" +#include "convectionScheme.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -140,6 +142,14 @@ class blendingFactor //- Disallow default bitwise assignment void operator=(const blendingFactor&); + //- Helper function to calculate the blending factor for the scheme + template + void calcScheme + ( + const GeometricField& field, + const typename fv::convectionScheme& cs + ); + //- Calculate the blending factor template void calc(); diff --git a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C index 26832a892d..7031607bd4 100644 --- a/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C +++ b/src/postProcessing/functionObjects/utilities/blendingFactor/blendingFactorTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "gaussConvectionScheme.H" +#include "boundedConvectionScheme.H" #include "blendedSchemeBase.H" #include "fvcCellReduce.H" #include "zeroGradientFvPatchFields.H" @@ -31,39 +32,35 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::blendingFactor::calc() +void Foam::blendingFactor::calcScheme +( + const GeometricField& field, + const typename fv::convectionScheme& cs +) { - typedef GeometricField fieldType; - - if (!obr_.foundObject(fieldName_)) + if (!isA>(cs)) { + WarningInFunction + << "Scheme for field " << field.name() << " is not a " + << fv::gaussConvectionScheme::typeName + << " scheme. Not calculating " << resultName_ << endl; + return; } - const fvMesh& mesh = refCast(obr_); - - const fieldType& field = mesh.lookupObject(fieldName_); - - const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')'); - ITstream& its = mesh.divScheme(divScheme); - - const surfaceScalarField& phi = - mesh.lookupObject(phiName_); - - tmp> cs = - fv::convectionScheme::New(mesh, phi, its); - const fv::gaussConvectionScheme& gcs = - refCast>(cs()); + refCast>(cs); - const surfaceInterpolationScheme& interpScheme = - gcs.interpScheme(); + + const surfaceInterpolationScheme& interpScheme = gcs.interpScheme(); if (!isA>(interpScheme)) { - FatalErrorInFunction - << interpScheme.typeName << " is not a blended scheme" - << exit(FatalError); + WarningInFunction + << interpScheme.type() << " is not a blended scheme" + << ". Not calculating " << resultName_ << endl; + + return; } // Retrieve the face-based blending factor @@ -123,4 +120,46 @@ void Foam::blendingFactor::calc() } +template +void Foam::blendingFactor::calc() +{ + typedef GeometricField fieldType; + + if (!obr_.foundObject(fieldName_)) + { + return; + } + + const fvMesh& mesh = refCast(obr_); + + const fieldType& field = mesh.lookupObject(fieldName_); + + const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')'); + ITstream& its = mesh.divScheme(divScheme); + + const surfaceScalarField& phi = + mesh.lookupObject(phiName_); + + tmp> tcs = + fv::convectionScheme::New(mesh, phi, its); + + const fv::convectionScheme& cs = tcs(); + + if (isA>(cs)) + { + const fv::boundedConvectionScheme& bcs = + refCast>(cs); + + calcScheme(field, bcs.scheme()); + } + else + { + const fv::gaussConvectionScheme& gcs = + refCast>(cs); + + calcScheme(field, gcs); + } +} + + // ************************************************************************* //