CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How execute DEFINE_ON_DEMAND udf in (section 2.2.8 (https://www.cfd-online.com/Forums/fluent/50424-how-execute-define_on_demand-udf-section-2-2-8-a.html)

Alireza HOS January 29, 2009 12:26

How execute DEFINE_ON_DEMAND udf in (section 2.2.8
 
Hi I tried to use a UDF from UDFHelp(section 2.2.8) but it has errors.

1-I compiled it without error

2-I defined (Define->user-Defined->Memory) in this case i select 1

3-using: (Define->user-Defined->Execute on Demand)

but i receive an error:

Error: FLUENT received fatal signal (ACCESS_VIOLATION)

1. Note exact events leading to error.

2. Save case/data under new name.

3. Exit program and restart to continue.

4. Report error to your distributor.

Error Object: ()

Would you please guide me why do i have this error. Also i checked it with different computers.

The macro is mentioned in following:

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

UDF to calculate temperature field function and store in

user-defined memory. Also print min, max, avg temperatures. ************************************************** *********************/ #include "udf.h"

DEFINE_ON_DEMAND(on_demand_calc) {

Domain *d; /* declare domain pointer since it is not passed as an

argument to the DEFINE macro */

real tavg = 0.;

real tmax = 0.;

real tmin = 0.;

real temp,volume,vol_tot;

Thread *t;

cell_t c;

d = Get_Domain(1); /* Get the domain using Fluent utility */

/* Loop over all cell threads in the domain */

thread_loop_c(t,d)

{

/* Compute max, min, volume-averaged temperature */

/* Loop over all cells */

begin_c_loop(c,t)

{

volume = C_VOLUME(c,t); /* get cell volume */

temp = C_T(c,t); /* get cell temperature */

if (temp < tmin || tmin == 0.) tmin = temp;

if (temp > tmax || tmax == 0.) tmax = temp;

vol_tot += volume;

tavg += temp*volume;

}

end_c_loop(c,t)

tavg /= vol_tot;

printf("\n Tmin = %g Tmax = %g Tavg = %g\n",tmin,tmax,tavg);

/* Compute temperature function and store in user-defined memory*/

/*(location index 0) */

begin_c_loop(c,t)

{

temp = C_T(c,t);

C_UDMI(c,t,0) = (temp-tmin)/(tmax-tmin);

}

end_c_loop(c,t)

} }


bohis February 1, 2009 10:23

Re: How execute DEFINE_ON_DEMAND udf in (section 2
 
thread_loop_c(t,d) is not closed with bracket! Moreover, t_avg and vol_tot have to be initialized!!!

good luck



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