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

Contribute a forceCoeff plot and merge utility

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2014, 12:05
Default Contribute a forceCoeffs monitoring, plotting and merging utility
  #1
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Dear All,

I'd like to share my small force coefficient merging/plotting utility with you. It can plot and merge and write out a postscript file. The merge function is quite useful in many situations.

Download Link:
--->fcsp.tar.gz

The needs (Situation A):
  1. You are doing transient simulation.
  2. And there are probably more than one forceCoeffs folders in your postprocessing/forceCoeffs directory, due to the following reasons (to list a few):
    • you have restarted the simulation because your simulation was killed by the system; or
    • you have changed your time step for some reason.
    So now you will have the folder tree something like this:
    ├── 0
    ├── constant
    ├── postProcessing
    │** ├── forceCoeffs
    │** │** ├── 0
    │** │** │** └── forceCoeffs.dat
    │** │** ├── 20
    │** │** │** └── forceCoeffs.dat
    │** │** ├── 35
    │** │** │** └── forceCoeffs.dat
    │** │** ├── 50
    │** │** │** └── forceCoeffs.dat
    │** │** └── 6
    │** │** └── forceCoeffs.dat
    ├── system
  3. Now, you want to merge these forceCoeffs files into one to plot it. Note: the time in these files might be overlapped!!!!

The needs (Situation B):
You just want to monitor your force history

This code should work on Ubuntu. To give a few examples:

Code:
$ ./fcsp -help --> This will show the help. 

USAGE: fcsp [-x label] [-y label] [-t title] [-c NUMBER] [-m OFF|ON] [-f] [-d ON|OFF] [-v OFF|ON] [-s width:height] dataFile ...

Further Explanation:

        [**] Merged before or not, the default data file is ALWAYS in the LATEST local forceCoeffs time directory
        [-c] Number of lines needed to be cut off from the head of data file (100 by default)
        [-m] Generate a merged data file and then plot it (OFF by default)
        [-f] Without asking, force replacing the existing merged file
        [-d] Gnuplot's dumb plot output (ON by default)
        [-v] Vector plot output (OFF by default), output file name is fcsPlot.eps
        [-s] Fill Screen by default
By default the fcsp will plot the forceCoeffs from the latest folder to the screen. A most common usage of this utility is to run
Code:
./fcsp -m on -v on
This will merge all the forceCoeffs files into a single file, then plot it on the screen and export the cd and cl to an eps file.

Cheers,
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email

Last edited by lakeat; June 16, 2014 at 15:57.
lakeat is offline   Reply With Quote

Old   May 31, 2016, 00:39
Default
  #2
New Member
 
Qin Zhang
Join Date: May 2012
Posts: 10
Rep Power: 14
zhangqin200000 is on a distinguished road
nice tool. I am looking for something like this.
It could be better if the mean value and rms value also calculated.
zhangqin200000 is offline   Reply With Quote

Old   June 14, 2018, 11:53
Default feedback
  #3
Member
 
Ran
Join Date: Aug 2016
Posts: 69
Rep Power: 9
random_ran is on a distinguished road
Quote:
Originally Posted by lakeat View Post
Dear All,

I'd like to share my small force coefficient merging/plotting utility with you. It can plot and merge and write out a postscript file. The merge function is quite useful in many situations.

Download Link:
--->Attachment 31688

The needs (Situation A):
  1. You are doing transient simulation.
  2. And there are probably more than one forceCoeffs folders in your postprocessing/forceCoeffs directory, due to the following reasons (to list a few):
    • you have restarted the simulation because your simulation was killed by the system; or
    • you have changed your time step for some reason.
    So now you will have the folder tree something like this:
    ├── 0
    ├── constant
    ├── postProcessing
    │** ├── forceCoeffs
    │** │** ├── 0
    │** │** │** └── forceCoeffs.dat
    │** │** ├── 20
    │** │** │** └── forceCoeffs.dat
    │** │** ├── 35
    │** │** │** └── forceCoeffs.dat
    │** │** ├── 50
    │** │** │** └── forceCoeffs.dat
    │** │** └── 6
    │** │** └── forceCoeffs.dat
    ├── system
  3. Now, you want to merge these forceCoeffs files into one to plot it. Note: the time in these files might be overlapped!!!!

The needs (Situation B):
You just want to monitor your force history

This code should work on Ubuntu. To give a few examples:

Code:
$ ./fcsp -help --> This will show the help. 

USAGE: fcsp [-x label] [-y label] [-t title] [-c NUMBER] [-m OFF|ON] [-f] [-d ON|OFF] [-v OFF|ON] [-s width:height] dataFile ...

Further Explanation:

        [**] Merged before or not, the default data file is ALWAYS in the LATEST local forceCoeffs time directory
        [-c] Number of lines needed to be cut off from the head of data file (100 by default)
        [-m] Generate a merged data file and then plot it (OFF by default)
        [-f] Without asking, force replacing the existing merged file
        [-d] Gnuplot's dumb plot output (ON by default)
        [-v] Vector plot output (OFF by default), output file name is fcsPlot.eps
        [-s] Fill Screen by default
