CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   How to make it work on parallel mode (https://www.cfd-online.com/Forums/fluent/223007-how-make-work-parallel-mode.html)

vivek162 December 17, 2019 18:58

How to make it work on parallel mode
 
This UDF works perfectly in serial mode,

/************************************************** ********************
UDF to calculate temperature at outlet and use it as a inlet temperature (for closed loop )

************************************************** *********************/
#include "udf.h"
#include "prf.h"
#include "para.h"

real tavg, Tavg;
DEFINE_EXECUTE_AT_END(average_temp)
{
#if !RP_HOST
real temper = 0.0;
real area = 0.0;
real area_tot = 0.0;

Domain *d;
face_t f;
real A[ND_ND];

int zone_ID;
int ID = 7; /*outlet boundary wall*/
Thread *t;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);
tavg = 0.0;
Tavg = 0.0;

begin_f_loop(f,t)
{
F_AREA(A,f,t);
area = NV_MAG(A);
area_tot += area;
temper = F_T(f,t);
tavg += temper*area;
}
end_f_loop(f,t)
Tavg = tavg/=area_tot;

printf("Tavg = %g Total_area = %g\n",Tavg,area_tot);
#endif
}

#include "udf.h"
DEFINE_PROFILE(inlet_temp,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = tavg;
}
end_f_loop(f,t)
/* printf("Inlet_temperature = %g\n",tavg); */
#endif
}



But when i try to compile it,

I am getting an error

Tavg = -nan(ind) Total_area = 0
Tavg = -nan(ind) Total_area = 0
Tavg = -nan(ind) Total_area = 0
Tavg = 295 Total_area = 7.83488e-05
Tavg = -nan(ind) Total_area = 0
Tavg = -nan(ind) Total_area = 0

I need help on how to use PRF_GSUM1(....)

Светлана December 17, 2019 21:31

Can you not use periodic BC to couple inlet and outlet?

AlexanderZ December 17, 2019 23:04

Code:

/************************************************** ********************
UDF to calculate temperature at outlet and use it as a inlet temperature (for closed loop )

************************************************** *********************/
#include "udf.h"
#include "prf.h"
#include "para.h"

real tavg, Tavg;
DEFINE_EXECUTE_AT_END(average_temp)
{
real temper = 0.0;
real area = 0.0;
real area_tot = 0.0;

Domain *d;
face_t f;
real A[ND_ND];

int zone_ID;
int ID = 7; /*outlet boundary wall*/
Thread *t;
d = Get_Domain(1);
t = Lookup_Thread(d,ID);
tavg = 0.0;
Tavg = 0.0;

begin_f_loop(f,t)
{
F_AREA(A,f,t);
area = NV_MAG(A);
area_tot += area;
temper = F_T(f,t);
tavg += temper*area;
}
end_f_loop(f,t)
# if RP_NODE /* Perform node synchronized actions here; Does nothing in Serial */
area_tot = PRF_GRSUM1(area_tot);
tavg = PRF_GRSUM1(tavg);
# endif /* RP_NODE */
Tavg = tavg/=area_tot;
Message0("Tavg = %g Total_area = %g\n",Tavg,area_tot);
}

DEFINE_PROFILE(inlet_temp,t,i)
{
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = tavg;
}
end_f_loop(f,t)

}


vivek162 December 19, 2019 14:52

Dear Tkachenko,

Yes, Periodic BC works perfectly but I also have to use outlet temperature to calculate thermal properties.


All times are GMT -4. The time now is 12:01.