CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM

Import xyz data

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

Like Tree4Likes
  • 4 Post By eelcovv

LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2010, 07:51
Question Import xyz data
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 15
eelcovv is on a distinguished road
Dear Foamers,

I have a question on importing an arbitrary xyz (or csv) file into OpenFoam.

I want to run a mhdFoam calculation. But the initial B-field is obtain from Comsol, which can only export .cvs files. Is there a way to interpolate an arbitrary xyz column file onto an OpenFoam mesh ? Similar like for instance mapFields.

Many thanks!


eelcovv is offline   Reply With Quote

Old   May 27, 2010, 14:03
M. Mahdi Salehi
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 50
Rep Power: 13
smehdi609 is on a distinguished road
There is a function called "interpolateXY" available in OpenFOAM. You can use that, but you should write a code to do this.
smehdi609 is offline   Reply With Quote

Old   May 28, 2010, 08:01
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 15
eelcovv is on a distinguished road
Thank you for your suggestion. Although I was hoping that there would be a little utility already there which works like mapfields but instead takes a cvs data file as input.
Ideally I want to convert the magnetic field which is stored in an external cvs file in to a openFoam format B-field in the zero directory, so you can read this file when you start the simulations. Hopefully somebody has already accomplished this, otherwise I need to write it myself.

eelcovv is offline   Reply With Quote

Old   May 28, 2010, 10:03
Senior Member
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 611
Blog Entries: 5
Rep Power: 20
elvis will become famous soon enough
Unfortunatly VTK does only have a OpenFOAMReader but no OpenFOAMWriter exists
elvis is offline   Reply With Quote

Old   June 8, 2010, 08:05
Smile solution csv data import
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 15
eelcovv is on a distinguished road
Dear Foamers,

In case anybody is interested, here my solution how to read a csv asci file with asci columns on a regular grid and interpolate it on an openFoam grid file.

I wrote a little perl script which converts the cvs file with x,y,z,v1,v2,...vN data columns and put them with a new file header into a regular structure plot3d file.
Then I modified the plot3dToFoam utility in order to read the newly created p3d data file and interpolate it on the openFoam grid. The OF grid is obtained from a vector field which is called Bf, hence this must be present in the 0 directory. Rename this field in the code and recompile it if you need it to be interpolated on another grid.
So, starting from the csv file do Bfield.csv

this generates Bfield.p3d

Then run in the OF case directory

plot3DmapField Bfield.p3d

This interpolates the Bfield.p3d field into the OF Bf field in the 0 directory.

Although this OF utility works perfectly fine for me, I am sharing it because hopefully somebody can suggest improvements. Especially, the field which is being interpolated must be a vector field which is called Bf (which is the magnetic field in my case). This works for me, but it should be possible to make the utility more generic, such that the field can have any name and type. Ideally, I would have liked to have something like foamCalc, where you can give as an option the field name to interpolate on, and a external file name representing the asci file. Something like

foamCalc <of-data-fieldname> <ascifield-to-be-read-and-interpolated>

Unfortunately, how this foamCalc is programmed is a bit to untransparant for me. A suggestion for the new release of OF? I think that the interpolation of an arbitrary data field obtained from measurements or another simulation program to an OF data field should be something standard present in OF. Another ugly thing in my solution is that I define my own interpolation of the regular grid to the OF grid, but probably this should be possible with interpolation functions which are present in OF already. However, I just don't see how to do that. Anybody?

In conclusion. This utility works, recompile for your own needs, but please get back with suggestions if you have a way to make it more generic, such that others can enjoy it as well. In my opinion, this kind of generic utilities (i.e.: non-process specific solutions) should be shared as much as possible such the OF gets better accessible for a larger group of people. The more people use and share OF, the faster the developments, which is in everybodies interest (except the interest of Ansys of course).


Attached Files
File Type: gz plot3DmapField.tar.gz (3.8 KB, 213 views)
JackW, Kirils, dkuesten and 1 others like this.
eelcovv is offline   Reply With Quote

Old   October 22, 2010, 12:29
Default import xyz data
abdikerim kurbanaliev
Join Date: Jun 2010
Location: Kyrgyzstan, Osh
Posts: 65
Rep Power: 12
kerim is on a distinguished road
Dear ellcovv

I'm a new openfoam user and interested in importing terrain data in xyz format into openfoam. My data looks like this body, div, table, thead, tbody, tfoot, tr, th, td, p { font-family: "Arial"; font-size: x-small; } X Y Z 426626.39 5051125.35 2351.69 426626.39 5051155.35 2351.7 426626.39 5051185.35 2351.58 426626.39 5051215.35 2351.32 426626.39 5051245.35 2351.08 Could you help me, please?

kerim is offline   Reply With Quote

Old   July 11, 2013, 11:26
Felipe Alves Portela
Join Date: Dec 2012
Location: UK
Posts: 68
Rep Power: 9
fportela is on a distinguished road

I managed to get the mesh converter to take in a data file (Q file) as an option. With some help from Eelco's program, I read in this data and "interpolate" it to the cell centres.

For my case it was enough to simply average the point values at the cell centre.

I am attaching it here as it might be useful to other people, note that for my case, I was reading rho u v w T from the Q-file, which differs from the standard rho rhoU rhoV rhoW T. Furthermore, the routine is quite slow as I didn't find an efficient way (honestly I don't understand most of the mesh conversion) to get the correspondence between the order in which the nodes are stored in the mesh file and the order in which they are written in OpenFOAM.
Attached Files
File Type: gz plot3dToFoamData.tar.gz (92.8 KB, 101 views)
fportela is offline   Reply With Quote

Old   February 25, 2014, 12:45
Default Hiii
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 9
manju819 is on a distinguished road
I to have a same doubt. on searching i got this csv reader at the location

N.Manjunath Reddy
manju819 is offline   Reply With Quote

Old   May 30, 2016, 09:03
New Member
Join Date: Nov 2015
Location: Japan
Posts: 12
Rep Power: 6
hisham007 is on a distinguished road
Dear eelcovv,

I'm new in OpenFOAM. Can you please guide me step by step how to do the interpolation in OpenFOAM start from convert the CSV file? I couldn`t understand how to keep the CSV file and run the and also how to call the plot3DmapField command? my CSV file as attached. Hope can hear from you soon.

Please help.

Attached Files
File Type: xls 120118.xls (34.0 KB, 19 views)
hisham007 is offline   Reply With Quote


csv, import

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] [DesignModeler] import data XYZ zelito ANSYS Meshing & Geometry 0 December 15, 2009 14:48
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30
XYZ (ASCII format) data points into GAMBIT Neil FLUENT 1 August 7, 2007 09:24
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 17:27
I-DEAS CAD data import with boundary conditions Yunus FLUENT 2 March 14, 2001 14:45

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