By default the fcsp will plot the forceCoeffs from the latest folder to the screen. A most common usage of this utility is to run
Code:
./fcsp -m on -v on
This will merge all the forceCoeffs files into a single file, then plot it on the screen and export the cd and cl to an eps file.

Cheers,
Thanks for your code!


I try to use your code to merge my data:

==========================
$ ./fcsp -c 10 -m on -d off -v off

------------------------------
Folder Name : forcesTesting
Data Type : forceCoeffs
------------------------------
4 time folders need to be merged
-- Folder 0 found in case forcesTesting/forceCoeffs.
./fcsp: line 139: bc: command not found
./fcsp: line 140: bc: command not found
-- Another folder 45 found in case forcesTesting/forceCoeffs.
--> Start merging ...
./fcsp: line 194: bc: command not found
./fcsp: line 195: bc: command not found
-- Another folder 90 found in case forcesTesting/forceCoeffs.
--> Start merging ...
./fcsp: line 194: bc: command not found
./fcsp: line 195: bc: command not found
-- Another folder 136.17 found in case forcesTesting/forceCoeffs.
--> Start merging ...
./fcsp: line 194: bc: command not found
./fcsp: line 195: bc: command not found
--> The latest simulation time is: 158.003
--> End merging ...
------------------------------
==========================

The force coefficient in my case looks like this in the 0 folder:

================================================== ===========
# Time Cm Cd Cl Cl Cl
0.003 1.886651e+02 3.765786e+02 1.110647e-03 1.886657e+02 -1.886645e+02
0.006 -9.400345e+01 -1.876334e+02 -1.919551e-03 -9.400441e+01 9.400249e+01
0.009 2.102545e-01 4.195944e-01 5.499815e-03 2.130044e-01 -2.075046e-01
0.012 1.636652e-01 3.268441e-01 -1.894238e-03 1.627181e-01 -1.646123e-01
...
================================================== ===========

However, I got the result like this in the mergedForceCoeffs.dat

==============================
# Time Cm Cd Cl
0 Time Cm Cd
0 Time Cm Cd
1 1.051044e-01 2.097883e-01 -2.932875e-04
2 4.741239e-01 9.463588e-01 1.309910e-04
3 4.638071e-01 9.257501e-01 8.461592e-04
4 2.801007e-01 5.591725e-01 5.642334e-04
5 3.741845e-01 7.446019e-01 7.464010e-03
6 3.897489e-01 7.761408e-01 3.843773e-02
...
==============================

- the time seem not correct after the merging

In my cases, the time step is 0.003, but the output is 1,2,3 ...

- at the end of the merged data:
=================================
...
158 5.474296e-01 1.081924e+00 -1.853809e-01
158 5.503081e-01 1.087717e+00 -1.837162e-01
158 5.482237e-01 1.083649e+00 -1.835996e-01
158 5.503837e-01 1.087997e+00 -1.827931e-01
158 5.495114e-01 1.086341e+00 -1.812269e-01
158 5.486711e-01 1.084763e+00 -1.803950e-01
158 5.504223e-01 1.088290e+00 -1.792501e-01
158.003 5.504223e-01 1.088290e+00 -1.792501e-01
===========EOF====================

The time is the same 158.



Is there any format requirement for your code?

Is my usage correct?

What does the meaning of "bc: command not found" ?

What pre-requirments of this code?

Is that possible to merge the bin data for further development this code?

Thanks,

Looking forward to hearning from you.


P.S. my machine:

Linux version 4.4.0-127-generic (buildd@lcy01-amd64-023) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) ) #153-Ubuntu SMP Sat May 19 10:58:46 UTC 2018

Last edited by random_ran; June 14, 2018 at 11:55. Reason: update machine info
random_ran is offline   Reply With Quote

Old   October 5, 2018, 12:03
Default
  #4
Member
 
Ran
Join Date: Aug 2016
Posts: 69
Rep Power: 9
random_ran is on a distinguished road
Hi:

After some time of searching on the Internet, I decided to write my own shell script.


As a newbie in shell scripts, I've tried my best effort to make it run. It seems fine in my situation, and I just want to share with anyone who has the same problem.


Please see this repository.

Hope it can help you.


Yours in CFD,

Ran
random_ran is offline   Reply With Quote

Old   October 5, 2018, 19:05
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

Just a quick comment. bc is a Linux for more advanced calculations in bash. General, it should be installed on your machine. Otherwise install it.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   October 5, 2018, 22:48
Default
  #6
Member
 
Ran
Join Date: Aug 2016
Posts: 69
Rep Power: 9
random_ran is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hi,

Just a quick comment. bc is a Linux for more advanced calculations in bash. General, it should be installed on your machine. Otherwise install it.
Thanks for your comment. I tested on a naive Ubuntu platform and did not notice 'bc' command. It could save me lot of effort if I know this at that time.

Last edited by random_ran; October 6, 2018 at 12:07.
random_ran is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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



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