CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Adding Source Terms in Specific Cells (https://www.cfd-online.com/Forums/fluent-udf/239174-adding-source-terms-specific-cells.html)

Cooper24 October 24, 2021 09:26

Adding Source Terms in Specific Cells
 
I am modelling a 2 phase flow using VOF in FLUENT. I want to add some source terms in the N-S equations and energy equations. I need to add this source terms in the cells at the interface of 2 phases. I have written a UDF to identify these cells at every iteration.
I am using F_C0 and F_C1 to get the index of cells at the interface. For example, real cell_t c1 = F_C0(c,t). Then I storing this c1 in a user define memory location(C_UDMI).
Now, I want to apply source in these cells with the index c1. So my question is can I use a if condition in DEFINE_SOURCE like:

if(c == C_UDMI(c,t,i))
{
source = .................
}
else
{
source = 0;
}

Is it the correct way or am I doing it wrong? Any help is much appreciated.
Thanks in advance.

AlexanderZ October 25, 2021 00:33

I suggest you to use other approach
once you've found c0,t0,c1,t1
use
Code:

C_UDMI(c0,t0,0)= 1, C_UDMI(c1,t1,0)= 1
so you will get a flag to check if cell is adjusted to interface

in define_source you'll need to check that flag
Code:

if(C_UDMI(c,t,i) == 1)
{}


Cooper24 October 25, 2021 03:06

Thanks a lot for your suggestion. I will try that. Till now I was going with
if(c == C_UDMI(c,t,i))
{
source = ...............
}

Also can you suggest if I am doing it right by using F_C0 and F_C1 to get the interfacial cells? I have been stuck with this for a long time now without any help. I am new to UDF writing and have written a UDF to track the interfacial cells but it is not working. I had posted this earlier in the forum also.

Thanks.

AlexanderZ October 25, 2021 04:13

from my point of view, if you need boundary between two phases while you are using VOF, then you don't need c0,c1

thre is a macro to check phase vof concentration C_VOF which will return you [0..1] depends on the phase inside the cell

so your you may check C_VOF in cell and consider it's boundary (which you called interface) in case C_VOF >0.5 and C_VOF <= 1
value 0.5 could be different

hope you get the idea

Cooper24 October 25, 2021 09:22

Actually earlier I was using this criteria only(0.01<C_VOF<1). Then I read a few papers and in those, authors had continuously tracked the interface using UDF. This is because, I am melting solid so when solid melts, iso surface for volume frction will change and I need to track the interface. So, I started writing a UDF for this taking help from the forum.

Thanks


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