CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Calculating fluctuation flux (Reynolds flux) of scalar in LES? (https://www.cfd-online.com/Forums/openfoam/242243-calculating-fluctuation-flux-reynolds-flux-scalar-les.html)

hhu_lulu April 12, 2022 02:15

Calculating fluctuation flux (Reynolds flux) of scalar in LES?
 
Hi FOAMer! I am using LES to simulate the scalar mixing in wall-bounded turbulent flow. The LES could calculate the transient velocity field U and scalar field s. With the fieldAverage function, the time-averaged value UMean and sMean could also be obtained.
Now I want to output the time-avearged flux and fluctuation flux of scalar, namely the <Us> and <U's'>, which requires to calculate the expression U*s and (U-UMean)*(s-sMean) and pass the result to fieldAverage function.
After searching through the forum, maybe the easiest way is to impose coded functionObject in controlDict file. I adapt the code in thread
HTML Code:

https://www.cfd-online.com/Forums/openfoam-post-processing/219817-fluctuating-component-scalar-quantity.html
to my case, but the simulation aborted in the middle of the process and the error shows:
Quote:

new cannot satisfy memory request.
This does not necessarily mean you have run out of virtual memory.
It could be due to a stack violation caused by e.g. bad use of pointers or an out of date shared library
BTW, I use the parallel computation on HPC.
Does anyone know the way to handle this, or any other workaround?

hhu_lulu April 12, 2022 02:25

For quick reference, I post the adapted code below, in which the flux1 represents the product of U and s.
Code:

fluctuation_flux1
        {
                type                        coded;
                libs                        ("libutilityFunctionObjects.so");
                enabled                true;
                timeStart                74;
                timeEnd                200;
                writeControl        adjustableRunTime;
                writeInterval        200;
                name                fluctuation_flux1;
               
                codeExecute
                #{
                        const volVectorField& U =
                        mesh().lookupObject<volVectorField>("U");               
                        const volScalarField& s =
                        mesh().lookupObject<volScalarField>("s");               
                       
                        obr_.store
                        (
                                new        volVectorField       
                                (
                                        IOobject
                                        (
                                                "flux1",
                                                obr_.time().timeName(),
                                                obr_,
                                                IOobject::NO_READ,
                                                IOobject::AUTO_WRITE
                                        ),
                                        U*s
                                )
                        );
                        const volVectorField& flux1 =
                        obr_.lookupObject<volVectorField>("flux1");
                #};
        }

Also the fieldAverage function to average the flux1 in time:
Code:

fieldAverage1
    {
      type                        fieldAverage;
      functionObjectLibs  ( "libfieldFunctionObjects.so" );
      resetOnRestart        true;
      resetOnOutput        false;
      startTime                75;               
      endTime                200;               
      writeControl            adjustableRunTime;
      writeInterval          200;
     
      fields
      (
            flux1
          {
            mean              on;
            prime2Mean    on;
            base              time;         
          }
      );
    }



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