CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

DEFINE_PROFILE ---- SIGSEGV error - Multiphase

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 19, 2020, 13:14
Default DEFINE_PROFILE ---- SIGSEGV error - Multiphase
  #1
Member
 
ssa
Join Date: Sep 2018
Posts: 93
Rep Power: 8
ssa_cfd is on a distinguished road
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.
Attached Images
File Type: png Screenshot.png (6.0 KB, 6 views)
ssa_cfd is offline   Reply With Quote

Old   October 19, 2020, 16:19
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   October 20, 2020, 04:31
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
pawan_kmr likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   October 20, 2020, 10:25
Default
  #4
Member
 
ssa
Join Date: Sep 2018
Posts: 93
Rep Power: 8
ssa_cfd is on a distinguished road
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.
ssa_cfd is offline   Reply With Quote

Old   October 20, 2020, 10:50
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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.
pakk is offline   Reply With Quote

Old   October 20, 2020, 12:05
Default
  #6
Member
 
ssa
Join Date: Sep 2018
Posts: 93
Rep Power: 8
ssa_cfd is on a distinguished road
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.
ssa_cfd is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Node 0: Process 15088: Received signal SIGSEGV. hasib61 FLUENT 7 September 4, 2022 02:25
SIGSEGV Memory Access Exeption when Exporting Files using 'Update' JamesPermain STAR-CCM+ 0 April 22, 2020 11:50
Process 10300: Received signal SIGSEGV metaliat93 FLUENT 2 January 28, 2020 01:53
error: Received signal SIGSEGV ianziti92 Fluent UDF and Scheme Programming 2 December 5, 2018 17:25
define_wall_functions density and dynamic viscosity Ionut G Fluent UDF and Scheme Programming 3 March 15, 2017 11:10


All times are GMT -4. The time now is 18:54.