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

Error: Segmentation Fault - Fluent

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 14, 2016, 14:13
Default Error: Segmentation Fault - Fluent
  #1
New Member
 
Braulio Uciel Alvarado Alcalá
Join Date: Jun 2016
Posts: 2
Rep Power: 0
uzziel01 is on a distinguished road
Hello!!

I'm trying to simulate Natural Convection inside a refrigerator. I have a polynomial to enviromental temperature and I've made a UDF to calculate the temperature inside the refrigerator and to calculate the "h" coefficient for convection using the correlation of Churchill y Chu.

Fluent interprets the UDF correctly, but when I'm going to initialize the solution a message appears.



Could anyone help me, please?


This is the code of de UDF.

Code:
DEFINE_PROFILE(h_constant, thread, position)
{
real tsuma=0;    
real tavg;
real temp;
face_t f;
int contador=0;

real p,t_env;
real r,Cp,k,mu,vis;
real Pr;

real g=9.81, beta,L=0.43,Ts,Gr;
real Ra,Nu,h;

        cell_t c; /* Se declara una variable de celda */
        Thread *t_c;
        Domain *y;
        int refri_id=1;        
        y=Get_Domain(refri_id);  /*    Indica el ID de la zona de la pared     */
        


    
                    /* Calculo de la temperatura promedio del dominio */    

            thread_loop_c(t_c,y)
            {

                begin_c_loop(c,t_c)
                {
                    temp = C_T(c,t_c);
                    contador++;
                    tsuma += temp;
                }
                end_c_loop(c,t_c)

                tavg = tsuma/contador;
            }


                            /* Temperatura ambiente */

               p=CURRENT_TIME;
         
             
              if (p<=9000)
                 t_env=298.1+0.001334*p-0.0000001681*(pow(p,2))+0.000000000006433*(pow(p,3));
              else if (p>9000 && p<=69900)
                 t_env=302.1-0.00003154*p-0.0000000006091*(pow(p,2));
              else if (p>69900 && p<=106800)
                 t_env=-231.3+0.022*p-0.0000003451*(pow(p,2))+0.000000000002433*(pow(p,3))-0.000000000000000006474*(pow(p,4));
              else if (p>106800 && p<=158400)
                 t_env=311.9-0.00006337*p-0.0000000001965*(pow(p,2));
              else if (p>158400 && p<=198900)
                 t_env=40.92+0.00281*p-0.000000007524*(pow(p,2));
              else if (p>198900 && p<=241500)
                 t_env=287.7+0.0002514*p-0.0000000009*(pow(p,2));
             



            /* ****************************************************************** */
                      /*     Correlación para h     */
            /* ****************************************************************** */



                /* Cálculo para propiedades del aire a T=tenv */
        

        r=3.68909-0.0128308*t_env+0.0000148526*(pow(t_env,2));
        Cp=1017.11-0.131603*(t_env)+0.000300914*(pow(t_env,2));
        k=0.00318413+0.0000748721*t_env;
        mu=0.00000429617+0.0000000475835*t_env;

        vis=mu/r;

                        /* Prandtl */

        
        Pr=(Cp*mu)/k;

                        /* Grashof */

        /* L=43.5 cm */
        

        Ts=(tavg+t_env)/2.;
        beta=1./Ts;

        Gr=(g*beta*(tavg-t_env)*(pow(L,3)))/(pow(vis,2));

                        /* Rayleigh */
        
        Ra=Gr*Pr;

                /* Correlación de Churchill y Chu para Nusselt */
        

        Nu=0.68+((0.670*(pow(Ra,0.25))))/pow(1+(0.492/(pow(Pr,9/16))),4/9);

        h=(Nu*k)/L;


        begin_f_loop(f,thread)
            {
                F_PROFILE(f,thread,position)=h;
            }
        end_f_loop(f,thread)

        printf("Valor de h: %g\n", h);

}
Attached Images
File Type: jpg Screenshot_1.jpg (11.4 KB, 10 views)
uzziel01 is offline   Reply With Quote

Old   June 14, 2016, 18:42
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
This segmentation error occurs when you're trying to access a variable which isn't available. You'll need to identify the line of code which is causing this error. First, try replacing C_T(c,t_c) with 1. to check if the cell temperature is available across all cells. If the segmentation error disappears, then it's possible the cell temperature isn't available on the first time step for the DEFINE_PROFILE macro (apply a conditional statement in this case).

Note: if you're running this macro with the parallel solver then these looping macros only access the cells within the compute node's partition. Therefore, the average temperature calculated would not cover the entire domain. See the UDF manual for examples on communicating between compute nodes (message passing).
`e` is offline   Reply With Quote

Old   June 14, 2016, 19:35
Default Thanks
  #3
New Member
 
Braulio Uciel Alvarado Alcalá
Join Date: Jun 2016
Posts: 2
Rep Power: 0
uzziel01 is on a distinguished road
Quote:
Originally Posted by `e` View Post
This segmentation error occurs when you're trying to access a variable which isn't available. You'll need to identify the line of code which is causing this error. First, try replacing C_T(c,t_c) with 1. to check if the cell temperature is available across all cells. If the segmentation error disappears, then it's possible the cell temperature isn't available on the first time step for the DEFINE_PROFILE macro (apply a conditional statement in this case).

