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

probe a line

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 3 Post By GerhardHolzinger
  • 2 Post By GerhardHolzinger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 16, 2013, 05:17
Default probe a line
  #1
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Hi all,

I wrote a little python script that allows me to probe a line.
Actually, I state the start and the end of the line as well as the number of points and my script generates a probesDict containing the defined points.

Have a look at it and if you find my nasty bit of code useful, feel free to use it, or even improve it.

The script assumes a file named "probeLineDict" to reside in the system directory. The script itself needs to be executed from the case directory. However, you can change the paths inside the script to get a different behaviour.
Attached Files
File Type: zip probeLine.zip (1.5 KB, 246 views)
GerhardHolzinger is offline   Reply With Quote

Old   May 21, 2013, 00:13
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
I believe that the 'sample' utility can do this as well. Give a start point, and end point, fields to sample, and number of sample points, it will extract the data requested.

http://www.openfoam.org/docs/user/sample.php
kmooney is offline   Reply With Quote

Old   May 21, 2013, 03:43
Default
  #3
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Quote:
Originally Posted by kmooney View Post
I believe that the 'sample' utility can do this as well.
You are right. However, if I use the probe function to do the job, I get a good time resolution.

I use sample as well, but in some cases I fell the need for higher time resolution. And writing everything to disk at a short interval and running sample afterwards is simply a waste of space.
GerhardHolzinger is offline   Reply With Quote

Old   May 21, 2013, 05:37
Default
  #4
New Member
 
Gerrit Laube
Join Date: Feb 2013
Posts: 5
Rep Power: 13
laubeg is on a distinguished road
Hi Gerhard,

I think in Line 25 it should be 'filename' instead of 'filenameW'.

And just to make things clear for future visitors of this thread: This file does not probe anything itselve, as one might expect from the title, but writes line coordinates to a probesDict, that is used by the 'native' OpenFOAM probeLocation application. As far as I know, you have to run this in advance of the processing itselve.

I never used the probe application, so Gerhard, maybe you could tell us a little more about the overall process: run Script -> run Solver -> find values in ./probes/-folder? Or is there anything else to consider? Do you have to modify the controlDict as well?

Thanks for the script! I hope that future generations of OpenFOAM will have a probe-application as good as the sample-app, but so far, this is a good workaround.
laubeg is offline   Reply With Quote

Old   May 21, 2013, 05:54
Default
  #5
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Quote:
Originally Posted by laubeg View Post
This file does not probe anything itselve, as one might expect from the title, but writes line coordinates to a probesDict, that is used by the 'native' OpenFOAM probeLocation application. As far as I know, you have to run this in advance of the processing itselve.
You are completely right. My first post was indeed short of the information of how to use the script.

The script reads probeLineDict and generates entries for the regular probe function object. However, defining (start, end, nPoints) is much easier than writing 50 points along a line manually into probesDict.

The script overwrites probesDict. However, you can change the name of the file into which the script writes. If you are already using probes, make sure they do not collide.

The variable filename is the name of the file which contains the definition of the line to be probed. The variable filenameW is the name of the file into which the generated dictionary for probes is written.

The definition of the probe function object in controlDict must make use of an external file for the definition of the probes, otherwise, the generated file would be useless. I let the script write a seperate file in order to prevent it from messing up the controlDict.

The usage follow this procedure.

Put the probeLineDict into the system directory.
Run probeLine.py from the case directory
Run the solver

The controlDict contains this code:

Code:
functions
{
    probes1
    {
        type probes;

        functionObjectLibs ("libsampling.so");

        dictionary probesDict;
    }
    
    probes2
    {
        type probes;

        functionObjectLibs ("libsampling.so");

        dictionary probesDict2;
    }
}
GerhardHolzinger is offline   Reply With Quote

Old   May 21, 2013, 06:12
Default
  #6
New Member
 
Gerrit Laube
Join Date: Feb 2013
Posts: 5
Rep Power: 13
laubeg is on a distinguished road
Thanks for the explanation!

