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/)
-   -   No rms values for LES (https://www.cfd-online.com/Forums/openfoam-solving/58975-no-rms-values-les.html)

lofty April 7, 2008 16:56

Dear Foamers I have simulat
 
Dear Foamers

I have simulated a LES case. In results files I have mean values, R values but there are no rms values. How are rms values for velocity abbreviated and where can I find them? Thanks in advance for your help.

kumar2 April 7, 2008 17:50

Hi , As far as i know , the
 
Hi ,

As far as i know , there are no rms values output. you will have to post process the output files to calculate these.

and the R values denotes a part of SGS stresses.

hope this helps

kumar

cedric_duprat April 8, 2008 02:57

Hi, I want to confirm what
 
Hi,

I want to confirm what kumar said. And add, that, there is a tool called postChannel which calculate rms value BUT, for a channel.
If your geometry looks like a channel or is a periodic geometry, you can modify the tool.
But in other case .... as far as I know, there is no tools.

enjoy,

Cedric

ngj April 8, 2008 03:36

Hi all Off course it would
 
Hi all

Off course it would be possible for you to get an estimate of the rms values using postprocessing, but if you want the rms some quantity, e.g. pressure, then I would suggest that you rerun your calculation and calculate the rms-value during runtime. In that way you are certain that you get the effect of all turbulent fluctuations.

By the way, I have been looking quickly in oodles and lesInterFoam and it looks like the average values are calculated in a wrong way. At the moment the average value is calculated based on a counter which is incremented each time step. This gives an even weighting of all time steps, but are you using a Courant based time step then the averaging should take the actual time step into account, otherwise the velocities for the small time steps get a significantly larger impact on the average, and since the velocities are large during these small time steps, the average velocities will be larger than is actually correct.

Do you agree with me, or is it still too early in the morninghttp://www.cfd-online.com/OpenFOAM_D...part/happy.gif

- Niels

lofty April 8, 2008 05:55

Hi Thanks for your answers
 
Hi

Thanks for your answers guys.

Yes I would like to calculate my rms values during the run as Neils suggested. However, when I set up the case I dont see no options to set up rms calculations. If you want to calculate P rms for channelOodles tutorials where would you set up the rms calculations?

My mean results look Ok when I compare them with published results!

OF Newbie

lofty April 8, 2008 06:33

One last thing in FoamX if we
 
One last thing in FoamX if we follow on from velocityField there is an option callled "uprime". What is this for? Thanks

ngj April 8, 2008 06:56

Hi Newbie I do not think th
 
Hi Newbie

I do not think there is such an option, so if you need the rms values during runtime, you have to make your own implementation.
You could try to take a look at the calculateAverages.H, which is in the les-folders.

Have fun,

Niels

ngj April 8, 2008 06:58

BTW are you using a constant t
 
BTW are you using a constant time step? If so that explains why your average values match with experiments.
- Niels

basneb March 14, 2010 06:38

Hello everybody, hello ngj,

you are talking about making an own implementation for calculating the rms value during runtime of a simulation. Since I am a total newbie in programming with C/C++, I have no idea, how an implementation could look like. Has anyone of you already made an own implementation or give me some hints on how to do it? For some aero-acoustic application I need the rms value of the pressure, but for now, I'm stuck with my work, unfortunately. I would be very grateful, if anyone could try to help me out!

Thanks already and have a nice sunday.


/Bastian

alberto March 15, 2010 02:55

Quote:

Originally Posted by basneb (Post 249884)
Hello everybody, hello ngj,

you are talking about making an own implementation for calculating the rms value during runtime of a simulation. Since I am a total newbie in programming with C/C++, I have no idea, how an implementation could look like. Has anyone of you already made an own implementation or give me some hints on how to do it? For some aero-acoustic application I need the rms value of the pressure, but for now, I'm stuck with my work, unfortunately. I would be very grateful, if anyone could try to help me out!

Thanks already and have a nice sunday.


/Bastian

Take a look at what channelFoam and postChannel do, and consider the channelFoam as tutorial.

The channelFoam solver computes the averages automatically during the simulation using the fieldAverage function object. At the end of the controlDict you find

Code:

functions
{
    fieldAverage1
    {
        type            fieldAverage;
        functionObjectLibs ( "libfieldFunctionObjects.so" );
        enabled        true;
        outputControl  outputTime;
        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
        );
    }
}

