BUILD.md 20.2 KB
Newer Older
1 2 3 4 5
<!--
   |--------------------------------------------------------------------------|
   | =========                 |                                              |
   | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox        |
   |  \\    /   O peration     |                                              |
mark's avatar
mark committed
6
   |   \\  /    A nd           | Copyright (C) 2016-2017 OpenCFD Ltd.         |
7 8 9 10 11 12 13 14 15 16 17 18 19 20
   |    \\/     M anipulation  |                                              |
   |--------------------------------------------------------------------------|
  -->

---

# OpenFOAM&reg; ThirdParty Build

OpenFOAM depends to a certain extent on third-party libraries
(*opensource only*). It also provides some interfaces to *opensource* or
*proprietary* libraries. This third-party package contains configurations and
scripts for building third-party packages. It should normally only be used in
conjunction with the corresponding OpenFOAM version.

21
## Organization
22

23 24
The ThirdParty directory contains a number of build scripts as well as
some directories:
25

26
| Directory         | Contains
mark's avatar
mark committed
27 28
|-------------------|-------------------------------------------------------
| etc/              | auxiliary tools and content used for the build process
29 30
| build/            | intermediate build objects
| platforms/        | the installation directories
31 32


33
## Configuration of Third-Party Versions
34

35 36
For most of the build scripts, the default software version
is provided by an appropriate OpenFOAM `etc/config.sh/...` entry.
37 38 39 40
This approach avoids duplicate entries for the default versions and
ensures the best overall consistency between the OpenFOAM installation
and its corresponding third-party installation.

41 42 43 44 45 46 47
Nonethess, the distributed make scripts can generally be used for a
variety of versions of the third-party libraries, with the software
version specified on the command-line. For example,

    $ ./makeFFTW -help
    usage: makeFFTW [OPTION] [fftw-VERSION]

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
---

## Before Starting

