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

error: FLUENT received fatal signal (ACCESS_VIOLATION)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2016, 19:45
Default error: FLUENT received fatal signal (ACCESS_VIOLATION)
  #1
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Hello,
I am quite new at UDFs, I’m trying to model the deposition of particles on a plate heat exchanger using four UDFs that are called by FLUENT at different times. The first UDF (impaction), called each time a particle impacts a deposition surface, determines the mass of the deposited particles and then calculate the thickness the mass gives the layer, this one is stored at the first UDM. The second UDF (heat flux), called during each fluent iteration, determines the heat flux through the deposit and base layers. The third UDF (injection initialization), called each time new particle streams are injected, and increments the simulation time before injecting a new set of particle streams. The fourth UDF (reset), called on-demand by the user, resets the user-defined memory locations (UDMLs), which store deposit information at each wall-face, to zero.
The problem is when I hook the heat flux UDF, I got this error:
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()
At first I thought that there would be some error in the UDF (heat flux) because apparently the denominator is zero (R_Eff) but then “ACCESS VIOLATION” means I’m trying to access some information that is not available yet. So I checked the first UDF (impaction) and I found that this one does not return any value.. when I open the UDM I got nothing, and I cannot find a way to solve it …
Can anybody give me a clue?.
Thanks in advance.
Here is both of UDFs I used:
//Particle impaction Boundary Condition UDF
DEFINE_DPM_BC(capture_bounce_bc, p, thread, f, f_normal, dim)
{
real x[ND_ND],p_temperature,p_diameter;
real A[ND_ND],area,flow,flux;
real viscosity,visc_exponent;
real p_rep_mass, deposit_mass;

//Calculate the mass represented by the impacting particle

p_diameter=P_DIAM(p); //Get Particle Diameter from Fluent
p_rep_mass = P_FLOW_RATE(p)*TIMESTEP_SIZE;
//p_rep_mass = P_MASS(p);
printf("%1.9lf\t%1.9lf\n",p_diameter,p_rep_mass);

//Determine viscosity of deposit particle

p_temperature=P_T(p); //Get particle temperature from Fluent
visc_exponent=14788/(p_temperature-T_Shift)-10.931; //Calculate deposit Viscosity
viscosity=(p_temperature-T_Shift)*pow(10,visc_exponent);

//Assume deposited mass is inversely proportional to viscosity when particle viscosity is less than critical

deposit_mass=p_rep_mass;

if(viscosity>critical_viscosity)
{
deposit_mass = p_rep_mass*critical_viscosity/viscosity;
}

//Calculate mass deposited per unit face area

F_AREA(A,f,thread);
area=NV_MAG(A); //Get face area from Fluent
flux=deposit_mass/area;

F_UDMI(f,thread,0)+=deposit_mass;
printf("depôtt%lf\n",F_UDMI(f,thread,2));
F_UDMI(f,thread,2)+=flux/RHO_depôt;

}



//Heat flux boundary condition

