OpenFOAM: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
No edit summary
(Compute Canada -> Alliance)
 
(15 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Draft}}
<languages/>
<translate>
 
<!--T:1-->
[[Category:Software]]
[[Category:Software]]
; Description: The OpenFOAM (Open Field Operation and Manipulation) CFD Toolbox is a free, open source CFD software package. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics and electromagnetics.
The [https://www.openfoam.com/ OpenFOAM] (Open Field Operation and Manipulation) CFD Toolbox is a free, open source software package for computational fluid dynamics. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics and electromagnetics.
; Modulefile: <code>openfoam</code>
 
; Documentation: [http://www.openfoam.com OpenFOAM homepage] and [http://www.openfoam.org/docs/user/tutorials.php Tutorials].
===Module files=== <!--T:2-->
; Usage:  
To load the recent version, run
: OpenFOAM requires substantial preparation of your environment. In order to run OpenFOAM commands (such as <code>paraFoam</code>, <code>blockMesh</code>, etc), you must load a [[Using modules| modulefile]] followed by sourcing a configuration script.
{{Command|module load openfoam}}
: Here is an example of a serial submission script for OpenFOAM 5.0:
 
<pre>
<!--T:3-->
The OpenFOAM development community consists of:
* The OpenFOAM Foundation Ltd., with web sites [https://openfoam.org/ openfoam.org] and [https://cfd.direct/ cfd.direct]
* OpenCFD Ltd., with web site [https://www.openfoam.com/ openfoam.com]
Up to version 2.3.1, released in December 2014, the release histories appear to be the same. On our clusters, module names after 2.3.1 which begin with "v" are derived from the .com branch (for example, <tt>openfoam/v1706</tt>); those beginning with a digit are derived from the .org branch (for example, <tt>openfoam/4.1</tt>).
 
<!--T:4-->
See [[Utiliser_des_modules/en| Using modules]] for more on module commands.
 
===Documentation=== <!--T:5-->
[https://www.openfoam.com/documentation/ OpenFOAM.com documentation] and [https://cfd.direct/openfoam/user-guide/ CFD Direct user guide].
 
===Usage=== <!--T:6-->
OpenFOAM requires substantial preparation of your environment. In order to run OpenFOAM commands (such as <code>paraFoam</code>, <code>blockMesh</code>, etc), you must load a [[Using modules| module file]].
 
<!--T:7-->
Here is an example of a serial submission script for OpenFOAM 5.0:
{{File
  |name=submit.sh
  |lang="bash"
  |contents=
#!/bin/bash
#!/bin/bash
#SBATCH --time=00:01:00
#SBATCH --time=00:01:00
#SBATCH --account=def-someuser
#SBATCH --account=def-someuser


<!--T:8-->
module purge
module purge
module load openfoam/5.0
module load openfoam/5.0
source $FOAM_ETC/bashrc


<!--T:9-->
blockMesh
blockMesh
icoFoam
icoFoam
</pre>
}}


: Here is an example of a parallel submission script for OpenFOAM 2.3.0:
<!--T:10-->
<pre>
Here is an example of a parallel submission script:
{{File
  |name=submit.sh
  |lang="bash"
  |contents=
#!/bin/bash
#!/bin/bash
#SBATCH --account=def-someuser
#SBATCH --account=def-someuser
Line 28: Line 56:
#SBATCH --time=0-00:10          # time (DD-HH:MM)
#SBATCH --time=0-00:10          # time (DD-HH:MM)


<!--T:11-->
module purge
module purge
module load openfoam/5.0
module load openfoam/5.0
source $FOAM_ETC/bashrc


decomposePar
<!--T:12-->
blockMesh
blockMesh
setFields
setFields
decomposePar
srun interFoam -parallel
srun interFoam -parallel
</pre>
}}
 
<!--T:13-->
Mesh preparation (<code>blockMesh</code>) may be fast enough to be done at the command line (see [[Running jobs]]).  The solver (<code>icoFoam</code> and others) is usually the most expensive step and should always be submitted as a Slurm job except in very small test cases or tutorials.
 
=== Segfaults with OpenMPI 3.1.2 === <!--T:16-->
 
<!--T:17-->
Users have reported random segfaults on Cedar when using OpenFOAM versions compiled for OpenMPI 3.1.2 in single-node jobs (shared memory communication). These issues seem not to happen with other versions of OpenMPI. If you experience such problems, first try to use an OpenMPI 2.1.1-based toolchain. For example:
 
<!--T:18-->
{{Commands
|module load gcc/5.4.0
|module load openmpi/2.1.1
|module load openfoam/7
}}
 
===Performance=== <!--T:14-->
OpenFOAM can emit a lot of debugging information in very frequent small writes (e.g. hundreds per second). This may lead to poor performance on our shared filesystems. If you are in stable production and don't need the debug output, you can reduce or disable it with:
{{Commands
|mkdir -p $HOME/.OpenFOAM/$WM_PROJECT_VERSION
|cp $WM_PROJECT_DIR/etc/controlDict $HOME/.OpenFOAM/$WM_PROJECT_VERSION/
}}
There are a variety of other parameters which can be used to reduce the amount of output that OpenFOAM writes to disk as well as the frequency; these run-time parameters are documented for [https://cfd.direct/openfoam/user-guide/v6-controldict/ version 6] and [https://cfd.direct/openfoam/user-guide/v7-controldict/ version 7].


: Mesh preparation (<code>blockMesh</code>) may be fast enough to be done at the command line (see [[Running jobs]]).  The solver (<code>icoFoam</code> and others) is usually the most expensive step and should always be submitted as a Slurm job except in very small test cases or tutorials.
<!--T:19-->
For example, the <code>debugSwitches</code> dictionary in <code>$HOME/.OpenFOAM/$WM_PROJECT_VERSION/controlDict</code> can be altered to change the flags from values greater than zero to zero. Another solution would be to make use of the local scratch (<tt>$SLURM_TMPDIR</tt>), a disk attached directly to the compute node, discussed [[Handling_large_collections_of_files#Local_disk|here]].


; Performance:
</translate>
: OpenFOAM can emit a lot of debugging information in very frequent small writes (e.g. hundreds per second). This may lead to poor performance on our network file systems. If you are in stable production and don't need the debug output, you can reduce or disable it with:
<pre>
$ mkdir -p $HOME/.OpenFOAM/$WM_PROJECT_VERSION
$ cp $WM_PROJECT_DIR/etc/controlDict $HOME/.OpenFOAM/$WM_PROJECT_VERSION/
</pre>
: followed by editing the <code>debugSwitches</code> dictionary in <code>$HOME/.OpenFOAM/$WM_PROJECT_VERSION/controlDict</code>, changing flags from values >0 to 0.  ''(Contribution from C. Lane)''

Latest revision as of 14:25, 26 August 2022

Other languages:

The OpenFOAM (Open Field Operation and Manipulation) CFD Toolbox is a free, open source software package for computational fluid dynamics. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics and electromagnetics.

Module files[edit]

To load the recent version, run

Question.png
[name@server ~]$ module load openfoam

The OpenFOAM development community consists of:

Up to version 2.3.1, released in December 2014, the release histories appear to be the same. On our clusters, module names after 2.3.1 which begin with "v" are derived from the .com branch (for example, openfoam/v1706); those beginning with a digit are derived from the .org branch (for example, openfoam/4.1).

See Using modules for more on module commands.

Documentation[edit]

OpenFOAM.com documentation and CFD Direct user guide.

Usage[edit]

OpenFOAM requires substantial preparation of your environment. In order to run OpenFOAM commands (such as paraFoam, blockMesh, etc), you must load a module file.

Here is an example of a serial submission script for OpenFOAM 5.0:

File : submit.sh

#!/bin/bash
#SBATCH --time=00:01:00
#SBATCH --account=def-someuser

module purge
module load openfoam/5.0

blockMesh
icoFoam


Here is an example of a parallel submission script:

File : submit.sh

#!/bin/bash
#SBATCH --account=def-someuser
#SBATCH --ntasks=4               # number of MPI processes
#SBATCH --mem-per-cpu=1024M      # memory; default unit is megabytes
#SBATCH --time=0-00:10           # time (DD-HH:MM)

module purge
module load openfoam/5.0

blockMesh
setFields
decomposePar
srun interFoam -parallel


Mesh preparation (blockMesh) may be fast enough to be done at the command line (see Running jobs). The solver (icoFoam and others) is usually the most expensive step and should always be submitted as a Slurm job except in very small test cases or tutorials.

Segfaults with OpenMPI 3.1.2[edit]

Users have reported random segfaults on Cedar when using OpenFOAM versions compiled for OpenMPI 3.1.2 in single-node jobs (shared memory communication). These issues seem not to happen with other versions of OpenMPI. If you experience such problems, first try to use an OpenMPI 2.1.1-based toolchain. For example:

[name@server ~]$ module load gcc/5.4.0
[name@server ~]$ module load openmpi/2.1.1
[name@server ~]$ module load openfoam/7


Performance[edit]

OpenFOAM can emit a lot of debugging information in very frequent small writes (e.g. hundreds per second). This may lead to poor performance on our shared filesystems. If you are in stable production and don't need the debug output, you can reduce or disable it with:

[name@server ~]$ mkdir -p $HOME/.OpenFOAM/$WM_PROJECT_VERSION
[name@server ~]$ cp $WM_PROJECT_DIR/etc/controlDict $HOME/.OpenFOAM/$WM_PROJECT_VERSION/

There are a variety of other parameters which can be used to reduce the amount of output that OpenFOAM writes to disk as well as the frequency; these run-time parameters are documented for version 6 and version 7.

For example, the debugSwitches dictionary in $HOME/.OpenFOAM/$WM_PROJECT_VERSION/controlDict can be altered to change the flags from values greater than zero to zero. Another solution would be to make use of the local scratch ($SLURM_TMPDIR), a disk attached directly to the compute node, discussed here.