1

Previous: Radiation properties Up: Test case: roomWithRadiator Next: Running test case

This is an automatically generated documentation by LaTeX2HTML utility. In case of any issue, please, contact us at info@cfdsupport.com.

Scripts

  • There are four main scripts in this tutorial makeMesh.shrunCalculation.shAllrun.sh and Allclean.sh
  • Script makeMesh.sh was already explained in Section Mesh generation crossref 3
  • Script Allclean.sh cleans the test case directory by deleting all files generated by makeMesh.sh and runCalculation.sh scripts
  • Let us walk through the script runCalculation.sh:
    #!/bin/bash
    # --------------------------------------------------------------------------- #
    #   ==   ===  ==                                                              #
    #  ||   ||=  || ))  support s. r. o. 2017, www.cfdsupport.com                 #
    #   ==        ==                                                              #
    # --------------------------------------------------------------------------- #
    
    # number of CPUs to run on
    if [[ "$1" -eq "" ]] ; then
        numProcs=6
    else
        numProcs=$1
    fi
    
    # endTime in seconds
    if [[ "$2" -eq "" ]] ; then
        endTime=1000
    else
        endTime=$2
    fi
    
    # writeInterval in seconds
    if [[ "$3" -eq "" ]] ; then
        writeInterval=100
    else
        writeInterval=$3
    fi
    
    # radiation model options: P1 or FvDOM
    if [[ -z "$4" ]] ; then
        radiationModel=P1
    else
        radiationModel=$4
    fi
    
    # check environment
    if [[ $(echo $WM_PROJECT_VERSION |  cut -c1-3) != "dev" ]];
    then
        echo "Use OpenFOAM dev with this example script, please."
        exit
    fi
    
    echo
    echo "Cleaning..."
    ./Allclean.sh > /dev/null 2>&1
    
    sed -i "s/\(.*numberOfSubdomains[ \t]*\)[0-9].*;/numberOfSubdomains $numProcs;/g" system/decomposeParDict
    sed -i "s/\(.*endTime[ \t]*\)[0-9].*;/\1$endTime;/g" system/controlDict
    sed -i "s/\(.*writeInterval[ \t]*\)[0-9].*;/\1$writeInterval;/g" system/controlDict
    
    cp -r 0.org 0
    cp constant/pipe/radiationProperties.$radiationModel constant/pipe/radiationProperties
    cp constant/room/radiationProperties.$radiationModel constant/room/radiationProperties
    
    echo "Decomposing case..."
    decomposePar -allRegions > log.decomposePar  2>&1 
    echo "Running simulation..."
    mpiexec -np $numProcs chtMultiRegionFoam -parallel > log.chtMultiRegionFoam 2>&1
    echo "Reconstructing results..."
    reconstructPar -allRegions > log.reconstructPar 2>&1
    paraFoam -touchAll
    echo "Simulation done."
    
  • Line 10 sets how many CPUs will be used for computation
  • Line 17 determines time interval to be solved
  • Line 24 sets time step for data saving during simulation
  • Line 31 selects one of two preset radiation models
  • If conditions in lines 9-34 allow runCalculation.sh script to get these four values from parameters, where the first parameter is number of CPUs, the second is end time of simulation, the third one is data write interval and the last is the radiation model
  • Lines 37-41 check if user uses compatible OpenFOAM version
  • Line 45 runs Allclean.sh script
  • Lines 47-49 puts the input parameters into the given OpenFOAM dictionaries using the sed stream editor
  • Line 51 copies boundary conditions from directory 0.org to directory 0
  • Lines 52 and 53 copy selected radiation model properties into the fluid regions
  • Line 56 decomposes the case
  • Line 58 starts the simulation in parallel
  • Line 60 reconstructs results
  • Line 61 prepares files for visualization in paraview
  • Script Allrun.sh runs all previous scripts. Lets walk through it:
#!/bin/bash
# --------------------------------------------------------------------------- #
#   ==   ===  ==                                                              #
#  ||   ||=  || ))  support s. r. o. 2017, www.cfdsupport.com                 #
#   ==        ==                                                              #
# --------------------------------------------------------------------------- #

# number of CPUs to run on
numProcs=6
# endTime in seconds
endTime=0.45
# writeInterval in seconds
writeInterval=0.15
# radiation model options: P1 or FvDOM
radiationModel=FvDOM
 
# check environment
if [[ $(echo $WM_PROJECT_VERSION |  cut -c1-3) != "dev" ]];
then
    echo "Use OpenFOAM dev with this example script, please."
    exit
fi

echo
echo "Running makeMesh script"
cd meshFactory
./makeMesh.sh $numProcs
cd ..

echo
echo "Running runCalculation script"
./runCalculation.sh $numProcs $endTime $writeInterval $radiationModel
  • Line 9 in file Allrun.sh determines how many processors will be used for the simulation
  • Line 11 sets end time of the simulation in seconds
  • Line 13 defines a snap shot interval (how often the intermediate results are stored)
  • Line 15 selects the pre-defined radiation model
  • Lines 18-22 check if user uses compatible OpenFOAM version
  • Line 27 runs makeMesh.sh script which generates a mesh
  • Line 32 starts runCalculation.sh script runs a calculation

Subsections