Skip to content

Commit 443a91a

Browse files
committed
Moved DuMuX-specific rules into a dedicated Snakefile and use environment_benchmarks in the DuMuX workflow file.
1 parent ad3298d commit 443a91a

6 files changed

Lines changed: 42 additions & 52 deletions

File tree

.github/workflows/run-dumux-benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: conda-incubator/setup-miniconda@v3
2828
with:
2929
miniforge-version: latest
30-
activate-environment: rc-dumux
30+
activate-environment: model-validation
3131
use-mamba: true
3232

3333
- name: Set strict channel priority
@@ -39,7 +39,7 @@ jobs:
3939
apptainer-version: 1.4.5
4040

4141
- name: Update environment
42-
run: mamba env update -n rc-dumux -f $GITHUB_WORKSPACE/benchmarks/rotating-cylinders/environment_dumux.yaml
42+
run: mamba env update -n model-validation -f environment_benchmarks.yml
4343

4444
- name: generate-rc-config
4545
shell: bash -l {0}

benchmarks/rotating-cylinders/Snakefile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,44 @@ configfile: "rotating-cylinders_config.json"
1111
tools = config["tools"]
1212
configs = config["configurations"]
1313
benchmark = config["benchmark"]
14-
benchmark_uri = config.get("benchmark_uri", "https://nfdi-benchmark.org/rc")
14+
benchmark_uri = config["benchmark_uri"]
1515
result_dir = f"snakemake_results/{benchmark}"
1616
shared_dir = os.getcwd()
17-
dumux_dir = f"{shared_dir}/dumux"
1817

1918
rule all:
2019
input:
2120
expand(f"{result_dir}/{{tool}}/summary.json", tool=tools)
2221

23-
rule generate_dumux_inputs:
24-
input:
25-
grid_t = f"{dumux_dir}/grid_files/grid_template.json",
26-
dumux_t = f"{dumux_dir}/input_files/dumux_config.json"
27-
output:
28-
params = expand(f"{dumux_dir}/input_files/params_{{conf}}.input", conf=configs),
29-
grids = expand(f"{dumux_dir}/grid_files/grid_{{conf}}.json", conf=configs)
30-
shell:
31-
"python3 dumux_input_gen.py --grid_template {input.grid_t} --dumux_template {input.dumux_t}"
32-
3322
for tool in tools:
3423
include: f"{tool}/Snakefile"
3524

3625
rule summary:
3726
input:
3827
script = "../common/summarize_results.py",
39-
# We use the grids generated by the generator rule
40-
parameters = expand(f"{dumux_dir}/grid_files/grid_{{conf}}.json", conf=configs),
41-
mesh = expand(f"{dumux_dir}/grid_files/grid_{{conf}}.json", conf=configs),
42-
metrics = lambda wildcards: expand(
43-
f"{result_dir}/{{tool}}/solution_metrics_{{conf}}.json",
44-
tool=[wildcards.tool], conf=configs
28+
29+
parameters=lambda wc: expand(
30+
f"{shared_dir}/{wc.tool}/grid_files/grid_{{conf}}.json",
31+
conf=configs
32+
),
33+
34+
mesh=lambda wc: expand(
35+
f"{shared_dir}/{wc.tool}/grid_files/grid_{{conf}}.json",
36+
conf=configs
37+
),
38+
39+
metrics=lambda wc: expand(
40+
f"{result_dir}/{wc.tool}/solution_metrics_{{conf}}.json",
41+
conf=configs
4542
),
46-
solution_field_data = lambda wildcards: expand(
47-
f"{result_dir}/{{tool}}/solution_field_data_{{conf}}.zip",
48-
tool=[wildcards.tool], conf=configs
43+
44+
solution_field_data=lambda wc: expand(
45+
f"{result_dir}/{wc.tool}/solution_field_data_{{conf}}.zip",
46+
conf=configs
4947
)
48+
5049
output:
51-
summary_json = f"{result_dir}/{{tool}}/summary.json"
50+
summary_json=f"{result_dir}/{{tool}}/summary.json"
51+
5252
shell:
5353
"""
5454
python3 {input.script} \

benchmarks/rotating-cylinders/dumux/Snakefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
# benchmarks/rotating-cylinders/dumux/Snakefile
12
import os
23

3-
# 1. Setup and Config
4+
# Setup and Config
45
tool = "dumux"
6+
container_image = config["container_image"]
7+
dumux_dir = f"{shared_dir}/dumux"
58

6-
# Use .get() to prevent crashes if config isn't fully loaded yet
7-
benchmark_name = config.get("benchmark", "rotating-cylinders")
8-
container_image = config.get("container_image", "git.iws.uni-stuttgart.de:4567/benchmarks/rotating-cylinders:3.0")
9+
# Rule 1: Input generation
10+
rule generate_dumux_inputs:
11+
input:
12+
grid_t = f"{dumux_dir}/grid_files/grid_template.json",
13+
dumux_t = f"{dumux_dir}/input_files/dumux_config.json",
14+
input_gen_script = f"{dumux_dir}/dumux_input_gen.py"
15+
output:
16+
params = expand(f"{dumux_dir}/input_files/params_{{conf}}.input", conf=configs),
17+
grids = expand(f"{dumux_dir}/grid_files/grid_{{conf}}.json", conf=configs)
18+
shell:
19+
"python3 {input.input_gen_script} --grid_template {input.grid_t} --dumux_template {input.dumux_t}"
920

10-
# Rule 1: Simulation
21+
# Rule 2: Simulation
1122
rule run_dumux_simulation:
1223
input:
1324
# Lambda prevents KeyError before the JSON is generated
@@ -28,7 +39,7 @@ rule run_dumux_simulation:
2839
./test_ff_navierstokes_rotatingcylinders {input.params}
2940
"""
3041

31-
# Rule 2: Post-processing
42+
# Rule 3: Post-processing
3243
rule postprocess_dumux:
3344
input:
3445
sim_data = [
File renamed without changes.

benchmarks/rotating-cylinders/environment_dumux.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

benchmarks/rotating-cylinders/generate_rc_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ def write_benchmark_config():
2626
"benchmark": "rotating-cylinders",
2727
"benchmark_uri": "https://www.openfoam.com/documentation/guides/latest/doc/verification-validation-rotating-cylinders-2d.html",
2828
"tools": ["dumux"],
29-
"configurations": configurations,
3029
"configuration_to_parameter_file": config_to_param,
31-
"configuration_to_solution_vtu_files": config_to_vtu,
30+
"configurations": configurations,
3231
"container_image": "git.iws.uni-stuttgart.de:4567/benchmarks/rotating-cylinders:3.0"
3332
}
3433

0 commit comments

Comments
 (0)