CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   FLUENT received fatal signal (ACCESS_VIOLATION) (http://www.cfd-online.com/Forums/fluent-udf/122546-fluent-received-fatal-signal-access_violation.html)

vExus August 21, 2013 18:39

FLUENT received fatal signal (ACCESS_VIOLATION)
 
Hi,
I wrote an UDF which fluent interprets without any errors but when initializing the solution i get:
Code:

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: #f

I found that
Code:

C_T(cell, thread)
is the reason. I dont undestand why this happens because i used this macro while defining 3 different properties and only one time it couse this kind of problem.
Energy equation is turned on.
Whole code:
Code:

#include "udf.h"       

DEFINE_PROPERTY(gestosc_miesa, cell, thread)

{
       

        real rom;
        real t = C_T(cell, thread);
       
       
                rom = 1226 - 0,56 * t;

                return rom;
}




DEFINE_PROPERTY(wsp_przew_ciepla_mieso, cell, thread)

{
       

        real km;
        real t = C_T(cell, thread);
       
       
                km = 0,044 + t * 1,56 * 10^-3;

                return km;
}




DEFINE_PROPERTY(cp_miesa, cell, thread)

{
        real cpm;
        real m;
        real t = C_T(cell, thread); //here is the problem
        m = 0,7;
       
        if (t < 303.)
                    cpm = 1675 + 2510 * m;
 
          else
                    cpm = 3000.;
               

                return cpm;
}










DEFINE_PROPERTY(gestosc_tluszczu, cell, thread)

{
       

        real rot;
        real t = C_T(cell, thread);
       
       
                rot = 1052 - 0,377 * t;

                return rot;
}

What should I do?

blackmask August 21, 2013 20:10

It does not hurt to check the pointer before accessing it
Code:

real t;
if (NNULLP(THREAD_STORAGE(thread, SV_T)))
  t = C_T(cell, thread);
else
  t = 300.0; /* or whatever appropriate */


vExus August 22, 2013 06:51

It doesnt help...
I even tried this:
Code:

#include "udf.h"       
DEFINE_PROPERTY(cp_miesa, cell, thread)

{
        real t;

if (NNULLP(THREAD_STORAGE(thread, SV_T)))
  t = C_T(cell, thread);

else
  t = 300.0; /* or whatever appropriate */
       

        return t;
}

just to check if it works and I got the same error.
What else can cause such an error?

Deleting "C_T(cell, thread)" from code makes error disappear.

blackmask August 22, 2013 08:25

It does not make sense to me. Could you post your full code with the non-null-pointer checking?

vExus August 22, 2013 13:36

Everything but
Code:

DEFINE_PROPERTY(cp_miesa, cell, thread)

{
        real cpm;
        real m;
        real t;
        m = 0,7;
       
        if (NNULLP(THREAD_STORAGE(thread, SV_T)))
        {
                t = C_T(cell, thread);
                if (t < 303.)
                    cpm = 1675 + 2510 * m;
        }
        else
        {
                        cpm = 3000.;
        }

        return cpm;
}

works fine.


Whole code:
Code:

#include "udf.h"       

DEFINE_PROPERTY(gestosc_miesa, cell, thread)

{
       

        real rom;
        real t = C_T(cell, thread);
       
       
                rom = 1226 - 0,56 * t;

                return rom;
}



DEFINE_PROPERTY(wsp_przew_ciepla_mieso, cell, thread)

{
       

        real km;
        real t = C_T(cell, thread);
       
       
                km = 0,044 + t * 1,56 * 10^-3;

                return km;
}



DEFINE_PROPERTY(cp_miesa, cell, thread)

{
        real cpm;
        real m;
        real t;
        m = 0,7;
       
        if (NNULLP(THREAD_STORAGE(thread, SV_T)))
        {
                t = C_T(cell, thread);
                if (t < 303.)
                    cpm = 1675 + 2510 * m;
        }
        else
        {
                        cpm = 3000.;
        }

        return cpm;
}




DEFINE_PROPERTY(gestosc_tluszczu, cell, thread)

{
       

        real rot;
        real t = C_T(cell, thread);
       
       
                rot = 1052 - 0,377 * t;

                return rot;
}




DEFINE_PROFILE (T_ot, thread, index)
{
        int s;
        real tval;
        double tab[8547]={};
        face_t f;
       
        s=RP_Get_Real("flow-time");
        tval = s < 8547 ? tab[s] : tab[8546];
       
        begin_f_loop(f, thread)
        {
                F_PROFILE(f, thread, index) = tval;
        }
        end_f_loop(f, thread);
}


blackmask August 22, 2013 20:23

You have several "C_T" in your code and only this one is wrapped by pointer-checking. When you said that the error disappear after deleting the "C_T" line, did you delete this specific "C_T" line or did you delete all the occurrence of "C_T"? If this specific line caused segmentation fault, I have no idea what is going on but I doubt it should happen.

You are French, right? Note that 0,56 1,56 0,377 should be changed to 0.56, 1.56 and 0.377, respectively. The expression "1,56 * 10^-3" should be changed to "1.56e-3".

"

vExus August 23, 2013 03:39

I know it seems strange but only this specific C_T couse trouble.

I am from Poland. Thanks for your advice.


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