This means that the mean and the prime2Mean values are computed and stored accounting for the correct time step, and that's all you need. You can re-use the settings in your controlDict, adapting them :D

If you then take a look at postChannel, you find out how the RMS are computed. In particular readFields.H contains:

Code:

volSymmTensorField UPrime2Mean
    (
        IOobject
        (
            "UPrime2Mean",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        ),
        mesh
    );

volScalarField Rxx(UPrime2Mean.component(symmTensor::XX));
    volScalarField Ryy(UPrime2Mean.component(symmTensor::YY));
    volScalarField Rzz(UPrime2Mean.component(symmTensor::ZZ));
    volScalarField Rxy(UPrime2Mean.component(symmTensor::XY));

and collapse.H, after collapsing the fields (it makes sense in the case of the channel due to the periodicity, but if you're not in these conditions, it does not), reports

scalarField urmsValues = sqrt(mag(RxxValues));
scalarField vrmsValues = sqrt(mag(RyyValues));
scalarField wrmsValues = sqrt(mag(RzzValues));

To make it short, you simply have to write a small utility that does this, since the unsteady data are already stored for you by the fieldAverage.

@Niels: What version of OF are you looking at? It seems to me averages are computed correctly in 1.6.x: http://foam.sourceforge.net/doc/Doxy...ce.html#l00139

If you consider to know the average <u> at time t, and you want to update it at t+dt, you just need to do, assuming sum_i(dt) is updated to the current time:

(<u> *(sum_i(dt) - dt_current) + dt_current*u_current)/(sum_i(dt))

which should give you the correct weighted average.

Best,

basneb March 15, 2010 03:34

Quote:

Originally Posted by alberto (Post 249951)
If you then take a look at postChannel, you find out how the RMS are computed. In particular readFields.H contains:

Code:

volSymmTensorField UPrime2Mean
    (
        IOobject
        (
            "UPrime2Mean",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        ),
        mesh
    );
 
volScalarField Rxx(UPrime2Mean.component(symmTensor::XX));
    volScalarField Ryy(UPrime2Mean.component(symmTensor::YY));
    volScalarField Rzz(UPrime2Mean.component(symmTensor::ZZ));
    volScalarField Rxy(UPrime2Mean.component(symmTensor::XY));

and collapse.H, after collapsing the fields (it makes sense in the case of the channel due to the periodicity, but if you're not in these conditions, it does not), reports

scalarField urmsValues = sqrt(mag(RxxValues));
scalarField vrmsValues = sqrt(mag(RyyValues));
scalarField wrmsValues = sqrt(mag(RzzValues));

To make it short, you simply have to write a small utility that does this, since the unsteady data are already stored for you by the fieldAverage.

Hi alberto,
thanks for your help. This clarifies a lot. So, in order to get the rms of the pressure, it is sufficient to simply take the sqrt of pPrime2Mean and compensate for the density, since it is already a scalar field?
And if so, does it make a difference, if I take the sqrt during run time or during post-processing (i.e. with the calculator tool in EnSight)?
Thanks again.

Best regards,
Bastian

panda60 March 15, 2010 08:50

Dear Alberto,

fieldAverage seems only can export u'^2, v'^2, w'^2, u'v', u'w' ,v'w', p'^2, T'^2.

but if I want to get vector and scalar multiply componet, <u'T'>,<v'T'>, <w'T'>, which T is tempeture, how can I modify to release this ?
Thank you very much.

alberto March 15, 2010 10:07

Quote:

Originally Posted by basneb (Post 249959)
Hi alberto,
thanks for your help. This clarifies a lot. So, in order to get the rms of the pressure, it is sufficient to simply take the sqrt of pPrime2Mean and compensate for the density, since it is already a scalar field?

Yes. Notice you do p is actually p/rho in incompressible codes.

Quote:

And if so, does it make a difference, if I take the sqrt during run time or during post-processing (i.e. with the calculator tool in EnSight)?
You can take the sqrt at the end, which is what postChannel does ;-)

Best,

alberto March 15, 2010 10:09

Quote:

Originally Posted by panda60 (Post 250051)
Dear Alberto,

fieldAverage seems only can export u'^2, v'^2, w'^2, u'v', u'w' ,v'w', p'^2, T'^2.

but if I want to get vector and scalar multiply componet, <u'T'>,<v'T'>, <w'T'>, which T is tempeture, how can I modify to release this ?
Thank you very much.

I would say the easiest way it to add a few lines of code to compute these quantities in you solver and output them.

Best,

basneb March 15, 2010 10:11

Quote:

Originally Posted by alberto (Post 250076)
Yes. Notice you do p is actually p/rho in incompressible codes.



You can take the sqrt at the end, which is what postChannel does ;-)

