CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

Define source on boundary cells in UDF

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

Like Tree6Likes
  • 2 Post By Amir
  • 1 Post By Amir
  • 3 Post By Amir

Reply
 
LinkBack Thread Tools Display Modes
Old   August 8, 2011, 17:26
Smile Define source on boundary cells in UDF
  #1
Member
 
Ming Cai
Join Date: Mar 2011
Posts: 50
Rep Power: 6
mingersai is on a distinguished road
Hi, friends

I want to define a mass source on the boundary cells with udf, here's my code,
I don't know why it doesn't work, can any of you guys kindly give me some suggestions?
I'm new to udf...

Thanks in advance!

# include "udf.h"

DEFINE_SOURCE(mass_source,c,t,dS,eqn)
{
real x[ND_ND];
real source;
Domain *domain = Get_Domain(1);
face_t f;
Thread *tb = Lookup_Thread(domain,2); /* Get boundary thread, wall zone id is 2 */
if(c = F_C0(f,tb)) /* if cell is wall boundary cell */
{
source = 10000;
dS[eqn]=0;
}
else
{
source = 0;
dS[eqn]=0;
}
return source;
}

Thank you very much!

Last edited by mingersai; August 9, 2011 at 09:32.
mingersai is offline   Reply With Quote

Old   August 9, 2011, 09:33
Default
  #2
Member
 
Ming Cai
Join Date: Mar 2011
Posts: 50
Rep Power: 6
mingersai is on a distinguished road
need help.......
mingersai is offline   Reply With Quote

Old   August 9, 2011, 14:47
Default
  #3
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
your if-clause is not right ...
one easy way is to store source values in temporary memory (UDM) and then use it in this macro; another way is to separate adjacent boundary cells to get new thread ID and then use that ...
mingersai and sso like this.
__________________
Amir
Amir is offline   Reply With Quote

Old   August 10, 2011, 10:04
Default
  #4
Member
 
Ming Cai
Join Date: Mar 2011
Posts: 50
Rep Power: 6
mingersai is on a distinguished road
Hi, Amir

Thanks for your help. Would you please tell me why the if statement is not correct?
How to implement this with UDM?
Because my problem is not suitable to go with separate zone method, I'll have to stick with the first way....

Thank you very much!



Quote:
Originally Posted by Amir View Post
your if-clause is not right ...
one easy way is to store source values in temporary memory (UDM) and then use it in this macro; another way is to separate adjacent boundary cells to get new thread ID and then use that ...
mingersai is offline   Reply With Quote

Old   August 10, 2011, 10:35
Default
  #5
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Quote:
Originally Posted by mingersai View Post
Hi, Amir

Thanks for your help. Would you please tell me why the if statement is not correct?
How to implement this with UDM?
Because my problem is not suitable to go with separate zone method, I'll have to stick with the first way....

Thank you very much!
Hi,

first, your idea about this case is not right; your macro retrieves cell ID and doesn't recognize f; i.e. you just define unreferenced face index (f)!
indeed, you need logical statement in if-clause; if(c == F_C0(f,tb)) ...
Easier way is to use another macro like on demand forms then, loop over your desired thread and store your source value to temporary volume scalar field (UDM) then use this UDM in above UDF.
sso likes this.
__________________
Amir
Amir is offline   Reply With Quote

Old   August 10, 2011, 15:17
Default
  #6
Member
 
Ming Cai
Join Date: Mar 2011
Posts: 50
Rep Power: 6
mingersai is on a distinguished road
Thanks a lot! I learnt a lot from this!

Would you please tell me the difference between different IDs showed in the pic? Why there's two different IDs for wall? what is each ID?

Thanks


Last edited by mingersai; August 10, 2011 at 22:45.
mingersai is offline   Reply With Quote

Old   August 11, 2011, 03:21
Default
  #7
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Quote:
Originally Posted by mingersai View Post
Thanks a lot! I learnt a lot from this!

Would you please tell me the difference between different IDs showed in the pic? Why there's two different IDs for wall? what is each ID?

