|
[Sponsors] |
OF-2.3.x: Get "latestTime" in a shell script? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 4, 2014, 05:35 |
OF-2.3.x: Get "latestTime" in a shell script?
|
#1 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
This is maybe a mix of a general UNIX question and an OF problem. During my meshing process, different time directories get created based on the meshing operations. Since they depend on the time step, which is set in the system/controlDict I would like to know how to get the directory of the latest time step into a variable. Since the formats of the time steps can be very different (1e-05, 0.001, etc.) it seems difficult, to compare these. Is there some way I can access the "latestTime" variable, which is used for many different OF tools, in my shell script? I want to do something like this:
Code:
sed -i "s/foo/bar/g" $latestTime/constant/polyMesh/boundary |
|
November 4, 2014, 06:25 |
|
#2 |
Senior Member
|
Hi,
if you'd like to modify boundary dictionary it's easier to use changeDictionary utility (with -latestTime flag). Also you can use -overwrite flag for your mesh operations if you don't need intermediate results. |
|
November 4, 2014, 06:27 |
|
#3 |
Senior Member
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 21 |
I do not have a full answer for you, but the following can take care of scientific notation:
Code:
$ bubRadius=20e-3 $ $ bubRadiusStr=`echo ${bubRadius} | sed -e 's/[eE]+*/\\*10\\^/'` #decode exponential notation into a mathematical string $ bubRadiusx1=$(echo 1*$bubRadiusStr | bc -l) #floating point math, convert the string into a floating point number Output: .02000000000000000000 So if you can loop over all directories, you should be able to find the maximum value somehow. Code:
cd $caseDir for someDir in * do stuff #$someDir is a file in your case file. It may be a number (timeDir), or e.g. "constant" done |
|
November 4, 2014, 06:41 |
|
#4 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
Thanks to both of you for your answers.
@alexeym: The changeDictionary tool might be an option. This is not the only thing I want to change, though. The overwriting option is definately my first choice once I have figured out the correct way to build my mesh and case. So far, I have to keep the intermediate meshes during the "development stage". @floquation: Yes this is probably what I will use first of all. But I just thought, that there is maybe an OF way to output/access the "latestTime" variable and to then use that in my shell script. I thought that would've been a nicer way to get the maximum time value. |
|
September 29, 2020, 05:19 |
New OpenFOAM versions functionality
|
#5 |
New Member
Aaron Endres
Join Date: Jun 2016
Posts: 13
Rep Power: 10 |
In newer OpenFOAM versions, you can use the foamListTimes function object.
latestTime=$(foamListTimes -latestTime | tail -n 1) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] Script: problems with face names | Maweil | ANSYS Meshing & Geometry | 3 | April 16, 2019 10:10 |
CentFOAM Python Script Installation: Error | socon009 | OpenFOAM Installation | 2 | May 26, 2012 10:36 |
paraView in shell mode (python script running) | Prosiaczek | OpenFOAM | 2 | March 19, 2012 08:54 |
shell conduction | ezabille | FLUENT | 2 | December 15, 2010 18:42 |
Perl script for intialisation | pratik mehta | CFX | 2 | September 10, 2008 04:09 |