|
[Sponsors] |
Mapping csv (or other text format) data sets onto volumetric mesh |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 24, 2017, 11:14 |
Mapping csv (or other text format) data sets onto volumetric mesh
|
#1 |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
Hi all,
my issue is quite straightforward: I need to map a data set (velocity field), which is contained in a csv file, onto an OpenFOAM mesh for flow initialization. The data set is 3D and ordered in columns. I have 3 columns representing the x,y,z coordinates of the nodes where velocities are stored, plus 3 columns representing the x,y,z velocity components. I know how to export data from OF to csv files (through Paraview), but I don't know how to do the opposite. Note that in my case the coordinates contained in the csv file are perfectly conformal to the coordinates of the cell centres in the target mesh. The latter is a simple 64^3 cubic mesh with equally spaced hexahedrons. Thank you in advance for your help V. |
|
July 24, 2017, 11:25 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
I don't think there's a built-in way. It's fairly straight forward to write your own tool though that reads your input file, finds the corresponding cells (using the convieniently named mesh.findCell function) and sets the value. Your mesh is so small you probably don't even need to worry about parallelization.
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
July 24, 2017, 12:52 |
|
#3 | |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
I was suspecting this, what surprises me is that I've found a relatively low amount of people asking about this (missing) feature around the web...
Quote:
Thanks V. |
||
July 25, 2017, 05:41 |
|
#4 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
I wrote very similar code for my PhD, but it will take a while to dig it up again.
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
July 25, 2017, 05:52 |
|
#5 |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
||
July 27, 2017, 16:49 |
|
#6 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
Code:
for (long row=1; row<=csv_total_rows; row++) { for(long column=1; column<=csv_total_columns; column++) { long index = (row-1)*csv_total_columns+column-1; scalar xpos = csv_data[index].nodeposition[0]; scalar ypos = csv_data[index].nodeposition[1]; scalar zpos = csv_data[index].nodeposition[2]; vector pos(xpos, ypos, zpos); label ofCellLabel = vsf().mesh().findCell(pos); vsf[ofCellLabel] = csv_data[index].value(); } }
__________________
*On twitter @akidTwit *Spend as much time formulating your questions as you expect people to spend on their answer. |
|
July 28, 2017, 14:58 |
|
#7 |
Senior Member
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20 |
Ok, thanks.
|
|
June 17, 2019, 09:41 |
Where to implement this code?
|
#8 | |
New Member
Wolvi_Tin
Join Date: Jun 2019
Posts: 1
Rep Power: 0 |
Quote:
I am very new to OpenFoam and c++ coding. I have a similar case like this. Can you please help me on how and where should i implement this in my source code? Regards |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Salome cgns format mesh to SU2 | JPBLourenco | SU2 | 19 | November 18, 2019 03:11 |
UDF for Mapping 3D Experimental Data (Heat Generation) to Mesh | jbo214 | Fluent UDF and Scheme Programming | 1 | May 15, 2017 16:47 |
Mapping values from 2D mesh to 3D mesh boundary during runtime | benk | OpenFOAM Programming & Development | 1 | June 13, 2014 03:39 |
Compare two data sets same mesh | gregjunqua | OpenFOAM Post-Processing | 0 | February 24, 2014 21:02 |
Icemcfd 11: Loss of mesh from surface mesh option? | Joe | CFX | 2 | March 26, 2007 19:10 |