Excercises

In this exercise we will investigate how permeability contrast affect hydrothermal flow and vent temperatures. We will first modify the Regular2DBox case to have constant temperature boundary condition and afterwards add a second layer to our mesh, so that we can explore permeability constrasts.

Constant temperature 1-layer system

What’s needed for the constant temperature case?

  • make a copy of the case directory

  • change the temperature boundary condition.

../../_images/RegularBox2D_constantT.png

Fig. 15 Constant temperature boundary condition.

Constant temperature 2-layer system

Now we will explore permeability contrasts!

What’s needed for the two-layer case?

  • make a copy of the 1-layer case directory

  • change the mesh to have two layers

  • assign different permeabilities to the two layers

Change the mesh

Remember how the vertice counting is done! If you don’t, check the info box.

../../_images/exercise_2layer.png

Fig. 16 Starting point for the two layer system.

The easiest way is start with the blockMeshDict file of the 1-layer case and then add a second layer on top. A good way of getting this right, is to draw the node numbering and then add the vertices to the blockMeshDict file. Notice how we give labels layer_bot and layer_top to the two blocks.

Order of vertices

../../_images/vertices_order.png

The OpenFoam documentation provides a nice description of the vertices ordering.

  • the axis origin is the first entry in the block definition, vertex 0 in our example

  • the x direction is described by moving from vertex 0 to vertex 1

  • the y direction is described by moving from vertex 1 to vertex 2

  • vertices 0, 1, 2, 3 define the plane z = 0

  • vertex 4 is found by moving from vertex 0 in the z direction

  • vertices 5,6 and 7 are similarly found by moving in the z direction from vertices 1,2 and 3 respectively.

Next boundary patches are defined and labeled in the blockMeshDict. Also here care must be take to provide the vertices in a consistent order (right-hand coordinate system). Two easy ways to remember this is to:

  • apply the right-hand rule, which means if the thumb of your right hand points to the outside of a face, the numbering has to follow your fingers.

  • or, looking onto a face and starting from any vertex, the numbering has to be counter-clockwise.

Assign properties

Next we need to set the permeability for the different zones. This can be achieved with setFields tool. The setFields tool requires a dictionary file setFieldsDict that tells it what to do. This file resides in the system folder. Here is a possible listing, just copy it and save it to your system folder.

Listing 16 Use the setFieldsDict to assign different permeabilities.
 1/*--------------------------------*- C++ -*----------------------------------*\
 2| =========                 |                                                 |
 3| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
 4|  \\    /   O peration     | Version:  5                                     |
 5|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 6|    \\/     M anipulation  |                                                 |
 7\*---------------------------------------------------------------------------*/
 8FoamFile
 9{
10    version     2.0;
11    format      ascii;
12    class       dictionary;
13    location    "system";
14    object      setFieldsDict;
15}
16// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17
18
19defaultFieldValues
20(
21    volScalarFieldValue permeability 1e-14
22);
23
24regions
25(
26    zoneToCell
27    {
28        name "layer_top";
29        fieldValues
30        (
31            volScalarFieldValue permeability 1e-13
32        );
33    }
34);
35
36// ************************************************************************* //
Listing 17 Use boxToCell to simply set permeability for two-layer model.
 1/*--------------------------------*- C++ -*----------------------------------*\
 2| =========                 |                                                 |
 3| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
 4|  \\    /   O peration     | Version:  5                                     |
 5|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
 6|    \\/     M anipulation  |                                                 |
 7\*---------------------------------------------------------------------------*/
 8FoamFile
 9{
10    version     2.0;
11    format      ascii;
12    class       dictionary;
13    location    "system";
14    object      setFieldsDict;
15}
16// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17
18
19defaultFieldValues
20(
21    volScalarFieldValue permeability 1e-14
22);
23
24regions
25(
26    boxToCell
27    {
28        box (0 -500 0) (1000 0 1); //(xmin,ymin,zmin) (xmax,ymax,zmax)
29        fieldValues
30        (
31            volScalarFieldValue permeability 1e-13
32        );
33    }
34);
35
36// ************************************************************************* //

Tip

Alternately, one can also set permeability of two layers by using boxToCell based on one layer mesh (see Listing 17), which is similar to zoneToCell shown in Listing 16.

Run the case

Now we are using the setFields utility to set the permeability. Therefore we need to change the run.sh script to also include the setFields command.

Listing 18 Modified run.sh file that also includes the setFields command.
 1#!/bin/sh
 2cd ${0%/*} || exit 1    # Run from this directory
 3
 4# Source tutorial run functions
 5. $WM_PROJECT_DIR/bin/tools/RunFunctions
 6
 7application=`getApplication`
 8
 9./clean.sh
10runApplication blockMesh
11cp 0/permeability.orig 0/permeability
12runApplication setFields
13runApplication $application

Tip

Notice that we have also included the statement cp 0/permeability.orig 0/permeability into the run.sh script. The setFields command writes mesh-dependent information into the permeability file, which causes problems when we want to change the mesh. Compare the permeability file before and after running the setFields command. To preserve the original file, it is a good idea to name the original file permeability.orig and only edit that one. When run.sh is executed, this file is then copied to permeability and mesh-dependent information is added to this file when setFields is executed.

Results of the two layer model. The highly permeable upper layer results in cold fluid entrainment and cooling due to mixing.