Skip to content

Building WindNinja on Linux 22.04

latwood edited this page Feb 17, 2025 · 6 revisions

Instructions for building the WindNinja CLI on Ubuntu 22.04 (latest version where model dependencies work)

Make sure you have C-Make and git installed before starting instructions.

Get WindNinja Source

Note: We are cloning from a branch and NOT the master, so some code may be out of date.

git clone -b qt4guiForUbuntu22o04 https://github.com/firelab/windninja.git 

Install Third-Party Libraries

Note: These instructions are specific to Ubuntu 22.04, but building on other distributions is possible as well. See the steps in scripts/build_deps_ubuntu_2204.sh.

Run scripts/build_deps_ubuntu_2204.sh to fetch, build, and install third party libraries.

cd windninja/scripts/ && ./build_deps_ubuntu_2204.sh

Start CMake

Create a build directory outside the source tree. For example, if WindNinja is in ~/src/wind/windninja: mkdir ~/src/wind/build.

This build directory is where all of the build-related files will be located (executables, shared libraries, object files, qt moc files, etc.). This is done so that these files don't contaminate the source tree. One advantage of this is that all of these files can be deleted easily by just deleting the build directory.

cd ~/src/wind/build && cmake-gui ../windninja

or

cd ~/src/wind/build && ccmake ../windninja

Select configure to start the process of setting options and identifying locations of third party libraries, etc. If asked to "Specify the generator for this project" select Unix Makefiles and choose "Use default native compilers".

The general procedure to be used in the cmake gui is to edit the "Value" fields in the Name/Value pair list appropriately, then click the configure button. This procedure must be typically done in an iterative fashion (multiple times) as one edit may add additional requirements. Read below for the possible Options available.

CMake options:

Turn on the following option (NINJA_QTGUI cannot be turned on):

  • NINJA_CLI -- builds the WindNinja CLI

If you plan to use the optional conservation of mass and momentum solver, set:

  • NINJAFOAM = ON

The CMake build has several other general options which can be set:

  • CMAKE_BUILD_TYPE -- can be set to debug or release
  • CMAKE_INSTALL_PREFIX -- defines the install path
  • OPENMP_SUPPORT -- enables OpenMP support
  • SUPPRESS_WARNINGS -- suppresses common, known warnings that are not thought to affect the build
  • VERBOSE_WARNINGS -- sets warnings to all, and supercedes SUPRESS_WARNINGS (you may also want to enable CMAKE_VERBOSE_MAKEFILE in the advanced options)

Third-party libraries:

CMake will attempt to find all of the third party libraries needed for WindNinja. All are required with the exception of Qt, if the gui is not being built. CMake has default methods for handling libraries. It will usually ask for a path to a lib, a path to an include directory, and possibly a path to a binary that can specify some configuration values for the install. Since all of the libraries are required, the CMake configuration fails when one is not found. This means you must find the paths for each lib in order, as CMake fails each time you click "Configure" on the next unfound lib. After everything is found and set, click "Generate".

Build WindNinja

If you have correctly configured in the cmake gui and clicked "generate", a Makefile will be built in the build directory. Next run:

make && sudo make install

You may also need to run:

sudo ldconfig

make should compile and link WindNinja to all of its dependency libraries. The WindNinja executable should be located build/src/cli for the CLI versions. The core WindNinja shared library that handles the number crunching part of WindNinja is located in build/src/ninja.

make install should install all of the necessary WindNinja binaries and other files in the location specified earlier in the cmake CMAKE_INSTALL_PREFIX option.

You can now run the following command in terminal to execute the program:

WindNinja_cli

For more information using the cli refer to http://firelab.github.io/windninja/pdf/CLI_instructions.pdf

Set Environment Variables

As of WindNinja 2.2.0, the environment variable WINDNINJA_DATA must be set. This points to datasets that WindNinja needs to run certain functions. If the program is installed (i.e., with make install), it is likely that WindNinja will find the path. Otherwise, the environment variable will need to be set:

export WINDNINJA_DATA=~/src/wind/windninja/data

(Optional) Build the mass and momentum solver OpenFOAM libraries and executables

If you want to use the conservation of mass and momentum solver, you will need to build some custom OpenFOAM libraries and executables. OpenFOAM 9 is installed when build_deps_ubuntu_2204.sh is run. You can test that it is installed with blockMesh -help. To build our custom libraries and executables run the following (be sure to adjust the path to the WindNinja source tree appropriately).

mkdir -p $FOAM_RUN/../applications
cp -r ~/src/wind/windninja/src/ninjafoam/9/* $FOAM_RUN/../applications
cd $FOAM_RUN/../applications
wmake libso
cd utility/applyInit
wmake

This should build an executable called applyInit in $FOAM_RUN/../platforms/linux64GccDPOpt/bin and a shared library called libWindNinja.so in $FOAM_RUN/../platforms/linux64GccDPOpt/lib.

Be sure that NINJAFOAM=ON in CMake before building WindNinja.

Accessing Third-Party Data in WindNinja

Some third-party data requires API keys for access. Because these keys have download limits associated with them, we require custom builds of WindNinja to acquire their own third-party keys. See Accessing third-party data for details.

Clone this wiki locally