CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF segmentation violation error (https://www.cfd-online.com/Forums/fluent-udf/92004-udf-segmentation-violation-error.html)

be89 August 30, 2011 03:48

UDF segmentation violation error
 
I wrote the following UDF to define the condensation in a multiphase model from moist air water vapor to liquid water:

#include "udf.h"
#include "mem.h"
#include "math.h"
#include "sg.h"
#include "prop.h" /* for function: Saturation_Pressure() (of water) */
real H2O_Saturation_Pressure(real T)
{
real ratio, aTmTp;
aTmTp = .01 * (T - 338.15);
ratio = (647.286/T - 1.) *
(-7.419242 + aTmTp*(.29721 +
aTmTp*(-.1155286 +
aTmTp*(8.685635e-3 +
aTmTp*(1.094098e-3 +
aTmTp*(-4.39993e-3 +
aTmTp*(2.520658e-3 -
aTmTp*5.218684e-4)))))));
return (22.089e6 * exp(MIN(ratio,35.)));
}

Domain *d;
DEFINE_MASS_TRANSFER(vap_condensation,c,t,from_pha se_index,from_species_index,to_phase_index,to_spec ies_index)
{
real m_lg;
int i;
Material *m=THREAD_MATERIAL(t), *sp;
real x_h2o, x_sat, w_sat; /* w=mv/ma; x=mv/(ma+mv) */
#define p 101325
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
if(MATERIAL_TYPE(m)==MATERIAL_MIXTURE)
{
mixture_species_loop(m,sp,i)
{
if (0 == strcmp(MIXTURE_SPECIE_NAME(m,i),"h2o") || (0 == strcmp(MIXTURE_SPECIE_NAME(m,i),"H2O")))
{
x_h2o = C_YI(c,t,i);
}
}
}

w_sat=.622*H2O_Saturation_Pressure(C_T(c,t))/(p-H2O_Saturation_Pressure(C_T(c,t)));
x_sat=w_sat/(1+w_sat);
m_lg = 0.;

if (x_h2o > x_sat)
{
m_lg=(x_h2o-x_sat)*C_R(c,t);
}
return m_lg;

}
end_c_loop(c,t)
}
}

Then I compiled it in Fluent receiving no error, but I can't initialize the calculation because Fluent gives a "segmentation violation error" when trying to do it.
Can anyone help me, please?

IndrajitW December 21, 2012 03:07

Hi Enrico Bezzi,
I am facing the same problem for a different case.When I compile there isn't any error however when I try to initialise it gives me segmentation violation error.
Since it has been an year, did you solve the problem??? What was going wrong?
Regards,
Indrajit


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