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

Access UMean at runtime

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 5 Post By ykanani

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 17, 2012, 16:14
Default Access UMean at runtime
  #1
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
Good day to all. Is it possible to access UMean at runtime? I need it to perform compute the u'? Or can I just access u' at runtime? Thanks.
deji is offline   Reply With Quote

Old   March 19, 2012, 11:53
Default
  #2
Member
 
Dejan Morar
Join Date: Nov 2010
Posts: 78
Rep Power: 16
morard is on a distinguished road
Hi deji,

in absence of better idea, I did it on the following way: I calculate UMean in the solver on the same way as it would be calculated by the averaging function written in controlDict (check fieldAverageTemplates.C)

alpha = ( time-startStatistics - dt ) / ( time-startStatistics );
beta = dt / ( time-startStatistics);

UM = alpha*UM + beta*U;

If you know how to access UMean directly, please let me know.

Regards,
Dejan
morard is offline   Reply With Quote

Old   March 19, 2012, 12:10
Default
  #3
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
Thank you Dejan, I will certainly take a look at the code.

Cheers,
Deji
deji is offline   Reply With Quote

Old   April 25, 2016, 19:20
Default
  #4
Member
 
Yousef
Join Date: Feb 2015
Posts: 40
Rep Power: 11
ykanani is on a distinguished road
Quote:
Originally Posted by deji View Post
Good day to all. Is it possible to access UMean at runtime? I need it to perform compute the u'? Or can I just access u' at runtime? Thanks.
I know this is a very old thread, however as I found a good solution to it, I wanted to share:
for accessing UMean or any other Mean values in your solver, first add this in your Creatfields.H
Code:
    Info<< "Reading field UMean\n" << endl;
    volVectorField UMean
    (
        IOobject
        (
            "UMean",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
Then add this line at the end of the time loop of the solver (before runtime.write)

Code:
       const GeometricField<vector, fvPatchField, volMesh>& UMean_ =
        U.db().objectRegistry::
        lookupObject<GeometricField<vector, fvPatchField, volMesh> >
        (
             "UMean"
        );
UMean_ is the updated UMean (just one iteration lag) and the good thing is that you don't have to start your simulation with averaging. it can be started at any time you want.

Also you will need to add UMean file to your 0 directory.


for checking if this is working or not, you can add this line to print Umean_[0] (first value of UMean) and compare it with the saved UMean file in the time directory.
Info << "UMean_[0] = " << UMean_[0] << endl;
ykanani 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
Online libraries - with access to Journals momentum_waves Main CFD Forum 2 December 12, 2007 10:08
UDF Data Access Macro Woo Meng Wai FLUENT 0 November 6, 2007 20:23
Error: access: unbound variable,HELP sudhakar FLUENT 0 January 15, 2007 23:21
Access Density Allan Walsh FLUENT 3 October 4, 2005 07:55
access to variables at interface of porous media? Mazyar FLUENT 0 October 10, 2003 14:59


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