CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

viewfactors and baffles problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 30, 2015, 15:02
Default viewfactors and baffles problem
  #1
Senior Member
 
Derek Mitchell
Join Date: Mar 2014
Location: UK, Reading
Posts: 172
Rep Power: 13
derekm is on a distinguished road
ViewFactorsGen will crash if you use baffles in interesting ways. This is because
ViewfactorsGen does not handle patches which are coincident e.g. baffles
the following function in //OpenFOAM-2.3.1/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.c attempts to divide by the scalar distance rmag between the two patches ( i j) as shown below. If the patches are coincident ~ BOOM
Code:
scalar calculateViewFactorFij
(
    const vector& i,
    const vector& j,
    const vector& dAi,
    const vector& dAj
)
{
    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;

    return
    (
        (cosThetaI*cosThetaJ*dAjMag*dAiMag)
       /(sqr(rMag)*constant::mathematical::pi)
    );
}
FIX: This can be fixed by substituting the following
Code:
scalar calculateViewFactorFij
(
    const vector& i,
    const vector& j,
    const vector& dAi,
    const vector& dAj
)
{
    vector r = i - j;
    scalar rMag = mag(r);
   
    scalar dAiMag = mag(dAi);
    scalar dAjMag = mag(dAj);
    if ( mag(r)==0)
    { return 0; } 
    else
    {
    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)
    );
  }
}
__________________
A CHEERING BAND OF FRIENDLY ELVES CARRY THE CONQUERING ADVENTURER OFF INTO THE SUNSET
derekm is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:12.