Note: if you're running this macro with the parallel solver then these looping macros only access the cells within the compute node's partition. Therefore, the average temperature calculated would not cover the entire domain. See the UDF manual for examples on communicating between compute nodes (message passing).
Thanks `e`

I've changed the value that you suggues me, but I have the same error yet.

I've change the value in F_PROFILE, to, but it's the same error.

Could you suggues me another thing to change?

Thanks `e`
uzziel01 is offline   Reply With Quote

Old   June 15, 2016, 08:25
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Quote:
Originally Posted by `e` View Post
You'll need to identify the line of code which is causing this error.
Either remove lines of code until you find the cause of the error or add messages using the Message() function to help with debugging.
`e` is offline   Reply With Quote

Old   December 9, 2016, 17:39
Default
  #5
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 17
alinik is on a distinguished road
Braulio,

I am having the same error.
Apparently this line is creating the problem:

thread_loop_c (t,domain)

Did you find a solution to your problem?



Quote:
Originally Posted by uzziel01 View Post
Hello!!

I'm trying to simulate Natural Convection inside a refrigerator. I have a polynomial to enviromental temperature and I've made a UDF to calculate the temperature inside the refrigerator and to calculate the "h" coefficient for convection using the correlation of Churchill y Chu.

Fluent interprets the UDF correctly, but when I'm going to initialize the solution a message appears.



Could anyone help me, please?


This is the code of de UDF.

Code:
DEFINE_PROFILE(h_constant, thread, position)
{
real tsuma=0;    
real tavg;
real temp;
face_t f;
int contador=0;

real p,t_env;
real r,Cp,k,mu,vis;
real Pr;

real g=9.81, beta,L=0.43,Ts,Gr;
real Ra,Nu,h;

        cell_t c; /* Se declara una variable de celda */
        Thread *t_c;
        Domain *y;
        int refri_id=1;        
        y=Get_Domain(refri_id);  /*    Indica el ID de la zona de la pared     */
        


    
                    /* Calculo de la temperatura promedio del dominio */    

            thread_loop_c(t_c,y)
            {

                begin_c_loop(c,t_c)
                {
                    temp = C_T(c,t_c);
                    contador++;
                    tsuma += temp;
                }
                end_c_loop(c,t_c)

                tavg = tsuma/contador;
            }


                            /* Temperatura ambiente */

               p=CURRENT_TIME;
         
             
              if (p<=9000)
                 t_env=298.1+0.001334*p-0.0000001681*(pow(p,2))+0.000000000006433*(pow(p,3));
              else if (p>9000 && p<=69900)
                 t_env=302.1-0.00003154*p-0.0000000006091*(pow(p,2));
              else if (p>69900 && p<=106800)
                 t_env=-231.3+0.022*p-0.0000003451*(pow(p,2))+0.000000000002433*(pow(p,3))-0.000000000000000006474*(pow(p,4));
              else if (p>106800 && p<=158400)
                 t_env=311.9-0.00006337*p-0.0000000001965*(pow(p,2));
              else if (p>158400 && p<=198900)
                 t_env=40.92+0.00281*p-0.000000007524*(pow(p,2));
              else if (p>198900 && p<=241500)
                 t_env=287.7+0.0002514*p-0.0000000009*(pow(p,2));
             



            /* ****************************************************************** */
                      /*     Correlación para h     */
            /* ****************************************************************** */



                /* Cálculo para propiedades del aire a T=tenv */
        

        r=3.68909-0.0128308*t_env+0.0000148526*(pow(t_env,2));
        Cp=1017.11-0.131603*(t_env)+0.000300914*(pow(t_env,2));
        k=0.00318413+0.0000748721*t_env;
        mu=0.00000429617+0.0000000475835*t_env;

        vis=mu/r;

                        /* Prandtl */

        
        Pr=(Cp*mu)/k;

                        /* Grashof */

        /* L=43.5 cm */
        

        Ts=(tavg+t_env)/2.;
        beta=1./Ts;

        Gr=(g*beta*(tavg-t_env)*(pow(L,3)))/(pow(vis,2));

                        /* Rayleigh */
        
        Ra=Gr*Pr;

                /* Correlación de Churchill y Chu para Nusselt */
        

        Nu=0.68+((0.670*(pow(Ra,0.25))))/pow(1+(0.492/(pow(Pr,9/16))),4/9);

        h=(Nu*k)/L;


        begin_f_loop(f,thread)
            {
                F_PROFILE(f,thread,position)=h;
            }
        end_f_loop(f,thread)

        printf("Valor de h: %g\n", h);

}
alinik is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Two questions on Fluent UDF Steven Fluent UDF and Scheme Programming 7 March 23, 2018 04:22
heat transfer with RANS wall function, over a flat plate (validation with fluent) bruce OpenFOAM Running, Solving & CFD 6 January 20, 2017 07:22
Fluent UDF Wall Shear Stress Segmentation Fault a1ananth Fluent UDF and Scheme Programming 3 February 24, 2015 04:23
Fluent 12.0 is worst then Fluent 6.2 herntan FLUENT 5 December 14, 2009 03:57
Problems in lauching FLUENT Lourival FLUENT 3 January 16, 2008 17:48


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