CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

UDF DEFINE_EXECUTE_AT_END

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   May 13, 2008, 16:44
Default UDF DEFINE_EXECUTE_AT_END
  #1
Giacomo de Renzi
Guest
 
Posts: n/a
Good morning.. I've got a problem with a DEFINE_EXECUTE_AT_END UDF, the problem is to calculate the average temperature on a boundary condition at every time step, and then compare it with a check temperature to decide if activate or not an air conditioner, the error which occures is the seguent:

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: ()

and the UDF is:

#include "udf.h" #define DeltaT_APC 10 #define DeltaT_CPU 20

real t_cpu_in,t_cond_in; real current_time,step;

DEFINE_EXECUTE_AT_END(T_cpu_in) { real temp1,volume,vol_tot;

Thread *cpu_in; cell_t c;

step = CURRENT_TIMESTEP; current_time = CURRENT_TIME;

if (current_time > 2*step) { begin_c_loop(c,cpu_in) { volume=C_VOLUME(c,cpu_in); temp1=C_T_M1(c,cpu_in); vol_tot += volume; t_cpu_in += temp1 * volume; } end_c_loop(c,cpu_in)

t_cpu_in /= vol_tot; } else { t_cpu_in = 293.15; } printf("t_cpu_in: %g\n", t_cpu_in); }

DEFINE_EXECUTE_AT_END(T_cond_in) { real temp2,volume,vol_tot;

Thread *cond_in; cell_t c;

step = CURRENT_TIMESTEP; current_time = CURRENT_TIME;

if (current_time > 2*step) { begin_c_loop(c,cond_in) { volume=C_VOLUME(c,cond_in); temp2=C_T_M1(c,cond_in); vol_tot += volume; t_cond_in += temp2 * volume;

} end_c_loop(c,cond_in)

t_cond_in /= vol_tot; } else { t_cond_in = 293.15; } }

DEFINE_PROFILE(inlet_x_cond_out, cond_out, index) {

real x[ND_ND]; real y; face_t f; begin_f_loop(f, cond_out) { F_CENTROID(x,f,cond_out); y = x[1]; F_PROFILE(f, cond_out, index) = t_cpu_in + DeltaT_CPU; } end_f_loop(f, cond_out) }

DEFINE_PROFILE(inlet_x_cpu_out, cpu_out, index) {

real x[ND_ND]; real y; face_t f;

if (current_time > step && t_cpu_in > 293.15)

begin_f_loop(f, cpu_out) { F_CENTROID(x,f,cpu_out); y = x[1]; F_PROFILE(f, cpu_out, index) = t_cond_in - DeltaT_APC; } end_f_loop(f, cpu_out) }

thank you, I hope You could help me, Giacomo de Renzi
  Reply With Quote

Old   May 13, 2008, 20:43
Default Re: UDF DEFINE_EXECUTE_AT_END
  #2
Giacomo de Renzi
Guest
 
Posts: n/a
reading UDF_manual I found that I need to use user-defined scalars to have access to C_T_M1: "! Note that data from C_T_M1 is available only if user-defined scalars are used."

has someone got experience with UDS, what kind of UDS I could use to solve my problem? and how?

thanks, Giacomo de Renzi

  Reply With Quote

Old   May 15, 2008, 10:25
Default Re: UDF DEFINE_EXECUTE_AT_END
  #3
HP
Guest
 
Posts: n/a
Just in case, i'm right...

C_VOLUME(c,t);

I think t should be the thread of your mixture and not a cell thread. Before looping over your cells you should probably loop over all threads. Or you can use Lookup_Thread(domain,Zone_ID) to get your mixture thread

  Reply With Quote

Old   May 15, 2008, 11:55
Default Re: UDF DEFINE_EXECUTE_AT_END
  #4
Giacomo de Renzi
Guest
 
Posts: n/a
thanks for answering.. I tried using what you suggested me but the same error occurs. (I've also another questione to make.. a Zone is a domain or a thread?)

that's the UDF using ('Lookup_Thread'): (I tried also using a loop over all threads but it's the same..) can you help me?

DEFINE_EXECUTE_AT_END(T_cpu_in) { real temp1,volume,vol_tot; Domain *d; Thread *t = Lookup_Thread(d,6); cell_t c;

step = CURRENT_TIMESTEP; current_time = CURRENT_TIME;

if (current_time > step) { begin_c_loop(c,t) { volume=C_VOLUME(c,t); temp1=C_T(c,t); vol_tot += volume; t_cpu_in += temp1 * volume; } end_c_loop(c,t)

t_cpu_in /= vol_tot; } else { t_cpu_in = 293.15; } printf("t_cpu_in: %g\n", t_cpu_in); }
  Reply With Quote

Old   May 16, 2008, 05:31
Default Re: UDF DEFINE_EXECUTE_AT_END
  #5
Giacomo de Renzi
Guest
 
Posts: n/a
I tried also the DEFINE_ON_DEMAND UDF copied by the Fluent_UDF_Manual, and the same error occurs.... why does it happen??? please help me!!

that's the UDF, exactly copied by the manual:

#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) } }
  Reply With Quote

Old   March 25, 2010, 05:01
Default the same question
  #6
New Member
 
Yang Chunlei
Join Date: Jun 2009
Posts: 1
Rep Power: 0
ycl229 is on a distinguished road
I have the same question that i have not solved.
ycl229 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
DEFINE_EXECUTE_AT_END( ) error jim FLUENT 0 June 15, 2006 03:05
Question about DEFINE_EXECUTE_AT_END macro Vishal FLUENT 4 March 10, 2006 06:24


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