CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How to read .txt data used by sampleDict? (https://www.cfd-online.com/Forums/openfoam-post-processing/124635-how-read-txt-data-used-sampledict.html)

kiddmax October 9, 2013 14:53

How to read .txt data used by sampleDict?
 
Dear Foamers.

I want to use sampleDict to get the velocity on a line. Since there are too many lines I need to plot, therefore it is challenging to input the start point and end point by hands. I got the coordinates of all the points in .txt file (x,y,z). Do you know how to read these data in sampleDict? I think we need a loop to use all these points, right? I really appreciate someone can give some hints!

Thank you!

Best regards,
Ye

nimasam October 11, 2013 02:46

i have two ideas for doing this:

1- OpenFOAM features called as code stream
2- write a bash-script to import such data using sed

kiddmax October 11, 2013 11:26

Thank you, Nima!

I will try that later!

Ye

wyldckat October 11, 2013 18:14

Greetings to all!

@Ye: If you don't manage to figure this out by yourself, please share an example of 2-3 lines in the TXT form, as well as the resulting "sampleDict" script you expect to get from said TXT file. I ask this because it'll be a lot easier to make any script once the materials are available.

As for scripting, it could be done with any number of possible tools, such as:
  • Creating an OpenFOAM utility that would read the TXT file and output the "sampleDict" file.
  • Using sed, grep, awk and any additional set of shell applications, which can be used for parsing the TXT file and outputting the ready-to-be-used "sampleDict".
  • Or even... one simple language, that can do it all and more: Python :cool:
Best regards,
Bruno


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