TAGGED: udf
-
-
May 3, 2024 at 5:11 pmantosanfSubscriber
Hello,
I need to calculate the area of all faces within a given domain. This was my approach:- I looked into the ANSYS UDF MANUAL and I found a code that outputs the location of the centroids of the cells (page 225).Â
- I adapted this code for outputting the area of each face within a domain but I receive a Segmentation fault.Â
- I debugged the code and the issue occurs when the code runs into the F_AREA(A,f,t) macro.
- FYI - I am not running in parallel.
 The problematic code is shown below. I would appreciate if you give me any advice on this.
-
May 7, 2024 at 1:43 pmRobForum Moderator
I don't think you've defined A correctly, https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v241/en/flu_udf/flu_udf_ModelSpecificDEFINE.html%23flu_udf_sec_ex_beam_directionÂ
-
May 7, 2024 at 3:21 pmantosanfSubscriber
Hi Rob,
Thank you for replying - do I first need to register for me to access your answer?
-
May 7, 2024 at 3:30 pmRobForum Moderator
No, click on Help in Fluent, and paste the link into the browser that opens. The solvers have a token/cookie/biscuit that bypasses the security check.Â
-
May 7, 2024 at 6:29 pmantosanfSubscriber
Hi Rob,
Thank you for your answer. I was able to read the link you provided in Fluent.Â
Regarding the definition of A, I realized the following:
- the UDF example you provided defines A as: real A[3]
- my UDF defines it as: real NV_VEC(A)
I am not sure if this is the issue (would it make a difference?).
If that is indeed the issue, I replaced the definition to "real A[3]" but I again receive the segmentation fault error.
Thank you!
Â
-
May 8, 2024 at 10:18 amRobForum Moderator
Looking here  https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v241/en/flu_udf/flu_udf_DPMDEFINE.html the example uses real A[ND_ND] and F_AREA[A,f,t] Â
In your code, the face loop calls F_AREA[A,f,t]Â but doesn't look to do anything with it other than print.Â
We're not able to offer debugging advice, and you're already on the right track by using comments to find the problem. F_AREA is used in several of the examples, search F_AREA and see what else you find.Â
-
May 8, 2024 at 5:45 pmantosanfSubscriber
Thank you for your comments, Rob.Â
Regarding the face loop, it is true that F_AREA[A,f,t] in the code doesn't do anything. It just prints because I can't get over the segmentation fault issue. I have looked through the examples using F_AREA and checked for syntax errors, and also looked at previous posts in the forum.Â
I understand that you cannot provide debugging advice. However, I followed your suggestion and I am now using the UDF that appears in the manual "Global Summation of Pressure on a Face Zone and its Area Average Computation". I am testing it in a parallel simulation, and I am having again the same issue.
Here are the highlights:
- I did not modify the code, except changing the surface_thread_id for the one that is relevant to my simulation.
- I get segmentation fault when including the F_AREA and the PRINCIPAL_FACE_P conditional inside the face loop. The code runs ok if I just place a message withing the face loop. I show below three alternatives of the face loop that I have tried so far.
- The problem is not with F_AREA only but if I modify the code for F_CENTROID it will give me the same problem.
- The problem is beyond F_AREA and I wonder what is wrong with the face loop.
1.face loop WITH segmentation fault (original loop from the code)begin_f_loop(face,thread)if (PRINCIPAL_FACE_P(face,thread)){F_AREA(area,face,thread);total_area += NV_MAG(area);total_force += NV_MAG(area)*F_P(face,thread);}end_f_loop(face,thread)Â2. Removed the conditional and the code still gives segmentation fault.begin_f_loop(face,thread)Â Â F_AREA(area,face,thread);Â Â total_area += NV_MAG(area);Â Â total_force += NV_MAG(area)*F_P(face,thread);Âend_f_loop(face,thread)3. Code runs OK with a message inside the loop.
begin_f_loop(face,thread)
Message("I am inside the loop\n");
end_f_loop(face,thread)ÂÂÂ -
May 9, 2024 at 8:46 amRobForum Moderator
The other difference being the "area" definition. How is that defined?
-
May 13, 2024 at 6:01 pmantosanfSubscriber
Hi Rob,
Than you for helping me out.
- I was trying to get information on the interior faces but I realized that the zone-id I was using in the code did not allow me to do that. I was using a zone-id that belongs to the "Cell Zone Conditions". From what I understand now, these zones only store cell information as opposed to information on interior faces. Is this correct?
- If I instead use the respective zone id that is listed in the "Boundary Conditions/Internals", I can get information on the interior faces and there is no segmentation fault. The code runs.
- I want to determine the flux that goes into each cell of a porous media. Would it be possible to loop over cells and then over the faces of each cell? The reason why I ask this is because the zone-id for cells is separate than for faces so I am not sure how to approach this task.
-
May 16, 2024 at 1:31 pmRobForum Moderator
Interior faces should also have an ID, click on the surface in the GUI and in the Boundary Conditions Task Page you should see an ID. F_AREA is for facet data (surface) and C_stuff is for volumes.Â
For flux into a porous zone I'd look at the bounding surface (interior) rather than the cells. You can loop over cells and then facets on a cell to find a boundary but that can be very inefficient as that loop may be called every iteration/timestep depending on the code.Â
-
- The topic ‘UDF: Segmentation fault when using F_AREA’ is closed to new replies.
- Workbench license error
- Unexpected error on Workbench: Root element not found.
- Unable to recover corrupted project in Workbench
- Unexpected issues with SCCM deployment of Ansys Fluids and Structures 2024 R1
- Questions and recommendations: Septum Horn Antenna
- AQWA: Hydrodynamic response error
- Tutorial or Help for 2 way FSI
- Moment Reaction probe with Large deformation
- 2 way coupled FSI for ball bearing
- Issue with force and current density calculations in Fluent MHD
-
1281
-
591
-
544
-
524
-
366
© 2024 Copyright ANSYS, Inc. All rights reserved.