0. Review the [system requirements](http://www.openfoam.com/documentation/system-requirements.php)
   and decide on the following:
   * compiler type/version - if the system compiler is not relatively recent,
     you will need a [third-party compiler](#makeGcc) installation.
   * MPI type/version.
   * ParaView type/version.
   * CMake type/version, ...
1. If you are using a system MPI (eg, openmpi), ensure that this environment
   has also been properly activated for your user.
   Often (but not always) a `mpi-selector` command is available for this purpose.
   You may need to open a new shell afterwards for the change to take effect.
   Using the following command may help diagnosing things:

       which mpicc

2. Adjust the OpenFOAM `etc/bashrc`, `etc/config.sh/...` or equivalent
   `prefs.sh` files to reflect your preferred configuration.
   For many config files, there are several configuration possibilities:
   - Define a particular third-party version.
   - Use a system installation.
   - Disable use of an optional component.
   - Define an alternative site-wide central location.
   - After making the desired changes, use `wmRefresh` or equivalent to use the configurations.


---

## Building

Many components of ThirdParty are *optional* or are invoked
automatically as part of the top-level OpenFOAM `Allwmake`.
Nonetheless it may be necessary or useful to build various
ThirdParty components prior to building OpenFOAM itself.

86
### Bootstrapping *(optional)*
87

88
* `makeGcc` _or_ `makeLLVM` <a name="makeGcc"></a>
89 90 91 92 93 94 95
   - Makes a third-party [gcc](#gcc-compiler) or [clang](#clang-compiler) installation,
     which is needed if the system gcc is [too old](#gcc-compiler).
     If your system compiler is recent enough, you can skip this step.
   - If you do use this option, you will need the following adjustments to the
     OpenFOAM `etc/bashrc` or your equivalent `prefs.sh` file:
     - `WM_COMPILER_TYPE=ThirdParty`
     - `WM_COMPILER=Gcc48` (for example)
96 97
     - `WM_COMPILER=Clang40` (for example)
     - or `WM_COMPILER=Clang` and adjust `clang_version` in the OpenFOAM
98 99 100 101 102
     `etc/config.sh/compiler` or equivalent.
   - More description is contained in the header comments of the
     `makeGcc` and `makeLLVM` files.
   - *Attention*: If you are building a newer version of clang, you may need to
     update your CMake beforehand.
103
* `makeCmake`
104 105 106 107 108
   - Makes a third-party [CMake](#general-packages) installation, which is
     needed if a system CMake does not exist or is [too old](#min-cmake),
   - Note that CMake is being used by an number of third-party packages
     (CGAL, LLVM, ParaView, VTK, ...)
     so this may become an increasingly important aspect of the build.
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

Note that the order of the bootstrapping process may need to be
reversed, or even require a few loops. For example, if you may need a
newer version of CMake before being able to build LLVM/Clang and
subsequently use the newly build clang to create a newer version of
CMake in the desired location.

Additionally, if you are using clang but with ThirdParty locations for
gmp/mpfr you will need some extra work. Here is an example:

* Compile a new ThirdParty clang version:

      ./makeLLVM llvm-4.0.1

* Now adjust the OpenFOAM `prefs.sh` to use the new compiler settings,
  and update the OpenFOAM environment (eg, `wmRefresh`)

* Next use (abuse) the `makeGcc` script to compile gmp/mpfr libraries.
  It is best to pass the desired versions explicitly, and necessary
  to set the CC/CXX variables so that the correct compiler is used:

      CC=clang CXX=clang++  ./makeGcc gmp-6.1.2 mpfr-4.0.0 gcc-system

  specifying `gcc-system` effectively disables building of gcc,
  but will build the gmp/mpfr components.

* As a final step, it will be necessary to add the ThirdParty
  gmp/mpfr locations in the OpenFOAM config files since they are
  normally only used in combination with a ThirdParty gcc.
  The location to make these changes is in the `etc/config.sh/CGAL`,
  since this is the component that uses the mpfr library.
  For example,

      gmp_version=gmp-6.1.2
      mpfr_version=mpfr-4.0.0

      export GMP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$gmp_version
      export GMP_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$mpfr_version

* Update update the OpenFOAM environment (eg, `wmRefresh`) again.


### Build Sequence

1. `Allwmake`
154 155 156
   - This will be automatically invoked by the top-level OpenFOAM `Allwmake`, but
     can also be invoked directly to find possible build errors.
   - Builds an mpi library (openmpi or mpich), scotch decomposition, boost, CGAL, FFTW.
157
   - If the optional kahip or metis  directories are found, they will also be compiled.
158
2. `makeParaView`  *(optional but highly recommended)*
159 160 161 162 163
   - This is optional, but extremely useful for visualization and for
     run-time post-processing function objects.
     You can build this at a later point in time, but then you should
     remember to rebuild the post-processing function objects and the
     reader module as well.
164
3. Make any additional optional components
165 166 167 168


#### Optional Components

mark's avatar
mark committed
169
`makeADIOS`
170
- Only required for [ADIOS](#parallel) support,
mark's avatar
mark committed
171 172
  which is currently staged in the [add-ons repository][link AddOns].

173
`makeCGAL`
174
- Builds [boost](#general-packages) and [CGAL](#general-packages).
175 176 177 178
  Automatically invoked from the ThirdParty `Allwmake`,
  but can be invoked directly to resolve possible build errors.

`makeFFTW`
179 180 181 182 183 184 185 186 187 188 189
- Builds [FFTW](#general-packages).
  Automatically invoked from the ThirdParty `Allwmake`,
  but can be invoked directly to resolve possible build errors.

`makeKAHIP`
- Builds [KaHIP](#parallel) decomposition library.
  Automatically invoked from the ThirdParty `Allwmake`,
  but can be invoked directly to resolve possible build errors.

`makeMETIS`
- Builds [METIS](#parallel) decomposition library.
190 191 192
  Automatically invoked from the ThirdParty `Allwmake`,
  but can be invoked directly to resolve possible build errors.

mark's avatar
mark committed
193 194 195
`makeMGridGen`
- Optional agglomeration routines.

196 197 198 199 200 201 202 203 204
`makeCCMIO`
- Only required for conversion to/from STARCD/STARCCM+ files.

`makeTecio`
- Only required for conversion of results to Tecplot format.

`makeMesa`, `makeVTK`
- Additional support for building offscreen rendering components.
  Useful if you want to render on computer servers without graphics cards.
205
  The `makeParaView.example` and `makeVTK.example` files offer some
206 207 208
  suggestions about compiling such a configuration.

`makeQt`
209
- Script to build a [Qt](#makeQt), including qmake.
210
- Possibly needed for `makeParaView`.
mark's avatar
mark committed
211 212
- The associated `etc/relocateQt` may be of independent use.
  Read the file for more details.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227

`makeGperftools`
- Build gperftools (originally Google Performance Tools)

`minCmake`
- Scour specified directories for CMakeLists.txt and their cmake_minimum.
  Report in sorted order.

`Allclean`
- After building, this script may be used to remove intermediate build information
and save some disk space.


## Build Notes

228 229 230
### CGAL
- The zlib library and zlib development headers are required.

231 232 233 234 235 236
### Scotch
- The zlib library and zlib development headers are required.


### Mesa
- Needed for off-screen rendering.
237 238
- Building with [mesa-11][older11 mesa] and [mesa-13][older13 mesa] both
  seem okay, as does building with [mesa-17][link mesa].
239 240 241 242 243 244 245 246 247 248
- Building with mesa-12 is not possible since it fails to create
  the necessary `include/GL` directory and `osmesa.h` file.

### VTK
- Needed for off-screen rendering and run-time post-processing without
  ParaView.
- Rather than downloading VTK separately, it is easy to reuse the VTK
  sources that are bundled with ParaView.
  For example, by using a symbolic link:

Mark Olesen's avatar
Mark Olesen committed
249
      ln -s ParaView-v5.4.1/VTK VTK-8.1.0
250 251 252 253 254

  The appropriate VTK version number can be found from the contents of
  the `vtkVersion.cmake` file.
  For example,

Mark Olesen's avatar
Mark Olesen committed
255
      $ cat ParaView-v5.4.1/VTK/CMake/vtkVersion.cmake
256 257

      # VTK version number components.
258
      set(VTK_MAJOR_VERSION 8)
259 260 261 262 263 264 265 266 267
      set(VTK_MINOR_VERSION 1)
      set(VTK_BUILD_VERSION 0)

### ParaView
- Building ParaView requires CMake, qmake and a `qt` development files.
  Use the `-cmake`, `-qmake` and `-qt-*` options for `makeParaView` as
  required.
  See additional notes below about [making Qt](#makeQt) if necessary.

Mark Olesen's avatar
Mark Olesen committed
268
#### 5.4.x
269 270 271
- Compiles without patching.
  No known issues with the native OpenFOAM reader.

272 273
#### 5.3.0 and older are neither recommended nor supported
- Various compilation issues and known bugs.
274

mark's avatar
mark committed
275 276 277 278 279 280 281 282 283
### ADIOS
- The github release currently requires GNU autoconf tools (eg,
  autoconf, autoheader, automake) for its configuration.
- Some inconsistency in directory names (ADIOS vs. adios) between releases.
- Optionally uses bzip2, zlib development headers (eg, libbz2-devel, zlib-devel)
  for the corresponding compression tranforms.
- The [zfp floating point compression][page zfp] library is now included as
  part of ADIOS.

284 285 286 287 288 289 290 291 292 293 294 295
### Making Qt <a name="makeQt"></a>
- Building a third-party Qt installation (prior to building ParaView) requires
  some additional effort, but should nonetheless work smoothly.

1. Download a [*qt-everywhere-opensource-src*][link Qt] package and
   unpack in the third-party directory.
2. Use the `makeQt` script with the QT version number. For example,

       ./makeQt 4.8.7

3. Build ParaView using this third-party QT. For example,

296
       ./makeParaView -qt-4.8.7 5.4.1
297

298
- ParaView versions prior to 5.3.0 do not properly support QT5.
299 300 301 302 303 304 305 306 307 308 309 310 311 312

- If you relocate the third-party directory to another location
  (eg, you built in your home directory, but want to install it in a
  central location), you will need to use the `etc/relocateQt` script
  afterwards.

---

## Versions

### Gcc Compiler <a name="gcc-compiler"></a>

The minimum version of gcc required is 4.8.0.

313 314 315 316 317 318
| Name              | Location
|-------------------|--------------------------------------------
| [gcc][page gcc]   | [releases][link gcc]
| [gmp][page gmp]   | system is often ok, otherwise [download][link gmp]
| [mpfr][page mpfr] | system is often ok, otherwise [download][link mpfr]
| [mpc][page mpc]   | system is often ok, otherwise [download][link mpc]
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344


#### Potential MPFR conflicts

If you elect to use a third-party version of mpfr, you may experience
conflicts with your installed system mpfr.
On some systems, mpfr is compiled as *non-threaded*, whereas the
third-party will use *threaded* by default.
This can cause some confusion at the linker stage, since it may
resolve the system mpfr first (and find that it is *non-threaded*).

You can avoid this by one of two means:
1. Use system components for gmp/mpfr/mpc:  `makeGcc -system ...`
2. Use third-party mpfr, but without threading: `makeGcc -no-threadsafe ...`


#### 32-bit build (on 64-bit)

If you have a 64-bit system, but wish to have a 32-bit compiler, you
will need to enable multi-lib support for Gcc: `makeGcc -multilib`,
which is normally disabled, since many (most?) 64-bit systems do not
install the 32-bit development libraries by default.


### Clang Compiler <a name="clang-compiler"></a>

345
The minimum version of clang required is 3.5.
346 347

*Attention*: If you are building a newer version of clang, you may need to
348 349 350 351 352 353
update your CMake beforehand since GNU *configure* can only be used prior
to clang version 3.9.

If your system gcc is particularly old
(see [minimum gcc requirements for clang](#min-gcc))
you may have additional hurdles to using the newest versions of clang.
354 355


356 357
| Name                  | Location
|-----------------------|------------------------
Mark Olesen's avatar
Mark Olesen committed
358 359 360
| [clang][page clang]   | [download][link clang] or [newer][newer clang]
| [llvm][page llvm]     | [download][link llvm] or [newer][newer llvm]
| [openmp][page omp]    | [download][link omp] or [newer][newer omp]
361 362 363 364


### General <a name="general-packages"></a>

365 366 367 368
| Name                  | Location
|-----------------------|------------------------
| [CMake][page cmake]   | [download][link cmake]
| [boost][page boost]   | [download][link boost]
369
| [CGAL][page CGAL]     | [download][link CGAL]
370 371 372 373
| [FFTW][page FFTW]     | [download][link FFTW]
| [ADF/CGNS][page CGNS], ccm | [link ccmio][link ccmio]
| [tecio][page tecio]   | [link tecio][link tecio]
| gperftools            | [repo][repo gperftools] or [download][link gperftools]
374 375


376 377 378 379 380 381 382 383 384 385 386
### Parallel Processing <a name="parallel"></a>

| Name                  | Location
|-----------------------|------------------------
| [openmpi][page openmpi] | [download][link openmpi]. The newer [openmpi][newer openmpi] make exhibit stability issues.
| [adios][page adios]   | [repo][repo adios] or [github download][link adios] or [alt download][altlink adios]
| [scotch, ptscotch][page scotch] | [download][link scotch]
| [kahip][page kahip] | [download][link kahip]
| [metis][page metis] | [download][link metis]


387 388
### Visualization <a name="viz-version"></a>

389 390
| Name                  | Location
|-----------------------|------------------------
391
| [MESA][page mesa]     | [download][link mesa] or [older 13][older13 mesa], [older 11][older11 mesa]
392
| [ParaView][page ParaView] | [download][link ParaView]
Mark Olesen's avatar
Mark Olesen committed
393
| [Qt][page Qt]         | Either the [older QT4][link Qt4] or the [newer QT5][link Qt5], which only works with ParaView-5.3.0 and later.
394 395 396 397 398 399 400 401


### CMake Minimum Requirements <a name="min-cmake"></a>

The minimum CMake requirements for building various components.

    2.8         llvm-3.4.2
    2.8.11      CGAL-4.9
Mark Olesen's avatar
Mark Olesen committed
402
    2.8.11      CGAL-4.11
mark's avatar
mark committed
403
    2.8.12.2    llvm-3.7.0
404 405
    2.8.12.2    llvm-3.8.0
    2.8.4       cmake-3.6.0
Mark Olesen's avatar
Mark Olesen committed
406
    3.3         ParaView-5.4.1
407
    3.4.3       llvm-3.9.1
408
    3.4.3       llvm-4.0.0
409 410


411 412 413 414 415 416 417 418 419
### GCC Minimum Requirements <a name="min-gcc"></a>

The minimum gcc/g++ requirements for building various components.

    4.7         llvm-3.7.0
    4.7         llvm-3.6.2
    4.7         llvm-3.5.2
    4.4         llvm-3.4.2

420 421 422 423
If your system gcc/g++ is too old to build the desired llvm/clang
version, you may need to build a lower llvm/clang version and then use
that clang compiler for building the newer llvm/clang version.

424

425 426 427 428 429 430 431 432 433 434 435 436 437 438
<!-- gcc-related -->
[page gcc]:       http://gcc.gnu.org/releases.html
[page gmp]:       http://gmplib.org/
[page mpfr]:      http://www.mpfr.org/
[page mpc]:       http://www.multiprecision.org/

[link gcc]:       http://gcc.gnu.org/releases.html
[link gmp]:       ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2
[link mpfr]:      ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2
[link mpc]:       ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz


<!-- clang-related -->
[page llvm]:      http://llvm.org/
Mark Olesen's avatar
Mark Olesen committed
439 440
[page clang]:     http://clang.llvm.org/
[page omp]:       http://openmp.llvm.org/
441

442 443
[link clang]:     http://llvm.org/releases/3.7.1/cfe-3.7.1.src.tar.xz
[link llvm]:      http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz
Mark Olesen's avatar
Mark Olesen committed
444
[link omp]:       http://llvm.org/releases/3.7.1/openmp-3.7.1.src.tar.xz
mark's avatar
mark committed
445

Mark Olesen's avatar
Mark Olesen committed
446 447 448
[newer clang]:    http://llvm.org/releases/4.0.1/cfe-4.0.1.src.tar.xz
[newer llvm]:     http://llvm.org/releases/4.0.1/llvm-4.0.1.src.tar.xz
[newer omp]:      http://llvm.org/releases/4.0.1/openmp-4.0.1.src.tar.xz
449 450 451 452 453


<!-- parallel -->
[page adios]:     https://www.olcf.ornl.gov/center-projects/adios/
[repo adios]:     https://github.com/ornladios/ADIOS
Mark Olesen's avatar
Mark Olesen committed
454 455
[link adios]:     https://github.com/ornladios/ADIOS/archive/v1.13.0.tar.gz
[altlink adios]:  http://users.nccs.gov/%7Epnorbert/adios-1.13.0.tar.gz
456 457 458 459 460
[page zfp]:       http://computation.llnl.gov/projects/floating-point-compression/zfp-versions

[page scotch]:    https://www.labri.fr/perso/pelegrin/scotch/
[link scotch]:    https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz

461 462 463 464 465 466
[page kahip]:     http://algo2.iti.kit.edu/documents/kahip/
[link kahip]:     http://algo2.iti.kit.edu/schulz/software_releases/KaHIP_2.00.tar.gz

[page metis]:     http://glaros.dtc.umn.edu/gkhome/metis/metis/overview
[link metis]:     http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz

467
[page openmpi]:   http://www.open-mpi.org/
Mark Olesen's avatar
Mark Olesen committed
468 469
[link openmpi]:   https://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.4.tar.bz2
[newer openmpi]:  https://www.open-mpi.org/software/ompi/v2.1/downloads/openmpi-2.1.1.tar.bz2
470 471 472 473 474 475 476


<!-- general -->
[page cmake]:     http://www.cmake.org/
[link cmake]:     http://www.cmake.org/files/v3.5/cmake-3.5.2.tar.gz

[page boost]:     http://boost.org
477
[link boost]:     https://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.bz2
478 479

[page CGAL]:      http://cgal.org
480
[link CGAL]:      https://github.com/CGAL/cgal/releases/download/releases%2FCGAL-4.9.1/CGAL-4.9.1.tar.xz
481 482

[page FFTW]:      http://www.fftw.org/
Mark Olesen's avatar
Mark Olesen committed
483
[link FFTW]:      http://www.fftw.org/fftw-3.3.7.tar.gz
484 485

[page cgns]:      http://cgns.github.io/
486 487
[link ccmio]:     http://portal.nersc.gov/project/visit/third_party/libccmio-2.6.1.tar.gz (check usage conditions)
[altlink ccmio]:  http://portal.nersc.gov/svn/visit/trunk/third_party/libccmio-2.6.1.tar.gz (check usage conditions)
488 489 490 491 492 493 494 495 496 497 498

[page tecio]:     http://www.tecplot.com/
[link tecio]:     http://www.tecplot.com/my/tecio-library/ (needs registration)

[repo gperftools]: https://github.com/gperftools/gperftools
[link gperftools]: https://github.com/gperftools/gperftools/releases/download/gperftools-2.5/gperftools-2.5.tar.gz


<!-- Visualization -->

[page ParaView]:  http://www.paraview.org/
Mark Olesen's avatar
Mark Olesen committed
499
[link ParaView]:  http://www.paraview.org/files/v5.4/ParaView-v5.4.1.tar.gz
500 501

[page mesa]:  http://mesa3d.org/
502 503 504
[link mesa]:  ftp://ftp.freedesktop.org/pub/mesa/mesa-17.1.1.tar.xz
[older13 mesa]: ftp://ftp.freedesktop.org/pub/mesa/13.0.6/mesa-13.0.6.tar.xz
[older11 mesa]: ftp://ftp.freedesktop.org/pub/mesa/older-versions/11.x/11.2.2/mesa-11.2.2.tar.xz
505 506 507

[page Qt]: https://www.qt.io/download-open-source/
[repo Qt]: http://code.qt.io/cgit/qt-creator/qt-creator.git
Mark Olesen's avatar
Mark Olesen committed
508 509
[link Qt4]: http://download.qt.io/official_releases/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz
[link Qt5]: http://download.qt.io/official_releases/qt/5.9/5.9.3/single/qt-everywhere-opensource-src-5.9.3.tar.xz
510

mark's avatar
mark committed
511 512 513
<!-- OpenFOAM -->

[link AddOns]: https://develop.openfoam.com/Community/OpenFOAM-addOns
514
[link community-projects]: http://www.openfoam.com/community/projects.php
mark's avatar
mark committed
515

516
---
517 518 519 520

<!-- Standard Footer -->
## Additional OpenFOAM Links

mark's avatar
mark committed
521 522
- [Community AddOns][link AddOns] repository
- [Collaborative and Community-based Developments][link community-projects]
523 524
- [Download](http://www.openfoam.com/download) and
  [installation instructions](http://www.openfoam.com/code/build-guide.php)
525
- [Documentation](http://www.openfoam.com/documentation)
Mark Olesen's avatar
Mark Olesen committed
526
- [Reporting bugs/issues](http://www.openfoam.com/code/bug-reporting.php) (including bugs/suggestions/feature requests) in OpenFOAM
527
- [Contacting OpenCFD](http://www.openfoam.com/contact)
Mark Olesen's avatar
Mark Olesen committed
528

529 530
---

531
Copyright 2016-2018 OpenCFD Ltd