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/)
-   -   DEFINE_PROFILE ---- SIGSEGV error - Multiphase (https://www.cfd-online.com/Forums/fluent-udf/231054-define_profile-sigsegv-error-multiphase.html)

ssa_cfd October 19, 2020 12:14

DEFINE_PROFILE ---- SIGSEGV error - Multiphase
 
1 Attachment(s)
Hi all,

I am new to UDF programming and I am doing a UDF for heat transfer coefficient in multiphase simulation. The code compiles good, but produces a SIGSEGV error on execution.

Code:

#include "udf.h"
DEFINE_PROFILE(heat_gas_wall,t,i)
{
  Message0("TEst 00000000000");
  /*face thread*/
Thread *ti = THREAD_SUB_THREAD(t,0);
Thread *tj = THREAD_SUB_THREAD(t,1);
/*cell thread*/
Thread *tci = THREAD_T0(ti);
Thread *tcj = THREAD_T0(tj);
cell_t c;
face_t f;
Message0("TEst 0");
real v_x=0., v_y=0., v_z=0.;
real vel;
v_x = C_U(c,tcj) - C_U(c,tci);
v_y = C_V(c,tcj) - C_V(c,tci);
v_z = C_W(c,tcj) - C_W(c,tci);
vel = sqrt(v_x*v_x + v_y*v_y + v_z*v_z);
/*NV_DD(v,=,C_U(c,tcj),C_V(c,tcj),C_W(c,tcj),-,C_U(c,tci),C_V(c,tci),C_W(c,tci));
vel = NV_MAG(v);*/

real beta = 90;
real D=1;
/*dia of kiln*/
Message0("TEst 0.5");
real De = 0.5*D*(2*M_PI-beta+sin(beta*M_PI/180))/(M_PI-beta/2-sin((beta*M_PI/180)/2));
Message0("TEst 0.6");
real Re = RE_NUMBER(C_R(c,tci),vel,De,C_MU_L(c,tci));
Message0("TEst 0.7");
real kg = 1;
/*C_K_L(c,tci);*/
real omega=0.1;
Message0("TEst 1");
/*real xc = 0.01*0.1;*/
/*particle dia * experiment constant*/
/*real kb=C_K_L(c,tcj);*/
/*thermal conductivity of bed*/

Message0("TEst 2");
real pb=1;
/*C_R(c,tcj);*/
/*density of bed*/

Message0("TEst 3");
/*real cp=C_CP(c,tcj);*/
/*heat capacity of bed*/
real Rew = pow(De,2)*omega*pb/C_MU_L(c,tci);
Message0("TEst 4");

FILE *fp, *val;
fp = fopen("htc_gas_wall.txt","a+");
val = fopen("htc_val.txt","a+");

begin_f_loop(f,t)
{
fprintf(val, "%f,%f,%f,%f\n", Re, Rew,kg,De);
fprintf(fp, "%f\n", 1.54*pow(Re,0.575)*pow(Rew,-0.292)*kg/De);

/*F_PROFILE(f,ti,i) = 1.54*pow(Re,0.575)*pow(Rew,-0.292)*kg/De; */
/*F_PROFILE(f,tj,i) = pow(xc/kg+pow(2*sqrt(kb*pb*cp/(M_PI*tc)),-1),-1); */
}
end_f_loop(f,t)
Message0("TEst 5");
fclose(val);
fclose(fp);
}

And the output from the files are
htc_gas_wall.txt
Quote:

31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
31.066258
htc_val.txt
Quote:

29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
29261.040588,5488.875738,1.000000,0.971641
The error message from fluent is attached as image. I thought the C_R, C_U, C_K_L such macros are creating this error. But even after setting those values to 1, produces the same error.

How to solve this error.?

Thanks,
Senthil.

pakk October 19, 2020 15:19

You tell Fluent that c is a Cell, but you don't say which cell. And then you ask fluent to use the velocity on that unspecified cell. That gives problems.

It looks like you want to use the flow in the cell closest to the wall to calculate the Reynolds number, as input for the heat transfer. I forgot the physical equations, but is this what you need? I would find one of two things more logical : take the overall Reynolds number (with average velocity) or take the velocity at the wall (if you have wall slip).

So I can see in which lines your code breaks, but I don't know how to fix it because I don't know which equations you are trying to implement.

AlexanderZ October 20, 2020 03:31

in addition to Pakk,

you should put the "computation" part of your code inside the loop of face
and define adjusted cell of each face, using F_C0 macro (and you are using thread_t0, which is thread of adjusted to face cell)

if you run in parallel, be careful with writing to file part. You should write to file from host

read ansys fluent customization manual for details

ssa_cfd October 20, 2020 09:25

Thanks for your comments.

My problem is I am modelling a heat transfer coefficients for multiphase h(gas-wall) and h(solid-wall). So I choose DEFINE_PROFILE and wanted to add both coefficients in the same UDF. Because, I am able to select only one UDF in the boundary conditions.

Simplified equations for heat transfer coefficients are
h(gas-wall) = 1.54*Re*k/D

and

h(solid-wall) = D/k + [2 * sqrt(k * rho * cp / pi)]^(-1)

So I got the sub threads from the mixture thread. Get the values from the adjacent cell and calculate the heat transfer coefficient. Because the velocity at the wall is zero.


After your comments., I simplified the code and executed. When I execute with just mixture level threads, the UDF is working and when I use the sub_threads for the phase, It produces SIGSEGV error.

Simplified UDF:
Code:

#include "udf.h"
DEFINE_PROFILE(heat_test,t,i)
{
  face_t f;
  Thread *ti = THREAD_SUB_THREAD(t,0);
Thread *tj = THREAD_SUB_THREAD(t,1);
Thread *tci = THREAD_T0(ti);
Thread *tcj = THREAD_T0(tj);
 cell_t c = F_C0(f,t);
real D = 1;
real beta = 90;
real v_x=0., v_y=0., v_z=0.;
real vel;
v_x = F_U(f,t);
v_y = F_V(f,t);
v_z = F_W(f,t);
vel = sqrt(v_x*v_x + v_y*v_y + v_z*v_z);
real De = 0.5*D*(2*M_PI-beta+sin(beta*M_PI/180))/(M_PI-beta/2-sin((beta*M_PI/180)/2));
real Re = vel;

begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = 1.54*Re/De;
}
end_f_loop(f,t)

}

