1.3 Installing from Source

This section explains how to build Nektar++ from the source-code package.

Nektar++ uses a number of third-party libraries. Some of these are required, others are optional. It is generally more straightforward to use versions of these libraries supplied pre-packaged for your operating system, but if you run into difficulties with compilation errors or failing regression tests, the Nektar++ build system can automatically build tried-and-tested versions of these libraries for you. This requires enabling the relevant options in the CMake configuration.

1.3.1 Obtaining the source code

There are two ways to obtain the source code for Nektar++:

1.3.2 Linux

1.3.2.1 Prerequisites

Nektar++ uses a number of external programs and libraries for some or all of its functionality. Some of these are required and must be installed prior to compiling Nektar++, most of which are available as pre-built system packages on most Linux distributions or can be installed manually by a user. Typically, the development packages, with a -dev or -devel suffix, are required to compile codes against these libraries. Others are optional and required only for specific features, or can be downloaded and compiled for use with Nektar++ automatically (but not installed system-wide).

Installation

Package Req. Sys. User Auto.

Note

C++ compiler

gcc, icc, etc, supporting C++11

CMake ≥ 3.5.1

Ncurses GUI optional

BLAS

Or MKL, ACML, OpenBLAS

LAPACK

Boost >= 1.56

Compile with iostreams

TinyXML

For reading XML input files

Scotch

Required for multi-level static condensation, highly recommended

METIS

Alternative mesh partitioning

FFTW > 3.0

For high-performance FFTs

ARPACK > 2.0

For arnoldi algorithms

MPI

For parallel execution (OpenMPI, MPICH, Intel MPI, etc)

GSMPI

For parallel execution

HDF5

For large-scale parallel I/O (requires CMake >3.1)

OpenCascade CE

For mesh generation and optimisation

PETSc

Alternative linear solvers

PT-Scotch

Required when MPI enabled

Tetgen

For 3D mesh generation

Triangle

For 2D mesh generation

VTK > 5.8

Not required to convert field output files to VTK, only mesh files

1.3.2.2 Quick Start

Open a terminal.

If you have downloaded the tarball, first unpack it:

tar -zxvf nektar++-5.5.0.tar.gz

Change into the nektar++ source code directory

mkdir -p build && cd build 
ccmake ../ 
make install

1.3.2.3 Detailed instructions

From a terminal:

  1. If you have downloaded the tarball, first unpack it

    tar -zxvf nektar++-5.5.0.tar.gz 
        
  2. Change into the source-code directory, create a build subdirectory and enter it

    mkdir -p build && cd build
  3. Run the CMake GUI and configure the build by pressing c

    ccmake ../

    A full list of configuration options can be found in Section 1.3.5.

    Note: Selecting THIRDPARTY_BUILD_ options will request CMake to automatically download thirdparty libraries and compile them within the Nektar++ directory. If you have administrative access to your machine, it is recommended to install the libraries system-wide through your package-management system.

    If you have installed additional system packages since running CMake, you may need to wipe your build directory and rerun CMake for them to be detected.

  4. Press c to configure the build. If errors arise relating to missing libraries, review the THIRDPARTY_BUILD_ selections in the configuration step above or install the missing libraries manually or from system packages.

  5. When configuration completes without errors, press c again until the option g to generate build files appears. Press g to generate the build files and exit CMake.

  6. Compile the code

    make install

    During the build, missing third-party libraries will be automatically downloaded, configured and built in the Nektar++ build directory.

    Tip: If you have multiple processors/cores on your system, compilation can be significantly increased by adding the -jX option to make, where X is the number of simultaneous jobs to spawn. For example, use

    make -j4 install

    on a quad-core system.

  7. Test the build by running unit and regression tests.

    ctest

1.3.3 OS X

1.3.3.1 Prerequisites

Nektar++ uses a number of external programs and libraries for some or all of its functionality. Some of these are required and must be installed prior to compiling Nektar++, most of which are available on MacPorts (www.macports.org) or can be installed manually by a user. Others are optional and required only for specific features, or can be downloaded and compiled for use with Nektar++ automatically (but not installed system-wide).

Note: To compile Nektar++ on OS X, Apple’s Xcode Developer Tools must be installed. They can be installed either from the App Store (only on Mac OS 10.7 and above) or downloaded directly from http://connect.apple.com/ (you are required to have an Apple Developer Connection account). Xcode includes Apple implementations of BLAS and LAPACK (called the Accelerate Framework).

Installation

Package Req. MacPorts User Auto.

Note

Xcode

Provides developer tools

CMake ≥ 3.5.1 cmake

Ncurses GUI optional

BLAS

Part of Xcode

LAPACK

Part of Xcode

Boost >= 1.56 boost

Compile with iostreams

