Skip to content

Commit

Permalink
Add Tutorial: Partitioned multiphase pipe flow (#418)
Browse files Browse the repository at this point in the history
Co-authored-by: Gerasimos Chourdakis <[email protected]>
  • Loading branch information
thesamriel and MakisH authored Jan 24, 2024
1 parent a1d46c4 commit d39627c
Show file tree
Hide file tree
Showing 50 changed files with 1,699 additions and 0 deletions.
73 changes: 73 additions & 0 deletions partitioned-pipe-two-phase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: Partitioned pipe two phase
permalink: tutorials-partitioned-pipe-two-phase.html
keywords: tutorial, FF, fluid-fluid coupling, OpenFOAM, interFoam, multiphase
summary: This tutorial describes how to run a partitioned two-phse fluid simulation using preCICE.
---

{% note %}
Get the [case files of this tutorial](https://github.com/precice/tutorials/tree/master/partitioned-pipe-two-phase). Read how in the [tutorials introduction](https://www.precice.org/tutorials.html).
{% endnote %}

{% note %}
This tutorial relies on yet unreleased features of the OpenFOAM adapter. You need [preCICE v2](https://github.com/precice/precice/releases)) and [the ff-develop branch of the OpenFOAM adapter](https://github.com/precice/openfoam-adapter/tree/ff-develop) to run this tutorial.
{% endnote %}

## Setup

This scenario consists of two pipes connected in series, both simulated with OpenFOAM's interFoam solver. Fluids can enter from the left (here $$ z=0 $$) boundary of the Fluid1 participant with a uniform velocity profile ($$ u_{in} = 1 m/s $$) and fixed flux pressure boundary coundition.
The simulation begins with some water being present at the bottom left of the pipe. The volume fraction variable alpha is set to be 1 (water) at the bottom half of the inlet and 0 (air) at the top half. The water stream will approach the coupling interface at around $t=5s$ in the simulation.
At the right boundary of Fluid2 there is a zero gradient boundary condition for velocity and alpha as well as a total pressure set to zero.

![two-phase-setup](images/tutorials-partitioned-pipe-two-phase-setup.png)

On the coupling interface, Fluid1 sends velocity, and alpha to Fluid2 and receives pressure, velocity gradient and alpha gradient. Fluid2 uses the [fixedFluxExtrapolatedPressure](https://www.openfoam.com/documentation/guides/v2112/api/classFoam_1_1fixedFluxExtrapolatedPressureFvPatchScalarField.html) boundary condition as shown in the [partitioned pipe tutorial](https://precice.org/tutorials-partitioned-pipe.html).

To make sure that preCICE works on the correct OpenFOAM fields, the field names are passed to the OpenFOAM adapter in `fluid*/system/preciceDict`:

```CPP
FF
{
nameP p_rgh;
nameAlpha alpha.water;
}
```

{% note %}
This is a very basic example case demonstrating the coupling of a two-phase flow. To keep it as simple as possible, gravity is set to $0$ to avoid any kind of turbulences/vortices. Read more in the accompanying conference paper [1].
{% endnote %}

## Available solvers

Both Fluid1 and Fluid2 are simulated with OpenFOAM (interFoam). An incompressible multiphase solver for two immiscible fluids using the *Volume-of-fluid* method. For more information, have a look at the [OpenFOAM adapter documentation](https://www.precice.org/adapter-openfoam-overview.html).

## Running the Simulation

Open two separate terminals and start the fluid1 and fluid2 participants by calling the respective run script. For example:

```bash
cd fluid1-openfoam
./run.sh
```

and

```bash
cd fluid2-openfoam
./run.sh
```

## Post-processing

The OpenFOAM solvers generate a `.foam` file each. You can open this file in ParaView.
You can see the water-air interface crossing the coupling interface at around $t=5.0s$.

![result](images/tutorials-partitioned-pipe-two-phase-result.png)

{% disclaimer %}
This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trade marks.
{% enddisclaimer %}

## References

[1] M. Mühlhäußer, G. Chourdakis and B. Uekermann, Partitioned Flow Simulations with preCICE and OpenFOAM, in: COUPLED 2023. DOI: [10.23967/c.coupled.2023.014](https://doi.org/10.23967/c.coupled.2023.014)
1 change: 1 addition & 0 deletions partitioned-pipe-two-phase/clean-tutorial.sh
36 changes: 36 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/0.orig/U
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}

dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 1);

boundaryField
{
inlet
{
type fixedValue;
value uniform (0 0 1);
}

outlet
{
type fixedGradient;
gradient uniform (0 0 0);
}

fixedWalls
{
type noSlip;
}

defaultFaces
{
type empty;
}
}
57 changes: 57 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/0.orig/alpha.water
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alpha.water;
}

dimensions [0 0 0 0 0 0 0];

internalField uniform 0;

boundaryField
{
inlet
{
type codedFixedValue;
value uniform 1;

// Name of generated boundary condition
name halvedFixedValue;

// Split the inlet in half water / half air across the y-axis.
code
#{
const vectorField &faceCenters = this->patch().Cf();
scalarField &alphaIn = *this;
forAll(faceCenters, faceID)
{
if (faceCenters[faceID].y() < 0.0)
{
alphaIn[faceID] = 1.0;
}
else
{
alphaIn[faceID] = 0.0;
}
}
#};
}

outlet
{
type fixedGradient;
gradient uniform 0;
}

fixedWalls
{
type zeroGradient;
}

defaultFaces
{
type empty;
}
}
37 changes: 37 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/0.orig/p_rgh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}

dimensions [1 -1 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
inlet
{
type fixedFluxPressure;
value uniform 0;
}

outlet
{
type fixedValue;
value uniform 0;
}

fixedWalls
{
type fixedFluxPressure;
value uniform 0;
}

defaultFaces
{
type empty;
}
}
7 changes: 7 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e -u

. ../../tools/cleaning-tools.sh

clean_openfoam .
rm -rf ./0/
10 changes: 10 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/constant/g
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedVectorField;
object g;
}

dimensions [0 1 -2 0 0 0 0];
value (0 0 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}

phases (water air);

water
{
transportModel Newtonian;
nu 1e-06;
rho 1000;
}

air
{
transportModel Newtonian;
nu 1.48e-05;
rho 1;
}

sigma 0.07;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}

