|
[Sponsors] |
May 2, 2024, 18:43 |
F_AREA in UDF leads to segmentation fault
|
#1 |
New Member
Maria Antonieta
Join Date: Oct 2013
Posts: 3
Rep Power: 13 |
Hello,
I need to calculate the area of all faces within a given domain. What I did is the following:
I would appreciate if you give me any advice on this. THANK YOU! -------------------------------------------------------------------- CODE 1: IN ANSYS UDF MANUAL FOR CENTROID CALCULATION (WORKS) ------------------------------------------------------------------- #include "udf.h" FILE *fout; void Print_Thread_Face_Centroids(Domain *domain, int id) { real FC[3]; face_t f; Thread *t = Lookup_Thread(domain, id); fprintf(fout,"thread id %d\n", id); begin_f_loop(f,t) { F_CENTROID(FC,f,t); fprintf(fout, "f%d %g %g %g\n", f, FC[0], FC[1], FC[2]); } end_f_loop(f,t) fprintf(fout, "\n"); } DEFINE_ON_DEMAND(get_coords) { Domain *domain; domain = Get_Domain(1); fout = fopen("faces.out", "w"); Print_Thread_Face_Centroids(domain, 23); fclose(fout); } ----------------------------------------------------------------------- CODE 2: ADAPTATION FOR AREA CALCULATION (DOES NOT WORK) ------------------------------------------------------------------------ #include "udf.h" FILE *fout; void Print_Thread_Face_Area(Domain *domain, int id) { real NV_VEC(A); face_t f; Thread *t = Lookup_Thread(domain, id); fprintf(fout,"thread id %d\n", id); begin_f_loop(f,t) { fprintf(fout,"inside loop\n"); F_AREA(A,f,t); /*fprintf(fout, "f%d %g \n", f, NV_MAG(A)); */ } end_f_loop(f,t) fprintf(fout, "\n"); } DEFINE_ON_DEMAND(get_facearea) { Domain *domain; domain = Get_Domain(1); fout = fopen("faces_areas.out", "w"); Print_Thread_Face_Area(domain, 23); fclose(fout); } Last edited by antosan; May 3, 2024 at 01:45. |
|
Tags |
ansys, fluent, f_area, segmentation fault, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDM segmentation fault. | Tushar_Telmasre | Fluent UDF and Scheme Programming | 1 | March 24, 2017 06:45 |
Segmentation fault in SU2 V5.0 | ygd | SU2 | 2 | March 1, 2017 05:38 |
fatal signal segmentation fault in a UDF | hares | FLUENT | 6 | January 21, 2017 04:26 |
segmentation fault when installing OF-2.1.1 on a cluster | Rebecca513 | OpenFOAM Installation | 9 | July 31, 2012 16:06 |
Segmentation Fault | Shawn_A | OpenFOAM Running, Solving & CFD | 6 | October 31, 2011 15:38 |