View Issue Details

IDProjectCategoryView StatusLast Update
0004167OpenFOAMBugpublic2024-10-24 13:10
Reportertobias2 Assigned Towill  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOtherOS Version(please specify)
Product Version12 
Fixed in Version12 
Summary0004167: Lagrangian particle tracking crash with turbulent dispersion on
DescriptionWhen tracking a large amount of particles, the generation of random numbers for the turbulentDispersion model 'stochasticDispersionRAS' and 'gradiantDispersionRAS' failes after some time:

3] #0 Foam::error::printStack(Foam::Ostream&) at ??:?
[3] #1 Foam::sigFpe::sigHandler(int) at ??:?
[3] #2 ? in "/lib/x86_64-linux-gnu/libc.so.6"
[3] #3 ? in "/lib/x86_64-linux-gnu/libm.so.6"
[3] #4 Foam::distributions::standardNormal::approxErfInv(double) at ??:?
[3] #5 Foam::distributions::standardNormal::sample() const at ??:?
[3] #6 Foam::StochasticDispersionRAS<Foam::MomentumCloud<Foam::ParcelCloudBase<Foam::MomentumParcel<Foam::particle> > > >::update(double, int, Foam::Vector<double> const&, Foam::Vector<double> const&, Foam::Vector<double>&, double&) at ??:?
...

With version 11 of OpenFOAM this bug does not occur. It seems to be related to the new implementation of the standardNormal distribution. In
standardNormal.C the function sample() returns approxErfInv(2*s - 1)*sqrt2 with s between 0 and 1. In approxErfInv(y) the call of the log-function could cause this error, since it is not guaranteed that s must not reach 0 or 1 exactly. A rootSmall might fix this problem.
Steps To ReproduceSee cloudProperties file attached
TagsNo tags attached.

Activities

tobias2

2024-10-24 12:17

reporter  

cloudProperties (2,199 bytes)   
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  12
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format          ascii;
    class           dictionary;
    location        "constant";
    object          cloudProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

type            cloud;

solution
{
    coupled         false;
    transient       yes;
    cellValueSourceCorrection off;
    maxCo           0.3;
    interpolationSchemes
    {
        rho             cell;
        U               cellPoint;
        mu              cell;
    }
    integrationSchemes
    {
        U               Euler;
    }
}

constantProperties
{
    rho0            2000;
}

subModels
{
    particleForces
    {
        sphereDrag      ;
        gravity         ;
    }
    injectionModels
    {
        model1
        {
            SOI             500.2;
            duration        3;
            type            patchInjection;
            patchName       inlet;
            U0              ( 0 -0.5 0 );
            nParticle       1;
            parcelsPerSecond 10000;
            flowRateProfile constant 1;
            sizeDistribution
            {
                type            uniform;
                Q               0;
                min             1e-06;
                max             0.0005;
            }
        }
    }
    dispersionModel none;
    patchInteractionModel stochasticDispersionRAS;
    localInteractionCoeffs
    {
        patches         ( inlet { type rebound ; e 1 ; mu 0 ; } outlet_o { type escape ; } outlet_inl { type escape ; } wall_u { type escape ; } wall_outer { type rebound ; e 0.97 ; mu 0 ; } wall_inlet { type rebound ; e 1 ; mu 0 ; } );
    }
    surfaceFilmModel none;
    stochasticCollisionModel none;
}

cloudFunctions
{
}


// ************************************************************************* //
cloudProperties (2,199 bytes)   

will

2024-10-24 13:10

manager   ~0013434

The implementation is identical in v11, just in distributions::normal, so I don't know why there's a difference. Maybe just luck. In any case, I agree that the call to log probably should be protected from a zero value. Small in this instance is sufficient. RootSmall would be excessive. Fixed in v12 and dev:

https://github.com/OpenFOAM/OpenFOAM-12/commit/d19b858ec2376cefb38cce4849f8b3616b766c00
https://github.com/OpenFOAM/OpenFOAM-dev/commit/94407e144334e6d54b381d56062fd2185a0b4e13

Issue History

Date Modified Username Field Change
2024-10-24 12:17 tobias2 New Issue
2024-10-24 12:17 tobias2 File Added: cloudProperties
2024-10-24 13:10 will Assigned To => will
2024-10-24 13:10 will Status new => resolved
2024-10-24 13:10 will Resolution open => fixed
2024-10-24 13:10 will Fixed in Version => 12
2024-10-24 13:10 will Note Added: 0013434