Thanks
As I know, we may find 2 IDs for some threads, one of them in boundary condition panel and another in (surface->manage) which have different applications.
ID which is in BC panel refer to realistic threads of your grid (consist of nodes, faces,...) and has to be used in, for example, loops over desired thread and so on; on the other hand, the IDs in surface panel have to be used in some calculations such as property integrations over that; note that these surfaces or volumes which are visible in this panel are not necessarily part of your numerical grid, they may be created as virtual surfaces or volumes for post-processing and I usually use then in TUI as a part of journal files. In your case, thread ID=12 refers to realistic part of your grid and ID=2 refers to virtual surface coincides with your realistic one.
these are 2 types of IDs which I find in FLUENT 6.3, maybe there would be created other types in later versions.


Bests,
mingersai, sso and yashganatra like this.
__________________
Amir
Amir is offline   Reply With Quote

Old   August 11, 2011, 17:43
Default
  #8
Member
 
Ming Cai
Join Date: Mar 2011
Posts: 50
Rep Power: 6
mingersai is on a distinguished road
Thanks, Amir
I got it work now!
I'm using both DPM and VOF model,
The source term I want to define in those cells are function of particle mass.
Do you have any idea about how to access DPM particle data in those cells?

Thanks~

Quote:
Originally Posted by Amir View Post
As I know, we may find 2 IDs for some threads, one of them in boundary condition panel and another in (surface->manage) which have different applications.
ID which is in BC panel refer to realistic threads of your grid (consist of nodes, faces,...) and has to be used in, for example, loops over desired thread and so on; on the other hand, the IDs in surface panel have to be used in some calculations such as property integrations over that; note that these surfaces or volumes which are visible in this panel are not necessarily part of your numerical grid, they may be created as virtual surfaces or volumes for post-processing and I usually use then in TUI as a part of journal files. In your case, thread ID=12 refers to realistic part of your grid and ID=2 refers to virtual surface coincides with your realistic one.
these are 2 types of IDs which I find in FLUENT 6.3, maybe there would be created other types in later versions.


Bests,
mingersai is offline   Reply With Quote

Old   August 12, 2011, 03:12
Default
  #9
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Quote:
Originally Posted by mingersai View Post
Thanks, Amir
I got it work now!
I'm using both DPM and VOF model,
The source term I want to define in those cells are function of particle mass.
Do you have any idea about how to access DPM particle data in those cells?

Thanks~
Yes, you can do that by implementing another UDF which converts data from lagrangian model to eulerian one, here, you should take care of mass flow rate of each stream; for more info refer to:
Experimental measurements and numerical simulations of particle transport and distribution in ventilated rooms; Z. Zhang, Q. Chen; Atmospheric Environment 40 (2006) 33963408

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   August 12, 2011, 05:23
Default
  #10
Member
 
Ming Cai
Join Date: Mar 2011
Posts: 50
Rep Power: 6
mingersai is on a distinguished road
Hi, Amir

Do you know specific UDF code we need to use in order to get the particle data in the chosen cells? I can't find it in Fluent documentation, and the paper you mentioned seems have not mentioned that.

Thanks!

Quote:
Originally Posted by Amir View Post
Yes, you can do that by implementing another UDF which converts data from lagrangian model to eulerian one, here, you should take care of mass flow rate of each stream; for more info refer to:
Experimental measurements and numerical simulations of particle transport and distribution in ventilated rooms; Z. Zhang, Q. Chen; Atmospheric Environment 40 (2006) 33963408

Bests,
mingersai is offline   Reply With Quote

Old   August 12, 2011, 05:38
Default
  #11
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Shiraz, Iran
Posts: 739
Blog Entries: 1
Rep Power: 14
Amir is on a distinguished road
Quote:
Originally Posted by mingersai View Post
Hi, Amir

Do you know specific UDF code we need to use in order to get the particle data in the chosen cells? I can't find it in Fluent documentation, and the paper you mentioned seems have not mentioned that.

