CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Define source on boundary cells in UDF (http://www.cfd-online.com/Forums/fluent-udf/91363-define-source-boundary-cells-udf.html)

mingersai August 8, 2011 17:26

Define source on boundary cells in UDF
 
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!

mingersai August 9, 2011 09:33

need help.......

Amir August 9, 2011 14:47

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 August 10, 2011 10:04

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 (Post 319515)
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 ...


Amir August 10, 2011 10:35

Quote:

Originally Posted by mingersai (Post 319627)
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.

mingersai August 10, 2011 15:17

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

https://lh4.googleusercontent.com/-1...yU/Capture.PNG

Amir August 11, 2011 03:21

Quote:

Originally Posted by mingersai (Post 319645)
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 August 11, 2011 17:43

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 (Post 319689)
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,


Amir August 12, 2011 03:12

Quote:

Originally Posted by mingersai (Post 319800)
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,

mingersai August 12, 2011 05:23

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 (Post 319838)
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 August 12, 2011 05:38

Quote:

Originally Posted by mingersai (Post 319867)
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,

Praneetha October 30, 2012 23:34

surface heat flux
 
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;
}

Bharadwaj B S February 24, 2015 09:05

Source term UDF
 
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

Lokanath July 7, 2015 11:56

Fatal segmentation error
 
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;
}


All times are GMT -4. The time now is 08:40.