Segmentation violation
I am using fluent 6.3.26in LINUX. after starting the solution fluent shows a error message. Error: fluent.6.3.26 received a fatal signal (SEGMENTATION VIOLATION).
I am solving the energy equation with the enthalpy formulation. I would like to add a source term via UDF that includes the gradient of enthalpy but I get an Access Violation error when I try to use the *C_H_G*(c,t) macro, or C_T_G(c,t)*cp. If anybody knows the remedies, Please help me. Thanks. |
hi,
you need to specify either a gradient direction or magnitude i.e. just doing C_T_G(c,t,0)*something as you have written is not correct, it either needs to be C_T_G(c,t)[0, 1 or 2] where 0 is x, 1 is y, 2 is z (so C_T_G(c,t)[0] is for dT/dx.) OR NV_MAG(C_T_G(c,t,0)) which is the magnitude of the gradient vector. I hope that helps |
Hi
Thank you for your repley, i tested this written, but i have also the same error message "segmentation violation". Good day |
hi again
do you mind posting the entire UDF? |
also could you please tell me all the steps uve taken before running the simulation (i.e. what models you are using, boundary conditions...step by step)
thanks |
Hi,
My UDF is: #include "udf.h" #include "models.h" #include "data_argon3.h" #include "data_anode.h" /*================================================= ===========================*/ /* */ /* User-Defined Scalars & User-Defined Memories */ /* */ /*================================================= ===========================*/ enum { ep, /* uds 0 -> Electric Potential (V) */ pvx, /* uds 1 -> Potential Vector Axial component (Ax) */ pvr, /* uds 2 -> Potential Vector Radial component (Ar) */ N_REQUIRED_UDS /* UDS number : 3 */ }; enum { efx, /* udm 0 -> Electric Field Axial Component (Ex) */ efr, /* udm 1 -> Electric Field radial Component(Er) */ efmagn, /* udm 2 -> Electric Field Magnitude(E) */ cudx, /* udm 3 -> Current Density Axial Component (jx) */ cudr, /* udm 4 -> Current Density radial Component(jr) */ cdmagn, /* udm 5 -> Current Density Magnitude(j) */ mfh, /* udm 6 -> Magnetic Field Azimuthal Component (B) */ lpfx, /* udm 7 -> Laplace Force Axial Component(jrB) */ lpfr, /* udm 8 -> Laplace Force Radial Component(-jxB) */ jh, /* udm 9 -> Joule Heating */ rl, /* udm 10 -> Radiative Losses */ addt, /* udm 11 -> enthalpy electron */ est, /* udm 12 -> Energy Source Term */ NUM_OF_USED_UDM /* Nombre d'UDM : 13 */ }; real interp_func(real temperature, real x_array[], real y_array[], int i_max) { real x1 = x_array[0]; real y1 = y_array[0]; real x2 = x_array[1]; real y2 = y_array[1]; real slop; real interp_prop; int i = 1; while ( (i < i_max) && (temperature > x2) ) { i++; y1 = y2; x1 = x2; y2 = y_array[i]; x2 = x_array[i]; } slop = (y2 - y1) / (x2 - x1); interp_prop = slop * (temperature - x1) + y1; return interp_prop; } DEFINE_DIFFUSIVITY(udf_diffusivity, c, t, i) { /*-------------------------------------------------------------------------*/ /* uds 0 -> Electric conductivity */ /*-------------------------------------------------------------------------*/ if (i == ep) { return interp_func( C_T(c,t), sig_x, sig_y, i_max_sig ) ; } /*-------------------------------------------------------------------------*/ /* uds 1 & uds 2 -> Potential Vector Components */ /*-------------------------------------------------------------------------*/ else { return 1.0 ; } } DEFINE_PROPERTY(udf_density, c, t) { return interp_func( C_T(c,t), rho_x, rho_y, i_max_rho ) ; } /*================================================= ===========================*/ /* */ /* User-Defined Memories calculation */ /* */ /*================================================= ===========================*/ DEFINE_ADJUST(udf_adjust, domain) { Thread *t; cell_t c; /* real temp_gradient_x;*/ if ( N_UDS < N_REQUIRED_UDS ) Error("Not enough user-defined scalars allocated !"); if ( N_UDM < NUM_OF_USED_UDM ) Error("Not enough user-defined memory allocated !"); thread_loop_c(t,domain) { if (NULLP(THREAD_STORAGE(t, SV_UDS_I(ep)))) Internal_Error("Storage is not allocated for user-defined storage variable : ep"); if (NULLP(T_STORAGE_R_NV(t, SV_UDSI_G(ep)))) return ; if (NULLP(THREAD_STORAGE(t, SV_UDS_I(pvx)))) Internal_Error("Storage is not allocated for user-defined storage variable : pvx"); if (NULLP(T_STORAGE_R_NV(t, SV_UDSI_G(pvx)))) return ; if (NULLP(THREAD_STORAGE(t, SV_UDS_I(pvr)))) Internal_Error("Storage is not allocated for user-defined storage variable : pvr"); if (NULLP(T_STORAGE_R_NV(t, SV_UDSI_G(pvr)))) return ; if (NULLP(THREAD_STORAGE(t, SV_UDM_I))) Internal_Error("Thread as no user-defined memories set up on it !"); /* if (NULL != THREAD_STORAGE(t,SV_T_G)) { temp_gradient_x = C_T_G(c,t)[0]; } else { /*first iteration OR option to store gradients not turned on */ /* temp_gradient_x = 0.0; }*/ begin_c_loop(c,t) { /*-------------------------------------------------------------*/ /* udm 0 -> Electric field axial component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,efx) = - C_UDSI_G(c,t,ep)[0] ; /*-------------------------------------------------------------*/ /* udm 1 -> Electric field radial component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,efr) = - C_UDSI_G(c,t,ep)[1] ; /*-------------------------------------------------------------*/ /* udm 2 -> Electric field magnitude */ /*-------------------------------------------------------------*/ C_UDMI(c,t,efmagn) = NV_MAG(C_UDSI_G(c,t,ep)) ; /*-------------------------------------------------------------*/ /* udm 3 -> Current density axial component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,cudx) = C_UDSI_DIFF(c,t,ep) * C_UDMI(c,t,efx) ; if (C_UDMI(c,t,cudx) > -1.0E+3) C_UDMI(c,t,cudx) = 0.0; /*-------------------------------------------------------------*/ /* udm 4 -> Current density radial component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,cudr) = C_UDSI_DIFF(c,t,ep) * C_UDMI(c,t,efr) ; if (C_UDMI(c,t,cudr) > -1.0E+3) C_UDMI(c,t,cudr) = 0.0; /*-------------------------------------------------------------*/ /* udm 5 -> Current density magnitude */ /*-------------------------------------------------------------*/ C_UDMI(c,t,cdmagn) = C_UDSI_DIFF(c,t,ep) * C_UDMI(c,t,efmagn) ; /*-------------------------------------------------------------*/ /* udm 6 -> Magnetic field Azimuthal Component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,mfh) = C_UDSI_G(c,t,pvr)[0] - C_UDSI_G(c,t,pvx)[1] ; /*-------------------------------------------------------------*/ /* udm 7 -> Laplace force axial component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,lpfx) = C_UDMI(c,t,cudr) * C_UDMI(c,t,mfh) ; /*-------------------------------------------------------------*/ /* udm 8 -> Laplace force radial component */ /*-------------------------------------------------------------*/ C_UDMI(c,t,lpfr) = -C_UDMI(c,t,cudx) * C_UDMI(c,t,mfh) ; /*-------------------------------------------------------------*/ /* udm 9 -> Joule heating */ /*-------------------------------------------------------------*/ C_UDMI(c,t,jh) = C_UDSI_DIFF(c,t,ep) * SQR(C_UDMI(c,t,efmagn)) ; /*-------------------------------------------------------------*/ /* udm 10 -> Radiative losses */ /*-------------------------------------------------------------*/ C_UDMI(c,t,rl) = -interp_func( C_T(c,t), eps_x, eps_y, i_max_eps ) ; /*------------------------------------------------------------*/ /* udm 11 -> enthalpy electron */ /*------------------------------------------------------------*/ real KB; real e; KB = 1.3806E-23; e = 1.6e-19; C_UDMI(c,t,addt) = (2.5*KB/e)*(C_T_G(c,t)[0]*C_UDMI(c,t,cudx)*C_CP(c,t)+ C_T_G(c,t)[1]*C_UDMI(c,t,cudr)*C_CP(c,t)); /*-------------------------------------------------------------*/ /* udm 12 -> Energy source term */ /*-------------------------------------------------------------*/ C_UDMI(c,t,est) = C_UDMI(c,t,jh) + C_UDMI(c,t,rl)+ C_UDMI(c,t,addt); } end_c_loop(c,t) } } /*================================================= ===========================*/ /* */ /* Source Terms */ /* */ /*================================================= ===========================*/ /*----------------------------------------------------------------------------*/ /* x-momemtum equation */ /*----------------------------------------------------------------------------*/ DEFINE_SOURCE(udf_source_x, c, t, dS, eqn) { dS[eqn] = 0.0 ; return C_UDMI(c,t,lpfx) ; } /*----------------------------------------------------------------------------*/ /* r-momemtum equation */ /*----------------------------------------------------------------------------*/ DEFINE_SOURCE(udf_source_r, c, t, dS, eqn) { dS[eqn] = 0.0 ; return C_UDMI(c,t,lpfr) ; } /*----------------------------------------------------------------------------*/ /* energy equation */ /*----------------------------------------------------------------------------*/ DEFINE_SOURCE(udf_source_h, c, t, dS, eqn) { dS[eqn] = 0.0 ; return C_UDMI(c,t,est) ; } /*----------------------------------------------------------------------------*/ /* uds 1 equation -> Potential vector axial component equation */ /*----------------------------------------------------------------------------*/ DEFINE_SOURCE(udf_source_pvx, c, t, dS, eqn) { real MU; MU = 4 * M_PI * 1.E-07; /* permittivite du vide */ dS[eqn] = 0. ; return MU * C_UDMI(c,t,cudx) ; } /*----------------------------------------------------------------------------*/ /* uds 2 equation -> Potential vector radial component equation */ /*----------------------------------------------------------------------------*/ DEFINE_SOURCE(udf_source_pvr, c, t, dS, eqn) { real MU; MU = 4 * M_PI * 1.E-07; /* permittivite du vide */ real coord[ND_ND]; C_CENTROID(coord,c,t); dS[eqn] = - 1.0/pow(coord[1],2.0); return MU*C_UDMI(c,t,cudr)- C_UDSI(c,t,pvr)/pow(coord[1],2.0) ; } DEFINE_INIT(udf_init_temp, domain) { cell_t c; Thread *t; real coord[ND_ND]; thread_loop_c(t,domain) { begin_c_loop_all(c,t) { C_CENTROID(coord,c,t); if (coord[1] < 0.0005) C_T(c,t) = 10000.0; } end_c_loop_all(c,t) } } DEFINE_PROFILE(udf_anode_profile, thread, position) { real x[ND_ND]; real y; face_t f; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); y = x[1]*1e+03; F_PROFILE(f, thread, position) = interp_func( y , ta_x , ta_y , i_max_t ) ; } end_f_loop(f, thread) } DEFINE_PROFILE(udf_cathode_profile, thread, position) { real x[ND_ND]; real J0; real Rmax; face_t f; J0 = -1.061E+9; Rmax = 3.0E-4; begin_f_loop(f, thread) { F_CENTROID(x,f,thread); F_PROFILE(f, thread, position) = (-x[1]/Rmax + 1)*J0 ; } end_f_loop(f, thread) } |
And i use version 6.3.26 (fluent), solver (pessure based)
|
this UDF runs very well without macro C_H_G or C_T_G in udm11, temperature max is 30000 k
|
a few things to try,
1. have you set the solve mode to expert? when fluent solves a transport equation it purges all gradient information available (in memory) from other transport equations, so if you have a dT/dx_i term in your momentum equation the gradient wont be in memory (wont be available at all) unless you issue the command: solve/set/expert in the FLUENT window, and answer YES when it asks if you want to free temporary memory. please try issuing this command. 2. if the above doesnt solve the problem, try hooking the adjust UDF one or two iterations after the start of the simulation to assure there is data to calculate a gradient from (but still applying the expert mode solver). |
Hi akour,
I tried the first sugugestion following the help of fluent, solver>set>expert and answer yes, i have also the same message error, I will try the second propostion and i tell you if it work. Thank you |
Quote:
what happen with that second option? Pl let me know becaus i m working on same problem. bye vishal.marje@gmail.com:o |
hi,
I try the second, but again the same error |
Gradient of UDM
Quote:
Pl help me out as i m having same problem as u had. i need to calculate current density vectors in r and x directions. Jr = delta(H_theta) / Delta(z) Jz = (1/r)*(delta(r*(H_theta)) / Delta(r)) H_theta = Magnetic field intensity r = radius Can i use C_UDMI_G(c,t,0) or something like that.........? I can post my UDF if u r interested. Pl let me know. VISHAL |
Hi Louiza, did the problem get solved?
Yash |
@ Louiza: was the problem solved?
I know its late |
I receive the same error message when I import the mesh that is of course seems to be not a very heavy kind of mesh since it only has about 57000 elements.
any luck finding out why this error message shows up? Thanks |
segmentation fault
In my momentum equation owing to density difference i have to write a source term udf. the source term is,
source term= - ρl.(1+∝).u ⃗ .∂fl/∂t where ∝ = the volume of fraction variable fl = liquid fraction ul = Velocity vector ρl and ρs = liquid and solid density respectively I did write a udf for it -----for x-momentum---- #include "udf.h" #define rho_l 1544.0 #define rho_s 1648.0 DEFINE_SOURCE(x_momentum_source,c,t,dS,eqn) { real source; source = -(rho_l*(1+C_VOF(c,t))*C_U(c,t)*((C_LIQF(c,t)-C_LIQF_M1(c,t))/CURRENT_TIMESTEP)); dS[eqn] = 0; return source; } ----for y-momentum----- #include "udf.h" #define rho_l 1544.0 #define rho_s 1648.0 DEFINE_SOURCE(y_momentum_source,c,t,dS,eqn) { real source; source = -(rho_l*(1+C_VOF(c,t))*C_V(c,t)*((C_LIQF(c,t)-C_LIQF_M1(c,t))/CURRENT_TIMESTEP)); dS[eqn] = 0; return source; } i hooked it in the cell zone section. i was using the VOF module. IT is giving me a segmentation fault. I am not able to understand the mistake here. can anybody help? |
All times are GMT -4. The time now is 05:13. |