Build.md 5.8 KB
Newer Older
1
2
## Getting the code

3
Links to all code packs are available on https://dl.openfoam.com. For OpenFOAM-v2112:
4

5
6
7
- https://dl.openfoam.com/source/latest/
- Source: https://dl.openfoam.com/source/v2112/OpenFOAM-v2112.tgz
- ThirdParty: https://dl.openfoam.com/source/v2112/ThirdParty-v2112.tgz
8

9
10
## OpenFOAM® Quick Build Guide

11
Prior to building, ensure that the [system requirements][link openfoam-require]
12
are satisfied (including any special [cross-compiling][wiki-cross-compile]
13
considerations), and source the correct OpenFOAM environment.
14
For example, for the OpenFOAM-v2112 version:
15
```
16
source <installation path>/OpenFOAM-v2112/etc/bashrc
17
```
18
e.g. if installed under the `~/openfoam` directory
Andrew Heather's avatar
Andrew Heather committed
19
```
20
source ~/openfoam/OpenFOAM-v2112/etc/bashrc
Andrew Heather's avatar
Andrew Heather committed
21
22
```

23
24
25

## Preliminaries

Mark Olesen's avatar
Mark Olesen committed
26
The [third-party][repo third] directory includes a
27
28
29
30
31
[readme][link third-readme] and additional information about
[requirements][link third-require] and a more detailed
[build guide][link third-build].

Some known build issues related to specific compiler and VTK library versions
32
33
can be found in the [$WM_PROJECT_DIR/doc/BuildIssues.md][link openfoam-issues]
file.
34
35
36

If you need to change the default versions for third-party libraries,
or use system libraries for some components, please some additional
37
information about the [config structure][wiki-config].
38
39
40
41
42
43

## Compile OpenFOAM

The compilation process is self-contained and will compile and install
all OpenFOAM code and dependencies.

44
- Test the system readiness (optional, not supported for cross-compilation)
45
46
47
48
49
50
51
52
53
54
55
56
```
foamSystemCheck
```
- Change to the main OpenFOAM directory ($WM_PROJECT_DIR).
  If this fails, the environment is not correctly configured.
```
foam
```
- Compile OpenFOAM
```
./Allwmake -s -l
```
Andrew Heather's avatar
Andrew Heather committed
57
58
59
- This will start the build process, where the `-s` option is used to reduce
  the level of output, and the `-l` option to record the output in a log file.
  To see all available options use `./Allwmake -help`
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
- In case you need to stop the compilation, continue later by running
`./Allwmake` again.

## Compile OpenFOAM faster

For faster compilation, users should take advantage of multi-processor
machines when building the code. This is supported directly by `wmake`
and the `Allwmake` scripts. For example,
```
wmake -j               # Use all cores
wmake -j 8             # Use specified number of cores
```
It can also be helpful to use the builtin queuing (the `-queue`
option), which collects subdirectories and dispatches to make in
larger chunks.

The following compilation sequence can be useful:
```
./Allwmake -j -s -q -l
```
This compiles with all cores (-j), reduced output (-s, -silent), with
queuing (-q, -queue) and logs (-l, -log) the output to a file such as
`log.linux64GccDPInt32Opt` for later inspection.

If you use the `-k` option (`-keep-going` = ignore errors) to compile
as much as possible on the first pass, be certain to follow that with
second pass (without the `-k` option) at a later stage to ensure that
you haven't missed any error messages.

## Post-compilation steps

- Open a new shell and source the OpenFOAM environment to see all
  changes (refer to top of page).
93
- Validate the build (not supported for cross-compilation) by running
94
95
96
```
foamInstallationTest
```
97
- test any given tutorial case. For example,
98
```
99
foamTestTutorial -full incompressible/simpleFoam/pitzDaily
100
```
101
- Note: the tutorial test can also be done manually:
102
```
103
104
105
# Create the user "run" directory:
mkdir -p "$FOAM_RUN"
# Change to the user "run" directory:
106
run
107
108
109
110
# Copy tutorial
cp -r "$FOAM_TUTORIALS"/incompressible/simpleFoam/pitzDaily ./
# Run the tutorial
( cd pitzDaily && blockMesh && simpleFoam )
111
112
113
114
115
```

### ParaView

OpenFOAM ships with ParaView sources for post-processing OpenFOAM
116
117
field results. However, it will [often be sufficient][FAQ ParaView]
to use the paraview version distributed with
118
the operating system or a [binary package][download ParaView]
119
and avoid additional compilation complexity.
120

121
122
If you do wish to compile ParaView from source, it is recommended
that you do so ***after*** completing an initial compilation of OpenFOAM.
123
This gets the process started much more quickly. At a later stage,
124
125
the OpenFOAM visualization module can be compiled for a particular
ParaView version _without_ recompiling OpenFOAM itself.
126

127
If you decide to compile in two passes, you only need to execute the
128
129
130
131
132
133
134
135
136
137
top-level `Allwmake` a second time. Do **not** use `wclean` to force a
complete rebuild! This is unnecessary.

More details in the [ThirdParty build guide][link third-build].


------------

<!-- Links -->

138
[page ParaView]: http://www.paraview.org/
139
[download ParaView]: https://www.paraview.org/download/
140
[FAQ ParaView]: https://discourse.paraview.org/t/i-want-to-visualize-my-openfoam-simulation-results-with-paraview-but-im-confused-which-version-should-i-use
141
142
143
144


<!-- OpenFOAM -->

Mark Olesen's avatar
Mark Olesen committed
145
146
147
148
149
150
151
152
153
154
[repo openfoam]: https://develop.openfoam.com/Development/openfoam/
[repo third]: https://develop.openfoam.com/Development/ThirdParty-common/

[link openfoam-readme]: https://develop.openfoam.com/Development/openfoam/blob/develop/README.md
[link openfoam-issues]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/BuildIssues.md
[link openfoam-build]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Build.md
[link openfoam-require]: https://develop.openfoam.com/Development/openfoam/blob/develop/doc/Requirements.md
[link third-readme]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/README.md
[link third-build]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/BUILD.md
[link third-require]: https://develop.openfoam.com/Development/ThirdParty-common/blob/develop/Requirements.md
155

156
157
158
[wiki-cross-compile]: https://develop.openfoam.com/Development/openfoam/-/wikis/building/cross-compile-mingw
[wiki-config]: https://develop.openfoam.com/Development/openfoam/-/wikis/configuring

159
---
160
Copyright 2019-2021 OpenCFD Ltd