CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Using setExprFields

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 2, 2023, 04:54
Default Using setExprFields
  #1
New Member
 
Join Date: Sep 2023
Posts: 3
Rep Power: 2
frenchCroissant is on a distinguished road
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 is offline   Reply With Quote

Old   September 17, 2023, 03:48
Default
  #2
New Member
 
Join Date: Sep 2023
Posts: 3
Rep Power: 2
frenchCroissant is on a distinguished road
Anyone that can clarify this for me?


Where can I get more information?
frenchCroissant is offline   Reply With Quote

Old   September 18, 2023, 03:29
Default
  #3
Senior Member
 
Join Date: Dec 2021
Posts: 209
Rep Power: 5
Alczem is on a distinguished road
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 but if you find out please update the thread, I have been looking into using setExprFields too.
Alczem is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
setExprFields CallumG OpenFOAM Pre-Processing 12 March 8, 2023 03:05
setExprFields example to generate an initial velocity field for LES of channel flow fumiya OpenFOAM Running, Solving & CFD 6 January 20, 2022 20:30
problem of using setExprFields qi.yang@polimi.it OpenFOAM Pre-Processing 1 May 25, 2021 15:15
Reading fields in setExprFields aeroengprof OpenFOAM Programming & Development 6 February 27, 2021 14:44


All times are GMT -4. The time now is 14:36.