-
-
July 2, 2018 at 12:03 pm
matus
SubscriberHai...
I am trying to incorporate a very simple UDF code into my problem, but it shows segmentation fault. The UDF code attached here works with other 2d geometries. I have checked the possible reasons for segmentation faults, like checking allocated memory locations number, zone id no ..etc.but not able to solve this issue.
I would be very thankful if someone can help me.
The simplified geometry and UDF code are attached.
Â
-
July 2, 2018 at 12:50 pm
Karthik Remella
AdministratorHello,
Segmentation fault generally occurs because of multiple reasons. Here are a few: if your code
- is trying to access incorrect memory locations.
- is incorrectly compiled.
- is not accessing the right zone.
- has something hard-coded (when it is not supposed to be).
Here is some general thoughts that I have employed in past to debug UDF errors.
- Check if you have allocated the correct number of UDMIs in Fluent and they match with your UDF.
- Make sure your UDF is being complied properly (without any errors or even warnings). It is important to read the compiled text line by line. There have been multiple scenarios in past where I skim through the compilation (and assume everything is right) and I have overlooked compilation errors. This also generally identifies syntactical errors.
- Are you accessing the correct zone in your UDF (zone IDs can be accessed in the boundary conditions panel)?
- If your UDMIs are physical quantities / source terms / BCs etc., try to appropriately plot them as contours plots right after initialization. If you are not able to see the correct values in your contours, there could be a problem and you might have to revisit your UDF.
- Another way I debug my code is using 'fprintf' or 'message' commands where ever necessary / possible. This way I ensure that my UDF is behaving the way it should. Please refer to the Fluent customization manual for more details.
- If my UDF contains a lot of macros, I try to debug one macro at a time. It is easy to isolate errors if your code is simple.
I hope these pointers help you debug your code. If your code is working correctly on other 2d geometries, it is likely that there is something hard-coded in your UDF (which might not be generic).
Thanks.
Best,
Karthik
-
July 3, 2018 at 3:00 am
matus
SubscriberDear Karthik,
Thanks for all your detailed suggestions.
I have followed all of your suggestion.
- 3 UDMI are used in UDFÂ so 3 memory locations are allocated.
- it is not showing any error message after compilation
- rechecked the zone id
- UDF is very simple and only using one macro
But still, the error exists..
-
July 4, 2018 at 2:05 pm
Karthik Remella
AdministratorHi,
Could you please post a screenshot of your UDF?
Thanks.
Best,
Karthik
-
July 4, 2018 at 2:30 pm
matus
Subscriber#include "udf.h"
DEFINE_EXECUTE_AT_END(source_calculation)
{
Domain *d=Get_Domain(1);
int zone_id=11;
Thread *t = Lookup_Thread(d,zone_id);
cell_t c;
real dt=CURRENT_TIMESTEP;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_UDMI(c,t,1)=pow(10,5);
if(NNULLP( THREAD_STORAGE(t, SV_P)))
{
if (C_P(c,t)>C_UDMI(c,t,1))
{
C_UDMI(c,t,2)=1;
}
else
{
C_UDMI(c,t,2)=100;
}
C_UDMI(c,t,0)=C_UDMI(c,t,0)+(C_UDMI(c,t,2)*dt);
}
end_c_loop(c,t)
}
}
} -
July 5, 2018 at 6:12 am
DrAmine
Ansys EmployeeHi,
Help yourself by adding some debugging messages which will show you where the error might happen. Moreover check if you are really solving transient.
A.
Â
-
December 8, 2018 at 7:41 pm
zypresse91
SubscriberÂ
Â
Dear all thanks for the discussion, it gives me such insight about my project.
Still, I have to ask since I couldn't manage to run it properly.
My system is composed of 3 bodies, and the middle body will be the host of a reaction. All those three systems have the porous zone option activated. I want the water liquid which flows through the undermost body and arriving the porous jump boundary, passing through this boundary, reacting with the chemicals I designated in the middle body, creating those other products, and finally once again those products for this time passing through the second porous jump boundary and reaching to the uppermost body.
I hope you could imagine the system. Now I created 2 cell zones just above these porous jump boundaries with a width of 1 grid cell which was 8 m for my case, and also set the Y velocities of those interior cell zones as 0. Logically, since they are just above the porous jump boundaries they are actually in-situ of the reaction area(the middle body). So, I did activate the porous zone and reaction options for my cell zones, and set '0' value for the Y velocities in the fixed values tab (A researcher who encountered the same problem proposed this method, so I wanted to give it a try.).
Â
Â
Â
-
December 8, 2018 at 7:54 pm
zypresse91
SubscriberMy problem is that I keep getting this error of Segmentation fault due to the zero flow at porous jump boundary. I tried to create cell zones just above the porous jump boundaries and set their Y-velocities as '0' to ensure that there's no slip in-situ boundaries. It didn't work out. Also for the values of porous jump boundary condition, how do I assign them?(I know that thickness is '0') If you could share your e-mail adresses with me , I would be much appreciated and grateful for giving me some insight on that matter. Cheers,Selvi.
-
December 11, 2018 at 2:53 am
matus
SubscriberHai...did you manage to solve your problem?
-
December 11, 2018 at 2:43 pm
DrAmine
Ansys EmployeeCheck this thread if it is helpful for you:Â /forum/forums/topic/segmentation-fault-error-due-to-zero-flow-at-porous-jump-boundary/Â if not create a new thread with your question and add more information.
-
- The topic ‘What are the possible reasons for segmentation fault in this problem’ is closed to new replies.
-
5884
-
1906
-
1420
-
1306
-
1021
© 2026 Copyright ANSYS, Inc. All rights reserved.