diff --git a/.github/workflows/run-benchmark.yml b/.github/workflows/run-benchmark.yml index a98a3d6..78cbe60 100644 --- a/.github/workflows/run-benchmark.yml +++ b/.github/workflows/run-benchmark.yml @@ -19,8 +19,8 @@ env: jobs: tests: runs-on: ubuntu-latest - - + container: + image: opencfd/openfoam-run:2412 steps: - name: checkout repo content @@ -30,19 +30,32 @@ jobs: uses: conda-incubator/setup-miniconda@v3 with: miniforge-version: latest - activate-environment: model-validation + activate-environment: model-validation use-mamba: true - name: Update environment run: mamba env update -n model-validation -f environment_benchmarks.yml if: steps.cache.outputs.cache-hit != 'true' + - name: Ensure log directory exists + run: mkdir -p benchmarks/rotating-cylinder-OpenFOAM/.snakemake/log + + - name: run-OpenFOAM-benchmarks + shell: bash -l {0} + run: | + cd $GITHUB_WORKSPACE/benchmarks/rotating-cylinder-OpenFOAM/ + mkdir -p ./.snakemake/log || true # bc. snakemake is not able to create this directory itself + chmod +x Allrun + echo "Starting snakemake" + snakemake --cores 1 + echo "Finished job." + - name: run-fenics-benchmarks shell: bash -l {0} run: | cd $GITHUB_WORKSPACE/benchmarks/linear-elasticity-plate-with-hole/ snakemake --use-conda --force --cores 'all' - + - name: run-Kratos-benchmarks shell: bash -l {0} run: | @@ -67,11 +80,36 @@ jobs: name: fenics-output path: | benchmarks/linear-elasticity-plate-with-hole/data - + - name: Archive kratos data uses: actions/upload-artifact@v4 with: name: kratos-output path: | benchmarks/linear-elasticity-plate-with-hole-Kratos/data - + + + test_rotCyl_OF: + runs-on: ubuntu-latest + container: + image: opencfd/openfoam-run:2412 + + steps: + - name: Print debug information + run: | + echo "Running on OpenFOAM image" + echo "Current directory: $PWD" + echo "Available files:" + ls -la + + - name: checkout repo content + uses: actions/checkout@v2 + + - name: run-OpenFOAM-benchmarks + shell: bash -l {0} + run: | + cd $GITHUB_WORKSPACE/benchmarks/rotating-cylinder-OpenFOAM/ + # sudo apt-get update && sudo apt-get install -y gnuplot + chmod +x ./plot + bash ./Allrun + echo "Finished job" diff --git a/.gitignore b/.gitignore index f684468..72025d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .snakemake -site \ No newline at end of file +site +venv/ diff --git a/benchmarks/rotating-cylinder-OpenFOAM/0/U b/benchmarks/rotating-cylinder-OpenFOAM/0/U new file mode 100644 index 0000000..ae67c92 --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/0/U @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2412 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + innerWall + { + type noSlip; + } + + outerWall + { + type noSlip; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/benchmarks/rotating-cylinder-OpenFOAM/0/p b/benchmarks/rotating-cylinder-OpenFOAM/0/p new file mode 100644 index 0000000..007b1b9 --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/0/p @@ -0,0 +1,34 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2412 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + "innerWall|outerWall" + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/benchmarks/rotating-cylinder-OpenFOAM/Allclean b/benchmarks/rotating-cylinder-OpenFOAM/Allclean new file mode 100755 index 0000000..ad9bdea --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/Allclean @@ -0,0 +1,10 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions +#------------------------------------------------------------------------------ + +cleanCase + +rm -f *.png + +#------------------------------------------------------------------------------ diff --git a/benchmarks/rotating-cylinder-OpenFOAM/Allrun b/benchmarks/rotating-cylinder-OpenFOAM/Allrun new file mode 100755 index 0000000..b2a0cbe --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/Allrun @@ -0,0 +1,12 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +runApplication blockMesh +runApplication $(getApplication) + +echo "Simulation completed. You could now post-process (e.g. visualize) the results." +# ./plot # disabled for benchmark/snakemake-setup + +#------------------------------------------------------------------------------ diff --git a/benchmarks/rotating-cylinder-OpenFOAM/Snakefile b/benchmarks/rotating-cylinder-OpenFOAM/Snakefile new file mode 100644 index 0000000..bc0614c --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/Snakefile @@ -0,0 +1,36 @@ +# Define the parameter space +# 40 is default +meshNs = [10, 20, 40] + +rule all: + input: + expand("cases/meshN_{meshN}/postprocessing/done", meshN=meshNs) + + +rule run_simulation_container: + input: + template="system/blockMeshDict.template", + scripts="Allrun" + output: + directory("cases/meshN_{meshN}/1000"), + touch("cases/meshN_{meshN}/postprocessing/done") + container: "docker://opencfd/openfoam-run:2412" + shell: + """ + set -euo pipefail + + echo "Setting up simulation {wildcards.meshN}." + mkdir -p cases/meshN_{wildcards.meshN} + cp -r 0 system constant Allclean Allrun plot cases/meshN_{wildcards.meshN}/ + cd cases/meshN_{wildcards.meshN} + sed "s/{{meshN}}/{wildcards.meshN}/g" {input.template} > system/blockMeshDict + + echo "Starting simulation." + chmod +x Allrun + ./Allrun + + ls -la + tail log.simpleFoam + + touch postprocessing/done + """ diff --git a/benchmarks/rotating-cylinder-OpenFOAM/cases/.gitkeep b/benchmarks/rotating-cylinder-OpenFOAM/cases/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/benchmarks/rotating-cylinder-OpenFOAM/constant/MRFProperties b/benchmarks/rotating-cylinder-OpenFOAM/constant/MRFProperties new file mode 100644 index 0000000..98414d4 --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/constant/MRFProperties @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2412 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object MRFProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +MRF1 +{ + cellZone all; + active yes; + + nonRotatingPatches (outerWall); + + origin (0 0 0); + axis (0 0 1); + omega 100; +} + +// ************************************************************************* // diff --git a/benchmarks/rotating-cylinder-OpenFOAM/constant/transportProperties b/benchmarks/rotating-cylinder-OpenFOAM/constant/transportProperties new file mode 100644 index 0000000..607db27 --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/constant/transportProperties @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2412 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +transportModel Newtonian; + +nu 1; + +// ************************************************************************* // diff --git a/benchmarks/rotating-cylinder-OpenFOAM/constant/turbulenceProperties b/benchmarks/rotating-cylinder-OpenFOAM/constant/turbulenceProperties new file mode 100644 index 0000000..52a7d3b --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2412 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/benchmarks/rotating-cylinder-OpenFOAM/plot b/benchmarks/rotating-cylinder-OpenFOAM/plot new file mode 100755 index 0000000..2fb9f14 --- /dev/null +++ b/benchmarks/rotating-cylinder-OpenFOAM/plot @@ -0,0 +1,44 @@ +#!/bin/sh +# Require gnuplot +command -v gnuplot >/dev/null || { + echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" 1>&2 + exit 1 +} + + +gnuplot<