forked from OPM/opm-upscaling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestUpscalingBinaries.cmake
111 lines (99 loc) · 5.24 KB
/
TestUpscalingBinaries.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Add tests to check if the upscaling binaries calculates correctly
#
# Tests are added in two steps (see already added tests below for examples):
#
# 1) Add test that runs the binary and output results to a file:
# add_test(<testname> <command>)
# <command> refers to the command used to run the binary with input variables in a terminal
#
# 2) Add test that compares the output from the previous test:
# add_test(<testname> ${PROJECT_BINARY_DIR}/bin/compare_upscaling_results <path_to_refSoln> <path_to_newSoln>
# ${tol} <number_of_result_rows> <number_of_result_cols>)
# This test should depend on the first test, so include:
# set_tests_properties(<test1> PROPERTIES DEPENDS <test2>)
#
# Some naming conventions:
# The first test should be named: run_<binary_name>_<options>_<model_name>
# The second test: compare_<binary_name>_<options>_<model_name>
#
# Test models and reference solutions are available in ${PROJECT_BINARY_DIR}/tests/input_data.
# New test data can be made available in the build tree by including them in CMakeLists_files.cmake,
# under 'APPEND TEST_SOURCE_FILES'.
# Set absolute tolerance to be used for testing
set(tol 1e-2)
# Define some paths
set(RESULT_PATH ${PROJECT_BINARY_DIR}/tests/results/)
set(INPUT_DATA_PATH ${PROJECT_BINARY_DIR}/tests/input_data/)
# Create directory to store upscaling results in
file(MAKE_DIRECTORY ${RESULT_PATH})
###########################################################################
# TEST: upscale_perm
###########################################################################
# Define macro that performs the two steps mentioned above for upscale_perm
# Input:
# - gridname: basename (no extension) of grid model
# - bcs: Boundary condition type (f, l or p, or combinations of these)
# - rows: Number of rows in result file that is to be compared
# This macro assumes that ${gridname}.grdecl is found in directory ${INPUT_DATA_PATH}grids/
# and that upscale_perm_BC${bcs}_${gridname}.txt is found in ${INPUT_DATA_PATH}reference_solutions
macro (add_test_upscale_perm gridname bcs rows)
# Add test that runs upscale_perm and outputs the results to file
add_test(NAME run_upscale_perm_BC${bcs}_${gridname}
COMMAND upscale_perm
-bc ${bcs}
-output ${RESULT_PATH}upscale_perm_BC${bcs}_${gridname}.txt
${INPUT_DATA_PATH}grids/${gridname}.grdecl)
# Add test that compare the results from the previous test with a reference solution
add_test(NAME compare_upscale_perm_BC${bcs}_${gridname}
COMMAND compare_upscaling_results
${INPUT_DATA_PATH}reference_solutions/upscale_perm_BC${bcs}_${gridname}.txt
${RESULT_PATH}upscale_perm_BC${bcs}_${gridname}.txt
${tol}
${rows} 3)
# Set dependency of the two tests
set_tests_properties(compare_upscale_perm_BC${bcs}_${gridname} PROPERTIES DEPENDS
run_upscale_perm_BC${bcs}_${gridname})
endmacro (add_test_upscale_perm gridname bcs)
###########################################################################
# TEST: upscale_elasticity
###########################################################################
# Define macro that performs the two steps mentioned above for upscale_elasticity
# Input:
# - gridname: basename (no extension) of grid model
# - method: method to apply
# This macro assumes that ${gridname}.grdecl is found in directory ${INPUT_DATA_PATH}grids/
# and that upscale_elasticity_${method}_${gridname}.txt is found in ${INPUT_DATA_PATH}reference_solutions
macro (add_test_upscale_elasticity gridname method)
# Add test that runs upscale_perm and outputs the results to file
add_test(NAME run_upscale_elasticity_${method}_${gridname}
COMMAND upscale_elasticity
output=${RESULT_PATH}upscale_elasticity_${method}_${gridname}.txt
gridfilename=${INPUT_DATA_PATH}grids/${gridname}.grdecl
method=${method})
# Add test that compare the results from the previous test with a reference solution
add_test(NAME compare_upscale_elasticity_${method}_${gridname}
COMMAND compare_upscaling_results
${INPUT_DATA_PATH}reference_solutions/upscale_elasticity_${method}_${gridname}.txt
${RESULT_PATH}upscale_elasticity_${method}_${gridname}.txt
${tol}
6 6)
# Set dependency of the two tests
set_tests_properties(compare_upscale_elasticity_${method}_${gridname} PROPERTIES DEPENDS
run_upscale_elasticity_${method}_${gridname})
endmacro (add_test_upscale_elasticity gridname method rows)
# Make sure that we build the helper executable before running tests
# (the "tests" target is setup in OpmLibMain.cmake)
add_dependencies (tests upscale_perm)
add_dependencies (tests compare_upscaling_results)
# Add tests for different models
add_test_upscale_perm(PeriodicTilted p 3)
add_test_upscale_perm(27cellsAniso flp 9)
add_test_upscale_perm(27cellsIso flp 9)
add_test_upscale_perm(EightCells fl 6)
add_test_upscale_perm(Hummocky flp 9)
if((DUNE_ISTL_VERSION_MAJOR GREATER 2) OR
(DUNE_ISTL_VERSION_MAJOR EQUAL 2 AND DUNE_ISTL_VERSION_MINOR GREATER 2))
add_dependencies (tests upscale_elasticity)
add_test_upscale_elasticity(EightCells mpc)
add_test_upscale_elasticity(EightCells mortar)
endif()