CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   My UDF works well with Fluent 16 but not with Fluent 19 (https://www.cfd-online.com/Forums/fluent-udf/208453-my-udf-works-well-fluent-16-but-not-fluent-19-a.html)

Ahmed A. Serageldin October 17, 2018 22:03

My UDF works well with Fluent 16 but not with Fluent 19
 
My UDF works well with Fluent 16 but did not works well with Fluent 19.
Is there any modification I have to do with my UDF or any setting in Fluent 19?
I attached The UDF to your consideration
#include "udf.h"

#define m 17
#define cp 4182

real Q[8761];
real avetempa=288.15;

DEFINE_ON_DEMAND(read_data)
{
int i;
real b;
FILE *rfile; /* declare a FILE pointer */
#if RP_HOST
host_to_node_sync_file("test.dat");
#endif
#if RP_NODE
host_to_node_sync_file("/");
#endif
rfile = fopen("data.txt", "r"); /* open file for reading */
#if RP_HOST
Message("file opened\n");
#endif
for (i=0;i<8760;i++)
{
fscanf(rfile, "%f\n", &b); /* that supposes one value per line */
Q[i]=b;
}
fclose(rfile);
#if RP_HOST
Message("file closed\n");
#endif
}

/* Defining outlet temperature.*/
DEFINE_ADJUST(average_exit_temp,domain)
{
real tempa=0.0;
real totalarea=0.0;
int ID1 = 4;//'108; /* the outlet boundary condition identifier*/
int ktt=N_TIME-1;

#if !RP_HOST
face_t f1;
real A[ND_ND];
Thread *outlet_thread = Lookup_Thread(domain,ID1);

begin_f_loop(f1,outlet_thread)
{
if PRINCIPAL_FACE_P(f1,outlet_thread)
{
F_AREA(A,f1,outlet_thread);
totalarea +=NV_MAG(A);
tempa +=NV_MAG(A)*F_T(f1,outlet_thread);
}
}
end_f_loop(f1,outlet_thread)

#if RP_NODE
tempa = PRF_GRSUM1(tempa);
totalarea = PRF_GRSUM1(totalarea);
#endif

avetempa= tempa/totalarea;
if(ktt==0) avetempa=288.15;
# endif

node_to_host_real_1(avetempa);

#if RP_HOST
Message("average temperature : %g K q7=%g\n",avetempa,Q[ktt]);
#endif
}

DEFINE_PROFILE(Inlettemp,thread,pos)
{
face_t f;
real x[ND_ND],btt;
real ftime = CURRENT_TIME;
int k_time=N_TIME;
real qheat=Q[k_time-1];

#if RP_NODE
begin_f_loop(f, thread)
{
if PRINCIPAL_FACE_P(f,thread)
{
if(ftime<1200) btt=288.15;
else btt = avetempa +((qheat-0.0000008*ftime)/(m*cp/60));
F_PROFILE(f, thread, pos) =btt;
}
}
end_f_loop(f, thread)
#endif
}

LuckyTran October 18, 2018 12:53

Fluent v19 and onwards no longer supports serial mode because they want the environment to be the same from now on. A consequence is that udf's which previously only worked in serial will no longer work because there is no longer a serial mode.


You can start Fluent in serial mode by passing the -t0 flag. Launching Fluent in serial mode will actually start parallel Fluent, equivalent to the -t1 flag.


Or fix your udf. Sorry I'm too lazy to debug your udf.

Ahmed A. Serageldin October 18, 2018 19:17

Quote:

Originally Posted by LuckyTran (Post 710508)
Fluent v19 and onwards no longer supports serial mode because they want the environment to be the same from now on. A consequence is that udf's which previously only worked in serial will no longer work because there is no longer a serial mode.


You can start Fluent in serial mode by passing the -t0 flag. Launching Fluent in serial mode will actually start parallel Fluent, equivalent to the -t1 flag.


Or fix your udf. Sorry I'm too lazy to debug your udf.

Thank you for kindly reply.
I used parallel fluent on Fluent 16, and this UDF is working good but when I tried it with Fluent 19 it compiled without errors, and I hooked the inlet profile and executed the read data macros but when I initialized and started calculation I found that q_time=0 and did not change with time. q_time values are stored in the data.txt file which has 8761 readings
what do you think is the wrong is it the structure of UDF or problem in Fluent 19?

LuckyTran October 19, 2018 11:38

What the heck is q_time? It's not in your udf anywhere.


All times are GMT -4. The time now is 03:02.