canh.dv@seoultech.ac.kr |
December 4, 2023 06:06 |
Multiple DEFINE_ADJUST in a running time
Hi everyone,
I am running a problem with 2 DEFINE_ADJUST.
1st DEFINE_ADJUST collects data and assigns it to a global variable array.
2nd DEFINE_ADJUST takes the data from the global variable array and assigns it to fluent.
Code:
DEFINE_ADJUST(adjust_absorb_coe_to_global_matrix_bb, d)
{
cell_t c;
Thread *t;
face_t f;
real xc[ND_ND];
real xx, yy;
int i,j,m,n, count;
d = Get_Domain(1);
thread_loop_c(t,d)
{
if(THREAD_ID(t) == 2)
{
begin_f_loop(f,t)
{
F_CENTROID(xc,f,t);
xx = xc[0];
yy = xc[1];
m = (xx+0.05)/0.001;
n = yy/0.001;
count = 24*m+n;
BB[count] = C_ABS_COEFF(c,t);
printf("Global array BB[%d] = %f\n", count, BB[count]);
}
end_f_loop(f,t)
}
}
}
DEFINE_ADJUST(adjust_cal_intensity_depend_on_bb, d)
{
int i,j,m,n, count;
i = 0;
for(j = 0; j<25; j++)
{
AA[24*i+j] = 1000;
printf("AA[%d] = %f\n", 24*i+j, AA[24*i+j]);
}
for(i = 0; i<100; i++)
{
for(j = 0; j<25; j++)
{
if(i == 0)
{
AA[24*i+j] = AA[24*i+j];
printf("AA[%d] = %f\n", 24*i+j, AA[24*i+j]);
}
else
{
AA[24*i+j] = AA[24*(i-1)+j] * (1 - BB[24*(i-1)+j]);
printf("AA[%d] = %f\n", 24*i+j, AA[24*i+j]);
}
}
}
}
To get the precise result, the first DEFINE_ADJUST must run first and assign all the data to the global variable array, then the second DEFINE_ADJUST will get the data from the global variable array.
I found that these two functions run as follows: ADJUST-1 run, assign ~150 values, and then ADJUST-2 run. This process repeats 17 times.
I cannot understand why this happened. What I expect is ADJUST-1 runs one time, assign 2500 value, and then ADJUST-2 run one time and get data.
|