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

F_AREA in UDF leads to segmentation fault

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 2, 2024, 18:43
Default F_AREA in UDF leads to 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:45.
antosan is offline   Reply With Quote

Reply

Tags
ansys, fluent, f_area, segmentation fault, 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


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


All times are GMT -4. The time now is 13:48.