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

P_POS Undeclared Variable Error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 24, 2013, 16:51
Default P_POS Undeclared Variable Error
  #1
New Member
 
Join Date: Oct 2013
Posts: 4
Rep Power: 13
osuguy is on a distinguished road
Hey Everyone,

I have this simple code below I am using to try to get a feel for body force modeling. I am having trouble compiling the code, as it comes up with an undeclared variable error when looking at the P_POS macros in the if statements.

#include "udf.h"

DEFINE_DPM_BODY_FORCE(BodyTest,p,i)
{
real bforce=0;

if (P_POS(p)[0]>-.01 && P_POS(p)[0]<.01 && P_POS(p)[1]>.03 && i==0)
{ bforce=2;
}
if (P_POS(p)[0]>-.01 && P_POS(p)[0]<.01 && P_POS(p)[1]>.03 && i==1)
{ bforce=1;
}

return bforce;
}

Any help as to why this is happening or ways to fix it would be greatly appreciated.

Thanks
osuguy is offline   Reply With Quote

Old   March 8, 2014, 06:38
Default
  #2
New Member
 
Select One
Join Date: Mar 2014
Posts: 2
Rep Power: 0
SSOHEIL is on a distinguished road
Hi,

Try to include dpm.h and declare P_POS as:
#include <dpm.h>
double P_POS[3]; //3 for a 3D or 2 for a 2D case

Regards.
SSOHEIL is offline   Reply With Quote

Old   July 29, 2019, 03:44
Default How to remove "Undeclared Variable" Error in Ansys Fluent UDF for Density?
  #3
New Member
 
Azim Memon
Join Date: Jul 2019
Posts: 12
Rep Power: 7
Azim07 is on a distinguished road
Here i have a UDF which Shows the undeclared variable error in line 6. How can i remove this?


#include "udf.h"
DEFINE_PROPERTY(cell_density,c,t)
{
real rho;
real T = C_T(c,t);
rho = 885/(0.0008(temp-321.35)+1);
C_UDMI(c,t,0) = rho;
return rho;
}
Azim07 is offline   Reply With Quote

Old   July 29, 2019, 03:57
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you've defined T, but later use temp
choose one of them

best regards
AlexanderZ is offline   Reply With Quote

Old   August 31, 2020, 22:23
Default how to remove undeclared variable error for P_POS
  #5
New Member
 
Join Date: Aug 2020
Posts: 2
Rep Power: 0
mmr1995 is on a distinguished road
I'm new to ANSYS and using UDFs. I also get the same error for P-POS even though this is described in the manual as an existing DPM variable.
The following is my code:


#include "udf.h"

#define w 50.0*30/3.14159265359 /* angular velocity rpm */
#define TSTART 0.0 /* field applied at t = tstart */

/* Calculate Centrifugal Acceleration */
/* acent= w^2*r */

DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
real bforce=0;
double P_POS[2];
if(P_TIME(p)>=TSTART)
{
if(i==1) bforce=w*w*P_POS(p)[1];

}
else
bforce=0.0;
return (bforce);
mmr1995 is offline   Reply With Quote

Old   September 1, 2020, 03:21
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try this code
next time show log of your error

Code:
#include "udf.h"

#define w 50.0*30/3.14159265359 /* angular velocity rpm */
#define TSTART 0.0 /* field applied at t = tstart */

/* Calculate Centrifugal Acceleration */
/* acent= w^2*r */

DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
real bforce=0;
if(P_TIME(p)>=TSTART)
{
if(i==1) bforce=w*w*P_POS(p)[1];
}
else
bforce=0.0;
return (bforce);
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   September 1, 2020, 09:55
Default
  #7
New Member
 
Join Date: Aug 2020
Posts: 2
Rep Power: 0
mmr1995 is on a distinguished road
hello! Thank you for your reply, even with your edited code I get the error:
"line 18: P_POS: undeclared variable"
mmr1995 is offline   Reply With Quote

Old   September 1, 2020, 22:42
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile the code
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
[OpenFOAM] an error in Calculator's equation immortality ParaView 12 June 29, 2021 01:10
UDF: DEFINE_CG_MOTION for vertical jump motion of an electrode! alban Fluent UDF and Scheme Programming 2 June 8, 2010 19:54
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 13:34
[swak4Foam] groovyBC: problems compiling: "flex: not found" and "undefined reference to ..." sega OpenFOAM Community Contributions 12 February 17, 2010 10:30
user subroutine error CFDUSER CFX 2 December 9, 2006 07:31


All times are GMT -4. The time now is 19:07.