CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   P_POS(p) undeclared variable (http://www.cfd-online.com/Forums/fluent/78470-p_pos-p-undeclared-variable.html)

spring July 22, 2010 09:58

P_POS(p) undeclared variable
 
Hi,

I have a problem with the variable P_POS(p). When interpreting my UDF (I don't understnad any of the errors when compiling my UDF) I always get this error:
P_POS: undeclared variable.

I don't have this problem with P_VEL(p), and there are no problems when I remove the line with P_POS. I have an ansys fluent version 12.1 running under linux and windows and I get the same error when interpreting my UDF in both operating systems. I looked into the dpm.h (windows) file and there P_POS was defined like this : #define P_POS(p)((p)->state.pos) but as I said, it still shows me an error. I don't know what else to do and I really hope that someone can help me.
Here is my code:
Thanks,
spring

Chris D July 22, 2010 15:51

What errors do you get when you try to compile it?

Allan Walsh July 22, 2010 17:04

I have used P_POS(p) without any problems in V12.1 of Windows Fluent.
As per one of the examples in the UDF tutorial, I have included the following in the variable declaration part of the code when interfacing particle and cell data:

cell_t c = RP_CELL(&p->cCell); /* Get Cell and Thread from */
Thread *t_cl = RP_THREAD(&p->cCell); /* Particle Structure */

Perhaps this might be needed in your implementation?

spring July 23, 2010 05:07

First of all thank you very much for trying to help me, I really appreciate that!
To be honest I only tryed to compile my UDF in linux, because I am working all the time in linux and I have 8 times more GB of RAM in linux than in windows. The compiler in linux is the standard GNU C/C++ compiler.


@ Allen
Ok I will try it your way.

best regards,
spring

spring July 23, 2010 13:40

Hey,

after I copied udf.h into my working folder and compiled my UDF (only in linux) and there weren't any error messages .


And I also was able to hook my UDF in the right place. Does this mean that the compilation was succesful? I ask, because I get a FATAL ERROR :

Error: fluent.12.1.2 received a fatal signal (SEGMENTATION VIOLATION).
Error Object: #f

when I want to start the discrete particle model simulation. In the (long, that's why I wont post it) message it's said that the error is due to my UDF. Any ideas.

regards,
spring

mohammad1008 March 11, 2012 01:01

P_POS(p) undeclared variable
 
Hi
I have the same problem. Did you find the solution?
I want to add a body forces fx=ax and fy=by to DPM model. The code I have written is:

/* UDF for computing the magnetic force on a charged particle */

# include "udf.h"


DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{

double a=0.01;
double b=-0.001;

double x;
double y;

real source;
x=P_POS(p)[0];
y=P_POS(p)[1];


if(i==0) source =a*x;
else if(i==1) source =b*y;

/* an acceleration should be returned */
return (source/P_MASS(p));

}
and the error is:P_POS: undeclared variable


I would be grateful if you help me.

Quote:

Originally Posted by spring (Post 268524)
Hi,

I have a problem with the variable P_POS(p). When interpreting my UDF (I don't understnad any of the errors when compiling my UDF) I always get this error:
P_POS: undeclared variable.

I don't have this problem with P_VEL(p), and there are no problems when I remove the line with P_POS. I have an ansys fluent version 12.1 running under linux and windows and I get the same error when interpreting my UDF in both operating systems. I looked into the dpm.h (windows) file and there P_POS was defined like this : #define P_POS(p)((p)->state.pos) but as I said, it still shows me an error. I don't know what else to do and I really hope that someone can help me.
Here is my code:
Thanks,
spring


SSOHEIL March 8, 2014 05:47

It may help if you declare P_POS as:

double P_POS[3];

3 for a 3D or 2 for a 2D case.

Regards


All times are GMT -4. The time now is 14:04.