diff --git a/Applications/Utils/ExtractBoundary.smk b/Applications/Utils/ExtractBoundary.smk index 82b11e57024eade1432832bdc063a753f1403ec4..32cf1733990a21e8dea06b6bb25f850495254cc4 100644 --- a/Applications/Utils/ExtractBoundary.smk +++ b/Applications/Utils/ExtractBoundary.smk @@ -1,9 +1,10 @@ # 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" diff --git a/Applications/Utils/Tests.cmake b/Applications/Utils/Tests.cmake index b66cebc940254171aa0ef2af9338cf1648e6ef1e..a6ac899544c2bc918abd4970a4d07b3f891c3a13 100644 --- a/Applications/Utils/Tests.cmake +++ b/Applications/Utils/Tests.cmake @@ -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() diff --git a/scripts/snakemake/vtkdiff/wrapper.py b/scripts/snakemake/vtkdiff/wrapper.py new file mode 100644 index 0000000000000000000000000000000000000000..2347d1bc31c285eab12e925597ed0e195470db6d --- /dev/null +++ b/scripts/snakemake/vtkdiff/wrapper.py @@ -0,0 +1,29 @@ +"""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]} + """ + )