Quote:
Originally Posted by GerhardHolzinger View Post
The variable filename is the name of the file which contains the definition of the line to be probed. The variable filenameW is the name of the file into which the generated dictionary for probes is written.
From line 23 to 25 you define 'filename' and use 'filenameW' afterwards.

Copied from your zip-file, line 23 to 25:
Code:
filename = './system/' + probesDict
#filenameW = probesDict
mywfile = open(filenameW,'w')
As far as I know, '#' is interpreted as a comment. Anyway I get an error, running the script:

Code:
Traceback (most recent call last):
  File "Y:\Home\laubeg\SharedFolder\Fehlman1\Fehlman2D_4\probeLine.py", line 25, in <module>
    mywfile = open(filenameW,'w')
NameError: name 'filenameW' is not defined
laubeg is offline   Reply With Quote

Old   May 21, 2013, 07:04
Default
  #7
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Hi, sorry for posting a buggy script. Mea culpa.

The code

Code:
filename = './system/' + probesDict
#filenameW = probesDict
should read

Code:
filenameW = './system/' + probesDict
#filenameW = probesDict
I used the commented filename-statements to test the script without the need of having an system directory present. However, filename and filenameW are not very good variable names.
Attached Files
File Type: zip probeLine.zip (1.5 KB, 124 views)
Jonas Ansoni and chengyu like this.
GerhardHolzinger is offline   Reply With Quote

Old   June 5, 2013, 10:56
Default
  #8
New Member
 
jiujiumin
Join Date: May 2013
Posts: 9
Rep Power: 13
jiujiumin is on a distinguished road
Quote:
Originally Posted by GerhardHolzinger View Post
You are completely right. My first post was indeed short of the information of how to use the script.

The script reads probeLineDict and generates entries for the regular probe function object. However, defining (start, end, nPoints) is much easier than writing 50 points along a line manually into probesDict.

The script overwrites probesDict. However, you can change the name of the file into which the script writes. If you are already using probes, make sure they do not collide.

The variable filename is the name of the file which contains the definition of the line to be probed. The variable filenameW is the name of the file into which the generated dictionary for probes is written.

The definition of the probe function object in controlDict must make use of an external file for the definition of the probes, otherwise, the generated file would be useless. I let the script write a seperate file in order to prevent it from messing up the controlDict.

The usage follow this procedure.

Put the probeLineDict into the system directory.
Run probeLine.py from the case directory
Run the solver

The controlDict contains this code:

Code:
functions
{
    probes1
    {
        type probes;
 
        functionObjectLibs ("libsampling.so");
 
        dictionary probesDict;
    }
 
    probes2
    {
        type probes;
 
        functionObjectLibs ("libsampling.so");
 
        dictionary probesDict2;
    }
}
this : Run probeLine.py from the case directory how to work?
jiujiumin is offline   Reply With Quote

Old   June 10, 2013, 00:45
Default The probesDict file where can i find?????
  #9
New Member
 
jiujiumin
Join Date: May 2013
Posts: 9
Rep Power: 13
jiujiumin is on a distinguished road
Quote:
Originally Posted by GerhardHolzinger View Post
Hi, sorry for posting a buggy script. Mea culpa.

The code

Code:
filename = './system/' + probesDict
#filenameW = probesDict
should read

Code:
filenameW = './system/' + probesDict
#filenameW = probesDict
I used the commented filename-statements to test the script without the need of having an system directory present. However, filename and filenameW are not very good variable names.
The probesDict file where can i find?????
The probesDict file where can i find?????
The probesDict file where can i find?????
The probesDict file where can i find?????
jiujiumin is offline   Reply With Quote

Old   June 10, 2013, 04:27
Default
  #10
New Member
 
Gerrit Laube
Join Date: Feb 2013
Posts: 5
Rep Power: 13
laubeg is on a distinguished road
Hi,

sorry for being rude, but did you even try to find a solution for one of your problems?

Here is one for running the python script: http://www.google.com

And one for the probesDict: Read the thread from the beginning or try the former solution!