simulationType laminar;
10 changes: 10 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -e -u

blockMesh
cp -r 0.orig 0
setFields
touch fluid1.foam

../../tools/run-openfoam.sh "$@"
. ../../tools/openfoam-remove-empty-dirs.sh && openfoam_remove_empty_dirs
77 changes: 77 additions & 0 deletions partitioned-pipe-two-phase/fluid1-openfoam/system/blockMeshDict
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant/polyMesh";
object blockMeshDict;
}

scale 1;


zmin 0;
zmax 10;

xcells 1; // per block (5 blocks)
ycells 10; // per block (5 blocks)
zcells 20;

vertices
(
(0.0 -2.0 $zmin) // 0
(0.0 2.0 $zmin) // 1
(0.0 -2.0 $zmax) // 2
(0.0 2.0 $zmax)// 3
(-1.0 -2.0 $zmin) // 4
(-1.0 2.0 $zmin) // 5
(-1.0 -2.0 $zmax) // 6
(-1.0 2.0 $zmax) // 7
);

blocks
(
hex (4 0 1 5 6 2 3 7) pipe ($xcells $ycells $zcells) edgeGrading (1 1 1 1 1 1 1 1 1 1 1 1)
);

edges
(
);


patches
(

patch fixedWalls
(
(0 4 6 2)
(1 3 7 5)
)

patch inlet
(
(0 1 5 4)
)

patch outlet
(
(3 2 6 7)
)
);

boundaries
(
emptyWalls
{
type empty;
faces
(
(0 2 3 1)
(4 5 7 6)
)
}
);

mergePatchPairs
(
);
Loading

0 comments on commit d39627c

Please sign in to comment.