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

How to calculate the number of if conditions executed in a fluent udf?

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 14, 2020, 03:38
Default
  #41
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
After putting the suggested lines in the if condition am getting the same output.

#include "udf.h"
real sensor_temperature = 315.15

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
real sensor_temperature = 0.0; /* had to re-initialize again otherwise the sensor_temperature value was increasing after each timestep.*/
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);

xc = 0.000000;
yc = 0.000000;
zc = 1.500000;

if ((xc >= -0.468547) && (xc <= 0.493969))
{
if ((yc >= -0.51177) && (yc <= 0.428963))
{
if ((zc >= 1.34611) && (zc <= 1.59948))
{
xc = x[0];
yc = x[1];
zc = x[2];
sensor_temperature = sensor_temperature + C_T(c,t);
nt=nt+1.0;
}
}
}
}
end_c_loop(c,t)

}
# if RP_NODE
nt = PRF_GRSUM1(nt);
sensor_temperature = PRF_GRSUM1(sensor_temperature);
# endif
sensor_temperature /= nt;

Message0 ("xc = %f\n",xc);
Message0 ("yc = %f\n",yc);
Message0 ("zc = %f\n",zc);
Message0 ("nt = %f\n",nt);
Message0("sensor_temperature = %f\n",sensor_temperature);

}

output:
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 321814.000000
sensor_temperature = 315.150000
Shubhamp is offline   Reply With Quote

Old   January 14, 2020, 22:42
Default
  #42
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile code, read errors
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 14, 2020, 23:46
Default
  #43
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
My mistake, actually the mentioned output values were during the simulation (compiled without any errors) i.e. before the first iteration and after the first solution convergence step.
Thanks
Shubhamp is offline   Reply With Quote

Old   January 15, 2020, 01:59
Default
  #44
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
code above definitely has errors
at least you can't define any variable twice

compile code.

if you selected 92 cells using fluent adaptation tool, you expect to get nt=92
work on it
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 16, 2020, 19:30
Default
  #45
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
I have worked on the coordinate values and received 92 cells as desired. However, now the inlet velocity is not altering from 0.051 to 0 when tavg_abr > sensor_temperature. I have mentioned the problem beside the line in the code. Your suggestion is highly required.
Thanks

#include "udf.h"
real tavg_abr;
real UDSavg_abr;
real sensor_temperature;
int if_number = 0;

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
real sensor_temperature = 0.0;
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);

xc = x[0];
yc = x[1];
zc = x[2];

if ((xc >= -0.468547) && (xc <= 0.523969))
{
if ((yc >= -0.51177) && (yc <= 0.468963))
{
if ((zc >= 1.34611) && (zc <= 1.63948))
{

sensor_temperature = sensor_temperature + C_T(c,t);
nt=nt+1.0;
}
}
}
}
end_c_loop(c,t)

}
# if RP_NODE
nt = PRF_GRSUM1(nt);
sensor_temperature = PRF_GRSUM1(sensor_temperature);
# endif
sensor_temperature /= nt;

Message0 ("xc = %f\n",xc);
Message0 ("yc = %f\n",yc);
Message0 ("zc = %f\n",zc);
Message0 ("nt = %f\n",nt);
Message0("sensor_temperature = %f\n",sensor_temperature);

}
DEFINE_EXECUTE_AT_END(avg_inlet_tempandUDS)
{

int ID = 8;
Domain *d;
face_t f;
real area[ND_ND];
real a;
real area_tot = 0.0;
real tavg_abr = 0.0;
real UDSavg_abr = 0.0;
Thread *tf;
d = Get_Domain(1);
tf = Lookup_Thread(d,ID);
begin_f_loop(f,tf)
{
F_AREA(area,f,tf);
a = NV_MAG(area);
area_tot += a;
tavg_abr += F_T(f,tf)*a;
UDSavg_abr += F_UDSI(f,tf,0)*a;
}
end_f_loop(f,tf)

#if RP_NODE
area_tot = PRF_GRSUM1(area_tot);
tavg_abr = PRF_GRSUM1(tavg_abr);
UDSavg_abr = PRF_GRSUM1(UDSavg_abr);
#endif
tavg_abr /= area_tot;
UDSavg_abr /= area_tot;

Message0("tavg_abr = %f UDSavg_abr = %f area_tot = %f\n",tavg_abr, UDSavg_abr, area_tot);

}
DEFINE_PROFILE(velocity,t,i)
{

real velocity;
face_t f;
if ((tavg_abr < sensor_temperature))
{
velocity = 0.051;
total_fan_time++;
}
else
{
velocity = 0.0;
}
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)

}
DEFINE_ON_DEMAND(get_if_number)
{

Message0("******** int if_number = %d**************\n",if_number);

}
output:
tavg_abr = 315.147083 UDSavg_abr = 0.007000 area_tot = 18.720000
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 93.000000
sensor_temperature = 315.150000
step flow-time report-def-0 report-def-0 flow-time
178 3.5600e+02 -9.5644e-01 9.5472e-01 3.5600e+02 /* the volume flow rate is okay here as it is obeying the if condition in DEFINE_PROFILE macro for velocity */


