Merge pull request #5136 from akva2/add_damaris_test

Add a basic regression test for Damaris output
This commit is contained in:
Atgeirr Flø Rasmussen 2024-01-31 09:54:48 +01:00 committed by GitHub
commit ba2b434dc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 113 additions and 0 deletions

View File

@ -276,6 +276,48 @@ endfunction()
###########################################################################
###########################################################################
# TEST: compareDamarisFiles
###########################################################################
# Input:
# - casename: basename (no extension)
#
# Details:
# - This test class compares output from a simulation to reference files.
function(add_test_compareDamarisFiles)
set(oneValueArgs CASENAME FILENAME SIMULATOR ABS_TOL REL_TOL DIR DIR_PREFIX PREFIX MPI_PROCS)
set(multiValueArgs TEST_ARGS)
cmake_parse_arguments(PARAM "$" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if(NOT PARAM_DIR)
set(PARAM_DIR ${PARAM_CASENAME})
endif()
if(NOT PARAM_PREFIX)
set(PARAM_PREFIX compareDamarisFiles)
endif()
if(PARAM_MPI_PROCS)
set(MPI_PROCS ${PARAM_MPI_PROCS})
else()
set(MPI_PROCS 4)
endif()
set(RESULT_PATH ${BASE_RESULT_PATH}${PARAM_DIR_PREFIX}/${PARAM_SIMULATOR}+${PARAM_CASENAME})
set(TEST_ARGS ${PARAM_TEST_ARGS})
set(DRIVER_ARGS -i ${OPM_TESTS_ROOT}/${PARAM_DIR}
-r ${RESULT_PATH}
-b ${PROJECT_BINARY_DIR}/bin
-f ${PARAM_FILENAME}
-a ${PARAM_ABS_TOL}
-t ${PARAM_REL_TOL}
-c ${HDF5_DIFF_EXECUTABLE}
-n ${MPI_PROCS})
set(TEST_NAME ${PARAM_PREFIX}_${PARAM_SIMULATOR}+${PARAM_FILENAME})
opm_add_test(${TEST_NAME} NO_COMPILE
EXE_NAME ${PARAM_SIMULATOR}
DRIVER_ARGS ${DRIVER_ARGS}
TEST_ARGS ${TEST_ARGS})
set_tests_properties(${TEST_NAME} PROPERTIES PROCESSORS ${MPI_PROCS})
endfunction()
if(NOT TARGET test-suite)
add_custom_target(test-suite)
@ -362,6 +404,17 @@ if(MPI_FOUND)
ABS_TOL 0.0
REL_TOL 0.0)
# Single test for damaris
if(Damaris_FOUND)
opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-damaris-regressionTest.sh "")
add_test_compareDamarisFiles(CASENAME spe1_damaris
FILENAME SPE1CASE1
SIMULATOR flow
ABS_TOL ${abs_tol}
REL_TOL ${rel_tol}
DIR spe1)
endif()
include (${CMAKE_CURRENT_SOURCE_DIR}/parallelTests.cmake)
endif()

View File

@ -0,0 +1,60 @@
#!/bin/bash
# This runs a simulator, then compares the damaris output files
# against a reference.
if test $# -eq 0
then
echo -e "Usage:\t$0 <options> -- [additional simulator options]"
echo -e "\tMandatory options:"
echo -e "\t\t -i <path> Path to read deck from"
echo -e "\t\t -r <path> Path to store results in"
echo -e "\t\t -b <path> Path to simulator binary"
echo -e "\t\t -f <filename> Deck file name"
echo -e "\t\t -a <tol> Absolute tolerance in comparison"
echo -e "\t\t -t <tol> Relative tolerance in comparison"
echo -e "\t\t -c <path> Path to comparison tool"
echo -e "\t\t -e <filename> Simulator binary to use"
echo -e "\tOptional options:"
echo -e "\t\t -n <procs> Number of MPI processes to use"
exit 1
fi
MPI_PROCS=4
OPTIND=1
while getopts "i:r:b:f:a:t:c:e:n:" OPT
do
case "${OPT}" in
i) INPUT_DATA_PATH=${OPTARG} ;;
r) RESULT_PATH=${OPTARG} ;;
b) BINPATH=${OPTARG} ;;
f) FILENAME=${OPTARG} ;;
a) ABS_TOL=${OPTARG} ;;
t) REL_TOL=${OPTARG} ;;
c) H5DIFF_COMMAND=${OPTARG} ;;
e) EXE_NAME=${OPTARG} ;;
n) MPI_PROCS=${OPTARG} ;;
esac
done
shift $(($OPTIND-1))
TEST_ARGS="$@"
mkdir -p ${RESULT_PATH}
cd ${RESULT_PATH}
mpirun -np ${MPI_PROCS} ${BINPATH}/${EXE_NAME} ${INPUT_DATA_PATH}/${FILENAME} ${TEST_ARGS} --output-dir=${RESULT_PATH} --damaris-dedicated-cores=1 --damaris-save-mesh-to-hdf=true --enable-damaris-output=true --enable-ecl-output=false --damaris-output-hdf-collective=1 --damaris-save-to-hdf=1 --damaris-sim-name="${FILENAME}"
test $? -eq 0 || exit 1
cd ..
echo "=== Executing comparison for files if these exists in reference folder ==="
for fname in `ls ${RESULT_PATH}/${FILENAME}*.h5`
do
fname=`basename $fname`
if test -f ${INPUT_DATA_PATH}/opm-simulation-reference/${EXE_NAME}/${fname}
then
echo -e "\t - ${fname}"
${H5DIFF_COMMAND} -d ${ABS_TOL} ${INPUT_DATA_PATH}/opm-simulation-reference/${EXE_NAME}/${fname} ${RESULT_PATH}/${fname}
test $? -eq 0 || exit 1
${H5DIFF_COMMAND} -p ${REL_TOL} ${INPUT_DATA_PATH}/opm-simulation-reference/${EXE_NAME}/${fname} ${RESULT_PATH}/${fname}
test $? -eq 0 || exit 1
fi
done