|
[Sponsors] |
November 22, 2020, 22:17 |
C_UDMI function causing SIGSEGV error
|
#1 |
New Member
Hosea Chan
Join Date: Nov 2018
Posts: 4
Rep Power: 8 |
Dear forum users,
I am working on a DEFINE_ADJUST function to compute the average velocity at the inlet of the cell zone and store the average velocity in the cells with C_UDMI function, which will be used to compute the momentum source term later. The code is as follows: Code:
DEFINE_ADJUST(update,d) { int id_a[cell_zones] = {17,21}; /* get zone id of channel-in later, need input */ int id_v[cell_zones] = {6,7}; /* get zone id of channel volume later, need input */ int i; for (i=0;i<2;i++) { #if !RP_HOST real A[ND_ND]; real tfa = 0.0; real tfi = 0.0; real Ux = 0.0; face_t f; cell_t c; Thread* t1=Lookup_Thread(d,id_a[i]); Thread* t2 = Lookup_Thread(d,id_v[i]); begin_f_loop(f, t1) { if PRINCIPAL_FACE_P(f,t1) { F_AREA(A,f,t1); tfa += NV_MAG(A); /* summing the x-velocity of face */ tfi += F_U(f,t1)*NV_MAG(A); } } end_f_loop(f, t1) tfi=PRF_GRSUM1(tfi); tfa=PRF_GRSUM1(tfa); Ux = tfi / tfa; Message0("Average zone %d U:%12.4e\n",i, Ux); Message0("Begin store c loop %d.\n",i); begin_c_loop(c,t2) { if (FLUID_THREAD_P(t2) && NNULLP(THREAD_STORAGE(t2, SV_UDM_I))) { C_UDMI(c,t2,1) = Ux; } } end_c_loop(c,t2) Message0("End store c loop %d.\n",i); #endif } } Code:
DEFINE_INIT(initialize,d) { #if !RP_HOST real total_volume[cell_zones]; //Domain* d; int i; d = Get_Domain(1); for (i=0; i<2 ; i++) { cell_t c; Thread* t2 = Lookup_Thread(d,id_v[i]); begin_c_loop(c, t2) Message0("Begin volume c loop %d\n",i); { total_volume[i] += C_VOLUME(c,t2); } end_c_loop(c, t2) #if RP_NODE total_volume[i] = PRF_GRSUM1(total_volume[i]); #endif Message0("Begin store c loop %d\n",i); begin_c_loop(c,t2) { if (FLUID_THREAD_P(t2) && NNULLP(THREAD_STORAGE(t2, SV_UDM_I))) { C_UDMI(c,t2,0) = total_volume[i]; } } end_c_loop(c,t2) Message0("total_volume of zone %d: %12.4e\n", i,total_volume[i]); } #endif /* !RP_HOST */ } Thank you for your help in advance! Best regards, Hosea |
|
December 13, 2020, 19:22 |
|
#2 |
New Member
amine
Join Date: Dec 2020
Posts: 7
Rep Power: 6 |
usefully you have to lunch the computation without hook the function for one iteration and after hook your udf and try it !
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Building OpenFOAM1.7.0 from source | ata | OpenFOAM Installation | 46 | March 6, 2022 14:21 |
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch | gschaider | OpenFOAM Installation | 225 | August 25, 2015 20:43 |
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh | gschaider | OpenFOAM Community Contributions | 300 | October 29, 2014 19:00 |
How to install CGNS under windows xp? | lzgwhy | Main CFD Forum | 1 | January 11, 2011 19:44 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |