CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   udf eror + Define property + density (http://www.cfd-online.com/Forums/fluent-udf/91981-udf-eror-define-property-density.html)

 rezvan August 29, 2011 08:54

udf eror + Define property + density

hi,I want to assign a high density (infinity) to a region of my 2D model.
I have writen the following code;

#include "udf.h"
{
real density;
if ( grid_x >= 30. && grid_x <= 40. )
{
if ( grid_y >= 10. && grid_y <= 20. )
{
density =1000000000;
}
}
}

but I have received the following error:

line 5: macro `NODE_Y' used with too many (2) args

can anyone help me with it?

 fox000002 August 29, 2011 09:24

See the definition:

Code:

`#define NODE_Y(v) (NODE_COORD(v)[1])`

 Amir August 29, 2011 09:36

Hi,
you wouldn't need any UDF for this case; separate desired space and set different density.

 rezvan August 29, 2011 10:29

re

hi,thanks for ur replying,you say true,but my teacher tell me that i should solve this problem with udf,please say me what i should to do?please write all of the udf(i am in the start of the writing udf)thanks

 Amir August 29, 2011 10:45

Quote:
 Originally Posted by rezvan (Post 322101) hi,thanks for ur replying,you say true,but my teacher tell me that i should solve this problem with udf,please say me what i should to do?please write all of the udf(i am in the start of the writing udf)thanks
Dear Rezvan,
for such cases, we use cell values instead of node ones. I didn't check this UDF; check 2 rho vales:
Code:

```#include "udf.h" DEFINE_PROPERTY(my_density, c, t) { real rho; real cr[ND_ND]; C_CENTROID(cr,c,t); if ( cr[0] >= 30. && cr[0] <= 40. && cr[1] >= 10. && cr[1] <= 20.) { rho =1000000000; } else { rho=1.0; //check that } return rho; }```
Bests,

 rezvan August 29, 2011 20:56

rep

hi,i am really thank you,i take a lot of ur time,exuse me,when i interpreted this udf,acure this eror:
line 1: parse error.
plz help me

 rezvan August 29, 2011 20:58

dear fox000002 ,hi,thank u a lot,i am in the start of writting udf,plz SITUATION your sentence in my udf

 Amir August 30, 2011 04:45

1 Attachment(s)
Quote:
 Originally Posted by rezvan (Post 322163) hi,i am really thank you,i take a lot of ur time,exuse me,when i interpreted this udf,acure this eror: line 1: parse error. plz help me
Hi,
I checked that both as interpreted and compiled one and there is not any error!
maybe there is a problem in your text editor. use this attached file.

Bests,

 rezvan August 30, 2011 06:43

s

hi,thank u a lot...with ur help,my problem solved,bud if u have time ,i am glading that u answer to my other guestions :
1=this program must be .h or .c ?
2=in this udf whats the meaning and aplication of these words:
("real" and "rho" and "cr[ND_ND] and "C_CENTROID(cr,c,t)"
3=and my importand guestion is that :
why u answer to my guestions and other guestion of every peaple ?and spend alot of ur time for me & others?

 Amir August 30, 2011 08:12

Quote:
 Originally Posted by rezvan (Post 322242) hi,thank u a lot...with ur help,my problem solved,bud if u have time ,i am glading that u answer to my other guestions : 1=this program must be .h or .c ?
this is a main program part which includes execution macro and should be stored in .C extension; .H extension are header files which are generally consist of class definitions such as udf.h. for more info, it's better to refer to C or C++ documentations.
Quote:
 Originally Posted by rezvan (Post 322242) 2=in this udf whats the meaning and aplication of these words: ("real" and "rho" and "cr[ND_ND] and "C_CENTROID(cr,c,t)"
real-> type definition(float); it's a class
rho-> just a name; it's an object in real class
cr[ND_ND]-> self adjusting dimension array in 2D or 3D solvers; i.e., in 2D it's cr[2] and in 3D it's cr[3]
C_CENTROID(cr,c,t)-> it stores center cell coordinate of cell index c which belongs to thread t in array cr
Quote:
 Originally Posted by rezvan (Post 322242) 3=and my importand guestion is that : why u answer to my guestions and other guestion of every peaple ?and spend alot of ur time for me & others?
I'll be glad if I can help others; in this forum, you can improve your CFD knowledge regardless that you ask a question or answer that. Many questions don't take much time; like yours.:D;)

Bests,

 bazaee July 10, 2015 04:30

property define

hi my friends
i want define kinetic viscosity for fluent by UDFs.
but i am very weak in c programming.
this is my equation:
http://s3.picofile.com/file/8199013118/mio_kin.JPG