This is a forum, not a google search. Regards!
laubeg is offline   Reply With Quote

Old   June 11, 2013, 10:13
Default sorry at the time i am very anxious
  #11
New Member
 
jiujiumin
Join Date: May 2013
Posts: 9
Rep Power: 13
jiujiumin is on a distinguished road
Quote:
Originally Posted by laubeg View Post
Hi,

sorry for being rude, but did you even try to find a solution for one of your problems?

Here is one for running the python script: http://www.google.com

And one for the probesDict: Read the thread from the beginning or try the former solution!

This is a forum, not a google search. Regards!
sorry never next and at the time i am very anxious.
At the same time
I have another question how do I set the probeLine.py file to probe many lines at the same time? such as two lines at a time. thanks
jiujiumin is offline   Reply With Quote

Old   June 11, 2020, 16:36
Default
  #12
Senior Member
 
Arijit Saha
Join Date: Feb 2019
Location: Singapore
Posts: 132
Rep Power: 7
ari003 is on a distinguished road
Quote:
Originally Posted by GerhardHolzinger View Post
Hi, sorry for posting a buggy script. Mea culpa.

The code

Code:
filename = './system/' + probesDict
#filenameW = probesDict
should read

Code:
filenameW = './system/' + probesDict
#filenameW = probesDict
I used the commented filename-statements to test the script without the need of having an system directory present. However, filename and filenameW are not very good variable names.
Sir I m trying the way which you just mentioned here but however I m confused whether to keep the python file and probeLineDict in the same system folder or not . Also do I have to include anything in controlDict folder?
I ll remain hopeful to get your reply.
ari003 is offline   Reply With Quote

Old   June 13, 2020, 22:09
Default
  #13
Senior Member
 
Arijit Saha
Join Date: Feb 2019
Location: Singapore
Posts: 132
Rep Power: 7
ari003 is on a distinguished road
Anyone from the forum can I get a response. I m in serious need. Please I ll remain hopeful.
ari003 is offline   Reply With Quote

Old   July 11, 2020, 15:08
Default
  #14
New Member
 
Marc
Join Date: Oct 2017
Posts: 11
Rep Power: 9
mcgoldba is on a distinguished road
Quote:
Originally Posted by ari003 View Post
Sir I m trying the way which you just mentioned here but however I m confused whether to keep the python file and probeLineDict in the same system folder or not . Also do I have to include anything in controlDict folder?
I ll remain hopeful to get your reply.
Hi Ari,

I have just started to look at using this script myself, and have not yet tested it. However, to answer your question, I believe the "probeLine.py" file should go into the main case directory, and the "probeLineDict" file should go into the "system/" sub-directory.

This is shown on line 17 of the python script:

Code:
filename = './system/' + probeLineDictName
Regards
mcgoldba is offline   Reply With Quote

Old   July 11, 2020, 15:13
Default
  #15
New Member
 
Marc
Join Date: Oct 2017
Posts: 11
Rep Power: 9
mcgoldba is on a distinguished road
In regards to your question about the controlDict, this was answered earlier in Gerhard's post:

Quote:
Originally Posted by GerhardHolzinger View Post

The controlDict contains this code:

Code:
functions
{
    probes1
    {
        type probes;

        functionObjectLibs ("libsampling.so");

        dictionary probesDict;
    }
    
    probes2
    {
        type probes;

        functionObjectLibs ("libsampling.so");

        dictionary probesDict2;
    }
}
mcgoldba is offline   Reply With Quote

Reply

Tags
probe, probes, runtime postprocessing


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
[Gmsh] Problem with Gmsh nishant_hull OpenFOAM Meshing & Mesh Conversion 23 August 5, 2015 03:09
8x icoFoam speed up with Cufflink CUDA solver library kmooney OpenFOAM Running, Solving & CFD 42 November 6, 2012 12:37
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 09:48
Regarding FoamX running Kindly help out hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 05:26
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00


All times are GMT -4. The time now is 16:46.