/*DEFINE_PROFILE(heat_flux_BC, thread, i)
{
real x[ND_ND];
real R_EFF, wall_temp;
face_t f;


begin_f_loop(f,thread)
{

//Calculate Effective thermal resistance of deposit layers

R_EFF=R_BASE+F_UDMI(f,thread,2)/K_dep;

F_UDMI(f,thread,1)=R_EFF;

wall_temp=F_T(f,thread); //Get boundary temperature from Fluent

F_PROFILE(f,thread,i)=(T_Cool-wall_temp)/R_EFF;
}

end_f_loop(f,thread)
}
fatima ezzahra is offline   Reply With Quote

Old   May 3, 2016, 22:20
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Have you allocated at least three user-defined memory locations via User-Defined > User Defined > Memory... > Number of User-Defined Memory Locations?
`e` is offline   Reply With Quote

Old   May 4, 2016, 08:30
Default
  #3
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by `e` View Post
Have you allocated at least three user-defined memory locations via User-Defined > User Defined > Memory... > Number of User-Defined Memory Locations?
Thank you for replying
yes, i did ..i allocated 4 UDMs
fatima ezzahra is offline   Reply With Quote

Old   May 4, 2016, 18:16
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
You have an accent on the o in the variable RHO_depôt, perhaps this character isn't valid? Try reducing your code until you find the line responsible for your error.
`e` is offline   Reply With Quote

Old   May 5, 2016, 05:56
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The variable RHO_depôt is never defined, so I am surprised you did not have a compilation problem...
pakk is offline   Reply With Quote

Old   May 5, 2016, 13:23
Default
  #6
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by `e` View Post
You have an accent on the o in the variable RHO_depôt, perhaps this character isn't valid? Try reducing your code until you find the line responsible for your error.
I tried what you said about RHO_depôt but i got the same error. Also, i have run my code without the second UDF for the Heat flux boundary condition, and i got this time no error but when i postprocess the results i got zero in all the UDMs (for the mass deposit and for the thickness) so i think that the problem is in the first UDF when i calculate the mass deposit maybe it doesn't work to get the particle Diameter from Fluent using P_DIAM(p); or the mass using P_MASS(p). But i can't figure out why or how should i make this thing work.
fatima ezzahra is offline   Reply With Quote

Old   May 5, 2016, 13:27
Default
  #7
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by pakk View Post
The variable RHO_depôt is never defined, so I am surprised you did not have a compilation problem...
Thank you for replying....
Actually i did. The variable RHo_depôt is defined in the beginning of my code as a constant using '#define RHO_depôt 3180'....
fatima ezzahra is offline   Reply With Quote

Old   May 6, 2016, 03:55
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
How did you conclude that your UDMs are all zeroes?

If you did it by looking at the output of "printf("depôtt%lf\n",F_UDMI(f,thread,2));", you might be misleading yourself, because the number is too small to show in this way, and you could better use "printf("depôtt%e\n",F_UDMI(f,thread,2)); ".

Another way is to let Fluent plot the value of the UDMs on the surfaces you are interested in. Or let Fluent calculate the integral of the UDMs, or whatever.

If you already did this, I have no other idea at this moment.
pakk is offline   Reply With Quote

Old   May 7, 2016, 20:23
Default
  #9
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by pakk View Post
How did you conclude that your UDMs are all zeroes?

If you did it by looking at the output of "printf("depôtt%lf\n",F_UDMI(f,thread,2));", you might be misleading yourself, because the number is too small to show in this way, and you could better use "printf("depôtt%e\n",F_UDMI(f,thread,2)); ".

Another way is to let Fluent plot the value of the UDMs on the surfaces you are interested in. Or let Fluent calculate the integral of the UDMs, or whatever.

If you already did this, I have no other idea at this moment.
7

Actually, i already let fluent plot the values of the UDMs on the surfaces i wanted however i get all the time zeroes...I got also, when i compile my code, a warning saying " 'capture_bounce_bc': not all control paths return a value " even if it is successfully compiling ... So, i think the problem is in the first UDF maybe in in the macros i'm using but i can't figure out what is exactly ...
fatima ezzahra is offline   Reply With Quote

Old   May 7, 2016, 20:39
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by fatima ezzahra View Post
Actually, i already let fluent plot the values of the UDMs on the surfaces i wanted however i get all the time zeroes...I got also, when i compile my code, a warning saying " 'capture_bounce_bc': not all control paths return a value " even if it is successfully compiling ... So, i think the problem is in the first UDF maybe in in the macros i'm using but i can't figure out what is exactly ...
The DEFINE_DPM_BC macro expects an integer return value. You should return PATH_END for when your particles deposit and are then removed from the domain. Add this line of code to the end of your code block:

Code:
return PATH_END;
`e` is offline   Reply With Quote

Old   May 7, 2016, 20:56
Default
  #11
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by `e` View Post
The DEFINE_DPM_BC macro expects an integer return value. You should return PATH_END for when your particles deposit and are then removed from the domain. Add this line of code to the end of your code block:

Code:
return PATH_END;
I tried what you said, this time i didn't get the warning but unfortunately i still get the same error which is " FLUENT received fatal signal (ACCESS_VIOLATION)" when i include the UDF of heat flux and i get zeroes in the UDMs when i exclude it.
fatima ezzahra is offline   Reply With Quote

Old   May 8, 2016, 01:05
Default
  #12
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by fatima ezzahra View Post
I tried what you said, this time i didn't get the warning but unfortunately i still get the same error which is " FLUENT received fatal signal (ACCESS_VIOLATION)" when i include the UDF of heat flux and i get zeroes in the UDMs when i exclude it.
Are you getting the fatal signal error when you're only using the DEFINE_PROFILE of the heat flux boundary? Try removing the lines of code including references to the user-defined memory (for example, F_UDMI). If your code works, then it's likely you haven't allocated the user-defined memory (as I suggested in the first reply).

You've also not defined T_Cool in the UDF provided. What is your complete UDF source file?
`e` is offline   Reply With Quote

Old   May 8, 2016, 16:06
Default
  #13
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by `e` View Post
Are you getting the fatal signal error when you're only using the DEFINE_PROFILE of the heat flux boundary? Try removing the lines of code including references to the user-defined memory (for example, F_UDMI). If your code works, then it's likely you haven't allocated the user-defined memory (as I suggested in the first reply).

You've also not defined T_Cool in the UDF provided. What is your complete UDF source file?
Yes, I’m getting it when I’m using the DEFINE_PROFILE of the heat flux boundary...

The problem is in the UDMs, there is nothing stored in them, however i can't remove them because in some UDFs I’m using variables which are already calculated in the others and stored in the UDM so I’m using them, for example in the DEFINE_PROFILE of the heat flux boundary I’m using F_UDMI(f,thread,2) where the thickness of the deposit layer is calculated in the DEFINE_DPM_BC of the particles impaction Boundary Condition....

Something else, every time i run the code before i compile it, i allocate the UDMs I’m needing from Define >> User-Define >>Memory >> Number of user defined Memory locations. Am I wrong?

I defined T_Cool, here is the complete UDF source code i'm using. Thank you for your help.

Code:
//Global Variables Defined
#include "udf.h"
#include "models.h"
#include "dpm.h"
#define stdout 
#define stderr 
#define stdin 
#define T_Cool 300                        // Cooling Temperature of the plate (K)
#define T_depôt 320                     // Temperature of the deposition (K)
#define T_Shift 20                      // Temperature Shift parameter for Browning Viscosity Model (K)
#define K_dep 9.71                         // Thermal Conductivity of deposit (W/m-K)
#define RHO_depôt 3180                  // Density of deposit particles (kg/m^3) 
#define TIMESTEP_SIZE 600                 // Timestep Length (s)
#define R_BASE 0.00034                      // Thermal Resistance of Base Layer (m^2-K/W)
#define RR_DBAR 10e-6                   // Rosin-Rammler parameter for avg.particle size (m) 
#define RR_SF 1.243                       // Rosin-Rammler parameter for shape factor
#define RR_NUM_PARTICLES 1000             // Total Number of particle streams from injectors 
#define MASS_FLOW 50             // Total particle injected mass flow (kg/s)
#define RR_DIAM_MAX 3e-3                // Rosin-Rammler maximum particle size (m) 
#define RR_DIAM_MIN 1e-7                  // Rosin-Rammler minimum particle size (m)
#define EXP 2.718282                      // e
#define PI 3.141593                       // pi
#define critical_viscosity 10000          // Critical viscosity for particle sticking (kg/m-s) 

/*
UDM Locations
0 - Total Deposit Mass 
1 - l/k Effective Thermal Re s
2 -  thickness
3 - Current Simulation Time
*/ 
//Particle impaction Boundary Condition UDF that is called when particle 'p' impacts face 'f'
DEFINE_DPM_BC(capture_bounce_bc, p, thread, f, f_normal, dim)
{
real p_loc[ND_ND],p_temperature,p_diameter;
real plocy,pvel;
real A[ND_ND],area,flow,flux; 
real viscosity,visc_exponent; 
real p_rep_mass, deposit_mass; 

//Calculate the mass represented by the impacting particle 

p_diameter=P_DIAM(p);        //Get Particle Diameter from Fluent

p_rep_mass = P_FLOW_RATE(p)*TIMESTEP_SIZE;

printf("%1.9lf\t%1.9lf\n",p_diameter,p_rep_mass); 

//Determine viscosity of particles

p_temperature=P_T(p);                                    //Get particle temperature from Fluent 
visc_exponent=14788/(p_temperature-T_Shift)-10.931;      //Calculate deposit Viscosity 
viscosity=(p_temperature-T_Shift)*pow(10,visc_exponent); // Finish Viscosity Calculation

//Assume deposited mass is inversely proportional to viscosity when particle viscosity is less than critical

deposit_mass=p_rep_mass;

if(viscosity>critical_viscosity)
 {
 deposit_mass = p_rep_mass*critical_viscosity/viscosity;
 } 

//Calculate mass deposited per unit face area

F_AREA(A,f,thread);
area=NV_MAG(A);            //Get face area from Fluent
flux=deposit_mass/area; 
F_UDMI(f,thread,0)+=deposit_mass; 

//Add thickness to deposit layer if the face temperature is higher than T_depôt

if(F_T(f,thread)>T_depôt) 
{
 printf("depôt\t%lf\n",F_UDMI(f,thread,3)); 
 F_UDMI(f,thread,2)+=flux/RHO_depôt;
 return(PATH_ABORT);
 }
return PATH_END;
}

