143 lines
4.3 KiB
Bash
Executable file
143 lines
4.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Build the OpenFOAM Foundation v14 serial subset needed for AirfRANS-style data generation.
|
|
# Tools built: foamRun/incompressibleFluid (simpleFoam replacement), simpleFoam wrapper,
|
|
# gmshToFoam, checkMesh, and foamToVTK.
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
|
OPENFOAM_REPO_URL="${OPENFOAM_REPO_URL:-https://github.com/OpenFOAM/OpenFOAM-14.git}"
|
|
THIRDPARTY_REPO_URL="${THIRDPARTY_REPO_URL:-https://github.com/OpenFOAM/ThirdParty-14.git}"
|
|
AIRFRANS_REPO_URL="${AIRFRANS_REPO_URL:-https://github.com/Extrality/AirfRANS.git}"
|
|
JOBS="${JOBS:-$(nproc)}"
|
|
|
|
validate_dependency_tree() {
|
|
local dir="$1"
|
|
shift
|
|
|
|
local root="${ROOT_DIR}/${dir}"
|
|
if [[ ! -d "${root}" ]]; then
|
|
printf 'dependency %s exists but is not a directory: %s\n' "${dir}" "${root}" >&2
|
|
return 1
|
|
fi
|
|
|
|
local -a missing=()
|
|
local expected
|
|
for expected in "$@"; do
|
|
if [[ ! -e "${root}/${expected}" ]]; then
|
|
missing+=("${expected}")
|
|
fi
|
|
done
|
|
|
|
if ((${#missing[@]})); then
|
|
printf 'dependency %s exists but is incomplete; missing expected path(s):' "${dir}" >&2
|
|
printf ' %s' "${missing[@]}" >&2
|
|
printf '\nMove or remove %s, or replace it with a complete checkout before rerunning.\n' "${root}" >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
clone_if_missing() {
|
|
local url="$1"
|
|
local dir="$2"
|
|
shift 2
|
|
|
|
local root="${ROOT_DIR}/${dir}"
|
|
if [[ -e "${root}" || -L "${root}" ]]; then
|
|
validate_dependency_tree "${dir}" "$@"
|
|
printf 'using existing %s\n' "${dir}"
|
|
else
|
|
git clone --depth 1 "${url}" "${root}"
|
|
validate_dependency_tree "${dir}" "$@"
|
|
fi
|
|
}
|
|
|
|
clone_if_missing "${OPENFOAM_REPO_URL}" OpenFOAM-14 \
|
|
etc/bashrc \
|
|
wmake/wmake \
|
|
src/OpenFOAM/Make/files \
|
|
applications/solvers/foamRun/Make/files \
|
|
tutorials/incompressibleFluid/venturiTube
|
|
clone_if_missing "${THIRDPARTY_REPO_URL}" ThirdParty-14 \
|
|
Allwmake \
|
|
etc/tools
|
|
clone_if_missing "${AIRFRANS_REPO_URL}" airfrans \
|
|
README.md \
|
|
dataset.py
|
|
|
|
# Dummy MPI keeps this subset serial and avoids requiring mpicc/OpenMPI for p1.
|
|
# Use SYSTEMOPENMPI instead only after installing a system MPI development package.
|
|
# OpenFOAM's bashrc probes optional shell variables that may be unset.
|
|
# shellcheck disable=SC1091
|
|
set +u
|
|
source "${ROOT_DIR}/OpenFOAM-14/etc/bashrc" \
|
|
WM_MPLIB=Dummy \
|
|
ParaView_TYPE=none \
|
|
SCOTCH_TYPE=none \
|
|
ZOLTAN_TYPE=none
|
|
set -u
|
|
|
|
cd "${ROOT_DIR}/OpenFOAM-14"
|
|
|
|
(cd wmake/src && make)
|
|
|
|
src/Pstream/Allwmake -j "${JOBS}"
|
|
src/OSspecific/${WM_OSTYPE:-POSIX}/Allwmake -j "${JOBS}"
|
|
wmake -j "${JOBS}" libso src/OpenFOAM
|
|
|
|
for target in \
|
|
src/fileFormats \
|
|
src/surfMesh \
|
|
src/triSurface \
|
|
src/meshTools \
|
|
src/finiteVolume \
|
|
src/ODE \
|
|
src/physicalProperties \
|
|
src/tracking \
|
|
src/lagrangian/basic \
|
|
src/generic/genericPatches \
|
|
src/generic/genericFields \
|
|
src/generic/genericFvPatches \
|
|
src/generic/genericFvFields \
|
|
src/sampling \
|
|
src/meshCheck \
|
|
src/mesh/extrudeModel \
|
|
src/polyTopoChange \
|
|
src/conversion \
|
|
src/thermophysicalModels/specie \
|
|
src/thermophysicalModels/thermophysicalProperties \
|
|
src/thermophysicalModels/basic \
|
|
src/thermophysicalModels/multicomponentThermo \
|
|
src/thermophysicalModels/solidThermo \
|
|
src/MomentumTransportModels/momentumTransportModels \
|
|
src/MomentumTransportModels/incompressible \
|
|
src/MomentumTransportModels/compressible \
|
|
src/ThermophysicalTransportModels/thermophysicalTransportModel \
|
|
src/ThermophysicalTransportModels/fluid \
|
|
src/ThermophysicalTransportModels/fluidThermo \
|
|
src/fvConstraints \
|
|
src/fvModels/general \
|
|
applications/modules/basicFluidSolver \
|
|
applications/modules/incompressibleFluid
|
|
do
|
|
wmake -j "${JOBS}" libso "${target}"
|
|
done
|
|
|
|
for app in \
|
|
applications/solvers/foamRun \
|
|
applications/utilities/mesh/conversion/gmshToFoam \
|
|
applications/utilities/mesh/manipulation/checkMesh
|
|
do
|
|
wmake -j "${JOBS}" "${app}"
|
|
done
|
|
|
|
applications/utilities/postProcessing/dataConversion/foamToVTK/Allwmake -j "${JOBS}"
|
|
|
|
foamRun -help >/dev/null
|
|
foamRun -solver incompressibleFluid -help >/dev/null
|
|
gmshToFoam -help >/dev/null
|
|
checkMesh -help >/dev/null
|
|
foamToVTK -help >/dev/null
|
|
simpleFoam -help >/dev/null
|
|
|
|
printf 'OpenFOAM v14 AirfRANS subset built and smoke-checked.\n'
|