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/)
-   -   An error occurs after initialized FLuent loaded UDF. (https://www.cfd-online.com/Forums/fluent-udf/185592-error-occurs-after-initialized-fluent-loaded-udf.html)

wpdeng March 29, 2017 05:52

An error occurs after initialized FLuent loaded UDF.
 
1, When I compiled my UDFs, it didn't show any error. But after initialized Fluent, an error occurs.

2, Error: received a fatal signal (segmentation fault).


3, /*My UDF is about the fluid properties depending on temperatures.*/
/* my_density */
#include "udf.h"
double Tm1[2] = {
293.15 ,
294.15
};

double D[2] = {
0.16632 ,
0.03831
};
DEFINE_PROPERTY(my_density,c,t)
{
int i;
double density;
double temp = C_T(c,t);
if(temp <= Tm1[0]) density = D[0];
else if(temp > Tm1[1]) density = D[1];
else
{
for(i = 0;i <1;i++)
{
if(temp > Tm1[i] && temp <= Tm1[i+1])
density = D[i] + (temp - Tm1[i]) * (D[i+1] - D[i]) / (Tm1[i+1] - Tm1[i]);
}
}
return density;
}

4, Help me, Please! I really want to solve this problem quickly.

pakk March 29, 2017 07:39

First initialize, then load the UDF.

wpdeng March 29, 2017 08:01

initialize first?
 
Quote:

Originally Posted by pakk (Post 642849)
First initialize, then load the UDF.


My UDF is the properties of the fluid.
If initialize first, how to define the properties?

pakk March 29, 2017 08:13

That does not really matter, but if possible do something close to your expected result. Define it for example with a uniform density based on a typical temperature in your problem.

wpdeng March 29, 2017 10:30

Thanks!
 
Quote:

Originally Posted by pakk (Post 642859)
That does not really matter, but if possible do something close to your expected result. Define it for example with a uniform density based on a typical temperature in your problem.


Really really thank you! I tried the method you told, the fluent can running!

kar1209 April 6, 2017 04:46

I am also facing the same error
 
I am getting the "received a fatal signal (segmentation fault)" error. Is it because the function is not able to access the previous timestep values using F_U_M1 and C_U_M1?
Code:

#include"udf.h"
DEFINE_PROFILE(CBC_u_vel,t,i)
{
real u_f_old, u_c_old, u_temp, u_cor, mass_out = 0, ds;
real x[ND_ND], y[ND_ND];
Thread *nt;
face_t f;
cell_t c, nc;
begin_f_loop(f,t)
{
mass_out+=F_FLUX(f,t);
}
end_f_loop(f,t)
u_cor = (20 - mass_out)/20;
begin_f_loop(f,t)
{
nc = F_C0(f,t);
nt = THREAD_T0(t);
F_CENTROID(x,f,t);
C_CENTROID(y,nc,nt);
ds = x[0] - y[0];
u_f_old = F_U_M1(f,t);
u_c_old = C_U_M1(nc,nt);
u_temp = u_f_old - CURRENT_TIMESTEP*(u_f_old - u_c_old)/ds;
F_PROFILE(f,t,i) = u_temp + u_cor;
}
end_f_loop(f,t)
}

The UDF manual says:
Quote:

Note that data from C_T_M1 is available only if user-defined scalars are defined.
How do I define and use user-defined scalars to access data using C_U_M1 in my program?

Any help would be appreciated.

wpdeng April 6, 2017 21:41

Don't worry about the error!
 
Quote:

Originally Posted by kar1209 (Post 643885)
I am getting the "received a fatal signal (segmentation fault)" error. Is it because the function is not able to access the previous timestep values using F_U_M1 and C_U_M1?
Code:

#include"udf.h"
DEFINE_PROFILE(CBC_u_vel,t,i)
{
real u_f_old, u_c_old, u_temp, u_cor, mass_out = 0, ds;
real x[ND_ND], y[ND_ND];
Thread *nt;
face_t f;
cell_t c, nc;
begin_f_loop(f,t)
{
mass_out+=F_FLUX(f,t);
}
end_f_loop(f,t)
u_cor = (20 - mass_out)/20;
begin_f_loop(f,t)
{
nc = F_C0(f,t);
nt = THREAD_T0(t);
F_CENTROID(x,f,t);
C_CENTROID(y,nc,nt);
ds = x[0] - y[0];
u_f_old = F_U_M1(f,t);
u_c_old = C_U_M1(nc,nt);
u_temp = u_f_old - CURRENT_TIMESTEP*(u_f_old - u_c_old)/ds;
F_PROFILE(f,t,i) = u_temp + u_cor;
}
end_f_loop(f,t)
}

The UDF manual says:


How do I define and use user-defined scalars to access data using C_U_M1 in my program?

Any help would be appreciated.


I don't know your UDFs, maybe you can check carefully by yourself.

But if you cannot running the Fluent, you can try the method, which using a constant velocity to initialize the Fluent and then load your UDFs to running the Fluent.

Maybe your problems can be solved. If cannot, you can ask for help to others.


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