Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions .github/workflows/run-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ env:
jobs:
tests:
runs-on: ubuntu-latest


container:
image: opencfd/openfoam-run:2412

steps:
- name: checkout repo content
Expand All @@ -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: |
Expand All @@ -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"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.snakemake
site
site
venv/
39 changes: 39 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/0/U
Original file line number Diff line number Diff line change
@@ -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;
}
}

// ************************************************************************* //
34 changes: 34 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/0/p
Original file line number Diff line number Diff line change
@@ -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;
}
}

// ************************************************************************* //
10 changes: 10 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/Allclean
Original file line number Diff line number Diff line change
@@ -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

#------------------------------------------------------------------------------
12 changes: 12 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/Allrun
Original file line number Diff line number Diff line change
@@ -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

#------------------------------------------------------------------------------
36 changes: 36 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/Snakefile
Original file line number Diff line number Diff line change
@@ -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
"""
Empty file.
30 changes: 30 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/constant/MRFProperties
Original file line number Diff line number Diff line change
@@ -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;
}

// ************************************************************************* //
22 changes: 22 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/constant/transportProperties
Original file line number Diff line number Diff line change
@@ -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;

// ************************************************************************* //
Original file line number Diff line number Diff line change
@@ -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;

// ************************************************************************* //
44 changes: 44 additions & 0 deletions benchmarks/rotating-cylinder-OpenFOAM/plot
Original file line number Diff line number Diff line change
@@ -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<<EOF
set terminal pngcairo font "helvetica,16" size 800,600
set xlabel "Radius, r"
set xrange [1:2]
set grid

Omega1 = 100.
Omega2 = 0.
R1 = 1.
R2 = 2.

mu = Omega2/Omega1

A = Omega1*(1. - R2*R2*mu/R1/R1)/(1. - R2*R2/R1/R1)
B = R1*R1*Omega1*(1. - mu)/(1. - R1*R1/R2/R2)

analytical_utheta(r) = A*r + B/r
C = 0.5*A*A*R1*R1 + 2.*A*B*log(R1) - 0.5*B*B/R1/R1
analytical_p(r) = 0.5*A*A*r*r + 2.*A*B*log(r) - 0.5*B*B/r/r - C

samples="postProcessing/sample1/1000/centreLine_p_U_U:Transformed.xy"

set ylabel "Pressure, p"
set output "p.png"
set samples 20
set key bottom right
plot samples u 1:2 w lines lw 2 lc "black" t "OpenFOAM", \
analytical_p(x) w p ps 2 pt 6 lw 2 lc rgb "red" t "analytical"

set ylabel "U_{/Symbol q}, rad/s"
set output "Utheta.png"
set samples 20
set key top right
plot samples u 1:7 w lines lw 2 lc "black" t "OpenFOAM", \
analytical_utheta(x) w p ps 2 pt 6 lw 2 lc rgb "red" t "analytical"
EOF
Loading
Loading