
[Sponsors] 
March 20, 2021, 17:30 
InterFoam letting one phase leave the domain

#1 
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Hello to all,
I would like to simulate the flow of a liquid and gas with InterFoam. I would like to have one of the phases (the gas) to leave the domain while the other (the liquid) fills the domain. Does OpenFOAM have any boundaries for this? What do you recommend to achieve this? Would it be achievable with a custom boundary condition that dynamically changes from outlet to wall based on the value of alpha? Best regards 

March 28, 2021, 12:12 

#2 
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
So, apparently this question has been going around in the forum for several years without a proper answer.
Some questions I still have:
Code:
myOutlet { type codedMixed; refValue uniform (0 0 0); refGradient uniform (0 0 0); valueFraction uniform 0; name dynamicOutlet; code #{ // Code goes here // Gets the alpha field scalarField alphap = patch().lookupPatchField<volScalarField, scalar>("alpha.liquid"); alphap = max(alphap, scalar(0)); alphap = min(alphap, scalar(1)); // write value as a function of alpha this>valueFraction() = alphap; #}; } if alpha = 1, we get a pure fixedValue if alpha =0 , we get a pure zeroGradient Any contribution would be very welcome! 

March 28, 2021, 12:35 

#3 
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 603
Rep Power: 14 
For a rising air bubble in water I applied zeruGradient for alpha and this https://www.openfoam.com/documentati...alarField.html
For prgh at the upper boundary. In this way the air bubble left the upper boundary 

March 29, 2021, 08:05 

#4 
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Hi,
After some reading, I need to implement something like this: with: So, the first one is a noslip boundary which is straightforward to implement. Just need to loop over the patch faces and check the value of alpha is higher than 0.5 (or any specified value for alpha). If so, I set Code:
this>refValue()[faceI] = vector::zero; this>valueFraction()[faceI] = 1.0; Any help be appreciated! 

March 29, 2021, 09:09 

#5 
Member
Join Date: Mar 2021
Posts: 38
Rep Power: 3 
Hello,
Although I do not have any input to give you, I am also interested in this matter! Best of luck! 

March 29, 2021, 11:04 

#6 
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 603
Rep Power: 14 
Quote:


March 30, 2021, 13:12 

#7  
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Quote:
Wouldn't it be better to create two boundaries. One that switches from zero velocity gradient to zero FixedValue and another for pressure that switches from fixedValue to zeroGradient? 

April 1, 2021, 08:58 

#8 
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Can anyone confirm this approach?
I have implemented this dynamic boundary, but now I am facing several convergence issues because the initial state of the problem has imposed value of pressure everywhere expect at the inlet ... 

April 5, 2021, 12:51 

#9 
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 603
Rep Power: 14 
Can you sketch your case? From the description above it's hard to guess what the exact problem is


April 6, 2021, 06:17 

#10  
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Quote:
Sure, Filling of a plate with water (other kind of fluid) with air inside the cavity. The water enters through an inlet and all other patches in the geometry should behave like a dynamic wall, letting the air out and keeping the water in. 

April 6, 2021, 06:48 

#11 
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 603
Rep Power: 14 
Where is the outlet and where the walls. The direction of g is missing


April 6, 2021, 07:12 

#12  
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Quote:
There is no outlet (at least explicitly specified). The walls should behave like an outlet up to and alpha of 0.5 and as a wall for values higher than 0.5 . Gravity is not being considered in this problem. 

April 6, 2021, 08:57 

#13 
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 603
Rep Power: 14 
This seem a good solution. How did you implement this. Seem you wrote a new boundary conditions


April 6, 2021, 13:10 

#14 
New Member
Bruno Ramoa
Join Date: Jul 2019
Posts: 18
Rep Power: 5 
Hi,
I would also be very interested in this kind of boundary! Based on your previous input, I wrote for U: Code:
wall { type codedMixed; refValue uniform (0 0 0); refGradient uniform (0 0 0); valueFraction uniform 0; name dynamicOutlet; code #{ scalarField alphap = patch().lookupPatchField<volScalarField, scalar>("alpha.liquid"); alphap = max(alphap, scalar(0)); alphap = min(alphap, scalar(1)); const scalar alphaValue = 0.5; // Loops over the patch forAll(patch(), faceI) { if(alphap[faceI] > alphaValue) { // Imposes fixedValue this>refValue()[faceI] = vector::zero; this>valueFraction()[faceI] = scalar(1); } else { // Imposes zeroGradient this>refGrad()[faceI] = vector::zero; this>valueFraction()[faceI] = scalar(0); } } #}; } and for P Code:
wall { type codedMixed; refValue uniform 0; refGradient uniform 0; valueFraction uniform 1; name dynamicOutlet; code #{ scalarField alphap = patch().lookupPatchField<volScalarField, scalar>("alpha.liquid"); alphap = max(alphap, scalar(0)); alphap = min(alphap, scalar(1)); const scalar alphaValue = 0.5; // Loops over the patch forAll(this>patch(), faceI) { if (alphap[faceI] > alphaValue) { // Imposes zeroGradient this>refGrad()[faceI] = scalar(0); this>valueFraction()[faceI] = scalar(0); } else { // Imposes fixedValue this>refValue()[faceI] = scalar(0); this>valueFraction()[faceI] = scalar(1); } } #}; } For: U: Fixed velocity on the inlet, noslip for the walls and zeroGradient for the outlet. P: ZeroGradient for the inlet and the walls and fixedValue for the outlet The simulation worked fine. However, with the codedMixed boundary the convergence is not good... Hopefully the code will get you started and someone else can fill in with a little CFD magic to make the boundary more well behaved 

April 21, 2021, 05:34 

#15 
Member
Zé
Join Date: Feb 2020
Posts: 90
Rep Power: 4 
Any suggestions on a possible strategy to improve the convergence of this boundary condition?
Best Regards! 

August 17, 2022, 09:05 

#16  
New Member
Julian Re
Join Date: Jan 2022
Location: Germany
Posts: 11
Rep Power: 2 
Quote:
Hey Shibi, you made any progress imroving convergence for the coded BC? I found this custom BC in the web; within the paper the code of the BC is also linked!: https://www.emerald.com/insight/cont...0190/full/html However, in my case this BC blows up my simulation within the first iterations... 

Tags 
boundary conditions, interfoam 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
[ICEM] How to generate an unstructured mesh for a 2 fluid domain rotor in ICEM CFD  Hazem24  ANSYS Meshing & Geometry  0  December 21, 2020 07:52 
UDF to constrain one of the phase to stay in the domain  Koromajor  Fluent UDF and Scheme Programming  23  April 15, 2020 20:21 
interFoam high air phase velocities  indy07cz  OpenFOAM Running, Solving & CFD  1  November 8, 2017 06:00 
Sudden increase the residual of Maxwell's equations  hsezsz  CFX  2  October 13, 2016 07:58 
phase fraction part of domain  RBJ  OpenFOAM PostProcessing  0  July 6, 2010 10:33 