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/)
-   -   Cell Zone Segmentation Access Violation (https://www.cfd-online.com/Forums/fluent-udf/140172-cell-zone-segmentation-access-violation.html)

Exodiah August 9, 2014 10:46

Cell Zone Segmentation Access Violation
 
Hi, I have a UDF for a translating mesh. My code compiles and loads with no errors. But hooking the code into the cell zone, specifically into the translation velocity field, will yield a Segmentation Violation error. The code is pasted below.


--------------------------------------------------------------------
#include "udf.h"
#include "mem.h"

#define pi M_PI

static real vel=0.0;


DEFINE_TRANSIENT_PROFILE(trans,time)
{
real fx = 0.0; /* init drag force */
real vol = 0.5*pi*0.025*1*5; /* vol of wing */
real sigma = 2.55; /* specific gravity of wing material */
real mass = 1000*sigma*vol; /* mass of wing */
real dvel;
real NV_VEC(A);

face_t f;
Thread *t;
Domain *d;

/* single phase domain is 1, wing zone is 6 */
d = Get_Domain(1);
t = Lookup_Thread(d, 6);
if(NULL == d) Error("Something wrong with your domain id!\n");
if(NULL == t) Error("Something wrong with your thread id!\n");


/* sum of drag forces */
if (NULL != t)
{
begin_f_loop(f,t)
{
F_AREA(A,f,t);
fx += F_P(f,t)*A[0]+F_STORAGE_R_N3V(f,t,SV_WALL_SHEAR)[0];
}
end_f_loop(f,t)

/* acceleration */
dvel=fx/mass;

/* new translational velocity */
vel+=dvel*CURRENT_TIMESTEP;
}

return vel;
}
--------------------------------------------------------------------


The problem with the code is the line "fx+= ... ". Commenting out this line will not produce an error during hooking.

Please kindly advise.

I have not been able to find any solution in this forum - if there is please kindly point me to it.


All times are GMT -4. The time now is 08:55.