CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Udf problem (https://www.cfd-online.com/Forums/fluent/33473-udf-problem.html)

Karthick April 14, 2004 10:46

Udf problem
 
Hello all

I am writing a simple udf to get the temperature at each cell during iterations. It is interpreting well. But when I try to run the iterations, it is showing Access_violation error and it comes out.

What may be the problem? Also I am having one more doubt. Whether can I include the udf in between the runs? It is leading to always error. Whether is it permissible in Fluent.

My udf is given below: #include "udf.h" DEFINE_EXECUTE_AT_END(my_execute) { Domain *d;

int ID=2;

Thread *t=Lookup_Thread(d,ID);

cell_t c;

FILE *fp4;

int i;

real temp=0.;

fp4=fopen("temp_zone2.dat","w");

begin_c_loop(c,t)

{

temp=C_T(c,t);

fprintf(fp4,"%g\n",temp);

i++;

}

end_c_loop(c,t) printf("The %d values ", i); fclose(fp4); }


Ajay April 14, 2004 18:33

Re: Udf problem
 
Karthik ,

you are missing

d=getdomain(1), use it before

Thread *t=Lookup_Thread(d,ID);

Should work then

-Ajay

Karthick April 15, 2004 01:51

Re: Udf problem
 
Since Get_Domain(1) and Thread *t=Lookup_Thread(d,ID) both are same, we can use either of two.

Is it right?

Regards Karthick

Ajay April 15, 2004 10:05

Re: Udf problem
 
No they are not the same .

Thread *t=Lookup_Thread(d,ID)

will return a thread pointing to the ID number which you specify .Each boundary or zone is associated with an unique ID. but the other paramter you need which is d the domain pointer is not passed automatically when you use define_execute_at_end you need to get the domain ponter by using d=get_domain(1)

-Ajay


All times are GMT -4. The time now is 21:48.