CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Coded function object in openfoam v5 (https://www.cfd-online.com/Forums/openfoam-post-processing/198216-coded-function-object-openfoam-v5.html)

kit607 January 30, 2018 10:48

Coded function object in openfoam v5
 
Greetings,

Recently I upgraded my OpenFOAM 2.1.1 to 5.0. Basically the simulation run smoothly until I insert coded function object into controlDict. The simulation detected the code and the dynamicCode folder is created but in the log file, there is no data generate from the coded function object. I installed swak4foam-dev and compiled correctly. I'm using funkySetFields to generate initial condition for fluid.

I tried the method post #12 https://www.cfd-online.com/Forums/op...tml#post387459, unfortunately I got the error of 'functions' entry is not a dictionary.

Is the openfoam v5 still support coded function object in 2.1.1? Or the v5 is using new script?

Thank You

kit607 January 30, 2018 11:10

*Update
 
Eventually wrong symbol was used, and the previous error is gone. But Currently lead to another warning which is No critical "code" prefixed keywords were found. Please check the code documentation for more details.

The things is I double check the code, and it is working in OF 2.1.1. I have no clue at all, anyone please help.

Thank You

bjnieuwboer April 30, 2018 12:04

code keyword has been updated in version 4.x
 
Hi,

I encountered the same error and came across this bugreport about it. It mentions that you should use the keyword "codeExecute" instead of "code". So a minimal working example would be:

Code:

functions
{
    printMinU
    {
        functionObjectLibs ( "libutilityFunctionObjects.so" );
        enabled        true;
        type            coded;
        redirectType    printMinU;
        writeControl  timeStep;
        writeInterval 1;

        codeOptions
        #{
            -I$(LIB_SRC)/meshTools/lnInclude
        #};

        codeExecute
        #{
            const volVectorField& U
            (
                mesh().lookupObject<volVectorField>("U")
            );
            Info << "minU = " << min(U) <<endl;
      #};
    }

}


ancolli September 29, 2020 15:43

Quote:

Originally Posted by bjnieuwboer (Post 690786)
Hi,

I encountered the same error and came across this bugreport about it. It mentions that you should use the keyword "codeExecute" instead of "code". So a minimal working example would be:

Code:

functions
{
    printMinU
    {
        functionObjectLibs ( "libutilityFunctionObjects.so" );
        enabled        true;
        type            coded;
        redirectType    printMinU;
        writeControl  timeStep;
        writeInterval 1;

        codeOptions
        #{
            -I$(LIB_SRC)/meshTools/lnInclude
        #};

        codeExecute
        #{
            const volVectorField& U
            (
                mesh().lookupObject<volVectorField>("U")
            );
            Info << "minU = " << min(U) <<endl;
      #};
    }

}


name instead of redirectType for the new OF versions


All times are GMT -4. The time now is 23:24.