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

[swak4Foam] How to read in fields from previous time-steps in swak4foam

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 21, 2016, 20:27
Default How to read in fields from previous time-steps in swak4foam
  #1
Member
 
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 80
Rep Power: 7
Mehrez is on a distinguished road
Hi Foamers,

I am trying to build a groovyBC in which I need the average of the velocity (and pressure) field at the last output time.
Do you have an idea how can I read or access the velocity field at the previous output time ?

I know that I can use "oldTime(p)" for the last time step (=/= last output time).

Thank you for your help.

Mhrz
Mehrez is offline   Reply With Quote

Old   March 22, 2016, 15:11
Default
  #2
Member
 
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 80
Rep Power: 7
Mehrez is on a distinguished road
I found that using "swak4Foam", I can read a field of the previous time step: oldTime(fieldName) but nothing to read the previous output time.
Mhrz
Mehrez is offline   Reply With Quote

Old   April 5, 2016, 05:56
Default How to read in fields from previous time-steps in swak4foam
  #3
New Member
 
Join Date: Jun 2015
Posts: 26
Rep Power: 4
Ali Blues is on a distinguished road
Hi,
Let's assume we have solved a transient scalar transport equation. Now for each time-step we want to evaluated the following global quantity (sort of an average of the entire field variable, so we end up with a scalar):

\frac{\sum_{i}\left| C_{i} - \bar{C} \right| \Delta v}{\sum_{i}\left| C^{o}_{i} - \bar{C} \right| \Delta v}

Now the issue is how i can read in the initial field C^{o}, and in a more general context any of the previous time-steps?


Also a side-note that assuming I just have the following to compute:
\sum_{i}\left| C_{i} - \bar{C} \right| \Delta v

I was thinking of putting the code like:
Code:
Index
{
        type swakExpression;
        valueType internalField;
        variables ( "Tmean = 0.05;" );
         accumulations ( sum );
        expression "mag(T-Tmean)*vol()";
        verbose true;
        outputControlMode timeStep;
       outputInterval  1;
}
but it gives me an error which I think concerns the subtraction of field from scalar:
Code:
Parser Error for driver FieldValueExpressionDriver at "1.7-11" :"field Tmean not existing or of wrong type"
So where is the silly mistake that I've made here!

Best
Ali
Ali Blues is offline   Reply With Quote

Old   April 10, 2016, 17:17
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,125
Blog Entries: 39
Rep Power: 110
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Quick answer: Tested with OpenFOAM 3.0.x, tutorial case "heatTransfer/buoyantSimpleFoam/circuitBoardCooling":
Code:
libs ("libthermalBaffleModels.so" "libOpenFOAM.so" "libsimpleFunctionObjects.so" "libsimpleSwakFunctionObjects.so");

functions
{
  Index
  {
          type swakExpression;
          valueType internalField;
          variables ("Tmean=0.05;");
          accumulations ( sum );
          expression "mag(T-Tmean)*vol()";
          verbose true;
          outputControlMode timeStep;
          outputInterval  1;
  }
}
The problem is that you had spaces in the variables definition, namely:
  • Good: "Tmean=0.05;"
  • Bad: "Tmean = 0.05;"
__________________
wyldckat is offline   Reply With Quote

Old   April 11, 2016, 09:40
Default
  #5
New Member
 
Join Date: Jun 2015
Posts: 26
Rep Power: 4
Ali Blues is on a distinguished road
Thanks a lot Bruno!
Completely overlooked that

I was also wondering if you would know how I can read-in the initial field , and well perhaps more generally previous time-step solutions, as I've indicated in the early part of my post.

Best
Ali
Ali Blues is offline   Reply With Quote

Old   April 13, 2016, 05:22
Default
  #6
New Member
 
Join Date: Jun 2015
Posts: 26
Rep Power: 4
Ali Blues is on a distinguished road
So can anyone suggest on how I can read-in previous time-steps solution into swak4foam?
Thanks
Ali
Ali Blues is offline   Reply With Quote

Old   April 15, 2016, 19:45
Default
  #7
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,125
Blog Entries: 39
Rep Power: 110
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Quick answer: swak4Foam has a function known as "oldTime". Some details and examples are available here: http://www.cfd-online.com/Forums/ope...ormations.html - there you'll also find a few tricks on how to store fields from previous times.

But as demonstrated in that thread, you cannot easily store/retrieve the field for any specific time step. You will need to do some clever gradual storage of values, so that you can continuously update only for the current time step, while accounting only for the previous accumulated values.
__________________
wyldckat is offline   Reply With Quote

Old   April 19, 2016, 13:00
Default
  #8
Member
 
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 80
Rep Power: 7
Mehrez is on a distinguished road
Thank you for participating in this tread.
The swak4Foam "storedVariables" is a good way to use the old fields averages but there is a bug when using it in parallel.
Regards,
Mhrz
Mehrez is offline   Reply With Quote

Old   May 24, 2016, 16:36
Default
  #9
Member
 
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 80
Rep Power: 7
Mehrez is on a distinguished road
Any idea ?
Thanks,
Mhrz
Mehrez 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
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 06:28
How to export time series of variables for one point? mary mor OpenFOAM Post-Processing 8 July 19, 2017 10:54
Read and average fields over different time steps yanyanh OpenFOAM Running, Solving & CFD 0 September 24, 2014 09:32
mixerVesselAMI2D's mass is not balancing sharonyue OpenFOAM Running, Solving & CFD 6 June 10, 2013 09:34


All times are GMT -4. The time now is 09:00.