CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   C_NNODES UDF 'function' problem (

Matthew Brannock June 21, 2000 03:55

C_NNODES UDF 'function' problem
With a view of patching values at a set position into a cell I need to check that they are exactly bounded by the cell nodes. First I need to see how many nodes there are (by using C_NNODES 'function') so I can use the NODE_X, ... function to find the position of the nodes. Hence I've run into problems at step 1 (see the code below) where I'm trying to use C_NNODES, with the following error resulting at trying to compile the interpreted UDF:

cpp -Ie:\\fluent5.2/src -Ie:\\fluent5.2/cortex/src -Ie:\\fluent5.2/client/src -Ie:\\fluent5.2/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" e: est.c

Error: e:\test.c: line 23: non-integer subscript expression: unsigned char.

I've supplied the test code below, where am I going wrong?

I think problems will develop for me when using the NODE_X function because I don't know where the heck the 'node' pointer is going to be passed from, I just want to see how to use C_NNODES first.

PS: Please keep in mind I'm quite a novice when it comes to using C.

/************************************************** *********************/

/* interpreted UDF for patching values at initialisation */

/************************************************** *********************/

#include "udf.h"

DEFINE_INIT(my_init_function, domain) { cell_t c; Thread *thread; real xc[ND_ND];

thread_loop_c (thread,domain)


begin_c_loop_all (c,thread)



if (sqrt(ND_SUM(pow(xc[0] - 0.5,2.),

pow(xc[1] - 0.5,2.),

pow(xc[2] - 0.5,2.))) < 1.7) { /* checks whether inside spherical test region of interest - just to check if c and thread work in other functions (here C_CENTROID) and to limit number of points to print out in GUI */

int num;

num = C_NNODES(c,thread);

printf("num = %d\n", num);

C_U(c,thread) = 1.;



C_U(c,thread) = 0.;


end_c_loop_all (c,thread)

} }

Chris June 21, 2000 10:16

Re: C_NNODES UDF 'function' problem
That is a bug. It should work OK as is for compiled UDFs.

To make it work in the interpreted UDFs, change the line:

num = C_NNODES(c,thread);

to read:

num = cell_type_nnodes[(int)C_TYPE(c,thread)];


Matthew Brannock June 21, 2000 22:46

Re: C_NNODES UDF 'function' problem
Excellent, thankyou!

All times are GMT -4. The time now is 05:25.