Skip to content

Commit 13b53e2

Browse files
committed
Merge remote-tracking branch 'origin/main' into dumux_and_rotating_cylinderMerge remote-tracking branch 'origin/main' into dumux_and_rotating_cylinder
@
2 parents 736fd1b + 8a03d3b commit 13b53e2

32 files changed

+514
-1188
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: CI
2+
on:
3+
push:
4+
5+
pull_request:
6+
branches: [ main ]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Runs the workflow once per day at 3:15am
12+
schedule:
13+
- cron: '3 16 * * *'
14+
15+
env:
16+
CACHE_NUMBER: 1 # increase to reset cache manually
17+
18+
jobs:
19+
tests:
20+
runs-on: ubuntu-latest
21+
22+
23+
24+
steps:
25+
- name: checkout repo content
26+
uses: actions/checkout@v2
27+
28+
- name: Setup Mambaforge
29+
uses: conda-incubator/setup-miniconda@v3
30+
with:
31+
miniforge-version: latest
32+
activate-environment: model-validation
33+
use-mamba: true
34+
35+
- name: Set strict channel priority
36+
run: conda config --set channel_priority strict
37+
38+
- name: Update environment
39+
run: mamba env update -n model-validation -f environment_benchmarks.yml
40+
41+
- name: generate-config-files
42+
shell: bash -l {0}
43+
run: |
44+
cd $GITHUB_WORKSPACE/benchmarks/linear-elastic-plate-with-hole/
45+
python generate_config.py
46+
47+
- name: run_linear-elastic-plate-with-hole-benchmarks_snakemake
48+
shell: bash -l {0}
49+
run: |
50+
cd $GITHUB_WORKSPACE/benchmarks/linear-elastic-plate-with-hole/
51+
snakemake --use-conda --force --cores 'all'
52+
snakemake --use-conda --force --cores all \
53+
--reporter metadata4ing \
54+
--report-metadata4ing-paramscript ../common/parameter_extractor.py \
55+
--report-metadata4ing-filename snakemake_provenance
56+
unzip snakemake_provenance -d snakemake_provenance
57+
58+
- name: run_linear-elastic-plate-with-hole-benchmarks_nextflow
59+
shell: bash -l {0}
60+
run: |
61+
cd $GITHUB_WORKSPACE/benchmarks/linear-elastic-plate-with-hole/
62+
nextflow run main.nf -params-file workflow_config.json -c ../common/nextflow.config -plugins [email protected]
63+
64+
- name: Archive Linear Elastic plate with a hole benchmark data for snakemake
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: snakemake_results_linear-elastic-plate-with-hole
68+
path: |
69+
benchmarks/linear-elastic-plate-with-hole/snakemake_provenance/
70+
71+
- name: Archive Linear Elastic plate with a hole benchmark data for nextflow
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: nextflow_results_linear-elastic-plate-with-hole
75+
path: |
76+
benchmarks/linear-elastic-plate-with-hole/nextflow_results/
77+
78+
process-artifacts:
79+
runs-on: ubuntu-latest
80+
needs: tests
81+
steps:
82+
- name: Checkout repo content
83+
uses: actions/checkout@v2
84+
85+
- name: Download artifact
86+
uses: actions/download-artifact@v4
87+
with:
88+
name: snakemake_results_linear-elastic-plate-with-hole
89+
path: ./snakemake_provenance
90+
91+
- name: Setup Mambaforge with postprocessing env
92+
uses: conda-incubator/setup-miniconda@v3
93+
with:
94+
miniforge-version: latest
95+
activate-environment: postprocessing
96+
use-mamba: true
97+
environment-file: benchmarks/linear-elastic-plate-with-hole/environment_postprocessing.yml
98+
99+
- name: Run plotting script
100+
shell: bash -l {0}
101+
run: |
102+
python benchmarks/linear-elastic-plate-with-hole/plot_metrics.py ./snakemake_provenance
103+
104+
- name: Upload PDF plot as artifact
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: element-size-vs-stress-plot
108+
path: element_size_vs_stress.pdf

benchmarks/linear-elastic-plate-with-hole/nextflow.config renamed to benchmarks/common/nextflow.config

File renamed without changes.

benchmarks/linear-elastic-plate-with-hole/parameter_extractor.py renamed to benchmarks/common/parameter_extractor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
ParameterExtractorInterface,
55
)
66

7+
"""
8+
Parses the parameter configuration files and their corresponding output files. Returns a dictionary.
9+
https://github.com/izus-fokus/snakemake-report-plugin-metadata4ing
10+
11+
"""
12+
713
class ParameterExtractor(ParameterExtractorInterface):
814
def extract_params(self, rule_name: str, file_path: str) -> dict:
915
results = {}

benchmarks/linear-elastic-plate-with-hole/summarise_results.py renamed to benchmarks/common/summarize_results.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,29 @@ def create_summary(configurations: list[str],
77
solution_metrics: list[str],
88
solution_field_data: list[str],
99
benchmark: str,
10+
benchmark_uri: str,
1011
summary_json: str) -> None:
1112