Thanks!
Hi,
The information in mentioned paper is enough! you need a relation to compute particle concentration in your domain i.e. equation (7); there is not your desired UDF in documantation, but you can use them in your algorithm.

Bests,
__________________
Amir
Amir is offline   Reply With Quote

Old   October 30, 2012, 23:34
Default surface heat flux
  #12
New Member
 
Praneetha
Join Date: Dec 2009
Posts: 7
Rep Power: 7
Praneetha is on a distinguished road
I am trying to do something similar, I am calculating surface integral over boundary which has zone id 15 and trying to use tohis as source for domain (cell zone). the code compiles and loads without any errors. But after 1st iteration nothing happens. It just hovers over 1st iteration. looks like it is going into infinite loop. But cannot figure out how?

#include "udf.h"
#define C 1.7e-8
#define V 5.7e-4
DEFINE_SOURCE(source3, c, t, dS, i)
{
real flux=0;
real ID=15;
face_t f;
Domain *d;
d=Get_Domain(1);
t=Lookup_Thread(d, ID);
begin_f_loop(f,t)
{
flux += ((pow(F_T(f,t),4))-(pow(297,4)))*(-C)/V;
}
end_f_loop(f,t)
dS[i]=0;
return flux;
}
Praneetha is offline   Reply With Quote

Old   February 24, 2015, 09:05
Default Source term UDF
  #13
Member
 
Baradwaj B S
Join Date: Jan 2015
Posts: 70
Rep Power: 2
Bharadwaj B S is on a distinguished road
Hi all,

Bharadwaj here, My case has also very similar requirement. I have to assign about 1kg of mass to a sphere surface. which is present in a fluid flow domain (cylindrical).

QUESTION:

If I use DEFINE_SOURCE UDF, will that be specifying mass directly to a domain or will the UDF just adds a source term to the governing equation. And if it adds the value as mass, how to verify that in FLUENT?

Any help by Amir and others are of great use for me. Thanks in advance.

Regards,
Bharadwaj
Bharadwaj B S is offline   Reply With Quote

Old   July 7, 2015, 11:56
Default Fatal segmentation error
  #14
New Member
 
Lokanath Mohanta
Join Date: Jun 2015
Posts: 1
Rep Power: 0
Lokanath is on a distinguished road
I have a similar problem in which I would like to define mass and momentum source in the cells close to one surface. UDF gets compiled and I can hook the sources with the volumes. But whenever I start running the fluent, it says Fatal segementation error. Any suggestions ?



Here is my UDF
--------------------------
# include "udf.h"
DEFINE_SOURCE(mass_source, c,t, dS, eqn)
{
real source;
Domain *domain = Get_Domain(17);
face_t f;
Thread *tb = Lookup_Thread(domain,24); /* Get boundary thread, wall zone id is 30 */
if(c == F_C0(f,tb)) /* if cell is wall boundary cell */
{
source = 10;
dS[eqn]=0.0;
}
else
{
source = 0;
dS[eqn]=0.0;
}
return source;
}
DEFINE_SOURCE(momentum_source, c,t, dS, eqn)
{
real momnt_source;
Domain *domain = Get_Domain(17);
face_t f;
Thread *tb = Lookup_Thread(domain,24); /* Get boundary thread, wall zone id is 30 */
if(c == F_C0(f,tb)) /* if cell is wall boundary cell */
{
momnt_source = 0.002;
dS[eqn]=0.0;
}
else
{
momnt_source = 0;
dS[eqn]=0.0;
}
return momnt_source;
}
Lokanath is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Robin B.C. Yu FLUENT 3 May 27, 2012 04:19
help:uds source added to boundary cells FredPacheo FLUENT 5 September 5, 2008 05:45
UDF to define source term at every grid point Ralf Schmidt FLUENT 0 September 21, 2006 11:32
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 12:24
Ignore cells on partition boundary Karl FLUENT 7 May 11, 2002 22:12


All times are GMT -4. The time now is 21:09.