Getting started with chtMultiRegionSimpleFoam - planeWall2D

From OpenFOAMWiki

Valid versions: OF Version 21.png OF Version 22.png OF Version 23.png

1 Introduction

This page is meant to help the user get started with the chtMultiRegionSimpleFoam and chtMultiRegionFoam solvers. This page is no where near complete, and it's certainly far from being perfect, so please do feel free to improve this page and add examples based on this planeWall2D example case and write instructions and/or tips on how to use these solvers.

This page began as a result from the discussion help here: chtMultiRegionFoam--unequal temperature at coupled patches - there you might find some very more precious hints on what you can do with these solvers!

Keep in mind that:

chtMultiRegionSimpleFoam is a
Steady-state version of chtMultiRegionFoam
chtMultiRegionFoam is a
Combination of heatConductionFoam and buoyantFoam for conjugate heat transfer between a solid region and fluid region

Warning: You should keep in mind that these examples have not been checked to confirm if they are physically sane, since the objective is simply to introduce you, the reader, to how simulation cases can be set-up for using with these solvers. Therefore, please do properly investigate each and every single detail in this page and tutorial case and properly diagnose the results for yourself. Do keep in mind that this page is currently not designed to teach you everything about CFD, nor about thermodynamics and fluid dynamics in general. This page is only able to introduce you to most of the topics that relate to these kinds of simulations and leaves everything else to you, the reader.

Some more ideas and discussions regarding this tutorial are being done on this thread: conjugate heat transfer in OpenFOAM

1.1 Requirements before continuing

This tutorial assumes you're already trained and are already familiar with the following topics:

  1. How to use the shell: Installation/Working_with_the_Shell
  2. How to open and edit text files... any online tutorial can teach you about that.
  3. Have carefully studied the OpenFOAM User Guide.
  4. Have already studied some tutorials that are isothermal. If you have not yet studied any such tutorials, then please study them first. (edit note: references missing)
  5. You might also want to have a look at the tutorials chapter in the OpenFOAM Programmer's Guide. For more details, see this page: OpenFOAM guide/Programmer's Guide Errata

2 planeWall2D - Case description

This is basically the example shown in the book Fundamentals of Heat and Mass Transfer by Frank P. Incropera et. al, chapter 3, section 3.1 "The Plane Wall", which is somewhat reproduced in the following picture:

This shows the schematic for the plane wall.
This shows the equivalent thermal circuit for this plane wall.

Basically, it's an infinite solid and uniform wall with generic fluids flowing on both sides of the wall. It's one of the most basic 1D examples of heat transfer between two fluids and a solid.

The untrained reader is unlikely familiar with the several details that occur in this scenario:

  1. This schematic is for when the flow is at a stable flow rate; in order words, when the flow is exactly the same at 1km or 10km and that there is enough hot and cold fluid on each side to assume that the set-up is as good as infinite.
  2. The case initially provided for using with OpenFOAM is an initial set-up, which is at the very start of this infinite wall. This means that:
    1. If temperature was not taken into account, this would exactly be the same case for the Boundary Layer on a Flat Plate.
    2. In addition, to make the case set-up easier, this fluids are actually flowing inside a pipe and the represented walls in the case below are actually symmetry planes, i.e. the axis of each tube.
    3. In other words, the flow is not yet fully developed, therefore you'll see the effect of the initial boundary layer, mixed in with the heat transfer.
    4. For more details, research on your own for more details on this topic and/or read this Wikipedia article: Boundary layer
  3. The heat transferred through convection depends directly on the flow speed near the solid wall.
  4. If you want to properly diagnose if your cases run with OpenFOAM for this kind of simulation, you must first study the analytical expressions for each scenario you're planning on simulating, so that you can better understand the physics behind this. Otherwise you will feel that the simulations are always wrong.
    • We'll try to do this with the provided example, but further developments will have to be done by yourself.

2.1 Provided case for OpenFOAM

The case is attached for the following versions of OpenFOAM:

Note: this case will also work with OF Version 20.png, if you do the necessary tweaks in the fvSchemes files of the attached example case.

The case provides a ready to be used case for OpenFOAM and is defined as follows:

  • It's based on the tutorial heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater, but stripped down to only 3 regions, one solid and two fluids.
  • The mesh of this example case "planeWall2D" is based on the traditional OpenFOAM cavity case, but with 1m x 1m.
  • The 3 regions are defined as follows:
    • topAir - 0.6 to 1m - where the air is cold at 300K and flows from the left to the right at 0.1m/s. The top patch is a symmetry plane.
    • wall - 0.4 to 0.6m - where a solid wall is placed, initiated at 300K and has a high conduction factor.
    • bottomAir - 0 to 0.4m - where the air is hot at 500K and flows from the left to the right at 0.1m/s. The bottom patch is a symmetry plane.

2.2 Get and run the case

  1. Download the attached file for the version of OpenFOAM you're using (seen in the Case description) and unpack it by running:
    • OF Version 21.png:
      tar xzf planeWall2D.tar.gz
    • OF Version 22.png:
      tar xzf planeWall2D-2.2.tar.gz
    • OF Version 23.png:
      tar xzf planeWall2D-2.3.tar.gz
  2. Then go into the folder:
    cd planeWall2D
  3. And run it:
  4. For resetting the case, run:

2.3 Post-Processing

When the script Allrun finishes executing, you'll have the following 3 files:


Start up ParaView from the command line and open those 3 files:


In the following two pictures is shown what you can do:

This shows how to configure the Plot Over Line filter. Notice that it is being applied to another intermediate filter named Group Datasets, which groups the 3 files into a single dataset.
This shows how to configure the lines to be plotted.

2.4 File description

The following list of files are the ones you should first study, before you even try to modify anything on this case:

  • 0/* - These files are pre-configured and don't need to be modified... at least in theory, because they provide a blank template of the field files that will be created. In other words, changing these files won't affect much.
  • Allclean - This script is the one that takes care of resetting everything. Reconfigure it if you add more regions.
  • Allrun - This script is the one that takes care of running the case. Reconfigure it if you add more regions and to suit your needs.
  • constant - In this folder is placed all properties that are preserved during execution.
    • polyMesh - In this folder is located the mesh for the case.
      • blockMeshDict - This is the dictionary file used by blockMesh to generate the base mesh. It's here that you can change the base resolution of the mesh or even extend the dimensions of the mesh.
    • regionProperties - This file defined which regions are solid and which are fluid.
    • bottomAir - In here are defined all properties of the fluid located in the bottom region.
    • topAir - In here are defined all properties of the fluid located in the top region.
    • wall - In here is a single file that defines the properties of the solid.
  • system - In here are the files that configure or help configure the case.
    • controlDict - Here you control the number of iterations and so on...
    • topoSetDict - Here you defined the extents of each region. It's here that you can select which cells of the mesh that belong in each region.
    • bottomAir - In here are the runtime configurations for the bottom region.
      • changeDictionaryDict - This is the main file where you define the actual boundary conditions to be used for the bottom region.
    • topAir - In here are the runtime configurations for the top region.
      • changeDictionaryDict - This is the main file where you define the actual boundary conditions to be used for the top region.
    • wall - In here are the runtime configurations for the wall region.
      • changeDictionaryDict - This is the main file where you define the actual boundary conditions to be used for the wall region.

2.5 Understanding the physics

There are at least 3 major topics that need to be seen and understood and which will be explained in the following subsections:

  1. The boundary layer that generates naturally near a no-slip wall: Boundary Layer
  2. How heat propagates along fluid, along solid and when solid interfaces with fluid: Analytical solution
  3. What happens when the two are combined: Interpreting the results

2.5.1 Boundary Layer

In case you haven't figure it out by now, there is something you should very aware when dealing with CFD and OpenFOAM: it's a tool, it's not a self-aware virtual laboratory. This to say that the burden of defining, understanding and interpreting the results is all on the side of the user; CFD theory and software will only be able to ensure that if you properly define the case, it will try to find the solution to the problem, as far as mathematics and computational resources allows it. (editor note: still need to give a link to a wiki page which extensively talks about this.)

Anyway, this first topic is regarding the boundary layer that occurs when you have a no-slip condition, i.e. the wall imposes the condition of not allowing the fluid to move when it's exactly on top of the wall. For more details, research on your own for more details on this topic and/or read these Wikipedia articles:

On this subsection we'll stick to interpreting what happens by using OpenFOAM to do a simple simulation that demonstrates all of this.

Now, the advice here is that you try and reproduce the following case and results on your own, since when it comes to OpenFOAM, you must train yourself. It's fairly simple to do on your own. The case description is a follows:

  1. We take the cavity case (see the very first tutorial in the OpenFOAM User Guide) and change it to have fluid entering on one side and exiting on the opposing side.
  2. The dimensions can be whatever you'd like, but if you need specifics, then think of a pipe with 1m in length and 0.1m in diameter.
  3. We'll stick to using 2D, since it makes it a lot easier to visualize results. But feel free to complicate things if you want to, namely to make it 3D instead.
  4. The fluid will enter at 0.001 m/s, so that we can keep things at a good scale.
  5. The transport properties will be the ones for water at 20 Celsius, simply because it's something we can easily relate to.
  6. We'll use icoFoam to keep things simplified, so you can follow the instructions given on the very first tutorial in the OpenFOAM User Guide.
  7. If you don't have an idea on the mesh resolution, then think of 800 cells along X and 80 over Y. It should give you a good enough resolution for an idea on how things work.

Now, if we look at results below, the caption on each image will explain what's going on:

This is the flow profile at the inlet, i.e. x=0m. It's not a perfect rectangle due to two reasons: the no-slip wall condition and the fact that we have a discrete mesh domain. This and the following plots are done with 81 sampling points, evenly distributed along the diameter of the pipe.
This is the flow profile at x=0.001m. This shows you a bit of how the flow is redistributing itself, due to the no-slip condition at the walls.
This is the flow profile at x=0.01m. It shows that it continues to adjust itself to the surrounding conditions.
This is the flow profile at x=0.02m.
This is the flow profile at x=0.03m.
This is the flow profile at x=0.05m.
This is the flow profile at x=0.1m. The flow profile here seems to already be fully developed.
This is the flow profile at x=0.8m. As you can see, it's identical to the one at x=0.1m, which shows that the flow is already stabilized.
This is a contour plot of the profile of the magnitude of the flow speed. As you can see, each line is the contour for a constant flow speed. Notice how perfectly aligned it is after a certain point.

This is essentially what you also see in the original case we're looking at, namely the 2D plane wall, but when looking only on one of the sides.

And just in case you're lazy or simply didn't manage to get the case working, here is the case used for this example:

2.5.2 Analytical solution

So, what is the analytical solution for the formulated example?
According to the equivalent thermal circuit (described in the book Fundamentals of Heat and Mass Transfer by Frank P. Incropera), the heat flux is as follows:
q_x = \frac{T_{\infty,1}-T_{s,1}}{\frac{1}{h_1 A}} = \frac{T_{s,1}-T_{s,2}}{\frac{L}{k A}} = \frac{T_{s,2}-T_{\infty,2}}{\frac{1}{h_2 A}}

Why is it important in the first place?
Because this allows us to better analyse if things are working properly. In addition, this isn't everything we need.

If we look at the introductory chapter of book Fundamentals of Heat and Mass Transfer (section 1.2), from which this is quoted:

[...] the parameter h (W/m^2 \cdot K) is termed the convection heat transfer coefficient. It depends on conditions in the boundary layer, which are influenced by surface geometry, the nature of the fluid thermodynamic and transport properties.

This gives us the notion of why the temperature profile on each fluid side is not linear. Since the boundary layer induces the flow profile, this means that the convection heat transfer coefficient will scale accordingly to the flow speed. This will be more closely addressed in the next subsection Interpreting the results, by looking directly at the results given in the simulation. For more specific details on how this coefficient can be calculated, please study chapter 6 on the aforementioned book.

Although... the detail that is missing is the notion of how the convection heat transfer coefficient relates to the flow speed. Well, as the quote above indicates, it depends on several details. If we assume that the fluid properties are roughly the same at the working temperatures, then we can perhaps assume that this coefficient scales linearly with the flow speed; if this is the case, and taking into account what we learned in the previous section Boundary Layer, then that means that this coefficient will scale in a non-linear way in function of the distance to the wall. Furthermore, keep in mind that this boundary layer can increase even more if the flow within the boundary layer becomes turbulent.

2.5.3 Interpreting the results

Taking into account the previous two subsections, we can now look in more detail to the results. Therefore, we will first look at the flow profiles on each side of the wall, using the contour lines (the case used was the one for OpenFOAM 2.1):

This is a contour plot of the profile of the magnitude of the flow speed. Looks sort of familiar, doesn't it? Well, not very much, but that's because there are several reasons for that, which are explained after these images.
This is a contour plot of the profile of the temperature. Here you can notice how the temperature seems to be affected by the flow speed.

There is more than one problem in this case, but it's an interesting case nonetheless, since the results are still somewhat physical. The problems are several and some of them are as follows:

  1. Since it's air flowing in both fluid regions, and since one starts at 300K and the other 500K, and both start off with the same pressure levels, what happens is that the air with the higher temperature must reduce it's density considerably when it transfers heat to the colder region.
  2. The other detail is that since this is air flowing, it becomes considerably turbulent near the end of this not very lengthy section of wall.
  3. The residuals are not stable enough after 50000 iterations. Something clearly is going on wrong.
  4. Didn't even have a better look at the y^+ values, but it's possibly not within the correct operating region and this might be the reason why it's not a converged result.

Therefore, the suggestion is that you, who are reading this, do the very first exercise of modifying the case to something more... easy to understand. For example, to use water on both sides of the fluid flow. Then compare the results achieved on in the section Boundary Layer.

3 Suggested Exercises

  • Reduce the resolution of the mesh from 100x100x1 to 20x20x1 and use refineMesh to increase resolution where it matters, namely near the wall! A good reference tutorial for this is multiphase/cavitatingFoam/les/throttle.
  • Change the properties of the solid and/or top and bottom fluids, so you can see what's going on.
  • Extend the wall or apply the cyclic boundary condition to the outlets and inlets (the ones named leftLet and rightLeft), turning this into an infinite wall.
  • Follow the directions given in the post #34 on the thread "conjugate heat transfer in OpenFOAM" at CFD-Online, to calculate the analytical solution, for comparison with the results achieved with the chtMultiRegion*Foam solvers.
    • Beyond that, you might want to try and implement a solver similar to potentialFoam, to do this calculation.
  • Any more exercises are up to you!

4 References

Maaike Van Der Tempel: A chtMultiRegionSimpleFoam tutorial. Slides Report Code Case1 Case2