InterFoam letting one phase leave the domain

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

 March 20, 2021, 16:30 InterFoam letting one phase leave the domain #1 Member   Join Date: Feb 2020 Posts: 90 Rep Power: 6 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 trailer likes this.

 March 28, 2021, 11:12 #2 Member   Join Date: Feb 2020 Posts: 90 Rep Power: 6 So, apparently this question has been going around in the forum for several years without a proper answer. Some questions I still have: how sudden should the outlet switch from a zeroGradient to a fixedValue ( 0 0 0)? Is it necessary to have a similar dynamic boundary condition for the pressure (to switch from fixedValue to a zeroGradient?) I am using the codedMixed boundary condition to write this. So far I 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("alpha.liquid"); alphap = max(alphap, scalar(0)); alphap = min(alphap, scalar(1)); // write value as a function of alpha this->valueFraction() = alphap; #}; } The code above is switching from zeroGradient to fixedValue based the value of alpha. if alpha = 1, we get a pure fixedValue if alpha =0 , we get a pure zeroGradient Any contribution would be very welcome! JuRe09 likes this.

 March 28, 2021, 11:35 #3 Senior Member   Michael Alletto Join Date: Jun 2018 Location: Bremen Posts: 615 Rep Power: 16 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, 07:05 #4 Member   Join Date: Feb 2020 Posts: 90 Rep Power: 6 Hi, After some reading, I need to implement something like this: with: So, the first one is a no-slip 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; The second one I do not know how to implement. Any help be appreciated!

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

March 29, 2021, 10:04
#6
Senior Member

Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 16
Quote:
 Originally Posted by Shibi Hi, After some reading, I need to implement something like this: with: So, the first one is a no-slip 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; The second one I do not know how to implement. Any help be appreciated!
You have three equations and four unknowns. If you fix the pressure than you have three equations and three unknowns from where you can obtain a relation for the velocity gradients

March 30, 2021, 12:12
#7
Member

Join Date: Feb 2020
Posts: 90
Rep Power: 6
Quote:
 Originally Posted by mAlletto You have three equations and four unknowns. If you fix the pressure than you have three equations and three unknowns from where you can obtain a relation for the velocity gradients

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, 07:58 #8 Member   Join Date: Feb 2020 Posts: 90 Rep Power: 6 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, 11:51 #9 Senior Member   Michael Alletto Join Date: Jun 2018 Location: Bremen Posts: 615 Rep Power: 16 Can you sketch your case? From the description above it's hard to guess what the exact problem is

April 6, 2021, 05:17
#10
Member

Join Date: Feb 2020
Posts: 90
Rep Power: 6
Quote:
 Originally Posted by mAlletto Can you sketch your case? From the description above it's hard to guess what the exact problem is

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, 05:48 #11 Senior Member   Michael Alletto Join Date: Jun 2018 Location: Bremen Posts: 615 Rep Power: 16 Where is the outlet and where the walls. The direction of g is missing

April 6, 2021, 06:12
#12
Member

Join Date: Feb 2020
Posts: 90
Rep Power: 6
Quote:
 Originally Posted by mAlletto Where is the outlet and where the walls. The direction of g is missing

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, 07:57
#13
Senior Member

Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 16
Quote:
 Originally Posted by Shibi 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?
This seem a good solution. How did you implement this. Seem you wrote a new boundary conditions

 April 6, 2021, 12:10 #14 New Member   Bruno Ramoa Join Date: Jul 2019 Posts: 18 Rep Power: 7 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("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("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); } } #}; } I did some tests in a plate with 3 patches: inlet, outlet, walls with "standard boundaries ". For: U: Fixed velocity on the inlet, no-slip 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 Shibi and JuRe09 like this.

 April 21, 2021, 04:34 #15 Member   Join Date: Feb 2020 Posts: 90 Rep Power: 6 Any suggestions on a possible strategy to improve the convergence of this boundary condition? Best Regards! JuRe09 likes this.

August 17, 2022, 08:05
#16
New Member

Julian Re
Join Date: Jan 2022
Location: Germany
Posts: 11
Rep Power: 4
Quote:
 Originally Posted by Shibi Any suggestions on a possible strategy to improve the convergence of this boundary condition? Best Regards!

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