1

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

Running the case with SALOME mesh

  • Running the case consists of several steps which are pre-defined in the script file AllrunSalomeMesh.sh below.
  • The basic steps are:
    • creating the necessary files for simpleFoam solver.
    • converting the mesh exported from SALOME (*.unv files must be placed in case directory, see Table crossref 3).
    • running simpleFoam solver.
    • modifying the simpleFoam results for use of twoPhaseEulerFoam solver.
    • creating the necessary files for twoPhaseEulerFoam solver.
    • running twoPhaseEulerFoam 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 "Modifying system files for simpleFoam..."
      echo "   Boundary conditions:"
      cp -rv 0.simple 0
      echo "                                     ...done"
      for fileName in controlDict fvSchemes fvSolution
      do
         echo "Creating system/$fileName..."
         cp -v system/$fileName.simple system/$fileName
         echo "                             ...done"
      done
      
      echo
      echo "Converting UNV mesh to OpenFOAM..."
      ideasUnvToFoam Cyclone.unv > log-02-ideasUnvToFoam 2>&1
      echo "                               ...done"
      
      echo
      echo "Checking mesh..."
      checkMesh > log-03-checkMesh 2>&1
      echo "                               ...done"
      
      
      echo
      echo "Changing entries for polyMesh/boundary..."
      cp -v system/changeDictionaryDict.mesh system/changeDictionaryDict
      changeDictionary > log-04-changeDicitonary-mesh 2>&1
      echo "                                      ...done"
      
      echo "Decomposing case..."
      decomposePar > log-05-decomposePar 2>&1
      echo "                ...done"
      
      echo "Running simpleFoam..."
      mpiexec -np $NPROCESS simpleFoam -parallel > log-06-simpleFoam 2>&1
      echo "                  ...done"
      
      echo "Reconstructing simpleFoam case..."
      reconstructPar -latestTime > log-07-reconstruct-simpleFoam 2>&1
      echo "                  ...done"
      
      #recTime=`foamListTimes | tail -n1`
      recTime=1000
      echo "Moving results from $recTime to 0 dir..."
      rm -rv 0
      mv $recTime 0
      echo "                                     ...done"
      
      echo "Modifiing and adding files in/to 0 dir..."
      cd 0
      rm -rv uniform
      cp -v U U.water
      mv -v U U.particles
      rm -v nut
      mv -v epsilon epsilon.water
      mv -v k k.water
      mv -v p p_rgh
      cp -v ../0.euler/nut.particles .
      cp -v ../0.euler/nut.water .
      cp -v ../0.euler/T.water .
      cp -v ../0.euler/T.particles .
      cp -v ../0.euler/Theta.particles .
      cp -v ../0.euler/alphat.particles .
      cp -v ../0.euler/alpha.particles .
      cp -v ../0.euler/alphat.water .
      cp -v ../0.euler/alpha.water .
      cp -v ../0.euler/p .
      cd ..
      echo "                                     ...done"
      
      echo
      echo "Changing entries for polyMesh/boundary..."
      cp -v system/changeDictionaryDict.euler system/changeDictionaryDict
      changeDictionary > log-08-changeDicitonary-euler 2>&1
      echo "                                      ...done"
      
      for fileName in controlDict fvSchemes fvSolution
      do
         echo "Creating system/$fileName..."
         cp -v system/$fileName.euler system/$fileName
         echo "                             ...done"
      done
      
      echo "Decomposing case..."
      decomposePar -force > log-09-decomposePar 2>&1
      echo "                ...done"
      
      echo "Running twoPhaseEulerFoam..."
      mpiexec -np $NPROCESS twoPhaseEulerFoam -parallel > log-10-twoPhaseEulerFoam 2>&1
      echo "                  ...done"
      
      echo "Reconstructing twoPhaseEulerFoam case..."
      reconstructPar -latestTime > log-11-reconstruct-twoPhaseEulerFoam 2>&1
      echo "                  ...done"
      
      • line 11 checks if the script is run from the place where the script file is stored.
      • lines 13-16 check if OpenFOAM v3.0.* is used.
      • lines 19-28 read number of subdomain used for computation, if nothing is specified than it used maximum number of cores available.
      • lines 30-34 run script which cleans the case directory.
      • lines 36-46 copy the listed system files for simpleFoam solver.
      • lines 48-51 convert the SALOME mesh to OpenFOAM mesh using ideasUnvToFoam utility.
      • lines 53-56 check the mesh.
      • lines 59-63 changes entries following the changeDictionaryDict.mesh, i.e. sets the boundary type of Cyclone-wall to wall.
      • lines 65-67 decompose the case for parallel running.
      • lines 69-71 run computation in parallel.
      • lines 73-75 reconstruct the last time step.
      • lines 77-82 rename the last time step folder to 0 – new initial setup for twoPhaseEulerFoam solver.
      • lines 84-104 adds additional initial setup files for twoPhaseEulerFoam solver.
      • lines 106-110 changes entries for p_rgh following the changeDictionaryDict.euler.
      • lines 112-117 copy the listed system files for twoPhaseEulerFoam solver.
      • lines 119-121 decompose the case for parallel running.
      • lines 123-125 run computation in parallel.
      • lines 127-129 reconstruct the last time step.
      • Go to case directory and run the script, e.g. using 4 cores:
        # ./AllrunSalomeMesh.sh 4