When I use F_U(f,ti) it crashes and when I use F_U(f,t) it works.!

Thanks,
Senthil.

pakk October 20, 2020 09:50

In this code, you use f before you tell fluent which face it is.
Put your begin_f_loop earlier in your code, before you use f for the first time.

ssa_cfd October 20, 2020 11:05

Code:

#include "udf.h"
DEFINE_PROFILE(heat_test,t,i)
{
  face_t f;
Thread *ti = THREAD_SUB_THREAD(t,0);
real D = 1;
real beta = 90;
real v_x=0., v_y=0., v_z=0.;
real vel;
real De = 0.5*D*(2*M_PI-beta+sin(beta*M_PI/180))/(M_PI-beta/2-sin((beta*M_PI/180)/2));

begin_f_loop(f,t)
{
v_x = F_U(f,ti);
v_y = F_V(f,ti);
v_z = F_W(f,ti);
vel = sqrt(v_x*v_x + v_y*v_y + v_z*v_z);
real Re = vel;
F_PROFILE(f,t,i) = 1.54*Re/De;
}
end_f_loop(f,t)
}

Is this correct now.? I don't get any warnings or errors during compilation.

But the same SIGSEGV error on execution with F_U(f,ti) and works fine with F_U(f,t).

Thanks,
Senthil.


All times are GMT -4. The time now is 19:45.