CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

F_AREA and Segmentation Fault

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 2, 2024, 22:35
Default F_AREA and Segmentation Fault
  #1
New Member
 
Maria Antonieta
Join Date: Oct 2013
Posts: 3
Rep Power: 13
antosan is on a distinguished road
Hello,

I need to calculate the area of all faces within a given domain. What I did is the following:
  1. To learn how to write the UDF, I looked into the ANSYS UDF MANUAL and I found a code that outputs a similar information for each face, i.e. the location of the centroids of the cells (page 225). This code is shown below (CODE 1). This code works and I am able to output a file with the centroid information.
  2. When I adapt this code for outputting the area of each face within a domain, I receive a Segmentation fault. The adapted code is CODE 2, below. I debugged the code and the issue occurs when the code runs into the F_AREA(A,f,t) macro.
  3. FYI- I am not running in parallel.
My approach is to compile the UDF and load it to DEFINE_ON_DEMAND.

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.
antosan is offline   Reply With Quote

Reply

Tags
f_area, segfault, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 11:51.