Next: Wheel mesh Up: Mesh Generation using snappyHexMesh Previous: Background mesh Contents Index
Mesh creation script
The whole process of the generation of the mesh can be automatized with the aid of a simple script. An example is below. The final mesh is shown in the figure .
#!/bin/bash # --------------------------------------------------------------------------- # # == === == # # || ||= || )) support s. r. o. 2014 # # == == # # --------------------------------------------------------------------------- # # Change to the root directory of the case first. It is assumed that the # location of this script is the root case. # cd ${0%/*} || exit 1 # Number of processes. This number will be written to "system/decomposeParDict". # This will not override already existing environment variable. if [[ $NPROCESS == "" ]]; then # Either use fixed number of cores ... # NPROCESS=4 # ... or use all cores of a single-processor machine. NPROCESS=$(sed -n "s/cpu cores[\t :]*\([0-9]\+\)/\1/p" /proc/cpuinfo | sort -u) fi # Check version of OpenFOAM. The mesh is being created in OpenFOAM 2.2, # if [[ $(echo $WM_PROJECT_VERSION | cut -c1-3) != "2.2" ]]; then echo "Use OpenFOAM 2.2 with this example script, please." exit fi rm -f log.all echo echo " Creating mesh using $NPROCESS threads" echo cd mesh-inflow echo " 1. inflow tube" sed -i "s/numberOfSubdomains \+[0-9]\+;/numberOfSubdomains $NPROCESS;/g" system/decomposeParDict rm -rf 1 2 processor* echo " * blockMesh" blockMesh | tee -a ../log.all > log.blockMesh echo " * decomposePar" decomposePar | tee -a ../log.all > log.decomposePar echo " * snappyHexMesh" mpirun -np $NPROCESS snappyHexMesh -parallel | tee -a ../log.all > log.snappyHexMesh echo " * reconstructParMesh" reconstructParMesh -latestTime | tee -a ../log.all > log.reconstructParMesh rm -rf processor* cd .. echo cd mesh-wheel echo " 2. wheel" sed -i "s/numberOfSubdomains \+[0-9]\+;/numberOfSubdomains $NPROCESS;/g" system/decomposeParDict rm -rf 1 2 processor* echo " * blockMesh" blockMesh | tee -a ../log.all > log.blockMesh echo " * decomposePar" decomposePar | tee -a ../log.all > log.decomposePar echo " * snappyHexMesh" mpirun -np $NPROCESS snappyHexMesh -parallel | tee -a ../log.all > log.snappyHexMesh echo " * reconstructParMesh" reconstructParMesh -latestTime | tee -a ../log.all > log.reconstructParMesh echo " * topoSet" topoSet | tee -a ../log.all > topoSet rm -rf processor* cd .. echo cd mesh-volute echo " 3. volute and outflow" sed -i "s/numberOfSubdomains \+[0-9]\+;/numberOfSubdomains $NPROCESS;/g" system/decomposeParDict rm -rf 1 2 processor* echo " * blockMesh" blockMesh | tee -a ../log.all > log.blockMesh echo " * decomposePar" decomposePar | tee -a ../log.all > log.decomposePar echo " * snappyHexMesh" mpirun -np $NPROCESS snappyHexMesh -parallel | tee -a ../log.all > log.snappyHexMesh echo " * reconstructParMesh" reconstructParMesh -latestTime | tee -a ../log.all > log.reconstructParMesh rm -rf processor* cd .. echo cd mesh-whole echo " 4. complete mesh" rm -rf 1 2 3 cd constant rm -rf polyMesh echo " * copying inflow part" cp -R ../../mesh-inflow/2/polyMesh . cd .. echo " * merging wheel part" mergeMeshes . ../mesh-wheel | tee -a ../log.all > log.mergeMeshes echo " * merging volute part" mergeMeshes . ../mesh-volute | tee -a ../log.all >> log.mergeMeshes echo " * renaming patches" createPatch | tee -a ../log.all > log.createPatch echo " * checking mesh" checkMesh -latestTime | tee -a ../log.all > log.checkMesh grep "cells:" log.checkMesh cd .. echo echo " Done." echo
Figure: View of the whole mesh of the fan.