Updating solution at time level N...
done.

tavg_abr = 315.156389 UDSavg_abr = 0.007000 area_tot = 18.720000
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 93.000000
sensor_temperature = 315.150000
step flow-time report-def-0 report-def-0 flow-time
179 3.5800e+02 -9.5644e-01 9.5472e-01 3.5800e+02 /* However here the volume flow rate should be zero as velocity should be zero according to DEFINE_PROFILE macro but it is not. What can be done to achieve this? Is the code not entering the 'else' condition?

******** int if_number = 179 ************** /* This is the iteration number. Can anything be done to obtain the number of timesteps instead of iterations? */
Shubhamp is offline   Reply With Quote

Old   January 21, 2020, 18:29
Default
  #46
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
Any suggestions on how to correct the above code?
Help is highly appreciated.

Thanks
Shubhamp is offline   Reply With Quote

Old   January 22, 2020, 02:22
Default
  #47
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
total_fan_time is not defined in your code

if_number is not calculated anywhere in code

all other parts should work with no errors
check velocity value on inlet boundary (where you've applied UDF)
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 22, 2020, 03:28
Default
  #48
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
Apologies for the typo error. I have attached the corrected code below. But receiving the same output as mentioned below against the code. Is there a way to obtain the number of time-steps instead of iterations. The velocity at the inlet boundary remains 0.051 m/s even when tavg_abr >= sensor_temperature. Please suggest if anything can be done.
Help is highly appreciated.

Thanks


#include "udf.h"
real tavg_abr;
real UDSavg_abr;
real sensor_temperature;
int if_number = 0;

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
real sensor_temperature = 0.0;
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);

xc = x[0];
yc = x[1];
zc = x[2];

if ((xc >= -0.468547) && (xc <= 0.523969))
{
if ((yc >= -0.51177) && (yc <= 0.468963))
{
if ((zc >= 1.34611) && (zc <= 1.63948))
{

sensor_temperature = sensor_temperature + C_T(c,t);
nt=nt+1.0;
}
}
}
}
end_c_loop(c,t)

}
# if RP_NODE
nt = PRF_GRSUM1(nt);
sensor_temperature = PRF_GRSUM1(sensor_temperature);
# endif
sensor_temperature /= nt;

