|
[Sponsors] |
use one Define macro into another Define macro ? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 17, 2014, 17:45 |
use one Define macro into another Define macro ?
|
#1 |
New Member
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 13 |
hi
is it possible use define macro like this: DEFINE_DELTAT(mydeltat, domain) { . . . DEFINE_ON_DEMAND(on_demand_calc) { ...... } . . . } |
|
December 17, 2014, 21:37 |
|
#2 |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
||
December 18, 2014, 03:01 |
|
#3 |
New Member
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 13 |
I need to find max temp in DEFINE_DELTAT's commands.
do u have any idea? |
|
December 18, 2014, 04:48 |
|
#4 |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
||
December 18, 2014, 05:01 |
|
#5 |
New Member
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 13 |
So why in Fluent UDF manual used DEFINE_ON_DEMAND to find max Temp?
Code:
/********************************************************************** 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 ANSYS 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) } } |
|
December 18, 2014, 05:13 |
|
#6 |
Member
Join Date: Jul 2013
Posts: 80
Rep Power: 13 |
DEFINE_DELTAT is used to define the time step in transient calculations.
DEFINE_ON_DEMAND is used mainly for post process purposes, for example, to show the contours of a used defined function such as (temp-tmin)/(tmax-tmin). |
|
December 18, 2014, 05:16 |
|
#7 |
New Member
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 13 |
thanks
I will try your suggestion |
|
December 18, 2014, 06:22 |
|
#8 |
New Member
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 13 |
my udf is:
Red number is line number in udf commands . Code:
DEFINE_DELTAT(mydeltat, domain) { real time_step; real T_max=0.0 ; real T1=303.0 ; real T2=300.5 ; real T3=304.0 ; Thread t; cell_t c; 54 thread_loop_c(t,domain) { 56 begin_c_loop(c,t) { 58 temp = C_T(c,t); if (temp > T_max || T_max == 0.0) T_max = temp; } end_c_loop(c,t) } if (T_max < T1) time_step = 1.0; else time_step = 0.00001; return time_step; } error after build in compiler window: Done. (chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h Paper_PCM_Prop_and_DeltaT_v2.c ..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(54) : error C2440: '=' : cannot convert from 'thread_struct *' to 'Thread' ..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(54) : error C2088: '!=' : illegal for struct ..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(54) : error C2232: '->next' : left operand has 'struct' type, use '.' ..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(56) : error C2232: '->nelements' : left operand has 'struct' type, use '.' ..\..\src\Paper_PCM_Prop_and_DeltaT_v2.c(58) : error C2232: '->storage' : left operand has 'struct' type, use '.' Done. whats wrong in udf? |
|
December 18, 2014, 21:39 |
|
#9 | |
Senior Member
Join Date: Feb 2010
Posts: 164
Rep Power: 17 |
"Thread t;" should be "Thread *t;", and temp must be declared before use.
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Which DEFINE macro should I go with? | darang | FLUENT | 7 | July 23, 2012 14:41 |
udf explaination | Ijaz | Fluent UDF and Scheme Programming | 4 | May 8, 2012 05:24 |
UDF problem | libia87 | Fluent UDF and Scheme Programming | 1 | May 4, 2012 22:49 |
UDF carbon conversion | papteo | Fluent UDF and Scheme Programming | 1 | August 18, 2011 08:32 |
Free surface boudary conditions with SOLA-VOF | Fan | Main CFD Forum | 10 | September 9, 2006 13:24 |