|
[Sponsors] |
May 2, 2024, 22:35 |
F_AREA and 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:46. |
|
Tags |
f_area, segfault, udf |
|
|