CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Using setExprFields (https://www.cfd-online.com/Forums/openfoam-solving/251688-using-setexprfields.html)

frenchCroissant September 2, 2023 04:54

Using setExprFields
 
Hello,

I would like to better understand the setExprFields utility.

I have tried to find information on this at www.openfoam.com but so far I have been unsuccessful.

The dictionary is composed of:

Code:

expressions
(
    name
    {
        field      name;

        dimensions  [0 0 0 0 0 0 0];

        constants
        {
        }

        fieldMask
        #{
        #};

        variables
        (
        );

        expression
        #{
        #};
    }
 );

So:

fieldMask is a condition defining where the utility is going to apply an expression

Expression is the equation to apply

constants are constant to the expression?

variables. What are variables?

From my limited understanding of this, I have seen constants and expressions in the variables sections.

Here are a couple of examples.

Code:


        variables
        (
            "x = pos().x()"
            "y = pos().y()"
            "z = pos().z()"
        );

        expression
        #{
            vector(x, y, z)
        #};

This should produce the same output as postProcess -func "writeCellCentres" [no values for the boundaries]

And here https://develop.openfoam.com/Develop...ExprFieldsDict

Code:

variables (    "radius = 0.1" );
Defines a constant.

What are the roles of variables and constants?
Is this a programing strategy where constants get stored in a single variable and variables get defined over the volume/surface?

Afterwards, everything is put together in the expression?

frenchCroissant September 17, 2023 03:48

Anyone that can clarify this for me?


Where can I get more information?

Alczem September 18, 2023 03:29

Hey :)


Have you looked for examples in the tutorials? I have found this one:


Code:

expressions
(
    T
    {
        field      T;
        dimensions  [0 0 0 1 0 0 0];

        constants
        {
            centre (0.21 0 0.01);
        }

        variables
        (
            "radius = 0.1"
        );

        fieldMask
        #{
            // Within the radius
            (mag(pos() - $[(vector)constants.centre]) < radius)

            // but only +ve y!
          && pos((pos() - $[(vector)constants.centre]).y()) > 0
        #};

        expression
        #{
            300
          + 200 * (1 - mag(pos() - $[(vector)constants.centre]) / radius)
        #};
    }
);


My guess about variables and constants is that variables are allowed to be modified using the expression and constants are not. Based on the example above, it might only be a way to make a distinction between fixed values and values you might want to try during different runs.


I am not really helping :D but if you find out please update the thread, I have been looking into using setExprFields too.


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