Message0 ("xc = %f\n",xc);
Message0 ("yc = %f\n",yc);
Message0 ("zc = %f\n",zc);
Message0 ("nt = %f\n",nt);
Message0("sensor_temperature = %f\n",sensor_temperature);

}
DEFINE_EXECUTE_AT_END(avg_inlet_tempandUDS)
{

int ID = 8;
Domain *d;
face_t f;
real area[ND_ND];
real a;
real area_tot = 0.0;
real tavg_abr = 0.0;
real UDSavg_abr = 0.0;
Thread *tf;
d = Get_Domain(1);
tf = Lookup_Thread(d,ID);
begin_f_loop(f,tf)
{
F_AREA(area,f,tf);
a = NV_MAG(area);
area_tot += a;
tavg_abr += F_T(f,tf)*a;
UDSavg_abr += F_UDSI(f,tf,0)*a;
}
end_f_loop(f,tf)

#if RP_NODE
area_tot = PRF_GRSUM1(area_tot);
tavg_abr = PRF_GRSUM1(tavg_abr);
UDSavg_abr = PRF_GRSUM1(UDSavg_abr);
#endif
tavg_abr /= area_tot;
UDSavg_abr /= area_tot;

Message0("tavg_abr = %f UDSavg_abr = %f area_tot = %f\n",tavg_abr, UDSavg_abr, area_tot);

}
DEFINE_PROFILE(velocity,t,i)
{

real velocity;
face_t f;
if ((tavg_abr < sensor_temperature))
{
velocity = 0.051;
if_number++;
}
else
{
velocity = 0.0;
}
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)

}
DEFINE_ON_DEMAND(get_if_number)
{

Message0("******** int if_number = %d**************\n",if_number);

}
output:
tavg_abr = 315.147083 UDSavg_abr = 0.007000 area_tot = 18.720000
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 93.000000
sensor_temperature = 315.150000
step flow-time report-def-0 report-def-0 flow-time
178 3.5600e+02 -9.5644e-01 9.5472e-01 3.5600e+02 /* the volume flow rate is okay here as it is obeying the if condition in DEFINE_PROFILE macro for velocity */


Updating solution at time level N...
done.

tavg_abr = 315.156389 UDSavg_abr = 0.007000 area_tot = 18.720000
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 93.000000
sensor_temperature = 315.150000
step flow-time report-def-0 report-def-0 flow-time
179 3.5800e+02 -9.5644e-01 9.5472e-01 3.5800e+02 /* However here the volume flow rate should be zero as velocity should be zero according to DEFINE_PROFILE macro but it is not. What can be done to achieve this? Is the code not entering the 'else' condition?

******** int if_number = 179 ************** /* This is the iteration number. Can anything be done to obtain the number of timesteps instead of iterations? */
Shubhamp is offline   Reply With Quote

Old   January 22, 2020, 04:01
Default
  #49
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Can anything be done to obtain the number of timesteps instead of iterations?
calculate if_number using DEFINE_EXECUTE_AT_END macro

you may use messages to check if you inside condition or outside

check VELOCITY on boundary, not mass flow rate, or anything else
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 22, 2020, 05:28
Default
  #50
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
Thanks for suggestions to include DEFINE_EXECUTE_AT_END to get the if number. It is working now. I used the Facet average of the velocity magnitude at inlet and outlet but velocity is not entering the "tavg_abr >= sensor_temperature" and it is 0.051 always.

Thanks
Shubhamp is offline   Reply With Quote

Old   January 22, 2020, 05:49
Default
  #51
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
make velocity global variable
put if ((tavg_abr < sensor_temperature)) in execute_at_end macro
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 22, 2020, 06:44
Default
  #52
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
I did the same. And now i am getting the number of if_number at every timesteps. But the velocity value is remaining same even if tavg_abr > sensor_temperature.
Thanks
Shubhamp is offline   Reply With Quote

Old   January 22, 2020, 20:48
Default
  #53
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
I have attached the code with velocity as a global variable. Even then also the report-def-0 (volume flow rate) is not changing. I have included a line to show if inlet is on or off but it is also showing inlet is on even if the condition is not met. Please suggest if anything can be done.
Help is highly appreciated.
Thanks

#include "udf.h"

real velocity;
real tavg_abr;
real UDSavg_abr;
real sensor_temperature;
int if_number = 0;

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
real sensor_temperature = 0.0;
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);

xc = x[0];
yc = x[1];
zc = x[2];

if ((xc >= -0.468547) && (xc <= 0.523969))
{
if ((yc >= -0.51177) && (yc <= 0.468963))
{
if ((zc >= 1.34611) && (zc <= 1.63948))
{

sensor_temperature = sensor_temperature + C_T(c,t);
nt=nt+1.0;
}
}
}
}
end_c_loop(c,t)

}
# if RP_NODE
nt = PRF_GRSUM1(nt);
sensor_temperature = PRF_GRSUM1(sensor_temperature);
# endif
sensor_temperature /= nt;

