Udf segmentation violation
Hello people,
I'm trying to write down a simple UDF which will calculate the pressure time derivative for each cell and time step and will also assign a zero value to the z velocity. The pressure time derivative and z-velocity value will also be saved as two new variables. I managed to compile and hook the function. However, when running the calculation I always get a SEGMENTATION VIOLATION and the simulation is terminated. The UDF I have coded is the following: /********************/ #include "udf.h" #include "mem.h" DEFINE_ADJUST(dp_dt_uzero,d) { Thread *t; cell_t c; real p1, p2, dt=0.05; thread_loop_c(t,d) { begin_c_loop(c,t) { /* Read pressure from previous and second previous time steps */ p1 = C_P_M1(c,t); p2 = C_P_M2(c,t); C_UDMI(c,t,0) = (p1 - p2) / (dt); /* Assign value zero to uz */ C_UDMI(c,t,1) = 0.; } end_c_loop(c,t) } } /********************/ Should I have looping in cells and threads? I tried without the loops and still have the same problem. Additionally, I am running in parallel. Might the code need to be parallelized? Thanks! :) |
All times are GMT -4. The time now is 07:35. |