CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Simple UDF array question [Fluent] (http://www.cfd-online.com/Forums/fluent-udf/100040-simple-udf-array-question-fluent.html)

Patrick1 April 19, 2012 01:41

Simple UDF array question [Fluent]
 
Hello,

Edit: Solved..array positions start at 0 and not 1 in C ;)
I'm making a simple UDF that is defined by a matrix of values, but am having problems in actually getting the UDF the access the matrix properly. Here's the bones of my code:


Quote:

real velocity; /*velocity value*/
real matrix[2]; /*1D array storing 2 velocity values*/
int value; /*variable describing the array position eg. column 1,2..*/

matrix[1]=1.1;
matrix[2]=1.5;

value=1;

{
F_CENTROID(radi_pos,f,thread);
velocity=matrix[value]; /* <<<PROBLEM LINE /*
F_PROFILE(f, thread, position) = velocity;
}
This code does NOT work for me. However, if I replace the problem line with:


Quote:

velocity=matrix[1]; or
velocity=matrix[2];
then my code works..so how can I access the matrix by an integer variable rather than by an actual integer?

Will post the full code if need be.

Thanks,
Patrick


All times are GMT -4. The time now is 01:45.