CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   P_POS Undeclared Variable Error (https://www.cfd-online.com/Forums/fluent-udf/125398-p_pos-undeclared-variable-error.html)

osuguy October 24, 2013 15:51

P_POS Undeclared Variable Error
 
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

SSOHEIL March 8, 2014 05:38

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.

Azim07 July 29, 2019 02:44

How to remove "Undeclared Variable" Error in Ansys Fluent UDF for Density?
 
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;
}

AlexanderZ July 29, 2019 02:57

you've defined T, but later use temp
choose one of them

best regards

mmr1995 August 31, 2020 21:23

how to remove undeclared variable error for P_POS
 
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);

AlexanderZ September 1, 2020 02:21

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);
}


mmr1995 September 1, 2020 08:55

hello! Thank you for your reply, even with your edited code I get the error:
"line 18: P_POS: undeclared variable"

AlexanderZ September 1, 2020 21:42

compile the code


All times are GMT -4. The time now is 18:32.