Fluent UDF Wall Shear Stress Segmentation Fault
Hi, I am using DEFINE_PROFILE to define wall shear stress value on boundary layer faces. The interpretation is successful but I am getting "Error: received a fatal signal (Segmentation fault)." when I do hybrid initialization. My udf code is:
DEFINE_PROFILE(wall_shear_udf_faces, thread, i) { face_t f; real x[ND_ND]; real ufree; real wall_shear_value; real L, U, rho, mu, Re; ufree = USTAR; begin_f_loop(f, thread) { F_CENTROID(x, f, thread); printf("X = %f and Y = %f\n\n", x[0], x[1]); L = sqrt( (x[0] * x[0]) + (x[1] * x[1]) ); // distance formula printf("Here\n\n"); rho = F_R(f, thread); printf("L = %f and rho = %f\n\n", L, rho); mu = F_MU_L(f, thread); U = F_U(f, thread); Re = (U * L) / mu; printf("MU = %f and Re = %f\n\n", mu, Re); // calculate using reynolds 1/5 power law wall_shear_value = ((mult * rho) * (ufree * ufree)) / (pow(Re, POWER)); F_PROFILE(f, thread, i) = wall_shear_value; } end_f_loop(f, thread) } Error occurs in the line rho = F_R(f, thread); .. I know this because it prints "Here" in the fluent console. Any idea why this error occurs and how to get it running? Thanks ahead! |
More error description
If I give constant values to all the variables it works.. but when I try to use the Face Field Variable Macros, it gives segmentation fault..
|
Quote:
The problem of "segmentation fault" occurs when a solver variable is illegally accessed which in this case I suspect are the density and viscosity variables because they are stored in cell nodes and not in faces. |
Quote:
Code:
rho = F_R(f, thread); In your case, if you do initialization, apparently this function is called before the density is set. If the order would have been differently, it would have worked. I can give you two solution approaches: 1. Change the UDF, so that it first checks if the density is set, and if it is not set, it should use a 'default' value for the density. This is the best solution, but maybe difficult to program. 2. When you want to initialize, remove all calls to this function (or use constant values inside the function), and change the function to the correct version after initialization. This is the quick-and-dirty workaround. |
All times are GMT -4. The time now is 23:45. |