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

fieldAverage and coded function

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 8, 2019, 14:32
Default fieldAverage and coded function
  #1
Member
 
Joaquín Neira
Join Date: Oct 2017
Posts: 38
Rep Power: 9
cojua8 is on a distinguished road
Hello,

I'm trying to calculate the turbulence intensity of my simulation.

the formula for this is: I = u'/U = \sqrt{\frac{1}{3}(u_{x}^{'2} + u_{y}^{'2} + u_{z}^{'2}) }/U

or, in terms of openFoam: I = sqrt(1/3)*(mag(U-Umean)/mag(Umean)

So, my idea is to use the fieldAverage function:

Code:
fieldAverage1
    {
        type                fieldAverage;
        libs                ("libfieldFunctionObjects.so");

        writeControl        writeTime;

        restartOnRestart    true;
        restartOnOutput     false;
        periodicRestart     true;
        restartPeriod       5;

        fields
        (
            U
            {
                mean            on;
                prime2Mean      off;
                base            time;
            }
         
        );
    }
and then create a codedFunction which creates a new turbulenceIntensity field and adds it to registry:

Code:
turbulenceIntensity
    {
        functionObjectLibs ("libutilityFunctionObjects.so");
        type coded;
        writeControl writeTime;
        name writeTurbulenceIntensity;
        codeWrite
        #{
            const volVectorField& U = mesh().lookupObject<volVectorField>("U");
            const volVectorField& Umean =
                mesh().lookupObject<volVectorField>("Umean");

            volScalarField turbulenceIntensity
            (
                IOobject
                (
                    "turbulenceIntensity",
                    mesh().time().timeName(),
                    mesh(),
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
                sqrt(1.0/3.0)*mag(U-Umean)/mag(Umean)
            );
            turbulenceIntensity.checkIn();
        #};
    }
then, I want to calculate the mean of this field over time, adding the field to the fieldAverage function.

Code:
...
turbulenceIntensity
{
    mean            on;
    prime2Mean      off;
    base            time;
}
...
but this does not seem to work, but also there are no errors.

How can I do this?
cojua8 is offline   Reply With Quote

Old   October 2, 2019, 10:14
Default
  #2
New Member
 
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 9
em17 is on a distinguished road
Hi,

OpenFOAM already has a postprocessing function for turbulence intensity. You can include this in your controlDict to write out the TI field during run time - simply include #includeFunc turbulenceIntensity in your functions section.

Emily
em17 is offline   Reply With Quote

Reply

Tags
fieldaverage, registry, turbulence intensity


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
Initialization of symmTensor by a coded function jsagg OpenFOAM Programming & Development 5 April 22, 2023 07:21
Unknown function type loadPsiThermoModel immortality OpenFOAM Running, Solving & CFD 1 June 9, 2017 08:50
coded function object and field average matthias OpenFOAM Post-Processing 3 June 30, 2014 05:52


All times are GMT -4. The time now is 12:10.