TinyXML tinyxml

Scotch scotch

Required for multi-level static condensation, highly recommended

METIS metis

Alternative mesh partitioning

FFTW > 3.0 fftw-3

For high-performance FFTs

ARPACK > 2.0 arpack

For arnoldi algorithms

OpenMPI openmpi

For parallel execution

GSMPI

For parallel execution

HDF5

For large-scale parallel I/O (requires CMake >3.1)

OpenCascade CE

For mesh generation and optimisation

PETSc petsc

Alternative linear solvers

PT-Scotch

Required when MPI enabled

Tetgen

For 3D mesh generation

Triangle

For 2D mesh generation

VTK > 5.8 vtk

Not required to convert field output files to VTK, only mesh files

Tip: CMake, and some other software, is available from MacPorts ( http://macports.org) and can be installed using, for example,

sudo port install cmake

Package names are given in the table above. Similar packages also exist in other package managers such as Homebrew.

1.3.3.2 Quick Start

Open a terminal (Applications->Utilities->Terminal).

If you have downloaded the tarball, first unpack it:

tar -zxvf nektar++-5.5.0.tar.gz

Change into the nektar++ source code directory

mkdir -p build && cd build 
ccmake ../ 
make install

1.3.3.3 Detailed instructions

From a terminal (Applications->Utilities->Terminal):

  1. If you have downloaded the tarball, first unpack it

    tar -zxvf nektar++-5.5.0.tar.gz 
        
  2. Change into the source-code directory, create a build subdirectory and enter it

    mkdir -p build && cd build
  3. Run the CMake GUI and configure the build

    ccmake ../

    Use the arrow keys to navigate the options and ENTER to select/edit an option.

    A full list of configuration options can be found in Section 1.3.5.

    Note: Selecting THIRDPARTY_BUILD_ options will request CMake to automatically download thirdparty libraries and compile them within the Nektar++ directory. If you have administrative access to your machine, it is recommended to install the libraries system-wide through MacPorts.

  4. Press c to configure the build. If errors arise relating to missing libraries (variables set to NOTFOUND), review the THIRDPARTY_BUILD_ selections in the previous step or install the missing libraries manually or through MacPorts.

  5. When configuration completes without errors, press c again until the option g to generate build files appears. Press g to generate the build files and exit CMake.

  6. Compile the code

    make install

    During the build, missing third-party libraries will be automatically downloaded, configured and built in the Nektar++ build directory.

    Tip: If you have multiple processors/cores on your system, compilation can be significantly increased by adding the -jX option to make, where X is the number of simultaneous jobs to spawn. For example,

    make -j4 install

  7. Test the build by running unit and regression tests.

    ctest

1.3.4 Windows

Windows compilation is supported but there are some complexities with building additional features on this platform at present. As such, only builds with a minimal amount of additional build packages are currently supported. These can either be installed by the user, or automatically as part of the build process. Support has recently been added for building with MPI on Windows. This enables parallel computations to be carried out with Nektar++ on Windows where only sequential computations were previously supported.

Installation

Package Req. User Auto.

Note

MS Visual Studio

2015, 2017, 2019 and 2022 known working

CMake ≥ 3.5.1

3.16+ recommended, see info below

BLAS

LAPACK

Boost ≥ 1.61

Recommend installing from binaries

Microsoft MPI ≥ 10.1.2

Required for parallel execution. Install both runtime and SDK

Note: These instructions assume you are using a 64-bit version of Windows 10.

Note: There have been issues with automatically building Boost from source as a third party dependency during the Nektar++ build when using MS Visual Studio 2015, 2017 and 2019. This should now be possible but it is, nonetheless, recommended you install a suitable version of Boost from binaries as detailed in the instructions below.

1.3.4.1 Detailed instructions

  1. Install Microsoft Visual Studio 2022, 2019 (preferred), 2017 or 2015 (both known to work). This can be obtained from Microsoft free of charge by using their Community developer tools from https://visualstudio.microsoft.com/vs/community/.

  2. Install CMake from http://www.cmake.org/download/. For building on Windows you are strongly recommended to use a recent version of CMake, e.g 3.16+. Minimum required CMake versions for building Nektar++ on Windows with Visual Studio are CMake 3.5.1+ (VS2015), 3.7+ (VS2017), 3.15+ (VS2019) or 3.21+ (VS2022). When prompted, select the option to add CMake to the system PATH.

  3. (Optional) As highlighted above, it is possible to have Boost built from source as a third-party library during the Nektar++ build. However, it is currently recommended to install the Boost binaries that can be found at http://sourceforge.net/projects/boost/files/boost-binaries. By default these install into
    C:\local\boost_<version>. We recommend installing a specific version of the binaries depending on the version of Visual Studio you are using, these are known to be working with the Nektar++ build:

    If you use these libraries, you will need to:

  4. (Optional) Install Git for Windows from https://gitforwindows.org/ to use the development versions of Nektar++. You can accept the default set of components in the Select Components panel. When prompted, in the “Adjusting your PATH environment” panel, select the option “Git from the command line and also from 3rd-party software”. You do not need to select the option to add Unix tools to the PATH.

  5. If you’ve downloaded the source code archive (as described in Section 1.3.1), unpack nektar++-5.5.0.zip.

    Note: Some Windows versions do not recognise the path of a folder which has ++ in the name. If you are not using Windows 10 and think that your Windows version cannot handle paths containing special characters, you should rename nektar++-5.5.0 to nektar-5.5.0.

  6. Create a build directory within the nektar++-5.5.0 subdirectory. If you cloned the source code from the git repository, your Nektar++ subdirectory will be called nektar rather than nektar++-5.5.0

  7. Open a Visual Studio terminal (Developer Command Prompt for VS [2015/2017/2019/2022] or x64 Native Tools Command Prompt. From the Start menu, this can be found under Visual Studio [2015/2017/2019/2022].

  8. Change directory into the build directory and run CMake to generate the build files. You need to set the generator to the correct Visual Studio version using the -G switch on the command line, e.g. for VS2019:

    cd C:\path\to\nektar\builds 
    cmake -G "Visual Studio 16 2019" ..

    You can see the list of available generators using cmake –help. For VS2017 use “Visual Studio 15 2017 Win64” and for VS2015 use “Visual Studio 14 2015 Win64”. Alternatively, run:

    cmake-gui

    to see the available generators and compile options.

    If you want to build a parallel version of Nektar++ with MPI support, you need to add the -DNEKTAR_USE_MPI=ON switch to the cmake command, e.g.:

    cmake -G "Visual Studio 16 2019" -D NEKTAR_USE_MPI=ON ..

    Note: If you installed Boost binaries, as described above, you should ensure at this stage that the version of Boost that you installed has been correctly detected by CMake. You should see a number of lines of output from CMake saying – – Found boost <library name> library: followed by paths to one or more files which should be located in the directory where you installed your Boost binaries. If you do not see this output, CMake has failed to detect the installed Boost libraries and the build process will instead try to build Boost from source as part of building Nektar++.

    If you experience any issues with CMake finding pre-installed Boost, binaries ensure that you are working in a Visual Studio command prompt that was opened after you installed boost and set up the BOOST_HOME environment variable.

  9. Assuming the configuration completes successfully and you see the message Build files have been written to: ..., you should now be ready to issue the build command:

    msbuild INSTALL.vcxproj /p:Configuration=Release

    To build in parallel with, for example, 12 processors, issue:

    msbuild INSTALL.vcxproj /p:Configuration=Release /m:12
  10. After the build and installation process has completed, the executables will be available in build\dist\bin.

  11. To use these executables, you need to modify your system PATH to include the bin directory and library directories where DLLs are stored. To do this, click the Start menu and type ‘env’, you should be presented with an “Edit the system environment variables” option. Alternatively, navigate to Settings > System > About > System info (under Related Settings on the right hand panel), select Advanced System Settings, and in the Advanced tab click the Environment Variables button. In the System Variables box, select Path and click Edit. Add the full paths to the following directories to the end of the list of paths shown in the “Edit environment variable” window:

  12. To run the test suite, open a new command line window, change to the build directory, and then issue the command

    ctest -C Release

1.3.5 CMake Option Reference

This section describes the main configuration options which can be set when building Nektar++. The default options should work on almost all systems, but additional features (such as parallelisation and specialist libraries) can be enabled if needed.

1.3.5.1 Components

The first set of options specify the components of the Nektar++ toolkit to compile. Some options are dependent on others being enabled, so the available options may change.

Components of the Nektar++ package can be selected using the following options:

A number of ThirdParty libraries are required by Nektar++. There are also optional libraries which provide additional functionality. These can be selected using the following options:

The THIRDPARTY_BUILD_X options select which third-party libraries are automatically built during the Nektar++ build process. Below are the choices of X:

There are also a number of additional options to fine-tune the build:

We have recently added explicit support to SIMD (Single Instruction Multiple Data) x86 instruction set extensions (i.e. AVX2, AVX512). Selected operators (the matrix free operators) utilize the SIMD types, if none of them is enabled these operators default to scalar types. The various extensions available are marked as advanced options (to visualize them in the cmake gui you need to press the t-button):

Note that if you are not configuring cmake for the first time, you need to delete the cached variable CMAKE_CXX_FLAGS in order for the appropriate flags to be set. Alternatively you can manually set the flag to target the appropriate architecture.