CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Mean value at each time step

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes
  • 4 Post By niklas
  • 1 Post By niklas
  • 1 Post By owayz
  • 1 Post By letzel

Reply
 
LinkBack Thread Tools Display Modes
Old   November 1, 2011, 05:06
Default Mean value at each time step
  #1
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
Hi,
I want to calculate budget terms of temperature variance and for that case I need mean value of velocity and temperature at each time step. For example, turbulent diffusion:

turbDiff1 = fvc::div((U-UM) * pow((T1-TM1),2.0));

where UM and TM1 are mean values calculated in fieldAverage function in controlDict. I have created fields UM and TM1 in createFields.H:

volVectorField UM
(
IOobject
(
"UMean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

volScalarField TM1
(
IOobject
(
"T1Mean",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

So, they are created at the beginning of time loop and remain constant during runtime. Now, I want these values to be adjusted at each time step. Is it possible to pass these averaged values (UMean and T1Mean), calculated in function implemented in controlDict, to the solver? Any suggestion?

Regards,
Dejan
morard is offline   Reply With Quote

Old   November 1, 2011, 05:21
Default
  #2
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 20
niklas will become famous soon enoughniklas will become famous soon enough
you mean something like this?

Code:
scalar time = runTime.value();
scalar dt = runTime.deltaT().value();

if (time > startAveraging )
{
    if ( (time - dt) < startAveraging )
    {
        Uav = U;
    }
    else
    {
        Uav = ( Uav*(time-startAveraging) + U*dt ) / (time-startAveraging + dt);
    }
}

Up = U - Uav;
niklas is offline   Reply With Quote

Old   November 1, 2011, 05:33
Default
  #3
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
Yes, exactly this. I will put it into the solver right now

Thanks Niklas so much!
morard is offline   Reply With Quote

Old   November 1, 2011, 06:58
Default
  #4
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
Hi Niklas again and sorry for interrupting. I was too fast. How can I specify startAveraging? Which function sends a signal that averaging is started?

Regards
morard is offline   Reply With Quote

Old   November 1, 2011, 07:01
Default
  #5
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 20
niklas will become famous soon enoughniklas will become famous soon enough
I did it like this for pimpleFoam. put this in the createFields.H-file

Code:
    scalar startAveraging
    (
        readScalar(mesh.solutionDict().subDict("PIMPLE").lookup("startAveraging"))
    );
startAveraging is the time-value
mm.abdollahzadeh likes this.
niklas is offline   Reply With Quote

Old   November 1, 2011, 08:59
Default
  #6
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
Hm, still I don't understand this, but I'll try to find out, somehow... It seams that I have to predefine startAveraging in fvSolution, but I want to start averaging at some point during run by adding function in controlDict. Than I should receive this info:

regIOobject::readIfModified() :
Reading object controlDict from file "/../system/controlDict"

and I want this time to be startAveraging.
Thanks for the reply.
morard is offline   Reply With Quote

Old   November 1, 2011, 10:34
Default
  #7
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 20
niklas will become famous soon enoughniklas will become famous soon enough
what do you mean with 'at some point during run'?

Is this a time you know when you start the simulation?
niklas is offline   Reply With Quote

Old   November 1, 2011, 11:50
Default
  #8
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
No, I don't know that time. I am just waiting for several flow-through times and than start averaging by putting ON for mean values in controlDict. Like this

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;
}
);
}
}

And I want the time when I put ON to be the startAveraging time. I don't know if this is possible.
morard is offline   Reply With Quote

Old   November 1, 2011, 13:20
Default
  #9
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 20
niklas will become famous soon enoughniklas will become famous soon enough
You dont need the function objects, if you add that piece of code to the solver.

just set startTime to a something sufficiently high so you get rid of the startup influence.
Thats all you need.

If you use the function-objects you will start averaging from start and if you want
to start at a certain time you have to code that yourself.
should be pretty straightforward though.

alternatively you can restart the simulation once the flow is fully developed and set cleanRestart true;

this way you dont need to add any code to the solver either.
check
src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverage.C

if you want to see how it works.
niklas is offline   Reply With Quote

Old   November 2, 2011, 04:05
Default
  #10
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
Quote:
Originally Posted by niklas View Post
You dont need the function objects, if you add that piece of code to the solver.

just set startTime to a something sufficiently high so you get rid of the startup influence.
Thats all you need.
I'll do it on this way. Thanks once again.
morard is offline   Reply With Quote

Old   November 4, 2012, 21:04
Default
  #11
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 127
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
Hallo Dejan,
Just a small question. To calculate the u' v' and w', I should first get a statistically converged UMean and then subtract the instantaneous velocity field U from it to get u' v' and w'. Is it right?
This means that I should wait for statistically converged simulations before recording the fluctuating fields, is there any easy way out. Because in some cases it could take considerable amount to time to get a converged simulation.

Regards,
Awais
owayz is offline   Reply With Quote

Old   November 5, 2012, 03:52
Default
  #12
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 7
morard is on a distinguished road
Hi Awais,

yes, that is the way how I did it. Well, I'm not sure if there is a faster option... Anyhow, those are statistical values and if you want good statistics, you haw to wait long. Check this code

prime2MeanField =
alpha*prime2MeanField
+ beta*sqr(baseField)
- sqr(meanField);

in fieldAverageTemplates.C. Try to implement it into your solver, maybe it works faster but, since I didn't try it, I'm really not sure..
morard is offline   Reply With Quote

Old   November 5, 2012, 12:34
Default
  #13
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 127
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
Thanks for your reply Dejan,
Actually I turn on the avraging and wait for statistical convergence. I have modified the solver adding something like:
Code:
UPrime = U - UMean
And then I get this data out and I don't know if there is any easier or Faster way.

Regards,
Awais
babakflame likes this.
owayz is offline   Reply With Quote

Old   June 6, 2014, 06:47
Default
  #14
Member
 
Niu
Join Date: Apr 2014
Posts: 42
Rep Power: 3
Z.Q. Niu is on a distinguished road
Dear Niklas,
should the value of startAveraging be set in dictionary of transportProperties?
Z.Q. Niu is offline   Reply With Quote

Old   June 6, 2014, 07:01
Default
  #15
Member
 
Marcus Letzel
Join Date: Sep 2012
Location: Aurich
Posts: 35
Rep Power: 4
letzel is on a distinguished road
The example by niklas expects startAveraging to be specified in file fvSolution in subdict PIMPLE.

If you prefer controlDict, use this code:
Code:
    scalar startAveraging
    (
        readScalar(runTime.controlDict().lookup("startAveraging"))
    );
Regards,
Marcus
bmikuz likes this.
letzel is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
Hydrostatic Pressure and Gravity miliante OpenFOAM Running, Solving & CFD 132 October 7, 2012 22:50
Full pipe 3D using icoFoam cyberbrain OpenFOAM 4 March 16, 2011 10:20
calculation diverge after continue to run zhajingjing OpenFOAM 0 April 28, 2010 04:35
HELP! time step too small? meangreen Main CFD Forum 5 August 27, 2009 12:32


All times are GMT -4. The time now is 08:13.