Newer
Older
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
## Introduction
[OpenFOAM][a] is a free, open source CFD software package developed by [OpenCFD Ltd][b] at [ESI Group][c] and distributed by the [OpenFOAM Foundation][d]. It has a large user base across most areas of engineering and science from both commercial and academic organizations.
### Installed Version
Currently, several versions are available compiled by GCC/ICC compilers in single/double precision with several versions of OpenMPI.
The naming convention of the installed versions is:
`openfoam/<VERSION>-<COMPILER>-<openmpiVERSION>-<PRECISION>`
* `VERSION` - version of openfoam
* `COMPILER` - version of used compiler
* `openmpiVERSION` - version of used openmpi/impi
* `PRECISION` - DP/SP – double/single precision
Example of the available OpenFOAM modules syntax is `openfoam/2.2.1-icc-openmpi1.6.5-DP`
This means OpenFOAM version 2.2.1 compiled by the ICC compiler with openmpi1.6.5 in double precision.
### Available OpenFOAM Modules
To check the available modules, use:
```console
$ ml av
```
In /opt/modules/modulefiles/engineering, you can see the installed engineering softwares:
```console
------------------------------------ /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 on how to use modules, look [here][1].
## Getting Started
To create OpenFOAM environment on Anselm, use the commands:
```console
$ ml openfoam/2.2.1-icc-openmpi1.6.5-DP
$ source $FOAM_BASHRC
```
!!! note
Load the correct module with your requirements “compiler - GCC/ICC, precision - DP/SP”.
Create a project directory within the $HOME/OpenFOAM directory named `<USER>-<OFversion>` and create a directory named `run` within it:
```console
$ mkdir -p $FOAM_RUN
```
The project directory is now available by typing:
```console
$ cd /home/<USER>/OpenFOAM/<USER>-<OFversion>/run
```
`<OFversion>` - for example `2.2.1`
or
```console
$ cd $FOAM_RUN
```
Copy the tutorial examples directory in the OpenFOAM distribution to the run directory:
```console
$ 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 test.sh Bash script:
```bash
#!/bin/bash
ml 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 (example for Anselm):
```console
$ qsub -A OPEN-0-0 -q qprod -l select=1:ncpus=16,walltime=03:00:00 test.sh
```
For information about job submission, look [here][2].
## Running Applications in Parallel
Run the second case, for example external incompressible turbulent flow - case - motorBike.
First we must run the serial application bockMesh and decomposePar for preparation of parallel computation.
!!! note
Create a test.sh Bash scrip:
```bash
#!/bin/bash
ml 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
```console
$ qsub -A OPEN-0-0 -q qprod -l select=1:ncpus=16,walltime=03:00:00 test.sh
```
This job creates a simple block mesh and domain decomposition. Check your decomposition and submit parallel computation:
!!! note
Create a testParallel.pbs PBS script:
```bash
#!/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
ml 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` – the number of subdomains
Job submission
```console
$ qsub testParallel.pbs
```
## Compile Your Own Solver
Initialize the OpenFOAM environment before compiling your solver:
```console
$ ml openfoam/2.2.1-icc-openmpi1.6.5-DP
$ source $FOAM_BASHRC
$ cd $FOAM_RUN/
```
Create the applications/solvers directory in the user directory:
```console
$ mkdir -p applications/solvers
$ cd applications/solvers
```
Copy icoFoam solver’s source files:
```console
$ cp -r $FOAM_SOLVERS/incompressible/icoFoam/ My_icoFoam
$ cd My_icoFoam
```
Rename icoFoam.C to My_icoFOAM.C:
```console
$ mv icoFoam.C My_icoFoam.C
```
Edit the _files_ file in the _Make_ directory:
```bash
icoFoam.C
EXE = $(FOAM_APPBIN)/icoFoam
```
and change to:
```bash
My_icoFoam.C
EXE = $(FOAM_USER_APPBIN)/My_icoFoam
```
In the My_icoFoam directory, use the compilation command:
```console
$ wmake
```
[1]: ../../environment-and-modules.md
[2]: ../../general/job-submission-and-execution.md
[a]: http://www.openfoam.com/
[b]: http://www.openfoam.com/about
[c]: http://www.esi-group.com/
[d]: http://www.openfoam.org/