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/)
-   -   Segmentation Fault on F_C0, F_AREA, etc (http://www.cfd-online.com/Forums/fluent-udf/108483-segmentation-fault-f_c0-f_area-etc.html)

salvadortiz October 24, 2012 15:24

Segmentation Fault on F_C0, F_AREA, etc
 
Hi,

I'm trying to write a simple code for computing gradients, but cannot get past a SIGSEGV signal at the " c1 = F_C1(f,t);" line. I also get this when trying to use F_AREA (but I can compute F_CENTROID).

Can anybody tell what is wrong here?

Thanks in advance

DEFINE_ON_DEMAND(gradientes)
{
real gx, gy;
Thread *t, *t1;
cell_t c, c1;
face_t f;
int n=0;
real NV_VEC(A), NV_VEC(xxx), surf;
FILE *fout;

Domain *d; /* declare domain pointer since it is not passed as an
argument to the DEFINE macro */
d = Get_Domain(1); /* Get the domain using ANSYS FLUENT utility */
/* fout = fopen("faces.dat", "w"); */
fout = fopen("pressgrad.dat", "w");

thread_loop_c(t,d) /* Loop over all cell threads in the domain */
{
begin_c_loop(c,t) /* Loop over all cells */
{
gx = gy =0.;
c_face_loop(c,t,n) /*loopsoverallfacesofacell*/
{
f=C_FACE(c,t,n);
/* if (f) F_CENTROID(xxx, f,t); /\* AREA(A, f, t); *\/ */
/* fprintf(fout, "Cell %ld\tFace %d: %ld\t %g %g\n", c, n, f, xxx[0], xxx[1]); */
c1 = F_C1(f,t);
if (c1==c) c1 = F_C0(f,t);
F_AREA(A, f, t);
t1 = C_FACE_THREAD(c1,t,n);
if (t1==NULL) {
gx += (C_P(c,t))*A[0]/2.;
gy += (C_P(c,t))*A[1]/2.;
} else {
gx += (C_P(c,t)+C_P(c1,t1))*A[0]/2.;
gy += (C_P(c,t)+C_P(c1,t1))*A[1]/2.;
}
}

surf = C_VOLUME(c,t);
C_CENTROID(xxx,c,t);
fprintf(fout, "%g %g %g %g %g %g %g\n", xxx[0], xxx[1], C_P(c,t), C_P_G(c,t)[0], C_P_G(c,t)[1], gx/surf, gy/surf);
}
end_c_loop(c,t);
}
fclose(fout);
}


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