Skip to content
Snippets Groups Projects
Open BUG: function object: Failed to store pointer: grad(U). Risk of memory leakage
  • View options
  • BUG: function object: Failed to store pointer: grad(U). Risk of memory leakage

  • View options
  • Open Issue created

    Summary

    When running grad function object on U field, the following error is issued (occurs with postProcess option and/or during simulation):

    "Failed to store pointer: grad(U). Risk of memory leakage"

    Possibly related to #2381, recommendation of including useNamePrefix true; in function object did not make the bug go away.

    Steps to reproduce

    Run grad function object on turbulentFlatPlate tutorial (solver simpleFoam). I ran it on the setup with kOmegaSST with y plus = 1.

    postProcess -func "grad(U)"

    or

    simpleFoam -postProcess -latestTime

    with FO grad included in controlDict.

    Example case

    As explained above. Below is modified controlDict from standard turbulentFlatPlateTutorial.

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                 |                                                 |
    | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
    |  \\    /   O peration     | Version:  v2206                                 |
    |   \\  /    A nd           | Website:  www.openfoam.com                      |
    |    \\/     M anipulation  |                                                 |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version     2.0;
        format      ascii;
        class       dictionary;
        object      controlDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    application     simpleFoam;
    
    startFrom       startTime;
    
    startTime       0;
    
    stopAt          endTime;
    
    endTime         5000;
    
    deltaT          1;
    
    writeControl    timeStep;
    
    writeInterval   100;
    
    purgeWrite      1;  
    
    writeFormat     ascii;
    
    writePrecision  8;  
    
    writeCompression off;
    
    timeFormat      general;
    
    timePrecision   8;  
    
    runTimeModifiable true;
    
    functions
    {
        minMax
        {
            type          fieldMinMax;
            libs          ("libfieldFunctionObjects.so");
            writeControl  timeStep;
            fields        (U);
        }
    
        yPlus
        {
            type            yPlus;
            libs            ("libfieldFunctionObjects.so");
            patches         (fixedWall);
            writeControl    writeTime;
        }
    
        #includeFunc "writeCellCentres"
        #includeFunc "wallShearStress"
        #include "FOgrad"
    }

    The file "FOgrad" is in system folder.

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                 |                                                 |
    | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
    |  \\    /   O peration     | Version:  v2212                                 |
    |   \\  /    A nd           | Website:  www.openfoam.com                      |
    |    \\/     M anipulation  |                                                 |
    \*---------------------------------------------------------------------------*/
    
    grad1
    {
        // Mandatory entries
        type            grad;
        libs            ("libfieldFunctionObjects.so");
        field           U;  
    
        // Optional (inherited) entries
        useNamePrefix true;
        //result          gradientU;
        log             true;
        writeControl    outputTime;
    }
    
    
    grad2
    {
        // Mandatory entries
        type            grad;
        libs            ("libfieldFunctionObjects.so");
        field           phi;
    
        // Optional (inherited) entries
        result          gradPhi;
        log             true;
        writeControl    outputTime;
    }
    
    
    // ************************************************************************* //
    

    What is the current bug behaviour?

    Error Failed to store pointer: grad(U). Risk of memory leakage is issued.

    What is the expected correct behavior?

    gradient of U field should be computed and file created in time folder. Tested on v2212, v2206, v2112. Works as expected with version v1706.

    Relevant logs and/or images

    OpenFOAM v2206

    --> FOAM Warning : 
        From bool Foam::regIOobject::store()
        in file /Users/jsalazar/openfoam/OpenFOAM-v2206/src/OpenFOAM/lnInclude/regIOobjectI.H at line 51
        Refuse to store unregistered object: grad(U)
    
    
    --> FOAM FATAL ERROR: (openfoam-2206)
    Failed to store pointer: grad(U). Risk of memory leakage
    
    
        From static Type &Foam::regIOobject::store(Type *) [Type = Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>]
        in file /Users/jsalazar/openfoam/OpenFOAM-v2206/src/OpenFOAM/lnInclude/regIOobjectI.H at line 73.
    
    FOAM aborting
    
    #0  Foam::error::printStack(Foam::Ostream&) in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #1  Foam::error::simpleExit(int, bool) (.cold.2) in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #2  Foam::error::simpleExit(int, bool) in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #3  Foam::error::exiting(int, bool) in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #4  Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>& Foam::regIOobject::store<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>*) in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #5  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::word&, Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> > const&, bool) in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #6  bool Foam::functionObjects::grad::calcGrad<Foam::Vector<double> >() in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #7  Foam::functionObjects::fieldExpression::execute() in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #8  Foam::functionObjects::timeControl::execute() in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #9  Foam::functionObjectList::execute() in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #10  main in /Volumes/OpenFOAM/OpenFOAM-v2206/platforms/darwinARM64ClangDPInt32Opt/bin/simpleFoam
    #11  start in /usr/lib/dyld
    zsh: abort      simpleFoam -postProcess -latestTime

    OpenFOAM v2212

    --> FOAM Warning : 
        From bool Foam::regIOobject::store()
        in file /Volumes/OpenFOAM-v2212/src/OpenFOAM/lnInclude/regIOobjectI.H at line 51
        Refuse to store unregistered object: grad(U)
    
    
    --> FOAM FATAL ERROR: (openfoam-2212)
    Failed to store pointer: grad(U). Risk of memory leakage
    
    
        From static Type &Foam::regIOobject::store(Type *) [Type = Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>]
        in file /Volumes/OpenFOAM-v2212/src/OpenFOAM/lnInclude/regIOobjectI.H at line 73.
    
    FOAM aborting
    
    #0  Foam::error::printStack(Foam::Ostream&) in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #1  Foam::error::simpleExit(int, bool) (.cold.2) in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #2  Foam::error::simpleExit(int, bool) in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #3  Foam::error::exiting(int, bool) in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #4  Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>& Foam::regIOobject::store<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>*) in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #5  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::word&, Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> > const&, bool) in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #6  bool Foam::functionObjects::grad::calcGrad<Foam::Vector<double> >() in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #7  Foam::functionObjects::fieldExpression::execute() in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #8  Foam::functionObjects::timeControl::execute() in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #9  Foam::functionObjectList::execute() in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #10  main in /Volumes/OpenFOAM-v2212/platforms/darwin64ClangDPInt32Opt/bin/simpleFoam
    #11  start in /usr/lib/dyld
    Abort trap: 6

    OpenFOAM v2112

    --> FOAM FATAL ERROR: (openfoam-2112)
    Failed to store pointer: grad(U). Risk of memory leakage
    
    
        From static Type &Foam::regIOobject::store(Type *) [Type = Foam::GeometricField<Foam::Tensor<double>, fvPatchField, Foam::volMesh>]
        in file /Users/jsalazar/openfoam/OpenFOAM-v2112/src/OpenFOAM/lnInclude/regIOobjectI.H at line 67.
    
    FOAM aborting
    
    #0  Foam::error::printStack(Foam::Ostream&) in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #1  Foam::error::simpleExit(int, bool) (.cold.2) in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #2  Foam::error::simpleExit(int, bool) in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #3  Foam::error::exiting(int, bool) in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #4  Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>& Foam::regIOobject::store<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>*) in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #5  bool Foam::functionObjects::regionFunctionObject::store<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >(Foam::word&, Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> > const&, bool) in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #6  bool Foam::functionObjects::grad::calcGrad<Foam::Vector<double> >() in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #7  Foam::functionObjects::fieldExpression::execute() in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libfieldFunctionObjects.dylib
    #8  Foam::functionObjects::timeControl::execute() in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #9  Foam::functionObjectList::execute() in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/lib/libOpenFOAM.dylib
    #10  main in /Volumes/OpenFOAM/OpenFOAM-v2112/platforms/darwin64ClangDPInt32Opt/bin/simpleFoam
    #11  start in /usr/lib/dyld

    Environment information

    • OpenFOAM version : v2212 or v2206 or v2112
    • Operating system : macOS. Also tested with OpenFOAM v2112 on docker container (Ubuntu 20.04)
    • Hardware info : MacBookPro Apple M1 Max 2021.
    • Compiler : clang (gcc on docker container)

    Possible fixes

    • Merge request
    • Branch

    Linked items ... 0

  • Activity

    • All activity
    • Comments only
    • History only
    • Newest first
    • Oldest first
    Loading Loading Loading Loading Loading Loading Loading Loading Loading Loading