CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CONVERGE (https://www.cfd-online.com/Forums/converge/)
-   -   Reading data from file using user_input.c (https://www.cfd-online.com/Forums/converge/201440-reading-data-file-using-user_input-c.html)

cmohapatra May 2, 2018 17:08

Reading data from file using user_input.c
 
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

xieshengbai May 14, 2018 17:28

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.


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