Setting cell variable values in a fluid zone using UDF
I am fairly new to ansys and very new to the whole concept of UDF's. I have some C++ programming knowledge ( fairly basic ) and currently learning C now aswell.
I am trying to create a UDF to exports cell data with a small fluid zone and I think i figured out the commands I need for those
value = C_T(c,t)
// write value out to file
however I am also trying to get a corresponding UDF for reading in particular variables from a file and assigning the value to a cell.
I am using this per iteration and I am not using the DEFINE_PROFILE macro to hook to the gui for various reasons and as such C_PROFILE(c,t,i) will not work for me in this situation.
I since I am not using DEFINE_Profile I have no way of understanding how I can set the value of a particular variable within a cell, for example.
// read in value, store in var
// temperature in cell c is now equal to var
// repeat loop for next cell and read in another line
If anyone knows the command to allow me to write to a particular variable within a cell please let me know, thank you.
The order of cells in "begin_loop_c" can not be guaranteed which means you wont be able to assign the value for the temperature if there is only one variable in your input file. The input should looks like
x1 y1 z1 t1
x2 y2 z2 t2
Then you can loop over all the cells in a particular thread, find the nearest coordinates from the input file, and assign the corresponding temperature for this cell.
Appreciate the advice, however my question is what the command is to write a particular variable to a particular cell?
C_T(c,t) will return a value for the temperature variable within a particular cell, but I do not know the command to set / write the particular variable into a cell's data.
I want to hook this to an adjust UDF so that it is called at start of every iteration aswell.
The expansion of C_T(c,t) macro results in an l-value, so that if you want to specify values for some particular cells you could used
no...I did not know that! :D
reading the UDF manual it seemed that those variable macro's could only be used like this
var = C_T(c,t) ( or C_P(c,t) etc )
And another post around here had stated that you can not use it to set a value within a cell, only to return a value from within a cell.
Because of this, i thought that C_T(c,t) returned an actual number (i.e a constant) and did not consider that it was an expression that could be an lvalue.
Does this mean I can use those C_T(c,t) macro's for both setting and getting of variables? that would be fantastic!
The only thing left to do if that is the case is to store the centroid of each cell as you suggested, since the loops do not go through a specific order.
EDIT: looking at my first post, i actually made a typing error, I had meant to state the following within that first loop.
value = C_T(c,t)
HI! Finally how did you solve this problem? Thanks!!
|All times are GMT -4. The time now is 06:52.|