Skip to content
Snippets Groups Projects
openfoam.md 6.16 KiB
Newer Older
  • Learn to ignore specific revisions
  • Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    OpenFOAM 
    ========
    
    A free, open source CFD software package
    
      
    
    Introduction**
    ----------------
    
    OpenFOAM is a free, open source CFD software package developed
    by [**OpenCFD Ltd**](http://www.openfoam.com/about) at [**ESI
    Group**](http://www.esi-group.com/) and distributed by the [**OpenFOAM
    Foundation **](http://www.openfoam.org/). It has a large user base
    across most areas of engineering and science, from both commercial and
    academic organisations. 
    
    Homepage: <http://www.openfoam.com/>
    
    ###Installed version**
    
    Currently, several version compiled by GCC/ICC compilers in
    single/double precision with several version of openmpi are available on
    Anselm.
    
    For example syntax of available OpenFOAM module is:
    
    &lt; openfoam/2.2.1-icc-openmpi1.6.5-DP &gt;
    
    this means openfoam version >2.2.1 compiled by
    ICC compiler with >openmpi1.6.5 in> double
    precision.
    
    Naming convection of the installed versions is following:
    
       
    openfoam/&lt;>VERSION>&gt;-&lt;>COMPILER<span>&gt;-&lt;</span><span>openmpiVERSION</span><span>&gt;-&lt;</span><span>PRECISION</span><span>&gt;</span>
    
    -   >&lt;>VERSION>&gt; - version of
        openfoam
    -   >&lt;>COMPILER&gt; - version of used
        compiler
    -   >&lt;>openmpiVERSION&gt; - version of used
        openmpi/impi
    -   >&lt;>PRECISION&gt; - DP/>SP –
        double/single precision
    
    ###Available OpenFOAM modules**
    
    To check available modules use
    
        $ module avail
    
    In /opt/modules/modulefiles/engineering you can see installed
    engineering softwares:
    
        ------------------------------------ /opt/modules/modulefiles/engineering -------------------------------------------------------------
        ansys/14.5.x               matlab/R2013a-COM                                openfoam/2.2.1-icc-impi4.1.1.036-DP
        comsol/43b-COM             matlab/R2013a-EDU                                openfoam/2.2.1-icc-openmpi1.6.5-DP
        comsol/43b-EDU             openfoam/2.2.1-gcc481-openmpi1.6.5-DP            paraview/4.0.1-gcc481-bullxmpi1.2.4.1-osmesa10.0
        lsdyna/7.x.x               openfoam/2.2.1-gcc481-openmpi1.6.5-SP
    
    For information how to use modules please [look
    here](../environment-and-modules.html "Environment and Modules ").
    
    Getting Started**
    -------------------
    
    To create OpenFOAM environment on ANSELM give the commands:
    
        $ module load openfoam/2.2.1-icc-openmpi1.6.5-DP
    
        $ source $FOAM_BASHRC
    
    Pleas load correct module with your requirements “compiler - GCC/ICC,
    precision - DP/SP”.
    
    Create a project directory within the $HOME/OpenFOAM directory
    named >&lt;USER&gt;-&lt;OFversion&gt; and create a directory
    named run within it, e.g. by typing:
    
        $ mkdir -p $FOAM_RUN
    
    Project directory is now available by typing:
    
        $ cd /home/<USER>/OpenFOAM/<USER>-<OFversion>/run
    
    &lt;OFversion&gt; - for example &lt;2.2.1&gt;
    
    or
    
        $ cd $FOAM_RUN
    
    Copy the tutorial examples directory in the OpenFOAM distribution to
    the run directory:
    
        $ cp -r $FOAM_TUTORIALS $FOAM_RUN
    
    Now you can run the first case for example incompressible laminar flow
    in a cavity.
    
    Running Serial Applications**
    -------------------------------
    
    Create a Bash script >test.sh 
    
     
        #!/bin/bash
        module load openfoam/2.2.1-icc-openmpi1.6.5-DP
        source $FOAM_BASHRC
    
        # source to run functions
        . $WM_PROJECT_DIR/bin/tools/RunFunctions
    
        cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity
    
        runApplication blockMesh
        runApplication icoFoam
    
     
    
     
    
    Job submission
    
     
        $ qsub -A OPEN-0-0 -q qprod -l select=1:ncpus=16,walltime=03:00:00 test.sh
    
     
    
     For information about job submission please [look
    here](../resource-allocation-and-job-execution/job-submission-and-execution.html "Job submission").
    
    Running applications in parallel**
    -------------------------------------------------
    
    Run the second case for example external incompressible turbulent
    flow - case - motorBike.
    
    First we must run serial application bockMesh and decomposePar for
    preparation of parallel computation.
    
    Create a Bash scrip test.sh:
    
     
        #!/bin/bash
        module load openfoam/2.2.1-icc-openmpi1.6.5-DP
        source $FOAM_BASHRC
    
        # source to run functions
        . $WM_PROJECT_DIR/bin/tools/RunFunctions
    
        cd $FOAM_RUN/tutorials/incompressible/simpleFoam/motorBike
    
        runApplication blockMesh
        runApplication decomposePar
    
     
    
    Job submission
    
     
        $ qsub -A OPEN-0-0 -q qprod -l select=1:ncpus=16,walltime=03:00:00 test.sh
    
     
    
    This job create simple block mesh and domain decomposition.
    Check your decomposition, and submit parallel computation:
    
    Create a PBS script>
    testParallel.pbs:
    
     
        #!/bin/bash
        #PBS -N motorBike
        #PBS -l select=2:ncpus=16
        #PBS -l walltime=01:00:00
        #PBS -q qprod
        #PBS -A OPEN-0-0
    
        module load openfoam/2.2.1-icc-openmpi1.6.5-DP
        source $FOAM_BASHRC
    
        cd $FOAM_RUN/tutorials/incompressible/simpleFoam/motorBike
    
        nproc = 32
    
        mpirun -hostfile ${PBS_NODEFILE} -np $nproc snappyHexMesh -overwrite -parallel | tee snappyHexMesh.log
    
        mpirun -hostfile ${PBS_NODEFILE} -np $nproc potentialFoam -noFunctionObject-writep -parallel | tee potentialFoam.log
    
        mpirun -hostfile ${PBS_NODEFILE} -np $nproc simpleFoam -parallel | tee simpleFoam.log 
    
     
    
    nproc – number of subdomains
    
    Job submission
    
     
        $ qsub testParallel.pbs
    
     
    
    Compile your own solver**
    ----------------------------------------
    
    Initialize OpenFOAM environment before compiling your solver
    
     
        $ module load openfoam/2.2.1-icc-openmpi1.6.5-DP
        $ source $FOAM_BASHRC
        $ cd $FOAM_RUN/
    
    Create directory applications/solvers in user directory
    
     
        $ mkdir -p applications/solvers
        $ cd applications/solvers
    
     
    
    Copy icoFoam solver’s source files
    
     
        $ cp -r $FOAM_SOLVERS/incompressible/icoFoam/ My_icoFoam
        $ cd My_icoFoam
    
    Rename icoFoam.C to My_icoFOAM.C
    
     
        $ mv icoFoam.C My_icoFoam.C
    
     
    
    Edit >*files* file in *Make* directory:
    
     
        icoFoam.C
        EXE = $(FOAM_APPBIN)/icoFoam
    
    and change to:
    
        My_icoFoam.C 
        EXE = $(FOAM_USER_APPBIN)/My_icoFoam
    
    In directory My_icoFoam give the compilation command:
    
     
        $ wmake
    
    ------------------------------------------------------------------------
    
     
    
     Have a fun with OpenFOAM :)**
    
      id="__caret">