Tutorial: Preparation of a multibody simulation with heat transfer in OpenFOAM. Part 2: simulation
We continue with the tutorial series in which we are improving our CFD capabilities in OpenFOAM. Today we completed the multibody simulation tutorial with heat transfer.
Let us remember that in the previous tutorial we learned how to generate a mesh in the SALOME-MECA software in a comfortable and simple way. In this case we will start from the created mesh and we will see which files will allow us to carry out the simulation in OpenFOAM.
Índice de contenidos
Mesh division into different bodies.
Before starting to configure the simulation files, it is important to obtain a mesh divided into as many regions as bodies exist in the case. If we take a look at our tutorial on the basic structure of OpenFOAM folders, we will see that we must always start from folders “0”, “constant” and “system”. In a multibody case like this, each of these folders will contain as many folders as regions exists. For example, in our case, these folders will be “fluid” and “solid”. Each one of them will contain the pertinent files.
To generate the different parts of the necessary mesh we will use the command “splitMeshRegions“. This command will divide the mesh using all internal surfaces that we have created. Additionally, we can use the “cellZones” option, which will allow us to divide the mesh into as many “cellzones” as we have (instead of dividing it according to the internal surfaces that the case contains). As we start from a mesh with each region created, we will use this command (“splitMeshRegions –cellZones”, without the use of quotes). It must be executed in the root folder of the case and having the mesh in its corresponding location (within “constant” and in its “polyMesh” folder). Once this is done, we will have generated a folder “1” in the root, in which we will have our two separate meshes (“fluid” and “solid”), which we will copy to the folder “constant“, inside a folder with the name of its region, along with the file “cellToRegion”.
To finish preparing the meshes, we must make some small modifications in the “boundary” files of each one of them. Apart from verifying that our input and output in the fluid region are specified as “patch” and the outer wall as “wall” (this is done automatically when exporting from SALOME), we must modify the contact surface between both regions. Remember that in the meshing software we only name it once (“solid_heat_wall”), so now, in the file corresponding to the fluid mesh, we must change the name to “fluid_heat_wall” (in the solid it will keep its original name) . Furthermore, by default the exporter automatically assigns the type “wall“, and in our case this surface will be a wall coupled between bodies, so we must rename it to “mappedWall“. Next, we must add some lines in which we will specify the type of contact, its analogue surface and the region where this surface is located, as shown in the image.
After that we will already have two continuous meshes with their corresponding interfaces defined appropriately.
Configuration of files in the “constant” folder.
The folder “constant” is one of those that our main directory should contain. This folder must include the folders “solid” and “fluid” (which we should have already generated to copy the meshes) and the file “regionProperties“. This file must be included in the simulations with several regions, and in it we only have to specify the name of our regions and if they are solid or fluid.
In both regions we must add the files “fvOptions” and “thermophysicalProperties“. The first has the function of specifying additional options within that region, and the second presents the thermodynamic properties necessary to perform the simulation. In the fluid region, in addition, the files common to any turbulent simulation with gravity (“turbulenceProperties” and “g”) must be present.
In the file “fvOptions“, we will use a temperature limiter with values between 274 and 1500 to help the convergence of the simulation (this is optional). In addition to this condition, which we will impose on the two regions, in the solid region we will also create a very high duration power source condition with a value of 100W. With this we specify that the solid will generate this amount of heat constantly during the simulation.
The “thermophysicalProperties” file, as we have already commented, must contain the physical properties, in this case the fluid region being air and the solid region being aluminium.
Configuration of files in folder “0”.
In this folder we have the “fluid” and “solid” folders again.
Inside the first one, there must be files that contain the typical conditions of a basic fluid dynamic simulation and those of temperature, these being “alphat“, “epsilon“, “k“, “nut“, “p“, “p_rgh“, “T” and “U“, in addition to the file “cellToRegion”, present in those studies in which there are several regions.
In them we will simply specify an initialization value for each variable on each surface and a pressure and temperature value in the internal field.
The most noteworthy aspects of this simulation are the specification of the temperature on the “inlet” surface of 300 K and a velocity on the same face of 0.1 m / s, as well as a value of 300 K and 100000 Pa in the internal fields of temperature and pressure, respectively.
In the study at hand, we must specify what type of contact condition will be used in the “solid-fluid” interface (“fluid_heat_wall”). In this case the type “compressible:: turbulentTemperatureCoupledBaffleMixed” has been used.
In the case of solid, its folder will only contain the “p” and “T” files, which will be specified analogously to those of the fluid region. For more detailed information on which boundary conditions to use, the following guide can be consulted.
Configuration of files in folder “system”.
The “system” folder is the last one that we must add to our main directory. Inside this, the folders “fluid“, “solid” and the files “controlDict“, “fvSchemes” and “fvSolution” must be included. Additionally, as we are going to carry out the case in a decomposed way to increase the resolution speed, we must also incorporate the file “decomposeParDict“, in which we will specify the number of processors that we will use in parallel. In the file “controlDict” we must specify the solver we are using, “chtMultiRegionFoam” as well as the number of iterations to perform and in the other two files we must specify the numerical methods to be used in the simulation.
For multi-region simulations, and with the exception of the “controlDict” file, the content of these files located outside the directories of each region will not be used during the simulation (they may be empty), but the software checks that they exist before starting the simulation, so they are necessary. Within the folder of each region we must have them properly configured since they will determine how to solve the case.
Simulation and results visualization.
With all the files configured, you simply need to use the “chtMultiRegionFoam” solver, specifying the number of processors to use and the command “decomposePar -allRegions”.
After that we wait for the simulation to finish and we generate the classic empty file “foam.foam” with the most comfortable method to us.
If we are going to visualize the results with Paraview, it is necessary to reconstruct the previously decomposed information by introducing the following sentence in the terminal “reconstructPar -allRegions -latestTime”.