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/)
-   -   saving C_UDMI from F_UDMI (global variable) (https://www.cfd-online.com/Forums/fluent-udf/244039-saving-c_udmi-f_udmi-global-variable.html)

qntldoql July 19, 2022 01:42

saving C_UDMI from F_UDMI (global variable)
 
I am currently trying to save the temperature values at the interface (at the boundary of the domain) in the global variable and access it to set the C_UDMI of the domain to be the temperature values at the interface according to their x-coordinate. (therefore same temperature vertically throughout the domain).



currently UDF I am using works perfectly in serial mode. But, in parallel, it is not vertically uniform throughout the domain, but it is influenced by how the cells are partitioned. Therefore, I believe it is a UDF parallelization error but cannot find a solution. If someone could provide me with a suggestion, I would greately appreciate it. (I have also attached the code below)


#include "udf.h"
#include "mem.h"
real xx[3809] = {0.}; //for x-coord at the wall
real zz[3809] = {0.}; // for temperature at that x-coord
int count = 0; //counter


DEFINE_INIT(my_init_func1,mixture_domain)
{

int phase_domain_index;
cell_t c;
Thread *t;
Domain *subdomain;
real xc[ND_ND];

sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
{

if (DOMAIN_ID(subdomain) == 2) //primary phase is domain 2, mixture is domain 1, etc.

thread_loop_c (t,subdomain)
{
begin_c_loop_all (c,t)
{
C_CENTROID(xc,c,t);
C_UDMI(c,t,2) = 0.0; //initialization of the C_UDMI

}
end_c_loop_all (c,t)
}

}
}


DEFINE_ADJUST(face_temp,mixture_domain)
{

int surface_id = 23;

#if !RP_HOST
Domain *d;
Thread *t;
d = Get_Domain(2);
face_t f;
real x[ND_ND];
#endif

host_to_node_int_1(surface_id);

#if !RP_HOST
t = Lookup_Thread(d,surface_id);

begin_f_loop(f,t) /*looping over the desired interface to save the x-coord & temperature values*/
if(PRINCIPAL_FACE_P(f,t)){
F_CENTROID(x,f,t);
xx[count] = x[0];
zz[count] = F_T(f,t);
count++;
}
end_f_loop(f,t)
#endif

}

DEFINE_ADJUST(liq_frac1,mixture_domain)
{
int phase_domain_index;

cell_t c;
Thread *t;
Domain *subdomain;
real xc[ND_ND];


sub_domain_loop(subdomain, mixture_domain, phase_domain_index)
{

if (DOMAIN_ID(subdomain) == 2)

thread_loop_c (t,subdomain)
{
begin_c_loop_all (c,t)
{
C_CENTROID(xc,c,t);
if(xc[0] < -1){
C_UDMI(c,t,2) = 0.;
}
else if(xc[0] >2){
C_UDMI(c,t,2)=0.;
}
else{

real dist_dummy =0.;
real dist_min = 100000.;
real tdummy = 0.;

for(int j =0; j<count; j++){
dist_dummy = fabs(xc[0]-xx[j]);
if(dist_min>dist_dummy){
dist_min = dist_dummy;
tdummy = zz[j];
}
}
C_UDMI(c,t,2) = tdummy;

}


}
end_c_loop_all (c,t)
}

}
}


All times are GMT -4. The time now is 09:06.