From 30d396ae284db316afbe9c5055b6b8d7568ce4c3 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 30 Apr 2015 22:25:40 +0100 Subject: [PATCH] viewFactorsGen: Handle baffles Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1680 --- .../viewFactorsGen/viewFactorsGen.C | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C b/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C index 385df00967..b1d1321c82 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C +++ b/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C @@ -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; + } }