CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   reading "global" variables in a UDF macro? (https://www.cfd-online.com/Forums/fluent-udf/77730-reading-global-variables-udf-macro.html)

bawfuls July 1, 2010 14:27

reading "global" variables in a UDF macro?
 
I'm not sure if what I want to do is possible. I'm using the DEFINE_SOURCE macro, and I'd like to read source terms from a pre-existing data file. I understand I could use DEFINE_RW_FILE to read the entire file into an array, and search the array for the term I need. However, this would be reading in the file to a large array every time the UDF gets called (i.e. for every cell in the mesh) and feels like an inefficient programing method. What I'd rather do is have fluent read in the data file to an array once, and then have the DEFINE_SOURCE macro search that array for the proper value each time it's called.

Is there any way to do this?

gearboy July 1, 2010 21:22

Quote:

Originally Posted by bawfuls (Post 265327)
I'm not sure if what I want to do is possible. I'm using the DEFINE_SOURCE macro, and I'd like to read source terms from a pre-existing data file. I understand I could use DEFINE_RW_FILE to read the entire file into an array, and search the array for the term I need. However, this would be reading in the file to a large array every time the UDF gets called (i.e. for every cell in the mesh) and feels like an inefficient programing method. What I'd rather do is have fluent read in the data file to an array once, and then have the DEFINE_SOURCE macro search that array for the proper value each time it's called.

Is there any way to do this?

Use UDM, and read the array into UDM when loading the library. DEFINE_EXECUTE_ON_LOADING


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