From 42e42a1466f2915d143de41e231f12b272096551 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 30 Apr 2015 22:22:37 +0100 Subject: [PATCH] viewFactorsGen: Handle baffles Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1680 --- .../viewFactorsGen/viewFactorsGen.C | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C b/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C index e374e196..b1d1321c 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C +++ b/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,6 +69,7 @@ Description using namespace Foam; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // triSurface triangulate ( @@ -208,19 +209,27 @@ scalar calculateViewFactorFij { vector r = i - j; scalar rMag = mag(r); - scalar dAiMag = mag(dAi); - scalar dAjMag = mag(dAj); - vector ni = dAi/dAiMag; - vector nj = dAj/dAjMag; - scalar cosThetaJ = mag(nj & r)/rMag; - scalar cosThetaI = mag(ni & r)/rMag; + if (rMag > SMALL) + { + scalar dAiMag = mag(dAi); + scalar dAjMag = mag(dAj); - return - ( - (cosThetaI*cosThetaJ*dAjMag*dAiMag) - /(sqr(rMag)*constant::mathematical::pi) - ); + vector ni = dAi/dAiMag; + vector nj = dAj/dAjMag; + scalar cosThetaJ = mag(nj & r)/rMag; + scalar cosThetaI = mag(ni & r)/rMag; + + return + ( + (cosThetaI*cosThetaJ*dAjMag*dAiMag) + /(sqr(rMag)*constant::mathematical::pi) + ); + } + else + { + return 0; + } } @@ -316,7 +325,7 @@ int main(int argc, char *argv[]) ( IOobject ( - mesh.name(), + "coarse:" + mesh.name(), runTime.timeName(), runTime, IOobject::NO_READ,