CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

use one Define macro into another Define macro ?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By gearboy
  • 1 Post By upeksa
  • 1 Post By gearboy

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 17, 2014, 16:45
Default use one Define macro into another Define macro ?
  #1
New Member
 
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 12
ho3ein.agl is on a distinguished road
hi

is it possible use define macro like this:

DEFINE_DELTAT(mydeltat, domain)
{
.
.
.
DEFINE_ON_DEMAND(on_demand_calc)
{

......

}

.
.
.
}
ho3ein.agl is offline   Reply With Quote

Old   December 17, 2014, 20:37
Default
  #2
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Absolutely impossible.

Quote:
Originally Posted by ho3ein.agl View Post
hi

is it possible use define macro like this:

DEFINE_DELTAT(mydeltat, domain)
{
.
.
.
DEFINE_ON_DEMAND(on_demand_calc)
{

......

}
.
.
.
}
gearboy is offline   Reply With Quote

Old   December 18, 2014, 02:01
Default
  #3
New Member
 
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 12
ho3ein.agl is on a distinguished road
I need to find max temp in DEFINE_DELTAT's commands.
do u have any idea?
ho3ein.agl is offline   Reply With Quote

Old   December 18, 2014, 03:48
Default
  #4
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
Quote:
Originally Posted by ho3ein.agl View Post
I need to find max temp in DEFINE_DELTAT's commands.
do u have any idea?
Just loop over all the cells in your DEFINE_DELTAT macro.
ho3ein.agl likes this.
gearboy is offline   Reply With Quote

Old   December 18, 2014, 04:01
Default
  #5
New Member
 
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 12
ho3ein.agl is on a distinguished road
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)
}
}
ho3ein.agl is offline   Reply With Quote

Old   December 18, 2014, 04:13
Default
  #6
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 12
upeksa is on a distinguished road
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).
ho3ein.agl likes this.
upeksa is offline   Reply With Quote

Old   December 18, 2014, 04:16
Default
  #7
New Member
 
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 12
ho3ein.agl is on a distinguished road
thanks

I will try your suggestion
ho3ein.agl is offline   Reply With Quote

Old   December 18, 2014, 05:22
Default
  #8
New Member
 
hosein
Join Date: Sep 2013
Posts: 16
Rep Power: 12
ho3ein.agl is on a distinguished road
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?
ho3ein.agl is offline   Reply With Quote

Old   December 18, 2014, 20:39
Default
  #9
Senior Member
 
Join Date: Feb 2010
Posts: 164
Rep Power: 17
gearboy is on a distinguished road
"Thread t;" should be "Thread *t;", and temp must be declared before use.

Quote:
Originally Posted by ho3ein.agl View Post
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?
ho3ein.agl likes this.
gearboy is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which DEFINE macro should I go with? darang FLUENT 7 July 23, 2012 13:41
udf explaination Ijaz Fluent UDF and Scheme Programming 4 May 8, 2012 04:24
UDF problem libia87 Fluent UDF and Scheme Programming 1 May 4, 2012 21:49
UDF carbon conversion papteo Fluent UDF and Scheme Programming 1 August 18, 2011 07:32
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 12:24


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