Best,

Okay, great! Thanks a lot! :)

/Bastian

panda60 June 10, 2010 02:53

Dear all,
my field has temperature, I want to get turbulent heat flux <w'T'>. I do like this:
1. Add three field variables to creatFields.H .

Info<< "Reading field Wave\n" << endl;
// the averaged value of w velocity.
volScalarField Wave
(
IOobject
(
"Wave",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

Info<< "Reading field Tave\n" << endl;
// the averaged value of temperature.
volScalarField Tave
(
IOobject
(
"Tave",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field WTA\n" << endl;
// the value o f<w'T'>.
volScalarField WTA
(
IOobject
(
"WTA",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

2. in my solver of *.C file, I add the following:

int main(int argc, char *argv[])
{
...................
...................
int nCounter = 0;
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
nCounter++; // new added
#include "readTimeControls.H"
#include "readPISOControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"

#include "UEqn.H"
#include "TEqn.H"
#include "CEqn.H"
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
#include "pEqn.H"
}
turbulence->correct();
Wave = (Wave*(nCounter-1)+U.component(2))/nCounter;
Tave = (Tave*(nCounter-1)+T)/nCounter;

WTA = (WTA*(nCounter-1)+(U.component(2)-Wave)*(T-Tave))/nCounter;

runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return 0;
}



I can get my result. but I think this is not smart. Because the definition of so many field variables will consume a lot of memory.
And I think if I use functionObject " fieldAverage" in the same time, I don't need to calculate the average value Wave and Tave, because fieldAvegare already do this , but How can I use this average value from fieldAverage ?
Who can give me some suggestions ? Thanks .

Eslam Reda January 2, 2016 15:39

1) I added these few lines at the end of the creatFields.H file of the solver:[/B]

Info<< "Reading field UT\n" << endl;
volVectorField UT
(
IOobject
(
"UT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

2) Then added this line to the buoyantPimpleFoam.C file

UT = thermo.T()*U;

just after the two lines

#include "UEqn.H"
#include "EEqn.H"

3) Make a file for "UT" in the "0" directory with proper (calculated) initial and boundary conditions and dimensions (0 1 -1 1 0 0 0)

4) Now OpenFOAM knows "UT" and you can add it to the filedAverage items in the ControlDict file:

functions
{
fieldAverage1
{
type fieldAverage;
functionObjectLibs ("libfieldFunctionObjects.so");
enabled true;
outputControl outputTime;

fields
(
U
{
mean on;
prime2Mean on;
base time;
}

p
{
mean on;
prime2Mean on;
base time;
}
T
{
mean on;
prime2Mean on;
base time;
}

UT
{
mean on;
prime2Mean on;
base time;
}
);
}

}

kakkapriyesh December 2, 2018 02:19

Quote:

Originally Posted by Eslam Reda (Post 579318)
1) I added these few lines at the end of the creatFields.H file of the solver:[/B]

Info<< "Reading field UT\n" << endl;
volVectorField UT
(
IOobject
(
"UT",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

2) Then added this line to the buoyantPimpleFoam.C file

UT = thermo.T()*U;

just after the two lines

#include "UEqn.H"
#include "EEqn.H"

3) Make a file for "UT" in the "0" directory with proper (calculated) initial and boundary conditions and dimensions (0 1 -1 1 0 0 0)

4) Now OpenFOAM knows "UT" and you can add it to the filedAverage items in the ControlDict file:

functions
{
fieldAverage1
{
type fieldAverage;
functionObjectLibs ("libfieldFunctionObjects.so");
enabled true;
outputControl outputTime;

fields
(
U
{
mean on;
prime2Mean on;
base time;
}

p
{
mean on;
prime2Mean on;
base time;
}
T
{
mean on;
prime2Mean on;
base time;
}

UT
{
mean on;
prime2Mean on;
base time;
}
);
}

}

This is incorrect as it will give <UT'UT'> and not <u'T'>,anyone has a code to do this??

svramana December 24, 2018 13:09

Hi Priyesh,
Please write correct one


All times are GMT -4. The time now is 05:52.