### OpenFOAM (https://www.openfoam.com/) is free, open source CFD software.
###
### This configuration times the execution of the OpenFOAM Motorbike tutorial
### based on the OpenFOAM-v1812 branch of the git repository. By default,
### the tutorial uses 6 processes for the calculations based on a 3x2 xdivision
### and ydivision (6 subdomains) which is modified depending on the machine.
###
### Scaling: Scale X and Y to maximise CPU usage while maintaining ratio
### Solver:  Default
### Faces:   Default
### Steps:   All
###
### Note that this means that not all CPUs may be used and in some cases, all
### CPUs will be used which is not necessarily optimal for openMPI. At the
### time of writing, the openMPI version used is openMPI 3.1.6-1.19 if using
### SLE 15 SP2 and openMPI 3.1.4-lp151.7.3.1 if using openSUSE Leap 15.1.
. $SHELLPACK_INCLUDE/include-sizes.sh
get_numa_details

export MMTESTS="openfoam"

# List of monitors
export RUN_MONITOR=yes
export MONITORS_ALWAYS=
export MONITORS_GZIP="proc-vmstat mpstat turbostat"
export MONITORS_WITH_LATENCY="vmstat"
export MONITOR_UPDATE_FREQUENCY=10

# OpenFOAM
export OPENFOAM_OPENMPI_VERSION=openmpi3
export OPENFOAM_MPI_PATH=/usr/$MMTESTS_LIBDIR/mpi/gcc/$OPENFOAM_OPENMPI_VERSION/bin
export OPENFOAM_MPI_LIBPATH=/usr/$MMTESTS_LIBDIR/mpi/gcc/$OPENFOAM_OPENMPI_VERSION/$MMTESTS_LIBDIR
export OPENFOAM_MODEL="motorbike-default"
export OPENFOAM_MAXCPUS=$NUMCPUS
export OPENFOAM_LOCAL_CELLS=100000
export OPENFOAM_GLOBAL_CELLS=100000000
export OPENFOAM_REFINEMENT_CELLS=10
export OPENFOAM_CELL_LEVELS=3
export OPENFOAM_ITERATIONS=3

# Set additional mpi options if required
grep -q " ht " /proc/cpuinfo
if [ $? -eq 0 ]; then
	if [ $OPENFOAM_MAXCPUS -gt $((NUMCPUS/2)) ]; then
		echo WARNING: Setting use-hwthread-cpus because HT siblings must be used
		OPENFOAM_MPI_OPTS+=" --use-hwthread-cpus"
	fi
fi
if [ "`whoami`" = "root" ]; then
	OPENFOAM_MPI_OPTS+=" --allow-run-as-root"
fi
export OPENFOAM_MPI_OPTS
