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

DeltaT values from a log file

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Bloerb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 9, 2022, 10:56
Default DeltaT values from a log file
  #1
New Member
 
Sandro Brad Martinez Sardon
Join Date: Sep 2021
Posts: 16
Rep Power: 4
sandrobrad is on a distinguished road
Hi everyone,
I would like to know if there is a way to get all the deltaT and Time Values and write it in columns inside a file. I know that the foamLog tool does it but that does not provide that certain values.

I've tried the followind command
Code:
grep -n 'deltaT = ' log.orig > log.delta
in the following log
Code:
Courant Number mean: 0.002301022713 max: 0.05578931023
deltaT = 1.199040767e-05
Time = 1.19904e-05

PIMPLE: Iteration 1
smoothSolver:  Solving for Ux, Initial residual = 0.9999999898, Final residual = 0.004609686912, No Iterations 1
smoothSolver:  Solving for Uz, Initial residual = 0.9999999885, Final residual = 0.004594001409, No Iterations 1
GAMG:  Solving for p, Initial residual = 1, Final residual = 0.007652692688, No Iterations 8
time step continuity errors : sum local = 1.458725802e-08, global = 2.382430583e-09, cumulative = 2.382430583e-09
GAMG:  Solving for p, Initial residual = 0.5096147552, Final residual = 8.985245077e-08, No Iterations 34
time step continuity errors : sum local = 2.705657257e-13, global = 6.257742803e-14, cumulative = 2.382493161e-09
PIMPLE: Iteration 2
smoothSolver:  Solving for Ux, Initial residual = 0.1138942546, Final residual = 0.0003334726579, No Iterations 1
smoothSolver:  Solving for Uz, Initial residual = 0.1186037818, Final residual = 0.0004058030468, No Iterations 1
GAMG:  Solving for p, Initial residual = 0.2334599784, Final residual = 0.001869522242, No Iterations 7
time step continuity errors : sum local = 1.103546731e-08, global = -8.185891426e-10, cumulative = 1.563904018e-09
GAMG:  Solving for p, Initial residual = 0.1528364148, Final residual = 5.283523199e-08, No Iterations 31
time step continuity errors : sum local = 3.077853457e-13, global = -7.28369012e-14, cumulative = 1.563831181e-09
forces forcesIncompressible write:
    sum of forces:
        pressure : (10464.36616 7.252435353e-14 220299.4662)
        viscous  : (0.08075981986 -1.419327402e-19 0.01956819158)
        porous   : (0 0 0)
    sum of moments:
        pressure : (-1.289929731e-15 -57665.86044 5.434377084e-14)
        viscous  : (5.458984645e-21 -0.002230887901 -1.752967528e-19)
        porous   : (0 0 0)

Courant Number mean: 0.002748514158 max: 0.1086504914
deltaT = 1.437123682e-05
Time = 2.63616e-05

PIMPLE: Iteration 1
smoothSolver:  Solving for Ux, Initial residual = 0.284301388, Final residual = 0.0009982551183, No Iterations 1
smoothSolver:  Solving for Uz, Initial residual = 0.2633078552, Final residual = 0.00105323674, No Iterations 1
GAMG:  Solving for p, Initial residual = 0.3739672548, Final residual = 0.002374599974, No Iterations 8
time step continuity errors : sum local = 1.428765825e-08, global = -2.232009691e-09, cumulative = -5.581283006e-10
GAMG:  Solving for p, Initial residual = 0.3158552079, Final residual = 5.5460372e-08, No Iterations 34
time step continuity errors : sum local = 2.931379403e-13, global = -6.818714439e-14, cumulative = -5.581964878e-10
PIMPLE: Iteration 2

and inside the generated file the following data pops up:
Code:
                                                      

1:276:deltaT = 1.199040767e-05
2:329:deltaT = 1.437123682e-05
3:382:deltaT = 1.722562756e-05
4:435:deltaT = 2.065645794e-05
5:488:deltaT = 2.477744706e-05

Last question, żis there any possibility to get only the value of the deltaT?. Thanks in advance.
sandrobrad is offline   Reply With Quote

Old   December 9, 2022, 14:47
Default
  #2
Senior Member
 
Join Date: Sep 2013
Posts: 353
Rep Power: 20
Bloerb will become famous soon enough
You could always use a functionObject and write out every time step for any quantity like the inflow velocity and get it from there.


Directly from the logfile you should learn awk. Very helpful for manipulating text files in many many ways. awk looks at a text file a line at a time and does some manipulation. So much like grep but way more flexibility.


Examples:
Code:
awk '{if ($0 ~ "deltaT") print $0}' logfile
If the line ($0) contains (~) the string "deltaT" print the entire line.
Code:
awk '{if ($0 ~ "deltaT") print $1}' logfile
If the line ($0) contains (~) the string "deltaT" print the first column
in awk columns are separated by empty space.
Code:
awk '{if ($1 == "deltaT") print $3}' logfile
If the first column ($1) is exaclty equal to deltaT print the third column.


So if a logfile like this
Code:
Courant Number mean: 0.002301022713 max: 0.05578931023
deltaT = 1.199040767e-05
Time = 1.19904e-05
the following code would print the value 1.199040767e-05


Code:
awk '{if ($0 ~ "deltaT") print $3}' logfile
You can do more complex manipulations as well.


You can make it more complex like this:
Code:
awk '{
if ($0 ~ "deltaT") {currentDeltaT= $3}
if ($0 ~ "Time") {currentTimeStep = $3}




if ($0 == "PIMPLE: Iteration 1") {print currentDeltaT,currentTimeStep}


}' logfile >result.dat

You need to modify this a bit, but i think you get the basic idea.
sandrobrad likes this.
Bloerb 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
[OpenFOAM.com] swak4foam compiling issues on a cluster saj216 OpenFOAM Installation 5 January 17, 2023 16:05
Using PengRobinsonGas EoS with sprayFoam Jabo OpenFOAM Running, Solving & CFD 35 April 29, 2022 15:35
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 19:43
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 10:57


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