Skip to content

Commit 30deb03

Browse files
committed
add OpenFOAM test case: rotating cylinder
1 parent dd29f7b commit 30deb03

File tree

14 files changed

+578
-6
lines changed

14 files changed

+578
-6
lines changed

.github/workflows/run-benchmark.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
tests:
2121
runs-on: ubuntu-latest
2222

23-
24-
2523
steps:
2624
- name: checkout repo content
2725
uses: actions/checkout@v2
@@ -30,19 +28,25 @@ jobs:
3028
uses: conda-incubator/setup-miniconda@v3
3129
with:
3230
miniforge-version: latest
33-
activate-environment: model-validation
31+
activate-environment: model-validation
3432
use-mamba: true
3533

3634
- name: Update environment
3735
run: mamba env update -n model-validation -f environment_benchmarks.yml
3836
if: steps.cache.outputs.cache-hit != 'true'
3937

38+
- name: run-OpenFOAM-benchmarks
39+
shell: bash -l {0}
40+
run: |
41+
cd $GITHUB_WORKSPACE/benchmarks/rotating-cylinder-OpenFOAM/
42+
snakemake --force --cores 'all'
43+
4044
- name: run-fenics-benchmarks
4145
shell: bash -l {0}
4246
run: |
4347
cd $GITHUB_WORKSPACE/benchmarks/linear-elasticity-plate-with-hole/
4448
snakemake --use-conda --force --cores 'all'
45-
49+
4650
- name: run-Kratos-benchmarks
4751
shell: bash -l {0}
4852
run: |
@@ -67,11 +71,36 @@ jobs:
6771
name: fenics-output
6872
path: |
6973
benchmarks/linear-elasticity-plate-with-hole/data
70-
74+
7175
- name: Archive kratos data
7276
uses: actions/upload-artifact@v4
7377
with:
7478
name: kratos-output
7579
path: |
7680
benchmarks/linear-elasticity-plate-with-hole-Kratos/data
77-
81+
82+
83+
test_rotCyl_OF:
84+
runs-on: ubuntu-latest
85+
container:
86+
image: opencfd/openfoam-run:2412
87+
88+
steps:
89+
- name: Print debug information
90+
run: |
91+
echo "Running on OpenFOAM image"
92+
echo "Current directory: $PWD"
93+
echo "Available files:"
94+
ls -la
95+
96+
- name: checkout repo content
97+
uses: actions/checkout@v2
98+
99+
- name: run-OpenFOAM-benchmarks
100+
shell: bash -l {0}
101+
run: |
102+
cd $GITHUB_WORKSPACE/benchmarks/rotating-cylinder-OpenFOAM/
103+
sudo apt-get update && sudo apt-get install -y gnuplot
104+
chmod +x ./plot
105+
bash ./Allrun
106+
echo "Finished job"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: v2412 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
class volVectorField;
13+
object U;
14+
}
15+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16+
17+
dimensions [0 1 -1 0 0 0 0];
18+
19+
internalField uniform (0 0 0);
20+
21+
boundaryField
22+
{
23+
innerWall
24+
{
25+
type noSlip;
26+
}
27+
28+
outerWall
29+
{
30+
type noSlip;
31+
}
32+
33+
frontAndBack
34+
{
35+
type empty;
36+
}
37+
}
38+
39+
// ************************************************************************* //
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: v2412 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
class volScalarField;
13+
object p;
14+
}
15+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16+
17+
dimensions [0 2 -2 0 0 0 0];
18+
19+
internalField uniform 0;
20+
21+
boundaryField
22+
{
23+
"innerWall|outerWall"
24+
{
25+
type zeroGradient;
26+
}
27+
28+
frontAndBack
29+
{
30+
type empty;
31+
}
32+
}
33+
34+
// ************************************************************************* //
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
cd "${0%/*}" || exit # Run from this directory
3+
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
4+
#------------------------------------------------------------------------------
5+
6+
cleanCase
7+
8+
rm -f *.png
9+
10+
#------------------------------------------------------------------------------
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
cd "${0%/*}" || exit # Run from this directory
3+
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
4+
#------------------------------------------------------------------------------
5+
6+
runApplication blockMesh
7+
runApplication $(getApplication)
8+
./plot
9+
10+
#------------------------------------------------------------------------------
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
rule run_simulation_container:
3+
input:
4+
".",
5+
output:
6+
directory("."),
7+
container: "docker://opencfd/openfoam-run:2412"
8+
shell: "./Allrun"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: v2412 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
class dictionary;
13+
location "constant";
14+
object MRFProperties;
15+
}
16+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17+
18+
MRF1
19+
{
20+
cellZone all;
21+
active yes;
22+
23+
nonRotatingPatches (outerWall);
24+
25+
origin (0 0 0);
26+
axis (0 0 1);
27+
omega 100;
28+
}
29+
30+
// ************************************************************************* //
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: v2412 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
class dictionary;
13+
location "constant";
14+
object transportProperties;
15+
}
16+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17+
18+
transportModel Newtonian;
19+
20+
nu 1;
21+
22+
// ************************************************************************* //
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: v2412 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
class dictionary;
13+
location "constant";
14+
object turbulenceProperties;
15+
}
16+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17+
18+
simulationType laminar;
19+
20+
// ************************************************************************* //
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
# Require gnuplot
3+
command -v gnuplot >/dev/null || {
4+
echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" 1>&2
5+
exit 1
6+
}
7+
8+
9+
gnuplot<<EOF
10+
set terminal pngcairo font "helvetica,16" size 800,600
11+
set xlabel "Radius, r"
12+
set xrange [1:2]
13+
set grid
14+
15+
Omega1 = 100.
16+
Omega2 = 0.
17+
R1 = 1.
18+
R2 = 2.
19+
20+
mu = Omega2/Omega1
21+
22+
A = Omega1*(1. - R2*R2*mu/R1/R1)/(1. - R2*R2/R1/R1)
23+
B = R1*R1*Omega1*(1. - mu)/(1. - R1*R1/R2/R2)
24+
25+
analytical_utheta(r) = A*r + B/r
26+
C = 0.5*A*A*R1*R1 + 2.*A*B*log(R1) - 0.5*B*B/R1/R1
27+
analytical_p(r) = 0.5*A*A*r*r + 2.*A*B*log(r) - 0.5*B*B/r/r - C
28+
29+
samples="postProcessing/sample1/1000/centreLine_p_U_U:Transformed.xy"
30+
31+
set ylabel "Pressure, p"
32+
set output "p.png"
33+
set samples 20
34+
set key bottom right
35+
plot samples u 1:2 w lines lw 2 lc "black" t "OpenFOAM", \
36+
analytical_p(x) w p ps 2 pt 6 lw 2 lc rgb "red" t "analytical"
37+
38+
set ylabel "U_{/Symbol q}, rad/s"
39+
set output "Utheta.png"
40+
set samples 20
41+
set key top right
42+
plot samples u 1:7 w lines lw 2 lc "black" t "OpenFOAM", \
43+
analytical_utheta(x) w p ps 2 pt 6 lw 2 lc rgb "red" t "analytical"
44+
EOF

0 commit comments

Comments
 (0)