|
[Sponsors] |
Export flow rate through faces and the adjacent cells ID |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 31, 2020, 07:46 |
Export flow rate through faces and the adjacent cells ID
|
#1 |
New Member
Join Date: Mar 2020
Posts: 2
Rep Power: 0 |
Dear friends,
I'm trying to export flow rate as well as the adjacent cells ID for each face in the domain. The first question: My code can be compiled and loaded into FLUENT, but when I use "execute on demand" : ----------------------------------------------------------------------------------- 999999: mpt_accept: error: accept failed: No such file or directory 999999: mpt_accept: error: accept failedMPI Application rank 0 exited before MPI_Finalize() with status 2 The fl process could not be started. ----------------------------------------------------------------------------------- The second question: In UDF manual: Get_Domain(domain_id) Does "domain_id" have the same meaning as "zone XXX" ? e.g. 16000 hexahedral cells, zone 7, binary. zone 7 means domain_id is 7? I'm a beginner and this is the first time I write UDF by myself. Maybe I made some stupid mistakes. Really hope someone can help me. Here's my code: Code:
#include "udf.h" #include "mem.h" DEFINE_ON_DEMAND(getflux) { FILE *fp; Thread *t; Domain *domain= Get_Domain(1); face_t face; cell_t c,c0,c1; real fl; int n; fp = fopen("data.txt","a+"); fprintf(fp,"c0,c1,flux\n"); thread_loop_c(t,domain) { begin_c_loop(c,t) { c_face_loop(c,t,n) { face = C_FACE(c, t, n); c0 = F_C0(face,t); c1 = F_C1(face,t); fl = F_FLUX(face,t); fprintf(fp,"%d,%d,%g\n",c0,c1,fl); } } end_c_loop(c,t) } fclose(fp); } Thank you! Ps.My English is not good, I'm sorry if it's bothering you. |
|
July 31, 2020, 13:23 |
|
#2 |
Senior Member
Arun raj.S
Join Date: Jul 2011
Posts: 210
Rep Power: 16 |
Try this.
#include "udf.h" #include "mem.h" DEFINE_ON_DEMAND(getflux) { Thread *t; Domain *d; d= Get_Domain(1); face_t f; cell_t c,c0,c1; real fl; int n; t = Lookup_Thread(d, PROVIDE_THE_ID_HERE); thread_loop_c(t,d) { begin_c_loop(c,t) { c_face_loop(c,t,n) { face = C_FACE(c, t, n); c0 = F_C0(f,t); c1 = F_C1(f,t); fl = F_FLUX(f,t); } } end_c_loop(c,t) } } |
|
August 2, 2020, 20:12 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
your code seems to be correct for single core computation,
the only thing could be: was Code:
int n; Code:
int n=0; Check ANsys Fluent Customization manual for more details
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 2, 2020, 23:11 |
|
#4 |
New Member
Join Date: Mar 2020
Posts: 2
Rep Power: 0 |
Hi arunraj and AlexanderZ,
Thanks for your advice ! I've tried your code but the program still can't run successfully. Thank you anyway. Fortunately, I figure it out. Seems like it's the problem with the using of pointers. The following code can run successfully. Hope it help someone someday. Code:
#include "udf.h" #include "mem.h" DEFINE_ON_DEMAND(getflux) { FILE *fp; Thread *c_thread,*f_thread; Domain *domain= Get_Domain(1); face_t face; cell_t c,c0,c1; real fl; int n; fp = fopen("data.txt","a+"); fprintf(fp,"c0,c1,flux\n"); thread_loop_c(c_thread,domain) { begin_c_loop(c,c_thread) { c_face_loop(c,c_thread,n) { face = C_FACE(c, c_thread, n); f_thread=C_FACE_THREAD(c,c_thread,n); c0 = F_C0(face,f_thread); c1 = F_C1(face,f_thread); fl = F_FLUX(face,f_thread); fprintf(fp,"%d,%d,%g\n",c0,c1,fl); } } end_c_loop(c,c_thread) } fclose(fp); } |
|
Tags |
data exporting, udf and programming |
|
|