# udf eror + Define property + density

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 29, 2011, 08:54 udf eror + Define property + density #1 New Member   rezvan Join Date: Aug 2011 Location: Mashhad,iran Posts: 10 Rep Power: 12 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" DEFINE_PROPERTY(cell_density, cell, thread) { real density; real grid_y = NODE_Y(cell, threads); real grid_x = NODE_X(cell, threads); 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?

 August 29, 2011, 09:24 #2 Member     Join Date: Apr 2009 Posts: 46 Rep Power: 15 See the definition: Code: `#define NODE_Y(v) (NODE_COORD(v)[1])`

 August 29, 2011, 09:36 #3 Senior Member     Amir Join Date: May 2009 Location: Montreal, QC Posts: 735 Blog Entries: 1 Rep Power: 21 Hi, you wouldn't need any UDF for this case; separate desired space and set different density. __________________ Amir

 August 29, 2011, 10:29 re #4 New Member   rezvan Join Date: Aug 2011 Location: Mashhad,iran Posts: 10 Rep Power: 12 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

August 29, 2011, 10:45
#5
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 21
Quote:
 Originally Posted by rezvan 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,
__________________
Amir

 August 29, 2011, 20:56 rep #6 New Member   rezvan Join Date: Aug 2011 Location: Mashhad,iran Posts: 10 Rep Power: 12 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

 August 29, 2011, 20:58 #7 New Member   rezvan Join Date: Aug 2011 Location: Mashhad,iran Posts: 10 Rep Power: 12 dear fox000002 ,hi,thank u a lot,i am in the start of writting udf,plz SITUATION your sentence in my udf

August 30, 2011, 04:45
#8
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 21
Quote:
 Originally Posted by rezvan 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,
Attached Files
 density.c (232 Bytes, 143 views)
__________________
Amir

 August 30, 2011, 06:43 s #9 New Member   rezvan Join Date: Aug 2011 Location: Mashhad,iran Posts: 10 Rep Power: 12 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? Last edited by rezvan; August 30, 2011 at 07:21.

August 30, 2011, 08:12
#10
Senior Member

Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 21
Quote:
 Originally Posted by rezvan 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 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 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.

Bests,
__________________
Amir

 July 10, 2015, 04:30 property define #11 New Member   hassan Join Date: Jul 2015 Posts: 3 Rep Power: 8 hi my friends i want define kinetic viscosity for fluent by UDFs. but i am very weak in c programming. this is my equation: please help me/ thank you

 Tags define property, density, udf eror