Message0 ("xc = %f\n",xc);
Message0 ("yc = %f\n",yc);
Message0 ("zc = %f\n",zc);
Message0 ("nt = %f\n",nt);
Message0("sensor_temperature = %f\n",sensor_temperature);

}
DEFINE_EXECUTE_AT_END(avg_inlet_tempandUDS)
{

int ID = 8;
Domain *d;
face_t f;
real area[ND_ND];
real a;
real area_tot = 0.0;
real tavg_abr = 0.0;
real UDSavg_abr = 0.0;
Thread *tf;
d = Get_Domain(1);
tf = Lookup_Thread(d,ID);
begin_f_loop(f,tf)
{
F_AREA(area,f,tf);
a = NV_MAG(area);
area_tot += a;
tavg_abr += F_T(f,tf)*a;
UDSavg_abr += F_UDSI(f,tf,0)*a;
}
end_f_loop(f,tf)

#if RP_NODE
area_tot = PRF_GRSUM1(area_tot);
tavg_abr = PRF_GRSUM1(tavg_abr);
UDSavg_abr = PRF_GRSUM1(UDSavg_abr);
#endif
tavg_abr /= area_tot;
UDSavg_abr /= area_tot;

Message0("tavg_abr = %f UDSavg_abr = %f area_tot = %f\n",tavg_abr, UDSavg_abr, area_tot);

}
DEFINE_PROFILE(velocity1,t,i)
{

face_t f;
if ((tavg_abr <= sensor_temperature))
{
#if !RP_HOST
Message0("inlet is on");
#endif
velocity = 0.051;
}
else
{
#if !RP_HOST
Message0("inlet is off");
#endif
velocity = 0.0;
}
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)

}

DEFINE_EXECUTE_AT_END(get_if_number)
{
if (tavg_abr <= sensor_temperature)
{
if_number++;
}
Message0("******** int if_number = %d **************\n",if_number);

}

output:
tavg_abr = 315.147083 UDSavg_abr = 0.007000 area_tot = 18.720000
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 93.000000
sensor_temperature = 315.150000
******** int if_number = 179 **************
inlet is on step flow-time report-def-0 report-def-0 flow-time
178 3.5600e+02 -9.5644e-01 9.5472e-01 3.5600e+02

Updating solution at time level N...
done.

tavg_abr = 315.156389 UDSavg_abr = 0.007000 area_tot = 18.720000
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 93.000000
sensor_temperature = 315.150000
******** int if_number = 180 **************
inlet is on step flow-time report-def-0 report-def-0 flow-time
179 3.5800e+02 -9.5644e-01 9.5472e-01 3.5800e+02 /* report-def-0 should be 0 here as tavg_abr >sensor_temperature */
Shubhamp is offline   Reply With Quote

Old   January 23, 2020, 00:13
Default
  #54
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
change last 2 functions
Code:
DEFINE_PROFILE(velocity1,t,i)
{

face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)

}

DEFINE_EXECUTE_AT_END(get_if_number)
{
if (tavg_abr <= sensor_temperature)
{
velocity = 0.051;
Message0("++++++++ inlet is on ++++++\n");	
if_number++;
}
else 
{velocity = 0.0;
Message0("------- inlet is off -------\n");	
}
Message0("******** int if_number = %d **************\n",if_number);
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 23, 2020, 01:24
Default
  #55
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
Thanks for the suggestions. I incorporated your changes but receiving the same message i.e. inlet is on even when tavg_abr > sensor_temperature. I had also tried with DEFINE_ADJUST macro but getting the same result. Could there be any other reason why it is not entering the "else" loop? Your suggestions are highly required.
Thanks

#include "udf.h"

real velocity;
real tavg_abr;
real UDSavg_abr;
real sensor_temperature;
int if_number = 0;

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
real sensor_temperature = 0.0;
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(x,c,t);

xc = x[0];
yc = x[1];
zc = x[2];

if ((xc >= -0.468547) && (xc <= 0.523969))
{
if ((yc >= -0.51177) && (yc <= 0.468963))
{
if ((zc >= 1.34611) && (zc <= 1.63948))
{

sensor_temperature = sensor_temperature + C_T(c,t);
nt=nt+1.0;
}
}
}
}
end_c_loop(c,t)

}
# if RP_NODE
nt = PRF_GRSUM1(nt);
sensor_temperature = PRF_GRSUM1(sensor_temperature);
# endif
sensor_temperature /= nt;

