OpenFOAM® v2012: New and improved usability

23/12/2020

Improved compiler configuration

Compile control

Introduced a WM_COMPILE_CONTROL variable to convey additional control information into the build rules. The convention being followed is as per spack:

  • + to select a feature
  • ~ to deselect a feature

For example, to select the gold linker, and disable openmp (spaces are not required):

WM_COMPILE_CONTROL="+gold ~openmp"

Rationalized tuning

Support config.sh/prefs.compiler with better possibilities to provide overload values.

New rules/settings
  • Added a cuda rule (provisional).
  • Add runtime settings for mingw cross-compiled binaries. The value WM_ARCH=win64 indicates the runtime environment.
  • Cross-compile the wmake toolchain as well.

wmake

Add hook for bear frontend to create json output. Example usage,

wmake -with-bear src/OpenFOAM
src/Allwmake -with-bear -s -j

And added bin/tools/vscode-settings to emit json content suitable for setting up Visual Studio Code for use with OpenFOAM. For example,

bin/tools/vscode-settings > .vscode/settings.json

Ideas from Volker Weissman

  • Using WM˙QUIET=false now works as expected.

Improved installation scripts

For downstream packages there are now additional packaging scripts to simplify installation and reduce the error potential.

  • bin/tools/createMingwRuntime : Script to copy/create mingw run-time installation from the Linux cross-compilation. Packs everything into a tar or a zip file. [Can only be called when the linux64Mingw environment is active.]
  • bin/tools/install-dirs : A general directory installer that copy installs non-binary directories.
  • bin/tools/install-platform : A platform (binary) installer.

Rationalized mpi configuration names

To keep track of the numerous MPI variants and versions, the internal naming has been adjusted. Most end-users will not be affected by these changes; only if you have been accustomed to particular ways of defining your MPI setup that things may change.

Clearly distinguish system vs. other MPI installations

The FOAM_MPI value is now prefixed with sys- for system versions, which also changes the name of the library sub-directories. This mostly impacts system openmpi users.

WM_MPLIB libdir (FOAM_MPI) old naming
SYSTEMMPI sys-mpi mpi
SYSTEMOPENMPI sys-openmpi openmpi-system

Support different major versions for system OpenMPI

Some installations provide different versions of OpenMPI that can all be considered ”system” openmpi. However, since programs compiled with openmpi1 will not load with openmpi2 and vice versa, it can be useful to distinguish which version is being used. To support this, it is now possible to add the major number. For example,

WM_MPLIB=SYSTEMOPENMPI2
This would define FOAM˙MPI=sys-openmpi2 and thus create a lib/sys-openmpi2 that would not conflict with a lib/sys-openmpi3 etc. It also allows variants such as SYSTEMOPENMPI2 to be handled separately if needed.

Additional preferences

For linking with MPI, the Make/options now uses a centralized handling of mpi as ’mpi-rules’.

include $(GENERAL_RULES)/mpi-rules
An additional hook is also provided for EASYBUILDMPI (eb-mpi), to make for smoother downstream packaging. Since EasyBuild uses mpicc when compiling, no explicit wmake rules are provided for it.

More information

The wmake command has been extended to include -show-mpi-compile and -show-mpi-link options. These can be very useful for diagnosing which MPI paths and flags are being used when setting up for a new MPI configuration.

Portability changes

It is now possible to build and run OpenFOAM without libz. If libz development headers are unavailable on your machine, it is possible to still possible to compile and use most of OpenFOAM. If compiled without libz support:

  • reading gz files : FatalError
  • writing gz files : emit warning and downgrade to uncompressed
  • warn if compression is specified in the case controlDict and downgrade to uncompressed
  • Added provisioning for libz detection as wmake/script/have˙libz.
  • Support config.sh/readline to customize the location for readline for packaging systems like EasyBuild and spack.

Internal equivalent of /dev/null

The OpenFOAM Snull is now backed by an internal dummy stream instead of relying on the system /dev/null for improved portability.

Consistent wrapping of compressed file streams

It is now possible to open a compressed file stream as a std::iostream. This low-level access is provided by the new ifstreamPointer and ofstreamPointer classes, which are also used internally by the OpenFOAM IFstream and OFstream. This is convenient when a plain (non-OpenFOAM) stream is required that also can handle compression as required. For example,

// Handle compressed (.gz) or uncompressed input files
ifstreamPointer isPtr(filename);
const bool unCompressed(IOstream::UNCOMPRESSED == isPtr.whichCompression());
auto& is = *isPtr;

More robust handling of processor directory names

Reduced code and improved the robustness when matching paths that themselves contain the word ”processor” in them. For example,

"/path/processor0generation2/case1/processor10/system"

would previously fail, but now correctly matches on processor10.

Reduced startup IO

Improvements were made based on the analysis from T.Aoyagi(RIST), A.Azami(RIST) to reduce load on the filing system when starting on very large systems.