|
[Sponsors] |
May 2, 2018, 17:08 |
Reading data from file using user_input.c
|
#1 |
New Member
chinmoy
Join Date: May 2017
Posts: 2
Rep Power: 0 |
Hi,
I want to read data from files, which has multiple rows (m) and columns(n). e.g. first three columns have spatial coordinates, next three columns have components of the velocity vector , next three columns have other scalar variable data. I want to read these information as user defined variables(list) e.g. myVel(m,3),myLoc(m,3),myTemp(m,1) and store them for further calculation. I would also like to deallocate the memory associated with these variable. So that, I can use these variable to read another set of data from another file after certain time steps. Kindly, guide. Thanks Chinmoy Last edited by cmohapatra; May 2, 2018 at 20:00. |
|
May 14, 2018, 17:28 |
|
#2 |
Member
Shengbai Xie
Join Date: Aug 2016
Location: Convergent Science, Madison WI
Posts: 60
Rep Power: 9 |
Hi,
It would be helpful to give more detailed information of the purpose of the udf. Do you want to read this array of data as the initial condition or just store them independently for some other purpose? For the former, actually, you don't need a udf because you can put them in a separate file and map from that file. The format of the map file can be find in the v24 Manual (page 753, chapter 22.6.1). For the latter, you can edit the udf as a normal c programming, e.g., declare the array pointers, allocate the array (malloc), read the file (fgets, sscanf, fscanf, etc), manipulate the array, then deallocate it (free). If you want to use the array globally, simply add the declaration to user_header.h. I don't know if I answered your question, but if you need further help, please contact support@convergecfd.com. Thanks. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFoam "Permission denied" and "command not found" problems. | iyidaniel@yahoo.co.uk | OpenFOAM Running, Solving & CFD | 11 | January 2, 2018 06:47 |
what is swap4foam ?? | AB08 | OpenFOAM | 28 | February 2, 2016 01:22 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 03:23 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 12:41 |
ParaView Compilation | jakaranda | OpenFOAM Installation | 3 | October 27, 2008 11:46 |