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

Import xyz data

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 6 Post By eelcovv

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2010, 08:51
Question Import xyz data
  #1
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
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!

Regards,

Eelco
eelcovv is offline   Reply With Quote

Old   May 27, 2010, 15:03
Default
  #2
Member
 
M. Mahdi Salehi
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 50
Rep Power: 17
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, 09:01
Arrow
  #3
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
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.
Regards,

Eelco
eelcovv is offline   Reply With Quote

Old   May 28, 2010, 11:03
Default
  #4
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 620
Blog Entries: 6
Rep Power: 24
elvis will become famous soon enough
Unfortunatly VTK does only have a OpenFOAMReader http://www.vtk.org/doc/release/5.6/html/a01234.html but no OpenFOAMWriter exists
elvis is offline   Reply With Quote

Old   June 8, 2010, 09:05
Smile solution csv data import
  #5
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
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

csv2p3d.pl 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).

Regards.

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

Old   October 22, 2010, 13:29
Default import xyz data
  #6
Senior Member
 
abdikerim kurbanaliev
Join Date: Jun 2010
Location: Kyrgyzstan, Osh
Posts: 121
Rep Power: 16
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
kerim is offline   Reply With Quote

Old   July 11, 2013, 12:26
Default
  #7
Member
 
Felipe Alves Portela
Join Date: Dec 2012
Location: FR
Posts: 70
Rep Power: 14
fportela is on a distinguished road
Hello!

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, 129 views)
fportela is offline   Reply With Quote

Old   February 25, 2014, 13:45
Default Hiii
  #8
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 13
manju819 is on a distinguished road
I to have a same doubt. on searching i got this csv reader at the location
/opt/openfoam222/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.H


Regards
N.Manjunath Reddy
manju819 is offline   Reply With Quote

Old   May 30, 2016, 10:03
Default
  #9
New Member
 
hisham
Join Date: Nov 2015
Location: Japan
Posts: 12
Rep Power: 11
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 csv2p3d.pl? and also how to call the plot3DmapField command? my CSV file as attached. Hope can hear from you soon.

Please help.

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

Reply

Tags
csv, import


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 15:48
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30
XYZ (ASCII format) data points into GAMBIT Neil FLUENT 1 August 7, 2007 10:24
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27
I-DEAS CAD data import with boundary conditions Yunus FLUENT 2 March 14, 2001 15:45


All times are GMT -4. The time now is 18:20.