13+
"""
14+
Create a summary JSON file containing simulation results and metadata.
15+
16+
Args:
17+
configurations: List of configuration names
18+
parameter_files: List of paths to parameter JSON files
19+
mesh_files: List of paths to mesh files
20+
solution_metrics: List of paths to metrics JSON files
21+
solution_field_data: List of paths to solution field data files
22+
benchmark: Name of the benchmark
23+
benchmark_uri: URI of the benchmark
24+
summary_json: Output path for the summary JSON file
25+
"""
26+
27+
1228
all_summaries = []
1329
for idx, config in enumerate(configurations):
14-
print(idx, config)
1530
summary = {}
1631
summary["benchmark"] = benchmark
17-
print(solution_metrics[idx])
32+
summary["benchmark_uri"] = benchmark_uri
1833
with open(parameter_files[idx], "r") as param_file:
1934
summary["parameters"] = json.load(param_file)
2035
summary["mesh"] = f"{config}/mesh"
@@ -38,6 +53,7 @@ def create_summary(configurations: list[str],
3853
parser.add_argument("--input_solution_metrics", nargs="+", type=str, required=True, help="Path to the metrics JSON file (input)")
3954
parser.add_argument("--input_solution_field_data", nargs="+", type=str, required=True, help="Path to the zipped solution files (input)")
4055
parser.add_argument("--input_benchmark", required=True, type=str, help="Name of the benchmark (input)")
56+
parser.add_argument("--input_benchmark_uri", required=True, type=str, help="URI of the benchmark (input)")
4157
parser.add_argument("--output_summary_json", required=True, type=str, help="Path to the summary JSON file (output)")
4258
args = parser.parse_args()
4359
create_summary(
@@ -47,5 +63,6 @@ def create_summary(configurations: list[str],
4763
args.input_solution_metrics,
4864
args.input_solution_field_data,
4965
args.input_benchmark,
66+
args.input_benchmark_uri,
5067
args.output_summary_json
5168
)

benchmarks/linear-elastic-plate-with-hole/Snakefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ configuration_to_parameter_file = config["configuration_to_parameter_file"]
66
configurations = config["configurations"]
77
tools = config["tools"]
88
benchmark = config["benchmark"]
9+
benchmark_uri = config["benchmark_uri"]
910

1011

1112
rule all:
@@ -43,7 +44,7 @@ rule summary:
4344
input:
4445
# the summary is performed for all configurations saved into a single file
4546
# (snakemake_results/linear-elastic-plate-with-hole/fenics/summary.json)
46-
script = "summarise_results.py",
47+
script = "../common/summarize_results.py",
4748
parameters = expand("{param}", param=[configuration_to_parameter_file[c] for c in configurations]),
4849
mesh = expand(f"{result_dir}/mesh/mesh_{{configuration}}.msh", configuration=configurations),
4950
metrics = lambda wildcards: expand(
@@ -68,5 +69,22 @@ rule summary:
6869
--input_solution_metrics {input.metrics} \
6970
--input_solution_field_data {input.solution_field_data} \
7071
--input_benchmark {benchmark} \
72+
--input_benchmark_uri {benchmark_uri} \
7173
--output_summary_json {output.summary_json}
72-
"""
74+
"""
75+
76+
"""
77+
Steps to add a new simulation tool to the workflow:
78+
79+
1. Write the tool-specific workflow, scripts, environment file and store them in the benchmarks/linear-elastic-plate-with-hole/tool_name/.
80+
2. Add the tool name to "tools" workflow_config.json (generated here using generate_config.py)
81+
82+
------------------------------------------------------------------------------------------------------------------------
83+
"rule all" defines the final target of the workflow. Knowing the final target, the snakemake determines
84+
the dependency chain automatically.
85+
86+
Wildcards in the rule definitions allow to generalize the rules for multiple configurations and tools.
87+
They act like placeholders (variables) in filenames or paths that get automatically filled in by Snakemake.
88+
89+
Information on snakemake rules: https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html
90+
"""

benchmarks/linear-elastic-plate-with-hole/plateWithHoleSolution.py renamed to benchmarks/linear-elastic-plate-with-hole/analytical_solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import sympy as sp
33

4-
class PlateWithHoleSolution:
4+
class AnalyticalSolution:
55
def __init__(self, E: float, nu: float, radius: float, L:float, load:float) -> None:
66
self.radius = radius
77
self.L = L

benchmarks/linear-elastic-plate-with-hole/environment_mesh.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: mesh-generation
2+
# Environment file for create_mesh.py script. Called by the main workflow.
3+
24
channels:
35
- conda-forge
46

benchmarks/linear-elastic-plate-with-hole/environment_postprocessing.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: postprocessing
2+
# Environment file for summarize_results.py script. Called by the main workflow.
3+
24
channels:
35
- conda-forge
46
- defaults

benchmarks/linear-elastic-plate-with-hole/fenics/environment_simulation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: fenics_simulation
2+
# Environment file for fenics simulation scripts. Called by fenics tool workflow.
3+
24
channels:
35
- conda-forge
46

benchmarks/linear-elastic-plate-with-hole/fenics/run_fenics_simulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Add parent directory to sys.path
1616
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
17-
from plateWithHoleSolution import PlateWithHoleSolution
17+
from analytical_solution import AnalyticalSolution
1818

1919

2020
def run_fenics_simulation(
@@ -76,7 +76,7 @@ def run_fenics_simulation(
7676
.magnitude
7777
)
7878

79-
analytical_solution = PlateWithHoleSolution(
79+
analytical_solution = AnalyticalSolution(
8080
E=E,
8181
nu=nu,
8282
radius=radius,

0 commit comments

Comments
 (0)