Skip to content
Snippets Groups Projects
Verified Commit 3e1b9721 authored by Lars Bilke's avatar Lars Bilke
Browse files

[T] Added snakemake wrapper for vtkdiff.

parent 79fcfe87
No related branches found
No related tags found
No related merge requests found
# Usage, e.g.:
# # generateStructuredMesh and ExtractBoundary have to be in the path
# snakemake -s ExtractBoundary.smk -j 1 --configfile $HOME/code/ogs6/build/Tests/snakemake.yaml -d $HOME/code/ogs6/build/Tests/Data/FileIO
# snakemake -s ExtractBoundary.smk -j 1 --configfile $HOME/code/ogs6/build/Tests/snakemake.yaml
output_path = "FileIO"
import os
os.environ["PATH"] += os.pathsep + os.pathsep.join([config['BIN_DIR']])
workdir: f"{config['Data_BINARY_DIR']}/{output_path}"
# "entry point", otherwise one would had to specify output files as snakemake
# arguments
......@@ -36,9 +37,12 @@ rule vtkdiff:
"square_1x1_{type}_boundary.vtu"
output:
"square_1x1_{type}_boundary_diff.out"
shell:
"""
vtkdiff {input} {config[Data_SOURCE_DIR]}/FileIO/square_1x1_{wildcards.type}_boundary.vtu -a bulk_node_ids -b bulk_node_ids --abs 0 --rel 0 > {output}
vtkdiff {input} {config[Data_SOURCE_DIR]}/FileIO/square_1x1_{wildcards.type}_boundary.vtu -a bulk_element_ids -b bulk_element_ids --abs 0 --rel 0 >> {output}
vtkdiff {input} {config[Data_SOURCE_DIR]}/FileIO/square_1x1_{wildcards.type}_boundary.vtu -a bulk_face_ids -b bulk_face_ids --abs 0 --rel 0 >> {output}
"""
params:
fields = [
# second field name can be omitted if identical
["bulk_node_ids", 0, 0],
["bulk_element_ids", 0, 0],
["bulk_face_ids", 0, 0]
]
wrapper:
f"file://{config['SOURCE_DIR']}/scripts/snakemake/vtkdiff"
......@@ -311,7 +311,6 @@ if(SNAKEMAKE AND NOT OGS_USE_MPI)
COMMAND ${SNAKEMAKE}
-j 1
--configfile ${PROJECT_BINARY_DIR}/snakemake.yaml
-d ${Data_BINARY_DIR}/FileIO/
-s ${CMAKE_CURRENT_SOURCE_DIR}/ExtractBoundary.smk
)
endif()
......
"""Snakemake wrapper for vtkdiff."""
__author__ = "Lars Bilke"
__copyright__ = "Copyright 2020, OpenGeoSys Community"
__license__ = "BSD"
import os
from snakemake.shell import shell
output_path = os.getcwd().replace(snakemake.config['Data_BINARY_DIR'], "")
for field in snakemake.params.fields:
field_a = field[0]
offset = 0
if len(field) == 4:
offset = 1
field_b = field[0 + offset]
abs_tol = field[1 + offset]
rel_tol = field[2 + offset]
shell(
"""
rm {snakemake.output[0]} || true
vtkdiff {snakemake.input[0]} \
{snakemake.config[Data_SOURCE_DIR]}/{output_path}/{snakemake.input[0]} \
-a {field_a} -b {field_b} \
--abs {abs_tol} --rel {rel_tol} > {snakemake.output[0]}
"""
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment