OpenFOAM is a very versatile tool that allows the study of multiple phenomenologies, heat exchange being a particularly difficult one to simulate if you are not used to using this software. In this series of tutorials, we will learn a way of performing a simulation in which two bodies intervene with heat exchange.
At the end of the first part of this tutorial, you will have learned a method to generate appropriate meshes to simulate in OpenFOAM a case where several bodies intervene with heat exchange. Although OpenFOAM has its own meshing modules, we will use the SALOME-MECA software, free software that has the advantage of being able to work with a graphical interface. Such software can be easily downloaded and installed by following the instructions on its website.
Índice de contenidos
Generation of simulation bodies.
To work with a simple case in this tutorial, we generate a cylinder that will act as a fluid body and inside it a parallelepiped (solid) that will generate the heat. To do this, in any CAD software, in the XY plane we draw a circumference centred at the origin of 100 mm radius and we extrude it in the Z axis 1000 mm. This body will be named “fluid”. After this, in the same plane, we generate a square centred on the origin with a side of 50 mm, we extrude it 100 mm and we move it on the Z axis until it is centred inside the cylinder. We will call this body “solid”.
Finally, we carry out a boolean subtraction operation between the cylinder and the parallelepiped so that the fluid volume does not intersect the solid and we export both bodies in STEP format.
Geometry preparation using SALOME MECA.
The previous step could have been perfectly executed in the SALOME geometry editing module, but if not, the first thing to do is import it in STEP format (or whatever we have used).
This software has various modules that can be accessed from the drop-down in the upper area. By selecting the “Geometry” module, we can carry out the previous actions before generating the mesh.
Within this module, by clicking on the “File” / “Import” menu, we select the format in which we have generated the geometry and select our file.
Once imported, we must perform an “Explode” of the bodies that make up the geometry (fluid and solid) to handle them separately. To do this, click on the top menu “New Entity /”Explode” and select our imported geometry (under “Main Object “) in the work tree. We must tick the option “Solid”, to obtain the two geometries.
Now, to obtain the surfaces of each of these bodies, necessary to create the boundary conditions, we will perform a second and third “Explode” on each body to name each of its faces appropriately (this time selecting the “Face” option).
In the case of the fluid body, we will name the face located at position Z = 0 as “inlet” and the face located at position Z = 1000 mm as “outlet” since we will assume that the fluid will circulate in the same direction of the axis. We name the external face of the cylinder as “wall” since this is the limit face of the fluid and physically it would be the one that would be in contact with the pipe through which the fluid circulates. The rest of the faces present in the fluid are those that are in contact with the inner solid.
According to the solving method that we propose in this tutorial (of course, this method is simply one that works, but it is not the only one to perform simulations of several bodies with heat exchange in OpenFOAM), the faces shared by two bodies do not they must be named in one of them. Since the solid only has faces in contact with the fluid, we will choose not to name the faces of the fluid body, so we will eliminate them and this body will only present the “inlet”, ”outlet” and “wall” faces.
For its part, the solid, by only presenting a group of faces that will correspond to the same boundary condition, we will group them into a set. We do this through the command “Create group”, within the upper menu “New Entity” / “Group” selecting “Faces” as shapes to add, our solid as the main shape and adding all the faces it presents. We will call this group “solid_heat_wall”.
Given that to carry out this method we will need to solve a continuous mesh (according to all the bodies that form it), we are going to unite the two bodies in a partition. To do this, we simply have to perform the operation called “Partition” in the upper menu “Operations” and select both bodies. This will allow the generation of a single mesh that encompasses both bodies. We must tick the option “Set presentation parameters …” so that the faces that we have named previously are kept. We will name this body “Partition_heat”.
Once this is done we have finished all the work with the SALOME geometry module and proceed to open the meshing module. The “Partition” created should be displayed in the tree as follows:
Mesh preparation and generation using SALOME MECA.
The first step to be carried out in this module is the creation of a mesh taking as the base geometry the partition generated in the previous step. Considering that for the resolution of this case we do not have precision restrictions of any kind, we are going to make a tetrahedral mesh with few elements, since in this way we can achieve results very quickly.
We select the “Mesh” module in the upper drop-down menu, and then click on the upper menu “Mesh” / “Create Mesh”. We make use of the NETGEN 1D-2D-3D algorithm and in its parameters (button with gear on the right) we are going to specify a degree of fine refinement, sizes between 10 and 20 mm, and we tick the option “Optimize”.
At this point we can generate our continuous mesh that includes both bodies (right click on it and click on “Compute”). However, before exporting it we must bear in mind that it is necessary to name the groups of elements that make up our mesh.
The good news is that, if we have done the previous step properly, this is quite simple. Just use the command “Create Groups from Geometry” (by right clicking on the mesh) and select all the elements named within our partition.
If you have done everything correctly, you can see that the mesh now has two groups of volumes, which are “fluid” and “solid” and four groups of surfaces, which are “inlet”, “outlet”, “wall” and “solid_heat_wall ”.
Mesh export to OpenFOAM format.
We already have a completely finished mesh to work with and the last step is to export it to operate in OpenFOAM. For them there are multiple ways, being the use of scripts one of them. In particular a highly recommended script that works very well is “salomeToOpenFOAM”, which has been created and distributed by Nicolas Edh, under the terms of the GNU license.
To use this script, we simply have to select the location where our mesh will be generated and make use of the script reading command that Salome has by selecting the generated mesh. (“File” / “Load script”).
If everything has worked correctly we already have a folder called “polyMesh” that contains all the information we need regarding the generation of files prior to OpenFOAM. In the next tutorial we will explain how to prepare the case configuration for this mesh in OpenFOAM.