CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF errors when complile

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 30, 2016, 05:23
Default UDF errors when complile
  #1
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
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
flo90000 is offline   Reply With Quote

Old   August 30, 2016, 08:30
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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)
This is such a common line in Fluent, so only three things could be wrong:
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;
So without the star.

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.
pakk is offline   Reply With Quote

Old   August 30, 2016, 09:59
Default
  #3
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Code:
face_t f;

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.
flo90000 is offline   Reply With Quote

Old   August 30, 2016, 10:47
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by flo90000 View Post
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.
Don't bother with the compiler or the user defined memory.

Quote:
Originally Posted by pakk
It did give a warning about "node" being uninitialized, you should look at that.
Do this instead. "node" is uninitialized, so it causes the invalid memory reference. Fix this. Why do you use "node"? What should it refer to?
pakk is offline   Reply With Quote

Old   August 30, 2016, 11:02
Default
  #5
Member
 
ERMACORA Florian
Join Date: May 2016
Posts: 39
Rep Power: 10
flo90000 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Why do you use "node"? What should it refer to?
node refer me the postion of each node on the wall to get the distance between the node and the center of gravity to calculate the momentum in Z due to the pressure on it
flo90000 is offline   Reply With Quote

Old   August 31, 2016, 02:26
Default
  #6
D.M
Member
 
Davoud Malekian
Join Date: Jan 2016
Posts: 53
Rep Power: 10
D.M is on a distinguished road
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.
D.M is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 11:33.