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/)
-   -   Udf dpm error (https://www.cfd-online.com/Forums/fluent-udf/151282-udf-dpm-error.html)

YANNAPOL April 8, 2015 04:04

Udf dpm error
 
1 Attachment(s)
Dear All,

I am new with UDF in Fluent, I have tried to understand UDF Manual from ANSYS, but I am still cannot solve this problem.

I provide part of my code which has error below.... and I attach the error shown in Fluent in the attachment

....
....
....
Thread *tcell;
*tcell=P_CELL_THREAD(p);
cell_t c=P_CELL(p);


Best Regards,
Yannapol S.

CeesH April 8, 2015 04:13

Hi,

You don't need the * in front of the second line:
Also, I would group all declarations first, and group steps where you set values later. so:


Code:

Thread *tcell;
cell_t c=P_CELL(p);
tcell=P_CELL_THREAD(p);


YANNAPOL April 8, 2015 04:19

Hi, CeesH

Thanks for your quickly reply.
Unfortunately, I did it, then the same error is still appear.

error C2275: 'Thread' : illegal use of this type as an expression
error C2065: 'tcell' : undeclared identifier
error C2275: 'cell_t' : illegal use of this type as an expression

`e` April 8, 2015 04:38

What is the rest of your UDF and are you compiling the UDF correctly? Have a read of my compiling process for Fluent UDFs with an existing library loaded.

YANNAPOL April 8, 2015 05:09

Dear 'e',

You mentioned that it should have 5 steps for compiling
Normally, for the simple code(code from UDF Manual), I think I am able to compile completely without step 1) and 2).

Anyway, I check the my UDF library Manager(Define > User-Defined > Functions > Manage...). It is blank !!!

Is it necessary to do step 1) and 2) for compiling UDF ?
if yes,
What should I do to make the existing library appear ?

Best Regards,
Yannapol S.

`e` April 8, 2015 05:17

The first two steps are there if you already have a compiled UDF which I assume is the case if you're modifying an existing UDF. What is your UDF?

YANNAPOL April 8, 2015 05:27

Code (only Error part)
 
1 Attachment(s)
Dear All,

i provide code in this Reply

YANNAPOL April 8, 2015 05:28

Dear 'e',

I provide part of my code in new reply, please help

Best Regards,
YannapoL S.

CeesH April 8, 2015 06:03

I see a few questionable things;

- You make a couple of declarations outside of the function body (namely
Code:

real ParticleTotalMass;
real P_Mass[6];
real P_Impact_Mass[6];
real P_Stick_Mass[6];
Domain *domain; /*Get domain pointer and assign later to domain*/

- your loops are not properly closed, make sure every { is matched with a } at the appropriate place

- your declaration section is very messy and this can give problems. For example:
Code:

FILE *fp;*

Thread *tcell;

is not a correct statement

- if you use #if loops, make sure they are closed with #endif. If you use if loops, use if{} to mark the extent of the loop. Also use for(...){} - always use brackets to mark what is included in the loop.

-
Code:

idim = dim;
,but dim is undeclared.


Maybe there's more, but I can't check all lines for you... I'd advice you to take a good look at the script, section it to be more readable, and make sure all loops and functions are properly closed. Do not do anything outside the function body, except of course the macro definitions and include statements.


All times are GMT -4. The time now is 23:12.