Introduction

OpenFOAM® is a C++ toolbox for the development of customized numerical solvers and pre-/post-processing utilities for the solution of continuum mechanics problems, including computational fluid dynamics. OpenFOAM is one of the leading CFD applications and is increasingly popular due to its features and open source availability.

Official Website: https://www.openfoam.com/

Build OpenFOAM using Spack

Please refer to this link for getting started with spack using AMD Zen Software Studio.

    # Example for building OpenFOAM with AOCC and AOCL.
$ spack install openfoam %aocc ^amdfftw ^openmpi fabrics=cma,ucx

Explanation of the command options:

Symbol Meaning
%aocc Build OpenFOAM with AOCC compiler.
^amdfftw Use amdfftw as the FFTW implementation.
^openmpi fabrics=cma,ucx Use OpenMPI as the MPI provider and use the CMA network for efficient intra-node communication, falling back to the UCX network fabric, if required. 
Note: It is advised to specifically set the appropriate fabric for the host system if possible. Refer to Open MPI with AMD Zen Software Studio for more guidance.

Running OpenFOAM®

OpenFOAM is a large and complex CFD toolkit and the steps to run it will depend entirely on the dataset being run. OpenFOAM provides Sample input files in its tutorial directory. A common benchmark and example/tutorial problem for OpenFOAM is the motorbike model. 

Sample script for running OpenFOAM with Motorbike dataset:

Run Script for AMD EPYC Processors

    #!/bin/bash
# Load OpenFOAM (if there're multiple installations, append to the command a hash to identify the installation e.g. /xxxxxxx)
spack load openfoam %aocc

# Copy the Motorbike dataset from the official tutorials
cp -r $(spack location -i openfoam %aocc)/tutorials/incompressible/simpleFoam/motorBike .
cd motorBike

# Patch input files for system settings, for a dual socket AMD 5th Gen EPYC™ 9755 Processor with 256 (128x2) cores
sed -i "s/numberOfSubdomains.*/numberOfSubdomains 256;/" system/decomposeParDict.6   # number of cores to use
sed -i "s/ n           (3 2 1)/ n           (64 4 1);/" system/decomposeParDict.6    # decompose for all cores
sed -i "s/(20 8 8)/(100 40 40)/" system/blockMeshDict                                # increase problem size

# Run the benchmark
./Allrun

Note: The above build and run steps are tested with OpenFOAM-2312, AOCC-5.0.0, AOCL-5.0.0, and OpenMPI-5.0.5 on Red Hat Enterprise Linux release 8.9 (Ootpa) using Spack v0.23.0.dev0 (commit id : 2da812cbad ).

For technical support  on the tools, benchmarks and applications that AMD offers on this page and related inquiries, reach out to us at toolchainsupport@amd.com