1

Previous: System files and case Up: OpenFOAM tutorial – Cyclone Next: Basic postprocessing
This is an automatically generated documentation by LaTeX2HTML utility. In case of any issue, please, contact us at info@cfdsupport.com.

Running the case

  • Running the case consists of several steps which are pre-defined in the script file AllrunSnappyMesh.sh below.
  • The basic steps are:
    • clean the case and set given number of processors
    • create background mesh and run snappyHexMesh
    • creating necessary files for MPPICFoam solver
    • running MPPICFoam solver

 

cd ${0%/*} || exit 1

if [[ $(echo $WM_PROJECT_VERSION | cut -c1-3) != "dev" ]]
then
    echo "Use OpenFOAM dev with this example script, please."
    exit
fi

NPROCESS=$1
# Number of processes. This number will be written to "system/decomposeParDict".
if [[ $NPROCESS == "" ]]
then
    # ... 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
echo
echo "Numer of processors set for this simulation: --> $NPROCESS <--"
sed -i "s/numberOfSubdomains.*[0-9][0-9]*;/numberOfSubdomains $NPROCESS;/g" system/decomposeParDict 

echo
echo "Cleaning cases..."
./AllcleanAll.sh > allClean 2>&1
mv allClean log-01-allClean
echo "              ...done"

echo
echo "Creating backgroundMesh..."
blockMesh > log-02-blockMesh 2>&1
echo "                       ...done"

echo
echo "Generating feature-edges..."
surfaceFeatureExtract > log-03-surfaceFeatureExtract 2>&1
echo "                        ...done"

echo
echo "Decomposing background mesh..."
decomposePar > log-04-decomposePar-backgroundMesh 2>&1
echo "                           ...done"
 
echo
echo "Running snappyHexMesh..."
mpiexec -np $NPROCESS snappyHexMesh -parallel -overwrite  > log-05-snappyHexMesh 2>&1
echo "                     ...done"

echo
echo "Checking mesh..."
mpiexec -np $NPROCESS checkMesh -parallel > log-06-checkMesh 2>&1
echo "                               ...done"
   
echo
echo "Reconstructing mesh..."
reconstructParMesh -latestTime -constant > log-07-reconstructParMesh 2>&1
echo "                   ...done"

echo 
echo "Cleaning mesh..."
createPatch -overwrite > log-08-createPatch 2>&1
echo "             ...done"

echo
echo "Creating initial setup..."
cp -rv 0.org 0
echo "                      ...done"

echo "Decomposing case..."
decomposePar -force > log-09-decomposePar 2>&1
echo "                ...done"

echo "Running MPPICFoam..."
mpiexec -np $NPROCESS MPPICFoam -parallel > log-10-MPPICFoam 2>&1
echo "                  ...done"

echo "Reconstructing all saved times..."
reconstructPar > log-11-reconstructPar 2>&1
echo "                  ...done"

 

  • line 11 checks if the script is run from the place where the script file is stored
  • lines 13-17 check if OpenFOAM v3.0.* is used
  • lines 19-28 read number of subdomain used for computation, it uses maximum number of cores available if nothing is specified
  • lines 30-34 run script which cleans the case directory
  • lines 36-39 creates the backgroundMesh which is defined in blockMeshDict file
  • lines 41-44 more robust snapping to geometry edges can be achieved by means of feature-edges which are generated using surfaceFeatureExtract utility
  • lines 46-49 for parallel mesh generation the case is decomposed
  • lines 51-54 run snappyHexMesh in parallel; the flag -overwrite means, that new mesh will be stored in /constant/polyMesh directory
  • lines 56-59 check the quality of new generated mesh
  • lines 61-64 reconstruct the mesh
  • lines 66-69 clean empty patches in mesh
  • lines 71-75 create directory 0
  • lines 76-78 decompose the case for parallel running
  • lines 80-82 run computation in parallel
  • lines 84-86 reconstruct all time directiories
  • Go to case directory and run the script, e.g. using 4 cores:
    # ./AllrunSnappyMesh.sh 4