CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF-Source term (https://www.cfd-online.com/Forums/fluent/91853-udf-source-term.html)

zhhjll August 24, 2011 13:33

UDF-Source term
 
Hello everybody. I have UDF code for define face area but I don't know how can I use it in a source term which is (Ro*u*A)/L, Ro= density, u=velocity, A=area, L= length!!!
this code is for face area but I don't know how can I use it in above source term I am new in UDF!! please help me :)

DEFINE_ON_DEMAND(calculate_area) { Domain *d = Get_Domain(1); Thread *ft; face_t f; real area = 0.;

thread_loop_f(ft,d) {

begin_f_loop(f,ft)

{

real NV_VEC(farea);

F_AREA(farea,f,ft);

area = NV_MAG(farea);

}

end_f_loop(f,ft) } }

mingersai August 24, 2011 13:49

what kind of area you want to get?
Area of Single cell or all the cells?

zhhjll August 24, 2011 14:53

Quote:

Originally Posted by mingersai (Post 321438)
what kind of area you want to get?
Area of Single cell or all the cells?

Dear mingresai thank you for your reply!
I think I should get Area of each face( single face)!!!

mingersai August 24, 2011 18:46

Quote:

Originally Posted by zhhjll (Post 321442)
Dear mingresai thank you for your reply!
I think I should get Area of each face( single face)!!!

The thread pointer in the source term seems to be a phase lever thread,
the geometry data such as area is stored in mixture domain.

I my opinion, you can define a Define on demand function to access the cell face area data and stored them in a udm.

then defined a source term utilize the udm.

If anybody have better ideas, please notice me.

zhhjll August 25, 2011 07:01

Quote:

Originally Posted by mingersai (Post 321472)
The thread pointer in the source term seems to be a phase lever thread,
the geometry data such as area is stored in mixture domain.

I my opinion, you can define a Define on demand function to access the cell face area data and stored them in a udm.

then defined a source term utilize the udm.

If anybody have better ideas, please notice me.

Dear mingersai
Thanks for your suggestion. would you please help me to write a UDF as you suggest me? really how can I write a udm and then defined a source term utilize the udm.???? I am new in UDF :( but read alot! thanks
regards

mingersai August 25, 2011 09:28

Quote:

Originally Posted by zhhjll (Post 321537)
Dear mingersai
Thanks for your suggestion. would you please help me to write a UDF as you suggest me? really how can I write a udm and then defined a source term utilize the udm.???? I am new in UDF :( but read alot! thanks
regards

I'm not very familiar with face data macros, I was new to udf 2 months ago :)

I mostly deals with cell data macros.

For cell udm, you just simply need to set udm in the GUI console
Define->user defined-> user defined memory
Set the udm to be the number of udm utilized in the udf

In the case of cell udm, for example I want to store cell volume in udm
I just simply need to write:

DEFINE_ON_DEMAND(name)
{
Domain *d=Get_Domain(1);
Thread *t;
cell_t c;
thread_loop_c
{
begin_c_loop
{
C_UDMI(c,t,0)=C_VOLUME(c,t)
}
end_c_loop
}

DEFINE_SOURCE(name,c,t,dS,eqn) /* For example, source = 1/cell_volume */
{
real source;
source = 1/C_UDMI(c,t,0); /* I'm not sure if it works without Define_on _demand just use source = 1/C_VOLUME(c,t), you can have a try~ :) */
return source;
}

In the case of face area, you might just need to change cell related macros into face related ones..

Hope it helps. Good Luck

zhhjll August 26, 2011 07:41

Hi, Dear mingresal
Thanks for your help.
I appreciate for your reply to my last post:)
regards
zohreh

niravtm007 August 29, 2011 02:21

velocity inlet udf
 
hiii friends i am entirely new to using udf's in fluent. I have a cubical geometry, with two inlets on perpendicular adjacent faces. i have to implement udf to only one of the conditions.
i have two cases
1) parabolic velocity inlet ( space varient)
2) sinusodial velocity velocity inlet ( time variant)
can any one pls send me the udf ( codes) ...


All times are GMT -4. The time now is 01:34.