|
[Sponsors] |
November 26, 2015, 07:52 |
a fatal signal (segmentation fault)
|
#1 |
New Member
angela huang
Join Date: Nov 2015
Posts: 6
Rep Power: 11 |
I have written a UDF about standard k-e turbulence model and compiled successfully, but when I try to initialize this code, it shows error: received a fatal signal (segmentation fault)
does anyone help me to remove this problem please? My UDF code are listed below: #include "udf.h" /*#include "math.h"*/ /* Turbulence model constants */ const real C1e=1.44; const real C2e=1.92; const real C_mu=0.09; const real SIG_k=1.0; const real SIG_e=1.3; /* User-defined scalars */ enum { TK, TE, N_REQUIRED_UDS }; /*Define source term in k equation */ DEFINE_SOURCE(TK_SOURCE, c, t, dS, eqn) { real source; dS[eqn]=0.0; source= C_MU_T(c,t)*C_STRAIN_RATE_MAG(c,t)*C_STRAIN_RATE_M AG(c,t)-C_R(c,t)*C_R(c,t)*C_mu*C_UDSI(c,t,TK)*C_UDSI(c,t,T K)/C_MU_T(c,t); return source; } /* define source term in eplison equation */ DEFINE_SOURCE(TE_SOURCE, c, t, dS, eqn) { real source, Pk; Pk=C_MU_T(c,t)*C_STRAIN_RATE_MAG(c,t)*C_STRAIN_RAT E_MAG(c,t); dS[eqn]=0.0; source=C1e*C_UDSI(c,t,TE)*Pk/C_UDSI(c,t,TK)-C2e*C_R(c,t)*C_UDSI(c,t,TE)*C_UDSI(c,t,TE)/C_UDSI(c,t,TK); return source; } /* define diffusion coefficienct */ DEFINE_DIFFUSIVITY(KE_diffusivity,c,t,i) { real diff; real mu_t; int nscalar=i; mu_t=C_R(c,t)*C_mu*C_UDSI(c,t,TK)*C_UDSI(c,t,TK)/C_UDSI(c,t,TE); if (nscalar==TK) diff= mu_t/SIG_k + C_MU_L(c,t); else diff = mu_t/SIG_e + C_MU_L(c,t); return diff; } /*define turbulent viscosity */ DEFINE_TURBULENT_VISCOSITY(turbVis,c,t) { real mu_t; mu_t=C_R(c,t)*C_mu*C_UDSI(c,t,TK)*C_UDSI(c,t,TK)/C_UDSI(c,t,TE); return mu_t; } |
|
November 26, 2015, 08:51 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Fluent tries to initialize the diffusivity, and to do this it needs the values of the user defined scalars, but they are not calculated yet.
The udf that you wrote tries to read data that is not stored yet. Without getting too technical, this is an example of a 'segmentation fault'. There are two possible solution methods: 1. Re-write your code such that if you are initializing, your code recognizes this and does not try to read undefined user defined scalars. (The preferred method if you were a professional programmer.) 2. Initialize your data without the udf, and attach the udf later. (The quick and easy solution.) |
|
September 14, 2017, 08:47 |
|
#3 |
Member
Camille Bilger
Join Date: Jul 2013
Posts: 43
Rep Power: 13 |
||
September 14, 2017, 09:15 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
My answer was specific for the code that Turbo_hrf gave.
You (probably) use different code, but get the same warning. If you want to know if the error is caused by something else than your udf, this is easy to test: don't use the udf, and see if you get the same error. It is possible that your error has nothing to do with your udf, and that it is caused by a mistake of the Fluent programmers. But it is far more likely that it is a problem in your udf; you are probably telling Fluent to read a value that does not exist. Without seeing your UDF, I can not help more. |
|
September 14, 2017, 10:35 |
|
#5 | ||
Member
Camille Bilger
Join Date: Jul 2013
Posts: 43
Rep Power: 13 |
Hi pakk,
thanks for getting back to me so quickly. Quote:
Quote:
Code:
DEFINE_HET_RXN_RATE(char_o2,c,t,hr,mw,yi,rr,rr_t) { Thread **pt = THREAD_SUB_THREADS(t); Thread *tp = pt[0]; /* gas phase or primary phase */ Thread *ts = pt[1]; /* solid phase or secondary phase */ real T_p = MAX(293.,C_T(c,tp)); /* primary phase temperature */ real T_s = MAX(293.,C_T(c,ts)); /* secondary phase temperature */ T_p = MIN(T_p,TMAX); T_s = MIN(T_s,TMAX); const real Rgas = 8.314; /* ideal gas constant Joule/mol.K */ /* UNIVERSAL_GAS_CONSTANT = 8314 J/kmol.K;*/ real p_o2 = 0.; /* pressure in Pa = N/m^2 = kg/m.s^2 */ real k_c, k_d; /* coefficients related diffusion and kinetic */ real D_p = C_PHASE_DIAMETER(c,ts); /* solid particle diameter FLUENT macro */ const real Ac = 0.052; /* kg/(m^2 . s . Pa^0.5) */ const real Ec = 6.1e7; /* J/kmol */ real Re, Sc, Sh, urel, urelx,urely,urelz=0.; real Dk = C_DIFF_EFF(c,tp,index_primary) - C_MU_T(c,tp)/(0.7*C_R(c,tp)); *rr = 0.0e0; /* reaction rate */ C_UDMI(c, t, 20) = 0.0e0; C_UDMI(c, t, 21) = 0.0e0; if(C_VOF(c, tp) < eps_g_small && yi[INDEX_PHASE_C][INDEX_SPECIES_C] > spe_small && yi[INDEX_PHASE_O2][INDEX_SPECIES_O2] > spe_small) { p_o2 = C_R(c,tp) * UNIVERSAL_GAS_CONSTANT * C_T(c,tp) * yi[index_primary][INDEX_SPECIES_O2] / 32.0e0; /* kg/m.s^2 */ if(C_VOF(c, ts) <= 0.0e0) /* for negative volume fraction from wrong calculations */ { *rr = 0.0e0; } else { k_c = Ac * exp( -1.0e0 * Ec / UNIVERSAL_GAS_CONSTANT / T_s ); /* kinetic coefficient */ /* Calculation of Sherwood number and then reaction rate */ if(Data_Valid_P()) { urelx = C_U(c,tp) - C_U(c,ts); urely = C_V(c,tp) - C_V(c,ts); #if RP_3D urelz = C_W(c,tp) - C_W(c,ts); #endif urel = sqrt(urelx*urelx + urely*urely + urelz*urelz); /* relative velocity*/ Re = urel * D_p * C_R(c,tp) / C_MU_L(c,tp); Sc = C_MU_L(c,tp) / C_R(c,tp) / Dk ; Sh = 2. + 0.6 * pow(Re, 0.5)* pow(Sc, 0.333); k_d = (Dk * mw[INDEX_PHASE_C][INDEX_SPECIES_C] * Sh ) / (T_p * UNIVERSAL_GAS_CONSTANT * D_p); /* diffusion coefficient */ *rr = (-1.0e0 * k_c) + sqrt(k_c * k_c + 4.0*k_d*k_d*p_o2); *rr = *rr * ( (6.0*C_VOF(c,ts)*k_c) / (2.0*D_p*k_d)); *rr = *rr / mw[INDEX_PHASE_C][INDEX_SPECIES_C]; C_UDMI(c, t, 20) = *rr; C_UDMI(c, t, 21) = yi[INDEX_PHASE_C][INDEX_SPECIES_C] * volume_p(D_p/2.0) * C_R(c,ts); } } } } But now I am using Code:
if(Data_Valid_P()) |
|||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
fluentError: received a fatal signal (Segmentation fault). | thomaszhangjing | Fluent UDF and Scheme Programming | 11 | January 13, 2021 10:37 |
receive fluent received a fatal signal (Segmentation fault). | chenkaiqe | FLUENT | 2 | March 10, 2015 09:21 |
Fluent Error: fatal signal received (Segmentation fault) | gopalkrishnan | FLUENT | 0 | December 16, 2014 02:37 |
Error: received a fatal signal (Segmentation fault). | Revist | Fluent UDF and Scheme Programming | 1 | December 12, 2014 14:18 |
error while compiling the USER Sub routine | CFD user | CFX | 3 | November 25, 2002 16:16 |