|
[Sponsors] |
August 30, 2016, 05:23 |
UDF errors when complile
|
#1 |
Member
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10 |
Hello
I wrote a udf to move a reed valve in 6DOF and I want to calculate the moment in z to allow or not a rotation but when I compile my udf, it appears there are some mistakes. but I don't know how to resolve it. Someone can help me, pls? thnak you for your help Code:
#include "udf.h" #include "math.h" DEFINE_SDOF_PROPERTIES(Valve_6dof_ex, prop, dt, time, dtime) { static real theta, cg_x, cg_y; static real NV_VEC(A); static real Mz, netmoment; Thread *t; Node *node; face_t *f; Mz = 0.0; t = DT_THREAD(dt); cg_x = 0.01625; cg_y = 0.0185; begin_f_loop(f,t) { F_AREA(A,f,t); Mz += F_P(f,t)*(A[0]*(NODE_Y(node)-cg_y)-A[1]*(NODE_X(node)-cg_x)); } end_f_loop(f,t) prop[SDOF_MASS] = 0.00114; prop[SDOF_IZZ] = 0.000023; prop[SDOF_ZERO_TRANS_X] = TRUE; prop[SDOF_ZERO_TRANS_Y] = TRUE; prop[SDOF_ZERO_TRANS_Z] = TRUE; prop[SDOF_ZERO_ROT_X] = TRUE; prop[SDOF_ZERO_ROT_Y] = TRUE; prop[SDOF_ZERO_ROT_Z] = TRUE; prop[SDOF_LOAD_M_Z] = 9.81*0.0114*cos(DT_THETA (dt)[2])*0.0095; theta = DT_THETA(dt)[2]; netmoment = Mz + prop[SDOF_LOAD_M_Z]; Message("\n 2d_ex : theta_Z:%e,Mz:%e,Mass:%e,mom_tot:%e\n", DT_THETA(dt)[2],prop[SDOF_LOAD_M_Z],prop[SDOF_MASS],netmoment); if((theta<0)||(theta>0.087)) { prop[SDOF_ZERO_ROT_Z]=TRUE; Message("Clapet_ex_bloqué"); } else { prop[SDOF_ZERO_ROT_Z] = FALSE; } } Code:
errors: valve__7.c: In function Valve_6dof_ex: valve__7.c:19: warning: comparison between pointer and integer valve__7.c:21: error: array subscript is not an integer valve__7.c:21: error: array subscript is not an integer valve__7.c:21: warning: left-hand operand of comma expression has no effect valve__7.c:22: error: array subscript is not an integer |
|
August 30, 2016, 08:30 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Let me show you the steps I took to debug your code.
I looked at the location of the first problem: line 19. (I compiled your code and it said line 18 to me, but that is not really important.) I checked which line this was: it was the following: Code:
begin_f_loop(f,t) 1. A typo in "begin_f_loop" 2. A problem with f 3. A problem with t So I checked how you defined f and t, and looked at examples in the help where f and t were defined, and I saw that your f was wrong, it should be: Code:
face_t f; I changed this, and this time the compilation gave no errors. It did give a warning about "node" being uninitialized, you should look at that. |
|
August 30, 2016, 09:59 |
|
#3 |
Member
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10 |
Thank you for your answer. I have another question. When I want to run it, fluent say me "receive a fatal signal(segmentation fault" in series and "Receive Signal SIGSEV" in parallel. It s due to an invalid memory reference. Will I add some parallel compiler? I try add some user defined memory. |
|
August 30, 2016, 10:47 |
|
#4 | ||
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
Quote:
|
|||
August 30, 2016, 11:02 |
|
#5 |
Member
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10 |
||
August 31, 2016, 02:26 |
|
#6 |
Member
Davoud Malekian
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
Hello,
i don't know if this gonna help you with your problem or not cause i haven't checked all the lines of your code , but when you want to use node values in your udf you must loop over all the nodes on your face and access their global index , try to change your code like this: #include "udf.h" #include "math.h" DEFINE_SDOF_PROPERTIES(Valve_6dof_ex, prop, dt, time, dtime) { static real theta, cg_x, cg_y; static real NV_VEC(A); static real Mz, netmoment; int n; Thread *t; Node *node; face_t *f; Mz = 0.0; t = DT_THREAD(dt); cg_x = 0.01625; cg_y = 0.0185; begin_f_loop(f,t) { f_node_loop(f,t,n) /*n refers to the local index of nodes on a face*/ { node = F_NODE(f,t,n); /*accesing global index of nodes*/ F_AREA(A,f,t); Mz += F_P(f,t)*(A[0]*(NODE_Y(node)-cg_y)-A[1]*(NODE_X(node)-cg_x)); } } end_f_loop(f,t) """ "node" is uninitialized""" this warning shows that you haven't defined "node" and it means that you should define nodes by their global index. it is exactly like "Thread *t" , and few lines below that you have defined " t = DT_THREAD(dt) " , you should do the same for the nodes too! sry i didn't check your code completely but i hope the udf above helps you a little bit. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Building OpenFOAM1.7.0 from source | ata | OpenFOAM Installation | 46 | March 6, 2022 14:21 |
UDF - compiling errors | Tscar | FLUENT | 1 | March 21, 2018 23:24 |
Stuck in a Rut- interDyMFoam! | xoitx | OpenFOAM Running, Solving & CFD | 14 | March 25, 2016 08:09 |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
errors in interpreted udf for two macro | Asghari | FLUENT | 0 | August 7, 2006 03:29 |