Skip to content

Commit 265b452

Browse files
committed
add some comments
1 parent 3c2b0de commit 265b452

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
2+
from os.path import join
23

34
files = list(Path(".").glob("parameters_*.json"))
45

@@ -25,7 +26,7 @@ def get_configuration(file):
2526
# configurations: {Path("parameters_1.json"): "1", ...}
2627
configurations = {file: get_configuration(file) for file in files if file.is_file()}
2728

28-
# Check for duplicate configuration values
29+
# Check for duplicate configuration values (the configurations should be unique)
2930
config_values = list(configurations.values())
3031
duplicates = set([x for x in config_values if config_values.count(x) > 1])
3132
if duplicates:
@@ -35,21 +36,20 @@ if duplicates:
3536
configuration_to_parameter_file = {v: str(k) for k, v in configurations.items()}
3637

3738
tools = ["fenics"]
38-
39-
result_dir = "snakemake_results/linear-elastic-plate-with-hole"
39+
benchmark = "linear-elastic-plate-with-hole"
40+
# results are stored in snakemake_results/linear-elastic-plate-with-hole/fenics
41+
result_dir = join("snakemake_results", benchmark)
4042

4143
rule all:
4244
input:
4345
expand(f"{result_dir}/{{tool}}/summary.json", tool=tools),
4446

45-
46-
47-
4847
rule create_mesh:
4948
input:
5049
script = "create_mesh.py",
5150
# the parameters file for the current configuration, this has to be a lambda function since
52-
# it the wildcard (configuration) has to be evaluated
51+
# the wildcard (configuration) has to be evaluated (the dictionary)
52+
# otherwise, you could just write configuration_to_parameter_file(configuration)
5353
parameters = lambda wildcards: configuration_to_parameter_file[wildcards.configuration],
5454
output:
5555
mesh = f"{result_dir}/mesh/mesh_{{configuration}}.msh",
@@ -76,6 +76,8 @@ rule run_simulation:
7676

7777
rule summary:
7878
input:
79+
# the summary is performed for all configurations saved into a single file
80+
# (snakemake_results/linear-elastic-plate-with-hole/fenics/summary.json)
7981
parameters = expand("{param}", param=[configuration_to_parameter_file[c] for c in configurations.values()]),
8082
mesh = expand(f"{result_dir}/mesh/mesh_{{configuration}}.msh", configuration=configurations.values()),
8183
metrics = lambda wildcards: expand(
@@ -96,7 +98,7 @@ rule summary:
9698
all_summaries = []
9799
for idx, config in enumerate(configurations.values()):
98100
summary = {}
99-
summary["benchmark"] = "linear-elastic-plate-with-hole"
101+
summary["benchmark"] = benchmark
100102
with open(input.parameters[idx], "r") as param_file:
101103
summary["parameters"] = json.load(param_file)
102104
summary["mesh"] = f"{config}/mesh"

benchmarks/linear-elastic-plate-with-hole/FEniCS/fenics/run_simulation.py

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

1919

2020
def run_simulation(
21-
parameter_file: str, mesh_file: str, solution_file_zip, metrics_file: str
21+
parameter_file: str, mesh_file: str, solution_file_zip: str, metrics_file: str
2222
) -> None:
2323
ureg = UnitRegistry()
2424
with open(parameter_file) as f:
@@ -147,7 +147,7 @@ def project(
147147
v: df.fem.Function | ufl.core.expr.Expr,
148148
V: df.fem.FunctionSpace,
149149
dx: ufl.Measure = ufl.dx,
150-
) -> None | df.fem.Function:
150+
) -> df.fem.Function:
151151
"""
152152
Calculates an approximation of `v` on the space `V`
153153

0 commit comments

Comments
 (0)