|
[Sponsors] |
June 8, 2015, 16:00 |
Volume of Fluid UDF for coordinates
|
#1 | |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
Hello guys!
I need to write UDF that will return x and y (and z for 3D) coordinates of place where there is fractional quantity of phase (black box region at the picture). As I'm quite new to the all multiphase things I've used code from this forum. After few changes it's look like: Code:
#include "udf.h" DEFINE_SOURCE(source,c,t,dS,eqn) { real source, alpha, xc[ND_ND]; Thread *mixture_thread; Thread **pt; Domain *domain; int zoneid = 2; domain = Get_Domain(1); mixture_thread = Lookup_Thread(domain,zoneid); pt = THREAD_SUB_THREADS(mixture_thread); alpha = C_VOF(c,pt[1]); Message("cell volume fraction = %f \n xc = %f \n yc = %f \n",alpha, xc[0], xc[1]); source =2; dS[eqn] = 0; return source; } Quote:
My fluid zone ID taken from GUI is 2. I have two phases:
|
||
June 9, 2015, 05:56 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Congratulations on your UDF, it is a good start.
What you missed: you never assigned xc. Before you print xc[0] and xc[1], you should make them have the position of the cell: Code:
C_CENTROID(xc,c,t); |
|
June 9, 2015, 06:34 |
|
#3 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
Thank You for comment. I've noticed that mistake today. I've reworked my code:
Code:
#include "udf.h" #include "sg_mphase.h" DEFINE_SOURCE(src, cell, mix_th, dS, eqn) { Thread *pri_th, *sec_th; real m_dot; real xc[ND_ND],xx,yy; pri_th = THREAD_SUB_THREAD(mix_th, 0); sec_th = THREAD_SUB_THREAD(mix_th, 1); C_CENTROID(xc,cell, pri_th); xx=xc[0]; yy=xc[1]; Message("cell volume fraction = %f \n %f \n %f \n",C_VOF(cell,pri_th), xx, yy); return 1; } |
|
June 9, 2015, 06:39 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
But the fractions in your solution really are 0 and 1...
You ask fluent for the values in the cell centers. Notice how there are now cell centers in your "interface area". Fluent draws a green line, because it calculates the face values as the average of the bordering cells, but your solution only has values 0 and 1, just as your udf shows. Argon and air did not mix. |
|
June 9, 2015, 10:04 |
|
#5 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
This is somewhat confusing because fluent plot shows that there is fractional phase quantity in the region between phases. Thank You for answer
|
|
June 23, 2015, 01:39 |
|
#6 |
Senior Member
Vaze
Join Date: Jun 2009
Posts: 172
Rep Power: 17 |
Hi Rafal
You have defined in your code pri_th and sec_th which points out to primary fluid or secondary fluid, correct? Your code does not understand how to treat interface? Which pointer to consider? Hence I believe that it is only dividing into 1 and 0, no fraction. I donot know wheter I am correct or not but you may get direction from this. Best wishes Vaze |
|
June 23, 2015, 06:33 |
|
#7 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
In fact 0-1 thing happtens only at first step. In dam break case at later time steps there are also fractional quantities.
|
|
June 24, 2015, 01:28 |
|
#8 |
Senior Member
Vaze
Join Date: Jun 2009
Posts: 172
Rep Power: 17 |
what volume fraction value does message shows at t=0 at interface?
|
|
June 24, 2015, 11:40 |
|
#9 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
Only 0 or 1
|
|
June 26, 2015, 07:19 |
|
#10 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
Maybe outcome from:
Code:
fprintf(fout,"%f %f %f\n", xx, yy, C_VOF(cell,pri_th)); Code:
x y C_VOF 0.000050 0.003950 1.000000 0.000050 0.003850 1.000000 0.000050 0.003750 1.000000 0.000050 0.003650 1.000000 0.000050 0.003550 1.000000 0.000050 0.003450 1.000000 0.000050 0.003350 1.000000 0.000050 0.003250 1.000000 0.000050 0.003150 1.000000 0.000050 0.003050 1.000000 0.000050 0.002950 1.000000 0.000050 0.002850 1.000000 0.000050 0.002750 1.000000 0.000050 0.002650 1.000000 0.000050 0.002550 1.000000 0.000050 0.002450 1.000000 0.000050 0.002350 1.000000 0.000050 0.002250 1.000000 0.000050 0.002150 1.000000 0.000050 0.002050 1.000000 0.000050 0.001950 0.000000 0.000050 0.001850 0.000000 0.000050 0.001750 0.000000 0.000050 0.001650 0.000000 0.000050 0.001550 0.000000 0.000050 0.001450 0.000000 0.000050 0.001350 0.000000 0.000050 0.001250 0.000000 0.000050 0.001150 0.000000 0.000050 0.001050 0.000000 0.000050 0.000950 0.000000 0.000050 0.000850 0.000000 0.000050 0.000750 0.000000 0.000050 0.000650 0.000000 0.000050 0.000550 0.000000 0.000050 0.000450 0.000000 0.000050 0.000350 0.000000 0.000050 0.000250 0.000000 0.000050 0.000150 0.000000 0.000050 0.000050 0.000000 I am still dissatisfied due to to the fact that only after some changes in phase interface (e.g. after one time step in dam break case) there are fractional values that could allow to designate actual phase interface coordinates. |
|
June 26, 2015, 08:02 |
|
#11 |
Senior Member
Vaze
Join Date: Jun 2009
Posts: 172
Rep Power: 17 |
Can you patch three zones with volume fraction of 0, 0.5 and 1?
and check printf during first iteration? Is it show value of 0.5? |
|
June 26, 2015, 11:41 |
|
#12 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
For better insight. I have two phases: first is air and second one is water (ice). During initialization water volume fraction is set to zero. Then I'm patching certain area with water.
Now for Your request. For patching one area with fraction = 0.5 Code:
x y VOF 0.000050 0.003950 1.000000 0.000050 0.003850 1.000000 0.000050 0.003750 1.000000 0.000050 0.003650 1.000000 0.000050 0.003550 1.000000 0.000050 0.003450 1.000000 0.000050 0.003350 1.000000 0.000050 0.003250 1.000000 0.000050 0.003150 1.000000 0.000050 0.003050 1.000000 0.000050 0.002950 1.000000 0.000050 0.002850 1.000000 0.000050 0.002750 1.000000 0.000050 0.002650 1.000000 0.000050 0.002550 1.000000 0.000050 0.002450 1.000000 0.000050 0.002350 1.000000 0.000050 0.002250 1.000000 0.000050 0.002150 1.000000 0.000050 0.002050 1.000000 0.000050 0.001950 0.500000 0.000050 0.001850 0.500000 0.000050 0.001750 0.500000 0.000050 0.001650 0.500000 0.000050 0.001550 0.500000 0.000050 0.001450 0.500000 0.000050 0.001350 0.500000 0.000050 0.001250 0.500000 0.000050 0.001150 0.500000 0.000050 0.001050 0.500000 0.000050 0.000950 0.500000 0.000050 0.000850 0.500000 0.000050 0.000750 0.500000 0.000050 0.000650 0.500000 0.000050 0.000550 0.500000 0.000050 0.000450 0.500000 0.000050 0.000350 0.500000 0.000050 0.000250 0.500000 0.000050 0.000150 0.500000 0.000050 0.000050 0.500000 Code:
x y VOF 0.000050 0.003950 1.000000 0.000050 0.003850 1.000000 0.000050 0.003750 1.000000 0.000050 0.003650 1.000000 0.000050 0.003550 1.000000 0.000050 0.003450 1.000000 0.000050 0.003350 1.000000 0.000050 0.003250 1.000000 0.000050 0.003150 1.000000 0.000050 0.003050 1.000000 0.000050 0.002950 1.000000 0.000050 0.002850 1.000000 0.000050 0.002750 1.000000 0.000050 0.002650 1.000000 0.000050 0.002550 1.000000 0.000050 0.002450 1.000000 0.000050 0.002350 1.000000 0.000050 0.002250 1.000000 0.000050 0.002150 1.000000 0.000050 0.002050 1.000000 0.000050 0.001950 0.500000 0.000050 0.001850 0.500000 0.000050 0.001750 0.500000 0.000050 0.001650 0.500000 0.000050 0.001550 0.500000 0.000050 0.001450 0.500000 0.000050 0.001350 0.500000 0.000050 0.001250 0.500000 0.000050 0.001150 0.500000 0.000050 0.001050 0.500000 0.000050 0.000950 0.000000 0.000050 0.000850 0.000000 0.000050 0.000750 0.000000 0.000050 0.000650 0.000000 0.000050 0.000550 0.000000 0.000050 0.000450 0.000000 0.000050 0.000350 0.000000 0.000050 0.000250 0.000000 0.000050 0.000150 0.000000 0.000050 0.000050 0.000000 |
|
June 26, 2015, 11:43 |
|
#13 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
So it does what would be expected. Mvee, why did you give Vekh this task?
|
|
June 29, 2015, 00:55 |
|
#14 |
Senior Member
Vaze
Join Date: Jun 2009
Posts: 172
Rep Power: 17 |
I supect thread pointer. It was only showing 0 and 1 due to its defination in THREAD_SUB_THREAD(mix_th, 0) becasue phase index does not understand the presence of interface and hence it only displays primary phase or secondary phase.
|
|
June 29, 2015, 06:25 |
|
#15 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
Hmmm... OK. So is there any other method to get what i want?
|
|
June 29, 2015, 07:18 |
|
#16 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
All signs indicate that the UDF is doing exactly what vekh wants, so don't make it more complicated than it is. |
||
June 29, 2015, 12:25 |
|
#17 |
Member
Rafal
Join Date: Aug 2013
Location: CK
Posts: 36
Rep Power: 13 |
So it seems that I should activate if C_VOF<1 statement after few timesteps.
|
|
June 29, 2015, 12:42 |
|
#18 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
||
June 29, 2015, 12:51 |
|
#19 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
If you want to show/print the position of the interface, you should first define what you mean with "interface".
Some choices that make at least some sense:
The drawbacks of each choice are:
Option 1 is easiest to program: Code:
if ((0.4<C_VOF(cell,pri_th))&&(C_VOF(cell,pri_th)<0.6)) {...} Code:
if (C_VOF(cell,pri_th)>1000) {...} |
|
October 7, 2015, 07:12 |
did you figure out the interface tracking ?
|
#20 |
New Member
logan
Join Date: Feb 2012
Posts: 10
Rep Power: 14 |
i have a similar pbm
__________________
I am a lost sheep... but survival is a necessity |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to set periodic boundary conditions | Ganesh | FLUENT | 15 | November 18, 2020 07:09 |
multiphase turbulance case floating error | harsha_kulkarni | OpenFOAM Running, Solving & CFD | 3 | February 18, 2016 06:06 |
Multiphase simulation of bubble rising | Niru | CFX | 5 | November 25, 2014 14:57 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
fluid hot volume in fluid cold volume | zahid | FLUENT | 4 | June 1, 2002 10:11 |