|
[Sponsors] |
DEFINE_ADJUST compute gas-liquid interface force, error after hook |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 27, 2017, 08:13 |
DEFINE_ADJUST compute gas-liquid interface force, error after hook
|
#1 |
New Member
Join Date: Feb 2017
Posts: 5
Rep Power: 9 |
Dear all,
I use vof to compute gas liquid two-phase with electric field. The electric field 'phi' in every phase is gauss law, i.e., Laplace (phi)=0; in gas-liquid interface, the interface charge density is Dot Product of electric strong and interface normal. I compute the electric strong with DEFINE_ADJUST(Calc_E_xyz, domain) and store vof gradient with DEFINE_ADJUST(store_VOF_gradient, d). However, when I hook the interface charge density code 'DEFINE_ADJUST(calm_rhos, domain)', fluent will show: C:\PROGRA~1\ANSYSI~1\v145\fluent\fluent14.5.0\win6 4\3d\fl1450s.exe received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 。。。。 Please help me and thanks. /* this udf is used to compute charge density at gas-liquid interface qs= dot(E, N)*/ #include "stdio.h" #include "udf.h" #include "sg.h" #include "sg_mphase.h" #include "math.h" #include "flow.h" #include "mem.h" #include "metric.h" #include "id.h" #define EPS_1 4.25 /* liquid electrical permittivity*/ #define EPS_0 8.8541878e-12 /* air electrical permittivity c^2/Nm^2 */ /* Define which user-defined scalars to use. */ enum { phi, /* electric potential*/ N_REQUIRED_UDSI /*UDS number*/ }; enum { Ex, /* x-direction electric field strength*/ Ey, Ez, vfx, /* x-direction vof gradient*/ vfy, vfz, rhos, /*volume charge density at gas-liquid interface*/ N_REQUIRED_UDM /*UMD number*/ }; DEFINE_ADJUST(store_VOF_gradient, d) /*store vof gradient*/ { Thread *t; Thread *ppt; Thread **pt; cell_t c; int phase_domain_index=1; Domain *pDomain = DOMAIN_SUB_DOMAIN(d,phase_domain_index); Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL); Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL); Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate); mp_thread_loop_c(t,d,pt) { if (FLUID_THREAD_P(t)) { ppt = pt[phase_domain_index]; begin_c_loop (c,t) { C_UDMI(c,t,vfx) = C_VOF_G(c,ppt)[0]; C_UDMI(c,t,vfy) = C_VOF_G(c,ppt)[1]; C_UDMI(c,t,vfz) = C_VOF_G(c,ppt)[2]; } end_c_loop (c,t) } } Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL); } DEFINE_ADJUST(Calc_E_xyz, domain) /* campute Electric field strength */ { Thread *t; cell_t c; face_t f; Thread *t0; cell_t c0; real dr0[ND_ND],dr1[ND_ND], xf[ND_ND], dy; if (n_uds < N_REQUIRED_UDSI) Internal_Error("not enough user-defined scalars allocated"); if(n_udm < N_REQUIRED_UDM) Error("Not enough udm allocated\n"); /* Do nothing if gradient isn't allocated yet. */ if (!Data_Valid_P()) return; thread_loop_c(t,domain) { if (FLUID_THREAD_P(t)) if (NULL != THREAD_STORAGE(t,SV_UDS_I(phi)) && NULL != T_STORAGE_R_NV (t,SV_UDSI_G(phi))) { begin_c_loop(c,t) /*volume loop*/ { C_UDMI(c,t,Ex) = -1.*C_UDSI_G(c,t,phi)[0]; /*Ex*/ C_UDMI(c,t,Ey) = -1.*C_UDSI_G(c,t,phi)[1]; C_UDMI(c,t,Ez) = -1.*C_UDSI_G(c,t,phi)[2]; } end_c_loop(c,t) /* Message("x electric strength: %g\n", C_UDMI(c,t,Ex)); */ } } } /***** this is a error code when I hook it 'DEFINE_ADJUST(calm_rhos, domain)', fluent will show 'received fatal signal' and stop ****/ DEFINE_ADJUST(calm_rhos, domain) /* integral face charge density 'qs' at gas-liquid interface, i.e., volume charge density */ { Thread *t; Thread *pri_th,*sec_th; cell_t c; real xc[ND_ND], EEp[3], EEs[3], nn[3], EE[3], rr; real qv =0.0; /* EEp, EEs and EE are Electric field strengths of primary-phase, second-phase and gas-liquid interface,respectively */ /* nn is the surface normal, defined as the gradient of second-phase vof */ /*? Domain *domain = Get_Domain(1); Get domain pointer */ int ID = 1; t =Lookup_Thread(domain, ID); /* mixture-level thread pointer */ pri_th = THREAD_SUB_THREAD(t,0); /* primary-phase thread pointer */ sec_th = THREAD_SUB_THREAD(t,1); /* second-phase thread pointer */ thread_loop_c(t,domain) { begin_c_loop(c,t) /*volume loop*/ { C_CENTROID(xc,c,t); if (C_VOF(c,sec_th)>0. && C_VOF(c,sec_th)<1.) { face_t f; Thread *tf; int n; real area; EEs[0]=C_UDMI(c,sec_th,Ex);/* Electric strength of second-phase*/ EEs[1]=C_UDMI(c,sec_th,Ey); EEs[2]=C_UDMI(c,sec_th,Ez); EEp[0]=C_UDMI(c,pri_th,Ex);/* Electric field strengths of primary-phase */ EEp[1]=C_UDMI(c,pri_th,Ey); EEp[2]=C_UDMI(c,pri_th,Ez); nn[0]=C_UDMI(c,sec_th,vfx);/* vof surface normal */ nn[1]=C_UDMI(c,sec_th,vfy); nn[2]=C_UDMI(c,sec_th,vfz); /*NV_V(EEs,=,EEp);*/ rr=EPS_0*EPS_1; NV_VS_VS(EE, =,EEp,*,EPS_0, -, EEs,*,rr); C_UDMI(c,t,rhos) = NV_DOT(nn,EE); /* face charge density 'qs' at gas-liquid interface */ /*** the above code are error, even if no under 'integral'code ***/ /* integral face charge density 'qs' at gas-liquid interface */ {c_face_loop(c,t,n) /* loop face in a cell */ { f=C_FACE(c,t,n); tf = C_FACE_THREAD(c,t,n); /* face thread */ F_AREA(A,f,tf); area=NV_MAG(A); /* face area */ qv+=area*C_UDMI(c,t,rhos)*C_VOF(c,sec_th); } } } else { qv=C_UDMI(c,t,rhos) =0; } } end_c_loop(c,t) } } |
|
March 1, 2017, 07:09 |
|
#2 |
New Member
Join Date: Feb 2017
Posts: 5
Rep Power: 9 |
Please help me !!!!
|
|
June 30, 2017, 04:16 |
Received a fatal Signal ( Segmentation fault )
|
#3 |
Member
|
Hi everyone !
I hope you are fine. I am using UDF in VOF model in ANSYS FLUENT, although, my VOF model without UDF is running fine. The UDF is written by my friend used it successfully. He has graduated last year after getting the results from same UDF. The UDF was working well on his server. He was using Fluent 6.3 on Linux system. When I am using same case, date and UDF on my laptop the case is not running, although UDF compilation is very fine. I also check it on Linux system too. During or after initialization, Error occurred segmentation fault error. It is very strange that same case and UDF is not working on his office now. Main error occurred when I am hooking ADJUST and EXECUTE-AT-END UDFs. May be there is some problem of writing/calling style is different in Windows and Linux system with 32bit and 64bit. ( this is just my opinion). I hope you can understand the situation and have a try to fix the problem. I would be highly thankful if you guide me that where is the problem. I can send UDF by email if needed.. Thanks in Advance, Regards, M. F. ALi |
|
February 29, 2020, 05:31 |
|
#4 |
Senior Member
mahdi rostami
Join Date: Jan 2020
Posts: 155
Rep Power: 6 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ActuatorDiskExplicitForce in OF2.1. Help | be_inspired | OpenFOAM Programming & Development | 10 | September 14, 2018 12:12 |
Initializing transient analysis using static analysis in two-way FSI simulation | Daniel_Khazaei | ANSYS | 50 | September 12, 2017 11:56 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |
Gas dissolution from liquid phase with CFX | Roger Young | CFX | 2 | May 6, 2008 08:37 |
Gas pressure question | Dan Moskal | Main CFD Forum | 0 | October 24, 2002 23:02 |