opm-simulators/compareECLFiles.cmake

144 lines
6.3 KiB
CMake
Raw Normal View History

2017-01-23 03:42:09 -06:00
# This script manages the addition of tests.
# The tests are orchestrated by a shell script,
# configured using opm_set_test_driver()
# and then the appropriate helper macro is called to
# register the ctest entry through the opm_add_test macro.
# Information such as the binary to call and test tolerances
# are passed from the build system to the driver script through
# command line parameters. See the opm_add_test() documentation for
# details on the parameters passed to the macro.
# Define some paths
2016-08-04 06:54:37 -05:00
set(BASE_RESULT_PATH ${PROJECT_BINARY_DIR}/tests/results)
###########################################################################
2016-08-04 06:54:37 -05:00
# TEST: compareECLFiles
###########################################################################
2016-08-04 06:54:37 -05:00
# Input:
# - casename: basename (no extension)
#
2017-01-23 03:42:09 -06:00
# Details:
# - This test class compares output from a simulation to reference files.
macro (add_test_compareECLFiles casename filename simulator abs_tol rel_tol prefix dirprefix)
if(${ARGC} GREATER 7)
set(DIR ${ARGN})
else()
set(DIR ${casename})
endif()
set(RESULT_PATH ${BASE_RESULT_PATH}${dirprefix}/${simulator}+${casename})
opm_add_test(${prefix}_${simulator}+${filename} NO_COMPILE
EXE_NAME ${simulator}
DRIVER_ARGS ${OPM_DATA_ROOT}/${DIR} ${RESULT_PATH}
${CMAKE_BINARY_DIR}/bin
${filename}
${abs_tol} ${rel_tol}
2016-08-04 06:54:37 -05:00
${COMPARE_SUMMARY_COMMAND}
${COMPARE_ECL_COMMAND}
TEST_ARGS ${OPM_DATA_ROOT}/${DIR}/${filename}.DATA )
endmacro (add_test_compareECLFiles)
2016-11-04 08:47:59 -05:00
###########################################################################
2017-01-23 04:15:49 -06:00
# TEST: add_test_compare_restarted_simulation
2016-11-04 08:47:59 -05:00
###########################################################################
# Input:
# - casename: basename (no extension)
#
2017-01-23 03:42:09 -06:00
# Details:
# - This test class compares the output from a restarted simulation
# to that of a non-restarted simulation.
macro (add_test_compare_restarted_simulation casename filename simulator abs_tol rel_tol)
2016-11-04 08:47:59 -05:00
set(RESULT_PATH ${BASE_RESULT_PATH}/restart/${simulator}+${casename})
2017-01-23 04:15:49 -06:00
opm_add_test(compareRestartedSim_${simulator}+${filename} NO_COMPILE
EXE_NAME ${simulator}
2016-11-04 08:47:59 -05:00
DRIVER_ARGS ${OPM_DATA_ROOT}/${casename} ${RESULT_PATH}
${CMAKE_BINARY_DIR}/bin
${filename}
${abs_tol} ${rel_tol}
${COMPARE_SUMMARY_COMMAND}
${COMPARE_ECL_COMMAND}
TEST_ARGS ${OPM_DATA_ROOT}/${casename}/${filename})
2017-01-23 04:15:49 -06:00
endmacro (add_test_compare_restarted_simulation)
2016-11-04 08:47:59 -05:00
###########################################################################
2017-01-23 04:15:49 -06:00
# TEST: add_test_compare_parallel_simulation
###########################################################################
# Input:
# - casename: basename (no extension)
#
2017-01-23 03:42:09 -06:00
# Details:
# - This test class compares the output from a parallel simulation
# to the output from the serial instance of the same model.
macro (add_test_compare_parallel_simulation casename filename simulator abs_tol rel_tol)
set(RESULT_PATH ${BASE_RESULT_PATH}/parallel/${simulator}+${casename})
# Add test that runs flow_mpi and outputs the results to file
2017-01-23 04:15:49 -06:00
opm_add_test(compareParallelSim_${simulator}+${filename} NO_COMPILE
EXE_NAME ${simulator}
DRIVER_ARGS ${OPM_DATA_ROOT}/${casename} ${RESULT_PATH}
${CMAKE_BINARY_DIR}/bin
${filename}
${abs_tol} ${rel_tol}
${COMPARE_SUMMARY_COMMAND}
${COMPARE_ECL_COMMAND}
TEST_ARGS ${OPM_DATA_ROOT}/${casename}/${filename})
2017-01-23 04:15:49 -06:00
endmacro (add_test_compare_parallel_simulation)
if(NOT TARGET test-suite)
add_custom_target(test-suite)
endif()
# Regression tests
opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-regressionTest.sh "")
# Set absolute tolerance to be used passed to the macros in the following tests
set(abs_tol 2e-2)
set(rel_tol 1e-5)
add_test_compareECLFiles(spe1 SPE1CASE2 flow_ebos ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(spe1_2p SPE1CASE2_2P flow_ebos ${abs_tol} ${rel_tol} compareECLFiles "" spe1)
add_test_compareECLFiles(spe1 SPE1CASE2 flow_legacy ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(spe1_2p SPE1CASE2_2P flow_legacy ${abs_tol} ${rel_tol} compareECLFiles "" spe1)
add_test_compareECLFiles(spe1 SPE1CASE1 flow_sequential ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(spe3 SPE3CASE1 flow_ebos ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(spe3 SPE3CASE1 flow_legacy ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(spe9 SPE9_CP_SHORT flow_ebos ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(spe9 SPE9_CP_SHORT flow_legacy ${abs_tol} ${rel_tol} compareECLFiles "")
add_test_compareECLFiles(msw_2d_h 2D_H__ flow_multisegment ${abs_tol} ${rel_tol} compareECLFiles "")
2016-11-04 08:47:59 -05:00
# Restart tests
opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-restart-regressionTest.sh "")
# Cruder tolerances for the restarted tests
set(abs_tol_restart 2e-1)
set(rel_tol_restart 4e-5)
foreach(sim flow_legacy flow_ebos)
2017-03-03 07:34:00 -06:00
add_test_compare_restarted_simulation(spe1 SPE1CASE2_ACTNUM ${sim} ${abs_tol_restart} ${rel_tol_restart})
add_test_compare_restarted_simulation(spe9 SPE9_CP_SHORT ${sim} ${abs_tol_restart} ${rel_tol_restart})
endforeach()
# Init tests
opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-init-regressionTest.sh "")
foreach(sim flow_legacy flow_ebos)
2017-03-03 07:34:11 -06:00
add_test_compareECLFiles(norne NORNE_ATW2013 ${sim} ${abs_tol} ${rel_tol} compareECLInitFiles /init)
endforeach()
# Parallel tests
if(MPI_FOUND)
opm_set_test_driver(${PROJECT_SOURCE_DIR}/tests/run-parallel-regressionTest.sh "")
# Different tolerances for these tests
set(abs_tol_parallel 0.02)
set(rel_tol_parallel 1e-5)
foreach(sim flow_mpi flow_ebos)
add_test_compare_parallel_simulation(spe1 SPE1CASE2 ${sim} ${abs_tol_parallel} ${rel_tol_parallel})
add_test_compare_parallel_simulation(spe9 SPE9_CP_SHORT ${sim} ${abs_tol_parallel} ${rel_tol_parallel})
endforeach()
add_test_compare_parallel_simulation(spe3 SPE3CASE1 flow_mpi ${abs_tol_parallel} ${rel_tol_parallel})
endif()