|
[Sponsors] |
October 24, 2013, 16:51 |
P_POS Undeclared Variable Error
|
#1 |
New Member
Join Date: Oct 2013
Posts: 4
Rep Power: 13 |
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 |
|
March 8, 2014, 06:38 |
|
#2 |
New Member
Select One
Join Date: Mar 2014
Posts: 2
Rep Power: 0 |
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. |
|
July 29, 2019, 03:44 |
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 |
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; } |
|
July 29, 2019, 03:57 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you've defined T, but later use temp
choose one of them best regards |
|
August 31, 2020, 22:23 |
how to remove undeclared variable error for P_POS
|
#5 |
New Member
Join Date: Aug 2020
Posts: 2
Rep Power: 0 |
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); |
|
September 1, 2020, 03:21 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
September 1, 2020, 09:55 |
|
#7 |
New Member
Join Date: Aug 2020
Posts: 2
Rep Power: 0 |
hello! Thank you for your reply, even with your edited code I get the error:
"line 18: P_POS: undeclared variable" |
|
September 1, 2020, 22:42 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
compile the code
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
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 |