Message0 ("xc = %f\n",xc);
Message0 ("yc = %f\n",yc);
Message0 ("zc = %f\n",zc);
Message0 ("nt = %f\n",nt);
Message0("sensor_temperature = %f\n",sensor_temperature);

}
DEFINE_EXECUTE_AT_END(avg_inlet_tempandUDS)
{

int ID = 8;
Domain *d;
face_t f;
real area[ND_ND];
real a;
real area_tot = 0.0;
real tavg_abr = 0.0;
real UDSavg_abr = 0.0;
Thread *tf;
d = Get_Domain(1);
tf = Lookup_Thread(d,ID);
begin_f_loop(f,tf)
{
F_AREA(area,f,tf);
a = NV_MAG(area);
area_tot += a;
tavg_abr += F_T(f,tf)*a;
UDSavg_abr += F_UDSI(f,tf,0)*a;
}
end_f_loop(f,tf)

#if RP_NODE
area_tot = PRF_GRSUM1(area_tot);
tavg_abr = PRF_GRSUM1(tavg_abr);
UDSavg_abr = PRF_GRSUM1(UDSavg_abr);
#endif
tavg_abr /= area_tot;
UDSavg_abr /= area_tot;

Message0("tavg_abr = %f UDSavg_abr = %f area_tot = %f\n",tavg_abr, UDSavg_abr, area_tot);

}

DEFINE_PROFILE(velocity1,t,i)
{

face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = velocity;
}
end_f_loop(f,t)

}

DEFINE_EXECUTE_AT_END(get_if_number)
{
if (tavg_abr <= sensor_temperature)
{
velocity = 0.051;
Message0("++++++++ inlet is on ++++++\n");
if_number++;
}
else
{velocity = 0.0;
Message0("------- inlet is off -------\n");
}
Message0("******** int if_number = %d **************\n",if_number);
}

Output:
tavg_abr = 315.147083 UDSavg_abr = 0.007000 area_tot = 18.720000
++++++++ inlet is on ++++++
******** int if_number = 179 **************
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 2.000000
sensor_temperature = 315.150000
step flow-time report-def-0 report-def-0 flow-time
178 3.5600e+02 -9.5644e-01 9.5472e-01 3.5600e+02

Updating solution at time level N...
done.

tavg_abr = 315.156389 UDSavg_abr = 0.007000 area_tot = 18.720000
++++++++ inlet is on ++++++
******** int if_number = 180 **************
xc = -2.738164
yc = 1.462940
zc = 4.978388
nt = 2.000000
sensor_temperature = 315.150000
step flow-time report-def-0 report-def-0 flow-time
179 3.5800e+02 -9.5644e-01 9.5472e-01 3.5800e+02 /* report-def-0 is still not 0 here when tavg_abr > sensor_temperature */
Shubhamp is offline   Reply With Quote

Old   January 23, 2020, 03:22
Default
  #56
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I've told you, you can't define variable twice in code but
Code:
#include "udf.h"

real velocity;
real tavg_abr;
real UDSavg_abr;
real sensor_temperature;
int if_number = 0;

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
real sensor_temperature = 0.0;
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;
wtf?
tobe
Code:
#include "udf.h"

real velocity;
real tavg_abr;
real UDSavg_abr;
real sensor_temperature;
int if_number = 0;

DEFINE_EXECUTE_AT_END(tsensor)
{

real x[ND_ND];
real xc,yc,zc,nt;
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
nt=0.0;
 sensor_temperature = 0.0;
check all your global variables

put messages everywhere and check which value you have on each step, find the place, where code doesn't work as you expect, fix it
Shubhamp likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   January 23, 2020, 19:19
Default
  #57
Member
 
South Australia
Join Date: Jan 2019
Posts: 32
Rep Power: 7
Shubhamp is on a distinguished road
Hello,
Apologies for not making that correction. Now the code works perfectly after changing the lines according to your suggestions.

Many Many thanks for the long discussion.
Shubhamp 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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 92 May 21, 2024 08:56
[General] Extracting ParaView Data into Python Arrays Jeffzda ParaView 30 November 6, 2023 22:00
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
How to use UDF to get the Global courant number at time in fluent 14.0? fangdian Fluent UDF and Scheme Programming 1 August 18, 2015 20:33
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


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