Fluids

Fluids

What are the possible reasons for segmentation fault in this problem

    • matus
      Subscriber

      Hai...


      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.


       

    • Karthik R
      Administrator

      Hello,


      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

    • matus
      Subscriber

      Dear 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..

    • Karthik R
      Administrator

      Hi,


      Could you please post a screenshot of your UDF?


      Thanks.


      Best,


      Karthik

    • 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)
      }
      }
      }

    • DrAmine
      Ansys Employee

      Hi,


      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.


       

    • 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.).


       


       


       

    • zypresse91
      Subscriber

      My 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.

    • matus
      Subscriber

      Hai...did you manage to solve your problem?

    • DrAmine
      Ansys Employee

      Check this thread if it is helpful for you: https://studentcommunity.ansys.com/thread/segmentation-fault-error-due-to-zero-flow-at-porous-jump-boundary/ if not create a new thread with your question and add more information.

Viewing 9 reply threads
  • You must be logged in to reply to this topic.