https://linen.dev logo
Join Discord
Powered by
# function-objects
  • y

    Yann

    03/05/2025, 1:36 PM
    and what do you get in your log file? You shoud see if the function is read and/or if you get an error/warning
  • b

    Boludo

    03/05/2025, 1:38 PM
    Yea, but... During the solution steps, nothing appears.
  • b

    Boludo

    03/05/2025, 1:38 PM
    I won't be able to see the beginning of the solution, because I didn't generate the .log. lol
  • y

    Yann

    03/05/2025, 1:39 PM
    not a good habit 😂
  • y

    Yann

    03/05/2025, 1:39 PM
    alright, for debugging try replacing ``writeControl outputTime;`` by ``writeControl timeStep;``, and show your controlDict file
  • b

    Boludo

    03/05/2025, 1:40 PM
    I'm lying, I managed to evaluate it, NOTHING appears. 😅
  • b

    Boludo

    03/05/2025, 1:41 PM
    Ok
  • b

    Boludo

    03/05/2025, 1:41 PM
    One minute
  • y

    Yann

    03/05/2025, 1:46 PM
    then there is something wrong with the way you define / include your functions in your controlDict
  • b

    Boludo

    03/05/2025, 2:17 PM
    Copy code
    /--------------------------------- C++ -----------------------------------\
      =========                 |
      \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
       \\    /   O peration     | Website:  https://openfoam.org
        \\  /    A nd           | Version:  9
         \\/     M anipulation  |
    \---------------------------------------------------------------------------/
    FoamFile
    {
        format      ascii;
        class       dictionary;
        location    "system";
        object      controlDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    libs ();
         
    application     multiphaseEulerFoam;
    
    startFrom       latestTime;
    
    startTime       0;
    
    stopAt          endTime;
    
    endTime         0.04; //~40000
    
    deltaT          1e-6; 
    
    writeControl    runTime;
    
    writeInterval   4e-5; 
    
    purgeWrite      0;
    
    writeFormat     ascii;
    
    writePrecision  6;
    
    writeCompression off;
    
    timeFormat      general;
    
    timePrecision   6;
    
    runTimeModifiable yes;
    
    adjustTimeStep  no;
    
    maxCo           0.5;
    
    //maxAlphaCo      0.5;
    
    maxDeltaT       0.01;
    
    // ************************* //
    
    cacheTemporaryObjects
    ();
        
    functions
    {
        //$surfaceFieldValueFunctions;   
        //#includeFunc Q(U.water)    
        
        #includeFunc faceZoneAverage(name=monitorZone, phi.water)
        #includeFunc faceZoneFlowRate(name=monitorZone)
        
        massFlowRate
        {
            type            surfaceFieldValue;
            functionObjectLibs ("libfieldFunctionObjects.so");
            writeControl    outputTime;
            enabled         true;
            log             true;
            writeFields     false;
            regionType      sampledSurface;
            name            monitorZone;
            operation       sum;
            fields          (phi.water phi.air);
            
            sampledSurfaceDict
            {
                type    faceZoneSet;
                setName monitorZone;
            }
        }
        
        fieldAverage
        {
            type            fieldAverage;
            functionObjectLibs ( "libfieldFunctionObjects.so" );
            writeControl    outputTime;        
            enabled         true;
            timeStart       0.01; //10000
    
            fields
            (
                U.air
                {
                     mean        on;
                     prime2Mean  on;
                     base        time;
                }
    
                U.water
                {
                     mean        on;
                     prime2Mean  on;
                     base        time;
                }
    
                alpha.air
                {
                     mean        on;
                     prime2Mean  off;
                     base        time;
                }
    
                alpha.water
                {
                     mean        on;
                     prime2Mean  off;
                     base        time;
                }
                
                nut.water
                {
                     mean        on;
                     prime2Mean  on;
                     base        time;
                }
    
                p
                {
                     mean        on;
                     prime2Mean  off;
                     base        time;
                }
                
                k.water
                {
                     mean        on;
                     prime2Mean  on;
                     base        time;
                }
            );
        }
        
    }
        
    surfaceFieldValueFunctions
    {}
    
    // ************************* //
  • b

    Boludo

    03/05/2025, 2:18 PM
    log https://cdn.discordapp.com/attachments/942811484730323045/1346849326600687656/message.txt?ex=67c9aeae&is=67c85d2e&hm=a437368097ab10354a1f6eaf11ed1daec89778d4bef7b8d272e89381dc1db613&
  • b

    Boludo

    03/05/2025, 2:21 PM
    Copy code
    writeControl    outputTime;
    works...
  • y

    Yann

    03/05/2025, 2:26 PM
    Aright, here is your problem:
    Copy code
    --> FOAM Warning : 
        From function bool Foam::functionObjectList::read()
        in file db/functionObjects/functionObjectList/functionObjectList.C at line 853
        Caught FatalError 
    --> FOAM FATAL ERROR: 
    Unknown sample type faceZoneSet
    
    Valid sample types : 
    
    8
    (
    cuttingPlane
    distanceSurface
    isoSurface
    patch
    patchInternalField
    plane
    thresholdCellFaces
    triSurfaceMesh
    )
  • y

    Yann

    03/05/2025, 2:27 PM
    faceZoneAverage and faceZoneFlowRate seems to work just fine
    Copy code
    surfaceFieldValue faceZoneAverage(name=monitorZone,phi.water):
        total faces  = 2841
        total area   = 0.0366263
    
    
    surfaceFieldValue faceZoneFlowRate(name=monitorZone):
        total faces  = 2841
        total area   = 0.0366263
  • b

    Boludo

    03/05/2025, 2:27 PM
    Yes, I saw this error, but it wasn't showing up before... the way I called the function was incorrect. That's why nothing was showing up. However, the options it offers me don't work for me. I created the region, but I don't know how to reference it.
  • b

    Boludo

    03/05/2025, 2:27 PM
    Yea
  • b

    Boludo

    03/05/2025, 2:28 PM
    In fact, one function would do the same as the other, it would be redundant.
  • y

    Yann

    03/05/2025, 2:29 PM
    you can use ``foamInfo`` to get some information about functions, boundary conditions, etc. For instance: ``foamInfo surfaceFieldValue``
  • b

    Boludo

    03/05/2025, 2:29 PM
    Now, he's calculating the average... I don't know if he would have to calculate the sum.
  • y

    Yann

    03/05/2025, 2:30 PM
    Since you have a faceZone, you should use:
    Copy code
    regionType      faceZone;
            name            monitorZone;
  • b

    Boludo

    03/05/2025, 2:31 PM
    I will try
  • y

    Yann

    03/05/2025, 2:32 PM
    I'm surprised that faceZoneAverage on phi.water gives you the same result as faceZoneFlowRate
  • b

    Boludo

    03/05/2025, 2:33 PM
    It's because there was still air in there.
  • b

    Boludo

    03/05/2025, 2:34 PM
    I believe it will go wrong because
  • b

    Boludo

    03/05/2025, 2:34 PM
    Copy code
    Unknown sample type faceZoneSet
    
    Valid sample types : 
    
    8
    (
    cuttingPlane
    distanceSurface
    isoSurface
    patch
    patchInternalField
    plane
    thresholdCellFaces
    triSurfaceMesh
    )
  • y

    Yann

    03/05/2025, 2:34 PM
    FYI, these functions (faceZoneAverage, faceZoneFlowRate, ...) are defined in ``$FOAM_ETC/caseDicts/postProcessing/``. It can be interesting to check how they are defined
  • y

    Yann

    03/05/2025, 2:35 PM
    You get this error because you are using a ``sampledSurface`` as ``regionType`` rather than ``faceZone``
  • b

    Boludo

    03/05/2025, 2:36 PM
    OOOh... ok, thanks.
  • y

    Yann

    03/05/2025, 2:39 PM
    ``regionType`` allows to define what kind of entity you want to use (faceZone, patch or sampledSurface). And depending on what you select there, you need to define either the name of the patch or faceZone, or a sampleSurfaceDict to use sampling functions
  • b

    Boludo

    03/05/2025, 2:40 PM
    Yes, I was not paying enough attention... 😅