CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Help with UDF (https://www.cfd-online.com/Forums/fluent/42284-help-udf.html)

Blas September 11, 2006 12:45

Help with UDF
 
Hi, can anybody help me out with this simple UDF. It compiles and loads fine but I keep getting the ACCESS VIOLATION error when iteration starts.

The UDF is as follows:

#include "udf.h" DEFINE_ADJUST(temp_cell, d) {

Thread *t;

cell_t c;

thread_loop_c(t,d)

{

begin_c_loop(c,t)

{

C_UDMI(c,t,0) = C_T(c,t);

printf("temp pared [C] = %f\n", C_UDMI(c,t,0));

}

end_c_loop(c,t)

} }

Thanks

MarkRussell September 11, 2006 14:19

Re: Help with UDF
 
Did you remember to set the the user defined memory?

Mark

Blas September 11, 2006 15:49

Re: Help with UDF
 
Mark, thanks for your help. I have now set the memory locations to 100 (I don't know whether this is too many locations or not)and apparently is the UDF is working (at least the access violation is gone) The thing is this UDF should print the cells' temperatures to the console window but nothing happens. Any idea of what may be going on?

MarkRussell September 12, 2006 02:54

Re: Help with UDF
 
Blas,

1. in your code you have

C_UDMI ...

this is the User Defined Memory, and since you only have one (referred to by the last entry in the array of C_UDMI, i.e. 0), recall C and C++ arrays start at zero, set the number to 1, not 100.

2. Try 'Message' instead of printf.

This should work

i.e. Message("hello world");

Mark


Blas September 14, 2006 07:50

Re: Help with UDF
 
Hi Mark I have been out for a couple of days. Today I came back and used Message instead of printf and the UDF worked fine!!. Thanks a lot again. Regards Blas


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