//Heat flux boundary condition

DEFINE_PROFILE(heat_flux_BC, thread, i)
{
   real  pos_vec[ND_ND];
   real  R_EFF, wall_temp;
   face_t f;
 
      
     begin_f_loop(f,thread) 
     {
     
     //Calculate Effective thermal resistance of deposit layers 
      
        R_EFF=R_BASE+F_UDMI(f,thread,2)/K_dep;

        F_UDMI(f,thread,1)=R_EFF;

        wall_temp=F_T(f,thread);    //Get boundary temperature from Fluent 

        F_PROFILE(f,thread,i)=(T_Cool-wall_temp)/R_EFF; 
           printf("R_eff = %f\n", R_EFF);
           
      }
      
      end_f_loop(f,thread) 
}

//Injection initialization UDF that defines the transition to a new simulation timestep, 
DEFINE_DPM_INJECTION_INIT(Injection_Init,I)
{

  int i;
  real current_time=0; 
  Thread*t;
  Domain*d;
  face_t f; 

  d=Get_Domain(1);

//Increment simulation time, print to screen and store a current simulation time at UDM No.3

thread_loop_f(t, d)
 {
   
    if (NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
     {
       begin_f_loop(f,t)
        {
          F_UDMI(f,t,3)+=TIMESTEP_SIZE;
          printf("current_time = %f\n", F_UDMI(f,t,3));
 
        }
      end_f_loop(f,t); 
     }
 }


}

//Reset UDML to Zero - This is a "define on demand" UDF so it is executed by the user 
DEFINE_ON_DEMAND(Reset_UDMLs) 
  {
   int i=0; 
   Thread *t;
   Domain *d;
   face_t f;

   d = Get_Domain(1); 

   thread_loop_f(t, d)
     {

       begin_f_loop(f,t)
         {
          
              for(i=0; i <4; i++)
                   
                   F_UDMI(f,t,i)=0;    //Set UDM to zero 
         }
      
        
      end_f_loop(f,t);
     }
}
fatima ezzahra is offline   Reply With Quote

Old   May 8, 2016, 19:31
Default
  #14
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
I've run your heat flux boundary condition in a simple case and found that the problem is with reading the face temperatures at time zero (with the F_T macro). The temperatures on faces are not defined when Fluent is started, and this DEFINE_PROFILE is called when the simulation is initialised. A simple fix would be to initially define the wall temperature as a fixed constant and then use F_T onward:

Code:
DEFINE_PROFILE(heat_flux_BC, thread, i)
{
   real  pos_vec[ND_ND];
   real  R_EFF, wall_temp;
   face_t f;
 
     begin_f_loop(f,thread) 
     {
     //Calculate Effective thermal resistance of deposit layers 
      
        R_EFF=R_BASE+F_UDMI(f,thread,2)/K_dep;

        F_UDMI(f,thread,1)=R_EFF;

        if (CURRENT_TIME > 0.)
          wall_temp=F_T(f,thread);    //Get boundary temperature from Fluent 
        else
          wall_temp=300.; // a default initial temperature

        F_PROFILE(f,thread,i)=(T_Cool-wall_temp)/R_EFF; 
           printf("R_eff = %f\n", R_EFF);
           
      }
      end_f_loop(f,thread) 
}
You could use CURRENT_TIME as the current simulation time instead of using a UDM. I also noticed that some of your compiler directives, with #define, were giving compilation errors and the UDF works fine without defining stdout, stderr and stdin.
`e` is offline   Reply With Quote

Old   May 8, 2016, 19:50
Default
  #15
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
I used the code you suggested but i still have the same error when running the complete code source. Did you run the complete one or just the heat flux boundary condition?
fatima ezzahra is offline   Reply With Quote

Old   May 8, 2016, 19:59
Default
  #16
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
I compiled the complete source code and hooked only the heat flux boundary condition. Try only running this define profile as that's where the source of the error was (you may need to restart Fluent after the segmentation error; not simply compile the UDF again).
`e` is offline   Reply With Quote

Old   May 8, 2016, 20:23
Default
  #17
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
I did as you said but i still get the same error. Did you leave "R_EFF=R_BASE+F_UDMI(f,thread,2)/K_dep;" and only hook the heat flux UDF ? How could Fluent calculate R_EFF without hooking the first UDF where F_UDMI(f,thread,2) is calculated ?? Or Fluent gives a default value (zero) to this UDM so R_ EFF=R_BASE.
This time even if i remove F_UDMI(f,thread,2) i still have the same error i don't know why.
Sorry for bothering you.
fatima ezzahra is offline   Reply With Quote

Old   May 8, 2016, 21:25
Default
  #18
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Yes, I compiled the entire code with my modified DEFINE_PROFILE as above and only hooked the heat flux boundary condition. Yes, the UDM values are defined as zero when allocated.

The error was with F_T and not the F_UDMI macro. Ensure you're updating the UDF correctly by following my compiling process for Fluent UDFs with an existing library loaded.
`e` is offline   Reply With Quote

Old   May 11, 2016, 16:52
Default
  #19
New Member
 
Join Date: Apr 2016
Posts: 10
Rep Power: 10
fatima ezzahra is on a distinguished road
Quote:
Originally Posted by `e` View Post
Yes, I compiled the entire code with my modified DEFINE_PROFILE as above and only hooked the heat flux boundary condition. Yes, the UDM values are defined as zero when allocated.

The error was with F_T and not the F_UDMI macro. Ensure you're updating the UDF correctly by following my compiling process for Fluent UDFs with an existing library loaded.
I did as you said but unfortunately i still have the same error .....
fatima ezzahra is offline   Reply With Quote

Reply


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
[ImmersedBoundary] About the moving immersed boundary tutorial: icoDyMIbFoam+movingCylinderInChannelIco wyldckat OpenFOAM Community Contributions 25 September 14, 2021 18:15
fluentError: received a fatal signal (Segmentation fault). thomaszhangjing Fluent UDF and Scheme Programming 11 January 13, 2021 10:37
FLUENT received fatal signal (ACCESS_VIOLATION) Mike Wong FLUENT 7 October 17, 2014 14:17
FLUENT received fatal signal (ACCESS_VIOLATION) osamaghani FLUENT 2 March 31, 2012 17:15
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 16:16


All times are GMT -4. The time now is 08:27.