diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8b51baeeca..3fa139a9dd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -36,7 +36,7 @@ jobs: export DYLD_LIBRARY_PATH=$PWD/lib ctest --output-on-failure env: - ECL_SKIP_SIGNAL: absolutely + RD_SKIP_SIGNAL: absolutely ERT_SHOW_BACKTRACE: yes please! @@ -88,7 +88,7 @@ jobs: python -m pip install pytest # pytest adds every directory up-to and including python/ into sys.path, - # meaning that "import ecl" will import python/ecl and not the installed + # meaning that "import resdata" will import python/ecl and not the installed # one. This doesn't work because the resdata.so library only exists in # site-packages, so we copy directories required by the tests out into its # own temporary directory. @@ -100,7 +100,7 @@ jobs: cp -R {..,$PWD}/python/tests # Env vars - export ECL_SKIP_SIGNAL=1 + export RD_SKIP_SIGNAL=1 export ERT_SHOW_BACKTRACE=1 # Run tests diff --git a/.gitignore b/.gitignore index db01f0c308..79a8ab0722 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ python/lib64 /temp-build /libert_util/tests/data/latex_OK.pdf /test-data/Equinor -/python/python/ert/ecl/ecl_local.py /GPATH /GRTAGS /GTAGS @@ -28,11 +27,11 @@ __resdata_info.py /venv/ /_skbuild/ -/python/ecl/version.py +/python/resdata/version.py .* *.egg-info/ /dist /dist-* -CMakeSettings.json \ No newline at end of file +CMakeSettings.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 15b3bf093f..17b7339694 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(ecl C CXX) +project(restdata C CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -79,25 +79,25 @@ conan_cmake_run( # ----------------------------------------------------------------- -set(ECL_VERSION_MAJOR 0) -set(ECL_VERSION_MINOR 0) -set(ECL_VERSION_MICRO "not-available") +set(RD_VERSION_MAJOR 0) +set(RD_VERSION_MINOR 0) +set(RD_VERSION_MICRO "not-available") # If the micro version is not integer, that should be interpreted as a # development version leading towards version MAJOR.MINOR.0 execute_process(COMMAND date "+%Y-%m-%d %H:%M:%S" - OUTPUT_VARIABLE ECL_BUILD_TIME) -string(STRIP "${ECL_BUILD_TIME}" ECL_BUILD_TIME) + OUTPUT_VARIABLE RD_BUILD_TIME) +string(STRIP "${RD_BUILD_TIME}" RD_BUILD_TIME) -if(ECL_VERSION) +if(RD_VERSION) # Have we been provided with an explicitly-set version? - string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\1" ECL_VERSION_MAJOR - "${ECL_VERSION}") - string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\2" ECL_VERSION_MINOR - "${ECL_VERSION}") - string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\3" ECL_VERSION_MICRO - "${ECL_VERSION}") + string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\1" RD_VERSION_MAJOR + "${RD_VERSION}") + string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\2" RD_VERSION_MINOR + "${RD_VERSION}") + string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\3" RD_VERSION_MICRO + "${RD_VERSION}") else() # Otherwise try to discover it via git find_package(Git) @@ -132,11 +132,11 @@ else() OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\1" ECL_VERSION_MAJOR + string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\1" RD_VERSION_MAJOR "${GIT_TAG}") - string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\2" ECL_VERSION_MINOR + string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\2" RD_VERSION_MINOR "${GIT_TAG}") - string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\3" ECL_VERSION_MICRO + string(REGEX REPLACE "^([^.]+)\\.([^.]+)\\.(.+)$" "\\3" RD_VERSION_MICRO "${GIT_TAG}") else() set(GIT_COMMIT "unknown (git not found!)") @@ -148,14 +148,14 @@ endif() message( STATUS - "resdata version: ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + "resdata version: ${RD_VERSION_MAJOR}.${RD_VERSION_MINOR}.${RD_VERSION_MICRO}" ) # ----------------------------------------------------------------- option(BUILD_TESTS "Should the tests be built" OFF) option(BUILD_APPLICATIONS "Should we build small utility applications" OFF) -option(BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF) +option(BUILD_RD_SUMMARY "Build the commandline application rd_summary" OFF) option(ENABLE_PYTHON "Build and install the Python wrappers" OFF) option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(ERT_USE_OPENMP "Use OpenMP" OFF) @@ -176,11 +176,11 @@ if(EXISTS ${EQUINOR_TESTDATA_ROOT}) message(STATUS "Linking testdata: ${LINK} -> ${EQUINOR_TESTDATA_ROOT}") set(_equinor_test_data ${CMAKE_SOURCE_DIR}/test-data/Equinor) - set(_eclpath ${_equinor_test_data}/ECLIPSE) + set(_resdatapath ${_equinor_test_data}/ECLIPSE) set(_geopath ${_equinor_test_data}/Geometry) endif() set(_local_test_data "${CMAKE_CURRENT_SOURCE_DIR}/test-data/local") -set(_local_eclpath ${_local_test_data}/ECLIPSE) +set(_local_resdatapath ${_local_test_data}/ECLIPSE) # output libs to some lib/ path for testing set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) @@ -472,7 +472,7 @@ endif() if(NOT SKBUILD) # Avoid installing when calling from python setup.py - install(EXPORT ecl-config DESTINATION share/cmake/ecl) - export(TARGETS ecl FILE eclConfig.cmake) - export(PACKAGE ecl) + install(EXPORT resdata-config DESTINATION share/cmake/resdata) + export(TARGETS resdata FILE resdataConfig.cmake) + export(PACKAGE resdata) endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9e4c7be29c..164e1f174a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -The following is a set of guidelines for contributing to ecl. +The following is a set of guidelines for contributing to resdata. ## Ground Rules diff --git a/README.md b/README.md index 7362e74223..fdf21c3fdf 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ compiler such as GNU GCC, the CMake build system and, optionally, zlib. ```bash $ git clone https://github.com/Equinor/ecl -$ mkdir ecl/build -$ cd ecl/build +$ mkdir resdata/build +$ cd resdata/build $ cmake .. $ make $ make install @@ -70,8 +70,8 @@ compiler, CMake and, optionally, zlib. ```bash $ git clone https://github.com/Equinor/ecl -$ mkdir ecl/build -$ cd ecl/build +$ mkdir resdata/build +$ cd resdata/build $ pip install -r ../requirements.txt $ cmake .. -DENABLE_PYTHON=ON $ make @@ -92,10 +92,10 @@ $ export LD_LIBRARY_PATH=/path/to/install/lib64:$LD_LIBRARY_PATH Then you can fire up your Python interpreter and try it out: ```python ->>> from ecl.summary import EclSum +>>> from resdata.summary import RdSum >>> import sys ->>> summary = EclSum(sys.argv[1]) +>>> summary = RdSum(sys.argv[1]) >>> fopt = summary.numpy_vector("FOPT") ``` diff --git a/WINDOWS.md b/WINDOWS.md index a40aeb348a..d8c1a84f90 100644 --- a/WINDOWS.md +++ b/WINDOWS.md @@ -24,4 +24,4 @@ ~~~~ 6. For **_resdata_** to be accessible in Python the `%INSTALLPATH%\lib\pythonX.Y\site-package` and Python subdirectories must be added to the `PATH` and `PYTHONPATH` variables. Where `pythonx.y` is the current Python version _e.g._ (`python3.9`, `python3.10` _etc._) . -8. Open a Python interactive session and run `import ecl` to check that the install and paths are now set. +8. Open a Python interactive session and run `import resdata` to check that the install and paths are now set. diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt index bbe948226e..637e1cc037 100644 --- a/applications/CMakeLists.txt +++ b/applications/CMakeLists.txt @@ -1,18 +1,18 @@ project(resdata-applications) function(target_link_resdata target) - target_link_libraries(${target} ecl) + target_link_libraries(${target} resdata) if(SKBUILD) set_target_properties(${target} PROPERTIES INSTALL_RPATH "$ORIGIN/../.libs") endif() endfunction() if(BUILD_APPLICATIONS) - add_executable(sum_write ecl/sum_write.cpp) - add_executable(make_grid ecl/make_grid.c) - add_executable(grdecl_grid ecl/grdecl_grid.c) - add_executable(summary ecl/view_summary.cpp) - add_executable(kw_extract ecl/kw_extract.cpp) + add_executable(sum_write resdata/sum_write.cpp) + add_executable(make_grid resdata/make_grid.c) + add_executable(grdecl_grid resdata/grdecl_grid.c) + add_executable(summary resdata/view_summary.cpp) + add_executable(kw_extract resdata/kw_extract.cpp) target_link_resdata(sum_write) target_link_resdata(make_grid) target_link_resdata(grdecl_grid) @@ -23,14 +23,14 @@ if(BUILD_APPLICATIONS) foreach( app - ecl_pack - ecl_unpack + rd_pack + rd_unpack grid_info grid_dump grid_dump_ascii select_test load_test) - add_executable(${app} ecl/${app}.c) + add_executable(${app} resdata/${app}.c) target_link_resdata(${app}) list(APPEND apps ${app}) if(ERT_LINUX) @@ -41,7 +41,7 @@ if(BUILD_APPLICATIONS) if(ERT_LINUX) foreach(app convert grdecl_test kw_list) - add_executable(${app} ecl/${app}.c) + add_executable(${app} resdata/${app}.c) target_link_resdata(${app}) # The .x extension creates problems on windows set_target_properties(${app} PROPERTIES SUFFIX ".x") @@ -62,12 +62,12 @@ if(BUILD_APPLICATIONS) list(APPEND apps segment_info CF_dump ri_well_test) endif() -if(BUILD_ECL_SUMMARY) - add_executable(ecl_summary ecl/view_summary.cpp) - target_link_resdata(ecl_summary) - list(APPEND apps ecl_summary) +if(BUILD_RD_SUMMARY) + add_executable(rd_summary resdata/view_summary.cpp) + target_link_resdata(rd_summary) + list(APPEND apps rd_summary) - install(FILES ${PROJECT_SOURCE_DIR}/man/man1/ecl_summary.1 + install(FILES ${PROJECT_SOURCE_DIR}/man/man1/rd_summary.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endif() diff --git a/applications/man/man1/rd_summary.1 b/applications/man/man1/rd_summary.1 index f881dc0efc..9f140d120a 100644 --- a/applications/man/man1/rd_summary.1 +++ b/applications/man/man1/rd_summary.1 @@ -1,7 +1,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH ecl_summary "1" "November 8 2016" +.TH rd_summary "1" "October 25 2023" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -15,12 +15,12 @@ .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME -ecl_summary \- Program to extract summary vectors from ECLIPSE files +rd_summary \- Program to extract summary vectors from ECLIPSE files .SH DESCRIPTION -The ecl_summary program is used to quickly extract summary vectors +The rd_summary program is used to quickly extract summary vectors from ECLIPSE summary files. The program is invoked as: .PP -computer> ecl_summary \fI\,/Path/to/ECLIPSE\/\fP key1 key2 key3 .... +computer> rd_summary \fI\,/Path/to/ECLIPSE\/\fP key1 key2 key3 .... .PP Here ECLIPSE is the name of an existing case, you can give it with extension, or without; the case need not be in the current directory. @@ -55,11 +55,11 @@ The option \fB\-\-list\fR can be used to list all available keys. .HP \fB\-\-no\-restart\fR: If the simulation in question is a restart, i.e a prediction .IP -which starts at the end of the historical period, the ecl_summary +which starts at the end of the historical period, the rd_summary program will by default also load historical data. If the \fB\-\-no\-restart\fR option is used the program will not look for old results. .HP -\fB\-\-no\-header\fR: By default ecl_summary will print a header line at the top, with the +\fB\-\-no\-header\fR: By default rd_summary will print a header line at the top, with the .IP option \fB\-\-no\-header\fR this will be suppressed. .HP @@ -71,7 +71,7 @@ The options should come before the ECLIPSE basename. .PP Example1: .TP -computer> ecl_summary +computer> rd_summary CASE1_XXX WWCT:F\-36 FOPT FWPT .IP This example will load results from case 'CASE1_XXX' and print the @@ -79,30 +79,30 @@ results for keys 'WWCT:F\-36', 'FOPT' and 'FWPT' on standard out. .PP Example2: .TP -computer> ecl_summary +computer> rd_summary \fB\-\-list\fR CASE2_XXX "*:F\-36" "BPR:*" .IP This example will list all the available keys which end with \&':F\-36' and those which start with 'BPR:'. Observe the use of quoting characters "" when using shell wildcards. .PP -The ecl_summary program will look for and load both unified and +The rd_summary program will look for and load both unified and non\-unified and formatted and non\-formatted files. The default search order is: UNSMRY, Snnnn, FUNSMRY, Annnn, however you can manipulate this with the extension to the basename: .PP -* If the extension corresponds to an unformatted file, ecl_summary +* If the extension corresponds to an unformatted file, rd_summary .IP will only look for unformatted files. .PP -* If the extension corresponds to a unified file, ecl_summary will +* If the extension corresponds to a unified file, rd_summary will .IP only look for unified files. .PP -The ecl_summary program is used to quickly extract summary vectors +The rd_summary program is used to quickly extract summary vectors from ECLIPSE summary files. The program is invoked as: .PP -computer> ecl_summary \fI\,/Path/to/ECLIPSE\/\fP key1 key2 key3 .... +computer> rd_summary \fI\,/Path/to/ECLIPSE\/\fP key1 key2 key3 .... .PP Here ECLIPSE is the name of an existing case, you can give it with extension, or without; the case need not be in the current directory. @@ -136,11 +136,11 @@ The option \fB\-\-list\fR can be used to list all available keys. .HP \fB\-\-no\-restart\fR: If the simulation in question is a restart, i.e a prediction .IP -which starts at the end of the historical period, the ecl_summary +which starts at the end of the historical period, the rd_summary program will by default also load historical data. If the \fB\-\-no\-restart\fR option is used the program will not look for old results. .HP -\fB\-\-no\-header\fR: By default ecl_summary will print a header line at the top, with the +\fB\-\-no\-header\fR: By default rd_summary will print a header line at the top, with the .IP option \fB\-\-no\-header\fR this will be suppressed. .HP @@ -152,7 +152,7 @@ The options should come before the ECLIPSE basename. .PP Example1: .TP -computer> ecl_summary +computer> rd_summary CASE1_XXX WWCT:F\-36 FOPT FWPT .IP This example will load results from case 'CASE1_XXX' and print the @@ -160,23 +160,23 @@ results for keys 'WWCT:F\-36', 'FOPT' and 'FWPT' on standard out. .PP Example2: .TP -computer> ecl_summary +computer> rd_summary \fB\-\-list\fR CASE2_XXX "*:F\-36" "BPR:*" .IP This example will list all the available keys which end with \&':F\-36' and those which start with 'BPR:'. Observe the use of quoting characters "" when using shell wildcards. .PP -The ecl_summary program will look for and load both unified and +The rd_summary program will look for and load both unified and non\-unified and formatted and non\-formatted files. The default search order is: UNSMRY, Snnnn, FUNSMRY, Annnn, however you can manipulate this with the extension to the basename: .PP -* If the extension corresponds to an unformatted file, ecl_summary +* If the extension corresponds to an unformatted file, rd_summary .IP will only look for unformatted files. .PP -* If the extension corresponds to a unified file, ecl_summary will +* If the extension corresponds to a unified file, rd_summary will .IP only look for unified files. .PP diff --git a/applications/resdata/convert.c b/applications/resdata/convert.c index 7d0fc9b4f2..27341fd4d7 100644 --- a/applications/resdata/convert.c +++ b/applications/resdata/convert.c @@ -23,18 +23,18 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include void file_convert(const char *src_file, const char *target_file, - ecl_file_enum file_type, bool fmt_src) { + rd_file_enum file_type, bool fmt_src) { fortio_type *src, *target; bool formatted_src; printf("Converting %s -> %s \n", src_file, target_file); - if (file_type != ECL_OTHER_FILE) + if (file_type != RD_OTHER_FILE) formatted_src = fmt_src; else { if (util_fmt_bit8(src_file)) @@ -43,18 +43,18 @@ void file_convert(const char *src_file, const char *target_file, formatted_src = false; } - target = fortio_open_writer(target_file, !formatted_src, ECL_ENDIAN_FLIP); - src = fortio_open_reader(src_file, formatted_src, ECL_ENDIAN_FLIP); + target = fortio_open_writer(target_file, !formatted_src, RD_ENDIAN_FLIP); + src = fortio_open_reader(src_file, formatted_src, RD_ENDIAN_FLIP); while (true) { if (fortio_read_at_eof(src)) break; { - ecl_kw_type *ecl_kw = ecl_kw_fread_alloc(src); - if (ecl_kw) { - ecl_kw_fwrite(ecl_kw, target); - ecl_kw_free(ecl_kw); + rd_kw_type *rd_kw = rd_kw_fread_alloc(src); + if (rd_kw) { + rd_kw_fwrite(rd_kw, target); + rd_kw_free(rd_kw); } else { fprintf(stderr, "Reading keyword failed \n"); break; @@ -77,11 +77,11 @@ int main(int argc, char **argv) { char *target_file; int report_nr; - ecl_file_enum file_type; + rd_file_enum file_type; bool fmt_file; - file_type = ecl_util_get_file_type(src_file, &fmt_file, &report_nr); + file_type = rd_get_file_type(src_file, &fmt_file, &report_nr); - if (file_type == ECL_OTHER_FILE) { + if (file_type == RD_OTHER_FILE) { if (argc != 3) { fprintf(stderr, "When the file can not be recognized on the name as an " @@ -98,9 +98,8 @@ int main(int argc, char **argv) { char *basename; char *extension; src_file = argv[file_nr]; - file_type = - ecl_util_get_file_type(src_file, &fmt_file, &report_nr); - if (file_type == ECL_OTHER_FILE) { + file_type = rd_get_file_type(src_file, &fmt_file, &report_nr); + if (file_type == RD_OTHER_FILE) { fprintf(stderr, "File: %s - problem \n", src_file); fprintf(stderr, "In a list of many files ALL must be " "recognizable by their name. \n"); @@ -109,8 +108,8 @@ int main(int argc, char **argv) { util_alloc_file_components(src_file, &path, &basename, &extension); - target_file = ecl_util_alloc_filename(path, basename, file_type, - !fmt_file, report_nr); + target_file = rd_alloc_filename(path, basename, file_type, + !fmt_file, report_nr); file_convert(src_file, target_file, file_type, fmt_file); free(path); diff --git a/applications/resdata/grdecl_grid.c b/applications/resdata/grdecl_grid.c index b174230a3b..2cf16da338 100644 --- a/applications/resdata/grdecl_grid.c +++ b/applications/resdata/grdecl_grid.c @@ -21,33 +21,33 @@ #include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { FILE *stream = util_fopen(argv[1], "r"); - ecl_kw_type *gridhead_kw = ecl_kw_fscanf_alloc_grdecl_dynamic__( - stream, SPECGRID_KW, false, ECL_INT); - ecl_kw_type *zcorn_kw = - ecl_kw_fscanf_alloc_grdecl_dynamic(stream, ZCORN_KW, ECL_FLOAT); - ecl_kw_type *coord_kw = - ecl_kw_fscanf_alloc_grdecl_dynamic(stream, COORD_KW, ECL_FLOAT); - ecl_kw_type *actnum_kw = - ecl_kw_fscanf_alloc_grdecl_dynamic(stream, ACTNUM_KW, ECL_INT); + rd_kw_type *gridhead_kw = + rd_kw_fscanf_alloc_grdecl_dynamic__(stream, SPECGRID_KW, false, RD_INT); + rd_kw_type *zcorn_kw = + rd_kw_fscanf_alloc_grdecl_dynamic(stream, ZCORN_KW, RD_FLOAT); + rd_kw_type *coord_kw = + rd_kw_fscanf_alloc_grdecl_dynamic(stream, COORD_KW, RD_FLOAT); + rd_kw_type *actnum_kw = + rd_kw_fscanf_alloc_grdecl_dynamic(stream, ACTNUM_KW, RD_INT); { - int nx = ecl_kw_iget_int(gridhead_kw, SPECGRID_NX_INDEX); - int ny = ecl_kw_iget_int(gridhead_kw, SPECGRID_NY_INDEX); - int nz = ecl_kw_iget_int(gridhead_kw, SPECGRID_NZ_INDEX); - ecl_grid_type *ecl_grid = ecl_grid_alloc_GRDECL_kw( + int nx = rd_kw_iget_int(gridhead_kw, SPECGRID_NX_INDEX); + int ny = rd_kw_iget_int(gridhead_kw, SPECGRID_NY_INDEX); + int nz = rd_kw_iget_int(gridhead_kw, SPECGRID_NZ_INDEX); + rd_grid_type *rd_grid = rd_grid_alloc_GRDECL_kw( nx, ny, nz, zcorn_kw, coord_kw, actnum_kw, NULL); /* .... */ - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } - ecl_kw_free(gridhead_kw); - ecl_kw_free(zcorn_kw); - ecl_kw_free(actnum_kw); - ecl_kw_free(coord_kw); + rd_kw_free(gridhead_kw); + rd_kw_free(zcorn_kw); + rd_kw_free(actnum_kw); + rd_kw_free(coord_kw); fclose(stream); } diff --git a/applications/resdata/grdecl_test.c b/applications/resdata/grdecl_test.c index c8f42f4f53..dfe639b50c 100644 --- a/applications/resdata/grdecl_test.c +++ b/applications/resdata/grdecl_test.c @@ -20,23 +20,23 @@ #include #include -#include +#include int main(int argc, char **argv) { FILE *stream = util_fopen(argv[1], "r"); { while (true) { - ecl_kw_type *grdecl_kw; + rd_kw_type *grdecl_kw; clock_t begin = clock(); - grdecl_kw = ecl_kw_fscanf_alloc_current_grdecl(stream, ECL_FLOAT); + grdecl_kw = rd_kw_fscanf_alloc_current_grdecl(stream, RD_FLOAT); clock_t end = clock(); double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; if (grdecl_kw != NULL) { printf("Loaded %s - %d elements : %g \n", - ecl_kw_get_header(grdecl_kw), ecl_kw_get_size(grdecl_kw), + rd_kw_get_header(grdecl_kw), rd_kw_get_size(grdecl_kw), time_spent); - ecl_kw_free(grdecl_kw); + rd_kw_free(grdecl_kw); } else break; } diff --git a/applications/resdata/grid_dump.c b/applications/resdata/grid_dump.c index a68bcc5880..afd460f5d1 100644 --- a/applications/resdata/grid_dump.c +++ b/applications/resdata/grid_dump.c @@ -21,7 +21,7 @@ #include -#include +#include int main(int argc, char **argv) { if (argc < 2) { @@ -32,7 +32,7 @@ int main(int argc, char **argv) { { const char *grid_file = argv[1]; char *output_file = NULL; - ecl_grid_type *ecl_grid; + rd_grid_type *rd_grid; FILE *stream; if (argc == 3) { @@ -41,11 +41,11 @@ int main(int argc, char **argv) { } else stream = stdout; - ecl_grid = ecl_grid_alloc(grid_file); - ecl_grid_dump(ecl_grid, stream); + rd_grid = rd_grid_alloc(grid_file); + rd_grid_dump(rd_grid, stream); if (output_file != NULL) fclose(stream); - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } } diff --git a/applications/resdata/grid_dump_ascii.c b/applications/resdata/grid_dump_ascii.c index cbbdfb5360..597b272d7c 100644 --- a/applications/resdata/grid_dump_ascii.c +++ b/applications/resdata/grid_dump_ascii.c @@ -21,7 +21,7 @@ #include -#include +#include int main(int argc, char **argv) { if (argc < 2) { @@ -32,7 +32,7 @@ int main(int argc, char **argv) { { const char *grid_file = argv[1]; char *output_file = NULL; - ecl_grid_type *ecl_grid; + rd_grid_type *rd_grid; FILE *stream; if (argc == 3) { @@ -41,11 +41,11 @@ int main(int argc, char **argv) { } else stream = stdout; - ecl_grid = ecl_grid_alloc(grid_file); - ecl_grid_dump_ascii(ecl_grid, false, stream); + rd_grid = rd_grid_alloc(grid_file); + rd_grid_dump_ascii(rd_grid, false, stream); if (output_file != NULL) fclose(stream); - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } } diff --git a/applications/resdata/grid_info.c b/applications/resdata/grid_info.c index ded31b7cc7..b3126aa329 100644 --- a/applications/resdata/grid_info.c +++ b/applications/resdata/grid_info.c @@ -21,7 +21,7 @@ #include -#include +#include int main(int argc, char **argv) { if (argc < 2) { @@ -30,32 +30,32 @@ int main(int argc, char **argv) { } { - ecl_grid_type *ecl_grid; + rd_grid_type *rd_grid; const char *grid_file = argv[1]; - ecl_grid = ecl_grid_alloc(grid_file); - ecl_grid_summarize(ecl_grid); + rd_grid = rd_grid_alloc(grid_file); + rd_grid_summarize(rd_grid); if (argc >= 3) { - ecl_grid_type *grid2 = ecl_grid_alloc(argv[2]); + rd_grid_type *grid2 = rd_grid_alloc(argv[2]); - if (ecl_grid_compare(ecl_grid, grid2, true, false, false)) + if (rd_grid_compare(rd_grid, grid2, true, false, false)) printf("\nThe grids %s %s are IDENTICAL.\n", argv[1], argv[2]); else { printf("\n"); - ecl_grid_summarize(grid2); + rd_grid_summarize(grid2); printf("\nThe grids %s %s are DIFFERENT.\n", argv[1], argv[2]); } - ecl_grid_free(grid2); + rd_grid_free(grid2); } /* printf("----\n"); { - double * ri_points = util_calloc( ecl_grid_get_global_size( ecl_grid ) * 24 , sizeof * ri_points ); - ecl_grid_ri_export( ecl_grid , ri_points ); + double * ri_points = util_calloc( rd_grid_get_global_size( rd_grid ) * 24 , sizeof * ri_points ); + rd_grid_ri_export( rd_grid , ri_points ); free( ri_points ); } printf("----\n"); */ - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } } diff --git a/applications/resdata/kw_extract.cpp b/applications/resdata/kw_extract.cpp index f6903c66d5..04460586b2 100644 --- a/applications/resdata/kw_extract.cpp +++ b/applications/resdata/kw_extract.cpp @@ -6,12 +6,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /** This file will extract all occurences of kw1,kw2,...,kwn from the @@ -36,30 +36,30 @@ int main(int argc, char **argv) { for (int iarg = 3; iarg < argc; iarg++) stringlist_append_copy(kw_set, argv[iarg]); - if (!ecl_util_fmt_file(src_file, &fmt_src)) + if (!rd_fmt_file(src_file, &fmt_src)) util_exit("Hmm - could not determine formatted/unformatted status " "for:%s \n", src_file); fmt_target = fmt_src; /* Can in principle be different */ - fortio_src = fortio_open_reader(src_file, fmt_src, ECL_ENDIAN_FLIP); + fortio_src = fortio_open_reader(src_file, fmt_src, RD_ENDIAN_FLIP); fortio_target = - fortio_open_writer(target_file, fmt_target, ECL_ENDIAN_FLIP); + fortio_open_writer(target_file, fmt_target, RD_ENDIAN_FLIP); { - ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); + rd_kw_type *rd_kw = rd_kw_alloc_empty(); while (true) { - if (ecl_kw_fread_header(ecl_kw, fortio_src) == ECL_KW_READ_OK) { - const char *header = ecl_kw_get_header(ecl_kw); + if (rd_kw_fread_header(rd_kw, fortio_src) == RD_KW_READ_OK) { + const char *header = rd_kw_get_header(rd_kw); if (stringlist_contains(kw_set, header)) { - ecl_kw_fread_realloc_data(ecl_kw, fortio_src); - ecl_kw_fwrite(ecl_kw, fortio_target); + rd_kw_fread_realloc_data(rd_kw, fortio_src); + rd_kw_fwrite(rd_kw, fortio_target); } else - ecl_kw_fskip_data(ecl_kw, fortio_src); + rd_kw_fskip_data(rd_kw, fortio_src); } else break; /* We have reached EOF */ } - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); } fortio_fclose(fortio_src); diff --git a/applications/resdata/kw_list.c b/applications/resdata/kw_list.c index 3d2055dd2f..ec6757a5b8 100644 --- a/applications/resdata/kw_list.c +++ b/applications/resdata/kw_list.c @@ -21,27 +21,27 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include void kw_list(const char *filename) { fortio_type *fortio; - ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); + rd_kw_type *rd_kw = rd_kw_alloc_empty(); bool fmt_file; - if (ecl_util_fmt_file(filename, &fmt_file)) { + if (rd_fmt_file(filename, &fmt_file)) { printf("---------------------------------------------------------------" "--\n"); printf("%s: \n", filename); - fortio = fortio_open_reader(filename, fmt_file, ECL_ENDIAN_FLIP); - while (ecl_kw_fread_realloc(ecl_kw, fortio)) - ecl_kw_summarize(ecl_kw); + fortio = fortio_open_reader(filename, fmt_file, RD_ENDIAN_FLIP); + while (rd_kw_fread_realloc(rd_kw, fortio)) + rd_kw_summarize(rd_kw); printf("---------------------------------------------------------------" "--\n"); - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); fortio_fclose(fortio); } else fprintf(stderr, diff --git a/applications/resdata/load_test.c b/applications/resdata/load_test.c index ec278ce06b..fd1643825e 100644 --- a/applications/resdata/load_test.c +++ b/applications/resdata/load_test.c @@ -20,47 +20,45 @@ #include #include -#include -#include +#include +#include void test_case(const char *base, bool load_all) { - char *grid_file = - ecl_util_alloc_filename(NULL, base, ECL_EGRID_FILE, false, 0); - char *init_file = - ecl_util_alloc_filename(NULL, base, ECL_INIT_FILE, false, 0); + char *grid_file = rd_alloc_filename(NULL, base, RD_EGRID_FILE, false, 0); + char *init_file = rd_alloc_filename(NULL, base, RD_INIT_FILE, false, 0); char *restart_file = - ecl_util_alloc_filename(NULL, base, ECL_UNIFIED_RESTART_FILE, false, 0); + rd_alloc_filename(NULL, base, RD_UNIFIED_RESTART_FILE, false, 0); - ecl_grid_type *grid; - ecl_file_type *restart; - ecl_file_type *init; + rd_grid_type *grid; + rd_file_type *restart; + rd_file_type *init; clock_t begin = clock(); - grid = ecl_grid_alloc(grid_file); + grid = rd_grid_alloc(grid_file); clock_t end = clock(); double grid_time = (double)(end - begin) / CLOCKS_PER_SEC; begin = clock(); - init = ecl_file_open(init_file, 0); + init = rd_file_open(init_file, 0); if (load_all) - ecl_file_load_all(init); + rd_file_load_all(init); end = clock(); double init_time = (double)(end - begin) / CLOCKS_PER_SEC; begin = clock(); - restart = ecl_file_open(restart_file, 0); + restart = rd_file_open(restart_file, 0); if (load_all) - ecl_file_load_all(restart); + rd_file_load_all(restart); end = clock(); double restarts_time = (double)(end - begin) / CLOCKS_PER_SEC; printf("%-64s Restart:%8.4f Grid:%8.4f Init:%8.4f \n", base, restarts_time, grid_time, init_time); - ecl_file_close(init); - ecl_file_close(restart); - ecl_grid_free(grid); + rd_file_close(init); + rd_file_close(restart); + rd_grid_free(grid); free(grid_file); free(init_file); free(restart_file); diff --git a/applications/resdata/make_grid.c b/applications/resdata/make_grid.c index 6745cdc4f9..83adce4b99 100644 --- a/applications/resdata/make_grid.c +++ b/applications/resdata/make_grid.c @@ -21,7 +21,7 @@ #include -#include +#include int main(int argc, char **argv) { if (argc != 5) { @@ -36,17 +36,17 @@ int main(int argc, char **argv) { int nz = atoi(argv[4]); char *path, *basename; - ecl_grid_type *ecl_grid; + rd_grid_type *rd_grid; util_alloc_file_components(base_input, &path, &basename, NULL); - ecl_grid = ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); + rd_grid = rd_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); { char *EGRID_file = util_alloc_filename(path, basename, "EGRID"); printf("Writing file: %s ...", EGRID_file); fflush(stdout); - ecl_grid_fwrite_EGRID2(ecl_grid, EGRID_file, ECL_METRIC_UNITS); + rd_grid_fwrite_EGRID2(rd_grid, EGRID_file, RD_METRIC_UNITS); free(EGRID_file); } @@ -55,7 +55,7 @@ int main(int argc, char **argv) { FILE *stream = util_fopen(grdecl_file, "w"); printf("\nWriting file: %s ...", grdecl_file); fflush(stdout); - ecl_grid_fprintf_grdecl(ecl_grid, stream); + rd_grid_fprintf_grdecl(rd_grid, stream); fclose(stream); free(grdecl_file); printf("\n"); @@ -63,6 +63,6 @@ int main(int argc, char **argv) { free(basename); free(path); - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } } diff --git a/applications/resdata/rd_pack.c b/applications/resdata/rd_pack.c index 7fccb9472b..918a66fdac 100644 --- a/applications/resdata/rd_pack.c +++ b/applications/resdata/rd_pack.c @@ -1,7 +1,7 @@ /* Copyright (C) 2011 Equinor ASA, Norway. - The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'rd_pack.c' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,32 +21,32 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { int num_files = argc - 1; if (num_files >= 1) { /* File type and formatted / unformatted is determined from the first argument on the command line. */ - char *ecl_base; + char *rd_base; char *path; - ecl_file_enum file_type, target_type; + rd_file_enum file_type, target_type; bool fmt_file; /** Look at the first command line argument to determine type and formatted/unformatted status. */ - file_type = ecl_util_get_file_type(argv[1], &fmt_file, NULL); - if (file_type == ECL_SUMMARY_FILE) - target_type = ECL_UNIFIED_SUMMARY_FILE; - else if (file_type == ECL_RESTART_FILE) - target_type = ECL_UNIFIED_RESTART_FILE; + file_type = rd_get_file_type(argv[1], &fmt_file, NULL); + if (file_type == RD_SUMMARY_FILE) + target_type = RD_UNIFIED_SUMMARY_FILE; + else if (file_type == RD_RESTART_FILE) + target_type = RD_UNIFIED_RESTART_FILE; else { - util_exit("The ecl_pack program can only be used with ECLIPSE " + util_exit("The rd_pack program can only be used with ECLIPSE " "restart files or summary files.\n"); target_type = -1; } - util_alloc_file_components(argv[1], &path, &ecl_base, NULL); + util_alloc_file_components(argv[1], &path, &rd_base, NULL); /** Will pack to cwd, even though the source files might be @@ -57,25 +57,25 @@ int main(int argc, char **argv) { { int i, report_step, prev_report_step; - char *target_file_name = ecl_util_alloc_filename( - NULL, ecl_base, target_type, fmt_file, -1); + char *target_file_name = + rd_alloc_filename(NULL, rd_base, target_type, fmt_file, -1); stringlist_type *filelist = stringlist_alloc_argv_copy((const char **)&argv[1], num_files); - ecl_kw_type *seqnum_kw = NULL; + rd_kw_type *seqnum_kw = NULL; fortio_type *target = - fortio_open_writer(target_file_name, fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(target_file_name, fmt_file, RD_ENDIAN_FLIP); - if (target_type == ECL_UNIFIED_RESTART_FILE) { + if (target_type == RD_UNIFIED_RESTART_FILE) { int dummy; - seqnum_kw = ecl_kw_alloc_new("SEQNUM", 1, ECL_INT, &dummy); + seqnum_kw = rd_kw_alloc_new("SEQNUM", 1, RD_INT, &dummy); } - stringlist_sort(filelist, ecl_util_fname_report_cmp); + stringlist_sort(filelist, rd_fname_report_cmp); prev_report_step = -1; for (i = 0; i < num_files; i++) { - ecl_file_enum this_file_type; - this_file_type = ecl_util_get_file_type( - stringlist_iget(filelist, i), NULL, &report_step); + rd_file_enum this_file_type; + this_file_type = rd_get_file_type(stringlist_iget(filelist, i), + NULL, &report_step); if (this_file_type == file_type) { if (report_step == prev_report_step) util_exit( @@ -85,15 +85,15 @@ int main(int argc, char **argv) { prev_report_step = report_step; { - ecl_file_type *src_file = - ecl_file_open(stringlist_iget(filelist, i), 0); - if (target_type == ECL_UNIFIED_RESTART_FILE) { + rd_file_type *src_file = + rd_file_open(stringlist_iget(filelist, i), 0); + if (target_type == RD_UNIFIED_RESTART_FILE) { /* Must insert the SEQNUM keyword first. */ - ecl_kw_iset_int(seqnum_kw, 0, report_step); - ecl_kw_fwrite(seqnum_kw, target); + rd_kw_iset_int(seqnum_kw, 0, report_step); + rd_kw_fwrite(seqnum_kw, target); } - ecl_file_fwrite_fortio(src_file, target, 0); - ecl_file_close(src_file); + rd_file_fwrite_fortio(src_file, target, 0); + rd_file_close(src_file); } } /* Else skipping file of incorrect type. */ } @@ -101,9 +101,9 @@ int main(int argc, char **argv) { free(target_file_name); stringlist_free(filelist); if (seqnum_kw != NULL) - ecl_kw_free(seqnum_kw); + rd_kw_free(seqnum_kw); } - free(ecl_base); + free(rd_base); free(path); } } diff --git a/applications/resdata/rd_unpack.c b/applications/resdata/rd_unpack.c index 18a260d0a4..8c059d53ca 100644 --- a/applications/resdata/rd_unpack.c +++ b/applications/resdata/rd_unpack.c @@ -1,7 +1,7 @@ /* Copyright (C) 2011 Equinor ASA, Norway. - The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'rd_unpack.c' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,31 +20,31 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void unpack_file(const char *filename) { - ecl_file_enum target_type = ECL_OTHER_FILE; - ecl_file_enum file_type; + rd_file_enum target_type = RD_OTHER_FILE; + rd_file_enum file_type; bool fmt_file; - file_type = ecl_util_get_file_type(filename, &fmt_file, NULL); - if (file_type == ECL_UNIFIED_SUMMARY_FILE) - target_type = ECL_SUMMARY_FILE; - else if (file_type == ECL_UNIFIED_RESTART_FILE) - target_type = ECL_RESTART_FILE; + file_type = rd_get_file_type(filename, &fmt_file, NULL); + if (file_type == RD_UNIFIED_SUMMARY_FILE) + target_type = RD_SUMMARY_FILE; + else if (file_type == RD_UNIFIED_RESTART_FILE) + target_type = RD_RESTART_FILE; else util_exit( "Can only unpack unified ECLIPSE summary and restart files\n"); - if (target_type == ECL_SUMMARY_FILE) { + if (target_type == RD_SUMMARY_FILE) { printf("** Warning: when unpacking unified summary files it as " "ambigous - starting with 0001 -> \n"); } { - ecl_file_type *src_file = ecl_file_open(filename, 0); + rd_file_type *src_file = rd_file_open(filename, 0); int size; int offset; int report_step = 0; @@ -53,29 +53,29 @@ void unpack_file(const char *filename) { char *base; util_alloc_file_components(filename, &path, &base, NULL); - if (target_type == ECL_SUMMARY_FILE) - size = ecl_file_get_num_named_kw(src_file, "SEQHDR"); + if (target_type == RD_SUMMARY_FILE) + size = rd_file_get_num_named_kw(src_file, "SEQHDR"); else - size = ecl_file_get_num_named_kw(src_file, "SEQNUM"); + size = rd_file_get_num_named_kw(src_file, "SEQNUM"); while (true) { - ecl_file_view_type *active_view; + rd_file_view_type *active_view; if (block_index == size) break; - if (target_type == ECL_SUMMARY_FILE) { - active_view = ecl_file_get_global_blockview(src_file, SEQHDR_KW, - block_index); + if (target_type == RD_SUMMARY_FILE) { + active_view = rd_file_get_global_blockview(src_file, SEQHDR_KW, + block_index); report_step += 1; offset = 0; } else { - ecl_kw_type *seqnum_kw; - active_view = ecl_file_get_global_blockview(src_file, SEQNUM_KW, - block_index); + rd_kw_type *seqnum_kw; + active_view = rd_file_get_global_blockview(src_file, SEQNUM_KW, + block_index); seqnum_kw = - ecl_file_view_iget_named_kw(active_view, SEQNUM_KW, 0); - report_step = ecl_kw_iget_int(seqnum_kw, 0); + rd_file_view_iget_named_kw(active_view, SEQNUM_KW, 0); + report_step = rd_kw_iget_int(seqnum_kw, 0); offset = 1; } @@ -87,18 +87,18 @@ void unpack_file(const char *filename) { */ { - char *target_file = ecl_util_alloc_filename( - NULL, base, target_type, fmt_file, report_step); + char *target_file = rd_alloc_filename(NULL, base, target_type, + fmt_file, report_step); fortio_type *fortio_target = - fortio_open_writer(target_file, fmt_file, ECL_ENDIAN_FLIP); - ecl_file_view_fwrite(active_view, fortio_target, offset); + fortio_open_writer(target_file, fmt_file, RD_ENDIAN_FLIP); + rd_file_view_fwrite(active_view, fortio_target, offset); fortio_fclose(fortio_target); free(target_file); } block_index++; } - ecl_file_close(src_file); + rd_file_close(src_file); free(path); free(base); } @@ -106,7 +106,7 @@ void unpack_file(const char *filename) { int main(int argc, char **argv) { if (argc == 1) - util_exit("ecl_unpack UNIFIED_FILE1 UNIFIED_FILE2 ...\n"); + util_exit("rd_unpack UNIFIED_FILE1 UNIFIED_FILE2 ...\n"); { int iarg; for (iarg = 1; iarg < argc; iarg++) diff --git a/applications/resdata/select_test.c b/applications/resdata/select_test.c index 6c31ebe3ff..f34427003d 100644 --- a/applications/resdata/select_test.c +++ b/applications/resdata/select_test.c @@ -22,14 +22,14 @@ #include #include -#include +#include int main(int argc, char **argv) { const char *path = argv[1]; const char *base = argv[2]; stringlist_type *names = stringlist_alloc_new(); - ecl_util_select_filelist(path, base, ECL_OTHER_FILE, false, names); + rd_select_filelist(path, base, RD_OTHER_FILE, false, names); { int i; for (i = 0; i < stringlist_get_size(names); i++) diff --git a/applications/resdata/sum_write.cpp b/applications/resdata/sum_write.cpp index 827d45eac9..b3c7b5d763 100644 --- a/applications/resdata/sum_write.cpp +++ b/applications/resdata/sum_write.cpp @@ -4,9 +4,9 @@ #include #include -#include -#include -#include +#include +#include +#include /* The ECLIPSE summary data is stored in two different files: @@ -25,7 +25,7 @@ The format is quite primitive, and very much influenced by Fortran77 arrays which are fixed-size-large-enough thank you. The header file - is (mainly) based on three different ecl_kw vectors which together + is (mainly) based on three different rd_kw vectors which together completely specify the variables. The example below consists of the following: @@ -58,7 +58,7 @@ ECLIPSE will determine the type of variable by looking at the first letter of the keyword: "W" for well variables, "F" for field variables and so on. This is further documented in the - ecl_smspec_identify_var_type() function. + rd_smspec_identify_var_type() function. 2. The KEYWORD vector in the SMSPEC file is relevant for all the entries, whereas the WGNAMES and NUMS entries should be @@ -81,7 +81,7 @@ - All timesteps are equally large. Due to this fixed size nature an important element in the - ecl_sum implementation is "the index of a variable" - i.e. the + rd_sum implementation is "the index of a variable" - i.e. the "FOPT" variable in the example above will be found at index 1 of every datablock. @@ -91,7 +91,7 @@ data block is the current time (in days) for that datablock; if labunits is used the stored value is the elapsed time in hours. - 6. In the ecl_sum library the concept of a 'gen_key' is used quite + 6. In the rd_sum library the concept of a 'gen_key' is used quite extensively. The gen_key is a string combination of the KEYWORD, WGNAMES and NUMS values from the smspec header file. Only the relevant elements are combined when forming a gen_key; i.e. for @@ -126,11 +126,11 @@ point 4 above, the library is somewhat cumbersome and unflexible to use. Very briefly the usage pattern will be like: - 1. Create a ecl_sum instance and add variables to it with the - ecl_sum_add_var() function. + 1. Create a rd_sum instance and add variables to it with the + rd_sum_add_var() function. 2. Use your simulator to step forward in time, and add timesteps - with ecl_sum_add_tstep(). + with rd_sum_add_tstep(). Now - the important thing is that steps 1 and 2 two can not be interchanged, that will lead to crash and burn. @@ -147,10 +147,10 @@ int main(int argc, char **argv) { arguments are: 1: The case - this an ECLIPSE basename, with an optional leading - path component. Can later be modified with ecl_sum_set_case(). + path component. Can later be modified with rd_sum_set_case(). 2: Should formatted files be used? Can be modified with - ecl_sum_set_fmt_output(). + rd_sum_set_fmt_output(). 3: Character(s) to separate the items from the smspec header generate a gen_key value. The value ":" is close to a @@ -158,7 +158,7 @@ int main(int argc, char **argv) { 4: Should the data be output as a unified file, or as a collection of files - one for each report step. Can be - modified with ecl_sum_set_unified_output(). + modified with rd_sum_set_unified_output(). 5: The real-world start time of this simulation, as a unix time_t value. @@ -166,7 +166,7 @@ int main(int argc, char **argv) { 6-8: Grid dimensions. */ bool time_in_days = true; - ecl_sum_type *ecl_sum = ecl_sum_alloc_writer( + rd_sum_type *rd_sum = rd_sum_alloc_writer( "/tmp/CASE", false, true, ":", start_time, time_in_days, nx, ny, nz); /* @@ -179,7 +179,7 @@ int main(int argc, char **argv) { 1. self / this 2. The KEYWORD value for the variable we are considering; the - function ecl_smspec_identify_var_type() will be called with + function rd_smspec_identify_var_type() will be called with this string - i.e. you must follow the ECLIPSE rules (see table 3.4 in the ECLIPSE file format reference manual). @@ -194,17 +194,17 @@ int main(int argc, char **argv) { 6. A defualt value for this variable. */ - ecl_sum_add_var(ecl_sum, "FOPT", NULL, 0, "Barrels", 99.0); - ecl_sum_add_var(ecl_sum, "BPR", NULL, 567, "BARS", 0.0); - ecl_sum_add_var(ecl_sum, "WWCT", "OP-1", 0, "(1)", 0.0); - ecl_sum_add_var(ecl_sum, "WOPR", "OP-1", 0, "Barrels", 0.0); + rd_sum_add_var(rd_sum, "FOPT", NULL, 0, "Barrels", 99.0); + rd_sum_add_var(rd_sum, "BPR", NULL, 567, "BARS", 0.0); + rd_sum_add_var(rd_sum, "WWCT", "OP-1", 0, "(1)", 0.0); + rd_sum_add_var(rd_sum, "WOPR", "OP-1", 0, "Barrels", 0.0); /* - The return value from the ecl_sum_add_var() function is an - ecl::smspec_node instance (implemented in file smspec_node.c); + The return value from the rd_sum_add_var() function is an + rd::smspec_node instance (implemented in file smspec_node.c); which is essentially a struct holding header information about this varible. There are several options on how to handle the - return value from the ecl_sum_add_var() function; which affect how + return value from the rd_sum_add_var() function; which affect how you can add data at a later stage: 1. You can just ignore it - that is not very clean; in this @@ -221,10 +221,10 @@ int main(int argc, char **argv) { */ - const ecl::smspec_node *wwct_wellx = - ecl_sum_add_var(ecl_sum, "WWCT", NULL, 0, "(1)", 0.0); - const ecl::smspec_node *wopr_wellx = - ecl_sum_add_var(ecl_sum, "WOPR", NULL, 0, "Barrels", 0.0); + const rd::smspec_node *wwct_wellx = + rd_sum_add_var(rd_sum, "WWCT", NULL, 0, "(1)", 0.0); + const rd::smspec_node *wopr_wellx = + rd_sum_add_var(rd_sum, "WOPR", NULL, 0, "Barrels", 0.0); { int num_dates = 10; @@ -240,7 +240,7 @@ int main(int argc, char **argv) { { /* Here we add a new timestep. The report steps are not - added explicitly; the ecl_sum layer will just see if this + added explicitly; the rd_sum layer will just see if this is a new report step. Observe that report_step == 1 is the first permissible report step. @@ -248,45 +248,45 @@ int main(int argc, char **argv) { element for each variable, and now we must set the various elements in the block. There are different ways to do this - depending on which metadata information we - are holding on to from the ecl_sum_add_var() calls. + are holding on to from the rd_sum_add_var() calls. Observe that one element for the number of simulation days has already been inserted in the timestep. The elements which are not set explicitly will have the - default value given in the ecl_sum_add_var() call. + default value given in the rd_sum_add_var() call. */ - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_days); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_days); /* We can just set a value by it's index using the - ecl_sum_tstep_iset() function. The index value should come + rd_sum_tstep_iset() function. The index value should come from the smspec_get_params_index() function. */ - ecl_sum_tstep_iset(tstep, 3, 0.98); + rd_sum_tstep_iset(tstep, 3, 0.98); /* We can use the gen_key value to set the numerical values. The gen_key value should could from the smpec_get_gen_key1() function: */ - ecl_sum_tstep_set_from_key(tstep, "WWCT:OP-1", - sim_days / 10); + rd_sum_tstep_set_from_key(tstep, "WWCT:OP-1", + sim_days / 10); if (report_step >= 5) { /* We can use the smspec_node value from the - ecl_sum_add_var() function directly: + rd_sum_add_var() function directly: */ - ecl_sum_tstep_set_from_node(tstep, *wwct_wellx, - sim_days); - ecl_sum_tstep_set_from_node(tstep, *wopr_wellx, - sim_days * 100); + rd_sum_tstep_set_from_node(tstep, *wwct_wellx, + sim_days); + rd_sum_tstep_set_from_node(tstep, *wopr_wellx, + sim_days * 100); } } } } } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); } diff --git a/applications/resdata/view_summary.cpp b/applications/resdata/view_summary.cpp index c132987931..60115ca6ae 100644 --- a/applications/resdata/view_summary.cpp +++ b/applications/resdata/view_summary.cpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include +#include void install_SIGNALS(void) { signal( @@ -114,21 +114,20 @@ void print_help_and_exit() { exit(1); } -static void build_key_list(const ecl_sum_type *ecl_sum, - stringlist_type *key_list, int argc, - const char **argv) { +static void build_key_list(const rd_sum_type *rd_sum, stringlist_type *key_list, + int argc, const char **argv) { int iarg; for (iarg = 0; iarg < argc; iarg++) { /** If the string does not contain wildcards we add it unconditionally; and then subsequently let the - ecl_sum_fprintf() function print a message on stderr about + rd_sum_fprintf() function print a message on stderr about missing keys. */ if (util_string_has_wildcard(argv[iarg])) - ecl_sum_select_matching_general_var_list(ecl_sum, argv[iarg], - key_list); + rd_sum_select_matching_general_var_list(rd_sum, argv[iarg], + key_list); else stringlist_append_copy(key_list, argv[iarg]); } @@ -193,17 +192,17 @@ int main(int argc, char **argv) { { char *data_file = argv[arg_offset]; - ecl_sum_type *ecl_sum; + rd_sum_type *rd_sum; int num_keys = argc - arg_offset - 1; const char **arg_list = (const char **)&argv[arg_offset + 1]; - ecl_sum = ecl_sum_fread_alloc_case2__(data_file, ":", - include_restart, true, 0); + rd_sum = rd_sum_fread_alloc_case2__(data_file, ":", include_restart, + true, 0); /** If no keys have been presented the function will list available keys. */ if (num_keys == 0) list_mode = true; - if (ecl_sum != NULL) { + if (rd_sum != NULL) { if (list_mode) { /* The program is called in list mode, we only print the @@ -214,11 +213,11 @@ int main(int argc, char **argv) { stringlist_type *keys = stringlist_alloc_new(); if (num_keys == 0) { - ecl_sum_select_matching_general_var_list(ecl_sum, "*", - keys); + rd_sum_select_matching_general_var_list(rd_sum, "*", + keys); stringlist_sort(keys, NULL); } else - build_key_list(ecl_sum, keys, num_keys, arg_list); + build_key_list(rd_sum, keys, num_keys, arg_list); { int columns = 5; @@ -233,21 +232,20 @@ int main(int argc, char **argv) { stringlist_free(keys); } else { /* Normal operation print results for the various keys on stdout. */ - ecl_sum_fmt_type fmt; + rd_sum_fmt_type fmt; stringlist_type *key_list = stringlist_alloc_new(); - build_key_list(ecl_sum, key_list, num_keys, arg_list); + build_key_list(rd_sum, key_list, num_keys, arg_list); if (print_header) - ecl_sum_fmt_init_summary_x(ecl_sum, &fmt); + rd_sum_fmt_init_summary_x(rd_sum, &fmt); else fmt.print_header = false; - ecl_sum_fprintf(ecl_sum, stdout, key_list, report_only, - &fmt); + rd_sum_fprintf(rd_sum, stdout, key_list, report_only, &fmt); stringlist_free(key_list); } - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); } else fprintf(stderr, "summary.x: No summary data found for case:%s\n", diff --git a/applications/well/ri_well_test.c b/applications/well/ri_well_test.c index 7c8322e66c..705429b895 100644 --- a/applications/well/ri_well_test.c +++ b/applications/well/ri_well_test.c @@ -16,9 +16,9 @@ for more details. */ -#include -#include -#include +#include +#include +#include /* This is a small test program which will load the well information in @@ -36,7 +36,7 @@ int main(int argc, char **argv) { usage(); else { char *grid_file = argv[1]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); + rd_grid_type *grid = rd_grid_alloc(grid_file); well_info_type *well_info = well_info_alloc(grid); int ifile; for (ifile = 2; ifile < argc; ifile++) { @@ -45,7 +45,7 @@ int main(int argc, char **argv) { well_info_load_rstfile(well_info, rst_file, true); } - ecl_grid_free(grid); + rd_grid_free(grid); well_info_free(well_info); } } diff --git a/applications/well/segment_info.c b/applications/well/segment_info.c index 5eb1e77792..b5fec6fd8f 100644 --- a/applications/well/segment_info.c +++ b/applications/well/segment_info.c @@ -22,37 +22,37 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { const char *Xfile = argv[1]; - ecl_file_type *rst_file = ecl_file_open(Xfile, 0); - ecl_rsthead_type *rst_head = ecl_rsthead_alloc( - ecl_file_get_global_view(rst_file), ecl_util_filename_report_nr(Xfile)); - const ecl_kw_type *iwel_kw = ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - const ecl_kw_type *iseg_kw = ecl_file_iget_named_kw(rst_file, ISEG_KW, 0); + rd_file_type *rst_file = rd_file_open(Xfile, 0); + rd_rsthead_type *rst_head = rd_rsthead_alloc( + rd_file_get_global_view(rst_file), rd_filename_report_nr(Xfile)); + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + const rd_kw_type *iseg_kw = rd_file_iget_named_kw(rst_file, ISEG_KW, 0); well_rseg_loader_type *rseg_loader = - well_rseg_loader_alloc(ecl_file_get_global_view(rst_file)); - const ecl_kw_type *icon_kw = ecl_file_iget_named_kw(rst_file, ICON_KW, 0); - const ecl_kw_type *scon_kw = ecl_file_iget_named_kw(rst_file, SCON_KW, 0); - const ecl_kw_type *xcon_kw = ecl_file_iget_named_kw(rst_file, XCON_KW, 0); - const ecl_kw_type *zwel_kw = ecl_file_iget_named_kw(rst_file, ZWEL_KW, 0); + well_rseg_loader_alloc(rd_file_get_global_view(rst_file)); + const rd_kw_type *icon_kw = rd_file_iget_named_kw(rst_file, ICON_KW, 0); + const rd_kw_type *scon_kw = rd_file_iget_named_kw(rst_file, SCON_KW, 0); + const rd_kw_type *xcon_kw = rd_file_iget_named_kw(rst_file, XCON_KW, 0); + const rd_kw_type *zwel_kw = rd_file_iget_named_kw(rst_file, ZWEL_KW, 0); { int well_nr; for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) { const int zwel_offset = rst_head->nzwelz * well_nr; char *well_name = - util_alloc_strip_copy(ecl_kw_iget_ptr(zwel_kw, zwel_offset)); + util_alloc_strip_copy(rd_kw_iget_ptr(zwel_kw, zwel_offset)); printf("===========================================================" "======\n"); @@ -77,7 +77,7 @@ int main(int argc, char **argv) { well_segment_collection_link(segments); well_segment_collection_add_branches(segments, branches); well_segment_collection_add_connections( - segments, ECL_GRID_GLOBAL_GRID, connections); + segments, RD_GRID_GLOBAL_GRID, connections); printf("\n"); printf("Segments:\n"); @@ -131,6 +131,6 @@ int main(int argc, char **argv) { } } - ecl_file_close(rst_file); - ecl_rsthead_free(rst_head); + rd_file_close(rst_file); + rd_rsthead_free(rst_head); } diff --git a/applications/well/well_CF_dump.c b/applications/well/well_CF_dump.c index 4daa7f5541..5f5bece82a 100644 --- a/applications/well/well_CF_dump.c +++ b/applications/well/well_CF_dump.c @@ -16,14 +16,14 @@ for more details. */ -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { char *grid_file = argv[1]; char *rst_file = argv[2]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); + rd_grid_type *grid = rd_grid_alloc(grid_file); well_info_type *well_info = well_info_alloc(grid); well_info_load_rstfile(well_info, rst_file, true); @@ -51,5 +51,5 @@ int main(int argc, char **argv) { } well_info_free(well_info); - ecl_grid_free(grid); + rd_grid_free(grid); } diff --git a/bin/summary_resample b/bin/summary_resample index 1a08006d2f..185248535f 100755 --- a/bin/summary_resample +++ b/bin/summary_resample @@ -1,8 +1,8 @@ #!/usr/bin/env python import sys import argparse -from ecl.summary import EclSum -from ecl.util.util import TimeVector, CTime +from resdata.summary import RdSum +from resdata.util.util import TimeVector, CTime @@ -14,9 +14,9 @@ parser.add_argument("--refcase", metavar="refcase", type=str) parser.add_argument("--extrapolation", action="store_true") args = parser.parse_args() -input_case = EclSum(args.input_case) +input_case = RdSum(args.input_case) if args.refcase: - refcase = EclSum(args.refcase) + refcase = RdSum(args.refcase) report_only = False time_points = refcase.alloc_time_vector( report_only ) else: diff --git a/ci/github/setup.py b/ci/github/setup.py index f492522571..298b40b6bd 100644 --- a/ci/github/setup.py +++ b/ci/github/setup.py @@ -10,5 +10,5 @@ author="Equinor ASA", author_email="fg_sib-scout@equinor.com", version=version, - install_requires=["ecl==" + version], + install_requires=["resdata==" + version], ) diff --git a/ci/testkomodo.sh b/ci/testkomodo.sh index 67345f7225..5a7c9a25a4 100755 --- a/ci/testkomodo.sh +++ b/ci/testkomodo.sh @@ -24,7 +24,7 @@ build_and_run_ctest () { pushd $CI_TEST_ROOT cmake $CI_SOURCE_ROOT \ -DBUILD_TESTS=ON \ - -DEQUINOR_TESTDATA_ROOT=$EQUINOR_TESTDATA_ROOT/ecl + -DEQUINOR_TESTDATA_ROOT=$EQUINOR_TESTDATA_ROOT/resdata cmake --build . ctest --output-on-failure popd diff --git a/cmake/libecl-config-version.cmake.in b/cmake/resdata-config-version.cmake.in similarity index 89% rename from cmake/libecl-config-version.cmake.in rename to cmake/resdata-config-version.cmake.in index 5a78f62b4e..8bcb05bef1 100644 --- a/cmake/libecl-config-version.cmake.in +++ b/cmake/resdata-config-version.cmake.in @@ -4,7 +4,7 @@ set(PACKAGE_VERSION_MINOR @ERT_VERSION_MINOR@) set(PACKAGE_VERSION_PATCH @ERT_VERSION_MICRO@) set(resdata_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include) -set(resdata_LIBRARIES -lecl_well -lecl -lert_geometry -lert_util) +set(resdata_LIBRARIES -lrd_well -lresdata -lert_geometry -lert_util) link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ ) include_directories( @CMAKE_INSTALL_PREFIX@/include ) diff --git a/cmake/libecl-config.cmake.in b/cmake/resdata-config.cmake.in similarity index 84% rename from cmake/libecl-config.cmake.in rename to cmake/resdata-config.cmake.in index cda16803e2..89606c3255 100644 --- a/cmake/libecl-config.cmake.in +++ b/cmake/resdata-config.cmake.in @@ -1,5 +1,5 @@ set(resdata_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include) -set(resdata_LIBRARIES -lecl_well -lecl -lert_geometry -lert_util) +set(resdata_LIBRARIES -lrd_well -lresdata -lert_geometry -lert_util) set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE_PATH}) link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ ) diff --git a/debian/libecl-dev.install b/debian/libecl-dev.install index 7b3c7d2f90..32557097fe 100644 --- a/debian/libecl-dev.install +++ b/debian/libecl-dev.install @@ -1,3 +1,3 @@ usr/include/* usr/lib/*/*.so -usr/share/cmake/ecl/* +usr/share/cmake/resdata/* diff --git a/debian/libecl1.install b/debian/libecl1.install index fb57ef3917..dd58bf28c3 100644 --- a/debian/libecl1.install +++ b/debian/libecl1.install @@ -1,3 +1,3 @@ usr/lib/*/lib*.so.* usr/bin/* -usr/share/man/man1/ecl_summary.1 +usr/share/man/man1/rd_summary.1 diff --git a/debian/python-ecl.install b/debian/python-ecl.install index c51cec5bee..f165493c2e 100644 --- a/debian/python-ecl.install +++ b/debian/python-ecl.install @@ -1 +1 @@ -usr/lib/python2.7/*/ecl/* +usr/lib/python2.7/*/resdata/* diff --git a/debian/rules b/debian/rules index a846fc431f..e9b9f1c5cf 100755 --- a/debian/rules +++ b/debian/rules @@ -19,7 +19,7 @@ override_dh_auto_build: dh_auto_build --buildsystem=cmake override_dh_auto_configure: - DESTDIR=$$(pwd)/debian/tmp dh_auto_configure --buildsystem=cmake -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DENABLE_PYTHON=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_ECL3=0 + DESTDIR=$$(pwd)/debian/tmp dh_auto_configure --buildsystem=cmake -- -DBUILD_SHARED_LIBS=1 -DBUILD_RD_SUMMARY=1 -DENABLE_PYTHON=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_RD3=0 override_dh_auto_install: dh_auto_install --buildsystem=cmake diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ccd1a0468f..0ec895fea9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -72,65 +72,65 @@ add_library( util/buffer.cpp util/string_util.cpp util/type_vector_functions.cpp - util/ecl_version.cpp + util/rd_version.cpp util/perm_vector.cpp util/test_util.cpp util/cxx_string_util.cpp ${opt_srcs} - ecl/ecl_rsthead.cpp - ecl/ecl_sum_tstep.cpp - ecl/ecl_rst_file.cpp - ecl/ecl_init_file.cpp - ecl/ecl_grid_cache.cpp - ecl/smspec_node.cpp - ecl/ecl_kw_grdecl.cpp - ecl/ecl_file_kw.cpp - ecl/ecl_file_view.cpp - ecl/ecl_grav.cpp - ecl/ecl_grav_calc.cpp - ecl/ecl_smspec.cpp - ecl/ecl_unsmry_loader.cpp - ecl/ecl_sum_data.cpp - ecl/ecl_sum_file_data.cpp - ecl/ecl_util.cpp - ecl/ecl_kw.cpp - ecl/ecl_sum.cpp - ecl/ecl_sum_vector.cpp - ecl/fortio.c - ecl/ecl_rft_file.cpp - ecl/ecl_rft_node.cpp - ecl/ecl_rft_cell.cpp - ecl/ecl_grid.cpp - ecl/ecl_coarse_cell.cpp - ecl/ecl_box.cpp - ecl/ecl_io_config.cpp - ecl/ecl_file.cpp - ecl/ecl_region.cpp - ecl/ecl_subsidence.cpp - ecl/ecl_grid_dims.cpp - ecl/grid_dims.cpp - ecl/nnc_info.cpp - ecl/ecl_grav_common.cpp - ecl/nnc_vector.cpp - ecl/ecl_nnc_export.cpp - ecl/ecl_nnc_data.cpp - ecl/ecl_nnc_geometry.cpp - ecl/layer.cpp - ecl/fault_block.cpp - ecl/fault_block_layer.cpp - ecl/ecl_type.cpp - ecl/ecl_type_python.cpp - ecl/well_state.cpp - ecl/well_conn.cpp - ecl/well_info.cpp - ecl/well_ts.cpp - ecl/well_conn_collection.cpp - ecl/well_segment.cpp - ecl/well_segment_collection.cpp - ecl/well_branch_collection.cpp - ecl/well_rseg_loader.cpp - ecl/FortIO.cpp - ecl/EclFilename.cpp + resdata/rd_rsthead.cpp + resdata/rd_sum_tstep.cpp + resdata/rd_rst_file.cpp + resdata/rd_init_file.cpp + resdata/rd_grid_cache.cpp + resdata/smspec_node.cpp + resdata/rd_kw_grdecl.cpp + resdata/rd_file_kw.cpp + resdata/rd_file_view.cpp + resdata/rd_grav.cpp + resdata/rd_grav_calc.cpp + resdata/rd_smspec.cpp + resdata/rd_unsmry_loader.cpp + resdata/rd_sum_data.cpp + resdata/rd_sum_file_data.cpp + resdata/rd_util.cpp + resdata/rd_kw.cpp + resdata/rd_sum.cpp + resdata/rd_sum_vector.cpp + resdata/fortio.c + resdata/rd_rft_file.cpp + resdata/rd_rft_node.cpp + resdata/rd_rft_cell.cpp + resdata/rd_grid.cpp + resdata/rd_coarse_cell.cpp + resdata/rd_box.cpp + resdata/rd_io_config.cpp + resdata/rd_file.cpp + resdata/rd_region.cpp + resdata/rd_subsidence.cpp + resdata/rd_grid_dims.cpp + resdata/grid_dims.cpp + resdata/nnc_info.cpp + resdata/rd_grav_common.cpp + resdata/nnc_vector.cpp + resdata/rd_nnc_export.cpp + resdata/rd_nnc_data.cpp + resdata/rd_nnc_geometry.cpp + resdata/layer.cpp + resdata/fault_block.cpp + resdata/fault_block_layer.cpp + resdata/rd_type.cpp + resdata/rd_type_python.cpp + resdata/well_state.cpp + resdata/well_conn.cpp + resdata/well_info.cpp + resdata/well_ts.cpp + resdata/well_conn_collection.cpp + resdata/well_segment.cpp + resdata/well_segment_collection.cpp + resdata/well_branch_collection.cpp + resdata/well_rseg_loader.cpp + resdata/FortIO.cpp + resdata/ResdataFilename.cpp geometry/geo_surface.cpp geometry/geo_util.cpp geometry/geo_pointset.cpp @@ -163,9 +163,9 @@ target_compile_definitions( ecl PRIVATE -DGIT_COMMIT=${GIT_COMMIT} -DGIT_COMMIT_SHORT=${GIT_COMMIT_SHORT} - -DECL_VERSION_MAJOR=${ECL_VERSION_MAJOR} - -DECL_VERSION_MINOR=${ECL_VERSION_MINOR} - -DECL_VERSION_MICRO=${ECL_VERSION_MICRO} + -DRD_VERSION_MAJOR=${RD_VERSION_MAJOR} + -DRD_VERSION_MINOR=${RD_VERSION_MINOR} + -DRD_VERSION_MICRO=${RD_VERSION_MICRO} $<$:HOST_BIG_ENDIAN>) target_compile_options(ecl PUBLIC ${pthreadarg}) @@ -180,8 +180,8 @@ if(ERT_USE_OPENMP) endif() set_target_properties( - ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} - SOVERSION ${ECL_VERSION_MAJOR}) + ecl PROPERTIES VERSION ${RD_VERSION_MAJOR}.${RD_VERSION_MINOR} + SOVERSION ${RD_VERSION_MAJOR}) install( TARGETS ecl @@ -197,20 +197,20 @@ if(NOT BUILD_TESTS) return() endif() -add_executable(ecl_test_suite tests/test_ecl_grid.cpp tests/test_ecl_util.cpp +add_executable(rd_test_suite tests/test_rd_grid.cpp tests/test_rd_util.cpp tests/testsuite.cpp tests/test_util.cpp) if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) - target_compile_options(ecl_test_suite PRIVATE -DFS_EXPERIMENTAL) + target_compile_options(rd_test_suite PRIVATE -DFS_EXPERIMENTAL) else() - target_compile_options(ecl_test_suite PRIVATE "--std=c++17") + target_compile_options(rd_test_suite PRIVATE "--std=c++17") endif() - target_link_libraries(ecl_test_suite ecl Catch2::Catch2WithMain stdc++fs) + target_link_libraries(rd_test_suite ecl Catch2::Catch2WithMain stdc++fs) else() - target_compile_options(ecl_test_suite PRIVATE "--std=c++17") - target_link_libraries(ecl_test_suite ecl Catch2::Catch2WithMain) + target_compile_options(rd_test_suite PRIVATE "--std=c++17") + target_link_libraries(rd_test_suite ecl Catch2::Catch2WithMain) endif() -add_test(NAME ecl_test_suite COMMAND ecl_test_suite) +add_test(NAME rd_test_suite COMMAND rd_test_suite) foreach( name @@ -248,9 +248,9 @@ foreach( add_test(NAME ${name} COMMAND ${name}) endforeach() -add_executable(ecl_smspec_node ecl/tests/ecl_smspec_node.cpp) -target_link_libraries(ecl_smspec_node ecl) -add_test(NAME ecl_smspec_node COMMAND ecl_smspec_node) +add_executable(rd_smspec_node resdata/tests/rd_smspec_node.cpp) +target_link_libraries(rd_smspec_node ecl) +add_test(NAME rd_smspec_node COMMAND rd_smspec_node) add_executable(ert_util_work_area util/tests/ert_util_work_area.cpp) target_link_libraries(ert_util_work_area ecl) @@ -301,45 +301,45 @@ endif() foreach( name - ecl_fault_block_layer - ecl_util_path_access - ecl_grid_add_nnc - ecl_grid_copy - ecl_grid_create - ecl_grid_unit_system - ecl_grid_export - ecl_grid_init_fwrite - ecl_grid_reset_actnum - ecl_grid_ext_actnum - ecl_nnc_export_intersect - ecl_sum_restart - ecl_sum_data_intermediate_test - ecl_grid_cell_contains - ecl_unsmry_loader_test - ecl_init_file - ecl_kw_space_pad - ecl_kw_cmp_string - ecl_kw_equal - ecl_kw_fread - ecl_kw_grdecl - ecl_kw_init - ecl_nnc_geometry - ecl_nnc_info_test - ecl_nnc_vector - ecl_rft_cell - ecl_sum_alloc_resampled_test - ecl_file_view - test_ecl_file_index + rd_fault_block_layer + rd_path_access + rd_grid_add_nnc + rd_grid_copy + rd_grid_create + rd_grid_unit_system + rd_grid_export + rd_grid_init_fwrite + rd_grid_reset_actnum + rd_grid_ext_actnum + rd_nnc_export_intersect + rd_sum_restart + rd_sum_data_intermediate_test + rd_grid_cell_contains + rd_unsmry_loader_test + rd_init_file + rd_kw_space_pad + rd_kw_cmp_string + rd_kw_equal + rd_kw_fread + rd_kw_grdecl + rd_kw_init + rd_nnc_geometry + rd_nnc_info_test + rd_nnc_vector + rd_rft_cell + rd_sum_alloc_resampled_test + rd_file_view + test_rd_file_index test_transactions - ecl_rst_file - ecl_sum_writer - ecl_util_filenames - ecl_util_make_date_no_shift - ecl_util_make_date_shift - ecl_util_month_range - ecl_valid_basename - test_ecl_nnc_data - ecl_nnc_pair + rd_rst_file + rd_sum_writer + rd_filenames + rd_make_date_no_shift + rd_make_date_shift + rd_month_range + rd_valid_basename + test_rd_nnc_data + rd_nnc_pair well_conn_collection well_branch_collection well_conn @@ -347,8 +347,8 @@ foreach( well_segment well_segment_conn well_segment_collection - ecl_file) - add_executable(${name} ecl/tests/${name}.cpp) + rd_file) + add_executable(${name} resdata/tests/${name}.cpp) target_link_libraries(${name} ecl) target_include_directories( ${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) @@ -356,33 +356,33 @@ foreach( endforeach() if(HAVE_UTIL_ABORT_INTERCEPT) - add_executable(ecl_grid_corner ecl/tests/ecl_grid_corner.cpp) - target_link_libraries(ecl_grid_corner ecl) - add_test(NAME ecl_grid_corner COMMAND ecl_grid_corner) + add_executable(rd_grid_corner resdata/tests/rd_grid_corner.cpp) + target_link_libraries(rd_grid_corner ecl) + add_test(NAME rd_grid_corner COMMAND rd_grid_corner) - add_executable(ecl_layer ecl/tests/ecl_layer.cpp) - target_link_libraries(ecl_layer ecl) + add_executable(rd_layer resdata/tests/rd_layer.cpp) + target_link_libraries(rd_layer ecl) target_include_directories( - ecl_layer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) - add_test(NAME ecl_layer COMMAND ecl_layer) + rd_layer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) + add_test(NAME rd_layer COMMAND rd_layer) endif() -add_executable(ecl_get_num_cpu ecl/tests/ecl_get_num_cpu_test.cpp) -target_link_libraries(ecl_get_num_cpu ecl) +add_executable(rd_get_num_cpu resdata/tests/rd_get_num_cpu_test.cpp) +target_link_libraries(rd_get_num_cpu ecl) add_test( - NAME ecl_get_num_cpu + NAME rd_get_num_cpu COMMAND - ecl_get_num_cpu ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu1 - ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu2 - ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu3 - ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu4 - ${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu5) + rd_get_num_cpu ${CMAKE_CURRENT_SOURCE_DIR}/resdata/tests/data/num_cpu1 + ${CMAKE_CURRENT_SOURCE_DIR}/resdata/tests/data/num_cpu2 + ${CMAKE_CURRENT_SOURCE_DIR}/resdata/tests/data/num_cpu3 + ${CMAKE_CURRENT_SOURCE_DIR}/resdata/tests/data/num_cpu4 + ${CMAKE_CURRENT_SOURCE_DIR}/resdata/tests/data/num_cpu5) -# The ecl_win64 application is not built as a proper test integrated into the +# The rd_win64 application is not built as a proper test integrated into the # CTEST system. Should be invoked manually on Windows. if(ERT_WINDOWS) - add_executable(ecl_lfs ecl/tests/ecl_lfs.cpp) - target_link_libraries(ecl_lfs ecl) + add_executable(rd_lfs resdata/tests/rd_lfs.cpp) + target_link_libraries(rd_lfs ecl) endif() # @@ -402,40 +402,40 @@ foreach(test ert_util_unique_ptr) endforeach() foreach(test eclxx_kw eclxx_fortio eclxx_filename eclxx_types) - add_executable(${test} ecl/tests/${test}.cpp) + add_executable(${test} resdata/tests/${test}.cpp) target_link_libraries(${test} ecl) add_test(NAME ${test} COMMAND ${test}) endforeach() foreach( name - ecl_coarse_test - ecl_grid_layer_contains - ecl_restart_test - ecl_nnc_export - ecl_nnc_export_get_tran - ecl_nnc_data_equinor_root - ecl_sum_case_exists - ecl_grid_lgr_name - ecl_region - ecl_grid_cell_contains_wellpath - ecl_region2region - ecl_grid_volume - ecl_grid_dims - ecl_nnc_test - ecl_lgr_test - ecl_layer_equinor - ecl_dualp - ecl_grid_dx_dy_dz - ecl_sum_test - ecl_sum_report_step_equal - ecl_sum_report_step_compatible - ecl_file_equinor - ecl_fmt - ecl_rsthead - ecl_smspec - ecl_rft - ecl_fault_block_layer_equinor + rd_coarse_test + rd_grid_layer_contains + rd_restart_test + rd_nnc_export + rd_nnc_export_get_tran + rd_nnc_data_equinor_root + rd_sum_case_exists + rd_grid_lgr_name + rd_region + rd_grid_cell_contains_wellpath + rd_region2region + rd_grid_volume + rd_grid_dims + rd_nnc_test + rd_lgr_test + rd_layer_equinor + rd_dualp + rd_grid_dx_dy_dz + rd_sum_test + rd_sum_report_step_equal + rd_sum_report_step_compatible + rd_file_equinor + rd_fmt + rd_rsthead + rd_smspec + rd_rft + rd_fault_block_layer_equinor well_state_load well_state_load_missing_RSEG well_segment_load @@ -447,13 +447,13 @@ foreach( well_dualp well_lgr_load) - add_executable(${name} ecl/tests/${name}.cpp) + add_executable(${name} resdata/tests/${name}.cpp) target_link_libraries(${name} ecl) target_include_directories( ${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) endforeach() -foreach(name ecl_grid_layer_contains ecl_region ecl_grid_copy) +foreach(name rd_grid_layer_contains rd_region rd_grid_copy) foreach(i RANGE 1 7) add_test(NAME ${name}_faarikaal${i} COMMAND ${name} ${_local_eclpath}/faarikaal/faarikaal${i}.EGRID) @@ -464,83 +464,83 @@ if(NOT EQUINOR_TESTDATA_ROOT) return() endif() -add_test(NAME ecl_grid_dx_dy_dz_gurbat COMMAND ecl_grid_dx_dy_dz +add_test(NAME rd_grid_dx_dy_dz_gurbat COMMAND rd_grid_dx_dy_dz ${_eclpath}/Gurbat/ECLIPSE) -add_test(NAME ecl_grid_dx_dy_dz_troll - COMMAND ecl_grid_dx_dy_dz ${_eclpath}/Troll/Ref2014/T07-4A-W2014-06) +add_test(NAME rd_grid_dx_dy_dz_troll + COMMAND rd_grid_dx_dy_dz ${_eclpath}/Troll/Ref2014/T07-4A-W2014-06) -add_test(NAME ecl_coarse_test COMMAND ecl_coarse_test +add_test(NAME rd_coarse_test COMMAND rd_coarse_test ${_eclpath}/LGCcase/LGC_TESTCASE2) -add_test(NAME ecl_restart_test COMMAND ecl_restart_test +add_test(NAME rd_restart_test COMMAND rd_restart_test ${_eclpath}/Gurbat/ECLIPSE.UNRST) -add_test(NAME ecl_nnc_export_gurbat COMMAND ecl_nnc_export +add_test(NAME rd_nnc_export_gurbat COMMAND rd_nnc_export ${_eclpath}/Gurbat/ECLIPSE TRUE) -add_test(NAME ecl_nnc_export_10kcase - COMMAND ecl_nnc_export ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC TRUE) -add_test(NAME ecl_nnc_export_dual_poro_diff - COMMAND ecl_nnc_export ${_eclpath}/DualPoro/DUAL_DIFF TRUE) -add_test(NAME ecl_nnc_export_dual_poro - COMMAND ecl_nnc_export ${_eclpath}/DualPoro/DUALPORO TRUE) -add_test(NAME ecl_nnc_export_nested_lgr_case - COMMAND ecl_nnc_export ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR +add_test(NAME rd_nnc_export_10kcase + COMMAND rd_nnc_export ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC TRUE) +add_test(NAME rd_nnc_export_dual_poro_diff + COMMAND rd_nnc_export ${_eclpath}/DualPoro/DUAL_DIFF TRUE) +add_test(NAME rd_nnc_export_dual_poro + COMMAND rd_nnc_export ${_eclpath}/DualPoro/DUALPORO TRUE) +add_test(NAME rd_nnc_export_nested_lgr_case + COMMAND rd_nnc_export ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR TRUE) -add_test(NAME ecl_nnc_export_tyrihans - COMMAND ecl_nnc_export ${_eclpath}/TYRIHANS/BASE20150218_MULTFLT FALSE) +add_test(NAME rd_nnc_export_tyrihans + COMMAND rd_nnc_export ${_eclpath}/TYRIHANS/BASE20150218_MULTFLT FALSE) add_test( - NAME ecl_nnc_export_get_tran - COMMAND ecl_nnc_export_get_tran + NAME rd_nnc_export_get_tran + COMMAND rd_nnc_export_get_tran ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3) add_test( - NAME ecl_nnc_data_equinor_root + NAME rd_nnc_data_equinor_root COMMAND - ecl_nnc_data_equinor_root + rd_nnc_data_equinor_root ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3 ${_eclpath}/flow-nnc/Simple4/SIMPLE_SUMMARY4) add_test( - NAME ecl_sum_case_exists + NAME rd_sum_case_exists COMMAND - ecl_sum_case_exists ${_eclpath}/Gurbat/ECLIPSE + rd_sum_case_exists ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/GurbatSummary/missingHeader/ECLIPSE ${_eclpath}/GurbatSummary/missingData/ECLIPSE) add_test( - NAME ecl_grid_lgr_name + NAME rd_grid_lgr_name COMMAND - ecl_grid_lgr_name + rd_grid_lgr_name ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID) add_test( - NAME ecl_grid_cell_contains_wellpath1 + NAME rd_grid_cell_contains_wellpath1 COMMAND - ecl_grid_cell_contains_wellpath ${_eclpath}/CellContains/model/SMS-0.EGRID + rd_grid_cell_contains_wellpath ${_eclpath}/CellContains/model/SMS-0.EGRID ${_eclpath}/CellContains/R_PB-4H.jira) -add_test(NAME ecl_region2region COMMAND ecl_region2region +add_test(NAME rd_region2region COMMAND rd_region2region ${_eclpath}/R2R/R2R.SMSPEC) -add_test(NAME ecl_lgr_test1 - COMMAND ecl_lgr_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID) -add_test(NAME ecl_lgr_test2 - COMMAND ecl_lgr_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.GRID) +add_test(NAME rd_lgr_test1 + COMMAND rd_lgr_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID) +add_test(NAME rd_lgr_test2 + COMMAND rd_lgr_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.GRID) add_test( - NAME ecl_lgr_test3 + NAME rd_lgr_test3 COMMAND - ecl_lgr_test + rd_lgr_test ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID) -add_test(NAME ecl_grid_volume1 COMMAND ecl_grid_volume +add_test(NAME rd_grid_volume1 COMMAND rd_grid_volume ${_eclpath}/Gurbat/ECLIPSE) -add_test(NAME ecl_grid_volume2 COMMAND ecl_grid_volume +add_test(NAME rd_grid_volume2 COMMAND rd_grid_volume ${_eclpath}/VolumeTest/TEST1) -add_test(NAME ecl_grid_volume3 COMMAND ecl_grid_volume +add_test(NAME rd_grid_volume3 COMMAND rd_grid_volume ${_eclpath}/OsebergSyd/Omega/OMEGA-0) -add_test(NAME ecl_grid_volume4 - COMMAND ecl_grid_volume +add_test(NAME rd_grid_volume4 + COMMAND rd_grid_volume ${_eclpath}/Norne/reservoir_models/Norne_ATW2013/NORNE_ATW2013) # The grid volume test fails miserably on the test case given as example five; @@ -548,114 +548,114 @@ add_test(NAME ecl_grid_volume4 # for PORV calculations has been different in this file - i.e. that the absolute # value of the individual tetrahedron parts have been taken during the sum, and # not at the end. At least the ert algorithm gets volumes ~ 0 whereas ECLIPSE -# reports ~10^9 for the same cell. add_test( ecl_grid_volume5 -# ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_volume +# reports ~10^9 for the same cell. add_test( rd_grid_volume5 +# ${EXECUTABLE_OUTPUT_PATH}/rd_grid_volume # ${_eclpath}/Heidrun/Summary/FF12_2013B3_CLEAN_RS) -add_test(NAME ecl_grid_dims0 COMMAND ecl_grid_dims) -add_test(NAME ecl_grid_dims1 - COMMAND ecl_grid_dims ${_eclpath}/Gurbat/ECLIPSE.EGRID +add_test(NAME rd_grid_dims0 COMMAND rd_grid_dims) +add_test(NAME rd_grid_dims1 + COMMAND rd_grid_dims ${_eclpath}/Gurbat/ECLIPSE.EGRID ${_eclpath}/Gurbat/ECLIPSE.INIT) -add_test(NAME ecl_grid_dims2 - COMMAND ecl_grid_dims ${_eclpath}/Gurbat/ECLIPSE.GRID +add_test(NAME rd_grid_dims2 + COMMAND rd_grid_dims ${_eclpath}/Gurbat/ECLIPSE.GRID ${_eclpath}/Gurbat/ECLIPSE.INIT) -add_test(NAME ecl_grid_dims3 COMMAND ecl_grid_dims +add_test(NAME rd_grid_dims3 COMMAND rd_grid_dims ${_eclpath}/Gurbat/ECLIPSE.EGRID) -add_test(NAME ecl_grid_dims4 COMMAND ecl_grid_dims +add_test(NAME rd_grid_dims4 COMMAND rd_grid_dims ${_eclpath}/Gurbat/ECLIPSE.GRID) -add_test(NAME ecl_grid_dims5 - COMMAND ecl_grid_dims +add_test(NAME rd_grid_dims5 + COMMAND rd_grid_dims ${_eclpath}/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID) -add_test(NAME ecl_nnc_test1 COMMAND ecl_nnc_test +add_test(NAME rd_nnc_test1 COMMAND rd_nnc_test ${_eclpath}/Gurbat/ECLIPSE.EGRID) -add_test(NAME ecl_nnc_test2 - COMMAND ecl_nnc_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID) +add_test(NAME rd_nnc_test2 + COMMAND rd_nnc_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID) add_test( - NAME ecl_nnc_test3 + NAME rd_nnc_test3 COMMAND - ecl_nnc_test + rd_nnc_test ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID) -add_test(NAME ecl_nnc_test4 COMMAND ecl_nnc_test +add_test(NAME rd_nnc_test4 COMMAND rd_nnc_test ${_eclpath}/DualPoro/DUAL_DIFF.EGRID) -add_test(NAME ecl_nnc_test5 - COMMAND ecl_nnc_test +add_test(NAME rd_nnc_test5 + COMMAND rd_nnc_test ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR.EGRID) -add_test(NAME ecl_layer_equinor - COMMAND ecl_layer_equinor ${_eclpath}/Mariner/MARINER.EGRID +add_test(NAME rd_layer_equinor + COMMAND rd_layer_equinor ${_eclpath}/Mariner/MARINER.EGRID ${_eclpath}/Mariner/faultblock.grdecl) -add_test(NAME ecl_dualp COMMAND ecl_dualp ${_eclpath}/LGCcase/LGC_TESTCASE2) +add_test(NAME rd_dualp COMMAND rd_dualp ${_eclpath}/LGCcase/LGC_TESTCASE2) -add_test(NAME ecl_sum_test COMMAND ecl_sum_test ${_eclpath}/Gurbat/ECLIPSE) +add_test(NAME rd_sum_test COMMAND rd_sum_test ${_eclpath}/Gurbat/ECLIPSE) -add_test(NAME ecl_sum_report_step_equal1 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_equal1 + COMMAND rd_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Snorre/SNORRE FALSE) -add_test(NAME ecl_sum_report_step_equal2 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_equal2 + COMMAND rd_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Gurbat/ECLIPSE TRUE) -add_test(NAME ecl_sum_report_step_equal3 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_equal3 + COMMAND rd_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/extraMinistep/ECLIPSE TRUE) -add_test(NAME ecl_sum_report_step_equal4 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_equal4 + COMMAND rd_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/short/ECLIPSE FALSE) -add_test(NAME ecl_sum_report_step_equal5 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_equal5 + COMMAND rd_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/enkf/ECLIPSE FALSE) -add_test(NAME ecl_sum_report_step_equal6 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Snorre/SNORRE +add_test(NAME rd_sum_report_step_equal6 + COMMAND rd_sum_report_step_equal ${_eclpath}/Snorre/SNORRE ${_eclpath}/Snorre2/SNORRE2 FALSE) -add_test(NAME ecl_sum_report_step_compatible1 - COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_compatible1 + COMMAND rd_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Snorre/SNORRE FALSE) -add_test(NAME ecl_sum_report_step_compatible2 - COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_compatible2 + COMMAND rd_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Gurbat/ECLIPSE TRUE) -add_test(NAME ecl_sum_report_step_compatible3 - COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_compatible3 + COMMAND rd_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/extraMinistep/ECLIPSE TRUE) -add_test(NAME ecl_sum_report_step_compatible4 - COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_compatible4 + COMMAND rd_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/short/ECLIPSE TRUE) -add_test(NAME ecl_sum_report_step_compatible5 - COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE +add_test(NAME rd_sum_report_step_compatible5 + COMMAND rd_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/enkf/ECLIPSE TRUE) -add_test(NAME ecl_sum_report_step_compatible6 - COMMAND ecl_sum_report_step_equal ${_eclpath}/Snorre/SNORRE +add_test(NAME rd_sum_report_step_compatible6 + COMMAND rd_sum_report_step_equal ${_eclpath}/Snorre/SNORRE ${_eclpath}/Snorre2/SNORRE2 FALSE) -add_test(NAME ecl_file_equinor - COMMAND ecl_file_equinor ${_eclpath}/Gurbat/ECLIPSE.UNRST +add_test(NAME rd_file_equinor + COMMAND rd_file_equinor ${_eclpath}/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST) -add_test(NAME ecl_rsthead COMMAND ecl_rsthead ${_eclpath}/Gurbat/ECLIPSE.UNRST +add_test(NAME rd_rsthead COMMAND rd_rsthead ${_eclpath}/Gurbat/ECLIPSE.UNRST ${_eclpath}/DualPoro/DUALPORO.X0005) -add_test(NAME ecl_smspec - COMMAND ecl_smspec ${_eclpath}/Gurbat/ECLIPSE.SMSPEC +add_test(NAME rd_smspec + COMMAND rd_smspec ${_eclpath}/Gurbat/ECLIPSE.SMSPEC ${_eclpath}/Heidrun/Summary/FF12_2013B3_CLEAN_RS.SMSPEC) -add_test(NAME ecl_rft_rft COMMAND ecl_rft ${_eclpath}/Gurbat/ECLIPSE.RFT RFT) -add_test(NAME ecl_rft_rft_rw COMMAND ecl_rft ${_eclpath}/Gurbat/ECLIPSE.RFT +add_test(NAME rd_rft_rft COMMAND rd_rft ${_eclpath}/Gurbat/ECLIPSE.RFT RFT) +add_test(NAME rd_rft_rft_rw COMMAND rd_rft ${_eclpath}/Gurbat/ECLIPSE.RFT RFT_RW) -add_test(NAME ecl_rft_plt COMMAND ecl_rft ${_eclpath}/RFT/TEST1_1A.RFT PLT) -add_test(NAME ecl_rft_mswplt COMMAND ecl_rft ${_eclpath}/RFT/RFT2.RFT MSW-PLT) -add_test(NAME ecl_rft_alloc - COMMAND ecl_rft ${_eclpath}/RFT/NORNE_ATW2013_RFTPLT_V2.RFT SIMPLE) +add_test(NAME rd_rft_plt COMMAND rd_rft ${_eclpath}/RFT/TEST1_1A.RFT PLT) +add_test(NAME rd_rft_mswplt COMMAND rd_rft ${_eclpath}/RFT/RFT2.RFT MSW-PLT) +add_test(NAME rd_rft_alloc + COMMAND rd_rft ${_eclpath}/RFT/NORNE_ATW2013_RFTPLT_V2.RFT SIMPLE) add_test( - NAME ecl_fault_block_layer_equinor - COMMAND ecl_fault_block_layer_equinor ${_eclpath}/Mariner/MARINER.EGRID + NAME rd_fault_block_layer_equinor + COMMAND rd_fault_block_layer_equinor ${_eclpath}/Mariner/MARINER.EGRID ${_eclpath}/Mariner/faultblock.grdecl) if(HAVE_UTIL_ABORT_INTERCEPT) - add_executable(ecl_fortio ecl/tests/ecl_fortio.cpp) - target_link_libraries(ecl_fortio ecl) - add_test(NAME ecl_fortio COMMAND ecl_fortio ${_eclpath}/Gurbat/ECLIPSE.UNRST) + add_executable(rd_fortio resdata/tests/rd_fortio.cpp) + target_link_libraries(rd_fortio ecl) + add_test(NAME rd_fortio COMMAND rd_fortio ${_eclpath}/Gurbat/ECLIPSE.UNRST) endif() add_test(NAME well_state_load1 diff --git a/lib/include/ert/util/rd_version.h b/lib/include/ert/util/rd_version.h index 726409d8b0..29496a4d34 100644 --- a/lib/include/ert/util/rd_version.h +++ b/lib/include/ert/util/rd_version.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/ert/util/rd_version.hpp b/lib/include/ert/util/rd_version.hpp index c05c39cdee..7b5a67695c 100644 --- a/lib/include/ert/util/rd_version.hpp +++ b/lib/include/ert/util/rd_version.hpp @@ -1,5 +1,5 @@ -#ifndef ECL_VERSION -#define ECL_VERSION +#ifndef RD_VERSION +#define RD_VERSION #include @@ -7,13 +7,13 @@ extern "C" { #endif -const char *ecl_version_get_git_commit(); -const char *ecl_version_get_git_commit_short(); -const char *ecl_version_get_build_time(); -int ecl_version_get_major_version(); -int ecl_version_get_minor_version(); -const char *ecl_version_get_micro_version(); -bool ecl_version_is_ert_devel_version(); +const char *rd_version_get_git_commit(); +const char *rd_version_get_git_commit_short(); +const char *rd_version_get_build_time(); +int rd_version_get_major_version(); +int rd_version_get_minor_version(); +const char *rd_version_get_micro_version(); +bool rd_version_is_ert_devel_version(); #ifdef __cplusplus } diff --git a/lib/include/ert/util/test_work_area.hpp b/lib/include/ert/util/test_work_area.hpp index 6be391619e..0e1ed94157 100644 --- a/lib/include/ert/util/test_work_area.hpp +++ b/lib/include/ert/util/test_work_area.hpp @@ -3,7 +3,7 @@ #include -namespace ecl { +namespace rd { namespace util { class TestArea { @@ -28,9 +28,9 @@ class TestArea { }; } // namespace util -} // namespace ecl +} // namespace rd -typedef ecl::util::TestArea test_work_area_type; +typedef rd::util::TestArea test_work_area_type; #ifdef __cplusplus extern "C" { diff --git a/lib/include/resdata/EclFilename.hpp b/lib/include/resdata/EclFilename.hpp index 6dd8c0a98d..77b5b9308c 100644 --- a/lib/include/resdata/EclFilename.hpp +++ b/lib/include/resdata/EclFilename.hpp @@ -1,21 +1,21 @@ -#ifndef ERT_ECL_FILEMAME_HPP -#define ERT_ECL_FILEMAME_HPP +#ifndef ERT_RD_FILEMAME_HPP +#define ERT_RD_FILEMAME_HPP #include -#include +#include namespace ERT { -std::string EclFilename(const std::string &base, ecl_file_enum file_type, - int report_step, bool fmt_file = false); -std::string EclFilename(const std::string &base, ecl_file_enum file_type, - bool fmt_file = false); +std::string ResdataFilename(const std::string &base, rd_file_enum file_type, + int report_step, bool fmt_file = false); +std::string ResdataFilename(const std::string &base, rd_file_enum file_type, + bool fmt_file = false); -std::string EclFilename(const std::string &path, const std::string &base, - ecl_file_enum file_type, int report_step, - bool fmt_file = false); -std::string EclFilename(const std::string &path, const std::string &base, - ecl_file_enum file_type, bool fmt_file = false); +std::string ResdataFilename(const std::string &path, const std::string &base, + rd_file_enum file_type, int report_step, + bool fmt_file = false); +std::string ResdataFilename(const std::string &path, const std::string &base, + rd_file_enum file_type, bool fmt_file = false); -ecl_file_enum EclFiletype(const std::string &filename); +rd_file_enum ResdataFiletype(const std::string &filename); } // namespace ERT #endif diff --git a/lib/include/resdata/EclKW.hpp b/lib/include/resdata/EclKW.hpp index a9d035501c..f1b4d41c69 100644 --- a/lib/include/resdata/EclKW.hpp +++ b/lib/include/resdata/EclKW.hpp @@ -1,5 +1,5 @@ -#ifndef OPM_ERT_ECL_KW -#define OPM_ERT_ECL_KW +#ifndef OPM_ERT_RD_KW +#define OPM_ERT_RD_KW #include #include @@ -8,210 +8,213 @@ #include #include -#include -#include -#include +#include +#include +#include namespace ERT { -template struct ecl_type {}; +template struct rd_type {}; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_FLOAT_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_FLOAT_TYPE}; }; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_DOUBLE_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_DOUBLE_TYPE}; }; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_INT_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_INT_TYPE}; }; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_BOOL_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_BOOL_TYPE}; }; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_CHAR_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_CHAR_TYPE}; }; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_CHAR_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_CHAR_TYPE}; }; /* Both std::string and char* are mapped to the eight character string type - ECL_CHAR_TYPE. That implies that the variable length string type - ECL_STRING is invisible from this API. + RD_CHAR_TYPE. That implies that the variable length string type + RD_STRING is invisible from this API. */ -template <> struct ecl_type { - static const ecl_type_enum type{ECL_CHAR_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_CHAR_TYPE}; }; -template <> struct ecl_type { - static const ecl_type_enum type{ECL_CHAR_TYPE}; +template <> struct rd_type { + static const rd_type_enum type{RD_CHAR_TYPE}; }; -template class EclKW_ref { +template class ResdataKW_ref { public: - explicit EclKW_ref(ecl_kw_type *kw) : m_kw(kw) { - if (ecl_type_get_type(ecl_kw_get_data_type(kw)) != ecl_type::type) + explicit ResdataKW_ref(rd_kw_type *kw) : m_kw(kw) { + if (rd_type_get_type(rd_kw_get_data_type(kw)) != rd_type::type) throw std::invalid_argument("Type error"); } - EclKW_ref() noexcept = default; + ResdataKW_ref() noexcept = default; - const char *name() const { return ecl_kw_get_header(this->m_kw); } + const char *name() const { return rd_kw_get_header(this->m_kw); } - size_t size() const { return size_t(ecl_kw_get_size(this->m_kw)); } + size_t size() const { return size_t(rd_kw_get_size(this->m_kw)); } void fwrite(FortIO &fortio) const { - ecl_kw_fwrite(this->m_kw, fortio.get()); + rd_kw_fwrite(this->m_kw, fortio.get()); } T at(size_t i) const { - return *static_cast(ecl_kw_iget_ptr(this->m_kw, i)); + return *static_cast(rd_kw_iget_ptr(this->m_kw, i)); } T &operator[](size_t i) { - return *static_cast(ecl_kw_iget_ptr(this->m_kw, i)); + return *static_cast(rd_kw_iget_ptr(this->m_kw, i)); } const typename std::remove_pointer::type *data() const { using Tp = const typename std::remove_pointer::type *; - return static_cast(ecl_kw_get_ptr(this->m_kw)); + return static_cast(rd_kw_get_ptr(this->m_kw)); } - ecl_kw_type *get() const { return this->m_kw; } + rd_kw_type *get() const { return this->m_kw; } - void resize(size_t new_size) { ecl_kw_resize(this->m_kw, new_size); } + void resize(size_t new_size) { rd_kw_resize(this->m_kw, new_size); } protected: - ecl_kw_type *m_kw = nullptr; + rd_kw_type *m_kw = nullptr; }; -template <> inline bool EclKW_ref::at(size_t i) const { - return ecl_kw_iget_bool(this->m_kw, i); +template <> inline bool ResdataKW_ref::at(size_t i) const { + return rd_kw_iget_bool(this->m_kw, i); } -template <> inline const char *EclKW_ref::at(size_t i) const { - return ecl_kw_iget_char_ptr(this->m_kw, i); +template <> inline const char *ResdataKW_ref::at(size_t i) const { + return rd_kw_iget_char_ptr(this->m_kw, i); } -template <> inline std::string EclKW_ref::at(size_t i) const { - return ecl_kw_iget_char_ptr(this->m_kw, i); +template <> inline std::string ResdataKW_ref::at(size_t i) const { + return rd_kw_iget_char_ptr(this->m_kw, i); } /* The current implementation of "string" and "bool" storage in the underlying C - ecl_kw structure does not lend itself to easily implement operator[]. We have + rd_kw structure does not lend itself to easily implement operator[]. We have therefore explicitly deleted them here. */ -template <> const char *&EclKW_ref::operator[](size_t i) = delete; +template <> +const char *&ResdataKW_ref::operator[](size_t i) = delete; -template <> bool &EclKW_ref::operator[](size_t i) = delete; +template <> bool &ResdataKW_ref::operator[](size_t i) = delete; -template class EclKW : public EclKW_ref { +template class ResdataKW : public ResdataKW_ref { private: - using base = EclKW_ref; + using base = ResdataKW_ref; public: - using EclKW_ref::EclKW_ref; + using ResdataKW_ref::ResdataKW_ref; - EclKW(const EclKW &) = delete; - EclKW(EclKW &&rhs) : base(rhs.m_kw) { rhs.m_kw = nullptr; } + ResdataKW(const ResdataKW &) = delete; + ResdataKW(ResdataKW &&rhs) : base(rhs.m_kw) { rhs.m_kw = nullptr; } - ~EclKW() { + ~ResdataKW() { if (this->m_kw) - ecl_kw_free(this->m_kw); + rd_kw_free(this->m_kw); } - EclKW(const std::string &kw, int size_) - : base(ecl_kw_alloc(kw.c_str(), size_, - ecl_type_create_from_type(ecl_type::type))) {} + ResdataKW(const std::string &kw, int size_) + : base(rd_kw_alloc(kw.c_str(), size_, + rd_type_create_from_type(rd_type::type))) {} - EclKW(const std::string &kw, const std::vector &data) - : EclKW(kw, data.size()) { - ecl_kw_set_memcpy_data(this->m_kw, data.data()); + ResdataKW(const std::string &kw, const std::vector &data) + : ResdataKW(kw, data.size()) { + rd_kw_set_memcpy_data(this->m_kw, data.data()); } template - EclKW(const std::string &kw, const std::vector &data) - : EclKW(kw, data.size()) { - T *target = static_cast(ecl_kw_get_ptr(this->m_kw)); + ResdataKW(const std::string &kw, const std::vector &data) + : ResdataKW(kw, data.size()) { + T *target = static_cast(rd_kw_get_ptr(this->m_kw)); for (size_t i = 0; i < data.size(); ++i) target[i] = T(data[i]); } std::vector data() const { - const T *ptr = static_cast(ecl_kw_get_ptr(this->m_kw)); + const T *ptr = static_cast(rd_kw_get_ptr(this->m_kw)); std::vector vector; vector.assign(ptr, ptr + this->size()); return vector; } - static EclKW load(FortIO &fortio) { - ecl_kw_type *c_ptr = ecl_kw_fread_alloc(fortio.get()); + static ResdataKW load(FortIO &fortio) { + rd_kw_type *c_ptr = rd_kw_fread_alloc(fortio.get()); if (!c_ptr) throw std::invalid_argument("fread kw failed - EOF?"); - return EclKW(c_ptr); + return ResdataKW(c_ptr); } }; template <> -inline EclKW::EclKW(const std::string &kw, - const std::vector &data) - : EclKW(kw, data.size()) { +inline ResdataKW::ResdataKW(const std::string &kw, + const std::vector &data) + : ResdataKW(kw, data.size()) { auto *ptr = this->get(); for (size_t i = 0; i < data.size(); ++i) { if (strlen(data[i]) > 8) throw std::range_error("Strings must be maximum 8 characters long"); - ecl_kw_iset_string8(ptr, i, data[i]); + rd_kw_iset_string8(ptr, i, data[i]); } } template <> -inline EclKW::EclKW(const std::string &kw, - const std::vector &data) - : EclKW(kw, data.size()) { +inline ResdataKW::ResdataKW(const std::string &kw, + const std::vector &data) + : ResdataKW(kw, data.size()) { auto *ptr = this->get(); for (size_t i = 0; i < data.size(); ++i) { if (data[i].size() > 8) throw std::range_error("Strings must be maximum 8 characters long"); - ecl_kw_iset_string8(ptr, i, data[i].c_str()); + rd_kw_iset_string8(ptr, i, data[i].c_str()); } } template <> template <> -inline EclKW::EclKW(const std::string &kw, - const std::vector &data) - : EclKW(kw, data.size()) { +inline ResdataKW::ResdataKW(const std::string &kw, + const std::vector &data) + : ResdataKW(kw, data.size()) { auto *ptr = this->get(); for (size_t i = 0; i < data.size(); ++i) { if (strlen(data[i]) > 8) throw std::range_error("Strings must be maximum 8 characters long"); - ecl_kw_iset_string8(ptr, i, data[i]); + rd_kw_iset_string8(ptr, i, data[i]); } } template <> -inline EclKW::EclKW(const std::string &kw, const std::vector &data) - : EclKW(kw, data.size()) { +inline ResdataKW::ResdataKW(const std::string &kw, + const std::vector &data) + : ResdataKW(kw, data.size()) { for (size_t i = 0; i < data.size(); i++) - ecl_kw_iset_bool(this->m_kw, i, data[i]); + rd_kw_iset_bool(this->m_kw, i, data[i]); } -template <> inline std::vector EclKW::data() const { +template <> +inline std::vector ResdataKW::data() const { std::vector strings; auto *ptr = this->get(); for (size_t i = 0; i < this->size(); ++i) { - std::string s8 = ecl_kw_iget_char_ptr(ptr, i); + std::string s8 = rd_kw_iget_char_ptr(ptr, i); s8.erase(s8.find_last_not_of(' ') + 1); strings.push_back(s8); } @@ -219,21 +222,21 @@ template <> inline std::vector EclKW::data() const { } /* - Will write an ecl_kw instance to the open Fortio file. + Will write an rd_kw instance to the open Fortio file. */ template void write_kw(FortIO &fortio, const std::string &kw, const std::vector &data) { - EclKW ecl_kw(kw, data); - ecl_kw_fwrite(ecl_kw.get(), fortio.get()); + ResdataKW rd_kw(kw, data); + rd_kw_fwrite(rd_kw.get(), fortio.get()); } /* - Will write an empty ecl_kw instance of type 'MESS' to the Fortio file. + Will write an empty rd_kw instance of type 'MESS' to the Fortio file. */ inline void write_mess(FortIO &fortio, const std::string &kw) { - ecl_kw_type *ecl_kw = ecl_kw_alloc(kw.c_str(), 0, ECL_MESS); - ecl_kw_fwrite(ecl_kw, fortio.get()); + rd_kw_type *rd_kw = rd_kw_alloc(kw.c_str(), 0, RD_MESS); + rd_kw_fwrite(rd_kw, fortio.get()); } } // namespace ERT diff --git a/lib/include/resdata/FortIO.hpp b/lib/include/resdata/FortIO.hpp index 795434b8e1..f7ec56ff76 100644 --- a/lib/include/resdata/FortIO.hpp +++ b/lib/include/resdata/FortIO.hpp @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include @@ -15,9 +15,9 @@ class FortIO { public: FortIO(); FortIO(const std::string &filename, std::ios_base::openmode mode, - bool fmt_file = false, bool endian_flip_header = ECL_ENDIAN_FLIP); + bool fmt_file = false, bool endian_flip_header = RD_ENDIAN_FLIP); void open(const std::string &filename, std::ios_base::openmode mode, - bool fmt_file = false, bool endian_flip_header = ECL_ENDIAN_FLIP); + bool fmt_file = false, bool endian_flip_header = RD_ENDIAN_FLIP); void fflush() const; bool ftruncate(offset_type new_size); diff --git a/lib/include/resdata/fault_block.h b/lib/include/resdata/fault_block.h index 4b2af188aa..33c6eb0a8d 100644 --- a/lib/include/resdata/fault_block.h +++ b/lib/include/resdata/fault_block.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/fault_block.hpp b/lib/include/resdata/fault_block.hpp index 919f03d36f..61157a22ec 100644 --- a/lib/include/resdata/fault_block.hpp +++ b/lib/include/resdata/fault_block.hpp @@ -10,8 +10,8 @@ extern "C" { #include -#include -#include +#include +#include typedef struct fault_block_struct fault_block_type; diff --git a/lib/include/resdata/fault_block_layer.h b/lib/include/resdata/fault_block_layer.h index 29f1046663..44145a8247 100644 --- a/lib/include/resdata/fault_block_layer.h +++ b/lib/include/resdata/fault_block_layer.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/fault_block_layer.hpp b/lib/include/resdata/fault_block_layer.hpp index ec05f6036f..e7604cae37 100644 --- a/lib/include/resdata/fault_block_layer.hpp +++ b/lib/include/resdata/fault_block_layer.hpp @@ -6,16 +6,16 @@ extern "C" { #include -#include -#include -#include -#include +#include +#include +#include +#include UTIL_IS_INSTANCE_HEADER(fault_block_layer); typedef struct fault_block_layer_struct fault_block_layer_type; -fault_block_layer_type *fault_block_layer_alloc(const ecl_grid_type *grid, +fault_block_layer_type *fault_block_layer_alloc(const rd_grid_type *grid, int k); void fault_block_layer_free(fault_block_layer_type *layer); void fault_block_layer_free__(void *arg); @@ -35,17 +35,17 @@ int fault_block_layer_get_max_id(const fault_block_layer_type *layer); int fault_block_layer_get_next_id(const fault_block_layer_type *layer); int fault_block_layer_get_size(const fault_block_layer_type *layer); bool fault_block_layer_scan_kw(fault_block_layer_type *layer, - const ecl_kw_type *fault_block_kw); + const rd_kw_type *fault_block_kw); bool fault_block_layer_load_kw(fault_block_layer_type *layer, - const ecl_kw_type *fault_block_kw); + const rd_kw_type *fault_block_kw); int fault_block_layer_get_k(const fault_block_layer_type *layer); void fault_block_layer_scan_layer(fault_block_layer_type *fault_layer, layer_type *layer); void fault_block_layer_insert_block_content(fault_block_layer_type *layer, const fault_block_type *src_block); bool fault_block_layer_export(const fault_block_layer_type *layer, - ecl_kw_type *faultblock_kw); -const ecl_grid_type * + rd_kw_type *faultblock_kw); +const rd_grid_type * fault_block_layer_get_grid(const fault_block_layer_type *layer); layer_type *fault_block_layer_get_layer(const fault_block_layer_type *layer); diff --git a/lib/include/resdata/grid_dims.h b/lib/include/resdata/grid_dims.h index e60cd7729e..e66d27d5f0 100644 --- a/lib/include/resdata/grid_dims.h +++ b/lib/include/resdata/grid_dims.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/layer.h b/lib/include/resdata/layer.h index 14a5716279..ed0f62ac9b 100644 --- a/lib/include/resdata/layer.h +++ b/lib/include/resdata/layer.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/layer.hpp b/lib/include/resdata/layer.hpp index 0d05afccbd..c8d0135172 100644 --- a/lib/include/resdata/layer.hpp +++ b/lib/include/resdata/layer.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include #ifdef __cplusplus extern "C" { @@ -58,7 +58,7 @@ void layer_add_interp_barrier(layer_type *layer, int c1, int c2); void layer_add_ijbarrier(layer_type *layer, int i1, int j1, int i2, int j2); void layer_add_barrier(layer_type *layer, int c1, int c2); void layer_memcpy(layer_type *target_layer, const layer_type *src_layer); -void layer_update_active(layer_type *layer, const ecl_grid_type *grid, int k); +void layer_update_active(layer_type *layer, const rd_grid_type *grid, int k); void layer_clear_cells(layer_type *layer); void layer_update_connected_cells(layer_type *layer, int i, int j, int org_value, int new_value); diff --git a/lib/include/resdata/nnc_info.h b/lib/include/resdata/nnc_info.h index bd6c7bf375..de5c44c3f6 100644 --- a/lib/include/resdata/nnc_info.h +++ b/lib/include/resdata/nnc_info.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/nnc_info.hpp b/lib/include/resdata/nnc_info.hpp index c518a4b83a..af8ff16242 100644 --- a/lib/include/resdata/nnc_info.hpp +++ b/lib/include/resdata/nnc_info.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include typedef struct nnc_info_struct nnc_info_type; diff --git a/lib/include/resdata/nnc_vector.h b/lib/include/resdata/nnc_vector.h index 37954c2368..067b7d609e 100644 --- a/lib/include/resdata/nnc_vector.h +++ b/lib/include/resdata/nnc_vector.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_box.hpp b/lib/include/resdata/rd_box.hpp index 7ad7b145fd..a1c01a2e79 100644 --- a/lib/include/resdata/rd_box.hpp +++ b/lib/include/resdata/rd_box.hpp @@ -1,24 +1,24 @@ -#ifndef ERT_ECL_BOX_H -#define ERT_ECL_BOX_H +#ifndef ERT_RD_BOX_H +#define ERT_RD_BOX_H #include -#include +#include -namespace ecl { +namespace rd { -class ecl_box { +class rd_box { public: - ecl_box(const ecl_grid_type *grid, int i1, int i2, int j1, int j2, int k1, - int k2); + rd_box(const rd_grid_type *grid, int i1, int i2, int j1, int j2, int k1, + int k2); const std::vector &active_list() const; private: - const ecl_grid_type *grid; + const rd_grid_type *grid; int i1, i2, j1, j2, k1, k2; std::vector active_index_list; std::vector global_index_list; }; -} // namespace ecl +} // namespace rd #endif diff --git a/lib/include/resdata/rd_coarse_cell.h b/lib/include/resdata/rd_coarse_cell.h index ff4e19cba6..791be99191 100644 --- a/lib/include/resdata/rd_coarse_cell.h +++ b/lib/include/resdata/rd_coarse_cell.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_coarse_cell.hpp b/lib/include/resdata/rd_coarse_cell.hpp index 9f31f22d9e..131ca3a878 100644 --- a/lib/include/resdata/rd_coarse_cell.hpp +++ b/lib/include/resdata/rd_coarse_cell.hpp @@ -1,49 +1,49 @@ -#ifndef ERT_ECL_COARSE_CELL_H -#define ERT_ECL_COARSE_CELL_H +#ifndef ERT_RD_COARSE_CELL_H +#define ERT_RD_COARSE_CELL_H #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_coarse_cell_struct ecl_coarse_cell_type; +typedef struct rd_coarse_cell_struct rd_coarse_cell_type; -bool ecl_coarse_cell_equal(const ecl_coarse_cell_type *coarse_cell1, - const ecl_coarse_cell_type *coarse_cell2); -ecl_coarse_cell_type *ecl_coarse_cell_alloc(void); -void ecl_coarse_cell_update(ecl_coarse_cell_type *coarse_cell, int i, int j, - int k, int global_index); -void ecl_coarse_cell_free(ecl_coarse_cell_type *coarse_cell); -void ecl_coarse_cell_free__(void *arg); +bool rd_coarse_cell_equal(const rd_coarse_cell_type *coarse_cell1, + const rd_coarse_cell_type *coarse_cell2); +rd_coarse_cell_type *rd_coarse_cell_alloc(void); +void rd_coarse_cell_update(rd_coarse_cell_type *coarse_cell, int i, int j, + int k, int global_index); +void rd_coarse_cell_free(rd_coarse_cell_type *coarse_cell); +void rd_coarse_cell_free__(void *arg); -int ecl_coarse_cell_get_i1(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_j1(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_k1(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_i2(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_j2(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_k2(const ecl_coarse_cell_type *coarse_cell); -const int *ecl_coarse_cell_get_box_ptr(const ecl_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_i1(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_j1(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_k1(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_i2(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_j2(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_k2(const rd_coarse_cell_type *coarse_cell); +const int *rd_coarse_cell_get_box_ptr(const rd_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_size(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_iget_cell_index(ecl_coarse_cell_type *coarse_cell, - int group_index); -const int *ecl_coarse_cell_get_index_ptr(ecl_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_size(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_iget_cell_index(rd_coarse_cell_type *coarse_cell, + int group_index); +const int *rd_coarse_cell_get_index_ptr(rd_coarse_cell_type *coarse_cell); const int_vector_type * -ecl_coarse_cell_get_index_vector(ecl_coarse_cell_type *coarse_cell); +rd_coarse_cell_get_index_vector(rd_coarse_cell_type *coarse_cell); -void ecl_coarse_cell_reset_active_index(ecl_coarse_cell_type *coarse_cell); -void ecl_coarse_cell_update_index(ecl_coarse_cell_type *coarse_cell, - int global_index, int *active_index, - int *active_fracture_index, int active_value); -int ecl_coarse_cell_get_active_index(const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_get_active_fracture_index( - const ecl_coarse_cell_type *coarse_cell); -int ecl_coarse_cell_iget_active_cell_index( - const ecl_coarse_cell_type *coarse_cell, int index); -int ecl_coarse_cell_iget_active_value(const ecl_coarse_cell_type *coarse_cell, - int index); -int ecl_coarse_cell_get_num_active(const ecl_coarse_cell_type *coarse_cell); -void ecl_coarse_cell_fprintf(const ecl_coarse_cell_type *coarse_cell, - FILE *stream); +void rd_coarse_cell_reset_active_index(rd_coarse_cell_type *coarse_cell); +void rd_coarse_cell_update_index(rd_coarse_cell_type *coarse_cell, + int global_index, int *active_index, + int *active_fracture_index, int active_value); +int rd_coarse_cell_get_active_index(const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_get_active_fracture_index( + const rd_coarse_cell_type *coarse_cell); +int rd_coarse_cell_iget_active_cell_index( + const rd_coarse_cell_type *coarse_cell, int index); +int rd_coarse_cell_iget_active_value(const rd_coarse_cell_type *coarse_cell, + int index); +int rd_coarse_cell_get_num_active(const rd_coarse_cell_type *coarse_cell); +void rd_coarse_cell_fprintf(const rd_coarse_cell_type *coarse_cell, + FILE *stream); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_endian_flip.h b/lib/include/resdata/rd_endian_flip.h index 8881147554..83b1e62668 100644 --- a/lib/include/resdata/rd_endian_flip.h +++ b/lib/include/resdata/rd_endian_flip.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_endian_flip.hpp b/lib/include/resdata/rd_endian_flip.hpp index 7ea91351c8..a48046ab80 100644 --- a/lib/include/resdata/rd_endian_flip.hpp +++ b/lib/include/resdata/rd_endian_flip.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_ENDIAN_FLIP_H -#define ERT_ECL_ENDIAN_FLIP_H +#ifndef ERT_RD_ENDIAN_FLIP_H +#define ERT_RD_ENDIAN_FLIP_H #ifdef __cplusplus extern "C" { #endif @@ -8,32 +8,32 @@ extern "C" { /** This header file checks if the ECLIPSE endianness and the hardware - endianness are equal, and defines the macro ECL_ENDIAN_FLIP + endianness are equal, and defines the macro RD_ENDIAN_FLIP accordingly. - All the ecl_xxx functions will use the ECL_ENDIAN_FLIP macro to + All the rd_xxx functions will use the RD_ENDIAN_FLIP macro to determine whether the endian flip should be performed. When opening - a fortio instance explicitly you can use the ECL_ENDIAN_FLIP macro + a fortio instance explicitly you can use the RD_ENDIAN_FLIP macro to get the endianness correct (for ECLIPSE usage that is). */ -#define ECLIPSE_BYTE_ORDER __BIG_ENDIAN // Alternatively: __LITTLE_ENDIAN +#define RD_BYTE_ORDER __BIG_ENDIAN // Alternatively: __LITTLE_ENDIAN #ifdef BYTE_ORDER -#if BYTE_ORDER == ECLIPSE_BYTE_ORDER -#define ECL_ENDIAN_FLIP false +#if BYTE_ORDER == RD_BYTE_ORDER +#define RD_ENDIAN_FLIP false #else -#define ECL_ENDIAN_FLIP true +#define RD_ENDIAN_FLIP true #endif #else #ifdef WIN32 -#define ECL_ENDIAN_FLIP true // Unconditional byte flip on Windows. +#define RD_ENDIAN_FLIP true // Unconditional byte flip on Windows. #else #error : The macro BYTE_ORDER is not defined? #endif #endif -#undef ECLIPSE_BYTE_ORDER +#undef RD_BYTE_ORDER #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_file.h b/lib/include/resdata/rd_file.h index 3584af5893..f510f1073c 100644 --- a/lib/include/resdata/rd_file.h +++ b/lib/include/resdata/rd_file.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_file.hpp b/lib/include/resdata/rd_file.hpp index 686cc06692..24bf254c49 100644 --- a/lib/include/resdata/rd_file.hpp +++ b/lib/include/resdata/rd_file.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_FILE_H -#define ERT_ECL_FILE_H +#ifndef ERT_RD_FILE_H +#define ERT_RD_FILE_H #ifdef __cplusplus extern "C" { @@ -8,126 +8,119 @@ extern "C" { #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#define ECL_FILE_FLAGS_ENUM_DEFS \ - {.value = 1, .name = "ECL_FILE_CLOSE_STREAM"}, { \ - .value = 2, .name = "ECL_FILE_WRITABLE" \ +#define RD_FILE_FLAGS_ENUM_DEFS \ + {.value = 1, .name = "RD_FILE_CLOSE_STREAM"}, { \ + .value = 2, .name = "RD_FILE_WRITABLE" \ } -#define ECL_FILE_FLAGS_ENUM_SIZE 2 - -typedef struct ecl_file_struct ecl_file_type; -bool ecl_file_load_all(ecl_file_type *ecl_file); -ecl_file_type *ecl_file_open(const char *filename, int flags); -ecl_file_type *ecl_file_fast_open(const char *filename, - const char *index_filename, int flags); -bool ecl_file_write_index(const ecl_file_type *ecl_file, - const char *index_filename); -bool ecl_file_index_valid(const char *file_name, const char *index_file_name); -void ecl_file_close(ecl_file_type *ecl_file); -void ecl_file_fortio_detach(ecl_file_type *ecl_file); -void ecl_file_free__(void *arg); -ecl_kw_type *ecl_file_icopy_named_kw(const ecl_file_type *ecl_file, - const char *kw, int ith); -ecl_kw_type *ecl_file_icopy_kw(const ecl_file_type *ecl_file, int index); -bool ecl_file_has_kw(const ecl_file_type *ecl_file, const char *kw); -int ecl_file_get_num_named_kw(const ecl_file_type *ecl_file, const char *kw); -int ecl_file_get_size(const ecl_file_type *ecl_file); -int ecl_file_get_num_distinct_kw(const ecl_file_type *ecl_file); -const char *ecl_file_iget_distinct_kw(const ecl_file_type *ecl_file, int index); -const char *ecl_file_get_src_file(const ecl_file_type *ecl_file); -int ecl_file_iget_occurence(const ecl_file_type *ecl_file, int index); -ecl_version_enum ecl_file_get_ecl_version(const ecl_file_type *file); -void ecl_file_fwrite_fortio(const ecl_file_type *ec_file, fortio_type *fortio, - int offset); -void ecl_file_fwrite(const ecl_file_type *ecl_file, const char *, - bool fmt_file); - -void ecl_file_replace_kw(ecl_file_type *ecl_file, ecl_kw_type *old_kw, - ecl_kw_type *new_kw, bool insert_copy); -int ecl_file_get_phases(const ecl_file_type *init_file); -void ecl_file_fprintf_kw_list(const ecl_file_type *ecl_file, FILE *stream); - -bool ecl_file_writable(const ecl_file_type *ecl_file); -int ecl_file_get_flags(const ecl_file_type *ecl_file); -void ecl_file_set_flags(ecl_file_type *ecl_file, int new_flags); -bool ecl_file_flags_set(const ecl_file_type *ecl_file, int flags); - -ecl_file_kw_type *ecl_file_iget_file_kw(const ecl_file_type *file, - int global_index); -ecl_file_kw_type *ecl_file_iget_named_file_kw(const ecl_file_type *file, - const char *kw, int ith); -ecl_kw_type *ecl_file_iget_kw(const ecl_file_type *file, int global_index); -ecl_data_type ecl_file_iget_data_type(const ecl_file_type *file, +#define RD_FILE_FLAGS_ENUM_SIZE 2 + +typedef struct rd_file_struct rd_file_type; +bool rd_file_load_all(rd_file_type *rd_file); +rd_file_type *rd_file_open(const char *filename, int flags); +rd_file_type *rd_file_fast_open(const char *filename, + const char *index_filename, int flags); +bool rd_file_write_index(const rd_file_type *rd_file, + const char *index_filename); +bool rd_file_index_valid(const char *file_name, const char *index_file_name); +void rd_file_close(rd_file_type *rd_file); +void rd_file_fortio_detach(rd_file_type *rd_file); +void rd_file_free__(void *arg); +rd_kw_type *rd_file_icopy_named_kw(const rd_file_type *rd_file, const char *kw, + int ith); +rd_kw_type *rd_file_icopy_kw(const rd_file_type *rd_file, int index); +bool rd_file_has_kw(const rd_file_type *rd_file, const char *kw); +int rd_file_get_num_named_kw(const rd_file_type *rd_file, const char *kw); +int rd_file_get_size(const rd_file_type *rd_file); +int rd_file_get_num_distinct_kw(const rd_file_type *rd_file); +const char *rd_file_iget_distinct_kw(const rd_file_type *rd_file, int index); +const char *rd_file_get_src_file(const rd_file_type *rd_file); +int rd_file_iget_occurence(const rd_file_type *rd_file, int index); +rd_version_enum rd_file_get_rd_version(const rd_file_type *file); +void rd_file_fwrite_fortio(const rd_file_type *ec_file, fortio_type *fortio, + int offset); +void rd_file_fwrite(const rd_file_type *rd_file, const char *, bool fmt_file); + +void rd_file_replace_kw(rd_file_type *rd_file, rd_kw_type *old_kw, + rd_kw_type *new_kw, bool insert_copy); +int rd_file_get_phases(const rd_file_type *init_file); +void rd_file_fprintf_kw_list(const rd_file_type *rd_file, FILE *stream); + +bool rd_file_writable(const rd_file_type *rd_file); +int rd_file_get_flags(const rd_file_type *rd_file); +void rd_file_set_flags(rd_file_type *rd_file, int new_flags); +bool rd_file_flags_set(const rd_file_type *rd_file, int flags); + +rd_file_kw_type *rd_file_iget_file_kw(const rd_file_type *file, int global_index); -int ecl_file_iget_size(const ecl_file_type *file, int global_index); -const char *ecl_file_iget_header(const ecl_file_type *file, int global_index); -ecl_kw_type *ecl_file_iget_named_kw(const ecl_file_type *file, const char *kw, - int ith); -ecl_data_type ecl_file_iget_named_data_type(const ecl_file_type *file, +rd_file_kw_type *rd_file_iget_named_file_kw(const rd_file_type *file, const char *kw, int ith); -int ecl_file_iget_named_size(const ecl_file_type *file, const char *kw, - int ith); -void ecl_file_indexed_read(const ecl_file_type *file, const char *kw, int index, - const int_vector_type *index_map, char *buffer); - -ecl_file_view_type *ecl_file_get_global_blockview(ecl_file_type *ecl_file, +rd_kw_type *rd_file_iget_kw(const rd_file_type *file, int global_index); +rd_data_type rd_file_iget_data_type(const rd_file_type *file, int global_index); +int rd_file_iget_size(const rd_file_type *file, int global_index); +const char *rd_file_iget_header(const rd_file_type *file, int global_index); +rd_kw_type *rd_file_iget_named_kw(const rd_file_type *file, const char *kw, + int ith); +rd_data_type rd_file_iget_named_data_type(const rd_file_type *file, + const char *kw, int ith); +int rd_file_iget_named_size(const rd_file_type *file, const char *kw, int ith); +void rd_file_indexed_read(const rd_file_type *file, const char *kw, int index, + const int_vector_type *index_map, char *buffer); + +rd_file_view_type *rd_file_get_global_blockview(rd_file_type *rd_file, + const char *kw, int occurence); +rd_file_view_type *rd_file_alloc_global_blockview(rd_file_type *rd_file, const char *kw, int occurence); -ecl_file_view_type *ecl_file_alloc_global_blockview(ecl_file_type *ecl_file, - const char *kw, - int occurence); -ecl_file_view_type *ecl_file_get_global_view(ecl_file_type *ecl_file); -ecl_file_view_type *ecl_file_get_active_view(ecl_file_type *ecl_file); -//bool ecl_file_writable( const ecl_file_type * ecl_file ); -bool ecl_file_save_kw(const ecl_file_type *ecl_file, const ecl_kw_type *ecl_kw); -bool ecl_file_has_kw_ptr(const ecl_file_type *ecl_file, - const ecl_kw_type *ecl_kw); - -double ecl_file_iget_restart_sim_days(const ecl_file_type *restart_file, - int index); -time_t ecl_file_iget_restart_sim_date(const ecl_file_type *restart_file, - int occurence); -int ecl_file_get_restart_index(const ecl_file_type *restart_file, - time_t sim_time); -bool ecl_file_has_report_step(const ecl_file_type *ecl_file, int report_step); -bool ecl_file_has_sim_time(const ecl_file_type *ecl_file, time_t sim_time); - -void ecl_file_close_fortio_stream(ecl_file_type *ecl_file); - -ecl_file_view_type *ecl_file_get_restart_view(ecl_file_type *ecl_file, - int input_index, int report_step, - time_t sim_time, double sim_days); -ecl_file_view_type *ecl_file_get_summary_view(ecl_file_type *ecl_file, - int report_step); - -UTIL_IS_INSTANCE_HEADER(ecl_file); +rd_file_view_type *rd_file_get_global_view(rd_file_type *rd_file); +rd_file_view_type *rd_file_get_active_view(rd_file_type *rd_file); +//bool rd_file_writable( const rd_file_type * rd_file ); +bool rd_file_save_kw(const rd_file_type *rd_file, const rd_kw_type *rd_kw); +bool rd_file_has_kw_ptr(const rd_file_type *rd_file, const rd_kw_type *rd_kw); + +double rd_file_iget_restart_sim_days(const rd_file_type *restart_file, + int index); +time_t rd_file_iget_restart_sim_date(const rd_file_type *restart_file, + int occurence); +int rd_file_get_restart_index(const rd_file_type *restart_file, + time_t sim_time); +bool rd_file_has_report_step(const rd_file_type *rd_file, int report_step); +bool rd_file_has_sim_time(const rd_file_type *rd_file, time_t sim_time); + +void rd_file_close_fortio_stream(rd_file_type *rd_file); + +rd_file_view_type *rd_file_get_restart_view(rd_file_type *rd_file, + int input_index, int report_step, + time_t sim_time, double sim_days); +rd_file_view_type *rd_file_get_summary_view(rd_file_type *rd_file, + int report_step); + +UTIL_IS_INSTANCE_HEADER(rd_file); //Deprecated: -void ecl_file_push_block(ecl_file_type *ecl_file); -void ecl_file_pop_block(ecl_file_type *ecl_file); -bool ecl_file_subselect_block(ecl_file_type *ecl_file, const char *kw, - int occurence); -bool ecl_file_select_block(ecl_file_type *ecl_file, const char *kw, - int occurence); - -bool ecl_file_select_rstblock_sim_time(ecl_file_type *ecl_file, - time_t sim_time); -bool ecl_file_select_rstblock_report_step(ecl_file_type *ecl_file, - int report_step); -bool ecl_file_iselect_rstblock(ecl_file_type *ecl_file, int seqnum_index); -ecl_file_type *ecl_file_open_rstblock_report_step(const char *filename, - int report_step, int flags); -ecl_file_type *ecl_file_open_rstblock_sim_time(const char *filename, - time_t sim_time, int flags); -ecl_file_type *ecl_file_iopen_rstblock(const char *filename, int seqnum_index, - int flags); +void rd_file_push_block(rd_file_type *rd_file); +void rd_file_pop_block(rd_file_type *rd_file); +bool rd_file_subselect_block(rd_file_type *rd_file, const char *kw, + int occurence); +bool rd_file_select_block(rd_file_type *rd_file, const char *kw, int occurence); + +bool rd_file_select_rstblock_sim_time(rd_file_type *rd_file, time_t sim_time); +bool rd_file_select_rstblock_report_step(rd_file_type *rd_file, + int report_step); +bool rd_file_iselect_rstblock(rd_file_type *rd_file, int seqnum_index); +rd_file_type *rd_file_open_rstblock_report_step(const char *filename, + int report_step, int flags); +rd_file_type *rd_file_open_rstblock_sim_time(const char *filename, + time_t sim_time, int flags); +rd_file_type *rd_file_iopen_rstblock(const char *filename, int seqnum_index, + int flags); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_file_kw.h b/lib/include/resdata/rd_file_kw.h index 8baefbbc5c..cba8144a4d 100644 --- a/lib/include/resdata/rd_file_kw.h +++ b/lib/include/resdata/rd_file_kw.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_file_kw.hpp b/lib/include/resdata/rd_file_kw.hpp index 7d5d86b69c..f81f16f6bd 100644 --- a/lib/include/resdata/rd_file_kw.hpp +++ b/lib/include/resdata/rd_file_kw.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_FILE_KW_H -#define ERT_ECL_FILE_KW_H +#ifndef ERT_RD_FILE_KW_H +#define ERT_RD_FILE_KW_H #ifdef __cplusplus extern "C" { @@ -9,48 +9,43 @@ extern "C" { #include -#include -#include +#include +#include -typedef struct ecl_file_kw_struct ecl_file_kw_type; +typedef struct rd_file_kw_struct rd_file_kw_type; typedef struct inv_map_struct inv_map_type; inv_map_type *inv_map_alloc(void); -ecl_file_kw_type *inv_map_get_file_kw(inv_map_type *inv_map, - const ecl_kw_type *ecl_kw); +rd_file_kw_type *inv_map_get_file_kw(inv_map_type *inv_map, + const rd_kw_type *rd_kw); void inv_map_free(inv_map_type *map); -bool ecl_file_kw_equal(const ecl_file_kw_type *kw1, - const ecl_file_kw_type *kw2); -ecl_file_kw_type *ecl_file_kw_alloc(const ecl_kw_type *ecl_kw, - offset_type offset); -ecl_file_kw_type *ecl_file_kw_alloc0(const char *header, - ecl_data_type data_type, int size, - offset_type offset); -void ecl_file_kw_free(ecl_file_kw_type *file_kw); -void ecl_file_kw_free__(void *arg); -ecl_kw_type *ecl_file_kw_get_kw(ecl_file_kw_type *file_kw, fortio_type *fortio, - inv_map_type *inv_map); -ecl_kw_type *ecl_file_kw_get_kw_ptr(ecl_file_kw_type *file_kw); -ecl_file_kw_type *ecl_file_kw_alloc_copy(const ecl_file_kw_type *src); -const char *ecl_file_kw_get_header(const ecl_file_kw_type *file_kw); -int ecl_file_kw_get_size(const ecl_file_kw_type *file_kw); -ecl_data_type ecl_file_kw_get_data_type(const ecl_file_kw_type *); -offset_type ecl_file_kw_get_offset(const ecl_file_kw_type *file_kw); -bool ecl_file_kw_ptr_eq(const ecl_file_kw_type *file_kw, - const ecl_kw_type *ecl_kw); -void ecl_file_kw_replace_kw(ecl_file_kw_type *file_kw, fortio_type *target, - ecl_kw_type *new_kw); -bool ecl_file_kw_fskip_data(const ecl_file_kw_type *file_kw, - fortio_type *fortio); -void ecl_file_kw_inplace_fwrite(ecl_file_kw_type *file_kw, fortio_type *fortio); - -void ecl_file_kw_fwrite(const ecl_file_kw_type *file_kw, FILE *stream); -ecl_file_kw_type **ecl_file_kw_fread_alloc_multiple(FILE *stream, int num); -ecl_file_kw_type *ecl_file_kw_fread_alloc(FILE *stream); - -void ecl_file_kw_start_transaction(const ecl_file_kw_type *file_kw, - int *ref_count); -void ecl_file_kw_end_transaction(ecl_file_kw_type *file_kw, int ref_count); +bool rd_file_kw_equal(const rd_file_kw_type *kw1, const rd_file_kw_type *kw2); +rd_file_kw_type *rd_file_kw_alloc(const rd_kw_type *rd_kw, offset_type offset); +rd_file_kw_type *rd_file_kw_alloc0(const char *header, rd_data_type data_type, + int size, offset_type offset); +void rd_file_kw_free(rd_file_kw_type *file_kw); +void rd_file_kw_free__(void *arg); +rd_kw_type *rd_file_kw_get_kw(rd_file_kw_type *file_kw, fortio_type *fortio, + inv_map_type *inv_map); +rd_kw_type *rd_file_kw_get_kw_ptr(rd_file_kw_type *file_kw); +rd_file_kw_type *rd_file_kw_alloc_copy(const rd_file_kw_type *src); +const char *rd_file_kw_get_header(const rd_file_kw_type *file_kw); +int rd_file_kw_get_size(const rd_file_kw_type *file_kw); +rd_data_type rd_file_kw_get_data_type(const rd_file_kw_type *); +offset_type rd_file_kw_get_offset(const rd_file_kw_type *file_kw); +bool rd_file_kw_ptr_eq(const rd_file_kw_type *file_kw, const rd_kw_type *rd_kw); +void rd_file_kw_replace_kw(rd_file_kw_type *file_kw, fortio_type *target, + rd_kw_type *new_kw); +bool rd_file_kw_fskip_data(const rd_file_kw_type *file_kw, fortio_type *fortio); +void rd_file_kw_inplace_fwrite(rd_file_kw_type *file_kw, fortio_type *fortio); + +void rd_file_kw_fwrite(const rd_file_kw_type *file_kw, FILE *stream); +rd_file_kw_type **rd_file_kw_fread_alloc_multiple(FILE *stream, int num); +rd_file_kw_type *rd_file_kw_fread_alloc(FILE *stream); + +void rd_file_kw_start_transaction(const rd_file_kw_type *file_kw, + int *ref_count); +void rd_file_kw_end_transaction(rd_file_kw_type *file_kw, int ref_count); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_file_view.h b/lib/include/resdata/rd_file_view.h index de51dbe2d9..91716c472b 100644 --- a/lib/include/resdata/rd_file_view.h +++ b/lib/include/resdata/rd_file_view.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_file_view.hpp b/lib/include/resdata/rd_file_view.hpp index 92f25c28d7..304f9cdd7a 100644 --- a/lib/include/resdata/rd_file_view.hpp +++ b/lib/include/resdata/rd_file_view.hpp @@ -1,147 +1,142 @@ -#ifndef ERT_ECL_FILE_VIEW_H -#define ERT_ECL_FILE_VIEW_H +#ifndef ERT_RD_FILE_VIEW_H +#define ERT_RD_FILE_VIEW_H #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { #endif typedef enum { - ECL_FILE_CLOSE_STREAM = 1, /* + RD_FILE_CLOSE_STREAM = 1, /* This flag will close the underlying FILE object between each access; this is - mainly to save filedescriptors in cases where many ecl_file instances are open at + mainly to save filedescriptors in cases where many rd_file instances are open at the same time. */ - ECL_FILE_WRITABLE = 2 /* + RD_FILE_WRITABLE = 2 /* This flag opens the file in a mode where it can be updated and modified, but it must still exist and be readable. I.e. this should not compared with the normal: fopen(filename , "w") where an existing file is truncated to zero upon successfull open. */ -} ecl_file_flag_type; +} rd_file_flag_type; -typedef struct ecl_file_view_struct ecl_file_view_type; -typedef struct ecl_file_transaction_struct ecl_file_transaction_type; +typedef struct rd_file_view_struct rd_file_view_type; +typedef struct rd_file_transaction_struct rd_file_transaction_type; -bool ecl_file_view_flags_set(const ecl_file_view_type *file_view, - int query_flags); -bool ecl_file_view_check_flags(int state_flags, int query_flags); +bool rd_file_view_flags_set(const rd_file_view_type *file_view, + int query_flags); +bool rd_file_view_check_flags(int state_flags, int query_flags); -ecl_file_view_type *ecl_file_view_alloc(fortio_type *fortio, int *flags, - inv_map_type *inv_map, bool owner); -int ecl_file_view_get_global_index(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith); -void ecl_file_view_make_index(ecl_file_view_type *ecl_file_view); -bool ecl_file_view_has_kw(const ecl_file_view_type *ecl_file_view, - const char *kw); -ecl_file_kw_type * -ecl_file_view_iget_file_kw(const ecl_file_view_type *ecl_file_view, - int global_index); -ecl_file_kw_type * -ecl_file_view_iget_named_file_kw(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith); -ecl_kw_type *ecl_file_view_iget_kw(const ecl_file_view_type *ecl_file_view, - int index); -void ecl_file_view_index_fload_kw(const ecl_file_view_type *ecl_file_view, - const char *kw, int index, - const int_vector_type *index_map, - char *buffer); -int ecl_file_view_find_kw_value(const ecl_file_view_type *ecl_file_view, - const char *kw, const void *value); -const char * -ecl_file_view_iget_distinct_kw(const ecl_file_view_type *ecl_file_view, - int index); -int ecl_file_view_get_num_distinct_kw(const ecl_file_view_type *ecl_file_view); -int ecl_file_view_get_size(const ecl_file_view_type *ecl_file_view); -ecl_data_type -ecl_file_view_iget_data_type(const ecl_file_view_type *ecl_file_view, - int index); -int ecl_file_view_iget_size(const ecl_file_view_type *ecl_file_view, int index); -const char *ecl_file_view_iget_header(const ecl_file_view_type *ecl_file_view, - int index); -ecl_kw_type * -ecl_file_view_iget_named_kw(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith); -ecl_data_type -ecl_file_view_iget_named_data_type(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith); -int ecl_file_view_iget_named_size(const ecl_file_view_type *ecl_file_view, +rd_file_view_type *rd_file_view_alloc(fortio_type *fortio, int *flags, + inv_map_type *inv_map, bool owner); +int rd_file_view_get_global_index(const rd_file_view_type *rd_file_view, + const char *kw, int ith); +void rd_file_view_make_index(rd_file_view_type *rd_file_view); +bool rd_file_view_has_kw(const rd_file_view_type *rd_file_view, const char *kw); +rd_file_kw_type * +rd_file_view_iget_file_kw(const rd_file_view_type *rd_file_view, + int global_index); +rd_file_kw_type * +rd_file_view_iget_named_file_kw(const rd_file_view_type *rd_file_view, + const char *kw, int ith); +rd_kw_type *rd_file_view_iget_kw(const rd_file_view_type *rd_file_view, + int index); +void rd_file_view_index_fload_kw(const rd_file_view_type *rd_file_view, + const char *kw, int index, + const int_vector_type *index_map, + char *buffer); +int rd_file_view_find_kw_value(const rd_file_view_type *rd_file_view, + const char *kw, const void *value); +const char *rd_file_view_iget_distinct_kw(const rd_file_view_type *rd_file_view, + int index); +int rd_file_view_get_num_distinct_kw(const rd_file_view_type *rd_file_view); +int rd_file_view_get_size(const rd_file_view_type *rd_file_view); +rd_data_type rd_file_view_iget_data_type(const rd_file_view_type *rd_file_view, + int index); +int rd_file_view_iget_size(const rd_file_view_type *rd_file_view, int index); +const char *rd_file_view_iget_header(const rd_file_view_type *rd_file_view, + int index); +rd_kw_type *rd_file_view_iget_named_kw(const rd_file_view_type *rd_file_view, + const char *kw, int ith); +rd_data_type +rd_file_view_iget_named_data_type(const rd_file_view_type *rd_file_view, const char *kw, int ith); -void ecl_file_view_replace_kw(ecl_file_view_type *ecl_file_view, - ecl_kw_type *old_kw, ecl_kw_type *new_kw, - bool insert_copy); -bool ecl_file_view_load_all(ecl_file_view_type *ecl_file_view); -void ecl_file_view_add_kw(ecl_file_view_type *ecl_file_view, - ecl_file_kw_type *file_kw); -void ecl_file_view_free(ecl_file_view_type *ecl_file_view); -void ecl_file_view_free__(void *arg); -int ecl_file_view_get_num_named_kw(const ecl_file_view_type *ecl_file_view, - const char *kw); -void ecl_file_view_fwrite(const ecl_file_view_type *ecl_file_view, - fortio_type *target, int offset); -int ecl_file_view_iget_occurence(const ecl_file_view_type *ecl_file_view, - int global_index); -void ecl_file_view_fprintf_kw_list(const ecl_file_view_type *ecl_file_view, - FILE *stream); -ecl_file_view_type * -ecl_file_view_add_blockview(ecl_file_view_type *ecl_file_view, - const char *header, int occurence); -ecl_file_view_type * -ecl_file_view_add_blockview2(ecl_file_view_type *ecl_file_view, - const char *start_kw, const char *end_kw, - int occurence); -ecl_file_view_type * -ecl_file_view_add_restart_view(ecl_file_view_type *file_view, int seqnum_index, - int report_step, time_t sim_time, - double sim_days); -ecl_file_view_type * -ecl_file_view_alloc_blockview(const ecl_file_view_type *ecl_file_view, - const char *header, int occurence); -ecl_file_view_type * -ecl_file_view_alloc_blockview2(const ecl_file_view_type *ecl_file_view, - const char *start_kw, const char *end_kw, - int occurence); +int rd_file_view_iget_named_size(const rd_file_view_type *rd_file_view, + const char *kw, int ith); +void rd_file_view_replace_kw(rd_file_view_type *rd_file_view, + rd_kw_type *old_kw, rd_kw_type *new_kw, + bool insert_copy); +bool rd_file_view_load_all(rd_file_view_type *rd_file_view); +void rd_file_view_add_kw(rd_file_view_type *rd_file_view, + rd_file_kw_type *file_kw); +void rd_file_view_free(rd_file_view_type *rd_file_view); +void rd_file_view_free__(void *arg); +int rd_file_view_get_num_named_kw(const rd_file_view_type *rd_file_view, + const char *kw); +void rd_file_view_fwrite(const rd_file_view_type *rd_file_view, + fortio_type *target, int offset); +int rd_file_view_iget_occurence(const rd_file_view_type *rd_file_view, + int global_index); +void rd_file_view_fprintf_kw_list(const rd_file_view_type *rd_file_view, + FILE *stream); +rd_file_view_type *rd_file_view_add_blockview(rd_file_view_type *rd_file_view, + const char *header, + int occurence); +rd_file_view_type *rd_file_view_add_blockview2(rd_file_view_type *rd_file_view, + const char *start_kw, + const char *end_kw, + int occurence); +rd_file_view_type *rd_file_view_add_restart_view(rd_file_view_type *file_view, + int seqnum_index, + int report_step, + time_t sim_time, + double sim_days); +rd_file_view_type * +rd_file_view_alloc_blockview(const rd_file_view_type *rd_file_view, + const char *header, int occurence); +rd_file_view_type * +rd_file_view_alloc_blockview2(const rd_file_view_type *rd_file_view, + const char *start_kw, const char *end_kw, + int occurence); -void ecl_file_view_add_child(ecl_file_view_type *parent, - ecl_file_view_type *child); -bool ecl_file_view_drop_flag(ecl_file_view_type *file_view, int flag); -void ecl_file_view_add_flag(ecl_file_view_type *file_view, int flag); +void rd_file_view_add_child(rd_file_view_type *parent, + rd_file_view_type *child); +bool rd_file_view_drop_flag(rd_file_view_type *file_view, int flag); +void rd_file_view_add_flag(rd_file_view_type *file_view, int flag); -int ecl_file_view_seqnum_index_from_sim_time(ecl_file_view_type *parent_map, - time_t sim_time); -bool ecl_file_view_has_sim_time(const ecl_file_view_type *ecl_file_view, - time_t sim_time); -int ecl_file_view_find_sim_time(const ecl_file_view_type *ecl_file_view, - time_t sim_time); -double -ecl_file_view_iget_restart_sim_days(const ecl_file_view_type *ecl_file_view, - int seqnum_index); -time_t -ecl_file_view_iget_restart_sim_date(const ecl_file_view_type *ecl_file_view, - int seqnum_index); -bool ecl_file_view_has_report_step(const ecl_file_view_type *ecl_file_view, - int report_step); +int rd_file_view_seqnum_index_from_sim_time(rd_file_view_type *parent_map, + time_t sim_time); +bool rd_file_view_has_sim_time(const rd_file_view_type *rd_file_view, + time_t sim_time); +int rd_file_view_find_sim_time(const rd_file_view_type *rd_file_view, + time_t sim_time); +double rd_file_view_iget_restart_sim_days(const rd_file_view_type *rd_file_view, + int seqnum_index); +time_t rd_file_view_iget_restart_sim_date(const rd_file_view_type *rd_file_view, + int seqnum_index); +bool rd_file_view_has_report_step(const rd_file_view_type *rd_file_view, + int report_step); -ecl_file_view_type * -ecl_file_view_add_summary_view(ecl_file_view_type *file_view, int report_step); -const char *ecl_file_view_get_src_file(const ecl_file_view_type *file_view); -void ecl_file_view_fclose_stream(ecl_file_view_type *file_view); +rd_file_view_type *rd_file_view_add_summary_view(rd_file_view_type *file_view, + int report_step); +const char *rd_file_view_get_src_file(const rd_file_view_type *file_view); +void rd_file_view_fclose_stream(rd_file_view_type *file_view); -void ecl_file_view_write_index(const ecl_file_view_type *file_view, - FILE *ostream); -ecl_file_view_type *ecl_file_view_fread_alloc(fortio_type *fortio, int *flags, - inv_map_type *inv_map, - FILE *istream); +void rd_file_view_write_index(const rd_file_view_type *file_view, + FILE *ostream); +rd_file_view_type *rd_file_view_fread_alloc(fortio_type *fortio, int *flags, + inv_map_type *inv_map, + FILE *istream); -ecl_file_transaction_type * -ecl_file_view_start_transaction(ecl_file_view_type *file_view); -void ecl_file_view_end_transaction(ecl_file_view_type *file_view, - ecl_file_transaction_type *transaction); +rd_file_transaction_type * +rd_file_view_start_transaction(rd_file_view_type *file_view); +void rd_file_view_end_transaction(rd_file_view_type *file_view, + rd_file_transaction_type *transaction); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_grav.h b/lib/include/resdata/rd_grav.h index bd976c9a83..12e54adf86 100644 --- a/lib/include/resdata/rd_grav.h +++ b/lib/include/resdata/rd_grav.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_grav.hpp b/lib/include/resdata/rd_grav.hpp index 73eeea4359..ce17a57f7f 100644 --- a/lib/include/resdata/rd_grav.hpp +++ b/lib/include/resdata/rd_grav.hpp @@ -1,39 +1,39 @@ -#ifndef ERT_ECL_GRAV_H -#define ERT_ECL_GRAV_H +#ifndef ERT_RD_GRAV_H +#define ERT_RD_GRAV_H -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_grav_struct ecl_grav_type; -typedef struct ecl_grav_survey_struct ecl_grav_survey_type; +typedef struct rd_grav_struct rd_grav_type; +typedef struct rd_grav_survey_struct rd_grav_survey_type; -void ecl_grav_free(ecl_grav_type *ecl_grav_config); -ecl_grav_type *ecl_grav_alloc(const ecl_grid_type *ecl_grid, - const ecl_file_type *init_file); -ecl_grav_survey_type * -ecl_grav_add_survey_FIP(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file); -ecl_grav_survey_type * -ecl_grav_add_survey_PORMOD(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file); -ecl_grav_survey_type * -ecl_grav_add_survey_RPORV(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file); -ecl_grav_survey_type * -ecl_grav_add_survey_RFIP(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file); -double ecl_grav_eval(const ecl_grav_type *grav, const char *base, - const char *monitor, ecl_region_type *region, double utm_x, - double utm_y, double depth, int phase_mask); -void ecl_grav_new_std_density(ecl_grav_type *grav, ecl_phase_enum phase, - double default_density); -void ecl_grav_add_std_density(ecl_grav_type *grav, ecl_phase_enum phase, - int pvtnum, double density); +void rd_grav_free(rd_grav_type *rd_grav_config); +rd_grav_type *rd_grav_alloc(const rd_grid_type *rd_grid, + const rd_file_type *init_file); +rd_grav_survey_type * +rd_grav_add_survey_FIP(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file); +rd_grav_survey_type * +rd_grav_add_survey_PORMOD(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file); +rd_grav_survey_type * +rd_grav_add_survey_RPORV(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file); +rd_grav_survey_type * +rd_grav_add_survey_RFIP(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file); +double rd_grav_eval(const rd_grav_type *grav, const char *base, + const char *monitor, rd_region_type *region, double utm_x, + double utm_y, double depth, int phase_mask); +void rd_grav_new_std_density(rd_grav_type *grav, rd_phase_enum phase, + double default_density); +void rd_grav_add_std_density(rd_grav_type *grav, rd_phase_enum phase, + int pvtnum, double density); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_grav_calc.h b/lib/include/resdata/rd_grav_calc.h index 1ef6b061c7..6a7a1e9070 100644 --- a/lib/include/resdata/rd_grav_calc.h +++ b/lib/include/resdata/rd_grav_calc.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_grav_calc.hpp b/lib/include/resdata/rd_grav_calc.hpp index 95ec01843f..9c3447b828 100644 --- a/lib/include/resdata/rd_grav_calc.hpp +++ b/lib/include/resdata/rd_grav_calc.hpp @@ -1,19 +1,19 @@ -#ifndef ERT_ECL_GRAV_CALC_H -#define ERT_ECL_GRAV_CALC_H +#ifndef ERT_RD_GRAV_CALC_H +#define ERT_RD_GRAV_CALC_H #ifdef __cplusplus extern "C" { #endif -#include -#include -#include +#include +#include +#include double -ecl_grav_phase_deltag(double utm_x, double utm_y, double tvd, - const ecl_grid_type *grid, const ecl_file_type *init_file, - const ecl_kw_type *sat_kw1, const ecl_kw_type *rho_kw1, - const ecl_kw_type *porv_kw1, const ecl_kw_type *sat_kw2, - const ecl_kw_type *rho_kw2, const ecl_kw_type *porv_kw2); +rd_grav_phase_deltag(double utm_x, double utm_y, double tvd, + const rd_grid_type *grid, const rd_file_type *init_file, + const rd_kw_type *sat_kw1, const rd_kw_type *rho_kw1, + const rd_kw_type *porv_kw1, const rd_kw_type *sat_kw2, + const rd_kw_type *rho_kw2, const rd_kw_type *porv_kw2); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_grav_common.h b/lib/include/resdata/rd_grav_common.h index f0c5d4d3ed..bc44af9765 100644 --- a/lib/include/resdata/rd_grav_common.h +++ b/lib/include/resdata/rd_grav_common.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_grav_common.hpp b/lib/include/resdata/rd_grav_common.hpp index 87a6f7dd6a..5b427bb2c3 100644 --- a/lib/include/resdata/rd_grav_common.hpp +++ b/lib/include/resdata/rd_grav_common.hpp @@ -1,29 +1,29 @@ -#ifndef ERT_ECL_GRAV_COMMON_H -#define ERT_ECL_GRAV_COMMON_H +#ifndef ERT_RD_GRAV_COMMON_H +#define ERT_RD_GRAV_COMMON_H #include -#include -#include "detail/ecl/ecl_grid_cache.hpp" +#include +#include "detail/resdata/rd_grid_cache.hpp" #ifdef __cplusplus extern "C" { #endif -bool *ecl_grav_common_alloc_aquifer_cell(const ecl::ecl_grid_cache &grid_cache, - const ecl_file_type *init_file); +bool *rd_grav_common_alloc_aquifer_cell(const rd::rd_grid_cache &grid_cache, + const rd_file_type *init_file); -double ecl_grav_common_eval_biot_savart(const ecl::ecl_grid_cache &grid_cache, - ecl_region_type *region, - const bool *aquifer, - const double *weight, double utm_x, - double utm_y, double depth); +double rd_grav_common_eval_biot_savart(const rd::rd_grid_cache &grid_cache, + rd_region_type *region, + const bool *aquifer, + const double *weight, double utm_x, + double utm_y, double depth); -double ecl_grav_common_eval_geertsma(const ecl::ecl_grid_cache &grid_cache, - ecl_region_type *region, - const bool *aquifer, const double *weight, - double utm_x, double utm_y, double depth, - double poisson_ratio, double seabed); +double rd_grav_common_eval_geertsma(const rd::rd_grid_cache &grid_cache, + rd_region_type *region, const bool *aquifer, + const double *weight, double utm_x, + double utm_y, double depth, + double poisson_ratio, double seabed); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_grid.h b/lib/include/resdata/rd_grid.h index 7879674e92..405b359cf2 100644 --- a/lib/include/resdata/rd_grid.h +++ b/lib/include/resdata/rd_grid.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_grid.hpp b/lib/include/resdata/rd_grid.hpp index 1ed89ca7e8..846d7547af 100644 --- a/lib/include/resdata/rd_grid.hpp +++ b/lib/include/resdata/rd_grid.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_GRID_H -#define ERT_ECL_GRID_H +#ifndef ERT_RD_GRID_H +#define ERT_RD_GRID_H #include @@ -7,379 +7,361 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -#define ECL_GRID_COORD_SIZE(nx, ny) (((nx) + 1) * ((ny) + 1) * 6) -#define ECL_GRID_ZCORN_SIZE(nx, ny, nz) (((nx) * (ny) * (nz)*8)) +#define RD_GRID_COORD_SIZE(nx, ny) (((nx) + 1) * ((ny) + 1) * 6) +#define RD_GRID_ZCORN_SIZE(nx, ny, nz) (((nx) * (ny) * (nz)*8)) -#define ECL_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids. -#define ECL_GRID_MAINGRID_LGR_NR 0 +#define RD_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids. +#define RD_GRID_MAINGRID_LGR_NR 0 typedef double(block_function_ftype)(const double_vector_type *); -typedef struct ecl_grid_struct ecl_grid_type; - -bool ecl_grid_have_coarse_cells(const ecl_grid_type *main_grid); -bool ecl_grid_cell_in_coarse_group1(const ecl_grid_type *main_grid, - int global_index); -bool ecl_grid_cell_in_coarse_group3(const ecl_grid_type *main_grid, int i, - int j, int k); -int ecl_grid_get_num_coarse_groups(const ecl_grid_type *main_grid); -ecl_coarse_cell_type *ecl_grid_iget_coarse_group(const ecl_grid_type *ecl_grid, - int coarse_nr); -ecl_coarse_cell_type * -ecl_grid_get_cell_coarse_group1(const ecl_grid_type *ecl_grid, - int global_index); -ecl_coarse_cell_type * -ecl_grid_get_cell_coarse_group3(const ecl_grid_type *ecl_grid, int i, int j, +typedef struct rd_grid_struct rd_grid_type; + +bool rd_grid_have_coarse_cells(const rd_grid_type *main_grid); +bool rd_grid_cell_in_coarse_group1(const rd_grid_type *main_grid, + int global_index); +bool rd_grid_cell_in_coarse_group3(const rd_grid_type *main_grid, int i, int j, + int k); +int rd_grid_get_num_coarse_groups(const rd_grid_type *main_grid); +rd_coarse_cell_type *rd_grid_iget_coarse_group(const rd_grid_type *rd_grid, + int coarse_nr); +rd_coarse_cell_type *rd_grid_get_cell_coarse_group1(const rd_grid_type *rd_grid, + int global_index); +rd_coarse_cell_type *rd_grid_get_cell_coarse_group3(const rd_grid_type *rd_grid, + int i, int j, int k); + +int rd_grid_get_cell_twist1(const rd_grid_type *rd_grid, int global_index); +int rd_grid_get_cell_twist3(const rd_grid_type *rd_grid, int i, int j, int k); + +void rd_grid_get_column_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, + double_vector_type *column); +int rd_grid_get_global_index_from_xy_top(const rd_grid_type *rd_grid, double x, + double y); +int rd_grid_get_global_index_from_xy_bottom(const rd_grid_type *rd_grid, + double x, double y); +rd_grid_type *rd_grid_alloc_dx_dy_dz_tops(int nx, int ny, int nz, + const double *dx, const double *dy, + const double *dz, const double *tops, + const int *actnum); + +void rd_grid_get_cell_corner_xyz3(const rd_grid_type *grid, int i, int j, int k, + int corner_nr, double *xpos, double *ypos, + double *zpos); +void rd_grid_get_cell_corner_xyz1(const rd_grid_type *grid, int global_index, + int corner_nr, double *xpos, double *ypos, + double *zpos); +void rd_grid_get_corner_xyz(const rd_grid_type *grid, int i, int j, int k, + double *xpos, double *ypos, double *zpos); + +double rd_grid_get_cell_dx1A(const rd_grid_type *grid, int active_index); +double rd_grid_get_cell_dy1A(const rd_grid_type *grid, int active_index); +double rd_grid_get_cell_dz1A(const rd_grid_type *grid, int active_index); +double rd_grid_get_cell_thickness1A(const rd_grid_type *grid, int active_index); + +double rd_grid_get_cell_dx1(const rd_grid_type *grid, int global_index); +double rd_grid_get_cell_dy1(const rd_grid_type *grid, int global_index); +double rd_grid_get_cell_dz1(const rd_grid_type *grid, int global_index); +double rd_grid_get_cell_thickness1(const rd_grid_type *grid, int global_index); + +double rd_grid_get_cell_dx3(const rd_grid_type *grid, int i, int j, int k); +double rd_grid_get_cell_dy3(const rd_grid_type *grid, int i, int j, int k); +double rd_grid_get_cell_dz3(const rd_grid_type *grid, int i, int j, int k); +double rd_grid_get_cell_thickness3(const rd_grid_type *grid, int i, int j, + int k); + +void rd_grid_get_distance(const rd_grid_type *grid, int global_index1, + int global_index2, double *dx, double *dy, + double *dz); +double rd_grid_get_cdepth1A(const rd_grid_type *grid, int active_index); +double rd_grid_get_cdepth1(const rd_grid_type *grid, int global_index); +double rd_grid_get_cdepth3(const rd_grid_type *grid, int i, int j, int k); +int rd_grid_get_global_index_from_xy(const rd_grid_type *rd_grid, int k, + bool lower_layer, double x, double y); +bool rd_grid_cell_contains_xyz1(const rd_grid_type *rd_grid, int global_index, + double x, double y, double z); +bool rd_grid_cell_contains_xyz3(const rd_grid_type *rd_grid, int i, int j, + int k, double x, double y, double z); +double rd_grid_get_cell_volume1(const rd_grid_type *rd_grid, int global_index); +double rd_grid_get_cell_volume3(const rd_grid_type *rd_grid, int i, int j, int k); +double rd_grid_get_cell_volume1A(const rd_grid_type *rd_grid, int active_index); +bool rd_grid_cell_contains1(const rd_grid_type *grid, int global_index, + double x, double y, double z); +bool rd_grid_cell_contains3(const rd_grid_type *grid, int i, int j, int k, + double x, double y, double z); +int rd_grid_get_global_index_from_xyz(rd_grid_type *grid, double x, double y, + double z, int start_index); +bool rd_grid_get_ijk_from_xyz(rd_grid_type *grid, double x, double y, double z, + int start_index, int *i, int *j, int *k); +bool rd_grid_get_ij_from_xy(const rd_grid_type *grid, double x, double y, int k, + int *i, int *j); +const char *rd_grid_get_name(const rd_grid_type *); +int rd_grid_get_active_index3(const rd_grid_type *rd_grid, int i, int j, int k); +int rd_grid_get_active_index1(const rd_grid_type *rd_grid, int global_index); +int rd_grid_get_active_fracture_index3(const rd_grid_type *rd_grid, int i, + int j, int k); +int rd_grid_get_active_fracture_index1(const rd_grid_type *rd_grid, + int global_index); +bool rd_grid_cell_active3(const rd_grid_type *, int, int, int); +bool rd_grid_cell_active1(const rd_grid_type *, int); +bool rd_grid_ijk_valid(const rd_grid_type *, int, int, int); +int rd_grid_get_global_index3(const rd_grid_type *, int, int, int); +int rd_grid_get_global_index1A(const rd_grid_type *rd_grid, int active_index); +int rd_grid_get_global_index1F(const rd_grid_type *rd_grid, + int active_fracture_index); + +const nnc_info_type *rd_grid_get_cell_nnc_info3(const rd_grid_type *grid, int i, + int j, int k); +const nnc_info_type *rd_grid_get_cell_nnc_info1(const rd_grid_type *grid, + int global_index); +void rd_grid_add_self_nnc(rd_grid_type *grid1, int g1, int g2, int nnc_index); +void rd_grid_add_self_nnc_list(rd_grid_type *grid, const int *g1_list, + const int *g2_list, int num_nnc); + +rd_grid_type *rd_grid_alloc_GRDECL_kw(int nx, int ny, int nz, + const rd_kw_type *zcorn_kw, + const rd_kw_type *coord_kw, + const rd_kw_type *actnum_kw, + const rd_kw_type *mapaxes_kw); +rd_grid_type *rd_grid_alloc_GRDECL_data(int, int, int, const float *, + const float *, const int *, + bool apply_mapaxes, + const float *mapaxes); +rd_grid_type *rd_grid_alloc_GRID_data(int num_coords, int nx, int ny, int nz, + int coords_size, int **coords, + float **corners, bool apply_mapaxes, + const float *mapaxes); +rd_grid_type *rd_grid_alloc(const char *); +rd_grid_type *rd_grid_alloc_ext_actnum(const char *, const int *ext_actnum); +rd_grid_type *rd_grid_load_case(const char *case_input); +rd_grid_type *rd_grid_load_case__(const char *case_input, bool apply_mapaxes); +rd_grid_type *rd_grid_alloc_rectangular(int nx, int ny, int nz, double dx, + double dy, double dz, + const int *actnum); +rd_grid_type *rd_grid_alloc_regular(int nx, int ny, int nz, const double *ivec, + const double *jvec, const double *kvec, + const int *actnum); +rd_grid_type *rd_grid_alloc_dxv_dyv_dzv(int nx, int ny, int nz, + const double *dxv, const double *dyv, + const double *dzv, const int *actnum); +rd_grid_type * +rd_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, + const double *dyv, const double *dzv, + const double *depthz, const int *actnum); +rd_kw_type *rd_grid_alloc_volume_kw(const rd_grid_type *grid, bool active_size); +rd_kw_type *rd_grid_alloc_mapaxes_kw(const rd_grid_type *grid); +rd_kw_type *rd_grid_alloc_coord_kw(const rd_grid_type *grid); + +bool rd_grid_exists(const char *case_input); +char *rd_grid_alloc_case_filename(const char *case_input); + +void rd_grid_free(rd_grid_type *); +void rd_grid_free__(void *arg); +grid_dims_type rd_grid_iget_dims(const rd_grid_type *grid, int grid_nr); +void rd_grid_get_dims(const rd_grid_type *, int *, int *, int *, int *); +int rd_grid_get_nz(const rd_grid_type *grid); +int rd_grid_get_nx(const rd_grid_type *grid); +int rd_grid_get_ny(const rd_grid_type *grid); +int rd_grid_get_nactive(const rd_grid_type *grid); +int rd_grid_get_nactive_fracture(const rd_grid_type *grid); +int rd_grid_get_active_index(const rd_grid_type *, int, int, int); +void rd_grid_summarize(const rd_grid_type *); +void rd_grid_get_ijk1(const rd_grid_type *, int global_index, int *, int *, + int *); +void rd_grid_get_ijk1A(const rd_grid_type *, int active_index, int *, int *, + int *); +void rd_grid_get_ijk_from_active_index(const rd_grid_type *, int, int *, int *, + int *); + +void rd_grid_get_xyz3(const rd_grid_type *, int, int, int, double *, double *, + double *); +void rd_grid_get_xyz1(const rd_grid_type *grid, int global_index, double *xpos, + double *ypos, double *zpos); +void rd_grid_get_xyz1A(const rd_grid_type *grid, int active_index, double *xpos, + double *ypos, double *zpos); -int ecl_grid_get_cell_twist1(const ecl_grid_type *ecl_grid, int global_index); -int ecl_grid_get_cell_twist3(const ecl_grid_type *ecl_grid, int i, int j, - int k); - -void ecl_grid_get_column_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - double_vector_type *column); -int ecl_grid_get_global_index_from_xy_top(const ecl_grid_type *ecl_grid, - double x, double y); -int ecl_grid_get_global_index_from_xy_bottom(const ecl_grid_type *ecl_grid, - double x, double y); -ecl_grid_type *ecl_grid_alloc_dx_dy_dz_tops(int nx, int ny, int nz, - const double *dx, const double *dy, - const double *dz, - const double *tops, - const int *actnum); - -void ecl_grid_get_cell_corner_xyz3(const ecl_grid_type *grid, int i, int j, - int k, int corner_nr, double *xpos, - double *ypos, double *zpos); -void ecl_grid_get_cell_corner_xyz1(const ecl_grid_type *grid, int global_index, - int corner_nr, double *xpos, double *ypos, - double *zpos); -void ecl_grid_get_corner_xyz(const ecl_grid_type *grid, int i, int j, int k, +bool rd_grid_get_xyz_inside1(const rd_grid_type *grid, int global_index, + double *xpos, double *ypos, double *zpos); +bool rd_grid_get_xyz_inside3(const rd_grid_type *grid, int i, int j, int k, double *xpos, double *ypos, double *zpos); -double ecl_grid_get_cell_dx1A(const ecl_grid_type *grid, int active_index); -double ecl_grid_get_cell_dy1A(const ecl_grid_type *grid, int active_index); -double ecl_grid_get_cell_dz1A(const ecl_grid_type *grid, int active_index); -double ecl_grid_get_cell_thickness1A(const ecl_grid_type *grid, - int active_index); - -double ecl_grid_get_cell_dx1(const ecl_grid_type *grid, int global_index); -double ecl_grid_get_cell_dy1(const ecl_grid_type *grid, int global_index); -double ecl_grid_get_cell_dz1(const ecl_grid_type *grid, int global_index); -double ecl_grid_get_cell_thickness1(const ecl_grid_type *grid, - int global_index); - -double ecl_grid_get_cell_dx3(const ecl_grid_type *grid, int i, int j, int k); -double ecl_grid_get_cell_dy3(const ecl_grid_type *grid, int i, int j, int k); -double ecl_grid_get_cell_dz3(const ecl_grid_type *grid, int i, int j, int k); -double ecl_grid_get_cell_thickness3(const ecl_grid_type *grid, int i, int j, - int k); - -void ecl_grid_get_distance(const ecl_grid_type *grid, int global_index1, - int global_index2, double *dx, double *dy, - double *dz); -double ecl_grid_get_cdepth1A(const ecl_grid_type *grid, int active_index); -double ecl_grid_get_cdepth1(const ecl_grid_type *grid, int global_index); -double ecl_grid_get_cdepth3(const ecl_grid_type *grid, int i, int j, int k); -int ecl_grid_get_global_index_from_xy(const ecl_grid_type *ecl_grid, int k, - bool lower_layer, double x, double y); -bool ecl_grid_cell_contains_xyz1(const ecl_grid_type *ecl_grid, - int global_index, double x, double y, - double z); -bool ecl_grid_cell_contains_xyz3(const ecl_grid_type *ecl_grid, int i, int j, - int k, double x, double y, double z); -double ecl_grid_get_cell_volume1(const ecl_grid_type *ecl_grid, - int global_index); -double ecl_grid_get_cell_volume3(const ecl_grid_type *ecl_grid, int i, int j, - int k); -double ecl_grid_get_cell_volume1A(const ecl_grid_type *ecl_grid, - int active_index); -bool ecl_grid_cell_contains1(const ecl_grid_type *grid, int global_index, - double x, double y, double z); -bool ecl_grid_cell_contains3(const ecl_grid_type *grid, int i, int j, int k, - double x, double y, double z); -int ecl_grid_get_global_index_from_xyz(ecl_grid_type *grid, double x, double y, - double z, int start_index); -bool ecl_grid_get_ijk_from_xyz(ecl_grid_type *grid, double x, double y, - double z, int start_index, int *i, int *j, - int *k); -bool ecl_grid_get_ij_from_xy(const ecl_grid_type *grid, double x, double y, - int k, int *i, int *j); -const char *ecl_grid_get_name(const ecl_grid_type *); -int ecl_grid_get_active_index3(const ecl_grid_type *ecl_grid, int i, int j, - int k); -int ecl_grid_get_active_index1(const ecl_grid_type *ecl_grid, int global_index); -int ecl_grid_get_active_fracture_index3(const ecl_grid_type *ecl_grid, int i, - int j, int k); -int ecl_grid_get_active_fracture_index1(const ecl_grid_type *ecl_grid, - int global_index); -bool ecl_grid_cell_active3(const ecl_grid_type *, int, int, int); -bool ecl_grid_cell_active1(const ecl_grid_type *, int); -bool ecl_grid_ijk_valid(const ecl_grid_type *, int, int, int); -int ecl_grid_get_global_index3(const ecl_grid_type *, int, int, int); -int ecl_grid_get_global_index1A(const ecl_grid_type *ecl_grid, - int active_index); -int ecl_grid_get_global_index1F(const ecl_grid_type *ecl_grid, - int active_fracture_index); - -const nnc_info_type *ecl_grid_get_cell_nnc_info3(const ecl_grid_type *grid, - int i, int j, int k); -const nnc_info_type *ecl_grid_get_cell_nnc_info1(const ecl_grid_type *grid, - int global_index); -void ecl_grid_add_self_nnc(ecl_grid_type *grid1, int g1, int g2, int nnc_index); -void ecl_grid_add_self_nnc_list(ecl_grid_type *grid, const int *g1_list, - const int *g2_list, int num_nnc); - -ecl_grid_type *ecl_grid_alloc_GRDECL_kw(int nx, int ny, int nz, - const ecl_kw_type *zcorn_kw, - const ecl_kw_type *coord_kw, - const ecl_kw_type *actnum_kw, - const ecl_kw_type *mapaxes_kw); -ecl_grid_type *ecl_grid_alloc_GRDECL_data(int, int, int, const float *, - const float *, const int *, - bool apply_mapaxes, - const float *mapaxes); -ecl_grid_type *ecl_grid_alloc_GRID_data(int num_coords, int nx, int ny, int nz, - int coords_size, int **coords, - float **corners, bool apply_mapaxes, - const float *mapaxes); -ecl_grid_type *ecl_grid_alloc(const char *); -ecl_grid_type *ecl_grid_alloc_ext_actnum(const char *, const int *ext_actnum); -ecl_grid_type *ecl_grid_load_case(const char *case_input); -ecl_grid_type *ecl_grid_load_case__(const char *case_input, bool apply_mapaxes); -ecl_grid_type *ecl_grid_alloc_rectangular(int nx, int ny, int nz, double dx, - double dy, double dz, - const int *actnum); -ecl_grid_type *ecl_grid_alloc_regular(int nx, int ny, int nz, - const double *ivec, const double *jvec, - const double *kvec, const int *actnum); -ecl_grid_type *ecl_grid_alloc_dxv_dyv_dzv(int nx, int ny, int nz, - const double *dxv, const double *dyv, - const double *dzv, const int *actnum); -ecl_grid_type * -ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, - const double *dyv, const double *dzv, - const double *depthz, const int *actnum); -ecl_kw_type *ecl_grid_alloc_volume_kw(const ecl_grid_type *grid, - bool active_size); -ecl_kw_type *ecl_grid_alloc_mapaxes_kw(const ecl_grid_type *grid); -ecl_kw_type *ecl_grid_alloc_coord_kw(const ecl_grid_type *grid); - -bool ecl_grid_exists(const char *case_input); -char *ecl_grid_alloc_case_filename(const char *case_input); - -void ecl_grid_free(ecl_grid_type *); -void ecl_grid_free__(void *arg); -grid_dims_type ecl_grid_iget_dims(const ecl_grid_type *grid, int grid_nr); -void ecl_grid_get_dims(const ecl_grid_type *, int *, int *, int *, int *); -int ecl_grid_get_nz(const ecl_grid_type *grid); -int ecl_grid_get_nx(const ecl_grid_type *grid); -int ecl_grid_get_ny(const ecl_grid_type *grid); -int ecl_grid_get_nactive(const ecl_grid_type *grid); -int ecl_grid_get_nactive_fracture(const ecl_grid_type *grid); -int ecl_grid_get_active_index(const ecl_grid_type *, int, int, int); -void ecl_grid_summarize(const ecl_grid_type *); -void ecl_grid_get_ijk1(const ecl_grid_type *, int global_index, int *, int *, - int *); -void ecl_grid_get_ijk1A(const ecl_grid_type *, int active_index, int *, int *, - int *); -void ecl_grid_get_ijk_from_active_index(const ecl_grid_type *, int, int *, - int *, int *); - -void ecl_grid_get_xyz3(const ecl_grid_type *, int, int, int, double *, double *, - double *); -void ecl_grid_get_xyz1(const ecl_grid_type *grid, int global_index, - double *xpos, double *ypos, double *zpos); -void ecl_grid_get_xyz1A(const ecl_grid_type *grid, int active_index, - double *xpos, double *ypos, double *zpos); - -bool ecl_grid_get_xyz_inside1(const ecl_grid_type *grid, int global_index, - double *xpos, double *ypos, double *zpos); -bool ecl_grid_get_xyz_inside3(const ecl_grid_type *grid, int i, int j, int k, - double *xpos, double *ypos, double *zpos); - -int ecl_grid_get_global_size(const ecl_grid_type *ecl_grid); -bool ecl_grid_compare(const ecl_grid_type *g1, const ecl_grid_type *g2, - bool include_lgr, bool include_nnc, bool verbose); -int ecl_grid_get_active_size(const ecl_grid_type *ecl_grid); - -double ecl_grid_get_bottom1(const ecl_grid_type *grid, int global_index); -double ecl_grid_get_bottom3(const ecl_grid_type *grid, int i, int j, int k); -double ecl_grid_get_bottom1A(const ecl_grid_type *grid, int active_index); -double ecl_grid_get_top1(const ecl_grid_type *grid, int global_index); -double ecl_grid_get_top3(const ecl_grid_type *grid, int i, int j, int k); -double ecl_grid_get_top1A(const ecl_grid_type *grid, int active_index); -double ecl_grid_get_top2(const ecl_grid_type *grid, int i, int j); -double ecl_grid_get_bottom2(const ecl_grid_type *grid, int i, int j); -int ecl_grid_locate_depth(const ecl_grid_type *grid, double depth, int i, - int j); - -void ecl_grid_alloc_blocking_variables(ecl_grid_type *, int); -void ecl_grid_init_blocking(ecl_grid_type *); -double ecl_grid_block_eval3d(ecl_grid_type *grid, int i, int j, int k, - block_function_ftype *blockf); -int ecl_grid_get_block_count3d(const ecl_grid_type *ecl_grid, int i, int j, - int k); -bool ecl_grid_block_value_3d(ecl_grid_type *, double, double, double, double); - -bool ecl_grid_cell_invalid1(const ecl_grid_type *ecl_grid, int global_index); -bool ecl_grid_cell_invalid3(const ecl_grid_type *ecl_grid, int i, int j, int k); -double ecl_grid_cell_invalid1A(const ecl_grid_type *grid, int active_index); - -bool ecl_grid_cell_valid1(const ecl_grid_type *ecl_grid, int global_index); -bool ecl_grid_cell_valid3(const ecl_grid_type *ecl_grid, int i, int j, int k); -double ecl_grid_cell_valid1A(const ecl_grid_type *grid, int active_index); - -void ecl_grid_dump(const ecl_grid_type *grid, FILE *stream); -void ecl_grid_dump_ascii(ecl_grid_type *grid, bool active_only, FILE *stream); -void ecl_grid_dump_ascii_cell1(ecl_grid_type *grid, int global_index, - FILE *stream, const double *offset); -void ecl_grid_dump_ascii_cell3(ecl_grid_type *grid, int i, int j, int k, - FILE *stream, const double *offset); +int rd_grid_get_global_size(const rd_grid_type *rd_grid); +bool rd_grid_compare(const rd_grid_type *g1, const rd_grid_type *g2, + bool include_lgr, bool include_nnc, bool verbose); +int rd_grid_get_active_size(const rd_grid_type *rd_grid); + +double rd_grid_get_bottom1(const rd_grid_type *grid, int global_index); +double rd_grid_get_bottom3(const rd_grid_type *grid, int i, int j, int k); +double rd_grid_get_bottom1A(const rd_grid_type *grid, int active_index); +double rd_grid_get_top1(const rd_grid_type *grid, int global_index); +double rd_grid_get_top3(const rd_grid_type *grid, int i, int j, int k); +double rd_grid_get_top1A(const rd_grid_type *grid, int active_index); +double rd_grid_get_top2(const rd_grid_type *grid, int i, int j); +double rd_grid_get_bottom2(const rd_grid_type *grid, int i, int j); +int rd_grid_locate_depth(const rd_grid_type *grid, double depth, int i, int j); + +void rd_grid_alloc_blocking_variables(rd_grid_type *, int); +void rd_grid_init_blocking(rd_grid_type *); +double rd_grid_block_eval3d(rd_grid_type *grid, int i, int j, int k, + block_function_ftype *blockf); +int rd_grid_get_block_count3d(const rd_grid_type *rd_grid, int i, int j, int k); +bool rd_grid_block_value_3d(rd_grid_type *, double, double, double, double); + +bool rd_grid_cell_invalid1(const rd_grid_type *rd_grid, int global_index); +bool rd_grid_cell_invalid3(const rd_grid_type *rd_grid, int i, int j, int k); +double rd_grid_cell_invalid1A(const rd_grid_type *grid, int active_index); + +bool rd_grid_cell_valid1(const rd_grid_type *rd_grid, int global_index); +bool rd_grid_cell_valid3(const rd_grid_type *rd_grid, int i, int j, int k); +double rd_grid_cell_valid1A(const rd_grid_type *grid, int active_index); + +void rd_grid_dump(const rd_grid_type *grid, FILE *stream); +void rd_grid_dump_ascii(rd_grid_type *grid, bool active_only, FILE *stream); +void rd_grid_dump_ascii_cell1(rd_grid_type *grid, int global_index, + FILE *stream, const double *offset); +void rd_grid_dump_ascii_cell3(rd_grid_type *grid, int i, int j, int k, + FILE *stream, const double *offset); /* lgr related functions */ -const ecl_grid_type *ecl_grid_get_cell_lgr3(const ecl_grid_type *grid, int i, - int j, int k); -const ecl_grid_type *ecl_grid_get_cell_lgr1A(const ecl_grid_type *grid, - int active_index); -const ecl_grid_type *ecl_grid_get_cell_lgr1(const ecl_grid_type *grid, - int global_index); -int ecl_grid_get_num_lgr(const ecl_grid_type *main_grid); -int ecl_grid_get_lgr_nr(const ecl_grid_type *ecl_grid); -int ecl_grid_get_lgr_nr_from_name(const ecl_grid_type *grid, const char *name); -ecl_grid_type *ecl_grid_iget_lgr(const ecl_grid_type *main_grid, int lgr_index); -ecl_grid_type *ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type *main_grid, - int lgr_nr); -ecl_grid_type *ecl_grid_get_lgr(const ecl_grid_type *main_grid, - const char *__lgr_name); -bool ecl_grid_has_lgr(const ecl_grid_type *main_grid, const char *__lgr_name); -bool ecl_grid_has_lgr_nr(const ecl_grid_type *main_grid, int lgr_nr); -const char *ecl_grid_iget_lgr_name(const ecl_grid_type *ecl_grid, - int lgr_index); -const char *ecl_grid_get_lgr_name(const ecl_grid_type *ecl_grid, int lgr_nr); -stringlist_type *ecl_grid_alloc_lgr_name_list(const ecl_grid_type *ecl_grid); -int ecl_grid_get_parent_cell1(const ecl_grid_type *grid, int global_index); -int ecl_grid_get_parent_cell3(const ecl_grid_type *grid, int i, int j, int k); -const ecl_grid_type *ecl_grid_get_global_grid(const ecl_grid_type *grid); -bool ecl_grid_is_lgr(const ecl_grid_type *ecl_grid); - -double ecl_grid_get_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, int k); -float ecl_grid_get_float_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - int k); -double ecl_grid_get_double_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - int k); -int ecl_grid_get_int_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, int k); - -void ecl_grid_grdecl_fprintf_kw(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, - const char *special_header, FILE *stream, - double double_default); -bool ecl_grid_test_lgr_consistency(const ecl_grid_type *ecl_grid); - -void ecl_grid_fwrite_dims(const ecl_grid_type *grid, fortio_type *init_file, - ert_ecl_unit_enum output_unit); -void ecl_grid_fwrite_depth(const ecl_grid_type *grid, fortio_type *init_file, - ert_ecl_unit_enum ouput_unit); - -void ecl_grid_fwrite_EGRID(ecl_grid_type *grid, const char *filename, - bool metric_output); -void ecl_grid_fwrite_EGRID2(ecl_grid_type *grid, const char *filename, - ert_ecl_unit_enum output_unit); - -void ecl_grid_fwrite_GRID(const ecl_grid_type *grid, const char *filename); -void ecl_grid_fwrite_GRID2(const ecl_grid_type *grid, const char *filename, - ert_ecl_unit_enum output_unit); - -void ecl_grid_fprintf_grdecl(ecl_grid_type *grid, FILE *stream); -void ecl_grid_fprintf_grdecl2(ecl_grid_type *grid, FILE *stream, - ert_ecl_unit_enum output_unit); - -int ecl_grid_zcorn_index__(int nx, int ny, int i, int j, int k, int c); -int ecl_grid_zcorn_index(const ecl_grid_type *grid, int i, int j, int k, int c); -ecl_grid_type *ecl_grid_alloc_EGRID(const char *grid_file, bool apply_mapaxes); -ecl_grid_type *ecl_grid_alloc_GRID(const char *grid_file, bool apply_mapaxes); - -float *ecl_grid_alloc_zcorn_data(const ecl_grid_type *grid); -ecl_kw_type *ecl_grid_alloc_zcorn_kw(const ecl_grid_type *grid); -int *ecl_grid_alloc_actnum_data(const ecl_grid_type *grid); -ecl_kw_type *ecl_grid_alloc_actnum_kw(const ecl_grid_type *grid); -ecl_kw_type *ecl_grid_alloc_hostnum_kw(const ecl_grid_type *grid); -ecl_kw_type *ecl_grid_alloc_gridhead_kw(int nx, int ny, int nz, int grid_nr); -ecl_grid_type *ecl_grid_alloc_copy(const ecl_grid_type *src_grid); -ecl_grid_type *ecl_grid_alloc_processed_copy(const ecl_grid_type *src_grid, - const double *zcorn, - const int *actnum); - -void ecl_grid_ri_export(const ecl_grid_type *ecl_grid, double *ri_points); -void ecl_grid_cell_ri_export(const ecl_grid_type *ecl_grid, int global_index, - double *ri_points); - -bool ecl_grid_dual_grid(const ecl_grid_type *ecl_grid); -int ecl_grid_get_num_nnc(const ecl_grid_type *grid); - -bool ecl_grid_cell_regular3(const ecl_grid_type *ecl_grid, int i, int j, int k); -bool ecl_grid_cell_regular1(const ecl_grid_type *ecl_grid, int global_index); - -void ecl_grid_init_zcorn_data(const ecl_grid_type *grid, float *zcorn); -void ecl_grid_init_zcorn_data_double(const ecl_grid_type *grid, double *zcorn); -int ecl_grid_get_zcorn_size(const ecl_grid_type *grid); - -void ecl_grid_init_coord_data(const ecl_grid_type *grid, float *coord); -void ecl_grid_init_coord_data_double(const ecl_grid_type *grid, double *coord); -int ecl_grid_get_coord_size(const ecl_grid_type *ecl_grid); - -void ecl_grid_init_actnum_data(const ecl_grid_type *grid, int *actnum); -bool ecl_grid_use_mapaxes(const ecl_grid_type *grid); -void ecl_grid_init_mapaxes_data_double(const ecl_grid_type *grid, - double *mapaxes); -void ecl_grid_reset_actnum(ecl_grid_type *grid, const int *actnum); -void ecl_grid_compressed_kw_copy(const ecl_grid_type *grid, - ecl_kw_type *target_kw, - const ecl_kw_type *src_kw); -void ecl_grid_global_kw_copy(const ecl_grid_type *grid, ecl_kw_type *target_kw, - const ecl_kw_type *src_kw); -void ecl_grid_export_cell_corners1(const ecl_grid_type *grid, int global_index, - double *x, double *y, double *z); - -ert_ecl_unit_enum ecl_grid_get_unit_system(const ecl_grid_type *grid); -void ecl_grid_export_index(const ecl_grid_type *grid, int *global_index, - int *index_data, bool active_only); -void ecl_grid_export_data_as_int(int index_size, const int *global_index, - const ecl_kw_type *kw, int *output); -void ecl_grid_export_data_as_double(int index_size, const int *data_index, - const ecl_kw_type *kw, double *output); -void ecl_grid_export_volume(const ecl_grid_type *grid, int index_size, - const int *global_index, double *output); -void ecl_grid_export_position(const ecl_grid_type *grid, int index_size, - const int *global_index, double *output); -void export_corners(const ecl_grid_type *grid, int index_size, +const rd_grid_type *rd_grid_get_cell_lgr3(const rd_grid_type *grid, int i, + int j, int k); +const rd_grid_type *rd_grid_get_cell_lgr1A(const rd_grid_type *grid, + int active_index); +const rd_grid_type *rd_grid_get_cell_lgr1(const rd_grid_type *grid, + int global_index); +int rd_grid_get_num_lgr(const rd_grid_type *main_grid); +int rd_grid_get_lgr_nr(const rd_grid_type *rd_grid); +int rd_grid_get_lgr_nr_from_name(const rd_grid_type *grid, const char *name); +rd_grid_type *rd_grid_iget_lgr(const rd_grid_type *main_grid, int lgr_index); +rd_grid_type *rd_grid_get_lgr_from_lgr_nr(const rd_grid_type *main_grid, + int lgr_nr); +rd_grid_type *rd_grid_get_lgr(const rd_grid_type *main_grid, + const char *__lgr_name); +bool rd_grid_has_lgr(const rd_grid_type *main_grid, const char *__lgr_name); +bool rd_grid_has_lgr_nr(const rd_grid_type *main_grid, int lgr_nr); +const char *rd_grid_iget_lgr_name(const rd_grid_type *rd_grid, int lgr_index); +const char *rd_grid_get_lgr_name(const rd_grid_type *rd_grid, int lgr_nr); +stringlist_type *rd_grid_alloc_lgr_name_list(const rd_grid_type *rd_grid); +int rd_grid_get_parent_cell1(const rd_grid_type *grid, int global_index); +int rd_grid_get_parent_cell3(const rd_grid_type *grid, int i, int j, int k); +const rd_grid_type *rd_grid_get_global_grid(const rd_grid_type *grid); +bool rd_grid_is_lgr(const rd_grid_type *rd_grid); + +double rd_grid_get_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k); +float rd_grid_get_float_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k); +double rd_grid_get_double_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, + int k); +int rd_grid_get_int_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k); + +void rd_grid_grdecl_fprintf_kw(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, + const char *special_header, FILE *stream, + double double_default); +bool rd_grid_test_lgr_consistency(const rd_grid_type *rd_grid); + +void rd_grid_fwrite_dims(const rd_grid_type *grid, fortio_type *init_file, + ert_rd_unit_enum output_unit); +void rd_grid_fwrite_depth(const rd_grid_type *grid, fortio_type *init_file, + ert_rd_unit_enum ouput_unit); + +void rd_grid_fwrite_EGRID(rd_grid_type *grid, const char *filename, + bool metric_output); +void rd_grid_fwrite_EGRID2(rd_grid_type *grid, const char *filename, + ert_rd_unit_enum output_unit); + +void rd_grid_fwrite_GRID(const rd_grid_type *grid, const char *filename); +void rd_grid_fwrite_GRID2(const rd_grid_type *grid, const char *filename, + ert_rd_unit_enum output_unit); + +void rd_grid_fprintf_grdecl(rd_grid_type *grid, FILE *stream); +void rd_grid_fprintf_grdecl2(rd_grid_type *grid, FILE *stream, + ert_rd_unit_enum output_unit); + +int rd_grid_zcorn_index__(int nx, int ny, int i, int j, int k, int c); +int rd_grid_zcorn_index(const rd_grid_type *grid, int i, int j, int k, int c); +rd_grid_type *rd_grid_alloc_EGRID(const char *grid_file, bool apply_mapaxes); +rd_grid_type *rd_grid_alloc_GRID(const char *grid_file, bool apply_mapaxes); + +float *rd_grid_alloc_zcorn_data(const rd_grid_type *grid); +rd_kw_type *rd_grid_alloc_zcorn_kw(const rd_grid_type *grid); +int *rd_grid_alloc_actnum_data(const rd_grid_type *grid); +rd_kw_type *rd_grid_alloc_actnum_kw(const rd_grid_type *grid); +rd_kw_type *rd_grid_alloc_hostnum_kw(const rd_grid_type *grid); +rd_kw_type *rd_grid_alloc_gridhead_kw(int nx, int ny, int nz, int grid_nr); +rd_grid_type *rd_grid_alloc_copy(const rd_grid_type *src_grid); +rd_grid_type *rd_grid_alloc_processed_copy(const rd_grid_type *src_grid, + const double *zcorn, + const int *actnum); + +void rd_grid_ri_export(const rd_grid_type *rd_grid, double *ri_points); +void rd_grid_cell_ri_export(const rd_grid_type *rd_grid, int global_index, + double *ri_points); + +bool rd_grid_dual_grid(const rd_grid_type *rd_grid); +int rd_grid_get_num_nnc(const rd_grid_type *grid); + +bool rd_grid_cell_regular3(const rd_grid_type *rd_grid, int i, int j, int k); +bool rd_grid_cell_regular1(const rd_grid_type *rd_grid, int global_index); + +void rd_grid_init_zcorn_data(const rd_grid_type *grid, float *zcorn); +void rd_grid_init_zcorn_data_double(const rd_grid_type *grid, double *zcorn); +int rd_grid_get_zcorn_size(const rd_grid_type *grid); + +void rd_grid_init_coord_data(const rd_grid_type *grid, float *coord); +void rd_grid_init_coord_data_double(const rd_grid_type *grid, double *coord); +int rd_grid_get_coord_size(const rd_grid_type *rd_grid); + +void rd_grid_init_actnum_data(const rd_grid_type *grid, int *actnum); +bool rd_grid_use_mapaxes(const rd_grid_type *grid); +void rd_grid_init_mapaxes_data_double(const rd_grid_type *grid, + double *mapaxes); +void rd_grid_reset_actnum(rd_grid_type *grid, const int *actnum); +void rd_grid_compressed_kw_copy(const rd_grid_type *grid, rd_kw_type *target_kw, + const rd_kw_type *src_kw); +void rd_grid_global_kw_copy(const rd_grid_type *grid, rd_kw_type *target_kw, + const rd_kw_type *src_kw); +void rd_grid_export_cell_corners1(const rd_grid_type *grid, int global_index, + double *x, double *y, double *z); + +ert_rd_unit_enum rd_grid_get_unit_system(const rd_grid_type *grid); +void rd_grid_export_index(const rd_grid_type *grid, int *global_index, + int *index_data, bool active_only); +void rd_grid_export_data_as_int(int index_size, const int *global_index, + const rd_kw_type *kw, int *output); +void rd_grid_export_data_as_double(int index_size, const int *data_index, + const rd_kw_type *kw, double *output); +void rd_grid_export_volume(const rd_grid_type *grid, int index_size, + const int *global_index, double *output); +void rd_grid_export_position(const rd_grid_type *grid, int index_size, + const int *global_index, double *output); +void export_corners(const rd_grid_type *grid, int index_size, const int *global_index, double *output); -UTIL_IS_INSTANCE_HEADER(ecl_grid); -UTIL_SAFE_CAST_HEADER(ecl_grid); +UTIL_IS_INSTANCE_HEADER(rd_grid); +UTIL_SAFE_CAST_HEADER(rd_grid); #ifdef __cplusplus } -namespace ecl { +namespace rd { -ecl_grid_type *ecl_grid_alloc_GRDECL_data(int nx, int ny, int nz, - const double *zcorn, - const double *coord, - const int *actnum, bool apply_mapaxes, - const float *mapaxes); +rd_grid_type *rd_grid_alloc_GRDECL_data(int nx, int ny, int nz, + const double *zcorn, + const double *coord, const int *actnum, + bool apply_mapaxes, + const float *mapaxes); } diff --git a/lib/include/resdata/rd_grid_dims.h b/lib/include/resdata/rd_grid_dims.h index 4e8559f373..bf3ed38ac5 100644 --- a/lib/include/resdata/rd_grid_dims.h +++ b/lib/include/resdata/rd_grid_dims.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_grid_dims.hpp b/lib/include/resdata/rd_grid_dims.hpp index 0e7ee18588..28fd00e079 100644 --- a/lib/include/resdata/rd_grid_dims.hpp +++ b/lib/include/resdata/rd_grid_dims.hpp @@ -1,19 +1,19 @@ -#ifndef ERT_ECL_GRID_DIMS_H -#define ERT_ECL_GRID_DIMS_H +#ifndef ERT_RD_GRID_DIMS_H +#define ERT_RD_GRID_DIMS_H #ifdef __cplusplus extern "C" { #endif -#include +#include -typedef struct ecl_grid_dims_struct ecl_grid_dims_type; +typedef struct rd_grid_dims_struct rd_grid_dims_type; -ecl_grid_dims_type *ecl_grid_dims_alloc(const char *grid_file, - const char *data_file); -void ecl_grid_dims_free(ecl_grid_dims_type *grid_dims); -int ecl_grid_dims_get_num_grids(const ecl_grid_dims_type *grid_dims); -const grid_dims_type * -ecl_grid_dims_iget_dims(const ecl_grid_dims_type *grid_dims, int grid_nr); +rd_grid_dims_type *rd_grid_dims_alloc(const char *grid_file, + const char *data_file); +void rd_grid_dims_free(rd_grid_dims_type *grid_dims); +int rd_grid_dims_get_num_grids(const rd_grid_dims_type *grid_dims); +const grid_dims_type *rd_grid_dims_iget_dims(const rd_grid_dims_type *grid_dims, + int grid_nr); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_init_file.h b/lib/include/resdata/rd_init_file.h index 5c8a4c5f21..50a0c3d059 100644 --- a/lib/include/resdata/rd_init_file.h +++ b/lib/include/resdata/rd_init_file.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_init_file.hpp b/lib/include/resdata/rd_init_file.hpp index c8ea276c6e..0ad81993c8 100644 --- a/lib/include/resdata/rd_init_file.hpp +++ b/lib/include/resdata/rd_init_file.hpp @@ -1,21 +1,21 @@ -#ifndef ERT_ECL_INIT_FILE_H -#define ERT_ECL_INIT_FILE_H +#ifndef ERT_RD_INIT_FILE_H +#define ERT_RD_INIT_FILE_H #include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -void ecl_init_file_fwrite_header(fortio_type *fortio, const ecl_grid_type *grid, - const ecl_kw_type *poro, - ert_ecl_unit_enum unit_system, int phases, - time_t start_date); +void rd_init_file_fwrite_header(fortio_type *fortio, const rd_grid_type *grid, + const rd_kw_type *poro, + ert_rd_unit_enum unit_system, int phases, + time_t start_date); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_io_config.h b/lib/include/resdata/rd_io_config.h index 0082a949f1..fd23eac204 100644 --- a/lib/include/resdata/rd_io_config.h +++ b/lib/include/resdata/rd_io_config.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_io_config.hpp b/lib/include/resdata/rd_io_config.hpp index ba77a0961c..d1d360eef9 100644 --- a/lib/include/resdata/rd_io_config.hpp +++ b/lib/include/resdata/rd_io_config.hpp @@ -1,24 +1,24 @@ -#ifndef ERT_ECL_IO_CONFIG_H -#define ERT_ECL_IO_CONFIG_H +#ifndef ERT_RD_IO_CONFIG_H +#define ERT_RD_IO_CONFIG_H #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_io_config_struct ecl_io_config_type; +typedef struct rd_io_config_struct rd_io_config_type; /* Modifiers */ -void ecl_io_config_set_formatted(ecl_io_config_type *, bool); -void ecl_io_config_set_unified_restart(ecl_io_config_type *, bool); -void ecl_io_config_set_unified_summary(ecl_io_config_type *, bool); +void rd_io_config_set_formatted(rd_io_config_type *, bool); +void rd_io_config_set_unified_restart(rd_io_config_type *, bool); +void rd_io_config_set_unified_summary(rd_io_config_type *, bool); /* Accesors */ -bool ecl_io_config_get_formatted(ecl_io_config_type *); -bool ecl_io_config_get_unified_restart(ecl_io_config_type *); -bool ecl_io_config_get_unified_summary(ecl_io_config_type *); +bool rd_io_config_get_formatted(rd_io_config_type *); +bool rd_io_config_get_unified_restart(rd_io_config_type *); +bool rd_io_config_get_unified_summary(rd_io_config_type *); /* Allocater & destructor */ -ecl_io_config_type *ecl_io_config_alloc(bool, bool, bool); -void ecl_io_config_free(ecl_io_config_type *); +rd_io_config_type *rd_io_config_alloc(bool, bool, bool); +void rd_io_config_free(rd_io_config_type *); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_kw.h b/lib/include/resdata/rd_kw.h index 0b6991e3c7..93f7690d0c 100644 --- a/lib/include/resdata/rd_kw.h +++ b/lib/include/resdata/rd_kw.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_kw.hpp b/lib/include/resdata/rd_kw.hpp index 5afada1cc6..d5af27e836 100644 --- a/lib/include/resdata/rd_kw.hpp +++ b/lib/include/resdata/rd_kw.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_KW_H -#define ERT_ECL_KW_H +#ifndef ERT_RD_KW_H +#define ERT_RD_KW_H #ifdef __cplusplus extern "C" { #endif @@ -11,282 +11,274 @@ extern "C" { #include #include -#include -#include -#include +#include +#include +#include -UTIL_IS_INSTANCE_HEADER(ecl_kw); +UTIL_IS_INSTANCE_HEADER(rd_kw); -typedef struct ecl_kw_struct ecl_kw_type; +typedef struct rd_kw_struct rd_kw_type; -typedef enum { ECL_KW_READ_OK = 0, ECL_KW_READ_FAIL = 1 } ecl_read_status_enum; +typedef enum { RD_KW_READ_OK = 0, RD_KW_READ_FAIL = 1 } rd_read_status_enum; /* - The size of an ecl_kw instance is denoted with an integer. The + The size of an rd_kw instance is denoted with an integer. The choice of int to store the size obviously limits the maximum size to INT_MAX elements. This choice is an historical mistake - it should - probably have been size_t; however the ecl_kw datastructure is + probably have been size_t; however the rd_kw datastructure is tightly bound to the on-disk binary format supplied by Eclipse, and there the number of elements is stored as a signed(?) 32 bit integer - so using int for size does make some sense- */ -#define ECL_KW_MAX_SIZE INT_MAX +#define RD_KW_MAX_SIZE INT_MAX /* Character data in ECLIPSE files comes as an array of fixed-length string. Each of these strings is 8 characters long. The type name, i.e. 'REAL', 'INTE', ... , come as 4 character strings. */ -#define ECL_KW_HEADER_DATA_SIZE ECL_STRING8_LENGTH + ECL_TYPE_LENGTH + 4 -#define ECL_KW_HEADER_FORTIO_SIZE ECL_KW_HEADER_DATA_SIZE + 8 - -int ecl_kw_first_different(const ecl_kw_type *kw1, const ecl_kw_type *kw2, - int offset, double abs_epsilon, double rel_epsilon); -size_t ecl_kw_fortio_size(const ecl_kw_type *ecl_kw); -void *ecl_kw_get_ptr(const ecl_kw_type *ecl_kw); -void ecl_kw_set_data_ptr(ecl_kw_type *ecl_kw, void *data); -void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw, fortio_type *fortio); -bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio); -ecl_data_type ecl_kw_get_data_type(const ecl_kw_type *); -const char *ecl_kw_get_header8(const ecl_kw_type *); -const char *ecl_kw_get_header(const ecl_kw_type *ecl_kw); -ecl_kw_type *ecl_kw_alloc_empty(void); -ecl_read_status_enum ecl_kw_fread_header(ecl_kw_type *, fortio_type *); -void ecl_kw_set_header_name(ecl_kw_type *, const char *); -bool ecl_kw_fseek_kw(const char *, bool, bool, fortio_type *); -bool ecl_kw_fseek_last_kw(const char *, bool, fortio_type *); -void ecl_kw_inplace_update_file(const ecl_kw_type *, const char *, int); -void ecl_kw_fskip(fortio_type *); -void ecl_kw_alloc_data(ecl_kw_type *); -void ecl_kw_alloc_double_data(ecl_kw_type *ecl_kw, double *values); -void ecl_kw_alloc_float_data(ecl_kw_type *ecl_kw, float *values); -bool ecl_kw_fread_realloc(ecl_kw_type *, fortio_type *); -void ecl_kw_fread(ecl_kw_type *, fortio_type *); -ecl_kw_type *ecl_kw_fread_alloc(fortio_type *); -ecl_kw_type *ecl_kw_alloc_actnum(const ecl_kw_type *porv_kw, float porv_limit); -ecl_kw_type *ecl_kw_alloc_actnum_bitmask(const ecl_kw_type *porv_kw, - float porv_limit, int actnum_bitmask); -void ecl_kw_free_data(ecl_kw_type *); -void ecl_kw_fread_indexed_data(fortio_type *fortio, offset_type data_offset, - ecl_data_type, int element_count, - const int_vector_type *index_map, char *buffer); -void ecl_kw_free(ecl_kw_type *); -void ecl_kw_free__(void *); -ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *); -ecl_kw_type *ecl_kw_alloc_sub_copy(const ecl_kw_type *src, const char *new_kw, - int offset, int count); -const void *ecl_kw_copyc__(const void *); -ecl_kw_type *ecl_kw_alloc_slice_copy(const ecl_kw_type *src, int index1, - int index2, int stride); -void ecl_kw_resize(ecl_kw_type *ecl_kw, int new_size); -//void * ecl_kw_get_data_ref(const ecl_kw_type *); -void *ecl_kw_alloc_data_copy(const ecl_kw_type *); -void ecl_kw_memcpy(ecl_kw_type *, const ecl_kw_type *); -void ecl_kw_get_memcpy_data(const ecl_kw_type *, void *); -void ecl_kw_get_memcpy_float_data(const ecl_kw_type *ecl_kw, float *target); -void ecl_kw_get_memcpy_double_data(const ecl_kw_type *ecl_kw, double *target); -void ecl_kw_get_memcpy_int_data(const ecl_kw_type *ecl_kw, int *target); -void ecl_kw_set_memcpy_data(ecl_kw_type *, const void *); -bool ecl_kw_fwrite(const ecl_kw_type *, fortio_type *); -void ecl_kw_iget(const ecl_kw_type *, int, void *); -void ecl_kw_iset(ecl_kw_type *ecl_kw, int i, const void *iptr); -void ecl_kw_iset_char_ptr(ecl_kw_type *ecl_kw, int index, const char *s); -void ecl_kw_iset_string8(ecl_kw_type *ecl_kw, int index, const char *s8); -void ecl_kw_iset_string_ptr(ecl_kw_type *, int, const char *); -const char *ecl_kw_iget_string_ptr(const ecl_kw_type *, int); -const char *ecl_kw_iget_char_ptr(const ecl_kw_type *ecl_kw, int i); -void *ecl_kw_iget_ptr(const ecl_kw_type *, int); -int ecl_kw_get_size(const ecl_kw_type *); -bool ecl_kw_ichar_eq(const ecl_kw_type *, int, const char *); -ecl_kw_type *ecl_kw_alloc(const char *header, int size, ecl_data_type); -ecl_kw_type *ecl_kw_alloc_new(const char *, int, ecl_data_type, const void *); -ecl_kw_type *ecl_kw_alloc_new_shared(const char *, int, ecl_data_type, void *); -ecl_kw_type *ecl_kw_alloc_global_copy(const ecl_kw_type *src, - const ecl_kw_type *actnum); -void ecl_kw_fwrite_param(const char *, bool, const char *, ecl_data_type, int, - void *); -void ecl_kw_fwrite_param_fortio(fortio_type *, const char *, ecl_data_type, int, - void *); -void ecl_kw_summarize(const ecl_kw_type *ecl_kw); -void ecl_kw_fread_double_param(const char *, bool, double *); -float ecl_kw_iget_as_float(const ecl_kw_type *ecl_kw, int i); -double ecl_kw_iget_as_double(const ecl_kw_type *ecl_kw, int i); -void ecl_kw_get_data_as_double(const ecl_kw_type *, double *); -void ecl_kw_get_data_as_float(const ecl_kw_type *ecl_kw, float *float_data); -bool ecl_kw_name_equal(const ecl_kw_type *ecl_kw, const char *name); -bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2); -bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2); -bool ecl_kw_size_and_type_equal(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2); -bool ecl_kw_icmp_string(const ecl_kw_type *ecl_kw, int index, - const char *other_string); -bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2, double abs_diff, - double rel_diff); -bool ecl_kw_block_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2, - int cmp_elements); -bool ecl_kw_data_equal(const ecl_kw_type *ecl_kw, const void *data); -bool ecl_kw_content_equal(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2); -bool ecl_kw_fskip_data__(ecl_data_type, int, fortio_type *); -bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio); -bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio); -void ecl_kw_fskip_header(fortio_type *fortio); -bool ecl_kw_size_and_numeric_type_equal(const ecl_kw_type *kw1, - const ecl_kw_type *kw2); -bool ecl_kw_inplace_safe_div(ecl_kw_type *target_kw, - const ecl_kw_type *divisor); -void ecl_kw_inplace_sqrt(ecl_kw_type *kw); - -bool ecl_kw_is_kw_file(fortio_type *fortio); - -int ecl_kw_element_sum_int(const ecl_kw_type *ecl_kw); -double ecl_kw_element_sum_float(const ecl_kw_type *ecl_kw); -void ecl_kw_inplace_inv(ecl_kw_type *my_kw); -void ecl_kw_element_sum(const ecl_kw_type *, void *); -void ecl_kw_element_sum_indexed(const ecl_kw_type *ecl_kw, - const int_vector_type *index_list, void *_sum); -void ecl_kw_max_min(const ecl_kw_type *, void *, void *); -void *ecl_kw_get_void_ptr(const ecl_kw_type *ecl_kw); - -ecl_kw_type *ecl_kw_buffer_alloc(buffer_type *buffer); -void ecl_kw_buffer_store(const ecl_kw_type *ecl_kw, buffer_type *buffer); - -void ecl_kw_fprintf_data(const ecl_kw_type *ecl_kw, const char *fmt, - FILE *stream); -void ecl_kw_memcpy_data(ecl_kw_type *target, const ecl_kw_type *src); - -bool ecl_kw_assert_numeric(const ecl_kw_type *kw); -bool ecl_kw_assert_binary(const ecl_kw_type *kw1, const ecl_kw_type *kw2); - -void ecl_kw_scalar_set_bool(ecl_kw_type *ecl_kw, bool bool_value); -void ecl_kw_scalar_set__(ecl_kw_type *ecl_kw, const void *value); -void ecl_kw_scalar_set_float_or_double(ecl_kw_type *ecl_kw, double value); - -#define ECL_KW_SCALAR_SET_TYPED_HEADER(ctype) \ - void ecl_kw_scalar_set_##ctype(ecl_kw_type *ecl_kw, ctype value); -ECL_KW_SCALAR_SET_TYPED_HEADER(int) -ECL_KW_SCALAR_SET_TYPED_HEADER(float) -ECL_KW_SCALAR_SET_TYPED_HEADER(double) -#undef ECL_KW_SCALAR_SET_TYPED_HEADER - -ecl_kw_type *ecl_kw_alloc_scatter_copy(const ecl_kw_type *src_kw, - int target_size, const int *mapping, - void *def_value); - -void ecl_kw_inplace_add_squared(ecl_kw_type *target_kw, - const ecl_kw_type *add_kw); -void ecl_kw_inplace_add(ecl_kw_type *target_kw, const ecl_kw_type *add_kw); -void ecl_kw_inplace_sub(ecl_kw_type *target_kw, const ecl_kw_type *sub_kw); -void ecl_kw_inplace_div(ecl_kw_type *target_kw, const ecl_kw_type *div_kw); -void ecl_kw_inplace_mul(ecl_kw_type *target_kw, const ecl_kw_type *mul_kw); -void ecl_kw_inplace_abs(ecl_kw_type *kw); - -void ecl_kw_inplace_add_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *add_kw); -void ecl_kw_inplace_sub_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *sub_kw); -void ecl_kw_inplace_mul_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *mul_kw); -void ecl_kw_inplace_div_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *div_kw); -void ecl_kw_copy_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *src_kw); - -bool ecl_kw_assert_binary_numeric(const ecl_kw_type *kw1, - const ecl_kw_type *kw2); -#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER(ctype) \ - bool ecl_kw_assert_binary_##ctype(const ecl_kw_type *kw1, \ - const ecl_kw_type *kw2) -ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER(int); -ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER(float); -ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER(double); -#undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER - -#define ECL_KW_SCALE_TYPED_HEADER(ctype) \ - void ecl_kw_scale_##ctype(ecl_kw_type *ecl_kw, ctype scale_factor) -ECL_KW_SCALE_TYPED_HEADER(int); -ECL_KW_SCALE_TYPED_HEADER(float); -ECL_KW_SCALE_TYPED_HEADER(double); -#undef ECL_KW_SCALE_TYPED_HEADER -void ecl_kw_scale_float_or_double(ecl_kw_type *ecl_kw, double scale_factor); - -#define ECL_KW_SHIFT_TYPED_HEADER(ctype) \ - void ecl_kw_shift_##ctype(ecl_kw_type *ecl_kw, ctype shift_factor) -ECL_KW_SHIFT_TYPED_HEADER(int); -ECL_KW_SHIFT_TYPED_HEADER(float); -ECL_KW_SHIFT_TYPED_HEADER(double); -#undef ECL_KW_SHIFT_TYPED_HEADER -void ecl_kw_shift_float_or_double(ecl_kw_type *ecl_kw, double shift_value); - -#define ECL_KW_IGET_TYPED_HEADER(type) \ - type ecl_kw_iget_##type(const ecl_kw_type *, int) -ECL_KW_IGET_TYPED_HEADER(double); -ECL_KW_IGET_TYPED_HEADER(float); -ECL_KW_IGET_TYPED_HEADER(int); -#undef ECL_KW_IGET_TYPED_HEADER -bool ecl_kw_iget_bool(const ecl_kw_type *ecl_kw, int i); - -#define ECL_KW_ISET_TYPED_HEADER(type) \ - void ecl_kw_iset_##type(ecl_kw_type *, int, type) -ECL_KW_ISET_TYPED_HEADER(double); -ECL_KW_ISET_TYPED_HEADER(float); -ECL_KW_ISET_TYPED_HEADER(int); -#undef ECL_KW_ISET_TYPED_HEADER -void ecl_kw_iset_bool(ecl_kw_type *ecl_kw, int i, bool bool_value); - -#define ECL_KW_GET_TYPED_PTR_HEADER(type) \ - type *ecl_kw_get_##type##_ptr(const ecl_kw_type *) -ECL_KW_GET_TYPED_PTR_HEADER(double); -ECL_KW_GET_TYPED_PTR_HEADER(float); -ECL_KW_GET_TYPED_PTR_HEADER(int); -ECL_KW_GET_TYPED_PTR_HEADER(bool); -#undef ECL_KW_GET_TYPED_PTR_HEADER - -#define ECL_KW_SET_INDEXED_HEADER(ctype) \ - void ecl_kw_set_indexed_##ctype( \ - ecl_kw_type *ecl_kw, const int_vector_type *index_list, ctype value) -ECL_KW_SET_INDEXED_HEADER(double); -ECL_KW_SET_INDEXED_HEADER(float); -ECL_KW_SET_INDEXED_HEADER(int); -#undef ECL_KW_SET_INDEXED_HEADER - -#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) \ - void ecl_kw_shift_indexed_##ctype( \ - ecl_kw_type *ecl_kw, const int_vector_type *index_list, ctype shift) -ECL_KW_SHIFT_INDEXED_HEADER(int); -ECL_KW_SHIFT_INDEXED_HEADER(float); -ECL_KW_SHIFT_INDEXED_HEADER(double); -#undef ECL_KW_SHIFT_INDEXED_HEADER - -#define ECL_KW_SCALE_INDEXED_HEADER(ctype) \ - void ecl_kw_scale_indexed_##ctype( \ - ecl_kw_type *ecl_kw, const int_vector_type *index_list, ctype scale) -ECL_KW_SCALE_INDEXED_HEADER(int); -ECL_KW_SCALE_INDEXED_HEADER(float); -ECL_KW_SCALE_INDEXED_HEADER(double); -#undef ECL_KW_SCALE_INDEXED_HEADER - -#define ECL_KW_MAX_MIN_HEADER(ctype) \ - void ecl_kw_max_min_##ctype(const ecl_kw_type *ecl_kw, ctype *_max, \ - ctype *_min) -ECL_KW_MAX_MIN_HEADER(int); -ECL_KW_MAX_MIN_HEADER(float); -ECL_KW_MAX_MIN_HEADER(double); -#undef ECL_KW_MAX_MIN_HEADER - -void ecl_kw_fix_uninitialized(ecl_kw_type *ecl_kw, int nx, int ny, int nz, - const int *actnum); - -ecl_type_enum ecl_kw_get_type(const ecl_kw_type *); - -#include +#define RD_KW_HEADER_DATA_SIZE RD_STRING8_LENGTH + RD_TYPE_LENGTH + 4 +#define RD_KW_HEADER_FORTIO_SIZE RD_KW_HEADER_DATA_SIZE + 8 + +int rd_kw_first_different(const rd_kw_type *kw1, const rd_kw_type *kw2, + int offset, double abs_epsilon, double rel_epsilon); +size_t rd_kw_fortio_size(const rd_kw_type *rd_kw); +void *rd_kw_get_ptr(const rd_kw_type *rd_kw); +void rd_kw_set_data_ptr(rd_kw_type *rd_kw, void *data); +void rd_kw_fwrite_data(const rd_kw_type *_rd_kw, fortio_type *fortio); +bool rd_kw_fread_realloc_data(rd_kw_type *rd_kw, fortio_type *fortio); +rd_data_type rd_kw_get_data_type(const rd_kw_type *); +const char *rd_kw_get_header8(const rd_kw_type *); +const char *rd_kw_get_header(const rd_kw_type *rd_kw); +rd_kw_type *rd_kw_alloc_empty(void); +rd_read_status_enum rd_kw_fread_header(rd_kw_type *, fortio_type *); +void rd_kw_set_header_name(rd_kw_type *, const char *); +bool rd_kw_fseek_kw(const char *, bool, bool, fortio_type *); +bool rd_kw_fseek_last_kw(const char *, bool, fortio_type *); +void rd_kw_inplace_update_file(const rd_kw_type *, const char *, int); +void rd_kw_fskip(fortio_type *); +void rd_kw_alloc_data(rd_kw_type *); +void rd_kw_alloc_double_data(rd_kw_type *rd_kw, double *values); +void rd_kw_alloc_float_data(rd_kw_type *rd_kw, float *values); +bool rd_kw_fread_realloc(rd_kw_type *, fortio_type *); +void rd_kw_fread(rd_kw_type *, fortio_type *); +rd_kw_type *rd_kw_fread_alloc(fortio_type *); +rd_kw_type *rd_kw_alloc_actnum(const rd_kw_type *porv_kw, float porv_limit); +rd_kw_type *rd_kw_alloc_actnum_bitmask(const rd_kw_type *porv_kw, + float porv_limit, int actnum_bitmask); +void rd_kw_free_data(rd_kw_type *); +void rd_kw_fread_indexed_data(fortio_type *fortio, offset_type data_offset, + rd_data_type, int element_count, + const int_vector_type *index_map, char *buffer); +void rd_kw_free(rd_kw_type *); +void rd_kw_free__(void *); +rd_kw_type *rd_kw_alloc_copy(const rd_kw_type *); +rd_kw_type *rd_kw_alloc_sub_copy(const rd_kw_type *src, const char *new_kw, + int offset, int count); +const void *rd_kw_copyc__(const void *); +rd_kw_type *rd_kw_alloc_slice_copy(const rd_kw_type *src, int index1, + int index2, int stride); +void rd_kw_resize(rd_kw_type *rd_kw, int new_size); +//void * rd_kw_get_data_ref(const rd_kw_type *); +void *rd_kw_alloc_data_copy(const rd_kw_type *); +void rd_kw_memcpy(rd_kw_type *, const rd_kw_type *); +void rd_kw_get_memcpy_data(const rd_kw_type *, void *); +void rd_kw_get_memcpy_float_data(const rd_kw_type *rd_kw, float *target); +void rd_kw_get_memcpy_double_data(const rd_kw_type *rd_kw, double *target); +void rd_kw_get_memcpy_int_data(const rd_kw_type *rd_kw, int *target); +void rd_kw_set_memcpy_data(rd_kw_type *, const void *); +bool rd_kw_fwrite(const rd_kw_type *, fortio_type *); +void rd_kw_iget(const rd_kw_type *, int, void *); +void rd_kw_iset(rd_kw_type *rd_kw, int i, const void *iptr); +void rd_kw_iset_char_ptr(rd_kw_type *rd_kw, int index, const char *s); +void rd_kw_iset_string8(rd_kw_type *rd_kw, int index, const char *s8); +void rd_kw_iset_string_ptr(rd_kw_type *, int, const char *); +const char *rd_kw_iget_string_ptr(const rd_kw_type *, int); +const char *rd_kw_iget_char_ptr(const rd_kw_type *rd_kw, int i); +void *rd_kw_iget_ptr(const rd_kw_type *, int); +int rd_kw_get_size(const rd_kw_type *); +bool rd_kw_ichar_eq(const rd_kw_type *, int, const char *); +rd_kw_type *rd_kw_alloc(const char *header, int size, rd_data_type); +rd_kw_type *rd_kw_alloc_new(const char *, int, rd_data_type, const void *); +rd_kw_type *rd_kw_alloc_new_shared(const char *, int, rd_data_type, void *); +rd_kw_type *rd_kw_alloc_global_copy(const rd_kw_type *src, + const rd_kw_type *actnum); +void rd_kw_fwrite_param(const char *, bool, const char *, rd_data_type, int, + void *); +void rd_kw_fwrite_param_fortio(fortio_type *, const char *, rd_data_type, int, + void *); +void rd_kw_summarize(const rd_kw_type *rd_kw); +void rd_kw_fread_double_param(const char *, bool, double *); +float rd_kw_iget_as_float(const rd_kw_type *rd_kw, int i); +double rd_kw_iget_as_double(const rd_kw_type *rd_kw, int i); +void rd_kw_get_data_as_double(const rd_kw_type *, double *); +void rd_kw_get_data_as_float(const rd_kw_type *rd_kw, float *float_data); +bool rd_kw_name_equal(const rd_kw_type *rd_kw, const char *name); +bool rd_kw_header_eq(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2); +bool rd_kw_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2); +bool rd_kw_size_and_type_equal(const rd_kw_type *rd_kw1, + const rd_kw_type *rd_kw2); +bool rd_kw_icmp_string(const rd_kw_type *rd_kw, int index, + const char *other_string); +bool rd_kw_numeric_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2, + double abs_diff, double rel_diff); +bool rd_kw_block_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2, + int cmp_elements); +bool rd_kw_data_equal(const rd_kw_type *rd_kw, const void *data); +bool rd_kw_content_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2); +bool rd_kw_fskip_data__(rd_data_type, int, fortio_type *); +bool rd_kw_fskip_data(rd_kw_type *rd_kw, fortio_type *fortio); +bool rd_kw_fread_data(rd_kw_type *rd_kw, fortio_type *fortio); +void rd_kw_fskip_header(fortio_type *fortio); +bool rd_kw_size_and_numeric_type_equal(const rd_kw_type *kw1, + const rd_kw_type *kw2); +bool rd_kw_inplace_safe_div(rd_kw_type *target_kw, const rd_kw_type *divisor); +void rd_kw_inplace_sqrt(rd_kw_type *kw); + +bool rd_kw_is_kw_file(fortio_type *fortio); + +int rd_kw_element_sum_int(const rd_kw_type *rd_kw); +double rd_kw_element_sum_float(const rd_kw_type *rd_kw); +void rd_kw_inplace_inv(rd_kw_type *my_kw); +void rd_kw_element_sum(const rd_kw_type *, void *); +void rd_kw_element_sum_indexed(const rd_kw_type *rd_kw, + const int_vector_type *index_list, void *_sum); +void rd_kw_max_min(const rd_kw_type *, void *, void *); +void *rd_kw_get_void_ptr(const rd_kw_type *rd_kw); + +rd_kw_type *rd_kw_buffer_alloc(buffer_type *buffer); +void rd_kw_buffer_store(const rd_kw_type *rd_kw, buffer_type *buffer); + +void rd_kw_fprintf_data(const rd_kw_type *rd_kw, const char *fmt, FILE *stream); +void rd_kw_memcpy_data(rd_kw_type *target, const rd_kw_type *src); + +bool rd_kw_assert_numeric(const rd_kw_type *kw); +bool rd_kw_assert_binary(const rd_kw_type *kw1, const rd_kw_type *kw2); + +void rd_kw_scalar_set_bool(rd_kw_type *rd_kw, bool bool_value); +void rd_kw_scalar_set__(rd_kw_type *rd_kw, const void *value); +void rd_kw_scalar_set_float_or_double(rd_kw_type *rd_kw, double value); + +#define RD_KW_SCALAR_SET_TYPED_HEADER(ctype) \ + void rd_kw_scalar_set_##ctype(rd_kw_type *rd_kw, ctype value); +RD_KW_SCALAR_SET_TYPED_HEADER(int) +RD_KW_SCALAR_SET_TYPED_HEADER(float) +RD_KW_SCALAR_SET_TYPED_HEADER(double) +#undef RD_KW_SCALAR_SET_TYPED_HEADER + +rd_kw_type *rd_kw_alloc_scatter_copy(const rd_kw_type *src_kw, int target_size, + const int *mapping, void *def_value); + +void rd_kw_inplace_add_squared(rd_kw_type *target_kw, const rd_kw_type *add_kw); +void rd_kw_inplace_add(rd_kw_type *target_kw, const rd_kw_type *add_kw); +void rd_kw_inplace_sub(rd_kw_type *target_kw, const rd_kw_type *sub_kw); +void rd_kw_inplace_div(rd_kw_type *target_kw, const rd_kw_type *div_kw); +void rd_kw_inplace_mul(rd_kw_type *target_kw, const rd_kw_type *mul_kw); +void rd_kw_inplace_abs(rd_kw_type *kw); + +void rd_kw_inplace_add_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *add_kw); +void rd_kw_inplace_sub_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *sub_kw); +void rd_kw_inplace_mul_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *mul_kw); +void rd_kw_inplace_div_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *div_kw); +void rd_kw_copy_indexed(rd_kw_type *target_kw, const int_vector_type *index_set, + const rd_kw_type *src_kw); + +bool rd_kw_assert_binary_numeric(const rd_kw_type *kw1, const rd_kw_type *kw2); +#define RD_KW_ASSERT_TYPED_BINARY_OP_HEADER(ctype) \ + bool rd_kw_assert_binary_##ctype(const rd_kw_type *kw1, \ + const rd_kw_type *kw2) +RD_KW_ASSERT_TYPED_BINARY_OP_HEADER(int); +RD_KW_ASSERT_TYPED_BINARY_OP_HEADER(float); +RD_KW_ASSERT_TYPED_BINARY_OP_HEADER(double); +#undef RD_KW_ASSERT_TYPED_BINARY_OP_HEADER + +#define RD_KW_SCALE_TYPED_HEADER(ctype) \ + void rd_kw_scale_##ctype(rd_kw_type *rd_kw, ctype scale_factor) +RD_KW_SCALE_TYPED_HEADER(int); +RD_KW_SCALE_TYPED_HEADER(float); +RD_KW_SCALE_TYPED_HEADER(double); +#undef RD_KW_SCALE_TYPED_HEADER +void rd_kw_scale_float_or_double(rd_kw_type *rd_kw, double scale_factor); + +#define RD_KW_SHIFT_TYPED_HEADER(ctype) \ + void rd_kw_shift_##ctype(rd_kw_type *rd_kw, ctype shift_factor) +RD_KW_SHIFT_TYPED_HEADER(int); +RD_KW_SHIFT_TYPED_HEADER(float); +RD_KW_SHIFT_TYPED_HEADER(double); +#undef RD_KW_SHIFT_TYPED_HEADER +void rd_kw_shift_float_or_double(rd_kw_type *rd_kw, double shift_value); + +#define RD_KW_IGET_TYPED_HEADER(type) \ + type rd_kw_iget_##type(const rd_kw_type *, int) +RD_KW_IGET_TYPED_HEADER(double); +RD_KW_IGET_TYPED_HEADER(float); +RD_KW_IGET_TYPED_HEADER(int); +#undef RD_KW_IGET_TYPED_HEADER +bool rd_kw_iget_bool(const rd_kw_type *rd_kw, int i); + +#define RD_KW_ISET_TYPED_HEADER(type) \ + void rd_kw_iset_##type(rd_kw_type *, int, type) +RD_KW_ISET_TYPED_HEADER(double); +RD_KW_ISET_TYPED_HEADER(float); +RD_KW_ISET_TYPED_HEADER(int); +#undef RD_KW_ISET_TYPED_HEADER +void rd_kw_iset_bool(rd_kw_type *rd_kw, int i, bool bool_value); + +#define RD_KW_GET_TYPED_PTR_HEADER(type) \ + type *rd_kw_get_##type##_ptr(const rd_kw_type *) +RD_KW_GET_TYPED_PTR_HEADER(double); +RD_KW_GET_TYPED_PTR_HEADER(float); +RD_KW_GET_TYPED_PTR_HEADER(int); +RD_KW_GET_TYPED_PTR_HEADER(bool); +#undef RD_KW_GET_TYPED_PTR_HEADER + +#define RD_KW_SET_INDEXED_HEADER(ctype) \ + void rd_kw_set_indexed_##ctype( \ + rd_kw_type *rd_kw, const int_vector_type *index_list, ctype value) +RD_KW_SET_INDEXED_HEADER(double); +RD_KW_SET_INDEXED_HEADER(float); +RD_KW_SET_INDEXED_HEADER(int); +#undef RD_KW_SET_INDEXED_HEADER + +#define RD_KW_SHIFT_INDEXED_HEADER(ctype) \ + void rd_kw_shift_indexed_##ctype( \ + rd_kw_type *rd_kw, const int_vector_type *index_list, ctype shift) +RD_KW_SHIFT_INDEXED_HEADER(int); +RD_KW_SHIFT_INDEXED_HEADER(float); +RD_KW_SHIFT_INDEXED_HEADER(double); +#undef RD_KW_SHIFT_INDEXED_HEADER + +#define RD_KW_SCALE_INDEXED_HEADER(ctype) \ + void rd_kw_scale_indexed_##ctype( \ + rd_kw_type *rd_kw, const int_vector_type *index_list, ctype scale) +RD_KW_SCALE_INDEXED_HEADER(int); +RD_KW_SCALE_INDEXED_HEADER(float); +RD_KW_SCALE_INDEXED_HEADER(double); +#undef RD_KW_SCALE_INDEXED_HEADER + +#define RD_KW_MAX_MIN_HEADER(ctype) \ + void rd_kw_max_min_##ctype(const rd_kw_type *rd_kw, ctype *_max, \ + ctype *_min) +RD_KW_MAX_MIN_HEADER(int); +RD_KW_MAX_MIN_HEADER(float); +RD_KW_MAX_MIN_HEADER(double); +#undef RD_KW_MAX_MIN_HEADER + +void rd_kw_fix_uninitialized(rd_kw_type *rd_kw, int nx, int ny, int nz, + const int *actnum); + +rd_type_enum rd_kw_get_type(const rd_kw_type *); + +#include #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_kw_grdecl.h b/lib/include/resdata/rd_kw_grdecl.h index 9303766093..366a9afd1a 100644 --- a/lib/include/resdata/rd_kw_grdecl.h +++ b/lib/include/resdata/rd_kw_grdecl.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_kw_grdecl.hpp b/lib/include/resdata/rd_kw_grdecl.hpp index e60ae89bb0..eb32049c77 100644 --- a/lib/include/resdata/rd_kw_grdecl.hpp +++ b/lib/include/resdata/rd_kw_grdecl.hpp @@ -1,45 +1,44 @@ /* This header does not define datatypes; just a couple of functions. It should - be included from the ecl_kw.h header, so applications do not need to include this + be included from the rd_kw.h header, so applications do not need to include this header explicitly. */ -#ifndef ERT_ECL_KW_GRDECL_H -#define ERT_ECL_KW_GRDECL_H +#ifndef ERT_RD_KW_GRDECL_H +#define ERT_RD_KW_GRDECL_H #ifdef __cplusplus extern "C" { #endif -bool ecl_kw_grdecl_fseek_kw(const char *, bool, FILE *); +bool rd_kw_grdecl_fseek_kw(const char *, bool, FILE *); -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_dynamic__(FILE *stream, const char *kw, - bool strict, ecl_data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_dynamic(FILE *stream, const char *kw, - ecl_data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_dynamic__(FILE *stream, const char *kw, + bool strict, rd_data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_dynamic(FILE *stream, const char *kw, + rd_data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_data__(FILE *stream, bool strict, - int size, - ecl_data_type data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_data(FILE *stream, int size, - ecl_data_type data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_data__(FILE *stream, bool strict, + int size, rd_data_type data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_data(FILE *stream, int size, + rd_data_type data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl__(FILE *stream, const char *kw, - bool strict, int size, - ecl_data_type data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl(FILE *stream, const char *kw, int size, - ecl_data_type data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl__(FILE *stream, const char *kw, + bool strict, int size, + rd_data_type data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl(FILE *stream, const char *kw, int size, + rd_data_type data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_current_grdecl__(FILE *stream, bool strict, - ecl_data_type data_type); -ecl_kw_type *ecl_kw_fscanf_alloc_current_grdecl(FILE *stream, - ecl_data_type data_type); +rd_kw_type *rd_kw_fscanf_alloc_current_grdecl__(FILE *stream, bool strict, + rd_data_type data_type); +rd_kw_type *rd_kw_fscanf_alloc_current_grdecl(FILE *stream, + rd_data_type data_type); -bool ecl_kw_grdecl_fseek_next_kw(FILE *stream); -char *ecl_kw_grdecl_alloc_next_header(FILE *stream); +bool rd_kw_grdecl_fseek_next_kw(FILE *stream); +char *rd_kw_grdecl_alloc_next_header(FILE *stream); -void ecl_kw_fprintf_grdecl(const ecl_kw_type *ecl_kw, FILE *stream); -void ecl_kw_fprintf_grdecl__(const ecl_kw_type *ecl_kw, - const char *special_header, FILE *stream); +void rd_kw_fprintf_grdecl(const rd_kw_type *rd_kw, FILE *stream); +void rd_kw_fprintf_grdecl__(const rd_kw_type *rd_kw, const char *special_header, + FILE *stream); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_kw_magic.h b/lib/include/resdata/rd_kw_magic.h index 852b6713a6..2fcabeef27 100644 --- a/lib/include/resdata/rd_kw_magic.h +++ b/lib/include/resdata/rd_kw_magic.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_kw_magic.hpp b/lib/include/resdata/rd_kw_magic.hpp index 8d8a68d9c3..b7d0ac35bb 100644 --- a/lib/include/resdata/rd_kw_magic.hpp +++ b/lib/include/resdata/rd_kw_magic.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_KW_MAGIC_H -#define ERT_ECL_KW_MAGIC_H +#ifndef ERT_RD_KW_MAGIC_H +#define ERT_RD_KW_MAGIC_H #ifdef __cplusplus extern "C" { @@ -486,7 +486,7 @@ values (2e20) are denoted with '*'. /* There are no magic indices in the summary data files, for all - interesting data the table created from the ecl_smspec file must be + interesting data the table created from the rd_smspec file must be consulted. */ @@ -629,7 +629,7 @@ values (2e20) are denoted with '*'. #define GRIDHEAD_SIZE 100 /* Observe that these indices are one value lower than the values used - in the ecl_smspec file. */ + in the rd_smspec file. */ #define DIMENS_NX_INDEX 0 #define DIMENS_NY_INDEX 1 #define DIMENS_NZ_INDEX 2 diff --git a/lib/include/resdata/rd_nnc_data.h b/lib/include/resdata/rd_nnc_data.h index 5c942f0776..2fa2033058 100644 --- a/lib/include/resdata/rd_nnc_data.h +++ b/lib/include/resdata/rd_nnc_data.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_nnc_data.hpp b/lib/include/resdata/rd_nnc_data.hpp index 1afb0efb8d..4d14a0de50 100644 --- a/lib/include/resdata/rd_nnc_data.hpp +++ b/lib/include/resdata/rd_nnc_data.hpp @@ -1,38 +1,38 @@ -#ifndef ECL_NNC_DATA_H -#define ECL_NNC_DATA_H +#ifndef RD_NNC_DATA_H +#define RD_NNC_DATA_H #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_nnc_data_struct ecl_nnc_data_type; - -ecl_nnc_data_type *ecl_nnc_data_alloc_tran(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file); -ecl_nnc_data_type * -ecl_nnc_data_alloc_wat_flux(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file); -ecl_nnc_data_type * -ecl_nnc_data_alloc_oil_flux(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file); -ecl_nnc_data_type * -ecl_nnc_data_alloc_gas_flux(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file); -void ecl_nnc_data_free(ecl_nnc_data_type *data); - -int ecl_nnc_data_get_size(ecl_nnc_data_type *data); -const double *ecl_nnc_data_get_values(const ecl_nnc_data_type *data); - -double ecl_nnc_data_iget_value(const ecl_nnc_data_type *data, int index); +typedef struct rd_nnc_data_struct rd_nnc_data_type; + +rd_nnc_data_type *rd_nnc_data_alloc_tran(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file); +rd_nnc_data_type * +rd_nnc_data_alloc_wat_flux(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file); +rd_nnc_data_type * +rd_nnc_data_alloc_oil_flux(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file); +rd_nnc_data_type * +rd_nnc_data_alloc_gas_flux(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file); +void rd_nnc_data_free(rd_nnc_data_type *data); + +int rd_nnc_data_get_size(rd_nnc_data_type *data); +const double *rd_nnc_data_get_values(const rd_nnc_data_type *data); + +double rd_nnc_data_iget_value(const rd_nnc_data_type *data, int index); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_nnc_export.h b/lib/include/resdata/rd_nnc_export.h index dddcc584fd..eb7bbb03ca 100644 --- a/lib/include/resdata/rd_nnc_export.h +++ b/lib/include/resdata/rd_nnc_export.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_nnc_export.hpp b/lib/include/resdata/rd_nnc_export.hpp index 73056e724a..2bc1771a66 100644 --- a/lib/include/resdata/rd_nnc_export.hpp +++ b/lib/include/resdata/rd_nnc_export.hpp @@ -1,17 +1,17 @@ -#ifndef ERT_ECL_NNC_EXPORT -#define ERT_ECL_NNC_EXPORT +#ifndef ERT_RD_NNC_EXPORT +#define ERT_RD_NNC_EXPORT #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -#define ERT_ECL_DEFAULT_NNC_TRANS HUGE_VAL +#define ERT_RD_DEFAULT_NNC_TRANS HUGE_VAL typedef struct { int grid_nr1; @@ -22,27 +22,27 @@ typedef struct { int input_index; /* corresponds to the input ordering of this nnc */ double trans; -} ecl_nnc_type; - -bool ecl_nnc_intersect_format(const ecl_grid_type *grid, - const ecl_file_type *init_file); -int ecl_nnc_export_get_size(const ecl_grid_type *grid, - const ecl_file_type *init_file); -int ecl_nnc_export(const ecl_grid_type *grid, const ecl_file_type *init_file, - ecl_nnc_type *nnc_data); - -ecl_kw_type *ecl_nnc_export_get_tranx_kw(const ecl_grid_type *grid, - const ecl_file_type *init_file, - int lgr_nr1, int lgr_nr2); -ecl_kw_type *ecl_nnc_export_get_tranll_kw(const ecl_grid_type *grid, - const ecl_file_type *init_file, - int lgr_nr1, int lgr_nr2); -ecl_kw_type *ecl_nnc_export_get_tran_kw(const ecl_file_type *init_file, - const char *kw, int lgr_nr); - -bool ecl_nnc_equal(const ecl_nnc_type *nnc1, const ecl_nnc_type *nnc2); -int ecl_nnc_sort_cmp(const ecl_nnc_type *nnc1, const ecl_nnc_type *nnc2); -void ecl_nnc_sort(ecl_nnc_type *nnc_list, int size); +} rd_nnc_type; + +bool rd_nnc_intersect_format(const rd_grid_type *grid, + const rd_file_type *init_file); +int rd_nnc_export_get_size(const rd_grid_type *grid, + const rd_file_type *init_file); +int rd_nnc_export(const rd_grid_type *grid, const rd_file_type *init_file, + rd_nnc_type *nnc_data); + +rd_kw_type *rd_nnc_export_get_tranx_kw(const rd_grid_type *grid, + const rd_file_type *init_file, + int lgr_nr1, int lgr_nr2); +rd_kw_type *rd_nnc_export_get_tranll_kw(const rd_grid_type *grid, + const rd_file_type *init_file, + int lgr_nr1, int lgr_nr2); +rd_kw_type *rd_nnc_export_get_tran_kw(const rd_file_type *init_file, + const char *kw, int lgr_nr); + +bool rd_nnc_equal(const rd_nnc_type *nnc1, const rd_nnc_type *nnc2); +int rd_nnc_sort_cmp(const rd_nnc_type *nnc1, const rd_nnc_type *nnc2); +void rd_nnc_sort(rd_nnc_type *nnc_list, int size); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_nnc_geometry.h b/lib/include/resdata/rd_nnc_geometry.h index a8d9b2ff64..c5520809a0 100644 --- a/lib/include/resdata/rd_nnc_geometry.h +++ b/lib/include/resdata/rd_nnc_geometry.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_nnc_geometry.hpp b/lib/include/resdata/rd_nnc_geometry.hpp index ad3648833f..b3a3fd0017 100644 --- a/lib/include/resdata/rd_nnc_geometry.hpp +++ b/lib/include/resdata/rd_nnc_geometry.hpp @@ -3,16 +3,16 @@ #include -#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_nnc_geometry_struct ecl_nnc_geometry_type; -typedef struct ecl_nnc_pair_struct ecl_nnc_pair_type; +typedef struct rd_nnc_geometry_struct rd_nnc_geometry_type; +typedef struct rd_nnc_pair_struct rd_nnc_pair_type; -struct ecl_nnc_pair_struct { +struct rd_nnc_pair_struct { int grid_nr1; int global_index1; int grid_nr2; @@ -21,14 +21,14 @@ struct ecl_nnc_pair_struct { int input_index; /* corresponds to the input ordering of this nnc */ }; -UTIL_IS_INSTANCE_HEADER(ecl_nnc_geometry); -void ecl_nnc_geometry_free(ecl_nnc_geometry_type *nnc_geo); -ecl_nnc_geometry_type *ecl_nnc_geometry_alloc(const ecl_grid_type *grid); -int ecl_nnc_geometry_size(const ecl_nnc_geometry_type *nnc_geo); -const ecl_nnc_pair_type * -ecl_nnc_geometry_iget(const ecl_nnc_geometry_type *nnc_geo, int index); -bool ecl_nnc_geometry_same_kw(const ecl_nnc_pair_type *nnc1, - const ecl_nnc_pair_type *nnc2); +UTIL_IS_INSTANCE_HEADER(rd_nnc_geometry); +void rd_nnc_geometry_free(rd_nnc_geometry_type *nnc_geo); +rd_nnc_geometry_type *rd_nnc_geometry_alloc(const rd_grid_type *grid); +int rd_nnc_geometry_size(const rd_nnc_geometry_type *nnc_geo); +const rd_nnc_pair_type * +rd_nnc_geometry_iget(const rd_nnc_geometry_type *nnc_geo, int index); +bool rd_nnc_geometry_same_kw(const rd_nnc_pair_type *nnc1, + const rd_nnc_pair_type *nnc2); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_region.h b/lib/include/resdata/rd_region.h index 6e9574da04..97035f9069 100644 --- a/lib/include/resdata/rd_region.h +++ b/lib/include/resdata/rd_region.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_region.hpp b/lib/include/resdata/rd_region.hpp index 4a23e4fe99..0d7659447d 100644 --- a/lib/include/resdata/rd_region.hpp +++ b/lib/include/resdata/rd_region.hpp @@ -1,13 +1,13 @@ -#ifndef ERT_ECL_REGION_H -#define ERT_ECL_REGION_H +#ifndef ERT_RD_REGION_H +#define ERT_RD_REGION_H #include #include #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" { @@ -29,231 +29,213 @@ typedef enum { SELECT_IN_INTERVAL = 12, DESELECT_IN_INTERVAL = 13, INVERT_SELECTION = 14 -} ecl_region_select_cmd; - -typedef struct ecl_region_struct ecl_region_type; - -void ecl_region_unlock(ecl_region_type *region); -void ecl_region_lock(ecl_region_type *region); -void ecl_region_reset(ecl_region_type *ecl_region); -ecl_region_type *ecl_region_alloc_copy(const ecl_region_type *ecl_region); -ecl_region_type *ecl_region_alloc(const ecl_grid_type *ecl_grid, - bool preselect); -void ecl_region_free(ecl_region_type *region); -void ecl_region_free__(void *__region); - -const int_vector_type *ecl_region_get_active_list(ecl_region_type *region); -const int_vector_type *ecl_region_get_global_list(ecl_region_type *region); -const int_vector_type * -ecl_region_get_global_active_list(ecl_region_type *region); - -bool ecl_region_contains_ijk(const ecl_region_type *ecl_region, int i, int j, - int k); -bool ecl_region_contains_global(const ecl_region_type *ecl_region, - int global_index); -bool ecl_region_contains_active(const ecl_region_type *ecl_region, - int active_index); - -void ecl_region_select_true(ecl_region_type *region, const ecl_kw_type *ecl_kw); - -void ecl_region_invert_selection(ecl_region_type *region); -void ecl_region_select_all(ecl_region_type *region); -void ecl_region_deselect_all(ecl_region_type *region); -void ecl_region_deselect_true(ecl_region_type *region, - const ecl_kw_type *ecl_kw); -void ecl_region_select_false(ecl_region_type *region, - const ecl_kw_type *ecl_kw); - -void ecl_region_select_in_interval(ecl_region_type *region, - const ecl_kw_type *ecl_kw, float min_value, - float max_value); -void ecl_region_deselect_in_interval(ecl_region_type *region, - const ecl_kw_type *ecl_kw, float min_value, - float max_value); - -void ecl_region_select_equal(ecl_region_type *region, const ecl_kw_type *ecl_kw, - int value); -void ecl_region_deselect_equal(ecl_region_type *region, - const ecl_kw_type *ecl_kw, int value); - -void ecl_region_select_inactive_cells(ecl_region_type *region); -void ecl_region_deselect_inactive_cells(ecl_region_type *region); -void ecl_region_select_active_cells(ecl_region_type *region); -void ecl_region_deselect_active_cells(ecl_region_type *region); - -void ecl_region_select_from_ijkbox(ecl_region_type *region, int i1, int i2, - int j1, int j2, int k1, int k2); -void ecl_region_deselect_from_ijkbox(ecl_region_type *region, int i1, int i2, - int j1, int j2, int k1, int k2); - -void ecl_region_select_i1i2(ecl_region_type *region, int i1, int i2); -void ecl_region_deselect_i1i2(ecl_region_type *region, int i1, int i2); -void ecl_region_select_j1j2(ecl_region_type *region, int j1, int j2); -void ecl_region_deselect_j1j2(ecl_region_type *region, int j1, int i2); -void ecl_region_select_k1k2(ecl_region_type *region, int k1, int k2); -void ecl_region_deselect_k1k2(ecl_region_type *region, int k1, int i2); - -void ecl_region_select_shallow_cells(ecl_region_type *region, - double depth_limit); -void ecl_region_deselect_shallow_cells(ecl_region_type *region, - double depth_limit); -void ecl_region_select_deep_cells(ecl_region_type *region, double depth_limit); -void ecl_region_deselect_deep_cells(ecl_region_type *region, - double depth_limit); - -void ecl_region_select_thin_cells(ecl_region_type *ecl_region, double dz_limit); -void ecl_region_deselect_thin_cells(ecl_region_type *ecl_region, - double dz_limit); -void ecl_region_select_thick_cells(ecl_region_type *ecl_region, - double dz_limit); -void ecl_region_deselect_thick_cells(ecl_region_type *ecl_region, - double dz_limit); - -void ecl_region_select_small_cells(ecl_region_type *ecl_region, - double volum_limit); -void ecl_region_deselect_small_cells(ecl_region_type *ecl_region, - double volum_limit); -void ecl_region_select_large_cells(ecl_region_type *ecl_region, - double volum_limit); -void ecl_region_deselect_large_cells(ecl_region_type *ecl_region, - double volum_limit); - -void ecl_region_select_global_index(ecl_region_type *ecl_region, - int global_index); -void ecl_region_deselect_global_index(ecl_region_type *ecl_region, - int global_index); - -void ecl_region_select_active_index(ecl_region_type *ecl_region, - int active_index); -void ecl_region_deselect_active_index(ecl_region_type *ecl_region, - int active_index); - -void ecl_region_intersection(ecl_region_type *region, - const ecl_region_type *new_region); -void ecl_region_union(ecl_region_type *region, - const ecl_region_type *new_region); -void ecl_region_subtract(ecl_region_type *region, - const ecl_region_type *new_region); -void ecl_region_xor(ecl_region_type *region, const ecl_region_type *new_region); - -void ecl_region_select_smaller(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit); -void ecl_region_deselect_smaller(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit); -void ecl_region_select_larger(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit); -void ecl_region_deselect_larger(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit); - -void ecl_region_cmp_select_less(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, const ecl_kw_type *kw2); -void ecl_region_cmp_deselect_less(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2); -void ecl_region_cmp_select_more(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, const ecl_kw_type *kw2); -void ecl_region_cmp_deselect_more(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2); - -void ecl_region_select_in_cylinder(ecl_region_type *region, double x0, - double y0, double R); -void ecl_region_deselect_in_cylinder(ecl_region_type *region, double x0, - double y0, double R); -void ecl_region_select_in_zcylinder(ecl_region_type *region, double x0, - double y0, double R, double z1, double z2); -void ecl_region_deselect_in_zcylinder(ecl_region_type *region, double x0, - double y0, double R, double z1, - double z2); - -void ecl_region_select_above_plane(ecl_region_type *region, const double n[3], - const double p[3]); -void ecl_region_select_below_plane(ecl_region_type *region, const double n[3], - const double p[3]); -void ecl_region_deselect_above_plane(ecl_region_type *region, const double n[3], - const double p[3]); -void ecl_region_deselect_below_plane(ecl_region_type *region, const double n[3], - const double p[3]); - -void ecl_region_select_inside_polygon(ecl_region_type *region, +} rd_region_select_cmd; + +typedef struct rd_region_struct rd_region_type; + +void rd_region_unlock(rd_region_type *region); +void rd_region_lock(rd_region_type *region); +void rd_region_reset(rd_region_type *rd_region); +rd_region_type *rd_region_alloc_copy(const rd_region_type *rd_region); +rd_region_type *rd_region_alloc(const rd_grid_type *rd_grid, bool preselect); +void rd_region_free(rd_region_type *region); +void rd_region_free__(void *__region); + +const int_vector_type *rd_region_get_active_list(rd_region_type *region); +const int_vector_type *rd_region_get_global_list(rd_region_type *region); +const int_vector_type *rd_region_get_global_active_list(rd_region_type *region); + +bool rd_region_contains_ijk(const rd_region_type *rd_region, int i, int j, + int k); +bool rd_region_contains_global(const rd_region_type *rd_region, + int global_index); +bool rd_region_contains_active(const rd_region_type *rd_region, + int active_index); + +void rd_region_select_true(rd_region_type *region, const rd_kw_type *rd_kw); + +void rd_region_invert_selection(rd_region_type *region); +void rd_region_select_all(rd_region_type *region); +void rd_region_deselect_all(rd_region_type *region); +void rd_region_deselect_true(rd_region_type *region, const rd_kw_type *rd_kw); +void rd_region_select_false(rd_region_type *region, const rd_kw_type *rd_kw); + +void rd_region_select_in_interval(rd_region_type *region, + const rd_kw_type *rd_kw, float min_value, + float max_value); +void rd_region_deselect_in_interval(rd_region_type *region, + const rd_kw_type *rd_kw, float min_value, + float max_value); + +void rd_region_select_equal(rd_region_type *region, const rd_kw_type *rd_kw, + int value); +void rd_region_deselect_equal(rd_region_type *region, const rd_kw_type *rd_kw, + int value); + +void rd_region_select_inactive_cells(rd_region_type *region); +void rd_region_deselect_inactive_cells(rd_region_type *region); +void rd_region_select_active_cells(rd_region_type *region); +void rd_region_deselect_active_cells(rd_region_type *region); + +void rd_region_select_from_ijkbox(rd_region_type *region, int i1, int i2, + int j1, int j2, int k1, int k2); +void rd_region_deselect_from_ijkbox(rd_region_type *region, int i1, int i2, + int j1, int j2, int k1, int k2); + +void rd_region_select_i1i2(rd_region_type *region, int i1, int i2); +void rd_region_deselect_i1i2(rd_region_type *region, int i1, int i2); +void rd_region_select_j1j2(rd_region_type *region, int j1, int j2); +void rd_region_deselect_j1j2(rd_region_type *region, int j1, int i2); +void rd_region_select_k1k2(rd_region_type *region, int k1, int k2); +void rd_region_deselect_k1k2(rd_region_type *region, int k1, int i2); + +void rd_region_select_shallow_cells(rd_region_type *region, double depth_limit); +void rd_region_deselect_shallow_cells(rd_region_type *region, + double depth_limit); +void rd_region_select_deep_cells(rd_region_type *region, double depth_limit); +void rd_region_deselect_deep_cells(rd_region_type *region, double depth_limit); + +void rd_region_select_thin_cells(rd_region_type *rd_region, double dz_limit); +void rd_region_deselect_thin_cells(rd_region_type *rd_region, double dz_limit); +void rd_region_select_thick_cells(rd_region_type *rd_region, double dz_limit); +void rd_region_deselect_thick_cells(rd_region_type *rd_region, double dz_limit); + +void rd_region_select_small_cells(rd_region_type *rd_region, + double volum_limit); +void rd_region_deselect_small_cells(rd_region_type *rd_region, + double volum_limit); +void rd_region_select_large_cells(rd_region_type *rd_region, + double volum_limit); +void rd_region_deselect_large_cells(rd_region_type *rd_region, + double volum_limit); + +void rd_region_select_global_index(rd_region_type *rd_region, int global_index); +void rd_region_deselect_global_index(rd_region_type *rd_region, + int global_index); + +void rd_region_select_active_index(rd_region_type *rd_region, int active_index); +void rd_region_deselect_active_index(rd_region_type *rd_region, + int active_index); + +void rd_region_intersection(rd_region_type *region, + const rd_region_type *new_region); +void rd_region_union(rd_region_type *region, const rd_region_type *new_region); +void rd_region_subtract(rd_region_type *region, + const rd_region_type *new_region); +void rd_region_xor(rd_region_type *region, const rd_region_type *new_region); + +void rd_region_select_smaller(rd_region_type *rd_region, + const rd_kw_type *rd_kw, float limit); +void rd_region_deselect_smaller(rd_region_type *rd_region, + const rd_kw_type *rd_kw, float limit); +void rd_region_select_larger(rd_region_type *rd_region, const rd_kw_type *rd_kw, + float limit); +void rd_region_deselect_larger(rd_region_type *rd_region, + const rd_kw_type *rd_kw, float limit); + +void rd_region_cmp_select_less(rd_region_type *rd_region, const rd_kw_type *kw1, + const rd_kw_type *kw2); +void rd_region_cmp_deselect_less(rd_region_type *rd_region, + const rd_kw_type *kw1, const rd_kw_type *kw2); +void rd_region_cmp_select_more(rd_region_type *rd_region, const rd_kw_type *kw1, + const rd_kw_type *kw2); +void rd_region_cmp_deselect_more(rd_region_type *rd_region, + const rd_kw_type *kw1, const rd_kw_type *kw2); + +void rd_region_select_in_cylinder(rd_region_type *region, double x0, double y0, + double R); +void rd_region_deselect_in_cylinder(rd_region_type *region, double x0, + double y0, double R); +void rd_region_select_in_zcylinder(rd_region_type *region, double x0, double y0, + double R, double z1, double z2); +void rd_region_deselect_in_zcylinder(rd_region_type *region, double x0, + double y0, double R, double z1, double z2); + +void rd_region_select_above_plane(rd_region_type *region, const double n[3], + const double p[3]); +void rd_region_select_below_plane(rd_region_type *region, const double n[3], + const double p[3]); +void rd_region_deselect_above_plane(rd_region_type *region, const double n[3], + const double p[3]); +void rd_region_deselect_below_plane(rd_region_type *region, const double n[3], + const double p[3]); + +void rd_region_select_inside_polygon(rd_region_type *region, + const geo_polygon_type *polygon); +void rd_region_deselect_inside_polygon(rd_region_type *region, + const geo_polygon_type *polygon); +void rd_region_select_outside_polygon(rd_region_type *region, const geo_polygon_type *polygon); -void ecl_region_deselect_inside_polygon(ecl_region_type *region, +void rd_region_deselect_outside_polygon(rd_region_type *region, const geo_polygon_type *polygon); -void ecl_region_select_outside_polygon(ecl_region_type *region, - const geo_polygon_type *polygon); -void ecl_region_deselect_outside_polygon(ecl_region_type *region, - const geo_polygon_type *polygon); - -void ecl_region_select_from_layer(ecl_region_type *region, - const layer_type *layer, int k, - int layer_value); -void ecl_region_deselect_from_layer(ecl_region_type *region, - const layer_type *layer, int k, - int layer_value); -void ecl_region_deselect_false(ecl_region_type *region, - const ecl_kw_type *ecl_kw); - -void ecl_region_set_kw_int(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - int value, bool force_active); -void ecl_region_set_kw_float(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - float value, bool force_active); -void ecl_region_set_kw_double(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - double value, bool force_active); -void ecl_region_kw_copy(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *src_kw, bool force_active); -int ecl_region_get_kw_size(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active); - -void ecl_region_kw_iadd(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *delta_kw, bool force_active); -void ecl_region_kw_idiv(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *div_kw, bool force_active); -void ecl_region_kw_imul(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *mul_kw, bool force_active); -void ecl_region_kw_isub(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *delta_kw, bool force_active); - -bool ecl_region_equal(const ecl_region_type *region1, - const ecl_region_type *region2); - -void ecl_region_scale_kw_float(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - float value, bool force_active); -void ecl_region_scale_kw_double(ecl_region_type *ecl_region, - ecl_kw_type *ecl_kw, double value, - bool force_active); -void ecl_region_scale_kw_int(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - int value, bool force_active); -void ecl_region_shift_kw_int(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - int value, bool force_active); -void ecl_region_shift_kw_double(ecl_region_type *ecl_region, - ecl_kw_type *ecl_kw, double value, - bool force_active); -void ecl_region_shift_kw_float(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - float value, bool force_active); - -const int_vector_type *ecl_region_get_kw_index_list(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, - bool force_active); - -void ecl_region_set_name(ecl_region_type *region, const char *name); -const char *ecl_region_get_name(const ecl_region_type *region); - -int ecl_region_get_active_size_cpp(ecl_region_type *region); -int ecl_region_get_global_size_cpp(ecl_region_type *region); -const int *ecl_region_get_active_list_cpp(ecl_region_type *region); -const int *ecl_region_get_global_list_cpp(ecl_region_type *region); - -double ecl_region_sum_kw_double(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active); -int ecl_region_sum_kw_int(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active); -float ecl_region_sum_kw_float(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active); -int ecl_region_sum_kw_bool(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active); - -UTIL_IS_INSTANCE_HEADER(ecl_region); -UTIL_SAFE_CAST_HEADER(ecl_region); + +void rd_region_select_from_layer(rd_region_type *region, + const layer_type *layer, int k, + int layer_value); +void rd_region_deselect_from_layer(rd_region_type *region, + const layer_type *layer, int k, + int layer_value); +void rd_region_deselect_false(rd_region_type *region, const rd_kw_type *rd_kw); + +void rd_region_set_kw_int(rd_region_type *rd_region, rd_kw_type *rd_kw, + int value, bool force_active); +void rd_region_set_kw_float(rd_region_type *rd_region, rd_kw_type *rd_kw, + float value, bool force_active); +void rd_region_set_kw_double(rd_region_type *rd_region, rd_kw_type *rd_kw, + double value, bool force_active); +void rd_region_kw_copy(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *src_kw, bool force_active); +int rd_region_get_kw_size(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active); + +void rd_region_kw_iadd(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *delta_kw, bool force_active); +void rd_region_kw_idiv(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *div_kw, bool force_active); +void rd_region_kw_imul(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *mul_kw, bool force_active); +void rd_region_kw_isub(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *delta_kw, bool force_active); + +bool rd_region_equal(const rd_region_type *region1, + const rd_region_type *region2); + +void rd_region_scale_kw_float(rd_region_type *rd_region, rd_kw_type *rd_kw, + float value, bool force_active); +void rd_region_scale_kw_double(rd_region_type *rd_region, rd_kw_type *rd_kw, + double value, bool force_active); +void rd_region_scale_kw_int(rd_region_type *rd_region, rd_kw_type *rd_kw, + int value, bool force_active); +void rd_region_shift_kw_int(rd_region_type *rd_region, rd_kw_type *rd_kw, + int value, bool force_active); +void rd_region_shift_kw_double(rd_region_type *rd_region, rd_kw_type *rd_kw, + double value, bool force_active); +void rd_region_shift_kw_float(rd_region_type *rd_region, rd_kw_type *rd_kw, + float value, bool force_active); + +const int_vector_type *rd_region_get_kw_index_list(rd_region_type *rd_region, + const rd_kw_type *rd_kw, + bool force_active); + +void rd_region_set_name(rd_region_type *region, const char *name); +const char *rd_region_get_name(const rd_region_type *region); + +int rd_region_get_active_size_cpp(rd_region_type *region); +int rd_region_get_global_size_cpp(rd_region_type *region); +const int *rd_region_get_active_list_cpp(rd_region_type *region); +const int *rd_region_get_global_list_cpp(rd_region_type *region); + +double rd_region_sum_kw_double(rd_region_type *rd_region, + const rd_kw_type *rd_kw, bool force_active); +int rd_region_sum_kw_int(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active); +float rd_region_sum_kw_float(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active); +int rd_region_sum_kw_bool(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active); + +UTIL_IS_INSTANCE_HEADER(rd_region); +UTIL_SAFE_CAST_HEADER(rd_region); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_rft_cell.h b/lib/include/resdata/rd_rft_cell.h index 1ff3653a81..52d5dc411b 100644 --- a/lib/include/resdata/rd_rft_cell.h +++ b/lib/include/resdata/rd_rft_cell.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_rft_cell.hpp b/lib/include/resdata/rd_rft_cell.hpp index a730d6e9ee..0009d19b4c 100644 --- a/lib/include/resdata/rd_rft_cell.hpp +++ b/lib/include/resdata/rd_rft_cell.hpp @@ -1,58 +1,57 @@ -#ifndef ERT_ECL_RFT_CELL_H -#define ERT_ECL_RFT_CELL_H +#ifndef ERT_RD_RFT_CELL_H +#define ERT_RD_RFT_CELL_H #ifdef __cplusplus extern "C" { #endif #include -#define ECL_RFT_CELL_INVALID_VALUE -1 - -typedef struct ecl_rft_cell_struct ecl_rft_cell_type; - -UTIL_IS_INSTANCE_HEADER(ecl_rft_cell); - -ecl_rft_cell_type * -ecl_rft_cell_alloc_PLT(int i, int j, int k, double depth, double pressure, - double orat, double grat, double wrat, - double connection_start, double connection_end, - double flowrate, double oil_flowrate, - double gas_flowrate, double water_flowrate); - -ecl_rft_cell_type *ecl_rft_cell_alloc_RFT(int i, int j, int k, double depth, - double pressure, double swat, - double sgas); -void ecl_rft_cell_free(ecl_rft_cell_type *cell); -void ecl_rft_cell_free__(void *arg); - -bool ecl_rft_cell_ijk_equal(const ecl_rft_cell_type *cell, int i, int j, int k); -void ecl_rft_cell_get_ijk(const ecl_rft_cell_type *cell, int *i, int *j, - int *k); -int ecl_rft_cell_get_i(const ecl_rft_cell_type *cell); -int ecl_rft_cell_get_j(const ecl_rft_cell_type *cell); -int ecl_rft_cell_get_k(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_depth(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_pressure(const ecl_rft_cell_type *cell); - -double ecl_rft_cell_get_swat(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_sgas(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_soil(const ecl_rft_cell_type *cell); - -double ecl_rft_cell_get_wrat(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_grat(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_orat(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_connection_start(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_connection_end(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_flowrate(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_oil_flowrate(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_gas_flowrate(const ecl_rft_cell_type *cell); -double ecl_rft_cell_get_water_flowrate(const ecl_rft_cell_type *cell); - -int ecl_rft_cell_cmp__(const void *arg1, const void *arg2); -int ecl_rft_cell_cmp(const ecl_rft_cell_type *cell1, - const ecl_rft_cell_type *cell2); -bool ecl_rft_cell_lt(const ecl_rft_cell_type *cell1, - const ecl_rft_cell_type *cell2); +#define RD_RFT_CELL_INVALID_VALUE -1 + +typedef struct rd_rft_cell_struct rd_rft_cell_type; + +UTIL_IS_INSTANCE_HEADER(rd_rft_cell); + +rd_rft_cell_type * +rd_rft_cell_alloc_PLT(int i, int j, int k, double depth, double pressure, + double orat, double grat, double wrat, + double connection_start, double connection_end, + double flowrate, double oil_flowrate, double gas_flowrate, + double water_flowrate); + +rd_rft_cell_type *rd_rft_cell_alloc_RFT(int i, int j, int k, double depth, + double pressure, double swat, + double sgas); +void rd_rft_cell_free(rd_rft_cell_type *cell); +void rd_rft_cell_free__(void *arg); + +bool rd_rft_cell_ijk_equal(const rd_rft_cell_type *cell, int i, int j, int k); +void rd_rft_cell_get_ijk(const rd_rft_cell_type *cell, int *i, int *j, int *k); +int rd_rft_cell_get_i(const rd_rft_cell_type *cell); +int rd_rft_cell_get_j(const rd_rft_cell_type *cell); +int rd_rft_cell_get_k(const rd_rft_cell_type *cell); +double rd_rft_cell_get_depth(const rd_rft_cell_type *cell); +double rd_rft_cell_get_pressure(const rd_rft_cell_type *cell); + +double rd_rft_cell_get_swat(const rd_rft_cell_type *cell); +double rd_rft_cell_get_sgas(const rd_rft_cell_type *cell); +double rd_rft_cell_get_soil(const rd_rft_cell_type *cell); + +double rd_rft_cell_get_wrat(const rd_rft_cell_type *cell); +double rd_rft_cell_get_grat(const rd_rft_cell_type *cell); +double rd_rft_cell_get_orat(const rd_rft_cell_type *cell); +double rd_rft_cell_get_connection_start(const rd_rft_cell_type *cell); +double rd_rft_cell_get_connection_end(const rd_rft_cell_type *cell); +double rd_rft_cell_get_flowrate(const rd_rft_cell_type *cell); +double rd_rft_cell_get_oil_flowrate(const rd_rft_cell_type *cell); +double rd_rft_cell_get_gas_flowrate(const rd_rft_cell_type *cell); +double rd_rft_cell_get_water_flowrate(const rd_rft_cell_type *cell); + +int rd_rft_cell_cmp__(const void *arg1, const void *arg2); +int rd_rft_cell_cmp(const rd_rft_cell_type *cell1, + const rd_rft_cell_type *cell2); +bool rd_rft_cell_lt(const rd_rft_cell_type *cell1, + const rd_rft_cell_type *cell2); #ifdef __cplusplus } #endif diff --git a/lib/include/resdata/rd_rft_file.h b/lib/include/resdata/rd_rft_file.h index 17f6571e64..8da1a521ed 100644 --- a/lib/include/resdata/rd_rft_file.h +++ b/lib/include/resdata/rd_rft_file.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_rft_file.hpp b/lib/include/resdata/rd_rft_file.hpp index e172b4e9ab..b3c4047a5f 100644 --- a/lib/include/resdata/rd_rft_file.hpp +++ b/lib/include/resdata/rd_rft_file.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_RFT_FILE_H -#define ERT_ECL_RFT_FILE_H +#ifndef ERT_RD_RFT_FILE_H +#define ERT_RD_RFT_FILE_H #ifdef __cplusplus extern "C" { #endif @@ -7,45 +7,42 @@ extern "C" { #include -#include +#include #include #include -typedef struct ecl_rft_file_struct ecl_rft_file_type; +typedef struct rd_rft_file_struct rd_rft_file_type; -char *ecl_rft_file_alloc_case_filename(const char *case_input); -const char *ecl_rft_file_get_filename(const ecl_rft_file_type *rft_file); -ecl_rft_file_type *ecl_rft_file_alloc_case(const char *case_input); -bool ecl_rft_file_case_has_rft(const char *case_input); -ecl_rft_file_type *ecl_rft_file_alloc(const char *); -void ecl_rft_file_free(ecl_rft_file_type *); -void ecl_rft_file_block(const ecl_rft_file_type *, double, const char *, int, - const double *, int *, int *, int *); -void ecl_rft_file_fprintf_rft_obs(const ecl_rft_file_type *, double, - const char *, const char *, const char *, - double); -ecl_rft_node_type *ecl_rft_file_get_node(const ecl_rft_file_type *, - const char *); +char *rd_rft_file_alloc_case_filename(const char *case_input); +const char *rd_rft_file_get_filename(const rd_rft_file_type *rft_file); +rd_rft_file_type *rd_rft_file_alloc_case(const char *case_input); +bool rd_rft_file_case_has_rft(const char *case_input); +rd_rft_file_type *rd_rft_file_alloc(const char *); +void rd_rft_file_free(rd_rft_file_type *); +void rd_rft_file_block(const rd_rft_file_type *, double, const char *, int, + const double *, int *, int *, int *); +void rd_rft_file_fprintf_rft_obs(const rd_rft_file_type *, double, const char *, + const char *, const char *, double); +rd_rft_node_type *rd_rft_file_get_node(const rd_rft_file_type *, const char *); -int ecl_rft_file_get_size__(const ecl_rft_file_type *rft_file, - const char *well_pattern, time_t recording_time); -int ecl_rft_file_get_size(const ecl_rft_file_type *rft_file); -ecl_rft_node_type * -ecl_rft_file_get_well_time_rft(const ecl_rft_file_type *rft_file, - const char *well, time_t recording_time); -ecl_rft_node_type *ecl_rft_file_iget_node(const ecl_rft_file_type *rft_file, - int index); -ecl_rft_node_type *ecl_rft_file_iget_well_rft(const ecl_rft_file_type *rft_file, - const char *well, int index); -bool ecl_rft_file_has_well(const ecl_rft_file_type *rft_file, const char *well); -int ecl_rft_file_get_well_occurences(const ecl_rft_file_type *rft_file, - const char *well); -stringlist_type * -ecl_rft_file_alloc_well_list(const ecl_rft_file_type *rft_file); -int ecl_rft_file_get_num_wells(const ecl_rft_file_type *rft_file); -void ecl_rft_file_free__(void *arg); -void ecl_rft_file_update(const char *rft_file_name, ecl_rft_node_type **nodes, - int num_nodes, ert_ecl_unit_enum unit_set); +int rd_rft_file_get_size__(const rd_rft_file_type *rft_file, + const char *well_pattern, time_t recording_time); +int rd_rft_file_get_size(const rd_rft_file_type *rft_file); +rd_rft_node_type * +rd_rft_file_get_well_time_rft(const rd_rft_file_type *rft_file, + const char *well, time_t recording_time); +rd_rft_node_type *rd_rft_file_iget_node(const rd_rft_file_type *rft_file, + int index); +rd_rft_node_type *rd_rft_file_iget_well_rft(const rd_rft_file_type *rft_file, + const char *well, int index); +bool rd_rft_file_has_well(const rd_rft_file_type *rft_file, const char *well); +int rd_rft_file_get_well_occurences(const rd_rft_file_type *rft_file, + const char *well); +stringlist_type *rd_rft_file_alloc_well_list(const rd_rft_file_type *rft_file); +int rd_rft_file_get_num_wells(const rd_rft_file_type *rft_file); +void rd_rft_file_free__(void *arg); +void rd_rft_file_update(const char *rft_file_name, rd_rft_node_type **nodes, + int num_nodes, ert_rd_unit_enum unit_set); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_rft_node.h b/lib/include/resdata/rd_rft_node.h index ff870c3758..faa08d1386 100644 --- a/lib/include/resdata/rd_rft_node.h +++ b/lib/include/resdata/rd_rft_node.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_rft_node.hpp b/lib/include/resdata/rd_rft_node.hpp index 98dc5c2253..ea92bd28ff 100644 --- a/lib/include/resdata/rd_rft_node.hpp +++ b/lib/include/resdata/rd_rft_node.hpp @@ -1,68 +1,68 @@ -#ifndef ERT_ECL_RFT_NODE_H -#define ERT_ECL_RFT_NODE_H +#ifndef ERT_RD_RFT_NODE_H +#define ERT_RD_RFT_NODE_H #ifdef __cplusplus extern "C" { #endif #include -#include -#include -#include +#include +#include +#include typedef enum { RFT = 1, PLT = 2, SEGMENT = 3 /* Not really implemented */ -} ecl_rft_enum; +} rd_rft_enum; -typedef struct ecl_rft_node_struct ecl_rft_node_type; +typedef struct rd_rft_node_struct rd_rft_node_type; -void ecl_rft_node_inplace_sort_cells(ecl_rft_node_type *rft_node); -const ecl_rft_cell_type * -ecl_rft_node_iget_cell_sorted(ecl_rft_node_type *rft_node, int index); -const ecl_rft_cell_type * -ecl_rft_node_iget_cell(const ecl_rft_node_type *rft_node, int index); -const ecl_rft_cell_type * -ecl_rft_node_lookup_ijk(const ecl_rft_node_type *rft_node, int i, int j, int k); -void ecl_rft_node_fprintf_rft_obs(const ecl_rft_node_type *, double, - const char *, const char *, double); -ecl_rft_node_type *ecl_rft_node_alloc(const ecl_file_view_type *rft_view); -void ecl_rft_node_free(ecl_rft_node_type *); -void ecl_rft_node_free__(void *); -time_t ecl_rft_node_get_date(const ecl_rft_node_type *); -int ecl_rft_node_get_size(const ecl_rft_node_type *); -const char *ecl_rft_node_get_well_name(const ecl_rft_node_type *rft_node); -void ecl_rft_node_iget_ijk(const ecl_rft_node_type *rft_node, int index, int *i, - int *j, int *k); +void rd_rft_node_inplace_sort_cells(rd_rft_node_type *rft_node); +const rd_rft_cell_type *rd_rft_node_iget_cell_sorted(rd_rft_node_type *rft_node, + int index); +const rd_rft_cell_type *rd_rft_node_iget_cell(const rd_rft_node_type *rft_node, + int index); +const rd_rft_cell_type *rd_rft_node_lookup_ijk(const rd_rft_node_type *rft_node, + int i, int j, int k); +void rd_rft_node_fprintf_rft_obs(const rd_rft_node_type *, double, const char *, + const char *, double); +rd_rft_node_type *rd_rft_node_alloc(const rd_file_view_type *rft_view); +void rd_rft_node_free(rd_rft_node_type *); +void rd_rft_node_free__(void *); +time_t rd_rft_node_get_date(const rd_rft_node_type *); +int rd_rft_node_get_size(const rd_rft_node_type *); +const char *rd_rft_node_get_well_name(const rd_rft_node_type *rft_node); +void rd_rft_node_iget_ijk(const rd_rft_node_type *rft_node, int index, int *i, + int *j, int *k); -bool ecl_rft_node_is_RFT(const ecl_rft_node_type *rft_node); -bool ecl_rft_node_is_PLT(const ecl_rft_node_type *rft_node); -bool ecl_rft_node_is_SEGMENT(const ecl_rft_node_type *rft_node); -bool ecl_rft_node_is_MSW(const ecl_rft_node_type *rft_node); +bool rd_rft_node_is_RFT(const rd_rft_node_type *rft_node); +bool rd_rft_node_is_PLT(const rd_rft_node_type *rft_node); +bool rd_rft_node_is_SEGMENT(const rd_rft_node_type *rft_node); +bool rd_rft_node_is_MSW(const rd_rft_node_type *rft_node); -double ecl_rft_node_iget_pressure(const ecl_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_depth(const ecl_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_wrat(const ecl_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_grat(const ecl_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_orat(const ecl_rft_node_type *rft_node, int index); +double rd_rft_node_iget_pressure(const rd_rft_node_type *rft_node, int index); +double rd_rft_node_iget_depth(const rd_rft_node_type *rft_node, int index); +double rd_rft_node_iget_wrat(const rd_rft_node_type *rft_node, int index); +double rd_rft_node_iget_grat(const rd_rft_node_type *rft_node, int index); +double rd_rft_node_iget_orat(const rd_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_swat(const ecl_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_sgas(const ecl_rft_node_type *rft_node, int index); -double ecl_rft_node_iget_soil(const ecl_rft_node_type *rft_node, int index); -void ecl_rft_node_fwrite(const ecl_rft_node_type *rft_node, fortio_type *fortio, - ert_ecl_unit_enum unit_set); -double ecl_rft_node_get_days(const ecl_rft_node_type *rft_node); -int ecl_rft_node_cmp(const ecl_rft_node_type *n1, const ecl_rft_node_type *n2); -bool ecl_rft_node_lt(const ecl_rft_node_type *n1, const ecl_rft_node_type *n2); +double rd_rft_node_iget_swat(const rd_rft_node_type *rft_node, int index); +double rd_rft_node_iget_sgas(const rd_rft_node_type *rft_node, int index); +double rd_rft_node_iget_soil(const rd_rft_node_type *rft_node, int index); +void rd_rft_node_fwrite(const rd_rft_node_type *rft_node, fortio_type *fortio, + ert_rd_unit_enum unit_set); +double rd_rft_node_get_days(const rd_rft_node_type *rft_node); +int rd_rft_node_cmp(const rd_rft_node_type *n1, const rd_rft_node_type *n2); +bool rd_rft_node_lt(const rd_rft_node_type *n1, const rd_rft_node_type *n2); -void ecl_rft_node_append_cell(ecl_rft_node_type *rft_node, - ecl_rft_cell_type *cell); -ecl_rft_node_type *ecl_rft_node_alloc_new(const char *well_name, - const char *data_type_string, - const time_t recording_date, - const double days); +void rd_rft_node_append_cell(rd_rft_node_type *rft_node, + rd_rft_cell_type *cell); +rd_rft_node_type *rd_rft_node_alloc_new(const char *well_name, + const char *data_type_string, + const time_t recording_date, + const double days); -ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type *rft_node); +rd_rft_enum rd_rft_node_get_type(const rd_rft_node_type *rft_node); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_rst_file.h b/lib/include/resdata/rd_rst_file.h index 4a8af63c14..d10fb5c91c 100644 --- a/lib/include/resdata/rd_rst_file.h +++ b/lib/include/resdata/rd_rst_file.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_rst_file.hpp b/lib/include/resdata/rd_rst_file.hpp index 61feb2d994..cdfc09718c 100644 --- a/lib/include/resdata/rd_rst_file.hpp +++ b/lib/include/resdata/rd_rst_file.hpp @@ -1,28 +1,27 @@ -#ifndef ERT_ECL_RST_FILE_H -#define ERT_ECL_RST_FILE_H +#ifndef ERT_RD_RST_FILE_H +#define ERT_RD_RST_FILE_H -#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_rst_file_struct ecl_rst_file_type; +typedef struct rd_rst_file_struct rd_rst_file_type; -ecl_rst_file_type *ecl_rst_file_open_read(const char *filename); -ecl_rst_file_type *ecl_rst_file_open_write(const char *filename); -ecl_rst_file_type *ecl_rst_file_open_append(const char *filename); -ecl_rst_file_type *ecl_rst_file_open_write_seek(const char *filename, - int report_step); -void ecl_rst_file_close(ecl_rst_file_type *rst_file); +rd_rst_file_type *rd_rst_file_open_read(const char *filename); +rd_rst_file_type *rd_rst_file_open_write(const char *filename); +rd_rst_file_type *rd_rst_file_open_append(const char *filename); +rd_rst_file_type *rd_rst_file_open_write_seek(const char *filename, + int report_step); +void rd_rst_file_close(rd_rst_file_type *rst_file); -void ecl_rst_file_start_solution(ecl_rst_file_type *rst_file); -void ecl_rst_file_end_solution(ecl_rst_file_type *rst_file); -void ecl_rst_file_fwrite_header(ecl_rst_file_type *rst_file, int seqnum, - ecl_rsthead_type *rsthead_data); -void ecl_rst_file_add_kw(ecl_rst_file_type *rst_file, - const ecl_kw_type *ecl_kw); -offset_type ecl_rst_file_ftell(const ecl_rst_file_type *rst_file); +void rd_rst_file_start_solution(rd_rst_file_type *rst_file); +void rd_rst_file_end_solution(rd_rst_file_type *rst_file); +void rd_rst_file_fwrite_header(rd_rst_file_type *rst_file, int seqnum, + rd_rsthead_type *rsthead_data); +void rd_rst_file_add_kw(rd_rst_file_type *rst_file, const rd_kw_type *rd_kw); +offset_type rd_rst_file_ftell(const rd_rst_file_type *rst_file); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_rsthead.h b/lib/include/resdata/rd_rsthead.h index 2b87ba8dad..679198fbc8 100644 --- a/lib/include/resdata/rd_rsthead.h +++ b/lib/include/resdata/rd_rsthead.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_rsthead.hpp b/lib/include/resdata/rd_rsthead.hpp index 090f616c15..e553981216 100644 --- a/lib/include/resdata/rd_rsthead.hpp +++ b/lib/include/resdata/rd_rsthead.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_RSTHEAD_H -#define ERT_ECL_RSTHEAD_H +#ifndef ERT_RD_RSTHEAD_H +#define ERT_RD_RSTHEAD_H #ifdef __cplusplus extern "C" { @@ -7,9 +7,9 @@ extern "C" { #include -#include -#include -#include +#include +#include +#include typedef struct { // The report step is from the SEQNUM keyword for unified files, @@ -22,7 +22,7 @@ typedef struct { int version; // 100, 300, 500 (Eclipse300-Thermal) int phase_sum; // Oil = 1 Gas = 2 Water = 4 - ert_ecl_unit_enum unit_system; + ert_rd_unit_enum unit_system; int nx; int ny; @@ -59,26 +59,26 @@ typedef struct { // Properties from the DOUBHEAD keyword: double sim_days; -} ecl_rsthead_type; +} rd_rsthead_type; -void ecl_rsthead_free(ecl_rsthead_type *rsthead); -ecl_rsthead_type *ecl_rsthead_alloc_from_kw(int report_step, - const ecl_kw_type *intehead_kw, - const ecl_kw_type *doubhead_kw, - const ecl_kw_type *logihead_kw); -ecl_rsthead_type *ecl_rsthead_alloc(const ecl_file_view_type *rst_file, - int report_step); -ecl_rsthead_type *ecl_rsthead_alloc_empty(void); -time_t ecl_rsthead_date(const ecl_kw_type *intehead_kw); -void ecl_rsthead_fprintf(const ecl_rsthead_type *header, FILE *stream); -void ecl_rsthead_fprintf_struct(const ecl_rsthead_type *header, FILE *stream); -bool ecl_rsthead_equal(const ecl_rsthead_type *header1, - const ecl_rsthead_type *header2); -double ecl_rsthead_get_sim_days(const ecl_rsthead_type *header); -int ecl_rsthead_get_report_step(const ecl_rsthead_type *header); -time_t ecl_rsthead_get_sim_time(const ecl_rsthead_type *header); -int ecl_rsthead_get_nxconz(const ecl_rsthead_type *rsthead); -int ecl_rsthead_get_ncwmax(const ecl_rsthead_type *rsthead); +void rd_rsthead_free(rd_rsthead_type *rsthead); +rd_rsthead_type *rd_rsthead_alloc_from_kw(int report_step, + const rd_kw_type *intehead_kw, + const rd_kw_type *doubhead_kw, + const rd_kw_type *logihead_kw); +rd_rsthead_type *rd_rsthead_alloc(const rd_file_view_type *rst_file, + int report_step); +rd_rsthead_type *rd_rsthead_alloc_empty(void); +time_t rd_rsthead_date(const rd_kw_type *intehead_kw); +void rd_rsthead_fprintf(const rd_rsthead_type *header, FILE *stream); +void rd_rsthead_fprintf_struct(const rd_rsthead_type *header, FILE *stream); +bool rd_rsthead_equal(const rd_rsthead_type *header1, + const rd_rsthead_type *header2); +double rd_rsthead_get_sim_days(const rd_rsthead_type *header); +int rd_rsthead_get_report_step(const rd_rsthead_type *header); +time_t rd_rsthead_get_sim_time(const rd_rsthead_type *header); +int rd_rsthead_get_nxconz(const rd_rsthead_type *rsthead); +int rd_rsthead_get_ncwmax(const rd_rsthead_type *rsthead); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_smspec.h b/lib/include/resdata/rd_smspec.h index f149c9a8fd..1de6582ebd 100644 --- a/lib/include/resdata/rd_smspec.h +++ b/lib/include/resdata/rd_smspec.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_smspec.hpp b/lib/include/resdata/rd_smspec.hpp index 93b140f675..44836f80ec 100644 --- a/lib/include/resdata/rd_smspec.hpp +++ b/lib/include/resdata/rd_smspec.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_SMSPEC -#define ERT_ECL_SMSPEC +#ifndef ERT_RD_SMSPEC +#define ERT_RD_SMSPEC #include #include @@ -7,50 +7,48 @@ #include #include -#include -#include +#include +#include -typedef struct ecl_smspec_struct ecl_smspec_type; +typedef struct rd_smspec_struct rd_smspec_type; #ifdef __cplusplus #include const std::vector & -ecl_smspec_get_params_default(const ecl_smspec_type *ecl_smspec); -const ecl::smspec_node & -ecl_smspec_get_well_var_node(const ecl_smspec_type *smspec, const char *well, +rd_smspec_get_params_default(const rd_smspec_type *rd_smspec); +const rd::smspec_node &rd_smspec_get_well_var_node(const rd_smspec_type *smspec, + const char *well, + const char *var); +const rd::smspec_node & +rd_smspec_get_group_var_node(const rd_smspec_type *smspec, const char *group, const char *var); -const ecl::smspec_node & -ecl_smspec_get_group_var_node(const ecl_smspec_type *smspec, const char *group, - const char *var); -const ecl::smspec_node & -ecl_smspec_get_field_var_node(const ecl_smspec_type *smspec, const char *var); -const ecl::smspec_node & -ecl_smspec_get_region_var_node(const ecl_smspec_type *ecl_smspec, - const char *region_var, int region_nr); -const ecl::smspec_node & -ecl_smspec_get_misc_var_node(const ecl_smspec_type *ecl_smspec, - const char *var); -const ecl::smspec_node & -ecl_smspec_get_block_var_node(const ecl_smspec_type *ecl_smspec, - const char *block_var, int block_nr); -const ecl::smspec_node & -ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type *ecl_smspec, - const char *block_var, int i, int j, int k); -const ecl::smspec_node & -ecl_smspec_get_well_completion_var_node(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var, - int cell_nr); -const ecl::smspec_node & -ecl_smspec_get_general_var_node(const ecl_smspec_type *smspec, - const char *lookup_kw); -const ecl::smspec_node & -ecl_smspec_iget_node_w_node_index(const ecl_smspec_type *smspec, - int node_index); -const ecl::smspec_node & -ecl_smspec_iget_node_w_params_index(const ecl_smspec_type *smspec, - int params_index); -const ecl::smspec_node &ecl_smspec_iget_node(const ecl_smspec_type *smspec, - int index); +const rd::smspec_node & +rd_smspec_get_field_var_node(const rd_smspec_type *smspec, const char *var); +const rd::smspec_node & +rd_smspec_get_region_var_node(const rd_smspec_type *rd_smspec, + const char *region_var, int region_nr); +const rd::smspec_node & +rd_smspec_get_misc_var_node(const rd_smspec_type *rd_smspec, const char *var); +const rd::smspec_node & +rd_smspec_get_block_var_node(const rd_smspec_type *rd_smspec, + const char *block_var, int block_nr); +const rd::smspec_node & +rd_smspec_get_block_var_node_ijk(const rd_smspec_type *rd_smspec, + const char *block_var, int i, int j, int k); +const rd::smspec_node & +rd_smspec_get_well_completion_var_node(const rd_smspec_type *rd_smspec, + const char *well, const char *var, + int cell_nr); +const rd::smspec_node & +rd_smspec_get_general_var_node(const rd_smspec_type *smspec, + const char *lookup_kw); +const rd::smspec_node & +rd_smspec_iget_node_w_node_index(const rd_smspec_type *smspec, int node_index); +const rd::smspec_node & +rd_smspec_iget_node_w_params_index(const rd_smspec_type *smspec, + int params_index); +const rd::smspec_node &rd_smspec_iget_node(const rd_smspec_type *smspec, + int index); #endif #ifdef __cplusplus @@ -59,167 +57,166 @@ extern "C" { /** These are the different variable types, see table 3.4 in the - ECLIPFE file format docuemntation for naming conventions. + ECLIPSE file format docuemntation for naming conventions. Only the variable types marked with "X" below are supported in the remaining implementation. To add support for a new variable type - the functions smspec_node_alloc(), ecl_smsepec_fread_header() and - ecl_smspec_install_gen_key() must be updated. + the functions smspec_node_alloc(), rd_smsepec_fread_header() and + rd_smspec_install_gen_key() must be updated. */ -int *ecl_smspec_alloc_mapping(const ecl_smspec_type *self, - const ecl_smspec_type *other); -const int *ecl_smspec_get_index_map(const ecl_smspec_type *smspec); -ecl_smspec_var_type ecl_smspec_iget_var_type(const ecl_smspec_type *smspec, - int index); -bool ecl_smspec_needs_num(ecl_smspec_var_type var_type); -bool ecl_smspec_needs_wgname(ecl_smspec_var_type var_type); -const char *ecl_smspec_get_var_type_name(ecl_smspec_var_type var_type); -ecl_smspec_var_type ecl_smspec_identify_var_type(const char *var); -ecl_smspec_type *ecl_smspec_alloc_empty(bool write_mode, - const char *key_join_string); - -ecl_smspec_type *ecl_smspec_alloc_restart_writer( +int *rd_smspec_alloc_mapping(const rd_smspec_type *self, + const rd_smspec_type *other); +const int *rd_smspec_get_index_map(const rd_smspec_type *smspec); +rd_smspec_var_type rd_smspec_iget_var_type(const rd_smspec_type *smspec, + int index); +bool rd_smspec_needs_num(rd_smspec_var_type var_type); +bool rd_smspec_needs_wgname(rd_smspec_var_type var_type); +const char *rd_smspec_get_var_type_name(rd_smspec_var_type var_type); +rd_smspec_var_type rd_smspec_identify_var_type(const char *var); +rd_smspec_type *rd_smspec_alloc_empty(bool write_mode, + const char *key_join_string); + +rd_smspec_type *rd_smspec_alloc_restart_writer( const char *key_join_string, const char *restart_case, int restart_step, time_t sim_start, bool time_in_days, int nx, int ny, int nz); -ecl_smspec_type *ecl_smspec_alloc_writer(const char *key_join_string, - time_t sim_start, bool time_in_days, - int nx, int ny, int nz); -void ecl_smspec_fwrite(const ecl_smspec_type *smspec, const char *ecl_case, - bool fmt_file); - -ecl_smspec_type *ecl_smspec_fread_alloc(const char *header_file, - const char *key_join_string, - bool include_restart); -void ecl_smspec_free(ecl_smspec_type *); - -int ecl_smspec_get_date_day_index(const ecl_smspec_type *smspec); -int ecl_smspec_get_date_month_index(const ecl_smspec_type *smspec); -int ecl_smspec_get_date_year_index(const ecl_smspec_type *smspec); - -int ecl_smspec_get_well_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var); -bool ecl_smspec_has_well_var(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var); - -int ecl_smspec_get_group_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *group, const char *var); -bool ecl_smspec_has_group_var(const ecl_smspec_type *ecl_smspec, - const char *group, const char *var); - -int ecl_smspec_get_field_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *var); -bool ecl_smspec_has_field_var(const ecl_smspec_type *ecl_smspec, - const char *var); - -int ecl_smspec_get_region_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *region_var, - int region_nr); -bool ecl_smspec_has_region_var(const ecl_smspec_type *ecl_smspec, - const char *region_var, int region_nr); - -int ecl_smspec_get_misc_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *var); -bool ecl_smspec_has_misc_var(const ecl_smspec_type *ecl_smspec, +rd_smspec_type *rd_smspec_alloc_writer(const char *key_join_string, + time_t sim_start, bool time_in_days, + int nx, int ny, int nz); +void rd_smspec_fwrite(const rd_smspec_type *smspec, const char *rd_case, + bool fmt_file); + +rd_smspec_type *rd_smspec_fread_alloc(const char *header_file, + const char *key_join_string, + bool include_restart); +void rd_smspec_free(rd_smspec_type *); + +int rd_smspec_get_date_day_index(const rd_smspec_type *smspec); +int rd_smspec_get_date_month_index(const rd_smspec_type *smspec); +int rd_smspec_get_date_year_index(const rd_smspec_type *smspec); + +int rd_smspec_get_well_var_params_index(const rd_smspec_type *rd_smspec, + const char *well, const char *var); +bool rd_smspec_has_well_var(const rd_smspec_type *rd_smspec, const char *well, + const char *var); + +int rd_smspec_get_group_var_params_index(const rd_smspec_type *rd_smspec, + const char *group, const char *var); +bool rd_smspec_has_group_var(const rd_smspec_type *rd_smspec, const char *group, const char *var); -int ecl_smspec_get_block_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *block_var, int block_nr); -bool ecl_smspec_has_block_var(const ecl_smspec_type *ecl_smspec, - const char *block_var, int block_nr); - -int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type *ecl_smspec, - const char *block_var, int i, - int j, int k); -bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type *ecl_smspec, - const char *block_var, int i, int j, int k); - -int ecl_smspec_get_well_completion_var_params_index( - const ecl_smspec_type *ecl_smspec, const char *well, const char *var, +int rd_smspec_get_field_var_params_index(const rd_smspec_type *rd_smspec, + const char *var); +bool rd_smspec_has_field_var(const rd_smspec_type *rd_smspec, const char *var); + +int rd_smspec_get_region_var_params_index(const rd_smspec_type *rd_smspec, + const char *region_var, + int region_nr); +bool rd_smspec_has_region_var(const rd_smspec_type *rd_smspec, + const char *region_var, int region_nr); + +int rd_smspec_get_misc_var_params_index(const rd_smspec_type *rd_smspec, + const char *var); +bool rd_smspec_has_misc_var(const rd_smspec_type *rd_smspec, const char *var); + +int rd_smspec_get_block_var_params_index(const rd_smspec_type *rd_smspec, + const char *block_var, int block_nr); +bool rd_smspec_has_block_var(const rd_smspec_type *rd_smspec, + const char *block_var, int block_nr); + +int rd_smspec_get_block_var_params_index_ijk(const rd_smspec_type *rd_smspec, + const char *block_var, int i, + int j, int k); +bool rd_smspec_has_block_var_ijk(const rd_smspec_type *rd_smspec, + const char *block_var, int i, int j, int k); + +int rd_smspec_get_well_completion_var_params_index( + const rd_smspec_type *rd_smspec, const char *well, const char *var, int cell_nr); -bool ecl_smspec_has_well_completion_var(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var, - int cell_nr); - -int ecl_smspec_get_general_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *lookup_kw); -bool ecl_smspec_has_general_var(const ecl_smspec_type *ecl_smspec, - const char *lookup_kw); -const char *ecl_smspec_get_general_var_unit(const ecl_smspec_type *ecl_smspec, - const char *lookup_kw); - -void ecl_smspec_select_matching_general_var_list(const ecl_smspec_type *smspec, - const char *pattern, - stringlist_type *keys); +bool rd_smspec_has_well_completion_var(const rd_smspec_type *rd_smspec, + const char *well, const char *var, + int cell_nr); + +int rd_smspec_get_general_var_params_index(const rd_smspec_type *rd_smspec, + const char *lookup_kw); +bool rd_smspec_has_general_var(const rd_smspec_type *rd_smspec, + const char *lookup_kw); +const char *rd_smspec_get_general_var_unit(const rd_smspec_type *rd_smspec, + const char *lookup_kw); + +void rd_smspec_select_matching_general_var_list(const rd_smspec_type *smspec, + const char *pattern, + stringlist_type *keys); stringlist_type * -ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type *smspec, +rd_smspec_alloc_matching_general_var_list(const rd_smspec_type *smspec, + const char *pattern); + +int rd_smspec_get_time_seconds(const rd_smspec_type *rd_smspec); +int rd_smspec_get_time_index(const rd_smspec_type *rd_smspec); +time_t rd_smspec_get_start_time(const rd_smspec_type *); +bool rd_smspec_get_formatted(const rd_smspec_type *rd_smspec); +const char *rd_smspec_get_header_file(const rd_smspec_type *rd_smspec); +stringlist_type *rd_smspec_alloc_well_list(const rd_smspec_type *smspec, const char *pattern); - -int ecl_smspec_get_time_seconds(const ecl_smspec_type *ecl_smspec); -int ecl_smspec_get_time_index(const ecl_smspec_type *ecl_smspec); -time_t ecl_smspec_get_start_time(const ecl_smspec_type *); -bool ecl_smspec_get_formatted(const ecl_smspec_type *ecl_smspec); -const char *ecl_smspec_get_header_file(const ecl_smspec_type *ecl_smspec); -stringlist_type *ecl_smspec_alloc_well_list(const ecl_smspec_type *smspec, +stringlist_type *rd_smspec_alloc_group_list(const rd_smspec_type *smspec, const char *pattern); -stringlist_type *ecl_smspec_alloc_group_list(const ecl_smspec_type *smspec, - const char *pattern); -stringlist_type *ecl_smspec_alloc_well_var_list(const ecl_smspec_type *smspec); -const char *ecl_smspec_get_simulation_path(const ecl_smspec_type *ecl_smspec); -int ecl_smspec_get_first_step(const ecl_smspec_type *ecl_smspec); -int ecl_smspec_get_restart_step(const ecl_smspec_type *ecl_smspec); -const char *ecl_smspec_get_restart_case(const ecl_smspec_type *ecl_smspec); -const char *ecl_smspec_get_join_string(const ecl_smspec_type *smspec); - -const int *ecl_smspec_get_grid_dims(const ecl_smspec_type *smspec); -int ecl_smspec_get_params_size(const ecl_smspec_type *smspec); -int ecl_smspec_num_nodes(const ecl_smspec_type *smspec); - -char *ecl_smspec_alloc_well_key(const ecl_smspec_type *smspec, - const char *keyword, const char *wgname); -bool ecl_smspec_equal(const ecl_smspec_type *self, - const ecl_smspec_type *other); - -// void ecl_smspec_sort( ecl_smspec_type * smspec ); -ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_smspec_type *smspec); +stringlist_type *rd_smspec_alloc_well_var_list(const rd_smspec_type *smspec); +const char *rd_smspec_get_simulation_path(const rd_smspec_type *rd_smspec); +int rd_smspec_get_first_step(const rd_smspec_type *rd_smspec); +int rd_smspec_get_restart_step(const rd_smspec_type *rd_smspec); +const char *rd_smspec_get_restart_case(const rd_smspec_type *rd_smspec); +const char *rd_smspec_get_join_string(const rd_smspec_type *smspec); + +const int *rd_smspec_get_grid_dims(const rd_smspec_type *smspec); +int rd_smspec_get_params_size(const rd_smspec_type *smspec); +int rd_smspec_num_nodes(const rd_smspec_type *smspec); + +char *rd_smspec_alloc_well_key(const rd_smspec_type *smspec, + const char *keyword, const char *wgname); +bool rd_smspec_equal(const rd_smspec_type *self, const rd_smspec_type *other); + +// void rd_smspec_sort( rd_smspec_type * smspec ); +ert_rd_unit_enum rd_smspec_get_unit_system(const rd_smspec_type *smspec); #ifdef __cplusplus } #endif -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const ecl::smspec_node &node); -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, int num, - const char *unit, - float default_value); -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, - const char *unit, - float default_value); -const ecl::smspec_node * -ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, const char *keyword, - const char *wgname, const char *unit, float default_value); -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, - const char *wgname, int num, - const char *unit, - float default_value); -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, int num, - const char *unit, - float default_value); - -const ecl::smspec_node * -ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, int params_index, - const char *keyword, const char *wgname, int num, - const char *unit, float default_value); - -const ecl::smspec_node * -ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, int params_index, - const char *keyword, const char *wgname, int num, - const char *unit, const char *lgr, int lgr_i, int lgr_j, - int lgr_k, float default_value); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const rd::smspec_node &node); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, int num, + const char *unit, + float default_value); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, const char *unit, + float default_value); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, + const char *wgname, const char *unit, + float default_value); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, + const char *wgname, int num, + const char *unit, + float default_value); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, int num, + const char *unit, + float default_value); + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + int params_index, const char *keyword, + const char *wgname, int num, + const char *unit, + float default_value); + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + int params_index, const char *keyword, + const char *wgname, int num, + const char *unit, const char *lgr, + int lgr_i, int lgr_j, int lgr_k, + float default_value); #endif diff --git a/lib/include/resdata/rd_subsidence.h b/lib/include/resdata/rd_subsidence.h index 18bda01a5c..af04dd8dfa 100644 --- a/lib/include/resdata/rd_subsidence.h +++ b/lib/include/resdata/rd_subsidence.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_subsidence.hpp b/lib/include/resdata/rd_subsidence.hpp index b5f3d8441d..04e06e3b61 100644 --- a/lib/include/resdata/rd_subsidence.hpp +++ b/lib/include/resdata/rd_subsidence.hpp @@ -1,46 +1,46 @@ -#ifndef ERT_ECL_SUBSIDENCE_H -#define ERT_ECL_SUBSIDENCE_H +#ifndef ERT_RD_SUBSIDENCE_H +#define ERT_RD_SUBSIDENCE_H #ifdef __cplusplus extern "C" { #endif -#include -#include -#include -#include +#include +#include +#include +#include -typedef struct ecl_subsidence_struct ecl_subsidence_type; -typedef struct ecl_subsidence_survey_struct ecl_subsidence_survey_type; +typedef struct rd_subsidence_struct rd_subsidence_type; +typedef struct rd_subsidence_survey_struct rd_subsidence_survey_type; -void ecl_subsidence_free(ecl_subsidence_type *ecl_subsidence_config); -ecl_subsidence_type *ecl_subsidence_alloc(const ecl_grid_type *ecl_grid, - const ecl_file_type *init_file); -ecl_subsidence_survey_type * -ecl_subsidence_add_survey_PRESSURE(ecl_subsidence_type *subsidence, - const char *name, - const ecl_file_view_type *restart_view); +void rd_subsidence_free(rd_subsidence_type *rd_subsidence_config); +rd_subsidence_type *rd_subsidence_alloc(const rd_grid_type *rd_grid, + const rd_file_type *init_file); +rd_subsidence_survey_type * +rd_subsidence_add_survey_PRESSURE(rd_subsidence_type *subsidence, + const char *name, + const rd_file_view_type *restart_view); -bool ecl_subsidence_has_survey(const ecl_subsidence_type *subsidence, - const char *name); -double ecl_subsidence_eval(const ecl_subsidence_type *subsidence, - const char *base, const char *monitor, - ecl_region_type *region, double utm_x, double utm_y, - double depth, double compressibility, - double poisson_ratio); +bool rd_subsidence_has_survey(const rd_subsidence_type *subsidence, + const char *name); +double rd_subsidence_eval(const rd_subsidence_type *subsidence, + const char *base, const char *monitor, + rd_region_type *region, double utm_x, double utm_y, + double depth, double compressibility, + double poisson_ratio); -double ecl_subsidence_eval_geertsma(const ecl_subsidence_type *subsidence, - const char *base, const char *monitor, - ecl_region_type *region, double utm_x, - double utm_y, double depth, - double youngs_modulus, double poisson_ratio, - double seabed); +double rd_subsidence_eval_geertsma(const rd_subsidence_type *subsidence, + const char *base, const char *monitor, + rd_region_type *region, double utm_x, + double utm_y, double depth, + double youngs_modulus, double poisson_ratio, + double seabed); -double ecl_subsidence_eval_geertsma_rporv(const ecl_subsidence_type *subsidence, - const char *base, const char *monitor, - ecl_region_type *region, double utm_x, - double utm_y, double depth, - double youngs_modulus, - double poisson_ratio, double seabed); +double rd_subsidence_eval_geertsma_rporv(const rd_subsidence_type *subsidence, + const char *base, const char *monitor, + rd_region_type *region, double utm_x, + double utm_y, double depth, + double youngs_modulus, + double poisson_ratio, double seabed); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_sum.h b/lib/include/resdata/rd_sum.h index e94fb1da0e..07a5553332 100644 --- a/lib/include/resdata/rd_sum.h +++ b/lib/include/resdata/rd_sum.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_sum.hpp b/lib/include/resdata/rd_sum.hpp index 6542182cef..eb01070fe6 100644 --- a/lib/include/resdata/rd_sum.hpp +++ b/lib/include/resdata/rd_sum.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_SUM_H -#define ERT_ECL_SUM_H +#ifndef ERT_RD_SUM_H +#define ERT_RD_SUM_H #include #include @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -30,291 +30,282 @@ typedef struct { const char *date_header; const char *date_dash; const char *value_dash; -} ecl_sum_fmt_type; - -typedef struct ecl_sum_vector_struct ecl_sum_vector_type; - -typedef struct ecl_sum_struct ecl_sum_type; - -void ecl_sum_fmt_init_summary_x(const ecl_sum_type *ecl_sum, - ecl_sum_fmt_type *fmt); -double ecl_sum_get_from_sim_time(const ecl_sum_type *ecl_sum, time_t sim_time, - const ecl::smspec_node *node); -double ecl_sum_get_from_sim_days(const ecl_sum_type *ecl_sum, double sim_days, - const ecl::smspec_node *node); -double ecl_sum_time2days(const ecl_sum_type *ecl_sum, time_t sim_time); - -void ecl_sum_set_unified(ecl_sum_type *ecl_sum, bool unified); -void ecl_sum_set_fmt_case(ecl_sum_type *ecl_sum, bool fmt_case); - -int ecl_sum_get_report_step_from_time(const ecl_sum_type *sum, time_t sim_time); -int ecl_sum_get_report_step_from_days(const ecl_sum_type *sum, double sim_days); -bool ecl_sum_check_sim_time(const ecl_sum_type *sum, time_t sim_time); -bool ecl_sum_check_sim_days(const ecl_sum_type *sum, double sim_days); -const char *ecl_sum_get_keyword(const ecl_sum_type *sum, const char *gen_key); -const char *ecl_sum_get_wgname(const ecl_sum_type *sum, const char *gen_key); -const char *ecl_sum_get_unit(const ecl_sum_type *sum, const char *gen_key); -int ecl_sum_get_num(const ecl_sum_type *sum, const char *gen_key); - -double ecl_sum_iget(const ecl_sum_type *ecl_sum, int time_index, - int param_index); -int ecl_sum_iget_num(const ecl_sum_type *sum, int param_index); -const char *ecl_sum_iget_wgname(const ecl_sum_type *sum, int param_index); -const char *ecl_sum_iget_keyword(const ecl_sum_type *sum, int param_index); -int ecl_sum_get_data_length(const ecl_sum_type *ecl_sum); -double ecl_sum_iget_from_sim_time(const ecl_sum_type *ecl_sum, time_t sim_time, - int param_index); -double ecl_sum_iget_from_sim_days(const ecl_sum_type *ecl_sum, double sim_days, - int param_index); - -void ecl_sum_summarize(const ecl_sum_type *ecl_sum, FILE *stream); -bool ecl_sum_general_is_total(const ecl_sum_type *ecl_sum, const char *gen_key); -void ecl_sum_free_data(ecl_sum_type *); -void ecl_sum_free__(void *); -void ecl_sum_free(ecl_sum_type *); -ecl_sum_type *ecl_sum_fread_alloc(const char *, - const stringlist_type *data_files, - const char *key_join_string, - bool include_restart, bool lazy_load, - int file_options); -ecl_sum_type *ecl_sum_fread_alloc_case(const char *, - const char *key_join_string); -ecl_sum_type *ecl_sum_fread_alloc_case__(const char *input_file, - const char *key_join_string, - bool include_restart); -ecl_sum_type *ecl_sum_fread_alloc_case2__(const char *, - const char *key_join_string, - bool include_restart, bool lazy_load, - int file_options); -ecl_sum_type *ecl_sum_alloc_resample(const ecl_sum_type *ecl_sum, - const char *ecl_case, - const time_t_vector_type *times, - bool lower_extrapolation, - bool upper_extrapolation); -bool ecl_sum_case_exists(const char *input_file); +} rd_sum_fmt_type; + +typedef struct rd_sum_vector_struct rd_sum_vector_type; + +typedef struct rd_sum_struct rd_sum_type; + +void rd_sum_fmt_init_summary_x(const rd_sum_type *rd_sum, rd_sum_fmt_type *fmt); +double rd_sum_get_from_sim_time(const rd_sum_type *rd_sum, time_t sim_time, + const rd::smspec_node *node); +double rd_sum_get_from_sim_days(const rd_sum_type *rd_sum, double sim_days, + const rd::smspec_node *node); +double rd_sum_time2days(const rd_sum_type *rd_sum, time_t sim_time); + +void rd_sum_set_unified(rd_sum_type *rd_sum, bool unified); +void rd_sum_set_fmt_case(rd_sum_type *rd_sum, bool fmt_case); + +int rd_sum_get_report_step_from_time(const rd_sum_type *sum, time_t sim_time); +int rd_sum_get_report_step_from_days(const rd_sum_type *sum, double sim_days); +bool rd_sum_check_sim_time(const rd_sum_type *sum, time_t sim_time); +bool rd_sum_check_sim_days(const rd_sum_type *sum, double sim_days); +const char *rd_sum_get_keyword(const rd_sum_type *sum, const char *gen_key); +const char *rd_sum_get_wgname(const rd_sum_type *sum, const char *gen_key); +const char *rd_sum_get_unit(const rd_sum_type *sum, const char *gen_key); +int rd_sum_get_num(const rd_sum_type *sum, const char *gen_key); + +double rd_sum_iget(const rd_sum_type *rd_sum, int time_index, int param_index); +int rd_sum_iget_num(const rd_sum_type *sum, int param_index); +const char *rd_sum_iget_wgname(const rd_sum_type *sum, int param_index); +const char *rd_sum_iget_keyword(const rd_sum_type *sum, int param_index); +int rd_sum_get_data_length(const rd_sum_type *rd_sum); +double rd_sum_iget_from_sim_time(const rd_sum_type *rd_sum, time_t sim_time, + int param_index); +double rd_sum_iget_from_sim_days(const rd_sum_type *rd_sum, double sim_days, + int param_index); + +void rd_sum_summarize(const rd_sum_type *rd_sum, FILE *stream); +bool rd_sum_general_is_total(const rd_sum_type *rd_sum, const char *gen_key); +void rd_sum_free_data(rd_sum_type *); +void rd_sum_free__(void *); +void rd_sum_free(rd_sum_type *); +rd_sum_type *rd_sum_fread_alloc(const char *, const stringlist_type *data_files, + const char *key_join_string, + bool include_restart, bool lazy_load, + int file_options); +rd_sum_type *rd_sum_fread_alloc_case(const char *, const char *key_join_string); +rd_sum_type *rd_sum_fread_alloc_case__(const char *input_file, + const char *key_join_string, + bool include_restart); +rd_sum_type *rd_sum_fread_alloc_case2__(const char *, + const char *key_join_string, + bool include_restart, bool lazy_load, + int file_options); +rd_sum_type *rd_sum_alloc_resample(const rd_sum_type *rd_sum, + const char *rd_case, + const time_t_vector_type *times, + bool lower_extrapolation, + bool upper_extrapolation); +bool rd_sum_case_exists(const char *input_file); /* Accessor functions : */ -double ecl_sum_get_well_var(const ecl_sum_type *ecl_sum, int time_index, - const char *well, const char *var); -bool ecl_sum_has_well_var(const ecl_sum_type *ecl_sum, const char *well, +double rd_sum_get_well_var(const rd_sum_type *rd_sum, int time_index, + const char *well, const char *var); +bool rd_sum_has_well_var(const rd_sum_type *rd_sum, const char *well, + const char *var); +double rd_sum_get_well_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *well, + const char *var); +double rd_sum_get_well_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *well, + const char *var); + +double rd_sum_get_group_var(const rd_sum_type *rd_sum, int time_index, + const char *group, const char *var); +bool rd_sum_has_group_var(const rd_sum_type *rd_sum, const char *group, const char *var); -double ecl_sum_get_well_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *well, - const char *var); -double ecl_sum_get_well_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *well, - const char *var); - -double ecl_sum_get_group_var(const ecl_sum_type *ecl_sum, int time_index, - const char *group, const char *var); -bool ecl_sum_has_group_var(const ecl_sum_type *ecl_sum, const char *group, - const char *var); -double ecl_sum_get_field_var(const ecl_sum_type *ecl_sum, int time_index, - const char *var); -bool ecl_sum_has_field_var(const ecl_sum_type *ecl_sum, const char *var); -double ecl_sum_get_field_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *var); -double ecl_sum_get_field_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *var); - -double ecl_sum_get_block_var(const ecl_sum_type *ecl_sum, int time_index, - const char *block_var, int block_nr); -int ecl_sum_get_block_var_index(const ecl_sum_type *ecl_sum, - const char *block_var, int block_nr); -bool ecl_sum_has_block_var(const ecl_sum_type *ecl_sum, const char *block_var, - int block_nr); -double ecl_sum_get_block_var_ijk(const ecl_sum_type *ecl_sum, int time_index, - const char *block_var, int i, int j, int k); -int ecl_sum_get_block_var_index_ijk(const ecl_sum_type *ecl_sum, - const char *block_var, int i, int j, int k); -bool ecl_sum_has_block_var_ijk(const ecl_sum_type *ecl_sum, - const char *block_var, int i, int j, int k); - -double ecl_sum_get_region_var(const ecl_sum_type *ecl_sum, int time_index, - const char *var, int region_nr); -bool ecl_sum_has_region_var(const ecl_sum_type *ecl_sum, const char *var, - int region_nr); - -double ecl_sum_get_misc_var(const ecl_sum_type *ecl_sum, int time_index, +double rd_sum_get_field_var(const rd_sum_type *rd_sum, int time_index, const char *var); -int ecl_sum_get_misc_var_index(const ecl_sum_type *ecl_sum, const char *var); -bool ecl_sum_has_misc_var(const ecl_sum_type *ecl_sum, const char *var); - -double ecl_sum_get_well_completion_var(const ecl_sum_type *ecl_sum, - int time_index, const char *well, - const char *var, int cell_nr); -int ecl_sum_get_well_completion_var_index(const ecl_sum_type *ecl_sum, - const char *well, const char *var, - int cell_nr); -bool ecl_sum_has_well_completion_var(const ecl_sum_type *ecl_sum, - const char *well, const char *var, - int cell_nr); - -double ecl_sum_get_general_var(const ecl_sum_type *ecl_sum, int time_index, - const char *lookup_kw); -int ecl_sum_get_general_var_params_index(const ecl_sum_type *ecl_sum, - const char *lookup_kw); -const ecl::smspec_node * -ecl_sum_get_general_var_node(const ecl_sum_type *ecl_sum, - const char *lookup_kw); -bool ecl_sum_has_general_var(const ecl_sum_type *ecl_sum, - const char *lookup_kw); -bool ecl_sum_has_key(const ecl_sum_type *ecl_sum, const char *lookup_kw); -double ecl_sum_get_general_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *var); -double ecl_sum_get_general_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *var); -const char *ecl_sum_get_general_var_unit(const ecl_sum_type *ecl_sum, - const char *var); -ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type *ecl_sum); - -void ecl_sum_fprintf(const ecl_sum_type *, FILE *, const stringlist_type *, - bool report_only, const ecl_sum_fmt_type *fmt); +bool rd_sum_has_field_var(const rd_sum_type *rd_sum, const char *var); +double rd_sum_get_field_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *var); +double rd_sum_get_field_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *var); + +double rd_sum_get_block_var(const rd_sum_type *rd_sum, int time_index, + const char *block_var, int block_nr); +int rd_sum_get_block_var_index(const rd_sum_type *rd_sum, const char *block_var, + int block_nr); +bool rd_sum_has_block_var(const rd_sum_type *rd_sum, const char *block_var, + int block_nr); +double rd_sum_get_block_var_ijk(const rd_sum_type *rd_sum, int time_index, + const char *block_var, int i, int j, int k); +int rd_sum_get_block_var_index_ijk(const rd_sum_type *rd_sum, + const char *block_var, int i, int j, int k); +bool rd_sum_has_block_var_ijk(const rd_sum_type *rd_sum, const char *block_var, + int i, int j, int k); + +double rd_sum_get_region_var(const rd_sum_type *rd_sum, int time_index, + const char *var, int region_nr); +bool rd_sum_has_region_var(const rd_sum_type *rd_sum, const char *var, + int region_nr); + +double rd_sum_get_misc_var(const rd_sum_type *rd_sum, int time_index, + const char *var); +int rd_sum_get_misc_var_index(const rd_sum_type *rd_sum, const char *var); +bool rd_sum_has_misc_var(const rd_sum_type *rd_sum, const char *var); + +double rd_sum_get_well_completion_var(const rd_sum_type *rd_sum, int time_index, + const char *well, const char *var, + int cell_nr); +int rd_sum_get_well_completion_var_index(const rd_sum_type *rd_sum, + const char *well, const char *var, + int cell_nr); +bool rd_sum_has_well_completion_var(const rd_sum_type *rd_sum, const char *well, + const char *var, int cell_nr); + +double rd_sum_get_general_var(const rd_sum_type *rd_sum, int time_index, + const char *lookup_kw); +int rd_sum_get_general_var_params_index(const rd_sum_type *rd_sum, + const char *lookup_kw); +const rd::smspec_node *rd_sum_get_general_var_node(const rd_sum_type *rd_sum, + const char *lookup_kw); +bool rd_sum_has_general_var(const rd_sum_type *rd_sum, const char *lookup_kw); +bool rd_sum_has_key(const rd_sum_type *rd_sum, const char *lookup_kw); +double rd_sum_get_general_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *var); +double rd_sum_get_general_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *var); +const char *rd_sum_get_general_var_unit(const rd_sum_type *rd_sum, + const char *var); +ert_rd_unit_enum rd_sum_get_unit_system(const rd_sum_type *rd_sum); + +void rd_sum_fprintf(const rd_sum_type *, FILE *, const stringlist_type *, + bool report_only, const rd_sum_fmt_type *fmt); /* Time related functions */ -int ecl_sum_get_restart_step(const ecl_sum_type *ecl_sum); -int ecl_sum_get_first_gt(const ecl_sum_type *ecl_sum, int param_index, - double limit); -int ecl_sum_get_first_lt(const ecl_sum_type *ecl_sum, int param_index, - double limit); -int ecl_sum_get_last_report_step(const ecl_sum_type *ecl_sum); -int ecl_sum_get_first_report_step(const ecl_sum_type *ecl_sum); -bool ecl_sum_has_report_step(const ecl_sum_type *ecl_sum, int report_step); -time_t ecl_sum_get_report_time(const ecl_sum_type *ecl_sum, int report_step); -time_t ecl_sum_iget_sim_time(const ecl_sum_type *ecl_sum, int index); -double ecl_sum_iget_sim_days(const ecl_sum_type *ecl_sum, int time_index); -int ecl_sum_iget_report_step(const ecl_sum_type *ecl_sum, int internal_index); -double ecl_sum_iget_general_var(const ecl_sum_type *ecl_sum, int internal_index, - const char *lookup_kw); - -double_vector_type *ecl_sum_alloc_data_vector(const ecl_sum_type *ecl_sum, - int data_index, bool report_only); -time_t_vector_type *ecl_sum_alloc_time_vector(const ecl_sum_type *ecl_sum, - bool report_only); -time_t ecl_sum_get_data_start(const ecl_sum_type *ecl_sum); -time_t ecl_sum_get_end_time(const ecl_sum_type *ecl_sum); -time_t ecl_sum_get_start_time(const ecl_sum_type *); - -const char *ecl_sum_get_base(const ecl_sum_type *ecl_sum); -const char *ecl_sum_get_path(const ecl_sum_type *ecl_sum); -const char *ecl_sum_get_abs_path(const ecl_sum_type *ecl_sum); -const ecl_sum_type *ecl_sum_get_restart_case(const ecl_sum_type *ecl_sum); -const char *ecl_sum_get_case(const ecl_sum_type *); -bool ecl_sum_same_case(const ecl_sum_type *ecl_sum, const char *input_file); - -void ecl_sum_resample_from_sim_days(const ecl_sum_type *ecl_sum, - const double_vector_type *sim_days, - double_vector_type *value, - const char *gen_key); -void ecl_sum_resample_from_sim_time(const ecl_sum_type *ecl_sum, - const time_t_vector_type *sim_time, - double_vector_type *value, - const char *gen_key); -time_t ecl_sum_time_from_days(const ecl_sum_type *ecl_sum, double sim_days); -double ecl_sum_days_from_time(const ecl_sum_type *ecl_sum, time_t sim_time); -double ecl_sum_get_sim_length(const ecl_sum_type *ecl_sum); -double ecl_sum_get_first_day(const ecl_sum_type *ecl_sum); - -stringlist_type *ecl_sum_alloc_well_list(const ecl_sum_type *ecl_sum, +int rd_sum_get_restart_step(const rd_sum_type *rd_sum); +int rd_sum_get_first_gt(const rd_sum_type *rd_sum, int param_index, + double limit); +int rd_sum_get_first_lt(const rd_sum_type *rd_sum, int param_index, + double limit); +int rd_sum_get_last_report_step(const rd_sum_type *rd_sum); +int rd_sum_get_first_report_step(const rd_sum_type *rd_sum); +bool rd_sum_has_report_step(const rd_sum_type *rd_sum, int report_step); +time_t rd_sum_get_report_time(const rd_sum_type *rd_sum, int report_step); +time_t rd_sum_iget_sim_time(const rd_sum_type *rd_sum, int index); +double rd_sum_iget_sim_days(const rd_sum_type *rd_sum, int time_index); +int rd_sum_iget_report_step(const rd_sum_type *rd_sum, int internal_index); +double rd_sum_iget_general_var(const rd_sum_type *rd_sum, int internal_index, + const char *lookup_kw); + +double_vector_type *rd_sum_alloc_data_vector(const rd_sum_type *rd_sum, + int data_index, bool report_only); +time_t_vector_type *rd_sum_alloc_time_vector(const rd_sum_type *rd_sum, + bool report_only); +time_t rd_sum_get_data_start(const rd_sum_type *rd_sum); +time_t rd_sum_get_end_time(const rd_sum_type *rd_sum); +time_t rd_sum_get_start_time(const rd_sum_type *); + +const char *rd_sum_get_base(const rd_sum_type *rd_sum); +const char *rd_sum_get_path(const rd_sum_type *rd_sum); +const char *rd_sum_get_abs_path(const rd_sum_type *rd_sum); +const rd_sum_type *rd_sum_get_restart_case(const rd_sum_type *rd_sum); +const char *rd_sum_get_case(const rd_sum_type *); +bool rd_sum_same_case(const rd_sum_type *rd_sum, const char *input_file); + +void rd_sum_resample_from_sim_days(const rd_sum_type *rd_sum, + const double_vector_type *sim_days, + double_vector_type *value, + const char *gen_key); +void rd_sum_resample_from_sim_time(const rd_sum_type *rd_sum, + const time_t_vector_type *sim_time, + double_vector_type *value, + const char *gen_key); +time_t rd_sum_time_from_days(const rd_sum_type *rd_sum, double sim_days); +double rd_sum_days_from_time(const rd_sum_type *rd_sum, time_t sim_time); +double rd_sum_get_sim_length(const rd_sum_type *rd_sum); +double rd_sum_get_first_day(const rd_sum_type *rd_sum); + +stringlist_type *rd_sum_alloc_well_list(const rd_sum_type *rd_sum, + const char *pattern); +stringlist_type *rd_sum_alloc_group_list(const rd_sum_type *rd_sum, const char *pattern); -stringlist_type *ecl_sum_alloc_group_list(const ecl_sum_type *ecl_sum, - const char *pattern); -stringlist_type *ecl_sum_alloc_well_var_list(const ecl_sum_type *ecl_sum); +stringlist_type *rd_sum_alloc_well_var_list(const rd_sum_type *rd_sum); stringlist_type * -ecl_sum_alloc_matching_general_var_list(const ecl_sum_type *ecl_sum, - const char *pattern); -void ecl_sum_select_matching_general_var_list(const ecl_sum_type *ecl_sum, - const char *pattern, - stringlist_type *keys); -ecl_smspec_type *ecl_sum_get_smspec(const ecl_sum_type *ecl_sum); -ecl_smspec_var_type ecl_sum_identify_var_type(const char *var); -ecl_smspec_var_type ecl_sum_get_var_type(const ecl_sum_type *ecl_sum, - const char *gen_key); -bool ecl_sum_var_is_rate(const ecl_sum_type *ecl_sum, const char *gen_key); -bool ecl_sum_var_is_total(const ecl_sum_type *ecl_sum, const char *gen_key); - -int ecl_sum_iget_report_end(const ecl_sum_type *ecl_sum, int report_step); -ecl_sum_type * -ecl_sum_alloc_restart_writer2(const char *ecl_case, const char *restart_case, - int restart_step, bool fmt_output, bool unified, - const char *key_join_string, time_t sim_start, - bool time_in_days, int nx, int ny, int nz); -void ecl_sum_set_case(ecl_sum_type *ecl_sum, const char *input_arg); - -ecl_sum_type *ecl_sum_alloc_restart_writer(const char *ecl_case, - const char *restart_case, - bool fmt_output, bool unified, - const char *key_join_string, - time_t sim_start, bool time_in_days, - int nx, int ny, int nz); -ecl_sum_type *ecl_sum_alloc_writer(const char *ecl_case, bool fmt_output, - bool unified, const char *key_join_string, - time_t sim_start, bool time_in_days, int nx, - int ny, int nz); -void ecl_sum_fwrite(const ecl_sum_type *ecl_sum); -bool ecl_sum_can_write(const ecl_sum_type *ecl_sum); -void ecl_sum_fwrite_smspec(const ecl_sum_type *ecl_sum); -const ecl::smspec_node *ecl_sum_add_smspec_node(ecl_sum_type *ecl_sum, - const ecl::smspec_node *node); -const ecl::smspec_node *ecl_sum_add_var(ecl_sum_type *ecl_sum, - const char *keyword, const char *wgname, - int num, const char *unit, - float default_value); -ecl_sum_tstep_type *ecl_sum_add_tstep(ecl_sum_type *ecl_sum, int report_step, - double sim_seconds); - -bool ecl_sum_is_oil_producer(const ecl_sum_type *ecl_sum, const char *well); -char *ecl_sum_alloc_well_key(const ecl_sum_type *ecl_sum, const char *keyword, - const char *wgname); -bool ecl_sum_report_step_equal(const ecl_sum_type *ecl_sum1, - const ecl_sum_type *ecl_sum2); -bool ecl_sum_report_step_compatible(const ecl_sum_type *ecl_sum1, - const ecl_sum_type *ecl_sum2); -void ecl_sum_export_csv(const ecl_sum_type *ecl_sum, const char *filename, - const stringlist_type *var_list, - const char *date_format, const char *sep); - -double_vector_type *ecl_sum_alloc_seconds_solution(const ecl_sum_type *ecl_sum, - const char *gen_key, - double cmp_value, - bool rates_clamp_lower); -double_vector_type *ecl_sum_alloc_days_solution(const ecl_sum_type *ecl_sum, - const char *gen_key, - double cmp_value, - bool rates_clamp_lower); -time_t_vector_type *ecl_sum_alloc_time_solution(const ecl_sum_type *ecl_sum, - const char *gen_key, - double cmp_value, - bool rates_clamp_lower); - -double ecl_sum_iget_last_value(const ecl_sum_type *ecl_sum, int param_index); -double ecl_sum_get_last_value_gen_key(const ecl_sum_type *ecl_sum, - const char *gen_key); -double ecl_sum_get_last_value_node(const ecl_sum_type *ecl_sum, - const ecl::smspec_node *node); -double ecl_sum_iget_first_value(const ecl_sum_type *ecl_sum, int param_index); -double ecl_sum_get_first_value_gen_key(const ecl_sum_type *ecl_sum, +rd_sum_alloc_matching_general_var_list(const rd_sum_type *rd_sum, + const char *pattern); +void rd_sum_select_matching_general_var_list(const rd_sum_type *rd_sum, + const char *pattern, + stringlist_type *keys); +rd_smspec_type *rd_sum_get_smspec(const rd_sum_type *rd_sum); +rd_smspec_var_type rd_sum_identify_var_type(const char *var); +rd_smspec_var_type rd_sum_get_var_type(const rd_sum_type *rd_sum, const char *gen_key); -double ecl_sum_get_first_value_node(const ecl_sum_type *ecl_sum, - const ecl::smspec_node *node); - -void ecl_sum_init_datetime64_vector(const ecl_sum_type *ecl_sum, int64_t *data, - int multiplier); -void ecl_sum_init_double_vector_interp(const ecl_sum_type *ecl_sum, - const char *gen_key, - const time_t_vector_type *time_points, - double *data); -void ecl_sum_init_double_vector(const ecl_sum_type *ecl_sum, - const char *gen_key, double *data); -void ecl_sum_init_double_frame(const ecl_sum_type *ecl_sum, - const ecl_sum_vector_type *keywords, - double *data); -void ecl_sum_init_double_frame_interp(const ecl_sum_type *ecl_sum, - const ecl_sum_vector_type *keywords, +bool rd_sum_var_is_rate(const rd_sum_type *rd_sum, const char *gen_key); +bool rd_sum_var_is_total(const rd_sum_type *rd_sum, const char *gen_key); + +int rd_sum_iget_report_end(const rd_sum_type *rd_sum, int report_step); +rd_sum_type * +rd_sum_alloc_restart_writer2(const char *rd_case, const char *restart_case, + int restart_step, bool fmt_output, bool unified, + const char *key_join_string, time_t sim_start, + bool time_in_days, int nx, int ny, int nz); +void rd_sum_set_case(rd_sum_type *rd_sum, const char *input_arg); + +rd_sum_type *rd_sum_alloc_restart_writer(const char *rd_case, + const char *restart_case, + bool fmt_output, bool unified, + const char *key_join_string, + time_t sim_start, bool time_in_days, + int nx, int ny, int nz); +rd_sum_type *rd_sum_alloc_writer(const char *rd_case, bool fmt_output, + bool unified, const char *key_join_string, + time_t sim_start, bool time_in_days, int nx, + int ny, int nz); +void rd_sum_fwrite(const rd_sum_type *rd_sum); +bool rd_sum_can_write(const rd_sum_type *rd_sum); +void rd_sum_fwrite_smspec(const rd_sum_type *rd_sum); +const rd::smspec_node *rd_sum_add_smspec_node(rd_sum_type *rd_sum, + const rd::smspec_node *node); +const rd::smspec_node *rd_sum_add_var(rd_sum_type *rd_sum, const char *keyword, + const char *wgname, int num, + const char *unit, float default_value); +rd_sum_tstep_type *rd_sum_add_tstep(rd_sum_type *rd_sum, int report_step, + double sim_seconds); + +bool rd_sum_is_oil_producer(const rd_sum_type *rd_sum, const char *well); +char *rd_sum_alloc_well_key(const rd_sum_type *rd_sum, const char *keyword, + const char *wgname); +bool rd_sum_report_step_equal(const rd_sum_type *rd_sum1, + const rd_sum_type *rd_sum2); +bool rd_sum_report_step_compatible(const rd_sum_type *rd_sum1, + const rd_sum_type *rd_sum2); +void rd_sum_export_csv(const rd_sum_type *rd_sum, const char *filename, + const stringlist_type *var_list, const char *date_format, + const char *sep); + +double_vector_type *rd_sum_alloc_seconds_solution(const rd_sum_type *rd_sum, + const char *gen_key, + double cmp_value, + bool rates_clamp_lower); +double_vector_type *rd_sum_alloc_days_solution(const rd_sum_type *rd_sum, + const char *gen_key, + double cmp_value, + bool rates_clamp_lower); +time_t_vector_type *rd_sum_alloc_time_solution(const rd_sum_type *rd_sum, + const char *gen_key, + double cmp_value, + bool rates_clamp_lower); + +double rd_sum_iget_last_value(const rd_sum_type *rd_sum, int param_index); +double rd_sum_get_last_value_gen_key(const rd_sum_type *rd_sum, + const char *gen_key); +double rd_sum_get_last_value_node(const rd_sum_type *rd_sum, + const rd::smspec_node *node); +double rd_sum_iget_first_value(const rd_sum_type *rd_sum, int param_index); +double rd_sum_get_first_value_gen_key(const rd_sum_type *rd_sum, + const char *gen_key); +double rd_sum_get_first_value_node(const rd_sum_type *rd_sum, + const rd::smspec_node *node); + +void rd_sum_init_datetime64_vector(const rd_sum_type *rd_sum, int64_t *data, + int multiplier); +void rd_sum_init_double_vector_interp(const rd_sum_type *rd_sum, + const char *gen_key, const time_t_vector_type *time_points, double *data); -UTIL_IS_INSTANCE_HEADER(ecl_sum); +void rd_sum_init_double_vector(const rd_sum_type *rd_sum, const char *gen_key, + double *data); +void rd_sum_init_double_frame(const rd_sum_type *rd_sum, + const rd_sum_vector_type *keywords, double *data); +void rd_sum_init_double_frame_interp(const rd_sum_type *rd_sum, + const rd_sum_vector_type *keywords, + const time_t_vector_type *time_points, + double *data); +UTIL_IS_INSTANCE_HEADER(rd_sum); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_sum_data.h b/lib/include/resdata/rd_sum_data.h index ea4c0b3146..ea633a1fdf 100644 --- a/lib/include/resdata/rd_sum_data.h +++ b/lib/include/resdata/rd_sum_data.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_sum_data.hpp b/lib/include/resdata/rd_sum_data.hpp index 827208cd53..ca70132f6c 100644 --- a/lib/include/resdata/rd_sum_data.hpp +++ b/lib/include/resdata/rd_sum_data.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_SUM_DATA_H -#define ERT_ECL_SUM_DATA_H +#ifndef ERT_RD_SUM_DATA_H +#define ERT_RD_SUM_DATA_H #include #include @@ -9,123 +9,118 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_sum_data_struct ecl_sum_data_type; +typedef struct rd_sum_data_struct rd_sum_data_type; -void ecl_sum_data_reset_self_map(ecl_sum_data_type *data); -void ecl_sum_data_add_case(ecl_sum_data_type *self, - const ecl_sum_data_type *other); -void ecl_sum_data_fwrite_step(const ecl_sum_data_type *data, - const char *ecl_case, bool fmt_case, bool unified, - int report_step); -void ecl_sum_data_fwrite(const ecl_sum_data_type *data, const char *ecl_case, - bool fmt_case, bool unified); -bool ecl_sum_data_can_write(const ecl_sum_data_type *data); -bool ecl_sum_data_fread(ecl_sum_data_type *data, - const stringlist_type *filelist, bool lazy_load, - int file_options); -ecl_sum_data_type *ecl_sum_data_alloc_writer(ecl_smspec_type *smspec); -ecl_sum_data_type *ecl_sum_data_alloc(ecl_smspec_type *smspec); -double ecl_sum_data_time2days(const ecl_sum_data_type *data, time_t sim_time); -int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type *data, - time_t sim_time); -int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type *data, - double days); -bool ecl_sum_data_check_sim_time(const ecl_sum_data_type *data, - time_t sim_time); -bool ecl_sum_data_check_sim_days(const ecl_sum_data_type *data, - double sim_days); -int ecl_sum_data_get_num_ministep(const ecl_sum_data_type *data); -double_vector_type * -ecl_sum_data_alloc_data_vector(const ecl_sum_data_type *data, int data_index, - bool report_only); -void ecl_sum_data_init_time_vector(const ecl_sum_data_type *data, - time_t_vector_type *time_vector, - bool report_only); -time_t_vector_type * -ecl_sum_data_alloc_time_vector(const ecl_sum_data_type *data, bool report_only); -time_t ecl_sum_data_get_data_start(const ecl_sum_data_type *data); -time_t ecl_sum_data_get_report_time(const ecl_sum_data_type *data, - int report_step); -double ecl_sum_data_get_first_day(const ecl_sum_data_type *data); -time_t ecl_sum_data_get_sim_start(const ecl_sum_data_type *data); -time_t ecl_sum_data_get_sim_end(const ecl_sum_data_type *data); -double ecl_sum_data_get_sim_length(const ecl_sum_data_type *data); -void ecl_sum_data_summarize(const ecl_sum_data_type *data, FILE *stream); -double ecl_sum_data_iget(const ecl_sum_data_type *data, int internal_index, - int params_index); +void rd_sum_data_reset_self_map(rd_sum_data_type *data); +void rd_sum_data_add_case(rd_sum_data_type *self, + const rd_sum_data_type *other); +void rd_sum_data_fwrite_step(const rd_sum_data_type *data, const char *rd_case, + bool fmt_case, bool unified, int report_step); +void rd_sum_data_fwrite(const rd_sum_data_type *data, const char *rd_case, + bool fmt_case, bool unified); +bool rd_sum_data_can_write(const rd_sum_data_type *data); +bool rd_sum_data_fread(rd_sum_data_type *data, const stringlist_type *filelist, + bool lazy_load, int file_options); +rd_sum_data_type *rd_sum_data_alloc_writer(rd_smspec_type *smspec); +rd_sum_data_type *rd_sum_data_alloc(rd_smspec_type *smspec); +double rd_sum_data_time2days(const rd_sum_data_type *data, time_t sim_time); +int rd_sum_data_get_report_step_from_time(const rd_sum_data_type *data, + time_t sim_time); +int rd_sum_data_get_report_step_from_days(const rd_sum_data_type *data, + double days); +bool rd_sum_data_check_sim_time(const rd_sum_data_type *data, time_t sim_time); +bool rd_sum_data_check_sim_days(const rd_sum_data_type *data, double sim_days); +int rd_sum_data_get_num_ministep(const rd_sum_data_type *data); +double_vector_type *rd_sum_data_alloc_data_vector(const rd_sum_data_type *data, + int data_index, + bool report_only); +void rd_sum_data_init_time_vector(const rd_sum_data_type *data, + time_t_vector_type *time_vector, + bool report_only); +time_t_vector_type *rd_sum_data_alloc_time_vector(const rd_sum_data_type *data, + bool report_only); +time_t rd_sum_data_get_data_start(const rd_sum_data_type *data); +time_t rd_sum_data_get_report_time(const rd_sum_data_type *data, + int report_step); +double rd_sum_data_get_first_day(const rd_sum_data_type *data); +time_t rd_sum_data_get_sim_start(const rd_sum_data_type *data); +time_t rd_sum_data_get_sim_end(const rd_sum_data_type *data); +double rd_sum_data_get_sim_length(const rd_sum_data_type *data); +void rd_sum_data_summarize(const rd_sum_data_type *data, FILE *stream); +double rd_sum_data_iget(const rd_sum_data_type *data, int internal_index, + int params_index); -double ecl_sum_data_iget_sim_days(const ecl_sum_data_type *, int); -time_t ecl_sum_data_iget_sim_time(const ecl_sum_data_type *, int); -void ecl_sum_data_get_interp_vector(const ecl_sum_data_type *data, - time_t sim_time, - const ecl_sum_vector_type *keylist, - double_vector_type *results); +double rd_sum_data_iget_sim_days(const rd_sum_data_type *, int); +time_t rd_sum_data_iget_sim_time(const rd_sum_data_type *, int); +void rd_sum_data_get_interp_vector(const rd_sum_data_type *data, + time_t sim_time, + const rd_sum_vector_type *keylist, + double_vector_type *results); -bool ecl_sum_data_has_report_step(const ecl_sum_data_type *, int); +bool rd_sum_data_has_report_step(const rd_sum_data_type *, int); -ecl_sum_data_type *ecl_sum_data_fread_alloc(ecl_smspec_type *, - const stringlist_type *filelist, - bool include_restart, - bool lazy_load); -void ecl_sum_data_free(ecl_sum_data_type *); -int ecl_sum_data_get_last_report_step(const ecl_sum_data_type *data); -int ecl_sum_data_get_first_report_step(const ecl_sum_data_type *data); +rd_sum_data_type *rd_sum_data_fread_alloc(rd_smspec_type *, + const stringlist_type *filelist, + bool include_restart, bool lazy_load); +void rd_sum_data_free(rd_sum_data_type *); +int rd_sum_data_get_last_report_step(const rd_sum_data_type *data); +int rd_sum_data_get_first_report_step(const rd_sum_data_type *data); -double ecl_sum_data_get_from_sim_time(const ecl_sum_data_type *data, - time_t sim_time, - const ecl::smspec_node &smspec_node); -double ecl_sum_data_get_from_sim_days(const ecl_sum_data_type *data, - double sim_days, - const ecl::smspec_node &smspec_node); +double rd_sum_data_get_from_sim_time(const rd_sum_data_type *data, + time_t sim_time, + const rd::smspec_node &smspec_node); +double rd_sum_data_get_from_sim_days(const rd_sum_data_type *data, + double sim_days, + const rd::smspec_node &smspec_node); -int ecl_sum_data_get_length(const ecl_sum_data_type *data); -int ecl_sum_data_iget_report_step(const ecl_sum_data_type *data, - int internal_index); -int ecl_sum_data_iget_report_end(const ecl_sum_data_type *data, - int report_step); -ecl_sum_tstep_type *ecl_sum_data_add_new_tstep(ecl_sum_data_type *data, - int report_step, - double sim_seconds); -bool ecl_sum_data_report_step_equal(const ecl_sum_data_type *data1, - const ecl_sum_data_type *data2); -bool ecl_sum_data_report_step_compatible(const ecl_sum_data_type *data1, - const ecl_sum_data_type *data2); -void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type *data, - time_t sim_time, - const ecl_sum_vector_type *keylist, - FILE *fp); -double ecl_sum_data_get_last_value(const ecl_sum_data_type *data, +int rd_sum_data_get_length(const rd_sum_data_type *data); +int rd_sum_data_iget_report_step(const rd_sum_data_type *data, + int internal_index); +int rd_sum_data_iget_report_end(const rd_sum_data_type *data, int report_step); +rd_sum_tstep_type *rd_sum_data_add_new_tstep(rd_sum_data_type *data, + int report_step, + double sim_seconds); +bool rd_sum_data_report_step_equal(const rd_sum_data_type *data1, + const rd_sum_data_type *data2); +bool rd_sum_data_report_step_compatible(const rd_sum_data_type *data1, + const rd_sum_data_type *data2); +void rd_sum_data_fwrite_interp_csv_line(const rd_sum_data_type *data, + time_t sim_time, + const rd_sum_vector_type *keylist, + FILE *fp); +double rd_sum_data_get_last_value(const rd_sum_data_type *data, + int param_index); +double rd_sum_data_iget_last_value(const rd_sum_data_type *data, int param_index); -double ecl_sum_data_iget_last_value(const ecl_sum_data_type *data, +double rd_sum_data_iget_first_value(const rd_sum_data_type *data, int param_index); -double ecl_sum_data_iget_first_value(const ecl_sum_data_type *data, - int param_index); -void ecl_sum_data_init_double_vector(const ecl_sum_data_type *data, - int params_index, double *output_data); -void ecl_sum_data_init_datetime64_vector(const ecl_sum_data_type *data, - int64_t *output_data, int multiplier); +void rd_sum_data_init_double_vector(const rd_sum_data_type *data, + int params_index, double *output_data); +void rd_sum_data_init_datetime64_vector(const rd_sum_data_type *data, + int64_t *output_data, int multiplier); -void ecl_sum_data_init_double_frame(const ecl_sum_data_type *data, - const ecl_sum_vector_type *keywords, - double *output_data); +void rd_sum_data_init_double_frame(const rd_sum_data_type *data, + const rd_sum_vector_type *keywords, + double *output_data); double_vector_type * -ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type *data, - const ecl::smspec_node &node, double value, - bool rates_clamp_lower); -void ecl_sum_data_init_double_frame_interp( - const ecl_sum_data_type *data, const ecl_sum_vector_type *keywords, - const time_t_vector_type *time_points, double *output_data); +rd_sum_data_alloc_seconds_solution(const rd_sum_data_type *data, + const rd::smspec_node &node, double value, + bool rates_clamp_lower); +void rd_sum_data_init_double_frame_interp(const rd_sum_data_type *data, + const rd_sum_vector_type *keywords, + const time_t_vector_type *time_points, + double *output_data); -void ecl_sum_data_init_double_vector_interp( - const ecl_sum_data_type *data, const ecl::smspec_node &smspec_node, +void rd_sum_data_init_double_vector_interp( + const rd_sum_data_type *data, const rd::smspec_node &smspec_node, const time_t_vector_type *time_points, double *output_data); #ifdef __cplusplus diff --git a/lib/include/resdata/rd_sum_index.h b/lib/include/resdata/rd_sum_index.h index a142c906ec..9709a63ed3 100644 --- a/lib/include/resdata/rd_sum_index.h +++ b/lib/include/resdata/rd_sum_index.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_sum_index.hpp b/lib/include/resdata/rd_sum_index.hpp index a3c6902324..042b19ca68 100644 --- a/lib/include/resdata/rd_sum_index.hpp +++ b/lib/include/resdata/rd_sum_index.hpp @@ -1,11 +1,11 @@ -#ifndef ERT_ECL_SUM_INDEX_H -#define ERT_ECL_SUM_INDEX_H +#ifndef ERT_RD_SUM_INDEX_H +#define ERT_RD_SUM_INDEX_H #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_sum_index_struct ecl_sum_index_type; +typedef struct rd_sum_index_struct rd_sum_index_type; #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_sum_tstep.h b/lib/include/resdata/rd_sum_tstep.h index 5c61e0764d..27faf358f0 100644 --- a/lib/include/resdata/rd_sum_tstep.h +++ b/lib/include/resdata/rd_sum_tstep.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_sum_tstep.hpp b/lib/include/resdata/rd_sum_tstep.hpp index aee0aa2fbe..daab8585f4 100644 --- a/lib/include/resdata/rd_sum_tstep.hpp +++ b/lib/include/resdata/rd_sum_tstep.hpp @@ -1,69 +1,70 @@ -#ifndef ERT_ECL_SUM_TSTEP_H -#define ERT_ECL_SUM_TSTEP_H +#ifndef ERT_RD_SUM_TSTEP_H +#define ERT_RD_SUM_TSTEP_H #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type; - -ecl_sum_tstep_type * -ecl_sum_tstep_alloc_remap_copy(const ecl_sum_tstep_type *src, - const ecl_smspec_type *new_smspec, - float default_value, const int *params_map); -ecl_sum_tstep_type *ecl_sum_tstep_alloc_copy(const ecl_sum_tstep_type *src); -void ecl_sum_tstep_free(ecl_sum_tstep_type *ministep); -void ecl_sum_tstep_free__(void *__ministep); -ecl_sum_tstep_type *ecl_sum_tstep_alloc_from_file( - int report_step, int ministep_nr, const ecl_kw_type *params_kw, - const char *src_file, const ecl_smspec_type *smspec); - -ecl_sum_tstep_type *ecl_sum_tstep_alloc_new(int report_step, int ministep, - float sim_seconds, - const ecl_smspec_type *smspec); - -void ecl_sum_tstep_set_from_node(ecl_sum_tstep_type *tstep, - const ecl::smspec_node &smspec_node, - float value); -double ecl_sum_tstep_get_from_node(const ecl_sum_tstep_type *tstep, - const ecl::smspec_node &smspec_node); - -double ecl_sum_tstep_iget(const ecl_sum_tstep_type *ministep, int index); -time_t ecl_sum_tstep_get_sim_time(const ecl_sum_tstep_type *ministep); -double ecl_sum_tstep_get_sim_days(const ecl_sum_tstep_type *ministep); -double ecl_sum_tstep_get_sim_seconds(const ecl_sum_tstep_type *ministep); - -int ecl_sum_tstep_get_report(const ecl_sum_tstep_type *ministep); -int ecl_sum_tstep_get_ministep(const ecl_sum_tstep_type *ministep); - -void ecl_sum_tstep_fwrite(const ecl_sum_tstep_type *ministep, - const int *index_map, int index_map_size, - fortio_type *fortio); -void ecl_sum_tstep_iset(ecl_sum_tstep_type *tstep, int index, float value); +typedef struct rd_sum_tstep_struct rd_sum_tstep_type; + +rd_sum_tstep_type * +rd_sum_tstep_alloc_remap_copy(const rd_sum_tstep_type *src, + const rd_smspec_type *new_smspec, + float default_value, const int *params_map); +rd_sum_tstep_type *rd_sum_tstep_alloc_copy(const rd_sum_tstep_type *src); +void rd_sum_tstep_free(rd_sum_tstep_type *ministep); +void rd_sum_tstep_free__(void *__ministep); +rd_sum_tstep_type *rd_sum_tstep_alloc_from_file(int report_step, + int ministep_nr, + const rd_kw_type *params_kw, + const char *src_file, + const rd_smspec_type *smspec); + +rd_sum_tstep_type *rd_sum_tstep_alloc_new(int report_step, int ministep, + float sim_seconds, + const rd_smspec_type *smspec); + +void rd_sum_tstep_set_from_node(rd_sum_tstep_type *tstep, + const rd::smspec_node &smspec_node, + float value); +double rd_sum_tstep_get_from_node(const rd_sum_tstep_type *tstep, + const rd::smspec_node &smspec_node); + +double rd_sum_tstep_iget(const rd_sum_tstep_type *ministep, int index); +time_t rd_sum_tstep_get_sim_time(const rd_sum_tstep_type *ministep); +double rd_sum_tstep_get_sim_days(const rd_sum_tstep_type *ministep); +double rd_sum_tstep_get_sim_seconds(const rd_sum_tstep_type *ministep); + +int rd_sum_tstep_get_report(const rd_sum_tstep_type *ministep); +int rd_sum_tstep_get_ministep(const rd_sum_tstep_type *ministep); + +void rd_sum_tstep_fwrite(const rd_sum_tstep_type *ministep, + const int *index_map, int index_map_size, + fortio_type *fortio); +void rd_sum_tstep_iset(rd_sum_tstep_type *tstep, int index, float value); /// scales with value; equivalent to iset( iget() * scalar) -void ecl_sum_tstep_iscale(ecl_sum_tstep_type *tstep, int index, float scalar); +void rd_sum_tstep_iscale(rd_sum_tstep_type *tstep, int index, float scalar); /// adds addend to tstep[index]; equivalent to iset( iget() + addend) -void ecl_sum_tstep_ishift(ecl_sum_tstep_type *tstep, int index, float addend); +void rd_sum_tstep_ishift(rd_sum_tstep_type *tstep, int index, float addend); -void ecl_sum_tstep_set_from_key(ecl_sum_tstep_type *tstep, const char *gen_key, - float value); -double ecl_sum_tstep_get_from_key(const ecl_sum_tstep_type *tstep, - const char *gen_key); -bool ecl_sum_tstep_has_key(const ecl_sum_tstep_type *tstep, - const char *gen_key); +void rd_sum_tstep_set_from_key(rd_sum_tstep_type *tstep, const char *gen_key, + float value); +double rd_sum_tstep_get_from_key(const rd_sum_tstep_type *tstep, + const char *gen_key); +bool rd_sum_tstep_has_key(const rd_sum_tstep_type *tstep, const char *gen_key); -bool ecl_sum_tstep_sim_time_equal(const ecl_sum_tstep_type *tstep1, - const ecl_sum_tstep_type *tstep2); +bool rd_sum_tstep_sim_time_equal(const rd_sum_tstep_type *tstep1, + const rd_sum_tstep_type *tstep2); -UTIL_SAFE_CAST_HEADER(ecl_sum_tstep); -UTIL_SAFE_CAST_HEADER_CONST(ecl_sum_tstep); +UTIL_SAFE_CAST_HEADER(rd_sum_tstep); +UTIL_SAFE_CAST_HEADER_CONST(rd_sum_tstep); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_sum_vector.h b/lib/include/resdata/rd_sum_vector.h index 3168ee0b51..4528fb8f9e 100644 --- a/lib/include/resdata/rd_sum_vector.h +++ b/lib/include/resdata/rd_sum_vector.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_sum_vector.hpp b/lib/include/resdata/rd_sum_vector.hpp index 4432d185ed..f85504a3bd 100644 --- a/lib/include/resdata/rd_sum_vector.hpp +++ b/lib/include/resdata/rd_sum_vector.hpp @@ -1,38 +1,38 @@ -#ifndef ERT_ECL_SUM_VECTOR_H -#define ERT_ECL_SUM_VECTOR_H +#ifndef ERT_RD_SUM_VECTOR_H +#define ERT_RD_SUM_VECTOR_H #include -#include +#include #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_sum_vector_struct ecl_sum_vector_type; +typedef struct rd_sum_vector_struct rd_sum_vector_type; -void ecl_sum_vector_free(ecl_sum_vector_type *keylist); -ecl_sum_vector_type *ecl_sum_vector_alloc(const ecl_sum_type *ecl_sum, - bool add_keywords); +void rd_sum_vector_free(rd_sum_vector_type *keylist); +rd_sum_vector_type *rd_sum_vector_alloc(const rd_sum_type *rd_sum, + bool add_keywords); -bool ecl_sum_vector_add_key(ecl_sum_vector_type *keylist, const char *key); -void ecl_sum_vector_add_keys(ecl_sum_vector_type *keylist, const char *pattern); +bool rd_sum_vector_add_key(rd_sum_vector_type *keylist, const char *key); +void rd_sum_vector_add_keys(rd_sum_vector_type *keylist, const char *pattern); -const char *ecl_sum_vector_iget_key(const ecl_sum_vector_type *ecl_sum_vector, - int index); -bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type *ecl_sum_vector, - int index); -int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type *ecl_sum_vector, - int index); -int ecl_sum_vector_get_size(const ecl_sum_vector_type *ecl_sum_vector); -bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type *ecl_sum_vector, - int index); +const char *rd_sum_vector_iget_key(const rd_sum_vector_type *rd_sum_vector, + int index); +bool rd_sum_vector_iget_is_rate(const rd_sum_vector_type *rd_sum_vector, + int index); +int rd_sum_vector_iget_param_index(const rd_sum_vector_type *rd_sum_vector, + int index); +int rd_sum_vector_get_size(const rd_sum_vector_type *rd_sum_vector); +bool rd_sum_vector_iget_valid(const rd_sum_vector_type *rd_sum_vector, + int index); -ecl_sum_vector_type * -ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type *src_vector, - const ecl_sum_type *ecl_sum); +rd_sum_vector_type * +rd_sum_vector_alloc_layout_copy(const rd_sum_vector_type *src_vector, + const rd_sum_type *rd_sum); -UTIL_IS_INSTANCE_HEADER(ecl_sum_vector); +UTIL_IS_INSTANCE_HEADER(rd_sum_vector); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_type.h b/lib/include/resdata/rd_type.h index 6ec87100e2..4c6295d565 100644 --- a/lib/include/resdata/rd_type.h +++ b/lib/include/resdata/rd_type.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_type.hpp b/lib/include/resdata/rd_type.hpp index c64771a88d..aeac1c4c6c 100644 --- a/lib/include/resdata/rd_type.hpp +++ b/lib/include/resdata/rd_type.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_TYPE_H -#define ERT_ECL_TYPE_H +#ifndef ERT_RD_TYPE_H +#define ERT_RD_TYPE_H #ifdef __cplusplus extern "C" { @@ -10,9 +10,9 @@ extern "C" { /* The type of an eclipse keyword is carried by a struct - ecl_type_struct which contains a type enum, and the size in bytes of + rd_type_struct which contains a type enum, and the size in bytes of one such element. These structs are for the most part handled with - value semantics, and created with macros ECL_INT, ECL_FLOAT and so + value semantics, and created with macros RD_INT, RD_FLOAT and so on. The macros in C use designated initializers, whereas the C++ macros @@ -20,27 +20,27 @@ extern "C" { different code paths for C and C++. */ -#define ECL_STRING8_LENGTH 8 -#define ECL_TYPE_LENGTH 4 +#define RD_STRING8_LENGTH 8 +#define RD_TYPE_LENGTH 4 typedef enum { - ECL_CHAR_TYPE = 0, - ECL_FLOAT_TYPE = 1, - ECL_DOUBLE_TYPE = 2, - ECL_INT_TYPE = 3, - ECL_BOOL_TYPE = 4, - ECL_MESS_TYPE = 5, - ECL_STRING_TYPE = 7 -} ecl_type_enum; - -#define ECL_TYPE_ENUM_DEFS \ - {.value = 0, .name = "ECL_CHAR_TYPE"}, \ - {.value = 1, .name = "ECL_FLOAT_TYPE"}, \ - {.value = 2, .name = "ECL_DOUBLE_TYPE"}, \ - {.value = 3, .name = "ECL_INT_TYPE"}, \ - {.value = 4, .name = "ECL_BOOL_TYPE"}, \ - {.value = 5, .name = "ECL_MESS_TYPE"}, { \ - .value = 7, .name = "ECL_STRING_TYPE" \ + RD_CHAR_TYPE = 0, + RD_FLOAT_TYPE = 1, + RD_DOUBLE_TYPE = 2, + RD_INT_TYPE = 3, + RD_BOOL_TYPE = 4, + RD_MESS_TYPE = 5, + RD_STRING_TYPE = 7 +} rd_type_enum; + +#define RD_TYPE_ENUM_DEFS \ + {.value = 0, .name = "RD_CHAR_TYPE"}, \ + {.value = 1, .name = "RD_FLOAT_TYPE"}, \ + {.value = 2, .name = "RD_DOUBLE_TYPE"}, \ + {.value = 3, .name = "RD_INT_TYPE"}, \ + {.value = 4, .name = "RD_BOOL_TYPE"}, \ + {.value = 5, .name = "RD_MESS_TYPE"}, { \ + .value = 7, .name = "RD_STRING_TYPE" \ } /* @@ -49,50 +49,50 @@ typedef enum { i.e. 'REAL', 'INTE', ... , come as 4 character strings. */ -#define ECL_STRING8_LENGTH 8 // 'Normal' 8 characters 'CHAR' type. -#define ECL_TYPE_LENGTH 4 +#define RD_STRING8_LENGTH 8 // 'Normal' 8 characters 'CHAR' type. +#define RD_TYPE_LENGTH 4 -struct ecl_type_struct { - const ecl_type_enum type; +struct rd_type_struct { + const rd_type_enum type; const size_t element_size; }; #ifdef __cplusplus -#define ECL_INT \ - ecl_data_type { ECL_INT_TYPE, sizeof(int) } -#define ECL_FLOAT \ - ecl_data_type { ECL_FLOAT_TYPE, sizeof(float) } -#define ECL_DOUBLE \ - ecl_data_type { ECL_DOUBLE_TYPE, sizeof(double) } -#define ECL_BOOL \ - ecl_data_type { ECL_BOOL_TYPE, sizeof(bool) } -#define ECL_CHAR \ - ecl_data_type { ECL_CHAR_TYPE, ECL_STRING8_LENGTH + 1 } -#define ECL_MESS \ - ecl_data_type { ECL_MESS_TYPE, 0 } -#define ECL_STRING(size) \ - ecl_data_type { ECL_STRING_TYPE, (size) + 1 } +#define RD_INT \ + rd_data_type { RD_INT_TYPE, sizeof(int) } +#define RD_FLOAT \ + rd_data_type { RD_FLOAT_TYPE, sizeof(float) } +#define RD_DOUBLE \ + rd_data_type { RD_DOUBLE_TYPE, sizeof(double) } +#define RD_BOOL \ + rd_data_type { RD_BOOL_TYPE, sizeof(bool) } +#define RD_CHAR \ + rd_data_type { RD_CHAR_TYPE, RD_STRING8_LENGTH + 1 } +#define RD_MESS \ + rd_data_type { RD_MESS_TYPE, 0 } +#define RD_STRING(size) \ + rd_data_type { RD_STRING_TYPE, (size) + 1 } } #else -#define ECL_CHAR \ - (ecl_data_type) { \ - .type = ECL_CHAR_TYPE, .element_size = ECL_STRING8_LENGTH + 1 \ +#define RD_CHAR \ + (rd_data_type) { \ + .type = RD_CHAR_TYPE, .element_size = RD_STRING8_LENGTH + 1 \ } -#define ECL_INT \ - (ecl_data_type) { .type = ECL_INT_TYPE, .element_size = sizeof(int) } -#define ECL_FLOAT \ - (ecl_data_type) { .type = ECL_FLOAT_TYPE, .element_size = sizeof(float) } -#define ECL_DOUBLE \ - (ecl_data_type) { .type = ECL_DOUBLE_TYPE, .element_size = sizeof(double) } -#define ECL_BOOL \ - (ecl_data_type) { .type = ECL_BOOL_TYPE, .element_size = sizeof(bool) } -#define ECL_MESS \ - (ecl_data_type) { .type = ECL_MESS_TYPE, .element_size = 0 } -#define ECL_STRING(size) \ - (ecl_data_type) { .type = ECL_STRING_TYPE, .element_size = (size) + 1 } +#define RD_INT \ + (rd_data_type) { .type = RD_INT_TYPE, .element_size = sizeof(int) } +#define RD_FLOAT \ + (rd_data_type) { .type = RD_FLOAT_TYPE, .element_size = sizeof(float) } +#define RD_DOUBLE \ + (rd_data_type) { .type = RD_DOUBLE_TYPE, .element_size = sizeof(double) } +#define RD_BOOL \ + (rd_data_type) { .type = RD_BOOL_TYPE, .element_size = sizeof(bool) } +#define RD_MESS \ + (rd_data_type) { .type = RD_MESS_TYPE, .element_size = 0 } +#define RD_STRING(size) \ + (rd_data_type) { .type = RD_STRING_TYPE, .element_size = (size) + 1 } #endif @@ -100,32 +100,32 @@ struct ecl_type_struct { extern "C" { #endif -typedef struct ecl_type_struct ecl_data_type; +typedef struct rd_type_struct rd_data_type; -ecl_data_type ecl_type_create_from_name(const char *); -ecl_data_type ecl_type_create(const ecl_type_enum, const size_t); -ecl_data_type ecl_type_create_from_type(const ecl_type_enum); +rd_data_type rd_type_create_from_name(const char *); +rd_data_type rd_type_create(const rd_type_enum, const size_t); +rd_data_type rd_type_create_from_type(const rd_type_enum); -ecl_type_enum ecl_type_get_type(const ecl_data_type); -char *ecl_type_alloc_name(const ecl_data_type); +rd_type_enum rd_type_get_type(const rd_data_type); +char *rd_type_alloc_name(const rd_data_type); -int ecl_type_get_sizeof_ctype(const ecl_data_type); -int ecl_type_get_sizeof_iotype(const ecl_data_type); +int rd_type_get_sizeof_ctype(const rd_data_type); +int rd_type_get_sizeof_iotype(const rd_data_type); -bool ecl_type_is_equal(const ecl_data_type, const ecl_data_type); +bool rd_type_is_equal(const rd_data_type, const rd_data_type); -bool ecl_type_is_numeric(const ecl_data_type); -bool ecl_type_is_alpha(const ecl_data_type); -bool ecl_type_is_char(const ecl_data_type); -bool ecl_type_is_int(const ecl_data_type); -bool ecl_type_is_float(const ecl_data_type); -bool ecl_type_is_double(const ecl_data_type); -bool ecl_type_is_mess(const ecl_data_type); -bool ecl_type_is_bool(const ecl_data_type); -bool ecl_type_is_string(const ecl_data_type); +bool rd_type_is_numeric(const rd_data_type); +bool rd_type_is_alpha(const rd_data_type); +bool rd_type_is_char(const rd_data_type); +bool rd_type_is_int(const rd_data_type); +bool rd_type_is_float(const rd_data_type); +bool rd_type_is_double(const rd_data_type); +bool rd_type_is_mess(const rd_data_type); +bool rd_type_is_bool(const rd_data_type); +bool rd_type_is_string(const rd_data_type); // Temporary fixup for OPM. -char *ecl_type_get_name(const ecl_data_type); +char *rd_type_get_name(const rd_data_type); #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_units.h b/lib/include/resdata/rd_units.h index 4dfec6d4b4..2a9bfea362 100644 --- a/lib/include/resdata/rd_units.h +++ b/lib/include/resdata/rd_units.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_units.hpp b/lib/include/resdata/rd_units.hpp index 01184be235..536bbcb052 100644 --- a/lib/include/resdata/rd_units.hpp +++ b/lib/include/resdata/rd_units.hpp @@ -1,26 +1,26 @@ -#ifndef ECL_UNITS_H -#define ECL_UNITS_H +#ifndef RD_UNITS_H +#define RD_UNITS_H #ifdef __cplusplus extern "C" { #endif -#define ECL_UNITS_CUBIC(x) ((x) * (x) * (x)) -#define ECL_UNITS_MILLI(x) ((x)*0.001) -#define ECL_UNITS_MEGA(x) ((x)*1000000) +#define RD_UNITS_CUBIC(x) ((x) * (x) * (x)) +#define RD_UNITS_MILLI(x) ((x)*0.001) +#define RD_UNITS_MEGA(x) ((x)*1000000) -#define ECL_UNITS_LENGTH_INCH 0.0254 -#define ECL_UNITS_LENGTH_FEET 12 * ECL_UNITS_LENGTH_INCH +#define RD_UNITS_LENGTH_INCH 0.0254 +#define RD_UNITS_LENGTH_FEET 12 * RD_UNITS_LENGTH_INCH -#define ECL_UNITS_VOLUME_GALLON 231 * ECL_UNITS_CUBIC(ECL_UNITS_LENGTH_INCH) -#define ECL_UNITS_VOLUME_BARREL ECL_UNITS_VOLUME_GALLON * 42 -#define ECL_UNITS_VOLUME_LITER 0.001 -#define ECL_UNITS_VOLUME_MILLI_LITER ECL_UNITS_MILLI(ECL_UNITS_VOLUME_LITER) -#define ECL_UNITS_VOLUME_GAS_FIELD \ - ECL_UNITS_MEGA(ECL_UNITS_CUBIC(ECL_UNITS_LENGTH_FEET)) +#define RD_UNITS_VOLUME_GALLON 231 * RD_UNITS_CUBIC(RD_UNITS_LENGTH_INCH) +#define RD_UNITS_VOLUME_BARREL RD_UNITS_VOLUME_GALLON * 42 +#define RD_UNITS_VOLUME_LITER 0.001 +#define RD_UNITS_VOLUME_MILLI_LITER RD_UNITS_MILLI(RD_UNITS_VOLUME_LITER) +#define RD_UNITS_VOLUME_GAS_FIELD \ + RD_UNITS_MEGA(RD_UNITS_CUBIC(RD_UNITS_LENGTH_FEET)) -#define ECL_UNITS_TIME_HOUR 3600 -#define ECL_UNITS_TIME_DAY 24 * ECL_UNITS_TIME_HOUR +#define RD_UNITS_TIME_HOUR 3600 +#define RD_UNITS_TIME_DAY 24 * RD_UNITS_TIME_HOUR #ifdef __cplusplus } diff --git a/lib/include/resdata/rd_util.h b/lib/include/resdata/rd_util.h index 3c0739895e..1ef3f5ba28 100644 --- a/lib/include/resdata/rd_util.h +++ b/lib/include/resdata/rd_util.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/rd_util.hpp b/lib/include/resdata/rd_util.hpp index 5dcb80d4cc..12db3605f8 100644 --- a/lib/include/resdata/rd_util.hpp +++ b/lib/include/resdata/rd_util.hpp @@ -1,5 +1,5 @@ -#ifndef ERT_ECL_UTIL_H -#define ERT_ECL_UTIL_H +#ifndef ERT_RD_UTIL_H +#define ERT_RD_UTIL_H #ifdef __cplusplus extern "C" { #endif @@ -9,21 +9,21 @@ extern "C" { #include #include #include -#include +#include typedef enum { - ECL_OTHER_FILE = 0, - ECL_RESTART_FILE = 1, - ECL_UNIFIED_RESTART_FILE = 2, - ECL_SUMMARY_FILE = 4, - ECL_UNIFIED_SUMMARY_FILE = 8, - ECL_SUMMARY_HEADER_FILE = 16, - ECL_GRID_FILE = 32, - ECL_EGRID_FILE = 64, - ECL_INIT_FILE = 128, - ECL_RFT_FILE = 256, - ECL_DATA_FILE = 512 -} ecl_file_enum; + RD_OTHER_FILE = 0, + RD_RESTART_FILE = 1, + RD_UNIFIED_RESTART_FILE = 2, + RD_SUMMARY_FILE = 4, + RD_UNIFIED_SUMMARY_FILE = 8, + RD_SUMMARY_HEADER_FILE = 16, + RD_GRID_FILE = 32, + RD_EGRID_FILE = 64, + RD_INIT_FILE = 128, + RD_RFT_FILE = 256, + RD_DATA_FILE = 512 +} rd_file_enum; /* This enum enumerates the four different ways summary and restart information @@ -31,12 +31,12 @@ typedef enum { */ typedef enum { - ECL_INVALID_STORAGE = 0, - ECL_BINARY_UNIFIED = 1, - ECL_FORMATTED_UNIFIED = 2, - ECL_BINARY_NON_UNIFIED = 4, - ECL_FORMATTED_NON_UNIFIED = 8 -} ecl_storage_enum; + RD_INVALID_STORAGE = 0, + RD_BINARY_UNIFIED = 1, + RD_FORMATTED_UNIFIED = 2, + RD_BINARY_NON_UNIFIED = 4, + RD_FORMATTED_NON_UNIFIED = 8 +} rd_storage_enum; /* The resdata library has been built and tested 99.5% with ECLIPSE100 @@ -44,7 +44,7 @@ typedef enum { functionality related to ECLIPSE100 versus ECLIPSE300 functionality. Observe that numerical values found as part of the INTEHAD keyword - differ from these values, and are found in the ecl_kw_magic.h + differ from these values, and are found in the rd_kw_magic.h header. */ @@ -55,14 +55,14 @@ typedef enum { ECLIPSE300_THERMAL = 3, INTERSECT = 4, FRONTSIM = 5 -} ecl_version_enum; +} rd_version_enum; /* Observe that the numerical enum VALUES matches those found in item 14 in the INTEHEAD keyword in the ECLIPSE INIT files; i.e. the distribution of numerical values 1,2,4 can NOT BE CHANGED. - The function ecl_util_get_phase_name() can be used to lookup a + The function rd_get_phase_name() can be used to lookup a string name from an enum value. The phases in a simulation will typically be a sum of these @@ -70,88 +70,84 @@ typedef enum { */ typedef enum { - ECL_OIL_PHASE = 1, - ECL_GAS_PHASE = 2, - ECL_WATER_PHASE = 4 -} ecl_phase_enum; - -#define ECL_PHASE_ENUM_DEFS \ - {.value = 1, .name = "ECL_OIL_PHASE"}, \ - {.value = 2, .name = "ECL_GAS_PHASE"}, { \ - .value = 4, .name = "ECL_WATER_PHASE" \ + RD_OIL_PHASE = 1, + RD_GAS_PHASE = 2, + RD_WATER_PHASE = 4 +} rd_phase_enum; + +#define RD_PHASE_ENUM_DEFS \ + {.value = 1, .name = "RD_OIL_PHASE"}, \ + {.value = 2, .name = "RD_GAS_PHASE"}, { \ + .value = 4, .name = "RD_WATER_PHASE" \ } -#define ECL_PHASE_ENUM_SIZE 3 +#define RD_PHASE_ENUM_SIZE 3 typedef enum { - ECL_METRIC_UNITS = 1, - ECL_FIELD_UNITS = 2, - ECL_LAB_UNITS = 3, - ECL_PVT_M_UNITS = 4 -} ert_ecl_unit_enum; + RD_METRIC_UNITS = 1, + RD_FIELD_UNITS = 2, + RD_LAB_UNITS = 3, + RD_PVT_M_UNITS = 4 +} ert_rd_unit_enum; // For unformatted files: -#define ECL_BOOL_TRUE_INT \ +#define RD_BOOL_TRUE_INT \ -1 // Binary representation: 11111111 11111111 11111111 1111111 -#define ECL_BOOL_FALSE_INT \ +#define RD_BOOL_FALSE_INT \ 0 // Binary representation: 00000000 00000000 00000000 0000000 -#define ECL_COMMENT_STRING "--" -#define ECL_COMMENT_CHAR '-' // Need to consecutive to make an ECLIPSE comment -#define ECL_DATA_TERMINATION "/" - -bool ecl_util_unified_file(const char *filename); -const char *ecl_util_file_type_name(ecl_file_enum file_type); -char *ecl_util_alloc_base_guess(const char *); -int ecl_util_filename_report_nr(const char *); -ecl_file_enum ecl_util_inspect_extension(const char *ext, bool *_fmt_file, - int *_report_nr); -ecl_file_enum ecl_util_get_file_type(const char *filename, bool *fmt_file, - int *report_nr); -char *ecl_util_alloc_filename(const char * /* path */, const char * /* base */, - ecl_file_enum, bool /* fmt_file */, - int /*report_nr*/); -char *ecl_util_alloc_exfilename(const char * /* path */, - const char * /* base */, ecl_file_enum, - bool /* fmt_file */, int /*report_nr*/); -void ecl_util_memcpy_typed_data(void *, const void *, ecl_data_type, - ecl_data_type, int); -void ecl_util_escape_kw(char *kw); -bool ecl_util_alloc_summary_files(const char *, const char *, const char *, - char **, stringlist_type *); -void ecl_util_alloc_summary_data_files(const char *path, const char *base, - bool fmt_file, - stringlist_type *filelist); -void ecl_util_alloc_restart_files(const char *, const char *, char ***, int *, - bool *, bool *); -time_t ecl_util_get_start_date(const char *); -int ecl_util_get_num_cpu(const char *data_file); -bool ecl_util_fmt_file(const char *filename, bool *__fmt_file); -char *ecl_util_alloc_exfilename_anyfmt(const char *path, const char *base, - ecl_file_enum file_type, bool start_fmt, - int report_nr); -int ecl_util_get_month_nr(const char *month_name); -int ecl_util_fname_report_cmp(const void *f1, const void *f2); -time_t ecl_util_make_date(int mday, int month, int year); -time_t ecl_util_make_date__(int mday, int month, int year, int *year_offset); -time_t ecl_util_make_datetime(int sec, int min, int hour, int mday, int month, - int year); -ert_ecl_unit_enum ecl_util_get_unit_set(const char *data_file); - -bool ecl_util_valid_basename_fmt(const char *basename_fmt); -bool ecl_util_valid_basename(const char *basename); -const char *ecl_util_get_phase_name(ecl_phase_enum phase); - -int ecl_util_select_filelist(const char *path, const char *base, - ecl_file_enum file_type, bool fmt_file, - stringlist_type *filelist); -void ecl_util_append_month_range(time_t_vector_type *date_list, - time_t start_date, time_t end_date, - bool force_append_end); -void ecl_util_init_month_range(time_t_vector_type *date_list, time_t start_date, - time_t end_date); -void ecl_util_set_date_values(time_t t, int *mday, int *month, int *year); -void ecl_util_set_datetime_values(time_t t, int *sec, int *min, int *hour, - int *mday, int *month, int *year); -bool ecl_util_path_access(const char *ecl_case); +#define RD_COMMENT_STRING "--" +#define RD_COMMENT_CHAR '-' // Need to consecutive to make an ECLIPSE comment +#define RD_DATA_TERMINATION "/" + +bool rd_unified_file(const char *filename); +const char *rd_file_type_name(rd_file_enum file_type); +char *rd_alloc_base_guess(const char *); +int rd_filename_report_nr(const char *); +rd_file_enum rd_inspect_extension(const char *ext, bool *_fmt_file, + int *_report_nr); +rd_file_enum rd_get_file_type(const char *filename, bool *fmt_file, + int *report_nr); +char *rd_alloc_filename(const char * /* path */, const char * /* base */, + rd_file_enum, bool /* fmt_file */, int /*report_nr*/); +char *rd_alloc_exfilename(const char * /* path */, const char * /* base */, + rd_file_enum, bool /* fmt_file */, int /*report_nr*/); +void rd_memcpy_typed_data(void *, const void *, rd_data_type, rd_data_type, + int); +void rd_escape_kw(char *kw); +bool rd_alloc_summary_files(const char *, const char *, const char *, char **, + stringlist_type *); +void rd_alloc_summary_data_files(const char *path, const char *base, + bool fmt_file, stringlist_type *filelist); +void rd_alloc_restart_files(const char *, const char *, char ***, int *, bool *, + bool *); +time_t rd_get_start_date(const char *); +int rd_get_num_cpu(const char *data_file); +bool rd_fmt_file(const char *filename, bool *__fmt_file); +char *rd_alloc_exfilename_anyfmt(const char *path, const char *base, + rd_file_enum file_type, bool start_fmt, + int report_nr); +int rd_get_month_nr(const char *month_name); +int rd_fname_report_cmp(const void *f1, const void *f2); +time_t rd_make_date(int mday, int month, int year); +time_t rd_make_date__(int mday, int month, int year, int *year_offset); +time_t rd_make_datetime(int sec, int min, int hour, int mday, int month, + int year); +ert_rd_unit_enum rd_get_unit_set(const char *data_file); + +bool rd_valid_basename_fmt(const char *basename_fmt); +bool rd_valid_basename(const char *basename); +const char *rd_get_phase_name(rd_phase_enum phase); + +int rd_select_filelist(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file, + stringlist_type *filelist); +void rd_append_month_range(time_t_vector_type *date_list, time_t start_date, + time_t end_date, bool force_append_end); +void rd_init_month_range(time_t_vector_type *date_list, time_t start_date, + time_t end_date); +void rd_set_date_values(time_t t, int *mday, int *month, int *year); +void rd_set_datetime_values(time_t t, int *sec, int *min, int *hour, int *mday, + int *month, int *year); +bool rd_path_access(const char *rd_case); #ifdef __cplusplus } #endif diff --git a/lib/include/resdata/smspec_node.h b/lib/include/resdata/smspec_node.h index 38aa96a25d..9c16accfee 100644 --- a/lib/include/resdata/smspec_node.h +++ b/lib/include/resdata/smspec_node.h @@ -25,22 +25,22 @@ extern "C" { #define SMSPEC_YEARS_NUMS_VALUE -32676 typedef enum { - ECL_SMSPEC_INVALID_VAR = 0, - ECL_SMSPEC_FIELD_VAR = 1, /* X */ - ECL_SMSPEC_REGION_VAR = 2, /* X */ - ECL_SMSPEC_GROUP_VAR = 3, /* X */ - ECL_SMSPEC_WELL_VAR = 4, /* X */ - ECL_SMSPEC_SEGMENT_VAR = 5, /* X */ - ECL_SMSPEC_BLOCK_VAR = 6, /* X */ - ECL_SMSPEC_AQUIFER_VAR = 7, - ECL_SMSPEC_COMPLETION_VAR = 8, /* X */ - ECL_SMSPEC_NETWORK_VAR = 9, - ECL_SMSPEC_REGION_2_REGION_VAR = 10, - ECL_SMSPEC_LOCAL_BLOCK_VAR = 11, /* X */ - ECL_SMSPEC_LOCAL_COMPLETION_VAR = 12, /* X */ - ECL_SMSPEC_LOCAL_WELL_VAR = 13, /* X */ - ECL_SMSPEC_MISC_VAR = 14 /* X */ -} ecl_smspec_var_type; + RD_SMSPEC_INVALID_VAR = 0, + RD_SMSPEC_FIELD_VAR = 1, /* X */ + RD_SMSPEC_REGION_VAR = 2, /* X */ + RD_SMSPEC_GROUP_VAR = 3, /* X */ + RD_SMSPEC_WELL_VAR = 4, /* X */ + RD_SMSPEC_SEGMENT_VAR = 5, /* X */ + RD_SMSPEC_BLOCK_VAR = 6, /* X */ + RD_SMSPEC_AQUIFER_VAR = 7, + RD_SMSPEC_COMPLETION_VAR = 8, /* X */ + RD_SMSPEC_NETWORK_VAR = 9, + RD_SMSPEC_REGION_2_REGION_VAR = 10, + RD_SMSPEC_LOCAL_BLOCK_VAR = 11, /* X */ + RD_SMSPEC_LOCAL_COMPLETION_VAR = 12, /* X */ + RD_SMSPEC_LOCAL_WELL_VAR = 13, /* X */ + RD_SMSPEC_MISC_VAR = 14 /* X */ +} rd_smspec_var_type; #define SMSPEC_NUMS_INVALID -991199 #define SMSPEC_NUMS_WELL 1 @@ -83,12 +83,12 @@ char *smspec_alloc_local_completion_key(const char *join_string, int k); bool smspec_node_identify_total(const char *keyword, - ecl_smspec_var_type var_type); + rd_smspec_var_type var_type); bool smspec_node_identify_rate(const char *keyword); bool smspec_node_equal(const void *node1, const void *node2); -void smspec_node_init(void *smspec_node, ecl_smspec_var_type var_type, +void smspec_node_init(void *smspec_node, rd_smspec_var_type var_type, const char *wgname, const char *keyword, const char *unit, const char *key_join_string, const int grid_dims[3], int num); @@ -98,7 +98,7 @@ void *smspec_node_alloc(int param_index, const char *keyword, const int grid_dims[3], float default_value, const char *key_join_string); -void *smspec_node_alloc_lgr(ecl_smspec_var_type var_type, const char *wgname, +void *smspec_node_alloc_lgr(rd_smspec_var_type var_type, const char *wgname, const char *keyword, const char *unit, const char *lgr, const char *key_join_string, int lgr_i, int lgr_j, int lgr_k, int param_index, @@ -112,7 +112,7 @@ void smspec_node_set_params_index(void *smspec_node, int params_index); int smspec_node_get_params_index(const void *smspec_node); const char *smspec_node_get_gen_key1(const void *smspec_node); const char *smspec_node_get_gen_key2(const void *smspec_node); -ecl_smspec_var_type smspec_node_get_var_type(const void *smspec_node); +rd_smspec_var_type smspec_node_get_var_type(const void *smspec_node); int smspec_node_get_num(const void *smspec_node); const char *smspec_node_get_wgname(const void *smspec_node); const char *smspec_node_get_keyword(const void *smspec_node); diff --git a/lib/include/resdata/smspec_node.hpp b/lib/include/resdata/smspec_node.hpp index 66804758b5..ac6c30dbd8 100644 --- a/lib/include/resdata/smspec_node.hpp +++ b/lib/include/resdata/smspec_node.hpp @@ -9,9 +9,9 @@ #include -#include +#include -namespace ecl { +namespace rd { class smspec_node { private: @@ -30,7 +30,7 @@ class smspec_node { gen_key1; /* The main composite key, i.e. WWCT:OP3 for this element. */ std::string gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Some of the region_2_region elements will have both a xxx:num and a xxx:r2-r2 key. Mostly NULL. */ - ecl_smspec_var_type var_type; /* The variable type */ + rd_smspec_var_type var_type; /* The variable type */ std::array ijk; /* The ijk coordinates (NB: OFFSET 1) corresponding to the nums value - will be NULL if not relevant. */ bool @@ -40,7 +40,7 @@ class smspec_node { int params_index; /* The index of this variable (applies to all the vectors - in particular the PARAMS vectors of the summary files *.Snnnn / *.UNSMRY ). */ float default_value; /* Default value for this variable. */ - static ecl_smspec_var_type identify_special_var(const char *var); + static rd_smspec_var_type identify_special_var(const char *var); void set_wgname(const char *wgname); void set_num(const int grid_dims[3], int num_); void set_gen_keys(const char *key_join_string_); @@ -48,8 +48,8 @@ class smspec_node { void set_lgr_ijk(int lgr_i, int lgr_j, int lgr_k); public: - static ecl_smspec_var_type valid_type(const char *keyword, - const char *wgname, int num); + static rd_smspec_var_type valid_type(const char *keyword, + const char *wgname, int num); int cmp(const smspec_node &node2) const; static int cmp(const smspec_node &node1, const smspec_node &node2); @@ -76,7 +76,7 @@ class smspec_node { const char *key_join_string); smspec_node(const smspec_node &node, int param_index); - static ecl_smspec_var_type identify_var_type(const char *var); + static rd_smspec_var_type identify_var_type(const char *var); static int cmp(const smspec_node *node1, const smspec_node *node2) { return node1->cmp(*node2); @@ -86,7 +86,7 @@ class smspec_node { int get_R2() const; const char *get_gen_key1() const; const char *get_gen_key2() const; - ecl_smspec_var_type get_var_type() const; + rd_smspec_var_type get_var_type() const; int get_num() const; const char *get_wgname() const; const char *get_keyword() const; @@ -103,6 +103,6 @@ class smspec_node { const std::array &get_lgr_ijk() const; }; -} // namespace ecl +} // namespace rd #endif diff --git a/lib/include/resdata/well/well_branch_collection.h b/lib/include/resdata/well/well_branch_collection.h index 8e8c1cd3e2..9e7d20b6dd 100644 --- a/lib/include/resdata/well/well_branch_collection.h +++ b/lib/include/resdata/well/well_branch_collection.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_branch_collection.hpp b/lib/include/resdata/well/well_branch_collection.hpp index 76e50ac35d..a4258da588 100644 --- a/lib/include/resdata/well/well_branch_collection.hpp +++ b/lib/include/resdata/well/well_branch_collection.hpp @@ -9,7 +9,7 @@ extern "C" { #include -#include +#include typedef struct well_branch_collection_struct well_branch_collection_type; diff --git a/lib/include/resdata/well/well_conn.h b/lib/include/resdata/well/well_conn.h index 25ba8559ab..d76f4cb124 100644 --- a/lib/include/resdata/well/well_conn.h +++ b/lib/include/resdata/well/well_conn.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_conn.hpp b/lib/include/resdata/well/well_conn.hpp index 3a7a5ba71d..1c57ce19f2 100644 --- a/lib/include/resdata/well/well_conn.hpp +++ b/lib/include/resdata/well/well_conn.hpp @@ -5,7 +5,7 @@ #include -#include +#include #ifdef __cplusplus extern "C" { @@ -40,13 +40,13 @@ well_conn_type *well_conn_alloc_fracture_MSW(int i, int j, int k, bool well_conn_MSW(const well_conn_type *conn); -well_conn_type *well_conn_alloc_from_kw(const ecl_kw_type *icon_kw, - const ecl_kw_type *scon_kw, - const ecl_kw_type *xcon_kw, - const ecl_rsthead_type *header, +well_conn_type *well_conn_alloc_from_kw(const rd_kw_type *icon_kw, + const rd_kw_type *scon_kw, + const rd_kw_type *xcon_kw, + const rd_rsthead_type *header, int well_nr, int conn_nr); -well_conn_type *well_conn_alloc_wellhead(const ecl_kw_type *iwel_kw, - const ecl_rsthead_type *header, +well_conn_type *well_conn_alloc_wellhead(const rd_kw_type *iwel_kw, + const rd_rsthead_type *header, int well_nr); int well_conn_get_i(const well_conn_type *conn); diff --git a/lib/include/resdata/well/well_conn_collection.h b/lib/include/resdata/well/well_conn_collection.h index 7ba6d73068..ec38f7ca6c 100644 --- a/lib/include/resdata/well/well_conn_collection.h +++ b/lib/include/resdata/well/well_conn_collection.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_conn_collection.hpp b/lib/include/resdata/well/well_conn_collection.hpp index ad74ad0a6f..2cf2dfee30 100644 --- a/lib/include/resdata/well/well_conn_collection.hpp +++ b/lib/include/resdata/well/well_conn_collection.hpp @@ -7,9 +7,9 @@ extern "C" { #include -#include +#include -#include +#include typedef struct well_conn_collection_struct well_conn_collection_type; @@ -27,11 +27,11 @@ void well_conn_collection_add(well_conn_collection_type *wellcc, void well_conn_collection_add_ref(well_conn_collection_type *wellcc, well_conn_type *conn); int well_conn_collection_load_from_kw(well_conn_collection_type *wellcc, - const ecl_kw_type *iwel_kw, - const ecl_kw_type *icon_kw, - const ecl_kw_type *scon_kw, - const ecl_kw_type *xcon_kw, int iwell, - const ecl_rsthead_type *rst_head); + const rd_kw_type *iwel_kw, + const rd_kw_type *icon_kw, + const rd_kw_type *scon_kw, + const rd_kw_type *xcon_kw, int iwell, + const rd_rsthead_type *rst_head); UTIL_IS_INSTANCE_HEADER(well_conn_collection); diff --git a/lib/include/resdata/well/well_const.h b/lib/include/resdata/well/well_const.h index 232fe1041c..6f83d36a67 100644 --- a/lib/include/resdata/well/well_const.h +++ b/lib/include/resdata/well/well_const.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_const.hpp b/lib/include/resdata/well/well_const.hpp index b07f43bbe0..26d9de2e4a 100644 --- a/lib/include/resdata/well/well_const.hpp +++ b/lib/include/resdata/well/well_const.hpp @@ -119,19 +119,19 @@ extern "C" { typedef enum { ERT_UNDOCUMENTED_ZERO = 0, // Deprecated - retained for Resinsight compatibility - ECL_WELL_ZERO = 0, + RD_WELL_ZERO = 0, ERT_PRODUCER = 1, // Deprecated - ECL_WELL_PRODUCER = 1, + RD_WELL_PRODUCER = 1, ERT_OIL_INJECTOR = 2, // Deprecated - ECL_WELL_OIL_INJECTOR = 2, + RD_WELL_OIL_INJECTOR = 2, ERT_WATER_INJECTOR = 3, // Deprecated - ECL_WELL_WATER_INJECTOR = 3, + RD_WELL_WATER_INJECTOR = 3, ERT_GAS_INJECTOR = 4, // Deprecated - ECL_WELL_GAS_INJECTOR = 4, + RD_WELL_GAS_INJECTOR = 4, } well_type_enum; #ifdef __cplusplus diff --git a/lib/include/resdata/well/well_info.h b/lib/include/resdata/well/well_info.h index b95b51c5b1..4bc5fef4d5 100644 --- a/lib/include/resdata/well/well_info.h +++ b/lib/include/resdata/well/well_info.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_info.hpp b/lib/include/resdata/well/well_info.hpp index 3ec26d1a49..5781764bdb 100644 --- a/lib/include/resdata/well/well_info.hpp +++ b/lib/include/resdata/well/well_info.hpp @@ -1,10 +1,10 @@ #ifndef ERT_WELL_INFO_H #define ERT_WELL_INFO_H -#include -#include +#include +#include -#include +#include #ifdef __cplusplus extern "C" { @@ -12,22 +12,22 @@ extern "C" { typedef struct well_info_struct well_info_type; -well_info_type *well_info_alloc(const ecl_grid_type *grid); +well_info_type *well_info_alloc(const rd_grid_type *grid); void well_info_add_UNRST_wells2(well_info_type *well_info, - ecl_file_view_type *rst_view, + rd_file_view_type *rst_view, bool load_segment_information); void well_info_add_UNRST_wells(well_info_type *well_info, - ecl_file_type *rst_file, + rd_file_type *rst_file, bool load_segment_information); -void well_info_add_wells(well_info_type *well_info, ecl_file_type *rst_file, +void well_info_add_wells(well_info_type *well_info, rd_file_type *rst_file, int report_nr, bool load_segment_information); void well_info_add_wells2(well_info_type *well_info, - ecl_file_view_type *rst_view, int report_nr, + rd_file_view_type *rst_view, int report_nr, bool load_segment_information); void well_info_load_rstfile(well_info_type *well_info, const char *filename, bool load_segment_information); void well_info_load_rst_eclfile(well_info_type *well_info, - ecl_file_type *rst_file, + rd_file_type *rst_file, bool load_segment_information); void well_info_free(well_info_type *well_info); diff --git a/lib/include/resdata/well/well_rseg_loader.h b/lib/include/resdata/well/well_rseg_loader.h index 7a68a6624c..b0a4d247ce 100644 --- a/lib/include/resdata/well/well_rseg_loader.h +++ b/lib/include/resdata/well/well_rseg_loader.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_rseg_loader.hpp b/lib/include/resdata/well/well_rseg_loader.hpp index 3fd1f330b2..9a8be56acd 100644 --- a/lib/include/resdata/well/well_rseg_loader.hpp +++ b/lib/include/resdata/well/well_rseg_loader.hpp @@ -5,11 +5,11 @@ extern "C" { #endif -#include +#include typedef struct well_rseg_loader_struct well_rseg_loader_type; -well_rseg_loader_type *well_rseg_loader_alloc(ecl_file_view_type *rst_view); +well_rseg_loader_type *well_rseg_loader_alloc(rd_file_view_type *rst_view); void well_rseg_loader_free(well_rseg_loader_type *well_rseg_loader); int well_rseg_loader_element_count( diff --git a/lib/include/resdata/well/well_segment.h b/lib/include/resdata/well/well_segment.h index 0b4dcdd13e..76011c3885 100644 --- a/lib/include/resdata/well/well_segment.h +++ b/lib/include/resdata/well/well_segment.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_segment.hpp b/lib/include/resdata/well/well_segment.hpp index 2ca4152daf..c6ae44cce2 100644 --- a/lib/include/resdata/well/well_segment.hpp +++ b/lib/include/resdata/well/well_segment.hpp @@ -7,19 +7,19 @@ extern "C" { #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include typedef struct well_segment_struct well_segment_type; well_segment_type * -well_segment_alloc_from_kw(const ecl_kw_type *iseg_kw, +well_segment_alloc_from_kw(const rd_kw_type *iseg_kw, const well_rseg_loader_type *rseg_loader, - const ecl_rsthead_type *header, int well_nr, + const rd_rsthead_type *header, int well_nr, int segment_index, int segment_id); well_segment_type *well_segment_alloc(int segment_id, int outlet_segment_id, int branch_id, const double *rseg_data); @@ -49,8 +49,8 @@ well_segment_get_connections(const well_segment_type *segment, const char *grid_name); const well_conn_collection_type * well_segment_get_global_connections(const well_segment_type *segment); -bool well_segment_well_is_MSW(int well_nr, const ecl_kw_type *iwel_kw, - const ecl_rsthead_type *rst_head); +bool well_segment_well_is_MSW(int well_nr, const rd_kw_type *iwel_kw, + const rd_rsthead_type *rst_head); double well_segment_get_depth(const well_segment_type *segment); double well_segment_get_length(const well_segment_type *segment); diff --git a/lib/include/resdata/well/well_segment_collection.h b/lib/include/resdata/well/well_segment_collection.h index 3da0d3dff2..290c8b638c 100644 --- a/lib/include/resdata/well/well_segment_collection.h +++ b/lib/include/resdata/well/well_segment_collection.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_segment_collection.hpp b/lib/include/resdata/well/well_segment_collection.hpp index de259da347..435847e681 100644 --- a/lib/include/resdata/well/well_segment_collection.hpp +++ b/lib/include/resdata/well/well_segment_collection.hpp @@ -7,12 +7,12 @@ extern "C" { #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include typedef struct well_segment_collection_struct well_segment_collection_type; @@ -32,8 +32,8 @@ well_segment_type *well_segment_collection_iget( const well_segment_collection_type *segment_collection, int index); int well_segment_collection_load_from_kw( well_segment_collection_type *segment_collection, int well_nr, - const ecl_kw_type *iwel_kw, const ecl_kw_type *iseg_kw, - const well_rseg_loader_type *rseg_loader, const ecl_rsthead_type *rst_head, + const rd_kw_type *iwel_kw, const rd_kw_type *iseg_kw, + const well_rseg_loader_type *rseg_loader, const rd_rsthead_type *rst_head, bool load_segment_information, bool *is_MSW_well); void well_segment_collection_link( diff --git a/lib/include/resdata/well/well_state.h b/lib/include/resdata/well/well_state.h index cd905ef505..d4bb315802 100644 --- a/lib/include/resdata/well/well_state.h +++ b/lib/include/resdata/well/well_state.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_state.hpp b/lib/include/resdata/well/well_state.hpp index 95f5803cb0..b61b1f1aee 100644 --- a/lib/include/resdata/well/well_state.hpp +++ b/lib/include/resdata/well/well_state.hpp @@ -3,14 +3,14 @@ #include -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -24,28 +24,28 @@ typedef struct well_state_struct well_state_type; well_state_type *well_state_alloc(const char *well_name, int global_well_nr, bool open, well_type_enum type, int report_nr, time_t valid_from); -well_state_type *well_state_alloc_from_file(ecl_file_type *ecl_file, - const ecl_grid_type *grid, +well_state_type *well_state_alloc_from_file(rd_file_type *rd_file, + const rd_grid_type *grid, int report_step, int well_nr, bool load_segment_information); -well_state_type *well_state_alloc_from_file2(ecl_file_view_type *file_view, - const ecl_grid_type *grid, +well_state_type *well_state_alloc_from_file2(rd_file_view_type *file_view, + const rd_grid_type *grid, int report_nr, int global_well_nr, bool load_segment_information); void well_state_add_connections2(well_state_type *well_state, - const ecl_grid_type *grid, - ecl_file_view_type *rst_view, int well_nr); + const rd_grid_type *grid, + rd_file_view_type *rst_view, int well_nr); void well_state_add_connections(well_state_type *well_state, - const ecl_grid_type *grid, - ecl_file_type *rst_file, int well_nr); + const rd_grid_type *grid, + rd_file_type *rst_file, int well_nr); -bool well_state_add_MSW(well_state_type *well_state, ecl_file_type *rst_file, +bool well_state_add_MSW(well_state_type *well_state, rd_file_type *rst_file, int well_nr, bool load_segment_information); bool well_state_add_MSW2(well_state_type *well_state, - ecl_file_view_type *rst_view, int well_nr, + rd_file_view_type *rst_view, int well_nr, bool load_segment_information); bool well_state_is_MSW(const well_state_type *well_state); @@ -72,7 +72,7 @@ well_state_iget_wellhead(const well_state_type *well_state, int grid_nr); const well_conn_type *well_state_get_wellhead(const well_state_type *well_state, const char *grid_name); -well_type_enum well_state_translate_ecl_type_int(int int_type); +well_type_enum well_state_translate_rd_type_int(int int_type); const well_conn_collection_type * well_state_get_grid_connections(const well_state_type *well_state, diff --git a/lib/include/resdata/well/well_ts.h b/lib/include/resdata/well/well_ts.h index 28d276c6eb..bd23fc6617 100644 --- a/lib/include/resdata/well/well_ts.h +++ b/lib/include/resdata/well/well_ts.h @@ -4,4 +4,4 @@ to switch to include the new hpp header directly in your code. */ -#include +#include diff --git a/lib/include/resdata/well/well_ts.hpp b/lib/include/resdata/well/well_ts.hpp index c06ec6e472..52c08a474a 100644 --- a/lib/include/resdata/well/well_ts.hpp +++ b/lib/include/resdata/well/well_ts.hpp @@ -1,7 +1,7 @@ #ifndef ERT_WELL_TS_H #define ERT_WELL_TS_H -#include +#include #ifdef __cplusplus extern "C" { diff --git a/lib/private-include/detail/resdata/layer_cxx.hpp b/lib/private-include/detail/resdata/layer_cxx.hpp index 69492c208b..22536b8df2 100644 --- a/lib/private-include/detail/resdata/layer_cxx.hpp +++ b/lib/private-include/detail/resdata/layer_cxx.hpp @@ -2,7 +2,7 @@ #define LAYER_CXX_HPP #include -#include +#include bool layer_trace_block_edge(const layer_type *layer, int i, int j, int value, std::vector &corner_list, diff --git a/lib/private-include/detail/resdata/rd_grid_cache.hpp b/lib/private-include/detail/resdata/rd_grid_cache.hpp index 62ade55b0a..3bc793e312 100644 --- a/lib/private-include/detail/resdata/rd_grid_cache.hpp +++ b/lib/private-include/detail/resdata/rd_grid_cache.hpp @@ -1,14 +1,14 @@ -#ifndef ERT_ECL_GRID_CACHE_H -#define ERT_ECL_GRID_CACHE_H +#ifndef ERT_RD_GRID_CACHE_H +#define ERT_RD_GRID_CACHE_H #include -#include +#include -namespace ecl { -class ecl_grid_cache { +namespace rd { +class rd_grid_cache { public: - ecl_grid_cache(const ecl_grid_type *grid); + rd_grid_cache(const rd_grid_type *grid); const std::vector &volume() const; const std::vector &xpos() const { return this->xp; } @@ -18,13 +18,13 @@ class ecl_grid_cache { int size() const { return this->xp.size(); } private: - const ecl_grid_type *grid; + const rd_grid_type *grid; std::vector gi; std::vector xp; std::vector yp; std::vector zp; mutable std::vector v; }; -} // namespace ecl +} // namespace rd #endif diff --git a/lib/private-include/detail/resdata/rd_sum_file_data.hpp b/lib/private-include/detail/resdata/rd_sum_file_data.hpp index 5843d64e9f..192fa5a152 100644 --- a/lib/private-include/detail/resdata/rd_sum_file_data.hpp +++ b/lib/private-include/detail/resdata/rd_sum_file_data.hpp @@ -5,11 +5,11 @@ #include -#include -#include -#include +#include +#include +#include -namespace ecl { +namespace rd { #define INVALID_MINISTEP_NR -1 #define INVALID_TIME_T 0 @@ -81,12 +81,12 @@ class TimeIndex { class unsmry_loader; -class ecl_sum_file_data { +class rd_sum_file_data { public: - ecl_sum_file_data(const ecl_smspec_type *smspec); - ~ecl_sum_file_data(); - const ecl_smspec_type *smspec() const; + rd_sum_file_data(const rd_smspec_type *smspec); + ~rd_sum_file_data(); + const rd_smspec_type *smspec() const; int length_before(time_t end_time) const; void get_time(int length, time_t *data); @@ -98,12 +98,12 @@ class ecl_sum_file_data { time_t iget_sim_time(int time_index) const; double iget_sim_days(int time_index) const; double iget_sim_seconds(int time_index) const; - ecl_sum_tstep_type *iget_ministep(int internal_index) const; + rd_sum_tstep_type *iget_ministep(int internal_index) const; double get_days_start() const; double get_sim_length() const; std::pair report_range(int report_step) const; - bool report_step_equal(const ecl_sum_file_data &other, bool strict) const; + bool report_step_equal(const rd_sum_file_data &other, bool strict) const; int report_before(time_t end_time) const; int get_time_report(int max_internal_index, time_t *data); int get_data_report(int params_index, int max_internal_index, double *data, @@ -115,26 +115,26 @@ class ecl_sum_file_data { int report_step_from_days(double sim_days) const; int report_step_from_time(time_t sim_time) const; - ecl_sum_tstep_type *add_new_tstep(int report_step, double sim_seconds); + rd_sum_tstep_type *add_new_tstep(int report_step, double sim_seconds); bool can_write() const; void fwrite_unified(fortio_type *fortio) const; - void fwrite_multiple(const char *ecl_case, bool fmt_case) const; + void fwrite_multiple(const char *rd_case, bool fmt_case) const; bool fread(const stringlist_type *filelist, bool lazy_load, int file_options); private: - const ecl_smspec_type *ecl_smspec; + const rd_smspec_type *rd_smspec; TimeIndex index; vector_type *data; - std::unique_ptr loader; + std::unique_ptr loader; - void append_tstep(ecl_sum_tstep_type *tstep); + void append_tstep(rd_sum_tstep_type *tstep); void build_index(); void fwrite_report(int report_step, fortio_type *fortio) const; - bool check_file(ecl_file_type *ecl_file); - void add_ecl_file(int report_step, const ecl_file_view_type *summary_view); + bool check_file(rd_file_type *rd_file); + void add_rd_file(int report_step, const rd_file_view_type *summary_view); }; -} // namespace ecl +} // namespace rd diff --git a/lib/private-include/detail/resdata/rd_unsmry_loader.hpp b/lib/private-include/detail/resdata/rd_unsmry_loader.hpp index b65f3e9c29..e1d0060762 100644 --- a/lib/private-include/detail/resdata/rd_unsmry_loader.hpp +++ b/lib/private-include/detail/resdata/rd_unsmry_loader.hpp @@ -3,14 +3,14 @@ #include #include -#include -#include +#include +#include -namespace ecl { +namespace rd { class unsmry_loader { public: - unsmry_loader(const ecl_smspec_type *smspec, const std::string &filename, + unsmry_loader(const rd_smspec_type *smspec, const std::string &filename, int file_options); ~unsmry_loader(); @@ -32,8 +32,8 @@ class unsmry_loader { int m_length; //Number of PARAMS in the UNSMRY file std::array date_index; - ecl_file_type *file; - ecl_file_view_type *file_view; + rd_file_type *file; + rd_file_view_type *file_view; }; -} // namespace ecl +} // namespace rd diff --git a/lib/private-include/detail/util/path.hpp b/lib/private-include/detail/util/path.hpp index a2d03d3cce..09e9b83a1f 100644 --- a/lib/private-include/detail/util/path.hpp +++ b/lib/private-include/detail/util/path.hpp @@ -2,7 +2,7 @@ #define PATH_UTIL #include -namespace ecl { +namespace rd { namespace util { namespace path { /* @@ -25,6 +25,6 @@ std::string basename(const std::string &fname); std::string extension(const std::string &fname); } // namespace path } // namespace util -} // namespace ecl +} // namespace rd #endif diff --git a/lib/private-include/detail/util/string_util.hpp b/lib/private-include/detail/util/string_util.hpp index b20e2c2ac8..d93e678549 100644 --- a/lib/private-include/detail/util/string_util.hpp +++ b/lib/private-include/detail/util/string_util.hpp @@ -1,11 +1,11 @@ -#ifndef ECL_STRING_UTIL -#define ECL_STRING_UTIL +#ifndef RD_STRING_UTIL +#define RD_STRING_UTIL #include -namespace ecl { +namespace rd { namespace util { std::string string_format(const char *fmt, ...); } -} // namespace ecl +} // namespace rd #endif diff --git a/lib/resdata/EclFilename.cpp b/lib/resdata/EclFilename.cpp index 4811a2f9c9..25fcac70b5 100644 --- a/lib/resdata/EclFilename.cpp +++ b/lib/resdata/EclFilename.cpp @@ -1,68 +1,68 @@ #include #include -#include +#include namespace ERT { -std::string EclFilename(const std::string &path, const std::string &base, - ecl_file_enum file_type, int report_step, - bool fmt_file) { - char *tmp = ecl_util_alloc_filename(path.c_str(), base.c_str(), file_type, - fmt_file, report_step); +std::string ResdataFilename(const std::string &path, const std::string &base, + rd_file_enum file_type, int report_step, + bool fmt_file) { + char *tmp = rd_alloc_filename(path.c_str(), base.c_str(), file_type, + fmt_file, report_step); std::string retval = tmp; free(tmp); return retval; } -std::string EclFilename(const std::string &base, ecl_file_enum file_type, - int report_step, bool fmt_file) { - char *tmp = ecl_util_alloc_filename(nullptr, base.c_str(), file_type, - fmt_file, report_step); +std::string ResdataFilename(const std::string &base, rd_file_enum file_type, + int report_step, bool fmt_file) { + char *tmp = rd_alloc_filename(nullptr, base.c_str(), file_type, fmt_file, + report_step); std::string retval = tmp; free(tmp); return retval; } namespace { -bool require_report_step(ecl_file_enum file_type) { - if ((file_type == ECL_RESTART_FILE) || (file_type == ECL_SUMMARY_FILE)) +bool require_report_step(rd_file_enum file_type) { + if ((file_type == RD_RESTART_FILE) || (file_type == RD_SUMMARY_FILE)) return true; else return false; } } // namespace -std::string EclFilename(const std::string &path, const std::string &base, - ecl_file_enum file_type, bool fmt_file) { +std::string ResdataFilename(const std::string &path, const std::string &base, + rd_file_enum file_type, bool fmt_file) { if (require_report_step(file_type)) throw std::runtime_error( "Must use overload with report step for this file type"); else { - char *tmp = ecl_util_alloc_filename(path.c_str(), base.c_str(), - file_type, fmt_file, -1); + char *tmp = rd_alloc_filename(path.c_str(), base.c_str(), file_type, + fmt_file, -1); std::string retval = tmp; free(tmp); return retval; } } -std::string EclFilename(const std::string &base, ecl_file_enum file_type, - bool fmt_file) { +std::string ResdataFilename(const std::string &base, rd_file_enum file_type, + bool fmt_file) { if (require_report_step(file_type)) throw std::runtime_error( "Must use overload with report step for this file type"); else { - char *tmp = ecl_util_alloc_filename(nullptr, base.c_str(), file_type, - fmt_file, -1); + char *tmp = + rd_alloc_filename(nullptr, base.c_str(), file_type, fmt_file, -1); std::string retval = tmp; free(tmp); return retval; } } -ecl_file_enum EclFiletype(const std::string &filename) { - return ecl_util_get_file_type(filename.c_str(), nullptr, nullptr); +rd_file_enum ResdataFiletype(const std::string &filename) { + return rd_get_file_type(filename.c_str(), nullptr, nullptr); } } // namespace ERT diff --git a/lib/resdata/FortIO.cpp b/lib/resdata/FortIO.cpp index c0f3e307b4..db9aef7559 100644 --- a/lib/resdata/FortIO.cpp +++ b/lib/resdata/FortIO.cpp @@ -2,7 +2,7 @@ #include -#include +#include namespace ERT { diff --git a/lib/resdata/fault_block.cpp b/lib/resdata/fault_block.cpp index b69d7ae547..8103a5bef7 100644 --- a/lib/resdata/fault_block.cpp +++ b/lib/resdata/fault_block.cpp @@ -7,19 +7,19 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include "detail/ecl/layer_cxx.hpp" +#include "detail/resdata/layer_cxx.hpp" #define FAULT_BLOCK_ID 3297376 struct fault_block_struct { UTIL_TYPE_ID_DECLARATION; - const ecl_grid_type *grid; + const rd_grid_type *grid; const fault_block_layer_type *parent_layer; int_vector_type *i_list; int_vector_type *j_list; @@ -77,7 +77,7 @@ void fault_block_add_cell(fault_block_type *fault_block, int i, int j) { int_vector_append(fault_block->j_list, j); int_vector_append( fault_block->global_index_list, - ecl_grid_get_global_index3(fault_block->grid, i, j, fault_block->k)); + rd_grid_get_global_index3(fault_block->grid, i, j, fault_block->k)); fault_block->valid_center = false; layer_iset_cell_value( fault_block_layer_get_layer(fault_block->parent_layer), i, j, @@ -109,11 +109,11 @@ static void fault_block_assert_center(fault_block_type *fault_block) { for (index = 0; index < int_vector_size(fault_block->i_list); index++) { int i = int_vector_iget(fault_block->i_list, index); int j = int_vector_iget(fault_block->j_list, index); - int g = ecl_grid_get_global_index3(fault_block->grid, i, j, - fault_block->k); + int g = rd_grid_get_global_index3(fault_block->grid, i, j, + fault_block->k); double x, y, z; - ecl_grid_get_xyz1(fault_block->grid, g, &x, &y, &z); + rd_grid_get_xyz1(fault_block->grid, g, &x, &y, &z); xc += x; yc += y; } @@ -141,7 +141,7 @@ void fault_block_export_cell(const fault_block_type *fault_block, int index, *j = int_vector_iget(fault_block->j_list, index); *k = fault_block->k; - ecl_grid_get_xyz3(fault_block->grid, *i, *j, *k, x, y, z); + rd_grid_get_xyz3(fault_block->grid, *i, *j, *k, x, y, z); } int fault_block_iget_i(const fault_block_type *fault_block, int index) { @@ -178,8 +178,8 @@ bool fault_block_trace_edge(const fault_block_type *block, for (const auto &p : corner_list) { double x, y, z; - ecl_grid_get_corner_xyz(block->grid, p.i, p.j, block->k, &x, &y, - &z); + rd_grid_get_corner_xyz(block->grid, p.i, p.j, block->k, &x, &y, + &z); double_vector_append(x_list, x); double_vector_append(y_list, y); } @@ -194,13 +194,13 @@ static bool fault_block_neighbour_xpolyline(const fault_block_type *block, int i1, int j1, int i2, int j2, const geo_polygon_collection_type *polylines) { - int g1 = ecl_grid_get_global_index3(block->grid, i1, j1, block->k); - int g2 = ecl_grid_get_global_index3(block->grid, i2, j2, block->k); + int g1 = rd_grid_get_global_index3(block->grid, i1, j1, block->k); + int g2 = rd_grid_get_global_index3(block->grid, i2, j2, block->k); double x1, y1, z1; double x2, y2, z2; - ecl_grid_get_xyz1(block->grid, g1, &x1, &y1, &z1); - ecl_grid_get_xyz1(block->grid, g2, &x2, &y2, &z2); + rd_grid_get_xyz1(block->grid, g1, &x1, &y1, &z1); + rd_grid_get_xyz1(block->grid, g2, &x2, &y2, &z2); { int polyline_index = 0; @@ -241,7 +241,7 @@ fault_block_connected_neighbour(const fault_block_type *block, int i1, int j1, Inactive cells do "not exist" - can not be connected neighbour with an inactive cell. */ - if (!ecl_grid_cell_active3(block->grid, i2, j2, block->k)) + if (!rd_grid_cell_active3(block->grid, i2, j2, block->k)) return false; { diff --git a/lib/resdata/fault_block_layer.cpp b/lib/resdata/fault_block_layer.cpp index e79e513715..e9b7968f52 100644 --- a/lib/resdata/fault_block_layer.cpp +++ b/lib/resdata/fault_block_layer.cpp @@ -3,11 +3,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define FAULT_BLOCK_LAYER_ID 2297476 @@ -32,7 +32,7 @@ void fault_block_free(fault_block_type *block, int block_id); struct fault_block_layer_struct { UTIL_TYPE_ID_DECLARATION; - const ecl_grid_type *grid; + const rd_grid_type *grid; int_vector_type *block_map; layer_type *layer; int k; @@ -89,7 +89,7 @@ void fault_block_layer_scan_layer(fault_block_layer_type *fault_layer, } /* - Observe that the id values from the ecl_kw instance are not + Observe that the id values from the rd_kw instance are not retained; the fault_block_layer instance gets new block id numbers, including a nonzero value for the cells which have value zero in the keyword. @@ -105,24 +105,23 @@ void fault_block_layer_scan_layer(fault_block_layer_type *fault_layer, */ bool fault_block_layer_scan_kw(fault_block_layer_type *layer, - const ecl_kw_type *fault_block_kw) { + const rd_kw_type *fault_block_kw) { bool assign_zero = true; - if (ecl_kw_get_size(fault_block_kw) != - ecl_grid_get_global_size(layer->grid)) + if (rd_kw_get_size(fault_block_kw) != rd_grid_get_global_size(layer->grid)) return false; - else if (!ecl_type_is_int(ecl_kw_get_data_type(fault_block_kw))) + else if (!rd_type_is_int(rd_kw_get_data_type(fault_block_kw))) return false; else { int i, j; int max_block_id = 0; - layer_type *work_layer = layer_alloc(ecl_grid_get_nx(layer->grid), - ecl_grid_get_ny(layer->grid)); + layer_type *work_layer = layer_alloc(rd_grid_get_nx(layer->grid), + rd_grid_get_ny(layer->grid)); - for (j = 0; j < ecl_grid_get_ny(layer->grid); j++) { - for (i = 0; i < ecl_grid_get_nx(layer->grid); i++) { - int g = ecl_grid_get_global_index3(layer->grid, i, j, layer->k); - int block_id = ecl_kw_iget_int(fault_block_kw, g); + for (j = 0; j < rd_grid_get_ny(layer->grid); j++) { + for (i = 0; i < rd_grid_get_nx(layer->grid); i++) { + int g = rd_grid_get_global_index3(layer->grid, i, j, layer->k); + int block_id = rd_kw_iget_int(fault_block_kw, g); if (block_id > 0) { layer_iset_cell_value(work_layer, i, j, block_id); @@ -147,19 +146,18 @@ bool fault_block_layer_scan_kw(fault_block_layer_type *layer, */ bool fault_block_layer_load_kw(fault_block_layer_type *layer, - const ecl_kw_type *fault_block_kw) { - if (ecl_kw_get_size(fault_block_kw) != - ecl_grid_get_global_size(layer->grid)) + const rd_kw_type *fault_block_kw) { + if (rd_kw_get_size(fault_block_kw) != rd_grid_get_global_size(layer->grid)) return false; - else if (!ecl_type_is_int(ecl_kw_get_data_type(fault_block_kw))) + else if (!rd_type_is_int(rd_kw_get_data_type(fault_block_kw))) return false; else { int i, j; - for (j = 0; j < ecl_grid_get_ny(layer->grid); j++) { - for (i = 0; i < ecl_grid_get_nx(layer->grid); i++) { - int g = ecl_grid_get_global_index3(layer->grid, i, j, layer->k); - int block_id = ecl_kw_iget_int(fault_block_kw, g); + for (j = 0; j < rd_grid_get_ny(layer->grid); j++) { + for (i = 0; i < rd_grid_get_nx(layer->grid); i++) { + int g = rd_grid_get_global_index3(layer->grid, i, j, layer->k); + int block_id = rd_kw_iget_int(fault_block_kw, g); if (block_id > 0) { fault_block_layer_add_block(layer, block_id); { @@ -175,9 +173,9 @@ bool fault_block_layer_load_kw(fault_block_layer_type *layer, } } -fault_block_layer_type *fault_block_layer_alloc(const ecl_grid_type *grid, +fault_block_layer_type *fault_block_layer_alloc(const rd_grid_type *grid, int k) { - if ((k < 0) || (k >= ecl_grid_get_nz(grid))) + if ((k < 0) || (k >= rd_grid_get_nz(grid))) return NULL; else { fault_block_layer_type *layer = @@ -187,8 +185,7 @@ fault_block_layer_type *fault_block_layer_alloc(const ecl_grid_type *grid, layer->k = k; layer->block_map = int_vector_alloc(0, -1); layer->blocks = vector_alloc_new(); - layer->layer = - layer_alloc(ecl_grid_get_nx(grid), ecl_grid_get_ny(grid)); + layer->layer = layer_alloc(rd_grid_get_nx(grid), rd_grid_get_ny(grid)); return layer; } @@ -287,17 +284,17 @@ void fault_block_layer_insert_block_content(fault_block_layer_type *layer, } bool fault_block_layer_export(const fault_block_layer_type *layer, - ecl_kw_type *faultblock_kw) { - if (ecl_type_is_int(ecl_kw_get_data_type(faultblock_kw)) && - (ecl_kw_get_size(faultblock_kw) == - ecl_grid_get_global_size(layer->grid))) { + rd_kw_type *faultblock_kw) { + if (rd_type_is_int(rd_kw_get_data_type(faultblock_kw)) && + (rd_kw_get_size(faultblock_kw) == + rd_grid_get_global_size(layer->grid))) { int i, j; - for (j = 0; j < ecl_grid_get_ny(layer->grid); j++) { - for (i = 0; i < ecl_grid_get_nx(layer->grid); i++) { - int g = ecl_grid_get_global_index3(layer->grid, i, j, layer->k); + for (j = 0; j < rd_grid_get_ny(layer->grid); j++) { + for (i = 0; i < rd_grid_get_nx(layer->grid); i++) { + int g = rd_grid_get_global_index3(layer->grid, i, j, layer->k); int cell_value = layer_iget_cell_value(layer->layer, i, j); - ecl_kw_iset_int(faultblock_kw, g, cell_value); + rd_kw_iset_int(faultblock_kw, g, cell_value); } } return true; @@ -305,7 +302,7 @@ bool fault_block_layer_export(const fault_block_layer_type *layer, return false; } -const ecl_grid_type * +const rd_grid_type * fault_block_layer_get_grid(const fault_block_layer_type *layer) { return layer->grid; } diff --git a/lib/resdata/fortio.c b/lib/resdata/fortio.c index 1fd3009aa4..2c2d5f6b47 100644 --- a/lib/resdata/fortio.c +++ b/lib/resdata/fortio.c @@ -24,7 +24,7 @@ #include #include -#include +#include #define FORTIO_ID 345116 diff --git a/lib/resdata/grid_dims.cpp b/lib/resdata/grid_dims.cpp index a4e973821b..184d9046ba 100644 --- a/lib/resdata/grid_dims.cpp +++ b/lib/resdata/grid_dims.cpp @@ -2,7 +2,7 @@ #include -#include +#include void grid_dims_init(grid_dims_type *dims, int nx, int ny, int nz, int nactive) { dims->nx = nx; diff --git a/lib/resdata/layer.cpp b/lib/resdata/layer.cpp index 61cdc4439f..6faea053fb 100644 --- a/lib/resdata/layer.cpp +++ b/lib/resdata/layer.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #define LAYER_TYPE_ID 55185409 @@ -762,12 +762,12 @@ int layer_count_equal(const layer_type *layer, int value) { return num_equal; } -void layer_update_active(layer_type *layer, const ecl_grid_type *grid, int k) { +void layer_update_active(layer_type *layer, const rd_grid_type *grid, int k) { int i, j; - for (j = 0; j < ecl_grid_get_ny(grid); j++) { - for (i = 0; i < ecl_grid_get_nx(grid); i++) { + for (j = 0; j < rd_grid_get_ny(grid); j++) { + for (i = 0; i < rd_grid_get_nx(grid); i++) { cell_type *cell = layer_iget_cell(layer, i, j); - cell->active = ecl_grid_cell_active3(grid, i, j, k); + cell->active = rd_grid_cell_active3(grid, i, j, k); } } } diff --git a/lib/resdata/nnc_info.cpp b/lib/resdata/nnc_info.cpp index 9b1444a420..d83b3b0e8c 100644 --- a/lib/resdata/nnc_info.cpp +++ b/lib/resdata/nnc_info.cpp @@ -9,9 +9,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define NNC_INFO_TYPE_ID 675415078 diff --git a/lib/resdata/nnc_vector.cpp b/lib/resdata/nnc_vector.cpp index 0fb3c78fac..c140d8647f 100644 --- a/lib/resdata/nnc_vector.cpp +++ b/lib/resdata/nnc_vector.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #define NNC_VECTOR_TYPE_ID 875615078 diff --git a/lib/resdata/overview.txt b/lib/resdata/overview.txt index 4f578adbe1..72e4e4a90c 100644 --- a/lib/resdata/overview.txt +++ b/lib/resdata/overview.txt @@ -17,42 +17,42 @@ three different layers in the resdata library: [High level]: At the highest level are function which implement functionality to work with spesific ECLIPSE files, these are - ecl_sum.c for summaryfiles, ecl_rft_file for rft files and - ecl_grid for GRID files. + rd_sum.c for summaryfiles, rd_rft_file for rft files and + rd_grid for GRID files. [Medium level]: At the medium level is only one file - the - ecl_file.c file which is to work with one arbitrary eclipse file + rd_file.c file which is to work with one arbitrary eclipse file with restart-like keywords. All the high level functions depend on this functionality. [Core level]: At the lowest level are functions to read/write binary - fortran files, ecl_kw to read *ONE* ECLIPSE keyword in restart - form and ecl_util which knows all filename conventions and so on + fortran files, rd_kw to read *ONE* ECLIPSE keyword in restart + form and rd_util which knows all filename conventions and so on for ECLIPSE. Unfortuntaely the lowest level shines through the medium level - i.e. nearly all the files in the [High level] and - [Medium level] depend explicitly on at least ecl_util and ecl_kw + [Medium level] depend explicitly on at least rd_util and rd_kw form the [Core level]. ---------------------------------------------------------------------- _______________________________________________________ / \ - | ecl_rft_file.c | + | rd_rft_file.c | | --------------------------------------------------------| - | ecl_rft_file.c: This file parses one X.RFT file, and | + | rd_rft_file.c: This file parses one X.RFT file, and | | internalizes the results in the form of a vector of |------->--------------\ | ecL_rft_node instances. The functions in this file | \ | are quite 'thin' - most of the functionality is | \ - | implemented in the ecl_rft_node layer. | \ + | implemented in the rd_rft_node layer. | \ \_______________________________________________________/ | | | | | | | | | | ______________________\|/_________ | | / \ | | - | ecl_rft_node.c | | | + | rd_rft_node.c | | | | ---------------------------------- | | | - | ecl_rft_node.c: This file |------------------------------------>---------------------------| + | rd_rft_node.c: This file |------------------------------------>---------------------------| | implements a RFT/PLT node for one | | | | time/well. | | | \__________________________________/ | | @@ -61,13 +61,13 @@ three different layers in the resdata library: | | | _________________________________________________ | | ________________________________________ | / \ | | / \ | - | ecl_sum.c | | | | ecl_grid.c | | + | rd_sum.c | | | | rd_grid.c | | | ------------------------------------------------- | | | | ---------------------------------------- | | - | The file ecl_sum.c implements the ecl_sum_type | | | | The file ecl_grid.c implements the type | | - | which is used to load summary files, and do | | | | ecl_grid_type. The functionality impl- | | - | queries on them. The ecl_sum type is a quite thin | | | | emented in ecl_grid.c is to load itself | | - | wrapper, containg a ecl_sum_data instance for the | | | | from an existing EGRID or GRID file. | | - | actual data, and a ecl_smspec instance for the | | | \________________________________________/ | + | The file rd_sum.c implements the rd_sum_type | | | | The file rd_grid.c implements the type | | + | which is used to load summary files, and do | | | | rd_grid_type. The functionality impl- | | + | queries on them. The rd_sum type is a quite thin | | | | emented in rd_grid.c is to load itself | | + | wrapper, containg a rd_sum_data instance for the | | | | from an existing EGRID or GRID file. | | + | actual data, and a rd_smspec instance for the | | | \________________________________________/ | | header information. | | | | | | | \_________________________________________________/ \ | | | | | | | \__________ \ | | | | @@ -75,12 +75,12 @@ three different layers in the resdata library: | | \ \ | | | | ____________________________\|/__________ _______\|/_______________________________\ \ | | | | / \ / \\ | | | | | - | ecl_smspec.c | | ecl_sum_data.c |\ | | | | | + | rd_smspec.c | | rd_sum_data.c |\ | | | | | | ----------------------------------------- | | ----------------------------------------- | | | | | | | - | The file ecl_smspec.c implements | | The file ecl_sum_data.c implements | | | | | | | + | The file rd_smspec.c implements | | The file rd_sum_data.c implements | | | | | | | | functions to parse and internalize the | | functions to parse and internalize the | | | | | | | | SMSPEC file. When asking to get e.g WWCT | | summary data, i.e. the BASE.Snnnn or |-|-|-|->----| | | | - | in well P2, the ecl_smspec object will | | BASE.UNSMRY files. All time information | | | | | | | | + | in well P2, the rd_smspec object will | | BASE.UNSMRY files. All time information | | | | | | | | | now which index in ECLIPSE PARAMS vector | | is handeled by this file. | | | | | | | | | that data has. | | | | | | | | | | \_________________________________________/ \_________________________________________/ | | | | | | | @@ -89,16 +89,16 @@ three different layers in the resdata library: | | | | | | | | | | | _\|/_______________\|/________________________________\|_|_|/_ | | | | | / \ | | | | - | | ecl_file.c | \|/ | | \|/ + | | rd_file.c | \|/ | | \|/ | | -------------------------------------------------------------- | | | | | - | | The ecl_file file implements functinality to load a an | | | | | - | | ECLIPSE file consisting of ecl_kw_type vectors. The ecl_file | | | | | + | | The rd_file file implements functinality to load a an | | | | | + | | ECLIPSE file consisting of rd_kw_type vectors. The rd_file | | | | | |-----------------------------| instance can either be used to load fthe full content of a | | | | | | | | file, or it can stop loading when a certain keyowrd is | | | | | | | | reached. The latter is useful for loading parts of a unified | | | | | | | | summary/restart file. | | | | | - | | | ecl_file is a simplification of the functionality which | | | | | - | | | prevously existed in ecl_block/ecl_fstate. | | | | | + | | | rd_file is a simplification of the functionality which | | | | | + | | | prevously existed in rd_block/rd_fstate. | | | | | | | \______________________________________________________________/ | | | | | | | | | \|/ | | | | | | | | | | @@ -107,10 +107,10 @@ three different layers in the resdata library: | | | | | | | | | ___\|/___________\|/____________________ | | | | | | / \ | | | | | - | | ecl_kw.c | | | | | | + | | rd_kw.c | | | | | | | | ---------------------------------------- | | | | | | - | | The file ecl_kw.c implements the type |<------|--------------<-----------------| | | | - | | ecl_kw_type. This is the lowest level | | | | | | + | | The file rd_kw.c implements the type |<------|--------------<-----------------| | | | + | | rd_kw_type. This is the lowest level | | | | | | | | function in the resdata type hierarchy. | | | | | | | | |<------|-------<------------|--------------| | | | | ECLIPSE restart files, summary files, | | | | | @@ -121,7 +121,7 @@ three different layers in the resdata library: | | * SIZE (number of elements) | | | | | | | * TYPE (float/double/int/logical/char) | | \|/ | | | | * DATA | | | | | - | | An ecl_kw instance contains one such | | | | | + | | An rd_kw instance contains one such | | | | | | | basic building block. | | | | | | \________________________________________/ | | | | | || | |------------- | \|/ @@ -132,16 +132,16 @@ three different layers in the resdata library: | | | | | | | _____\|/_____________\|/________________ _________\|/_________\|/_____\|/_____ | | / \ / \ | | -| fortio.c | | ecl_util.c | | | +| fortio.c | | rd_util.c | | | | ---------------------------------------- | | ------------------------------------- | | | -| ECLIPSE is written in Fortran; the | | The ecl_util.c file implements a | | | +| ECLIPSE is written in Fortran; the | | The rd_util.c file implements a | | | | Fortran runtime library adds a header & | | number of small utility functions for | | | | tail when it writes binary data. | | working with ECLIPSE. Typically func- | | | | | | tions to determine the type of a file | | | | The fortio file implements the | | from the name, and oppsite functions |<----------------------------| | | fortio_type struct which is used to read | | to create an ECLIPSE filename. | | | and write binary Fortran files in a | | | | -| transparent manner. | | All the functions in ecl_util.c are |<----------------------------------------------/ +| transparent manner. | | All the functions in rd_util.c are |<----------------------------------------------/ \________________________________________/ | stateless. | \_____________________________________/ diff --git a/lib/resdata/rd_box.cpp b/lib/resdata/rd_box.cpp index ecc5bf7c2a..70f0f6be87 100644 --- a/lib/resdata/rd_box.cpp +++ b/lib/resdata/rd_box.cpp @@ -4,12 +4,12 @@ #include -#include -#include +#include +#include -namespace ecl { -ecl_box::ecl_box(const ecl_grid_type *grid, int i1, int i2, int j1, int j2, - int k1, int k2) +namespace rd { +rd_box::rd_box(const rd_grid_type *grid, int i1, int i2, int j1, int j2, int k1, + int k2) : grid(grid), i1(std::min(i1, i2)), i2(std::max(i1, i2)), j1(std::min(j1, j2)), j2(std::max(j1, j2)), k1(std::min(k1, k2)), k2(std::max(k1, k2)) { @@ -17,16 +17,16 @@ ecl_box::ecl_box(const ecl_grid_type *grid, int i1, int i2, int j1, int j2, for (int j = this->j1; j <= this->j2; j++) for (int i = this->i1; i <= this->i2; i++) { int active_index = - ecl_grid_get_active_index3(this->grid, i, j, k); + rd_grid_get_active_index3(this->grid, i, j, k); if (active_index >= 0) this->active_index_list.push_back(active_index); this->global_index_list.push_back( - ecl_grid_get_global_index3(this->grid, i, j, k)); + rd_grid_get_global_index3(this->grid, i, j, k)); } } -const std::vector &ecl_box::active_list() const { +const std::vector &rd_box::active_list() const { return this->active_index_list; } -} // namespace ecl +} // namespace rd diff --git a/lib/resdata/rd_coarse_cell.cpp b/lib/resdata/rd_coarse_cell.cpp index c40177659e..aef3bc3b9c 100644 --- a/lib/resdata/rd_coarse_cell.cpp +++ b/lib/resdata/rd_coarse_cell.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include /* @@ -68,12 +68,12 @@ current grid active_index == 3 will point to the coarse cell, and all the cells in the coarse region will: - - ecl_grid_cell_active1( grid , global_index) => True - - ecl_grid_get_active_index1( grid , global_index) => 3 + - rd_grid_cell_active1( grid , global_index) => True + - rd_grid_get_active_index1( grid , global_index) => 3 -For the example above the ecl_coarse_cell datastructure would have the +For the example above the rd_coarse_cell datastructure would have the following content: ijk = {0 , 5 , 0 , 4 , k1 , k2 } @@ -84,9 +84,9 @@ following content: */ -#define ECL_COARSE_CELL_TYPE_ID 91554106 +#define RD_COARSE_CELL_TYPE_ID 91554106 -struct ecl_coarse_cell_struct { +struct rd_coarse_cell_struct { UTIL_TYPE_ID_DECLARATION; int ijk[6]; // {i1, i2 , j1 , j2 , k1 , k2} int active_index; @@ -98,9 +98,9 @@ struct ecl_coarse_cell_struct { int_vector_type *active_values; }; -static UTIL_SAFE_CAST_FUNCTION(ecl_coarse_cell, ECL_COARSE_CELL_TYPE_ID) +static UTIL_SAFE_CAST_FUNCTION(rd_coarse_cell, RD_COARSE_CELL_TYPE_ID) - void ecl_coarse_cell_assert(ecl_coarse_cell_type *coarse_cell) { + void rd_coarse_cell_assert(rd_coarse_cell_type *coarse_cell) { int box_size = (1 + coarse_cell->ijk[1] - coarse_cell->ijk[0]) * (1 + coarse_cell->ijk[2] - coarse_cell->ijk[3]) * (1 + coarse_cell->ijk[4] - coarse_cell->ijk[5]); @@ -111,11 +111,11 @@ static UTIL_SAFE_CAST_FUNCTION(ecl_coarse_cell, ECL_COARSE_CELL_TYPE_ID) __func__, box_size, int_vector_size(coarse_cell->cell_list)); } -ecl_coarse_cell_type *ecl_coarse_cell_alloc() { +rd_coarse_cell_type *rd_coarse_cell_alloc() { const int LARGE = 1 << 30; - ecl_coarse_cell_type *coarse_cell = - (ecl_coarse_cell_type *)util_malloc(sizeof *coarse_cell); - UTIL_TYPE_ID_INIT(coarse_cell, ECL_COARSE_CELL_TYPE_ID); + rd_coarse_cell_type *coarse_cell = + (rd_coarse_cell_type *)util_malloc(sizeof *coarse_cell); + UTIL_TYPE_ID_INIT(coarse_cell, RD_COARSE_CELL_TYPE_ID); coarse_cell->ijk[0] = LARGE; coarse_cell->ijk[2] = LARGE; @@ -134,8 +134,8 @@ ecl_coarse_cell_type *ecl_coarse_cell_alloc() { return coarse_cell; } -bool ecl_coarse_cell_equal(const ecl_coarse_cell_type *coarse_cell1, - const ecl_coarse_cell_type *coarse_cell2) { +bool rd_coarse_cell_equal(const rd_coarse_cell_type *coarse_cell1, + const rd_coarse_cell_type *coarse_cell2) { bool equal = true; if (coarse_cell1->active_index != coarse_cell2->active_index) equal = false; @@ -163,8 +163,8 @@ bool ecl_coarse_cell_equal(const ecl_coarse_cell_type *coarse_cell1, int_vector_equal(coarse_cell1->cell_list, coarse_cell2->cell_list); if (!equal) { - ecl_coarse_cell_fprintf(coarse_cell1, stdout); - ecl_coarse_cell_fprintf(coarse_cell2, stdout); + rd_coarse_cell_fprintf(coarse_cell1, stdout); + rd_coarse_cell_fprintf(coarse_cell2, stdout); } return equal; @@ -175,8 +175,8 @@ bool ecl_coarse_cell_equal(const ecl_coarse_cell_type *coarse_cell1, not checked. */ -void ecl_coarse_cell_update(ecl_coarse_cell_type *coarse_cell, int i, int j, - int k, int global_index) { +void rd_coarse_cell_update(rd_coarse_cell_type *coarse_cell, int i, int j, + int k, int global_index) { coarse_cell->ijk[0] = util_int_min(coarse_cell->ijk[0], i); coarse_cell->ijk[2] = util_int_min(coarse_cell->ijk[2], j); coarse_cell->ijk[4] = util_int_min(coarse_cell->ijk[4], k); @@ -188,84 +188,82 @@ void ecl_coarse_cell_update(ecl_coarse_cell_type *coarse_cell, int i, int j, int_vector_append(coarse_cell->cell_list, global_index); } -void ecl_coarse_cell_free(ecl_coarse_cell_type *coarse_cell) { +void rd_coarse_cell_free(rd_coarse_cell_type *coarse_cell) { int_vector_free(coarse_cell->cell_list); int_vector_free(coarse_cell->active_cells); int_vector_free(coarse_cell->active_values); free(coarse_cell); } -void ecl_coarse_cell_free__(void *arg) { - ecl_coarse_cell_type *coarse_cell = ecl_coarse_cell_safe_cast(arg); - ecl_coarse_cell_free(coarse_cell); +void rd_coarse_cell_free__(void *arg) { + rd_coarse_cell_type *coarse_cell = rd_coarse_cell_safe_cast(arg); + rd_coarse_cell_free(coarse_cell); } -static void ecl_coarse_cell_sort(ecl_coarse_cell_type *coarse_cell) { +static void rd_coarse_cell_sort(rd_coarse_cell_type *coarse_cell) { if (!coarse_cell->__cell_list_sorted) { int_vector_sort(coarse_cell->cell_list); coarse_cell->__cell_list_sorted = true; } } -int ecl_coarse_cell_get_size(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_size(const rd_coarse_cell_type *coarse_cell) { return int_vector_size(coarse_cell->cell_list); } -int ecl_coarse_cell_iget_cell_index(ecl_coarse_cell_type *coarse_cell, - int group_index) { - ecl_coarse_cell_sort(coarse_cell); +int rd_coarse_cell_iget_cell_index(rd_coarse_cell_type *coarse_cell, + int group_index) { + rd_coarse_cell_sort(coarse_cell); return int_vector_iget(coarse_cell->cell_list, group_index); } -const int *ecl_coarse_cell_get_index_ptr(ecl_coarse_cell_type *coarse_cell) { - ecl_coarse_cell_sort(coarse_cell); +const int *rd_coarse_cell_get_index_ptr(rd_coarse_cell_type *coarse_cell) { + rd_coarse_cell_sort(coarse_cell); return int_vector_get_const_ptr(coarse_cell->cell_list); } const int_vector_type * -ecl_coarse_cell_get_index_vector(ecl_coarse_cell_type *coarse_cell) { - ecl_coarse_cell_sort(coarse_cell); +rd_coarse_cell_get_index_vector(rd_coarse_cell_type *coarse_cell) { + rd_coarse_cell_sort(coarse_cell); return coarse_cell->cell_list; } -int ecl_coarse_cell_get_i1(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_i1(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk[0]; } -int ecl_coarse_cell_get_i2(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_i2(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk[1]; } -int ecl_coarse_cell_get_j1(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_j1(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk[2]; } -int ecl_coarse_cell_get_j2(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_j2(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk[3]; } -int ecl_coarse_cell_get_k1(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_k1(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk[4]; } -int ecl_coarse_cell_get_k2(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_k2(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk[5]; } -const int * -ecl_coarse_cell_get_box_ptr(const ecl_coarse_cell_type *coarse_cell) { +const int *rd_coarse_cell_get_box_ptr(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->ijk; } -void ecl_coarse_cell_reset_active_index(ecl_coarse_cell_type *coarse_cell) { +void rd_coarse_cell_reset_active_index(rd_coarse_cell_type *coarse_cell) { coarse_cell->active_index = -1; coarse_cell->active_fracture_index = -1; } -void ecl_coarse_cell_update_index(ecl_coarse_cell_type *coarse_cell, - int global_index, int *active_index, - int *active_fracture_index, - int active_value) { +void rd_coarse_cell_update_index(rd_coarse_cell_type *coarse_cell, + int global_index, int *active_index, + int *active_fracture_index, int active_value) { if (active_value & CELL_ACTIVE_MATRIX) { if (coarse_cell->active_index == -1) { coarse_cell->active_index = *active_index; @@ -293,12 +291,12 @@ void ecl_coarse_cell_update_index(ecl_coarse_cell_type *coarse_cell, } } -int ecl_coarse_cell_get_active_index(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_active_index(const rd_coarse_cell_type *coarse_cell) { return coarse_cell->active_index; } -int ecl_coarse_cell_get_active_fracture_index( - const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_active_fracture_index( + const rd_coarse_cell_type *coarse_cell) { return coarse_cell->active_fracture_index; } @@ -306,22 +304,22 @@ int ecl_coarse_cell_get_active_fracture_index( Will return the global index of the 'ith active cell in the coarse cell. */ -int ecl_coarse_cell_iget_active_cell_index( - const ecl_coarse_cell_type *coarse_cell, int index) { +int rd_coarse_cell_iget_active_cell_index( + const rd_coarse_cell_type *coarse_cell, int index) { return int_vector_iget(coarse_cell->active_cells, index); } -int ecl_coarse_cell_iget_active_value(const ecl_coarse_cell_type *coarse_cell, - int index) { +int rd_coarse_cell_iget_active_value(const rd_coarse_cell_type *coarse_cell, + int index) { return int_vector_iget(coarse_cell->active_values, index); } -int ecl_coarse_cell_get_num_active(const ecl_coarse_cell_type *coarse_cell) { +int rd_coarse_cell_get_num_active(const rd_coarse_cell_type *coarse_cell) { return int_vector_size(coarse_cell->active_cells); } -void ecl_coarse_cell_fprintf(const ecl_coarse_cell_type *coarse_cell, - FILE *stream) { +void rd_coarse_cell_fprintf(const rd_coarse_cell_type *coarse_cell, + FILE *stream) { fprintf(stream, "Coarse box: \n"); fprintf(stream, " i : %3d - %3d\n", coarse_cell->ijk[0], coarse_cell->ijk[1]); diff --git a/lib/resdata/rd_file.cpp b/lib/resdata/rd_file.cpp index 75b61b4f34..39f01f7015 100644 --- a/lib/resdata/rd_file.cpp +++ b/lib/resdata/rd_file.cpp @@ -10,37 +10,37 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** This file implements functionality to load an ECLIPSE file in - ecl_kw format. The implementation works by first searching through + rd_kw format. The implementation works by first searching through the complete file to create an index over all the keywords present in the file. The actual keyword data is not loaded before they are explicitly requested. - The ecl_file_type is the middle layer of abstraction in the resdata + The rd_file_type is the middle layer of abstraction in the resdata hierarchy (see the file overview.txt in this directory); it works - with a collection of ecl_kw instances and has various query + with a collection of rd_kw instances and has various query functions, however it does not utilize knowledge of the - structure/content of the files in the way e.g. ecl_grid.c does[1]. + structure/content of the files in the way e.g. rd_grid.c does[1]. - The main datatype here is the ecl_file type, but in addition each - ecl_kw instance is wrapped in an ecl_file_kw (implemented in - ecl_file_kw.c) structure and all the indexing is implemented with - the ecl_file_view type. The ecl_file_view type is not used outside this file. + The main datatype here is the rd_file type, but in addition each + rd_kw instance is wrapped in an rd_file_kw (implemented in + rd_file_kw.c) structure and all the indexing is implemented with + the rd_file_view type. The rd_file_view type is not used outside this file. When the file is opened an index of all the keywords is created and stored in the field global_map, and the field active_view is set to - point to global_map, i.e. all query/get operations on the ecl_file + point to global_map, i.e. all query/get operations on the rd_file will be based on the complete index: In many cases (in particular for unified restart files) it is quite @@ -74,43 +74,43 @@ For the unified summary file depicted here e.g. the call - ecl_file_get_blockmap( ecl_file , "SEQHDR" , 2 ) + rd_file_get_blockmap( rd_file , "SEQHDR" , 2 ) Will create a sub-index consisting of the (three) keywords in what is called 'Block 2' in the figure above. In particular for restart files this abstraction is very convenient, because an extra layer of functionality is required to get from natural time coordinates (i.e. simulation time or report step) to the occurence number (see - ecl_rstfile for more details). + rd_rstfile for more details). To select a subindex as the active index you use the - ecl_file_select_block() function, or alternatively you can use - ecl_file_open_block() to directly select the relevant block + rd_file_select_block() function, or alternatively you can use + rd_file_open_block() to directly select the relevant block immediately after the open() statement. Observe that when using a - sub index thorugh ecl_file_select_block() function the global_map - will still be present in the ecl_file instance, and subsequent + sub index thorugh rd_file_select_block() function the global_map + will still be present in the rd_file instance, and subsequent calls to create a new sub index will also use the global_map index - i.e. the indexing is not recursive, a sub index is always created based on the global_map, and not on the currently active map. - [1]: This is not entirely true - in the file ecl_rstfile.c; which + [1]: This is not entirely true - in the file rd_rstfile.c; which is included from this file are several specialized function for working with restart files. However the restart files are - still treated as collections of ecl_kw instances, and not - internalized as in e.g. ecl_sum. + still treated as collections of rd_kw instances, and not + internalized as in e.g. rd_sum. */ -#define ECL_FILE_ID 776107 +#define RD_FILE_ID 776107 -struct ecl_file_struct { +struct rd_file_struct { UTIL_TYPE_ID_DECLARATION; fortio_type *fortio; /* The source of all the keywords - must be retained open for reading for the entire lifetime of the - ecl_file object. */ - ecl_file_view_type - *global_view; /* The index of all the ecl_kw instances in the file. */ - ecl_file_view_type *active_view; /* The currently active index. */ + rd_file object. */ + rd_file_view_type + *global_view; /* The index of all the rd_kw instances in the file. */ + rd_file_view_type *active_view; /* The currently active index. */ bool read_only; int flags; vector_type *map_stack; @@ -118,8 +118,8 @@ struct ecl_file_struct { }; /* - This illustrates the indexing. The ecl_file instance contains in - total 7 ecl_kw instances, the global index [0...6] is the internal + This illustrates the indexing. The rd_file instance contains in + total 7 rd_kw instances, the global index [0...6] is the internal way to access the various keywords. The kw_index is a hash table with entries 'SEQHDR', 'MINISTEP' and 'PARAMS'. Each entry in the hash table is an integer vector which again contains the internal @@ -141,21 +141,21 @@ struct ecl_file_struct { */ -UTIL_SAFE_CAST_FUNCTION(ecl_file, ECL_FILE_ID) -UTIL_IS_INSTANCE_FUNCTION(ecl_file, ECL_FILE_ID) +UTIL_SAFE_CAST_FUNCTION(rd_file, RD_FILE_ID) +UTIL_IS_INSTANCE_FUNCTION(rd_file, RD_FILE_ID) -ecl_file_type *ecl_file_alloc_empty(int flags) { - ecl_file_type *ecl_file = (ecl_file_type *)util_malloc(sizeof *ecl_file); - UTIL_TYPE_ID_INIT(ecl_file, ECL_FILE_ID); - ecl_file->map_stack = vector_alloc_new(); - ecl_file->inv_view = inv_map_alloc(); - ecl_file->flags = flags; - return ecl_file; +rd_file_type *rd_file_alloc_empty(int flags) { + rd_file_type *rd_file = (rd_file_type *)util_malloc(sizeof *rd_file); + UTIL_TYPE_ID_INIT(rd_file, RD_FILE_ID); + rd_file->map_stack = vector_alloc_new(); + rd_file->inv_view = inv_map_alloc(); + rd_file->flags = flags; + return rd_file; } -void ecl_file_fwrite_fortio(const ecl_file_type *ecl_file, fortio_type *target, - int offset) { - ecl_file_view_fwrite(ecl_file->active_view, target, offset); +void rd_file_fwrite_fortio(const rd_file_type *rd_file, fortio_type *target, + int offset) { + rd_file_view_fwrite(rd_file->active_view, target, offset); } /* @@ -164,50 +164,50 @@ void ecl_file_fwrite_fortio(const ecl_file_type *ecl_file, fortio_type *target, is NOT consulted. */ -void ecl_file_fwrite(const ecl_file_type *ecl_file, const char *filename, - bool fmt_file) { +void rd_file_fwrite(const rd_file_type *rd_file, const char *filename, + bool fmt_file) { bool __fmt_file; - ecl_file_enum file_type; + rd_file_enum file_type; - file_type = ecl_util_get_file_type(filename, &__fmt_file, NULL); - if (file_type == ECL_OTHER_FILE) + file_type = rd_get_file_type(filename, &__fmt_file, NULL); + if (file_type == RD_OTHER_FILE) __fmt_file = fmt_file; { fortio_type *target = - fortio_open_writer(filename, __fmt_file, ECL_ENDIAN_FLIP); - ecl_file_fwrite_fortio(ecl_file, target, 0); + fortio_open_writer(filename, __fmt_file, RD_ENDIAN_FLIP); + rd_file_fwrite_fortio(rd_file, target, 0); fortio_fclose(target); } } /** - Here comes several functions for querying the ecl_file instance, and - getting pointers to the ecl_kw content of the ecl_file. For getting - ecl_kw instances there are two principally different access methods: + Here comes several functions for querying the rd_file instance, and + getting pointers to the rd_kw content of the rd_file. For getting + rd_kw instances there are two principally different access methods: - * ecl_file_iget_named_kw(): This function will take a keyword + * rd_file_iget_named_kw(): This function will take a keyword (char *) and an integer as input. The integer corresponds to the ith occurence of the keyword in the file. - * ecl_file_iget_kw(): This function just takes an integer index as - input, and returns the corresponding ecl_kw instance - without + * rd_file_iget_kw(): This function just takes an integer index as + input, and returns the corresponding rd_kw instance - without considering which keyword it is. ------- - In addition the functions ecl_file_get_num_distinct_kw() and - ecl_file_iget_distinct_kw() will return the number of distinct + In addition the functions rd_file_get_num_distinct_kw() and + rd_file_iget_distinct_kw() will return the number of distinct keywords, and distinct keyword keyword nr i (as a const char *). Possible usage pattern: .... - for (ikw = 0; ikw < ecl_file_get_num_distinct_kw(ecl_file); ikw++) { - const char * kw = ecl_file_iget_distinct_kw(ecl_file , ikw); + for (ikw = 0; ikw < rd_file_get_num_distinct_kw(rd_file); ikw++) { + const char * kw = rd_file_iget_distinct_kw(rd_file , ikw); - printf("The file contains: %d occurences of \'%s\' \n",ecl_file_get_num_named_kw( ecl_file , kw) , kw); + printf("The file contains: %d occurences of \'%s\' \n",rd_file_get_num_named_kw( rd_file , kw) , kw); } .... @@ -220,62 +220,61 @@ void ecl_file_fwrite(const ecl_file_type *ecl_file, const char *filename, */ /** - This function will iterate through the ecl_file instance and search - for the ecl_kw instance @old_kw - the search is based on pointer - equality, i.e. the actual ecl_kw instance, and not on content + This function will iterate through the rd_file instance and search + for the rd_kw instance @old_kw - the search is based on pointer + equality, i.e. the actual rd_kw instance, and not on content equality. When @old_kw is found that keyword instance will be discarded with - ecl_kw_free() and the new keyword @new_kw will be inserted. If + rd_kw_free() and the new keyword @new_kw will be inserted. If @old_kw can not be found the function will fail hard - to verify - that @new_kw is indeed in the ecl_file instance you should use - ecl_file_has_kw_ptr() first. + that @new_kw is indeed in the rd_file instance you should use + rd_file_has_kw_ptr() first. - The ecl_file function typically gives out references to the - internal ecl_kw instances via the ecl_file_iget_kw() function. Use - of ecl_file_replace_kw() might lead to invalidating ecl_kw + The rd_file function typically gives out references to the + internal rd_kw instances via the rd_file_iget_kw() function. Use + of rd_file_replace_kw() might lead to invalidating rd_kw instances held by the calling scope: .... - ecl_file_type * restart_file = ecl_file_fread_alloc( "ECLIPSE.UNRST" ); - ecl_kw_type * initial_pressure = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , 0); - ecl_kw_type * faked_pressure = ecl_kw_alloc_copy( initial_pressure ); + rd_file_type * restart_file = rd_file_fread_alloc( "ECLIPSE.UNRST" ); + rd_kw_type * initial_pressure = rd_file_iget_named_kw( rd_file , "PRESSURE" , 0); + rd_kw_type * faked_pressure = rd_kw_alloc_copy( initial_pressure ); - ecl_kw_scale( faked_pressure , 1.25 ); - ecl_file_replace_kw( restart_file , initial_pressure , faked_pressure , false ); <--- This call will invalidate the inital_pressure reference + rd_kw_scale( faked_pressure , 1.25 ); + rd_file_replace_kw( restart_file , initial_pressure , faked_pressure , false ); <--- This call will invalidate the inital_pressure reference .... .... // This will fail horribly: - printf("The initial pressure in cell(0) was:%g \n",ecl_kw_iget_double( initial_pressure , 0 )); + printf("The initial pressure in cell(0) was:%g \n",rd_kw_iget_double( initial_pressure , 0 )); /|\ | +---------> Using initial_pressure => Crash and burn! - The ecl_file structure takes ownership of all the keywords, and + The rd_file structure takes ownership of all the keywords, and will also take ownership of the newly instered @new_kw instance; if the boolean @insert_copy is set to true the function will insert a copy of @new_kw, leaving the original reference untouched. */ -void ecl_file_replace_kw(ecl_file_type *ecl_file, ecl_kw_type *old_kw, - ecl_kw_type *new_kw, bool insert_copy) { - ecl_file_view_replace_kw(ecl_file->active_view, old_kw, new_kw, - insert_copy); +void rd_file_replace_kw(rd_file_type *rd_file, rd_kw_type *old_kw, + rd_kw_type *new_kw, bool insert_copy) { + rd_file_view_replace_kw(rd_file->active_view, old_kw, new_kw, insert_copy); } -ecl_kw_type *ecl_file_icopy_named_kw(const ecl_file_type *ecl_file, - const char *kw, int ith) { - return ecl_kw_alloc_copy(ecl_file_iget_named_kw(ecl_file, kw, ith)); +rd_kw_type *rd_file_icopy_named_kw(const rd_file_type *rd_file, const char *kw, + int ith) { + return rd_kw_alloc_copy(rd_file_iget_named_kw(rd_file, kw, ith)); } /* Will return the number of times a particular keyword occurs in a - ecl_file instance. Will return 0 if the keyword can not be found. + rd_file instance. Will return 0 if the keyword can not be found. */ -int ecl_file_get_num_named_kw(const ecl_file_type *ecl_file, const char *kw) { - return ecl_file_view_get_num_named_kw(ecl_file->active_view, kw); +int rd_file_get_num_named_kw(const rd_file_type *rd_file, const char *kw) { + return rd_file_view_get_num_named_kw(rd_file->active_view, kw); } /** @@ -288,151 +287,147 @@ int ecl_file_get_num_named_kw(const ecl_file_type *ecl_file, const char *kw) { With the example above we get: - ecl_file_iget_occurence(ecl_file , 2) -> 0; Global index 2 will + rd_file_iget_occurence(rd_file , 2) -> 0; Global index 2 will look up the first occurence of PARAMS. - ecl_file_iget_occurence(ecl_file , 5) -> 2; Global index 5 will + rd_file_iget_occurence(rd_file , 5) -> 2; Global index 5 will look up th third occurence of MINISTEP. The enkf layer uses this funny functionality. */ -int ecl_file_iget_occurence(const ecl_file_type *ecl_file, int index) { - return ecl_file_view_iget_occurence(ecl_file->active_view, index); +int rd_file_iget_occurence(const rd_file_type *rd_file, int index) { + return rd_file_view_iget_occurence(rd_file->active_view, index); } /** - Returns the total number of ecl_kw instances in the ecl_file + Returns the total number of rd_kw instances in the rd_file instance. */ -int ecl_file_get_size(const ecl_file_type *ecl_file) { - return ecl_file_view_get_size(ecl_file->active_view); +int rd_file_get_size(const rd_file_type *rd_file) { + return rd_file_view_get_size(rd_file->active_view); } /** - Returns true if the ecl_file instance has at-least one occurence of - ecl_kw 'kw'. + Returns true if the rd_file instance has at-least one occurence of + rd_kw 'kw'. */ -bool ecl_file_has_kw(const ecl_file_type *ecl_file, const char *kw) { - return ecl_file_view_has_kw(ecl_file->active_view, kw); +bool rd_file_has_kw(const rd_file_type *rd_file, const char *kw) { + return rd_file_view_has_kw(rd_file->active_view, kw); } -int ecl_file_get_num_distinct_kw(const ecl_file_type *ecl_file) { - return ecl_file_view_get_num_distinct_kw(ecl_file->active_view); +int rd_file_get_num_distinct_kw(const rd_file_type *rd_file) { + return rd_file_view_get_num_distinct_kw(rd_file->active_view); } -const char *ecl_file_iget_distinct_kw(const ecl_file_type *ecl_file, - int index) { - return ecl_file_view_iget_distinct_kw(ecl_file->active_view, index); +const char *rd_file_iget_distinct_kw(const rd_file_type *rd_file, int index) { + return rd_file_view_iget_distinct_kw(rd_file->active_view, index); } -const char *ecl_file_get_src_file(const ecl_file_type *ecl_file) { - return fortio_filename_ref(ecl_file->fortio); +const char *rd_file_get_src_file(const rd_file_type *rd_file) { + return fortio_filename_ref(rd_file->fortio); } -void ecl_file_fprintf_kw_list(const ecl_file_type *ecl_file, FILE *stream) { - ecl_file_view_fprintf_kw_list(ecl_file->active_view, stream); +void rd_file_fprintf_kw_list(const rd_file_type *rd_file, FILE *stream) { + rd_file_view_fprintf_kw_list(rd_file->active_view, stream); } -ecl_file_kw_type *ecl_file_iget_file_kw(const ecl_file_type *file, - int global_index) { - return ecl_file_view_iget_file_kw(file->active_view, global_index); +rd_file_kw_type *rd_file_iget_file_kw(const rd_file_type *file, + int global_index) { + return rd_file_view_iget_file_kw(file->active_view, global_index); } -ecl_file_kw_type *ecl_file_iget_named_file_kw(const ecl_file_type *file, - const char *kw, int ith) { - return ecl_file_view_iget_named_file_kw(file->active_view, kw, ith); +rd_file_kw_type *rd_file_iget_named_file_kw(const rd_file_type *file, + const char *kw, int ith) { + return rd_file_view_iget_named_file_kw(file->active_view, kw, ith); } -ecl_kw_type *ecl_file_iget_kw(const ecl_file_type *file, int global_index) { - return ecl_file_view_iget_kw(file->active_view, global_index); +rd_kw_type *rd_file_iget_kw(const rd_file_type *file, int global_index) { + return rd_file_view_iget_kw(file->active_view, global_index); } -ecl_data_type ecl_file_iget_data_type(const ecl_file_type *file, - int global_index) { - return ecl_file_view_iget_data_type(file->active_view, global_index); +rd_data_type rd_file_iget_data_type(const rd_file_type *file, + int global_index) { + return rd_file_view_iget_data_type(file->active_view, global_index); } -int ecl_file_iget_size(const ecl_file_type *file, int global_index) { - return ecl_file_view_iget_size(file->active_view, global_index); +int rd_file_iget_size(const rd_file_type *file, int global_index) { + return rd_file_view_iget_size(file->active_view, global_index); } -const char *ecl_file_iget_header(const ecl_file_type *file, int global_index) { - return ecl_file_view_iget_header(file->active_view, global_index); +const char *rd_file_iget_header(const rd_file_type *file, int global_index) { + return rd_file_view_iget_header(file->active_view, global_index); } /* This function will return the ith occurence of 'kw' in - ecl_file. Will abort hard if the request can not be satisifed - use + rd_file. Will abort hard if the request can not be satisifed - use query functions if you can not take that. */ -ecl_kw_type *ecl_file_iget_named_kw(const ecl_file_type *file, const char *kw, - int ith) { - return ecl_file_view_iget_named_kw(file->active_view, kw, ith); +rd_kw_type *rd_file_iget_named_kw(const rd_file_type *file, const char *kw, + int ith) { + return rd_file_view_iget_named_kw(file->active_view, kw, ith); } -void ecl_file_indexed_read(const ecl_file_type *file, const char *kw, int index, - const int_vector_type *index_map, char *buffer) { - ecl_file_view_index_fload_kw(file->active_view, kw, index, index_map, - buffer); +void rd_file_indexed_read(const rd_file_type *file, const char *kw, int index, + const int_vector_type *index_map, char *buffer) { + rd_file_view_index_fload_kw(file->active_view, kw, index, index_map, + buffer); } -ecl_data_type ecl_file_iget_named_data_type(const ecl_file_type *file, - const char *kw, int ith) { - return ecl_file_view_iget_named_data_type(file->active_view, kw, ith); +rd_data_type rd_file_iget_named_data_type(const rd_file_type *file, + const char *kw, int ith) { + return rd_file_view_iget_named_data_type(file->active_view, kw, ith); } -int ecl_file_iget_named_size(const ecl_file_type *file, const char *kw, - int ith) { - return ecl_file_view_iget_named_size(file->active_view, kw, ith); +int rd_file_iget_named_size(const rd_file_type *file, const char *kw, int ith) { + return rd_file_view_iget_named_size(file->active_view, kw, ith); } -ecl_file_view_type *ecl_file_get_global_view(ecl_file_type *ecl_file) { - return ecl_file->global_view; +rd_file_view_type *rd_file_get_global_view(rd_file_type *rd_file) { + return rd_file->global_view; } // Very deprecated ... -ecl_file_view_type *ecl_file_get_active_view(ecl_file_type *ecl_file) { - return ecl_file->active_view; +rd_file_view_type *rd_file_get_active_view(rd_file_type *rd_file) { + return rd_file->active_view; } -ecl_file_view_type *ecl_file_get_global_blockview(ecl_file_type *ecl_file, - const char *kw, - int occurence) { - ecl_file_view_type *view = - ecl_file_view_add_blockview(ecl_file->global_view, kw, occurence); +rd_file_view_type *rd_file_get_global_blockview(rd_file_type *rd_file, + const char *kw, int occurence) { + rd_file_view_type *view = + rd_file_view_add_blockview(rd_file->global_view, kw, occurence); return view; } -ecl_file_view_type *ecl_file_alloc_global_blockview2(ecl_file_type *ecl_file, - const char *start_kw, - const char *end_kw, - int occurence) { - ecl_file_view_type *view = ecl_file_view_alloc_blockview2( - ecl_file->global_view, start_kw, end_kw, occurence); +rd_file_view_type *rd_file_alloc_global_blockview2(rd_file_type *rd_file, + const char *start_kw, + const char *end_kw, + int occurence) { + rd_file_view_type *view = rd_file_view_alloc_blockview2( + rd_file->global_view, start_kw, end_kw, occurence); return view; } -ecl_file_view_type *ecl_file_alloc_global_blockview(ecl_file_type *ecl_file, - const char *kw, - int occurence) { - return ecl_file_alloc_global_blockview2(ecl_file, kw, kw, occurence); +rd_file_view_type *rd_file_alloc_global_blockview(rd_file_type *rd_file, + const char *kw, + int occurence) { + return rd_file_alloc_global_blockview2(rd_file, kw, kw, occurence); } -ecl_file_view_type *ecl_file_get_restart_view(ecl_file_type *ecl_file, - int input_index, int report_step, - time_t sim_time, - double sim_days) { - ecl_file_view_type *view = ecl_file_view_add_restart_view( - ecl_file->global_view, input_index, report_step, sim_time, sim_days); +rd_file_view_type *rd_file_get_restart_view(rd_file_type *rd_file, + int input_index, int report_step, + time_t sim_time, double sim_days) { + rd_file_view_type *view = rd_file_view_add_restart_view( + rd_file->global_view, input_index, report_step, sim_time, sim_days); return view; } -ecl_file_view_type *ecl_file_get_summary_view(ecl_file_type *ecl_file, - int report_step) { - ecl_file_view_type *view = - ecl_file_view_add_summary_view(ecl_file->global_view, report_step); +rd_file_view_type *rd_file_get_summary_view(rd_file_type *rd_file, + int report_step) { + rd_file_view_type *view = + rd_file_view_add_summary_view(rd_file->global_view, report_step); return view; } @@ -441,173 +436,171 @@ ecl_file_view_type *ecl_file_get_summary_view(ecl_file_type *ecl_file, */ /** - The ecl_file_scan() function will scan through the whole file and build up an + The rd_file_scan() function will scan through the whole file and build up an index of all the kewyords. The map created from this scan will be stored under the 'global_view' field; and all subsequent lookup operations will ultimately be based on the global map. - The ecl_file_scan function will scan through the file as long as it finds - valid ecl_kw instances on the disk; it will return when EOF is encountered or - an invalid ecl_kw instance is detected. This implies that for a partly broken - file the ecl_file_scan function will index the valid keywords which are in + The rd_file_scan function will scan through the file as long as it finds + valid rd_kw instances on the disk; it will return when EOF is encountered or + an invalid rd_kw instance is detected. This implies that for a partly broken + file the rd_file_scan function will index the valid keywords which are in the file, possible garbage at the end will be ignored. */ -static void ecl_file_scan(ecl_file_type *ecl_file) { - fortio_fseek(ecl_file->fortio, 0, SEEK_SET); +static void rd_file_scan(rd_file_type *rd_file) { + fortio_fseek(rd_file->fortio, 0, SEEK_SET); { - ecl_kw_type *work_kw = ecl_kw_alloc_new("WORK-KW", 0, ECL_INT, NULL); + rd_kw_type *work_kw = rd_kw_alloc_new("WORK-KW", 0, RD_INT, NULL); while (true) { - if (fortio_read_at_eof(ecl_file->fortio)) + if (fortio_read_at_eof(rd_file->fortio)) break; { - offset_type current_offset = fortio_ftell(ecl_file->fortio); - ecl_read_status_enum read_status = - ecl_kw_fread_header(work_kw, ecl_file->fortio); - if (read_status == ECL_KW_READ_FAIL) + offset_type current_offset = fortio_ftell(rd_file->fortio); + rd_read_status_enum read_status = + rd_kw_fread_header(work_kw, rd_file->fortio); + if (read_status == RD_KW_READ_FAIL) break; - if (read_status == ECL_KW_READ_OK) { - ecl_file_kw_type *file_kw = - ecl_file_kw_alloc(work_kw, current_offset); + if (read_status == RD_KW_READ_OK) { + rd_file_kw_type *file_kw = + rd_file_kw_alloc(work_kw, current_offset); - if (ecl_file_kw_fskip_data(file_kw, ecl_file->fortio)) - ecl_file_view_add_kw(ecl_file->global_view, file_kw); + if (rd_file_kw_fskip_data(file_kw, rd_file->fortio)) + rd_file_view_add_kw(rd_file->global_view, file_kw); else { - ecl_file_kw_free(file_kw); + rd_file_kw_free(file_kw); break; } } } } - ecl_kw_free(work_kw); + rd_kw_free(work_kw); } - ecl_file_view_make_index(ecl_file->global_view); + rd_file_view_make_index(rd_file->global_view); } -void ecl_file_select_global(ecl_file_type *ecl_file) { - ecl_file->active_view = ecl_file->global_view; +void rd_file_select_global(rd_file_type *rd_file) { + rd_file->active_view = rd_file->global_view; } /** The fundamental open file function; all alternative open() functions start by calling this one. This function will read through the complete file, extract all the keyword headers and - create the map/index stored in the global_view field of the ecl_file + create the map/index stored in the global_view field of the rd_file structure. No keyword data will be loaded from the file. - The ecl_file instance will retain an open fortio reference to the - file until ecl_file_close() is called. + The rd_file instance will retain an open fortio reference to the + file until rd_file_close() is called. */ -static fortio_type *ecl_file_alloc_fortio(const char *filename, int flags) { +static fortio_type *rd_file_alloc_fortio(const char *filename, int flags) { fortio_type *fortio = NULL; bool fmt_file; - ecl_util_fmt_file(filename, &fmt_file); + rd_fmt_file(filename, &fmt_file); - if (ecl_file_view_check_flags(flags, ECL_FILE_WRITABLE)) - fortio = fortio_open_readwrite(filename, fmt_file, ECL_ENDIAN_FLIP); + if (rd_file_view_check_flags(flags, RD_FILE_WRITABLE)) + fortio = fortio_open_readwrite(filename, fmt_file, RD_ENDIAN_FLIP); else - fortio = fortio_open_reader(filename, fmt_file, ECL_ENDIAN_FLIP); + fortio = fortio_open_reader(filename, fmt_file, RD_ENDIAN_FLIP); return fortio; } -ecl_file_type *ecl_file_open(const char *filename, int flags) { - fortio_type *fortio = ecl_file_alloc_fortio(filename, flags); +rd_file_type *rd_file_open(const char *filename, int flags) { + fortio_type *fortio = rd_file_alloc_fortio(filename, flags); if (fortio) { - ecl_file_type *ecl_file = ecl_file_alloc_empty(flags); - ecl_file->fortio = fortio; - ecl_file->global_view = ecl_file_view_alloc( - ecl_file->fortio, &ecl_file->flags, ecl_file->inv_view, true); + rd_file_type *rd_file = rd_file_alloc_empty(flags); + rd_file->fortio = fortio; + rd_file->global_view = rd_file_view_alloc( + rd_file->fortio, &rd_file->flags, rd_file->inv_view, true); - ecl_file_scan(ecl_file); - ecl_file_select_global(ecl_file); + rd_file_scan(rd_file); + rd_file_select_global(rd_file); - if (ecl_file_view_check_flags(ecl_file->flags, ECL_FILE_CLOSE_STREAM)) - fortio_fclose_stream(ecl_file->fortio); + if (rd_file_view_check_flags(rd_file->flags, RD_FILE_CLOSE_STREAM)) + fortio_fclose_stream(rd_file->fortio); - return ecl_file; + return rd_file; } else return NULL; } -int ecl_file_get_flags(const ecl_file_type *ecl_file) { - return ecl_file->flags; -} +int rd_file_get_flags(const rd_file_type *rd_file) { return rd_file->flags; } -void ecl_file_set_flags(ecl_file_type *ecl_file, int flags) { - ecl_file->flags = flags; +void rd_file_set_flags(rd_file_type *rd_file, int flags) { + rd_file->flags = flags; } -bool ecl_file_flags_set(const ecl_file_type *ecl_file, int flags) { - return ecl_file_view_check_flags(ecl_file->flags, flags); +bool rd_file_flags_set(const rd_file_type *rd_file, int flags) { + return rd_file_view_check_flags(rd_file->flags, flags); } -bool ecl_file_writable(const ecl_file_type *ecl_file) { - return ecl_file_view_check_flags(ecl_file->flags, ECL_FILE_WRITABLE); +bool rd_file_writable(const rd_file_type *rd_file) { + return rd_file_view_check_flags(rd_file->flags, RD_FILE_WRITABLE); } /** - The ecl_file_close() function will close the fortio instance and - free all the data created by the ecl_file instance; this includes - the ecl_kw instances which have been loaded on demand. + The rd_file_close() function will close the fortio instance and + free all the data created by the rd_file instance; this includes + the rd_kw instances which have been loaded on demand. */ -void ecl_file_close(ecl_file_type *ecl_file) { - if (ecl_file->fortio != NULL) - fortio_fclose(ecl_file->fortio); +void rd_file_close(rd_file_type *rd_file) { + if (rd_file->fortio != NULL) + fortio_fclose(rd_file->fortio); - if (ecl_file->global_view) - ecl_file_view_free(ecl_file->global_view); + if (rd_file->global_view) + rd_file_view_free(rd_file->global_view); - inv_map_free(ecl_file->inv_view); - vector_free(ecl_file->map_stack); - free(ecl_file); + inv_map_free(rd_file->inv_view); + vector_free(rd_file->map_stack); + free(rd_file); } -void ecl_file_close_fortio_stream(ecl_file_type *ecl_file) { - if (ecl_file->fortio != NULL) { - fortio_fclose_stream(ecl_file->fortio); +void rd_file_close_fortio_stream(rd_file_type *rd_file) { + if (rd_file->fortio != NULL) { + fortio_fclose_stream(rd_file->fortio); } } /** - This function will detach the current ecl_file instance from the - underlying fortio instance. The ecl_file instance can be used - further to access the ecl_kw instances which have been loaded + This function will detach the current rd_file instance from the + underlying fortio instance. The rd_file instance can be used + further to access the rd_kw instances which have been loaded already, but if you try on-demand loading of a keyword you will get crash-and-burn. To ensure that all keywords are in memory you can - call ecl_file_load_all() prior to the detach call. + call rd_file_load_all() prior to the detach call. */ -void ecl_file_fortio_detach(ecl_file_type *ecl_file) { - fortio_fclose(ecl_file->fortio); - ecl_file->fortio = NULL; +void rd_file_fortio_detach(rd_file_type *rd_file) { + fortio_fclose(rd_file->fortio); + rd_file->fortio = NULL; } -bool ecl_file_load_all(ecl_file_type *ecl_file) { - return ecl_file_view_load_all(ecl_file->active_view); +bool rd_file_load_all(rd_file_type *rd_file) { + return rd_file_view_load_all(rd_file->active_view); } -void ecl_file_free__(void *arg) { ecl_file_close(ecl_file_safe_cast(arg)); } +void rd_file_free__(void *arg) { rd_file_close(rd_file_safe_cast(arg)); } /* Functions specialized to work with restart files. */ /* Query functions. */ /** Will look through all the INTEHEAD kw instances of the current - ecl_file and look for @sim_time. If the value is found true is + rd_file and look for @sim_time. If the value is found true is returned, otherwise false. */ -bool ecl_file_has_sim_time(const ecl_file_type *ecl_file, time_t sim_time) { - return ecl_file_view_has_sim_time(ecl_file->active_view, sim_time); +bool rd_file_has_sim_time(const rd_file_type *rd_file, time_t sim_time) { + return rd_file_view_has_sim_time(rd_file->active_view, sim_time); } /* @@ -625,20 +618,20 @@ bool ecl_file_has_sim_time(const ecl_file_type *ecl_file, time_t sim_time) { Direct access: - int index = ecl_file_get_restart_index( ecl_file , sim_time ); + int index = rd_file_get_restart_index( rd_file , sim_time ); if (index >= 0) { - ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , index ); + rd_kw_type * pressure_kw = rd_file_iget_named_kw( rd_file , "PRESSURE" , index ); .... } Using block restriction: - int index = ecl_file_get_restart_index( ecl_file , sim_time ); + int index = rd_file_get_restart_index( rd_file , sim_time ); if (index >= 0) { - ecl_file_iselect_rstblock( ecl_file , index ); + rd_file_iselect_rstblock( rd_file , index ); { - ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , 0 ); + rd_kw_type * pressure_kw = rd_file_iget_named_kw( rd_file , "PRESSURE" , 0 ); .... } } @@ -646,39 +639,37 @@ bool ecl_file_has_sim_time(const ecl_file_type *ecl_file, time_t sim_time) { Specially in the case of LGRs the block restriction should be used. */ -int ecl_file_get_restart_index(const ecl_file_type *ecl_file, time_t sim_time) { +int rd_file_get_restart_index(const rd_file_type *rd_file, time_t sim_time) { int active_index = - ecl_file_view_find_sim_time(ecl_file->active_view, sim_time); + rd_file_view_find_sim_time(rd_file->active_view, sim_time); return active_index; } /** Will look through all the SEQNUM kw instances of the current - ecl_file and look for @report_step. If the value is found true is + rd_file and look for @report_step. If the value is found true is returned, otherwise false. */ -bool ecl_file_has_report_step(const ecl_file_type *ecl_file, int report_step) { - return ecl_file_view_has_report_step(ecl_file->active_view, report_step); +bool rd_file_has_report_step(const rd_file_type *rd_file, int report_step) { + return rd_file_view_has_report_step(rd_file->active_view, report_step); } /** - This function will look up the INTEHEAD keyword in a ecl_file_type + This function will look up the INTEHEAD keyword in a rd_file_type instance, and calculate simulation date from this instance. Will return -1 if the requested INTEHEAD keyword can not be found. */ -time_t ecl_file_iget_restart_sim_date(const ecl_file_type *restart_file, - int index) { - return ecl_file_view_iget_restart_sim_date(restart_file->active_view, - index); +time_t rd_file_iget_restart_sim_date(const rd_file_type *restart_file, + int index) { + return rd_file_view_iget_restart_sim_date(restart_file->active_view, index); } -double ecl_file_iget_restart_sim_days(const ecl_file_type *restart_file, - int index) { - return ecl_file_view_iget_restart_sim_days(restart_file->active_view, - index); +double rd_file_iget_restart_sim_days(const rd_file_type *restart_file, + int index) { + return rd_file_view_iget_restart_sim_days(restart_file->active_view, index); } /* @@ -691,9 +682,9 @@ double ecl_file_iget_restart_sim_days(const ecl_file_type *restart_file, return ECLIPSE300 in both those cases. */ -ecl_version_enum ecl_file_get_ecl_version(const ecl_file_type *file) { - ecl_kw_type *intehead_kw = ecl_file_iget_named_kw(file, INTEHEAD_KW, 0); - int int_value = ecl_kw_iget_int(intehead_kw, INTEHEAD_IPROG_INDEX); +rd_version_enum rd_file_get_rd_version(const rd_file_type *file) { + rd_kw_type *intehead_kw = rd_file_iget_named_kw(file, INTEHEAD_KW, 0); + int int_value = rd_kw_iget_int(intehead_kw, INTEHEAD_IPROG_INDEX); if (int_value == INTEHEAD_ECLIPSE100_VALUE) return ECLIPSE100; @@ -712,7 +703,7 @@ ecl_version_enum ecl_file_get_ecl_version(const ecl_file_type *file) { util_abort("%s: Simulator version value:%d not recognized \n", __func__, int_value); - return (ecl_version_enum)0; + return (rd_version_enum)0; } /* @@ -725,31 +716,29 @@ ecl_version_enum ecl_file_get_ecl_version(const ecl_file_type *file) { 7: Gas + Water + Oil */ -int ecl_file_get_phases(const ecl_file_type *init_file) { - ecl_kw_type *intehead_kw = - ecl_file_iget_named_kw(init_file, INTEHEAD_KW, 0); - int phases = ecl_kw_iget_int(intehead_kw, INTEHEAD_PHASE_INDEX); +int rd_file_get_phases(const rd_file_type *init_file) { + rd_kw_type *intehead_kw = rd_file_iget_named_kw(init_file, INTEHEAD_KW, 0); + int phases = rd_kw_iget_int(intehead_kw, INTEHEAD_PHASE_INDEX); return phases; } /* -bool ecl_file_writable( const ecl_file_type * ecl_file ) { - return fortio_writable( ecl_file->fortio ); +bool rd_file_writable( const rd_file_type * rd_file ) { + return fortio_writable( rd_file->fortio ); } */ /** - Checks if the ecl_file contains ecl_kw; this check is based on - pointer equality - i.e. we check if the ecl_file contains exactly + Checks if the rd_file contains rd_kw; this check is based on + pointer equality - i.e. we check if the rd_file contains exactly this keyword - not an arbitrary equivalent keyword. This function can be called as a safeguard before calling - ecl_file_save_kw(). + rd_file_save_kw(). */ -bool ecl_file_has_kw_ptr(const ecl_file_type *ecl_file, - const ecl_kw_type *ecl_kw) { - ecl_file_kw_type *file_kw = inv_map_get_file_kw(ecl_file->inv_view, ecl_kw); +bool rd_file_has_kw_ptr(const rd_file_type *rd_file, const rd_kw_type *rd_kw) { + rd_file_kw_type *file_kw = inv_map_get_file_kw(rd_file->inv_view, rd_kw); if (file_kw == NULL) return false; else @@ -757,83 +746,81 @@ bool ecl_file_has_kw_ptr(const ecl_file_type *ecl_file, } /* - Will save the content of @ecl_kw to the on-disk file wrapped by the - ecl_file instance. This function is quite strict: + Will save the content of @rd_kw to the on-disk file wrapped by the + rd_file instance. This function is quite strict: 1. The actual keyword which should be updated is identified using - pointer comparison; i.e. the ecl_kw argument must be the actual - return value from an earlier ecl_file_get_kw() operation. To - check this you can call ecl_file_has_kw_ptr(). + pointer comparison; i.e. the rd_kw argument must be the actual + return value from an earlier rd_file_get_kw() operation. To + check this you can call rd_file_has_kw_ptr(). - 2. The header data of the ecl_kw must be unmodified; this is checked - by the ecl_file_kw_inplace_fwrite() function and crash-and-burn + 2. The header data of the rd_kw must be unmodified; this is checked + by the rd_file_kw_inplace_fwrite() function and crash-and-burn will ensue if this is not satisfied. - 3. The ecl_file must have been opened with one of the _writable() + 3. The rd_file must have been opened with one of the _writable() open functions. */ -bool ecl_file_save_kw(const ecl_file_type *ecl_file, - const ecl_kw_type *ecl_kw) { - ecl_file_kw_type *file_kw = inv_map_get_file_kw( - ecl_file->inv_view, - ecl_kw); // We just verify that the input ecl_kw points to an ecl_kw +bool rd_file_save_kw(const rd_file_type *rd_file, const rd_kw_type *rd_kw) { + rd_file_kw_type *file_kw = inv_map_get_file_kw( + rd_file->inv_view, + rd_kw); // We just verify that the input rd_kw points to an rd_kw if (file_kw != NULL) { // we manage; from then on we use the reference contained in if (fortio_assert_stream_open( - ecl_file->fortio)) { // the corresponding ecl_file_kw instance. + rd_file->fortio)) { // the corresponding rd_file_kw instance. - ecl_file_kw_inplace_fwrite(file_kw, ecl_file->fortio); + rd_file_kw_inplace_fwrite(file_kw, rd_file->fortio); - if (ecl_file_view_check_flags(ecl_file->flags, - ECL_FILE_CLOSE_STREAM)) - fortio_fclose_stream(ecl_file->fortio); + if (rd_file_view_check_flags(rd_file->flags, RD_FILE_CLOSE_STREAM)) + fortio_fclose_stream(rd_file->fortio); return true; } else return false; } else { - util_abort("%s: keyword pointer:%p not found in ecl_file instance. \n", - __func__, ecl_kw); + util_abort("%s: keyword pointer:%p not found in rd_file instance. \n", + __func__, rd_kw); return false; } } /* DEPRECATED */ -void ecl_file_push_block(ecl_file_type *ecl_file) { - vector_append_ref(ecl_file->map_stack, ecl_file->active_view); +void rd_file_push_block(rd_file_type *rd_file) { + vector_append_ref(rd_file->map_stack, rd_file->active_view); } -void ecl_file_pop_block(ecl_file_type *ecl_file) { - ecl_file->active_view = - (ecl_file_view_type *)vector_pop_back(ecl_file->map_stack); +void rd_file_pop_block(rd_file_type *rd_file) { + rd_file->active_view = + (rd_file_view_type *)vector_pop_back(rd_file->map_stack); } -static ecl_file_view_type * -ecl_file_get_relative_blockview(ecl_file_type *ecl_file, const char *kw, - int occurence) { - ecl_file_view_type *view = - ecl_file_view_add_blockview(ecl_file->active_view, kw, occurence); +static rd_file_view_type *rd_file_get_relative_blockview(rd_file_type *rd_file, + const char *kw, + int occurence) { + rd_file_view_type *view = + rd_file_view_add_blockview(rd_file->active_view, kw, occurence); return view; } -bool ecl_file_subselect_block(ecl_file_type *ecl_file, const char *kw, - int occurence) { - ecl_file_view_type *blockmap = - ecl_file_get_relative_blockview(ecl_file, kw, occurence); +bool rd_file_subselect_block(rd_file_type *rd_file, const char *kw, + int occurence) { + rd_file_view_type *blockmap = + rd_file_get_relative_blockview(rd_file, kw, occurence); if (blockmap != NULL) { - ecl_file->active_view = blockmap; + rd_file->active_view = blockmap; return true; } else return false; } -bool ecl_file_select_block(ecl_file_type *ecl_file, const char *kw, - int occurence) { - ecl_file_view_type *blockmap = - ecl_file_get_global_blockview(ecl_file, kw, occurence); +bool rd_file_select_block(rd_file_type *rd_file, const char *kw, + int occurence) { + rd_file_view_type *blockmap = + rd_file_get_global_blockview(rd_file, kw, occurence); if (blockmap != NULL) { - ecl_file->active_view = blockmap; + rd_file->active_view = blockmap; return true; } else return false; @@ -843,88 +830,87 @@ bool ecl_file_select_block(ecl_file_type *ecl_file, const char *kw, Will select restart block nr @seqnum_index - without considering report_steps or simulation time. */ -bool ecl_file_iselect_rstblock(ecl_file_type *ecl_file, int seqnum_index) { - return ecl_file_select_block(ecl_file, SEQNUM_KW, seqnum_index); +bool rd_file_iselect_rstblock(rd_file_type *rd_file, int seqnum_index) { + return rd_file_select_block(rd_file, SEQNUM_KW, seqnum_index); } -bool ecl_file_select_rstblock_sim_time(ecl_file_type *ecl_file, - time_t sim_time) { - int seqnum_index = ecl_file_view_seqnum_index_from_sim_time( - ecl_file->global_view, sim_time); +bool rd_file_select_rstblock_sim_time(rd_file_type *rd_file, time_t sim_time) { + int seqnum_index = + rd_file_view_seqnum_index_from_sim_time(rd_file->global_view, sim_time); if (seqnum_index >= 0) - return ecl_file_iselect_rstblock(ecl_file, seqnum_index); + return rd_file_iselect_rstblock(rd_file, seqnum_index); else return false; } -bool ecl_file_select_rstblock_report_step(ecl_file_type *ecl_file, - int report_step) { - int global_index = ecl_file_view_find_kw_value(ecl_file->global_view, - SEQNUM_KW, &report_step); +bool rd_file_select_rstblock_report_step(rd_file_type *rd_file, + int report_step) { + int global_index = rd_file_view_find_kw_value(rd_file->global_view, + SEQNUM_KW, &report_step); if (global_index >= 0) { int seqnum_index = - ecl_file_view_iget_occurence(ecl_file->global_view, global_index); - return ecl_file_iselect_rstblock(ecl_file, seqnum_index); + rd_file_view_iget_occurence(rd_file->global_view, global_index); + return rd_file_iselect_rstblock(rd_file, seqnum_index); } else return false; } -static ecl_file_type *ecl_file_open_rstblock_report_step__(const char *filename, - int report_step, - int flags) { - ecl_file_type *ecl_file = ecl_file_open(filename, flags); - if (ecl_file) { - if (!ecl_file_select_rstblock_report_step(ecl_file, report_step)) { - ecl_file_close(ecl_file); - ecl_file = NULL; +static rd_file_type *rd_file_open_rstblock_report_step__(const char *filename, + int report_step, + int flags) { + rd_file_type *rd_file = rd_file_open(filename, flags); + if (rd_file) { + if (!rd_file_select_rstblock_report_step(rd_file, report_step)) { + rd_file_close(rd_file); + rd_file = NULL; } } - return ecl_file; + return rd_file; } -ecl_file_type *ecl_file_open_rstblock_report_step(const char *filename, - int report_step, int flags) { - return ecl_file_open_rstblock_report_step__(filename, report_step, flags); +rd_file_type *rd_file_open_rstblock_report_step(const char *filename, + int report_step, int flags) { + return rd_file_open_rstblock_report_step__(filename, report_step, flags); } -static ecl_file_type *ecl_file_open_rstblock_sim_time__(const char *filename, - time_t sim_time, - int flags) { - ecl_file_type *ecl_file = ecl_file_open(filename, flags); - if (ecl_file) { - if (!ecl_file_select_rstblock_sim_time(ecl_file, sim_time)) { - ecl_file_close(ecl_file); - ecl_file = NULL; +static rd_file_type *rd_file_open_rstblock_sim_time__(const char *filename, + time_t sim_time, + int flags) { + rd_file_type *rd_file = rd_file_open(filename, flags); + if (rd_file) { + if (!rd_file_select_rstblock_sim_time(rd_file, sim_time)) { + rd_file_close(rd_file); + rd_file = NULL; } } - return ecl_file; + return rd_file; } -ecl_file_type *ecl_file_open_rstblock_sim_time(const char *filename, - time_t sim_time, int flags) { - return ecl_file_open_rstblock_sim_time__(filename, sim_time, flags); +rd_file_type *rd_file_open_rstblock_sim_time(const char *filename, + time_t sim_time, int flags) { + return rd_file_open_rstblock_sim_time__(filename, sim_time, flags); } -static ecl_file_type *ecl_file_iopen_rstblock__(const char *filename, - int seqnum_index, int flags) { - ecl_file_type *ecl_file = ecl_file_open(filename, flags); - if (ecl_file) { - if (!ecl_file_iselect_rstblock(ecl_file, seqnum_index)) { - ecl_file_close(ecl_file); - ecl_file = NULL; +static rd_file_type *rd_file_iopen_rstblock__(const char *filename, + int seqnum_index, int flags) { + rd_file_type *rd_file = rd_file_open(filename, flags); + if (rd_file) { + if (!rd_file_iselect_rstblock(rd_file, seqnum_index)) { + rd_file_close(rd_file); + rd_file = NULL; } } - return ecl_file; + return rd_file; } -ecl_file_type *ecl_file_iopen_rstblock(const char *filename, int seqnum_index, - int flags) { - return ecl_file_iopen_rstblock__(filename, seqnum_index, flags); +rd_file_type *rd_file_iopen_rstblock(const char *filename, int seqnum_index, + int flags) { + return rd_file_iopen_rstblock__(filename, seqnum_index, flags); } -static bool ecl_file_index_valid0(const char *file_name, - const char *index_file_name) { +static bool rd_file_index_valid0(const char *file_name, + const char *index_file_name) { if (!util_file_exists(file_name)) return false; @@ -937,7 +923,7 @@ static bool ecl_file_index_valid0(const char *file_name, return true; } -static bool ecl_file_index_valid1(const char *file_name, FILE *stream) { +static bool rd_file_index_valid1(const char *file_name, FILE *stream) { bool name_equal; char *source_file = util_fread_alloc_string(stream); char *input_name = util_split_alloc_filename(file_name); @@ -949,66 +935,65 @@ static bool ecl_file_index_valid1(const char *file_name, FILE *stream) { return name_equal; } -bool ecl_file_index_valid(const char *file_name, const char *index_file_name) { - if (!ecl_file_index_valid0(file_name, index_file_name)) +bool rd_file_index_valid(const char *file_name, const char *index_file_name) { + if (!rd_file_index_valid0(file_name, index_file_name)) return false; bool valid = false; FILE *stream = fopen(index_file_name, "rb"); if (stream) { - valid = ecl_file_index_valid1(file_name, stream); + valid = rd_file_index_valid1(file_name, stream); fclose(stream); } return valid; } -bool ecl_file_write_index(const ecl_file_type *ecl_file, - const char *index_filename) { +bool rd_file_write_index(const rd_file_type *rd_file, + const char *index_filename) { FILE *ostream = fopen(index_filename, "wb"); if (!ostream) return false; { char *filename = - util_split_alloc_filename(fortio_filename_ref(ecl_file->fortio)); + util_split_alloc_filename(fortio_filename_ref(rd_file->fortio)); util_fwrite_string(filename, ostream); free(filename); } - ecl_file_view_write_index(ecl_file->global_view, ostream); + rd_file_view_write_index(rd_file->global_view, ostream); fclose(ostream); return true; } -ecl_file_type *ecl_file_fast_open(const char *file_name, - const char *index_file_name, int flags) { - if (!ecl_file_index_valid0(file_name, index_file_name)) +rd_file_type *rd_file_fast_open(const char *file_name, + const char *index_file_name, int flags) { + if (!rd_file_index_valid0(file_name, index_file_name)) return NULL; FILE *istream = fopen(index_file_name, "rb"); if (!istream) return NULL; - ecl_file_type *ecl_file = NULL; + rd_file_type *rd_file = NULL; - if (ecl_file_index_valid1(file_name, istream)) { - fortio_type *fortio = ecl_file_alloc_fortio(file_name, flags); + if (rd_file_index_valid1(file_name, istream)) { + fortio_type *fortio = rd_file_alloc_fortio(file_name, flags); if (fortio) { - ecl_file = ecl_file_alloc_empty(flags); - ecl_file->fortio = fortio; - ecl_file->global_view = - ecl_file_view_fread_alloc(ecl_file->fortio, &ecl_file->flags, - ecl_file->inv_view, istream); - if (ecl_file->global_view) { - ecl_file_select_global(ecl_file); - if (ecl_file_view_check_flags(ecl_file->flags, - ECL_FILE_CLOSE_STREAM)) - fortio_fclose_stream(ecl_file->fortio); + rd_file = rd_file_alloc_empty(flags); + rd_file->fortio = fortio; + rd_file->global_view = rd_file_view_fread_alloc( + rd_file->fortio, &rd_file->flags, rd_file->inv_view, istream); + if (rd_file->global_view) { + rd_file_select_global(rd_file); + if (rd_file_view_check_flags(rd_file->flags, + RD_FILE_CLOSE_STREAM)) + fortio_fclose_stream(rd_file->fortio); } else { - ecl_file_close(ecl_file); - ecl_file = NULL; + rd_file_close(rd_file); + rd_file = NULL; } } } fclose(istream); - return ecl_file; + return rd_file; } diff --git a/lib/resdata/rd_file_kw.cpp b/lib/resdata/rd_file_kw.cpp index 4ea43e3f16..c0153cddff 100644 --- a/lib/resdata/rd_file_kw.cpp +++ b/lib/resdata/rd_file_kw.cpp @@ -5,64 +5,64 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include /* - This file implements the datatype ecl_file_kw which is used to hold - header-information about an ecl_kw instance on file. When a - ecl_file_kw instance is created it is initialized with the header - information (name, size, type) for an ecl_kw instance and the offset + This file implements the datatype rd_file_kw which is used to hold + header-information about an rd_kw instance on file. When a + rd_file_kw instance is created it is initialized with the header + information (name, size, type) for an rd_kw instance and the offset in a file actually containing the keyword. If and when the keyword is actually queried for at a later stage the - ecl_file_kw_get_kw() method will seek to the keyword position in an - open fortio instance and call ecl_kw_fread_alloc() to instantiate + rd_file_kw_get_kw() method will seek to the keyword position in an + open fortio instance and call rd_kw_fread_alloc() to instantiate the keyword itself. - The ecl_file_kw datatype is mainly used by the ecl_file datatype; - whose index tables consists of ecl_file_kw instances. + The rd_file_kw datatype is mainly used by the rd_file datatype; + whose index tables consists of rd_file_kw instances. */ -#define ECL_FILE_KW_TYPE_ID 646107 +#define RD_FILE_KW_TYPE_ID 646107 struct inv_map_struct { size_t_vector_type *file_kw_ptr; - size_t_vector_type *ecl_kw_ptr; + size_t_vector_type *rd_kw_ptr; bool sorted; }; -struct ecl_file_kw_struct { +struct rd_file_kw_struct { UTIL_TYPE_ID_DECLARATION; offset_type file_offset; - ecl_data_type data_type; + rd_data_type data_type; int kw_size; int ref_count; char *header; - ecl_kw_type *kw; + rd_kw_type *kw; }; inv_map_type *inv_map_alloc() { inv_map_type *map = (inv_map_type *)util_malloc(sizeof *map); map->file_kw_ptr = size_t_vector_alloc(0, 0); - map->ecl_kw_ptr = size_t_vector_alloc(0, 0); + map->rd_kw_ptr = size_t_vector_alloc(0, 0); map->sorted = false; return map; } void inv_map_free(inv_map_type *map) { size_t_vector_free(map->file_kw_ptr); - size_t_vector_free(map->ecl_kw_ptr); + size_t_vector_free(map->rd_kw_ptr); free(map); } static void inv_map_assert_sort(inv_map_type *map) { if (!map->sorted) { - perm_vector_type *perm = size_t_vector_alloc_sort_perm(map->ecl_kw_ptr); + perm_vector_type *perm = size_t_vector_alloc_sort_perm(map->rd_kw_ptr); - size_t_vector_permute(map->ecl_kw_ptr, perm); + size_t_vector_permute(map->rd_kw_ptr, perm); size_t_vector_permute(map->file_kw_ptr, perm); map->sorted = true; @@ -70,50 +70,49 @@ static void inv_map_assert_sort(inv_map_type *map) { } } -static void inv_map_drop_kw(inv_map_type *map, const ecl_kw_type *ecl_kw) { +static void inv_map_drop_kw(inv_map_type *map, const rd_kw_type *rd_kw) { inv_map_assert_sort(map); { - int index = size_t_vector_index_sorted(map->ecl_kw_ptr, (size_t)ecl_kw); + int index = size_t_vector_index_sorted(map->rd_kw_ptr, (size_t)rd_kw); if (index == -1) util_abort("%s: trying to drop non-existent kw \n", __func__); - size_t_vector_idel(map->ecl_kw_ptr, index); + size_t_vector_idel(map->rd_kw_ptr, index); size_t_vector_idel(map->file_kw_ptr, index); map->sorted = false; } } -static void inv_map_add_kw(inv_map_type *map, const ecl_file_kw_type *file_kw, - const ecl_kw_type *ecl_kw) { +static void inv_map_add_kw(inv_map_type *map, const rd_file_kw_type *file_kw, + const rd_kw_type *rd_kw) { size_t_vector_append(map->file_kw_ptr, (size_t)file_kw); - size_t_vector_append(map->ecl_kw_ptr, (size_t)ecl_kw); + size_t_vector_append(map->rd_kw_ptr, (size_t)rd_kw); map->sorted = false; } -ecl_file_kw_type *inv_map_get_file_kw(inv_map_type *inv_map, - const ecl_kw_type *ecl_kw) { +rd_file_kw_type *inv_map_get_file_kw(inv_map_type *inv_map, + const rd_kw_type *rd_kw) { inv_map_assert_sort(inv_map); { int index = - size_t_vector_index_sorted(inv_map->ecl_kw_ptr, (size_t)ecl_kw); + size_t_vector_index_sorted(inv_map->rd_kw_ptr, (size_t)rd_kw); if (index == -1) - /* ecl_kw ptr not found. */ + /* rd_kw ptr not found. */ return NULL; else - return (ecl_file_kw_type *)size_t_vector_iget(inv_map->file_kw_ptr, - index); + return (rd_file_kw_type *)size_t_vector_iget(inv_map->file_kw_ptr, + index); } } -static UTIL_SAFE_CAST_FUNCTION(ecl_file_kw, ECL_FILE_KW_TYPE_ID) - UTIL_IS_INSTANCE_FUNCTION(ecl_file_kw, ECL_FILE_KW_TYPE_ID) +static UTIL_SAFE_CAST_FUNCTION(rd_file_kw, RD_FILE_KW_TYPE_ID) + UTIL_IS_INSTANCE_FUNCTION(rd_file_kw, RD_FILE_KW_TYPE_ID) - ecl_file_kw_type *ecl_file_kw_alloc0(const char *header, - ecl_data_type data_type, int size, - offset_type offset) { - ecl_file_kw_type *file_kw = - (ecl_file_kw_type *)util_malloc(sizeof *file_kw); - UTIL_TYPE_ID_INIT(file_kw, ECL_FILE_KW_TYPE_ID); + rd_file_kw_type *rd_file_kw_alloc0(const char *header, + rd_data_type data_type, int size, + offset_type offset) { + rd_file_kw_type *file_kw = (rd_file_kw_type *)util_malloc(sizeof *file_kw); + UTIL_TYPE_ID_INIT(file_kw, RD_FILE_KW_TYPE_ID); file_kw->header = util_alloc_string_copy(header); memcpy(&file_kw->data_type, &data_type, sizeof data_type); @@ -126,106 +125,104 @@ static UTIL_SAFE_CAST_FUNCTION(ecl_file_kw, ECL_FILE_KW_TYPE_ID) } /** - Create a new ecl_file_kw instance based on header information from + Create a new rd_file_kw instance based on header information from the input keyword. Typically only the header has been loaded from the keyword. Observe that it is the users responsability that the @offset - argument in ecl_file_kw_alloc() comes from the same fortio instance - as used when calling ecl_file_kw_get_kw() to actually instatiate - the ecl_kw. This is automatically assured when using ecl_file to - access the ecl_file_kw instances. + argument in rd_file_kw_alloc() comes from the same fortio instance + as used when calling rd_file_kw_get_kw() to actually instatiate + the rd_kw. This is automatically assured when using rd_file to + access the rd_file_kw instances. */ -ecl_file_kw_type *ecl_file_kw_alloc(const ecl_kw_type *ecl_kw, - offset_type offset) { - return ecl_file_kw_alloc0(ecl_kw_get_header(ecl_kw), - ecl_kw_get_data_type(ecl_kw), - ecl_kw_get_size(ecl_kw), offset); +rd_file_kw_type *rd_file_kw_alloc(const rd_kw_type *rd_kw, offset_type offset) { + return rd_file_kw_alloc0(rd_kw_get_header(rd_kw), + rd_kw_get_data_type(rd_kw), rd_kw_get_size(rd_kw), + offset); } /** Does NOT copy the kw pointer which must be reloaded. */ -ecl_file_kw_type *ecl_file_kw_alloc_copy(const ecl_file_kw_type *src) { - return ecl_file_kw_alloc0(src->header, ecl_file_kw_get_data_type(src), - src->kw_size, src->file_offset); +rd_file_kw_type *rd_file_kw_alloc_copy(const rd_file_kw_type *src) { + return rd_file_kw_alloc0(src->header, rd_file_kw_get_data_type(src), + src->kw_size, src->file_offset); } -void ecl_file_kw_free(ecl_file_kw_type *file_kw) { +void rd_file_kw_free(rd_file_kw_type *file_kw) { if (file_kw->kw != NULL) { - ecl_kw_free(file_kw->kw); + rd_kw_free(file_kw->kw); file_kw->kw = NULL; } free(file_kw->header); free(file_kw); } -void ecl_file_kw_free__(void *arg) { - ecl_file_kw_type *file_kw = ecl_file_kw_safe_cast(arg); - ecl_file_kw_free(file_kw); +void rd_file_kw_free__(void *arg) { + rd_file_kw_type *file_kw = rd_file_kw_safe_cast(arg); + rd_file_kw_free(file_kw); } -bool ecl_file_kw_equal(const ecl_file_kw_type *kw1, - const ecl_file_kw_type *kw2) { +bool rd_file_kw_equal(const rd_file_kw_type *kw1, const rd_file_kw_type *kw2) { if (kw1->file_offset != kw2->file_offset) return false; if (kw1->kw_size != kw2->kw_size) return false; - if (!ecl_type_is_equal(kw1->data_type, kw2->data_type)) + if (!rd_type_is_equal(kw1->data_type, kw2->data_type)) return false; return util_string_equal(kw1->header, kw2->header); } -static void ecl_file_kw_assert_kw(const ecl_file_kw_type *file_kw) { - if (!ecl_type_is_equal(ecl_file_kw_get_data_type(file_kw), - ecl_kw_get_data_type(file_kw->kw))) +static void rd_file_kw_assert_kw(const rd_file_kw_type *file_kw) { + if (!rd_type_is_equal(rd_file_kw_get_data_type(file_kw), + rd_kw_get_data_type(file_kw->kw))) util_abort("%s: type mismatch between header and file.\n", __func__); - if (file_kw->kw_size != ecl_kw_get_size(file_kw->kw)) + if (file_kw->kw_size != rd_kw_get_size(file_kw->kw)) util_abort("%s: size mismatch between header and file.\n", __func__); - if (strcmp(file_kw->header, ecl_kw_get_header(file_kw->kw)) != 0) + if (strcmp(file_kw->header, rd_kw_get_header(file_kw->kw)) != 0) util_abort("%s: name mismatch between header and file.\n", __func__); } -static void ecl_file_kw_drop_kw(ecl_file_kw_type *file_kw, - inv_map_type *inv_map) { +static void rd_file_kw_drop_kw(rd_file_kw_type *file_kw, + inv_map_type *inv_map) { if (file_kw->kw != NULL) { inv_map_drop_kw(inv_map, file_kw->kw); - ecl_kw_free(file_kw->kw); + rd_kw_free(file_kw->kw); file_kw->kw = NULL; } } -static void ecl_file_kw_load_kw(ecl_file_kw_type *file_kw, fortio_type *fortio, - inv_map_type *inv_map) { +static void rd_file_kw_load_kw(rd_file_kw_type *file_kw, fortio_type *fortio, + inv_map_type *inv_map) { if (fortio == NULL) util_abort("%s: trying to load a keyword after the backing file has " "been detached.\n", __func__); if (file_kw->kw != NULL) - ecl_file_kw_drop_kw(file_kw, inv_map); + rd_file_kw_drop_kw(file_kw, inv_map); { fortio_fseek(fortio, file_kw->file_offset, SEEK_SET); - file_kw->kw = ecl_kw_fread_alloc(fortio); - ecl_file_kw_assert_kw(file_kw); + file_kw->kw = rd_kw_fread_alloc(fortio); + rd_file_kw_assert_kw(file_kw); inv_map_add_kw(inv_map, file_kw, file_kw->kw); } } /* Calling scope will handle the NULL return value, and (optionally) - reopen the fortio stream and then call the ecl_file_kw_get_kw() + reopen the fortio stream and then call the rd_file_kw_get_kw() function. */ -ecl_kw_type *ecl_file_kw_get_kw_ptr(ecl_file_kw_type *file_kw) { +rd_kw_type *rd_file_kw_get_kw_ptr(rd_file_kw_type *file_kw) { if (file_kw->ref_count == 0) return NULL; @@ -234,23 +231,23 @@ ecl_kw_type *ecl_file_kw_get_kw_ptr(ecl_file_kw_type *file_kw) { } /* - Will return the ecl_kw instance of this file_kw; if it is not - currently loaded the method will instantiate the ecl_kw instance + Will return the rd_kw instance of this file_kw; if it is not + currently loaded the method will instantiate the rd_kw instance from the @fortio input handle. After loading the keyword it will be kept in memory, so a possible subsequent lookup will be served from memory. - The ecl_file layer maintains a pointer mapping between the - ecl_kw_type pointers and their ecl_file_kw_type containers; this + The rd_file layer maintains a pointer mapping between the + rd_kw_type pointers and their rd_file_kw_type containers; this mapping needs the new_load return value from the - ecl_file_kw_get_kw() function. + rd_file_kw_get_kw() function. */ -ecl_kw_type *ecl_file_kw_get_kw(ecl_file_kw_type *file_kw, fortio_type *fortio, - inv_map_type *inv_map) { +rd_kw_type *rd_file_kw_get_kw(rd_file_kw_type *file_kw, fortio_type *fortio, + inv_map_type *inv_map) { if (file_kw->ref_count == 0) - ecl_file_kw_load_kw(file_kw, fortio, inv_map); + rd_file_kw_load_kw(file_kw, fortio, inv_map); if (file_kw->kw) file_kw->ref_count++; @@ -258,75 +255,74 @@ ecl_kw_type *ecl_file_kw_get_kw(ecl_file_kw_type *file_kw, fortio_type *fortio, return file_kw->kw; } -bool ecl_file_kw_ptr_eq(const ecl_file_kw_type *file_kw, - const ecl_kw_type *ecl_kw) { - if (file_kw->kw == ecl_kw) +bool rd_file_kw_ptr_eq(const rd_file_kw_type *file_kw, + const rd_kw_type *rd_kw) { + if (file_kw->kw == rd_kw) return true; else return false; } -void ecl_file_kw_replace_kw(ecl_file_kw_type *file_kw, fortio_type *target, - ecl_kw_type *new_kw) { - if (!ecl_type_is_equal(ecl_file_kw_get_data_type(file_kw), - ecl_kw_get_data_type(new_kw))) +void rd_file_kw_replace_kw(rd_file_kw_type *file_kw, fortio_type *target, + rd_kw_type *new_kw) { + if (!rd_type_is_equal(rd_file_kw_get_data_type(file_kw), + rd_kw_get_data_type(new_kw))) util_abort("%s: sorry type mismatch between in-file keyword and new " "keyword \n", __func__); - if (file_kw->kw_size != ecl_kw_get_size(new_kw)) + if (file_kw->kw_size != rd_kw_get_size(new_kw)) util_abort("%s: sorry size mismatch between in-file keyword and new " "keyword \n", __func__); if (file_kw->kw != NULL) - ecl_kw_free(file_kw->kw); + rd_kw_free(file_kw->kw); file_kw->kw = new_kw; fortio_fseek(target, file_kw->file_offset, SEEK_SET); - ecl_kw_fwrite(file_kw->kw, target); + rd_kw_fwrite(file_kw->kw, target); } -const char *ecl_file_kw_get_header(const ecl_file_kw_type *file_kw) { +const char *rd_file_kw_get_header(const rd_file_kw_type *file_kw) { return file_kw->header; } -int ecl_file_kw_get_size(const ecl_file_kw_type *file_kw) { +int rd_file_kw_get_size(const rd_file_kw_type *file_kw) { return file_kw->kw_size; } -ecl_data_type ecl_file_kw_get_data_type(const ecl_file_kw_type *file_kw) { +rd_data_type rd_file_kw_get_data_type(const rd_file_kw_type *file_kw) { return file_kw->data_type; } -offset_type ecl_file_kw_get_offset(const ecl_file_kw_type *file_kw) { +offset_type rd_file_kw_get_offset(const rd_file_kw_type *file_kw) { return file_kw->file_offset; } -bool ecl_file_kw_fskip_data(const ecl_file_kw_type *file_kw, - fortio_type *fortio) { - return ecl_kw_fskip_data__(ecl_file_kw_get_data_type(file_kw), - file_kw->kw_size, fortio); +bool rd_file_kw_fskip_data(const rd_file_kw_type *file_kw, + fortio_type *fortio) { + return rd_kw_fskip_data__(rd_file_kw_get_data_type(file_kw), + file_kw->kw_size, fortio); } /** This function will replace the file content of the keyword pointed - to by @file_kw, with the new content given by @ecl_kw. The new - @ecl_kw keyword must have identical header to the one already + to by @file_kw, with the new content given by @rd_kw. The new + @rd_kw keyword must have identical header to the one already present in the file. */ -void ecl_file_kw_inplace_fwrite(ecl_file_kw_type *file_kw, - fortio_type *fortio) { - ecl_file_kw_assert_kw(file_kw); +void rd_file_kw_inplace_fwrite(rd_file_kw_type *file_kw, fortio_type *fortio) { + rd_file_kw_assert_kw(file_kw); fortio_fseek(fortio, file_kw->file_offset, SEEK_SET); - ecl_kw_fskip_header(fortio); + rd_kw_fskip_header(fortio); fortio_fclean(fortio); - ecl_kw_fwrite_data(file_kw->kw, fortio); + rd_kw_fwrite_data(file_kw->kw, fortio); } -void ecl_file_kw_fwrite(const ecl_file_kw_type *file_kw, FILE *stream) { +void rd_file_kw_fwrite(const rd_file_kw_type *file_kw, FILE *stream) { int header_length = strlen(file_kw->header); - for (int i = 0; i < ECL_STRING8_LENGTH; i++) { + for (int i = 0; i < RD_STRING8_LENGTH; i++) { if (i < header_length) fputc(file_kw->header[i], stream); else @@ -335,13 +331,13 @@ void ecl_file_kw_fwrite(const ecl_file_kw_type *file_kw, FILE *stream) { util_fwrite_int(file_kw->kw_size, stream); util_fwrite_offset(file_kw->file_offset, stream); - util_fwrite_int(ecl_type_get_type(file_kw->data_type), stream); - util_fwrite_size_t(ecl_type_get_sizeof_iotype(file_kw->data_type), stream); + util_fwrite_int(rd_type_get_type(file_kw->data_type), stream); + util_fwrite_size_t(rd_type_get_sizeof_iotype(file_kw->data_type), stream); } -ecl_file_kw_type **ecl_file_kw_fread_alloc_multiple(FILE *stream, int num) { +rd_file_kw_type **rd_file_kw_fread_alloc_multiple(FILE *stream, int num) { - size_t file_kw_size = ECL_STRING8_LENGTH + 2 * sizeof(int) + + size_t file_kw_size = RD_STRING8_LENGTH + 2 * sizeof(int) + sizeof(offset_type) + sizeof(size_t); size_t buffer_size = num * file_kw_size; char *buffer = (char *)util_malloc(buffer_size * sizeof *buffer); @@ -353,14 +349,14 @@ ecl_file_kw_type **ecl_file_kw_fread_alloc_multiple(FILE *stream, int num) { } { - ecl_file_kw_type **kw_list = - (ecl_file_kw_type **)util_malloc(num * sizeof *kw_list); + rd_file_kw_type **kw_list = + (rd_file_kw_type **)util_malloc(num * sizeof *kw_list); for (int ikw = 0; ikw < num; ikw++) { int buffer_offset = ikw * file_kw_size; - char header[ECL_STRING8_LENGTH + 1]; + char header[RD_STRING8_LENGTH + 1]; int kw_size; offset_type file_offset; - ecl_type_enum ecl_type; + rd_type_enum rd_type; size_t type_size; { int index = 0; @@ -371,11 +367,11 @@ ecl_file_kw_type **ecl_file_kw_fread_alloc_multiple(FILE *stream, int num) { break; index++; - if (index == ECL_STRING8_LENGTH) + if (index == RD_STRING8_LENGTH) break; } header[index] = '\0'; - buffer_offset += ECL_STRING8_LENGTH; + buffer_offset += RD_STRING8_LENGTH; } memcpy(&kw_size, &buffer[buffer_offset], sizeof kw_size); @@ -384,15 +380,15 @@ ecl_file_kw_type **ecl_file_kw_fread_alloc_multiple(FILE *stream, int num) { memcpy(&file_offset, &buffer[buffer_offset], sizeof file_offset); buffer_offset += sizeof file_offset; - memcpy(&ecl_type, &buffer[buffer_offset], sizeof ecl_type); - buffer_offset += sizeof ecl_type; + memcpy(&rd_type, &buffer[buffer_offset], sizeof rd_type); + buffer_offset += sizeof rd_type; memcpy(&type_size, &buffer[buffer_offset], sizeof type_size); buffer_offset += sizeof type_size; kw_list[ikw] = - ecl_file_kw_alloc0(header, ecl_type_create(ecl_type, type_size), - kw_size, file_offset); + rd_file_kw_alloc0(header, rd_type_create(rd_type, type_size), + kw_size, file_offset); } free(buffer); @@ -400,9 +396,9 @@ ecl_file_kw_type **ecl_file_kw_fread_alloc_multiple(FILE *stream, int num) { } } -ecl_file_kw_type *ecl_file_kw_fread_alloc(FILE *stream) { - ecl_file_kw_type *file_kw = NULL; - ecl_file_kw_type **multiple = ecl_file_kw_fread_alloc_multiple(stream, 1); +rd_file_kw_type *rd_file_kw_fread_alloc(FILE *stream) { + rd_file_kw_type *file_kw = NULL; + rd_file_kw_type **multiple = rd_file_kw_fread_alloc_multiple(stream, 1); if (multiple) { file_kw = multiple[0]; @@ -412,14 +408,14 @@ ecl_file_kw_type *ecl_file_kw_fread_alloc(FILE *stream) { return file_kw; } -void ecl_file_kw_start_transaction(const ecl_file_kw_type *file_kw, - int *ref_count) { +void rd_file_kw_start_transaction(const rd_file_kw_type *file_kw, + int *ref_count) { *ref_count = file_kw->ref_count; } -void ecl_file_kw_end_transaction(ecl_file_kw_type *file_kw, int ref_count) { +void rd_file_kw_end_transaction(rd_file_kw_type *file_kw, int ref_count) { if (ref_count == 0 && file_kw->ref_count > 0) { - ecl_kw_free(file_kw->kw); + rd_kw_free(file_kw->kw); file_kw->kw = NULL; } file_kw->ref_count = ref_count; diff --git a/lib/resdata/rd_file_view.cpp b/lib/resdata/rd_file_view.cpp index 9b3c1db270..ad18c99392 100644 --- a/lib/resdata/rd_file_view.cpp +++ b/lib/resdata/rd_file_view.cpp @@ -2,65 +2,65 @@ #include #include -#include -#include -#include -#include -#include -#include -#include - -struct ecl_file_view_struct { - std::vector kw_list; +#include +#include +#include +#include +#include +#include +#include + +struct rd_file_view_struct { + std::vector kw_list; std::map> kw_index; std::vector distinct_kw; /* A list of the keywords occuring in the file - each string occurs ONLY ONCE. */ fortio_type * - fortio; /* The same fortio instance pointer as in the ecl_file styructure. */ + fortio; /* The same fortio instance pointer as in the rd_file styructure. */ bool - owner; /* Is this map the owner of the ecl_file_kw instances; only true for the global_map. */ + owner; /* Is this map the owner of the rd_file_kw instances; only true for the global_map. */ inv_map_type - *inv_map; /* Shared reference owned by the ecl_file structure. */ - std::vector child_list; + *inv_map; /* Shared reference owned by the rd_file structure. */ + std::vector child_list; int *flags; }; -struct ecl_file_transaction_struct { - const ecl_file_view_type *file_view; +struct rd_file_transaction_struct { + const rd_file_view_type *file_view; int *ref_count; }; -bool ecl_file_view_check_flags(int state_flags, int query_flags) { +bool rd_file_view_check_flags(int state_flags, int query_flags) { if ((state_flags & query_flags) == query_flags) return true; else return false; } -bool ecl_file_view_flags_set(const ecl_file_view_type *file_view, - int query_flags) { - return ecl_file_view_check_flags(*file_view->flags, query_flags); +bool rd_file_view_flags_set(const rd_file_view_type *file_view, + int query_flags) { + return rd_file_view_check_flags(*file_view->flags, query_flags); } -const char *ecl_file_view_get_src_file(const ecl_file_view_type *file_view) { +const char *rd_file_view_get_src_file(const rd_file_view_type *file_view) { return fortio_filename_ref(file_view->fortio); } -ecl_file_view_type *ecl_file_view_alloc(fortio_type *fortio, int *flags, - inv_map_type *inv_map, bool owner) { - ecl_file_view_type *ecl_file_view = new ecl_file_view_type(); +rd_file_view_type *rd_file_view_alloc(fortio_type *fortio, int *flags, + inv_map_type *inv_map, bool owner) { + rd_file_view_type *rd_file_view = new rd_file_view_type(); - ecl_file_view->owner = owner; - ecl_file_view->fortio = fortio; - ecl_file_view->inv_map = inv_map; - ecl_file_view->flags = flags; + rd_file_view->owner = owner; + rd_file_view->fortio = fortio; + rd_file_view->inv_map = inv_map; + rd_file_view->flags = flags; - return ecl_file_view; + return rd_file_view; } -int ecl_file_view_get_global_index(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith) { - const auto &index_vector = ecl_file_view->kw_index.at(kw); +int rd_file_view_get_global_index(const rd_file_view_type *rd_file_view, + const char *kw, int ith) { + const auto &index_vector = rd_file_view->kw_index.at(kw); return index_vector[ith]; } @@ -68,112 +68,110 @@ int ecl_file_view_get_global_index(const ecl_file_view_type *ecl_file_view, This function iterates over the kw_list vector and builds the internal index fields 'kw_index' and 'distinct_kw'. This function must be called every time the content of the kw_list vector is - modified (otherwise the ecl_file instance will be in an + modified (otherwise the rd_file instance will be in an inconsistent state). */ -void ecl_file_view_make_index(ecl_file_view_type *ecl_file_view) { - ecl_file_view->distinct_kw.clear(); - ecl_file_view->kw_index.clear(); +void rd_file_view_make_index(rd_file_view_type *rd_file_view) { + rd_file_view->distinct_kw.clear(); + rd_file_view->kw_index.clear(); { int global_index = 0; - for (const auto &file_kw : ecl_file_view->kw_list) { - const std::string &header = ecl_file_kw_get_header(file_kw); - if (ecl_file_view->kw_index.find(header) == - ecl_file_view->kw_index.end()) - ecl_file_view->distinct_kw.push_back(header); + for (const auto &file_kw : rd_file_view->kw_list) { + const std::string &header = rd_file_kw_get_header(file_kw); + if (rd_file_view->kw_index.find(header) == + rd_file_view->kw_index.end()) + rd_file_view->distinct_kw.push_back(header); - auto &index_vector = ecl_file_view->kw_index[header]; + auto &index_vector = rd_file_view->kw_index[header]; index_vector.push_back(global_index); global_index++; } } } -bool ecl_file_view_has_kw(const ecl_file_view_type *ecl_file_view, - const char *kw) { - return (ecl_file_view->kw_index.find(kw) != ecl_file_view->kw_index.end()); +bool rd_file_view_has_kw(const rd_file_view_type *rd_file_view, + const char *kw) { + return (rd_file_view->kw_index.find(kw) != rd_file_view->kw_index.end()); } -ecl_file_kw_type * -ecl_file_view_iget_file_kw(const ecl_file_view_type *ecl_file_view, - int global_index) { - return ecl_file_view->kw_list[global_index]; +rd_file_kw_type * +rd_file_view_iget_file_kw(const rd_file_view_type *rd_file_view, + int global_index) { + return rd_file_view->kw_list[global_index]; } -ecl_file_kw_type * -ecl_file_view_iget_named_file_kw(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith) { - int global_index = ecl_file_view_get_global_index(ecl_file_view, kw, ith); - ecl_file_kw_type *file_kw = - ecl_file_view_iget_file_kw(ecl_file_view, global_index); +rd_file_kw_type * +rd_file_view_iget_named_file_kw(const rd_file_view_type *rd_file_view, + const char *kw, int ith) { + int global_index = rd_file_view_get_global_index(rd_file_view, kw, ith); + rd_file_kw_type *file_kw = + rd_file_view_iget_file_kw(rd_file_view, global_index); return file_kw; } -bool ecl_file_view_drop_flag(ecl_file_view_type *file_view, int flag) { - bool flag_set = ecl_file_view_flags_set(file_view, flag); +bool rd_file_view_drop_flag(rd_file_view_type *file_view, int flag) { + bool flag_set = rd_file_view_flags_set(file_view, flag); if (flag_set) *file_view->flags -= flag; return flag_set; } -void ecl_file_view_add_flag(ecl_file_view_type *file_view, int flag) { +void rd_file_view_add_flag(rd_file_view_type *file_view, int flag) { *file_view->flags |= flag; } -static ecl_kw_type * -ecl_file_view_get_kw(const ecl_file_view_type *ecl_file_view, - ecl_file_kw_type *file_kw) { - ecl_kw_type *ecl_kw = ecl_file_kw_get_kw_ptr(file_kw); - if (!ecl_kw) { - if (fortio_assert_stream_open(ecl_file_view->fortio)) { +static rd_kw_type *rd_file_view_get_kw(const rd_file_view_type *rd_file_view, + rd_file_kw_type *file_kw) { + rd_kw_type *rd_kw = rd_file_kw_get_kw_ptr(file_kw); + if (!rd_kw) { + if (fortio_assert_stream_open(rd_file_view->fortio)) { - ecl_kw = ecl_file_kw_get_kw(file_kw, ecl_file_view->fortio, - ecl_file_view->inv_map); + rd_kw = rd_file_kw_get_kw(file_kw, rd_file_view->fortio, + rd_file_view->inv_map); - if (ecl_file_view_flags_set(ecl_file_view, ECL_FILE_CLOSE_STREAM)) - fortio_fclose_stream(ecl_file_view->fortio); + if (rd_file_view_flags_set(rd_file_view, RD_FILE_CLOSE_STREAM)) + fortio_fclose_stream(rd_file_view->fortio); } } - return ecl_kw; + return rd_kw; } -ecl_kw_type *ecl_file_view_iget_kw(const ecl_file_view_type *ecl_file_view, - int index) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_file_kw(ecl_file_view, index); - return ecl_file_view_get_kw(ecl_file_view, file_kw); +rd_kw_type *rd_file_view_iget_kw(const rd_file_view_type *rd_file_view, + int index) { + rd_file_kw_type *file_kw = rd_file_view_iget_file_kw(rd_file_view, index); + return rd_file_view_get_kw(rd_file_view, file_kw); } -void ecl_file_view_index_fload_kw(const ecl_file_view_type *ecl_file_view, - const char *kw, int index, - const int_vector_type *index_map, - char *io_buffer) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_named_file_kw(ecl_file_view, kw, index); +void rd_file_view_index_fload_kw(const rd_file_view_type *rd_file_view, + const char *kw, int index, + const int_vector_type *index_map, + char *io_buffer) { + rd_file_kw_type *file_kw = + rd_file_view_iget_named_file_kw(rd_file_view, kw, index); - if (fortio_assert_stream_open(ecl_file_view->fortio)) { - offset_type offset = ecl_file_kw_get_offset(file_kw); - ecl_data_type data_type = ecl_file_kw_get_data_type(file_kw); - int element_count = ecl_file_kw_get_size(file_kw); + if (fortio_assert_stream_open(rd_file_view->fortio)) { + offset_type offset = rd_file_kw_get_offset(file_kw); + rd_data_type data_type = rd_file_kw_get_data_type(file_kw); + int element_count = rd_file_kw_get_size(file_kw); - ecl_kw_fread_indexed_data(ecl_file_view->fortio, - offset + ECL_KW_HEADER_FORTIO_SIZE, data_type, - element_count, index_map, io_buffer); + rd_kw_fread_indexed_data(rd_file_view->fortio, + offset + RD_KW_HEADER_FORTIO_SIZE, data_type, + element_count, index_map, io_buffer); } } -int ecl_file_view_find_kw_value(const ecl_file_view_type *ecl_file_view, - const char *kw, const void *value) { +int rd_file_view_find_kw_value(const rd_file_view_type *rd_file_view, + const char *kw, const void *value) { int global_index = -1; - if (ecl_file_view_has_kw(ecl_file_view, kw)) { - const auto &index_list = ecl_file_view->kw_index.at(kw); + if (rd_file_view_has_kw(rd_file_view, kw)) { + const auto &index_list = rd_file_view->kw_index.at(kw); size_t index = 0; while (index < index_list.size()) { - const ecl_kw_type *ecl_kw = - ecl_file_view_iget_kw(ecl_file_view, index_list[index]); - if (ecl_kw_data_equal(ecl_kw, value)) { + const rd_kw_type *rd_kw = + rd_file_view_iget_kw(rd_file_view, index_list[index]); + if (rd_kw_data_equal(rd_kw, value)) { global_index = index_list[index]; break; } @@ -183,153 +181,145 @@ int ecl_file_view_find_kw_value(const ecl_file_view_type *ecl_file_view, return global_index; } -const char * -ecl_file_view_iget_distinct_kw(const ecl_file_view_type *ecl_file_view, - int index) { - const std::string &string = ecl_file_view->distinct_kw[index]; +const char *rd_file_view_iget_distinct_kw(const rd_file_view_type *rd_file_view, + int index) { + const std::string &string = rd_file_view->distinct_kw[index]; return string.c_str(); } -int ecl_file_view_get_num_distinct_kw(const ecl_file_view_type *ecl_file_view) { - return ecl_file_view->distinct_kw.size(); +int rd_file_view_get_num_distinct_kw(const rd_file_view_type *rd_file_view) { + return rd_file_view->distinct_kw.size(); } -int ecl_file_view_get_size(const ecl_file_view_type *ecl_file_view) { - return ecl_file_view->kw_list.size(); +int rd_file_view_get_size(const rd_file_view_type *rd_file_view) { + return rd_file_view->kw_list.size(); } -ecl_data_type -ecl_file_view_iget_data_type(const ecl_file_view_type *ecl_file_view, - int index) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_file_kw(ecl_file_view, index); - return ecl_file_kw_get_data_type(file_kw); +rd_data_type rd_file_view_iget_data_type(const rd_file_view_type *rd_file_view, + int index) { + rd_file_kw_type *file_kw = rd_file_view_iget_file_kw(rd_file_view, index); + return rd_file_kw_get_data_type(file_kw); } -int ecl_file_view_iget_size(const ecl_file_view_type *ecl_file_view, - int index) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_file_kw(ecl_file_view, index); - return ecl_file_kw_get_size(file_kw); +int rd_file_view_iget_size(const rd_file_view_type *rd_file_view, int index) { + rd_file_kw_type *file_kw = rd_file_view_iget_file_kw(rd_file_view, index); + return rd_file_kw_get_size(file_kw); } -const char *ecl_file_view_iget_header(const ecl_file_view_type *ecl_file_view, - int index) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_file_kw(ecl_file_view, index); - return ecl_file_kw_get_header(file_kw); +const char *rd_file_view_iget_header(const rd_file_view_type *rd_file_view, + int index) { + rd_file_kw_type *file_kw = rd_file_view_iget_file_kw(rd_file_view, index); + return rd_file_kw_get_header(file_kw); } -ecl_kw_type * -ecl_file_view_iget_named_kw(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_named_file_kw(ecl_file_view, kw, ith); - return ecl_file_view_get_kw(ecl_file_view, file_kw); +rd_kw_type *rd_file_view_iget_named_kw(const rd_file_view_type *rd_file_view, + const char *kw, int ith) { + rd_file_kw_type *file_kw = + rd_file_view_iget_named_file_kw(rd_file_view, kw, ith); + return rd_file_view_get_kw(rd_file_view, file_kw); } -ecl_data_type -ecl_file_view_iget_named_data_type(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_named_file_kw(ecl_file_view, kw, ith); - return ecl_file_kw_get_data_type(file_kw); +rd_data_type +rd_file_view_iget_named_data_type(const rd_file_view_type *rd_file_view, + const char *kw, int ith) { + rd_file_kw_type *file_kw = + rd_file_view_iget_named_file_kw(rd_file_view, kw, ith); + return rd_file_kw_get_data_type(file_kw); } -int ecl_file_view_iget_named_size(const ecl_file_view_type *ecl_file_view, - const char *kw, int ith) { - ecl_file_kw_type *file_kw = - ecl_file_view_iget_named_file_kw(ecl_file_view, kw, ith); - return ecl_file_kw_get_size(file_kw); +int rd_file_view_iget_named_size(const rd_file_view_type *rd_file_view, + const char *kw, int ith) { + rd_file_kw_type *file_kw = + rd_file_view_iget_named_file_kw(rd_file_view, kw, ith); + return rd_file_kw_get_size(file_kw); } -void ecl_file_view_replace_kw(ecl_file_view_type *ecl_file_view, - ecl_kw_type *old_kw, ecl_kw_type *new_kw, - bool insert_copy) { +void rd_file_view_replace_kw(rd_file_view_type *rd_file_view, + rd_kw_type *old_kw, rd_kw_type *new_kw, + bool insert_copy) { size_t index = 0; - while (index < ecl_file_view->kw_list.size()) { - auto *ikw = ecl_file_view->kw_list[index]; - if (ecl_file_kw_ptr_eq(ikw, old_kw)) { + while (index < rd_file_view->kw_list.size()) { + auto *ikw = rd_file_view->kw_list[index]; + if (rd_file_kw_ptr_eq(ikw, old_kw)) { /* Found it; observe that the vector_iset() function will automatically invoke the destructor on the old_kw. */ - ecl_kw_type *insert_kw = new_kw; + rd_kw_type *insert_kw = new_kw; if (insert_copy) - insert_kw = ecl_kw_alloc_copy(new_kw); - ecl_file_kw_replace_kw(ikw, ecl_file_view->fortio, insert_kw); + insert_kw = rd_kw_alloc_copy(new_kw); + rd_file_kw_replace_kw(ikw, rd_file_view->fortio, insert_kw); - ecl_file_view_make_index(ecl_file_view); + rd_file_view_make_index(rd_file_view); return; } index++; } - util_abort("%s: could not find ecl_kw ptr: %p \n", __func__, old_kw); + util_abort("%s: could not find rd_kw ptr: %p \n", __func__, old_kw); } -bool ecl_file_view_load_all(ecl_file_view_type *ecl_file_view) { +bool rd_file_view_load_all(rd_file_view_type *rd_file_view) { bool loadOK = false; - if (fortio_assert_stream_open(ecl_file_view->fortio)) { - for (ecl_file_kw_type *file_kw : ecl_file_view->kw_list) - ecl_file_kw_get_kw(file_kw, ecl_file_view->fortio, - ecl_file_view->inv_map); + if (fortio_assert_stream_open(rd_file_view->fortio)) { + for (rd_file_kw_type *file_kw : rd_file_view->kw_list) + rd_file_kw_get_kw(file_kw, rd_file_view->fortio, + rd_file_view->inv_map); loadOK = true; } - if (ecl_file_view_flags_set(ecl_file_view, ECL_FILE_CLOSE_STREAM)) - fortio_fclose_stream(ecl_file_view->fortio); + if (rd_file_view_flags_set(rd_file_view, RD_FILE_CLOSE_STREAM)) + fortio_fclose_stream(rd_file_view->fortio); return loadOK; } -void ecl_file_view_add_kw(ecl_file_view_type *ecl_file_view, - ecl_file_kw_type *file_kw) { - ecl_file_view->kw_list.push_back(file_kw); +void rd_file_view_add_kw(rd_file_view_type *rd_file_view, + rd_file_kw_type *file_kw) { + rd_file_view->kw_list.push_back(file_kw); } -void ecl_file_view_free(ecl_file_view_type *ecl_file_view) { +void rd_file_view_free(rd_file_view_type *rd_file_view) { - for (auto &child_ptr : ecl_file_view->child_list) - ecl_file_view_free(child_ptr); + for (auto &child_ptr : rd_file_view->child_list) + rd_file_view_free(child_ptr); - if (ecl_file_view->owner) { - for (auto &kw_ptr : ecl_file_view->kw_list) - ecl_file_kw_free(kw_ptr); + if (rd_file_view->owner) { + for (auto &kw_ptr : rd_file_view->kw_list) + rd_file_kw_free(kw_ptr); } - delete ecl_file_view; + delete rd_file_view; } -void ecl_file_view_free__(void *arg) { - ecl_file_view_type *ecl_file_view = (ecl_file_view_type *)arg; - ecl_file_view_free(ecl_file_view); +void rd_file_view_free__(void *arg) { + rd_file_view_type *rd_file_view = (rd_file_view_type *)arg; + rd_file_view_free(rd_file_view); } -int ecl_file_view_get_num_named_kw(const ecl_file_view_type *ecl_file_view, - const char *kw) { - if (ecl_file_view_has_kw(ecl_file_view, kw)) { - const auto &index_vector = ecl_file_view->kw_index.at(kw); +int rd_file_view_get_num_named_kw(const rd_file_view_type *rd_file_view, + const char *kw) { + if (rd_file_view_has_kw(rd_file_view, kw)) { + const auto &index_vector = rd_file_view->kw_index.at(kw); return index_vector.size(); } else return 0; } -void ecl_file_view_fwrite(const ecl_file_view_type *ecl_file_view, - fortio_type *target, int offset) { - for (size_t index = offset; index < ecl_file_view->kw_list.size(); - index++) { - ecl_kw_type *ecl_kw = ecl_file_view_iget_kw(ecl_file_view, index); - ecl_kw_fwrite(ecl_kw, target); +void rd_file_view_fwrite(const rd_file_view_type *rd_file_view, + fortio_type *target, int offset) { + for (size_t index = offset; index < rd_file_view->kw_list.size(); index++) { + rd_kw_type *rd_kw = rd_file_view_iget_kw(rd_file_view, index); + rd_kw_fwrite(rd_kw, target); } } -int ecl_file_view_iget_occurence(const ecl_file_view_type *ecl_file_view, - int global_index) { - const ecl_file_kw_type *file_kw = ecl_file_view->kw_list[global_index]; - const char *header = ecl_file_kw_get_header(file_kw); - const auto &index_vector = ecl_file_view->kw_index.at(header); +int rd_file_view_iget_occurence(const rd_file_view_type *rd_file_view, + int global_index) { + const rd_file_kw_type *file_kw = rd_file_view->kw_list[global_index]; + const char *header = rd_file_kw_get_header(file_kw); + const auto &index_vector = rd_file_view->kw_index.at(header); int occurence = -1; { @@ -345,69 +335,68 @@ int ecl_file_view_iget_occurence(const ecl_file_view_type *ecl_file_view, return occurence; } -void ecl_file_view_fprintf_kw_list(const ecl_file_view_type *ecl_file_view, - FILE *stream) { - for (auto &file_kw : ecl_file_view->kw_list) { - char *type_name = - ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw)); - fprintf(stream, "%-8s %7d:%s\n", ecl_file_kw_get_header(file_kw), - ecl_file_kw_get_size(file_kw), type_name); +void rd_file_view_fprintf_kw_list(const rd_file_view_type *rd_file_view, + FILE *stream) { + for (auto &file_kw : rd_file_view->kw_list) { + char *type_name = rd_type_alloc_name(rd_file_kw_get_data_type(file_kw)); + fprintf(stream, "%-8s %7d:%s\n", rd_file_kw_get_header(file_kw), + rd_file_kw_get_size(file_kw), type_name); free(type_name); } } -ecl_file_view_type * -ecl_file_view_alloc_blockview2(const ecl_file_view_type *ecl_file_view, - const char *start_kw, const char *end_kw, - int occurence) { +rd_file_view_type * +rd_file_view_alloc_blockview2(const rd_file_view_type *rd_file_view, + const char *start_kw, const char *end_kw, + int occurence) { if ((start_kw != NULL) && - ecl_file_view_get_num_named_kw(ecl_file_view, start_kw) <= occurence) + rd_file_view_get_num_named_kw(rd_file_view, start_kw) <= occurence) return NULL; - ecl_file_view_type *block_map = - ecl_file_view_alloc(ecl_file_view->fortio, ecl_file_view->flags, - ecl_file_view->inv_map, false); + rd_file_view_type *block_map = + rd_file_view_alloc(rd_file_view->fortio, rd_file_view->flags, + rd_file_view->inv_map, false); size_t kw_index = 0; if (start_kw) kw_index = - ecl_file_view_get_global_index(ecl_file_view, start_kw, occurence); + rd_file_view_get_global_index(rd_file_view, start_kw, occurence); { - ecl_file_kw_type *file_kw = ecl_file_view->kw_list[kw_index]; + rd_file_kw_type *file_kw = rd_file_view->kw_list[kw_index]; while (true) { - ecl_file_view_add_kw(block_map, file_kw); + rd_file_view_add_kw(block_map, file_kw); kw_index++; - if (kw_index == ecl_file_view->kw_list.size()) + if (kw_index == rd_file_view->kw_list.size()) break; else { if (end_kw) { - file_kw = ecl_file_view->kw_list[kw_index]; - if (strcmp(end_kw, ecl_file_kw_get_header(file_kw)) == 0) + file_kw = rd_file_view->kw_list[kw_index]; + if (strcmp(end_kw, rd_file_kw_get_header(file_kw)) == 0) break; } } } } - ecl_file_view_make_index(block_map); + rd_file_view_make_index(block_map); return block_map; } /** Will return NULL if the block which is asked for is not present. */ -ecl_file_view_type * -ecl_file_view_alloc_blockview(const ecl_file_view_type *ecl_file_view, - const char *header, int occurence) { - return ecl_file_view_alloc_blockview2(ecl_file_view, header, header, - occurence); +rd_file_view_type * +rd_file_view_alloc_blockview(const rd_file_view_type *rd_file_view, + const char *header, int occurence) { + return rd_file_view_alloc_blockview2(rd_file_view, header, header, + occurence); } -ecl_file_view_type *ecl_file_view_add_blockview(ecl_file_view_type *file_view, - const char *header, - int occurence) { - ecl_file_view_type *child = - ecl_file_view_alloc_blockview2(file_view, header, header, occurence); +rd_file_view_type *rd_file_view_add_blockview(rd_file_view_type *file_view, + const char *header, + int occurence) { + rd_file_view_type *child = + rd_file_view_alloc_blockview2(file_view, header, header, occurence); if (child) file_view->child_list.push_back(child); @@ -415,22 +404,22 @@ ecl_file_view_type *ecl_file_view_add_blockview(ecl_file_view_type *file_view, return child; } -ecl_file_view_type * -ecl_file_view_add_blockview2(ecl_file_view_type *ecl_file_view, - const char *start_kw, const char *end_kw, - int occurence) { - ecl_file_view_type *child = ecl_file_view_alloc_blockview2( - ecl_file_view, start_kw, end_kw, occurence); +rd_file_view_type *rd_file_view_add_blockview2(rd_file_view_type *rd_file_view, + const char *start_kw, + const char *end_kw, + int occurence) { + rd_file_view_type *child = rd_file_view_alloc_blockview2( + rd_file_view, start_kw, end_kw, occurence); if (child) - ecl_file_view->child_list.push_back(child); + rd_file_view->child_list.push_back(child); return child; } /* There is no special datastructure for working with restart files, - they are 100% stock ecl_file instances with the following limited + they are 100% stock rd_file instances with the following limited structure: * They are organized in blocks; where each block starts with a @@ -513,11 +502,11 @@ we have introduced the following concepts: i.e. to do queries based on the report_step we must load the seqnum kewyord and read the value. - ecl_file_get_unrstmap_report_step( ecl_file , 0 ) => A - ecl_file_get_unrstmap_report_step( ecl_file , 1 ) => NULL + rd_file_get_unrstmap_report_step( rd_file , 0 ) => A + rd_file_get_unrstmap_report_step( rd_file , 1 ) => NULL - ecl_file_has_report_step( ecl_file , 5 ) => True - ecl_file_has_report_step( ecl_file , 2 ) => False + rd_file_has_report_step( rd_file , 5 ) => True + rd_file_has_report_step( rd_file , 2 ) => False sim_time: This correpsonds to the true simulation time of the report step, the simulation time is stored as integers DAY, MONTH, YEAR @@ -525,7 +514,7 @@ we have introduced the following concepts: the DAY, MONTH and YEAR values from an INTEHEAD keyword instance and convert to a time_t instance. The functions: - ecl_file_get_unrstmap_sim_time() and ecl_file_has_has_sim_time() + rd_file_get_unrstmap_sim_time() and rd_file_has_has_sim_time() can be used to query for simulation times and get the corresponding block maps. @@ -543,61 +532,59 @@ we have introduced the following concepts: */ -bool ecl_file_view_has_report_step(const ecl_file_view_type *ecl_file_view, - int report_step) { +bool rd_file_view_has_report_step(const rd_file_view_type *rd_file_view, + int report_step) { int global_index = - ecl_file_view_find_kw_value(ecl_file_view, SEQNUM_KW, &report_step); + rd_file_view_find_kw_value(rd_file_view, SEQNUM_KW, &report_step); if (global_index >= 0) return true; else return false; } -time_t -ecl_file_view_iget_restart_sim_date(const ecl_file_view_type *ecl_file_view, - int seqnum_index) { +time_t rd_file_view_iget_restart_sim_date(const rd_file_view_type *rd_file_view, + int seqnum_index) { time_t sim_time = -1; - ecl_file_view_type *seqnum_map = - ecl_file_view_alloc_blockview(ecl_file_view, SEQNUM_KW, seqnum_index); + rd_file_view_type *seqnum_map = + rd_file_view_alloc_blockview(rd_file_view, SEQNUM_KW, seqnum_index); if (seqnum_map != NULL) { - ecl_kw_type *intehead_kw = - ecl_file_view_iget_named_kw(seqnum_map, INTEHEAD_KW, 0); - sim_time = ecl_rsthead_date(intehead_kw); - ecl_file_view_free(seqnum_map); + rd_kw_type *intehead_kw = + rd_file_view_iget_named_kw(seqnum_map, INTEHEAD_KW, 0); + sim_time = rd_rsthead_date(intehead_kw); + rd_file_view_free(seqnum_map); } return sim_time; } -double -ecl_file_view_iget_restart_sim_days(const ecl_file_view_type *ecl_file_view, - int seqnum_index) { +double rd_file_view_iget_restart_sim_days(const rd_file_view_type *rd_file_view, + int seqnum_index) { double sim_days = 0; - ecl_file_view_type *seqnum_map = - ecl_file_view_alloc_blockview(ecl_file_view, SEQNUM_KW, seqnum_index); + rd_file_view_type *seqnum_map = + rd_file_view_alloc_blockview(rd_file_view, SEQNUM_KW, seqnum_index); if (seqnum_map != NULL) { - ecl_kw_type *doubhead_kw = - ecl_file_view_iget_named_kw(seqnum_map, DOUBHEAD_KW, 0); - sim_days = ecl_kw_iget_double(doubhead_kw, DOUBHEAD_DAYS_INDEX); - ecl_file_view_free(seqnum_map); + rd_kw_type *doubhead_kw = + rd_file_view_iget_named_kw(seqnum_map, DOUBHEAD_KW, 0); + sim_days = rd_kw_iget_double(doubhead_kw, DOUBHEAD_DAYS_INDEX); + rd_file_view_free(seqnum_map); } return sim_days; } -int ecl_file_view_find_sim_time(const ecl_file_view_type *ecl_file_view, - time_t sim_time) { +int rd_file_view_find_sim_time(const rd_file_view_type *rd_file_view, + time_t sim_time) { int seqnum_index = -1; - if (ecl_file_view_has_kw(ecl_file_view, INTEHEAD_KW)) { + if (rd_file_view_has_kw(rd_file_view, INTEHEAD_KW)) { const auto &intehead_index_list = - ecl_file_view->kw_index.at(INTEHEAD_KW); + rd_file_view->kw_index.at(INTEHEAD_KW); size_t index = 0; while (index < intehead_index_list.size()) { - const ecl_kw_type *intehead_kw = ecl_file_view_iget_kw( - ecl_file_view, intehead_index_list[index]); - if (ecl_rsthead_date(intehead_kw) == sim_time) { + const rd_kw_type *intehead_kw = + rd_file_view_iget_kw(rd_file_view, intehead_index_list[index]); + if (rd_rsthead_date(intehead_kw) == sim_time) { seqnum_index = index; break; } @@ -608,7 +595,7 @@ int ecl_file_view_find_sim_time(const ecl_file_view_type *ecl_file_view, } /** - This function will scan through the ecl_file looking for INTEHEAD + This function will scan through the rd_file looking for INTEHEAD headers corresponding to sim_time. If sim_time is found the function will return the INTEHEAD occurence number, i.e. for a unified restart file like: @@ -631,7 +618,7 @@ int ecl_file_view_find_sim_time(const ecl_file_view_type *ecl_file_view, The function call: - ecl_file_get_restart_index( restart_file , (time_t) "01.03.2000") + rd_file_get_restart_index( restart_file , (time_t) "01.03.2000") will return 1. Observe that this will in general NOT agree with the DATES step number. @@ -648,17 +635,16 @@ int ecl_file_view_find_sim_time(const ecl_file_view_type *ecl_file_view, calling this function. */ -bool ecl_file_view_has_sim_time(const ecl_file_view_type *ecl_file_view, - time_t sim_time) { - int num_INTEHEAD = - ecl_file_view_get_num_named_kw(ecl_file_view, INTEHEAD_KW); +bool rd_file_view_has_sim_time(const rd_file_view_type *rd_file_view, + time_t sim_time) { + int num_INTEHEAD = rd_file_view_get_num_named_kw(rd_file_view, INTEHEAD_KW); if (num_INTEHEAD == 0) return false; /* We have no INTEHEAD headers - probably not a restart file at all. */ else { int intehead_index = 0; while (true) { - time_t itime = ecl_file_view_iget_restart_sim_date(ecl_file_view, - intehead_index); + time_t itime = rd_file_view_iget_restart_sim_date(rd_file_view, + intehead_index); if (itime == sim_time) /* Perfect hit. */ return true; @@ -675,17 +661,16 @@ bool ecl_file_view_has_sim_time(const ecl_file_view_type *ecl_file_view, } } -bool ecl_file_view_has_sim_days(const ecl_file_view_type *ecl_file_view, - double sim_days) { - int num_DOUBHEAD = - ecl_file_view_get_num_named_kw(ecl_file_view, DOUBHEAD_KW); +bool rd_file_view_has_sim_days(const rd_file_view_type *rd_file_view, + double sim_days) { + int num_DOUBHEAD = rd_file_view_get_num_named_kw(rd_file_view, DOUBHEAD_KW); if (num_DOUBHEAD == 0) return false; /* We have no DOUBHEAD headers - probably not a restart file at all. */ else { int doubhead_index = 0; while (true) { - double file_sim_days = ecl_file_view_iget_restart_sim_days( - ecl_file_view, doubhead_index); + double file_sim_days = rd_file_view_iget_restart_sim_days( + rd_file_view, doubhead_index); if (util_double_approx_equal(sim_days, file_sim_days)) /* Perfect hit. */ @@ -703,42 +688,41 @@ bool ecl_file_view_has_sim_days(const ecl_file_view_type *ecl_file_view, } } -int ecl_file_view_seqnum_index_from_sim_time(ecl_file_view_type *parent_map, - time_t sim_time) { - int num_seqnum = ecl_file_view_get_num_named_kw(parent_map, SEQNUM_KW); - ecl_file_view_type *seqnum_map; +int rd_file_view_seqnum_index_from_sim_time(rd_file_view_type *parent_map, + time_t sim_time) { + int num_seqnum = rd_file_view_get_num_named_kw(parent_map, SEQNUM_KW); + rd_file_view_type *seqnum_map; for (int s_idx = 0; s_idx < num_seqnum; s_idx++) { - seqnum_map = - ecl_file_view_alloc_blockview(parent_map, SEQNUM_KW, s_idx); + seqnum_map = rd_file_view_alloc_blockview(parent_map, SEQNUM_KW, s_idx); if (!seqnum_map) continue; - bool sim = ecl_file_view_has_sim_time(seqnum_map, sim_time); - ecl_file_view_free(seqnum_map); + bool sim = rd_file_view_has_sim_time(seqnum_map, sim_time); + rd_file_view_free(seqnum_map); if (sim) return s_idx; } return -1; } -int ecl_file_view_seqnum_index_from_sim_days(ecl_file_view_type *file_view, - double sim_days) { - int num_seqnum = ecl_file_view_get_num_named_kw(file_view, SEQNUM_KW); +int rd_file_view_seqnum_index_from_sim_days(rd_file_view_type *file_view, + double sim_days) { + int num_seqnum = rd_file_view_get_num_named_kw(file_view, SEQNUM_KW); int seqnum_index = 0; - ecl_file_view_type *seqnum_map; + rd_file_view_type *seqnum_map; while (true) { seqnum_map = - ecl_file_view_alloc_blockview(file_view, SEQNUM_KW, seqnum_index); + rd_file_view_alloc_blockview(file_view, SEQNUM_KW, seqnum_index); if (seqnum_map != NULL) { - if (ecl_file_view_has_sim_days(seqnum_map, sim_days)) { - ecl_file_view_free(seqnum_map); + if (rd_file_view_has_sim_days(seqnum_map, sim_days)) { + rd_file_view_free(seqnum_map); return seqnum_index; } else { - ecl_file_view_free(seqnum_map); + rd_file_view_free(seqnum_map); seqnum_index++; } } @@ -751,105 +735,105 @@ int ecl_file_view_seqnum_index_from_sim_days(ecl_file_view_type *file_view, /* Will mulitplex on the four input arguments. */ -ecl_file_view_type * -ecl_file_view_add_restart_view(ecl_file_view_type *file_view, int input_index, - int report_step, time_t sim_time, - double sim_days) { - ecl_file_view_type *child = NULL; +rd_file_view_type *rd_file_view_add_restart_view(rd_file_view_type *file_view, + int input_index, + int report_step, + time_t sim_time, + double sim_days) { + rd_file_view_type *child = NULL; int seqnum_index = -1; if (input_index >= 0) seqnum_index = input_index; else if (report_step >= 0) { int global_index = - ecl_file_view_find_kw_value(file_view, SEQNUM_KW, &report_step); + rd_file_view_find_kw_value(file_view, SEQNUM_KW, &report_step); if (global_index >= 0) - seqnum_index = - ecl_file_view_iget_occurence(file_view, global_index); + seqnum_index = rd_file_view_iget_occurence(file_view, global_index); } else if (sim_time != -1) seqnum_index = - ecl_file_view_seqnum_index_from_sim_time(file_view, sim_time); + rd_file_view_seqnum_index_from_sim_time(file_view, sim_time); else if (sim_days >= 0) seqnum_index = - ecl_file_view_seqnum_index_from_sim_days(file_view, sim_days); + rd_file_view_seqnum_index_from_sim_days(file_view, sim_days); if (seqnum_index >= 0) - child = ecl_file_view_add_blockview(file_view, SEQNUM_KW, seqnum_index); + child = rd_file_view_add_blockview(file_view, SEQNUM_KW, seqnum_index); return child; } -ecl_file_view_type * -ecl_file_view_add_summary_view(ecl_file_view_type *file_view, int report_step) { - ecl_file_view_type *child = - ecl_file_view_add_blockview(file_view, SEQHDR_KW, report_step); +rd_file_view_type *rd_file_view_add_summary_view(rd_file_view_type *file_view, + int report_step) { + rd_file_view_type *child = + rd_file_view_add_blockview(file_view, SEQHDR_KW, report_step); return child; } -void ecl_file_view_fclose_stream(ecl_file_view_type *file_view) { +void rd_file_view_fclose_stream(rd_file_view_type *file_view) { fortio_fclose_stream(file_view->fortio); } -void ecl_file_view_write_index(const ecl_file_view_type *file_view, - FILE *ostream) { - int size = ecl_file_view_get_size(file_view); +void rd_file_view_write_index(const rd_file_view_type *file_view, + FILE *ostream) { + int size = rd_file_view_get_size(file_view); util_fwrite_int(size, ostream); - ecl_file_kw_type *file_kw; + rd_file_kw_type *file_kw; for (int i = 0; i < size; i++) { - file_kw = ecl_file_view_iget_file_kw(file_view, i); - ecl_file_kw_fwrite(file_kw, ostream); + file_kw = rd_file_view_iget_file_kw(file_view, i); + rd_file_kw_fwrite(file_kw, ostream); } } -ecl_file_view_type *ecl_file_view_fread_alloc(fortio_type *fortio, int *flags, - inv_map_type *inv_map, - FILE *istream) { +rd_file_view_type *rd_file_view_fread_alloc(fortio_type *fortio, int *flags, + inv_map_type *inv_map, + FILE *istream) { int index_size = util_fread_int(istream); - ecl_file_kw_type **file_kw_list = - ecl_file_kw_fread_alloc_multiple(istream, index_size); + rd_file_kw_type **file_kw_list = + rd_file_kw_fread_alloc_multiple(istream, index_size); if (file_kw_list) { - ecl_file_view_type *file_view = - ecl_file_view_alloc(fortio, flags, inv_map, true); + rd_file_view_type *file_view = + rd_file_view_alloc(fortio, flags, inv_map, true); for (int i = 0; i < index_size; i++) - ecl_file_view_add_kw(file_view, file_kw_list[i]); + rd_file_view_add_kw(file_view, file_kw_list[i]); free(file_kw_list); - ecl_file_view_make_index(file_view); + rd_file_view_make_index(file_view); return file_view; } else { - fprintf(stderr, "%s: error reading ecl_file_type index file.\n", + fprintf(stderr, "%s: error reading rd_file_type index file.\n", __func__); return NULL; } } -ecl_file_transaction_type * -ecl_file_view_start_transaction(ecl_file_view_type *file_view) { - ecl_file_transaction_type *t = - (ecl_file_transaction_type *)util_malloc(sizeof *t); - int size = ecl_file_view_get_size(file_view); +rd_file_transaction_type * +rd_file_view_start_transaction(rd_file_view_type *file_view) { + rd_file_transaction_type *t = + (rd_file_transaction_type *)util_malloc(sizeof *t); + int size = rd_file_view_get_size(file_view); t->file_view = file_view; t->ref_count = (int *)util_malloc(size * sizeof *t->ref_count); for (int i = 0; i < size; i++) { - ecl_file_kw_type *file_kw = ecl_file_view_iget_file_kw(file_view, i); - ecl_file_kw_start_transaction(file_kw, &t->ref_count[i]); + rd_file_kw_type *file_kw = rd_file_view_iget_file_kw(file_view, i); + rd_file_kw_start_transaction(file_kw, &t->ref_count[i]); } return t; } -void ecl_file_view_end_transaction(ecl_file_view_type *file_view, - ecl_file_transaction_type *transaction) { +void rd_file_view_end_transaction(rd_file_view_type *file_view, + rd_file_transaction_type *transaction) { if (transaction->file_view != file_view) util_abort("%s: internal error - file_view / transaction mismatch\n", __func__); const int *ref_count = transaction->ref_count; - for (int i = 0; i < ecl_file_view_get_size(file_view); i++) { - ecl_file_kw_type *file_kw = ecl_file_view_iget_file_kw(file_view, i); - ecl_file_kw_end_transaction(file_kw, ref_count[i]); + for (int i = 0; i < rd_file_view_get_size(file_view); i++) { + rd_file_kw_type *file_kw = rd_file_view_iget_file_kw(file_view, i); + rd_file_kw_end_transaction(file_kw, ref_count[i]); } free(transaction->ref_count); free(transaction); diff --git a/lib/resdata/rd_grav.cpp b/lib/resdata/rd_grav.cpp index 180719abd4..c7ad324bd3 100644 --- a/lib/resdata/rd_grav.cpp +++ b/lib/resdata/rd_grav.cpp @@ -8,21 +8,21 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "detail/ecl/ecl_grid_cache.hpp" +#include "detail/resdata/rd_grid_cache.hpp" /** This file contains datastructures for calculating changes in gravitational response in reservoirs. The main datastructure is the - ecl_grav_type structure (which is the only structure which is + rd_grav_type structure (which is the only structure which is exported). */ @@ -37,22 +37,22 @@ typedef enum { GRAV_CALC_RFIP = 4 + GRAV_CALC_USE_RHO } grav_calc_type; -typedef struct ecl_grav_phase_struct ecl_grav_phase_type; +typedef struct rd_grav_phase_struct rd_grav_phase_type; /** - The ecl_grav_struct datastructure is the main structure for + The rd_grav_struct datastructure is the main structure for calculating the gravimetric response from time lapse ECLIPSE simulations. */ -struct ecl_grav_struct { - const ecl_file_type * +struct rd_grav_struct { + const rd_file_type * init_file; /* The init file - a shared reference owned by calling scope. */ - ecl::ecl_grid_cache * + rd::rd_grid_cache * grid_cache; /* An internal specialized structure to facilitate fast grid lookup. */ bool *aquifer_cell; /* Numerical aquifer cells should be ignored. */ - std::unordered_map surveys; + std::unordered_map surveys; std::unordered_map default_density; std::unordered_map> std_density; }; @@ -61,17 +61,17 @@ struct ecl_grav_struct { Data structure representing one gravimetric survey. */ -#define ECL_GRAV_SURVEY_ID 88517 -struct ecl_grav_survey_struct { +#define RD_GRAV_SURVEY_ID 88517 +struct rd_grav_survey_struct { UTIL_TYPE_ID_DECLARATION; - const ecl::ecl_grid_cache *grid_cache; + const rd::rd_grid_cache *grid_cache; const bool *aquifer_cell; char *name; /* Name of the survey - arbitrary string. */ double * - porv; /* Reference shared by the ecl_grav_phase structures - i.e. it must not be updated. */ - std::vector - phase_list; /* ecl_grav_phase_type objects - one for each phase present in the model. */ - std::unordered_map + porv; /* Reference shared by the rd_grav_phase structures - i.e. it must not be updated. */ + std::vector + phase_list; /* rd_grav_phase_type objects - one for each phase present in the model. */ + std::unordered_map phase_map; /* The same objects as in the phase_list vector - accessible by the "SWAT", "SGAS" and "SOIL" keys. */ }; @@ -79,44 +79,43 @@ struct ecl_grav_survey_struct { Data structure representing the results from one phase at one survey. */ -#define ECL_GRAV_PHASE_TYPE_ID 1066652 -struct ecl_grav_phase_struct { +#define RD_GRAV_PHASE_TYPE_ID 1066652 +struct rd_grav_phase_struct { UTIL_TYPE_ID_DECLARATION; - const ecl::ecl_grid_cache *grid_cache; + const rd::rd_grid_cache *grid_cache; const bool *aquifer_cell; double * fluid_mass; /* The total fluid in place (mass) of this phase - for each active cell.*/ double *work; /* Temporary used in the summation over all cells. */ - ecl_phase_enum phase; + rd_phase_enum phase; }; -static const char *get_den_kw(ecl_phase_enum phase, - ecl_version_enum ecl_version) { - if (ecl_version == ECLIPSE100) { +static const char *get_den_kw(rd_phase_enum phase, rd_version_enum rd_version) { + if (rd_version == ECLIPSE100) { switch (phase) { - case (ECL_OIL_PHASE): + case (RD_OIL_PHASE): return ECLIPSE100_OIL_DEN_KW; break; - case (ECL_GAS_PHASE): + case (RD_GAS_PHASE): return ECLIPSE100_GAS_DEN_KW; break; - case (ECL_WATER_PHASE): + case (RD_WATER_PHASE): return ECLIPSE100_WATER_DEN_KW; break; default: util_abort("%s: unrecognized phase id:%d \n", __func__, phase); return NULL; } - } else if ((ecl_version == ECLIPSE300) || - (ecl_version == ECLIPSE300_THERMAL)) { + } else if ((rd_version == ECLIPSE300) || + (rd_version == ECLIPSE300_THERMAL)) { switch (phase) { - case (ECL_OIL_PHASE): + case (RD_OIL_PHASE): return ECLIPSE300_OIL_DEN_KW; break; - case (ECL_GAS_PHASE): + case (RD_GAS_PHASE): return ECLIPSE300_GAS_DEN_KW; break; - case (ECL_WATER_PHASE): + case (RD_WATER_PHASE): return ECLIPSE300_WATER_DEN_KW; break; default: @@ -124,27 +123,26 @@ static const char *get_den_kw(ecl_phase_enum phase, return NULL; } } else { - util_abort("%s: unrecognized simulator id:%d \n", __func__, - ecl_version); + util_abort("%s: unrecognized simulator id:%d \n", __func__, rd_version); return NULL; } } -static void ecl_grav_phase_ensure_work(ecl_grav_phase_type *grav_phase) { +static void rd_grav_phase_ensure_work(rd_grav_phase_type *grav_phase) { if (grav_phase->work == NULL) grav_phase->work = (double *)util_calloc(grav_phase->grid_cache->size(), sizeof *grav_phase->work); } -static double ecl_grav_phase_eval(ecl_grav_phase_type *base_phase, - const ecl_grav_phase_type *monitor_phase, - ecl_region_type *region, double utm_x, - double utm_y, double depth) { +static double rd_grav_phase_eval(rd_grav_phase_type *base_phase, + const rd_grav_phase_type *monitor_phase, + rd_region_type *region, double utm_x, + double utm_y, double depth) { - ecl_grav_phase_ensure_work(base_phase); + rd_grav_phase_ensure_work(base_phase); if ((monitor_phase == NULL) || (base_phase->phase == monitor_phase->phase)) { - const ecl::ecl_grid_cache &grid_cache = *(base_phase->grid_cache); + const rd::rd_grid_cache &grid_cache = *(base_phase->grid_cache); const bool *aquifer = base_phase->aquifer_cell; double *mass_diff = base_phase->work; double deltag; @@ -169,7 +167,7 @@ static double ecl_grav_phase_eval(ecl_grav_phase_type *base_phase, return the result in microGal, i.e. we scale with 10^2 * 10^6 => 6.67E-3. */ - deltag = 6.67428E-3 * ecl_grav_common_eval_biot_savart( + deltag = 6.67428E-3 * rd_grav_common_eval_biot_savart( grid_cache, region, aquifer, mass_diff, utm_x, utm_y, depth); @@ -180,97 +178,93 @@ static double ecl_grav_phase_eval(ecl_grav_phase_type *base_phase, } } -static ecl_grav_phase_type *ecl_grav_phase_alloc( - ecl_grav_type *ecl_grav, ecl_grav_survey_type *survey, ecl_phase_enum phase, - const ecl_file_view_type *restart_file, grav_calc_type calc_type) { +static rd_grav_phase_type * +rd_grav_phase_alloc(rd_grav_type *rd_grav, rd_grav_survey_type *survey, + rd_phase_enum phase, const rd_file_view_type *restart_file, + grav_calc_type calc_type) { - const ecl_file_type *init_file = ecl_grav->init_file; - const ecl::ecl_grid_cache *grid_cache = ecl_grav->grid_cache; - const char *sat_kw_name = ecl_util_get_phase_name(phase); + const rd_file_type *init_file = rd_grav->init_file; + const rd::rd_grid_cache *grid_cache = rd_grav->grid_cache; + const char *sat_kw_name = rd_get_phase_name(phase); { - ecl_grav_phase_type *grav_phase = new ecl_grav_phase_type(); + rd_grav_phase_type *grav_phase = new rd_grav_phase_type(); const int size = grid_cache->size(); - UTIL_TYPE_ID_INIT(grav_phase, ECL_GRAV_PHASE_TYPE_ID); + UTIL_TYPE_ID_INIT(grav_phase, RD_GRAV_PHASE_TYPE_ID); grav_phase->grid_cache = grid_cache; - grav_phase->aquifer_cell = ecl_grav->aquifer_cell; + grav_phase->aquifer_cell = rd_grav->aquifer_cell; grav_phase->fluid_mass = (double *)util_calloc(size, sizeof *grav_phase->fluid_mass); grav_phase->phase = phase; grav_phase->work = NULL; if (calc_type == GRAV_CALC_FIP) { - ecl_kw_type *pvtnum_kw = - ecl_file_iget_named_kw(init_file, PVTNUM_KW, 0); + rd_kw_type *pvtnum_kw = + rd_file_iget_named_kw(init_file, PVTNUM_KW, 0); const std::vector std_density = - ecl_grav - ->std_density[std::string(ecl_util_get_phase_name(phase))]; - ecl_kw_type *fip_kw; - - if (phase == ECL_OIL_PHASE) - fip_kw = - ecl_file_view_iget_named_kw(restart_file, FIPOIL_KW, 0); - else if (phase == ECL_GAS_PHASE) - fip_kw = - ecl_file_view_iget_named_kw(restart_file, FIPGAS_KW, 0); + rd_grav->std_density[std::string(rd_get_phase_name(phase))]; + rd_kw_type *fip_kw; + + if (phase == RD_OIL_PHASE) + fip_kw = rd_file_view_iget_named_kw(restart_file, FIPOIL_KW, 0); + else if (phase == RD_GAS_PHASE) + fip_kw = rd_file_view_iget_named_kw(restart_file, FIPGAS_KW, 0); else - fip_kw = - ecl_file_view_iget_named_kw(restart_file, FIPWAT_KW, 0); + fip_kw = rd_file_view_iget_named_kw(restart_file, FIPWAT_KW, 0); { int iactive; for (iactive = 0; iactive < size; iactive++) { - double fip = ecl_kw_iget_as_double(fip_kw, iactive); - int pvtnum = ecl_kw_iget_int(pvtnum_kw, iactive); + double fip = rd_kw_iget_as_double(fip_kw, iactive); + int pvtnum = rd_kw_iget_int(pvtnum_kw, iactive); grav_phase->fluid_mass[iactive] = fip * std_density[pvtnum]; } } } else { - ecl_version_enum ecl_version = ecl_file_get_ecl_version(init_file); - const char *den_kw_name = get_den_kw(phase, ecl_version); - const ecl_kw_type *den_kw = - ecl_file_view_iget_named_kw(restart_file, den_kw_name, 0); + rd_version_enum rd_version = rd_file_get_rd_version(init_file); + const char *den_kw_name = get_den_kw(phase, rd_version); + const rd_kw_type *den_kw = + rd_file_view_iget_named_kw(restart_file, den_kw_name, 0); if (calc_type == GRAV_CALC_RFIP) { - ecl_kw_type *rfip_kw; - if (phase == ECL_OIL_PHASE) - rfip_kw = ecl_file_view_iget_named_kw(restart_file, - RFIPOIL_KW, 0); - else if (phase == ECL_GAS_PHASE) - rfip_kw = ecl_file_view_iget_named_kw(restart_file, - RFIPGAS_KW, 0); + rd_kw_type *rfip_kw; + if (phase == RD_OIL_PHASE) + rfip_kw = + rd_file_view_iget_named_kw(restart_file, RFIPOIL_KW, 0); + else if (phase == RD_GAS_PHASE) + rfip_kw = + rd_file_view_iget_named_kw(restart_file, RFIPGAS_KW, 0); else - rfip_kw = ecl_file_view_iget_named_kw(restart_file, - RFIPWAT_KW, 0); + rfip_kw = + rd_file_view_iget_named_kw(restart_file, RFIPWAT_KW, 0); { int iactive; for (iactive = 0; iactive < size; iactive++) { - double rho = ecl_kw_iget_as_double(den_kw, iactive); - double rfip = ecl_kw_iget_as_double(rfip_kw, iactive); + double rho = rd_kw_iget_as_double(den_kw, iactive); + double rfip = rd_kw_iget_as_double(rfip_kw, iactive); grav_phase->fluid_mass[iactive] = rho * rfip; } } } else { /* (calc_type == GRAV_CALC_RPORV) || (calc_type == GRAV_CALC_PORMOD) */ - ecl_kw_type *sat_kw; + rd_kw_type *sat_kw; bool private_sat_kw = false; - if (ecl_file_view_has_kw(restart_file, sat_kw_name)) - sat_kw = ecl_file_view_iget_named_kw(restart_file, - sat_kw_name, 0); + if (rd_file_view_has_kw(restart_file, sat_kw_name)) + sat_kw = rd_file_view_iget_named_kw(restart_file, + sat_kw_name, 0); else { /* We are targeting the residual phase, e.g. the OIL phase in a three phase system. */ - const ecl_kw_type *swat_kw = - ecl_file_view_iget_named_kw(restart_file, "SWAT", 0); - sat_kw = ecl_kw_alloc_copy(swat_kw); - ecl_kw_scalar_set_float(sat_kw, 1.0); - ecl_kw_inplace_sub(sat_kw, swat_kw); /* sat = 1 - SWAT */ - - if (ecl_file_view_has_kw(restart_file, "SGAS")) { - const ecl_kw_type *sgas_kw = - ecl_file_view_iget_named_kw(restart_file, "SGAS", - 0); - ecl_kw_inplace_sub(sat_kw, sgas_kw); /* sat -= SGAS */ + const rd_kw_type *swat_kw = + rd_file_view_iget_named_kw(restart_file, "SWAT", 0); + sat_kw = rd_kw_alloc_copy(swat_kw); + rd_kw_scalar_set_float(sat_kw, 1.0); + rd_kw_inplace_sub(sat_kw, swat_kw); /* sat = 1 - SWAT */ + + if (rd_file_view_has_kw(restart_file, "SGAS")) { + const rd_kw_type *sgas_kw = + rd_file_view_iget_named_kw(restart_file, "SGAS", 0); + rd_kw_inplace_sub(sat_kw, sgas_kw); /* sat -= SGAS */ } private_sat_kw = true; } @@ -278,15 +272,15 @@ static ecl_grav_phase_type *ecl_grav_phase_alloc( { int iactive; for (iactive = 0; iactive < size; iactive++) { - double rho = ecl_kw_iget_as_double(den_kw, iactive); - double sat = ecl_kw_iget_as_double(sat_kw, iactive); + double rho = rd_kw_iget_as_double(den_kw, iactive); + double sat = rd_kw_iget_as_double(sat_kw, iactive); grav_phase->fluid_mass[iactive] = rho * sat * survey->porv[iactive]; } } if (private_sat_kw) - ecl_kw_free(sat_kw); + rd_kw_free(sat_kw); } } @@ -294,54 +288,54 @@ static ecl_grav_phase_type *ecl_grav_phase_alloc( } } -static void ecl_grav_phase_free(ecl_grav_phase_type *grav_phase) { +static void rd_grav_phase_free(rd_grav_phase_type *grav_phase) { free(grav_phase->work); free(grav_phase->fluid_mass); delete grav_phase; } -static void ecl_grav_survey_add_phase(ecl_grav_survey_type *survey, - ecl_phase_enum phase, - ecl_grav_phase_type *grav_phase) { +static void rd_grav_survey_add_phase(rd_grav_survey_type *survey, + rd_phase_enum phase, + rd_grav_phase_type *grav_phase) { survey->phase_list.push_back(grav_phase); - survey->phase_map[std::string(ecl_util_get_phase_name(phase))] = grav_phase; + survey->phase_map[std::string(rd_get_phase_name(phase))] = grav_phase; } -static void ecl_grav_survey_add_phases(ecl_grav_type *ecl_grav, - ecl_grav_survey_type *survey, - const ecl_file_view_type *restart_file, - grav_calc_type calc_type) { - int phases = ecl_file_get_phases(ecl_grav->init_file); - if (phases & ECL_OIL_PHASE) { - ecl_grav_phase_type *oil_phase = ecl_grav_phase_alloc( - ecl_grav, survey, ECL_OIL_PHASE, restart_file, calc_type); - ecl_grav_survey_add_phase(survey, ECL_OIL_PHASE, oil_phase); +static void rd_grav_survey_add_phases(rd_grav_type *rd_grav, + rd_grav_survey_type *survey, + const rd_file_view_type *restart_file, + grav_calc_type calc_type) { + int phases = rd_file_get_phases(rd_grav->init_file); + if (phases & RD_OIL_PHASE) { + rd_grav_phase_type *oil_phase = rd_grav_phase_alloc( + rd_grav, survey, RD_OIL_PHASE, restart_file, calc_type); + rd_grav_survey_add_phase(survey, RD_OIL_PHASE, oil_phase); } - if (phases & ECL_GAS_PHASE) { - ecl_grav_phase_type *gas_phase = ecl_grav_phase_alloc( - ecl_grav, survey, ECL_GAS_PHASE, restart_file, calc_type); - ecl_grav_survey_add_phase(survey, ECL_GAS_PHASE, gas_phase); + if (phases & RD_GAS_PHASE) { + rd_grav_phase_type *gas_phase = rd_grav_phase_alloc( + rd_grav, survey, RD_GAS_PHASE, restart_file, calc_type); + rd_grav_survey_add_phase(survey, RD_GAS_PHASE, gas_phase); } - if (phases & ECL_WATER_PHASE) { - ecl_grav_phase_type *water_phase = ecl_grav_phase_alloc( - ecl_grav, survey, ECL_WATER_PHASE, restart_file, calc_type); - ecl_grav_survey_add_phase(survey, ECL_WATER_PHASE, water_phase); + if (phases & RD_WATER_PHASE) { + rd_grav_phase_type *water_phase = rd_grav_phase_alloc( + rd_grav, survey, RD_WATER_PHASE, restart_file, calc_type); + rd_grav_survey_add_phase(survey, RD_WATER_PHASE, water_phase); } } -static ecl_grav_survey_type * -ecl_grav_survey_alloc_empty(const ecl_grav_type *ecl_grav, const char *name, - grav_calc_type calc_type) { - ecl_grav_survey_type *survey = new ecl_grav_survey_type(); - UTIL_TYPE_ID_INIT(survey, ECL_GRAV_SURVEY_ID); - survey->grid_cache = ecl_grav->grid_cache; - survey->aquifer_cell = ecl_grav->aquifer_cell; +static rd_grav_survey_type * +rd_grav_survey_alloc_empty(const rd_grav_type *rd_grav, const char *name, + grav_calc_type calc_type) { + rd_grav_survey_type *survey = new rd_grav_survey_type(); + UTIL_TYPE_ID_INIT(survey, RD_GRAV_SURVEY_ID); + survey->grid_cache = rd_grav->grid_cache; + survey->aquifer_cell = rd_grav->aquifer_cell; survey->name = util_alloc_string_copy(name); if (calc_type & GRAV_CALC_USE_PORV) - survey->porv = (double *)util_calloc(ecl_grav->grid_cache->size(), + survey->porv = (double *)util_calloc(rd_grav->grid_cache->size(), sizeof *survey->porv); else survey->porv = NULL; @@ -355,12 +349,12 @@ ecl_grav_survey_alloc_empty(const ecl_grav_type *ecl_grav, const char *name, for some random locations in the grid. */ -static void ecl_grav_survey_assert_RPORV(const ecl_grav_survey_type *survey, - const ecl_file_type *init_file) { - const ecl::ecl_grid_cache &grid_cache = *(survey->grid_cache); +static void rd_grav_survey_assert_RPORV(const rd_grav_survey_type *survey, + const rd_file_type *init_file) { + const rd::rd_grid_cache &grid_cache = *(survey->grid_cache); int active_size = grid_cache.size(); - const ecl_kw_type *init_porv_kw = - ecl_file_iget_named_kw(init_file, PORV_KW, 0); + const rd_kw_type *init_porv_kw = + rd_file_iget_named_kw(init_file, PORV_KW, 0); int check_points = 100; int check_nr = 0; const std::vector &global_index = grid_cache.global_index(); @@ -368,7 +362,7 @@ static void ecl_grav_survey_assert_RPORV(const ecl_grav_survey_type *survey, while (check_nr < check_points) { int active_index = rand() % active_size; - double init_porv = ecl_kw_iget_as_double( + double init_porv = rd_kw_iget_as_double( init_porv_kw, global_index[active_index]); /* NB - this uses global indexing. */ if (init_porv > 0) { @@ -410,18 +404,18 @@ static void ecl_grav_survey_assert_RPORV(const ecl_grav_survey_type *survey, This method requires access to the instantaneous pore volume. This can be accessed in two different ways, based either on the RPORV keyword or the PORV_MOD keyword. This functionality is available - through the ecl_grav_survey_alloc_RPORV() and - ecl_grav_survey_alloc_PORMOD() functions. + through the rd_grav_survey_alloc_RPORV() and + rd_grav_survey_alloc_PORMOD() functions. 2. The mass of each phase can be calculated based on the fluid in place values (volume of phase when the matter is brought to standard conditions), i.e. the FIPGAS, FIPWAT and FIPOIL keywords, and the corresponding densities at surface conditions. This functionality is - implemented with the ecl_grav_survey_alloc_FIP() function. + implemented with the rd_grav_survey_alloc_FIP() function. Observe that use of the FIP based method requires densities entered - with ecl_grav_new_std_density()/ecl_grav_add_std_density() prior to + with rd_grav_new_std_density()/rd_grav_add_std_density() prior to adding the actual survey. */ @@ -434,119 +428,118 @@ static void ecl_grav_survey_assert_RPORV(const ecl_grav_survey_type *survey, range of bugs related to the RPORV keyword, including: - Using the pressure values instead of pore volumes - this will be - cached by the ecl_grav_survey_assert_RPORV() function. + cached by the rd_grav_survey_assert_RPORV() function. - Ignoring the dynamic pore volume changes, and just using RPORV == INIT PORV. */ -static ecl_grav_survey_type * -ecl_grav_survey_alloc_RPORV(ecl_grav_type *ecl_grav, - const ecl_file_view_type *restart_file, - const char *name) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_empty(ecl_grav, name, GRAV_CALC_RPORV); - if (ecl_file_view_has_kw(restart_file, RPORV_KW)) { - ecl_kw_type *rporv_kw = - ecl_file_view_iget_named_kw(restart_file, RPORV_KW, 0); +static rd_grav_survey_type * +rd_grav_survey_alloc_RPORV(rd_grav_type *rd_grav, + const rd_file_view_type *restart_file, + const char *name) { + rd_grav_survey_type *survey = + rd_grav_survey_alloc_empty(rd_grav, name, GRAV_CALC_RPORV); + if (rd_file_view_has_kw(restart_file, RPORV_KW)) { + rd_kw_type *rporv_kw = + rd_file_view_iget_named_kw(restart_file, RPORV_KW, 0); int iactive; - for (iactive = 0; iactive < ecl_kw_get_size(rporv_kw); iactive++) - survey->porv[iactive] = ecl_kw_iget_as_double(rporv_kw, iactive); + for (iactive = 0; iactive < rd_kw_get_size(rporv_kw); iactive++) + survey->porv[iactive] = rd_kw_iget_as_double(rporv_kw, iactive); } else util_abort("%s: restart file did not contain %s keyword??\n", __func__, RPORV_KW); { - const ecl_file_type *init_file = ecl_grav->init_file; - ecl_grav_survey_assert_RPORV(survey, init_file); - ecl_grav_survey_add_phases(ecl_grav, survey, restart_file, - GRAV_CALC_RPORV); + const rd_file_type *init_file = rd_grav->init_file; + rd_grav_survey_assert_RPORV(survey, init_file); + rd_grav_survey_add_phases(rd_grav, survey, restart_file, + GRAV_CALC_RPORV); } return survey; } -static ecl_grav_survey_type * -ecl_grav_survey_alloc_PORMOD(ecl_grav_type *ecl_grav, - const ecl_file_view_type *restart_file, - const char *name) { - ecl::ecl_grid_cache &grid_cache = *(ecl_grav->grid_cache); - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_empty(ecl_grav, name, GRAV_CALC_PORMOD); - ecl_kw_type *init_porv_kw = ecl_file_iget_named_kw( - ecl_grav->init_file, PORV_KW, 0); /* Global indexing */ - ecl_kw_type *pormod_kw = ecl_file_view_iget_named_kw( - restart_file, PORMOD_KW, 0); /* Active indexing */ +static rd_grav_survey_type * +rd_grav_survey_alloc_PORMOD(rd_grav_type *rd_grav, + const rd_file_view_type *restart_file, + const char *name) { + rd::rd_grid_cache &grid_cache = *(rd_grav->grid_cache); + rd_grav_survey_type *survey = + rd_grav_survey_alloc_empty(rd_grav, name, GRAV_CALC_PORMOD); + rd_kw_type *init_porv_kw = rd_file_iget_named_kw( + rd_grav->init_file, PORV_KW, 0); /* Global indexing */ + rd_kw_type *pormod_kw = rd_file_view_iget_named_kw(restart_file, PORMOD_KW, + 0); /* Active indexing */ const int size = grid_cache.size(); const auto &global_index = grid_cache.global_index(); int active_index; for (active_index = 0; active_index < size; active_index++) survey->porv[active_index] = - ecl_kw_iget_float(pormod_kw, active_index) * - ecl_kw_iget_float(init_porv_kw, global_index[active_index]); + rd_kw_iget_float(pormod_kw, active_index) * + rd_kw_iget_float(init_porv_kw, global_index[active_index]); - ecl_grav_survey_add_phases(ecl_grav, survey, restart_file, - GRAV_CALC_PORMOD); + rd_grav_survey_add_phases(rd_grav, survey, restart_file, GRAV_CALC_PORMOD); return survey; } /** - Use of the ecl_grav_survey_alloc_FIP() function requires that the densities - have been added for all phases with the ecl_grav_new_std_density() and - possibly also the ecl_grav_add_std_density() functions. + Use of the rd_grav_survey_alloc_FIP() function requires that the densities + have been added for all phases with the rd_grav_new_std_density() and + possibly also the rd_grav_add_std_density() functions. */ -static ecl_grav_survey_type * -ecl_grav_survey_alloc_FIP(ecl_grav_type *ecl_grav, - const ecl_file_view_type *restart_file, - const char *name) { +static rd_grav_survey_type * +rd_grav_survey_alloc_FIP(rd_grav_type *rd_grav, + const rd_file_view_type *restart_file, + const char *name) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_empty(ecl_grav, name, GRAV_CALC_FIP); - ecl_grav_survey_add_phases(ecl_grav, survey, restart_file, GRAV_CALC_FIP); + rd_grav_survey_type *survey = + rd_grav_survey_alloc_empty(rd_grav, name, GRAV_CALC_FIP); + rd_grav_survey_add_phases(rd_grav, survey, restart_file, GRAV_CALC_FIP); return survey; } -static ecl_grav_survey_type * -ecl_grav_survey_alloc_RFIP(ecl_grav_type *ecl_grav, - const ecl_file_view_type *restart_file, - const char *name) { +static rd_grav_survey_type * +rd_grav_survey_alloc_RFIP(rd_grav_type *rd_grav, + const rd_file_view_type *restart_file, + const char *name) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_empty(ecl_grav, name, GRAV_CALC_RFIP); - ecl_grav_survey_add_phases(ecl_grav, survey, restart_file, GRAV_CALC_RFIP); + rd_grav_survey_type *survey = + rd_grav_survey_alloc_empty(rd_grav, name, GRAV_CALC_RFIP); + rd_grav_survey_add_phases(rd_grav, survey, restart_file, GRAV_CALC_RFIP); return survey; } -static void ecl_grav_survey_free(ecl_grav_survey_type *grav_survey) { +static void rd_grav_survey_free(rd_grav_survey_type *grav_survey) { free(grav_survey->name); free(grav_survey->porv); for (auto *phase : grav_survey->phase_list) - ecl_grav_phase_free(phase); + rd_grav_phase_free(phase); delete grav_survey; } -static double ecl_grav_survey_eval(const ecl_grav_survey_type *base_survey, - const ecl_grav_survey_type *monitor_survey, - ecl_region_type *region, double utm_x, - double utm_y, double depth, int phase_mask) { +static double rd_grav_survey_eval(const rd_grav_survey_type *base_survey, + const rd_grav_survey_type *monitor_survey, + rd_region_type *region, double utm_x, + double utm_y, double depth, int phase_mask) { double deltag = 0; for (std::size_t phase_nr = 0; phase_nr < base_survey->phase_list.size(); phase_nr++) { - ecl_grav_phase_type *base_phase = base_survey->phase_list[phase_nr]; + rd_grav_phase_type *base_phase = base_survey->phase_list[phase_nr]; if (base_phase->phase & phase_mask) { if (monitor_survey != NULL) { - const ecl_grav_phase_type *monitor_phase = + const rd_grav_phase_type *monitor_phase = monitor_survey->phase_list[phase_nr]; - deltag += ecl_grav_phase_eval(base_phase, monitor_phase, region, - utm_x, utm_y, depth); + deltag += rd_grav_phase_eval(base_phase, monitor_phase, region, + utm_x, utm_y, depth); } else - deltag += ecl_grav_phase_eval(base_phase, NULL, region, utm_x, - utm_y, depth); + deltag += rd_grav_phase_eval(base_phase, NULL, region, utm_x, + utm_y, depth); } } return deltag; @@ -554,66 +547,66 @@ static double ecl_grav_survey_eval(const ecl_grav_survey_type *base_survey, /** The grid instance is only used during the construction phase. The - @init_file object is used by the ecl_grav_add_survey_XXX() + @init_file object is used by the rd_grav_add_survey_XXX() functions; and calling scope must NOT destroy this object before all surveys have been added. */ -ecl_grav_type *ecl_grav_alloc(const ecl_grid_type *ecl_grid, - const ecl_file_type *init_file) { - ecl_grav_type *ecl_grav = new ecl_grav_type(); +rd_grav_type *rd_grav_alloc(const rd_grid_type *rd_grid, + const rd_file_type *init_file) { + rd_grav_type *rd_grav = new rd_grav_type(); - ecl_grav->init_file = init_file; - ecl_grav->grid_cache = new ecl::ecl_grid_cache(ecl_grid); - ecl_grav->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( - *(ecl_grav->grid_cache), ecl_grav->init_file); + rd_grav->init_file = init_file; + rd_grav->grid_cache = new rd::rd_grid_cache(rd_grid); + rd_grav->aquifer_cell = rd_grav_common_alloc_aquifer_cell( + *(rd_grav->grid_cache), rd_grav->init_file); - return ecl_grav; + return rd_grav; } -static void ecl_grav_add_survey__(ecl_grav_type *grav, const char *name, - ecl_grav_survey_type *survey) { +static void rd_grav_add_survey__(rd_grav_type *grav, const char *name, + rd_grav_survey_type *survey) { grav->surveys[name] = survey; } -ecl_grav_survey_type * -ecl_grav_add_survey_RPORV(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_RPORV(grav, restart_file, name); - ecl_grav_add_survey__(grav, name, survey); +rd_grav_survey_type * +rd_grav_add_survey_RPORV(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file) { + rd_grav_survey_type *survey = + rd_grav_survey_alloc_RPORV(grav, restart_file, name); + rd_grav_add_survey__(grav, name, survey); return survey; } -ecl_grav_survey_type * -ecl_grav_add_survey_FIP(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_FIP(grav, restart_file, name); - ecl_grav_add_survey__(grav, name, survey); +rd_grav_survey_type * +rd_grav_add_survey_FIP(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file) { + rd_grav_survey_type *survey = + rd_grav_survey_alloc_FIP(grav, restart_file, name); + rd_grav_add_survey__(grav, name, survey); return survey; } -ecl_grav_survey_type * -ecl_grav_add_survey_RFIP(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_RFIP(grav, restart_file, name); - ecl_grav_add_survey__(grav, name, survey); +rd_grav_survey_type * +rd_grav_add_survey_RFIP(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file) { + rd_grav_survey_type *survey = + rd_grav_survey_alloc_RFIP(grav, restart_file, name); + rd_grav_add_survey__(grav, name, survey); return survey; } -ecl_grav_survey_type * -ecl_grav_add_survey_PORMOD(ecl_grav_type *grav, const char *name, - const ecl_file_view_type *restart_file) { - ecl_grav_survey_type *survey = - ecl_grav_survey_alloc_PORMOD(grav, restart_file, name); - ecl_grav_add_survey__(grav, name, survey); +rd_grav_survey_type * +rd_grav_add_survey_PORMOD(rd_grav_type *grav, const char *name, + const rd_file_view_type *restart_file) { + rd_grav_survey_type *survey = + rd_grav_survey_alloc_PORMOD(grav, restart_file, name); + rd_grav_add_survey__(grav, name, survey); return survey; } -static ecl_grav_survey_type *ecl_grav_get_survey(const ecl_grav_type *grav, - const char *name) { +static rd_grav_survey_type *rd_grav_get_survey(const rd_grav_type *grav, + const char *name) { if (name == NULL) return NULL; // Calling scope must determine if this is OK? else { @@ -634,64 +627,64 @@ static ecl_grav_survey_type *ecl_grav_get_survey(const ecl_grav_type *grav, } } -double ecl_grav_eval(const ecl_grav_type *grav, const char *base, - const char *monitor, ecl_region_type *region, double utm_x, - double utm_y, double depth, int phase_mask) { - ecl_grav_survey_type *base_survey = ecl_grav_get_survey(grav, base); - ecl_grav_survey_type *monitor_survey = ecl_grav_get_survey(grav, monitor); +double rd_grav_eval(const rd_grav_type *grav, const char *base, + const char *monitor, rd_region_type *region, double utm_x, + double utm_y, double depth, int phase_mask) { + rd_grav_survey_type *base_survey = rd_grav_get_survey(grav, base); + rd_grav_survey_type *monitor_survey = rd_grav_get_survey(grav, monitor); - return ecl_grav_survey_eval(base_survey, monitor_survey, region, utm_x, - utm_y, depth, phase_mask); + return rd_grav_survey_eval(base_survey, monitor_survey, region, utm_x, + utm_y, depth, phase_mask); } -/* The functions ecl_grav_new_std_density() and ecl_grav_add_std_density() are +/* The functions rd_grav_new_std_density() and rd_grav_add_std_density() are used to "install" standard conditions densities for the various phases involved. These functions must be called prior to calling - ecl_grav_add_survey_FIP() - failure to do so will lead to hard failure. + rd_grav_add_survey_FIP() - failure to do so will lead to hard failure. */ /** - The function ecl_grav_new_std_density() is used to add a default density for + The function rd_grav_new_std_density() is used to add a default density for a new phase. */ -void ecl_grav_new_std_density(ecl_grav_type *grav, ecl_phase_enum phase, - double default_density) { - const char *phase_key = ecl_util_get_phase_name(phase); +void rd_grav_new_std_density(rd_grav_type *grav, rd_phase_enum phase, + double default_density) { + const char *phase_key = rd_get_phase_name(phase); grav->default_density[std::string(phase_key)] = default_density; } /** In cases with many PVT regions it is possible to install per PVT - region densities. The ecl_grav_new_std_density() must be called + region densities. The rd_grav_new_std_density() must be called first to install a default density for the phase, and then this function can be called afterwards to install density for a particular PVT region. In the example below we set the default gas density to 0.75, but in PVT regions 2 and 7 the density is different: - ecl_grav_new_std_density( grav , ECL_GAS_PHASE , 0.75 ); - ecl_grav_add_std_density( grav , ECL_GAS_PHASE , 2 , 0.70 ); - ecl_grav_add_std_density( grav , ECL_GAS_PHASE , 7 , 0.80 ); + rd_grav_new_std_density( grav , RD_GAS_PHASE , 0.75 ); + rd_grav_add_std_density( grav , RD_GAS_PHASE , 2 , 0.70 ); + rd_grav_add_std_density( grav , RD_GAS_PHASE , 7 , 0.80 ); */ -void ecl_grav_add_std_density(ecl_grav_type *grav, ecl_phase_enum phase, - int pvtnum, double density) { +void rd_grav_add_std_density(rd_grav_type *grav, rd_phase_enum phase, + int pvtnum, double density) { std::vector &std_density = - grav->std_density[std::string(ecl_util_get_phase_name(phase))]; + grav->std_density[std::string(rd_get_phase_name(phase))]; if (std_density.size() <= static_cast(pvtnum)) std_density.resize( pvtnum + 1, - grav->default_density[std::string(ecl_util_get_phase_name(phase))]); + grav->default_density[std::string(rd_get_phase_name(phase))]); std_density[pvtnum] = density; } -void ecl_grav_free(ecl_grav_type *ecl_grav) { - delete ecl_grav->grid_cache; - free(ecl_grav->aquifer_cell); +void rd_grav_free(rd_grav_type *rd_grav) { + delete rd_grav->grid_cache; + free(rd_grav->aquifer_cell); - for (const auto &survey_pair : ecl_grav->surveys) - ecl_grav_survey_free(survey_pair.second); + for (const auto &survey_pair : rd_grav->surveys) + rd_grav_survey_free(survey_pair.second); - delete ecl_grav; + delete rd_grav; } diff --git a/lib/resdata/rd_grav_calc.cpp b/lib/resdata/rd_grav_calc.cpp index 1a3c50c397..abdf547ec9 100644 --- a/lib/resdata/rd_grav_calc.cpp +++ b/lib/resdata/rd_grav_calc.cpp @@ -4,13 +4,13 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include /** - This file contains one function, ecl_grav_phase_deltag() which + This file contains one function, rd_grav_phase_deltag() which calculates the change in local gravitational strength (in units of micro Gal) in a point, based on base and monitor values for pore volume, saturation and density. Should typically be called several @@ -23,23 +23,23 @@ versus RPORV for ten 'random' locations in the grid. */ -static void ecl_grav_check_rporv(const ecl_grid_type *ecl_grid, - const ecl_kw_type *rporv1_kw, - const ecl_kw_type *rporv2_kw, - const ecl_kw_type *init_porv_kw) { +static void rd_grav_check_rporv(const rd_grid_type *rd_grid, + const rd_kw_type *rporv1_kw, + const rd_kw_type *rporv2_kw, + const rd_kw_type *init_porv_kw) { int active_index; int active_delta; int active_size; - ecl_grid_get_dims(ecl_grid, NULL, NULL, NULL, &active_size); + rd_grid_get_dims(rd_grid, NULL, NULL, NULL, &active_size); active_delta = active_size / 12; for (active_index = active_delta; active_index < active_size; active_index += active_delta) { - int global_index = ecl_grid_get_global_index1A(ecl_grid, active_index); - double init_porv = ecl_kw_iget_as_double( + int global_index = rd_grid_get_global_index1A(rd_grid, active_index); + double init_porv = rd_kw_iget_as_double( init_porv_kw, global_index); /* NB - this uses global indexing. */ - double rporv1 = ecl_kw_iget_as_double(rporv1_kw, active_index); - double rporv2 = ecl_kw_iget_as_double(rporv2_kw, active_index); + double rporv1 = rd_kw_iget_as_double(rporv1_kw, active_index); + double rporv2 = rd_kw_iget_as_double(rporv2_kw, active_index); double rporv12 = 0.5 * (rporv1 + rporv2); double fraction = util_double_min(init_porv, rporv12) / util_double_max(init_porv, rporv12); @@ -66,37 +66,37 @@ static void ecl_grav_check_rporv(const ecl_grid_type *ecl_grid, } double -ecl_grav_phase_deltag(double utm_x, double utm_y, double tvd, - const ecl_grid_type *grid, const ecl_file_type *init_file, - const ecl_kw_type *sat1_kw, const ecl_kw_type *rho1_kw, - const ecl_kw_type *porv1_kw, const ecl_kw_type *sat2_kw, - const ecl_kw_type *rho2_kw, const ecl_kw_type *porv2_kw) { +rd_grav_phase_deltag(double utm_x, double utm_y, double tvd, + const rd_grid_type *grid, const rd_file_type *init_file, + const rd_kw_type *sat1_kw, const rd_kw_type *rho1_kw, + const rd_kw_type *porv1_kw, const rd_kw_type *sat2_kw, + const rd_kw_type *rho2_kw, const rd_kw_type *porv2_kw) { double deltag = 0; const int *aquifern = NULL; - const float *rho1 = ecl_kw_get_float_ptr(rho1_kw); - const float *rho2 = ecl_kw_get_float_ptr(rho2_kw); - const float *sat1 = ecl_kw_get_float_ptr(sat1_kw); - const float *sat2 = ecl_kw_get_float_ptr(sat2_kw); - const float *porv1 = ecl_kw_get_float_ptr(porv1_kw); - const float *porv2 = ecl_kw_get_float_ptr(porv2_kw); - - if (ecl_file_has_kw(init_file, "AQUIFERN")) { - const ecl_kw_type *aquifern_kw = - ecl_file_iget_named_kw(init_file, "AQUIFERN", 0); - aquifern = ecl_kw_get_int_ptr(aquifern_kw); + const float *rho1 = rd_kw_get_float_ptr(rho1_kw); + const float *rho2 = rd_kw_get_float_ptr(rho2_kw); + const float *sat1 = rd_kw_get_float_ptr(sat1_kw); + const float *sat2 = rd_kw_get_float_ptr(sat2_kw); + const float *porv1 = rd_kw_get_float_ptr(porv1_kw); + const float *porv2 = rd_kw_get_float_ptr(porv2_kw); + + if (rd_file_has_kw(init_file, "AQUIFERN")) { + const rd_kw_type *aquifern_kw = + rd_file_iget_named_kw(init_file, "AQUIFERN", 0); + aquifern = rd_kw_get_int_ptr(aquifern_kw); } { - const ecl_kw_type *init_porv_kw = - ecl_file_iget_named_kw(init_file, "PORV", 0); - ecl_grav_check_rporv(grid, porv1_kw, porv2_kw, init_porv_kw); + const rd_kw_type *init_porv_kw = + rd_file_iget_named_kw(init_file, "PORV", 0); + rd_grav_check_rporv(grid, porv1_kw, porv2_kw, init_porv_kw); } { int active_index; - for (active_index = 0; active_index < ecl_grid_get_active_size(grid); + for (active_index = 0; active_index < rd_grid_get_active_size(grid); active_index++) { if (aquifern != NULL && aquifern[active_index] != 0) continue; /* This is a numerical aquifer cell - skip it. */ @@ -109,7 +109,7 @@ ecl_grav_phase_deltag(double utm_x, double utm_y, double tvd, mas2 = rho2[active_index] * porv2[active_index] * sat2[active_index]; - ecl_grid_get_xyz1A(grid, active_index, &xpos, &ypos, &zpos); + rd_grid_get_xyz1A(grid, active_index, &xpos, &ypos, &zpos); { double dist_x = xpos - utm_x; double dist_y = ypos - utm_y; diff --git a/lib/resdata/rd_grav_common.cpp b/lib/resdata/rd_grav_common.cpp index a7ab347602..46de8d7ff8 100644 --- a/lib/resdata/rd_grav_common.cpp +++ b/lib/resdata/rd_grav_common.cpp @@ -4,31 +4,31 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include "detail/ecl/ecl_grid_cache.hpp" +#include "detail/resdata/rd_grid_cache.hpp" /* - This file contains code which is common to both the ecl_grav - implementation for gravity changes, and the ecl_subsidence + This file contains code which is common to both the rd_grav + implementation for gravity changes, and the rd_subsidence implementation for changes in subsidence. */ -bool *ecl_grav_common_alloc_aquifer_cell(const ecl::ecl_grid_cache &grid_cache, - const ecl_file_type *init_file) { +bool *rd_grav_common_alloc_aquifer_cell(const rd::rd_grid_cache &grid_cache, + const rd_file_type *init_file) { bool *aquifer_cell = (bool *)util_calloc(grid_cache.size(), sizeof *aquifer_cell); for (int active_index = 0; active_index < grid_cache.size(); active_index++) aquifer_cell[active_index] = false; - if (ecl_file_has_kw(init_file, AQUIFER_KW)) { - ecl_kw_type *aquifer_kw = - ecl_file_iget_named_kw(init_file, AQUIFER_KW, 0); - const int *aquifer_data = ecl_kw_get_int_ptr(aquifer_kw); + if (rd_file_has_kw(init_file, AQUIFER_KW)) { + rd_kw_type *aquifer_kw = + rd_file_iget_named_kw(init_file, AQUIFER_KW, 0); + const int *aquifer_data = rd_kw_get_int_ptr(aquifer_kw); for (int active_index = 0; active_index < grid_cache.size(); active_index++) { @@ -40,11 +40,11 @@ bool *ecl_grav_common_alloc_aquifer_cell(const ecl::ecl_grid_cache &grid_cache, return aquifer_cell; } -double ecl_grav_common_eval_biot_savart(const ecl::ecl_grid_cache &grid_cache, - ecl_region_type *region, - const bool *aquifer, - const double *weight, double utm_x, - double utm_y, double depth) { +double rd_grav_common_eval_biot_savart(const rd::rd_grid_cache &grid_cache, + rd_region_type *region, + const bool *aquifer, + const double *weight, double utm_x, + double utm_y, double depth) { const auto &xpos = grid_cache.xpos(); const auto &ypos = grid_cache.ypos(); const auto &zpos = grid_cache.zpos(); @@ -68,8 +68,7 @@ double ecl_grav_common_eval_biot_savart(const ecl::ecl_grid_cache &grid_cache, } } } else { - const int_vector_type *index_vector = - ecl_region_get_active_list(region); + const int_vector_type *index_vector = rd_region_get_active_list(region); const int size = int_vector_size(index_vector); const int *index_list = int_vector_get_const_ptr(index_vector); int i, index; @@ -90,10 +89,10 @@ double ecl_grav_common_eval_biot_savart(const ecl::ecl_grid_cache &grid_cache, } static inline double -ecl_grav_common_eval_geertsma_kernel(int index, const double *xpos, - const double *ypos, const double *zpos, - double utm_x, double utm_y, double depth, - double poisson_ratio, double seabed) { +rd_grav_common_eval_geertsma_kernel(int index, const double *xpos, + const double *ypos, const double *zpos, + double utm_x, double utm_y, double depth, + double poisson_ratio, double seabed) { double z = zpos[index]; z -= seabed; double dist_x = xpos[index] - utm_x; @@ -116,11 +115,11 @@ ecl_grav_common_eval_geertsma_kernel(int index, const double *xpos, return displacement; } -double ecl_grav_common_eval_geertsma(const ecl::ecl_grid_cache &grid_cache, - ecl_region_type *region, - const bool *aquifer, const double *weight, - double utm_x, double utm_y, double depth, - double poisson_ratio, double seabed) { +double rd_grav_common_eval_geertsma(const rd::rd_grid_cache &grid_cache, + rd_region_type *region, const bool *aquifer, + const double *weight, double utm_x, + double utm_y, double depth, + double poisson_ratio, double seabed) { const auto &xpos = grid_cache.xpos(); const auto &ypos = grid_cache.ypos(); const auto &zpos = grid_cache.zpos(); @@ -131,7 +130,7 @@ double ecl_grav_common_eval_geertsma(const ecl::ecl_grid_cache &grid_cache, for (index = 0; index < size; index++) { if (!aquifer[index]) { - double displacement = ecl_grav_common_eval_geertsma_kernel( + double displacement = rd_grav_common_eval_geertsma_kernel( index, xpos.data(), ypos.data(), zpos.data(), utm_x, utm_y, depth, poisson_ratio, seabed); @@ -143,15 +142,14 @@ double ecl_grav_common_eval_geertsma(const ecl::ecl_grid_cache &grid_cache, } } } else { - const int_vector_type *index_vector = - ecl_region_get_active_list(region); + const int_vector_type *index_vector = rd_region_get_active_list(region); const int size = int_vector_size(index_vector); const int *index_list = int_vector_get_const_ptr(index_vector); int i, index; for (i = 0; i < size; i++) { index = index_list[i]; if (!aquifer[index]) { - double displacement = ecl_grav_common_eval_geertsma_kernel( + double displacement = rd_grav_common_eval_geertsma_kernel( index, xpos.data(), ypos.data(), zpos.data(), utm_x, utm_y, depth, poisson_ratio, seabed); sum += weight[index] * displacement; diff --git a/lib/resdata/rd_grid.cpp b/lib/resdata/rd_grid.cpp index f069fac50e..37397c06a5 100644 --- a/lib/resdata/rd_grid.cpp +++ b/lib/resdata/rd_grid.cpp @@ -18,16 +18,16 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** this function implements functionality to load eclispe grid files, @@ -51,9 +51,9 @@ ways. the expected arguments are indicated as the last part of the function name: - ecl_grid_get_pos3() - 3: this function expects i,j,k - ecl_grid_get_pos1() - 1: this function expects a global index - ecl_grid_get_pos1a() - 1a: this function expects an active index. + rd_grid_get_pos3() - 3: this function expects i,j,k + rd_grid_get_pos1() - 1: this function expects a global index + rd_grid_get_pos1a() - 1a: this function expects an active index. */ @@ -183,11 +183,11 @@ the lgr implementation in is based on the following main principles: - 1. when loading a egrid/grid file one ecl_grid_type instance will + 1. when loading a egrid/grid file one rd_grid_type instance will be allocated; this grid will contain the main grid, and all the lgr grids. - 2. only one datatype (ecl_grid_type) is used both for the main grid + 2. only one datatype (rd_grid_type) is used both for the main grid and the lgr grids. 3. the main grid will own (memory wise) all the lgr grids, this @@ -201,34 +201,34 @@ -------- { - ecl_file_type * restart_data = ecl_file_fread_alloc(restart_filename , true); // load some restart info to inspect - ecl_grid_type * grid = ecl_grid_alloc(grid_filename , true); // bootstrap ecl_grid instance - stringlist_type * lgr_names = ecl_grid_alloc_name_list( grid ); // get a list of all the lgr names. + rd_file_type * restart_data = rd_file_fread_alloc(restart_filename , true); // load some restart info to inspect + rd_grid_type * grid = rd_grid_alloc(grid_filename , true); // bootstrap rd_grid instance + stringlist_type * lgr_names = rd_grid_alloc_name_list( grid ); // get a list of all the lgr names. printf("grid:%s has %d a total of %d lgr's \n", grid_filename , stringlist_get_size( lgr_names )); for (int lgr_nr = 0; lgr_nr < stringlist_get_size( lgr_names); lgr_nr++) { - ecl_grid_type * lgr_grid = ecl_grid_get_lgr( grid , stringlist_iget( lgr_names , lgr_nr )); // get the ecl_grid instance of the lgr - by name. - ecl_kw_type * pressure_kw; + rd_grid_type * lgr_grid = rd_grid_get_lgr( grid , stringlist_iget( lgr_names , lgr_nr )); // get the rd_grid instance of the lgr - by name. + rd_kw_type * pressure_kw; int nx,ny,nz,active_size; - ecl_grid_get_dims( lgr_grid , &nx , &ny , &nz , &active_size); // get some size info from this lgr. + rd_grid_get_dims( lgr_grid , &nx , &ny , &nz , &active_size); // get some size info from this lgr. printf("lgr:%s has %d x %d x %d elements \n",stringlist_iget(lgr_names , lgr_nr ) , nx , ny , nz); // ok - now we want to extract the solution vector (pressure) corresponding to this lgr: - pressure_kw = ecl_file_iget_named_kw( ecl_file , "pressure" , ecl_grid_get_grid_nr( lgr_grid )); + pressure_kw = rd_file_iget_named_kw( rd_file , "pressure" , rd_grid_get_grid_nr( lgr_grid )); /|\ | | we query the lgr_grid instance to find which occurence of the solution data we should look - up in the ecl_file instance with restart data. puuhh!! + up in the rd_file instance with restart data. puuhh!! { - int center_index = ecl_grid_get_global_index3( lgr_grid , nx/2 , ny/2 , nz/2 ); // ask the lgr_grid to get the index at the center of the lgr grid. - printf("the pressure in the middle of %s is %g \n", stinglist_iget( lgr_names , lgr_nr ) , ecl_kw_iget_as_double( pressure_kw , center_index )); + int center_index = rd_grid_get_global_index3( lgr_grid , nx/2 , ny/2 , nz/2 ); // ask the lgr_grid to get the index at the center of the lgr grid. + printf("the pressure in the middle of %s is %g \n", stinglist_iget( lgr_names , lgr_nr ) , rd_kw_iget_as_double( pressure_kw , center_index )); } } - ecl_file_free( restart_data ); - ecl_grid_free( grid ); + rd_file_free( restart_data ); + rd_grid_free( grid ); stringlist_free( lgr_names ); } @@ -246,9 +246,9 @@ the coarse group that the current cell is part of, or the value COARSE_NONE for cells which are not part of a coarsening group. - 2. The details of a coarse cell is implemented in ecl_coarse_cell.c. + 2. The details of a coarse cell is implemented in rd_coarse_cell.c. - 3. The ecl_grid structure contains a list of ecl_coarse_cell + 3. The rd_grid structure contains a list of rd_coarse_cell instances in the coarse_cells vector. 4. The introduction of coarse groups makes the concept of active @@ -266,12 +266,12 @@ The api for coarse related tasks is briefly: - - int ecl_grid_get_num_coarse_groups( const ecl_grid_type * main_grid ) - - bool ecl_grid_have_coarse_cells( const ecl_grid_type * main_grid ) - - ecl_coarse_cell_type * ecl_grid_iget_coarse_group( const ecl_grid_type * ecl_grid , int coarse_nr ); - - ecl_coarse_cell_type * ecl_grid_get_cell_coarse_group1( const ecl_grid_type * ecl_grid , int global_index); + - int rd_grid_get_num_coarse_groups( const rd_grid_type * main_grid ) + - bool rd_grid_have_coarse_cells( const rd_grid_type * main_grid ) + - rd_coarse_cell_type * rd_grid_iget_coarse_group( const rd_grid_type * rd_grid , int coarse_nr ); + - rd_coarse_cell_type * rd_grid_get_cell_coarse_group1( const rd_grid_type * rd_grid , int global_index); - In addition to the API presented by the ecl_coarse_cell.c implementation. + In addition to the API presented by the rd_coarse_cell.c implementation. */ /* @@ -321,16 +321,16 @@ { char fracture_kw[9]; char matrix_kw[9]; - int matrix_size = ecl_grid_get_nactive( ecl_grid ); - int fracture_size = ecl_grid_get_nactive_fracture( ecl_grid ); + int matrix_size = rd_grid_get_nactive( rd_grid ); + int fracture_size = rd_grid_get_nactive_fracture( rd_grid ); - swat = ecl_file_iget_name_kw( rst_file , "SWAT" , 0); + swat = rd_file_iget_name_kw( rst_file , "SWAT" , 0); - snsprintf(fracture_kw , 9 , "F-%6s" , ecl_kw_get_header( swat )); - snsprintf(matrix_kw , 9 , "M-%6s" , ecl_kw_get_header( swat )); + snsprintf(fracture_kw , 9 , "F-%6s" , rd_kw_get_header( swat )); + snsprintf(matrix_kw , 9 , "M-%6s" , rd_kw_get_header( swat )); - ecl_kw_type * M = ecl_kw_alloc_sub_copy( swat , matrix_kw , 0 , matrix_size ); - ecl_kw_type * F = ecl_kw_alloc_sub_copy( swat , fracture_kw , matrix_size , fracture_size ); + rd_kw_type * M = rd_kw_alloc_sub_copy( swat , matrix_kw , 0 , matrix_size ); + rd_kw_type * F = rd_kw_alloc_sub_copy( swat , fracture_kw , matrix_size , fracture_size ); } */ @@ -355,16 +355,16 @@ Example usage: -------------- - ecl_grid_type * grid = ecl_grid_alloc("FILE.EGRID"); + rd_grid_type * grid = rd_grid_alloc("FILE.EGRID"); // Get a int_vector instance with all the cells which have nnc info // attached. - const int_vector_type * cells_with_nnc = ecl_grid_get_nnc_index_list( grid ); + const int_vector_type * cells_with_nnc = rd_grid_get_nnc_index_list( grid ); // Iterate over all the cells with nnc info: for (int i=0; i < int_vector_size( cells_with_nnc ); i++) { int cell_index = int_vector_iget( cells_with_nnc , i); - const nnc_info_type * nnc_info = ecl_grid_get_nnc_info1( grid , cell_index); + const nnc_info_type * nnc_info = rd_grid_get_nnc_info1( grid , cell_index); // Get all the nnc connections from @cell_index to other cells in the same grid { @@ -381,7 +381,7 @@ if (lgr_nr != nnc_info_get_lgr_nr( nnc_info )) { const int_vector_type * nnc_list = nnc_vector_get_index_list( nnc_vector ); for (int j=0; j < int_vector_size( nnc_list ); j++) - printf("Cell[%d] -> %d in lgr:%d/%s \n",cell_index , int_vector_iget(nnc_list , j) , lgr_nr , ecl_grid_get_lgr_name(ecl_grid , lgr_nr)); + printf("Cell[%d] -> %d in lgr:%d/%s \n",cell_index , int_vector_iget(nnc_list , j) , lgr_nr , rd_grid_get_lgr_name(rd_grid , lgr_nr)); } } } @@ -433,7 +433,7 @@ 0---1 4---5 - table entries are ripped from eclpost code - file: kvpvos.f in + table entries are ripped from resdatapost code - file: kvpvos.f in klib/ */ @@ -520,8 +520,8 @@ static const int tetrahedron_permutations[2][12][3] = {{// K- the implementation is based on a hierarchy of three datatypes: - 1. ecl_grid - this is the only exported datatype - 2. ecl_cell - internal + 1. rd_grid - this is the only exported datatype + 2. rd_cell - internal 3. point - internal */ @@ -651,7 +651,7 @@ static void point_copy_values(point_type *p, const point_type *src) { 4 /* Keep invalid cells out of real-world calculations with some heuristics.*/ #define CELL_FLAG_VOLUME 8 -typedef struct ecl_cell_struct ecl_cell_type; +typedef struct rd_cell_struct rd_cell_type; #define GET_CELL_FLAG(cell, flag) \ (((cell->cell_flags & (flag)) == 0) ? false : true) @@ -659,7 +659,7 @@ typedef struct ecl_cell_struct ecl_cell_type; #define METER_TO_FEET_SCALE_FACTOR 3.28084 #define METER_TO_CM_SCALE_FACTOR 100.0 -struct ecl_cell_struct { +struct rd_cell_struct { point_type center; point_type corner_list[8]; @@ -668,7 +668,7 @@ struct ecl_cell_struct { int active; int active_index [2]; /* [0]: The active matrix index; [1]: the active fracture index */ - const ecl_grid_type * + const rd_grid_type * lgr; /* if this cell is part of an lgr; this will point to a grid instance for that lgr; NULL if not part of lgr. */ int host_cell; /* the global index of the host cell for an lgr cell, set to -1 for normal cells. */ int coarse_group; /* The index of the coarse group holding this cell -1 for non-coarsened cells. */ @@ -676,16 +676,16 @@ struct ecl_cell_struct { nnc_info_type *nnc_info; /* Non-neighbour connection info*/ }; -static ert_ecl_unit_enum -ecl_grid_check_unit_system(const ecl_kw_type *gridunit_kw); -static void ecl_grid_init_mapaxes_data_float(const ecl_grid_type *grid, - float *mapaxes); -float *ecl_grid_alloc_coord_data(const ecl_grid_type *grid); -static const float *ecl_grid_get_mapaxes(const ecl_grid_type *grid); +static ert_rd_unit_enum +rd_grid_check_unit_system(const rd_kw_type *gridunit_kw); +static void rd_grid_init_mapaxes_data_float(const rd_grid_type *grid, + float *mapaxes); +float *rd_grid_alloc_coord_data(const rd_grid_type *grid); +static const float *rd_grid_get_mapaxes(const rd_grid_type *grid); -#define ECL_GRID_ID 991010 +#define RD_GRID_ID 991010 -struct ecl_grid_struct { +struct rd_grid_struct { UTIL_TYPE_ID_DECLARATION; int lgr_nr; /* EGRID files: corresponds to item 4 in gridhead - 0 for the main grid. GRID files: 0 for the main grid, then 1 -> number of LGRs in order read from file*/ @@ -707,15 +707,15 @@ struct ecl_grid_struct { int * inv_fracture_index_map; /* For fractures: this is list of total_active elements - which point back to the index_map. */ - ecl_cell_type *cells; + rd_cell_type *cells; char * parent_name; /* the name of the parent for a nested lgr - for the main grid, and also a lgr descending directly from the main grid this will be NULL. */ - std::unordered_map children; - const ecl_grid_type * + std::unordered_map children; + const rd_grid_type * parent_grid; /* the parent grid for this (lgr) - NULL for the main grid. */ - const ecl_grid_type + const rd_grid_type *global_grid; /* the global grid - NULL for the main grid. */ bool coarsening_active; @@ -726,11 +726,11 @@ struct ecl_grid_struct { lgr_nr > 0. */ vector_type * - LGR_list; /* a vector of ecl_grid instances for LGRs - the index corresponds to the order LGRs are read from file*/ + LGR_list; /* a vector of rd_grid instances for LGRs - the index corresponds to the order LGRs are read from file*/ int_vector_type * lgr_index_map; /* a vector that maps LGR-nr for EGRID files to index into the LGR_list.*/ - std::unordered_map - LGR_hash; /* a hash of pointers to ecl_grid instances - for name based lookup of lgr. */ + std::unordered_map + LGR_hash; /* a hash of pointers to rd_grid instances - for name based lookup of lgr. */ int parent_box [6]; /* integers i1,i2, j1,j2, k1,k2 of the parent grid region containing this lgr. the indices are inclusive - zero offset */ /* not used yet .. */ @@ -746,22 +746,22 @@ struct ecl_grid_struct { int block_size; int last_block_index; double_vector_type **values; - ecl_kw_type *coord_kw; /* Retained for writing the grid to file. + rd_kw_type *coord_kw; /* Retained for writing the grid to file. In principal it should be possible to recalculate this from the cell coordinates, but in cases with skewed cells this has proved numerically challenging. */ - ert_ecl_unit_enum unit_system; + ert_rd_unit_enum unit_system; int eclipse_version; }; -ert_ecl_unit_enum ecl_grid_get_unit_system(const ecl_grid_type *grid) { +ert_rd_unit_enum rd_grid_get_unit_system(const rd_grid_type *grid) { return grid->unit_system; } -static void ecl_cell_compare(const ecl_cell_type *c1, const ecl_cell_type *c2, - bool include_nnc, bool *equal) { +static void rd_cell_compare(const rd_cell_type *c1, const rd_cell_type *c2, + bool include_nnc, bool *equal) { int i; if (c1->active != c2->active) @@ -790,23 +790,23 @@ static void ecl_cell_compare(const ecl_cell_type *c1, const ecl_cell_type *c2, } } -static void ecl_cell_dump(const ecl_cell_type *cell, FILE *stream) { +static void rd_cell_dump(const rd_cell_type *cell, FILE *stream) { int i; for (i = 0; i < 8; i++) point_dump(&cell->corner_list[i], stream); } -static void ecl_cell_assert_center(ecl_cell_type *cell); +static void rd_cell_assert_center(rd_cell_type *cell); -static void ecl_cell_dump_ascii(ecl_cell_type *cell, int i, int j, int k, - FILE *stream, const double *offset) { +static void rd_cell_dump_ascii(rd_cell_type *cell, int i, int j, int k, + FILE *stream, const double *offset) { fprintf(stream, "Cell: i:%3d j:%3d k:%3d host_cell:%d CoarseGroup:%4d " "active_nr:%6d active:%d \nCorners:\n", i, j, k, cell->host_cell, cell->coarse_group, cell->active_index[MATRIX_INDEX], cell->active); - ecl_cell_assert_center(cell); + rd_cell_assert_center(cell); fprintf(stream, "Center : "); point_dump_ascii(&cell->center, stream, offset); fprintf(stream, "\n"); @@ -822,33 +822,33 @@ static void ecl_cell_dump_ascii(ecl_cell_type *cell, int i, int j, int k, fprintf(stream, "\n"); } -static void ecl_cell_fwrite_GRID(const ecl_grid_type *grid, - const ecl_cell_type *cell, bool fracture_cell, - int coords_size, int i, int j, int k, - int global_index, ecl_kw_type *coords_kw, - ecl_kw_type *corners_kw, fortio_type *fortio) { - ecl_kw_iset_int(coords_kw, 0, i + 1); - ecl_kw_iset_int(coords_kw, 1, j + 1); - ecl_kw_iset_int(coords_kw, 2, k + 1); - ecl_kw_iset_int(coords_kw, 3, global_index + 1); +static void rd_cell_fwrite_GRID(const rd_grid_type *grid, + const rd_cell_type *cell, bool fracture_cell, + int coords_size, int i, int j, int k, + int global_index, rd_kw_type *coords_kw, + rd_kw_type *corners_kw, fortio_type *fortio) { + rd_kw_iset_int(coords_kw, 0, i + 1); + rd_kw_iset_int(coords_kw, 1, j + 1); + rd_kw_iset_int(coords_kw, 2, k + 1); + rd_kw_iset_int(coords_kw, 3, global_index + 1); - ecl_kw_iset_int(coords_kw, 4, 0); + rd_kw_iset_int(coords_kw, 4, 0); if (fracture_cell) { if (cell->active & CELL_ACTIVE_FRACTURE) - ecl_kw_iset_int(coords_kw, 4, 1); + rd_kw_iset_int(coords_kw, 4, 1); } else { if (cell->active & CELL_ACTIVE_MATRIX) - ecl_kw_iset_int(coords_kw, 4, 1); + rd_kw_iset_int(coords_kw, 4, 1); } if (coords_size == 7) { - ecl_kw_iset_int(coords_kw, 5, cell->host_cell + 1); - ecl_kw_iset_int(coords_kw, 6, cell->coarse_group + 1); + rd_kw_iset_int(coords_kw, 5, cell->host_cell + 1); + rd_kw_iset_int(coords_kw, 6, cell->coarse_group + 1); } - ecl_kw_fwrite(coords_kw, fortio); + rd_kw_fwrite(coords_kw, fortio); { - float *corners = (float *)ecl_kw_get_void_ptr(corners_kw); + float *corners = (float *)rd_kw_get_void_ptr(corners_kw); point_type point; int c; @@ -863,13 +863,13 @@ static void ecl_cell_fwrite_GRID(const ecl_grid_type *grid, corners[3 * c + 2] = point.z; } } - ecl_kw_fwrite(corners_kw, fortio); + rd_kw_fwrite(corners_kw, fortio); } -//static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; -static void ecl_cell_ri_export(const ecl_cell_type *cell, double *ri_points) { - int ecl_offset = 4; - int ri_offset = ecl_offset * 3; +//static const size_t cellMappingRDRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; +static void rd_cell_ri_export(const rd_cell_type *cell, double *ri_points) { + int rd_offset = 4; + int ri_offset = rd_offset * 3; { int point_nr; // Handling the points 0,1 & 4,5 which map directly between ECLIPSE and RI @@ -881,34 +881,34 @@ static void ecl_cell_ri_export(const ecl_cell_type *cell, double *ri_points) { // Points 4 & 5 ri_points[ri_offset + point_nr * 3] = - cell->corner_list[ecl_offset + point_nr].x; + cell->corner_list[rd_offset + point_nr].x; ri_points[ri_offset + point_nr * 3 + 1] = - cell->corner_list[ecl_offset + point_nr].y; + cell->corner_list[rd_offset + point_nr].y; ri_points[ri_offset + point_nr * 3 + 2] = - -cell->corner_list[ecl_offset + point_nr].z; + -cell->corner_list[rd_offset + point_nr].z; } } { - int ecl_point; + int rd_point; /* Handling the points 2,3 & 6,7 which are flipped when (2,3) -> (3,2) and (6,7) -> (7,6) when going between ECLIPSE and ResInsight. */ - for (ecl_point = 2; ecl_point < 4; ecl_point++) { - int ri_point = 5 - ecl_point; + for (rd_point = 2; rd_point < 4; rd_point++) { + int ri_point = 5 - rd_point; // Points 2 & 3 - ri_points[ri_point * 3] = cell->corner_list[ecl_point].x; - ri_points[ri_point * 3 + 1] = cell->corner_list[ecl_point].y; - ri_points[ri_point * 3 + 2] = -cell->corner_list[ecl_point].z; + ri_points[ri_point * 3] = cell->corner_list[rd_point].x; + ri_points[ri_point * 3 + 1] = cell->corner_list[rd_point].y; + ri_points[ri_point * 3 + 2] = -cell->corner_list[rd_point].z; // Points 6 & 7 ri_points[ri_offset + ri_point * 3] = - cell->corner_list[ecl_offset + ecl_point].x; + cell->corner_list[rd_offset + rd_point].x; ri_points[ri_offset + ri_point * 3 + 1] = - cell->corner_list[ecl_offset + ecl_point].y; + cell->corner_list[rd_offset + rd_point].y; ri_points[ri_offset + ri_point * 3 + 2] = - -cell->corner_list[ecl_offset + ecl_point].z; + -cell->corner_list[rd_offset + rd_point].z; } } } @@ -935,12 +935,12 @@ static double min8(double x1, double x2, double x3, double x4, double x5, return min2(min4(x1, x2, x3, x4), min4(x5, x6, x7, x8)); } -static double ecl_cell_min_z(const ecl_cell_type *cell) { +static double rd_cell_min_z(const rd_cell_type *cell) { return min4(cell->corner_list[0].z, cell->corner_list[1].z, cell->corner_list[2].z, cell->corner_list[3].z); } -static double ecl_cell_max_z(const ecl_cell_type *cell) { +static double rd_cell_max_z(const rd_cell_type *cell) { return max4(cell->corner_list[4].z, cell->corner_list[5].z, cell->corner_list[6].z, cell->corner_list[7].z); } @@ -950,28 +950,28 @@ static double ecl_cell_max_z(const ecl_cell_type *cell) { plane for the x/y min/max. */ -static double ecl_cell_min_x(const ecl_cell_type *cell) { +static double rd_cell_min_x(const rd_cell_type *cell) { return min8(cell->corner_list[0].x, cell->corner_list[1].x, cell->corner_list[2].x, cell->corner_list[3].x, cell->corner_list[4].x, cell->corner_list[5].x, cell->corner_list[6].x, cell->corner_list[7].x); } -static double ecl_cell_max_x(const ecl_cell_type *cell) { +static double rd_cell_max_x(const rd_cell_type *cell) { return max8(cell->corner_list[0].x, cell->corner_list[1].x, cell->corner_list[2].x, cell->corner_list[3].x, cell->corner_list[4].x, cell->corner_list[5].x, cell->corner_list[6].x, cell->corner_list[7].x); } -static double ecl_cell_min_y(const ecl_cell_type *cell) { +static double rd_cell_min_y(const rd_cell_type *cell) { return min8(cell->corner_list[0].y, cell->corner_list[1].y, cell->corner_list[2].y, cell->corner_list[3].y, cell->corner_list[4].y, cell->corner_list[5].y, cell->corner_list[6].y, cell->corner_list[7].y); } -static double ecl_cell_max_y(const ecl_cell_type *cell) { +static double rd_cell_max_y(const rd_cell_type *cell) { return max8(cell->corner_list[0].y, cell->corner_list[1].y, cell->corner_list[2].y, cell->corner_list[3].y, cell->corner_list[4].y, cell->corner_list[5].y, @@ -1011,7 +1011,7 @@ static double ecl_cell_max_y(const ecl_cell_type *cell) { active elements. */ -static void ecl_cell_taint_cell(ecl_cell_type *cell) { +static void rd_cell_taint_cell(rd_cell_type *cell) { int c; for (c = 0; c < 8; c++) { const point_type p = cell->corner_list[c]; @@ -1047,7 +1047,7 @@ static void ecl_cell_taint_cell(ecl_cell_type *cell) { } } -static int ecl_cell_get_twist(const ecl_cell_type *cell) { +static int rd_cell_get_twist(const rd_cell_type *cell) { int twist_count = 0; for (int c = 0; c < 4; c++) { @@ -1065,7 +1065,7 @@ static int ecl_cell_get_twist(const ecl_cell_type *cell) { will have a coords/corners section in the grid file. */ -static void ecl_cell_init(ecl_cell_type *cell, bool init_valid) { +static void rd_cell_init(rd_cell_type *cell, bool init_valid) { cell->active = CELL_NOT_ACTIVE; cell->lgr = NULL; cell->host_cell = HOST_CELL_NONE; @@ -1081,13 +1081,13 @@ static void ecl_cell_init(ecl_cell_type *cell, bool init_valid) { /* #define mod(x,n) ((x) % (n)) -static int ecl_cell_get_tetrahedron_method( int i , int j , int k) { +static int rd_cell_get_tetrahedron_method( int i , int j , int k) { return (1 + (1 - 2*mod(i,2)) * (1 - 2 * mod(j,2)) * (1 - 2*mod(k,2))) / 2; } #undef mod */ -static void ecl_cell_set_center(ecl_cell_type *cell) { +static void rd_cell_set_center(rd_cell_type *cell) { point_set(&cell->center, 0, 0, 0); { int c; @@ -1099,18 +1099,18 @@ static void ecl_cell_set_center(ecl_cell_type *cell) { SET_CELL_FLAG(cell, CELL_FLAG_CENTER); } -static void ecl_cell_assert_center(ecl_cell_type *cell) { +static void rd_cell_assert_center(rd_cell_type *cell) { if (!GET_CELL_FLAG(cell, CELL_FLAG_CENTER)) - ecl_cell_set_center(cell); + rd_cell_set_center(cell); } -static void ecl_cell_memcpy(ecl_cell_type *target_cell, - const ecl_cell_type *src_cell) { +static void rd_cell_memcpy(rd_cell_type *target_cell, + const rd_cell_type *src_cell) { memcpy(target_cell, src_cell, sizeof *target_cell); } -static void ecl_cell_install_lgr(ecl_cell_type *cell, - const ecl_grid_type *lgr_grid) { +static void rd_cell_install_lgr(rd_cell_type *cell, + const rd_grid_type *lgr_grid) { cell->lgr = lgr_grid; } @@ -1143,7 +1143,7 @@ static double C(double *r, int f1, int f2, int f3) { } } -static double ecl_cell_get_volume(ecl_cell_type *cell) { +static double rd_cell_get_volume(rd_cell_type *cell) { double volume = 0; int pb, pg, qa, qg, ra, rb; double X[8]; @@ -1338,8 +1338,8 @@ static bool triangle_contains3d(const point_type *p0, const point_type *p1, triangle_contains(). */ -static bool ecl_cell_layer_contains_xy(const ecl_cell_type *cell, - bool lower_layer, double x, double y) { +static bool rd_cell_layer_contains_xy(const rd_cell_type *cell, + bool lower_layer, double x, double y) { if (GET_CELL_FLAG(cell, CELL_FLAG_TAINTED)) return false; { @@ -1371,10 +1371,10 @@ static bool ecl_cell_layer_contains_xy(const ecl_cell_type *cell, | | | | 0---1 4---5 */ -static void ecl_cell_init_regular(ecl_cell_type *cell, const double *offset, - int i, int j, int k, int global_index, - const double *ivec, const double *jvec, - const double *kvec, const int *actnum) { +static void rd_cell_init_regular(rd_cell_type *cell, const double *offset, + int i, int j, int k, int global_index, + const double *ivec, const double *jvec, + const double *kvec, const int *actnum) { point_set(&cell->corner_list[0], offset[0], offset[1], offset[2]); // Point 0 @@ -1401,57 +1401,57 @@ static void ecl_cell_init_regular(ecl_cell_type *cell, const double *offset, cell->active = CELL_ACTIVE; } -UTIL_SAFE_CAST_FUNCTION(ecl_grid, ECL_GRID_ID); -UTIL_IS_INSTANCE_FUNCTION(ecl_grid, ECL_GRID_ID); +UTIL_SAFE_CAST_FUNCTION(rd_grid, RD_GRID_ID); +UTIL_IS_INSTANCE_FUNCTION(rd_grid, RD_GRID_ID); /** this function allocates the internal index_map and inv_index_map fields. */ -static ecl_cell_type *ecl_grid_get_cell(const ecl_grid_type *grid, - int global_index) { +static rd_cell_type *rd_grid_get_cell(const rd_grid_type *grid, + int global_index) { return &grid->cells[global_index]; } /** this function uses heuristics in an attempt to mark cells with wrong geometry - see further comments in the function - ecl_cell_taint_cell() which actually does it. + rd_cell_taint_cell() which actually does it. */ -static void ecl_grid_taint_cells(ecl_grid_type *ecl_grid) { +static void rd_grid_taint_cells(rd_grid_type *rd_grid) { int index; - for (index = 0; index < ecl_grid->size; index++) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, index); - ecl_cell_taint_cell(cell); + for (index = 0; index < rd_grid->size; index++) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, index); + rd_cell_taint_cell(cell); } } -static void ecl_grid_free_cells(ecl_grid_type *grid) { +static void rd_grid_free_cells(rd_grid_type *grid) { if (!grid->cells) return; for (int i = 0; i < grid->size; i++) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, i); + rd_cell_type *cell = rd_grid_get_cell(grid, i); if (cell->nnc_info) nnc_info_free(cell->nnc_info); } free(grid->cells); } -static bool ecl_grid_alloc_cells(ecl_grid_type *grid, bool init_valid) { - grid->cells = (ecl_cell_type *)malloc(grid->size * sizeof *grid->cells); +static bool rd_grid_alloc_cells(rd_grid_type *grid, bool init_valid) { + grid->cells = (rd_cell_type *)malloc(grid->size * sizeof *grid->cells); if (!grid->cells) return false; { - ecl_cell_type *cell0 = ecl_grid_get_cell(grid, 0); - ecl_cell_init(cell0, init_valid); + rd_cell_type *cell0 = rd_grid_get_cell(grid, 0); + rd_cell_init(cell0, init_valid); { int i; for (i = 1; i < grid->size; i++) { - ecl_cell_type *target_cell = ecl_grid_get_cell(grid, i); - ecl_cell_memcpy(target_cell, cell0); + rd_cell_type *target_cell = rd_grid_get_cell(grid, i); + rd_cell_memcpy(target_cell, cell0); } } return true; @@ -1466,11 +1466,10 @@ static bool ecl_grid_alloc_cells(ecl_grid_type *grid, bool init_valid) { is performed. */ -static ecl_grid_type *ecl_grid_alloc_empty(ecl_grid_type *global_grid, - ert_ecl_unit_enum unit_system, - int dualp_flag, int nx, int ny, - int nz, int lgr_nr, - bool init_valid) { +static rd_grid_type *rd_grid_alloc_empty(rd_grid_type *global_grid, + ert_rd_unit_enum unit_system, + int dualp_flag, int nx, int ny, int nz, + int lgr_nr, bool init_valid) { /* Check for int overflow in a roundabout way */ long size = static_cast(nx) * static_cast(ny); if (nx < 0 || ny < 0 || nz < 0 || size > INT_MAX) @@ -1479,8 +1478,8 @@ static ecl_grid_type *ecl_grid_alloc_empty(ecl_grid_type *global_grid, if (size > INT_MAX) return NULL; - ecl_grid_type *grid = new ecl_grid_type(); - UTIL_TYPE_ID_INIT(grid, ECL_GRID_ID); + rd_grid_type *grid = new rd_grid_type(); + UTIL_TYPE_ID_INIT(grid, RD_GRID_ID); grid->total_active = 0; grid->total_active_fracture = 0; grid->nx = nx; @@ -1526,7 +1525,7 @@ static ecl_grid_type *ecl_grid_alloc_empty(ecl_grid_type *global_grid, grid->block_dim = 0; grid->values = NULL; - if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */ + if (RD_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */ grid->LGR_list = vector_alloc_new(); grid->lgr_index_map = int_vector_alloc(0, 0); } else { @@ -1540,25 +1539,25 @@ static ecl_grid_type *ecl_grid_alloc_empty(ecl_grid_type *global_grid, grid->eclipse_version = 0; /* This is the large allocation - which can potentially fail. */ - if (!ecl_grid_alloc_cells(grid, init_valid)) { - ecl_grid_free(grid); + if (!rd_grid_alloc_cells(grid, init_valid)) { + rd_grid_free(grid); grid = NULL; } return grid; } -static int ecl_grid_get_global_index__(const ecl_grid_type *ecl_grid, int i, - int j, int k) { - return i + j * ecl_grid->nx + k * ecl_grid->nx * ecl_grid->ny; +static int rd_grid_get_global_index__(const rd_grid_type *rd_grid, int i, int j, + int k) { + return i + j * rd_grid->nx + k * rd_grid->nx * rd_grid->ny; } -static void ecl_grid_set_cell_EGRID(ecl_grid_type *ecl_grid, int i, int j, - int k, double x[4][2], double y[4][2], - double z[4][2], const int *actnum, - const int *corsnum) { +static void rd_grid_set_cell_EGRID(rd_grid_type *rd_grid, int i, int j, int k, + double x[4][2], double y[4][2], + double z[4][2], const int *actnum, + const int *corsnum) { - const int global_index = ecl_grid_get_global_index__(ecl_grid, i, j, k); - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); + const int global_index = rd_grid_get_global_index__(rd_grid, i, j, k); + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); int ip, iz; for (iz = 0; iz < 2; iz++) { @@ -1566,9 +1565,9 @@ static void ecl_grid_set_cell_EGRID(ecl_grid_type *ecl_grid, int i, int j, int c = ip + iz * 4; point_set(&cell->corner_list[c], x[ip][iz], y[ip][iz], z[ip][iz]); - if (ecl_grid->use_mapaxes) - point_mapaxes_transform(&cell->corner_list[c], ecl_grid->origo, - ecl_grid->unit_x, ecl_grid->unit_y); + if (rd_grid->use_mapaxes) + point_mapaxes_transform(&cell->corner_list[c], rd_grid->origo, + rd_grid->unit_x, rd_grid->unit_y); } } @@ -1587,14 +1586,14 @@ static void ecl_grid_set_cell_EGRID(ecl_grid_type *ecl_grid, int i, int j, cell->coarse_group = corsnum[global_index] - 1; } -static void ecl_grid_set_cell_GRID(ecl_grid_type *ecl_grid, int coords_size, - const int *coords, const float *corners) { +static void rd_grid_set_cell_GRID(rd_grid_type *rd_grid, int coords_size, + const int *coords, const float *corners) { const int i = coords[0] - 1; /* eclipse 1 offset */ const int j = coords[1] - 1; int k = coords[2] - 1; int global_index; - ecl_cell_type *cell; + rd_cell_type *cell; bool matrix_cell = true; int active_value = CELL_ACTIVE_MATRIX; @@ -1606,14 +1605,14 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type *ecl_grid, int coords_size, properties of the fracture. */ - if (k >= ecl_grid->nz) { - k -= ecl_grid->nz; + if (k >= rd_grid->nz) { + k -= rd_grid->nz; matrix_cell = false; active_value = CELL_ACTIVE_FRACTURE; } - global_index = ecl_grid_get_global_index__(ecl_grid, i, j, k); - cell = ecl_grid_get_cell(ecl_grid, global_index); + global_index = rd_grid_get_global_index__(rd_grid, i, j, k); + cell = rd_grid_get_cell(rd_grid, global_index); /* the coords keyword can optionally contain 4,5 or 7 elements: @@ -1638,13 +1637,12 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type *ecl_grid, int coords_size, int c; /* - The ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr test checks if + The RD_GRID_MAINGRID_LGR_NR != rd_grid->lgr_nr test checks if this is a LGR; if this test applies we either have bug - or a GRID file with LGRs and only 4/5 elements in the coords keywords. In the latter case we must start using the LGRILG keyword. */ - if ((ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr) && - (coords_size != 7)) + if ((RD_GRID_MAINGRID_LGR_NR != rd_grid->lgr_nr) && (coords_size != 7)) util_abort("%s: Need 7 element coords keywords for LGR - or " "reimplement to use LGRILG keyword.\n", __func__); @@ -1661,7 +1659,7 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type *ecl_grid, int coords_size, cell->host_cell = coords[5] - 1; cell->coarse_group = coords[6] - 1; if (cell->coarse_group >= 0) - ecl_grid->coarsening_active = true; + rd_grid->coarsening_active = true; break; default: util_abort("%s: coord size:%d unrecognized - should 4,5 or 7.\n", @@ -1673,10 +1671,10 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type *ecl_grid, int coords_size, point_set(&cell->corner_list[c], corners[3 * c], corners[3 * c + 1], corners[3 * c + 2]); - if (ecl_grid->use_mapaxes) + if (rd_grid->use_mapaxes) point_mapaxes_transform(&cell->corner_list[c], - ecl_grid->origo, ecl_grid->unit_x, - ecl_grid->unit_y); + rd_grid->origo, rd_grid->unit_x, + rd_grid->unit_y); } } } @@ -1684,16 +1682,16 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type *ecl_grid, int coords_size, } /** - The function ecl_grid_set_active_index() must be called immediately + The function rd_grid_set_active_index() must be called immediately prior to calling this function, to ensure that - ecl_grid->total_active is correct. + rd_grid->total_active is correct. */ -static void ecl_grid_init_index_map__(ecl_grid_type *ecl_grid, int *index_map, - int *inv_index_map, int active_mask, - int type_index) { - for (int global_index = 0; global_index < ecl_grid->size; global_index++) { - const ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); +static void rd_grid_init_index_map__(rd_grid_type *rd_grid, int *index_map, + int *inv_index_map, int active_mask, + int type_index) { + for (int global_index = 0; global_index < rd_grid->size; global_index++) { + const rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (cell->active & active_mask) { index_map[global_index] = cell->active_index[type_index]; @@ -1705,29 +1703,29 @@ static void ecl_grid_init_index_map__(ecl_grid_type *ecl_grid, int *index_map, } } -static void ecl_grid_realloc_index_map(ecl_grid_type *ecl_grid) { +static void rd_grid_realloc_index_map(rd_grid_type *rd_grid) { /* Creating the inverse mapping for the matrix cells. */ - ecl_grid->index_map = (int *)util_realloc( - ecl_grid->index_map, ecl_grid->size * sizeof *ecl_grid->index_map); - ecl_grid->inv_index_map = (int *)util_realloc( - ecl_grid->inv_index_map, - ecl_grid->total_active * sizeof *ecl_grid->inv_index_map); - ecl_grid_init_index_map__(ecl_grid, ecl_grid->index_map, - ecl_grid->inv_index_map, CELL_ACTIVE_MATRIX, - MATRIX_INDEX); + rd_grid->index_map = (int *)util_realloc( + rd_grid->index_map, rd_grid->size * sizeof *rd_grid->index_map); + rd_grid->inv_index_map = (int *)util_realloc( + rd_grid->inv_index_map, + rd_grid->total_active * sizeof *rd_grid->inv_index_map); + rd_grid_init_index_map__(rd_grid, rd_grid->index_map, + rd_grid->inv_index_map, CELL_ACTIVE_MATRIX, + MATRIX_INDEX); /* Create the inverse mapping for the fractures. */ - if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { - ecl_grid->fracture_index_map = (int *)util_realloc( - ecl_grid->fracture_index_map, - ecl_grid->size * sizeof *ecl_grid->fracture_index_map); - ecl_grid->inv_fracture_index_map = - (int *)util_realloc(ecl_grid->inv_fracture_index_map, - ecl_grid->total_active_fracture * - sizeof *ecl_grid->inv_fracture_index_map); - ecl_grid_init_index_map__(ecl_grid, ecl_grid->fracture_index_map, - ecl_grid->inv_fracture_index_map, - CELL_ACTIVE_FRACTURE, FRACTURE_INDEX); + if (rd_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { + rd_grid->fracture_index_map = (int *)util_realloc( + rd_grid->fracture_index_map, + rd_grid->size * sizeof *rd_grid->fracture_index_map); + rd_grid->inv_fracture_index_map = + (int *)util_realloc(rd_grid->inv_fracture_index_map, + rd_grid->total_active_fracture * + sizeof *rd_grid->inv_fracture_index_map); + rd_grid_init_index_map__(rd_grid, rd_grid->fracture_index_map, + rd_grid->inv_fracture_index_map, + CELL_ACTIVE_FRACTURE, FRACTURE_INDEX); } /* Update the inverse map in the case of coarse cells. Observe that @@ -1735,45 +1733,44 @@ static void ecl_grid_realloc_index_map(ecl_grid_type *ecl_grid) { main grid, the inverse active -> global mapping will map to the first active cell in the coarse cell. */ - int size = ecl_grid_get_num_coarse_groups(ecl_grid); + int size = rd_grid_get_num_coarse_groups(rd_grid); for (int coarse_group = 0; coarse_group < size; coarse_group++) { - ecl_coarse_cell_type *coarse_cell = - ecl_grid_iget_coarse_group(ecl_grid, coarse_group); + rd_coarse_cell_type *coarse_cell = + rd_grid_iget_coarse_group(rd_grid, coarse_group); // Coarse cell group numbering is not necessarily in consecutive order if (coarse_cell == NULL) { continue; } - if (ecl_coarse_cell_get_num_active(coarse_cell) > 0) { + if (rd_coarse_cell_get_num_active(coarse_cell) > 0) { int global_index = - ecl_coarse_cell_iget_active_cell_index(coarse_cell, 0); - int active_value = - ecl_coarse_cell_iget_active_value(coarse_cell, 0); - int active_index = ecl_coarse_cell_get_active_index(coarse_cell); + rd_coarse_cell_iget_active_cell_index(coarse_cell, 0); + int active_value = rd_coarse_cell_iget_active_value(coarse_cell, 0); + int active_index = rd_coarse_cell_get_active_index(coarse_cell); int active_fracture_index = - ecl_coarse_cell_get_active_fracture_index(coarse_cell); + rd_coarse_cell_get_active_fracture_index(coarse_cell); if (active_value & CELL_ACTIVE_MATRIX) // active->global mapping point to one "random" cell in the coarse group - ecl_grid->inv_index_map[active_index] = global_index; + rd_grid->inv_index_map[active_index] = global_index; if (active_value & CELL_ACTIVE_FRACTURE) - ecl_grid->inv_fracture_index_map[active_fracture_index] = + rd_grid->inv_fracture_index_map[active_fracture_index] = global_index; - int coarse_size = ecl_coarse_cell_get_size(coarse_cell); + int coarse_size = rd_coarse_cell_get_size(coarse_cell); const int_vector_type *global_index_list = - ecl_coarse_cell_get_index_vector(coarse_cell); + rd_coarse_cell_get_index_vector(coarse_cell); for (int ic = 0; ic < coarse_size; ic++) { int gi = int_vector_iget(global_index_list, ic); if (active_value & CELL_ACTIVE_MATRIX) // All cells in the coarse group point to the same active index. - ecl_grid->index_map[gi] = active_index; + rd_grid->index_map[gi] = active_index; if (active_value & CELL_ACTIVE_FRACTURE) - ecl_grid->fracture_index_map[gi] = active_fracture_index; + rd_grid->fracture_index_map[gi] = active_fracture_index; } } // else the coarse cell does not have any active cells. } @@ -1781,20 +1778,20 @@ static void ecl_grid_realloc_index_map(ecl_grid_type *ecl_grid) { /* This function goes through the entire grid and sets the active_index - of all the cells. The functione ecl_grid_realloc_index_map() + of all the cells. The functione rd_grid_realloc_index_map() subsequently reads this to create and initialize the index map. */ -static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { +static void rd_grid_set_active_index(rd_grid_type *rd_grid) { int global_index; int active_index = 0; int active_fracture_index = 0; - if (!ecl_grid_have_coarse_cells(ecl_grid)) { + if (!rd_grid_have_coarse_cells(rd_grid)) { /* Keeping a fast path for the 99% most common case of no coarse groups and single porosity. */ - for (global_index = 0; global_index < ecl_grid->size; global_index++) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); + for (global_index = 0; global_index < rd_grid->size; global_index++) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (cell->active & CELL_ACTIVE_MATRIX) { cell->active_index[MATRIX_INDEX] = active_index; @@ -1802,10 +1799,10 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { } } - if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { - for (global_index = 0; global_index < ecl_grid->size; + if (rd_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { + for (global_index = 0; global_index < rd_grid->size; global_index++) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (cell->active & CELL_ACTIVE_FRACTURE) { cell->active_index[FRACTURE_INDEX] = active_fracture_index; active_fracture_index++; @@ -1816,18 +1813,18 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { /* --- More involved path in the case of coarsening groups. --- */ /* 1: Reset the coarse cell active_indices. - In the involved path ecl_coarse_cell_update_index() only updates + In the involved path rd_coarse_cell_update_index() only updates the coarse cells' active_index if it is -1. */ for (int coarse_index = 0; - coarse_index < vector_get_size(ecl_grid->coarse_cells); + coarse_index < vector_get_size(rd_grid->coarse_cells); coarse_index++) { - ecl_coarse_cell_type *coarse_cell = - (ecl_coarse_cell_type *)vector_iget_const( - ecl_grid->coarse_cells, coarse_index); + rd_coarse_cell_type *coarse_cell = + (rd_coarse_cell_type *)vector_iget_const(rd_grid->coarse_cells, + coarse_index); // Coarse cell group numbering is not necessarily in consecutive order if (coarse_cell != NULL) { - ecl_coarse_cell_reset_active_index(coarse_cell); + rd_coarse_cell_reset_active_index(coarse_cell); } } @@ -1835,8 +1832,8 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { case of coarse cells we only set the common active index of the entire coarse cell. */ - for (global_index = 0; global_index < ecl_grid->size; global_index++) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); + for (global_index = 0; global_index < rd_grid->size; global_index++) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (cell->active != CELL_NOT_ACTIVE) { if (cell->coarse_group == COARSE_GROUP_NONE) { @@ -1852,10 +1849,9 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { } } else { - ecl_coarse_cell_type *coarse_cell = - ecl_grid_iget_coarse_group(ecl_grid, - cell->coarse_group); - ecl_coarse_cell_update_index( + rd_coarse_cell_type *coarse_cell = + rd_grid_iget_coarse_group(rd_grid, cell->coarse_group); + rd_coarse_cell_update_index( coarse_cell, global_index, &active_index, &active_fracture_index, cell->active); } @@ -1868,30 +1864,30 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { common value for the coarse cell. */ - int size = ecl_grid_get_num_coarse_groups(ecl_grid); + int size = rd_grid_get_num_coarse_groups(rd_grid); for (int coarse_group = 0; coarse_group < size; coarse_group++) { - ecl_coarse_cell_type *coarse_cell = - ecl_grid_iget_coarse_group(ecl_grid, coarse_group); + rd_coarse_cell_type *coarse_cell = + rd_grid_iget_coarse_group(rd_grid, coarse_group); // Coarse cell group numbering is not necessarily in consecutive order if (coarse_cell == NULL) { continue; } - if (ecl_coarse_cell_get_num_active(coarse_cell) > 0) { + if (rd_coarse_cell_get_num_active(coarse_cell) > 0) { int cell_active_index = - ecl_coarse_cell_get_active_index(coarse_cell); + rd_coarse_cell_get_active_index(coarse_cell); int cell_active_value = - ecl_coarse_cell_iget_active_value(coarse_cell, 0); - int group_size = ecl_coarse_cell_get_size(coarse_cell); + rd_coarse_cell_iget_active_value(coarse_cell, 0); + int group_size = rd_coarse_cell_get_size(coarse_cell); const int *coarse_cell_list = - ecl_coarse_cell_get_index_ptr(coarse_cell); + rd_coarse_cell_get_index_ptr(coarse_cell); for (int i = 0; i < group_size; i++) { global_index = coarse_cell_list[i]; - ecl_cell_type *cell = - ecl_grid_get_cell(ecl_grid, global_index); + rd_cell_type *cell = + rd_grid_get_cell(rd_grid, global_index); if (cell_active_value & CELL_ACTIVE_MATRIX) cell->active_index[MATRIX_INDEX] = cell_active_index; @@ -1899,7 +1895,7 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { /* Coarse cell and dual porosity - that is probably close to zero measure. */ if (cell_active_value & CELL_ACTIVE_FRACTURE) { int cell_active_fracture_index = - ecl_coarse_cell_get_active_fracture_index( + rd_coarse_cell_get_active_fracture_index( coarse_cell); cell->active_index[FRACTURE_INDEX] = cell_active_fracture_index; @@ -1908,84 +1904,79 @@ static void ecl_grid_set_active_index(ecl_grid_type *ecl_grid) { } } } - ecl_grid->total_active = active_index; - ecl_grid->total_active_fracture = active_fracture_index; + rd_grid->total_active = active_index; + rd_grid->total_active_fracture = active_fracture_index; } -static void ecl_grid_update_index(ecl_grid_type *ecl_grid) { - ecl_grid_set_active_index(ecl_grid); - ecl_grid_realloc_index_map(ecl_grid); +static void rd_grid_update_index(rd_grid_type *rd_grid) { + rd_grid_set_active_index(rd_grid); + rd_grid_realloc_index_map(rd_grid); } -static ecl_coarse_cell_type * -ecl_grid_get_or_create_coarse_cell(ecl_grid_type *ecl_grid, int coarse_nr) { - if (vector_safe_iget(ecl_grid->coarse_cells, coarse_nr) == NULL) - vector_iset_owned_ref(ecl_grid->coarse_cells, coarse_nr, - ecl_coarse_cell_alloc(), ecl_coarse_cell_free__); +static rd_coarse_cell_type * +rd_grid_get_or_create_coarse_cell(rd_grid_type *rd_grid, int coarse_nr) { + if (vector_safe_iget(rd_grid->coarse_cells, coarse_nr) == NULL) + vector_iset_owned_ref(rd_grid->coarse_cells, coarse_nr, + rd_coarse_cell_alloc(), rd_coarse_cell_free__); - return (ecl_coarse_cell_type *)vector_iget(ecl_grid->coarse_cells, - coarse_nr); + return (rd_coarse_cell_type *)vector_iget(rd_grid->coarse_cells, coarse_nr); } -static void ecl_grid_init_coarse_cells(ecl_grid_type *ecl_grid) { - if (ecl_grid->coarsening_active) { +static void rd_grid_init_coarse_cells(rd_grid_type *rd_grid) { + if (rd_grid->coarsening_active) { int global_index; - for (global_index = 0; global_index < ecl_grid->size; global_index++) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); + for (global_index = 0; global_index < rd_grid->size; global_index++) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (cell->coarse_group != COARSE_GROUP_NONE) { - ecl_coarse_cell_type *coarse_cell = - ecl_grid_get_or_create_coarse_cell(ecl_grid, - cell->coarse_group); + rd_coarse_cell_type *coarse_cell = + rd_grid_get_or_create_coarse_cell(rd_grid, + cell->coarse_group); int i, j, k; - ecl_grid_get_ijk1(ecl_grid, global_index, &i, &j, &k); - ecl_coarse_cell_update(coarse_cell, i, j, k, global_index); + rd_grid_get_ijk1(rd_grid, global_index, &i, &j, &k); + rd_coarse_cell_update(coarse_cell, i, j, k, global_index); } } } } -ecl_coarse_cell_type *ecl_grid_iget_coarse_group(const ecl_grid_type *ecl_grid, - int coarse_nr) { - return (ecl_coarse_cell_type *)vector_iget(ecl_grid->coarse_cells, - coarse_nr); +rd_coarse_cell_type *rd_grid_iget_coarse_group(const rd_grid_type *rd_grid, + int coarse_nr) { + return (rd_coarse_cell_type *)vector_iget(rd_grid->coarse_cells, coarse_nr); } -ecl_coarse_cell_type * -ecl_grid_get_cell_coarse_group1(const ecl_grid_type *ecl_grid, - int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); +rd_coarse_cell_type *rd_grid_get_cell_coarse_group1(const rd_grid_type *rd_grid, + int global_index) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (cell->coarse_group == COARSE_GROUP_NONE) return NULL; else - return ecl_grid_iget_coarse_group(ecl_grid, cell->coarse_group); + return rd_grid_iget_coarse_group(rd_grid, cell->coarse_group); } -ecl_coarse_cell_type * -ecl_grid_get_cell_coarse_group3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_get_cell_coarse_group1(ecl_grid, global_index); +rd_coarse_cell_type *rd_grid_get_cell_coarse_group3(const rd_grid_type *rd_grid, + int i, int j, int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_get_cell_coarse_group1(rd_grid, global_index); } -bool ecl_grid_cell_in_coarse_group1(const ecl_grid_type *main_grid, - int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(main_grid, global_index); +bool rd_grid_cell_in_coarse_group1(const rd_grid_type *main_grid, + int global_index) { + rd_cell_type *cell = rd_grid_get_cell(main_grid, global_index); if (cell->coarse_group == COARSE_GROUP_NONE) return false; else return true; } -bool ecl_grid_cell_in_coarse_group3(const ecl_grid_type *main_grid, int i, - int j, int k) { - return ecl_grid_cell_in_coarse_group1( - main_grid, ecl_grid_get_global_index3(main_grid, i, j, k)); +bool rd_grid_cell_in_coarse_group3(const rd_grid_type *main_grid, int i, int j, + int k) { + return rd_grid_cell_in_coarse_group1( + main_grid, rd_grid_get_global_index3(main_grid, i, j, k)); } -static void ecl_grid_pillar_cross_planes(const point_type *p0, double e_x, - double e_y, double e_z, - const double *z, double *x, - double *y) { +static void rd_grid_pillar_cross_planes(const point_type *p0, double e_x, + double e_y, double e_z, const double *z, + double *x, double *y) { int k; if (e_z != 0) { for (k = 0; k < 2; k++) { @@ -2008,9 +1999,9 @@ static void ecl_grid_pillar_cross_planes(const point_type *p0, double e_x, settings from the global grid. */ -static void ecl_grid_init_mapaxes(ecl_grid_type *ecl_grid, bool apply_mapaxes, - const float *mapaxes) { - if (ecl_grid->global_grid != NULL) +static void rd_grid_init_mapaxes(rd_grid_type *rd_grid, bool apply_mapaxes, + const float *mapaxes) { + if (rd_grid->global_grid != NULL) util_abort("%s: GridError: Trying to grid transformation data from " "mapaxes for a subgrid(lgr)\n", __func__); @@ -2025,27 +2016,27 @@ static void ecl_grid_init_mapaxes(ecl_grid_type *ecl_grid, bool apply_mapaxes, double norm_y = 1.0 / sqrt(unit_y[0] * unit_y[0] + unit_y[1] * unit_y[1]); - ecl_grid->unit_x[0] = unit_x[0] * norm_x; - ecl_grid->unit_x[1] = unit_x[1] * norm_x; - ecl_grid->unit_y[0] = unit_y[0] * norm_y; - ecl_grid->unit_y[1] = unit_y[1] * norm_y; + rd_grid->unit_x[0] = unit_x[0] * norm_x; + rd_grid->unit_x[1] = unit_x[1] * norm_x; + rd_grid->unit_y[0] = unit_y[0] * norm_y; + rd_grid->unit_y[1] = unit_y[1] * norm_y; } - ecl_grid->origo[0] = mapaxes[2]; - ecl_grid->origo[1] = mapaxes[3]; - ecl_grid->mapaxes = (float *)util_malloc(6 * sizeof *ecl_grid->mapaxes); - memcpy(ecl_grid->mapaxes, mapaxes, 6 * sizeof(float)); + rd_grid->origo[0] = mapaxes[2]; + rd_grid->origo[1] = mapaxes[3]; + rd_grid->mapaxes = (float *)util_malloc(6 * sizeof *rd_grid->mapaxes); + memcpy(rd_grid->mapaxes, mapaxes, 6 * sizeof(float)); /* If the apply_mapaxes variable is false we will not apply the transformation; however we will still internalize the mapaxes information, and also output that if the file is saved again. */ - ecl_grid->use_mapaxes = apply_mapaxes; + rd_grid->use_mapaxes = apply_mapaxes; } } /** - this function will add a ecl_grid instance as a lgr to the main + this function will add a rd_grid instance as a lgr to the main grid. the lgr grid as added to two different structures of the main grid: @@ -2074,9 +2065,8 @@ static void ecl_grid_init_mapaxes(ecl_grid_type *ecl_grid, bool apply_mapaxes, in the _install_egrid / install_grid functions further down. */ -static void ecl_grid_add_lgr(ecl_grid_type *main_grid, - ecl_grid_type *lgr_grid) { - vector_append_owned_ref(main_grid->LGR_list, lgr_grid, ecl_grid_free__); +static void rd_grid_add_lgr(rd_grid_type *main_grid, rd_grid_type *lgr_grid) { + vector_append_owned_ref(main_grid->LGR_list, lgr_grid, rd_grid_free__); if (lgr_grid->lgr_nr >= int_vector_size(main_grid->lgr_index_map)) int_vector_resize(main_grid->lgr_index_map, lgr_grid->lgr_nr + 1, 0); int_vector_iset(main_grid->lgr_index_map, lgr_grid->lgr_nr, @@ -2084,51 +2074,51 @@ static void ecl_grid_add_lgr(ecl_grid_type *main_grid, main_grid->LGR_hash[lgr_grid->name] = lgr_grid; } -static void ecl_grid_install_lgr_common(ecl_grid_type *host_grid, - ecl_grid_type *lgr_grid) { +static void rd_grid_install_lgr_common(rd_grid_type *host_grid, + rd_grid_type *lgr_grid) { host_grid->children[lgr_grid->name] = lgr_grid; lgr_grid->parent_grid = host_grid; } /** this function will set the lgr pointer of the relevant cells in the - host grid to point to the lgr_grid. observe that the ecl_cell_type + host grid to point to the lgr_grid. observe that the rd_cell_type instances do *not* own the lgr_grid - all lgr_grid instances are owned by the main grid. */ -static void ecl_grid_install_lgr_EGRID(ecl_grid_type *host_grid, - ecl_grid_type *lgr_grid, - const int *hostnum) { +static void rd_grid_install_lgr_EGRID(rd_grid_type *host_grid, + rd_grid_type *lgr_grid, + const int *hostnum) { int global_lgr_index; for (global_lgr_index = 0; global_lgr_index < lgr_grid->size; global_lgr_index++) { int host_index = hostnum[global_lgr_index] - 1; - ecl_cell_type *lgr_cell = ecl_grid_get_cell(lgr_grid, global_lgr_index); - ecl_cell_type *host_cell = ecl_grid_get_cell(host_grid, host_index); + rd_cell_type *lgr_cell = rd_grid_get_cell(lgr_grid, global_lgr_index); + rd_cell_type *host_cell = rd_grid_get_cell(host_grid, host_index); - ecl_cell_install_lgr(host_cell, lgr_grid); + rd_cell_install_lgr(host_cell, lgr_grid); lgr_cell->host_cell = host_index; } - ecl_grid_install_lgr_common(host_grid, lgr_grid); + rd_grid_install_lgr_common(host_grid, lgr_grid); } /** - similar to ecl_grid_install_lgr_egrid for grid based instances. + similar to rd_grid_install_lgr_egrid for grid based instances. */ -static void ecl_grid_install_lgr_GRID(ecl_grid_type *host_grid, - ecl_grid_type *lgr_grid) { +static void rd_grid_install_lgr_GRID(rd_grid_type *host_grid, + rd_grid_type *lgr_grid) { int global_lgr_index; for (global_lgr_index = 0; global_lgr_index < lgr_grid->size; global_lgr_index++) { - ecl_cell_type *lgr_cell = ecl_grid_get_cell(lgr_grid, global_lgr_index); - ecl_cell_type *host_cell = - ecl_grid_get_cell(host_grid, lgr_cell->host_cell); - ecl_cell_install_lgr(host_cell, lgr_grid); + rd_cell_type *lgr_cell = rd_grid_get_cell(lgr_grid, global_lgr_index); + rd_cell_type *host_cell = + rd_grid_get_cell(host_grid, lgr_cell->host_cell); + rd_cell_install_lgr(host_cell, lgr_grid); } - ecl_grid_install_lgr_common(host_grid, lgr_grid); + rd_grid_install_lgr_common(host_grid, lgr_grid); } /** @@ -2137,19 +2127,18 @@ static void ecl_grid_install_lgr_GRID(ecl_grid_type *host_grid, the parent_name is set to NULL. */ -static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type *lgr_grid, - const ecl_file_type *ecl_file, - int grid_nr) { - ecl_kw_type *lgrname_kw = - ecl_file_iget_named_kw(ecl_file, LGR_KW, grid_nr - 1); - lgr_grid->name = - (char *)util_alloc_strip_copy((const char *)ecl_kw_iget_ptr( - lgrname_kw, 0)); /* trailing zeros are stripped away. */ - if (ecl_file_has_kw(ecl_file, LGR_PARENT_KW)) { - ecl_kw_type *parent_kw = - ecl_file_iget_named_kw(ecl_file, LGR_PARENT_KW, grid_nr - 1); +static void rd_grid_set_lgr_name_EGRID(rd_grid_type *lgr_grid, + const rd_file_type *rd_file, + int grid_nr) { + rd_kw_type *lgrname_kw = + rd_file_iget_named_kw(rd_file, LGR_KW, grid_nr - 1); + lgr_grid->name = (char *)util_alloc_strip_copy((const char *)rd_kw_iget_ptr( + lgrname_kw, 0)); /* trailing zeros are stripped away. */ + if (rd_file_has_kw(rd_file, LGR_PARENT_KW)) { + rd_kw_type *parent_kw = + rd_file_iget_named_kw(rd_file, LGR_PARENT_KW, grid_nr - 1); char *parent = (char *)util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(parent_kw, 0)); + (const char *)rd_kw_iget_ptr(parent_kw, 0)); if (strlen(parent) > 0) lgr_grid->parent_name = parent; @@ -2165,22 +2154,21 @@ static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type *lgr_grid, cool?). anyway global -> NULL. */ -static void ecl_grid_set_lgr_name_GRID(ecl_grid_type *lgr_grid, - const ecl_file_type *ecl_file, - int grid_nr) { - ecl_kw_type *lgr_kw = ecl_file_iget_named_kw(ecl_file, LGR_KW, grid_nr - 1); - lgr_grid->name = - (char *)util_alloc_strip_copy((const char *)ecl_kw_iget_ptr( - lgr_kw, 0)); /* trailing zeros are stripped away. */ +static void rd_grid_set_lgr_name_GRID(rd_grid_type *lgr_grid, + const rd_file_type *rd_file, + int grid_nr) { + rd_kw_type *lgr_kw = rd_file_iget_named_kw(rd_file, LGR_KW, grid_nr - 1); + lgr_grid->name = (char *)util_alloc_strip_copy((const char *)rd_kw_iget_ptr( + lgr_kw, 0)); /* trailing zeros are stripped away. */ { /** the lgr keyword can have one or two elements; in the case of two elements the second element will be the name of the parent grid - in the case of only one element the current lgr is assumed to descend from the main grid */ - if (ecl_kw_get_size(lgr_kw) == 2) { + if (rd_kw_get_size(lgr_kw) == 2) { char *parent = (char *)util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(lgr_kw, 1)); + (const char *)rd_kw_iget_ptr(lgr_kw, 1)); if ((strlen(parent) == 0) || (strcmp(parent, GLOBAL_STRING) == 0)) free(parent); @@ -2198,7 +2186,7 @@ static void ecl_grid_set_lgr_name_GRID(ecl_grid_type *lgr_grid, the zcorn vector. */ -int ecl_grid_zcorn_index__(int nx, int ny, int i, int j, int k, int c) { +int rd_grid_zcorn_index__(int nx, int ny, int i, int j, int k, int c) { int zcorn_index = k * 8 * nx * ny + j * 4 * nx + 2 * i; if ((c % 2) == 1) zcorn_index += 1; @@ -2215,18 +2203,17 @@ int ecl_grid_zcorn_index__(int nx, int ny, int i, int j, int k, int c) { return zcorn_index; } -int ecl_grid_zcorn_index(const ecl_grid_type *grid, int i, int j, int k, - int c) { - return ecl_grid_zcorn_index__(grid->nx, grid->ny, i, j, k, c); +int rd_grid_zcorn_index(const rd_grid_type *grid, int i, int j, int k, int c) { + return rd_grid_zcorn_index__(grid->nx, grid->ny, i, j, k, c); } -static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type *ecl_grid, - const double *zcorn, - const double *coord, - const int *actnum, - const int *corsnum, int j) { - const int nx = ecl_grid->nx; - const int ny = ecl_grid->ny; - const int nz = ecl_grid->nz; +static void rd_grid_init_GRDECL_data_jslice(rd_grid_type *rd_grid, + const double *zcorn, + const double *coord, + const int *actnum, + const int *corsnum, int j) { + const int nx = rd_grid->nx; + const int ny = rd_grid->ny; + const int nz = rd_grid->nz; int i; for (i = 0; i < nx; i++) { @@ -2287,26 +2274,26 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type *ecl_grid, { int ip; for (ip = 0; ip < 4; ip++) - ecl_grid_pillar_cross_planes(&pillars[ip][0], ex[ip], - ey[ip], ez[ip], z[ip], - x[ip], y[ip]); + rd_grid_pillar_cross_planes(&pillars[ip][0], ex[ip], + ey[ip], ez[ip], z[ip], + x[ip], y[ip]); } - ecl_grid_set_cell_EGRID(ecl_grid, i, j, k, x, y, z, actnum, - corsnum); + rd_grid_set_cell_EGRID(rd_grid, i, j, k, x, y, z, actnum, + corsnum); } } } } -static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type *ecl_grid, - const float *zcorn, - const float *coord, - const int *actnum, - const int *corsnum, int j) { - const int nx = ecl_grid->nx; - const int ny = ecl_grid->ny; - const int nz = ecl_grid->nz; +static void rd_grid_init_GRDECL_data_jslice(rd_grid_type *rd_grid, + const float *zcorn, + const float *coord, + const int *actnum, + const int *corsnum, int j) { + const int nx = rd_grid->nx; + const int ny = rd_grid->ny; + const int nz = rd_grid->nz; int i; for (i = 0; i < nx; i++) { @@ -2367,38 +2354,38 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type *ecl_grid, { int ip; for (ip = 0; ip < 4; ip++) - ecl_grid_pillar_cross_planes(&pillars[ip][0], ex[ip], - ey[ip], ez[ip], z[ip], - x[ip], y[ip]); + rd_grid_pillar_cross_planes(&pillars[ip][0], ex[ip], + ey[ip], ez[ip], z[ip], + x[ip], y[ip]); } - ecl_grid_set_cell_EGRID(ecl_grid, i, j, k, x, y, z, actnum, - corsnum); + rd_grid_set_cell_EGRID(rd_grid, i, j, k, x, y, z, actnum, + corsnum); } } } } -void ecl_grid_init_GRDECL_data(ecl_grid_type *ecl_grid, const double *zcorn, - const double *coord, const int *actnum, - const int *corsnum) { - const int ny = ecl_grid->ny; +void rd_grid_init_GRDECL_data(rd_grid_type *rd_grid, const double *zcorn, + const double *coord, const int *actnum, + const int *corsnum) { + const int ny = rd_grid->ny; int j; #pragma omp parallel for for (j = 0; j < ny; j++) - ecl_grid_init_GRDECL_data_jslice(ecl_grid, zcorn, coord, actnum, - corsnum, j); + rd_grid_init_GRDECL_data_jslice(rd_grid, zcorn, coord, actnum, corsnum, + j); } -void ecl_grid_init_GRDECL_data(ecl_grid_type *ecl_grid, const float *zcorn, - const float *coord, const int *actnum, - const int *corsnum) { - const int ny = ecl_grid->ny; +void rd_grid_init_GRDECL_data(rd_grid_type *rd_grid, const float *zcorn, + const float *coord, const int *actnum, + const int *corsnum) { + const int ny = rd_grid->ny; int j; #pragma omp parallel for for (j = 0; j < ny; j++) - ecl_grid_init_GRDECL_data_jslice(ecl_grid, zcorn, coord, actnum, - corsnum, j); + rd_grid_init_GRDECL_data_jslice(rd_grid, zcorn, coord, actnum, corsnum, + j); } /* @@ -2407,65 +2394,65 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type *ecl_grid, const float *zcorn, 0---1 */ -static ecl_grid_type *ecl_grid_alloc_GRDECL_data__( - ecl_grid_type *global_grid, ert_ecl_unit_enum unit_system, int dualp_flag, +static rd_grid_type *rd_grid_alloc_GRDECL_data__( + rd_grid_type *global_grid, ert_rd_unit_enum unit_system, int dualp_flag, bool apply_mapaxes, int nx, int ny, int nz, const double *zcorn, const double *coord, const int *actnum, const float *mapaxes, const int *corsnum, int lgr_nr) { - ecl_grid_type *ecl_grid = ecl_grid_alloc_empty( + rd_grid_type *rd_grid = rd_grid_alloc_empty( global_grid, unit_system, dualp_flag, nx, ny, nz, lgr_nr, true); - if (ecl_grid) { + if (rd_grid) { if (mapaxes != NULL) - ecl_grid_init_mapaxes(ecl_grid, apply_mapaxes, mapaxes); + rd_grid_init_mapaxes(rd_grid, apply_mapaxes, mapaxes); if (corsnum != NULL) - ecl_grid->coarsening_active = true; + rd_grid->coarsening_active = true; - ecl_grid->coord_kw = - ecl_kw_alloc("COORD", 6 * (nx + 1) * (ny + 1), ECL_FLOAT); + rd_grid->coord_kw = + rd_kw_alloc("COORD", 6 * (nx + 1) * (ny + 1), RD_FLOAT); { - float *coord_float = (float *)ecl_kw_get_ptr(ecl_grid->coord_kw); - for (int i = 0; i < ecl_kw_get_size(ecl_grid->coord_kw); i++) + float *coord_float = (float *)rd_kw_get_ptr(rd_grid->coord_kw); + for (int i = 0; i < rd_kw_get_size(rd_grid->coord_kw); i++) coord_float[i] = coord[i]; } - ecl_grid_init_GRDECL_data(ecl_grid, zcorn, coord, actnum, corsnum); + rd_grid_init_GRDECL_data(rd_grid, zcorn, coord, actnum, corsnum); - ecl_grid_init_coarse_cells(ecl_grid); - ecl_grid_update_index(ecl_grid); - ecl_grid_taint_cells(ecl_grid); + rd_grid_init_coarse_cells(rd_grid); + rd_grid_update_index(rd_grid); + rd_grid_taint_cells(rd_grid); } - return ecl_grid; + return rd_grid; } -static ecl_grid_type *ecl_grid_alloc_GRDECL_data__( - ecl_grid_type *global_grid, ert_ecl_unit_enum unit_system, int dualp_flag, +static rd_grid_type *rd_grid_alloc_GRDECL_data__( + rd_grid_type *global_grid, ert_rd_unit_enum unit_system, int dualp_flag, bool apply_mapaxes, int nx, int ny, int nz, const float *zcorn, const float *coord, const int *actnum, const float *mapaxes, const int *corsnum, int lgr_nr) { - ecl_grid_type *ecl_grid = ecl_grid_alloc_empty( + rd_grid_type *rd_grid = rd_grid_alloc_empty( global_grid, unit_system, dualp_flag, nx, ny, nz, lgr_nr, true); - if (ecl_grid) { + if (rd_grid) { if (mapaxes != NULL) - ecl_grid_init_mapaxes(ecl_grid, apply_mapaxes, mapaxes); + rd_grid_init_mapaxes(rd_grid, apply_mapaxes, mapaxes); if (corsnum != NULL) - ecl_grid->coarsening_active = true; + rd_grid->coarsening_active = true; - ecl_grid->coord_kw = ecl_kw_alloc_new("COORD", 6 * (nx + 1) * (ny + 1), - ECL_FLOAT, coord); - ecl_grid_init_GRDECL_data(ecl_grid, zcorn, coord, actnum, corsnum); + rd_grid->coord_kw = + rd_kw_alloc_new("COORD", 6 * (nx + 1) * (ny + 1), RD_FLOAT, coord); + rd_grid_init_GRDECL_data(rd_grid, zcorn, coord, actnum, corsnum); - ecl_grid_init_coarse_cells(ecl_grid); - ecl_grid_update_index(ecl_grid); - ecl_grid_taint_cells(ecl_grid); + rd_grid_init_coarse_cells(rd_grid); + rd_grid_update_index(rd_grid); + rd_grid_taint_cells(rd_grid); } - return ecl_grid; + return rd_grid; } -static void ecl_grid_copy_mapaxes(ecl_grid_type *target_grid, - const ecl_grid_type *src_grid) { +static void rd_grid_copy_mapaxes(rd_grid_type *target_grid, + const rd_grid_type *src_grid) { target_grid->use_mapaxes = src_grid->use_mapaxes; if (src_grid->mapaxes) target_grid->mapaxes = @@ -2482,77 +2469,75 @@ static void ecl_grid_copy_mapaxes(ecl_grid_type *target_grid, } } -static void ecl_grid_copy_content(ecl_grid_type *target_grid, - const ecl_grid_type *src_grid) { +static void rd_grid_copy_content(rd_grid_type *target_grid, + const rd_grid_type *src_grid) { int global_index; for (global_index = 0; global_index < src_grid->size; global_index++) { - ecl_cell_type *target_cell = - ecl_grid_get_cell(target_grid, global_index); - const ecl_cell_type *src_cell = - ecl_grid_get_cell(src_grid, global_index); + rd_cell_type *target_cell = rd_grid_get_cell(target_grid, global_index); + const rd_cell_type *src_cell = rd_grid_get_cell(src_grid, global_index); - ecl_cell_memcpy(target_cell, src_cell); + rd_cell_memcpy(target_cell, src_cell); if (src_cell->nnc_info) target_cell->nnc_info = nnc_info_alloc_copy(src_cell->nnc_info); } - ecl_grid_copy_mapaxes(target_grid, src_grid); + rd_grid_copy_mapaxes(target_grid, src_grid); target_grid->parent_name = util_alloc_string_copy(src_grid->parent_name); target_grid->name = util_alloc_string_copy(src_grid->name); target_grid->coarsening_active = src_grid->coarsening_active; - ecl_grid_init_coarse_cells(target_grid); + rd_grid_init_coarse_cells(target_grid); } -static ecl_grid_type *ecl_grid_alloc_copy__(const ecl_grid_type *src_grid, - ecl_grid_type *main_grid) { - ecl_grid_type *copy_grid = ecl_grid_alloc_empty( +static rd_grid_type *rd_grid_alloc_copy__(const rd_grid_type *src_grid, + rd_grid_type *main_grid) { + rd_grid_type *copy_grid = rd_grid_alloc_empty( main_grid, src_grid->unit_system, src_grid->dualp_flag, - ecl_grid_get_nx(src_grid), ecl_grid_get_ny(src_grid), - ecl_grid_get_nz(src_grid), 0, false); + rd_grid_get_nx(src_grid), rd_grid_get_ny(src_grid), + rd_grid_get_nz(src_grid), 0, false); if (copy_grid) { - ecl_grid_copy_content( + rd_grid_copy_content( copy_grid, src_grid); // This will handle everything except LGR relationships which is established in the calling routine - ecl_grid_update_index(copy_grid); + rd_grid_update_index(copy_grid); } return copy_grid; } -ecl_grid_type *ecl_grid_alloc_copy(const ecl_grid_type *src_grid) { - ecl_grid_type *copy_grid = ecl_grid_alloc_copy__(src_grid, NULL); +rd_grid_type *rd_grid_alloc_copy(const rd_grid_type *src_grid) { + rd_grid_type *copy_grid = rd_grid_alloc_copy__(src_grid, NULL); { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size(src_grid->LGR_list); grid_nr++) { - const ecl_grid_type *src_lgr = - (const ecl_grid_type *)vector_iget_const(src_grid->LGR_list, - grid_nr); - ecl_grid_type *copy_lgr = ecl_grid_alloc_copy__(src_lgr, copy_grid); - ecl_grid_type *host_grid; + const rd_grid_type *src_lgr = + (const rd_grid_type *)vector_iget_const(src_grid->LGR_list, + grid_nr); + rd_grid_type *copy_lgr = rd_grid_alloc_copy__(src_lgr, copy_grid); + rd_grid_type *host_grid; - ecl_grid_add_lgr( + rd_grid_add_lgr( copy_grid, copy_lgr); // This handles the storage ownership of the LGR. if (copy_lgr->parent_name == NULL) host_grid = copy_grid; else - host_grid = ecl_grid_get_lgr(copy_grid, copy_lgr->parent_name); + host_grid = rd_grid_get_lgr(copy_grid, copy_lgr->parent_name); { int global_lgr_index; for (global_lgr_index = 0; global_lgr_index < copy_lgr->size; global_lgr_index++) { - ecl_cell_type *lgr_cell = - ecl_grid_get_cell(copy_lgr, global_lgr_index); - ecl_cell_type *host_cell = - ecl_grid_get_cell(host_grid, lgr_cell->host_cell); + rd_cell_type *lgr_cell = + rd_grid_get_cell(copy_lgr, global_lgr_index); + rd_cell_type *host_cell = + rd_grid_get_cell(host_grid, lgr_cell->host_cell); - ecl_cell_install_lgr(host_cell, copy_lgr); + rd_cell_install_lgr(host_cell, copy_lgr); } - ecl_grid_install_lgr_common(host_grid, copy_lgr); + rd_grid_install_lgr_common(host_grid, copy_lgr); } } } @@ -2563,34 +2548,33 @@ ecl_grid_type *ecl_grid_alloc_copy(const ecl_grid_type *src_grid) { /* Does not handle LGR */ -ecl_grid_type *ecl_grid_alloc_processed_copy(const ecl_grid_type *src_grid, - const double *zcorn, - const int *actnum) { - ecl_grid_type *grid; +rd_grid_type *rd_grid_alloc_processed_copy(const rd_grid_type *src_grid, + const double *zcorn, + const int *actnum) { + rd_grid_type *grid; if (zcorn == NULL) { - grid = ecl_grid_alloc_copy__(src_grid, NULL); + grid = rd_grid_alloc_copy__(src_grid, NULL); if (actnum) - ecl_grid_reset_actnum(grid, actnum); + rd_grid_reset_actnum(grid, actnum); } else { int nx, ny, nz, na; - int zcorn_size = ecl_grid_get_zcorn_size(src_grid); + int zcorn_size = rd_grid_get_zcorn_size(src_grid); float *zcorn_float = (float *)util_malloc(zcorn_size * sizeof *zcorn_float); - float *coord = ecl_grid_alloc_coord_data(src_grid); + float *coord = rd_grid_alloc_coord_data(src_grid); float *mapaxes = NULL; - if (ecl_grid_get_mapaxes(src_grid)) { + if (rd_grid_get_mapaxes(src_grid)) { mapaxes = (float *)util_malloc(6 * sizeof *mapaxes); - ecl_grid_init_mapaxes_data_float(src_grid, mapaxes); + rd_grid_init_mapaxes_data_float(src_grid, mapaxes); } - ecl_grid_get_dims(src_grid, &nx, &ny, &nz, &na); + rd_grid_get_dims(src_grid, &nx, &ny, &nz, &na); for (int i = 0; i < zcorn_size; i++) zcorn_float[i] = zcorn[i]; - grid = - ecl_grid_alloc_GRDECL_data(nx, ny, nz, zcorn_float, coord, actnum, - src_grid->use_mapaxes, mapaxes); + grid = rd_grid_alloc_GRDECL_data(nx, ny, nz, zcorn_float, coord, actnum, + src_grid->use_mapaxes, mapaxes); free(mapaxes); free(coord); @@ -2607,35 +2591,34 @@ ecl_grid_type *ecl_grid_alloc_processed_copy(const ecl_grid_type *src_grid, a lgr hierarchy - or cell coarsening. */ -ecl_grid_type *ecl_grid_alloc_GRDECL_data(int nx, int ny, int nz, - const float *zcorn, - const float *coord, const int *actnum, - bool apply_mapaxes, - const float *mapaxes) { +rd_grid_type *rd_grid_alloc_GRDECL_data(int nx, int ny, int nz, + const float *zcorn, const float *coord, + const int *actnum, bool apply_mapaxes, + const float *mapaxes) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - return ecl_grid_alloc_GRDECL_data__( + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + return rd_grid_alloc_GRDECL_data__( NULL, unit_system, FILEHEAD_SINGLE_POROSITY, apply_mapaxes, nx, ny, nz, zcorn, coord, actnum, mapaxes, NULL, 0); } -namespace ecl { +namespace rd { -ecl_grid_type *ecl_grid_alloc_GRDECL_data(int nx, int ny, int nz, - const double *zcorn, - const double *coord, - const int *actnum, bool apply_mapaxes, - const float *mapaxes) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - return ecl_grid_alloc_GRDECL_data__( +rd_grid_type *rd_grid_alloc_GRDECL_data(int nx, int ny, int nz, + const double *zcorn, + const double *coord, const int *actnum, + bool apply_mapaxes, + const float *mapaxes) { + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + return rd_grid_alloc_GRDECL_data__( NULL, unit_system, FILEHEAD_SINGLE_POROSITY, apply_mapaxes, nx, ny, nz, zcorn, coord, actnum, mapaxes, NULL, 0); } -} // namespace ecl +} // namespace rd -const float *ecl_grid_get_mapaxes_from_kw__(const ecl_kw_type *mapaxes_kw) { - const float *mapaxes_data = ecl_kw_get_float_ptr(mapaxes_kw); +const float *rd_grid_get_mapaxes_from_kw__(const rd_kw_type *mapaxes_kw) { + const float *mapaxes_data = rd_kw_get_float_ptr(mapaxes_kw); float x1 = mapaxes_data[2]; float y1 = mapaxes_data[3]; @@ -2651,27 +2634,25 @@ const float *ecl_grid_get_mapaxes_from_kw__(const ecl_kw_type *mapaxes_kw) { return mapaxes_data; } -static ecl_grid_type * -ecl_grid_alloc_GRDECL_kw__(ecl_grid_type *global_grid, int dualp_flag, - bool apply_mapaxes, const ecl_kw_type *gridhead_kw, - const ecl_kw_type *zcorn_kw, - const ecl_kw_type *coord_kw, - const ecl_kw_type *gridunit_kw, /* Can be NULL */ - const ecl_kw_type *mapaxes_kw, /* Can be NULL */ - const ecl_kw_type *corsnum_kw, /* Can be NULL */ - const int *actnum_data) { /* Can be NULL */ +static rd_grid_type *rd_grid_alloc_GRDECL_kw__( + rd_grid_type *global_grid, int dualp_flag, bool apply_mapaxes, + const rd_kw_type *gridhead_kw, const rd_kw_type *zcorn_kw, + const rd_kw_type *coord_kw, const rd_kw_type *gridunit_kw, /* Can be NULL */ + const rd_kw_type *mapaxes_kw, /* Can be NULL */ + const rd_kw_type *corsnum_kw, /* Can be NULL */ + const int *actnum_data) { /* Can be NULL */ int gtype, nx, ny, nz, lgr_nr; - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - gtype = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_TYPE_INDEX); - nx = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NX_INDEX); - ny = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NY_INDEX); - nz = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NZ_INDEX); - lgr_nr = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_LGR_INDEX); + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + gtype = rd_kw_iget_int(gridhead_kw, GRIDHEAD_TYPE_INDEX); + nx = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NX_INDEX); + ny = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NY_INDEX); + nz = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NZ_INDEX); + lgr_nr = rd_kw_iget_int(gridhead_kw, GRIDHEAD_LGR_INDEX); /* The code used to have this test: - if (grid_nr != ecl_kw_iget_int( gridhead_kw , GRIDHEAD_LGR_INDEX)) + if (grid_nr != rd_kw_iget_int( gridhead_kw , GRIDHEAD_LGR_INDEX)) util_abort("%s: internal error in grid loader - lgr index mismatch\n",__func__); But then suddenly a EGRID file where this did not apply appeared :-( @@ -2687,62 +2668,62 @@ ecl_grid_alloc_GRDECL_kw__(ecl_grid_type *global_grid, int dualp_flag, const int *corsnum_data = NULL; if (mapaxes_kw) - mapaxes_data = ecl_grid_get_mapaxes_from_kw__(mapaxes_kw); + mapaxes_data = rd_grid_get_mapaxes_from_kw__(mapaxes_kw); if (corsnum_kw) - corsnum_data = ecl_kw_get_int_ptr(corsnum_kw); + corsnum_data = rd_kw_get_int_ptr(corsnum_kw); if (gridunit_kw) - unit_system = ecl_grid_check_unit_system(gridunit_kw); + unit_system = rd_grid_check_unit_system(gridunit_kw); - return ecl_grid_alloc_GRDECL_data__( + return rd_grid_alloc_GRDECL_data__( global_grid, unit_system, dualp_flag, apply_mapaxes, nx, ny, nz, - ecl_kw_get_float_ptr(zcorn_kw), ecl_kw_get_float_ptr(coord_kw), + rd_kw_get_float_ptr(zcorn_kw), rd_kw_get_float_ptr(coord_kw), actnum_data, mapaxes_data, corsnum_data, lgr_nr); } } /** - If you create/load ecl_kw instances for the various fields, this + If you create/load rd_kw instances for the various fields, this function can be used to create a GRID instance, without going through a GRID/EGRID file. Does not support LGR or coarsening hierarchies. */ -ecl_grid_type * -ecl_grid_alloc_GRDECL_kw(int nx, int ny, int nz, const ecl_kw_type *zcorn_kw, - const ecl_kw_type *coord_kw, - const ecl_kw_type *actnum_kw, /* Can be NULL */ - const ecl_kw_type *mapaxes_kw) { /* Can be NULL */ +rd_grid_type * +rd_grid_alloc_GRDECL_kw(int nx, int ny, int nz, const rd_kw_type *zcorn_kw, + const rd_kw_type *coord_kw, + const rd_kw_type *actnum_kw, /* Can be NULL */ + const rd_kw_type *mapaxes_kw) { /* Can be NULL */ const int *actnum_data = NULL; if (actnum_kw) - actnum_data = ecl_kw_get_int_ptr(actnum_kw); + actnum_data = rd_kw_get_int_ptr(actnum_kw); bool apply_mapaxes = true; - ecl_kw_type *gridhead_kw = ecl_grid_alloc_gridhead_kw(nx, ny, nz, 0); - ecl_kw_type *gridunit_kw = NULL; - ecl_grid_type *ecl_grid = ecl_grid_alloc_GRDECL_kw__( + rd_kw_type *gridhead_kw = rd_grid_alloc_gridhead_kw(nx, ny, nz, 0); + rd_kw_type *gridunit_kw = NULL; + rd_grid_type *rd_grid = rd_grid_alloc_GRDECL_kw__( NULL, FILEHEAD_SINGLE_POROSITY, apply_mapaxes, gridhead_kw, zcorn_kw, coord_kw, gridunit_kw, mapaxes_kw, NULL, actnum_data); - ecl_kw_free(gridhead_kw); - return ecl_grid; + rd_kw_free(gridhead_kw); + return rd_grid; } -static void ecl_grid_init_cell_nnc_info(ecl_grid_type *ecl_grid, - int global_index) { - ecl_cell_type *grid_cell = ecl_grid_get_cell(ecl_grid, global_index); +static void rd_grid_init_cell_nnc_info(rd_grid_type *rd_grid, + int global_index) { + rd_cell_type *grid_cell = rd_grid_get_cell(rd_grid, global_index); if (!grid_cell->nnc_info) - grid_cell->nnc_info = nnc_info_alloc(ecl_grid->lgr_nr); + grid_cell->nnc_info = nnc_info_alloc(rd_grid->lgr_nr); } /* - The function ecl_grid_add_self_nnc() will add a NNC connection + The function rd_grid_add_self_nnc() will add a NNC connection between two cells in the same grid. Observe that there are two peculiarities with this implementation: - 1. In the ecl_grid structure the nnc information is distributed + 1. In the rd_grid structure the nnc information is distributed among the cells. The main purpose of adding the nnc information like this is to include the NNC information in the EGRID files when writing to disk. Before being written to disk the NNC @@ -2758,32 +2739,32 @@ static void ecl_grid_init_cell_nnc_info(ecl_grid_type *ecl_grid, 2. To get valid NNC information to load in e.g. Resinsight the corresponding TRANNNC keyword must be added to the INIT file, - i.e. the calling scope must create a ecl_kw with + i.e. the calling scope must create a rd_kw with transmissibility values in parallell with adding NNC information to the grid: fortio_type * init_file = fortio_open_writer( "CASE.INIT" , ... - ecl_grid_type * grid ... - ecl_kw_type * trannnc_kw = ecl_kw_alloc( "TRANNNC" , num_nnc , ECL_FLOAT_TYPE ); + rd_grid_type * grid ... + rd_kw_type * trannnc_kw = rd_kw_alloc( "TRANNNC" , num_nnc , RD_FLOAT_TYPE ); for (int i = 0; i < num_nnc; i++) { int g1 = ... int g2 = .. float T = .. - ecl_grid_add_self_nnc( grid , g1 , g2 , i ); - ecl_kw_iset( trannnc_kw , i , T ); + rd_grid_add_self_nnc( grid , g1 , g2 , i ); + rd_kw_iset( trannnc_kw , i , T ); } ... - ecl_grid_fwrite_EGRID( grid , ... ); - ecl_kw_fwrite( trannnc_kw , init_file ); + rd_grid_fwrite_EGRID( grid , ... ); + rd_kw_fwrite( trannnc_kw , init_file ); */ -void ecl_grid_add_self_nnc(ecl_grid_type *grid, int cell_index1, - int cell_index2, int nnc_index) { - ecl_cell_type *grid_cell = ecl_grid_get_cell(grid, cell_index1); - ecl_grid_init_cell_nnc_info(grid, cell_index1); +void rd_grid_add_self_nnc(rd_grid_type *grid, int cell_index1, int cell_index2, + int nnc_index) { + rd_cell_type *grid_cell = rd_grid_get_cell(grid, cell_index1); + rd_grid_init_cell_nnc_info(grid, cell_index1); nnc_info_add_nnc(grid_cell->nnc_info, grid->lgr_nr, cell_index2, nnc_index); } @@ -2793,11 +2774,11 @@ void ecl_grid_add_self_nnc(ecl_grid_type *grid, int cell_index1, consecutively running nnc_index = [0,num_nnc). */ -void ecl_grid_add_self_nnc_list(ecl_grid_type *grid, const int *g1_list, - const int *g2_list, int num_nnc) { +void rd_grid_add_self_nnc_list(rd_grid_type *grid, const int *g1_list, + const int *g2_list, int num_nnc) { int i; for (i = 0; i < num_nnc; i++) - ecl_grid_add_self_nnc(grid, g1_list[i], g2_list[i], i); + rd_grid_add_self_nnc(grid, g1_list[i], g2_list[i], i); } /* @@ -2814,13 +2795,13 @@ void ecl_grid_add_self_nnc_list(ecl_grid_type *grid, const int *g1_list, NNA1 -> NNA2 For links between different LGRs */ -static void ecl_grid_init_nnc_cells(ecl_grid_type *grid1, ecl_grid_type *grid2, - const ecl_kw_type *keyword1, - const ecl_kw_type *keyword2) { +static void rd_grid_init_nnc_cells(rd_grid_type *grid1, rd_grid_type *grid2, + const rd_kw_type *keyword1, + const rd_kw_type *keyword2) { - int *grid1_nnc_cells = ecl_kw_get_int_ptr(keyword1); - int *grid2_nnc_cells = ecl_kw_get_int_ptr(keyword2); - int nnc_count = ecl_kw_get_size(keyword2); + int *grid1_nnc_cells = rd_kw_get_int_ptr(keyword1); + int *grid2_nnc_cells = rd_kw_get_int_ptr(keyword2); + int nnc_count = rd_kw_get_size(keyword2); int nnc_index; for (nnc_index = 0; nnc_index < nnc_count; nnc_index++) { @@ -2846,9 +2827,9 @@ static void ecl_grid_init_nnc_cells(ecl_grid_type *grid1, ecl_grid_type *grid2, break; { - ecl_cell_type *grid1_cell = - ecl_grid_get_cell(grid1, grid1_cell_index); - ecl_grid_init_cell_nnc_info(grid1, grid1_cell_index); + rd_cell_type *grid1_cell = + rd_grid_get_cell(grid1, grid1_cell_index); + rd_grid_init_cell_nnc_info(grid1, grid1_cell_index); nnc_info_add_nnc(grid1_cell->nnc_info, grid2->lgr_nr, grid2_cell_index, nnc_index); } @@ -2858,9 +2839,8 @@ static void ecl_grid_init_nnc_cells(ecl_grid_type *grid1, ecl_grid_type *grid2, /* This function reads the non-neighbour connection data from file and initializes the grid structure with the the nnc data */ -static void ecl_grid_init_nnc(ecl_grid_type *main_grid, - ecl_file_type *ecl_file) { - int num_nnchead_kw = ecl_file_get_num_named_kw(ecl_file, NNCHEAD_KW); +static void rd_grid_init_nnc(rd_grid_type *main_grid, rd_file_type *rd_file) { + int num_nnchead_kw = rd_file_get_num_named_kw(rd_file, NNCHEAD_KW); int i; /* @@ -2875,42 +2855,42 @@ static void ecl_grid_init_nnc(ecl_grid_type *main_grid, */ for (i = 0; i < num_nnchead_kw; i++) { - ecl_file_view_type *lgr_view = - ecl_file_alloc_global_blockview(ecl_file, NNCHEAD_KW, i); - ecl_kw_type *nnchead_kw = - ecl_file_view_iget_named_kw(lgr_view, NNCHEAD_KW, 0); - int lgr_nr = ecl_kw_iget_int(nnchead_kw, NNCHEAD_LGR_INDEX); - - if (ecl_file_view_has_kw(lgr_view, NNC1_KW)) { - const ecl_kw_type *nnc1 = - ecl_file_view_iget_named_kw(lgr_view, NNC1_KW, 0); - const ecl_kw_type *nnc2 = - ecl_file_view_iget_named_kw(lgr_view, NNC2_KW, 0); + rd_file_view_type *lgr_view = + rd_file_alloc_global_blockview(rd_file, NNCHEAD_KW, i); + rd_kw_type *nnchead_kw = + rd_file_view_iget_named_kw(lgr_view, NNCHEAD_KW, 0); + int lgr_nr = rd_kw_iget_int(nnchead_kw, NNCHEAD_LGR_INDEX); + + if (rd_file_view_has_kw(lgr_view, NNC1_KW)) { + const rd_kw_type *nnc1 = + rd_file_view_iget_named_kw(lgr_view, NNC1_KW, 0); + const rd_kw_type *nnc2 = + rd_file_view_iget_named_kw(lgr_view, NNC2_KW, 0); { - ecl_grid_type *grid = + rd_grid_type *grid = (lgr_nr > 0) - ? ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr) + ? rd_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr) : main_grid; - ecl_grid_init_nnc_cells(grid, grid, nnc1, nnc2); + rd_grid_init_nnc_cells(grid, grid, nnc1, nnc2); } } - if (ecl_file_view_has_kw(lgr_view, NNCL_KW)) { - const ecl_kw_type *nncl = - ecl_file_view_iget_named_kw(lgr_view, NNCL_KW, 0); - const ecl_kw_type *nncg = - ecl_file_view_iget_named_kw(lgr_view, NNCG_KW, 0); + if (rd_file_view_has_kw(lgr_view, NNCL_KW)) { + const rd_kw_type *nncl = + rd_file_view_iget_named_kw(lgr_view, NNCL_KW, 0); + const rd_kw_type *nncg = + rd_file_view_iget_named_kw(lgr_view, NNCG_KW, 0); { - ecl_grid_type *grid = + rd_grid_type *grid = (lgr_nr > 0) - ? ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr) + ? rd_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr) : main_grid; - ecl_grid_init_nnc_cells(main_grid, grid, nncg, nncl); + rd_grid_init_nnc_cells(main_grid, grid, nncg, nncl); } } - ecl_file_view_free(lgr_view); + rd_file_view_free(lgr_view); } } @@ -2919,26 +2899,26 @@ static void ecl_grid_init_nnc(ecl_grid_type *main_grid, amalgamated LGRs (that is, non-neighbour connections between two LGRs) and initializes the grid structure with the nnc data. */ -static void ecl_grid_init_nnc_amalgamated(ecl_grid_type *main_grid, - ecl_file_type *ecl_file) { - int num_nncheada_kw = ecl_file_get_num_named_kw(ecl_file, NNCHEADA_KW); +static void rd_grid_init_nnc_amalgamated(rd_grid_type *main_grid, + rd_file_type *rd_file) { + int num_nncheada_kw = rd_file_get_num_named_kw(rd_file, NNCHEADA_KW); int i; for (i = 0; i < num_nncheada_kw; i++) { - ecl_kw_type *nncheada_kw = - ecl_file_iget_named_kw(ecl_file, NNCHEADA_KW, i); - int lgr_nr1 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX); - int lgr_nr2 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX); + rd_kw_type *nncheada_kw = + rd_file_iget_named_kw(rd_file, NNCHEADA_KW, i); + int lgr_nr1 = rd_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX); + int lgr_nr2 = rd_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX); - ecl_grid_type *lgr_grid1 = - ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr1); - ecl_grid_type *lgr_grid2 = - ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr2); + rd_grid_type *lgr_grid1 = + rd_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr1); + rd_grid_type *lgr_grid2 = + rd_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr2); - ecl_kw_type *nna1_kw = ecl_file_iget_named_kw(ecl_file, NNA1_KW, i); - ecl_kw_type *nna2_kw = ecl_file_iget_named_kw(ecl_file, NNA2_KW, i); + rd_kw_type *nna1_kw = rd_file_iget_named_kw(rd_file, NNA1_KW, i); + rd_kw_type *nna2_kw = rd_file_iget_named_kw(rd_file, NNA2_KW, i); - ecl_grid_init_nnc_cells(lgr_grid1, lgr_grid2, nna1_kw, nna2_kw); + rd_grid_init_nnc_cells(lgr_grid1, lgr_grid2, nna1_kw, nna2_kw); } } @@ -2952,29 +2932,29 @@ static void ecl_grid_init_nnc_amalgamated(ecl_grid_type *main_grid, The point is that external scope can create grid based on both a list of keywords, and actual data - in addition to the normal loading of a full file. Currently the 'shortcuts' - ecl_grid_alloc_grdecl_kw() and ecl_grid_alloc_grdecl_data() do not + rd_grid_alloc_grdecl_kw() and rd_grid_alloc_grdecl_data() do not support LGRs. */ -static ecl_grid_type *ecl_grid_alloc_EGRID__(ecl_grid_type *main_grid, - const ecl_file_type *ecl_file, - int grid_nr, bool apply_mapaxes, - const int *ext_actnum) { - ecl_kw_type *gridhead_kw = - ecl_file_iget_named_kw(ecl_file, GRIDHEAD_KW, grid_nr); - ecl_kw_type *zcorn_kw = ecl_file_iget_named_kw(ecl_file, ZCORN_KW, grid_nr); - ecl_kw_type *coord_kw = ecl_file_iget_named_kw(ecl_file, COORD_KW, grid_nr); - ecl_kw_type *corsnum_kw = NULL; - ecl_kw_type *actnum_kw = NULL; - ecl_kw_type *gridunit_kw = NULL; - ecl_kw_type *mapaxes_kw = NULL; +static rd_grid_type *rd_grid_alloc_EGRID__(rd_grid_type *main_grid, + const rd_file_type *rd_file, + int grid_nr, bool apply_mapaxes, + const int *ext_actnum) { + rd_kw_type *gridhead_kw = + rd_file_iget_named_kw(rd_file, GRIDHEAD_KW, grid_nr); + rd_kw_type *zcorn_kw = rd_file_iget_named_kw(rd_file, ZCORN_KW, grid_nr); + rd_kw_type *coord_kw = rd_file_iget_named_kw(rd_file, COORD_KW, grid_nr); + rd_kw_type *corsnum_kw = NULL; + rd_kw_type *actnum_kw = NULL; + rd_kw_type *gridunit_kw = NULL; + rd_kw_type *mapaxes_kw = NULL; int dualp_flag; int eclipse_version; if (grid_nr == 0) { - ecl_kw_type *filehead_kw = - ecl_file_iget_named_kw(ecl_file, FILEHEAD_KW, grid_nr); - dualp_flag = ecl_kw_iget_int(filehead_kw, FILEHEAD_DUALP_INDEX); - eclipse_version = ecl_kw_iget_int(filehead_kw, FILEHEAD_YEAR_INDEX); + rd_kw_type *filehead_kw = + rd_file_iget_named_kw(rd_file, FILEHEAD_KW, grid_nr); + dualp_flag = rd_kw_iget_int(filehead_kw, FILEHEAD_DUALP_INDEX); + eclipse_version = rd_kw_iget_int(filehead_kw, FILEHEAD_YEAR_INDEX); } else { dualp_flag = main_grid->dualp_flag; eclipse_version = main_grid->eclipse_version; @@ -2988,116 +2968,116 @@ static ecl_grid_type *ecl_grid_alloc_EGRID__(ecl_grid_type *main_grid, if (ext_actnum) actnum_data = ext_actnum; else { - if (ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW) > grid_nr) { - actnum_kw = ecl_file_iget_named_kw(ecl_file, ACTNUM_KW, grid_nr); - actnum_data = ecl_kw_get_int_ptr(actnum_kw); + if (rd_file_get_num_named_kw(rd_file, ACTNUM_KW) > grid_nr) { + actnum_kw = rd_file_iget_named_kw(rd_file, ACTNUM_KW, grid_nr); + actnum_data = rd_kw_get_int_ptr(actnum_kw); } } if (grid_nr == 0) { /* MAPAXES and COARSENING only apply to the global grid. */ - if (ecl_file_has_kw(ecl_file, MAPAXES_KW)) - mapaxes_kw = ecl_file_iget_named_kw(ecl_file, MAPAXES_KW, 0); + if (rd_file_has_kw(rd_file, MAPAXES_KW)) + mapaxes_kw = rd_file_iget_named_kw(rd_file, MAPAXES_KW, 0); - if (ecl_file_has_kw(ecl_file, CORSNUM_KW)) - corsnum_kw = ecl_file_iget_named_kw(ecl_file, CORSNUM_KW, 0); + if (rd_file_has_kw(rd_file, CORSNUM_KW)) + corsnum_kw = rd_file_iget_named_kw(rd_file, CORSNUM_KW, 0); - if (ecl_file_has_kw(ecl_file, GRIDUNIT_KW)) - gridunit_kw = ecl_file_iget_named_kw(ecl_file, GRIDUNIT_KW, 0); + if (rd_file_has_kw(rd_file, GRIDUNIT_KW)) + gridunit_kw = rd_file_iget_named_kw(rd_file, GRIDUNIT_KW, 0); } { - ecl_grid_type *ecl_grid = ecl_grid_alloc_GRDECL_kw__( + rd_grid_type *rd_grid = rd_grid_alloc_GRDECL_kw__( main_grid, dualp_flag, apply_mapaxes, gridhead_kw, zcorn_kw, coord_kw, gridunit_kw, mapaxes_kw, corsnum_kw, actnum_data); - if (ECL_GRID_MAINGRID_LGR_NR != grid_nr) - ecl_grid_set_lgr_name_EGRID(ecl_grid, ecl_file, grid_nr); - ecl_grid->eclipse_version = eclipse_version; - return ecl_grid; + if (RD_GRID_MAINGRID_LGR_NR != grid_nr) + rd_grid_set_lgr_name_EGRID(rd_grid, rd_file, grid_nr); + rd_grid->eclipse_version = eclipse_version; + return rd_grid; } } -static ecl_grid_type *ecl_grid_alloc_GRID_all_grids(const char *filename) { +static rd_grid_type *rd_grid_alloc_GRID_all_grids(const char *filename) { util_abort("%s .GRID files - %s - not supported \n", __func__, filename); return NULL; } -static ecl_grid_type *ecl_grid_alloc_EGRID_all_grids(const char *grid_file, - bool apply_mapaxes, - const int *ext_actnum) { - ecl_file_enum file_type; - file_type = ecl_util_get_file_type(grid_file, NULL, NULL); - if (file_type != ECL_EGRID_FILE) +static rd_grid_type *rd_grid_alloc_EGRID_all_grids(const char *grid_file, + bool apply_mapaxes, + const int *ext_actnum) { + rd_file_enum file_type; + file_type = rd_get_file_type(grid_file, NULL, NULL); + if (file_type != RD_EGRID_FILE) util_abort( "%s: %s wrong file type - expected .EGRID file - aborting \n", __func__, grid_file); { - ecl_file_type *ecl_file = ecl_file_open(grid_file, 0); - if (ecl_file) { - int num_grid = ecl_file_get_num_named_kw(ecl_file, GRIDHEAD_KW); - ecl_grid_type *main_grid = ecl_grid_alloc_EGRID__( - NULL, ecl_file, 0, apply_mapaxes, ext_actnum); + rd_file_type *rd_file = rd_file_open(grid_file, 0); + if (rd_file) { + int num_grid = rd_file_get_num_named_kw(rd_file, GRIDHEAD_KW); + rd_grid_type *main_grid = rd_grid_alloc_EGRID__( + NULL, rd_file, 0, apply_mapaxes, ext_actnum); int grid_nr; for (grid_nr = 1; grid_nr < num_grid; grid_nr++) { // The apply_mapaxes argument is ignored for LGR - // it inherits from parent anyway. - ecl_grid_type *lgr_grid = ecl_grid_alloc_EGRID__( - main_grid, ecl_file, grid_nr, false, NULL); - ecl_grid_add_lgr(main_grid, lgr_grid); + rd_grid_type *lgr_grid = rd_grid_alloc_EGRID__( + main_grid, rd_file, grid_nr, false, NULL); + rd_grid_add_lgr(main_grid, lgr_grid); { - ecl_grid_type *host_grid; - ecl_kw_type *hostnum_kw = ecl_file_iget_named_kw( - ecl_file, HOSTNUM_KW, grid_nr - 1); + rd_grid_type *host_grid; + rd_kw_type *hostnum_kw = + rd_file_iget_named_kw(rd_file, HOSTNUM_KW, grid_nr - 1); if (lgr_grid->parent_name == NULL) host_grid = main_grid; else host_grid = - ecl_grid_get_lgr(main_grid, lgr_grid->parent_name); + rd_grid_get_lgr(main_grid, lgr_grid->parent_name); - ecl_grid_install_lgr_EGRID(host_grid, lgr_grid, - ecl_kw_get_int_ptr(hostnum_kw)); + rd_grid_install_lgr_EGRID(host_grid, lgr_grid, + rd_kw_get_int_ptr(hostnum_kw)); } } main_grid->name = util_alloc_string_copy(grid_file); - ecl_grid_init_nnc(main_grid, ecl_file); - ecl_grid_init_nnc_amalgamated(main_grid, ecl_file); + rd_grid_init_nnc(main_grid, rd_file); + rd_grid_init_nnc_amalgamated(main_grid, rd_file); - ecl_file_close(ecl_file); + rd_file_close(rd_file); return main_grid; } else return NULL; } } -ecl_grid_type *ecl_grid_alloc_EGRID(const char *grid_file, bool apply_mapaxes) { - return ecl_grid_alloc_EGRID_all_grids(grid_file, apply_mapaxes, NULL); +rd_grid_type *rd_grid_alloc_EGRID(const char *grid_file, bool apply_mapaxes) { + return rd_grid_alloc_EGRID_all_grids(grid_file, apply_mapaxes, NULL); } -static ecl_grid_type *ecl_grid_alloc_GRID_data__( - ecl_grid_type *global_grid, int num_coords, ert_ecl_unit_enum unit_system, +static rd_grid_type *rd_grid_alloc_GRID_data__( + rd_grid_type *global_grid, int num_coords, ert_rd_unit_enum unit_system, int dualp_flag, bool apply_mapaxes, int nx, int ny, int nz, int grid_nr, int coords_size, int **coords, float **corners, const float *mapaxes) { if (dualp_flag != FILEHEAD_SINGLE_POROSITY) nz = nz / 2; { - ecl_grid_type *grid = ecl_grid_alloc_empty( + rd_grid_type *grid = rd_grid_alloc_empty( global_grid, unit_system, dualp_flag, nx, ny, nz, grid_nr, false); if (grid) { if (mapaxes != NULL) - ecl_grid_init_mapaxes(grid, apply_mapaxes, mapaxes); + rd_grid_init_mapaxes(grid, apply_mapaxes, mapaxes); { int index; for (index = 0; index < num_coords; index++) - ecl_grid_set_cell_GRID(grid, coords_size, coords[index], - corners[index]); + rd_grid_set_cell_GRID(grid, coords_size, coords[index], + corners[index]); } - ecl_grid_init_coarse_cells(grid); - ecl_grid_update_index(grid); - ecl_grid_taint_cells(grid); + rd_grid_init_coarse_cells(grid); + rd_grid_update_index(grid); + rd_grid_taint_cells(grid); } return grid; } @@ -3108,33 +3088,33 @@ static ecl_grid_type *ecl_grid_alloc_GRID_data__( corners[num_coords][24] */ -ecl_grid_type *ecl_grid_alloc_GRID_data(int num_coords, int nx, int ny, int nz, - int coords_size, int **coords, - float **corners, bool apply_mapaxes, - const float *mapaxes) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - return ecl_grid_alloc_GRID_data__( +rd_grid_type *rd_grid_alloc_GRID_data(int num_coords, int nx, int ny, int nz, + int coords_size, int **coords, + float **corners, bool apply_mapaxes, + const float *mapaxes) { + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + return rd_grid_alloc_GRID_data__( NULL, num_coords, unit_system, FILEHEAD_SINGLE_POROSITY, /* Does currently not support to determine dualp_flag from inspection. */ apply_mapaxes, nx, ny, nz, 0, coords_size, coords, corners, mapaxes); } -static int ecl_grid_dual_porosity_GRID_check(ecl_file_type *ecl_file) { - ecl_kw_type *dimens_kw = ecl_file_iget_named_kw(ecl_file, DIMENS_KW, 0); - int nx = ecl_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); - int ny = ecl_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); - int nz = ecl_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); +static int rd_grid_dual_porosity_GRID_check(rd_file_type *rd_file) { + rd_kw_type *dimens_kw = rd_file_iget_named_kw(rd_file, DIMENS_KW, 0); + int nx = rd_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); + int ny = rd_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); + int nz = rd_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); if ((nz % 2) == 1) return FILEHEAD_SINGLE_POROSITY; else { int dualp_flag = FILEHEAD_DUAL_POROSITY; - int num_corners = ecl_file_get_num_named_kw(ecl_file, CORNERS_KW); + int num_corners = rd_file_get_num_named_kw(rd_file, CORNERS_KW); int matrix_index = 0; int fracture_index; - ecl_kw_type *matrix_kw; - ecl_kw_type *fracture_kw; + rd_kw_type *matrix_kw; + rd_kw_type *fracture_kw; if (num_corners > nx * ny * nz) fracture_index = nx * ny * nz / 2; @@ -3143,11 +3123,11 @@ static int ecl_grid_dual_porosity_GRID_check(ecl_file_type *ecl_file) { while (true) { matrix_kw = - ecl_file_iget_named_kw(ecl_file, CORNERS_KW, matrix_index); + rd_file_iget_named_kw(rd_file, CORNERS_KW, matrix_index); fracture_kw = - ecl_file_iget_named_kw(ecl_file, CORNERS_KW, fracture_index); + rd_file_iget_named_kw(rd_file, CORNERS_KW, fracture_index); - if (!ecl_kw_equal(matrix_kw, fracture_kw)) { + if (!rd_kw_equal(matrix_kw, fracture_kw)) { dualp_flag = FILEHEAD_SINGLE_POROSITY; break; } @@ -3162,38 +3142,37 @@ static int ecl_grid_dual_porosity_GRID_check(ecl_file_type *ecl_file) { } } -static ecl_grid_type *ecl_grid_alloc_GRID__(ecl_grid_type *global_grid, - const ecl_file_type *ecl_file, - int cell_offset, int grid_nr, - int dualp_flag, - bool apply_mapaxes) { +static rd_grid_type *rd_grid_alloc_GRID__(rd_grid_type *global_grid, + const rd_file_type *rd_file, + int cell_offset, int grid_nr, + int dualp_flag, bool apply_mapaxes) { int nx, ny, nz; const float *mapaxes_data = NULL; - ecl_grid_type *grid; - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; + rd_grid_type *grid; + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; // 1: Fetching header data from the DIMENS keyword. { - ecl_kw_type *dimens_kw = - ecl_file_iget_named_kw(ecl_file, DIMENS_KW, grid_nr); - nx = ecl_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); - ny = ecl_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); - nz = ecl_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); + rd_kw_type *dimens_kw = + rd_file_iget_named_kw(rd_file, DIMENS_KW, grid_nr); + nx = rd_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); + ny = rd_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); + nz = rd_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); } // 2: Fetching the mapaxes data from the MAPAXES keyword; the // keyword is optional, and is only applicable to the global grid. { - if ((grid_nr == 0) && (ecl_file_has_kw(ecl_file, MAPAXES_KW))) { - const ecl_kw_type *mapaxes_kw = - ecl_file_iget_named_kw(ecl_file, MAPAXES_KW, 0); - mapaxes_data = ecl_grid_get_mapaxes_from_kw__(mapaxes_kw); + if ((grid_nr == 0) && (rd_file_has_kw(rd_file, MAPAXES_KW))) { + const rd_kw_type *mapaxes_kw = + rd_file_iget_named_kw(rd_file, MAPAXES_KW, 0); + mapaxes_data = rd_grid_get_mapaxes_from_kw__(mapaxes_kw); } } - if ((grid_nr == 0) && (ecl_file_has_kw(ecl_file, GRIDUNIT_KW))) - unit_system = ecl_grid_check_unit_system( - ecl_file_iget_named_kw(ecl_file, GRIDUNIT_KW, 0)); + if ((grid_nr == 0) && (rd_file_has_kw(rd_file, GRIDUNIT_KW))) + unit_system = rd_grid_check_unit_system( + rd_file_iget_named_kw(rd_file, GRIDUNIT_KW, 0)); /* The number of COORDS/CORNERS blocks depends on the GRIDFILE option @@ -3226,7 +3205,7 @@ static ecl_grid_type *ecl_grid_alloc_GRID__(ecl_grid_type *global_grid, Possible LGR cells will follow *AFTER* the first nx*ny*nz cells; the loop stops at nx*ny*nz. Additionally the LGR cells should be - discarded (by checking coords[5]) in the ecl_grid_set_cell_GRID() + discarded (by checking coords[5]) in the rd_grid_set_cell_GRID() function. */ @@ -3235,7 +3214,7 @@ static ecl_grid_type *ecl_grid_alloc_GRID__(ecl_grid_type *global_grid, if (global_grid == NULL) { /* This is the main grid - can be both nactive or nx*ny*nz coord elements. */ - int num_coords_kw = ecl_file_get_num_named_kw(ecl_file, COORDS_KW); + int num_coords_kw = rd_file_get_num_named_kw(rd_file, COORDS_KW); if (num_coords_kw >= nx * ny * nz) num_coords = nx * ny * nz; else @@ -3255,17 +3234,17 @@ static ecl_grid_type *ecl_grid_alloc_GRID__(ecl_grid_type *global_grid, (float **)util_calloc(num_coords, sizeof *corners); for (index = 0; index < num_coords; index++) { - const ecl_kw_type *coords_kw = ecl_file_iget_named_kw( - ecl_file, COORDS_KW, index + cell_offset); - const ecl_kw_type *corners_kw = ecl_file_iget_named_kw( - ecl_file, CORNERS_KW, index + cell_offset); - - coords[index] = ecl_kw_get_int_ptr(coords_kw); - corners[index] = ecl_kw_get_float_ptr(corners_kw); - coords_size = ecl_kw_get_size(coords_kw); + const rd_kw_type *coords_kw = rd_file_iget_named_kw( + rd_file, COORDS_KW, index + cell_offset); + const rd_kw_type *corners_kw = rd_file_iget_named_kw( + rd_file, CORNERS_KW, index + cell_offset); + + coords[index] = rd_kw_get_int_ptr(coords_kw); + corners[index] = rd_kw_get_float_ptr(corners_kw); + coords_size = rd_kw_get_size(coords_kw); } // Create the grid: - grid = ecl_grid_alloc_GRID_data__( + grid = rd_grid_alloc_GRID_data__( global_grid, num_coords, unit_system, dualp_flag, apply_mapaxes, nx, ny, nz, grid_nr, coords_size, coords, corners, mapaxes_data); @@ -3276,50 +3255,50 @@ static ecl_grid_type *ecl_grid_alloc_GRID__(ecl_grid_type *global_grid, } if (grid_nr > 0) - ecl_grid_set_lgr_name_GRID(grid, ecl_file, grid_nr); + rd_grid_set_lgr_name_GRID(grid, rd_file, grid_nr); return grid; } -ecl_grid_type *ecl_grid_alloc_GRID(const char *grid_file, bool apply_mapaxes) { +rd_grid_type *rd_grid_alloc_GRID(const char *grid_file, bool apply_mapaxes) { - ecl_file_enum file_type; - file_type = ecl_util_get_file_type(grid_file, NULL, NULL); - if (file_type != ECL_GRID_FILE) + rd_file_enum file_type; + file_type = rd_get_file_type(grid_file, NULL, NULL); + if (file_type != RD_GRID_FILE) util_abort("%s: %s wrong file type - expected .GRID file - aborting \n", __func__, grid_file); { int cell_offset = 0; - ecl_file_type *ecl_file = ecl_file_open(grid_file, 0); - int num_grid = ecl_file_get_num_named_kw(ecl_file, DIMENS_KW); - ecl_grid_type *main_grid; + rd_file_type *rd_file = rd_file_open(grid_file, 0); + int num_grid = rd_file_get_num_named_kw(rd_file, DIMENS_KW); + rd_grid_type *main_grid; int grid_nr; int dualp_flag; - dualp_flag = ecl_grid_dual_porosity_GRID_check(ecl_file); - main_grid = ecl_grid_alloc_GRID__(NULL, ecl_file, cell_offset, 0, - dualp_flag, apply_mapaxes); - cell_offset += ecl_grid_get_global_size(main_grid); + dualp_flag = rd_grid_dual_porosity_GRID_check(rd_file); + main_grid = rd_grid_alloc_GRID__(NULL, rd_file, cell_offset, 0, + dualp_flag, apply_mapaxes); + cell_offset += rd_grid_get_global_size(main_grid); for (grid_nr = 1; grid_nr < num_grid; grid_nr++) { - ecl_grid_type *lgr_grid = ecl_grid_alloc_GRID__( - main_grid, ecl_file, cell_offset, grid_nr, dualp_flag, false); - cell_offset += ecl_grid_get_global_size(lgr_grid); - ecl_grid_add_lgr(main_grid, lgr_grid); + rd_grid_type *lgr_grid = rd_grid_alloc_GRID__( + main_grid, rd_file, cell_offset, grid_nr, dualp_flag, false); + cell_offset += rd_grid_get_global_size(lgr_grid); + rd_grid_add_lgr(main_grid, lgr_grid); { - ecl_grid_type *host_grid; + rd_grid_type *host_grid; if (lgr_grid->parent_name == NULL) host_grid = main_grid; else host_grid = - ecl_grid_get_lgr(main_grid, lgr_grid->parent_name); + rd_grid_get_lgr(main_grid, lgr_grid->parent_name); - ecl_grid_install_lgr_GRID(host_grid, lgr_grid); + rd_grid_install_lgr_GRID(host_grid, lgr_grid); } } main_grid->name = util_alloc_string_copy(grid_file); - ecl_file_close(ecl_file); + rd_file_close(rd_file); return main_grid; } } @@ -3334,11 +3313,11 @@ ecl_grid_type *ecl_grid_alloc_GRID(const char *grid_file, bool apply_mapaxes) { cells and 0 for inactive cells. The actnum array can be NULL, in which case all cells will be active. */ -ecl_grid_type *ecl_grid_alloc_regular(int nx, int ny, int nz, - const double *ivec, const double *jvec, - const double *kvec, const int *actnum) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - ecl_grid_type *grid = ecl_grid_alloc_empty( +rd_grid_type *rd_grid_alloc_regular(int nx, int ny, int nz, const double *ivec, + const double *jvec, const double *kvec, + const int *actnum) { + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + rd_grid_type *grid = rd_grid_alloc_empty( NULL, unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, 0, true); if (grid) { const double grid_offset[3] = {0, 0, 0}; @@ -3355,13 +3334,13 @@ ecl_grid_type *ecl_grid_alloc_regular(int nx, int ny, int nz, grid_offset[2] + i * ivec[2] + j * jvec[2] + k * kvec[2]}; - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); - ecl_cell_init_regular(cell, offset, i, j, k, global_index, - ivec, jvec, kvec, actnum); + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); + rd_cell_init_regular(cell, offset, i, j, k, global_index, + ivec, jvec, kvec, actnum); } } } - ecl_grid_update_index(grid); + rd_grid_update_index(grid); } return grid; @@ -3378,14 +3357,14 @@ ecl_grid_type *ecl_grid_alloc_regular(int nx, int ny, int nz, which case all cells will be active. */ -ecl_grid_type *ecl_grid_alloc_rectangular(int nx, int ny, int nz, double dx, - double dy, double dz, - const int *actnum) { +rd_grid_type *rd_grid_alloc_rectangular(int nx, int ny, int nz, double dx, + double dy, double dz, + const int *actnum) { const double ivec[3] = {dx, 0, 0}; const double jvec[3] = {0, dy, 0}; const double kvec[3] = {0, 0, dz}; - return ecl_grid_alloc_regular(nx, ny, nz, ivec, jvec, kvec, actnum); + return rd_grid_alloc_regular(nx, ny, nz, ivec, jvec, kvec, actnum); } /** @@ -3398,12 +3377,11 @@ ecl_grid_type *ecl_grid_alloc_rectangular(int nx, int ny, int nz, double dx, nx*ny*nz where actnum[i + j*nx + k*nx*ny] == 1 for active cells and 0 for inactive cells. The actnum array can be NULL, in which case all cells will be active. */ -ecl_grid_type *ecl_grid_alloc_dxv_dyv_dzv(int nx, int ny, int nz, - const double *dxv, const double *dyv, - const double *dzv, - const int *actnum) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - ecl_grid_type *grid = ecl_grid_alloc_empty( +rd_grid_type *rd_grid_alloc_dxv_dyv_dzv(int nx, int ny, int nz, + const double *dxv, const double *dyv, + const double *dzv, const int *actnum) { + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + rd_grid_type *grid = rd_grid_alloc_empty( NULL, unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, /*lgr_nr=*/0, /*init_valid=*/true); if (grid) { @@ -3423,29 +3401,29 @@ ecl_grid_type *ecl_grid_alloc_dxv_dyv_dzv(int nx, int ny, int nz, offset[0] = grid_offset[0]; for (i = 0; i < nx; i++) { int global_index = i + j * nx + k * nx * ny; - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); ivec[0] = dxv[i]; - ecl_cell_init_regular(cell, offset, i, j, k, global_index, - ivec, jvec, kvec, actnum); + rd_cell_init_regular(cell, offset, i, j, k, global_index, + ivec, jvec, kvec, actnum); offset[0] += dxv[i]; } offset[1] += dyv[j]; } offset[2] += dzv[k]; } - ecl_grid_update_index(grid); + rd_grid_update_index(grid); } return grid; } -ecl_grid_type * -ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, - const double *dyv, const double *dzv, - const double *depthz, const int *actnum) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - ecl_grid_type *grid = ecl_grid_alloc_empty( +rd_grid_type * +rd_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, + const double *dyv, const double *dzv, + const double *depthz, const int *actnum) { + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + rd_grid_type *grid = rd_grid_alloc_empty( NULL, unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, /*lgr_nr=*/0, /*init_valid=*/true); @@ -3458,7 +3436,7 @@ ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, double x0 = 0; for (i = 0; i < nx; i++) { int global_index = i + j * nx + k * nx * ny; - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); double z0 = depthz[i + j * (nx + 1)]; double z1 = depthz[i + 1 + j * (nx + 1)]; double z2 = depthz[i + (j + 1) * (nx + 1)]; @@ -3489,8 +3467,8 @@ ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, for (i = 0; i < nx; i++) { int g2 = i + j * nx + k * nx * ny; int g1 = i + j * nx + (k - 1) * nx * ny; - ecl_cell_type *cell2 = ecl_grid_get_cell(grid, g2); - ecl_cell_type *cell1 = ecl_grid_get_cell(grid, g1); + rd_cell_type *cell2 = rd_grid_get_cell(grid, g2); + rd_cell_type *cell1 = rd_grid_get_cell(grid, g1); int c; for (c = 0; c < 4; c++) { @@ -3509,7 +3487,7 @@ ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, for (j = 0; j < ny; j++) { for (i = 0; i < nx; i++) { int global_index = i + j * nx + k * nx * ny; - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); if (actnum) cell->active = actnum[global_index]; @@ -3521,7 +3499,7 @@ ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, } if (grid) - ecl_grid_update_index(grid); + rd_grid_update_index(grid); return grid; } @@ -3543,13 +3521,12 @@ ecl_grid_alloc_dxv_dyv_dzv_depthz(int nx, int ny, int nz, const double *dxv, trickery must be performed before calling this function. */ -ecl_grid_type *ecl_grid_alloc_dx_dy_dz_tops(int nx, int ny, int nz, - const double *dx, const double *dy, - const double *dz, - const double *tops, - const int *actnum) { - ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; - ecl_grid_type *grid = ecl_grid_alloc_empty( +rd_grid_type *rd_grid_alloc_dx_dy_dz_tops(int nx, int ny, int nz, + const double *dx, const double *dy, + const double *dz, const double *tops, + const int *actnum) { + ert_rd_unit_enum unit_system = RD_METRIC_UNITS; + rd_grid_type *grid = rd_grid_alloc_empty( NULL, unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, 0, true); if (grid) { int i, j, k; @@ -3563,7 +3540,7 @@ ecl_grid_type *ecl_grid_alloc_dx_dy_dz_tops(int nx, int ny, int nz, double x0 = 0; for (i = 0; i < nx; i++) { int g = i + j * nx + k * nx * ny; - ecl_cell_type *cell = ecl_grid_get_cell(grid, g); + rd_cell_type *cell = rd_grid_get_cell(grid, g); double z0 = tops[g]; point_set(&cell->corner_list[0], x0, y0[i], z0); @@ -3592,54 +3569,54 @@ ecl_grid_type *ecl_grid_alloc_dx_dy_dz_tops(int nx, int ny, int nz, } free(y0); - ecl_grid_update_index(grid); + rd_grid_update_index(grid); } return grid; } /** - This function will allocate a ecl_grid instance. As input it takes + This function will allocate a rd_grid instance. As input it takes a filename, which can be both a GRID file and an EGRID file (both formatted and unformatted). When allocating based on an EGRID file the COORDS, ZCORN and ACTNUM - keywords are extracted, and the ecl_grid_alloc_GRDECL() function is + keywords are extracted, and the rd_grid_alloc_GRDECL() function is called with these keywords. This function can be called directly with these keywords. */ -ecl_grid_type *ecl_grid_alloc__(const char *grid_file, bool apply_mapaxes) { - ecl_file_enum file_type; - ecl_grid_type *ecl_grid = NULL; +rd_grid_type *rd_grid_alloc__(const char *grid_file, bool apply_mapaxes) { + rd_file_enum file_type; + rd_grid_type *rd_grid = NULL; - file_type = ecl_util_get_file_type(grid_file, NULL, NULL); - if (file_type == ECL_GRID_FILE) - ecl_grid = ecl_grid_alloc_GRID(grid_file, apply_mapaxes); - else if (file_type == ECL_EGRID_FILE) - ecl_grid = ecl_grid_alloc_EGRID(grid_file, apply_mapaxes); + file_type = rd_get_file_type(grid_file, NULL, NULL); + if (file_type == RD_GRID_FILE) + rd_grid = rd_grid_alloc_GRID(grid_file, apply_mapaxes); + else if (file_type == RD_EGRID_FILE) + rd_grid = rd_grid_alloc_EGRID(grid_file, apply_mapaxes); else util_abort("%s must have .GRID or .EGRID file - %s not recognized \n", __func__, grid_file); - return ecl_grid; + return rd_grid; } -ecl_grid_type *ecl_grid_alloc(const char *grid_file) { +rd_grid_type *rd_grid_alloc(const char *grid_file) { bool apply_mapaxes = true; - return ecl_grid_alloc__(grid_file, apply_mapaxes); + return rd_grid_alloc__(grid_file, apply_mapaxes); } // This function is used to override use of the keyword ACTNUM from the EGRID file. // ext_actnum must have size equal to the number of cells in the main grid // if ext_actnum = NULL, actnum is taken from file, otherwise ext_actnums // determines which cells are active. -ecl_grid_type *ecl_grid_alloc_ext_actnum(const char *grid_file, - const int *ext_actnum) { - ecl_file_enum file_type = ecl_util_get_file_type(grid_file, NULL, NULL); - if (file_type == ECL_EGRID_FILE) - return ecl_grid_alloc_EGRID_all_grids(grid_file, true, ext_actnum); - else if (file_type == ECL_GRID_FILE) - ecl_grid_alloc_GRID_all_grids(grid_file); +rd_grid_type *rd_grid_alloc_ext_actnum(const char *grid_file, + const int *ext_actnum) { + rd_file_enum file_type = rd_get_file_type(grid_file, NULL, NULL); + if (file_type == RD_EGRID_FILE) + return rd_grid_alloc_EGRID_all_grids(grid_file, true, ext_actnum); + else if (file_type == RD_GRID_FILE) + rd_grid_alloc_GRID_all_grids(grid_file); else util_abort("%s must have .EGRID file - %s not recognized \n", __func__, grid_file); @@ -3647,48 +3624,48 @@ ecl_grid_type *ecl_grid_alloc_ext_actnum(const char *grid_file, return NULL; } -static void ecl_grid_file_nactive_dims(fortio_type *data_fortio, int *dims) { +static void rd_grid_file_nactive_dims(fortio_type *data_fortio, int *dims) { if (data_fortio) { - if (ecl_kw_fseek_kw(INTEHEAD_KW, false, false, data_fortio)) { - ecl_kw_type *intehead_kw = ecl_kw_fread_alloc(data_fortio); - dims[3] = ecl_kw_iget_int(intehead_kw, INTEHEAD_NACTIVE_INDEX); - ecl_kw_free(intehead_kw); + if (rd_kw_fseek_kw(INTEHEAD_KW, false, false, data_fortio)) { + rd_kw_type *intehead_kw = rd_kw_fread_alloc(data_fortio); + dims[3] = rd_kw_iget_int(intehead_kw, INTEHEAD_NACTIVE_INDEX); + rd_kw_free(intehead_kw); } } } -static bool ecl_grid_file_EGRID_dims(fortio_type *grid_fortio, - fortio_type *data_fortio, int *dims) { +static bool rd_grid_file_EGRID_dims(fortio_type *grid_fortio, + fortio_type *data_fortio, int *dims) { - if (ecl_kw_fseek_kw(GRIDHEAD_KW, false, false, grid_fortio)) { + if (rd_kw_fseek_kw(GRIDHEAD_KW, false, false, grid_fortio)) { { - ecl_kw_type *gridhead_kw = ecl_kw_fread_alloc(grid_fortio); - dims[0] = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NX_INDEX); - dims[1] = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NY_INDEX); - dims[2] = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NZ_INDEX); + rd_kw_type *gridhead_kw = rd_kw_fread_alloc(grid_fortio); + dims[0] = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NX_INDEX); + dims[1] = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NY_INDEX); + dims[2] = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NZ_INDEX); - ecl_kw_free(gridhead_kw); + rd_kw_free(gridhead_kw); } - ecl_grid_file_nactive_dims(data_fortio, dims); + rd_grid_file_nactive_dims(data_fortio, dims); return true; } else return false; } -static bool ecl_grid_file_GRID_dims(fortio_type *grid_fortio, - fortio_type *data_fortio, int *dims) { +static bool rd_grid_file_GRID_dims(fortio_type *grid_fortio, + fortio_type *data_fortio, int *dims) { - if (ecl_kw_fseek_kw(DIMENS_KW, false, false, grid_fortio)) { + if (rd_kw_fseek_kw(DIMENS_KW, false, false, grid_fortio)) { { - ecl_kw_type *dimens_kw = ecl_kw_fread_alloc(grid_fortio); - dims[0] = ecl_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); - dims[1] = ecl_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); - dims[2] = ecl_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); + rd_kw_type *dimens_kw = rd_kw_fread_alloc(grid_fortio); + dims[0] = rd_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); + dims[1] = rd_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); + dims[2] = rd_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); - ecl_kw_free(dimens_kw); + rd_kw_free(dimens_kw); } - ecl_grid_file_nactive_dims(data_fortio, dims); + rd_grid_file_nactive_dims(data_fortio, dims); return true; } else return false; @@ -3715,34 +3692,32 @@ static bool ecl_grid_file_GRID_dims(fortio_type *grid_fortio, dims vector is not touched. */ -bool ecl_grid_file_dims(const char *grid_filename, - const char *init_restart_filename, int *dims) { +bool rd_grid_file_dims(const char *grid_filename, + const char *init_restart_filename, int *dims) { bool input_file_OK = false; bool grid_fmt_file; - ecl_file_enum grid_file_type = - ecl_util_get_file_type(grid_filename, &grid_fmt_file, NULL); + rd_file_enum grid_file_type = + rd_get_file_type(grid_filename, &grid_fmt_file, NULL); - if ((grid_file_type == ECL_GRID_FILE) || - (grid_file_type == ECL_EGRID_FILE)) { + if ((grid_file_type == RD_GRID_FILE) || (grid_file_type == RD_EGRID_FILE)) { fortio_type *grid_fortio = - fortio_open_reader(grid_filename, grid_fmt_file, ECL_ENDIAN_FLIP); + fortio_open_reader(grid_filename, grid_fmt_file, RD_ENDIAN_FLIP); if (grid_fortio) { fortio_type *data_fortio = NULL; bool data_fmt_file; if (init_restart_filename) { - ecl_util_get_file_type(init_restart_filename, &data_fmt_file, - NULL); - data_fortio = fortio_open_reader( - init_restart_filename, data_fmt_file, ECL_ENDIAN_FLIP); + rd_get_file_type(init_restart_filename, &data_fmt_file, NULL); + data_fortio = fortio_open_reader(init_restart_filename, + data_fmt_file, RD_ENDIAN_FLIP); } - if (grid_file_type == ECL_GRID_FILE) + if (grid_file_type == RD_GRID_FILE) input_file_OK = - ecl_grid_file_GRID_dims(grid_fortio, data_fortio, dims); + rd_grid_file_GRID_dims(grid_fortio, data_fortio, dims); else input_file_OK = - ecl_grid_file_EGRID_dims(grid_fortio, data_fortio, dims); + rd_grid_file_EGRID_dims(grid_fortio, data_fortio, dims); if (data_fortio) fortio_fclose(data_fortio); @@ -3778,31 +3753,31 @@ bool ecl_grid_file_dims(const char *grid_filename, files can be found. */ -char *ecl_grid_alloc_case_filename(const char *case_input) { - ecl_file_enum file_type; +char *rd_grid_alloc_case_filename(const char *case_input) { + rd_file_enum file_type; bool fmt_file; - file_type = ecl_util_get_file_type(case_input, &fmt_file, NULL); + file_type = rd_get_file_type(case_input, &fmt_file, NULL); - if (file_type == ECL_GRID_FILE) + if (file_type == RD_GRID_FILE) return util_alloc_string_copy(case_input); /* Case 1 */ - else if (file_type == ECL_EGRID_FILE) + else if (file_type == RD_EGRID_FILE) return util_alloc_string_copy(case_input); /* Case 1 */ else { char *grid_file = NULL; char *path; char *basename; util_alloc_file_components(case_input, &path, &basename, NULL); - if ((file_type == ECL_OTHER_FILE) || + if ((file_type == RD_OTHER_FILE) || (file_type == - ECL_DATA_FILE)) { /* Case 3 - only basename recognized */ - char *EGRID = ecl_util_alloc_filename(path, basename, - ECL_EGRID_FILE, false, -1); - char *GRID = ecl_util_alloc_filename(path, basename, ECL_GRID_FILE, - false, -1); - char *FEGRID = ecl_util_alloc_filename(path, basename, - ECL_EGRID_FILE, true, -1); - char *FGRID = ecl_util_alloc_filename(path, basename, ECL_GRID_FILE, - true, -1); + RD_DATA_FILE)) { /* Case 3 - only basename recognized */ + char *EGRID = + rd_alloc_filename(path, basename, RD_EGRID_FILE, false, -1); + char *GRID = + rd_alloc_filename(path, basename, RD_GRID_FILE, false, -1); + char *FEGRID = + rd_alloc_filename(path, basename, RD_EGRID_FILE, true, -1); + char *FGRID = + rd_alloc_filename(path, basename, RD_GRID_FILE, true, -1); if (util_file_exists(EGRID)) grid_file = util_alloc_string_copy(EGRID); @@ -3821,10 +3796,10 @@ char *ecl_grid_alloc_case_filename(const char *case_input) { free(GRID); free(FGRID); } else { /* Case 2 - we know the formatted / unformatted status. */ - char *EGRID = ecl_util_alloc_filename(path, basename, - ECL_EGRID_FILE, fmt_file, -1); - char *GRID = ecl_util_alloc_filename(path, basename, ECL_GRID_FILE, - fmt_file, -1); + char *EGRID = + rd_alloc_filename(path, basename, RD_EGRID_FILE, fmt_file, -1); + char *GRID = + rd_alloc_filename(path, basename, RD_GRID_FILE, fmt_file, -1); if (util_file_exists(EGRID)) grid_file = util_alloc_string_copy(EGRID); @@ -3838,28 +3813,27 @@ char *ecl_grid_alloc_case_filename(const char *case_input) { } } -ecl_grid_type *ecl_grid_load_case__(const char *case_input, - bool apply_mapaxes) { - ecl_grid_type *ecl_grid = NULL; - char *grid_file = ecl_grid_alloc_case_filename(case_input); +rd_grid_type *rd_grid_load_case__(const char *case_input, bool apply_mapaxes) { + rd_grid_type *rd_grid = NULL; + char *grid_file = rd_grid_alloc_case_filename(case_input); if (grid_file != NULL) { if (util_file_exists(grid_file)) - ecl_grid = ecl_grid_alloc__(grid_file, apply_mapaxes); + rd_grid = rd_grid_alloc__(grid_file, apply_mapaxes); free(grid_file); } - return ecl_grid; + return rd_grid; } -ecl_grid_type *ecl_grid_load_case(const char *case_input) { +rd_grid_type *rd_grid_load_case(const char *case_input) { bool apply_mapaxes = true; - return ecl_grid_load_case__(case_input, apply_mapaxes); + return rd_grid_load_case__(case_input, apply_mapaxes); } -bool ecl_grid_exists(const char *case_input) { +bool rd_grid_exists(const char *case_input) { bool exists = false; - char *grid_file = ecl_grid_alloc_case_filename(case_input); + char *grid_file = rd_grid_alloc_case_filename(case_input); if (grid_file != NULL) { exists = true; free(grid_file); @@ -3867,23 +3841,22 @@ bool ecl_grid_exists(const char *case_input) { return exists; } -static bool ecl_grid_compare_coarse_cells(const ecl_grid_type *g1, - const ecl_grid_type *g2, - bool verbose) { +static bool rd_grid_compare_coarse_cells(const rd_grid_type *g1, + const rd_grid_type *g2, bool verbose) { if (vector_get_size(g1->coarse_cells) == vector_get_size(g2->coarse_cells)) { bool equal = true; int c; for (c = 0; c < vector_get_size(g1->coarse_cells); c++) { - const ecl_coarse_cell_type *coarse_cell1 = - (const ecl_coarse_cell_type *)vector_iget_const( - g1->coarse_cells, c); - const ecl_coarse_cell_type *coarse_cell2 = - (const ecl_coarse_cell_type *)vector_iget_const( - g2->coarse_cells, c); - - equal = ecl_coarse_cell_equal(coarse_cell1, coarse_cell2); + const rd_coarse_cell_type *coarse_cell1 = + (const rd_coarse_cell_type *)vector_iget_const(g1->coarse_cells, + c); + const rd_coarse_cell_type *coarse_cell2 = + (const rd_coarse_cell_type *)vector_iget_const(g2->coarse_cells, + c); + + equal = rd_coarse_cell_equal(coarse_cell1, coarse_cell2); if (!equal) if (verbose) fprintf(stderr, "Difference in coarse cell:%d \n", c); @@ -3893,32 +3866,32 @@ static bool ecl_grid_compare_coarse_cells(const ecl_grid_type *g1, return false; } -static bool ecl_grid_compare_cells(const ecl_grid_type *g1, - const ecl_grid_type *g2, bool include_nnc, - bool verbose) { +static bool rd_grid_compare_cells(const rd_grid_type *g1, + const rd_grid_type *g2, bool include_nnc, + bool verbose) { int g; bool equal = true; for (g = 0; g < g1->size; g++) { bool this_equal = true; - ecl_cell_type *c1 = ecl_grid_get_cell(g1, g); - ecl_cell_type *c2 = ecl_grid_get_cell(g2, g); - ecl_cell_compare(c1, c2, include_nnc, &this_equal); + rd_cell_type *c1 = rd_grid_get_cell(g1, g); + rd_cell_type *c2 = rd_grid_get_cell(g2, g); + rd_cell_compare(c1, c2, include_nnc, &this_equal); if (!this_equal) { if (verbose) { int i, j, k; - ecl_grid_get_ijk1(g1, g, &i, &j, &k); + rd_grid_get_ijk1(g1, g, &i, &j, &k); printf("Difference in cell: %d : %d,%d,%d nnc_equal:%d " "Volume:%g \n", g, i, j, k, nnc_info_equal(c1->nnc_info, c2->nnc_info), - ecl_cell_get_volume(c1)); + rd_cell_get_volume(c1)); printf("-------------------------------------------------------" "----------\n"); - ecl_cell_dump_ascii(c1, i, j, k, stdout, NULL); + rd_cell_dump_ascii(c1, i, j, k, stdout, NULL); printf("-------------------------------------------------------" "----------\n"); - ecl_cell_dump_ascii(c2, i, j, k, stdout, NULL); + rd_cell_dump_ascii(c2, i, j, k, stdout, NULL); printf("-------------------------------------------------------" "----------\n"); } @@ -3929,8 +3902,8 @@ static bool ecl_grid_compare_cells(const ecl_grid_type *g1, return equal; } -static bool ecl_grid_compare_index(const ecl_grid_type *g1, - const ecl_grid_type *g2, bool verbose) { +static bool rd_grid_compare_index(const rd_grid_type *g1, + const rd_grid_type *g2, bool verbose) { bool equal = true; if (g1->total_active != g2->total_active) { @@ -3988,8 +3961,8 @@ static bool ecl_grid_compare_index(const ecl_grid_type *g1, return equal; } -static bool ecl_grid_compare_mapaxes(const ecl_grid_type *g1, - const ecl_grid_type *g2, bool verbose) { +static bool rd_grid_compare_mapaxes(const rd_grid_type *g1, + const rd_grid_type *g2, bool verbose) { bool equal = true; if (g1->use_mapaxes == g2->use_mapaxes) { if (g1->mapaxes) { @@ -4010,8 +3983,8 @@ static bool ecl_grid_compare_mapaxes(const ecl_grid_type *g1, return true all cells must be identical. */ -static bool ecl_grid_compare__(const ecl_grid_type *g1, const ecl_grid_type *g2, - bool include_nnc, bool verbose) { +static bool rd_grid_compare__(const rd_grid_type *g1, const rd_grid_type *g2, + bool include_nnc, bool verbose) { bool equal = true; if (g1->size != g2->size) @@ -4038,38 +4011,38 @@ static bool ecl_grid_compare__(const ecl_grid_type *g1, const ecl_grid_type *g2, } if (equal) - equal = ecl_grid_compare_cells(g1, g2, include_nnc, verbose); + equal = rd_grid_compare_cells(g1, g2, include_nnc, verbose); if (equal) - equal = ecl_grid_compare_index(g1, g2, true /*verbose*/); + equal = rd_grid_compare_index(g1, g2, true /*verbose*/); if (equal) - equal = ecl_grid_compare_coarse_cells(g1, g2, verbose); + equal = rd_grid_compare_coarse_cells(g1, g2, verbose); if (equal) - equal = ecl_grid_compare_mapaxes(g1, g2, verbose); + equal = rd_grid_compare_mapaxes(g1, g2, verbose); return equal; } -bool ecl_grid_compare(const ecl_grid_type *g1, const ecl_grid_type *g2, - bool include_lgr, bool include_nnc, bool verbose) { - bool equal = ecl_grid_compare__(g1, g2, include_nnc, verbose); +bool rd_grid_compare(const rd_grid_type *g1, const rd_grid_type *g2, + bool include_lgr, bool include_nnc, bool verbose) { + bool equal = rd_grid_compare__(g1, g2, include_nnc, verbose); if (equal && include_lgr) { if (vector_get_size(g1->LGR_list) == vector_get_size(g2->LGR_list)) { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size(g1->LGR_list); grid_nr++) { - const ecl_grid_type *lgr1 = - (const ecl_grid_type *)vector_iget_const(g1->LGR_list, - grid_nr); - const ecl_grid_type *lgr2 = - (const ecl_grid_type *)vector_iget_const(g2->LGR_list, - grid_nr); + const rd_grid_type *lgr1 = + (const rd_grid_type *)vector_iget_const(g1->LGR_list, + grid_nr); + const rd_grid_type *lgr2 = + (const rd_grid_type *)vector_iget_const(g2->LGR_list, + grid_nr); printf("Comparing lgr grid:%d \n", grid_nr); - equal = ecl_grid_compare__(lgr1, lgr2, include_nnc, verbose); + equal = rd_grid_compare__(lgr1, lgr2, include_nnc, verbose); if (!equal) break; } @@ -4089,24 +4062,24 @@ typedef enum { Returns whether the given point is contained within the minimal cube encapsulating the cell that has all faces parallel to a coordinate plane. */ -static bool ecl_grid_cube_contains(const ecl_cell_type *cell, - const point_type *p) { - if (p->z < ecl_cell_min_z(cell)) +static bool rd_grid_cube_contains(const rd_cell_type *cell, + const point_type *p) { + if (p->z < rd_cell_min_z(cell)) return false; - if (p->z > ecl_cell_max_z(cell)) + if (p->z > rd_cell_max_z(cell)) return false; - if (p->x < ecl_cell_min_x(cell)) + if (p->x < rd_cell_min_x(cell)) return false; - if (p->x > ecl_cell_max_x(cell)) + if (p->x > rd_cell_max_x(cell)) return false; - if (p->y < ecl_cell_min_y(cell)) + if (p->y < rd_cell_min_y(cell)) return false; - if (p->y > ecl_cell_max_y(cell)) + if (p->y > rd_cell_max_y(cell)) return false; return true; @@ -4115,8 +4088,8 @@ static bool ecl_grid_cube_contains(const ecl_cell_type *cell, /* Returns true if and only if p is on plane "plane" of cell when decomposed by "method". */ -static bool ecl_grid_on_plane(const ecl_cell_type *cell, const int method, - const int plane, const point_type *p) { +static bool rd_grid_on_plane(const rd_cell_type *cell, const int method, + const int plane, const point_type *p) { const point_type *p0 = &cell->corner_list[tetrahedron_permutations[method][plane][0]]; const point_type *p1 = @@ -4144,17 +4117,18 @@ static bool ecl_grid_on_plane(const ecl_cell_type *cell, const int method, Note: The correctness of this function relies *HEAVILY* on the permutation of the tetrahedrons in the decompositions. */ -static face_status_enum -ecl_grid_on_cell_face(const ecl_cell_type *cell, const int method, - const point_type *p, const bool max_i, const bool max_j, - const bool max_k) { +static face_status_enum rd_grid_on_cell_face(const rd_cell_type *cell, + const int method, + const point_type *p, + const bool max_i, const bool max_j, + const bool max_k) { int k_minus = 0, j_pluss = 1, i_minus = 2, i_pluss = 3, j_minus = 4, k_pluss = 5; bool on[6]; for (int i = 0; i < 6; ++i) { - on[i] = (ecl_grid_on_plane(cell, method, 2 * i, p) || - ecl_grid_on_plane(cell, method, 2 * i + 1, p)); + on[i] = (rd_grid_on_plane(cell, method, 2 * i, p) || + rd_grid_on_plane(cell, method, 2 * i + 1, p)); } // Not on any of the cell sides @@ -4225,7 +4199,7 @@ static bool tetrahedron_by_points_contains(const point_type *p0, Note: This function relies *HEAVILY* on the permutation of tetrahedron_permutations. */ -static bool concave_cell_contains(const ecl_cell_type *cell, int method, +static bool concave_cell_contains(const rd_cell_type *cell, int method, const point_type *p) { const point_type *dia[2][2] = { @@ -4271,14 +4245,14 @@ static bool concave_cell_contains(const ecl_cell_type *cell, int method, warning will be printed on stderr if a cell is discarded due to twist. - - See the documentation of ecl_grid_on_cell_face for caveats regarding + - See the documentation of rd_grid_on_cell_face for caveats regarding containtment of points of cell faces. */ -bool ecl_grid_cell_contains_xyz3(const ecl_grid_type *ecl_grid, int i, int j, - int k, double x, double y, double z) { +bool rd_grid_cell_contains_xyz3(const rd_grid_type *rd_grid, int i, int j, + int k, double x, double y, double z) { point_type p; - ecl_cell_type *cell = ecl_grid_get_cell( - ecl_grid, ecl_grid_get_global_index3(ecl_grid, i, j, k)); + rd_cell_type *cell = + rd_grid_get_cell(rd_grid, rd_grid_get_global_index3(rd_grid, i, j, k)); point_set(&p, x, y, z); int method = (i + j + k) % @@ -4288,22 +4262,22 @@ bool ecl_grid_cell_contains_xyz3(const ecl_grid_type *ecl_grid, int i, int j, return false; // Pruning - if (!ecl_grid_cube_contains(cell, &p)) + if (!rd_grid_cube_contains(cell, &p)) return false; // Checks if point is on one of the faces of the cell, and if so whether it // "belongs" to this cell. - bool max_i = (i == ecl_grid->nx - 1); - bool max_j = (j == ecl_grid->ny - 1); - bool max_k = (k == ecl_grid->nz - 1); + bool max_i = (i == rd_grid->nx - 1); + bool max_j = (j == rd_grid->ny - 1); + bool max_k = (k == rd_grid->nz - 1); face_status_enum face_status = - ecl_grid_on_cell_face(cell, method, &p, max_i, max_j, max_k); + rd_grid_on_cell_face(cell, method, &p, max_i, max_j, max_k); if (face_status != NOT_ON_FACE) return face_status == BELONGS_TO_CELL; // Twisted cells - if (ecl_cell_get_twist(cell) > 0) { + if (rd_cell_get_twist(cell) > 0) { fprintf(stderr, "** Warning: Point (%g,%g,%g) is in vicinity of twisted cell: " "(%d,%d,%d) - function:%s might be mistaken.\n", @@ -4315,47 +4289,45 @@ bool ecl_grid_cell_contains_xyz3(const ecl_grid_type *ecl_grid, int i, int j, return concave_cell_contains(cell, method, &p); } -bool ecl_grid_cell_contains_xyz1(const ecl_grid_type *ecl_grid, - int global_index, double x, double y, - double z) { +bool rd_grid_cell_contains_xyz1(const rd_grid_type *rd_grid, int global_index, + double x, double y, double z) { int i, j, k; - ecl_grid_get_ijk1(ecl_grid, global_index, &i, &j, &k); - return ecl_grid_cell_contains_xyz3(ecl_grid, i, j, k, x, y, z); + rd_grid_get_ijk1(rd_grid, global_index, &i, &j, &k); + return rd_grid_cell_contains_xyz3(rd_grid, i, j, k, x, y, z); } /** This function returns the global index for the cell (in layer 'k') which contains the point x,y. Observe that if you are looking for - (i,j) you must call the function ecl_grid_get_ijk1() on the return value. + (i,j) you must call the function rd_grid_get_ijk1() on the return value. */ -int ecl_grid_get_global_index_from_xy(const ecl_grid_type *ecl_grid, int k, - bool lower_layer, double x, double y) { +int rd_grid_get_global_index_from_xy(const rd_grid_type *rd_grid, int k, + bool lower_layer, double x, double y) { int i, j; - for (j = 0; j < ecl_grid->ny; j++) - for (i = 0; i < ecl_grid->nx; i++) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - if (ecl_cell_layer_contains_xy( - ecl_grid_get_cell(ecl_grid, global_index), lower_layer, x, - y)) + for (j = 0; j < rd_grid->ny; j++) + for (i = 0; i < rd_grid->nx; i++) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + if (rd_cell_layer_contains_xy( + rd_grid_get_cell(rd_grid, global_index), lower_layer, x, y)) return global_index; } return -1; /* Did not find x,y */ } -int ecl_grid_get_global_index_from_xy_top(const ecl_grid_type *ecl_grid, - double x, double y) { - return ecl_grid_get_global_index_from_xy(ecl_grid, ecl_grid->nz - 1, false, - x, y); +int rd_grid_get_global_index_from_xy_top(const rd_grid_type *rd_grid, double x, + double y) { + return rd_grid_get_global_index_from_xy(rd_grid, rd_grid->nz - 1, false, x, + y); } -int ecl_grid_get_global_index_from_xy_bottom(const ecl_grid_type *ecl_grid, - double x, double y) { - return ecl_grid_get_global_index_from_xy(ecl_grid, 0, true, x, y); +int rd_grid_get_global_index_from_xy_bottom(const rd_grid_type *rd_grid, + double x, double y) { + return rd_grid_get_global_index_from_xy(rd_grid, 0, true, x, y); } -static void ecl_grid_clear_visited(ecl_grid_type *grid) { +static void rd_grid_clear_visited(rd_grid_type *grid) { if (grid->visited == NULL) grid->visited = (bool *)util_calloc(grid->size, sizeof *grid->visited); @@ -4369,20 +4341,20 @@ static void ecl_grid_clear_visited(ecl_grid_type *grid) { /* Box coordinates are not inclusive, i.e. [i1,i2) */ -static int ecl_grid_box_contains_xyz(const ecl_grid_type *grid, int i1, int i2, - int j1, int j2, int k1, int k2, - const point_type *p) { +static int rd_grid_box_contains_xyz(const rd_grid_type *grid, int i1, int i2, + int j1, int j2, int k1, int k2, + const point_type *p) { int i, j, k; int global_index = -1; for (k = k1; k < k2; k++) for (j = j1; j < j2; j++) for (i = i1; i < i2; i++) { - global_index = ecl_grid_get_global_index3(grid, i, j, k); + global_index = rd_grid_get_global_index3(grid, i, j, k); if (!grid->visited[global_index]) { grid->visited[global_index] = true; - if (ecl_grid_cell_contains_xyz1(grid, global_index, p->x, - p->y, p->z)) { + if (rd_grid_cell_contains_xyz1(grid, global_index, p->x, + p->y, p->z)) { return global_index; } } @@ -4393,15 +4365,17 @@ static int ecl_grid_box_contains_xyz(const ecl_grid_type *grid, int i1, int i2, /** * Search for given xyz coordinate around global start_index in a box of size bx */ -static int ecl_grid_get_global_index_from_xyz_around_box( - ecl_grid_type *grid, double x, double y, double z, int start_index, int bx, - point_type *p) { +static int rd_grid_get_global_index_from_xyz_around_box(rd_grid_type *grid, + double x, double y, + double z, + int start_index, int bx, + point_type *p) { /* Try neighbours */ int i, j, k; int i1, i2, j1, j2, k1, k2; int nx, ny, nz; - ecl_grid_get_dims(grid, &nx, &ny, &nz, NULL); - ecl_grid_get_ijk1(grid, start_index, &i, &j, &k); + rd_grid_get_dims(grid, &nx, &ny, &nz, NULL); + rd_grid_get_ijk1(grid, start_index, &i, &j, &k); i1 = util_int_max(0, i - bx); j1 = util_int_max(0, j - bx); @@ -4412,7 +4386,7 @@ static int ecl_grid_get_global_index_from_xyz_around_box( k2 = util_int_min(nz, k + bx); int global_index = - ecl_grid_box_contains_xyz(grid, i1, i2, j1, j2, k1, k2, p); + rd_grid_box_contains_xyz(grid, i1, i2, j1, j2, k1, k2, p); return global_index; } @@ -4440,21 +4414,21 @@ static int ecl_grid_get_global_index_from_xyz_around_box( 3. Give up and do a linear search starting from start_index. */ -int ecl_grid_get_global_index_from_xyz(ecl_grid_type *grid, double x, double y, - double z, int start_index) { +int rd_grid_get_global_index_from_xyz(rd_grid_type *grid, double x, double y, + double z, int start_index) { int global_index; point_type p; point_set(&p, x, y, z); - ecl_grid_clear_visited(grid); + rd_grid_clear_visited(grid); if (start_index >= 0) { /* Try start index */ - if (ecl_grid_cell_contains_xyz1(grid, start_index, x, y, z)) + if (rd_grid_cell_contains_xyz1(grid, start_index, x, y, z)) return start_index; else { /* Try boxes 2, 4, 8, ..., 64 */ for (int bx = 1; bx <= 6; bx++) { - global_index = ecl_grid_get_global_index_from_xyz_around_box( + global_index = rd_grid_get_global_index_from_xyz_around_box( grid, x, y, z, start_index, 1 << bx, &p); if (global_index >= 0) return global_index; @@ -4469,27 +4443,26 @@ int ecl_grid_get_global_index_from_xyz(ecl_grid_type *grid, double x, double y, global_index = -1; for (int index = 0; index < grid->size; index++) { - if (ecl_grid_cell_contains_xyz1(grid, index, x, y, z)) + if (rd_grid_cell_contains_xyz1(grid, index, x, y, z)) return index; } return -1; } -bool ecl_grid_get_ijk_from_xyz(ecl_grid_type *grid, double x, double y, - double z, int start_index, int *i, int *j, - int *k) { - int g = ecl_grid_get_global_index_from_xyz(grid, x, y, z, start_index); +bool rd_grid_get_ijk_from_xyz(rd_grid_type *grid, double x, double y, double z, + int start_index, int *i, int *j, int *k) { + int g = rd_grid_get_global_index_from_xyz(grid, x, y, z, start_index); if (g < 0) return false; - ecl_grid_get_ijk1(grid, g, i, j, k); + rd_grid_get_ijk1(grid, g, i, j, k); return true; } -static bool ecl_grid_sublayer_contanins_xy__(const ecl_grid_type *grid, - double x, double y, int k, int i1, - int i2, int j1, int j2, - geo_polygon_type *polygon) { +static bool rd_grid_sublayer_contanins_xy__(const rd_grid_type *grid, double x, + double y, int k, int i1, int i2, + int j1, int j2, + geo_polygon_type *polygon) { int i, j; geo_polygon_reset(polygon); @@ -4497,45 +4470,45 @@ static bool ecl_grid_sublayer_contanins_xy__(const ecl_grid_type *grid, /* Bottom edge */ for (i = i1; i < i2; i++) { double corner_pos[3]; - ecl_grid_get_corner_xyz(grid, i, j1, k, &corner_pos[0], &corner_pos[1], - &corner_pos[2]); + rd_grid_get_corner_xyz(grid, i, j1, k, &corner_pos[0], &corner_pos[1], + &corner_pos[2]); geo_polygon_add_point(polygon, corner_pos[0], corner_pos[1]); } /* Right edge */ for (j = j1; j < j2; j++) { double corner_pos[3]; - ecl_grid_get_corner_xyz(grid, i2, j, k, &corner_pos[0], &corner_pos[1], - &corner_pos[2]); + rd_grid_get_corner_xyz(grid, i2, j, k, &corner_pos[0], &corner_pos[1], + &corner_pos[2]); geo_polygon_add_point(polygon, corner_pos[0], corner_pos[1]); } /* Top edge */ for (i = i2; i > i1; i--) { double corner_pos[3]; - ecl_grid_get_corner_xyz(grid, i, j2, k, &corner_pos[0], &corner_pos[1], - &corner_pos[2]); + rd_grid_get_corner_xyz(grid, i, j2, k, &corner_pos[0], &corner_pos[1], + &corner_pos[2]); geo_polygon_add_point(polygon, corner_pos[0], corner_pos[1]); } /* Left edge */ for (j = j2; j > j1; j--) { double corner_pos[3]; - ecl_grid_get_corner_xyz(grid, i1, j, k, &corner_pos[0], &corner_pos[1], - &corner_pos[2]); + rd_grid_get_corner_xyz(grid, i1, j, k, &corner_pos[0], &corner_pos[1], + &corner_pos[2]); geo_polygon_add_point(polygon, corner_pos[0], corner_pos[1]); } geo_polygon_close(polygon); return geo_polygon_contains_point__(polygon, x, y, true); } -bool ecl_grid_get_ij_from_xy(const ecl_grid_type *grid, double x, double y, - int k, int *i, int *j) { +bool rd_grid_get_ij_from_xy(const rd_grid_type *grid, double x, double y, int k, + int *i, int *j) { geo_polygon_type *polygon = geo_polygon_alloc(NULL); - int nx = ecl_grid_get_nx(grid); - int ny = ecl_grid_get_ny(grid); + int nx = rd_grid_get_nx(grid); + int ny = rd_grid_get_ny(grid); bool inside = - ecl_grid_sublayer_contanins_xy__(grid, x, y, k, 0, nx, 0, ny, polygon); + rd_grid_sublayer_contanins_xy__(grid, x, y, k, 0, nx, 0, ny, polygon); if (inside) { int i1 = 0; int i2 = nx; @@ -4545,12 +4518,12 @@ bool ecl_grid_get_ij_from_xy(const ecl_grid_type *grid, double x, double y, while (true) { if ((i2 - i1) > 1) { int ic = (i1 + i2) / 2; - if (ecl_grid_sublayer_contanins_xy__(grid, x, y, k, i1, ic, j1, - j2, polygon)) + if (rd_grid_sublayer_contanins_xy__(grid, x, y, k, i1, ic, j1, + j2, polygon)) i2 = ic; else { - if (!ecl_grid_sublayer_contanins_xy__(grid, x, y, k, ic, i2, - j1, j2, polygon)) + if (!rd_grid_sublayer_contanins_xy__(grid, x, y, k, ic, i2, + j1, j2, polygon)) util_abort("%s: point nowhere to be found ... \n", __func__); i1 = ic; @@ -4559,12 +4532,12 @@ bool ecl_grid_get_ij_from_xy(const ecl_grid_type *grid, double x, double y, if ((j2 - j1) > 1) { int jc = (j1 + j2) / 2; - if (ecl_grid_sublayer_contanins_xy__(grid, x, y, k, i1, i2, j1, - jc, polygon)) + if (rd_grid_sublayer_contanins_xy__(grid, x, y, k, i1, i2, j1, + jc, polygon)) j2 = jc; else { - if (!ecl_grid_sublayer_contanins_xy__(grid, x, y, k, i1, i2, - jc, j2, polygon)) + if (!rd_grid_sublayer_contanins_xy__(grid, x, y, k, i1, i2, + jc, j2, polygon)) util_abort("%s: point nowhere to be found ... \n", __func__); j1 = jc; @@ -4583,7 +4556,7 @@ bool ecl_grid_get_ij_from_xy(const ecl_grid_type *grid, double x, double y, return inside; } -void ecl_grid_alloc_blocking_variables(ecl_grid_type *grid, int block_dim) { +void rd_grid_alloc_blocking_variables(rd_grid_type *grid, int block_dim) { int index; grid->block_dim = block_dim; if (block_dim == 2) @@ -4600,19 +4573,19 @@ void ecl_grid_alloc_blocking_variables(ecl_grid_type *grid, int block_dim) { grid->values[index] = double_vector_alloc(0, 0.0); } -void ecl_grid_init_blocking(ecl_grid_type *grid) { +void rd_grid_init_blocking(rd_grid_type *grid) { int index; for (index = 0; index < grid->block_size; index++) double_vector_reset(grid->values[index]); grid->last_block_index = 0; } -bool ecl_grid_block_value_3d(ecl_grid_type *grid, double x, double y, double z, - double value) { +bool rd_grid_block_value_3d(rd_grid_type *grid, double x, double y, double z, + double value) { if (grid->block_dim != 3) util_abort("%s: Wrong blocking dimension \n", __func__); { - int global_index = ecl_grid_get_global_index_from_xyz( + int global_index = rd_grid_get_global_index_from_xyz( grid, x, y, z, grid->last_block_index); if (global_index >= 0) { double_vector_append(grid->values[global_index], value); @@ -4623,19 +4596,19 @@ bool ecl_grid_block_value_3d(ecl_grid_type *grid, double x, double y, double z, } } -double ecl_grid_block_eval3d(ecl_grid_type *grid, int i, int j, int k, - block_function_ftype *blockf) { - int global_index = ecl_grid_get_global_index3(grid, i, j, k); +double rd_grid_block_eval3d(rd_grid_type *grid, int i, int j, int k, + block_function_ftype *blockf) { + int global_index = rd_grid_get_global_index3(grid, i, j, k); return blockf(grid->values[global_index]); } -int ecl_grid_get_block_count3d(const ecl_grid_type *grid, int i, int j, int k) { - int global_index = ecl_grid_get_global_index3(grid, i, j, k); +int rd_grid_get_block_count3d(const rd_grid_type *grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index3(grid, i, j, k); return double_vector_size(grid->values[global_index]); } -void ecl_grid_free(ecl_grid_type *grid) { - ecl_grid_free_cells(grid); +void rd_grid_free(rd_grid_type *grid) { + rd_grid_free_cells(grid); free(grid->index_map); free(grid->inv_index_map); @@ -4649,12 +4622,12 @@ void ecl_grid_free(ecl_grid_type *grid) { double_vector_free(grid->values[i]); free(grid->values); } - if (ECL_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */ + if (RD_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */ vector_free(grid->LGR_list); int_vector_free(grid->lgr_index_map); } if (grid->coord_kw != NULL) - ecl_kw_free(grid->coord_kw); + rd_kw_free(grid->coord_kw); vector_free(grid->coarse_cells); free(grid->parent_name); @@ -4663,19 +4636,19 @@ void ecl_grid_free(ecl_grid_type *grid) { delete grid; } -void ecl_grid_free__(void *arg) { - ecl_grid_type *ecl_grid = ecl_grid_safe_cast(arg); - ecl_grid_free(ecl_grid); +void rd_grid_free__(void *arg) { + rd_grid_type *rd_grid = rd_grid_safe_cast(arg); + rd_grid_free(rd_grid); } -void ecl_grid_get_distance(const ecl_grid_type *grid, int global_index1, - int global_index2, double *dx, double *dy, - double *dz) { - ecl_cell_type *cell1 = ecl_grid_get_cell(grid, global_index1); - ecl_cell_type *cell2 = ecl_grid_get_cell(grid, global_index2); +void rd_grid_get_distance(const rd_grid_type *grid, int global_index1, + int global_index2, double *dx, double *dy, + double *dz) { + rd_cell_type *cell1 = rd_grid_get_cell(grid, global_index1); + rd_cell_type *cell2 = rd_grid_get_cell(grid, global_index2); - ecl_cell_assert_center(cell1); - ecl_cell_assert_center(cell2); + rd_cell_assert_center(cell1); + rd_cell_assert_center(cell2); { *dx = cell1->center.x - cell2->center.x; *dy = cell1->center.y - cell2->center.y; @@ -4692,7 +4665,7 @@ void ecl_grid_get_distance(const ecl_grid_type *grid, int global_index1, */ -bool ecl_grid_ijk_valid(const ecl_grid_type *grid, int i, int j, int k) { +bool rd_grid_ijk_valid(const rd_grid_type *grid, int i, int j, int k) { bool OK = false; if (i >= 0 && i < grid->nx) @@ -4703,8 +4676,8 @@ bool ecl_grid_ijk_valid(const ecl_grid_type *grid, int i, int j, int k) { return OK; } -void ecl_grid_get_dims(const ecl_grid_type *grid, int *nx, int *ny, int *nz, - int *active_size) { +void rd_grid_get_dims(const rd_grid_type *grid, int *nx, int *ny, int *nz, + int *active_size) { if (nx != NULL) *nx = grid->nx; if (ny != NULL) @@ -4715,24 +4688,22 @@ void ecl_grid_get_dims(const ecl_grid_type *grid, int *nx, int *ny, int *nz, *active_size = grid->total_active; } -int ecl_grid_get_nz(const ecl_grid_type *grid) { return grid->nz; } +int rd_grid_get_nz(const rd_grid_type *grid) { return grid->nz; } -int ecl_grid_get_nx(const ecl_grid_type *grid) { return grid->nx; } +int rd_grid_get_nx(const rd_grid_type *grid) { return grid->nx; } -int ecl_grid_get_ny(const ecl_grid_type *grid) { return grid->ny; } +int rd_grid_get_ny(const rd_grid_type *grid) { return grid->ny; } -int ecl_grid_get_nactive(const ecl_grid_type *grid) { - return grid->total_active; -} +int rd_grid_get_nactive(const rd_grid_type *grid) { return grid->total_active; } -grid_dims_type ecl_grid_iget_dims(const ecl_grid_type *grid, int grid_nr) { +grid_dims_type rd_grid_iget_dims(const rd_grid_type *grid, int grid_nr) { grid_dims_type dims; - const ecl_grid_type *lgr; + const rd_grid_type *lgr; if (grid_nr == 0) lgr = grid; else - lgr = ecl_grid_iget_lgr(grid, grid_nr - 1); + lgr = rd_grid_iget_lgr(grid, grid_nr - 1); dims.nx = lgr->nx; dims.ny = lgr->ny; @@ -4742,32 +4713,32 @@ grid_dims_type ecl_grid_iget_dims(const ecl_grid_type *grid, int grid_nr) { return dims; } -int ecl_grid_get_nactive_fracture(const ecl_grid_type *grid) { +int rd_grid_get_nactive_fracture(const rd_grid_type *grid) { return grid->total_active_fracture; } -int ecl_grid_get_parent_cell1(const ecl_grid_type *grid, int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +int rd_grid_get_parent_cell1(const rd_grid_type *grid, int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); return cell->host_cell; } -int ecl_grid_get_parent_cell3(const ecl_grid_type *grid, int i, int j, int k) { - int global_index = ecl_grid_get_global_index__(grid, i, j, k); - return ecl_grid_get_parent_cell1(grid, global_index); +int rd_grid_get_parent_cell3(const rd_grid_type *grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index__(grid, i, j, k); + return rd_grid_get_parent_cell1(grid, global_index); } /** Converts: (i,j,k) -> global_index. i,j,k are zero offset. */ -int ecl_grid_get_global_index3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - if (ecl_grid_ijk_valid(ecl_grid, i, j, k)) - return ecl_grid_get_global_index__(ecl_grid, i, j, k); +int rd_grid_get_global_index3(const rd_grid_type *rd_grid, int i, int j, + int k) { + if (rd_grid_ijk_valid(rd_grid, i, j, k)) + return rd_grid_get_global_index__(rd_grid, i, j, k); else { util_abort("%s: i,j,k = (%d,%d,%d) is invalid:\n\n nx: [0,%d>\n ny: " "[0,%d>\n nz: [0,%d>\n", - __func__, i, j, k, ecl_grid->nx, ecl_grid->ny, ecl_grid->nz); + __func__, i, j, k, rd_grid->nx, rd_grid->ny, rd_grid->nz); return -1; /* Compiler shut up. */ } } @@ -4776,14 +4747,13 @@ int ecl_grid_get_global_index3(const ecl_grid_type *ecl_grid, int i, int j, Converts: active_index -> global_index */ -int ecl_grid_get_global_index1A(const ecl_grid_type *ecl_grid, - int active_index) { - return ecl_grid->inv_index_map[active_index]; +int rd_grid_get_global_index1A(const rd_grid_type *rd_grid, int active_index) { + return rd_grid->inv_index_map[active_index]; } -int ecl_grid_get_global_index1F(const ecl_grid_type *ecl_grid, - int active_fracture_index) { - return ecl_grid->inv_fracture_index_map[active_fracture_index]; +int rd_grid_get_global_index1F(const rd_grid_type *rd_grid, + int active_fracture_index) { + return rd_grid->inv_fracture_index_map[active_fracture_index]; } /** @@ -4793,11 +4763,11 @@ int ecl_grid_get_global_index1F(const ecl_grid_type *ecl_grid, Will return -1 if the cell is not active. */ -int ecl_grid_get_active_index3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - int global_index = ecl_grid_get_global_index3( - ecl_grid, i, j, k); /* In range: [0,nx*ny*nz) */ - return ecl_grid_get_active_index1(ecl_grid, global_index); +int rd_grid_get_active_index3(const rd_grid_type *rd_grid, int i, int j, + int k) { + int global_index = rd_grid_get_global_index3( + rd_grid, i, j, k); /* In range: [0,nx*ny*nz) */ + return rd_grid_get_active_index1(rd_grid, global_index); } /** @@ -4806,16 +4776,15 @@ int ecl_grid_get_active_index3(const ecl_grid_type *ecl_grid, int i, int j, Will return -1 if the cell is not active. */ -int ecl_grid_get_active_index1(const ecl_grid_type *ecl_grid, - int global_index) { - return ecl_grid->index_map[global_index]; +int rd_grid_get_active_index1(const rd_grid_type *rd_grid, int global_index) { + return rd_grid->index_map[global_index]; } -int ecl_grid_get_active_fracture_index3(const ecl_grid_type *ecl_grid, int i, - int j, int k) { - int global_index = ecl_grid_get_global_index3( - ecl_grid, i, j, k); /* In range: [0,nx*ny*nz) */ - return ecl_grid_get_active_fracture_index1(ecl_grid, global_index); +int rd_grid_get_active_fracture_index3(const rd_grid_type *rd_grid, int i, + int j, int k) { + int global_index = rd_grid_get_global_index3( + rd_grid, i, j, k); /* In range: [0,nx*ny*nz) */ + return rd_grid_get_active_fracture_index1(rd_grid, global_index); } /** @@ -4824,12 +4793,12 @@ int ecl_grid_get_active_fracture_index3(const ecl_grid_type *ecl_grid, int i, Will return -1 if the cell is not active. */ -int ecl_grid_get_active_fracture_index1(const ecl_grid_type *ecl_grid, - int global_index) { - if (ecl_grid->fracture_index_map == NULL) +int rd_grid_get_active_fracture_index1(const rd_grid_type *rd_grid, + int global_index) { + if (rd_grid->fracture_index_map == NULL) return -1; else - return ecl_grid->fracture_index_map[global_index]; + return rd_grid->fracture_index_map[global_index]; } /* @@ -4838,8 +4807,8 @@ int ecl_grid_get_active_fracture_index1(const ecl_grid_type *ecl_grid, This function returns C-based zero offset indices. cell_ */ -void ecl_grid_get_ijk1(const ecl_grid_type *grid, int global_index, int *i, - int *j, int *k) { +void rd_grid_get_ijk1(const rd_grid_type *grid, int global_index, int *i, + int *j, int *k) { *k = global_index / (grid->nx * grid->ny); global_index -= (*k) * (grid->nx * grid->ny); *j = global_index / grid->nx; @@ -4851,15 +4820,15 @@ void ecl_grid_get_ijk1(const ecl_grid_type *grid, int global_index, int *i, Converts active_index -> (i,j,k) */ -void ecl_grid_get_ijk1A(const ecl_grid_type *ecl_grid, int active_index, int *i, - int *j, int *k) { - if (active_index >= 0 && active_index < ecl_grid->total_active) { - int global_index = ecl_grid_get_global_index1A(ecl_grid, active_index); - ecl_grid_get_ijk1(ecl_grid, global_index, i, j, k); +void rd_grid_get_ijk1A(const rd_grid_type *rd_grid, int active_index, int *i, + int *j, int *k) { + if (active_index >= 0 && active_index < rd_grid->total_active) { + int global_index = rd_grid_get_global_index1A(rd_grid, active_index); + rd_grid_get_ijk1(rd_grid, global_index, i, j, k); } else util_abort("%s: error active_index:%d invalid - grid has only:%d " "active cells. \n", - __func__, active_index, ecl_grid->total_active); + __func__, active_index, rd_grid->total_active); } /* @@ -4872,10 +4841,10 @@ void ecl_grid_get_ijk1A(const ecl_grid_type *ecl_grid, int active_index, int *i, actually is on the inside of the cell. */ -void ecl_grid_get_xyz1(const ecl_grid_type *grid, int global_index, - double *xpos, double *ypos, double *zpos) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); - ecl_cell_assert_center(cell); +void rd_grid_get_xyz1(const rd_grid_type *grid, int global_index, double *xpos, + double *ypos, double *zpos) { + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); + rd_cell_assert_center(cell); { *xpos = cell->center.x; *ypos = cell->center.y; @@ -4883,10 +4852,10 @@ void ecl_grid_get_xyz1(const ecl_grid_type *grid, int global_index, } } -void ecl_grid_get_xyz3(const ecl_grid_type *grid, int i, int j, int k, - double *xpos, double *ypos, double *zpos) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, k); - ecl_grid_get_xyz1(grid, global_index, xpos, ypos, zpos); +void rd_grid_get_xyz3(const rd_grid_type *grid, int i, int j, int k, + double *xpos, double *ypos, double *zpos) { + const int global_index = rd_grid_get_global_index__(grid, i, j, k); + rd_grid_get_xyz1(grid, global_index, xpos, ypos, zpos); } /** @@ -4895,11 +4864,11 @@ void ecl_grid_get_xyz3(const ecl_grid_type *grid, int i, int j, int k, tetraheder decomposition for the numbering of the corners. */ -void ecl_grid_get_cell_corner_xyz1(const ecl_grid_type *grid, int global_index, - int corner_nr, double *xpos, double *ypos, - double *zpos) { +void rd_grid_get_cell_corner_xyz1(const rd_grid_type *grid, int global_index, + int corner_nr, double *xpos, double *ypos, + double *zpos) { if ((corner_nr >= 0) && (corner_nr <= 7)) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); const point_type point = cell->corner_list[corner_nr]; *xpos = point.x; *ypos = point.y; @@ -4907,9 +4876,9 @@ void ecl_grid_get_cell_corner_xyz1(const ecl_grid_type *grid, int global_index, } } -void ecl_grid_export_cell_corners1(const ecl_grid_type *grid, int global_index, - double *x, double *y, double *z) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +void rd_grid_export_cell_corners1(const rd_grid_type *grid, int global_index, + double *x, double *y, double *z) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); for (int i = 0; i < 8; i++) { const point_type point = cell->corner_list[i]; x[i] = point.x; @@ -4918,16 +4887,16 @@ void ecl_grid_export_cell_corners1(const ecl_grid_type *grid, int global_index, } } -void ecl_grid_get_cell_corner_xyz3(const ecl_grid_type *grid, int i, int j, - int k, int corner_nr, double *xpos, - double *ypos, double *zpos) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, k); - ecl_grid_get_cell_corner_xyz1(grid, global_index, corner_nr, xpos, ypos, - zpos); +void rd_grid_get_cell_corner_xyz3(const rd_grid_type *grid, int i, int j, int k, + int corner_nr, double *xpos, double *ypos, + double *zpos) { + const int global_index = rd_grid_get_global_index__(grid, i, j, k); + rd_grid_get_cell_corner_xyz1(grid, global_index, corner_nr, xpos, ypos, + zpos); } -void ecl_grid_get_corner_xyz(const ecl_grid_type *grid, int i, int j, int k, - double *xpos, double *ypos, double *zpos) { +void rd_grid_get_corner_xyz(const rd_grid_type *grid, int i, int j, int k, + double *xpos, double *ypos, double *zpos) { if (i < 0 || i > grid->nx) util_abort("%s: invalid i value:%d Valid range: [0,%d] \n", __func__, i, grid->nx); @@ -4957,46 +4926,45 @@ void ecl_grid_get_corner_xyz(const ecl_grid_type *grid, int i, int j, int k, corner_nr += 4; } - ecl_grid_get_cell_corner_xyz3(grid, i, j, k, corner_nr, xpos, ypos, - zpos); + rd_grid_get_cell_corner_xyz3(grid, i, j, k, corner_nr, xpos, ypos, + zpos); } } -void ecl_grid_get_xyz1A(const ecl_grid_type *grid, int active_index, - double *xpos, double *ypos, double *zpos) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - ecl_grid_get_xyz1(grid, global_index, xpos, ypos, zpos); +void rd_grid_get_xyz1A(const rd_grid_type *grid, int active_index, double *xpos, + double *ypos, double *zpos) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + rd_grid_get_xyz1(grid, global_index, xpos, ypos, zpos); } -double ecl_grid_get_cdepth1(const ecl_grid_type *grid, int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); - ecl_cell_assert_center(cell); +double rd_grid_get_cdepth1(const rd_grid_type *grid, int global_index) { + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); + rd_cell_assert_center(cell); return cell->center.z; } -double ecl_grid_get_cdepth3(const ecl_grid_type *grid, int i, int j, int k) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, k); - return ecl_grid_get_cdepth1(grid, global_index); +double rd_grid_get_cdepth3(const rd_grid_type *grid, int i, int j, int k) { + const int global_index = rd_grid_get_global_index__(grid, i, j, k); + return rd_grid_get_cdepth1(grid, global_index); } -double ecl_grid_get_cdepth1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_cdepth1(grid, global_index); +double rd_grid_get_cdepth1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_cdepth1(grid, global_index); } -int ecl_grid_locate_depth(const ecl_grid_type *grid, double depth, int i, - int j) { - if (depth < ecl_grid_get_top2(grid, i, j)) +int rd_grid_locate_depth(const rd_grid_type *grid, double depth, int i, int j) { + if (depth < rd_grid_get_top2(grid, i, j)) return -1; - else if (depth >= ecl_grid_get_bottom2(grid, i, j)) + else if (depth >= rd_grid_get_bottom2(grid, i, j)) return -1 * grid->nz; else { int k = 0; - double bottom = ecl_grid_get_top3(grid, i, j, k); + double bottom = rd_grid_get_top3(grid, i, j, k); while (true) { double top = bottom; - bottom = ecl_grid_get_bottom3(grid, i, j, k); + bottom = rd_grid_get_bottom3(grid, i, j, k); if ((depth >= top) && (depth < bottom)) return k; @@ -5013,8 +4981,8 @@ int ecl_grid_locate_depth(const ecl_grid_type *grid, double depth, int i, Returns the depth of the top surface of the cell. */ -double ecl_grid_get_top1(const ecl_grid_type *grid, int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +double rd_grid_get_top1(const rd_grid_type *grid, int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); double depth = 0; int ij; @@ -5024,33 +4992,33 @@ double ecl_grid_get_top1(const ecl_grid_type *grid, int global_index) { return depth * 0.25; } -double ecl_grid_get_top3(const ecl_grid_type *grid, int i, int j, int k) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, k); - return ecl_grid_get_top1(grid, global_index); +double rd_grid_get_top3(const rd_grid_type *grid, int i, int j, int k) { + const int global_index = rd_grid_get_global_index__(grid, i, j, k); + return rd_grid_get_top1(grid, global_index); } -double ecl_grid_get_top2(const ecl_grid_type *grid, int i, int j) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, 0); - return ecl_grid_get_top1(grid, global_index); +double rd_grid_get_top2(const rd_grid_type *grid, int i, int j) { + const int global_index = rd_grid_get_global_index__(grid, i, j, 0); + return rd_grid_get_top1(grid, global_index); } -double ecl_grid_get_bottom2(const ecl_grid_type *grid, int i, int j) { +double rd_grid_get_bottom2(const rd_grid_type *grid, int i, int j) { const int global_index = - ecl_grid_get_global_index__(grid, i, j, grid->nz - 1); - return ecl_grid_get_bottom1(grid, global_index); + rd_grid_get_global_index__(grid, i, j, grid->nz - 1); + return rd_grid_get_bottom1(grid, global_index); } -double ecl_grid_get_top1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_top1(grid, global_index); +double rd_grid_get_top1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_top1(grid, global_index); } /** Returns the depth of the bottom surface of the cell. */ -double ecl_grid_get_bottom1(const ecl_grid_type *grid, int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +double rd_grid_get_bottom1(const rd_grid_type *grid, int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); double depth = 0; int ij; @@ -5060,18 +5028,18 @@ double ecl_grid_get_bottom1(const ecl_grid_type *grid, int global_index) { return depth * 0.25; } -double ecl_grid_get_bottom3(const ecl_grid_type *grid, int i, int j, int k) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, k); - return ecl_grid_get_bottom1(grid, global_index); +double rd_grid_get_bottom3(const rd_grid_type *grid, int i, int j, int k) { + const int global_index = rd_grid_get_global_index__(grid, i, j, k); + return rd_grid_get_bottom1(grid, global_index); } -double ecl_grid_get_bottom1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_bottom1(grid, global_index); +double rd_grid_get_bottom1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_bottom1(grid, global_index); } -double ecl_grid_get_cell_dz1(const ecl_grid_type *grid, int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +double rd_grid_get_cell_dz1(const rd_grid_type *grid, int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); double dz = 0; int ij; @@ -5081,33 +5049,32 @@ double ecl_grid_get_cell_dz1(const ecl_grid_type *grid, int global_index) { return dz * 0.25; } -double ecl_grid_get_cell_dz3(const ecl_grid_type *grid, int i, int j, int k) { - const int global_index = ecl_grid_get_global_index3(grid, i, j, k); - return ecl_grid_get_cell_dz1(grid, global_index); +double rd_grid_get_cell_dz3(const rd_grid_type *grid, int i, int j, int k) { + const int global_index = rd_grid_get_global_index3(grid, i, j, k); + return rd_grid_get_cell_dz1(grid, global_index); } -double ecl_grid_get_cell_dz1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_cell_dz1(grid, global_index); +double rd_grid_get_cell_dz1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_cell_dz1(grid, global_index); } -double ecl_grid_get_cell_thickness1(const ecl_grid_type *grid, - int global_index) { - return ecl_grid_get_cell_dz1(grid, global_index); +double rd_grid_get_cell_thickness1(const rd_grid_type *grid, int global_index) { + return rd_grid_get_cell_dz1(grid, global_index); } -double ecl_grid_get_cell_thickness3(const ecl_grid_type *grid, int i, int j, - int k) { - return ecl_grid_get_cell_dz3(grid, i, j, k); +double rd_grid_get_cell_thickness3(const rd_grid_type *grid, int i, int j, + int k) { + return rd_grid_get_cell_dz3(grid, i, j, k); } -double ecl_grid_get_cell_thickness1A(const ecl_grid_type *grid, - int active_index) { - return ecl_grid_get_cell_dz1A(grid, active_index); +double rd_grid_get_cell_thickness1A(const rd_grid_type *grid, + int active_index) { + return rd_grid_get_cell_dz1A(grid, active_index); } -double ecl_grid_get_cell_dx1(const ecl_grid_type *grid, int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +double rd_grid_get_cell_dx1(const rd_grid_type *grid, int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); double dx = 0; double dy = 0; int c; @@ -5122,14 +5089,14 @@ double ecl_grid_get_cell_dx1(const ecl_grid_type *grid, int global_index) { return sqrt(dx * dx + dy * dy); } -double ecl_grid_get_cell_dx3(const ecl_grid_type *grid, int i, int j, int k) { - const int global_index = ecl_grid_get_global_index3(grid, i, j, k); - return ecl_grid_get_cell_dx1(grid, global_index); +double rd_grid_get_cell_dx3(const rd_grid_type *grid, int i, int j, int k) { + const int global_index = rd_grid_get_global_index3(grid, i, j, k); + return rd_grid_get_cell_dx1(grid, global_index); } -double ecl_grid_get_cell_dx1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_cell_dx1(grid, global_index); +double rd_grid_get_cell_dx1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_cell_dx1(grid, global_index); } /* @@ -5145,8 +5112,8 @@ double ecl_grid_get_cell_dx1A(const ecl_grid_type *grid, int active_index) { does generally not hold. */ -double ecl_grid_get_cell_dy1(const ecl_grid_type *grid, int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +double rd_grid_get_cell_dy1(const rd_grid_type *grid, int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); double dx = 0; double dy = 0; @@ -5164,100 +5131,99 @@ double ecl_grid_get_cell_dy1(const ecl_grid_type *grid, int global_index) { return sqrt(dx * dx + dy * dy); } -double ecl_grid_get_cell_dy3(const ecl_grid_type *grid, int i, int j, int k) { - const int global_index = ecl_grid_get_global_index3(grid, i, j, k); - return ecl_grid_get_cell_dy1(grid, global_index); +double rd_grid_get_cell_dy3(const rd_grid_type *grid, int i, int j, int k) { + const int global_index = rd_grid_get_global_index3(grid, i, j, k); + return rd_grid_get_cell_dy1(grid, global_index); } -double ecl_grid_get_cell_dy1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_cell_dy1(grid, global_index); +double rd_grid_get_cell_dy1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_cell_dy1(grid, global_index); } -const nnc_info_type *ecl_grid_get_cell_nnc_info1(const ecl_grid_type *grid, - int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +const nnc_info_type *rd_grid_get_cell_nnc_info1(const rd_grid_type *grid, + int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); return cell->nnc_info; } -const nnc_info_type *ecl_grid_get_cell_nnc_info3(const ecl_grid_type *grid, - int i, int j, int k) { - const int global_index = ecl_grid_get_global_index3(grid, i, j, k); - return ecl_grid_get_cell_nnc_info1(grid, global_index); +const nnc_info_type *rd_grid_get_cell_nnc_info3(const rd_grid_type *grid, int i, + int j, int k) { + const int global_index = rd_grid_get_global_index3(grid, i, j, k); + return rd_grid_get_cell_nnc_info1(grid, global_index); } /* Global index in [0,...,nx*ny*nz) */ -bool ecl_grid_cell_active1(const ecl_grid_type *ecl_grid, int global_index) { - if (ecl_grid->index_map[global_index] >= 0) +bool rd_grid_cell_active1(const rd_grid_type *rd_grid, int global_index) { + if (rd_grid->index_map[global_index] >= 0) return true; else return false; } -bool ecl_grid_cell_active3(const ecl_grid_type *ecl_grid, int i, int j, int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_cell_active1(ecl_grid, global_index); +bool rd_grid_cell_active3(const rd_grid_type *rd_grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_cell_active1(rd_grid, global_index); } -bool ecl_grid_cell_invalid1(const ecl_grid_type *ecl_grid, int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); +bool rd_grid_cell_invalid1(const rd_grid_type *rd_grid, int global_index) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); return GET_CELL_FLAG(cell, CELL_FLAG_TAINTED); } -bool ecl_grid_cell_invalid3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_cell_invalid1(ecl_grid, global_index); +bool rd_grid_cell_invalid3(const rd_grid_type *rd_grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_cell_invalid1(rd_grid, global_index); } -double ecl_grid_cell_invalid1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_cell_invalid1(grid, global_index); +double rd_grid_cell_invalid1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_cell_invalid1(grid, global_index); } -bool ecl_grid_cell_valid1(const ecl_grid_type *ecl_grid, int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); +bool rd_grid_cell_valid1(const rd_grid_type *rd_grid, int global_index) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); if (GET_CELL_FLAG(cell, CELL_FLAG_TAINTED)) return false; else return (GET_CELL_FLAG(cell, CELL_FLAG_VALID)); } -bool ecl_grid_cell_valid3(const ecl_grid_type *ecl_grid, int i, int j, int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_cell_valid1(ecl_grid, global_index); +bool rd_grid_cell_valid3(const rd_grid_type *rd_grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_cell_valid1(rd_grid, global_index); } -double ecl_grid_cell_valid1A(const ecl_grid_type *grid, int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_cell_valid1(grid, global_index); +double rd_grid_cell_valid1A(const rd_grid_type *grid, int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_cell_valid1(grid, global_index); } -static void __assert_main_grid(const ecl_grid_type *ecl_grid) { - if (ecl_grid->lgr_nr != ECL_GRID_MAINGRID_LGR_NR) +static void __assert_main_grid(const rd_grid_type *rd_grid) { + if (rd_grid->lgr_nr != RD_GRID_MAINGRID_LGR_NR) util_abort("%s: tried to get LGR grid from another LGR_grid - only " "main grid can be used as first input \n", __func__); } /** - This functon will return a a ecl_grid instance corresponding to the + This functon will return a a rd_grid instance corresponding to the lgr with name lgr_name. The function will fail HARD if no lgr with this name is installed under the present main grid; check first - with ecl_grid_has_lgr() if you are whimp. + with rd_grid_has_lgr() if you are whimp. Leading/trailing spaces on lgr_name are stripped prior to the hash lookup. */ -ecl_grid_type *ecl_grid_get_lgr(const ecl_grid_type *main_grid, - const char *__lgr_name) { +rd_grid_type *rd_grid_get_lgr(const rd_grid_type *main_grid, + const char *__lgr_name) { __assert_main_grid(main_grid); { char *lgr_name = util_alloc_strip_copy(__lgr_name); - ecl_grid_type *lgr_grid = main_grid->LGR_hash.at(lgr_name); + rd_grid_type *lgr_grid = main_grid->LGR_hash.at(lgr_name); free(lgr_name); return lgr_grid; } @@ -5268,7 +5234,7 @@ ecl_grid_type *ecl_grid_get_lgr(const ecl_grid_type *main_grid, __lgr_name. Leading/trailing spaces are stripped before checking. */ -bool ecl_grid_has_lgr(const ecl_grid_type *main_grid, const char *__lgr_name) { +bool rd_grid_has_lgr(const rd_grid_type *main_grid, const char *__lgr_name) { if (!__lgr_name) return false; @@ -5281,7 +5247,7 @@ bool ecl_grid_has_lgr(const ecl_grid_type *main_grid, const char *__lgr_name) { } } -bool ecl_grid_has_lgr_nr(const ecl_grid_type *main_grid, int lgr_nr) { +bool rd_grid_has_lgr_nr(const rd_grid_type *main_grid, int lgr_nr) { __assert_main_grid(main_grid); { if (int_vector_size(main_grid->lgr_index_map) > lgr_nr) @@ -5291,11 +5257,11 @@ bool ecl_grid_has_lgr_nr(const ecl_grid_type *main_grid, int lgr_nr) { } } -int ecl_grid_get_num_coarse_groups(const ecl_grid_type *main_grid) { +int rd_grid_get_num_coarse_groups(const rd_grid_type *main_grid) { return vector_get_size(main_grid->coarse_cells); } -bool ecl_grid_have_coarse_cells(const ecl_grid_type *main_grid) { +bool rd_grid_have_coarse_cells(const rd_grid_type *main_grid) { if (vector_get_size(main_grid->coarse_cells) == 0) return false; else @@ -5306,22 +5272,21 @@ bool ecl_grid_have_coarse_cells(const ecl_grid_type *main_grid) { Return the number of LGR's associated with this main grid instance. The main grid is not counted. */ -int ecl_grid_get_num_lgr(const ecl_grid_type *main_grid) { +int rd_grid_get_num_lgr(const rd_grid_type *main_grid) { __assert_main_grid(main_grid); return vector_get_size(main_grid->LGR_list); } /** The lgr_index has zero offset - ecl_grid_iget_lgr( ecl_grid , 0); will return the first lgr - ecl_grid_iget_lgr( ecl_grid , 1); will return the second lgr + rd_grid_iget_lgr( rd_grid , 0); will return the first lgr + rd_grid_iget_lgr( rd_grid , 1); will return the second lgr The method will fail HARD if lgr_index is out of bounds. */ -ecl_grid_type *ecl_grid_iget_lgr(const ecl_grid_type *main_grid, - int lgr_index) { +rd_grid_type *rd_grid_iget_lgr(const rd_grid_type *main_grid, int lgr_index) { __assert_main_grid(main_grid); - return (ecl_grid_type *)vector_iget(main_grid->LGR_list, lgr_index); + return (rd_grid_type *)vector_iget(main_grid->LGR_list, lgr_index); } /* @@ -5334,12 +5299,12 @@ ecl_grid_type *ecl_grid_iget_lgr(const ecl_grid_type *main_grid, lgr_nr is 0 for all grids. */ -ecl_grid_type *ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type *main_grid, - int lgr_nr) { +rd_grid_type *rd_grid_get_lgr_from_lgr_nr(const rd_grid_type *main_grid, + int lgr_nr) { __assert_main_grid(main_grid); { int lgr_index = int_vector_iget(main_grid->lgr_index_map, lgr_nr); - return (ecl_grid_type *)vector_iget(main_grid->LGR_list, lgr_index); + return (rd_grid_type *)vector_iget(main_grid->LGR_list, lgr_index); } } @@ -5357,29 +5322,29 @@ ecl_grid_type *ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type *main_grid, deeper into the refinement hierarchy. */ -const ecl_grid_type *ecl_grid_get_cell_lgr1(const ecl_grid_type *grid, - int global_index) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +const rd_grid_type *rd_grid_get_cell_lgr1(const rd_grid_type *grid, + int global_index) { + const rd_cell_type *cell = rd_grid_get_cell(grid, global_index); return cell->lgr; } -const ecl_grid_type *ecl_grid_get_cell_lgr3(const ecl_grid_type *grid, int i, - int j, int k) { - const int global_index = ecl_grid_get_global_index__(grid, i, j, k); - return ecl_grid_get_cell_lgr1(grid, global_index); +const rd_grid_type *rd_grid_get_cell_lgr3(const rd_grid_type *grid, int i, + int j, int k) { + const int global_index = rd_grid_get_global_index__(grid, i, j, k); + return rd_grid_get_cell_lgr1(grid, global_index); } -const ecl_grid_type *ecl_grid_get_cell_lgr1A(const ecl_grid_type *grid, - int active_index) { - const int global_index = ecl_grid_get_global_index1A(grid, active_index); - return ecl_grid_get_cell_lgr1(grid, global_index); +const rd_grid_type *rd_grid_get_cell_lgr1A(const rd_grid_type *grid, + int active_index) { + const int global_index = rd_grid_get_global_index1A(grid, active_index); + return rd_grid_get_cell_lgr1(grid, global_index); } /** Will return the global grid for a lgr. If the input grid is indeed a global grid itself the function will return NULL. */ -const ecl_grid_type *ecl_grid_get_global_grid(const ecl_grid_type *grid) { +const rd_grid_type *rd_grid_get_global_grid(const rd_grid_type *grid) { return grid->global_grid; } @@ -5387,43 +5352,42 @@ const ecl_grid_type *ecl_grid_get_global_grid(const ecl_grid_type *grid) { Allocates a stringlist instance with the lookup names of the lgr names in this grid. */ -stringlist_type *ecl_grid_alloc_lgr_name_list(const ecl_grid_type *ecl_grid) { - __assert_main_grid(ecl_grid); +stringlist_type *rd_grid_alloc_lgr_name_list(const rd_grid_type *rd_grid) { + __assert_main_grid(rd_grid); { stringlist_type *s = stringlist_alloc_new(); - for (const auto &lgr_pair : ecl_grid->LGR_hash) + for (const auto &lgr_pair : rd_grid->LGR_hash) stringlist_append_copy(s, lgr_pair.first.c_str()); return s; } } -const char *ecl_grid_iget_lgr_name(const ecl_grid_type *ecl_grid, - int lgr_index) { - __assert_main_grid(ecl_grid); - if (lgr_index < (vector_get_size(ecl_grid->LGR_list))) { - const ecl_grid_type *lgr = - (const ecl_grid_type *)vector_iget(ecl_grid->LGR_list, lgr_index); +const char *rd_grid_iget_lgr_name(const rd_grid_type *rd_grid, int lgr_index) { + __assert_main_grid(rd_grid); + if (lgr_index < (vector_get_size(rd_grid->LGR_list))) { + const rd_grid_type *lgr = + (const rd_grid_type *)vector_iget(rd_grid->LGR_list, lgr_index); return lgr->name; } else return NULL; } -const char *ecl_grid_get_lgr_name(const ecl_grid_type *ecl_grid, int lgr_nr) { - __assert_main_grid(ecl_grid); +const char *rd_grid_get_lgr_name(const rd_grid_type *rd_grid, int lgr_nr) { + __assert_main_grid(rd_grid); if (lgr_nr == 0) - return ecl_grid->name; + return rd_grid->name; { - int lgr_index = int_vector_iget(ecl_grid->lgr_index_map, lgr_nr); - return ecl_grid_iget_lgr_name(ecl_grid, lgr_index); + int lgr_index = int_vector_iget(rd_grid->lgr_index_map, lgr_nr); + return rd_grid_iget_lgr_name(rd_grid, lgr_index); } } -int ecl_grid_get_lgr_nr_from_name(const ecl_grid_type *grid, const char *name) { +int rd_grid_get_lgr_nr_from_name(const rd_grid_type *grid, const char *name) { __assert_main_grid(grid); if (strcmp(name, grid->name) == 0) return 0; else { - const ecl_grid_type *lgr = ecl_grid_get_lgr(grid, name); + const rd_grid_type *lgr = rd_grid_get_lgr(grid, name); return lgr->lgr_nr; } } @@ -5436,36 +5400,33 @@ int ecl_grid_get_lgr_nr_from_name(const ecl_grid_type *grid, const char *name) { gridhead). */ -int ecl_grid_get_lgr_nr(const ecl_grid_type *ecl_grid) { - return ecl_grid->lgr_nr; -} +int rd_grid_get_lgr_nr(const rd_grid_type *rd_grid) { return rd_grid->lgr_nr; } -const char *ecl_grid_get_name(const ecl_grid_type *ecl_grid) { - return ecl_grid->name; +const char *rd_grid_get_name(const rd_grid_type *rd_grid) { + return rd_grid->name; } -int ecl_grid_get_global_size(const ecl_grid_type *ecl_grid) { - return ecl_grid->nx * ecl_grid->ny * ecl_grid->nz; +int rd_grid_get_global_size(const rd_grid_type *rd_grid) { + return rd_grid->nx * rd_grid->ny * rd_grid->nz; } -int ecl_grid_get_active_size(const ecl_grid_type *ecl_grid) { - return ecl_grid_get_nactive(ecl_grid); +int rd_grid_get_active_size(const rd_grid_type *rd_grid) { + return rd_grid_get_nactive(rd_grid); } -bool ecl_grid_cell_regular1(const ecl_grid_type *ecl_grid, int global_index) { +bool rd_grid_cell_regular1(const rd_grid_type *rd_grid, int global_index) { double x, y, z; - ecl_grid_get_xyz1(ecl_grid, global_index, &x, &y, &z); - return ecl_grid_cell_contains_xyz1(ecl_grid, global_index, x, y, z); + rd_grid_get_xyz1(rd_grid, global_index, &x, &y, &z); + return rd_grid_cell_contains_xyz1(rd_grid, global_index, x, y, z); } -bool ecl_grid_cell_regular3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_cell_regular1(ecl_grid, global_index); +bool rd_grid_cell_regular3(const rd_grid_type *rd_grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_cell_regular1(rd_grid, global_index); } /* - The function ecl_grid_get_cell_twist() is an attempt to measure how + The function rd_grid_get_cell_twist() is an attempt to measure how twisted or deformed a cell is. For a 'normal' cell the corners [0..3] will z value <= the corners [4..7]. This function will count the number of times the z value from the [4..7] is lower than the @@ -5473,147 +5434,145 @@ bool ecl_grid_cell_regular3(const ecl_grid_type *ecl_grid, int i, int j, The purpose of the function is to detect twisted cells before embarking on cell contains calculation. The current - ecl_cell_contains_xyz( ) implementation will fail badly for twisted + rd_cell_contains_xyz( ) implementation will fail badly for twisted cells. If the function return 4 you probably have an inverted z-axis! */ -int ecl_grid_get_cell_twist1(const ecl_grid_type *ecl_grid, int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); - return ecl_cell_get_twist(cell); +int rd_grid_get_cell_twist1(const rd_grid_type *rd_grid, int global_index) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); + return rd_cell_get_twist(cell); } -int ecl_grid_get_cell_twist3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_get_cell_twist1(ecl_grid, global_index); +int rd_grid_get_cell_twist3(const rd_grid_type *rd_grid, int i, int j, int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_get_cell_twist1(rd_grid, global_index); } -double ecl_grid_get_cell_volume1(const ecl_grid_type *ecl_grid, - int global_index) { - ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); +double rd_grid_get_cell_volume1(const rd_grid_type *rd_grid, int global_index) { + rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); int i, j, k; - ecl_grid_get_ijk1(ecl_grid, global_index, &i, &j, &k); - return ecl_cell_get_volume(cell); + rd_grid_get_ijk1(rd_grid, global_index, &i, &j, &k); + return rd_cell_get_volume(cell); } -double ecl_grid_get_cell_volume1A(const ecl_grid_type *ecl_grid, - int active_index) { - int global_index = ecl_grid_get_global_index1A(ecl_grid, active_index); - return ecl_grid_get_cell_volume1(ecl_grid, global_index); +double rd_grid_get_cell_volume1A(const rd_grid_type *rd_grid, + int active_index) { + int global_index = rd_grid_get_global_index1A(rd_grid, active_index); + return rd_grid_get_cell_volume1(rd_grid, global_index); } -double ecl_grid_get_cell_volume3(const ecl_grid_type *ecl_grid, int i, int j, - int k) { - int global_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - return ecl_grid_get_cell_volume1(ecl_grid, global_index); +double rd_grid_get_cell_volume3(const rd_grid_type *rd_grid, int i, int j, + int k) { + int global_index = rd_grid_get_global_index3(rd_grid, i, j, k); + return rd_grid_get_cell_volume1(rd_grid, global_index); } -void ecl_grid_summarize(const ecl_grid_type *ecl_grid) { +void rd_grid_summarize(const rd_grid_type *rd_grid) { int active_cells, nx, ny, nz; - ecl_grid_get_dims(ecl_grid, &nx, &ny, &nz, &active_cells); - printf(" Name ..................: %s \n", ecl_grid->name); - printf(" Grid nr ...............: %d \n", ecl_grid->lgr_nr); + rd_grid_get_dims(rd_grid, &nx, &ny, &nz, &active_cells); + printf(" Name ..................: %s \n", rd_grid->name); + printf(" Grid nr ...............: %d \n", rd_grid->lgr_nr); printf(" Active cells ..........: %d \n", active_cells); printf(" Active fracture cells..: %d \n", - ecl_grid_get_nactive_fracture(ecl_grid)); + rd_grid_get_nactive_fracture(rd_grid)); printf(" nx ....................: %d \n", nx); printf(" ny ....................: %d \n", ny); printf(" nz ....................: %d \n", nz); printf(" Volume ................: %d \n", nx * ny * nz); - printf(" Origo X................: %10.2f \n", ecl_grid->origo[0]); - printf(" Origo Y................: %10.2f \n", ecl_grid->origo[1]); + printf(" Origo X................: %10.2f \n", rd_grid->origo[0]); + printf(" Origo Y................: %10.2f \n", rd_grid->origo[1]); - if (ECL_GRID_MAINGRID_LGR_NR == ecl_grid->lgr_nr) { + if (RD_GRID_MAINGRID_LGR_NR == rd_grid->lgr_nr) { int grid_nr; - for (grid_nr = 1; grid_nr < vector_get_size(ecl_grid->LGR_list); + for (grid_nr = 1; grid_nr < vector_get_size(rd_grid->LGR_list); grid_nr++) { printf("\n"); - ecl_grid_summarize((const ecl_grid_type *)vector_iget_const( - ecl_grid->LGR_list, grid_nr)); + rd_grid_summarize((const rd_grid_type *)vector_iget_const( + rd_grid->LGR_list, grid_nr)); } } - ecl_grid_test_lgr_consistency(ecl_grid); + rd_grid_test_lgr_consistency(rd_grid); } /** - This function is used to translate (with the help of the ecl_grid + This function is used to translate (with the help of the rd_grid functionality) i,j,k to an index which can be used to look up an - element in the ecl_kw instance. It is just a minor convenience + element in the rd_kw instance. It is just a minor convenience function. - * If the ecl_kw instance has nx*ny*nz (i,j,k) are translated to a - global index with ecl_grid_get_global_index3(). This is typically - the case when the ecl_kw instance represents a petrophysical + * If the rd_kw instance has nx*ny*nz (i,j,k) are translated to a + global index with rd_grid_get_global_index3(). This is typically + the case when the rd_kw instance represents a petrophysical property which is e.g. loaded from a INIT file. - * If the ecl_kw instance has nactive elements the (i,j,k) indices + * If the rd_kw instance has nactive elements the (i,j,k) indices are converted to an active index with - ecl_grid_get_active_index3(). This is typically the case if the - ecl_kw instance is a solution vector which has been loaded from a + rd_grid_get_active_index3(). This is typically the case if the + rd_kw instance is a solution vector which has been loaded from a restart file. If you ask for an inactive cell the function will return -1. - * If the ecl_kw instance has neither nx*ny*nz nor nactive elements + * If the rd_kw instance has neither nx*ny*nz nor nactive elements the function will fail HARD. * The return value is double, irrespective of the type of the - underlying datatype of the ecl_kw instance - the function will + underlying datatype of the rd_kw instance - the function will fail HARD if the underlying type can not be safely converted to - double, i.e. if it is not in the set [ecl_float_type , - ecl_int_type , ecl_double_type]. + double, i.e. if it is not in the set [rd_float_type , + rd_int_type , rd_double_type]. * i,j,k: C-based zero offset grid coordinates. */ -static int ecl_grid_get_property_index__(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, - int j, int k) { - int kw_size = ecl_kw_get_size(ecl_kw); +static int rd_grid_get_property_index__(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, + int k) { + int kw_size = rd_kw_get_size(rd_kw); int lookup_index = -1; - if (kw_size == ecl_grid->nx * ecl_grid->ny * ecl_grid->nz) - lookup_index = ecl_grid_get_global_index3(ecl_grid, i, j, k); - else if (kw_size == ecl_grid->total_active) + if (kw_size == rd_grid->nx * rd_grid->ny * rd_grid->nz) + lookup_index = rd_grid_get_global_index3(rd_grid, i, j, k); + else if (kw_size == rd_grid->total_active) /* Will be set to -1 if the cell is not active. */ - lookup_index = ecl_grid_get_active_index3(ecl_grid, i, j, k); + lookup_index = rd_grid_get_active_index3(rd_grid, i, j, k); else util_abort("%s: incommensurable size ... \n", __func__); return lookup_index; } -static bool ecl_grid_get_property__(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - int k, void *value) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - if (ecl_type_is_numeric(data_type)) { +static bool rd_grid_get_property__(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k, + void *value) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + if (rd_type_is_numeric(data_type)) { int lookup_index = - ecl_grid_get_property_index__(ecl_grid, ecl_kw, i, j, k); + rd_grid_get_property_index__(rd_grid, rd_kw, i, j, k); if (lookup_index >= 0) { - ecl_kw_iget(ecl_kw, lookup_index, value); + rd_kw_iget(rd_kw, lookup_index, value); return true; } else return false; } else { util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n", - __func__, ecl_type_alloc_name(data_type), __func__); + __func__, rd_type_alloc_name(data_type), __func__); return false; } } -double ecl_grid_get_double_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - int k) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - if (ecl_type_is_double(data_type)) { +double rd_grid_get_double_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, + int k) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + if (rd_type_is_double(data_type)) { double value; - if (ecl_grid_get_property__(ecl_grid, ecl_kw, i, j, k, &value)) + if (rd_grid_get_property__(rd_grid, rd_kw, i, j, k, &value)) return value; else return -1; // (i,j,k) Points to an inactive cell. @@ -5623,13 +5582,13 @@ double ecl_grid_get_double_property(const ecl_grid_type *ecl_grid, } } -int ecl_grid_get_int_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, int k) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - if (ecl_type_is_int(data_type)) { +int rd_grid_get_int_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + if (rd_type_is_int(data_type)) { int value; - if (ecl_grid_get_property__(ecl_grid, ecl_kw, i, j, k, &value)) + if (rd_grid_get_property__(rd_grid, rd_kw, i, j, k, &value)) return value; else return -1; // (i,j,k) Points to an inactive cell. @@ -5640,14 +5599,13 @@ int ecl_grid_get_int_property(const ecl_grid_type *ecl_grid, } } -float ecl_grid_get_float_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - int k) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - if (ecl_type_is_float(data_type)) { +float rd_grid_get_float_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + if (rd_type_is_float(data_type)) { float value; - if (ecl_grid_get_property__(ecl_grid, ecl_kw, i, j, k, &value)) + if (rd_grid_get_property__(rd_grid, rd_kw, i, j, k, &value)) return value; else return -1; // (i,j,k) Points to an inactive cell. @@ -5658,84 +5616,84 @@ float ecl_grid_get_float_property(const ecl_grid_type *ecl_grid, } } -double ecl_grid_get_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, int k) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - if (ecl_type_is_numeric(data_type)) { +double rd_grid_get_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, int k) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + if (rd_type_is_numeric(data_type)) { int lookup_index = - ecl_grid_get_property_index__(ecl_grid, ecl_kw, i, j, k); + rd_grid_get_property_index__(rd_grid, rd_kw, i, j, k); if (lookup_index >= 0) - return ecl_kw_iget_as_double(ecl_kw, lookup_index); + return rd_kw_iget_as_double(rd_kw, lookup_index); else return -1; /* Tried to lookup an inactive cell. */ } else { util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n", - __func__, ecl_type_alloc_name(data_type), __func__); + __func__, rd_type_alloc_name(data_type), __func__); return -1; } } /** Will fill the double_vector instance @column with values from - ecl_kw from the column given by (i,j). If @ecl_kw has size nactive + rd_kw from the column given by (i,j). If @rd_kw has size nactive the inactive k values will not be set, i.e. you should make sure that the default value of the @column instance has been properly set beforehand. The column vector will be filled with double values, the content of - ecl_kw will be converted to double in the case INTE,REAL and DOUB + rd_kw will be converted to double in the case INTE,REAL and DOUB types, otherwsie it is crash and burn. */ -void ecl_grid_get_column_property(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, int i, int j, - double_vector_type *column) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - if (ecl_type_is_numeric(data_type)) { - int kw_size = ecl_kw_get_size(ecl_kw); +void rd_grid_get_column_property(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, int i, int j, + double_vector_type *column) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + if (rd_type_is_numeric(data_type)) { + int kw_size = rd_kw_get_size(rd_kw); bool use_global_index = false; - if (kw_size == ecl_grid->nx * ecl_grid->ny * ecl_grid->nz) + if (kw_size == rd_grid->nx * rd_grid->ny * rd_grid->nz) use_global_index = true; - else if (kw_size == ecl_grid->total_active) + else if (kw_size == rd_grid->total_active) use_global_index = false; else util_abort("%s: incommensurable sizes: nx*ny*nz = %d nactive=%d " "kw_size:%d \n", - __func__, ecl_grid->size, ecl_grid->total_active, - ecl_kw_get_size(ecl_kw)); + __func__, rd_grid->size, rd_grid->total_active, + rd_kw_get_size(rd_kw)); double_vector_reset(column); { int k; - for (k = 0; k < ecl_grid->nz; k++) { + for (k = 0; k < rd_grid->nz; k++) { if (use_global_index) { int global_index = - ecl_grid_get_global_index3(ecl_grid, i, j, k); + rd_grid_get_global_index3(rd_grid, i, j, k); double_vector_iset( - column, k, ecl_kw_iget_as_double(ecl_kw, global_index)); + column, k, rd_kw_iget_as_double(rd_kw, global_index)); } else { int active_index = - ecl_grid_get_active_index3(ecl_grid, i, j, k); + rd_grid_get_active_index3(rd_grid, i, j, k); if (active_index >= 0) double_vector_iset( column, k, - ecl_kw_iget_as_double(ecl_kw, active_index)); + rd_kw_iget_as_double(rd_kw, active_index)); } } } } else util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n", - __func__, ecl_type_alloc_name(data_type), __func__); + __func__, rd_type_alloc_name(data_type), __func__); } /** This function will look up all the indices in the grid where the - region_kw has a certain value (region_value). The ecl_kw instance + region_kw has a certain value (region_value). The rd_kw instance must be loaded beforehand, typically with the functions - ecl_kw_grdecl_fseek_kw / ecl_kw_fscanf_alloc_grdecl_data. + rd_kw_grdecl_fseek_kw / rd_kw_fscanf_alloc_grdecl_data. The two boolean flags active_only and export_active_index determine how active/inactive indieces should be handled: @@ -5749,39 +5707,39 @@ void ecl_grid_get_column_property(const ecl_grid_type *ecl_grid, cell is in the space of active cells, otherwise it is in terms of the global indexing. - Observe the following about the ecl_kw instance wth region data: + Observe the following about the rd_kw instance wth region data: * It must be of type integer - otherwise we blow up hard. The * size must be the total number of cells (should handle boxes and so on ...) Observe that there is no way to get ijk from this function, then - you must call ecl_grid_get_ijk() afterwards. the return value is + you must call rd_grid_get_ijk() afterwards. the return value is the number of cells found. */ -int ecl_grid_get_region_cells(const ecl_grid_type *ecl_grid, - const ecl_kw_type *region_kw, int region_value, - bool active_only, bool export_active_index, - int_vector_type *index_list) { +int rd_grid_get_region_cells(const rd_grid_type *rd_grid, + const rd_kw_type *region_kw, int region_value, + bool active_only, bool export_active_index, + int_vector_type *index_list) { int cells_found = 0; - if (ecl_kw_get_size(region_kw) == ecl_grid->size) { - if (ecl_type_is_int(ecl_kw_get_data_type(region_kw))) { - const int *region_ptr = (const int *)ecl_kw_iget_ptr(region_kw, 0); + if (rd_kw_get_size(region_kw) == rd_grid->size) { + if (rd_type_is_int(rd_kw_get_data_type(region_kw))) { + const int *region_ptr = (const int *)rd_kw_iget_ptr(region_kw, 0); int_vector_reset(index_list); { int global_index; - for (global_index = 0; global_index < ecl_grid->size; + for (global_index = 0; global_index < rd_grid->size; global_index++) { if (region_ptr[global_index] == region_value) { if (!active_only || - (ecl_grid->index_map[global_index] >= 0)) { + (rd_grid->index_map[global_index] >= 0)) { /* Okay - this index should be included */ if (export_active_index) int_vector_iset( index_list, cells_found, - ecl_grid->index_map[global_index]); + rd_grid->index_map[global_index]); else int_vector_iset(index_list, cells_found, global_index); @@ -5798,39 +5756,38 @@ int ecl_grid_get_region_cells(const ecl_grid_type *ecl_grid, } else util_abort( "%s: size mismatch grid has %d cells - region specifier:%d \n", - __func__, ecl_grid->size, ecl_kw_get_size(region_kw)); + __func__, rd_grid->size, rd_kw_get_size(region_kw)); return cells_found; } -void ecl_grid_grdecl_fprintf_kw(const ecl_grid_type *ecl_grid, - const ecl_kw_type *ecl_kw, - const char *special_header, FILE *stream, - double double_default) { - int src_size = ecl_kw_get_size(ecl_kw); - if (src_size == ecl_grid->size) - ecl_kw_fprintf_grdecl__(ecl_kw, special_header, stream); - else if (src_size == ecl_grid->total_active) { +void rd_grid_grdecl_fprintf_kw(const rd_grid_type *rd_grid, + const rd_kw_type *rd_kw, + const char *special_header, FILE *stream, + double double_default) { + int src_size = rd_kw_get_size(rd_kw); + if (src_size == rd_grid->size) + rd_kw_fprintf_grdecl__(rd_kw, special_header, stream); + else if (src_size == rd_grid->total_active) { void *default_ptr = NULL; float float_default; int int_default; int bool_default; - ecl_type_enum ecl_type = - ecl_type_get_type(ecl_kw_get_data_type(ecl_kw)); + rd_type_enum rd_type = rd_type_get_type(rd_kw_get_data_type(rd_kw)); - if (ecl_type == ECL_FLOAT_TYPE) { + if (rd_type == RD_FLOAT_TYPE) { float_default = (float)double_default; default_ptr = &float_default; - } else if (ecl_type == ECL_INT_TYPE) { + } else if (rd_type == RD_INT_TYPE) { int_default = (int)double_default; default_ptr = &int_default; - } else if (ecl_type == ECL_DOUBLE_TYPE) { + } else if (rd_type == RD_DOUBLE_TYPE) { default_ptr = &double_default; - } else if (ecl_type == ECL_BOOL_TYPE) { + } else if (rd_type == RD_BOOL_TYPE) { int tmp = (int)double_default; if (tmp == 1) - bool_default = ECL_BOOL_TRUE_INT; + bool_default = RD_BOOL_TRUE_INT; else if (tmp == 0) - bool_default = ECL_BOOL_FALSE_INT; + bool_default = RD_BOOL_FALSE_INT; else util_abort( "%s: only 0 and 1 are allowed for bool interpolation\n", @@ -5842,27 +5799,27 @@ void ecl_grid_grdecl_fprintf_kw(const ecl_grid_type *ecl_grid, util_abort("%s: invalid type \n", __func__); { - ecl_kw_type *tmp_kw = ecl_kw_alloc_scatter_copy( - ecl_kw, ecl_grid->size, ecl_grid->inv_index_map, default_ptr); - ecl_kw_fprintf_grdecl__(tmp_kw, special_header, stream); - ecl_kw_free(tmp_kw); + rd_kw_type *tmp_kw = rd_kw_alloc_scatter_copy( + rd_kw, rd_grid->size, rd_grid->inv_index_map, default_ptr); + rd_kw_fprintf_grdecl__(tmp_kw, special_header, stream); + rd_kw_free(tmp_kw); } } else - util_abort("%s: size mismatch. ecl_kw must have either nx*ny*ny " + util_abort("%s: size mismatch. rd_kw must have either nx*ny*ny " "elements or nactive elements\n", __func__); } -static bool ecl_grid_test_lgr_consistency2(const ecl_grid_type *parent, - const ecl_grid_type *child) { +static bool rd_grid_test_lgr_consistency2(const rd_grid_type *parent, + const rd_grid_type *child) { bool consistent = true; - int child_size = ecl_grid_get_global_size(child); + int child_size = rd_grid_get_global_size(child); int child_index; for (child_index = 0; child_index < child_size; child_index++) { - int parent_cell = ecl_grid_get_parent_cell1(child, child_index); + int parent_cell = rd_grid_get_parent_cell1(child, child_index); if (parent_cell >= 0) { - const ecl_grid_type *child_test = - ecl_grid_get_cell_lgr1(parent, parent_cell); + const rd_grid_type *child_test = + rd_grid_get_cell_lgr1(parent, parent_cell); if (child != child_test) { fprintf(stderr, "Child parent mapping failure : ptr difference.\n"); @@ -5877,17 +5834,17 @@ static bool ecl_grid_test_lgr_consistency2(const ecl_grid_type *parent, return consistent; } -bool ecl_grid_test_lgr_consistency(const ecl_grid_type *ecl_grid) { +bool rd_grid_test_lgr_consistency(const rd_grid_type *rd_grid) { bool consistent = true; - for (const auto &lgr_pair : ecl_grid->children) { - const ecl_grid_type *lgr = lgr_pair.second; - consistent &= ecl_grid_test_lgr_consistency2(ecl_grid, lgr); - consistent &= ecl_grid_test_lgr_consistency(lgr); + for (const auto &lgr_pair : rd_grid->children) { + const rd_grid_type *lgr = lgr_pair.second; + consistent &= rd_grid_test_lgr_consistency2(rd_grid, lgr); + consistent &= rd_grid_test_lgr_consistency(lgr); } return consistent; } -static void ecl_grid_dump__(const ecl_grid_type *grid, FILE *stream) { +static void rd_grid_dump__(const rd_grid_type *grid, FILE *stream) { util_fwrite_int(grid->lgr_nr, stream); util_fwrite_string(grid->name, stream); util_fwrite_int(grid->nx, stream); @@ -5902,14 +5859,14 @@ static void ecl_grid_dump__(const ecl_grid_type *grid, FILE *stream) { { int i; for (i = 0; i < grid->size; i++) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, i); - ecl_cell_dump(cell, stream); + const rd_cell_type *cell = rd_grid_get_cell(grid, i); + rd_cell_dump(cell, stream); } } } -static void ecl_grid_dump_ascii__(ecl_grid_type *grid, bool active_only, - FILE *stream) { +static void rd_grid_dump_ascii__(rd_grid_type *grid, bool active_only, + FILE *stream) { fprintf(stream, "Grid nr : %d\n", grid->lgr_nr); fprintf(stream, "Grid name : %s\n", grid->name); fprintf(stream, "nx : %6d\n", grid->nx); @@ -5921,11 +5878,11 @@ static void ecl_grid_dump_ascii__(ecl_grid_type *grid, bool active_only, { int l; for (l = 0; l < grid->size; l++) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, l); + rd_cell_type *cell = rd_grid_get_cell(grid, l); if (cell->active_index[MATRIX_INDEX] >= 0 || !active_only) { int i, j, k; - ecl_grid_get_ijk1(grid, l, &i, &j, &k); - ecl_cell_dump_ascii(cell, i, j, k, stream, NULL); + rd_grid_get_ijk1(grid, l, &i, &j, &k); + rd_cell_dump_ascii(cell, i, j, k, stream, NULL); } } } @@ -5939,41 +5896,40 @@ static void ecl_grid_dump_ascii__(ecl_grid_type *grid, bool active_only, to be read. */ -void ecl_grid_dump(const ecl_grid_type *grid, FILE *stream) { - ecl_grid_dump__(grid, stream); +void rd_grid_dump(const rd_grid_type *grid, FILE *stream) { + rd_grid_dump__(grid, stream); { int i; for (i = 0; i < vector_get_size(grid->LGR_list); i++) - ecl_grid_dump__( - (const ecl_grid_type *)vector_iget_const(grid->LGR_list, i), + rd_grid_dump__( + (const rd_grid_type *)vector_iget_const(grid->LGR_list, i), stream); } } -void ecl_grid_dump_ascii(ecl_grid_type *grid, bool active_only, FILE *stream) { - ecl_grid_dump_ascii__(grid, active_only, stream); +void rd_grid_dump_ascii(rd_grid_type *grid, bool active_only, FILE *stream) { + rd_grid_dump_ascii__(grid, active_only, stream); { int i; for (i = 0; i < vector_get_size(grid->LGR_list); i++) - ecl_grid_dump_ascii__( - (ecl_grid_type *)vector_iget(grid->LGR_list, i), active_only, - stream); + rd_grid_dump_ascii__((rd_grid_type *)vector_iget(grid->LGR_list, i), + active_only, stream); } } -void ecl_grid_dump_ascii_cell1(ecl_grid_type *grid, int global_index, - FILE *stream, const double *offset) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); +void rd_grid_dump_ascii_cell1(rd_grid_type *grid, int global_index, + FILE *stream, const double *offset) { + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); int i, j, k; - ecl_grid_get_ijk1(grid, global_index, &i, &j, &k); - ecl_cell_dump_ascii(cell, i, j, k, stream, offset); + rd_grid_get_ijk1(grid, global_index, &i, &j, &k); + rd_cell_dump_ascii(cell, i, j, k, stream, offset); } -void ecl_grid_dump_ascii_cell3(ecl_grid_type *grid, int i, int j, int k, - FILE *stream, const double *offset) { - int global_index = ecl_grid_get_global_index3(grid, i, j, k); - ecl_cell_type *cell = ecl_grid_get_cell(grid, global_index); - ecl_cell_dump_ascii(cell, i, j, k, stream, offset); +void rd_grid_dump_ascii_cell3(rd_grid_type *grid, int i, int j, int k, + FILE *stream, const double *offset) { + int global_index = rd_grid_get_global_index3(grid, i, j, k); + rd_cell_type *cell = rd_grid_get_cell(grid, global_index); + rd_cell_dump_ascii(cell, i, j, k, stream, offset); } /* @@ -6005,179 +5961,177 @@ void ecl_grid_dump_ascii_cell3(ecl_grid_type *grid, int i, int j, int k, ... */ -bool ecl_grid_use_mapaxes(const ecl_grid_type *grid) { - return grid->use_mapaxes; -} +bool rd_grid_use_mapaxes(const rd_grid_type *grid) { return grid->use_mapaxes; } -void ecl_grid_init_mapaxes_data_double(const ecl_grid_type *grid, - double *mapaxes) { +void rd_grid_init_mapaxes_data_double(const rd_grid_type *grid, + double *mapaxes) { int i; for (i = 0; i < 6; i++) mapaxes[i] = grid->mapaxes[i]; } -static void ecl_grid_init_mapaxes_data_float(const ecl_grid_type *grid, - float *mapaxes) { +static void rd_grid_init_mapaxes_data_float(const rd_grid_type *grid, + float *mapaxes) { int i; for (i = 0; i < 6; i++) mapaxes[i] = grid->mapaxes[i]; } -static const float *ecl_grid_get_mapaxes(const ecl_grid_type *grid) { +static const float *rd_grid_get_mapaxes(const rd_grid_type *grid) { return grid->mapaxes; } -ecl_kw_type *ecl_grid_alloc_mapaxes_kw(const ecl_grid_type *grid) { - return ecl_kw_alloc_new(MAPAXES_KW, 6, ECL_FLOAT, grid->mapaxes); +rd_kw_type *rd_grid_alloc_mapaxes_kw(const rd_grid_type *grid) { + return rd_kw_alloc_new(MAPAXES_KW, 6, RD_FLOAT, grid->mapaxes); } -static ecl_kw_type *ecl_grid_alloc_mapunits_kw(ert_ecl_unit_enum output_unit) { - ecl_kw_type *mapunits_kw = ecl_kw_alloc(MAPUNITS_KW, 1, ECL_CHAR); +static rd_kw_type *rd_grid_alloc_mapunits_kw(ert_rd_unit_enum output_unit) { + rd_kw_type *mapunits_kw = rd_kw_alloc(MAPUNITS_KW, 1, RD_CHAR); - if (output_unit == ECL_FIELD_UNITS) - ecl_kw_iset_string8(mapunits_kw, 0, "FEET"); + if (output_unit == RD_FIELD_UNITS) + rd_kw_iset_string8(mapunits_kw, 0, "FEET"); - if (output_unit == ECL_METRIC_UNITS) - ecl_kw_iset_string8(mapunits_kw, 0, "METRES"); + if (output_unit == RD_METRIC_UNITS) + rd_kw_iset_string8(mapunits_kw, 0, "METRES"); - if (output_unit == ECL_LAB_UNITS) - ecl_kw_iset_string8(mapunits_kw, 0, "CM"); + if (output_unit == RD_LAB_UNITS) + rd_kw_iset_string8(mapunits_kw, 0, "CM"); return mapunits_kw; } -static ecl_kw_type *ecl_grid_alloc_gridunits_kw(ert_ecl_unit_enum output_unit) { - ecl_kw_type *gridunits_kw = ecl_kw_alloc(GRIDUNIT_KW, 2, ECL_CHAR); +static rd_kw_type *rd_grid_alloc_gridunits_kw(ert_rd_unit_enum output_unit) { + rd_kw_type *gridunits_kw = rd_kw_alloc(GRIDUNIT_KW, 2, RD_CHAR); - if (output_unit == ECL_FIELD_UNITS) - ecl_kw_iset_string8(gridunits_kw, 0, "FEET"); + if (output_unit == RD_FIELD_UNITS) + rd_kw_iset_string8(gridunits_kw, 0, "FEET"); - if (output_unit == ECL_METRIC_UNITS) - ecl_kw_iset_string8(gridunits_kw, 0, "METRES"); + if (output_unit == RD_METRIC_UNITS) + rd_kw_iset_string8(gridunits_kw, 0, "METRES"); - if (output_unit == ECL_LAB_UNITS) - ecl_kw_iset_string8(gridunits_kw, 0, "CM"); + if (output_unit == RD_LAB_UNITS) + rd_kw_iset_string8(gridunits_kw, 0, "CM"); - ecl_kw_iset_string8(gridunits_kw, 1, ""); + rd_kw_iset_string8(gridunits_kw, 1, ""); return gridunits_kw; } -static ert_ecl_unit_enum -ecl_grid_check_unit_system(const ecl_kw_type *gridunit_kw) { - const char *length_unit = ecl_kw_iget_char_ptr(gridunit_kw, 0); +static ert_rd_unit_enum +rd_grid_check_unit_system(const rd_kw_type *gridunit_kw) { + const char *length_unit = rd_kw_iget_char_ptr(gridunit_kw, 0); if (strncmp(length_unit, "FEET", 4) == 0) - return ECL_FIELD_UNITS; + return RD_FIELD_UNITS; if (strncmp(length_unit, "CM", 2) == 0) - return ECL_LAB_UNITS; + return RD_LAB_UNITS; - return ECL_METRIC_UNITS; + return RD_METRIC_UNITS; } -static float ecl_grid_output_scaling(const ecl_grid_type *grid, - ert_ecl_unit_enum output_unit) { +static float rd_grid_output_scaling(const rd_grid_type *grid, + ert_rd_unit_enum output_unit) { if (grid->unit_system == output_unit) return 1.0; else { double scale_factor = 1; - if (grid->unit_system == ECL_FIELD_UNITS) + if (grid->unit_system == RD_FIELD_UNITS) scale_factor = 1.0 / METER_TO_FEET_SCALE_FACTOR; - if (grid->unit_system == ECL_LAB_UNITS) + if (grid->unit_system == RD_LAB_UNITS) scale_factor = 1.0 / METER_TO_CM_SCALE_FACTOR; - if (output_unit == ECL_FIELD_UNITS) + if (output_unit == RD_FIELD_UNITS) scale_factor *= METER_TO_FEET_SCALE_FACTOR; - if (output_unit == ECL_LAB_UNITS) + if (output_unit == RD_LAB_UNITS) scale_factor *= METER_TO_CM_SCALE_FACTOR; return scale_factor; } } -static void ecl_grid_fwrite_mapaxes(const ecl_grid_type *grid, - fortio_type *fortio) { - ecl_kw_type *mapaxes_kw = ecl_grid_alloc_mapaxes_kw(grid); - ecl_kw_fwrite(mapaxes_kw, fortio); - ecl_kw_free(mapaxes_kw); +static void rd_grid_fwrite_mapaxes(const rd_grid_type *grid, + fortio_type *fortio) { + rd_kw_type *mapaxes_kw = rd_grid_alloc_mapaxes_kw(grid); + rd_kw_fwrite(mapaxes_kw, fortio); + rd_kw_free(mapaxes_kw); } -static void ecl_grid_fwrite_mapunits(fortio_type *fortio, - ert_ecl_unit_enum output_unit) { - ecl_kw_type *mapunits_kw = ecl_grid_alloc_mapunits_kw(output_unit); - ecl_kw_fwrite(mapunits_kw, fortio); - ecl_kw_free(mapunits_kw); +static void rd_grid_fwrite_mapunits(fortio_type *fortio, + ert_rd_unit_enum output_unit) { + rd_kw_type *mapunits_kw = rd_grid_alloc_mapunits_kw(output_unit); + rd_kw_fwrite(mapunits_kw, fortio); + rd_kw_free(mapunits_kw); } -static void ecl_grid_fwrite_gridunits(fortio_type *fortio, - ert_ecl_unit_enum output_unit) { - ecl_kw_type *gridunits_kw = ecl_grid_alloc_gridunits_kw(output_unit); - ecl_kw_fwrite(gridunits_kw, fortio); - ecl_kw_free(gridunits_kw); +static void rd_grid_fwrite_gridunits(fortio_type *fortio, + ert_rd_unit_enum output_unit) { + rd_kw_type *gridunits_kw = rd_grid_alloc_gridunits_kw(output_unit); + rd_kw_fwrite(gridunits_kw, fortio); + rd_kw_free(gridunits_kw); } -static void ecl_grid_fwrite_main_GRID_headers(const ecl_grid_type *ecl_grid, - fortio_type *fortio, - ert_ecl_unit_enum output_unit) { - ecl_grid_fwrite_mapunits(fortio, output_unit); +static void rd_grid_fwrite_main_GRID_headers(const rd_grid_type *rd_grid, + fortio_type *fortio, + ert_rd_unit_enum output_unit) { + rd_grid_fwrite_mapunits(fortio, output_unit); - if (ecl_grid->use_mapaxes) - ecl_grid_fwrite_mapaxes(ecl_grid, fortio); + if (rd_grid->use_mapaxes) + rd_grid_fwrite_mapaxes(rd_grid, fortio); - ecl_grid_fwrite_gridunits(fortio, output_unit); + rd_grid_fwrite_gridunits(fortio, output_unit); } -static void ecl_grid_fwrite_GRID__(const ecl_grid_type *grid, int coords_size, - fortio_type *fortio, - ert_ecl_unit_enum output_unit) { +static void rd_grid_fwrite_GRID__(const rd_grid_type *grid, int coords_size, + fortio_type *fortio, + ert_rd_unit_enum output_unit) { if (grid->parent_grid != NULL) { - ecl_kw_type *lgr_kw = ecl_kw_alloc(LGR_KW, 1, ECL_CHAR); - ecl_kw_iset_string8(lgr_kw, 0, grid->name); - ecl_kw_fwrite(lgr_kw, fortio); - ecl_kw_free(lgr_kw); + rd_kw_type *lgr_kw = rd_kw_alloc(LGR_KW, 1, RD_CHAR); + rd_kw_iset_string8(lgr_kw, 0, grid->name); + rd_kw_fwrite(lgr_kw, fortio); + rd_kw_free(lgr_kw); } { - ecl_kw_type *dimens_kw = ecl_kw_alloc(DIMENS_KW, 3, ECL_INT); - ecl_kw_iset_int(dimens_kw, 0, grid->nx); - ecl_kw_iset_int(dimens_kw, 1, grid->ny); + rd_kw_type *dimens_kw = rd_kw_alloc(DIMENS_KW, 3, RD_INT); + rd_kw_iset_int(dimens_kw, 0, grid->nx); + rd_kw_iset_int(dimens_kw, 1, grid->ny); if (grid->dualp_flag == FILEHEAD_SINGLE_POROSITY) - ecl_kw_iset_int(dimens_kw, 2, grid->nz); + rd_kw_iset_int(dimens_kw, 2, grid->nz); else - ecl_kw_iset_int(dimens_kw, 2, 2 * grid->nz); + rd_kw_iset_int(dimens_kw, 2, 2 * grid->nz); - ecl_kw_fwrite(dimens_kw, fortio); - ecl_kw_free(dimens_kw); + rd_kw_fwrite(dimens_kw, fortio); + rd_kw_free(dimens_kw); } if (grid->parent_grid == NULL) - ecl_grid_fwrite_main_GRID_headers(grid, fortio, output_unit); + rd_grid_fwrite_main_GRID_headers(grid, fortio, output_unit); { - ecl_kw_type *radial_kw = ecl_kw_alloc(RADIAL_KW, 1, ECL_CHAR); - ecl_kw_iset_string8(radial_kw, 0, "FALSE"); - ecl_kw_fwrite(radial_kw, fortio); - ecl_kw_free(radial_kw); + rd_kw_type *radial_kw = rd_kw_alloc(RADIAL_KW, 1, RD_CHAR); + rd_kw_iset_string8(radial_kw, 0, "FALSE"); + rd_kw_fwrite(radial_kw, fortio); + rd_kw_free(radial_kw); } { - ecl_kw_type *coords_kw = ecl_kw_alloc(COORDS_KW, coords_size, ECL_INT); - ecl_kw_type *corners_kw = ecl_kw_alloc(CORNERS_KW, 24, ECL_FLOAT); + rd_kw_type *coords_kw = rd_kw_alloc(COORDS_KW, coords_size, RD_INT); + rd_kw_type *corners_kw = rd_kw_alloc(CORNERS_KW, 24, RD_FLOAT); int i, j, k; for (k = 0; k < grid->nz; k++) { for (j = 0; j < grid->ny; j++) { for (i = 0; i < grid->nx; i++) { int global_index = - ecl_grid_get_global_index__(grid, i, j, k); - const ecl_cell_type *cell = - ecl_grid_get_cell(grid, global_index); + rd_grid_get_global_index__(grid, i, j, k); + const rd_cell_type *cell = + rd_grid_get_cell(grid, global_index); - ecl_cell_fwrite_GRID(grid, cell, false, coords_size, i, j, - k, global_index, coords_kw, corners_kw, - fortio); + rd_cell_fwrite_GRID(grid, cell, false, coords_size, i, j, k, + global_index, coords_kw, corners_kw, + fortio); } } } @@ -6186,53 +6140,52 @@ static void ecl_grid_fwrite_GRID__(const ecl_grid_type *grid, int coords_size, for (k = grid->nz; k < 2 * grid->nz; k++) { for (j = 0; j < grid->ny; j++) { for (i = 0; i < grid->nx; i++) { - int global_index = ecl_grid_get_global_index__( + int global_index = rd_grid_get_global_index__( grid, i, j, k - grid->nz); - const ecl_cell_type *cell = - ecl_grid_get_cell(grid, global_index); + const rd_cell_type *cell = + rd_grid_get_cell(grid, global_index); - ecl_cell_fwrite_GRID(grid, cell, true, coords_size, i, - j, k, global_index, coords_kw, - corners_kw, fortio); + rd_cell_fwrite_GRID(grid, cell, true, coords_size, i, j, + k, global_index, coords_kw, + corners_kw, fortio); } } } } - ecl_kw_free(coords_kw); - ecl_kw_free(corners_kw); + rd_kw_free(coords_kw); + rd_kw_free(corners_kw); } } -void ecl_grid_fwrite_GRID2(const ecl_grid_type *grid, const char *filename, - ert_ecl_unit_enum output_unit) { +void rd_grid_fwrite_GRID2(const rd_grid_type *grid, const char *filename, + ert_rd_unit_enum output_unit) { int coords_size = 5; bool fmt_file = false; fortio_type *fortio = - fortio_open_writer(filename, fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, fmt_file, RD_ENDIAN_FLIP); if (grid->children.size() > 0) coords_size = 7; if (grid->coarsening_active) coords_size = 7; - ecl_grid_fwrite_GRID__(grid, coords_size, fortio, output_unit); + rd_grid_fwrite_GRID__(grid, coords_size, fortio, output_unit); { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size(grid->LGR_list); grid_nr++) { - const ecl_grid_type *igrid = - (const ecl_grid_type *)vector_iget_const(grid->LGR_list, - grid_nr); - ecl_grid_fwrite_GRID__(igrid, coords_size, fortio, output_unit); + const rd_grid_type *igrid = (const rd_grid_type *)vector_iget_const( + grid->LGR_list, grid_nr); + rd_grid_fwrite_GRID__(igrid, coords_size, fortio, output_unit); } } fortio_fclose(fortio); } -void ecl_grid_fwrite_GRID(const ecl_grid_type *grid, const char *filename) { - ecl_grid_fwrite_GRID2(grid, filename, ECL_METRIC_UNITS); +void rd_grid_fwrite_GRID(const rd_grid_type *grid, const char *filename) { + rd_grid_fwrite_GRID2(grid, filename, RD_METRIC_UNITS); } /* @@ -6253,43 +6206,43 @@ ENDGRID 0:INTE a standard EGRID header without creating a grid instance first. */ -static void ecl_grid_fwrite_main_EGRID_header(const ecl_grid_type *grid, - fortio_type *fortio, - ert_ecl_unit_enum output_unit) { +static void rd_grid_fwrite_main_EGRID_header(const rd_grid_type *grid, + fortio_type *fortio, + ert_rd_unit_enum output_unit) { int EGRID_VERSION = 3; int RELEASE_YEAR = 2007; int COMPAT_VERSION = 0; - const float *mapaxes = ecl_grid_get_mapaxes(grid); + const float *mapaxes = rd_grid_get_mapaxes(grid); { - ecl_kw_type *filehead_kw = ecl_kw_alloc(FILEHEAD_KW, 100, ECL_INT); - ecl_kw_scalar_set_int(filehead_kw, 0); + rd_kw_type *filehead_kw = rd_kw_alloc(FILEHEAD_KW, 100, RD_INT); + rd_kw_scalar_set_int(filehead_kw, 0); - ecl_kw_iset_int(filehead_kw, FILEHEAD_VERSION_INDEX, EGRID_VERSION); - ecl_kw_iset_int(filehead_kw, FILEHEAD_YEAR_INDEX, RELEASE_YEAR); - ecl_kw_iset_int(filehead_kw, FILEHEAD_COMPAT_INDEX, COMPAT_VERSION); - ecl_kw_iset_int(filehead_kw, FILEHEAD_TYPE_INDEX, - FILEHEAD_GRIDTYPE_CORNERPOINT); - ecl_kw_iset_int(filehead_kw, FILEHEAD_DUALP_INDEX, grid->dualp_flag); - ecl_kw_iset_int(filehead_kw, FILEHEAD_ORGFORMAT_INDEX, - FILEHEAD_ORGTYPE_CORNERPOINT); + rd_kw_iset_int(filehead_kw, FILEHEAD_VERSION_INDEX, EGRID_VERSION); + rd_kw_iset_int(filehead_kw, FILEHEAD_YEAR_INDEX, RELEASE_YEAR); + rd_kw_iset_int(filehead_kw, FILEHEAD_COMPAT_INDEX, COMPAT_VERSION); + rd_kw_iset_int(filehead_kw, FILEHEAD_TYPE_INDEX, + FILEHEAD_GRIDTYPE_CORNERPOINT); + rd_kw_iset_int(filehead_kw, FILEHEAD_DUALP_INDEX, grid->dualp_flag); + rd_kw_iset_int(filehead_kw, FILEHEAD_ORGFORMAT_INDEX, + FILEHEAD_ORGTYPE_CORNERPOINT); - ecl_kw_fwrite(filehead_kw, fortio); - ecl_kw_free(filehead_kw); + rd_kw_fwrite(filehead_kw, fortio); + rd_kw_free(filehead_kw); } - ecl_grid_fwrite_mapunits(fortio, output_unit); + rd_grid_fwrite_mapunits(fortio, output_unit); if (mapaxes != NULL) - ecl_grid_fwrite_mapaxes(grid, fortio); + rd_grid_fwrite_mapaxes(grid, fortio); - ecl_grid_fwrite_gridunits(fortio, output_unit); + rd_grid_fwrite_gridunits(fortio, output_unit); } -static void ecl_grid_fwrite_gridhead_kw(int nx, int ny, int nz, int grid_nr, - fortio_type *fortio) { - ecl_kw_type *gridhead_kw = ecl_grid_alloc_gridhead_kw(nx, ny, nz, grid_nr); - ecl_kw_fwrite(gridhead_kw, fortio); - ecl_kw_free(gridhead_kw); +static void rd_grid_fwrite_gridhead_kw(int nx, int ny, int nz, int grid_nr, + fortio_type *fortio) { + rd_kw_type *gridhead_kw = rd_grid_alloc_gridhead_kw(nx, ny, nz, grid_nr); + rd_kw_fwrite(gridhead_kw, fortio); + rd_kw_free(gridhead_kw); } /* @@ -6297,17 +6250,17 @@ static void ecl_grid_fwrite_gridhead_kw(int nx, int ny, int nz, int grid_nr, valid geometry. If no cell is found the function will return -1. */ -static int ecl_grid_get_valid_index(const ecl_grid_type *grid, int i, int j, - int k1, int k2) { +static int rd_grid_get_valid_index(const rd_grid_type *grid, int i, int j, + int k1, int k2) { int global_index; int k = k1; int delta = (k1 < k2) ? 1 : -1; while (true) { - ecl_cell_type *cell; - global_index = ecl_grid_get_global_index3(grid, i, j, k); + rd_cell_type *cell; + global_index = rd_grid_get_global_index3(grid, i, j, k); - cell = ecl_grid_get_cell(grid, global_index); + cell = rd_grid_get_cell(grid, global_index); if (GET_CELL_FLAG(cell, CELL_FLAG_VALID)) return global_index; else { @@ -6318,23 +6271,22 @@ static int ecl_grid_get_valid_index(const ecl_grid_type *grid, int i, int j, } } -static int ecl_grid_get_bottom_valid_index(const ecl_grid_type *grid, int i, - int j) { - return ecl_grid_get_valid_index(grid, i, j, grid->nz - 1, -1); +static int rd_grid_get_bottom_valid_index(const rd_grid_type *grid, int i, + int j) { + return rd_grid_get_valid_index(grid, i, j, grid->nz - 1, -1); } -static int ecl_grid_get_top_valid_index(const ecl_grid_type *grid, int i, - int j) { - return ecl_grid_get_valid_index(grid, i, j, 0, grid->nz); +static int rd_grid_get_top_valid_index(const rd_grid_type *grid, int i, int j) { + return rd_grid_get_valid_index(grid, i, j, 0, grid->nz); } -static bool ecl_grid_init_coord_section__(const ecl_grid_type *grid, int i, - int j, int i_corner, int j_corner, - bool force_set, float *coord_float, - double *coord_double) { +static bool rd_grid_init_coord_section__(const rd_grid_type *grid, int i, int j, + int i_corner, int j_corner, + bool force_set, float *coord_float, + double *coord_double) { - const int top_index = ecl_grid_get_top_valid_index(grid, i, j); - const int bottom_index = ecl_grid_get_bottom_valid_index(grid, i, j); + const int top_index = rd_grid_get_top_valid_index(grid, i, j); + const int bottom_index = rd_grid_get_bottom_valid_index(grid, i, j); if (top_index == -1) util_exit("% : no cell with a valid geometry description found in " @@ -6345,9 +6297,8 @@ static bool ecl_grid_init_coord_section__(const ecl_grid_type *grid, int i, point_type top_point; point_type bottom_point; - const ecl_cell_type *bottom_cell = - ecl_grid_get_cell(grid, bottom_index); - const ecl_cell_type *top_cell = ecl_grid_get_cell(grid, top_index); + const rd_cell_type *bottom_cell = rd_grid_get_cell(grid, bottom_index); + const rd_cell_type *top_cell = rd_grid_get_cell(grid, top_index); /* 2---3 @@ -6398,9 +6349,9 @@ static bool ecl_grid_init_coord_section__(const ecl_grid_type *grid, int i, } } -static void ecl_grid_init_coord_section(const ecl_grid_type *grid, int i, int j, - float *coord_float, - double *coord_double) { +static void rd_grid_init_coord_section(const rd_grid_type *grid, int i, int j, + float *coord_float, + double *coord_double) { int i_corner = 0; int j_corner = 0; @@ -6414,12 +6365,11 @@ static void ecl_grid_init_coord_section(const ecl_grid_type *grid, int i, int j, j_corner = 1; } - ecl_grid_init_coord_section__(grid, i, j, i_corner, j_corner, - /*force_set=*/true, coord_float, - coord_double); + rd_grid_init_coord_section__(grid, i, j, i_corner, j_corner, + /*force_set=*/true, coord_float, coord_double); } -void ecl_grid_init_coord_data(const ecl_grid_type *grid, float *coord) { +void rd_grid_init_coord_data(const rd_grid_type *grid, float *coord) { /* The coord vector contains the points defining the top and bottom of the pillars. The vector contains (nx + 1) * (ny + 1) 6 element @@ -6429,11 +6379,11 @@ void ecl_grid_init_coord_data(const ecl_grid_type *grid, float *coord) { int i, j; for (j = 0; j <= grid->ny; j++) { for (i = 0; i <= grid->nx; i++) - ecl_grid_init_coord_section(grid, i, j, coord, NULL); + rd_grid_init_coord_section(grid, i, j, coord, NULL); } } -void ecl_grid_init_coord_data_double(const ecl_grid_type *grid, double *coord) { +void rd_grid_init_coord_data_double(const rd_grid_type *grid, double *coord) { /* The coord vector contains the points defining the top and bottom of the pillars. The vector contains (nx + 1) * (ny + 1) 6 element @@ -6443,29 +6393,29 @@ void ecl_grid_init_coord_data_double(const ecl_grid_type *grid, double *coord) { int i, j; for (j = 0; j <= grid->ny; j++) { for (i = 0; i <= grid->nx; i++) - ecl_grid_init_coord_section(grid, i, j, NULL, coord); + rd_grid_init_coord_section(grid, i, j, NULL, coord); } } -float *ecl_grid_alloc_coord_data(const ecl_grid_type *grid) { +float *rd_grid_alloc_coord_data(const rd_grid_type *grid) { float *coord = - (float *)util_calloc(ecl_grid_get_coord_size(grid), sizeof *coord); - ecl_grid_init_coord_data(grid, coord); + (float *)util_calloc(rd_grid_get_coord_size(grid), sizeof *coord); + rd_grid_init_coord_data(grid, coord); return coord; } -void ecl_grid_assert_coord_kw(ecl_grid_type *grid) { +void rd_grid_assert_coord_kw(rd_grid_type *grid) { if (grid->coord_kw == NULL) { grid->coord_kw = - ecl_kw_alloc(COORD_KW, ecl_grid_get_coord_size(grid), ECL_FLOAT); - ecl_grid_init_coord_data(grid, - (float *)ecl_kw_get_void_ptr(grid->coord_kw)); + rd_kw_alloc(COORD_KW, rd_grid_get_coord_size(grid), RD_FLOAT); + rd_grid_init_coord_data(grid, + (float *)rd_kw_get_void_ptr(grid->coord_kw)); } } -static void ecl_grid_init_zcorn_data__(const ecl_grid_type *grid, - float *zcorn_float, - double *zcorn_double) { +static void rd_grid_init_zcorn_data__(const rd_grid_type *grid, + float *zcorn_float, + double *zcorn_double) { int nx = grid->nx; int ny = grid->ny; int nz = grid->nz; @@ -6473,9 +6423,8 @@ static void ecl_grid_init_zcorn_data__(const ecl_grid_type *grid, for (j = 0; j < ny; j++) { for (i = 0; i < nx; i++) { for (k = 0; k < nz; k++) { - const int cell_index = - ecl_grid_get_global_index3(grid, i, j, k); - const ecl_cell_type *cell = ecl_grid_get_cell(grid, cell_index); + const int cell_index = rd_grid_get_global_index3(grid, i, j, k); + const rd_cell_type *cell = rd_grid_get_cell(grid, cell_index); int l; for (l = 0; l < 2; l++) { @@ -6512,63 +6461,63 @@ static void ecl_grid_init_zcorn_data__(const ecl_grid_type *grid, } } -void ecl_grid_init_zcorn_data(const ecl_grid_type *grid, float *zcorn) { - ecl_grid_init_zcorn_data__(grid, zcorn, NULL); +void rd_grid_init_zcorn_data(const rd_grid_type *grid, float *zcorn) { + rd_grid_init_zcorn_data__(grid, zcorn, NULL); } -void ecl_grid_init_zcorn_data_double(const ecl_grid_type *grid, double *zcorn) { - ecl_grid_init_zcorn_data__(grid, NULL, zcorn); +void rd_grid_init_zcorn_data_double(const rd_grid_type *grid, double *zcorn) { + rd_grid_init_zcorn_data__(grid, NULL, zcorn); } -float *ecl_grid_alloc_zcorn_data(const ecl_grid_type *grid) { +float *rd_grid_alloc_zcorn_data(const rd_grid_type *grid) { float *zcorn = (float *)util_calloc(8 * grid->size, sizeof *zcorn); - ecl_grid_init_zcorn_data(grid, zcorn); + rd_grid_init_zcorn_data(grid, zcorn); return zcorn; } -ecl_kw_type *ecl_grid_alloc_zcorn_kw(const ecl_grid_type *grid) { - ecl_kw_type *zcorn_kw = - ecl_kw_alloc(ZCORN_KW, ecl_grid_get_zcorn_size(grid), ECL_FLOAT); - ecl_grid_init_zcorn_data(grid, (float *)ecl_kw_get_void_ptr(zcorn_kw)); +rd_kw_type *rd_grid_alloc_zcorn_kw(const rd_grid_type *grid) { + rd_kw_type *zcorn_kw = + rd_kw_alloc(ZCORN_KW, rd_grid_get_zcorn_size(grid), RD_FLOAT); + rd_grid_init_zcorn_data(grid, (float *)rd_kw_get_void_ptr(zcorn_kw)); return zcorn_kw; } -ecl_kw_type *ecl_grid_alloc_coord_kw(const ecl_grid_type *grid) { +rd_kw_type *rd_grid_alloc_coord_kw(const rd_grid_type *grid) { if (grid->coord_kw) - return ecl_kw_alloc_copy(grid->coord_kw); + return rd_kw_alloc_copy(grid->coord_kw); - ecl_kw_type *coord_kw = ecl_kw_alloc( - COORD_KW, ECL_GRID_COORD_SIZE(grid->nx, grid->ny), ECL_FLOAT); - ecl_grid_init_coord_data(grid, ecl_kw_get_float_ptr(coord_kw)); + rd_kw_type *coord_kw = + rd_kw_alloc(COORD_KW, RD_GRID_COORD_SIZE(grid->nx, grid->ny), RD_FLOAT); + rd_grid_init_coord_data(grid, rd_kw_get_float_ptr(coord_kw)); return coord_kw; } -int ecl_grid_get_coord_size(const ecl_grid_type *grid) { - return ECL_GRID_COORD_SIZE(grid->nx, grid->ny); +int rd_grid_get_coord_size(const rd_grid_type *grid) { + return RD_GRID_COORD_SIZE(grid->nx, grid->ny); } -int ecl_grid_get_zcorn_size(const ecl_grid_type *grid) { - return ECL_GRID_ZCORN_SIZE(grid->nx, grid->ny, grid->nz); +int rd_grid_get_zcorn_size(const rd_grid_type *grid) { + return RD_GRID_ZCORN_SIZE(grid->nx, grid->ny, grid->nz); } -void ecl_grid_init_actnum_data(const ecl_grid_type *grid, int *actnum) { +void rd_grid_init_actnum_data(const rd_grid_type *grid, int *actnum) { int i; for (i = 0; i < grid->size; i++) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, i); + const rd_cell_type *cell = rd_grid_get_cell(grid, i); if (cell->coarse_group == COARSE_GROUP_NONE) actnum[i] = cell->active; else { /* In the case of coarse cells we must query the coarse cell for the original, uncoarsened distribution of actnum values. */ - ecl_coarse_cell_type *coarse_cell = - ecl_grid_iget_coarse_group(grid, cell->coarse_group); + rd_coarse_cell_type *coarse_cell = + rd_grid_iget_coarse_group(grid, cell->coarse_group); /* 1: Set all the elements in the coarse group to inactive. */ { - int group_size = ecl_coarse_cell_get_size(coarse_cell); + int group_size = rd_coarse_cell_get_size(coarse_cell); const int *index_ptr = - ecl_coarse_cell_get_index_ptr(coarse_cell); + rd_coarse_cell_get_index_ptr(coarse_cell); int j; for (j = 0; j < group_size; j++) actnum[index_ptr[j]] = CELL_NOT_ACTIVE; @@ -6577,14 +6526,14 @@ void ecl_grid_init_actnum_data(const ecl_grid_type *grid, int *actnum) { /* 2: Explicitly pick up the active cells from the coarse group and mark them correctly. */ { - int num_active = ecl_coarse_cell_get_num_active(coarse_cell); + int num_active = rd_coarse_cell_get_num_active(coarse_cell); int j; for (j = 0; j < num_active; j++) { int global_index = - ecl_coarse_cell_iget_active_cell_index(coarse_cell, j); + rd_coarse_cell_iget_active_cell_index(coarse_cell, j); int active_value = - ecl_coarse_cell_iget_active_value(coarse_cell, j); + rd_coarse_cell_iget_active_value(coarse_cell, j); actnum[global_index] = active_value; } @@ -6593,137 +6542,133 @@ void ecl_grid_init_actnum_data(const ecl_grid_type *grid, int *actnum) { } } -int *ecl_grid_alloc_actnum_data(const ecl_grid_type *grid) { +int *rd_grid_alloc_actnum_data(const rd_grid_type *grid) { int *actnum = (int *)util_calloc(grid->size, sizeof *actnum); - ecl_grid_init_actnum_data(grid, actnum); + rd_grid_init_actnum_data(grid, actnum); return actnum; } -ecl_kw_type *ecl_grid_alloc_actnum_kw(const ecl_grid_type *grid) { - ecl_kw_type *actnum_kw = ecl_kw_alloc(ACTNUM_KW, grid->size, ECL_INT); - ecl_grid_init_actnum_data(grid, (int *)ecl_kw_get_void_ptr(actnum_kw)); +rd_kw_type *rd_grid_alloc_actnum_kw(const rd_grid_type *grid) { + rd_kw_type *actnum_kw = rd_kw_alloc(ACTNUM_KW, grid->size, RD_INT); + rd_grid_init_actnum_data(grid, (int *)rd_kw_get_void_ptr(actnum_kw)); return actnum_kw; } -void ecl_grid_compressed_kw_copy(const ecl_grid_type *grid, - ecl_kw_type *target_kw, - const ecl_kw_type *src_kw) { - if ((ecl_kw_get_size(target_kw) == ecl_grid_get_nactive(grid)) && - (ecl_kw_get_size(src_kw) == ecl_grid_get_global_size(grid))) { +void rd_grid_compressed_kw_copy(const rd_grid_type *grid, rd_kw_type *target_kw, + const rd_kw_type *src_kw) { + if ((rd_kw_get_size(target_kw) == rd_grid_get_nactive(grid)) && + (rd_kw_get_size(src_kw) == rd_grid_get_global_size(grid))) { int active_index = 0; int global_index; - for (global_index = 0; global_index < ecl_grid_get_global_size(grid); + for (global_index = 0; global_index < rd_grid_get_global_size(grid); global_index++) { - if (ecl_grid_cell_active1(grid, global_index)) { - ecl_kw_iset(target_kw, active_index, - ecl_kw_iget_ptr(src_kw, global_index)); + if (rd_grid_cell_active1(grid, global_index)) { + rd_kw_iset(target_kw, active_index, + rd_kw_iget_ptr(src_kw, global_index)); active_index++; } } } else util_abort("%s: size mismatch target:%d src:%d expected %d,%d \n", - ecl_kw_get_size(target_kw), ecl_kw_get_size(src_kw), - ecl_grid_get_nactive(grid), ecl_grid_get_global_size(grid)); + rd_kw_get_size(target_kw), rd_kw_get_size(src_kw), + rd_grid_get_nactive(grid), rd_grid_get_global_size(grid)); } -void ecl_grid_global_kw_copy(const ecl_grid_type *grid, ecl_kw_type *target_kw, - const ecl_kw_type *src_kw) { - if ((ecl_kw_get_size(src_kw) == ecl_grid_get_nactive(grid)) && - (ecl_kw_get_size(target_kw) == ecl_grid_get_global_size(grid))) { +void rd_grid_global_kw_copy(const rd_grid_type *grid, rd_kw_type *target_kw, + const rd_kw_type *src_kw) { + if ((rd_kw_get_size(src_kw) == rd_grid_get_nactive(grid)) && + (rd_kw_get_size(target_kw) == rd_grid_get_global_size(grid))) { int active_index = 0; int global_index; - for (global_index = 0; global_index < ecl_grid_get_global_size(grid); + for (global_index = 0; global_index < rd_grid_get_global_size(grid); global_index++) { - if (ecl_grid_cell_active1(grid, global_index)) { - ecl_kw_iset(target_kw, global_index, - ecl_kw_iget_ptr(src_kw, active_index)); + if (rd_grid_cell_active1(grid, global_index)) { + rd_kw_iset(target_kw, global_index, + rd_kw_iget_ptr(src_kw, active_index)); active_index++; } } } else util_abort("%s: size mismatch target:%d src:%d expected %d,%d \n", - ecl_kw_get_size(target_kw), ecl_kw_get_size(src_kw), - ecl_grid_get_global_size(grid), ecl_grid_get_nactive(grid)); + rd_kw_get_size(target_kw), rd_kw_get_size(src_kw), + rd_grid_get_global_size(grid), rd_grid_get_nactive(grid)); } -static void ecl_grid_init_hostnum_data(const ecl_grid_type *grid, - int *hostnum) { +static void rd_grid_init_hostnum_data(const rd_grid_type *grid, int *hostnum) { int i; for (i = 0; i < grid->size; i++) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, i); + const rd_cell_type *cell = rd_grid_get_cell(grid, i); hostnum[i] = cell->host_cell; } } -int *ecl_grid_alloc_hostnum_data(const ecl_grid_type *grid) { +int *rd_grid_alloc_hostnum_data(const rd_grid_type *grid) { int *hostnum = (int *)util_calloc(grid->size, sizeof *hostnum); - ecl_grid_init_hostnum_data(grid, hostnum); + rd_grid_init_hostnum_data(grid, hostnum); return hostnum; } -ecl_kw_type *ecl_grid_alloc_hostnum_kw(const ecl_grid_type *grid) { - ecl_kw_type *hostnum_kw = ecl_kw_alloc(HOSTNUM_KW, grid->size, ECL_INT); - ecl_grid_init_hostnum_data(grid, (int *)ecl_kw_get_void_ptr(hostnum_kw)); +rd_kw_type *rd_grid_alloc_hostnum_kw(const rd_grid_type *grid) { + rd_kw_type *hostnum_kw = rd_kw_alloc(HOSTNUM_KW, grid->size, RD_INT); + rd_grid_init_hostnum_data(grid, (int *)rd_kw_get_void_ptr(hostnum_kw)); return hostnum_kw; } -static void ecl_grid_init_corsnum_data(const ecl_grid_type *grid, - int *corsnum) { +static void rd_grid_init_corsnum_data(const rd_grid_type *grid, int *corsnum) { int i; for (i = 0; i < grid->size; i++) { - const ecl_cell_type *cell = ecl_grid_get_cell(grid, i); + const rd_cell_type *cell = rd_grid_get_cell(grid, i); corsnum[i] = cell->coarse_group + 1; } } -int *ecl_grid_alloc_corsnum_data(const ecl_grid_type *grid) { +int *rd_grid_alloc_corsnum_data(const rd_grid_type *grid) { int *corsnum = (int *)util_calloc(grid->size, sizeof *corsnum); - ecl_grid_init_corsnum_data(grid, corsnum); + rd_grid_init_corsnum_data(grid, corsnum); return corsnum; } -ecl_kw_type *ecl_grid_alloc_corsnum_kw(const ecl_grid_type *grid) { - ecl_kw_type *corsnum_kw = ecl_kw_alloc(CORSNUM_KW, grid->size, ECL_INT); - ecl_grid_init_corsnum_data(grid, (int *)ecl_kw_get_void_ptr(corsnum_kw)); +rd_kw_type *rd_grid_alloc_corsnum_kw(const rd_grid_type *grid) { + rd_kw_type *corsnum_kw = rd_kw_alloc(CORSNUM_KW, grid->size, RD_INT); + rd_grid_init_corsnum_data(grid, (int *)rd_kw_get_void_ptr(corsnum_kw)); return corsnum_kw; } -ecl_kw_type *ecl_grid_alloc_gridhead_kw(int nx, int ny, int nz, int grid_nr) { - ecl_kw_type *gridhead_kw = - ecl_kw_alloc(GRIDHEAD_KW, GRIDHEAD_SIZE, ECL_INT); - ecl_kw_scalar_set_int(gridhead_kw, 0); - ecl_kw_iset_int(gridhead_kw, GRIDHEAD_TYPE_INDEX, - GRIDHEAD_GRIDTYPE_CORNERPOINT); - ecl_kw_iset_int(gridhead_kw, GRIDHEAD_NX_INDEX, nx); - ecl_kw_iset_int(gridhead_kw, GRIDHEAD_NY_INDEX, ny); - ecl_kw_iset_int(gridhead_kw, GRIDHEAD_NZ_INDEX, nz); - ecl_kw_iset_int(gridhead_kw, GRIDHEAD_NUMRES_INDEX, 1); - ecl_kw_iset_int(gridhead_kw, GRIDHEAD_LGR_INDEX, grid_nr); +rd_kw_type *rd_grid_alloc_gridhead_kw(int nx, int ny, int nz, int grid_nr) { + rd_kw_type *gridhead_kw = rd_kw_alloc(GRIDHEAD_KW, GRIDHEAD_SIZE, RD_INT); + rd_kw_scalar_set_int(gridhead_kw, 0); + rd_kw_iset_int(gridhead_kw, GRIDHEAD_TYPE_INDEX, + GRIDHEAD_GRIDTYPE_CORNERPOINT); + rd_kw_iset_int(gridhead_kw, GRIDHEAD_NX_INDEX, nx); + rd_kw_iset_int(gridhead_kw, GRIDHEAD_NY_INDEX, ny); + rd_kw_iset_int(gridhead_kw, GRIDHEAD_NZ_INDEX, nz); + rd_kw_iset_int(gridhead_kw, GRIDHEAD_NUMRES_INDEX, 1); + rd_kw_iset_int(gridhead_kw, GRIDHEAD_LGR_INDEX, grid_nr); return gridhead_kw; } -void ecl_grid_reset_actnum(ecl_grid_type *grid, const int *actnum) { - const int global_size = ecl_grid_get_global_size(grid); +void rd_grid_reset_actnum(rd_grid_type *grid, const int *actnum) { + const int global_size = rd_grid_get_global_size(grid); int g; for (g = 0; g < global_size; g++) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, g); + rd_cell_type *cell = rd_grid_get_cell(grid, g); if (actnum) cell->active = actnum[g]; else cell->active = 1; } - ecl_grid_update_index(grid); + rd_grid_update_index(grid); } -static void ecl_grid_fwrite_self_nnc(const ecl_grid_type *grid, - fortio_type *fortio) { +static void rd_grid_fwrite_self_nnc(const rd_grid_type *grid, + fortio_type *fortio) { const int default_index = 1; int_vector_type *g1 = int_vector_alloc(0, default_index); int_vector_type *g2 = int_vector_alloc(0, default_index); int g; - for (g = 0; g < ecl_grid_get_global_size(grid); g++) { - ecl_cell_type *cell = ecl_grid_get_cell(grid, g); + for (g = 0; g < rd_grid_get_global_size(grid); g++) { + rd_cell_type *cell = rd_grid_get_cell(grid, g); const nnc_info_type *nnc_info = cell->nnc_info; if (nnc_info) { const nnc_vector_type *nnc_vector = @@ -6739,197 +6684,194 @@ static void ecl_grid_fwrite_self_nnc(const ecl_grid_type *grid, } { int num_nnc = int_vector_size(g1); - ecl_kw_type *nnc1_kw = ecl_kw_alloc_new_shared( - NNC1_KW, num_nnc, ECL_INT, int_vector_get_ptr(g1)); - ecl_kw_type *nnc2_kw = ecl_kw_alloc_new_shared( - NNC2_KW, num_nnc, ECL_INT, int_vector_get_ptr(g2)); - ecl_kw_type *nnchead_kw = - ecl_kw_alloc(NNCHEAD_KW, NNCHEAD_SIZE, ECL_INT); + rd_kw_type *nnc1_kw = rd_kw_alloc_new_shared(NNC1_KW, num_nnc, RD_INT, + int_vector_get_ptr(g1)); + rd_kw_type *nnc2_kw = rd_kw_alloc_new_shared(NNC2_KW, num_nnc, RD_INT, + int_vector_get_ptr(g2)); + rd_kw_type *nnchead_kw = rd_kw_alloc(NNCHEAD_KW, NNCHEAD_SIZE, RD_INT); - ecl_kw_scalar_set_int(nnchead_kw, 0); - ecl_kw_iset_int(nnchead_kw, NNCHEAD_NUMNNC_INDEX, num_nnc); - ecl_kw_iset_int(nnchead_kw, NNCHEAD_LGR_INDEX, grid->lgr_nr); + rd_kw_scalar_set_int(nnchead_kw, 0); + rd_kw_iset_int(nnchead_kw, NNCHEAD_NUMNNC_INDEX, num_nnc); + rd_kw_iset_int(nnchead_kw, NNCHEAD_LGR_INDEX, grid->lgr_nr); - ecl_kw_fwrite(nnchead_kw, fortio); - ecl_kw_fwrite(nnc1_kw, fortio); - ecl_kw_fwrite(nnc2_kw, fortio); + rd_kw_fwrite(nnchead_kw, fortio); + rd_kw_fwrite(nnc1_kw, fortio); + rd_kw_fwrite(nnc2_kw, fortio); - ecl_kw_free(nnchead_kw); - ecl_kw_free(nnc2_kw); - ecl_kw_free(nnc1_kw); + rd_kw_free(nnchead_kw); + rd_kw_free(nnc2_kw); + rd_kw_free(nnc1_kw); } int_vector_free(g1); int_vector_free(g2); } -static void ecl_grid_fwrite_EGRID__(ecl_grid_type *grid, fortio_type *fortio, - ert_ecl_unit_enum output_unit) { +static void rd_grid_fwrite_EGRID__(rd_grid_type *grid, fortio_type *fortio, + ert_rd_unit_enum output_unit) { bool is_lgr = true; if (grid->parent_grid == NULL) is_lgr = false; /* Writing header */ if (!is_lgr) { - ecl_grid_fwrite_main_EGRID_header(grid, fortio, output_unit); + rd_grid_fwrite_main_EGRID_header(grid, fortio, output_unit); } else { { - ecl_kw_type *lgr_kw = ecl_kw_alloc(LGR_KW, 1, ECL_CHAR); - ecl_kw_iset_string8(lgr_kw, 0, grid->name); - ecl_kw_fwrite(lgr_kw, fortio); - ecl_kw_free(lgr_kw); + rd_kw_type *lgr_kw = rd_kw_alloc(LGR_KW, 1, RD_CHAR); + rd_kw_iset_string8(lgr_kw, 0, grid->name); + rd_kw_fwrite(lgr_kw, fortio); + rd_kw_free(lgr_kw); } { - ecl_kw_type *lgr_parent_kw = - ecl_kw_alloc(LGR_PARENT_KW, 1, ECL_CHAR); + rd_kw_type *lgr_parent_kw = rd_kw_alloc(LGR_PARENT_KW, 1, RD_CHAR); if (grid->parent_name != NULL) - ecl_kw_iset_string8(lgr_parent_kw, 0, grid->parent_name); + rd_kw_iset_string8(lgr_parent_kw, 0, grid->parent_name); else - ecl_kw_iset_string8(lgr_parent_kw, 0, ""); + rd_kw_iset_string8(lgr_parent_kw, 0, ""); - ecl_kw_fwrite(lgr_parent_kw, fortio); - ecl_kw_free(lgr_parent_kw); + rd_kw_fwrite(lgr_parent_kw, fortio); + rd_kw_free(lgr_parent_kw); } } - ecl_grid_fwrite_gridhead_kw(grid->nx, grid->ny, grid->nz, grid->lgr_nr, - fortio); + rd_grid_fwrite_gridhead_kw(grid->nx, grid->ny, grid->nz, grid->lgr_nr, + fortio); /* Writing main grid data */ { - ecl_grid_assert_coord_kw(grid); + rd_grid_assert_coord_kw(grid); { - ecl_kw_type *coord_kw = ecl_kw_alloc_copy(grid->coord_kw); - ecl_kw_type *zcorn_kw = ecl_grid_alloc_zcorn_kw(grid); + rd_kw_type *coord_kw = rd_kw_alloc_copy(grid->coord_kw); + rd_kw_type *zcorn_kw = rd_grid_alloc_zcorn_kw(grid); if (output_unit != grid->unit_system) { - double scale_factor = - ecl_grid_output_scaling(grid, output_unit); - ecl_kw_scale_float(coord_kw, scale_factor); - ecl_kw_scale_float(zcorn_kw, scale_factor); + double scale_factor = rd_grid_output_scaling(grid, output_unit); + rd_kw_scale_float(coord_kw, scale_factor); + rd_kw_scale_float(zcorn_kw, scale_factor); } - ecl_kw_fwrite(coord_kw, fortio); - ecl_kw_fwrite(zcorn_kw, fortio); - ecl_kw_free(zcorn_kw); - ecl_kw_free(coord_kw); + rd_kw_fwrite(coord_kw, fortio); + rd_kw_fwrite(zcorn_kw, fortio); + rd_kw_free(zcorn_kw); + rd_kw_free(coord_kw); } { - ecl_kw_type *actnum_kw = ecl_grid_alloc_actnum_kw(grid); - ecl_kw_fwrite(actnum_kw, fortio); - ecl_kw_free(actnum_kw); + rd_kw_type *actnum_kw = rd_grid_alloc_actnum_kw(grid); + rd_kw_fwrite(actnum_kw, fortio); + rd_kw_free(actnum_kw); } if (is_lgr) { - ecl_kw_type *hostnum_kw = ecl_grid_alloc_hostnum_kw(grid); - ecl_kw_fwrite(hostnum_kw, fortio); - ecl_kw_free(hostnum_kw); + rd_kw_type *hostnum_kw = rd_grid_alloc_hostnum_kw(grid); + rd_kw_fwrite(hostnum_kw, fortio); + rd_kw_free(hostnum_kw); } if (grid->coarsening_active) { - ecl_kw_type *corsnum_kw = ecl_grid_alloc_corsnum_kw(grid); - ecl_kw_fwrite(corsnum_kw, fortio); - ecl_kw_free(corsnum_kw); + rd_kw_type *corsnum_kw = rd_grid_alloc_corsnum_kw(grid); + rd_kw_fwrite(corsnum_kw, fortio); + rd_kw_free(corsnum_kw); } { - ecl_kw_type *endgrid_kw = ecl_kw_alloc(ENDGRID_KW, 0, ECL_INT); - ecl_kw_fwrite(endgrid_kw, fortio); - ecl_kw_free(endgrid_kw); + rd_kw_type *endgrid_kw = rd_kw_alloc(ENDGRID_KW, 0, RD_INT); + rd_kw_fwrite(endgrid_kw, fortio); + rd_kw_free(endgrid_kw); } } if (is_lgr) { - ecl_kw_type *endlgr_kw = ecl_kw_alloc(ENDLGR_KW, 0, ECL_INT); - ecl_kw_fwrite(endlgr_kw, fortio); - ecl_kw_free(endlgr_kw); + rd_kw_type *endlgr_kw = rd_kw_alloc(ENDLGR_KW, 0, RD_INT); + rd_kw_fwrite(endlgr_kw, fortio); + rd_kw_free(endlgr_kw); } - ecl_grid_fwrite_self_nnc(grid, fortio); + rd_grid_fwrite_self_nnc(grid, fortio); } -void ecl_grid_fwrite_EGRID2(ecl_grid_type *grid, const char *filename, - ert_ecl_unit_enum output_unit) { +void rd_grid_fwrite_EGRID2(rd_grid_type *grid, const char *filename, + ert_rd_unit_enum output_unit) { bool fmt_file = false; { bool is_fmt; - if (ecl_util_get_file_type(filename, &is_fmt, NULL) != ECL_OTHER_FILE) + if (rd_get_file_type(filename, &is_fmt, NULL) != RD_OTHER_FILE) fmt_file = is_fmt; } fortio_type *fortio = - fortio_open_writer(filename, fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, fmt_file, RD_ENDIAN_FLIP); - ecl_grid_fwrite_EGRID__(grid, fortio, output_unit); + rd_grid_fwrite_EGRID__(grid, fortio, output_unit); { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size(grid->LGR_list); grid_nr++) { - ecl_grid_type *igrid = - (ecl_grid_type *)vector_iget(grid->LGR_list, grid_nr); - ecl_grid_fwrite_EGRID__(igrid, fortio, output_unit); + rd_grid_type *igrid = + (rd_grid_type *)vector_iget(grid->LGR_list, grid_nr); + rd_grid_fwrite_EGRID__(igrid, fortio, output_unit); } } fortio_fclose(fortio); } /* - The construction with ecl_grid_fwrite_EGRID() and - ecl_grid_fwrite_EGRID2() is an attempt to create API stability. New - code should use the ecl_grid_fwrite_EGRID2() function. + The construction with rd_grid_fwrite_EGRID() and + rd_grid_fwrite_EGRID2() is an attempt to create API stability. New + code should use the rd_grid_fwrite_EGRID2() function. */ -void ecl_grid_fwrite_EGRID(ecl_grid_type *grid, const char *filename, - bool output_metric) { - ert_ecl_unit_enum output_unit = ECL_METRIC_UNITS; +void rd_grid_fwrite_EGRID(rd_grid_type *grid, const char *filename, + bool output_metric) { + ert_rd_unit_enum output_unit = RD_METRIC_UNITS; if (!output_metric) - output_unit = ECL_FIELD_UNITS; + output_unit = RD_FIELD_UNITS; - ecl_grid_fwrite_EGRID2(grid, filename, output_unit); + rd_grid_fwrite_EGRID2(grid, filename, output_unit); } -void ecl_grid_fwrite_depth(const ecl_grid_type *grid, fortio_type *init_file, - ert_ecl_unit_enum output_unit) { - ecl_kw_type *depth_kw = - ecl_kw_alloc("DEPTH", ecl_grid_get_nactive(grid), ECL_FLOAT); +void rd_grid_fwrite_depth(const rd_grid_type *grid, fortio_type *init_file, + ert_rd_unit_enum output_unit) { + rd_kw_type *depth_kw = + rd_kw_alloc("DEPTH", rd_grid_get_nactive(grid), RD_FLOAT); { - float *depth_ptr = (float *)ecl_kw_get_ptr(depth_kw); - for (int i = 0; i < ecl_grid_get_nactive(grid); i++) - depth_ptr[i] = ecl_grid_get_cdepth1A(grid, i); + float *depth_ptr = (float *)rd_kw_get_ptr(depth_kw); + for (int i = 0; i < rd_grid_get_nactive(grid); i++) + depth_ptr[i] = rd_grid_get_cdepth1A(grid, i); } - ecl_kw_scale_float(depth_kw, ecl_grid_output_scaling(grid, output_unit)); - ecl_kw_fwrite(depth_kw, init_file); - ecl_kw_free(depth_kw); + rd_kw_scale_float(depth_kw, rd_grid_output_scaling(grid, output_unit)); + rd_kw_fwrite(depth_kw, init_file); + rd_kw_free(depth_kw); } -void ecl_grid_fwrite_dims(const ecl_grid_type *grid, fortio_type *init_file, - ert_ecl_unit_enum output_unit) { - ecl_kw_type *dx = ecl_kw_alloc("DX", ecl_grid_get_nactive(grid), ECL_FLOAT); - ecl_kw_type *dy = ecl_kw_alloc("DY", ecl_grid_get_nactive(grid), ECL_FLOAT); - ecl_kw_type *dz = ecl_kw_alloc("DZ", ecl_grid_get_nactive(grid), ECL_FLOAT); +void rd_grid_fwrite_dims(const rd_grid_type *grid, fortio_type *init_file, + ert_rd_unit_enum output_unit) { + rd_kw_type *dx = rd_kw_alloc("DX", rd_grid_get_nactive(grid), RD_FLOAT); + rd_kw_type *dy = rd_kw_alloc("DY", rd_grid_get_nactive(grid), RD_FLOAT); + rd_kw_type *dz = rd_kw_alloc("DZ", rd_grid_get_nactive(grid), RD_FLOAT); { { - float *dx_ptr = (float *)ecl_kw_get_ptr(dx); - float *dy_ptr = (float *)ecl_kw_get_ptr(dy); - float *dz_ptr = (float *)ecl_kw_get_ptr(dz); - - for (int i = 0; i < ecl_grid_get_nactive(grid); i++) { - dx_ptr[i] = ecl_grid_get_cell_dx1A(grid, i); - dy_ptr[i] = ecl_grid_get_cell_dy1A(grid, i); - dz_ptr[i] = ecl_grid_get_cell_dz1A(grid, i); + float *dx_ptr = (float *)rd_kw_get_ptr(dx); + float *dy_ptr = (float *)rd_kw_get_ptr(dy); + float *dz_ptr = (float *)rd_kw_get_ptr(dz); + + for (int i = 0; i < rd_grid_get_nactive(grid); i++) { + dx_ptr[i] = rd_grid_get_cell_dx1A(grid, i); + dy_ptr[i] = rd_grid_get_cell_dy1A(grid, i); + dz_ptr[i] = rd_grid_get_cell_dz1A(grid, i); } } { - float scale_factor = ecl_grid_output_scaling(grid, output_unit); - ecl_kw_scale_float(dx, scale_factor); - ecl_kw_scale_float(dy, scale_factor); - ecl_kw_scale_float(dz, scale_factor); + float scale_factor = rd_grid_output_scaling(grid, output_unit); + rd_kw_scale_float(dx, scale_factor); + rd_kw_scale_float(dy, scale_factor); + rd_kw_scale_float(dz, scale_factor); } } - ecl_kw_fwrite(dx, init_file); - ecl_kw_fwrite(dy, init_file); - ecl_kw_fwrite(dz, init_file); - ecl_kw_free(dx); - ecl_kw_free(dy); - ecl_kw_free(dz); + rd_kw_fwrite(dx, init_file); + rd_kw_fwrite(dy, init_file); + rd_kw_fwrite(dz, init_file); + rd_kw_free(dx); + rd_kw_free(dy); + rd_kw_free(dz); } /** @@ -6938,25 +6880,25 @@ void ecl_grid_fwrite_dims(const ecl_grid_type *grid, fortio_type *init_file, possible LGRs which are attached. */ -void ecl_grid_fprintf_grdecl2(ecl_grid_type *grid, FILE *stream, - ert_ecl_unit_enum output_unit) { +void rd_grid_fprintf_grdecl2(rd_grid_type *grid, FILE *stream, + ert_rd_unit_enum output_unit) { { - ecl_kw_type *mapunits_kw = ecl_grid_alloc_mapunits_kw(output_unit); - ecl_kw_fprintf_grdecl(mapunits_kw, stream); - ecl_kw_free(mapunits_kw); + rd_kw_type *mapunits_kw = rd_grid_alloc_mapunits_kw(output_unit); + rd_kw_fprintf_grdecl(mapunits_kw, stream); + rd_kw_free(mapunits_kw); fprintf(stream, "\n"); } if (grid->mapaxes != NULL) { - ecl_kw_type *mapaxes_kw = ecl_grid_alloc_mapaxes_kw(grid); - ecl_kw_fprintf_grdecl(mapaxes_kw, stream); - ecl_kw_free(mapaxes_kw); + rd_kw_type *mapaxes_kw = rd_grid_alloc_mapaxes_kw(grid); + rd_kw_fprintf_grdecl(mapaxes_kw, stream); + rd_kw_free(mapaxes_kw); } { - ecl_kw_type *gridunits_kw = ecl_grid_alloc_gridunits_kw(output_unit); - ecl_kw_fprintf_grdecl(gridunits_kw, stream); - ecl_kw_free(gridunits_kw); + rd_kw_type *gridunits_kw = rd_grid_alloc_gridunits_kw(output_unit); + rd_kw_fprintf_grdecl(gridunits_kw, stream); + rd_kw_free(gridunits_kw); fprintf(stream, "\n"); } @@ -6973,28 +6915,28 @@ void ecl_grid_fprintf_grdecl2(ecl_grid_type *grid, FILE *stream, } { - ecl_grid_assert_coord_kw(grid); - ecl_kw_fprintf_grdecl(grid->coord_kw, stream); + rd_grid_assert_coord_kw(grid); + rd_kw_fprintf_grdecl(grid->coord_kw, stream); fprintf(stream, "\n"); } { - ecl_kw_type *zcorn_kw = ecl_grid_alloc_zcorn_kw(grid); - ecl_kw_fprintf_grdecl(zcorn_kw, stream); - ecl_kw_free(zcorn_kw); + rd_kw_type *zcorn_kw = rd_grid_alloc_zcorn_kw(grid); + rd_kw_fprintf_grdecl(zcorn_kw, stream); + rd_kw_free(zcorn_kw); fprintf(stream, "\n"); } { - ecl_kw_type *actnum_kw = ecl_grid_alloc_actnum_kw(grid); - ecl_kw_fprintf_grdecl(actnum_kw, stream); - ecl_kw_free(actnum_kw); + rd_kw_type *actnum_kw = rd_grid_alloc_actnum_kw(grid); + rd_kw_fprintf_grdecl(actnum_kw, stream); + rd_kw_free(actnum_kw); fprintf(stream, "\n"); } } -void ecl_grid_fprintf_grdecl(ecl_grid_type *grid, FILE *stream) { - ecl_grid_fprintf_grdecl2(grid, stream, ECL_METRIC_UNITS); +void rd_grid_fprintf_grdecl(rd_grid_type *grid, FILE *stream) { + rd_grid_fprintf_grdecl2(grid, stream, RD_METRIC_UNITS); } /** @@ -7003,100 +6945,100 @@ void ecl_grid_fprintf_grdecl(ecl_grid_type *grid, FILE *stream) { global_index. */ -void ecl_grid_cell_ri_export(const ecl_grid_type *ecl_grid, int global_index, - double *ri_points) { - const ecl_cell_type *cell = ecl_grid_get_cell(ecl_grid, global_index); +void rd_grid_cell_ri_export(const rd_grid_type *rd_grid, int global_index, + double *ri_points) { + const rd_cell_type *cell = rd_grid_get_cell(rd_grid, global_index); int offset = global_index * 8 * 3; - ecl_cell_ri_export(cell, &ri_points[offset]); + rd_cell_ri_export(cell, &ri_points[offset]); } -void ecl_grid_ri_export(const ecl_grid_type *ecl_grid, double *ri_points) { +void rd_grid_ri_export(const rd_grid_type *rd_grid, double *ri_points) { int global_index; - for (global_index = 0; global_index < ecl_grid->size; global_index++) - ecl_grid_cell_ri_export(ecl_grid, global_index, ri_points); + for (global_index = 0; global_index < rd_grid->size; global_index++) + rd_grid_cell_ri_export(rd_grid, global_index, ri_points); } -bool ecl_grid_dual_grid(const ecl_grid_type *ecl_grid) { - if (ecl_grid->dualp_flag == FILEHEAD_SINGLE_POROSITY) +bool rd_grid_dual_grid(const rd_grid_type *rd_grid) { + if (rd_grid->dualp_flag == FILEHEAD_SINGLE_POROSITY) return false; else return true; } -static int ecl_grid_get_num_nnc__(const ecl_grid_type *grid) { +static int rd_grid_get_num_nnc__(const rd_grid_type *grid) { int g; int num_nnc = 0; for (g = 0; g < grid->size; g++) { - const nnc_info_type *nnc_info = ecl_grid_get_cell_nnc_info1(grid, g); + const nnc_info_type *nnc_info = rd_grid_get_cell_nnc_info1(grid, g); if (nnc_info) num_nnc += nnc_info_get_total_size(nnc_info); } return num_nnc; } -int ecl_grid_get_num_nnc(const ecl_grid_type *grid) { - int num_nnc = ecl_grid_get_num_nnc__(grid); +int rd_grid_get_num_nnc(const rd_grid_type *grid) { + int num_nnc = rd_grid_get_num_nnc__(grid); { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size(grid->LGR_list); grid_nr++) { - ecl_grid_type *igrid = - (ecl_grid_type *)vector_iget(grid->LGR_list, grid_nr); - num_nnc += ecl_grid_get_num_nnc__(igrid); + rd_grid_type *igrid = + (rd_grid_type *)vector_iget(grid->LGR_list, grid_nr); + num_nnc += rd_grid_get_num_nnc__(igrid); } } return num_nnc; } -static ecl_kw_type *ecl_grid_alloc_volume_kw_active(const ecl_grid_type *grid) { - ecl_kw_type *volume_kw = - ecl_kw_alloc("VOLUME", ecl_grid_get_active_size(grid), ECL_DOUBLE); +static rd_kw_type *rd_grid_alloc_volume_kw_active(const rd_grid_type *grid) { + rd_kw_type *volume_kw = + rd_kw_alloc("VOLUME", rd_grid_get_active_size(grid), RD_DOUBLE); { - double *volume_data = (double *)ecl_kw_get_ptr(volume_kw); + double *volume_data = (double *)rd_kw_get_ptr(volume_kw); int active_index; - for (active_index = 0; active_index < ecl_grid_get_active_size(grid); + for (active_index = 0; active_index < rd_grid_get_active_size(grid); active_index++) { - double cell_volume = ecl_grid_get_cell_volume1A(grid, active_index); + double cell_volume = rd_grid_get_cell_volume1A(grid, active_index); volume_data[active_index] = cell_volume; } } return volume_kw; } -static ecl_kw_type *ecl_grid_alloc_volume_kw_global(const ecl_grid_type *grid) { - ecl_kw_type *volume_kw = - ecl_kw_alloc("VOLUME", ecl_grid_get_global_size(grid), ECL_DOUBLE); +static rd_kw_type *rd_grid_alloc_volume_kw_global(const rd_grid_type *grid) { + rd_kw_type *volume_kw = + rd_kw_alloc("VOLUME", rd_grid_get_global_size(grid), RD_DOUBLE); { - double *volume_data = (double *)ecl_kw_get_ptr(volume_kw); + double *volume_data = (double *)rd_kw_get_ptr(volume_kw); int global_index; - for (global_index = 0; global_index < ecl_grid_get_global_size(grid); + for (global_index = 0; global_index < rd_grid_get_global_size(grid); global_index++) { - double cell_volume = ecl_grid_get_cell_volume1(grid, global_index); + double cell_volume = rd_grid_get_cell_volume1(grid, global_index); volume_data[global_index] = cell_volume; } } return volume_kw; } -ecl_kw_type *ecl_grid_alloc_volume_kw(const ecl_grid_type *grid, - bool active_size) { +rd_kw_type *rd_grid_alloc_volume_kw(const rd_grid_type *grid, + bool active_size) { if (active_size) - return ecl_grid_alloc_volume_kw_active(grid); + return rd_grid_alloc_volume_kw_active(grid); else - return ecl_grid_alloc_volume_kw_global(grid); + return rd_grid_alloc_volume_kw_global(grid); } //This function is meant to be used w/ pandas datafram and numpy -//Note: global_index must be allocated w/ ecl_grid->total_active or ecl_grid->global_size int32 data points -// index_data must be allocated w/ (4 * ecl_grid->total_active or ecl_grid->global_size) int32 data points. -void ecl_grid_export_index(const ecl_grid_type *grid, int *global_index, - int *index_data, bool active_only) { +//Note: global_index must be allocated w/ rd_grid->total_active or rd_grid->global_size int32 data points +// index_data must be allocated w/ (4 * rd_grid->total_active or rd_grid->global_size) int32 data points. +void rd_grid_export_index(const rd_grid_type *grid, int *global_index, + int *index_data, bool active_only) { int pos_indx = 0; int pos_data = 0; for (int k = 0; k < grid->nz; k++) for (int j = 0; j < grid->ny; j++) for (int i = 0; i < grid->nx; i++) { - int g = ecl_grid_get_global_index__(grid, i, j, k); + int g = rd_grid_get_global_index__(grid, i, j, k); if (!active_only || grid->cells[g].active_index[0] >= 0) { global_index[pos_indx++] = g; index_data[pos_data++] = i; @@ -7109,9 +7051,9 @@ void ecl_grid_export_index(const ecl_grid_type *grid, int *global_index, //This function is meant to be used w/ pandas datafram and numpy //Note: index_size must equal allocated size of output -void ecl_grid_export_data_as_int(int index_size, const int *data_index, - const ecl_kw_type *kw, int *output) { - int *input = ecl_kw_get_int_ptr(kw); +void rd_grid_export_data_as_int(int index_size, const int *data_index, + const rd_kw_type *kw, int *output) { + int *input = rd_kw_get_int_ptr(kw); for (int i = 0; i < index_size; i++) { int di = data_index[i]; if (di >= 0) @@ -7121,42 +7063,42 @@ void ecl_grid_export_data_as_int(int index_size, const int *data_index, //This function is meant to be used w/ pandas datafram and numpy //Note: index_size must equal allocated size of output -void ecl_grid_export_data_as_double(int index_size, const int *data_index, - const ecl_kw_type *kw, double *output) { +void rd_grid_export_data_as_double(int index_size, const int *data_index, + const rd_kw_type *kw, double *output) { for (int i = 0; i < index_size; i++) { int di = data_index[i]; if (di >= 0) - output[i] = ecl_kw_iget_as_double(kw, di); + output[i] = rd_kw_iget_as_double(kw, di); } } //This function is meant to be used w/ pandas datafram and numpy -void ecl_grid_export_volume(const ecl_grid_type *grid, int index_size, - const int *global_index, double *output) { +void rd_grid_export_volume(const rd_grid_type *grid, int index_size, + const int *global_index, double *output) { for (int i = 0; i < index_size; i++) { int g = global_index[i]; - output[i] = ecl_grid_get_cell_volume1(grid, g); + output[i] = rd_grid_get_cell_volume1(grid, g); } } //This function is meant to be used w/ pandas datafram and numpy -void ecl_grid_export_position(const ecl_grid_type *grid, int index_size, - const int *global_index, double *output) { +void rd_grid_export_position(const rd_grid_type *grid, int index_size, + const int *global_index, double *output) { for (int i = 0; i < index_size; i++) { int g = global_index[i]; int j = 3 * i; - ecl_grid_get_xyz1(grid, g, &output[j], &output[j + 1], &output[j + 2]); + rd_grid_get_xyz1(grid, g, &output[j], &output[j + 1], &output[j + 2]); } } //This function is meant to be used w/ pandas dataframe and numpy -void export_corners(const ecl_grid_type *grid, int index_size, +void export_corners(const rd_grid_type *grid, int index_size, const int *global_index, double *output) { double x[8], y[8], z[8]; int pos = 0; for (int i = 0; i < index_size; i++) { int g = global_index[i]; - ecl_grid_export_cell_corners1(grid, g, x, y, z); + rd_grid_export_cell_corners1(grid, g, x, y, z); for (int j = 0; j < 8; j++) { output[pos++] = x[j]; output[pos++] = y[j]; diff --git a/lib/resdata/rd_grid_cache.cpp b/lib/resdata/rd_grid_cache.cpp index c5105e61a2..104ed49fd8 100644 --- a/lib/resdata/rd_grid_cache.cpp +++ b/lib/resdata/rd_grid_cache.cpp @@ -4,28 +4,27 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "detail/ecl/ecl_grid_cache.hpp" +#include "detail/resdata/rd_grid_cache.hpp" /** - The ecl_grid_cache_struct data structure internalizes the world + The rd_grid_cache_struct data structure internalizes the world position of all the active cells. This is just a minor simplification to speed up repeated calls to get the true world coordinates of a cell. */ -namespace ecl { -ecl_grid_cache::ecl_grid_cache(const ecl_grid_type *grid) : grid(grid) { +namespace rd { +rd_grid_cache::rd_grid_cache(const rd_grid_type *grid) : grid(grid) { for (int active_index = 0; - active_index < ecl_grid_get_active_size(this->grid); active_index++) { + active_index < rd_grid_get_active_size(this->grid); active_index++) { double x, y, z; - int global_index = - ecl_grid_get_global_index1A(this->grid, active_index); - ecl_grid_get_xyz1(this->grid, global_index, &x, &y, &z); + int global_index = rd_grid_get_global_index1A(this->grid, active_index); + rd_grid_get_xyz1(this->grid, global_index, &x, &y, &z); this->gi.push_back(global_index); this->xp.push_back(x); @@ -34,13 +33,13 @@ ecl_grid_cache::ecl_grid_cache(const ecl_grid_type *grid) : grid(grid) { } } -const std::vector &ecl_grid_cache::volume() const { +const std::vector &rd_grid_cache::volume() const { if (this->v.empty()) { for (int active_index = 0; active_index < this->size(); active_index++) this->v.push_back( - ecl_grid_get_cell_volume1A(this->grid, active_index)); + rd_grid_get_cell_volume1A(this->grid, active_index)); } return this->v; } -} // namespace ecl +} // namespace rd diff --git a/lib/resdata/rd_grid_dims.cpp b/lib/resdata/rd_grid_dims.cpp index 22ab4f1731..9bdcc91f26 100644 --- a/lib/resdata/rd_grid_dims.cpp +++ b/lib/resdata/rd_grid_dims.cpp @@ -4,39 +4,39 @@ #include #include -#include -#include -#include -#include -#include -#include - -struct ecl_grid_dims_struct { +#include +#include +#include +#include +#include +#include + +struct rd_grid_dims_struct { vector_type *dims_list; }; -static void ecl_grid_dims_read_EGRID(ecl_grid_dims_type *grid_dims, - fortio_type *grid_fortio, - fortio_type *data_fortio) { - while (ecl_kw_fseek_kw(GRIDHEAD_KW, false, false, grid_fortio)) { +static void rd_grid_dims_read_EGRID(rd_grid_dims_type *grid_dims, + fortio_type *grid_fortio, + fortio_type *data_fortio) { + while (rd_kw_fseek_kw(GRIDHEAD_KW, false, false, grid_fortio)) { grid_dims_type *dims; { - ecl_kw_type *gridhead_kw = ecl_kw_fread_alloc(grid_fortio); + rd_kw_type *gridhead_kw = rd_kw_fread_alloc(grid_fortio); - int nx = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NX_INDEX); - int ny = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NY_INDEX); - int nz = ecl_kw_iget_int(gridhead_kw, GRIDHEAD_NZ_INDEX); + int nx = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NX_INDEX); + int ny = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NY_INDEX); + int nz = rd_kw_iget_int(gridhead_kw, GRIDHEAD_NZ_INDEX); dims = grid_dims_alloc(nx, ny, nz, 0); - ecl_kw_free(gridhead_kw); + rd_kw_free(gridhead_kw); } if (data_fortio) { - if (ecl_kw_fseek_kw(INTEHEAD_KW, false, false, data_fortio)) { - ecl_kw_type *intehead_kw = ecl_kw_fread_alloc(data_fortio); + if (rd_kw_fseek_kw(INTEHEAD_KW, false, false, data_fortio)) { + rd_kw_type *intehead_kw = rd_kw_fread_alloc(data_fortio); dims->nactive = - ecl_kw_iget_int(intehead_kw, INTEHEAD_NACTIVE_INDEX); - ecl_kw_free(intehead_kw); + rd_kw_iget_int(intehead_kw, INTEHEAD_NACTIVE_INDEX); + rd_kw_free(intehead_kw); } } @@ -44,28 +44,28 @@ static void ecl_grid_dims_read_EGRID(ecl_grid_dims_type *grid_dims, } } -static void ecl_grid_dims_read_GRID(ecl_grid_dims_type *grid_dims, - fortio_type *grid_fortio, - fortio_type *data_fortio) { - while (ecl_kw_fseek_kw(DIMENS_KW, false, false, grid_fortio)) { +static void rd_grid_dims_read_GRID(rd_grid_dims_type *grid_dims, + fortio_type *grid_fortio, + fortio_type *data_fortio) { + while (rd_kw_fseek_kw(DIMENS_KW, false, false, grid_fortio)) { grid_dims_type *dims; { - ecl_kw_type *dimens_kw = ecl_kw_fread_alloc(grid_fortio); + rd_kw_type *dimens_kw = rd_kw_fread_alloc(grid_fortio); - int nx = ecl_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); - int ny = ecl_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); - int nz = ecl_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); + int nx = rd_kw_iget_int(dimens_kw, DIMENS_NX_INDEX); + int ny = rd_kw_iget_int(dimens_kw, DIMENS_NY_INDEX); + int nz = rd_kw_iget_int(dimens_kw, DIMENS_NZ_INDEX); dims = grid_dims_alloc(nx, ny, nz, 0); - ecl_kw_free(dimens_kw); + rd_kw_free(dimens_kw); } if (data_fortio) { - if (ecl_kw_fseek_kw(INTEHEAD_KW, false, false, data_fortio)) { - ecl_kw_type *intehead_kw = ecl_kw_fread_alloc(data_fortio); + if (rd_kw_fseek_kw(INTEHEAD_KW, false, false, data_fortio)) { + rd_kw_type *intehead_kw = rd_kw_fread_alloc(data_fortio); dims->nactive = - ecl_kw_iget_int(intehead_kw, INTEHEAD_NACTIVE_INDEX); - ecl_kw_free(intehead_kw); + rd_kw_iget_int(intehead_kw, INTEHEAD_NACTIVE_INDEX); + rd_kw_free(intehead_kw); } } @@ -73,19 +73,18 @@ static void ecl_grid_dims_read_GRID(ecl_grid_dims_type *grid_dims, } } -ecl_grid_dims_type *ecl_grid_dims_alloc(const char *grid_file, - const char *data_file) { - ecl_grid_dims_type *grid_dims = NULL; +rd_grid_dims_type *rd_grid_dims_alloc(const char *grid_file, + const char *data_file) { + rd_grid_dims_type *grid_dims = NULL; bool grid_fmt_file; - ecl_file_enum grid_file_type = - ecl_util_get_file_type(grid_file, &grid_fmt_file, NULL); + rd_file_enum grid_file_type = + rd_get_file_type(grid_file, &grid_fmt_file, NULL); - if ((grid_file_type == ECL_GRID_FILE) || - (grid_file_type == ECL_EGRID_FILE)) { + if ((grid_file_type == RD_GRID_FILE) || (grid_file_type == RD_EGRID_FILE)) { fortio_type *grid_fortio = - fortio_open_reader(grid_file, grid_fmt_file, ECL_ENDIAN_FLIP); + fortio_open_reader(grid_file, grid_fmt_file, RD_ENDIAN_FLIP); if (grid_fortio) { - grid_dims = (ecl_grid_dims_type *)util_malloc(sizeof *grid_dims); + grid_dims = (rd_grid_dims_type *)util_malloc(sizeof *grid_dims); grid_dims->dims_list = vector_alloc_new(); { @@ -93,17 +92,16 @@ ecl_grid_dims_type *ecl_grid_dims_alloc(const char *grid_file, bool data_fmt_file; if (data_file) { - ecl_util_get_file_type(data_file, &data_fmt_file, NULL); + rd_get_file_type(data_file, &data_fmt_file, NULL); data_fortio = fortio_open_reader(data_file, data_fmt_file, - ECL_ENDIAN_FLIP); + RD_ENDIAN_FLIP); } - if (grid_file_type == ECL_EGRID_FILE) - ecl_grid_dims_read_EGRID(grid_dims, grid_fortio, - data_fortio); - else - ecl_grid_dims_read_GRID(grid_dims, grid_fortio, + if (grid_file_type == RD_EGRID_FILE) + rd_grid_dims_read_EGRID(grid_dims, grid_fortio, data_fortio); + else + rd_grid_dims_read_GRID(grid_dims, grid_fortio, data_fortio); if (data_fortio) fortio_fclose(data_fortio); @@ -115,17 +113,17 @@ ecl_grid_dims_type *ecl_grid_dims_alloc(const char *grid_file, return grid_dims; } -void ecl_grid_dims_free(ecl_grid_dims_type *grid_dims) { +void rd_grid_dims_free(rd_grid_dims_type *grid_dims) { vector_free(grid_dims->dims_list); free(grid_dims); } -int ecl_grid_dims_get_num_grids(const ecl_grid_dims_type *grid_dims) { +int rd_grid_dims_get_num_grids(const rd_grid_dims_type *grid_dims) { return vector_get_size(grid_dims->dims_list); } -const grid_dims_type * -ecl_grid_dims_iget_dims(const ecl_grid_dims_type *grid_dims, int grid_nr) { +const grid_dims_type *rd_grid_dims_iget_dims(const rd_grid_dims_type *grid_dims, + int grid_nr) { return (const grid_dims_type *)vector_iget_const(grid_dims->dims_list, grid_nr); } diff --git a/lib/resdata/rd_init_file.cpp b/lib/resdata/rd_init_file.cpp index 0b22a2965a..a27cb86d58 100644 --- a/lib/resdata/rd_init_file.cpp +++ b/lib/resdata/rd_init_file.cpp @@ -7,49 +7,49 @@ The functionality is mainly targeted at saving grid properties like PORO, PERMX and FIPNUM. The thermodynamic/relperm properties are mainly hardcoded to FALSE (in particular in the - ecl_init_file_alloc_LOGIHEAD() function); this implies that the INIT + rd_init_file_alloc_LOGIHEAD() function); this implies that the INIT files produced in this way are probably not 100% valid, and can certainly not be used to query for e.g. relperm properties. */ #include -#include -#include -#include -#include -#include -#include -#include - -static ecl_kw_type *ecl_init_file_alloc_INTEHEAD(const ecl_grid_type *ecl_grid, - ert_ecl_unit_enum unit_system, - int phases, time_t start_date, - int simulator) { - ecl_kw_type *intehead_kw = - ecl_kw_alloc(INTEHEAD_KW, INTEHEAD_INIT_SIZE, ECL_INT); - ecl_kw_scalar_set_int(intehead_kw, 0); - - ecl_kw_iset_int(intehead_kw, INTEHEAD_UNIT_INDEX, unit_system); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NX_INDEX, ecl_grid_get_nx(ecl_grid)); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NY_INDEX, ecl_grid_get_ny(ecl_grid)); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NZ_INDEX, ecl_grid_get_nz(ecl_grid)); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NACTIVE_INDEX, - ecl_grid_get_active_size(ecl_grid)); - ecl_kw_iset_int(intehead_kw, INTEHEAD_PHASE_INDEX, phases); +#include +#include +#include +#include +#include +#include +#include + +static rd_kw_type *rd_init_file_alloc_INTEHEAD(const rd_grid_type *rd_grid, + ert_rd_unit_enum unit_system, + int phases, time_t start_date, + int simulator) { + rd_kw_type *intehead_kw = + rd_kw_alloc(INTEHEAD_KW, INTEHEAD_INIT_SIZE, RD_INT); + rd_kw_scalar_set_int(intehead_kw, 0); + + rd_kw_iset_int(intehead_kw, INTEHEAD_UNIT_INDEX, unit_system); + rd_kw_iset_int(intehead_kw, INTEHEAD_NX_INDEX, rd_grid_get_nx(rd_grid)); + rd_kw_iset_int(intehead_kw, INTEHEAD_NY_INDEX, rd_grid_get_ny(rd_grid)); + rd_kw_iset_int(intehead_kw, INTEHEAD_NZ_INDEX, rd_grid_get_nz(rd_grid)); + rd_kw_iset_int(intehead_kw, INTEHEAD_NACTIVE_INDEX, + rd_grid_get_active_size(rd_grid)); + rd_kw_iset_int(intehead_kw, INTEHEAD_PHASE_INDEX, phases); { int mday, month, year; - ecl_util_set_date_values(start_date, &mday, &month, &year); - ecl_kw_iset_int(intehead_kw, INTEHEAD_DAY_INDEX, mday); - ecl_kw_iset_int(intehead_kw, INTEHEAD_MONTH_INDEX, month); - ecl_kw_iset_int(intehead_kw, INTEHEAD_YEAR_INDEX, year); + rd_set_date_values(start_date, &mday, &month, &year); + rd_kw_iset_int(intehead_kw, INTEHEAD_DAY_INDEX, mday); + rd_kw_iset_int(intehead_kw, INTEHEAD_MONTH_INDEX, month); + rd_kw_iset_int(intehead_kw, INTEHEAD_YEAR_INDEX, year); } - ecl_kw_iset_int(intehead_kw, INTEHEAD_IPROG_INDEX, simulator); + rd_kw_iset_int(intehead_kw, INTEHEAD_IPROG_INDEX, simulator); return intehead_kw; } -static ecl_kw_type *ecl_init_file_alloc_LOGIHEAD(int simulator) { +static rd_kw_type *rd_init_file_alloc_LOGIHEAD(int simulator) { /* This function includes lots of hardcoded options; the main intention of writing the INIT file is to store the grid properties @@ -75,53 +75,53 @@ static ecl_kw_type *ecl_init_file_alloc_LOGIHEAD(int simulator) { bool scale_water_PC_at_max_sat = false; bool scale_gas_PC_at_max_sat = false; - ecl_kw_type *logihead_kw = - ecl_kw_alloc(LOGIHEAD_KW, LOGIHEAD_INIT_SIZE, ECL_BOOL); + rd_kw_type *logihead_kw = + rd_kw_alloc(LOGIHEAD_KW, LOGIHEAD_INIT_SIZE, RD_BOOL); - ecl_kw_scalar_set_bool(logihead_kw, false); + rd_kw_scalar_set_bool(logihead_kw, false); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_RS_INDEX, with_RS); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_RV_INDEX, with_RV); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_DIR_RELPERM_INDEX, - with_directional_relperm); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_RS_INDEX, with_RS); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_RV_INDEX, with_RV); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_DIR_RELPERM_INDEX, + with_directional_relperm); if (simulator == INTEHEAD_ECLIPSE100_VALUE) { - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_REV_RELPERM100_INDEX, - with_reversible_relperm_ECLIPSE100); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL100_INDEX, - radial_grid_ECLIPSE100); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_REV_RELPERM100_INDEX, + with_reversible_relperm_ECLIPSE100); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL100_INDEX, + radial_grid_ECLIPSE100); } else { - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_REV_RELPERM300_INDEX, - with_reversible_relperm_ECLIPSE300); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL300_INDEX, - radial_grid_ECLIPSE300); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_REV_RELPERM300_INDEX, + with_reversible_relperm_ECLIPSE300); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL300_INDEX, + radial_grid_ECLIPSE300); } - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_HYSTERISIS_INDEX, with_hysterisis); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_DUALP_INDEX, dual_porosity); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_ENDPOINT_SCALING_INDEX, - endpoint_scaling); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_DIR_ENDPOINT_SCALING_INDEX, - directional_endpoint_scaling); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_REV_ENDPOINT_SCALING_INDEX, - reversible_endpoint_scaling); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX, - alternative_endpoint_scaling); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_MISC_DISPLACEMENT_INDEX, - miscible_displacement); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_SCALE_WATER_PC_AT_MAX_SAT_INDEX, - scale_water_PC_at_max_sat); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_SCALE_GAS_PC_AT_MAX_SAT_INDEX, - scale_gas_PC_at_max_sat); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_HYSTERISIS_INDEX, with_hysterisis); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_DUALP_INDEX, dual_porosity); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_ENDPOINT_SCALING_INDEX, + endpoint_scaling); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_DIR_ENDPOINT_SCALING_INDEX, + directional_endpoint_scaling); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_REV_ENDPOINT_SCALING_INDEX, + reversible_endpoint_scaling); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX, + alternative_endpoint_scaling); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_MISC_DISPLACEMENT_INDEX, + miscible_displacement); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_SCALE_WATER_PC_AT_MAX_SAT_INDEX, + scale_water_PC_at_max_sat); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_SCALE_GAS_PC_AT_MAX_SAT_INDEX, + scale_gas_PC_at_max_sat); return logihead_kw; } -static ecl_kw_type *ecl_init_file_alloc_DOUBHEAD() { - ecl_kw_type *doubhead_kw = - ecl_kw_alloc(DOUBHEAD_KW, DOUBHEAD_INIT_SIZE, ECL_DOUBLE); +static rd_kw_type *rd_init_file_alloc_DOUBHEAD() { + rd_kw_type *doubhead_kw = + rd_kw_alloc(DOUBHEAD_KW, DOUBHEAD_INIT_SIZE, RD_DOUBLE); - ecl_kw_scalar_set_double(doubhead_kw, 0); + rd_kw_scalar_set_double(doubhead_kw, 0); return doubhead_kw; } @@ -140,39 +140,36 @@ static ecl_kw_type *ecl_init_file_alloc_DOUBHEAD() { If you do not wish this function to be used for the PORV special casing you can just pass NULL as the poro_kw in the - ecl_init_file_fwrite_header() function. + rd_init_file_fwrite_header() function. */ -static void ecl_init_file_fwrite_poro(fortio_type *fortio, - const ecl_grid_type *ecl_grid, - const ecl_kw_type *poro) { +static void rd_init_file_fwrite_poro(fortio_type *fortio, + const rd_grid_type *rd_grid, + const rd_kw_type *poro) { { - ecl_kw_type *porv = ecl_kw_alloc( - PORV_KW, ecl_grid_get_global_size(ecl_grid), ECL_FLOAT); + rd_kw_type *porv = + rd_kw_alloc(PORV_KW, rd_grid_get_global_size(rd_grid), RD_FLOAT); int global_index; bool global_poro = - (ecl_kw_get_size(poro) == ecl_grid_get_global_size(ecl_grid)) - ? true - : false; - for (global_index = 0; - global_index < ecl_grid_get_global_size(ecl_grid); + (rd_kw_get_size(poro) == rd_grid_get_global_size(rd_grid)) ? true + : false; + for (global_index = 0; global_index < rd_grid_get_global_size(rd_grid); global_index++) { - int active_index = - ecl_grid_get_active_index1(ecl_grid, global_index); + int active_index = rd_grid_get_active_index1(rd_grid, global_index); if (active_index >= 0) { int poro_index = global_poro ? global_index : active_index; - ecl_kw_iset_float( + rd_kw_iset_float( porv, global_index, - ecl_kw_iget_float(poro, poro_index) * - ecl_grid_get_cell_volume1(ecl_grid, global_index)); + rd_kw_iget_float(poro, poro_index) * + rd_grid_get_cell_volume1(rd_grid, global_index)); } else - ecl_kw_iset_float(porv, global_index, 0); + rd_kw_iset_float(porv, global_index, 0); } - ecl_kw_fwrite(porv, fortio); - ecl_kw_free(porv); + rd_kw_fwrite(porv, fortio); + rd_kw_free(porv); } - ecl_kw_fwrite(poro, fortio); + rd_kw_fwrite(poro, fortio); } /* @@ -181,40 +178,40 @@ static void ecl_init_file_fwrite_poro(fortio_type *fortio, that. */ -void ecl_init_file_fwrite_header(fortio_type *fortio, - const ecl_grid_type *ecl_grid, - const ecl_kw_type *poro, - ert_ecl_unit_enum unit_system, int phases, - time_t start_date) { +void rd_init_file_fwrite_header(fortio_type *fortio, + const rd_grid_type *rd_grid, + const rd_kw_type *poro, + ert_rd_unit_enum unit_system, int phases, + time_t start_date) { int simulator = INTEHEAD_ECLIPSE100_VALUE; { - ecl_kw_type *intehead_kw = ecl_init_file_alloc_INTEHEAD( - ecl_grid, unit_system, phases, start_date, simulator); - ecl_kw_fwrite(intehead_kw, fortio); - ecl_kw_free(intehead_kw); + rd_kw_type *intehead_kw = rd_init_file_alloc_INTEHEAD( + rd_grid, unit_system, phases, start_date, simulator); + rd_kw_fwrite(intehead_kw, fortio); + rd_kw_free(intehead_kw); } { - ecl_kw_type *logihead_kw = ecl_init_file_alloc_LOGIHEAD(simulator); - ecl_kw_fwrite(logihead_kw, fortio); - ecl_kw_free(logihead_kw); + rd_kw_type *logihead_kw = rd_init_file_alloc_LOGIHEAD(simulator); + rd_kw_fwrite(logihead_kw, fortio); + rd_kw_free(logihead_kw); } { - ecl_kw_type *doubhead_kw = ecl_init_file_alloc_DOUBHEAD(); - ecl_kw_fwrite(doubhead_kw, fortio); - ecl_kw_free(doubhead_kw); + rd_kw_type *doubhead_kw = rd_init_file_alloc_DOUBHEAD(); + rd_kw_fwrite(doubhead_kw, fortio); + rd_kw_free(doubhead_kw); } if (poro) { - int poro_size = ecl_kw_get_size(poro); - if ((poro_size == ecl_grid_get_nactive(ecl_grid)) || - (poro_size == ecl_grid_get_global_size(ecl_grid))) - ecl_init_file_fwrite_poro(fortio, ecl_grid, poro); + int poro_size = rd_kw_get_size(poro); + if ((poro_size == rd_grid_get_nactive(rd_grid)) || + (poro_size == rd_grid_get_global_size(rd_grid))) + rd_init_file_fwrite_poro(fortio, rd_grid, poro); else util_abort("%s: keyword PORO has wrong size:%d Grid: %d/%d \n", - __func__, ecl_kw_get_size(poro), - ecl_grid_get_nactive(ecl_grid), - ecl_grid_get_global_size(ecl_grid)); + __func__, rd_kw_get_size(poro), + rd_grid_get_nactive(rd_grid), + rd_grid_get_global_size(rd_grid)); } } diff --git a/lib/resdata/rd_io_config.cpp b/lib/resdata/rd_io_config.cpp index 3fcb5e7d6c..ed947f39b5 100644 --- a/lib/resdata/rd_io_config.cpp +++ b/lib/resdata/rd_io_config.cpp @@ -3,8 +3,8 @@ #include -#include -#include +#include +#include /** This file implements a pathetically small struct which is used to @@ -29,48 +29,47 @@ typedef enum { FMT_UNDEFINED = 2 } formatted_type; -struct ecl_io_config_struct { +struct rd_io_config_struct { formatted_type formatted; unified_type unified_restart; unified_type unified_summary; }; -static ecl_io_config_type *ecl_io_config_alloc__() { - ecl_io_config_type *ecl_io_config = - (ecl_io_config_type *)util_malloc(sizeof *ecl_io_config); +static rd_io_config_type *rd_io_config_alloc__() { + rd_io_config_type *rd_io_config = + (rd_io_config_type *)util_malloc(sizeof *rd_io_config); - ecl_io_config->formatted = FMT_UNDEFINED; - ecl_io_config->unified_restart = UNIF_UNDEFINED; - ecl_io_config->unified_summary = UNIF_UNDEFINED; + rd_io_config->formatted = FMT_UNDEFINED; + rd_io_config->unified_restart = UNIF_UNDEFINED; + rd_io_config->unified_summary = UNIF_UNDEFINED; - return ecl_io_config; + return rd_io_config; } -void ecl_io_config_set_formatted(ecl_io_config_type *io_config, - bool formatted) { +void rd_io_config_set_formatted(rd_io_config_type *io_config, bool formatted) { if (formatted) io_config->formatted = FORMATTED; else io_config->formatted = UNFORMATTED; } -void ecl_io_config_set_unified_restart(ecl_io_config_type *io_config, - bool unified) { +void rd_io_config_set_unified_restart(rd_io_config_type *io_config, + bool unified) { if (unified) io_config->unified_restart = UNIFIED; else io_config->unified_restart = MULTIPLE; } -void ecl_io_config_set_unified_summary(ecl_io_config_type *io_config, - bool unified) { +void rd_io_config_set_unified_summary(rd_io_config_type *io_config, + bool unified) { if (unified) io_config->unified_summary = UNIFIED; else io_config->unified_summary = MULTIPLE; } -bool ecl_io_config_get_formatted(ecl_io_config_type *io_config) { +bool rd_io_config_get_formatted(rd_io_config_type *io_config) { if (io_config->formatted == FORMATTED) return true; else if (io_config->formatted == UNFORMATTED) @@ -81,7 +80,7 @@ bool ecl_io_config_get_formatted(ecl_io_config_type *io_config) { } } -bool ecl_io_config_get_unified_summary(ecl_io_config_type *io_config) { +bool rd_io_config_get_unified_summary(rd_io_config_type *io_config) { if (io_config->unified_summary == UNIFIED) return true; else if (io_config->unified_summary == MULTIPLE) @@ -92,7 +91,7 @@ bool ecl_io_config_get_unified_summary(ecl_io_config_type *io_config) { } } -bool ecl_io_config_get_unified_restart(ecl_io_config_type *io_config) { +bool rd_io_config_get_unified_restart(rd_io_config_type *io_config) { if (io_config->unified_restart == UNIFIED) return true; else if (io_config->unified_restart == MULTIPLE) @@ -103,15 +102,15 @@ bool ecl_io_config_get_unified_restart(ecl_io_config_type *io_config) { } } -ecl_io_config_type *ecl_io_config_alloc(bool formatted, bool unified_summary, - bool unified_restart) { - ecl_io_config_type *ecl_io_config = ecl_io_config_alloc__(); +rd_io_config_type *rd_io_config_alloc(bool formatted, bool unified_summary, + bool unified_restart) { + rd_io_config_type *rd_io_config = rd_io_config_alloc__(); - ecl_io_config_set_formatted(ecl_io_config, formatted); - ecl_io_config_set_unified_restart(ecl_io_config, unified_restart); - ecl_io_config_set_unified_summary(ecl_io_config, unified_summary); + rd_io_config_set_formatted(rd_io_config, formatted); + rd_io_config_set_unified_restart(rd_io_config, unified_restart); + rd_io_config_set_unified_summary(rd_io_config, unified_summary); - return ecl_io_config; + return rd_io_config; } -void ecl_io_config_free(ecl_io_config_type *io_config) { free(io_config); } +void rd_io_config_free(rd_io_config_type *io_config) { free(io_config); } diff --git a/lib/resdata/rd_kw.cpp b/lib/resdata/rd_kw.cpp index a078e1f1e6..bc419cac96 100644 --- a/lib/resdata/rd_kw.cpp +++ b/lib/resdata/rd_kw.cpp @@ -8,18 +8,18 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#define ECL_KW_TYPE_ID 6111098 +#define RD_KW_TYPE_ID 6111098 -struct ecl_kw_struct { +struct rd_kw_struct { UTIL_TYPE_ID_DECLARATION; int size; - ecl_data_type data_type; + rd_data_type data_type; char * header8; /* Header which is right padded with ' ' to become exactly 8 characters long. Should only be used internally.*/ char *header; /* Header which is trimmed to no-space. */ @@ -27,7 +27,7 @@ struct ecl_kw_struct { bool shared_data; /* Whether this keyword has shared data or not. */ }; -UTIL_IS_INSTANCE_FUNCTION(ecl_kw, ECL_KW_TYPE_ID) +UTIL_IS_INSTANCE_FUNCTION(rd_kw, RD_KW_TYPE_ID) /* For some peculiar reason the keyword data is written in blocks, all numeric data is in blocks of 1000 elements, and character data is @@ -100,13 +100,13 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw, ECL_KW_TYPE_ID) repsectively. o In the unformatted ECLIPSE files the boolean values are - represented as integers with the values ECL_BOOL_TRUE_INT and - ECL_BOOL_FALSE_INT respectively. + represented as integers with the values RD_BOOL_TRUE_INT and + RD_BOOL_FALSE_INT respectively. - Internally in an ecl_kw instance boolean values are represented as - integers (NOT bool), with the representation given by ECL_BOOL_TRUE_INT - and ECL_BOOL_FALSE_INT. This implies that read/write of unformatted - data can go transparently without between ECLIPSE and the ecl_kw + Internally in an rd_kw instance boolean values are represented as + integers (NOT bool), with the representation given by RD_BOOL_TRUE_INT + and RD_BOOL_FALSE_INT. This implies that read/write of unformatted + data can go transparently without between ECLIPSE and the rd_kw implementation, but exported set()/get() functions with bool must intercept the bool values and convert to the appropriate integer value. @@ -116,131 +116,130 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw, ECL_KW_TYPE_ID) #define BOOL_TRUE_CHAR 'T' #define BOOL_FALSE_CHAR 'F' -ecl_type_enum ecl_kw_get_type(const ecl_kw_type *); -void ecl_kw_set_data_type(ecl_kw_type *ecl_kw, ecl_data_type data_type); +rd_type_enum rd_kw_get_type(const rd_kw_type *); +void rd_kw_set_data_type(rd_kw_type *rd_kw, rd_data_type data_type); -static char *alloc_read_fmt_string(const ecl_data_type ecl_type) { - return util_alloc_sprintf("%%%dc", ecl_type_get_sizeof_iotype(ecl_type)); +static char *alloc_read_fmt_string(const rd_data_type rd_type) { + return util_alloc_sprintf("%%%dc", rd_type_get_sizeof_iotype(rd_type)); } -static char *alloc_read_fmt(const ecl_data_type data_type) { - switch (ecl_type_get_type(data_type)) { - case (ECL_CHAR_TYPE): +static char *alloc_read_fmt(const rd_data_type data_type) { + switch (rd_type_get_type(data_type)) { + case (RD_CHAR_TYPE): return util_alloc_string_copy(READ_FMT_CHAR); - case (ECL_INT_TYPE): + case (RD_INT_TYPE): return util_alloc_string_copy(READ_FMT_INT); - case (ECL_FLOAT_TYPE): + case (RD_FLOAT_TYPE): return util_alloc_string_copy(READ_FMT_FLOAT); - case (ECL_DOUBLE_TYPE): + case (RD_DOUBLE_TYPE): return util_alloc_string_copy(READ_FMT_DOUBLE); - case (ECL_BOOL_TYPE): + case (RD_BOOL_TYPE): return util_alloc_string_copy(READ_FMT_BOOL); - case (ECL_MESS_TYPE): + case (RD_MESS_TYPE): return util_alloc_string_copy(READ_FMT_MESS); - case (ECL_STRING_TYPE): + case (RD_STRING_TYPE): return alloc_read_fmt_string(data_type); default: - util_abort("%s: invalid ecl_type:%s \n", __func__, - ecl_type_alloc_name(data_type)); + util_abort("%s: invalid rd_type:%s \n", __func__, + rd_type_alloc_name(data_type)); return NULL; } } -static char *alloc_write_fmt_string(const ecl_data_type ecl_type) { - return util_alloc_sprintf(" '%%-%ds'", - ecl_type_get_sizeof_iotype(ecl_type)); +static char *alloc_write_fmt_string(const rd_data_type rd_type) { + return util_alloc_sprintf(" '%%-%ds'", rd_type_get_sizeof_iotype(rd_type)); } -static char *alloc_write_fmt(const ecl_data_type data_type) { - switch (ecl_type_get_type(data_type)) { - case (ECL_CHAR_TYPE): +static char *alloc_write_fmt(const rd_data_type data_type) { + switch (rd_type_get_type(data_type)) { + case (RD_CHAR_TYPE): return util_alloc_string_copy(WRITE_FMT_CHAR); - case (ECL_INT_TYPE): + case (RD_INT_TYPE): return util_alloc_string_copy(WRITE_FMT_INT); - case (ECL_FLOAT_TYPE): + case (RD_FLOAT_TYPE): return util_alloc_string_copy(WRITE_FMT_FLOAT); - case (ECL_DOUBLE_TYPE): + case (RD_DOUBLE_TYPE): return util_alloc_string_copy(WRITE_FMT_DOUBLE); - case (ECL_BOOL_TYPE): + case (RD_BOOL_TYPE): return util_alloc_string_copy(WRITE_FMT_BOOL); - case (ECL_MESS_TYPE): + case (RD_MESS_TYPE): return util_alloc_string_copy(WRITE_FMT_MESS); - case (ECL_STRING_TYPE): + case (RD_STRING_TYPE): return alloc_write_fmt_string(data_type); default: - util_abort("%s: invalid ecl_type: %s\n", __func__, - ecl_type_alloc_name(data_type)); + util_abort("%s: invalid rd_type: %s\n", __func__, + rd_type_alloc_name(data_type)); return NULL; } } -static int get_blocksize(ecl_data_type data_type) { - if (ecl_type_is_alpha(data_type)) +static int get_blocksize(rd_data_type data_type) { + if (rd_type_is_alpha(data_type)) return BLOCKSIZE_CHAR; return BLOCKSIZE_NUMERIC; } -static int get_columns(const ecl_data_type data_type) { - switch (ecl_type_get_type(data_type)) { - case (ECL_CHAR_TYPE): +static int get_columns(const rd_data_type data_type) { + switch (rd_type_get_type(data_type)) { + case (RD_CHAR_TYPE): return COLUMNS_CHAR; - case (ECL_INT_TYPE): + case (RD_INT_TYPE): return COLUMNS_INT; - case (ECL_FLOAT_TYPE): + case (RD_FLOAT_TYPE): return COLUMNS_FLOAT; - case (ECL_DOUBLE_TYPE): + case (RD_DOUBLE_TYPE): return COLUMNS_DOUBLE; - case (ECL_BOOL_TYPE): + case (RD_BOOL_TYPE): return COLUMNS_BOOL; - case (ECL_MESS_TYPE): + case (RD_MESS_TYPE): return COLUMNS_MESSAGE; - case (ECL_STRING_TYPE): + case (RD_STRING_TYPE): return COLUMNS_CHAR; // TODO: Is this correct? default: - util_abort("%s: invalid ecl_type: %s\n", __func__, - ecl_type_alloc_name(data_type)); + util_abort("%s: invalid rd_type: %s\n", __func__, + rd_type_alloc_name(data_type)); return -1; } } -static void ecl_kw_assert_index(const ecl_kw_type *ecl_kw, int index, - const char *caller) { - if (index < 0 || index >= ecl_kw->size) +static void rd_kw_assert_index(const rd_kw_type *rd_kw, int index, + const char *caller) { + if (index < 0 || index >= rd_kw->size) util_abort( "%s: Invalid index lookup. kw:%s input_index:%d size:%d \n", - caller, ecl_kw->header, index, ecl_kw->size); + caller, rd_kw->header, index, rd_kw->size); } -static char *ecl_kw_alloc_output_buffer(const ecl_kw_type *ecl_kw) { - size_t sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); - size_t buffer_size = ecl_kw->size * sizeof_iotype; +static char *rd_kw_alloc_output_buffer(const rd_kw_type *rd_kw) { + size_t sizeof_iotype = rd_type_get_sizeof_iotype(rd_kw->data_type); + size_t buffer_size = rd_kw->size * sizeof_iotype; char *buffer = (char *)util_malloc(buffer_size); - if (ecl_type_is_bool(ecl_kw->data_type)) { + if (rd_type_is_bool(rd_kw->data_type)) { int *int_data = (int *)buffer; - bool *bool_data = (bool *)ecl_kw->data; + bool *bool_data = (bool *)rd_kw->data; - for (int i = 0; i < ecl_kw->size; i++) + for (int i = 0; i < rd_kw->size; i++) if (bool_data[i]) - int_data[i] = ECL_BOOL_TRUE_INT; + int_data[i] = RD_BOOL_TRUE_INT; else - int_data[i] = ECL_BOOL_FALSE_INT; + int_data[i] = RD_BOOL_FALSE_INT; - util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + util_endian_flip_vector(buffer, sizeof_iotype, rd_kw->size); return buffer; } - if (ecl_type_is_char(ecl_kw->data_type) || - ecl_type_is_string(ecl_kw->data_type)) { - size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); - for (int i = 0; i < ecl_kw->size; i++) { + if (rd_type_is_char(rd_kw->data_type) || + rd_type_is_string(rd_kw->data_type)) { + size_t sizeof_ctype = rd_type_get_sizeof_ctype(rd_kw->data_type); + for (int i = 0; i < rd_kw->size; i++) { size_t buffer_offset = i * sizeof_iotype; size_t data_offset = i * sizeof_ctype; - size_t string_length = strlen(&ecl_kw->data[data_offset]); + size_t string_length = strlen(&rd_kw->data[data_offset]); for (size_t i = 0; i < string_length; i++) - buffer[buffer_offset + i] = ecl_kw->data[data_offset + i]; + buffer[buffer_offset + i] = rd_kw->data[data_offset + i]; // Pad with spaces for (size_t i = string_length; i < sizeof_iotype; i++) @@ -250,44 +249,44 @@ static char *ecl_kw_alloc_output_buffer(const ecl_kw_type *ecl_kw) { return buffer; } - if (ecl_type_is_mess(ecl_kw->data_type)) + if (rd_type_is_mess(rd_kw->data_type)) return buffer; - if (ecl_kw->data) { - memcpy(buffer, ecl_kw->data, buffer_size); - util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + if (rd_kw->data) { + memcpy(buffer, rd_kw->data, buffer_size); + util_endian_flip_vector(buffer, sizeof_iotype, rd_kw->size); } return buffer; } -static char *ecl_kw_alloc_input_buffer(const ecl_kw_type *ecl_kw) { +static char *rd_kw_alloc_input_buffer(const rd_kw_type *rd_kw) { size_t buffer_size = - ecl_kw->size * ecl_type_get_sizeof_iotype(ecl_kw->data_type); + rd_kw->size * rd_type_get_sizeof_iotype(rd_kw->data_type); char *buffer = (char *)util_malloc(buffer_size); return buffer; } -static void ecl_kw_load_from_input_buffer(ecl_kw_type *ecl_kw, char *buffer) { - size_t sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); - size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); - size_t buffer_size = ecl_kw->size * sizeof_iotype; - if (ECL_ENDIAN_FLIP) { - if (ecl_type_is_numeric(ecl_kw->data_type) || - ecl_type_is_bool(ecl_kw->data_type)) - util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); +static void rd_kw_load_from_input_buffer(rd_kw_type *rd_kw, char *buffer) { + size_t sizeof_iotype = rd_type_get_sizeof_iotype(rd_kw->data_type); + size_t sizeof_ctype = rd_type_get_sizeof_ctype(rd_kw->data_type); + size_t buffer_size = rd_kw->size * sizeof_iotype; + if (RD_ENDIAN_FLIP) { + if (rd_type_is_numeric(rd_kw->data_type) || + rd_type_is_bool(rd_kw->data_type)) + util_endian_flip_vector(buffer, sizeof_iotype, rd_kw->size); } /* Special case bool: Return Eclipse integer representation of bool to native bool. */ - if (ecl_type_is_bool(ecl_kw->data_type)) { + if (rd_type_is_bool(rd_kw->data_type)) { int *int_data = (int *)buffer; - bool *bool_data = (bool *)ecl_kw->data; + bool *bool_data = (bool *)rd_kw->data; - for (int i = 0; i < ecl_kw->size; i++) { - if (int_data[i] == ECL_BOOL_TRUE_INT) + for (int i = 0; i < rd_kw->size; i++) { + if (int_data[i] == RD_BOOL_TRUE_INT) bool_data[i] = true; else bool_data[i] = false; @@ -300,78 +299,75 @@ static void ecl_kw_load_from_input_buffer(ecl_kw_type *ecl_kw, char *buffer) { when writing out again strlen() will be called on data - i.e. it is paramount to add this '\0'. */ - if (ecl_type_is_char(ecl_kw->data_type) || - ecl_type_is_string(ecl_kw->data_type)) { + if (rd_type_is_char(rd_kw->data_type) || + rd_type_is_string(rd_kw->data_type)) { const char null_char = '\0'; - for (int i = 0; i < ecl_kw->size; i++) { + for (int i = 0; i < rd_kw->size; i++) { size_t buffer_offset = i * sizeof_iotype; size_t data_offset = i * sizeof_ctype; - memcpy(&ecl_kw->data[data_offset], &buffer[buffer_offset], + memcpy(&rd_kw->data[data_offset], &buffer[buffer_offset], sizeof_iotype); - ecl_kw->data[data_offset + sizeof_iotype] = null_char; + rd_kw->data[data_offset + sizeof_iotype] = null_char; } return; } - if (ecl_type_is_mess(ecl_kw->data_type)) + if (rd_type_is_mess(rd_kw->data_type)) return; /* Plain int, double, float data - that can be copied straight over to the ->data field. */ - memcpy(ecl_kw->data, buffer, buffer_size); + memcpy(rd_kw->data, buffer, buffer_size); } -const char *ecl_kw_get_header8(const ecl_kw_type *ecl_kw) { - return ecl_kw->header8; +const char *rd_kw_get_header8(const rd_kw_type *rd_kw) { + return rd_kw->header8; } /* Return the header without the trailing spaces */ -const char *ecl_kw_get_header(const ecl_kw_type *ecl_kw) { - return ecl_kw->header; -} +const char *rd_kw_get_header(const rd_kw_type *rd_kw) { return rd_kw->header; } -bool ecl_kw_name_equal(const ecl_kw_type *ecl_kw, const char *name) { - return (strcmp(ecl_kw->header, name) == 0); +bool rd_kw_name_equal(const rd_kw_type *rd_kw, const char *name) { + return (strcmp(rd_kw->header, name) == 0); } -void ecl_kw_get_memcpy_data(const ecl_kw_type *ecl_kw, void *target) { - memcpy(target, ecl_kw->data, - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); +void rd_kw_get_memcpy_data(const rd_kw_type *rd_kw, void *target) { + memcpy(target, rd_kw->data, + rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type)); } -void ecl_kw_get_memcpy_int_data(const ecl_kw_type *ecl_kw, int *target) { - if (ecl_type_is_int(ecl_kw->data_type)) - ecl_kw_get_memcpy_data(ecl_kw, target); +void rd_kw_get_memcpy_int_data(const rd_kw_type *rd_kw, int *target) { + if (rd_type_is_int(rd_kw->data_type)) + rd_kw_get_memcpy_data(rd_kw, target); } -void ecl_kw_get_memcpy_float_data(const ecl_kw_type *ecl_kw, float *target) { - if (ecl_type_is_float(ecl_kw->data_type)) - ecl_kw_get_memcpy_data(ecl_kw, target); +void rd_kw_get_memcpy_float_data(const rd_kw_type *rd_kw, float *target) { + if (rd_type_is_float(rd_kw->data_type)) + rd_kw_get_memcpy_data(rd_kw, target); } -void ecl_kw_get_memcpy_double_data(const ecl_kw_type *ecl_kw, double *target) { - if (ecl_type_is_double(ecl_kw->data_type)) - ecl_kw_get_memcpy_data(ecl_kw, target); +void rd_kw_get_memcpy_double_data(const rd_kw_type *rd_kw, double *target) { + if (rd_type_is_double(rd_kw->data_type)) + rd_kw_get_memcpy_data(rd_kw, target); } -/** Allocates a untyped buffer with exactly the same content as the ecl_kw instances data. */ -void *ecl_kw_alloc_data_copy(const ecl_kw_type *ecl_kw) { +/** Allocates a untyped buffer with exactly the same content as the rd_kw instances data. */ +void *rd_kw_alloc_data_copy(const rd_kw_type *rd_kw) { void *buffer = util_alloc_copy( - ecl_kw->data, - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); + rd_kw->data, rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type)); return buffer; } -void ecl_kw_set_memcpy_data(ecl_kw_type *ecl_kw, const void *src) { +void rd_kw_set_memcpy_data(rd_kw_type *rd_kw, const void *src) { if (src != NULL) - memcpy(ecl_kw->data, src, - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); + memcpy(rd_kw->data, src, + rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type)); } -static bool ecl_kw_string_eq(const char *s1, const char *s2) { +static bool rd_kw_string_eq(const char *s1, const char *s2) { const char space_char = ' '; const char *long_kw = (strlen(s1) >= strlen(s2)) ? s1 : s2; const char *short_kw = (strlen(s1) < strlen(s2)) ? s1 : s2; @@ -379,7 +375,7 @@ static bool ecl_kw_string_eq(const char *s1, const char *s2) { const int len2 = strlen(short_kw); int index; bool eq = true; - if (len1 > ECL_STRING8_LENGTH) + if (len1 > RD_STRING8_LENGTH) util_abort("%s : eclipse keyword:%s is too long - aborting \n", __func__, long_kw); @@ -394,34 +390,33 @@ static bool ecl_kw_string_eq(const char *s1, const char *s2) { return eq; } -bool ecl_kw_ichar_eq(const ecl_kw_type *ecl_kw, int i, const char *value) { - char s1[ECL_STRING8_LENGTH + 1]; - ecl_kw_iget(ecl_kw, i, s1); - return ecl_kw_string_eq(s1, value); +bool rd_kw_ichar_eq(const rd_kw_type *rd_kw, int i, const char *value) { + char s1[RD_STRING8_LENGTH + 1]; + rd_kw_iget(rd_kw, i, s1); + return rd_kw_string_eq(s1, value); } -bool ecl_kw_size_and_type_equal(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2) { - return (ecl_kw1->size == ecl_kw2->size && - ecl_type_is_equal(ecl_kw1->data_type, ecl_kw2->data_type)); +bool rd_kw_size_and_type_equal(const rd_kw_type *rd_kw1, + const rd_kw_type *rd_kw2) { + return (rd_kw1->size == rd_kw2->size && + rd_type_is_equal(rd_kw1->data_type, rd_kw2->data_type)); } -bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2) { +bool rd_kw_header_eq(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2) { bool equal = true; - if (strcmp(ecl_kw1->header8, ecl_kw2->header8) != 0) + if (strcmp(rd_kw1->header8, rd_kw2->header8) != 0) equal = false; else - equal = ecl_kw_size_and_type_equal(ecl_kw1, ecl_kw2); + equal = rd_kw_size_and_type_equal(rd_kw1, rd_kw2); return equal; } -static bool ecl_kw_data_equal__(const ecl_kw_type *ecl_kw, const void *data, - int cmp_elements) { - int cmp = - memcmp(ecl_kw->data, data, - cmp_elements * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); +static bool rd_kw_data_equal__(const rd_kw_type *rd_kw, const void *data, + int cmp_elements) { + int cmp = memcmp(rd_kw->data, data, + cmp_elements * rd_type_get_sizeof_ctype(rd_kw->data_type)); if (cmp == 0) return true; else @@ -433,40 +428,39 @@ static bool ecl_kw_data_equal__(const ecl_kw_type *ecl_kw, const void *data, i.e. "reasonably good" numerical agreement is *not* enough. */ -bool ecl_kw_data_equal(const ecl_kw_type *ecl_kw, const void *data) { - return ecl_kw_data_equal__(ecl_kw, data, ecl_kw->size); +bool rd_kw_data_equal(const rd_kw_type *rd_kw, const void *data) { + return rd_kw_data_equal__(rd_kw, data, rd_kw->size); } -bool ecl_kw_content_equal(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2) { - if (ecl_kw_size_and_type_equal(ecl_kw1, ecl_kw2)) - return ecl_kw_data_equal__(ecl_kw1, ecl_kw2->data, ecl_kw1->size); +bool rd_kw_content_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2) { + if (rd_kw_size_and_type_equal(rd_kw1, rd_kw2)) + return rd_kw_data_equal__(rd_kw1, rd_kw2->data, rd_kw1->size); else return false; } /** - This function compares two ecl_kw instances, and returns true if they are equal. + This function compares two rd_kw instances, and returns true if they are equal. */ -bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2) { - bool equal = ecl_kw_header_eq(ecl_kw1, ecl_kw2); +bool rd_kw_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2) { + bool equal = rd_kw_header_eq(rd_kw1, rd_kw2); if (equal) - equal = ecl_kw_data_equal(ecl_kw1, ecl_kw2->data); + equal = rd_kw_data_equal(rd_kw1, rd_kw2->data); return equal; } -#define ECL_KW_NUMERIC_CMP(ctype) \ - static bool ecl_kw_numeric_equal_##ctype(const ecl_kw_type *ecl_kw1, \ - const ecl_kw_type *ecl_kw2, \ - ctype abs_diff, ctype rel_diff) { \ +#define RD_KW_NUMERIC_CMP(ctype) \ + static bool rd_kw_numeric_equal_##ctype(const rd_kw_type *rd_kw1, \ + const rd_kw_type *rd_kw2, \ + ctype abs_diff, ctype rel_diff) { \ int index; \ bool equal = true; \ { \ - const ctype *data1 = (const ctype *)ecl_kw1->data; \ - const ctype *data2 = (const ctype *)ecl_kw2->data; \ - for (index = 0; index < ecl_kw1->size; index++) { \ + const ctype *data1 = (const ctype *)rd_kw1->data; \ + const ctype *data2 = (const ctype *)rd_kw2->data; \ + for (index = 0; index < rd_kw1->size; index++) { \ equal = util_##ctype##_approx_equal__( \ data1[index], data2[index], rel_diff, abs_diff); \ if (!equal) \ @@ -476,164 +470,159 @@ bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2) { return equal; \ } -ECL_KW_NUMERIC_CMP(float) -ECL_KW_NUMERIC_CMP(double) -#undef ECL_KW_NUMERIC_CMP +RD_KW_NUMERIC_CMP(float) +RD_KW_NUMERIC_CMP(double) +#undef RD_KW_NUMERIC_CMP /** - This function compares the data of two ecl_kw instances, and + This function compares the data of two rd_kw instances, and returns true if the relative numerical difference is less than @rel_diff. Does not consider consider the kw header. */ -bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2, double abs_diff, - double rel_diff) { - if (!ecl_kw_size_and_type_equal(ecl_kw1, ecl_kw2)) +bool rd_kw_numeric_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2, + double abs_diff, double rel_diff) { + if (!rd_kw_size_and_type_equal(rd_kw1, rd_kw2)) return false; - if (ecl_type_is_float(ecl_kw1->data_type)) - return ecl_kw_numeric_equal_float(ecl_kw1, ecl_kw2, abs_diff, rel_diff); - else if (ecl_type_is_double(ecl_kw1->data_type)) - return ecl_kw_numeric_equal_double(ecl_kw1, ecl_kw2, abs_diff, - rel_diff); + if (rd_type_is_float(rd_kw1->data_type)) + return rd_kw_numeric_equal_float(rd_kw1, rd_kw2, abs_diff, rel_diff); + else if (rd_type_is_double(rd_kw1->data_type)) + return rd_kw_numeric_equal_double(rd_kw1, rd_kw2, abs_diff, rel_diff); else - return ecl_kw_data_equal(ecl_kw1, ecl_kw2->data); + return rd_kw_data_equal(rd_kw1, rd_kw2->data); } -bool ecl_kw_block_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2, - int cmp_elements) { - if (ecl_kw_header_eq(ecl_kw1, ecl_kw2)) { +bool rd_kw_block_equal(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2, + int cmp_elements) { + if (rd_kw_header_eq(rd_kw1, rd_kw2)) { if (cmp_elements == 0) - cmp_elements = ecl_kw1->size; + cmp_elements = rd_kw1->size; - return ecl_kw_data_equal__(ecl_kw1, ecl_kw2->data, cmp_elements); + return rd_kw_data_equal__(rd_kw1, rd_kw2->data, cmp_elements); } else return false; } -static void ecl_kw_set_shared_ref(ecl_kw_type *ecl_kw, void *data_ptr) { - if (!ecl_kw->shared_data) { - if (ecl_kw->data != NULL) +static void rd_kw_set_shared_ref(rd_kw_type *rd_kw, void *data_ptr) { + if (!rd_kw->shared_data) { + if (rd_kw->data != NULL) util_abort("%s: can not change to shared for keyword with " "allocated storage - aborting \n", __func__); } - ecl_kw->shared_data = true; - ecl_kw->data = (char *)data_ptr; + rd_kw->shared_data = true; + rd_kw->data = (char *)data_ptr; } -static void ecl_kw_initialize(ecl_kw_type *ecl_kw, const char *header, int size, - ecl_data_type data_type) { - ecl_kw_set_data_type(ecl_kw, data_type); - ecl_kw_set_header_name(ecl_kw, header); - ecl_kw->size = size; +static void rd_kw_initialize(rd_kw_type *rd_kw, const char *header, int size, + rd_data_type data_type) { + rd_kw_set_data_type(rd_kw, data_type); + rd_kw_set_header_name(rd_kw, header); + rd_kw->size = size; } -static size_t ecl_kw_fortio_data_size(const ecl_kw_type *ecl_kw) { - const int blocksize = get_blocksize(ecl_kw->data_type); +static size_t rd_kw_fortio_data_size(const rd_kw_type *rd_kw) { + const int blocksize = get_blocksize(rd_kw->data_type); const int num_blocks = - ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); + rd_kw->size / blocksize + (rd_kw->size % blocksize == 0 ? 0 : 1); return num_blocks * (4 + 4) + // Fortran fluff for each block - ecl_kw->size * - ecl_type_get_sizeof_iotype(ecl_kw->data_type); // Actual data + rd_kw->size * + rd_type_get_sizeof_iotype(rd_kw->data_type); // Actual data } /** - Returns the number of bytes this ecl_kw instance would occupy in + Returns the number of bytes this rd_kw instance would occupy in BINARY file; we add 2*4 to the header size to include the size of the fortran header and trailer combo. */ -size_t ecl_kw_fortio_size(const ecl_kw_type *ecl_kw) { - size_t size = ECL_KW_HEADER_FORTIO_SIZE; - size += ecl_kw_fortio_data_size(ecl_kw); +size_t rd_kw_fortio_size(const rd_kw_type *rd_kw) { + size_t size = RD_KW_HEADER_FORTIO_SIZE; + size += rd_kw_fortio_data_size(rd_kw); return size; } /** - The data is copied from the input argument to the ecl_kw; data can be NULL. + The data is copied from the input argument to the rd_kw; data can be NULL. */ -ecl_kw_type *ecl_kw_alloc_new(const char *header, int size, - ecl_data_type data_type, const void *data) { - ecl_kw_type *ecl_kw; - ecl_kw = ecl_kw_alloc_empty(); - ecl_kw_initialize(ecl_kw, header, size, data_type); +rd_kw_type *rd_kw_alloc_new(const char *header, int size, + rd_data_type data_type, const void *data) { + rd_kw_type *rd_kw; + rd_kw = rd_kw_alloc_empty(); + rd_kw_initialize(rd_kw, header, size, data_type); if (data != NULL) { - ecl_kw_alloc_data(ecl_kw); - ecl_kw_set_memcpy_data(ecl_kw, data); + rd_kw_alloc_data(rd_kw); + rd_kw_set_memcpy_data(rd_kw, data); } - return ecl_kw; + return rd_kw; } -ecl_kw_type *ecl_kw_alloc(const char *header, int size, - ecl_data_type data_type) { - ecl_kw_type *ecl_kw; +rd_kw_type *rd_kw_alloc(const char *header, int size, rd_data_type data_type) { + rd_kw_type *rd_kw; - ecl_kw = ecl_kw_alloc_empty(); - ecl_kw_initialize(ecl_kw, header, size, data_type); - ecl_kw_alloc_data(ecl_kw); + rd_kw = rd_kw_alloc_empty(); + rd_kw_initialize(rd_kw, header, size, data_type); + rd_kw_alloc_data(rd_kw); - return ecl_kw; + return rd_kw; } -ecl_kw_type *ecl_kw_alloc_new_shared(const char *header, int size, - ecl_data_type data_type, void *data) { - ecl_kw_type *ecl_kw; - ecl_kw = ecl_kw_alloc_empty(); - ecl_kw_initialize(ecl_kw, header, size, data_type); - ecl_kw_set_shared_ref(ecl_kw, data); - return ecl_kw; +rd_kw_type *rd_kw_alloc_new_shared(const char *header, int size, + rd_data_type data_type, void *data) { + rd_kw_type *rd_kw; + rd_kw = rd_kw_alloc_empty(); + rd_kw_initialize(rd_kw, header, size, data_type); + rd_kw_set_shared_ref(rd_kw, data); + return rd_kw; } -ecl_kw_type *ecl_kw_alloc_empty() { - ecl_kw_type *ecl_kw; +rd_kw_type *rd_kw_alloc_empty() { + rd_kw_type *rd_kw; - ecl_kw = (ecl_kw_type *)util_malloc(sizeof *ecl_kw); - ecl_kw->header = NULL; - ecl_kw->header8 = NULL; - ecl_kw->data = NULL; - ecl_kw->shared_data = false; - ecl_kw->size = 0; + rd_kw = (rd_kw_type *)util_malloc(sizeof *rd_kw); + rd_kw->header = NULL; + rd_kw->header8 = NULL; + rd_kw->data = NULL; + rd_kw->shared_data = false; + rd_kw->size = 0; - UTIL_TYPE_ID_INIT(ecl_kw, ECL_KW_TYPE_ID); + UTIL_TYPE_ID_INIT(rd_kw, RD_KW_TYPE_ID); - return ecl_kw; + return rd_kw; } -void ecl_kw_free(ecl_kw_type *ecl_kw) { - free(ecl_kw->header); - free(ecl_kw->header8); - ecl_kw_free_data(ecl_kw); - free(ecl_kw); +void rd_kw_free(rd_kw_type *rd_kw) { + free(rd_kw->header); + free(rd_kw->header8); + rd_kw_free_data(rd_kw); + free(rd_kw); } -void ecl_kw_free__(void *void_ecl_kw) { - ecl_kw_free((ecl_kw_type *)void_ecl_kw); -} +void rd_kw_free__(void *void_rd_kw) { rd_kw_free((rd_kw_type *)void_rd_kw); } -void ecl_kw_memcpy_data(ecl_kw_type *target, const ecl_kw_type *src) { - if (!ecl_kw_size_and_type_equal(target, src)) +void rd_kw_memcpy_data(rd_kw_type *target, const rd_kw_type *src) { + if (!rd_kw_size_and_type_equal(target, src)) util_abort("%s: type/size mismatch \n", __func__); memcpy(target->data, src->data, - target->size * ecl_type_get_sizeof_ctype(target->data_type)); + target->size * rd_type_get_sizeof_ctype(target->data_type)); } -void ecl_kw_memcpy(ecl_kw_type *target, const ecl_kw_type *src) { +void rd_kw_memcpy(rd_kw_type *target, const rd_kw_type *src) { target->size = src->size; - ecl_kw_set_data_type(target, src->data_type); + rd_kw_set_data_type(target, src->data_type); - ecl_kw_set_header_name(target, src->header); - ecl_kw_alloc_data(target); - ecl_kw_memcpy_data(target, src); + rd_kw_set_header_name(target, src->header); + rd_kw_alloc_data(target); + rd_kw_memcpy_data(target, src); } -ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *src) { - ecl_kw_type *new_; - new_ = ecl_kw_alloc_empty(); - ecl_kw_memcpy(new_, src); +rd_kw_type *rd_kw_alloc_copy(const rd_kw_type *src) { + rd_kw_type *new_; + new_ = rd_kw_alloc_empty(); + rd_kw_memcpy(new_, src); return new_; } @@ -651,8 +640,8 @@ ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *src) { <= 0. */ -ecl_kw_type *ecl_kw_alloc_slice_copy(const ecl_kw_type *src, int index1, - int index2, int stride) { +rd_kw_type *rd_kw_alloc_slice_copy(const rd_kw_type *src, int index1, + int index2, int stride) { if (index1 < 0) index1 = 0; if (index2 > src->size) @@ -662,7 +651,7 @@ ecl_kw_type *ecl_kw_alloc_slice_copy(const ecl_kw_type *src, int index1, if (stride <= 0) util_abort("%s: stride:%d completely broken ...\n", __func__, stride); { - ecl_kw_type *new_kw = NULL; + rd_kw_type *new_kw = NULL; int src_index = index1; /* 1: Determine size of the sliced copy. */ { @@ -672,10 +661,9 @@ ecl_kw_type *ecl_kw_alloc_slice_copy(const ecl_kw_type *src, int index1, src_index += stride; } if (new_size > 0) { - new_kw = ecl_kw_alloc_empty(); - ecl_kw_initialize(new_kw, src->header, new_size, - src->data_type); - ecl_kw_alloc_data(new_kw); + new_kw = rd_kw_alloc_empty(); + rd_kw_initialize(new_kw, src->header, new_size, src->data_type); + rd_kw_alloc_data(new_kw); /* 2: Copy over the elements. */ src_index = index1; @@ -684,7 +672,7 @@ ecl_kw_type *ecl_kw_alloc_slice_copy(const ecl_kw_type *src, int index1, const char *src_ptr = src->data; char *new_ptr = new_kw->data; int sizeof_ctype = - ecl_type_get_sizeof_ctype(new_kw->data_type); + rd_type_get_sizeof_ctype(new_kw->data_type); while (src_index < index2) { memcpy(&new_ptr[target_index * sizeof_ctype], @@ -700,24 +688,24 @@ ecl_kw_type *ecl_kw_alloc_slice_copy(const ecl_kw_type *src, int index1, } } -void ecl_kw_resize(ecl_kw_type *ecl_kw, int new_size) { - if (ecl_kw->shared_data) - util_abort("%s: trying to allocate data for ecl_kw object which has " +void rd_kw_resize(rd_kw_type *rd_kw, int new_size) { + if (rd_kw->shared_data) + util_abort("%s: trying to allocate data for rd_kw object which has " "been declared with shared storage - aborting \n", __func__); - if (new_size != ecl_kw->size) { + if (new_size != rd_kw->size) { size_t old_byte_size = - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); + rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type); size_t new_byte_size = - new_size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); + new_size * rd_type_get_sizeof_ctype(rd_kw->data_type); - ecl_kw->data = (char *)util_realloc(ecl_kw->data, new_byte_size); + rd_kw->data = (char *)util_realloc(rd_kw->data, new_byte_size); if (new_byte_size > old_byte_size) { size_t offset = old_byte_size; - memset(&ecl_kw->data[offset], 0, new_byte_size - old_byte_size); + memset(&rd_kw->data[offset], 0, new_byte_size - old_byte_size); } - ecl_kw->size = new_size; + rd_kw->size = new_size; } } @@ -729,8 +717,8 @@ void ecl_kw_resize(ecl_kw_type *ecl_kw, int new_size) { used. */ -ecl_kw_type *ecl_kw_alloc_sub_copy(const ecl_kw_type *src, const char *new_kw, - int offset, int count) { +rd_kw_type *rd_kw_alloc_sub_copy(const rd_kw_type *src, const char *new_kw, + int offset, int count) { if (new_kw == NULL) new_kw = src->header; @@ -744,48 +732,48 @@ ecl_kw_type *ecl_kw_alloc_sub_copy(const ecl_kw_type *src, const char *new_kw, util_abort("%s: invalid count value: %d \n", __func__, count); { - void *src_data = ecl_kw_iget_ptr(src, offset); - return ecl_kw_alloc_new(new_kw, count, src->data_type, src_data); + void *src_data = rd_kw_iget_ptr(src, offset); + return rd_kw_alloc_new(new_kw, count, src->data_type, src_data); } } -const void *ecl_kw_copyc__(const void *void_kw) { - return ecl_kw_alloc_copy((const ecl_kw_type *)void_kw); +const void *rd_kw_copyc__(const void *void_kw) { + return rd_kw_alloc_copy((const rd_kw_type *)void_kw); } -static void *ecl_kw_iget_ptr_static(const ecl_kw_type *ecl_kw, int i) { - ecl_kw_assert_index(ecl_kw, i, __func__); - return &ecl_kw->data[i * ecl_type_get_sizeof_ctype(ecl_kw->data_type)]; +static void *rd_kw_iget_ptr_static(const rd_kw_type *rd_kw, int i) { + rd_kw_assert_index(rd_kw, i, __func__); + return &rd_kw->data[i * rd_type_get_sizeof_ctype(rd_kw->data_type)]; } -static void ecl_kw_iget_static(const ecl_kw_type *ecl_kw, int i, void *iptr) { - memcpy(iptr, ecl_kw_iget_ptr_static(ecl_kw, i), - ecl_type_get_sizeof_ctype(ecl_kw->data_type)); +static void rd_kw_iget_static(const rd_kw_type *rd_kw, int i, void *iptr) { + memcpy(iptr, rd_kw_iget_ptr_static(rd_kw, i), + rd_type_get_sizeof_ctype(rd_kw->data_type)); } -static void ecl_kw_iset_static(ecl_kw_type *ecl_kw, int i, const void *iptr) { - size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); - ecl_kw_assert_index(ecl_kw, i, __func__); - memcpy(&ecl_kw->data[i * sizeof_ctype], iptr, sizeof_ctype); +static void rd_kw_iset_static(rd_kw_type *rd_kw, int i, const void *iptr) { + size_t sizeof_ctype = rd_type_get_sizeof_ctype(rd_kw->data_type); + rd_kw_assert_index(rd_kw, i, __func__); + memcpy(&rd_kw->data[i * sizeof_ctype], iptr, sizeof_ctype); } -void ecl_kw_iget(const ecl_kw_type *ecl_kw, int i, void *iptr) { - ecl_kw_iget_static(ecl_kw, i, iptr); +void rd_kw_iget(const rd_kw_type *rd_kw, int i, void *iptr) { + rd_kw_iget_static(rd_kw, i, iptr); } /** Will return a double value for underlying data types of double, float and int. */ -double ecl_kw_iget_as_double(const ecl_kw_type *ecl_kw, int index) { - if (ecl_type_is_float(ecl_kw->data_type)) - return ecl_kw_iget_float( - ecl_kw, +double rd_kw_iget_as_double(const rd_kw_type *rd_kw, int index) { + if (rd_type_is_float(rd_kw->data_type)) + return rd_kw_iget_float( + rd_kw, index); /* Here the compiler will silently insert a float -> double conversion. */ - else if (ecl_type_is_double(ecl_kw->data_type)) - return ecl_kw_iget_double(ecl_kw, index); - else if (ecl_type_is_int(ecl_kw->data_type)) - return ecl_kw_iget_int(ecl_kw, index); /* */ + else if (rd_type_is_double(rd_kw->data_type)) + return rd_kw_iget_double(rd_kw, index); + else if (rd_type_is_int(rd_kw->data_type)) + return rd_kw_iget_int(rd_kw, index); /* */ else { util_abort("%s: can not be converted to double - no data for you! \n", __func__); @@ -797,11 +785,11 @@ double ecl_kw_iget_as_double(const ecl_kw_type *ecl_kw, int index) { Will return a float value for underlying data types of double and float. */ -float ecl_kw_iget_as_float(const ecl_kw_type *ecl_kw, int i) { - if (ecl_type_is_float(ecl_kw->data_type)) - return ecl_kw_iget_float(ecl_kw, i); - else if (ecl_type_is_double(ecl_kw->data_type)) - return (float)ecl_kw_iget_double(ecl_kw, i); +float rd_kw_iget_as_float(const rd_kw_type *rd_kw, int i) { + if (rd_type_is_float(rd_kw->data_type)) + return rd_kw_iget_float(rd_kw, i); + else if (rd_type_is_double(rd_kw->data_type)) + return (float)rd_kw_iget_double(rd_kw, i); else { util_abort("%s: can not be converted to float - no data for you! \n", __func__); @@ -809,66 +797,66 @@ float ecl_kw_iget_as_float(const ecl_kw_type *ecl_kw, int i) { } } -#define ECL_KW_IGET_TYPED(ctype, ECL_TYPE) \ - ctype ecl_kw_iget_##ctype(const ecl_kw_type *ecl_kw, int i) { \ +#define RD_KW_IGET_TYPED(ctype, RD_TYPE) \ + ctype rd_kw_iget_##ctype(const rd_kw_type *rd_kw, int i) { \ ctype value; \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ - ecl_kw_iget_static(ecl_kw, i, &value); \ + __func__, rd_kw_get_header8(rd_kw)); \ + rd_kw_iget_static(rd_kw, i, &value); \ return value; \ } -ECL_KW_IGET_TYPED(double, ECL_DOUBLE_TYPE); -ECL_KW_IGET_TYPED(float, ECL_FLOAT_TYPE); -ECL_KW_IGET_TYPED(int, ECL_INT_TYPE); -ECL_KW_IGET_TYPED(bool, ECL_BOOL_TYPE); -#undef ECL_KW_IGET_TYPED +RD_KW_IGET_TYPED(double, RD_DOUBLE_TYPE); +RD_KW_IGET_TYPED(float, RD_FLOAT_TYPE); +RD_KW_IGET_TYPED(int, RD_INT_TYPE); +RD_KW_IGET_TYPED(bool, RD_BOOL_TYPE); +#undef RD_KW_IGET_TYPED -const char *ecl_kw_iget_char_ptr(const ecl_kw_type *ecl_kw, int i) { - if (ecl_kw_get_type(ecl_kw) != ECL_CHAR_TYPE) +const char *rd_kw_iget_char_ptr(const rd_kw_type *rd_kw, int i) { + if (rd_kw_get_type(rd_kw) != RD_CHAR_TYPE) util_abort("%s: Keyword: %s is wrong type - aborting \n", __func__, - ecl_kw_get_header8(ecl_kw)); - return (const char *)ecl_kw_iget_ptr(ecl_kw, i); + rd_kw_get_header8(rd_kw)); + return (const char *)rd_kw_iget_ptr(rd_kw, i); } -const char *ecl_kw_iget_string_ptr(const ecl_kw_type *ecl_kw, int i) { - if (ecl_kw_get_type(ecl_kw) != ECL_STRING_TYPE) +const char *rd_kw_iget_string_ptr(const rd_kw_type *rd_kw, int i) { + if (rd_kw_get_type(rd_kw) != RD_STRING_TYPE) util_abort("%s: Keyword: %s is wrong type - aborting \n", __func__, - ecl_kw_get_header8(ecl_kw)); - return (const char *)ecl_kw_iget_ptr(ecl_kw, i); + rd_kw_get_header8(rd_kw)); + return (const char *)rd_kw_iget_ptr(rd_kw, i); } /** - This will set the elemnts of the ecl_kw data storage in index to + This will set the elemnts of the rd_kw data storage in index to the value of s8; if s8 is shorter than 8 characters the result will be padded, if s8 is longer than 8 characters the characters from 9 and out will be ignored. */ -void ecl_kw_iset_string8(ecl_kw_type *ecl_kw, int index, const char *s8) { - char *ecl_string = (char *)ecl_kw_iget_ptr(ecl_kw, index); - if (strlen(s8) >= ECL_STRING8_LENGTH) { +void rd_kw_iset_string8(rd_kw_type *rd_kw, int index, const char *s8) { + char *rd_string = (char *)rd_kw_iget_ptr(rd_kw, index); + if (strlen(s8) >= RD_STRING8_LENGTH) { /* The whole string goes in - possibly loosing content at the end. */ int i; - for (i = 0; i < ECL_STRING8_LENGTH; i++) - ecl_string[i] = s8[i]; + for (i = 0; i < RD_STRING8_LENGTH; i++) + rd_string[i] = s8[i]; } else { /* The string is padded with trailing spaces. */ int string_length = strlen(s8); int i; for (i = 0; i < string_length; i++) - ecl_string[i] = s8[i]; + rd_string[i] = s8[i]; - for (i = string_length; i < ECL_STRING8_LENGTH; i++) - ecl_string[i] = ' '; + for (i = string_length; i < RD_STRING8_LENGTH; i++) + rd_string[i] = ' '; } - ecl_string[ECL_STRING8_LENGTH] = '\0'; + rd_string[RD_STRING8_LENGTH] = '\0'; } /** - This function will set the string @index in the ecl_kw string array + This function will set the string @index in the rd_kw string array to @s. IFF @s is longer than 8 characters, the first part will go in element @index, and then we will continue writing into the next elements. If the resulting index goes beyond the length of the @@ -878,35 +866,35 @@ void ecl_kw_iset_string8(ecl_kw_type *ecl_kw, int index, const char *s8) { length greater than 8 - maybe the overwriting of consecutive elements is not what you want? */ -void ecl_kw_iset_char_ptr(ecl_kw_type *ecl_kw, int index, const char *s) { - int strings = strlen(s) / ECL_STRING8_LENGTH; - if ((strlen(s) % ECL_STRING8_LENGTH) != 0) +void rd_kw_iset_char_ptr(rd_kw_type *rd_kw, int index, const char *s) { + int strings = strlen(s) / RD_STRING8_LENGTH; + if ((strlen(s) % RD_STRING8_LENGTH) != 0) strings++; { int sub_index; for (sub_index = 0; sub_index < strings; sub_index++) - ecl_kw_iset_string8(ecl_kw, index + sub_index, - &s[sub_index * ECL_STRING8_LENGTH]); + rd_kw_iset_string8(rd_kw, index + sub_index, + &s[sub_index * RD_STRING8_LENGTH]); } } /** This function will verify that the given string is of approperiate length (0 <= lenght <= data_type.element_size). If so, the elements - of @s will be written to the @ecl_kw string array starting at + of @s will be written to the @rd_kw string array starting at @index. If the input string is shorter than the type length the string will be padded with trailing spaces. */ -void ecl_kw_iset_string_ptr(ecl_kw_type *ecl_kw, int index, const char *s) { - if (!ecl_type_is_alpha(ecl_kw_get_data_type(ecl_kw))) { - char *type_name = ecl_type_alloc_name(ecl_kw_get_data_type(ecl_kw)); +void rd_kw_iset_string_ptr(rd_kw_type *rd_kw, int index, const char *s) { + if (!rd_type_is_alpha(rd_kw_get_data_type(rd_kw))) { + char *type_name = rd_type_alloc_name(rd_kw_get_data_type(rd_kw)); util_abort( "%s: Expected alphabetic data type (CHAR, CXXX or MESS), was %s\n", __func__, type_name); } size_t input_len = strlen(s); - size_t type_len = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + size_t type_len = rd_type_get_sizeof_iotype(rd_kw->data_type); if (input_len > type_len) util_abort( @@ -914,16 +902,16 @@ void ecl_kw_iset_string_ptr(ecl_kw_type *ecl_kw, int index, const char *s) { __func__, type_len, input_len); { - char *ecl_string = (char *)ecl_kw_iget_ptr(ecl_kw, index); + char *rd_string = (char *)rd_kw_iget_ptr(rd_kw, index); size_t i; for (i = 0; i < input_len; ++i) - ecl_string[i] = s[i]; + rd_string[i] = s[i]; for (i = input_len; i < type_len; ++i) - ecl_string[i] = ' '; + rd_string[i] = ' '; - ecl_string[type_len] = '\0'; + rd_string[type_len] = '\0'; } } @@ -934,9 +922,9 @@ void ecl_kw_iset_string_ptr(ecl_kw_type *ecl_kw, int index, const char *s) { comparison. If the strings are considered equal true is returned. */ -bool ecl_kw_icmp_string(const ecl_kw_type *ecl_kw, int index, - const char *other_string) { - const char *kw_string = (const char *)ecl_kw_iget_char_ptr(ecl_kw, index); +bool rd_kw_icmp_string(const rd_kw_type *rd_kw, int index, + const char *other_string) { + const char *kw_string = (const char *)rd_kw_iget_char_ptr(rd_kw, index); if (strlen(other_string)) { const char *match = strstr(kw_string, other_string); if (match == kw_string) @@ -946,28 +934,28 @@ bool ecl_kw_icmp_string(const ecl_kw_type *ecl_kw, int index, return false; } -#define ECL_KW_ISET_TYPED(ctype, ECL_TYPE) \ - void ecl_kw_iset_##ctype(ecl_kw_type *ecl_kw, int i, ctype value) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_ISET_TYPED(ctype, RD_TYPE) \ + void rd_kw_iset_##ctype(rd_kw_type *rd_kw, int i, ctype value) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ - ecl_kw_iset_static(ecl_kw, i, &value); \ + __func__, rd_kw_get_header8(rd_kw)); \ + rd_kw_iset_static(rd_kw, i, &value); \ } -ECL_KW_ISET_TYPED(double, ECL_DOUBLE_TYPE); -ECL_KW_ISET_TYPED(float, ECL_FLOAT_TYPE); -ECL_KW_ISET_TYPED(int, ECL_INT_TYPE); -ECL_KW_ISET_TYPED(bool, ECL_BOOL_TYPE); -#undef ECL_KW_ISET_TYPED +RD_KW_ISET_TYPED(double, RD_DOUBLE_TYPE); +RD_KW_ISET_TYPED(float, RD_FLOAT_TYPE); +RD_KW_ISET_TYPED(int, RD_INT_TYPE); +RD_KW_ISET_TYPED(bool, RD_BOOL_TYPE); +#undef RD_KW_ISET_TYPED -#define ECL_KW_SET_INDEXED(ctype, ECL_TYPE) \ - void ecl_kw_set_indexed_##ctype( \ - ecl_kw_type *ecl_kw, const int_vector_type *index_list, ctype value) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_SET_INDEXED(ctype, RD_TYPE) \ + void rd_kw_set_indexed_##ctype( \ + rd_kw_type *rd_kw, const int_vector_type *index_list, ctype value) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ + __func__, rd_kw_get_header8(rd_kw)); \ { \ - ctype *data = (ctype *)ecl_kw->data; \ + ctype *data = (ctype *)rd_kw->data; \ int size = int_vector_size(index_list); \ const int *index_ptr = int_vector_get_const_ptr(index_list); \ int i; \ @@ -976,19 +964,19 @@ ECL_KW_ISET_TYPED(bool, ECL_BOOL_TYPE); } \ } -ECL_KW_SET_INDEXED(double, ECL_DOUBLE_TYPE); -ECL_KW_SET_INDEXED(float, ECL_FLOAT_TYPE); -ECL_KW_SET_INDEXED(int, ECL_INT_TYPE); -#undef ECL_KW_SET_INDEXED +RD_KW_SET_INDEXED(double, RD_DOUBLE_TYPE); +RD_KW_SET_INDEXED(float, RD_FLOAT_TYPE); +RD_KW_SET_INDEXED(int, RD_INT_TYPE); +#undef RD_KW_SET_INDEXED -#define ECL_KW_SHIFT_INDEXED(ctype, ECL_TYPE) \ - void ecl_kw_shift_indexed_##ctype( \ - ecl_kw_type *ecl_kw, const int_vector_type *index_list, ctype shift) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_SHIFT_INDEXED(ctype, RD_TYPE) \ + void rd_kw_shift_indexed_##ctype( \ + rd_kw_type *rd_kw, const int_vector_type *index_list, ctype shift) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ + __func__, rd_kw_get_header8(rd_kw)); \ { \ - ctype *data = (ctype *)ecl_kw->data; \ + ctype *data = (ctype *)rd_kw->data; \ int size = int_vector_size(index_list); \ const int *index_ptr = int_vector_get_const_ptr(index_list); \ int i; \ @@ -997,19 +985,19 @@ ECL_KW_SET_INDEXED(int, ECL_INT_TYPE); } \ } -ECL_KW_SHIFT_INDEXED(double, ECL_DOUBLE_TYPE); -ECL_KW_SHIFT_INDEXED(float, ECL_FLOAT_TYPE); -ECL_KW_SHIFT_INDEXED(int, ECL_INT_TYPE); -#undef ECL_KW_SHIFT_INDEXED +RD_KW_SHIFT_INDEXED(double, RD_DOUBLE_TYPE); +RD_KW_SHIFT_INDEXED(float, RD_FLOAT_TYPE); +RD_KW_SHIFT_INDEXED(int, RD_INT_TYPE); +#undef RD_KW_SHIFT_INDEXED -#define ECL_KW_SCALE_INDEXED(ctype, ECL_TYPE) \ - void ecl_kw_scale_indexed_##ctype( \ - ecl_kw_type *ecl_kw, const int_vector_type *index_list, ctype scale) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_SCALE_INDEXED(ctype, RD_TYPE) \ + void rd_kw_scale_indexed_##ctype( \ + rd_kw_type *rd_kw, const int_vector_type *index_list, ctype scale) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ + __func__, rd_kw_get_header8(rd_kw)); \ { \ - ctype *data = (ctype *)ecl_kw->data; \ + ctype *data = (ctype *)rd_kw->data; \ int size = int_vector_size(index_list); \ const int *index_ptr = int_vector_get_const_ptr(index_list); \ int i; \ @@ -1018,36 +1006,36 @@ ECL_KW_SHIFT_INDEXED(int, ECL_INT_TYPE); } \ } -ECL_KW_SCALE_INDEXED(double, ECL_DOUBLE_TYPE); -ECL_KW_SCALE_INDEXED(float, ECL_FLOAT_TYPE); -ECL_KW_SCALE_INDEXED(int, ECL_INT_TYPE); -#undef ECL_KW_SCALE_INDEXED +RD_KW_SCALE_INDEXED(double, RD_DOUBLE_TYPE); +RD_KW_SCALE_INDEXED(float, RD_FLOAT_TYPE); +RD_KW_SCALE_INDEXED(int, RD_INT_TYPE); +#undef RD_KW_SCALE_INDEXED -#define ECL_KW_GET_TYPED_PTR(ctype, ECL_TYPE) \ - ctype *ecl_kw_get_##ctype##_ptr(const ecl_kw_type *ecl_kw) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_GET_TYPED_PTR(ctype, RD_TYPE) \ + ctype *rd_kw_get_##ctype##_ptr(const rd_kw_type *rd_kw) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ - return (ctype *)ecl_kw->data; \ + __func__, rd_kw_get_header8(rd_kw)); \ + return (ctype *)rd_kw->data; \ } -ECL_KW_GET_TYPED_PTR(double, ECL_DOUBLE_TYPE); -ECL_KW_GET_TYPED_PTR(float, ECL_FLOAT_TYPE); -ECL_KW_GET_TYPED_PTR(int, ECL_INT_TYPE); -ECL_KW_GET_TYPED_PTR(bool, ECL_BOOL_TYPE); -#undef ECL_KW_GET_TYPED_PTR +RD_KW_GET_TYPED_PTR(double, RD_DOUBLE_TYPE); +RD_KW_GET_TYPED_PTR(float, RD_FLOAT_TYPE); +RD_KW_GET_TYPED_PTR(int, RD_INT_TYPE); +RD_KW_GET_TYPED_PTR(bool, RD_BOOL_TYPE); +#undef RD_KW_GET_TYPED_PTR -void *ecl_kw_get_void_ptr(const ecl_kw_type *ecl_kw) { return ecl_kw->data; } +void *rd_kw_get_void_ptr(const rd_kw_type *rd_kw) { return rd_kw->data; } -void *ecl_kw_iget_ptr(const ecl_kw_type *ecl_kw, int i) { - return ecl_kw_iget_ptr_static(ecl_kw, i); +void *rd_kw_iget_ptr(const rd_kw_type *rd_kw, int i) { + return rd_kw_iget_ptr_static(rd_kw, i); } -void ecl_kw_iset(ecl_kw_type *ecl_kw, int i, const void *iptr) { - ecl_kw_iset_static(ecl_kw, i, iptr); +void rd_kw_iset(rd_kw_type *rd_kw, int i, const void *iptr) { + rd_kw_iset_static(rd_kw, i, iptr); } -static bool ecl_kw_qskip(FILE *stream) { +static bool rd_kw_qskip(FILE *stream) { const char sep = '\''; const char space = ' '; const char newline = '\n'; @@ -1070,12 +1058,12 @@ static bool ecl_kw_qskip(FILE *stream) { return OK; } -static bool ecl_kw_fscanf_qstring(char *s, const char *fmt, int len, - FILE *stream) { +static bool rd_kw_fscanf_qstring(char *s, const char *fmt, int len, + FILE *stream) { const char null_char = '\0'; char last_sep; bool OK; - OK = ecl_kw_qskip(stream); + OK = rd_kw_qskip(stream); if (OK) { int read_count = 0; read_count += fscanf(stream, fmt, s); @@ -1095,7 +1083,7 @@ static bool ecl_kw_fscanf_qstring(char *s, const char *fmt, int len, */ /** Should be: NESTED */ -static double __fscanf_ECL_double(FILE *stream, const char *fmt) { +static double __fscanf_RD_double(FILE *stream, const char *fmt) { int read_count, power; double value, arg; read_count = fscanf(stream, fmt, &arg, &power); @@ -1108,70 +1096,69 @@ static double __fscanf_ECL_double(FILE *stream, const char *fmt) { return value; } -bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { +bool rd_kw_fread_data(rd_kw_type *rd_kw, fortio_type *fortio) { bool fmt_file = fortio_fmt_file(fortio); - if (ecl_kw->size > 0) { - const int blocksize = get_blocksize(ecl_kw->data_type); + if (rd_kw->size > 0) { + const int blocksize = get_blocksize(rd_kw->data_type); if (fmt_file) { - const int blocks = ecl_kw->size / blocksize + - (ecl_kw->size % blocksize == 0 ? 0 : 1); - char *read_fmt = alloc_read_fmt(ecl_kw->data_type); + const int blocks = rd_kw->size / blocksize + + (rd_kw->size % blocksize == 0 ? 0 : 1); + char *read_fmt = alloc_read_fmt(rd_kw->data_type); FILE *stream = fortio_get_FILE(fortio); int offset = 0; int index = 0; int ib, ir; for (ib = 0; ib < blocks; ib++) { - int read_elm = - util_int_min((ib + 1) * blocksize, ecl_kw->size) - - ib * blocksize; + int read_elm = util_int_min((ib + 1) * blocksize, rd_kw->size) - + ib * blocksize; for (ir = 0; ir < read_elm; ir++) { - switch (ecl_kw_get_type(ecl_kw)) { - case (ECL_CHAR_TYPE): - ecl_kw_fscanf_qstring(&ecl_kw->data[offset], read_fmt, - 8, stream); + switch (rd_kw_get_type(rd_kw)) { + case (RD_CHAR_TYPE): + rd_kw_fscanf_qstring(&rd_kw->data[offset], read_fmt, 8, + stream); break; - case (ECL_STRING_TYPE): - ecl_kw_fscanf_qstring(&ecl_kw->data[offset], read_fmt, - ecl_type_get_sizeof_iotype( - ecl_kw_get_data_type(ecl_kw)), - stream); + case (RD_STRING_TYPE): + rd_kw_fscanf_qstring(&rd_kw->data[offset], read_fmt, + rd_type_get_sizeof_iotype( + rd_kw_get_data_type(rd_kw)), + stream); break; - case (ECL_INT_TYPE): { + case (RD_INT_TYPE): { int iread = fscanf(stream, read_fmt, - (int *)&ecl_kw->data[offset]); + (int *)&rd_kw->data[offset]); if (iread != 1) util_abort( "%s: after reading %d values reading of " "keyword:%s from:%s failed - aborting \n", __func__, - offset / ecl_type_get_sizeof_ctype( - ecl_kw->data_type), - ecl_kw->header8, fortio_filename_ref(fortio)); + offset / + rd_type_get_sizeof_ctype(rd_kw->data_type), + rd_kw->header8, fortio_filename_ref(fortio)); } break; - case (ECL_FLOAT_TYPE): { + case (RD_FLOAT_TYPE): { int iread = fscanf(stream, read_fmt, - (float *)&ecl_kw->data[offset]); + (float *)&rd_kw->data[offset]); if (iread != 1) { util_abort( "%s: after reading %d values reading of " "keyword:%s from:%s failed - aborting \n", __func__, - offset / ecl_type_get_sizeof_ctype( - ecl_kw->data_type), - ecl_kw->header8, fortio_filename_ref(fortio)); + offset / + rd_type_get_sizeof_ctype(rd_kw->data_type), + rd_kw->header8, fortio_filename_ref(fortio)); } } break; - case (ECL_DOUBLE_TYPE): { - double value = __fscanf_ECL_double(stream, read_fmt); - ecl_kw_iset(ecl_kw, index, &value); + case (RD_DOUBLE_TYPE): { + double value = __fscanf_RD_double(stream, read_fmt); + rd_kw_iset(rd_kw, index, &value); } break; - case (ECL_BOOL_TYPE): { + case (RD_BOOL_TYPE): { char bool_char; if (fscanf(stream, read_fmt, &bool_char) == 1) { if (bool_char == BOOL_TRUE_CHAR) - ecl_kw_iset_bool(ecl_kw, index, true); + rd_kw_iset_bool(rd_kw, index, true); else if (bool_char == BOOL_FALSE_CHAR) - ecl_kw_iset_bool(ecl_kw, index, false); + rd_kw_iset_bool(rd_kw, index, false); else util_abort("%s: Logical value: [%c] not " "recogniced - aborting \n", @@ -1181,16 +1168,16 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { "%s: read failed - premature file end? \n", __func__); } break; - case (ECL_MESS_TYPE): - ecl_kw_fscanf_qstring(&ecl_kw->data[offset], read_fmt, - 8, stream); + case (RD_MESS_TYPE): + rd_kw_fscanf_qstring(&rd_kw->data[offset], read_fmt, 8, + stream); break; default: util_abort("%s: Internal error: internal eclipse_type: " "%d not recognized - aborting \n", - __func__, ecl_kw_get_type(ecl_kw)); + __func__, rd_kw_get_type(rd_kw)); } - offset += ecl_type_get_sizeof_ctype(ecl_kw->data_type); + offset += rd_type_get_sizeof_ctype(rd_kw->data_type); index++; } } @@ -1200,14 +1187,14 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { free(read_fmt); return true; } else { - char *buffer = ecl_kw_alloc_input_buffer(ecl_kw); + char *buffer = rd_kw_alloc_input_buffer(rd_kw); const int sizeof_iotype = - ecl_type_get_sizeof_iotype(ecl_kw->data_type); + rd_type_get_sizeof_iotype(rd_kw->data_type); bool read_ok = fortio_fread_buffer(fortio, buffer, - ecl_kw->size * sizeof_iotype); + rd_kw->size * sizeof_iotype); if (read_ok) - ecl_kw_load_from_input_buffer(ecl_kw, buffer); + rd_kw_load_from_input_buffer(rd_kw, buffer); free(buffer); return read_ok; @@ -1217,14 +1204,14 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { return true; } -void ecl_kw_fread_indexed_data(fortio_type *fortio, offset_type data_offset, - ecl_data_type data_type, int element_count, - const int_vector_type *index_map, - char *io_buffer) { +void rd_kw_fread_indexed_data(fortio_type *fortio, offset_type data_offset, + rd_data_type data_type, int element_count, + const int_vector_type *index_map, + char *io_buffer) { const int block_size = get_blocksize(data_type); FILE *stream = fortio_get_FILE(fortio); int index; - int sizeof_iotype = ecl_type_get_sizeof_iotype(data_type); + int sizeof_iotype = rd_type_get_sizeof_iotype(data_type); for (index = 0; index < int_vector_size(index_map); index++) { int element_index = int_vector_iget(index_map, index); @@ -1239,7 +1226,7 @@ void ecl_kw_fread_indexed_data(fortio_type *fortio, offset_type data_offset, __func__); } - if (ECL_ENDIAN_FLIP) + if (RD_ENDIAN_FLIP) util_endian_flip_vector(io_buffer, sizeof_iotype, int_vector_size(index_map)); } @@ -1247,33 +1234,33 @@ void ecl_kw_fread_indexed_data(fortio_type *fortio, offset_type data_offset, /** Allocates storage and reads data. */ -bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { - ecl_kw_alloc_data(ecl_kw); - return ecl_kw_fread_data(ecl_kw, fortio); +bool rd_kw_fread_realloc_data(rd_kw_type *rd_kw, fortio_type *fortio) { + rd_kw_alloc_data(rd_kw); + return rd_kw_fread_data(rd_kw, fortio); } /** Static method without a class instance. */ -bool ecl_kw_fskip_data__(ecl_data_type data_type, const int element_count, - fortio_type *fortio) { +bool rd_kw_fskip_data__(rd_data_type data_type, const int element_count, + fortio_type *fortio) { if (element_count <= 0) return true; bool fmt_file = fortio_fmt_file(fortio); if (fmt_file) { /* Formatted skipping actually involves reading the data - nice ??? */ - ecl_kw_type *tmp_kw = ecl_kw_alloc_empty(); - ecl_kw_initialize(tmp_kw, "WORK", element_count, data_type); - ecl_kw_alloc_data(tmp_kw); - ecl_kw_fread_data(tmp_kw, fortio); - ecl_kw_free(tmp_kw); + rd_kw_type *tmp_kw = rd_kw_alloc_empty(); + rd_kw_initialize(tmp_kw, "WORK", element_count, data_type); + rd_kw_alloc_data(tmp_kw); + rd_kw_fread_data(tmp_kw, fortio); + rd_kw_free(tmp_kw); } else { const int blocksize = get_blocksize(data_type); const int block_count = element_count / blocksize + (element_count % blocksize != 0); - int element_size = ecl_type_get_sizeof_iotype(data_type); + int element_size = rd_type_get_sizeof_iotype(data_type); if (!fortio_data_fskip(fortio, element_size, element_count, block_count)) @@ -1283,83 +1270,81 @@ bool ecl_kw_fskip_data__(ecl_data_type data_type, const int element_count, return true; } -bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { - return ecl_kw_fskip_data__(ecl_kw_get_data_type(ecl_kw), ecl_kw->size, - fortio); +bool rd_kw_fskip_data(rd_kw_type *rd_kw, fortio_type *fortio) { + return rd_kw_fskip_data__(rd_kw_get_data_type(rd_kw), rd_kw->size, fortio); } /** - This function will skip the header part of an ecl_kw instance. The + This function will skip the header part of an rd_kw instance. The function will read the file content at the current position, it is therefore essential that the file pointer is positioned at the beginning of a keyword when this function is called; otherwise it will be complete crash and burn. */ -void ecl_kw_fskip_header(fortio_type *fortio) { +void rd_kw_fskip_header(fortio_type *fortio) { bool fmt_file = fortio_fmt_file(fortio); if (fmt_file) { - ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); - ecl_kw_fread_header(ecl_kw, fortio); - ecl_kw_free(ecl_kw); + rd_kw_type *rd_kw = rd_kw_alloc_empty(); + rd_kw_fread_header(rd_kw, fortio); + rd_kw_free(rd_kw); } else fortio_fskip_record(fortio); } -ecl_read_status_enum ecl_kw_fread_header(ecl_kw_type *ecl_kw, - fortio_type *fortio) { +rd_read_status_enum rd_kw_fread_header(rd_kw_type *rd_kw, fortio_type *fortio) { const char null_char = '\0'; FILE *stream = fortio_get_FILE(fortio); bool fmt_file = fortio_fmt_file(fortio); - char header[ECL_STRING8_LENGTH + 1]; - char ecl_type_str[ECL_TYPE_LENGTH + 1]; + char header[RD_STRING8_LENGTH + 1]; + char rd_type_str[RD_TYPE_LENGTH + 1]; int record_size; int size; if (fmt_file) { - if (!ecl_kw_fscanf_qstring(header, "%8c", 8, stream)) - return ECL_KW_READ_FAIL; + if (!rd_kw_fscanf_qstring(header, "%8c", 8, stream)) + return RD_KW_READ_FAIL; int read_count = fscanf(stream, "%d", &size); if (read_count != 1) - return ECL_KW_READ_FAIL; + return RD_KW_READ_FAIL; - if (!ecl_kw_fscanf_qstring(ecl_type_str, "%4c", 4, stream)) - return ECL_KW_READ_FAIL; + if (!rd_kw_fscanf_qstring(rd_type_str, "%4c", 4, stream)) + return RD_KW_READ_FAIL; fgetc(stream); /* Reading the trailing newline ... */ } else { - header[ECL_STRING8_LENGTH] = null_char; - ecl_type_str[ECL_TYPE_LENGTH] = null_char; + header[RD_STRING8_LENGTH] = null_char; + rd_type_str[RD_TYPE_LENGTH] = null_char; record_size = fortio_init_read(fortio); if (record_size <= 0) - return ECL_KW_READ_FAIL; + return RD_KW_READ_FAIL; - char buffer[ECL_KW_HEADER_DATA_SIZE]; - size_t read_bytes = fread(buffer, 1, ECL_KW_HEADER_DATA_SIZE, stream); + char buffer[RD_KW_HEADER_DATA_SIZE]; + size_t read_bytes = fread(buffer, 1, RD_KW_HEADER_DATA_SIZE, stream); - if (read_bytes != ECL_KW_HEADER_DATA_SIZE) - return ECL_KW_READ_FAIL; + if (read_bytes != RD_KW_HEADER_DATA_SIZE) + return RD_KW_READ_FAIL; - memcpy(header, &buffer[0], ECL_STRING8_LENGTH); - void *ptr = &buffer[ECL_STRING8_LENGTH]; + memcpy(header, &buffer[0], RD_STRING8_LENGTH); + void *ptr = &buffer[RD_STRING8_LENGTH]; size = *((int *)ptr); - memcpy(ecl_type_str, &buffer[ECL_STRING8_LENGTH + sizeof(size)], - ECL_TYPE_LENGTH); + memcpy(rd_type_str, &buffer[RD_STRING8_LENGTH + sizeof(size)], + RD_TYPE_LENGTH); if (!fortio_complete_read(fortio, record_size)) - return ECL_KW_READ_FAIL; + return RD_KW_READ_FAIL; - if (ECL_ENDIAN_FLIP) + if (RD_ENDIAN_FLIP) util_endian_flip_vector(&size, sizeof size, 1); } - ecl_data_type data_type = ecl_type_create_from_name(ecl_type_str); - ecl_kw_initialize(ecl_kw, header, size, data_type); + rd_data_type data_type = rd_type_create_from_name(rd_type_str); + rd_kw_initialize(rd_kw, header, size, data_type); - return ECL_KW_READ_OK; + return RD_KW_READ_OK; } /** @@ -1376,9 +1361,9 @@ ecl_read_status_enum ecl_kw_fread_header(ecl_kw_type *ecl_kw, found. */ -bool ecl_kw_fseek_kw(const char *kw, bool rewind, bool abort_on_error, - fortio_type *fortio) { - ecl_kw_type *tmp_kw = ecl_kw_alloc_empty(); +bool rd_kw_fseek_kw(const char *kw, bool rewind, bool abort_on_error, + fortio_type *fortio) { + rd_kw_type *tmp_kw = rd_kw_alloc_empty(); long int init_pos = fortio_ftell(fortio); bool cont, kw_found; @@ -1386,13 +1371,13 @@ bool ecl_kw_fseek_kw(const char *kw, bool rewind, bool abort_on_error, kw_found = false; while (cont) { long current_pos = fortio_ftell(fortio); - if (ecl_kw_fread_header(tmp_kw, fortio) == ECL_KW_READ_OK) { - if (ecl_kw_string_eq(ecl_kw_get_header8(tmp_kw), kw)) { + if (rd_kw_fread_header(tmp_kw, fortio) == RD_KW_READ_OK) { + if (rd_kw_string_eq(rd_kw_get_header8(tmp_kw), kw)) { fortio_fseek(fortio, current_pos, SEEK_SET); kw_found = true; cont = false; } else - ecl_kw_fskip_data(tmp_kw, fortio); + rd_kw_fskip_data(tmp_kw, fortio); } else { if (rewind) { fortio_rewind(fortio); @@ -1410,32 +1395,32 @@ bool ecl_kw_fseek_kw(const char *kw, bool rewind, bool abort_on_error, fortio_fseek(fortio, init_pos, SEEK_SET); } - ecl_kw_free(tmp_kw); + rd_kw_free(tmp_kw); return kw_found; } -bool ecl_kw_ifseek_kw(const char *kw, fortio_type *fortio, int index) { +bool rd_kw_ifseek_kw(const char *kw, fortio_type *fortio, int index) { int i = 0; do { - ecl_kw_fseek_kw(kw, false, true, fortio); + rd_kw_fseek_kw(kw, false, true, fortio); i++; } while (i <= index); return true; } -bool ecl_kw_fseek_last_kw(const char *kw, bool abort_on_error, - fortio_type *fortio) { +bool rd_kw_fseek_last_kw(const char *kw, bool abort_on_error, + fortio_type *fortio) { long int init_pos = fortio_ftell(fortio); bool kw_found = false; fortio_fseek(fortio, 0L, SEEK_SET); - kw_found = ecl_kw_fseek_kw(kw, false, false, fortio); + kw_found = rd_kw_fseek_kw(kw, false, false, fortio); if (kw_found) { bool cont = true; do { long int current_pos = fortio_ftell(fortio); - ecl_kw_fskip(fortio); - cont = ecl_kw_fseek_kw(kw, false, false, fortio); + rd_kw_fskip(fortio); + cont = rd_kw_fseek_kw(kw, false, false, fortio); if (!cont) fortio_fseek(fortio, current_pos, SEEK_SET); } while (cont); @@ -1449,105 +1434,105 @@ bool ecl_kw_fseek_last_kw(const char *kw, bool abort_on_error, return kw_found; } -void ecl_kw_set_data_ptr(ecl_kw_type *ecl_kw, void *data) { - if (!ecl_kw->shared_data) - free(ecl_kw->data); - ecl_kw->data = (char *)data; +void rd_kw_set_data_ptr(rd_kw_type *rd_kw, void *data) { + if (!rd_kw->shared_data) + free(rd_kw->data); + rd_kw->data = (char *)data; } /** - This is where the storage buffer of the ecl_kw is allocated. + This is where the storage buffer of the rd_kw is allocated. */ -void ecl_kw_alloc_data(ecl_kw_type *ecl_kw) { - if (ecl_kw->shared_data) - util_abort("%s: trying to allocate data for ecl_kw object which has " +void rd_kw_alloc_data(rd_kw_type *rd_kw) { + if (rd_kw->shared_data) + util_abort("%s: trying to allocate data for rd_kw object which has " "been declared with shared storage - aborting \n", __func__); { size_t byte_size = - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); - ecl_kw->data = (char *)util_realloc(ecl_kw->data, byte_size); - if (ecl_kw->data) { - memset(ecl_kw->data, 0, byte_size); + rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type); + rd_kw->data = (char *)util_realloc(rd_kw->data, byte_size); + if (rd_kw->data) { + memset(rd_kw->data, 0, byte_size); } } } -void ecl_kw_free_data(ecl_kw_type *ecl_kw) { - if (!ecl_kw->shared_data) - free(ecl_kw->data); +void rd_kw_free_data(rd_kw_type *rd_kw) { + if (!rd_kw->shared_data) + free(rd_kw->data); - ecl_kw->data = NULL; + rd_kw->data = NULL; } -void ecl_kw_set_header_name(ecl_kw_type *ecl_kw, const char *header) { - ecl_kw->header8 = (char *)realloc(ecl_kw->header8, ECL_STRING8_LENGTH + 1); +void rd_kw_set_header_name(rd_kw_type *rd_kw, const char *header) { + rd_kw->header8 = (char *)realloc(rd_kw->header8, RD_STRING8_LENGTH + 1); if (strlen(header) <= 8) { - sprintf(ecl_kw->header8, "%-8s", header); + sprintf(rd_kw->header8, "%-8s", header); /* Internalizing a header without the trailing spaces as well. */ - free(ecl_kw->header); - ecl_kw->header = util_alloc_strip_copy(ecl_kw->header8); + free(rd_kw->header); + rd_kw->header = util_alloc_strip_copy(rd_kw->header8); } else { - ecl_kw->header = (char *)util_alloc_copy(header, strlen(header) + 1); + rd_kw->header = (char *)util_alloc_copy(header, strlen(header) + 1); } } -void ecl_kw_set_data_type(ecl_kw_type *ecl_kw, ecl_data_type data_type) { - memcpy(&ecl_kw->data_type, &data_type, sizeof data_type); +void rd_kw_set_data_type(rd_kw_type *rd_kw, rd_data_type data_type) { + memcpy(&rd_kw->data_type, &data_type, sizeof data_type); } -bool ecl_kw_fread_realloc(ecl_kw_type *ecl_kw, fortio_type *fortio) { - if (ecl_kw_fread_header(ecl_kw, fortio) == ECL_KW_READ_OK) - return ecl_kw_fread_realloc_data(ecl_kw, fortio); +bool rd_kw_fread_realloc(rd_kw_type *rd_kw, fortio_type *fortio) { + if (rd_kw_fread_header(rd_kw, fortio) == RD_KW_READ_OK) + return rd_kw_fread_realloc_data(rd_kw, fortio); else return false; } -void ecl_kw_fread(ecl_kw_type *ecl_kw, fortio_type *fortio) { - int current_size = ecl_kw->size; - if (ecl_kw_fread_header(ecl_kw, fortio) != ECL_KW_READ_OK) - util_abort("%s: failed to read header for ecl_kw - aborting \n", +void rd_kw_fread(rd_kw_type *rd_kw, fortio_type *fortio) { + int current_size = rd_kw->size; + if (rd_kw_fread_header(rd_kw, fortio) != RD_KW_READ_OK) + util_abort("%s: failed to read header for rd_kw - aborting \n", __func__); - if (ecl_kw->size == current_size) - ecl_kw_fread_data(ecl_kw, fortio); + if (rd_kw->size == current_size) + rd_kw_fread_data(rd_kw, fortio); else util_abort("%s: size mismatch - aborting \n", __func__); } -ecl_kw_type *ecl_kw_fread_alloc(fortio_type *fortio) { +rd_kw_type *rd_kw_fread_alloc(fortio_type *fortio) { bool OK; - ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); - OK = ecl_kw_fread_realloc(ecl_kw, fortio); + rd_kw_type *rd_kw = rd_kw_alloc_empty(); + OK = rd_kw_fread_realloc(rd_kw, fortio); if (!OK) { - ecl_kw_free(ecl_kw); - ecl_kw = NULL; + rd_kw_free(rd_kw); + rd_kw = NULL; } - return ecl_kw; + return rd_kw; } -void ecl_kw_fskip(fortio_type *fortio) { - ecl_kw_type *tmp_kw; - tmp_kw = ecl_kw_fread_alloc(fortio); - ecl_kw_free(tmp_kw); +void rd_kw_fskip(fortio_type *fortio) { + rd_kw_type *tmp_kw; + tmp_kw = rd_kw_fread_alloc(fortio); + rd_kw_free(tmp_kw); } -static void ecl_kw_fwrite_data_unformatted(const ecl_kw_type *ecl_kw, - fortio_type *fortio) { - char *iobuffer = ecl_kw_alloc_output_buffer(ecl_kw); - int sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); +static void rd_kw_fwrite_data_unformatted(const rd_kw_type *rd_kw, + fortio_type *fortio) { + char *iobuffer = rd_kw_alloc_output_buffer(rd_kw); + int sizeof_iotype = rd_type_get_sizeof_iotype(rd_kw->data_type); { - const int blocksize = get_blocksize(ecl_kw->data_type); + const int blocksize = get_blocksize(rd_kw->data_type); const int num_blocks = - ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); + rd_kw->size / blocksize + (rd_kw->size % blocksize == 0 ? 0 : 1); int block_nr; for (block_nr = 0; block_nr < num_blocks; block_nr++) { int this_blocksize = - util_int_min((block_nr + 1) * blocksize, ecl_kw->size) - + util_int_min((block_nr + 1) * blocksize, rd_kw->size) - block_nr * blocksize; int record_size = this_blocksize * @@ -1595,22 +1580,22 @@ static void __fprintf_scientific(FILE *stream, const char *fmt, double x) { fprintf(stream, fmt, arg_x, (int)pow_x); } -static void ecl_kw_fwrite_data_formatted(ecl_kw_type *ecl_kw, - fortio_type *fortio) { +static void rd_kw_fwrite_data_formatted(rd_kw_type *rd_kw, + fortio_type *fortio) { { FILE *stream = fortio_get_FILE(fortio); - const int blocksize = get_blocksize(ecl_kw->data_type); - const int columns = get_columns(ecl_kw->data_type); - char *write_fmt = alloc_write_fmt(ecl_kw->data_type); + const int blocksize = get_blocksize(rd_kw->data_type); + const int columns = get_columns(rd_kw->data_type); + char *write_fmt = alloc_write_fmt(rd_kw->data_type); const int num_blocks = - ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); + rd_kw->size / blocksize + (rd_kw->size % blocksize == 0 ? 0 : 1); int block_nr; for (block_nr = 0; block_nr < num_blocks; block_nr++) { int this_blocksize = - util_int_min((block_nr + 1) * blocksize, ecl_kw->size) - + util_int_min((block_nr + 1) * blocksize, rd_kw->size) - block_nr * blocksize; int num_lines = this_blocksize / columns + (this_blocksize % columns == 0 ? 0 : 1); @@ -1623,34 +1608,34 @@ static void ecl_kw_fwrite_data_formatted(ecl_kw_type *ecl_kw, for (col_nr = 0; col_nr < num_columns; col_nr++) { int data_index = block_nr * blocksize + line_nr * columns + col_nr; - void *data_ptr = ecl_kw_iget_ptr_static(ecl_kw, data_index); - switch (ecl_kw_get_type(ecl_kw)) { - case (ECL_CHAR_TYPE): + void *data_ptr = rd_kw_iget_ptr_static(rd_kw, data_index); + switch (rd_kw_get_type(rd_kw)) { + case (RD_CHAR_TYPE): fprintf(stream, write_fmt, data_ptr); break; - case (ECL_STRING_TYPE): + case (RD_STRING_TYPE): fprintf(stream, write_fmt, data_ptr); break; - case (ECL_INT_TYPE): { + case (RD_INT_TYPE): { int int_value = ((int *)data_ptr)[0]; fprintf(stream, write_fmt, int_value); } break; - case (ECL_BOOL_TYPE): { + case (RD_BOOL_TYPE): { bool bool_value = ((bool *)data_ptr)[0]; if (bool_value) fprintf(stream, write_fmt, BOOL_TRUE_CHAR); else fprintf(stream, write_fmt, BOOL_FALSE_CHAR); } break; - case (ECL_FLOAT_TYPE): { + case (RD_FLOAT_TYPE): { float float_value = ((float *)data_ptr)[0]; __fprintf_scientific(stream, write_fmt, float_value); } break; - case (ECL_DOUBLE_TYPE): { + case (RD_DOUBLE_TYPE): { double double_value = ((double *)data_ptr)[0]; __fprintf_scientific(stream, write_fmt, double_value); } break; - case (ECL_MESS_TYPE): + case (RD_MESS_TYPE): util_abort("%s: Internal inconsistency : message type " "keywords should not have data\n", __func__); @@ -1665,153 +1650,149 @@ static void ecl_kw_fwrite_data_formatted(ecl_kw_type *ecl_kw, } } -void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw, fortio_type *fortio) { - ecl_kw_type *ecl_kw = (ecl_kw_type *)_ecl_kw; +void rd_kw_fwrite_data(const rd_kw_type *_rd_kw, fortio_type *fortio) { + rd_kw_type *rd_kw = (rd_kw_type *)_rd_kw; bool fmt_file = fortio_fmt_file(fortio); if (fmt_file) - ecl_kw_fwrite_data_formatted(ecl_kw, fortio); + rd_kw_fwrite_data_formatted(rd_kw, fortio); else - ecl_kw_fwrite_data_unformatted(ecl_kw, fortio); + rd_kw_fwrite_data_unformatted(rd_kw, fortio); } -void ecl_kw_fwrite_header(const ecl_kw_type *ecl_kw, fortio_type *fortio) { +void rd_kw_fwrite_header(const rd_kw_type *rd_kw, fortio_type *fortio) { FILE *stream = fortio_get_FILE(fortio); bool fmt_file = fortio_fmt_file(fortio); - char *type_name = ecl_type_alloc_name(ecl_kw->data_type); + char *type_name = rd_type_alloc_name(rd_kw->data_type); if (fmt_file) - fprintf(stream, WRITE_HEADER_FMT, ecl_kw->header8, ecl_kw->size, + fprintf(stream, WRITE_HEADER_FMT, rd_kw->header8, rd_kw->size, type_name); else { - int size = ecl_kw->size; - if (ECL_ENDIAN_FLIP) + int size = rd_kw->size; + if (RD_ENDIAN_FLIP) util_endian_flip_vector(&size, sizeof size, 1); - fortio_init_write(fortio, ECL_KW_HEADER_DATA_SIZE); + fortio_init_write(fortio, RD_KW_HEADER_DATA_SIZE); - fwrite(ecl_kw->header8, sizeof(char), ECL_STRING8_LENGTH, stream); + fwrite(rd_kw->header8, sizeof(char), RD_STRING8_LENGTH, stream); fwrite(&size, sizeof(int), 1, stream); - fwrite(type_name, sizeof(char), ECL_TYPE_LENGTH, stream); + fwrite(type_name, sizeof(char), RD_TYPE_LENGTH, stream); - fortio_complete_write(fortio, ECL_KW_HEADER_DATA_SIZE); + fortio_complete_write(fortio, RD_KW_HEADER_DATA_SIZE); } free(type_name); } -bool ecl_kw_fwrite(const ecl_kw_type *ecl_kw, fortio_type *fortio) { - if (strlen(ecl_kw_get_header(ecl_kw)) > ECL_STRING8_LENGTH) { +bool rd_kw_fwrite(const rd_kw_type *rd_kw, fortio_type *fortio) { + if (strlen(rd_kw_get_header(rd_kw)) > RD_STRING8_LENGTH) { fortio_fwrite_error(fortio); return false; } - ecl_kw_fwrite_header(ecl_kw, fortio); - ecl_kw_fwrite_data(ecl_kw, fortio); + rd_kw_fwrite_header(rd_kw, fortio); + rd_kw_fwrite_data(rd_kw, fortio); return true; } -static void *ecl_kw_get_data_ref(const ecl_kw_type *ecl_kw) { - return ecl_kw->data; -} +static void *rd_kw_get_data_ref(const rd_kw_type *rd_kw) { return rd_kw->data; } -void *ecl_kw_get_ptr(const ecl_kw_type *ecl_kw) { - return ecl_kw_get_data_ref(ecl_kw); +void *rd_kw_get_ptr(const rd_kw_type *rd_kw) { + return rd_kw_get_data_ref(rd_kw); } -int ecl_kw_get_size(const ecl_kw_type *ecl_kw) { return ecl_kw->size; } +int rd_kw_get_size(const rd_kw_type *rd_kw) { return rd_kw->size; } -ecl_type_enum ecl_kw_get_type(const ecl_kw_type *ecl_kw) { - return ecl_type_get_type(ecl_kw->data_type); +rd_type_enum rd_kw_get_type(const rd_kw_type *rd_kw) { + return rd_type_get_type(rd_kw->data_type); } -ecl_data_type ecl_kw_get_data_type(const ecl_kw_type *ecl_kw) { - return ecl_kw->data_type; +rd_data_type rd_kw_get_data_type(const rd_kw_type *rd_kw) { + return rd_kw->data_type; } -ecl_kw_type *ecl_kw_buffer_alloc(buffer_type *buffer) { +rd_kw_type *rd_kw_buffer_alloc(buffer_type *buffer) { const char *header = buffer_fread_string(buffer); int size = buffer_fread_int(buffer); - ecl_type_enum ecl_type = (ecl_type_enum)buffer_fread_int(buffer); + rd_type_enum rd_type = (rd_type_enum)buffer_fread_int(buffer); size_t element_size = buffer_fread_int(buffer); - ecl_data_type data_type = ecl_type_create(ecl_type, element_size); - ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); - ecl_kw_initialize(ecl_kw, header, size, data_type); - ecl_kw_alloc_data(ecl_kw); - buffer_fread(buffer, ecl_kw->data, - ecl_type_get_sizeof_ctype(ecl_kw->data_type), ecl_kw->size); - return ecl_kw; + rd_data_type data_type = rd_type_create(rd_type, element_size); + rd_kw_type *rd_kw = rd_kw_alloc_empty(); + rd_kw_initialize(rd_kw, header, size, data_type); + rd_kw_alloc_data(rd_kw); + buffer_fread(buffer, rd_kw->data, + rd_type_get_sizeof_ctype(rd_kw->data_type), rd_kw->size); + return rd_kw; } -void ecl_kw_buffer_store(const ecl_kw_type *ecl_kw, buffer_type *buffer) { - buffer_fwrite_string(buffer, ecl_kw->header8); - buffer_fwrite_int(buffer, ecl_kw->size); - buffer_fwrite_int(buffer, ecl_type_get_type(ecl_kw->data_type)); - buffer_fwrite_int(buffer, ecl_type_get_sizeof_ctype(ecl_kw->data_type)); - buffer_fwrite(buffer, ecl_kw->data, - ecl_type_get_sizeof_ctype(ecl_kw->data_type), ecl_kw->size); +void rd_kw_buffer_store(const rd_kw_type *rd_kw, buffer_type *buffer) { + buffer_fwrite_string(buffer, rd_kw->header8); + buffer_fwrite_int(buffer, rd_kw->size); + buffer_fwrite_int(buffer, rd_type_get_type(rd_kw->data_type)); + buffer_fwrite_int(buffer, rd_type_get_sizeof_ctype(rd_kw->data_type)); + buffer_fwrite(buffer, rd_kw->data, + rd_type_get_sizeof_ctype(rd_kw->data_type), rd_kw->size); } -void ecl_kw_fwrite_param_fortio(fortio_type *fortio, const char *header, - ecl_data_type data_type, int size, void *data) { - ecl_kw_type *ecl_kw = - ecl_kw_alloc_new_shared(header, size, data_type, data); - ecl_kw_fwrite(ecl_kw, fortio); - ecl_kw_free(ecl_kw); +void rd_kw_fwrite_param_fortio(fortio_type *fortio, const char *header, + rd_data_type data_type, int size, void *data) { + rd_kw_type *rd_kw = rd_kw_alloc_new_shared(header, size, data_type, data); + rd_kw_fwrite(rd_kw, fortio); + rd_kw_free(rd_kw); } -void ecl_kw_fwrite_param(const char *filename, bool fmt_file, - const char *header, ecl_data_type data_type, int size, - void *data) { +void rd_kw_fwrite_param(const char *filename, bool fmt_file, const char *header, + rd_data_type data_type, int size, void *data) { fortio_type *fortio = - fortio_open_writer(filename, fmt_file, ECL_ENDIAN_FLIP); - ecl_kw_fwrite_param_fortio(fortio, header, data_type, size, data); + fortio_open_writer(filename, fmt_file, RD_ENDIAN_FLIP); + rd_kw_fwrite_param_fortio(fortio, header, data_type, size, data); fortio_fclose(fortio); } -void ecl_kw_get_data_as_double(const ecl_kw_type *ecl_kw, double *double_data) { +void rd_kw_get_data_as_double(const rd_kw_type *rd_kw, double *double_data) { - if (ecl_type_is_double(ecl_kw->data_type)) + if (rd_type_is_double(rd_kw->data_type)) // Direct memcpy - no conversion - ecl_kw_get_memcpy_data(ecl_kw, double_data); + rd_kw_get_memcpy_data(rd_kw, double_data); else { - if (ecl_type_is_float(ecl_kw->data_type)) { - const float *float_data = (const float *)ecl_kw->data; - util_float_to_double(double_data, float_data, ecl_kw->size); - } else if (ecl_type_is_int(ecl_kw->data_type)) { - const int *int_data = (const int *)ecl_kw->data; + if (rd_type_is_float(rd_kw->data_type)) { + const float *float_data = (const float *)rd_kw->data; + util_float_to_double(double_data, float_data, rd_kw->size); + } else if (rd_type_is_int(rd_kw->data_type)) { + const int *int_data = (const int *)rd_kw->data; int i; - for (i = 0; i < ecl_kw->size; i++) + for (i = 0; i < rd_kw->size; i++) double_data[i] = int_data[i]; } else { fprintf(stderr, "%s: type can not be converted to double - aborting \n", __func__); - ecl_kw_summarize(ecl_kw); + rd_kw_summarize(rd_kw); util_abort("%s: Aborting \n", __func__); } } } -void ecl_kw_get_data_as_float(const ecl_kw_type *ecl_kw, float *float_data) { +void rd_kw_get_data_as_float(const rd_kw_type *rd_kw, float *float_data) { - if (ecl_type_is_float(ecl_kw->data_type)) + if (rd_type_is_float(rd_kw->data_type)) // Direct memcpy - no conversion - ecl_kw_get_memcpy_data(ecl_kw, float_data); + rd_kw_get_memcpy_data(rd_kw, float_data); else { - if (ecl_type_is_double(ecl_kw->data_type)) { - const double *double_data = (const double *)ecl_kw->data; - util_double_to_float(float_data, double_data, ecl_kw->size); - } else if (ecl_type_is_int(ecl_kw->data_type)) { - const int *int_data = (const int *)ecl_kw->data; + if (rd_type_is_double(rd_kw->data_type)) { + const double *double_data = (const double *)rd_kw->data; + util_double_to_float(float_data, double_data, rd_kw->size); + } else if (rd_type_is_int(rd_kw->data_type)) { + const int *int_data = (const int *)rd_kw->data; int i; - for (i = 0; i < ecl_kw->size; i++) + for (i = 0; i < rd_kw->size; i++) float_data[i] = (float)int_data[i]; } else { fprintf(stderr, "%s: type can not be converted to float - aborting \n", __func__); - ecl_kw_summarize(ecl_kw); + rd_kw_summarize(rd_kw); util_abort("%s: Aborting \n", __func__); } } @@ -1831,45 +1812,44 @@ void ecl_kw_get_data_as_float(const ecl_kw_type *ecl_kw, float *float_data) { "" - For char */ -ecl_kw_type *ecl_kw_alloc_scatter_copy(const ecl_kw_type *src_kw, - int target_size, const int *mapping, - void *def_value) { +rd_kw_type *rd_kw_alloc_scatter_copy(const rd_kw_type *src_kw, int target_size, + const int *mapping, void *def_value) { int default_int = 0; double default_double = 0; float default_float = 0; bool default_bool = false; const char *default_char = ""; - ecl_kw_type *new_kw = - ecl_kw_alloc(src_kw->header, target_size, src_kw->data_type); + rd_kw_type *new_kw = + rd_kw_alloc(src_kw->header, target_size, src_kw->data_type); if (def_value != NULL) - ecl_kw_scalar_set__(new_kw, def_value); + rd_kw_scalar_set__(new_kw, def_value); else { /** Initialize with defaults .*/ - switch (ecl_kw_get_type(src_kw)) { - case (ECL_INT_TYPE): - ecl_kw_scalar_set__(new_kw, &default_int); + switch (rd_kw_get_type(src_kw)) { + case (RD_INT_TYPE): + rd_kw_scalar_set__(new_kw, &default_int); break; - case (ECL_FLOAT_TYPE): - ecl_kw_scalar_set__(new_kw, &default_float); + case (RD_FLOAT_TYPE): + rd_kw_scalar_set__(new_kw, &default_float); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_scalar_set__(new_kw, &default_double); + case (RD_DOUBLE_TYPE): + rd_kw_scalar_set__(new_kw, &default_double); break; - case (ECL_BOOL_TYPE): - ecl_kw_scalar_set__(new_kw, &default_bool); + case (RD_BOOL_TYPE): + rd_kw_scalar_set__(new_kw, &default_bool); break; - case (ECL_CHAR_TYPE): - ecl_kw_scalar_set__(new_kw, default_char); + case (RD_CHAR_TYPE): + rd_kw_scalar_set__(new_kw, default_char); break; default: util_abort("%s: unsupported type:%d \n", __func__, - ecl_kw_get_type(src_kw)); + rd_kw_get_type(src_kw)); } } { - int sizeof_ctype = ecl_type_get_sizeof_ctype(src_kw->data_type); + int sizeof_ctype = rd_type_get_sizeof_ctype(src_kw->data_type); int i; for (i = 0; i < src_kw->size; i++) { int target_index = mapping[i]; @@ -1881,86 +1861,86 @@ ecl_kw_type *ecl_kw_alloc_scatter_copy(const ecl_kw_type *src_kw, return new_kw; } -ecl_kw_type *ecl_kw_alloc_global_copy(const ecl_kw_type *src, - const ecl_kw_type *actnum) { - if (ecl_kw_get_type(actnum) != ECL_INT_TYPE) +rd_kw_type *rd_kw_alloc_global_copy(const rd_kw_type *src, + const rd_kw_type *actnum) { + if (rd_kw_get_type(actnum) != RD_INT_TYPE) return NULL; - const int global_size = ecl_kw_get_size(actnum); - ecl_kw_type *global_copy = - ecl_kw_alloc(ecl_kw_get_header(src), global_size, src->data_type); - const int *mapping = ecl_kw_get_int_ptr(actnum); - const int src_size = ecl_kw_get_size(src); + const int global_size = rd_kw_get_size(actnum); + rd_kw_type *global_copy = + rd_kw_alloc(rd_kw_get_header(src), global_size, src->data_type); + const int *mapping = rd_kw_get_int_ptr(actnum); + const int src_size = rd_kw_get_size(src); int src_index = 0; for (int global_index = 0; global_index < global_size; global_index++) { if (mapping[global_index]) { /* We ran through and beyond the size of the src keyword. */ if (src_index >= src_size) { - ecl_kw_free(global_copy); + rd_kw_free(global_copy); global_copy = NULL; break; } - const void *value_ptr = ecl_kw_iget_ptr(src, src_index); - ecl_kw_iset_static(global_copy, global_index, value_ptr); + const void *value_ptr = rd_kw_iget_ptr(src, src_index); + rd_kw_iset_static(global_copy, global_index, value_ptr); src_index++; } } /* Not all the src data was distributed. */ if (src_index < src_size) { - ecl_kw_free(global_copy); + rd_kw_free(global_copy); global_copy = NULL; } return global_copy; } -void ecl_kw_fread_double_param(const char *filename, bool fmt_file, - double *double_data) { +void rd_kw_fread_double_param(const char *filename, bool fmt_file, + double *double_data) { fortio_type *fortio = - fortio_open_reader(filename, fmt_file, ECL_ENDIAN_FLIP); - ecl_kw_type *ecl_kw = ecl_kw_fread_alloc(fortio); + fortio_open_reader(filename, fmt_file, RD_ENDIAN_FLIP); + rd_kw_type *rd_kw = rd_kw_fread_alloc(fortio); fortio_fclose(fortio); - if (ecl_kw == NULL) + if (rd_kw == NULL) util_abort( "%s: fatal error: loading parameter from: %s failed - aborting \n", __func__, filename); - ecl_kw_get_data_as_double(ecl_kw, double_data); - ecl_kw_free(ecl_kw); + rd_kw_get_data_as_double(rd_kw, double_data); + rd_kw_free(rd_kw); } -void ecl_kw_summarize(const ecl_kw_type *ecl_kw) { - char *type_name = ecl_type_alloc_name(ecl_kw->data_type); - printf("%8s %10d:%4s \n", ecl_kw_get_header8(ecl_kw), - ecl_kw_get_size(ecl_kw), type_name); +void rd_kw_summarize(const rd_kw_type *rd_kw) { + char *type_name = rd_type_alloc_name(rd_kw->data_type); + printf("%8s %10d:%4s \n", rd_kw_get_header8(rd_kw), rd_kw_get_size(rd_kw), + type_name); free(type_name); } -#define ECL_KW_SCALAR_SET_TYPED(ctype, ECL_TYPE) \ - void ecl_kw_scalar_set_##ctype(ecl_kw_type *ecl_kw, ctype value) { \ - if (ecl_kw_get_type(ecl_kw) == ECL_TYPE) { \ - ctype *data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ +#define RD_KW_SCALAR_SET_TYPED(ctype, RD_TYPE) \ + void rd_kw_scalar_set_##ctype(rd_kw_type *rd_kw, ctype value) { \ + if (rd_kw_get_type(rd_kw) == RD_TYPE) { \ + ctype *data = (ctype *)rd_kw_get_data_ref(rd_kw); \ int i; \ - for (i = 0; i < ecl_kw->size; i++) \ + for (i = 0; i < rd_kw->size; i++) \ data[i] = value; \ } else \ util_abort("%s: wrong type\n", __func__); \ } -ECL_KW_SCALAR_SET_TYPED(int, ECL_INT_TYPE) -ECL_KW_SCALAR_SET_TYPED(float, ECL_FLOAT_TYPE) -ECL_KW_SCALAR_SET_TYPED(double, ECL_DOUBLE_TYPE) -ECL_KW_SCALAR_SET_TYPED(bool, ECL_BOOL_TYPE) -#undef ECL_KW_SCALAR_SET_TYPED +RD_KW_SCALAR_SET_TYPED(int, RD_INT_TYPE) +RD_KW_SCALAR_SET_TYPED(float, RD_FLOAT_TYPE) +RD_KW_SCALAR_SET_TYPED(double, RD_DOUBLE_TYPE) +RD_KW_SCALAR_SET_TYPED(bool, RD_BOOL_TYPE) +#undef RD_KW_SCALAR_SET_TYPED -void ecl_kw_scalar_set_float_or_double(ecl_kw_type *ecl_kw, double value) { - ecl_type_enum ecl_type = ecl_kw_get_type(ecl_kw); - if (ecl_type == ECL_FLOAT_TYPE) - ecl_kw_scalar_set_float(ecl_kw, (float)value); - else if (ecl_type == ECL_DOUBLE_TYPE) - ecl_kw_scalar_set_double(ecl_kw, value); +void rd_kw_scalar_set_float_or_double(rd_kw_type *rd_kw, double value) { + rd_type_enum rd_type = rd_kw_get_type(rd_kw); + if (rd_type == RD_FLOAT_TYPE) + rd_kw_scalar_set_float(rd_kw, (float)value); + else if (rd_type == RD_DOUBLE_TYPE) + rd_kw_scalar_set_double(rd_kw, value); else util_abort("%s: wrong type \n", __func__); } @@ -1968,113 +1948,112 @@ void ecl_kw_scalar_set_float_or_double(ecl_kw_type *ecl_kw, double value) { /* Untyped - low level alternative. */ -void ecl_kw_scalar_set__(ecl_kw_type *ecl_kw, const void *value) { - int sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); +void rd_kw_scalar_set__(rd_kw_type *rd_kw, const void *value) { + int sizeof_ctype = rd_type_get_sizeof_ctype(rd_kw->data_type); int i; - for (i = 0; i < ecl_kw->size; i++) - memcpy(&ecl_kw->data[i * sizeof_ctype], value, sizeof_ctype); + for (i = 0; i < rd_kw->size; i++) + memcpy(&rd_kw->data[i * sizeof_ctype], value, sizeof_ctype); } -void ecl_kw_alloc_double_data(ecl_kw_type *ecl_kw, double *values) { - ecl_kw_alloc_data(ecl_kw); - memcpy(ecl_kw->data, values, - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); +void rd_kw_alloc_double_data(rd_kw_type *rd_kw, double *values) { + rd_kw_alloc_data(rd_kw); + memcpy(rd_kw->data, values, + rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type)); } -void ecl_kw_alloc_float_data(ecl_kw_type *ecl_kw, float *values) { - ecl_kw_alloc_data(ecl_kw); - memcpy(ecl_kw->data, values, - ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); +void rd_kw_alloc_float_data(rd_kw_type *rd_kw, float *values) { + rd_kw_alloc_data(rd_kw); + memcpy(rd_kw->data, values, + rd_kw->size * rd_type_get_sizeof_ctype(rd_kw->data_type)); } -#define ECL_KW_SCALE_TYPED(ctype, ECL_TYPE) \ - void ecl_kw_scale_##ctype(ecl_kw_type *ecl_kw, ctype scale_factor) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_SCALE_TYPED(ctype, RD_TYPE) \ + void rd_kw_scale_##ctype(rd_kw_type *rd_kw, ctype scale_factor) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ + __func__, rd_kw_get_header8(rd_kw)); \ { \ - ctype *data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ - int size = ecl_kw_get_size(ecl_kw); \ + ctype *data = (ctype *)rd_kw_get_data_ref(rd_kw); \ + int size = rd_kw_get_size(rd_kw); \ int i; \ for (i = 0; i < size; i++) \ data[i] *= scale_factor; \ } \ } -ECL_KW_SCALE_TYPED(int, ECL_INT_TYPE) -ECL_KW_SCALE_TYPED(float, ECL_FLOAT_TYPE) -ECL_KW_SCALE_TYPED(double, ECL_DOUBLE_TYPE) -#undef ECL_KW_SCALE_TYPED +RD_KW_SCALE_TYPED(int, RD_INT_TYPE) +RD_KW_SCALE_TYPED(float, RD_FLOAT_TYPE) +RD_KW_SCALE_TYPED(double, RD_DOUBLE_TYPE) +#undef RD_KW_SCALE_TYPED -void ecl_kw_scale_float_or_double(ecl_kw_type *ecl_kw, double scale_factor) { - ecl_type_enum ecl_type = ecl_kw_get_type(ecl_kw); - if (ecl_type == ECL_FLOAT_TYPE) - ecl_kw_scale_float(ecl_kw, (float)scale_factor); - else if (ecl_type == ECL_DOUBLE_TYPE) - ecl_kw_scale_double(ecl_kw, scale_factor); +void rd_kw_scale_float_or_double(rd_kw_type *rd_kw, double scale_factor) { + rd_type_enum rd_type = rd_kw_get_type(rd_kw); + if (rd_type == RD_FLOAT_TYPE) + rd_kw_scale_float(rd_kw, (float)scale_factor); + else if (rd_type == RD_DOUBLE_TYPE) + rd_kw_scale_double(rd_kw, scale_factor); else util_abort("%s: wrong type \n", __func__); } -#define ECL_KW_SHIFT_TYPED(ctype, ECL_TYPE) \ - void ecl_kw_shift_##ctype(ecl_kw_type *ecl_kw, ctype shift_value) { \ - if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ +#define RD_KW_SHIFT_TYPED(ctype, RD_TYPE) \ + void rd_kw_shift_##ctype(rd_kw_type *rd_kw, ctype shift_value) { \ + if (rd_kw_get_type(rd_kw) != RD_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n", \ - __func__, ecl_kw_get_header8(ecl_kw)); \ + __func__, rd_kw_get_header8(rd_kw)); \ { \ - ctype *data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ - int size = ecl_kw_get_size(ecl_kw); \ + ctype *data = (ctype *)rd_kw_get_data_ref(rd_kw); \ + int size = rd_kw_get_size(rd_kw); \ int i; \ for (i = 0; i < size; i++) \ data[i] += shift_value; \ } \ } -ECL_KW_SHIFT_TYPED(int, ECL_INT_TYPE) -ECL_KW_SHIFT_TYPED(float, ECL_FLOAT_TYPE) -ECL_KW_SHIFT_TYPED(double, ECL_DOUBLE_TYPE) -#undef ECL_KW_SHIFT_TYPED +RD_KW_SHIFT_TYPED(int, RD_INT_TYPE) +RD_KW_SHIFT_TYPED(float, RD_FLOAT_TYPE) +RD_KW_SHIFT_TYPED(double, RD_DOUBLE_TYPE) +#undef RD_KW_SHIFT_TYPED -void ecl_kw_shift_float_or_double(ecl_kw_type *ecl_kw, double shift_value) { - ecl_type_enum ecl_type = ecl_kw_get_type(ecl_kw); - if (ecl_type == ECL_FLOAT_TYPE) - ecl_kw_shift_float(ecl_kw, (float)shift_value); - else if (ecl_type == ECL_DOUBLE_TYPE) - ecl_kw_shift_double(ecl_kw, shift_value); +void rd_kw_shift_float_or_double(rd_kw_type *rd_kw, double shift_value) { + rd_type_enum rd_type = rd_kw_get_type(rd_kw); + if (rd_type == RD_FLOAT_TYPE) + rd_kw_shift_float(rd_kw, (float)shift_value); + else if (rd_type == RD_DOUBLE_TYPE) + rd_kw_shift_double(rd_kw, shift_value); else util_abort("%s: wrong type \n", __func__); } -bool ecl_kw_size_and_numeric_type_equal(const ecl_kw_type *kw1, - const ecl_kw_type *kw2) { - return ecl_kw_size_and_type_equal(kw1, kw2) && - ecl_type_is_numeric(kw1->data_type); +bool rd_kw_size_and_numeric_type_equal(const rd_kw_type *kw1, + const rd_kw_type *kw2) { + return rd_kw_size_and_type_equal(kw1, kw2) && + rd_type_is_numeric(kw1->data_type); } -#define ECL_KW_ASSERT_TYPED_BINARY_OP(ctype, ECL_TYPE) \ - bool ecl_kw_assert_binary_##ctype(const ecl_kw_type *kw1, \ - const ecl_kw_type *kw2) { \ - if (!ecl_kw_size_and_numeric_type_equal(kw1, kw2)) \ +#define RD_KW_ASSERT_TYPED_BINARY_OP(ctype, RD_TYPE) \ + bool rd_kw_assert_binary_##ctype(const rd_kw_type *kw1, \ + const rd_kw_type *kw2) { \ + if (!rd_kw_size_and_numeric_type_equal(kw1, kw2)) \ return false; \ - if (ecl_kw_get_type(kw1) != ECL_TYPE) \ + if (rd_kw_get_type(kw1) != RD_TYPE) \ return false; /* Type mismatch */ \ return true; \ } -ECL_KW_ASSERT_TYPED_BINARY_OP(int, ECL_INT_TYPE) -ECL_KW_ASSERT_TYPED_BINARY_OP(float, ECL_FLOAT_TYPE) -ECL_KW_ASSERT_TYPED_BINARY_OP(double, ECL_DOUBLE_TYPE) -#undef ECL_KW_ASSERT_TYPED_BINARY_OP +RD_KW_ASSERT_TYPED_BINARY_OP(int, RD_INT_TYPE) +RD_KW_ASSERT_TYPED_BINARY_OP(float, RD_FLOAT_TYPE) +RD_KW_ASSERT_TYPED_BINARY_OP(double, RD_DOUBLE_TYPE) +#undef RD_KW_ASSERT_TYPED_BINARY_OP -void ecl_kw_copy_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *src_kw) { - if (!ecl_kw_size_and_type_equal(target_kw, src_kw)) +void rd_kw_copy_indexed(rd_kw_type *target_kw, const int_vector_type *index_set, + const rd_kw_type *src_kw) { + if (!rd_kw_size_and_type_equal(target_kw, src_kw)) util_abort("%s: type/size mismatch\n", __func__); { - char *target_data = (char *)ecl_kw_get_data_ref(target_kw); - const char *src_data = (const char *)ecl_kw_get_data_ref(src_kw); - int sizeof_ctype = ecl_type_get_sizeof_ctype(target_kw->data_type); + char *target_data = (char *)rd_kw_get_data_ref(target_kw); + const char *src_data = (const char *)rd_kw_get_data_ref(src_kw); + int sizeof_ctype = rd_type_get_sizeof_ctype(target_kw->data_type); int set_size = int_vector_size(index_set); const int *index_data = int_vector_get_const_ptr(index_set); int i; @@ -2086,16 +2065,15 @@ void ecl_kw_copy_indexed(ecl_kw_type *target_kw, } } -#define ECL_KW_TYPED_INPLACE_ADD_INDEXED(ctype) \ - static void ecl_kw_inplace_add_indexed_##ctype( \ - ecl_kw_type *target_kw, const int_vector_type *index_set, \ - const ecl_kw_type *add_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, add_kw)) \ +#define RD_KW_TYPED_INPLACE_ADD_INDEXED(ctype) \ + static void rd_kw_inplace_add_indexed_##ctype( \ + rd_kw_type *target_kw, const int_vector_type *index_set, \ + const rd_kw_type *add_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, add_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *add_data = \ - (const ctype *)ecl_kw_get_data_ref(add_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *add_data = (const ctype *)rd_kw_get_data_ref(add_kw); \ int set_size = int_vector_size(index_set); \ const int *index_data = int_vector_get_const_ptr(index_set); \ int i; \ @@ -2106,155 +2084,151 @@ void ecl_kw_copy_indexed(ecl_kw_type *target_kw, } \ } -ECL_KW_TYPED_INPLACE_ADD_INDEXED(int) -ECL_KW_TYPED_INPLACE_ADD_INDEXED(double) -ECL_KW_TYPED_INPLACE_ADD_INDEXED(float) -#undef ECL_KW_TYPED_INPLACE_ADD +RD_KW_TYPED_INPLACE_ADD_INDEXED(int) +RD_KW_TYPED_INPLACE_ADD_INDEXED(double) +RD_KW_TYPED_INPLACE_ADD_INDEXED(float) +#undef RD_KW_TYPED_INPLACE_ADD -void ecl_kw_inplace_add_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *add_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_add_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *add_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_add_indexed_float(target_kw, index_set, add_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_add_indexed_float(target_kw, index_set, add_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_add_indexed_double(target_kw, index_set, add_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_add_indexed_double(target_kw, index_set, add_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_add_indexed_int(target_kw, index_set, add_kw); + case (RD_INT_TYPE): + rd_kw_inplace_add_indexed_int(target_kw, index_set, add_kw); break; default: util_abort("%s: inplace add not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_ADD(ctype) \ - static void ecl_kw_inplace_add_##ctype(ecl_kw_type *target_kw, \ - const ecl_kw_type *add_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, add_kw)) \ +#define RD_KW_TYPED_INPLACE_ADD(ctype) \ + static void rd_kw_inplace_add_##ctype(rd_kw_type *target_kw, \ + const rd_kw_type *add_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, add_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *add_data = \ - (const ctype *)ecl_kw_get_data_ref(add_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *add_data = (const ctype *)rd_kw_get_data_ref(add_kw); \ int i; \ for (i = 0; i < target_kw->size; i++) \ target_data[i] += add_data[i]; \ } \ } -ECL_KW_TYPED_INPLACE_ADD(int) -ECL_KW_TYPED_INPLACE_ADD(double) -ECL_KW_TYPED_INPLACE_ADD(float) +RD_KW_TYPED_INPLACE_ADD(int) +RD_KW_TYPED_INPLACE_ADD(double) +RD_KW_TYPED_INPLACE_ADD(float) -#undef ECL_KW_TYPED_INPLACE_ADD +#undef RD_KW_TYPED_INPLACE_ADD -void ecl_kw_inplace_add(ecl_kw_type *target_kw, const ecl_kw_type *add_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_add(rd_kw_type *target_kw, const rd_kw_type *add_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_add_float(target_kw, add_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_add_float(target_kw, add_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_add_double(target_kw, add_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_add_double(target_kw, add_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_add_int(target_kw, add_kw); + case (RD_INT_TYPE): + rd_kw_inplace_add_int(target_kw, add_kw); break; default: util_abort("%s: inplace add not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_ADD_SQUARED(ctype) \ - static void ecl_kw_inplace_add_squared_##ctype( \ - ecl_kw_type *target_kw, const ecl_kw_type *add_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, add_kw)) \ +#define RD_KW_TYPED_INPLACE_ADD_SQUARED(ctype) \ + static void rd_kw_inplace_add_squared_##ctype(rd_kw_type *target_kw, \ + const rd_kw_type *add_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, add_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *add_data = \ - (const ctype *)ecl_kw_get_data_ref(add_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *add_data = (const ctype *)rd_kw_get_data_ref(add_kw); \ int i; \ for (i = 0; i < target_kw->size; i++) \ target_data[i] += add_data[i] * add_data[i]; \ } \ } -ECL_KW_TYPED_INPLACE_ADD_SQUARED(int) -ECL_KW_TYPED_INPLACE_ADD_SQUARED(double) -ECL_KW_TYPED_INPLACE_ADD_SQUARED(float) +RD_KW_TYPED_INPLACE_ADD_SQUARED(int) +RD_KW_TYPED_INPLACE_ADD_SQUARED(double) +RD_KW_TYPED_INPLACE_ADD_SQUARED(float) -#undef ECL_KW_TYPED_INPLACE_ADD +#undef RD_KW_TYPED_INPLACE_ADD -void ecl_kw_inplace_add_squared(ecl_kw_type *target_kw, - const ecl_kw_type *add_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_add_squared(rd_kw_type *target_kw, + const rd_kw_type *add_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_add_squared_float(target_kw, add_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_add_squared_float(target_kw, add_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_add_squared_double(target_kw, add_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_add_squared_double(target_kw, add_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_add_squared_int(target_kw, add_kw); + case (RD_INT_TYPE): + rd_kw_inplace_add_squared_int(target_kw, add_kw); break; default: util_abort("%s: inplace add not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_SUB(ctype) \ - void ecl_kw_inplace_sub_##ctype(ecl_kw_type *target_kw, \ - const ecl_kw_type *sub_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, sub_kw)) \ +#define RD_KW_TYPED_INPLACE_SUB(ctype) \ + void rd_kw_inplace_sub_##ctype(rd_kw_type *target_kw, \ + const rd_kw_type *sub_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, sub_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *sub_data = \ - (const ctype *)ecl_kw_get_data_ref(sub_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *sub_data = (const ctype *)rd_kw_get_data_ref(sub_kw); \ int i; \ for (i = 0; i < target_kw->size; i++) \ target_data[i] -= sub_data[i]; \ } \ } -ECL_KW_TYPED_INPLACE_SUB(int) -ECL_KW_TYPED_INPLACE_SUB(double) -ECL_KW_TYPED_INPLACE_SUB(float) -#undef ECL_KW_TYPED_INPLACE_SUB +RD_KW_TYPED_INPLACE_SUB(int) +RD_KW_TYPED_INPLACE_SUB(double) +RD_KW_TYPED_INPLACE_SUB(float) +#undef RD_KW_TYPED_INPLACE_SUB -void ecl_kw_inplace_sub(ecl_kw_type *target_kw, const ecl_kw_type *sub_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_sub(rd_kw_type *target_kw, const rd_kw_type *sub_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_sub_float(target_kw, sub_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_sub_float(target_kw, sub_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_sub_double(target_kw, sub_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_sub_double(target_kw, sub_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_sub_int(target_kw, sub_kw); + case (RD_INT_TYPE): + rd_kw_inplace_sub_int(target_kw, sub_kw); break; default: util_abort("%s: inplace sub not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_SUB_INDEXED(ctype) \ - static void ecl_kw_inplace_sub_indexed_##ctype( \ - ecl_kw_type *target_kw, const int_vector_type *index_set, \ - const ecl_kw_type *sub_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, sub_kw)) \ +#define RD_KW_TYPED_INPLACE_SUB_INDEXED(ctype) \ + static void rd_kw_inplace_sub_indexed_##ctype( \ + rd_kw_type *target_kw, const int_vector_type *index_set, \ + const rd_kw_type *sub_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, sub_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *sub_data = \ - (const ctype *)ecl_kw_get_data_ref(sub_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *sub_data = (const ctype *)rd_kw_get_data_ref(sub_kw); \ int set_size = int_vector_size(index_set); \ const int *index_data = int_vector_get_const_ptr(index_set); \ int i; \ @@ -2265,142 +2239,140 @@ void ecl_kw_inplace_sub(ecl_kw_type *target_kw, const ecl_kw_type *sub_kw) { } \ } -ECL_KW_TYPED_INPLACE_SUB_INDEXED(int) -ECL_KW_TYPED_INPLACE_SUB_INDEXED(double) -ECL_KW_TYPED_INPLACE_SUB_INDEXED(float) -#undef ECL_KW_TYPED_INPLACE_SUB +RD_KW_TYPED_INPLACE_SUB_INDEXED(int) +RD_KW_TYPED_INPLACE_SUB_INDEXED(double) +RD_KW_TYPED_INPLACE_SUB_INDEXED(float) +#undef RD_KW_TYPED_INPLACE_SUB -void ecl_kw_inplace_sub_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *sub_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_sub_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *sub_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_sub_indexed_float(target_kw, index_set, sub_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_sub_indexed_float(target_kw, index_set, sub_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_sub_indexed_double(target_kw, index_set, sub_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_sub_indexed_double(target_kw, index_set, sub_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_sub_indexed_int(target_kw, index_set, sub_kw); + case (RD_INT_TYPE): + rd_kw_inplace_sub_indexed_int(target_kw, index_set, sub_kw); break; default: util_abort("%s: inplace sub not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_ABS(ctype, abs_func) \ - void ecl_kw_inplace_abs_##ctype(ecl_kw_type *kw) { \ - ctype *data = (ctype *)ecl_kw_get_data_ref(kw); \ +#define RD_KW_TYPED_INPLACE_ABS(ctype, abs_func) \ + void rd_kw_inplace_abs_##ctype(rd_kw_type *kw) { \ + ctype *data = (ctype *)rd_kw_get_data_ref(kw); \ int i; \ for (i = 0; i < kw->size; i++) \ data[i] = abs_func(data[i]); \ } -ECL_KW_TYPED_INPLACE_ABS(int, abs) -ECL_KW_TYPED_INPLACE_ABS(double, fabs) -ECL_KW_TYPED_INPLACE_ABS(float, fabsf) -#undef ECL_KW_TYPED_INPLACE_ABS +RD_KW_TYPED_INPLACE_ABS(int, abs) +RD_KW_TYPED_INPLACE_ABS(double, fabs) +RD_KW_TYPED_INPLACE_ABS(float, fabsf) +#undef RD_KW_TYPED_INPLACE_ABS -void ecl_kw_inplace_abs(ecl_kw_type *kw) { - ecl_type_enum type = ecl_kw_get_type(kw); +void rd_kw_inplace_abs(rd_kw_type *kw) { + rd_type_enum type = rd_kw_get_type(kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_abs_float(kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_abs_float(kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_abs_double(kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_abs_double(kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_abs_int(kw); + case (RD_INT_TYPE): + rd_kw_inplace_abs_int(kw); break; default: util_abort("%s: inplace abs not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(kw))); + rd_type_alloc_name(rd_kw_get_data_type(kw))); } } static int sqrti(int x) { return round(sqrt(x)); } -#define ECL_KW_TYPED_INPLACE_SQRT(ctype, sqrt_func) \ - void ecl_kw_inplace_sqrt_##ctype(ecl_kw_type *kw) { \ - ctype *data = (ctype *)ecl_kw_get_data_ref(kw); \ +#define RD_KW_TYPED_INPLACE_SQRT(ctype, sqrt_func) \ + void rd_kw_inplace_sqrt_##ctype(rd_kw_type *kw) { \ + ctype *data = (ctype *)rd_kw_get_data_ref(kw); \ int i; \ for (i = 0; i < kw->size; i++) \ data[i] = sqrt_func(data[i]); \ } -ECL_KW_TYPED_INPLACE_SQRT(double, sqrt) -ECL_KW_TYPED_INPLACE_SQRT(float, sqrtf) -ECL_KW_TYPED_INPLACE_SQRT(int, sqrti) -#undef ECL_KW_TYPED_INPLACE_SQRT +RD_KW_TYPED_INPLACE_SQRT(double, sqrt) +RD_KW_TYPED_INPLACE_SQRT(float, sqrtf) +RD_KW_TYPED_INPLACE_SQRT(int, sqrti) +#undef RD_KW_TYPED_INPLACE_SQRT -void ecl_kw_inplace_sqrt(ecl_kw_type *kw) { - ecl_type_enum type = ecl_kw_get_type(kw); +void rd_kw_inplace_sqrt(rd_kw_type *kw) { + rd_type_enum type = rd_kw_get_type(kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_sqrt_float(kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_sqrt_float(kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_sqrt_double(kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_sqrt_double(kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_sqrt_int(kw); + case (RD_INT_TYPE): + rd_kw_inplace_sqrt_int(kw); break; default: util_abort("%s: inplace sqrt not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(kw))); + rd_type_alloc_name(rd_kw_get_data_type(kw))); } } -#define ECL_KW_TYPED_INPLACE_MUL(ctype) \ - void ecl_kw_inplace_mul_##ctype(ecl_kw_type *target_kw, \ - const ecl_kw_type *mul_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, mul_kw)) \ +#define RD_KW_TYPED_INPLACE_MUL(ctype) \ + void rd_kw_inplace_mul_##ctype(rd_kw_type *target_kw, \ + const rd_kw_type *mul_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, mul_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *mul_data = \ - (const ctype *)ecl_kw_get_data_ref(mul_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *mul_data = (const ctype *)rd_kw_get_data_ref(mul_kw); \ int i; \ for (i = 0; i < target_kw->size; i++) \ target_data[i] *= mul_data[i]; \ } \ } -ECL_KW_TYPED_INPLACE_MUL(int) -ECL_KW_TYPED_INPLACE_MUL(double) -ECL_KW_TYPED_INPLACE_MUL(float) -#undef ECL_KW_TYPED_INPLACE_MUL +RD_KW_TYPED_INPLACE_MUL(int) +RD_KW_TYPED_INPLACE_MUL(double) +RD_KW_TYPED_INPLACE_MUL(float) +#undef RD_KW_TYPED_INPLACE_MUL -void ecl_kw_inplace_mul(ecl_kw_type *target_kw, const ecl_kw_type *mul_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_mul(rd_kw_type *target_kw, const rd_kw_type *mul_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_mul_float(target_kw, mul_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_mul_float(target_kw, mul_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_mul_double(target_kw, mul_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_mul_double(target_kw, mul_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_mul_int(target_kw, mul_kw); + case (RD_INT_TYPE): + rd_kw_inplace_mul_int(target_kw, mul_kw); break; default: util_abort("%s: inplace mul not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_MUL_INDEXED(ctype) \ - static void ecl_kw_inplace_mul_indexed_##ctype( \ - ecl_kw_type *target_kw, const int_vector_type *index_set, \ - const ecl_kw_type *mul_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, mul_kw)) \ +#define RD_KW_TYPED_INPLACE_MUL_INDEXED(ctype) \ + static void rd_kw_inplace_mul_indexed_##ctype( \ + rd_kw_type *target_kw, const int_vector_type *index_set, \ + const rd_kw_type *mul_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, mul_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *mul_data = \ - (const ctype *)ecl_kw_get_data_ref(mul_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *mul_data = (const ctype *)rd_kw_get_data_ref(mul_kw); \ int set_size = int_vector_size(index_set); \ const int *index_data = int_vector_get_const_ptr(index_set); \ int i; \ @@ -2411,78 +2383,76 @@ void ecl_kw_inplace_mul(ecl_kw_type *target_kw, const ecl_kw_type *mul_kw) { } \ } -ECL_KW_TYPED_INPLACE_MUL_INDEXED(int) -ECL_KW_TYPED_INPLACE_MUL_INDEXED(double) -ECL_KW_TYPED_INPLACE_MUL_INDEXED(float) -#undef ECL_KW_TYPED_INPLACE_MUL +RD_KW_TYPED_INPLACE_MUL_INDEXED(int) +RD_KW_TYPED_INPLACE_MUL_INDEXED(double) +RD_KW_TYPED_INPLACE_MUL_INDEXED(float) +#undef RD_KW_TYPED_INPLACE_MUL -void ecl_kw_inplace_mul_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *mul_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_mul_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *mul_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_mul_indexed_float(target_kw, index_set, mul_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_mul_indexed_float(target_kw, index_set, mul_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_mul_indexed_double(target_kw, index_set, mul_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_mul_indexed_double(target_kw, index_set, mul_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_mul_indexed_int(target_kw, index_set, mul_kw); + case (RD_INT_TYPE): + rd_kw_inplace_mul_indexed_int(target_kw, index_set, mul_kw); break; default: util_abort("%s: inplace mul not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_DIV(ctype) \ - void ecl_kw_inplace_div_##ctype(ecl_kw_type *target_kw, \ - const ecl_kw_type *div_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, div_kw)) \ +#define RD_KW_TYPED_INPLACE_DIV(ctype) \ + void rd_kw_inplace_div_##ctype(rd_kw_type *target_kw, \ + const rd_kw_type *div_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, div_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *div_data = \ - (const ctype *)ecl_kw_get_data_ref(div_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *div_data = (const ctype *)rd_kw_get_data_ref(div_kw); \ int i; \ for (i = 0; i < target_kw->size; i++) \ target_data[i] /= div_data[i]; \ } \ } -ECL_KW_TYPED_INPLACE_DIV(int) -ECL_KW_TYPED_INPLACE_DIV(double) -ECL_KW_TYPED_INPLACE_DIV(float) -#undef ECL_KW_TYPED_INPLACE_DIV +RD_KW_TYPED_INPLACE_DIV(int) +RD_KW_TYPED_INPLACE_DIV(double) +RD_KW_TYPED_INPLACE_DIV(float) +#undef RD_KW_TYPED_INPLACE_DIV -void ecl_kw_inplace_div(ecl_kw_type *target_kw, const ecl_kw_type *div_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_div(rd_kw_type *target_kw, const rd_kw_type *div_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_div_float(target_kw, div_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_div_float(target_kw, div_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_div_double(target_kw, div_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_div_double(target_kw, div_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_div_int(target_kw, div_kw); + case (RD_INT_TYPE): + rd_kw_inplace_div_int(target_kw, div_kw); break; default: util_abort("%s: inplace div not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -#define ECL_KW_TYPED_INPLACE_DIV_INDEXED(ctype) \ - static void ecl_kw_inplace_div_indexed_##ctype( \ - ecl_kw_type *target_kw, const int_vector_type *index_set, \ - const ecl_kw_type *div_kw) { \ - if (!ecl_kw_assert_binary_##ctype(target_kw, div_kw)) \ +#define RD_KW_TYPED_INPLACE_DIV_INDEXED(ctype) \ + static void rd_kw_inplace_div_indexed_##ctype( \ + rd_kw_type *target_kw, const int_vector_type *index_set, \ + const rd_kw_type *div_kw) { \ + if (!rd_kw_assert_binary_##ctype(target_kw, div_kw)) \ util_abort("%s: type/size mismatch\n", __func__); \ { \ - ctype *target_data = (ctype *)ecl_kw_get_data_ref(target_kw); \ - const ctype *div_data = \ - (const ctype *)ecl_kw_get_data_ref(div_kw); \ + ctype *target_data = (ctype *)rd_kw_get_data_ref(target_kw); \ + const ctype *div_data = (const ctype *)rd_kw_get_data_ref(div_kw); \ int set_size = int_vector_size(index_set); \ const int *index_data = int_vector_get_const_ptr(index_set); \ int i; \ @@ -2493,41 +2463,40 @@ void ecl_kw_inplace_div(ecl_kw_type *target_kw, const ecl_kw_type *div_kw) { } \ } -ECL_KW_TYPED_INPLACE_DIV_INDEXED(int) -ECL_KW_TYPED_INPLACE_DIV_INDEXED(double) -ECL_KW_TYPED_INPLACE_DIV_INDEXED(float) -#undef ECL_KW_TYPED_INPLACE_DIV +RD_KW_TYPED_INPLACE_DIV_INDEXED(int) +RD_KW_TYPED_INPLACE_DIV_INDEXED(double) +RD_KW_TYPED_INPLACE_DIV_INDEXED(float) +#undef RD_KW_TYPED_INPLACE_DIV -void ecl_kw_inplace_div_indexed(ecl_kw_type *target_kw, - const int_vector_type *index_set, - const ecl_kw_type *div_kw) { - ecl_type_enum type = ecl_kw_get_type(target_kw); +void rd_kw_inplace_div_indexed(rd_kw_type *target_kw, + const int_vector_type *index_set, + const rd_kw_type *div_kw) { + rd_type_enum type = rd_kw_get_type(target_kw); switch (type) { - case (ECL_FLOAT_TYPE): - ecl_kw_inplace_div_indexed_float(target_kw, index_set, div_kw); + case (RD_FLOAT_TYPE): + rd_kw_inplace_div_indexed_float(target_kw, index_set, div_kw); break; - case (ECL_DOUBLE_TYPE): - ecl_kw_inplace_div_indexed_double(target_kw, index_set, div_kw); + case (RD_DOUBLE_TYPE): + rd_kw_inplace_div_indexed_double(target_kw, index_set, div_kw); break; - case (ECL_INT_TYPE): - ecl_kw_inplace_div_indexed_int(target_kw, index_set, div_kw); + case (RD_INT_TYPE): + rd_kw_inplace_div_indexed_int(target_kw, index_set, div_kw); break; default: util_abort("%s: inplace div not implemented for type:%s \n", __func__, - ecl_type_alloc_name(ecl_kw_get_data_type(target_kw))); + rd_type_alloc_name(rd_kw_get_data_type(target_kw))); } } -bool ecl_kw_inplace_safe_div(ecl_kw_type *target_kw, - const ecl_kw_type *divisor) { - if (ecl_kw_get_type(target_kw) != ECL_FLOAT_TYPE) +bool rd_kw_inplace_safe_div(rd_kw_type *target_kw, const rd_kw_type *divisor) { + if (rd_kw_get_type(target_kw) != RD_FLOAT_TYPE) return false; - if (ecl_kw_get_type(divisor) != ECL_INT_TYPE) + if (rd_kw_get_type(divisor) != RD_INT_TYPE) return false; - float *target_data = (float *)ecl_kw_get_data_ref(target_kw); - const int *div_data = (const int *)ecl_kw_get_data_ref(divisor); + float *target_data = (float *)rd_kw_get_data_ref(target_kw); + const int *div_data = (const int *)rd_kw_get_data_ref(divisor); for (int i = 0; i < target_kw->size; i++) { if (div_data[i] != 0) target_data[i] /= div_data[i]; @@ -2536,81 +2505,81 @@ bool ecl_kw_inplace_safe_div(ecl_kw_type *target_kw, return true; } -void ecl_kw_inplace_inv(ecl_kw_type *my_kw) { - int size = ecl_kw_get_size(my_kw); - ecl_type_enum type = ecl_kw_get_type(my_kw); +void rd_kw_inplace_inv(rd_kw_type *my_kw) { + int size = rd_kw_get_size(my_kw); + rd_type_enum type = rd_kw_get_type(my_kw); { int i; - void *my_data = ecl_kw_get_data_ref(my_kw); + void *my_data = rd_kw_get_data_ref(my_kw); switch (type) { - case (ECL_DOUBLE_TYPE): { + case (RD_DOUBLE_TYPE): { double *my_double = (double *)my_data; for (i = 0; i < size; i++) my_double[i] = 1.0 / my_double[i]; break; } - case (ECL_FLOAT_TYPE): { + case (RD_FLOAT_TYPE): { float *my_float = (float *)my_data; for (i = 0; i < size; i++) my_float[i] = 1.0f / my_float[i]; break; } default: - util_abort("%s: can only be called on ECL_FLOAT_TYPE and " - "ECL_DOUBLE_TYPE - aborting \n", + util_abort("%s: can only be called on RD_FLOAT_TYPE and " + "RD_DOUBLE_TYPE - aborting \n", __func__); } } } -void ecl_kw_inplace_update_file(const ecl_kw_type *ecl_kw, const char *filename, - int index) { +void rd_kw_inplace_update_file(const rd_kw_type *rd_kw, const char *filename, + int index) { if (util_file_exists(filename)) { bool fmt_file = util_fmt_bit8(filename); { fortio_type *fortio = - fortio_open_readwrite(filename, fmt_file, ECL_ENDIAN_FLIP); - ecl_kw_ifseek_kw(ecl_kw_get_header8(ecl_kw), fortio, index); + fortio_open_readwrite(filename, fmt_file, RD_ENDIAN_FLIP); + rd_kw_ifseek_kw(rd_kw_get_header8(rd_kw), fortio, index); { - ecl_kw_type *file_kw = ecl_kw_alloc_empty(); + rd_kw_type *file_kw = rd_kw_alloc_empty(); long int current_pos = fortio_ftell(fortio); - ecl_kw_fread_header(file_kw, fortio); + rd_kw_fread_header(file_kw, fortio); fortio_fseek(fortio, current_pos, SEEK_SET); - if (!ecl_kw_size_and_type_equal(ecl_kw, file_kw)) + if (!rd_kw_size_and_type_equal(rd_kw, file_kw)) util_abort( "%s: header mismatch when trying to update:%s in %s \n", - __func__, ecl_kw_get_header8(ecl_kw), filename); - ecl_kw_free(file_kw); + __func__, rd_kw_get_header8(rd_kw), filename); + rd_kw_free(file_kw); } fortio_fflush(fortio); - ecl_kw_fwrite(ecl_kw, fortio); + rd_kw_fwrite(rd_kw, fortio); fortio_fclose(fortio); } } } -bool ecl_kw_is_kw_file(fortio_type *fortio) { +bool rd_kw_is_kw_file(fortio_type *fortio) { const long int init_pos = fortio_ftell(fortio); bool kw_file; { - ecl_kw_type *ecl_kw = ecl_kw_alloc_empty(); + rd_kw_type *rd_kw = rd_kw_alloc_empty(); if (fortio_fmt_file(fortio)) - kw_file = (ecl_kw_fread_header(ecl_kw, fortio) != ECL_KW_READ_FAIL); + kw_file = (rd_kw_fread_header(rd_kw, fortio) != RD_KW_READ_FAIL); else { if (fortio_is_fortio_file(fortio)) kw_file = - (ecl_kw_fread_header(ecl_kw, fortio) != ECL_KW_READ_FAIL); + (rd_kw_fread_header(rd_kw, fortio) != RD_KW_READ_FAIL); else kw_file = false; } - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); } fortio_fseek(fortio, init_pos, SEEK_SET); @@ -2619,25 +2588,25 @@ bool ecl_kw_is_kw_file(fortio_type *fortio) { #define KW_MAX_MIN(type) \ { \ - type *data = (type *)ecl_kw_get_data_ref(ecl_kw); \ + type *data = (type *)rd_kw_get_data_ref(rd_kw); \ type max = data[0]; \ type min = data[0]; \ int i; \ - for (i = 1; i < ecl_kw_get_size(ecl_kw); i++) \ + for (i = 1; i < rd_kw_get_size(rd_kw); i++) \ util_update_##type##_max_min(data[i], &max, &min); \ - memcpy(_max, &max, ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ - memcpy(_min, &min, ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ + memcpy(_max, &max, rd_type_get_sizeof_ctype(rd_kw->data_type)); \ + memcpy(_min, &min, rd_type_get_sizeof_ctype(rd_kw->data_type)); \ } -void ecl_kw_max_min(const ecl_kw_type *ecl_kw, void *_max, void *_min) { - switch (ecl_kw_get_type(ecl_kw)) { - case (ECL_FLOAT_TYPE): +void rd_kw_max_min(const rd_kw_type *rd_kw, void *_max, void *_min) { + switch (rd_kw_get_type(rd_kw)) { + case (RD_FLOAT_TYPE): KW_MAX_MIN(float); break; - case (ECL_DOUBLE_TYPE): + case (RD_DOUBLE_TYPE): KW_MAX_MIN(double); break; - case (ECL_INT_TYPE): + case (RD_INT_TYPE): KW_MAX_MIN(int); break; default: @@ -2645,68 +2614,68 @@ void ecl_kw_max_min(const ecl_kw_type *ecl_kw, void *_max, void *_min) { } } -#define ECL_KW_MAX_MIN(ctype) \ - void ecl_kw_max_min_##ctype(const ecl_kw_type *ecl_kw, ctype *_max, \ - ctype *_min) { \ +#define RD_KW_MAX_MIN(ctype) \ + void rd_kw_max_min_##ctype(const rd_kw_type *rd_kw, ctype *_max, \ + ctype *_min) { \ KW_MAX_MIN(ctype); \ } -#define ECL_KW_MAX(ctype) \ - ctype ecl_kw_##ctype##_max(const ecl_kw_type *ecl_kw) { \ +#define RD_KW_MAX(ctype) \ + ctype rd_kw_##ctype##_max(const rd_kw_type *rd_kw) { \ ctype max, min; \ - ecl_kw_max_min_##ctype(ecl_kw, &max, &min); \ + rd_kw_max_min_##ctype(rd_kw, &max, &min); \ return max; \ } -#define ECL_KW_MIN(ctype) \ - ctype ecl_kw_##ctype##_min(const ecl_kw_type *ecl_kw) { \ +#define RD_KW_MIN(ctype) \ + ctype rd_kw_##ctype##_min(const rd_kw_type *rd_kw) { \ ctype max, min; \ - ecl_kw_max_min_##ctype(ecl_kw, &max, &min); \ + rd_kw_max_min_##ctype(rd_kw, &max, &min); \ return min; \ } -ECL_KW_MAX_MIN(int) -ECL_KW_MAX_MIN(float) -ECL_KW_MAX_MIN(double) +RD_KW_MAX_MIN(int) +RD_KW_MAX_MIN(float) +RD_KW_MAX_MIN(double) -ECL_KW_MAX(int) -ECL_KW_MAX(float) -ECL_KW_MAX(double) +RD_KW_MAX(int) +RD_KW_MAX(float) +RD_KW_MAX(double) -ECL_KW_MIN(int) -ECL_KW_MIN(float) -ECL_KW_MIN(double) +RD_KW_MIN(int) +RD_KW_MIN(float) +RD_KW_MIN(double) -#undef ECL_KW_MAX -#undef ECL_KW_MIN +#undef RD_KW_MAX +#undef RD_KW_MIN #undef KW_MAX_MIN -#undef ECL_KW_MAX_MIN +#undef RD_KW_MAX_MIN #define KW_SUM_INDEXED(type) \ { \ - const type *data = (const type *)ecl_kw_get_data_ref(ecl_kw); \ + const type *data = (const type *)rd_kw_get_data_ref(rd_kw); \ type sum = 0; \ int size = int_vector_size(index_list); \ const int *index_ptr = int_vector_get_const_ptr(index_list); \ for (int i = 0; i < size; i++) \ sum += data[index_ptr[i]]; \ - memcpy(_sum, &sum, ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ + memcpy(_sum, &sum, rd_type_get_sizeof_ctype(rd_kw->data_type)); \ } -void ecl_kw_element_sum_indexed(const ecl_kw_type *ecl_kw, - const int_vector_type *index_list, void *_sum) { - switch (ecl_kw_get_type(ecl_kw)) { - case (ECL_FLOAT_TYPE): +void rd_kw_element_sum_indexed(const rd_kw_type *rd_kw, + const int_vector_type *index_list, void *_sum) { + switch (rd_kw_get_type(rd_kw)) { + case (RD_FLOAT_TYPE): KW_SUM_INDEXED(float); break; - case (ECL_DOUBLE_TYPE): + case (RD_DOUBLE_TYPE): KW_SUM_INDEXED(double); break; - case (ECL_INT_TYPE): + case (RD_INT_TYPE): KW_SUM_INDEXED(int); break; - case (ECL_BOOL_TYPE): { - const bool *data = (const bool *)ecl_kw_get_data_ref(ecl_kw); + case (RD_BOOL_TYPE): { + const bool *data = (const bool *)rd_kw_get_data_ref(rd_kw); const int *index_ptr = int_vector_get_const_ptr(index_list); const int size = int_vector_size(index_list); int sum = 0; @@ -2723,22 +2692,22 @@ void ecl_kw_element_sum_indexed(const ecl_kw_type *ecl_kw, #define KW_SUM(type) \ { \ - const type *data = (const type *)ecl_kw_get_data_ref(ecl_kw); \ + const type *data = (const type *)rd_kw_get_data_ref(rd_kw); \ type sum = 0; \ - for (int i = 0; i < ecl_kw_get_size(ecl_kw); i++) \ + for (int i = 0; i < rd_kw_get_size(rd_kw); i++) \ sum += data[i]; \ - memcpy(_sum, &sum, ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ + memcpy(_sum, &sum, rd_type_get_sizeof_ctype(rd_kw->data_type)); \ } -void ecl_kw_element_sum(const ecl_kw_type *ecl_kw, void *_sum) { - switch (ecl_kw_get_type(ecl_kw)) { - case (ECL_FLOAT_TYPE): +void rd_kw_element_sum(const rd_kw_type *rd_kw, void *_sum) { + switch (rd_kw_get_type(rd_kw)) { + case (RD_FLOAT_TYPE): KW_SUM(float); break; - case (ECL_DOUBLE_TYPE): + case (RD_DOUBLE_TYPE): KW_SUM(double); break; - case (ECL_INT_TYPE): + case (RD_INT_TYPE): KW_SUM(int); break; default: @@ -2747,108 +2716,106 @@ void ecl_kw_element_sum(const ecl_kw_type *ecl_kw, void *_sum) { } #undef KW_SUM -double ecl_kw_element_sum_float(const ecl_kw_type *ecl_kw) { +double rd_kw_element_sum_float(const rd_kw_type *rd_kw) { float float_sum; double double_sum; void *sum_ptr = NULL; - if (ecl_type_is_double(ecl_kw->data_type)) + if (rd_type_is_double(rd_kw->data_type)) sum_ptr = &double_sum; - else if (ecl_type_is_float(ecl_kw->data_type)) + else if (rd_type_is_float(rd_kw->data_type)) sum_ptr = &float_sum; else util_abort("%s: invalid type: \n", __func__); - ecl_kw_element_sum(ecl_kw, sum_ptr); + rd_kw_element_sum(rd_kw, sum_ptr); - if (ecl_type_is_double(ecl_kw->data_type)) + if (rd_type_is_double(rd_kw->data_type)) return double_sum; - else if (ecl_type_is_float(ecl_kw->data_type)) + else if (rd_type_is_float(rd_kw->data_type)) return float_sum; else return 0; } -int ecl_kw_element_sum_int(const ecl_kw_type *ecl_kw) { +int rd_kw_element_sum_int(const rd_kw_type *rd_kw) { int int_sum; - ecl_kw_element_sum(ecl_kw, &int_sum); + rd_kw_element_sum(rd_kw, &int_sum); return int_sum; } -#define ECL_KW_FPRINTF_DATA(ctype) \ - static void ecl_kw_fprintf_data_##ctype(const ecl_kw_type *ecl_kw, \ - const char *fmt, FILE *stream) { \ - const ctype *data = (const ctype *)ecl_kw->data; \ +#define RD_KW_FPRINTF_DATA(ctype) \ + static void rd_kw_fprintf_data_##ctype(const rd_kw_type *rd_kw, \ + const char *fmt, FILE *stream) { \ + const ctype *data = (const ctype *)rd_kw->data; \ int i; \ - for (i = 0; i < ecl_kw->size; i++) \ + for (i = 0; i < rd_kw->size; i++) \ fprintf(stream, fmt, data[i]); \ } -ECL_KW_FPRINTF_DATA(int) -ECL_KW_FPRINTF_DATA(float) -ECL_KW_FPRINTF_DATA(double) -ECL_KW_FPRINTF_DATA(bool) -#undef ECL_KW_FPRINTF_DATA +RD_KW_FPRINTF_DATA(int) +RD_KW_FPRINTF_DATA(float) +RD_KW_FPRINTF_DATA(double) +RD_KW_FPRINTF_DATA(bool) +#undef RD_KW_FPRINTF_DATA -static void ecl_kw_fprintf_data_string(const ecl_kw_type *ecl_kw, - const char *fmt, FILE *stream) { +static void rd_kw_fprintf_data_string(const rd_kw_type *rd_kw, const char *fmt, + FILE *stream) { int i; - for (i = 0; i < ecl_kw->size; i++) - fprintf( - stream, fmt, - &ecl_kw->data[i * ecl_type_get_sizeof_ctype(ecl_kw->data_type)]); -} - -void ecl_kw_fprintf_data(const ecl_kw_type *ecl_kw, const char *fmt, - FILE *stream) { - if (ecl_type_is_double(ecl_kw->data_type)) - ecl_kw_fprintf_data_double(ecl_kw, fmt, stream); - else if (ecl_type_is_float(ecl_kw->data_type)) - ecl_kw_fprintf_data_float(ecl_kw, fmt, stream); - else if (ecl_type_is_int(ecl_kw->data_type)) - ecl_kw_fprintf_data_int(ecl_kw, fmt, stream); - else if (ecl_type_is_bool(ecl_kw->data_type)) - ecl_kw_fprintf_data_bool(ecl_kw, fmt, stream); - else if (ecl_type_is_char(ecl_kw->data_type) || - ecl_type_is_string(ecl_kw->data_type)) - ecl_kw_fprintf_data_string(ecl_kw, fmt, stream); -} - -static bool ecl_kw_elm_equal_numeric__(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2, int offset, - double abs_epsilon, double rel_epsilon) { - double v1 = ecl_kw_iget_as_double(ecl_kw1, offset); - double v2 = ecl_kw_iget_as_double(ecl_kw2, offset); + for (i = 0; i < rd_kw->size; i++) + fprintf(stream, fmt, + &rd_kw->data[i * rd_type_get_sizeof_ctype(rd_kw->data_type)]); +} + +void rd_kw_fprintf_data(const rd_kw_type *rd_kw, const char *fmt, + FILE *stream) { + if (rd_type_is_double(rd_kw->data_type)) + rd_kw_fprintf_data_double(rd_kw, fmt, stream); + else if (rd_type_is_float(rd_kw->data_type)) + rd_kw_fprintf_data_float(rd_kw, fmt, stream); + else if (rd_type_is_int(rd_kw->data_type)) + rd_kw_fprintf_data_int(rd_kw, fmt, stream); + else if (rd_type_is_bool(rd_kw->data_type)) + rd_kw_fprintf_data_bool(rd_kw, fmt, stream); + else if (rd_type_is_char(rd_kw->data_type) || + rd_type_is_string(rd_kw->data_type)) + rd_kw_fprintf_data_string(rd_kw, fmt, stream); +} + +static bool rd_kw_elm_equal_numeric__(const rd_kw_type *rd_kw1, + const rd_kw_type *rd_kw2, int offset, + double abs_epsilon, double rel_epsilon) { + double v1 = rd_kw_iget_as_double(rd_kw1, offset); + double v2 = rd_kw_iget_as_double(rd_kw2, offset); return util_double_approx_equal__(v1, v2, rel_epsilon, abs_epsilon); } -static bool ecl_kw_elm_equal__(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2, int offset) { - size_t data_offset = ecl_type_get_sizeof_ctype(ecl_kw1->data_type) * offset; - int cmp = memcmp(&ecl_kw1->data[data_offset], &ecl_kw2->data[data_offset], - ecl_type_get_sizeof_ctype(ecl_kw1->data_type)); +static bool rd_kw_elm_equal__(const rd_kw_type *rd_kw1, + const rd_kw_type *rd_kw2, int offset) { + size_t data_offset = rd_type_get_sizeof_ctype(rd_kw1->data_type) * offset; + int cmp = memcmp(&rd_kw1->data[data_offset], &rd_kw2->data[data_offset], + rd_type_get_sizeof_ctype(rd_kw1->data_type)); if (cmp == 0) return true; else return false; } -int ecl_kw_first_different(const ecl_kw_type *ecl_kw1, - const ecl_kw_type *ecl_kw2, int offset, - double abs_epsilon, double rel_epsilon) { - if (!ecl_kw_size_and_type_equal(ecl_kw1, ecl_kw2)) +int rd_kw_first_different(const rd_kw_type *rd_kw1, const rd_kw_type *rd_kw2, + int offset, double abs_epsilon, double rel_epsilon) { + if (!rd_kw_size_and_type_equal(rd_kw1, rd_kw2)) util_abort("%s: sorry invalid comparison\n", __func__); - if (offset >= ecl_kw_get_size(ecl_kw1)) + if (offset >= rd_kw_get_size(rd_kw1)) util_abort("%s: sorry - invalid offset value\n", __func__); { bool numeric_compare = false; if (((abs_epsilon > 0) || (rel_epsilon > 0)) && - ((ecl_kw_get_type(ecl_kw1) == ECL_FLOAT_TYPE) || - (ecl_kw_get_type(ecl_kw1) == ECL_DOUBLE_TYPE))) + ((rd_kw_get_type(rd_kw1) == RD_FLOAT_TYPE) || + (rd_kw_get_type(rd_kw1) == RD_DOUBLE_TYPE))) numeric_compare = true; { int index = offset; @@ -2856,14 +2823,14 @@ int ecl_kw_first_different(const ecl_kw_type *ecl_kw1, while (true) { bool equal = (numeric_compare) - ? ecl_kw_elm_equal_numeric__(ecl_kw1, ecl_kw2, index, - abs_epsilon, rel_epsilon) - : ecl_kw_elm_equal__(ecl_kw1, ecl_kw2, index); + ? rd_kw_elm_equal_numeric__(rd_kw1, rd_kw2, index, + abs_epsilon, rel_epsilon) + : rd_kw_elm_equal__(rd_kw1, rd_kw2, index); if (!equal) break; index++; - if (index == ecl_kw_get_size(ecl_kw1)) + if (index == rd_kw_get_size(rd_kw1)) break; } @@ -2872,4 +2839,4 @@ int ecl_kw_first_different(const ecl_kw_type *ecl_kw1, } } -#include "ecl_kw_functions.cpp" +#include "rd_kw_functions.cpp" diff --git a/lib/resdata/rd_kw_functions.cpp b/lib/resdata/rd_kw_functions.cpp index 54d3ce4820..1c02a0ab9e 100644 --- a/lib/resdata/rd_kw_functions.cpp +++ b/lib/resdata/rd_kw_functions.cpp @@ -1,12 +1,12 @@ /* - This file is included from the ecl_kw.c file during compilation. It - contains functions which are not really related to the ecl_kw as a - datastructure, but rather use an ecl_kw instance in a function. + This file is included from the rd_kw.c file during compilation. It + contains functions which are not really related to the rd_kw as a + datastructure, but rather use an rd_kw instance in a function. */ /* This is an extremely special-case function written for the region - creation code. Given a completed ecl_kw regions keyword, the purpose + creation code. Given a completed rd_kw regions keyword, the purpose of this function is to "detect and correct" uninitialized cells with value 0. This function is purely heuristic: @@ -19,10 +19,10 @@ value zero are not considered when comparing. */ -void ecl_kw_fix_uninitialized(ecl_kw_type *ecl_kw, int nx, int ny, int nz, - const int *actnum) { +void rd_kw_fix_uninitialized(rd_kw_type *rd_kw, int nx, int ny, int nz, + const int *actnum) { int i, j, k; - int *data = (int *)ecl_kw_get_ptr(ecl_kw); + int *data = (int *)rd_kw_get_ptr(rd_kw); int_vector_type *undetermined1 = int_vector_alloc(0, 0); int_vector_type *undetermined2 = int_vector_alloc(0, 0); @@ -127,17 +127,17 @@ void ecl_kw_fix_uninitialized(ecl_kw_type *ecl_kw, int nx, int ny, int nz, int_vector_free(undetermined2); } -ecl_kw_type *ecl_kw_alloc_actnum(const ecl_kw_type *porv_kw, float porv_limit) { - if (!ecl_type_is_float(porv_kw->data_type)) +rd_kw_type *rd_kw_alloc_actnum(const rd_kw_type *porv_kw, float porv_limit) { + if (!rd_type_is_float(porv_kw->data_type)) return NULL; - if (!util_string_equal(PORV_KW, ecl_kw_get_header(porv_kw))) + if (!util_string_equal(PORV_KW, rd_kw_get_header(porv_kw))) return NULL; - const int size = ecl_kw_get_size(porv_kw); - ecl_kw_type *actnum_kw = ecl_kw_alloc(ACTNUM_KW, size, ECL_INT); - const float *porv_values = ecl_kw_get_float_ptr(porv_kw); - int *actnum_values = ecl_kw_get_int_ptr(actnum_kw); + const int size = rd_kw_get_size(porv_kw); + rd_kw_type *actnum_kw = rd_kw_alloc(ACTNUM_KW, size, RD_INT); + const float *porv_values = rd_kw_get_float_ptr(porv_kw); + int *actnum_values = rd_kw_get_int_ptr(actnum_kw); for (int i = 0; i < size; i++) { if (porv_values[i] > porv_limit) @@ -153,20 +153,20 @@ ecl_kw_type *ecl_kw_alloc_actnum(const ecl_kw_type *porv_kw, float porv_limit) { Allocate actnum, and assign actnum_bitmask to all cells with pore volume larger than zero. The bit mask can be any combination of CELL_ACTIVE_MATRIX and CELL_ACTIVE_FRACTURE. - See documentation in top of ecl_grid.cpp + See documentation in top of rd_grid.cpp */ -ecl_kw_type *ecl_kw_alloc_actnum_bitmask(const ecl_kw_type *porv_kw, - float porv_limit, int actnum_bitmask) { - if (!ecl_type_is_float(porv_kw->data_type)) +rd_kw_type *rd_kw_alloc_actnum_bitmask(const rd_kw_type *porv_kw, + float porv_limit, int actnum_bitmask) { + if (!rd_type_is_float(porv_kw->data_type)) return NULL; - if (!util_string_equal(PORV_KW, ecl_kw_get_header(porv_kw))) + if (!util_string_equal(PORV_KW, rd_kw_get_header(porv_kw))) return NULL; - const int size = ecl_kw_get_size(porv_kw); - ecl_kw_type *actnum_kw = ecl_kw_alloc(ACTNUM_KW, size, ECL_INT); - const float *porv_values = ecl_kw_get_float_ptr(porv_kw); - int *actnum_values = ecl_kw_get_int_ptr(actnum_kw); + const int size = rd_kw_get_size(porv_kw); + rd_kw_type *actnum_kw = rd_kw_alloc(ACTNUM_KW, size, RD_INT); + const float *porv_values = rd_kw_get_float_ptr(porv_kw); + int *actnum_values = rd_kw_get_int_ptr(actnum_kw); for (int i = 0; i < size; i++) { if (porv_values[i] > porv_limit) diff --git a/lib/resdata/rd_kw_grdecl.cpp b/lib/resdata/rd_kw_grdecl.cpp index e95a0b69b5..e9d8969a2f 100644 --- a/lib/resdata/rd_kw_grdecl.cpp +++ b/lib/resdata/rd_kw_grdecl.cpp @@ -3,9 +3,9 @@ #include -#include -#include -#include +#include +#include +#include #define MAX_GRDECL_HEADER_SIZE 512 @@ -25,7 +25,7 @@ formatted numbers it is in general impossible to determine whether the underlying datatype should be integer, float or double. Therefore all the file-reading routines here expect an - ecl_data_type as input. + rd_data_type as input. 2. The files can have comment sections; even in the data block. @@ -52,7 +52,7 @@ are ignored. */ -bool ecl_kw_grdecl_fseek_next_kw(FILE *stream) { +bool rd_kw_grdecl_fseek_next_kw(FILE *stream) { long start_pos = util_ftell(stream); long current_pos; char next_kw[MAX_GRDECL_HEADER_SIZE]; @@ -100,7 +100,7 @@ bool ecl_kw_grdecl_fseek_next_kw(FILE *stream) { while (true) { current_pos = util_ftell(stream); if (fscanf(stream, "%s", next_kw) == 1) { - if ((next_kw[0] == next_kw[1]) && (next_kw[0] == ECL_COMMENT_CHAR)) + if ((next_kw[0] == next_kw[1]) && (next_kw[0] == RD_COMMENT_CHAR)) // This is a comment line - skip it. util_fskip_lines(stream, 1); else { @@ -117,14 +117,14 @@ bool ecl_kw_grdecl_fseek_next_kw(FILE *stream) { } /** - Will use the ecl_kw_grdecl_fseek_next_header() to seek out the next + Will use the rd_kw_grdecl_fseek_next_header() to seek out the next header string, and read and return that string. If no more headers are found the function will return NULL. The storage allocated by this function must be free'd by the calling scope. */ -char *ecl_kw_grdecl_alloc_next_header(FILE *stream) { - if (ecl_kw_grdecl_fseek_next_kw(stream)) { +char *rd_kw_grdecl_alloc_next_header(FILE *stream) { + if (rd_kw_grdecl_fseek_next_kw(stream)) { char next_kw[MAX_GRDECL_HEADER_SIZE]; fscanf(stream, "%s", next_kw); return util_alloc_string_copy(next_kw); @@ -135,7 +135,7 @@ char *ecl_kw_grdecl_alloc_next_header(FILE *stream) { /** This function will search through a GRDECL file to look for the 'kw'; input variables and return vales are similar to - ecl_kw_fseek_kw(). Observe that the GRDECL files are extremely + rd_kw_fseek_kw(). Observe that the GRDECL files are extremely weakly structured, it is therefore veeeery easy to fool this function with a malformed GRDECL file. @@ -145,10 +145,10 @@ char *ecl_kw_grdecl_alloc_next_header(FILE *stream) { If the kw is not found the file pointer is repositioned. */ -static bool ecl_kw_grdecl_fseek_kw__(const char *kw, FILE *stream) { +static bool rd_kw_grdecl_fseek_kw__(const char *kw, FILE *stream) { long init_pos = util_ftell(stream); while (true) { - if (ecl_kw_grdecl_fseek_next_kw(stream)) { + if (rd_kw_grdecl_fseek_next_kw(stream)) { char next_kw[256]; fscanf(stream, "%s", next_kw); if (strcmp(kw, next_kw) == 0) { @@ -163,14 +163,14 @@ static bool ecl_kw_grdecl_fseek_kw__(const char *kw, FILE *stream) { } } -bool ecl_kw_grdecl_fseek_kw(const char *kw, bool rewind, FILE *stream) { - if (ecl_kw_grdecl_fseek_kw__(kw, stream)) +bool rd_kw_grdecl_fseek_kw(const char *kw, bool rewind, FILE *stream) { + if (rd_kw_grdecl_fseek_kw__(kw, stream)) return true; /* OK - we found the kw between current file pos and EOF. */ else if (rewind) { long int init_pos = util_ftell(stream); util_fseek(stream, 0L, SEEK_SET); - if (ecl_kw_grdecl_fseek_kw__( + if (rd_kw_grdecl_fseek_kw__( kw, stream)) /* Try again from the beginning of the file. */ return true; else @@ -229,21 +229,21 @@ static void iset_range(char *data, int data_index, int sizeof_ctype, */ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, - ecl_data_type data_type, int *kw_size, + rd_data_type data_type, int *kw_size, FILE *stream) { char newline = '\n'; bool atEOF = false; size_t init_size = 32; size_t buffer_size = 64; size_t data_index = 0; - int sizeof_ctype = ecl_type_get_sizeof_ctype(data_type); + int sizeof_ctype = rd_type_get_sizeof_ctype(data_type); size_t data_size = init_size; char *buffer = (char *)util_calloc((buffer_size + 1), sizeof *buffer); char *data = (char *)util_calloc(sizeof_ctype * data_size, sizeof *data); while (true) { if (fscanf(stream, "%32s", buffer) == 1) { - if (strcmp(buffer, ECL_COMMENT_STRING) == 0) { + if (strcmp(buffer, RD_COMMENT_STRING) == 0) { // We have read a comment marker - just read up to the end of line. char c; while (true) { @@ -255,7 +255,7 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, break; } } - } else if (strcmp(buffer, ECL_DATA_TERMINATION) == 0) + } else if (strcmp(buffer, RD_DATA_TERMINATION) == 0) break; else { // We have read a valid input string; scan numerical input values from it. @@ -270,7 +270,7 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, int multiplier; bool char_input = false; - if (ecl_type_is_int(data_type)) { + if (rd_type_is_int(data_type)) { if (sscanf(buffer, "%d*%d", &multiplier, &value.i) == 2) { } else if (sscanf(buffer, "%d", &value.i) == 1) multiplier = 1; @@ -281,7 +281,7 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, "reading keyword:%s \n", __func__, buffer, header); } - } else if (ecl_type_is_float(data_type)) { + } else if (rd_type_is_float(data_type)) { if (sscanf(buffer, "%d*%g", &multiplier, &value.f) == 2) { } else if (sscanf(buffer, "%g", &value.f) == 1) multiplier = 1; @@ -292,7 +292,7 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, "reading keyword:%s \n", __func__, buffer, header); } - } else if (ecl_type_is_double(data_type)) { + } else if (rd_type_is_double(data_type)) { if (sscanf(buffer, "%d*%lg", &multiplier, &value.d) == 2) { } else if (sscanf(buffer, "%lg", &value.d) == 1) multiplier = 1; @@ -305,7 +305,7 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, } } else util_abort("%s: sorry type:%s not supported \n", __func__, - ecl_type_alloc_name(data_type)); + rd_type_alloc_name(data_type)); /* Removing this warning on user request: @@ -315,11 +315,11 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, if (!char_input) { size_t min_size = data_index + multiplier; if (min_size >= data_size) { - if (min_size <= ECL_KW_MAX_SIZE) { + if (min_size <= RD_KW_MAX_SIZE) { size_t byte_size = sizeof_ctype * sizeof *data; data_size = util_size_t_min( - ECL_KW_MAX_SIZE, 2 * (data_index + multiplier)); + RD_KW_MAX_SIZE, 2 * (data_index + multiplier)); byte_size *= data_size; data = (char *)util_realloc(data, byte_size); @@ -357,20 +357,20 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, first. Observe that the grdecl files are very weakly structured, so the - loading of ecl_kw instances from a grdecl file can go wrong in many + loading of rd_kw instances from a grdecl file can go wrong in many ways; if the loading fails the function returns NULL. The main loop is extremely simple - it is just repeated calls to fscanf() to read one-number-at-atime; when that reading fails that is interpreted as the end of the keyword. - Currently ONLY integer and float types are supported in ecl_type - + Currently ONLY integer and float types are supported in rd_type - any other types will lead to a hard failure. - The ecl_kw class has a quite deeply wired assumption that the + The rd_kw class has a quite deeply wired assumption that the header is a string of length 8 (I hope/think that is an ECLIPSE limitation). The class cannot read/write kw with headers longer than 8 bytes. - ecl_kw_grdecl is a workaround allowing for reading/writing kw with long + rd_kw_grdecl is a workaround allowing for reading/writing kw with long headers. ----------------------------------------------------------------- @@ -398,9 +398,9 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, elements found on the file. - ecl_type: The files have no embedded type information and the type + rd_type: The files have no embedded type information and the type must be supplied by the calling scope. Currently only the - ECL_FLOAT_TYPE and ECL_INT_TYPE types are supported. + RD_FLOAT_TYPE and RD_INT_TYPE types are supported. ----------------------------------------------------------------- @@ -409,21 +409,21 @@ static char *fscanf_alloc_grdecl_data(const char *header, bool strict, if there is something wrong it can be difficult to detect. */ -static ecl_kw_type *__ecl_kw_fscanf_alloc_grdecl__(FILE *stream, - const char *header, - bool strict, int size, - ecl_data_type data_type) { +static rd_kw_type *__rd_kw_fscanf_alloc_grdecl__(FILE *stream, + const char *header, + bool strict, int size, + rd_data_type data_type) { if (header && strlen(header) > MAX_GRDECL_HEADER_SIZE) util_abort( "%s cannot read KW of more than %d bytes. strlen(header) == %d\n", __func__, MAX_GRDECL_HEADER_SIZE, strlen(header)); - if (!ecl_type_is_numeric(data_type)) + if (!rd_type_is_numeric(data_type)) util_abort("%s: sorry only types FLOAT, INT and DOUBLE supported\n", __func__); if (header != NULL) - if (!ecl_kw_grdecl_fseek_kw(header, true, stream)) + if (!rd_kw_grdecl_fseek_kw(header, true, stream)) return NULL; /* Could not find it. */ { @@ -443,10 +443,10 @@ static ecl_kw_type *__ecl_kw_fscanf_alloc_grdecl__(FILE *stream, } { - ecl_kw_type *ecl_kw = - ecl_kw_alloc_new(file_header, kw_size, data_type, NULL); - ecl_kw_set_data_ptr(ecl_kw, data); - return ecl_kw; + rd_kw_type *rd_kw = + rd_kw_alloc_new(file_header, kw_size, data_type, NULL); + rd_kw_set_data_ptr(rd_kw, data); + return rd_kw; } } else @@ -462,17 +462,15 @@ static ecl_kw_type *__ecl_kw_fscanf_alloc_grdecl__(FILE *stream, incorrectly positioned this will most probably blow up big time. */ -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_data__(FILE *stream, bool strict, - int size, - ecl_data_type data_type) { - return __ecl_kw_fscanf_alloc_grdecl__(stream, NULL, strict, size, - data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_data__(FILE *stream, bool strict, + int size, rd_data_type data_type) { + return __rd_kw_fscanf_alloc_grdecl__(stream, NULL, strict, size, data_type); } -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_data(FILE *stream, int size, - ecl_data_type data_type) { +rd_kw_type *rd_kw_fscanf_alloc_grdecl_data(FILE *stream, int size, + rd_data_type data_type) { bool strict = true; - return ecl_kw_fscanf_alloc_grdecl_data__(stream, strict, size, data_type); + return rd_kw_fscanf_alloc_grdecl_data__(stream, strict, size, data_type); } /* @@ -485,16 +483,16 @@ ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_data(FILE *stream, int size, the whole keyword is loaded, and then return. */ -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_dynamic__(FILE *stream, const char *kw, - bool strict, - ecl_data_type data_type) { - return __ecl_kw_fscanf_alloc_grdecl__(stream, kw, strict, 0, data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_dynamic__(FILE *stream, const char *kw, + bool strict, + rd_data_type data_type) { + return __rd_kw_fscanf_alloc_grdecl__(stream, kw, strict, 0, data_type); } -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_dynamic(FILE *stream, const char *kw, - ecl_data_type data_type) { +rd_kw_type *rd_kw_fscanf_alloc_grdecl_dynamic(FILE *stream, const char *kw, + rd_data_type data_type) { bool strict = true; - return ecl_kw_fscanf_alloc_grdecl_dynamic__(stream, kw, strict, data_type); + return rd_kw_fscanf_alloc_grdecl_dynamic__(stream, kw, strict, data_type); } /* @@ -506,20 +504,20 @@ ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_dynamic(FILE *stream, const char *kw, When the data has been loaded the function will compare actual size with the supplied size argument and verify equality; if they differ it will crash hard. If you are uncertain of the size use the - ecl_kw_fscanf_alloc_grdecl_dynamic() function instead; or supply + rd_kw_fscanf_alloc_grdecl_dynamic() function instead; or supply size == 0. */ -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl__(FILE *stream, const char *kw, - bool strict, int size, - ecl_data_type data_type) { - return __ecl_kw_fscanf_alloc_grdecl__(stream, kw, strict, size, data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl__(FILE *stream, const char *kw, + bool strict, int size, + rd_data_type data_type) { + return __rd_kw_fscanf_alloc_grdecl__(stream, kw, strict, size, data_type); } -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl(FILE *stream, const char *kw, int size, - ecl_data_type data_type) { +rd_kw_type *rd_kw_fscanf_alloc_grdecl(FILE *stream, const char *kw, int size, + rd_data_type data_type) { bool strict = true; - return ecl_kw_fscanf_alloc_grdecl__(stream, kw, strict, size, data_type); + return rd_kw_fscanf_alloc_grdecl__(stream, kw, strict, size, data_type); } /* @@ -530,15 +528,15 @@ ecl_kw_type *ecl_kw_fscanf_alloc_grdecl(FILE *stream, const char *kw, int size, that the input file is well formatted. */ -ecl_kw_type *ecl_kw_fscanf_alloc_current_grdecl__(FILE *stream, bool strict, - ecl_data_type data_type) { - return __ecl_kw_fscanf_alloc_grdecl__(stream, NULL, strict, 0, data_type); +rd_kw_type *rd_kw_fscanf_alloc_current_grdecl__(FILE *stream, bool strict, + rd_data_type data_type) { + return __rd_kw_fscanf_alloc_grdecl__(stream, NULL, strict, 0, data_type); } -ecl_kw_type *ecl_kw_fscanf_alloc_current_grdecl(FILE *stream, - ecl_data_type data_type) { +rd_kw_type *rd_kw_fscanf_alloc_current_grdecl(FILE *stream, + rd_data_type data_type) { bool strict = true; - return ecl_kw_fscanf_alloc_current_grdecl__(stream, strict, data_type); + return rd_kw_fscanf_alloc_current_grdecl__(stream, strict, data_type); } /* @@ -547,23 +545,23 @@ ecl_kw_type *ecl_kw_fscanf_alloc_current_grdecl(FILE *stream, length limit; i.e. loading it back naively will fail. */ -void ecl_kw_fprintf_grdecl__(const ecl_kw_type *ecl_kw, - const char *special_header, FILE *stream) { +void rd_kw_fprintf_grdecl__(const rd_kw_type *rd_kw, const char *special_header, + FILE *stream) { if (special_header) fprintf(stream, "%s\n", special_header); else - fprintf(stream, "%s\n", ecl_kw_get_header(ecl_kw)); + fprintf(stream, "%s\n", rd_kw_get_header(rd_kw)); { fortio_type *fortio = fortio_alloc_FILE_wrapper( NULL, false, true, true, stream); /* Endian flip should *NOT* be used */ - ecl_kw_fwrite_data(ecl_kw, fortio); + rd_kw_fwrite_data(rd_kw, fortio); fortio_free_FILE_wrapper(fortio); } fprintf(stream, "/\n"); } -void ecl_kw_fprintf_grdecl(const ecl_kw_type *ecl_kw, FILE *stream) { - ecl_kw_fprintf_grdecl__(ecl_kw, NULL, stream); +void rd_kw_fprintf_grdecl(const rd_kw_type *rd_kw, FILE *stream) { + rd_kw_fprintf_grdecl__(rd_kw, NULL, stream); } diff --git a/lib/resdata/rd_nnc_data.cpp b/lib/resdata/rd_nnc_data.cpp index 84565fd1e2..479634336c 100644 --- a/lib/resdata/rd_nnc_data.cpp +++ b/lib/resdata/rd_nnc_data.cpp @@ -1,11 +1,11 @@ -#define ECL_NNC_DATA_TYPE_ID 83756236 +#define RD_NNC_DATA_TYPE_ID 83756236 -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include enum kw_data_type { TRANS_DATA = 1, @@ -14,13 +14,13 @@ enum kw_data_type { GAS_FLUX_DATA = 4 }; -struct ecl_nnc_data_struct { +struct rd_nnc_data_struct { UTIL_TYPE_ID_DECLARATION; int size; double *values; }; -static const char *ecl_nnc_data_get_str_kw(int kw_type, int grid1, int grid2) { +static const char *rd_nnc_data_get_str_kw(int kw_type, int grid1, int grid2) { const char *kw = NULL; switch (kw_type) { @@ -66,27 +66,27 @@ static const char *ecl_nnc_data_get_str_kw(int kw_type, int grid1, int grid2) { return kw; } -static ecl_kw_type * -ecl_nnc_data_get_gl_kw(const ecl_file_view_type *init_file_view, const char *kw, - int kw_type, int lgr_nr) { +static rd_kw_type * +rd_nnc_data_get_gl_kw(const rd_file_view_type *init_file_view, const char *kw, + int kw_type, int lgr_nr) { if (!kw) return NULL; if (lgr_nr == 0) { - if (ecl_file_view_has_kw(init_file_view, kw)) - return ecl_file_view_iget_named_kw(init_file_view, kw, 0); + if (rd_file_view_has_kw(init_file_view, kw)) + return rd_file_view_iget_named_kw(init_file_view, kw, 0); else return NULL; } bool correct_lgrheadi = false; - const int file_num_kw = ecl_file_view_get_size(init_file_view); + const int file_num_kw = rd_file_view_get_size(init_file_view); for (int kw_index = 0, head_index = 0; kw_index < file_num_kw; ++kw_index) { - ecl_kw_type *ecl_kw = ecl_file_view_iget_kw(init_file_view, kw_index); - const char *current_kw = ecl_kw_get_header(ecl_kw); + rd_kw_type *rd_kw = rd_file_view_iget_kw(init_file_view, kw_index); + const char *current_kw = rd_kw_get_header(rd_kw); if (strcmp(LGRHEADI_KW, current_kw) == 0) { - if (ecl_kw_iget_int(ecl_kw, LGRHEADI_LGR_NR_INDEX) == lgr_nr) { + if (rd_kw_iget_int(rd_kw, LGRHEADI_LGR_NR_INDEX) == lgr_nr) { correct_lgrheadi = true; head_index = kw_index; } else { @@ -100,7 +100,7 @@ ecl_nnc_data_get_gl_kw(const ecl_file_view_type *init_file_view, const char *kw, /* We only support a file format where TRANNNC is 3 steps and TRANGL is 4 or 6 steps from LGRHEADI */ if (kw_type != TRANS_DATA || steps == 3 || steps == 4 || steps == 6) { - return ecl_kw; + return rd_kw; } } } @@ -108,29 +108,29 @@ ecl_nnc_data_get_gl_kw(const ecl_file_view_type *init_file_view, const char *kw, return NULL; } -static ecl_kw_type * -ecl_nnc_data_get_tranll_kw(const ecl_grid_type *grid, - const ecl_file_view_type *init_file_view, - int lgr_nr1, int lgr_nr2) { - const char *lgr_name1 = ecl_grid_get_lgr_name(grid, lgr_nr1); - const char *lgr_name2 = ecl_grid_get_lgr_name(grid, lgr_nr2); +static rd_kw_type * +rd_nnc_data_get_tranll_kw(const rd_grid_type *grid, + const rd_file_view_type *init_file_view, int lgr_nr1, + int lgr_nr2) { + const char *lgr_name1 = rd_grid_get_lgr_name(grid, lgr_nr1); + const char *lgr_name2 = rd_grid_get_lgr_name(grid, lgr_nr2); - ecl_kw_type *tran_kw = NULL; - const int file_num_kw = ecl_file_view_get_size(init_file_view); + rd_kw_type *tran_kw = NULL; + const int file_num_kw = rd_file_view_get_size(init_file_view); int global_kw_index = 0; while (true) { if (global_kw_index >= file_num_kw) break; { - ecl_kw_type *ecl_kw = - ecl_file_view_iget_kw(init_file_view, global_kw_index); - if (strcmp(LGRJOIN_KW, ecl_kw_get_header(ecl_kw)) == 0) { - - if (ecl_kw_icmp_string(ecl_kw, 0, lgr_name1) && - ecl_kw_icmp_string(ecl_kw, 1, lgr_name2)) { - tran_kw = ecl_file_view_iget_kw(init_file_view, - global_kw_index + 1); + rd_kw_type *rd_kw = + rd_file_view_iget_kw(init_file_view, global_kw_index); + if (strcmp(LGRJOIN_KW, rd_kw_get_header(rd_kw)) == 0) { + + if (rd_kw_icmp_string(rd_kw, 0, lgr_name1) && + rd_kw_icmp_string(rd_kw, 1, lgr_name2)) { + tran_kw = rd_file_view_iget_kw(init_file_view, + global_kw_index + 1); break; } } @@ -141,44 +141,42 @@ ecl_nnc_data_get_tranll_kw(const ecl_grid_type *grid, return tran_kw; } -static ecl_kw_type * -ecl_nnc_data_get_kw(const ecl_grid_type *grid, - const ecl_file_view_type *init_file_view, int lgr_nr1, - int lgr_nr2, int kw_type) { +static rd_kw_type *rd_nnc_data_get_kw(const rd_grid_type *grid, + const rd_file_view_type *init_file_view, + int lgr_nr1, int lgr_nr2, int kw_type) { - const char *kw = ecl_nnc_data_get_str_kw(kw_type, lgr_nr1, lgr_nr2); + const char *kw = rd_nnc_data_get_str_kw(kw_type, lgr_nr1, lgr_nr2); if (lgr_nr1 == 0 || lgr_nr1 == lgr_nr2) - return ecl_nnc_data_get_gl_kw(init_file_view, kw, kw_type, lgr_nr2); + return rd_nnc_data_get_gl_kw(init_file_view, kw, kw_type, lgr_nr2); else if (kw_type == TRANS_DATA) - return ecl_nnc_data_get_tranll_kw(grid, init_file_view, lgr_nr1, - lgr_nr2); + return rd_nnc_data_get_tranll_kw(grid, init_file_view, lgr_nr1, + lgr_nr2); else return NULL; } -static void assert_correct_kw_count(ecl_kw_type *kw, const char *function_name, +static void assert_correct_kw_count(rd_kw_type *kw, const char *function_name, int correct_kw_count, int kw_count) { if (correct_kw_count != kw_count) util_abort("In function %s, reading kw: %s. %d != %d", function_name, - ecl_kw_get_header(kw), correct_kw_count, kw_count); + rd_kw_get_header(kw), correct_kw_count, kw_count); } -static bool ecl_nnc_data_set_values(ecl_nnc_data_type *data, - const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file, - int kw_type) { +static bool rd_nnc_data_set_values(rd_nnc_data_type *data, + const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file, + int kw_type) { int current_grid1 = -1; int current_grid2 = -1; - ecl_kw_type *current_kw = NULL; + rd_kw_type *current_kw = NULL; int correct_kw_count = 0; int kw_count = 0; - int nnc_size = ecl_nnc_geometry_size(nnc_geo); + int nnc_size = rd_nnc_geometry_size(nnc_geo); for (int nnc_index = 0; nnc_index < nnc_size; nnc_index++) { - const ecl_nnc_pair_type *pair = - ecl_nnc_geometry_iget(nnc_geo, nnc_index); + const rd_nnc_pair_type *pair = rd_nnc_geometry_iget(nnc_geo, nnc_index); int grid1 = pair->grid_nr1; int grid2 = pair->grid_nr2; @@ -188,17 +186,17 @@ static bool ecl_nnc_data_set_values(ecl_nnc_data_type *data, assert_correct_kw_count(current_kw, __func__, correct_kw_count, kw_count); current_kw = - ecl_nnc_data_get_kw(grid, init_file, grid1, grid2, kw_type); + rd_nnc_data_get_kw(grid, init_file, grid1, grid2, kw_type); kw_count = 0; if (current_kw) { - correct_kw_count = ecl_kw_get_size(current_kw); + correct_kw_count = rd_kw_get_size(current_kw); } else { return false; } } if (current_kw) { data->values[nnc_index] = - ecl_kw_iget_as_double(current_kw, pair->input_index); + rd_kw_iget_as_double(current_kw, pair->input_index); kw_count++; } } @@ -206,65 +204,64 @@ static bool ecl_nnc_data_set_values(ecl_nnc_data_type *data, return true; } -static ecl_nnc_data_type * -ecl_nnc_data_alloc__(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file, int kw_type) { - ecl_nnc_data_type *data = (ecl_nnc_data_type *)util_malloc(sizeof *data); +static rd_nnc_data_type * +rd_nnc_data_alloc__(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file, int kw_type) { + rd_nnc_data_type *data = (rd_nnc_data_type *)util_malloc(sizeof *data); - int nnc_size = ecl_nnc_geometry_size(nnc_geo); + int nnc_size = rd_nnc_geometry_size(nnc_geo); data->size = nnc_size; data->values = (double *)util_malloc(nnc_size * sizeof(double)); - if (ecl_nnc_data_set_values(data, grid, nnc_geo, init_file, kw_type)) + if (rd_nnc_data_set_values(data, grid, nnc_geo, init_file, kw_type)) return data; else { - ecl_nnc_data_free(data); + rd_nnc_data_free(data); return NULL; } } -ecl_nnc_data_type * -ecl_nnc_data_alloc_tran(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file) { - return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, TRANS_DATA); +rd_nnc_data_type *rd_nnc_data_alloc_tran(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file) { + return rd_nnc_data_alloc__(grid, nnc_geo, init_file, TRANS_DATA); } -ecl_nnc_data_type * -ecl_nnc_data_alloc_wat_flux(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file) { - return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, WTR_FLUX_DATA); +rd_nnc_data_type * +rd_nnc_data_alloc_wat_flux(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file) { + return rd_nnc_data_alloc__(grid, nnc_geo, init_file, WTR_FLUX_DATA); } -ecl_nnc_data_type * -ecl_nnc_data_alloc_oil_flux(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file) { - return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, OIL_FLUX_DATA); +rd_nnc_data_type * +rd_nnc_data_alloc_oil_flux(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file) { + return rd_nnc_data_alloc__(grid, nnc_geo, init_file, OIL_FLUX_DATA); } -ecl_nnc_data_type * -ecl_nnc_data_alloc_gas_flux(const ecl_grid_type *grid, - const ecl_nnc_geometry_type *nnc_geo, - const ecl_file_view_type *init_file) { - return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, GAS_FLUX_DATA); +rd_nnc_data_type * +rd_nnc_data_alloc_gas_flux(const rd_grid_type *grid, + const rd_nnc_geometry_type *nnc_geo, + const rd_file_view_type *init_file) { + return rd_nnc_data_alloc__(grid, nnc_geo, init_file, GAS_FLUX_DATA); } -void ecl_nnc_data_free(ecl_nnc_data_type *data) { +void rd_nnc_data_free(rd_nnc_data_type *data) { free(data->values); free(data); } -int ecl_nnc_data_get_size(ecl_nnc_data_type *data) { return data->size; } +int rd_nnc_data_get_size(rd_nnc_data_type *data) { return data->size; } -const double *ecl_nnc_data_get_values(const ecl_nnc_data_type *data) { +const double *rd_nnc_data_get_values(const rd_nnc_data_type *data) { return data->values; } -double ecl_nnc_data_iget_value(const ecl_nnc_data_type *data, int index) { +double rd_nnc_data_iget_value(const rd_nnc_data_type *data, int index) { if (index >= data->size) util_abort("%s: index value:%d out range: [0,%d) \n", __func__, index, data->size); diff --git a/lib/resdata/rd_nnc_export.cpp b/lib/resdata/rd_nnc_export.cpp index f191e16fe1..58872c7398 100644 --- a/lib/resdata/rd_nnc_export.cpp +++ b/lib/resdata/rd_nnc_export.cpp @@ -2,76 +2,75 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** * Return true if the NNC information is stored in the Intersect format, false otherwise. * In the Intersect format, the NNC information stored in the grid is unrealiable. * The correct NNC data is stored in the init file instead */ -bool ecl_nnc_intersect_format(const ecl_grid_type *grid, - const ecl_file_type *init_file) { - if (!ecl_file_has_kw(init_file, NNC1_KW) || - !ecl_file_has_kw(init_file, NNC2_KW) || - !ecl_file_has_kw(init_file, TRANNNC_KW)) +bool rd_nnc_intersect_format(const rd_grid_type *grid, + const rd_file_type *init_file) { + if (!rd_file_has_kw(init_file, NNC1_KW) || + !rd_file_has_kw(init_file, NNC2_KW) || + !rd_file_has_kw(init_file, TRANNNC_KW)) return false; // In the specific case we are treating, there should be just 1 occurrence of the kw const auto nnc1_num = - ecl_kw_get_size(ecl_file_iget_named_kw(init_file, NNC1_KW, 0)); + rd_kw_get_size(rd_file_iget_named_kw(init_file, NNC1_KW, 0)); const auto nnc2_num = - ecl_kw_get_size(ecl_file_iget_named_kw(init_file, NNC2_KW, 0)); + rd_kw_get_size(rd_file_iget_named_kw(init_file, NNC2_KW, 0)); const auto tran_num = - ecl_kw_get_size(ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0)); + rd_kw_get_size(rd_file_iget_named_kw(init_file, TRANNNC_KW, 0)); return nnc1_num == tran_num && nnc2_num == tran_num; } -int ecl_nnc_export_get_size(const ecl_grid_type *grid, - const ecl_file_type *init_file) { - return ecl_nnc_intersect_format(grid, init_file) - ? ecl_kw_get_size( - ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0)) - : // Intersect format - ecl_grid_get_num_nnc(grid); // Eclipse format +int rd_nnc_export_get_size(const rd_grid_type *grid, + const rd_file_type *init_file) { + return rd_nnc_intersect_format(grid, init_file) + ? rd_kw_get_size(rd_file_iget_named_kw(init_file, TRANNNC_KW, 0)) + : // Intersect format + rd_grid_get_num_nnc(grid); // Eclipse format } -static int ecl_nnc_export_intersect__(const ecl_file_type *init_file, - ecl_nnc_type *nnc_data, int *nnc_offset) { - const auto nnc1_kw = ecl_file_iget_named_kw(init_file, NNC1_KW, 0); - const auto nnc2_kw = ecl_file_iget_named_kw(init_file, NNC2_KW, 0); - const auto tran_kw = ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0); +static int rd_nnc_export_intersect__(const rd_file_type *init_file, + rd_nnc_type *nnc_data, int *nnc_offset) { + const auto nnc1_kw = rd_file_iget_named_kw(init_file, NNC1_KW, 0); + const auto nnc2_kw = rd_file_iget_named_kw(init_file, NNC2_KW, 0); + const auto tran_kw = rd_file_iget_named_kw(init_file, TRANNNC_KW, 0); auto nnc_index = *nnc_offset; - for (int i = 0; i < ecl_kw_get_size(tran_kw); ++i) { - auto const nnc1 = ecl_kw_iget_int(nnc1_kw, i); - auto const nnc2 = ecl_kw_iget_int(nnc2_kw, i); - auto const tran = ecl_kw_iget_as_double(tran_kw, i); - nnc_data[nnc_index] = ecl_nnc_type{0, nnc1, 0, nnc2, i, tran}; + for (int i = 0; i < rd_kw_get_size(tran_kw); ++i) { + auto const nnc1 = rd_kw_iget_int(nnc1_kw, i); + auto const nnc2 = rd_kw_iget_int(nnc2_kw, i); + auto const tran = rd_kw_iget_as_double(tran_kw, i); + nnc_data[nnc_index] = rd_nnc_type{0, nnc1, 0, nnc2, i, tran}; ++nnc_index; } *nnc_offset = nnc_index; - return ecl_kw_get_size(tran_kw); // Assume all valid + return rd_kw_get_size(tran_kw); // Assume all valid } -static int ecl_nnc_export__(const ecl_grid_type *grid, int lgr_index1, - const ecl_file_type *init_file, - ecl_nnc_type *nnc_data, int *nnc_offset) { +static int rd_nnc_export__(const rd_grid_type *grid, int lgr_index1, + const rd_file_type *init_file, rd_nnc_type *nnc_data, + int *nnc_offset) { int nnc_index = *nnc_offset; - int lgr_nr1 = ecl_grid_get_lgr_nr(grid); + int lgr_nr1 = rd_grid_get_lgr_nr(grid); int global_index1; int valid_trans = 0; - const ecl_grid_type *global_grid = ecl_grid_get_global_grid(grid); + const rd_grid_type *global_grid = rd_grid_get_global_grid(grid); if (!global_grid) global_grid = grid; - for (global_index1 = 0; global_index1 < ecl_grid_get_global_size(grid); + for (global_index1 = 0; global_index1 < rd_grid_get_global_size(grid); global_index1++) { const nnc_info_type *nnc_info = - ecl_grid_get_cell_nnc_info1(grid, global_index1); + rd_grid_get_cell_nnc_info1(grid, global_index1); if (nnc_info) { int lgr_index2; for (lgr_index2 = 0; lgr_index2 < nnc_info_get_size(nnc_info); @@ -83,11 +82,11 @@ static int ecl_nnc_export__(const ecl_grid_type *grid, int lgr_index1, const std::vector &nnc_index_list = nnc_vector_get_nnc_index_list(nnc_vector); int lgr_nr2 = nnc_vector_get_lgr_nr(nnc_vector); - const ecl_kw_type *tran_kw = ecl_nnc_export_get_tranx_kw( + const rd_kw_type *tran_kw = rd_nnc_export_get_tranx_kw( global_grid, init_file, lgr_nr1, lgr_nr2); int index2; - ecl_nnc_type nnc; + rd_nnc_type nnc; nnc.grid_nr1 = lgr_nr1; nnc.grid_nr2 = lgr_nr2; @@ -99,10 +98,10 @@ static int ecl_nnc_export__(const ecl_grid_type *grid, int lgr_index1, nnc.input_index = nnc_index_list[index2]; if (tran_kw) { nnc.trans = - ecl_kw_iget_as_double(tran_kw, nnc.input_index); + rd_kw_iget_as_double(tran_kw, nnc.input_index); valid_trans++; } else { - nnc.trans = ERT_ECL_DEFAULT_NNC_TRANS; + nnc.trans = ERT_RD_DEFAULT_NNC_TRANS; } nnc_data[nnc_index] = nnc; @@ -115,33 +114,33 @@ static int ecl_nnc_export__(const ecl_grid_type *grid, int lgr_index1, return valid_trans; } -int ecl_nnc_export(const ecl_grid_type *grid, const ecl_file_type *init_file, - ecl_nnc_type *nnc_data) { +int rd_nnc_export(const rd_grid_type *grid, const rd_file_type *init_file, + rd_nnc_type *nnc_data) { int nnc_index = 0; int total_valid_trans = 0; - if (ecl_nnc_intersect_format(grid, init_file)) { + if (rd_nnc_intersect_format(grid, init_file)) { // Intersect format total_valid_trans = - ecl_nnc_export_intersect__(init_file, nnc_data, &nnc_index); + rd_nnc_export_intersect__(init_file, nnc_data, &nnc_index); } else { // Eclipse format total_valid_trans = - ecl_nnc_export__(grid, 0, init_file, nnc_data, &nnc_index); + rd_nnc_export__(grid, 0, init_file, nnc_data, &nnc_index); { - for (int lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); + for (int lgr_index = 0; lgr_index < rd_grid_get_num_lgr(grid); lgr_index++) { - ecl_grid_type *igrid = ecl_grid_iget_lgr(grid, lgr_index); - total_valid_trans += ecl_nnc_export__( + rd_grid_type *igrid = rd_grid_iget_lgr(grid, lgr_index); + total_valid_trans += rd_nnc_export__( igrid, lgr_index, init_file, nnc_data, &nnc_index); } } - nnc_index = ecl_grid_get_num_nnc(grid); + nnc_index = rd_grid_get_num_nnc(grid); } - ecl_nnc_sort(nnc_data, nnc_index); + rd_nnc_sort(nnc_data, nnc_index); return total_valid_trans; } -int ecl_nnc_sort_cmp(const ecl_nnc_type *nnc1, const ecl_nnc_type *nnc2) { +int rd_nnc_sort_cmp(const rd_nnc_type *nnc1, const rd_nnc_type *nnc2) { if (nnc1->grid_nr1 != nnc2->grid_nr1) { if (nnc1->grid_nr1 < nnc2->grid_nr1) @@ -174,44 +173,44 @@ int ecl_nnc_sort_cmp(const ecl_nnc_type *nnc1, const ecl_nnc_type *nnc2) { return 0; } -bool ecl_nnc_equal(const ecl_nnc_type *nnc1, const ecl_nnc_type *nnc2) { +bool rd_nnc_equal(const rd_nnc_type *nnc1, const rd_nnc_type *nnc2) { - if (ecl_nnc_sort_cmp(nnc1, nnc2) == 0) + if (rd_nnc_sort_cmp(nnc1, nnc2) == 0) return ((nnc1->trans == nnc2->trans) && (nnc1->input_index == nnc2->input_index)); else return false; } -static int ecl_nnc_sort_cmp__(const void *nnc1, const void *nnc2) { - return ecl_nnc_sort_cmp((const ecl_nnc_type *)nnc1, - (const ecl_nnc_type *)nnc2); +static int rd_nnc_sort_cmp__(const void *nnc1, const void *nnc2) { + return rd_nnc_sort_cmp((const rd_nnc_type *)nnc1, + (const rd_nnc_type *)nnc2); } -void ecl_nnc_sort(ecl_nnc_type *nnc_list, int size) { - qsort(nnc_list, size, sizeof *nnc_list, ecl_nnc_sort_cmp__); +void rd_nnc_sort(rd_nnc_type *nnc_list, int size) { + qsort(nnc_list, size, sizeof *nnc_list, rd_nnc_sort_cmp__); } -ecl_kw_type *ecl_nnc_export_get_tranll_kw(const ecl_grid_type *grid, - const ecl_file_type *init_file, - int lgr_nr1, int lgr_nr2) { - const char *lgr_name1 = ecl_grid_get_lgr_name(grid, lgr_nr1); - const char *lgr_name2 = ecl_grid_get_lgr_name(grid, lgr_nr2); +rd_kw_type *rd_nnc_export_get_tranll_kw(const rd_grid_type *grid, + const rd_file_type *init_file, + int lgr_nr1, int lgr_nr2) { + const char *lgr_name1 = rd_grid_get_lgr_name(grid, lgr_nr1); + const char *lgr_name2 = rd_grid_get_lgr_name(grid, lgr_nr2); - ecl_kw_type *tran_kw = NULL; - const int file_num_kw = ecl_file_get_size(init_file); + rd_kw_type *tran_kw = NULL; + const int file_num_kw = rd_file_get_size(init_file); int global_kw_index = 0; while (true) { if (global_kw_index >= file_num_kw) break; { - ecl_kw_type *ecl_kw = ecl_file_iget_kw(init_file, global_kw_index); - if (strcmp(LGRJOIN_KW, ecl_kw_get_header(ecl_kw)) == 0) { + rd_kw_type *rd_kw = rd_file_iget_kw(init_file, global_kw_index); + if (strcmp(LGRJOIN_KW, rd_kw_get_header(rd_kw)) == 0) { - if (ecl_kw_icmp_string(ecl_kw, 0, lgr_name1) && - ecl_kw_icmp_string(ecl_kw, 1, lgr_name2)) { - tran_kw = ecl_file_iget_kw(init_file, global_kw_index + 1); + if (rd_kw_icmp_string(rd_kw, 0, lgr_name1) && + rd_kw_icmp_string(rd_kw, 1, lgr_name2)) { + tran_kw = rd_file_iget_kw(init_file, global_kw_index + 1); break; } } @@ -222,17 +221,17 @@ ecl_kw_type *ecl_nnc_export_get_tranll_kw(const ecl_grid_type *grid, return tran_kw; } -ecl_kw_type *ecl_nnc_export_get_tran_kw(const ecl_file_type *init_file, - const char *kw, int lgr_nr) { - ecl_kw_type *tran_kw = NULL; +rd_kw_type *rd_nnc_export_get_tran_kw(const rd_file_type *init_file, + const char *kw, int lgr_nr) { + rd_kw_type *tran_kw = NULL; if (lgr_nr == 0) { if (strcmp(kw, TRANNNC_KW) == 0) - if (ecl_file_has_kw(init_file, kw)) { - tran_kw = ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0); + if (rd_file_has_kw(init_file, kw)) { + tran_kw = rd_file_iget_named_kw(init_file, TRANNNC_KW, 0); } } else { if ((strcmp(kw, TRANNNC_KW) == 0) || (strcmp(kw, TRANGL_KW) == 0)) { - const int file_num_kw = ecl_file_get_size(init_file); + const int file_num_kw = rd_file_get_size(init_file); int global_kw_index = 0; bool finished = false; bool correct_lgrheadi = false; @@ -240,11 +239,10 @@ ecl_kw_type *ecl_nnc_export_get_tran_kw(const ecl_file_type *init_file, int steps = 0; while (!finished) { - ecl_kw_type *ecl_kw = - ecl_file_iget_kw(init_file, global_kw_index); - const char *current_kw = ecl_kw_get_header(ecl_kw); + rd_kw_type *rd_kw = rd_file_iget_kw(init_file, global_kw_index); + const char *current_kw = rd_kw_get_header(rd_kw); if (strcmp(LGRHEADI_KW, current_kw) == 0) { - if (ecl_kw_iget_int(ecl_kw, LGRHEADI_LGR_NR_INDEX) == + if (rd_kw_iget_int(rd_kw, LGRHEADI_LGR_NR_INDEX) == lgr_nr) { correct_lgrheadi = true; head_index = global_kw_index; @@ -260,7 +258,7 @@ ecl_kw_type *ecl_nnc_export_get_tran_kw(const ecl_file_type *init_file, if (steps == 3 || steps == 4 || steps == 6) { /* We only support a file format where TRANNNC is 3 steps and TRANGL is 4 or 6 steps from LGRHEADI */ - tran_kw = ecl_kw; + tran_kw = rd_kw; finished = true; break; } @@ -275,16 +273,16 @@ ecl_kw_type *ecl_nnc_export_get_tran_kw(const ecl_file_type *init_file, return tran_kw; } -ecl_kw_type *ecl_nnc_export_get_tranx_kw(const ecl_grid_type *grid, - const ecl_file_type *init_file, - int lgr_nr1, int lgr_nr2) { +rd_kw_type *rd_nnc_export_get_tranx_kw(const rd_grid_type *grid, + const rd_file_type *init_file, + int lgr_nr1, int lgr_nr2) { if (lgr_nr1 == lgr_nr2) - return ecl_nnc_export_get_tran_kw(init_file, TRANNNC_KW, lgr_nr2); + return rd_nnc_export_get_tran_kw(init_file, TRANNNC_KW, lgr_nr2); else { if (lgr_nr1 == 0) - return ecl_nnc_export_get_tran_kw(init_file, TRANGL_KW, lgr_nr2); + return rd_nnc_export_get_tran_kw(init_file, TRANGL_KW, lgr_nr2); else - return ecl_nnc_export_get_tranll_kw(grid, init_file, lgr_nr1, - lgr_nr2); + return rd_nnc_export_get_tranll_kw(grid, init_file, lgr_nr1, + lgr_nr2); } } diff --git a/lib/resdata/rd_nnc_geometry.cpp b/lib/resdata/rd_nnc_geometry.cpp index 8ffa986dec..0a0ff2ad21 100644 --- a/lib/resdata/rd_nnc_geometry.cpp +++ b/lib/resdata/rd_nnc_geometry.cpp @@ -1,18 +1,18 @@ #include #include -#include +#include -#define ECL_NNC_GEOMETRY_TYPE_ID 6124343 +#define RD_NNC_GEOMETRY_TYPE_ID 6124343 -struct ecl_nnc_geometry_struct { +struct rd_nnc_geometry_struct { UTIL_TYPE_ID_DECLARATION; - std::vector *data; + std::vector *data; }; -UTIL_IS_INSTANCE_FUNCTION(ecl_nnc_geometry, ECL_NNC_GEOMETRY_TYPE_ID) +UTIL_IS_INSTANCE_FUNCTION(rd_nnc_geometry, RD_NNC_GEOMETRY_TYPE_ID) -int ecl_nnc_geometry_size(const ecl_nnc_geometry_type *nnc_geo) { +int rd_nnc_geometry_size(const rd_nnc_geometry_type *nnc_geo) { return nnc_geo->data->size(); } @@ -26,18 +26,18 @@ int ecl_nnc_geometry_size(const ecl_nnc_geometry_type *nnc_geo) { cells (grid_nr1, global_index1) and (grid_nr2, global_index2). */ -static void ecl_nnc_geometry_add_pairs(const ecl_nnc_geometry_type *nnc_geo, - const ecl_grid_type *grid) { - int lgr_nr1 = ecl_grid_get_lgr_nr(grid); - const ecl_grid_type *global_grid = ecl_grid_get_global_grid(grid); +static void rd_nnc_geometry_add_pairs(const rd_nnc_geometry_type *nnc_geo, + const rd_grid_type *grid) { + int lgr_nr1 = rd_grid_get_lgr_nr(grid); + const rd_grid_type *global_grid = rd_grid_get_global_grid(grid); if (!global_grid) global_grid = grid; - for (int global_index1 = 0; global_index1 < ecl_grid_get_global_size(grid); + for (int global_index1 = 0; global_index1 < rd_grid_get_global_size(grid); global_index1++) { const nnc_info_type *nnc_info = - ecl_grid_get_cell_nnc_info1(grid, global_index1); + rd_grid_get_cell_nnc_info1(grid, global_index1); if (!nnc_info) continue; @@ -53,7 +53,7 @@ static void ecl_nnc_geometry_add_pairs(const ecl_nnc_geometry_type *nnc_geo, for (int index2 = 0; index2 < nnc_vector_get_size(nnc_vector); index2++) { - ecl_nnc_pair_type pair; + rd_nnc_pair_type pair; pair.grid_nr1 = lgr_nr1; pair.global_index1 = global_index1; pair.grid_nr2 = lgr_nr2; @@ -65,8 +65,8 @@ static void ecl_nnc_geometry_add_pairs(const ecl_nnc_geometry_type *nnc_geo, } } -static bool ecl_nnc_cmp(const ecl_nnc_pair_type &nnc1, - const ecl_nnc_pair_type &nnc2) { +static bool rd_nnc_cmp(const rd_nnc_pair_type &nnc1, + const rd_nnc_pair_type &nnc2) { if (nnc1.grid_nr1 != nnc2.grid_nr1) return nnc1.grid_nr1 < nnc2.grid_nr1; @@ -82,35 +82,35 @@ static bool ecl_nnc_cmp(const ecl_nnc_pair_type &nnc1, return false; } -ecl_nnc_geometry_type *ecl_nnc_geometry_alloc(const ecl_grid_type *grid) { - ecl_nnc_geometry_type *nnc_geo = - (ecl_nnc_geometry_type *)util_malloc(sizeof *nnc_geo); - UTIL_TYPE_ID_INIT(nnc_geo, ECL_NNC_GEOMETRY_TYPE_ID); - nnc_geo->data = new std::vector(); +rd_nnc_geometry_type *rd_nnc_geometry_alloc(const rd_grid_type *grid) { + rd_nnc_geometry_type *nnc_geo = + (rd_nnc_geometry_type *)util_malloc(sizeof *nnc_geo); + UTIL_TYPE_ID_INIT(nnc_geo, RD_NNC_GEOMETRY_TYPE_ID); + nnc_geo->data = new std::vector(); - ecl_nnc_geometry_add_pairs(nnc_geo, grid); - for (int lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); + rd_nnc_geometry_add_pairs(nnc_geo, grid); + for (int lgr_index = 0; lgr_index < rd_grid_get_num_lgr(grid); lgr_index++) { - ecl_grid_type *igrid = ecl_grid_iget_lgr(grid, lgr_index); - ecl_nnc_geometry_add_pairs(nnc_geo, igrid); + rd_grid_type *igrid = rd_grid_iget_lgr(grid, lgr_index); + rd_nnc_geometry_add_pairs(nnc_geo, igrid); } - std::sort(nnc_geo->data->begin(), nnc_geo->data->end(), ecl_nnc_cmp); + std::sort(nnc_geo->data->begin(), nnc_geo->data->end(), rd_nnc_cmp); return nnc_geo; } -void ecl_nnc_geometry_free(ecl_nnc_geometry_type *nnc_geo) { +void rd_nnc_geometry_free(rd_nnc_geometry_type *nnc_geo) { delete nnc_geo->data; free(nnc_geo); } -const ecl_nnc_pair_type * -ecl_nnc_geometry_iget(const ecl_nnc_geometry_type *nnc_geo, int index) { - const std::vector &nnc_data = *nnc_geo->data; +const rd_nnc_pair_type * +rd_nnc_geometry_iget(const rd_nnc_geometry_type *nnc_geo, int index) { + const std::vector &nnc_data = *nnc_geo->data; return &nnc_data[index]; } -bool ecl_nnc_geometry_same_kw(const ecl_nnc_pair_type *nnc1, - const ecl_nnc_pair_type *nnc2) { +bool rd_nnc_geometry_same_kw(const rd_nnc_pair_type *nnc1, + const rd_nnc_pair_type *nnc2) { if ((nnc1->grid_nr1 == nnc2->grid_nr1) && (nnc1->grid_nr2 == nnc2->grid_nr2)) return true; diff --git a/lib/resdata/rd_region.cpp b/lib/resdata/rd_region.cpp index 9e713a1ec9..4ec68ed4c5 100644 --- a/lib/resdata/rd_region.cpp +++ b/lib/resdata/rd_region.cpp @@ -8,36 +8,36 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** - This file implements a type called ecl_region which is a way to + This file implements a type called rd_region which is a way to select and keep track of designated cells in an ECLIPSE reservoir grid. An instance is allocated with a grid (a shared reference which is NOT modified). Then we can select/deselect cells based on: - 1. Integer equality - ecl_region_select_equal() - 2. Float interval - ecl_region_select_in_interval() - 3. A rectangualar box - ecl_region_select_from_box() - 4. Subsections of i/j/k - ecl_region_select_i1i2() / ecl_region_seleect_j1j2() / ... - 5. All cells - ecl_region_select_all() + 1. Integer equality - rd_region_select_equal() + 2. Float interval - rd_region_select_in_interval() + 3. A rectangualar box - rd_region_select_from_box() + 4. Subsections of i/j/k - rd_region_select_i1i2() / rd_region_seleect_j1j2() / ... + 5. All cells - rd_region_select_all() When allocating an instance you determine whether all cells should be initially selected, or not-selected. The various select functions can (of course ...) be chained together. All functions exist in a xxx_select() and an opposite xxx_deselect() version. - When you are finished with selecting you can query the ecl_region + When you are finished with selecting you can query the rd_region instance for the number of active cells, and get a (const int *) to the indices. You can also get the results in term of global - indices. (Refer to ecl_grid for the difference between active and + indices. (Refer to rd_grid for the difference between active and global indices). - For the functions which take ecl_kw input, the ecl_kw instance must + For the functions which take rd_kw input, the rd_kw instance must have either nx*ny*nz elements, or nactive(from the grid) elements. This is checked, and the program will fail hard if it is not satisfied. @@ -45,20 +45,20 @@ Example: -------- - ecl_grid_type * ecl_grid; - ecl_kw_type * soil; - ecl_kw_type * regions; - ecl_region_type * ecl_region; + rd_grid_type * rd_grid; + rd_kw_type * soil; + rd_kw_type * regions; + rd_region_type * rd_region; // Load grid, soil and regions somehow. - ecl_region = ecl_region_alloc( ecl_grid , false ); // Start with nothing selected - ecl_region_select_in_interval( ecl_region , soil , 0.50, 1.00); // Select all cells with soil > 0.50 - ecl_region_select_equal( ecl_region , regions , 3 ); // Only consider ECLIPSE region 3. - ecl_region_select_k1k2( ecl_region , 5 , 8); // Select layers 5,6,7,8 + rd_region = rd_region_alloc( rd_grid , false ); // Start with nothing selected + rd_region_select_in_interval( rd_region , soil , 0.50, 1.00); // Select all cells with soil > 0.50 + rd_region_select_equal( rd_region , regions , 3 ); // Only consider ECLIPSE region 3. + rd_region_select_k1k2( rd_region , 5 , 8); // Select layers 5,6,7,8 { - int num_cells = ecl_region_get_global_size( ecl_region ); // How many cells are active - const int * cell_list = ecl_region_get_global_list( ecl_region ); // Get a list of indices + int num_cells = rd_region_get_global_size( rd_region ); // How many cells are active + const int * cell_list = rd_region_get_global_list( rd_region ); // Get a list of indices int i; printf("%d cells satisfy your selection. The cells are: \n"); @@ -66,13 +66,13 @@ printf("Cell: %d \n",cell_list[i]); } - ecl_region_free( ecl_region ); + rd_region_free( rd_region ); */ -#define ECL_REGION_TYPE_ID 1106377 +#define RD_REGION_TYPE_ID 1106377 -struct ecl_region_struct { +struct rd_region_struct { UTIL_TYPE_ID_DECLARATION; bool * active_mask; /* This marks active|inactive in the region, which is unrelated to active in the grid. */ @@ -89,36 +89,35 @@ struct ecl_region_struct { bool preselect; /* Grid properties */ int grid_nx, grid_ny, grid_nz, grid_vol, grid_active; - const ecl_grid_type *parent_grid; + const rd_grid_type *parent_grid; }; -UTIL_IS_INSTANCE_FUNCTION(ecl_region, ECL_REGION_TYPE_ID) -UTIL_SAFE_CAST_FUNCTION(ecl_region, ECL_REGION_TYPE_ID) +UTIL_IS_INSTANCE_FUNCTION(rd_region, RD_REGION_TYPE_ID) +UTIL_SAFE_CAST_FUNCTION(rd_region, RD_REGION_TYPE_ID) -static void ecl_region_invalidate_index_list(ecl_region_type *region) { +static void rd_region_invalidate_index_list(rd_region_type *region) { region->global_index_list_valid = false; region->active_index_list_valid = false; } -void ecl_region_lock(ecl_region_type *region) { +void rd_region_lock(rd_region_type *region) { int_vector_set_read_only(region->global_index_list, true); int_vector_set_read_only(region->active_index_list, true); int_vector_set_read_only(region->global_active_list, true); } -void ecl_region_unlock(ecl_region_type *region) { +void rd_region_unlock(rd_region_type *region) { int_vector_set_read_only(region->global_index_list, false); int_vector_set_read_only(region->active_index_list, false); int_vector_set_read_only(region->global_active_list, false); } -ecl_region_type *ecl_region_alloc(const ecl_grid_type *ecl_grid, - bool preselect) { - ecl_region_type *region = (ecl_region_type *)util_malloc(sizeof *region); - UTIL_TYPE_ID_INIT(region, ECL_REGION_TYPE_ID); - region->parent_grid = ecl_grid; - ecl_grid_get_dims(ecl_grid, ®ion->grid_nx, ®ion->grid_ny, - ®ion->grid_nz, ®ion->grid_active); +rd_region_type *rd_region_alloc(const rd_grid_type *rd_grid, bool preselect) { + rd_region_type *region = (rd_region_type *)util_malloc(sizeof *region); + UTIL_TYPE_ID_INIT(region, RD_REGION_TYPE_ID); + region->parent_grid = rd_grid; + rd_grid_get_dims(rd_grid, ®ion->grid_nx, ®ion->grid_ny, + ®ion->grid_nz, ®ion->grid_active); region->grid_vol = region->grid_nx * region->grid_ny * region->grid_nz; region->active_mask = (bool *)util_calloc(region->grid_vol, sizeof *region->active_mask); @@ -127,21 +126,21 @@ ecl_region_type *ecl_region_alloc(const ecl_grid_type *ecl_grid, region->global_active_list = int_vector_alloc(0, 0); region->preselect = preselect; region->name = NULL; - ecl_region_reset( + rd_region_reset( region); /* This MUST be called to ensure that xxx_valid is correctly initialized. */ return region; } -ecl_region_type *ecl_region_alloc_copy(const ecl_region_type *ecl_region) { - ecl_region_type *new_region = - ecl_region_alloc(ecl_region->parent_grid, ecl_region->preselect); - memcpy(new_region->active_mask, ecl_region->active_mask, - ecl_region->grid_vol * sizeof *ecl_region->active_mask); - ecl_region_invalidate_index_list(new_region); +rd_region_type *rd_region_alloc_copy(const rd_region_type *rd_region) { + rd_region_type *new_region = + rd_region_alloc(rd_region->parent_grid, rd_region->preselect); + memcpy(new_region->active_mask, rd_region->active_mask, + rd_region->grid_vol * sizeof *rd_region->active_mask); + rd_region_invalidate_index_list(new_region); return new_region; } -void ecl_region_free(ecl_region_type *region) { +void rd_region_free(rd_region_type *region) { free(region->active_mask); int_vector_free(region->active_index_list); int_vector_free(region->global_index_list); @@ -150,12 +149,12 @@ void ecl_region_free(ecl_region_type *region) { free(region); } -void ecl_region_free__(void *__region) { - ecl_region_type *region = ecl_region_safe_cast(__region); - ecl_region_free(region); +void rd_region_free__(void *__region) { + rd_region_type *region = rd_region_safe_cast(__region); + rd_region_free(region); } -static void ecl_region_assert_global_index_list(ecl_region_type *region) { +static void rd_region_assert_global_index_list(rd_region_type *region) { if (!region->global_index_list_valid) { int global_index; @@ -168,7 +167,7 @@ static void ecl_region_assert_global_index_list(ecl_region_type *region) { } } -static void ecl_region_assert_active_index_list(ecl_region_type *region) { +static void rd_region_assert_active_index_list(rd_region_type *region) { if (!region->active_index_list_valid) { int global_index; @@ -177,7 +176,7 @@ static void ecl_region_assert_active_index_list(ecl_region_type *region) { for (global_index = 0; global_index < region->grid_vol; global_index++) { if (region->active_mask[global_index]) { - int active_index = ecl_grid_get_active_index1( + int active_index = rd_grid_get_active_index1( region->parent_grid, global_index); if (active_index >= 0) { int_vector_append(region->active_index_list, active_index); @@ -189,45 +188,45 @@ static void ecl_region_assert_active_index_list(ecl_region_type *region) { } } -const int_vector_type *ecl_region_get_active_list(ecl_region_type *region) { - ecl_region_assert_active_index_list(region); +const int_vector_type *rd_region_get_active_list(rd_region_type *region) { + rd_region_assert_active_index_list(region); return region->active_index_list; } const int_vector_type * -ecl_region_get_global_active_list(ecl_region_type *region) { - ecl_region_assert_active_index_list(region); +rd_region_get_global_active_list(rd_region_type *region) { + rd_region_assert_active_index_list(region); return region->global_active_list; } -const int_vector_type *ecl_region_get_global_list(ecl_region_type *region) { - ecl_region_assert_global_index_list(region); +const int_vector_type *rd_region_get_global_list(rd_region_type *region) { + rd_region_assert_global_index_list(region); return region->global_index_list; } /* Cpp compat/legacy/cruft functions. */ -int ecl_region_get_active_size_cpp(ecl_region_type *region) { - return int_vector_size(ecl_region_get_active_list(region)); +int rd_region_get_active_size_cpp(rd_region_type *region) { + return int_vector_size(rd_region_get_active_list(region)); } -int ecl_region_get_global_size_cpp(ecl_region_type *region) { - return int_vector_size(ecl_region_get_global_list(region)); +int rd_region_get_global_size_cpp(rd_region_type *region) { + return int_vector_size(rd_region_get_global_list(region)); } -const int *ecl_region_get_active_list_cpp(ecl_region_type *region) { - return int_vector_get_const_ptr(ecl_region_get_active_list(region)); +const int *rd_region_get_active_list_cpp(rd_region_type *region) { + return int_vector_get_const_ptr(rd_region_get_active_list(region)); } -const int *ecl_region_get_global_list_cpp(ecl_region_type *region) { - return int_vector_get_const_ptr(ecl_region_get_global_list(region)); +const int *rd_region_get_global_list_cpp(rd_region_type *region) { + return int_vector_get_const_ptr(rd_region_get_global_list(region)); } -static void ecl_region_assert_kw(const ecl_region_type *region, - const ecl_kw_type *ecl_kw, bool *global_kw) { - int kw_size = ecl_kw_get_size(ecl_kw); +static void rd_region_assert_kw(const rd_region_type *region, + const rd_kw_type *rd_kw, bool *global_kw) { + int kw_size = rd_kw_get_size(rd_kw); if (!(kw_size == region->grid_vol || kw_size == region->grid_active)) util_abort( - "%s: size mismatch between ecl_kw instance and region->grid \n", + "%s: size mismatch between rd_kw instance and region->grid \n", __func__); if (kw_size == region->grid_vol) *global_kw = true; @@ -235,39 +234,39 @@ static void ecl_region_assert_kw(const ecl_region_type *region, *global_kw = false; } -void ecl_region_reset(ecl_region_type *ecl_region) { +void rd_region_reset(rd_region_type *rd_region) { int i; - for (i = 0; i < ecl_region->grid_vol; i++) - ecl_region->active_mask[i] = ecl_region->preselect; - ecl_region_invalidate_index_list(ecl_region); + for (i = 0; i < rd_region->grid_vol; i++) + rd_region->active_mask[i] = rd_region->preselect; + rd_region_invalidate_index_list(rd_region); } -static void ecl_region_select_cell__(ecl_region_type *region, int i, int j, - int k, bool select) { - int global_index = ecl_grid_get_global_index3(region->parent_grid, i, j, k); +static void rd_region_select_cell__(rd_region_type *region, int i, int j, int k, + bool select) { + int global_index = rd_grid_get_global_index3(region->parent_grid, i, j, k); region->active_mask[global_index] = select; - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_cell(ecl_region_type *region, int i, int j, int k) { - ecl_region_select_cell__(region, i, j, k, true); +void rd_region_select_cell(rd_region_type *region, int i, int j, int k) { + rd_region_select_cell__(region, i, j, k, true); } -void ecl_region_deselect_cell(ecl_region_type *region, int i, int j, int k) { - ecl_region_select_cell__(region, i, j, k, false); +void rd_region_deselect_cell(rd_region_type *region, int i, int j, int k) { + rd_region_select_cell__(region, i, j, k, false); } -static void ecl_region_select_equal__(ecl_region_type *region, - const ecl_kw_type *ecl_kw, int value, - bool select) { +static void rd_region_select_equal__(rd_region_type *region, + const rd_kw_type *rd_kw, int value, + bool select) { bool global_kw; - ecl_region_assert_kw(region, ecl_kw, &global_kw); - if (!ecl_type_is_int(ecl_kw_get_data_type(ecl_kw))) + rd_region_assert_kw(region, rd_kw, &global_kw); + if (!rd_type_is_int(rd_kw_get_data_type(rd_kw))) util_abort("%s: sorry - select by equality is only supported for " "integer keywords \n", __func__); { - const int *kw_data = ecl_kw_get_int_ptr(ecl_kw); + const int *kw_data = rd_kw_get_int_ptr(rd_kw); if (global_kw) { int global_index; for (global_index = 0; global_index < region->grid_vol; @@ -280,32 +279,32 @@ static void ecl_region_select_equal__(ecl_region_type *region, for (active_index = 0; active_index < region->grid_active; active_index++) { if (kw_data[active_index] == value) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_equal(ecl_region_type *region, const ecl_kw_type *ecl_kw, - int value) { - ecl_region_select_equal__(region, ecl_kw, value, true); +void rd_region_select_equal(rd_region_type *region, const rd_kw_type *rd_kw, + int value) { + rd_region_select_equal__(region, rd_kw, value, true); } -void ecl_region_deselect_equal(ecl_region_type *region, - const ecl_kw_type *ecl_kw, int value) { - ecl_region_select_equal__(region, ecl_kw, value, false); +void rd_region_deselect_equal(rd_region_type *region, const rd_kw_type *rd_kw, + int value) { + rd_region_select_equal__(region, rd_kw, value, false); } -static void ecl_region_select_bool_equal__(ecl_region_type *region, - const ecl_kw_type *ecl_kw, - bool value, bool select) { +static void rd_region_select_bool_equal__(rd_region_type *region, + const rd_kw_type *rd_kw, bool value, + bool select) { bool global_kw; - ecl_region_assert_kw(region, ecl_kw, &global_kw); - if (!ecl_type_is_bool(ecl_kw_get_data_type(ecl_kw))) + rd_region_assert_kw(region, rd_kw, &global_kw); + if (!rd_type_is_bool(rd_kw_get_data_type(rd_kw))) util_abort("%s: sorry - select by equality is only supported for " "boolean keywords \n", __func__); @@ -314,56 +313,52 @@ static void ecl_region_select_bool_equal__(ecl_region_type *region, int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) { - if (ecl_kw_iget_bool(ecl_kw, global_index) == value) + if (rd_kw_iget_bool(rd_kw, global_index) == value) region->active_mask[global_index] = select; } } else { int active_index; for (active_index = 0; active_index < region->grid_active; active_index++) { - if (ecl_kw_iget_bool(ecl_kw, active_index) == value) { - int global_index = ecl_grid_get_global_index1A( + if (rd_kw_iget_bool(rd_kw, active_index) == value) { + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_true(ecl_region_type *region, - const ecl_kw_type *ecl_kw) { - ecl_region_select_bool_equal__(region, ecl_kw, true, true); +void rd_region_select_true(rd_region_type *region, const rd_kw_type *rd_kw) { + rd_region_select_bool_equal__(region, rd_kw, true, true); } -void ecl_region_deselect_true(ecl_region_type *region, - const ecl_kw_type *ecl_kw) { - ecl_region_select_bool_equal__(region, ecl_kw, true, false); +void rd_region_deselect_true(rd_region_type *region, const rd_kw_type *rd_kw) { + rd_region_select_bool_equal__(region, rd_kw, true, false); } -void ecl_region_select_false(ecl_region_type *region, - const ecl_kw_type *ecl_kw) { - ecl_region_select_bool_equal__(region, ecl_kw, false, true); +void rd_region_select_false(rd_region_type *region, const rd_kw_type *rd_kw) { + rd_region_select_bool_equal__(region, rd_kw, false, true); } -void ecl_region_deselect_false(ecl_region_type *region, - const ecl_kw_type *ecl_kw) { - ecl_region_select_bool_equal__(region, ecl_kw, false, false); +void rd_region_deselect_false(rd_region_type *region, const rd_kw_type *rd_kw) { + rd_region_select_bool_equal__(region, rd_kw, false, false); } -static void ecl_region_select_in_interval__(ecl_region_type *region, - const ecl_kw_type *ecl_kw, - float min_value, float max_value, - bool select) { +static void rd_region_select_in_interval__(rd_region_type *region, + const rd_kw_type *rd_kw, + float min_value, float max_value, + bool select) { bool global_kw; - ecl_region_assert_kw(region, ecl_kw, &global_kw); - if (!ecl_type_is_float(ecl_kw_get_data_type(ecl_kw))) + rd_region_assert_kw(region, rd_kw, &global_kw); + if (!rd_type_is_float(rd_kw_get_data_type(rd_kw))) util_abort("%s: sorry - select by in_interval is only supported for " "float keywords \n", __func__); { - const float *kw_data = ecl_kw_get_float_ptr(ecl_kw); + const float *kw_data = rd_kw_get_float_ptr(rd_kw); if (global_kw) { int global_index; for (global_index = 0; global_index < region->grid_vol; @@ -378,27 +373,26 @@ static void ecl_region_select_in_interval__(ecl_region_type *region, active_index++) { if (kw_data[active_index] >= min_value && kw_data[active_index] < max_value) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_in_interval(ecl_region_type *region, - const ecl_kw_type *ecl_kw, float min_value, - float max_value) { - ecl_region_select_in_interval__(region, ecl_kw, min_value, max_value, true); +void rd_region_select_in_interval(rd_region_type *region, + const rd_kw_type *rd_kw, float min_value, + float max_value) { + rd_region_select_in_interval__(region, rd_kw, min_value, max_value, true); } -void ecl_region_deselect_in_interval(ecl_region_type *region, - const ecl_kw_type *ecl_kw, float min_value, - float max_value) { - ecl_region_select_in_interval__(region, ecl_kw, min_value, max_value, - false); +void rd_region_deselect_in_interval(rd_region_type *region, + const rd_kw_type *rd_kw, float min_value, + float max_value) { + rd_region_select_in_interval__(region, rd_kw, min_value, max_value, false); } /** @@ -410,21 +404,20 @@ void ecl_region_deselect_in_interval(ecl_region_type *region, /* NBNBNBNB: Select >= on float values and select > on integer!!!!!! */ -static void ecl_region_select_with_limit__(ecl_region_type *region, - const ecl_kw_type *ecl_kw, - float limit, bool select_less, - bool select) { +static void rd_region_select_with_limit__(rd_region_type *region, + const rd_kw_type *rd_kw, float limit, + bool select_less, bool select) { bool global_kw; - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - ecl_region_assert_kw(region, ecl_kw, &global_kw); - if (!ecl_type_is_numeric(data_type)) + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + rd_region_assert_kw(region, rd_kw, &global_kw); + if (!rd_type_is_numeric(data_type)) util_abort("%s: sorry - select by in_interval is only supported for " "float and integer keywords \n", __func__); { - if (ecl_type_is_float(data_type)) { - const float *kw_data = ecl_kw_get_float_ptr(ecl_kw); + if (rd_type_is_float(data_type)) { + const float *kw_data = rd_kw_get_float_ptr(rd_kw); float float_limit = limit; if (global_kw) { int global_index; @@ -444,21 +437,21 @@ static void ecl_region_select_with_limit__(ecl_region_type *region, active_index++) { if (select_less) { if (kw_data[active_index] < float_limit) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } else { if (kw_data[active_index] >= float_limit) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } } } - } else if (ecl_type_is_int(data_type)) { - const int *kw_data = ecl_kw_get_int_ptr(ecl_kw); + } else if (rd_type_is_int(data_type)) { + const int *kw_data = rd_kw_get_int_ptr(rd_kw); int int_limit = (int)limit; if (global_kw) { int global_index; @@ -478,21 +471,21 @@ static void ecl_region_select_with_limit__(ecl_region_type *region, active_index++) { if (select_less) { if (kw_data[active_index] < int_limit) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } else { if (kw_data[active_index] > int_limit) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } } } - } else if (ecl_type_is_double(data_type)) { - const double *kw_data = ecl_kw_get_double_ptr(ecl_kw); + } else if (rd_type_is_double(data_type)) { + const double *kw_data = rd_kw_get_double_ptr(rd_kw); double double_limit = (double)limit; if (global_kw) { int global_index; @@ -512,13 +505,13 @@ static void ecl_region_select_with_limit__(ecl_region_type *region, active_index++) { if (select_less) { if (kw_data[active_index] < double_limit) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } else { if (kw_data[active_index] >= double_limit) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } @@ -527,48 +520,47 @@ static void ecl_region_select_with_limit__(ecl_region_type *region, } } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_smaller(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit) { - ecl_region_select_with_limit__(ecl_region, ecl_kw, limit, true, true); +void rd_region_select_smaller(rd_region_type *rd_region, + const rd_kw_type *rd_kw, float limit) { + rd_region_select_with_limit__(rd_region, rd_kw, limit, true, true); } -void ecl_region_deselect_smaller(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit) { - ecl_region_select_with_limit__(ecl_region, ecl_kw, limit, true, false); +void rd_region_deselect_smaller(rd_region_type *rd_region, + const rd_kw_type *rd_kw, float limit) { + rd_region_select_with_limit__(rd_region, rd_kw, limit, true, false); } -void ecl_region_select_larger(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit) { - ecl_region_select_with_limit__(ecl_region, ecl_kw, limit, false, true); +void rd_region_select_larger(rd_region_type *rd_region, const rd_kw_type *rd_kw, + float limit) { + rd_region_select_with_limit__(rd_region, rd_kw, limit, false, true); } -void ecl_region_deselect_larger(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, float limit) { - ecl_region_select_with_limit__(ecl_region, ecl_kw, limit, false, false); +void rd_region_deselect_larger(rd_region_type *rd_region, + const rd_kw_type *rd_kw, float limit) { + rd_region_select_with_limit__(rd_region, rd_kw, limit, false, false); } /** Selection based on comparing two keywords. */ -static void ecl_region_cmp_select__(ecl_region_type *region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2, bool select_less, - bool select) { +static void rd_region_cmp_select__(rd_region_type *region, + const rd_kw_type *kw1, const rd_kw_type *kw2, + bool select_less, bool select) { bool global_kw; - ecl_region_assert_kw(region, kw1, &global_kw); - if (!ecl_type_is_float(ecl_kw_get_data_type(kw1))) + rd_region_assert_kw(region, kw1, &global_kw); + if (!rd_type_is_float(rd_kw_get_data_type(kw1))) util_abort("%s: sorry - select by cmp() is only supported for float " "keywords \n", __func__); { - if (ecl_kw_size_and_type_equal(kw1, kw2)) { + if (rd_kw_size_and_type_equal(kw1, kw2)) { - const float *kw1_data = ecl_kw_get_float_ptr(kw1); - const float *kw2_data = ecl_kw_get_float_ptr(kw2); + const float *kw1_data = rd_kw_get_float_ptr(kw1); + const float *kw2_data = rd_kw_get_float_ptr(kw2); if (global_kw) { int global_index; @@ -588,13 +580,13 @@ static void ecl_region_cmp_select__(ecl_region_type *region, active_index++) { if (select_less) { if (kw1_data[active_index] < kw2_data[active_index]) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } } else { if (kw1_data[active_index] >= kw2_data[active_index]) { - int global_index = ecl_grid_get_global_index1A( + int global_index = rd_grid_get_global_index1A( region->parent_grid, active_index); region->active_mask[global_index] = select; } @@ -604,31 +596,27 @@ static void ecl_region_cmp_select__(ecl_region_type *region, } else util_abort("%s: type/size mismatch between keywords. \n", __func__); } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_cmp_select_less(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2) { - ecl_region_cmp_select__(ecl_region, kw1, kw2, true, true); +void rd_region_cmp_select_less(rd_region_type *rd_region, const rd_kw_type *kw1, + const rd_kw_type *kw2) { + rd_region_cmp_select__(rd_region, kw1, kw2, true, true); } -void ecl_region_cmp_deselect_less(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2) { - ecl_region_cmp_select__(ecl_region, kw1, kw2, true, false); +void rd_region_cmp_deselect_less(rd_region_type *rd_region, + const rd_kw_type *kw1, const rd_kw_type *kw2) { + rd_region_cmp_select__(rd_region, kw1, kw2, true, false); } -void ecl_region_cmp_select_more(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2) { - ecl_region_cmp_select__(ecl_region, kw1, kw2, false, true); +void rd_region_cmp_select_more(rd_region_type *rd_region, const rd_kw_type *kw1, + const rd_kw_type *kw2) { + rd_region_cmp_select__(rd_region, kw1, kw2, false, true); } -void ecl_region_cmp_deselect_more(ecl_region_type *ecl_region, - const ecl_kw_type *kw1, - const ecl_kw_type *kw2) { - ecl_region_cmp_select__(ecl_region, kw1, kw2, false, false); +void rd_region_cmp_deselect_more(rd_region_type *rd_region, + const rd_kw_type *kw1, const rd_kw_type *kw2) { + rd_region_cmp_select__(rd_region, kw1, kw2, false, false); } /** @@ -638,13 +626,12 @@ void ecl_region_cmp_deselect_more(ecl_region_type *ecl_region, input and create a temporary box object. */ -static void ecl_region_select_from_box__(ecl_region_type *region, - const ecl::ecl_box &ecl_box, - bool select) { - for (auto global_index : ecl_box.active_list()) +static void rd_region_select_from_box__(rd_region_type *region, + const rd::rd_box &rd_box, bool select) { + for (auto global_index : rd_box.active_list()) region->active_mask[global_index] = select; - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } /** @@ -653,24 +640,24 @@ static void ecl_region_select_from_box__(ecl_region_type *region, 1. All the indices are inclusive. 2. All the indices have zero offset. - Only a thin wrapper around the ecl_region_select_from_box() function. + Only a thin wrapper around the rd_region_select_from_box() function. */ -static void ecl_region_select_from_ijkbox__(ecl_region_type *region, int i1, - int i2, int j1, int j2, int k1, - int k2, bool select) { - ecl::ecl_box tmp_box(region->parent_grid, i1, i2, j1, j2, k1, k2); - ecl_region_select_from_box__(region, tmp_box, select); +static void rd_region_select_from_ijkbox__(rd_region_type *region, int i1, + int i2, int j1, int j2, int k1, + int k2, bool select) { + rd::rd_box tmp_box(region->parent_grid, i1, i2, j1, j2, k1, k2); + rd_region_select_from_box__(region, tmp_box, select); } -void ecl_region_select_from_ijkbox(ecl_region_type *region, int i1, int i2, - int j1, int j2, int k1, int k2) { - ecl_region_select_from_ijkbox__(region, i1, i2, j1, j2, k1, k2, true); +void rd_region_select_from_ijkbox(rd_region_type *region, int i1, int i2, + int j1, int j2, int k1, int k2) { + rd_region_select_from_ijkbox__(region, i1, i2, j1, j2, k1, k2, true); } -void ecl_region_deselect_from_ijkbox(ecl_region_type *region, int i1, int i2, - int j1, int j2, int k1, int k2) { - ecl_region_select_from_ijkbox__(region, i1, i2, j1, j2, k1, k2, false); +void rd_region_deselect_from_ijkbox(rd_region_type *region, int i1, int i2, + int j1, int j2, int k1, int k2) { + rd_region_select_from_ijkbox__(region, i1, i2, j1, j2, k1, k2, false); } /** @@ -682,8 +669,8 @@ void ecl_region_deselect_from_ijkbox(ecl_region_type *region, int i1, int i2, Input values below zero or above the upper limit are truncated. */ -static void ecl_region_select_i1i2__(ecl_region_type *region, int i1, int i2, - bool select) { +static void rd_region_select_i1i2__(rd_region_type *region, int i1, int i2, + bool select) { if (i1 > i2) util_abort("%s: i1 > i2 - this is illogical ... \n", __func__); i1 = util_int_max(0, i1); @@ -693,20 +680,20 @@ static void ecl_region_select_i1i2__(ecl_region_type *region, int i1, int i2, for (k = 0; k < region->grid_nz; k++) for (j = 0; j < region->grid_ny; j++) for (i = i1; i <= i2; i++) { - int global_index = ecl_grid_get_global_index3( - region->parent_grid, i, j, k); + int global_index = + rd_grid_get_global_index3(region->parent_grid, i, j, k); region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_i1i2(ecl_region_type *region, int i1, int i2) { - ecl_region_select_i1i2__(region, i1, i2, true); +void rd_region_select_i1i2(rd_region_type *region, int i1, int i2) { + rd_region_select_i1i2__(region, i1, i2, true); } -void ecl_region_deselect_i1i2(ecl_region_type *region, int i1, int i2) { - ecl_region_select_i1i2__(region, i1, i2, false); +void rd_region_deselect_i1i2(rd_region_type *region, int i1, int i2) { + rd_region_select_i1i2__(region, i1, i2, false); } /** @@ -718,8 +705,8 @@ void ecl_region_deselect_i1i2(ecl_region_type *region, int i1, int i2) { Input values below zero or above the upper limit are truncated. */ -static void ecl_region_select_j1j2__(ecl_region_type *region, int j1, int j2, - bool select) { +static void rd_region_select_j1j2__(rd_region_type *region, int j1, int j2, + bool select) { if (j1 > j2) util_abort("%s: i1 > i2 - this is illogical ... \n", __func__); @@ -730,20 +717,20 @@ static void ecl_region_select_j1j2__(ecl_region_type *region, int j1, int j2, for (k = 0; k < region->grid_nz; k++) for (j = j1; j <= j2; j++) for (i = 0; i < region->grid_nx; i++) { - int global_index = ecl_grid_get_global_index3( - region->parent_grid, i, j, k); + int global_index = + rd_grid_get_global_index3(region->parent_grid, i, j, k); region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_j1j2(ecl_region_type *region, int j1, int j2) { - ecl_region_select_j1j2__(region, j1, j2, true); +void rd_region_select_j1j2(rd_region_type *region, int j1, int j2) { + rd_region_select_j1j2__(region, j1, j2, true); } -void ecl_region_deselect_j1j2(ecl_region_type *region, int j1, int j2) { - ecl_region_select_j1j2__(region, j1, j2, false); +void rd_region_deselect_j1j2(rd_region_type *region, int j1, int j2) { + rd_region_select_j1j2__(region, j1, j2, false); } /** @@ -755,8 +742,8 @@ void ecl_region_deselect_j1j2(ecl_region_type *region, int j1, int j2) { Input values below zero or above the upper limit are truncated. */ -static void ecl_region_select_k1k2__(ecl_region_type *region, int k1, int k2, - bool select) { +static void rd_region_select_k1k2__(rd_region_type *region, int k1, int k2, + bool select) { if (k1 > k2) util_abort("%s: i1 > i2 - this is illogical ... \n", __func__); k1 = util_int_max(0, k1); @@ -766,20 +753,20 @@ static void ecl_region_select_k1k2__(ecl_region_type *region, int k1, int k2, for (k = k1; k <= k2; k++) for (j = 0; j < region->grid_ny; j++) for (i = 0; i < region->grid_nx; i++) { - int global_index = ecl_grid_get_global_index3( - region->parent_grid, i, j, k); + int global_index = + rd_grid_get_global_index3(region->parent_grid, i, j, k); region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_k1k2(ecl_region_type *region, int k1, int k2) { - ecl_region_select_k1k2__(region, k1, k2, true); +void rd_region_select_k1k2(rd_region_type *region, int k1, int k2) { + rd_region_select_k1k2__(region, k1, k2, true); } -void ecl_region_deselect_k1k2(ecl_region_type *region, int k1, int k2) { - ecl_region_select_k1k2__(region, k1, k2, false); +void rd_region_deselect_k1k2(rd_region_type *region, int k1, int k2) { + rd_region_select_k1k2__(region, k1, k2, false); } /** @@ -788,13 +775,13 @@ void ecl_region_deselect_k1k2(ecl_region_type *region, int k1, int k2) { determined by the depth of the center of a cell. */ -static void ecl_region_select_from_depth__(ecl_region_type *region, - double depth_limit, bool select_deep, - bool select) { +static void rd_region_select_from_depth__(rd_region_type *region, + double depth_limit, bool select_deep, + bool select) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) { double cell_depth = - ecl_grid_get_cdepth1(region->parent_grid, global_index); + rd_grid_get_cdepth1(region->parent_grid, global_index); if (select_deep) { // The select/deselect mechanism should be applied to deep cells. if (cell_depth >= depth_limit) @@ -805,35 +792,34 @@ static void ecl_region_select_from_depth__(ecl_region_type *region, region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_shallow_cells(ecl_region_type *region, - double depth_limit) { - ecl_region_select_from_depth__(region, depth_limit, false, true); +void rd_region_select_shallow_cells(rd_region_type *region, + double depth_limit) { + rd_region_select_from_depth__(region, depth_limit, false, true); } -void ecl_region_deselect_shallow_cells(ecl_region_type *region, - double depth_limit) { - ecl_region_select_from_depth__(region, depth_limit, false, false); +void rd_region_deselect_shallow_cells(rd_region_type *region, + double depth_limit) { + rd_region_select_from_depth__(region, depth_limit, false, false); } -void ecl_region_select_deep_cells(ecl_region_type *region, double depth_limit) { - ecl_region_select_from_depth__(region, depth_limit, true, true); +void rd_region_select_deep_cells(rd_region_type *region, double depth_limit) { + rd_region_select_from_depth__(region, depth_limit, true, true); } -void ecl_region_deselect_deep_cells(ecl_region_type *region, - double depth_limit) { - ecl_region_select_from_depth__(region, depth_limit, true, false); +void rd_region_deselect_deep_cells(rd_region_type *region, double depth_limit) { + rd_region_select_from_depth__(region, depth_limit, true, false); } -static void ecl_region_select_from_volume__(ecl_region_type *region, - double volum_limit, - bool select_small, bool select) { +static void rd_region_select_from_volume__(rd_region_type *region, + double volum_limit, + bool select_small, bool select) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) { double cell_size = - ecl_grid_get_cell_volume1(region->parent_grid, global_index); + rd_grid_get_cell_volume1(region->parent_grid, global_index); if (select_small) { // The select/deselect mechanism should be applied to small cells. if (cell_size <= volum_limit) @@ -844,36 +830,35 @@ static void ecl_region_select_from_volume__(ecl_region_type *region, region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_small_cells(ecl_region_type *ecl_region, - double volum_limit) { - ecl_region_select_from_volume__(ecl_region, volum_limit, true, true); +void rd_region_select_small_cells(rd_region_type *rd_region, + double volum_limit) { + rd_region_select_from_volume__(rd_region, volum_limit, true, true); } -void ecl_region_deselect_small_cells(ecl_region_type *ecl_region, - double volum_limit) { - ecl_region_select_from_volume__(ecl_region, volum_limit, true, false); +void rd_region_deselect_small_cells(rd_region_type *rd_region, + double volum_limit) { + rd_region_select_from_volume__(rd_region, volum_limit, true, false); } -void ecl_region_select_large_cells(ecl_region_type *ecl_region, - double volum_limit) { - ecl_region_select_from_volume__(ecl_region, volum_limit, false, true); +void rd_region_select_large_cells(rd_region_type *rd_region, + double volum_limit) { + rd_region_select_from_volume__(rd_region, volum_limit, false, true); } -void ecl_region_deselect_large_cells(ecl_region_type *ecl_region, - double volum_limit) { - ecl_region_select_from_volume__(ecl_region, volum_limit, false, false); +void rd_region_deselect_large_cells(rd_region_type *rd_region, + double volum_limit) { + rd_region_select_from_volume__(rd_region, volum_limit, false, false); } -static void ecl_region_select_from_dz__(ecl_region_type *region, - double dz_limit, bool select_thin, - bool select) { +static void rd_region_select_from_dz__(rd_region_type *region, double dz_limit, + bool select_thin, bool select) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) { double cell_dz = - ecl_grid_get_cell_thickness1(region->parent_grid, global_index); + rd_grid_get_cell_thickness1(region->parent_grid, global_index); if (select_thin) { // The select/deselect mechanism should be applied to thin cells. if (cell_dz <= dz_limit) @@ -884,84 +869,79 @@ static void ecl_region_select_from_dz__(ecl_region_type *region, region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_thin_cells(ecl_region_type *ecl_region, - double dz_limit) { - ecl_region_select_from_dz__(ecl_region, dz_limit, true, true); +void rd_region_select_thin_cells(rd_region_type *rd_region, double dz_limit) { + rd_region_select_from_dz__(rd_region, dz_limit, true, true); } -void ecl_region_deselect_thin_cells(ecl_region_type *ecl_region, - double dz_limit) { - ecl_region_select_from_dz__(ecl_region, dz_limit, true, false); +void rd_region_deselect_thin_cells(rd_region_type *rd_region, double dz_limit) { + rd_region_select_from_dz__(rd_region, dz_limit, true, false); } -void ecl_region_select_thick_cells(ecl_region_type *ecl_region, - double dz_limit) { - ecl_region_select_from_dz__(ecl_region, dz_limit, false, true); +void rd_region_select_thick_cells(rd_region_type *rd_region, double dz_limit) { + rd_region_select_from_dz__(rd_region, dz_limit, false, true); } -void ecl_region_deselect_thick_cells(ecl_region_type *ecl_region, - double dz_limit) { - ecl_region_select_from_dz__(ecl_region, dz_limit, false, false); +void rd_region_deselect_thick_cells(rd_region_type *rd_region, + double dz_limit) { + rd_region_select_from_dz__(rd_region, dz_limit, false, false); } -static void ecl_region_select_active_cells__(ecl_region_type *ecl_region, - bool select_active, bool select) { +static void rd_region_select_active_cells__(rd_region_type *rd_region, + bool select_active, bool select) { int global_index; - for (global_index = 0; global_index < ecl_region->grid_vol; - global_index++) { + for (global_index = 0; global_index < rd_region->grid_vol; global_index++) { if (select_active) { - if (ecl_grid_get_active_index1(ecl_region->parent_grid, - global_index) >= 0) - ecl_region->active_mask[global_index] = select; + if (rd_grid_get_active_index1(rd_region->parent_grid, + global_index) >= 0) + rd_region->active_mask[global_index] = select; } else { - if (ecl_grid_get_active_index1(ecl_region->parent_grid, - global_index) < 0) - ecl_region->active_mask[global_index] = select; + if (rd_grid_get_active_index1(rd_region->parent_grid, + global_index) < 0) + rd_region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(ecl_region); + rd_region_invalidate_index_list(rd_region); } -void ecl_region_select_active_cells(ecl_region_type *region) { - ecl_region_select_active_cells__(region, true, true); +void rd_region_select_active_cells(rd_region_type *region) { + rd_region_select_active_cells__(region, true, true); } -void ecl_region_deselect_active_cells(ecl_region_type *region) { - ecl_region_select_active_cells__(region, true, false); +void rd_region_deselect_active_cells(rd_region_type *region) { + rd_region_select_active_cells__(region, true, false); } -void ecl_region_select_inactive_cells(ecl_region_type *region) { - ecl_region_select_active_cells__(region, false, true); +void rd_region_select_inactive_cells(rd_region_type *region) { + rd_region_select_active_cells__(region, false, true); } -void ecl_region_deselect_inactive_cells(ecl_region_type *region) { - ecl_region_select_active_cells__(region, false, false); +void rd_region_deselect_inactive_cells(rd_region_type *region) { + rd_region_select_active_cells__(region, false, false); } /** This function will select a cell based on global_index. */ -static void ecl_region_select_global_index__(ecl_region_type *region, - int global_index, bool select) { +static void rd_region_select_global_index__(rd_region_type *region, + int global_index, bool select) { if ((global_index >= 0) && (global_index < region->grid_vol)) region->active_mask[global_index] = select; else util_abort("%s: global_index:%d invalid - legal interval: [0,%d) \n", __func__, global_index, region->grid_vol); - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_global_index(ecl_region_type *region, int global_index) { - ecl_region_select_global_index__(region, global_index, true); +void rd_region_select_global_index(rd_region_type *region, int global_index) { + rd_region_select_global_index__(region, global_index, true); } -void ecl_region_deselect_global_index(ecl_region_type *region, - int global_index) { - ecl_region_select_global_index__(region, global_index, false); +void rd_region_deselect_global_index(rd_region_type *region, int global_index) { + rd_region_select_global_index__(region, global_index, false); } /** @@ -973,13 +953,13 @@ void ecl_region_deselect_global_index(ecl_region_type *region, cylinder piercing the complete reservoir. Currently all user-exported functions call the - ecl_region_clyinder_select__() with select_inside == true. + rd_region_clyinder_select__() with select_inside == true. */ -static void ecl_region_cylinder_select__(ecl_region_type *region, double x0, - double y0, double R, double z1, - double z2, bool select_inside, - bool select) { +static void rd_region_cylinder_select__(rd_region_type *region, double x0, + double y0, double R, double z1, + double z2, bool select_inside, + bool select) { double R2 = R * R; if (z1 < z2) { @@ -987,7 +967,7 @@ static void ecl_region_cylinder_select__(ecl_region_type *region, double x0, for (global_index = 0; global_index < region->grid_vol; global_index++) { double x, y, z; - ecl_grid_get_xyz1(region->parent_grid, global_index, &x, &y, &z); + rd_grid_get_xyz1(region->parent_grid, global_index, &x, &y, &z); if ((z >= z1) && (z <= z2)) { double pointR2 = (x - x0) * (x - x0) + (y - y0) * (y - y0); if ((pointR2 < R2) && (select_inside)) @@ -1004,7 +984,7 @@ static void ecl_region_cylinder_select__(ecl_region_type *region, double x0, for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { double x, y, z; - ecl_grid_get_xyz3(region->parent_grid, i, j, 0, &x, &y, &z); + rd_grid_get_xyz3(region->parent_grid, i, j, 0, &x, &y, &z); { double pointR2 = (x - x0) * (x - x0) + (y - y0) * (y - y0); bool select_column = false; @@ -1017,7 +997,7 @@ static void ecl_region_cylinder_select__(ecl_region_type *region, double x0, if (select_column) { int k; for (k = 0; k < nz; k++) { - int global_index = ecl_grid_get_global_index3( + int global_index = rd_grid_get_global_index3( region->parent_grid, i, j, k); region->active_mask[global_index] = select; } @@ -1026,30 +1006,30 @@ static void ecl_region_cylinder_select__(ecl_region_type *region, double x0, } } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_in_cylinder(ecl_region_type *region, double x0, - double y0, double R) { - ecl_region_cylinder_select__(region, x0, y0, R, 1, 0, true, true); +void rd_region_select_in_cylinder(rd_region_type *region, double x0, double y0, + double R) { + rd_region_cylinder_select__(region, x0, y0, R, 1, 0, true, true); } -void ecl_region_deselect_in_cylinder(ecl_region_type *region, double x0, - double y0, double R) { - ecl_region_cylinder_select__(region, x0, y0, R, 1, 0, true, false); +void rd_region_deselect_in_cylinder(rd_region_type *region, double x0, + double y0, double R) { + rd_region_cylinder_select__(region, x0, y0, R, 1, 0, true, false); } -void ecl_region_select_in_zcylinder(ecl_region_type *region, double x0, - double y0, double R, double z1, double z2) { - ecl_region_cylinder_select__(region, x0, y0, R, util_double_min(z1, z2), - util_double_max(z1, z2), true, true); +void rd_region_select_in_zcylinder(rd_region_type *region, double x0, double y0, + double R, double z1, double z2) { + rd_region_cylinder_select__(region, x0, y0, R, util_double_min(z1, z2), + util_double_max(z1, z2), true, true); } -void ecl_region_deselect_in_zcylinder(ecl_region_type *region, double x0, - double y0, double R, double z1, - double z2) { - ecl_region_cylinder_select__(region, x0, y0, R, util_double_min(z1, z2), - util_double_max(z1, z2), true, false); +void rd_region_deselect_in_zcylinder(rd_region_type *region, double x0, + double y0, double R, double z1, + double z2) { + rd_region_cylinder_select__(region, x0, y0, R, util_double_min(z1, z2), + util_double_max(z1, z2), true, false); } /** @@ -1057,9 +1037,9 @@ void ecl_region_deselect_in_zcylinder(ecl_region_type *region, double x0, specified by normal vector @n and point @p. */ -static void ecl_region_plane_select__(ecl_region_type *region, - const double n[3], const double p[3], - bool select_above, bool select) { +static void rd_region_plane_select__(rd_region_type *region, const double n[3], + const double p[3], bool select_above, + bool select) { const double a = n[0]; const double b = n[1]; const double c = -n[2]; @@ -1073,7 +1053,7 @@ static void ecl_region_plane_select__(ecl_region_type *region, global_index++) { double x, y, z; double D; - ecl_grid_get_xyz1(region->parent_grid, global_index, &x, &y, &z); + rd_grid_get_xyz1(region->parent_grid, global_index, &x, &y, &z); D = a * x + b * y + c * z + d; if ((D >= 0) && (select_above)) region->active_mask[global_index] = select; @@ -1081,27 +1061,27 @@ static void ecl_region_plane_select__(ecl_region_type *region, region->active_mask[global_index] = select; } } - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_above_plane(ecl_region_type *region, const double n[3], - const double p[3]) { - ecl_region_plane_select__(region, n, p, true, true); +void rd_region_select_above_plane(rd_region_type *region, const double n[3], + const double p[3]) { + rd_region_plane_select__(region, n, p, true, true); } -void ecl_region_select_below_plane(ecl_region_type *region, const double n[3], - const double p[3]) { - ecl_region_plane_select__(region, n, p, false, true); +void rd_region_select_below_plane(rd_region_type *region, const double n[3], + const double p[3]) { + rd_region_plane_select__(region, n, p, false, true); } -void ecl_region_deselect_above_plane(ecl_region_type *region, const double n[3], - const double p[3]) { - ecl_region_plane_select__(region, n, p, true, false); +void rd_region_deselect_above_plane(rd_region_type *region, const double n[3], + const double p[3]) { + rd_region_plane_select__(region, n, p, true, false); } -void ecl_region_deselect_below_plane(ecl_region_type *region, const double n[3], - const double p[3]) { - ecl_region_plane_select__(region, n, p, false, false); +void rd_region_deselect_below_plane(rd_region_type *region, const double n[3], + const double p[3]) { + rd_region_plane_select__(region, n, p, false, false); } /** @@ -1123,9 +1103,9 @@ void ecl_region_deselect_below_plane(ecl_region_type *region, const double n[3], effectively change in size. */ -static void ecl_region_polygon_select__(ecl_region_type *region, - const geo_polygon_type *polygon, - bool select_inside, bool select) { +static void rd_region_polygon_select__(rd_region_type *region, + const geo_polygon_type *polygon, + bool select_inside, bool select) { const int define_k = 0; // The k-level where the polygon is checked. const int k1 = 0; // Selection range in k @@ -1137,17 +1117,16 @@ static void ecl_region_polygon_select__(ecl_region_type *region, for (j = 0; j < region->grid_ny; j++) { double x, y, z; bool inside; - int global_index = ecl_grid_get_global_index3( + int global_index = rd_grid_get_global_index3( region->parent_grid, i, j, define_k); - ecl_grid_get_xyz1(region->parent_grid, global_index, &x, &y, - &z); + rd_grid_get_xyz1(region->parent_grid, global_index, &x, &y, &z); inside = geo_polygon_contains_point(polygon, x, y); if (select_inside == inside) { int k; for (k = k1; k < k2; k++) { - global_index = ecl_grid_get_global_index3( + global_index = rd_grid_get_global_index3( region->parent_grid, i, j, k); region->active_mask[global_index] = select; } @@ -1157,54 +1136,53 @@ static void ecl_region_polygon_select__(ecl_region_type *region, } } -void ecl_region_select_inside_polygon(ecl_region_type *region, - const geo_polygon_type *polygon) { - ecl_region_polygon_select__(region, polygon, true, true); +void rd_region_select_inside_polygon(rd_region_type *region, + const geo_polygon_type *polygon) { + rd_region_polygon_select__(region, polygon, true, true); } -void ecl_region_deselect_inside_polygon(ecl_region_type *region, - const geo_polygon_type *polygon) { - ecl_region_polygon_select__(region, polygon, true, false); +void rd_region_deselect_inside_polygon(rd_region_type *region, + const geo_polygon_type *polygon) { + rd_region_polygon_select__(region, polygon, true, false); } -void ecl_region_select_outside_polygon(ecl_region_type *region, - const geo_polygon_type *polygon) { - ecl_region_polygon_select__(region, polygon, false, true); +void rd_region_select_outside_polygon(rd_region_type *region, + const geo_polygon_type *polygon) { + rd_region_polygon_select__(region, polygon, false, true); } -void ecl_region_deselect_outside_polygon(ecl_region_type *region, - const geo_polygon_type *polygon) { - ecl_region_polygon_select__(region, polygon, false, false); +void rd_region_deselect_outside_polygon(rd_region_type *region, + const geo_polygon_type *polygon) { + rd_region_polygon_select__(region, polygon, false, false); } /** This function will select a cell based on active_index. */ -static void ecl_region_select_active_index__(ecl_region_type *region, - int active_index, bool select) { +static void rd_region_select_active_index__(rd_region_type *region, + int active_index, bool select) { if ((active_index >= 0) && (active_index < region->grid_active)) { int global_index = - ecl_grid_get_global_index1A(region->parent_grid, active_index); + rd_grid_get_global_index1A(region->parent_grid, active_index); region->active_mask[global_index] = select; } else util_abort("%s: active_index:%d invalid - legal interval: [0,%d) \n", __func__, active_index, region->grid_vol); - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_active_index(ecl_region_type *region, int active_index) { - ecl_region_select_active_index__(region, active_index, true); +void rd_region_select_active_index(rd_region_type *region, int active_index) { + rd_region_select_active_index__(region, active_index, true); } -void ecl_region_deselect_active_index(ecl_region_type *region, - int active_index) { - ecl_region_select_active_index__(region, active_index, false); +void rd_region_deselect_active_index(rd_region_type *region, int active_index) { + rd_region_select_active_index__(region, active_index, false); } -static void ecl_region_select_from_layer__(ecl_region_type *region, - const layer_type *layer, int k, - int layer_value, bool select) { +static void rd_region_select_from_layer__(rd_region_type *region, + const layer_type *layer, int k, + int layer_value, bool select) { int_vector_type *i_list = int_vector_alloc(0, 0); int_vector_type *j_list = int_vector_alloc(0, 0); @@ -1215,50 +1193,50 @@ static void ecl_region_select_from_layer__(ecl_region_type *region, int index; for (index = 0; index < int_vector_size(i_list); index++) { - int global_index = ecl_grid_get_global_index3( - region->parent_grid, i[index], j[index], k); + int global_index = rd_grid_get_global_index3(region->parent_grid, + i[index], j[index], k); region->active_mask[global_index] = select; } } if (int_vector_size(i_list) > 0) - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); int_vector_free(i_list); int_vector_free(j_list); } -void ecl_region_select_from_layer(ecl_region_type *region, - const layer_type *layer, int k, - int layer_value) { - ecl_region_select_from_layer__(region, layer, k, layer_value, true); +void rd_region_select_from_layer(rd_region_type *region, + const layer_type *layer, int k, + int layer_value) { + rd_region_select_from_layer__(region, layer, k, layer_value, true); } -void ecl_region_deselect_from_layer(ecl_region_type *region, - const layer_type *layer, int k, - int layer_value) { - ecl_region_select_from_layer__(region, layer, k, layer_value, false); +void rd_region_deselect_from_layer(rd_region_type *region, + const layer_type *layer, int k, + int layer_value) { + rd_region_select_from_layer__(region, layer, k, layer_value, false); } -static void ecl_region_select_all__(ecl_region_type *region, bool select) { +static void rd_region_select_all__(rd_region_type *region, bool select) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] = select; - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } -void ecl_region_select_all(ecl_region_type *region) { - ecl_region_select_all__(region, true); +void rd_region_select_all(rd_region_type *region) { + rd_region_select_all__(region, true); } -void ecl_region_deselect_all(ecl_region_type *region) { - ecl_region_select_all__(region, false); +void rd_region_deselect_all(rd_region_type *region) { + rd_region_select_all__(region, false); } -void ecl_region_invert_selection(ecl_region_type *region) { +void rd_region_invert_selection(rd_region_type *region) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] = !region->active_mask[global_index]; - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } /** @@ -1268,23 +1246,23 @@ void ecl_region_invert_selection(ecl_region_type *region) { ijk have zero offset. */ -bool ecl_region_contains_ijk(const ecl_region_type *ecl_region, int i, int j, - int k) { +bool rd_region_contains_ijk(const rd_region_type *rd_region, int i, int j, + int k) { int global_index = - ecl_grid_get_global_index3(ecl_region->parent_grid, i, j, k); - return ecl_region->active_mask[global_index]; + rd_grid_get_global_index3(rd_region->parent_grid, i, j, k); + return rd_region->active_mask[global_index]; } -bool ecl_region_contains_global(const ecl_region_type *ecl_region, - int global_index) { - return ecl_region->active_mask[global_index]; +bool rd_region_contains_global(const rd_region_type *rd_region, + int global_index) { + return rd_region->active_mask[global_index]; } -bool ecl_region_contains_active(const ecl_region_type *ecl_region, - int active_index) { +bool rd_region_contains_active(const rd_region_type *rd_region, + int active_index) { int global_index = - ecl_grid_get_global_index1A(ecl_region->parent_grid, active_index); - return ecl_region->active_mask[global_index]; + rd_grid_get_global_index1A(rd_region->parent_grid, active_index); + return rd_region->active_mask[global_index]; } /** @@ -1296,8 +1274,8 @@ bool ecl_region_contains_active(const ecl_region_type *ecl_region, A &= B */ -void ecl_region_intersection(ecl_region_type *region, - const ecl_region_type *new_region) { +void rd_region_intersection(rd_region_type *region, + const rd_region_type *new_region) { if (region->parent_grid == new_region->parent_grid) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) @@ -1305,7 +1283,7 @@ void ecl_region_intersection(ecl_region_type *region, (region->active_mask[global_index] && new_region->active_mask[global_index]); - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } else util_abort("%s: The two regions do not share grid - aborting \n", __func__); @@ -1317,8 +1295,7 @@ void ecl_region_intersection(ecl_region_type *region, A |= B */ -void ecl_region_union(ecl_region_type *region, - const ecl_region_type *new_region) { +void rd_region_union(rd_region_type *region, const rd_region_type *new_region) { if (region->parent_grid == new_region->parent_grid) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) @@ -1326,7 +1303,7 @@ void ecl_region_union(ecl_region_type *region, (region->active_mask[global_index] || new_region->active_mask[global_index]); - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } else util_abort("%s: The two regions do not share grid - aborting \n", __func__); @@ -1338,15 +1315,15 @@ void ecl_region_union(ecl_region_type *region, A &= !B */ -void ecl_region_subtract(ecl_region_type *region, - const ecl_region_type *new_region) { +void rd_region_subtract(rd_region_type *region, + const rd_region_type *new_region) { if (region->parent_grid == new_region->parent_grid) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] &= !new_region->active_mask[global_index]; - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } else util_abort("%s: The two regions do not share grid - aborting \n", __func__); @@ -1358,35 +1335,34 @@ void ecl_region_subtract(ecl_region_type *region, A ^= B */ -void ecl_region_xor(ecl_region_type *region, - const ecl_region_type *new_region) { +void rd_region_xor(rd_region_type *region, const rd_region_type *new_region) { if (region->parent_grid == new_region->parent_grid) { int global_index; for (global_index = 0; global_index < region->grid_vol; global_index++) region->active_mask[global_index] ^= !new_region->active_mask[global_index]; - ecl_region_invalidate_index_list(region); + rd_region_invalidate_index_list(region); } else util_abort("%s: The two regions do not share grid - aborting \n", __func__); } -const int_vector_type *ecl_region_get_kw_index_list(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, - bool force_active) { +const int_vector_type *rd_region_get_kw_index_list(rd_region_type *rd_region, + const rd_kw_type *rd_kw, + bool force_active) { const int_vector_type *index_set = NULL; - int kw_size = ecl_kw_get_size(ecl_kw); - int grid_active = ecl_grid_get_active_size(ecl_region->parent_grid); - int grid_global = ecl_grid_get_global_size(ecl_region->parent_grid); + int kw_size = rd_kw_get_size(rd_kw); + int grid_active = rd_grid_get_active_size(rd_region->parent_grid); + int grid_global = rd_grid_get_global_size(rd_region->parent_grid); if (kw_size == grid_active) - index_set = ecl_region_get_active_list(ecl_region); + index_set = rd_region_get_active_list(rd_region); else if (kw_size == grid_global) { if (force_active) - index_set = ecl_region_get_global_active_list(ecl_region); + index_set = rd_region_get_global_active_list(rd_region); else - index_set = ecl_region_get_global_list(ecl_region); + index_set = rd_region_get_global_list(rd_region); } else util_abort( "%s: size mismatch: grid_active:%d grid_global:%d kw_size:%d \n", @@ -1395,116 +1371,114 @@ const int_vector_type *ecl_region_get_kw_index_list(ecl_region_type *ecl_region, return index_set; } -void ecl_region_set_kw_int(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - int value, bool force_active) { +void rd_region_set_kw_int(rd_region_type *rd_region, rd_kw_type *rd_kw, + int value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_set_indexed_int(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_set_indexed_int(rd_kw, index_set, value); } -void ecl_region_set_kw_float(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - float value, bool force_active) { +void rd_region_set_kw_float(rd_region_type *rd_region, rd_kw_type *rd_kw, + float value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_set_indexed_float(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_set_indexed_float(rd_kw, index_set, value); } -void ecl_region_set_kw_double(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - double value, bool force_active) { +void rd_region_set_kw_double(rd_region_type *rd_region, rd_kw_type *rd_kw, + double value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_set_indexed_double(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_set_indexed_double(rd_kw, index_set, value); } -void ecl_region_shift_kw_int(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - int value, bool force_active) { +void rd_region_shift_kw_int(rd_region_type *rd_region, rd_kw_type *rd_kw, + int value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_shift_indexed_int(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_shift_indexed_int(rd_kw, index_set, value); } -void ecl_region_shift_kw_float(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - float value, bool force_active) { +void rd_region_shift_kw_float(rd_region_type *rd_region, rd_kw_type *rd_kw, + float value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_shift_indexed_float(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_shift_indexed_float(rd_kw, index_set, value); } -void ecl_region_shift_kw_double(ecl_region_type *ecl_region, - ecl_kw_type *ecl_kw, double value, - bool force_active) { +void rd_region_shift_kw_double(rd_region_type *rd_region, rd_kw_type *rd_kw, + double value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_shift_indexed_double(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_shift_indexed_double(rd_kw, index_set, value); } -void ecl_region_scale_kw_int(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - int value, bool force_active) { +void rd_region_scale_kw_int(rd_region_type *rd_region, rd_kw_type *rd_kw, + int value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_scale_indexed_int(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_scale_indexed_int(rd_kw, index_set, value); } -void ecl_region_scale_kw_float(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - float value, bool force_active) { +void rd_region_scale_kw_float(rd_region_type *rd_region, rd_kw_type *rd_kw, + float value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_scale_indexed_float(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_scale_indexed_float(rd_kw, index_set, value); } -void ecl_region_scale_kw_double(ecl_region_type *ecl_region, - ecl_kw_type *ecl_kw, double value, - bool force_active) { +void rd_region_scale_kw_double(rd_region_type *rd_region, rd_kw_type *rd_kw, + double value, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_scale_indexed_double(ecl_kw, index_set, value); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_scale_indexed_double(rd_kw, index_set, value); } -void ecl_region_kw_iadd(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *delta_kw, bool force_active) { +void rd_region_kw_iadd(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *delta_kw, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_inplace_add_indexed(ecl_kw, index_set, delta_kw); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_inplace_add_indexed(rd_kw, index_set, delta_kw); } -void ecl_region_kw_idiv(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *div_kw, bool force_active) { +void rd_region_kw_idiv(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *div_kw, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_inplace_div_indexed(ecl_kw, index_set, div_kw); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_inplace_div_indexed(rd_kw, index_set, div_kw); } -void ecl_region_kw_imul(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *mul_kw, bool force_active) { +void rd_region_kw_imul(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *mul_kw, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_inplace_mul_indexed(ecl_kw, index_set, mul_kw); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_inplace_mul_indexed(rd_kw, index_set, mul_kw); } -void ecl_region_kw_isub(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *delta_kw, bool force_active) { +void rd_region_kw_isub(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *delta_kw, bool force_active) { const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_inplace_sub_indexed(ecl_kw, index_set, delta_kw); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_inplace_sub_indexed(rd_kw, index_set, delta_kw); } -void ecl_region_kw_copy(ecl_region_type *ecl_region, ecl_kw_type *ecl_kw, - const ecl_kw_type *src_kw, bool force_active) { +void rd_region_kw_copy(rd_region_type *rd_region, rd_kw_type *rd_kw, + const rd_kw_type *src_kw, bool force_active) { const int_vector_type *target_index = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_copy_indexed(ecl_kw, target_index, src_kw); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_copy_indexed(rd_kw, target_index, src_kw); } -void ecl_region_set_name(ecl_region_type *region, const char *name) { +void rd_region_set_name(rd_region_type *region, const char *name) { region->name = util_realloc_string_copy(region->name, name); } -const char *ecl_region_get_name(const ecl_region_type *region) { +const char *rd_region_get_name(const rd_region_type *region) { return region->name; } -bool ecl_region_equal(const ecl_region_type *region1, - const ecl_region_type *region2) { +bool rd_region_equal(const rd_region_type *region1, + const rd_region_type *region2) { if (region1->parent_grid == region2 ->parent_grid) { // Must be exactly the same grid instance to compare as equal. @@ -1517,38 +1491,38 @@ bool ecl_region_equal(const ecl_region_type *region1, return false; } -int ecl_region_sum_kw_int(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active) { +int rd_region_sum_kw_int(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active) { int sum; const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_element_sum_indexed(ecl_kw, index_set, &sum); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_element_sum_indexed(rd_kw, index_set, &sum); return sum; } -float ecl_region_sum_kw_float(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active) { +float rd_region_sum_kw_float(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active) { float sum; const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_element_sum_indexed(ecl_kw, index_set, &sum); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_element_sum_indexed(rd_kw, index_set, &sum); return sum; } -double ecl_region_sum_kw_double(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active) { +double rd_region_sum_kw_double(rd_region_type *rd_region, + const rd_kw_type *rd_kw, bool force_active) { double sum; const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_element_sum_indexed(ecl_kw, index_set, &sum); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_element_sum_indexed(rd_kw, index_set, &sum); return sum; } -int ecl_region_sum_kw_bool(ecl_region_type *ecl_region, - const ecl_kw_type *ecl_kw, bool force_active) { +int rd_region_sum_kw_bool(rd_region_type *rd_region, const rd_kw_type *rd_kw, + bool force_active) { int sum; const int_vector_type *index_set = - ecl_region_get_kw_index_list(ecl_region, ecl_kw, force_active); - ecl_kw_element_sum_indexed(ecl_kw, index_set, &sum); + rd_region_get_kw_index_list(rd_region, rd_kw, force_active); + rd_kw_element_sum_indexed(rd_kw, index_set, &sum); return sum; } diff --git a/lib/resdata/rd_rft_cell.cpp b/lib/resdata/rd_rft_cell.cpp index 4820f5de7d..b1a8099ddb 100644 --- a/lib/resdata/rd_rft_cell.cpp +++ b/lib/resdata/rd_rft_cell.cpp @@ -8,16 +8,16 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#define ECL_RFT_CELL_TYPE_ID 99164012 +#define RD_RFT_CELL_TYPE_ID 99164012 #define RFT_DATA_TYPE_ID 66787166 #define PLT_DATA_TYPE_ID 87166667 -struct ecl_rft_cell_struct { +struct rd_rft_cell_struct { UTIL_TYPE_ID_DECLARATION; int i, j, k; double pressure; @@ -95,15 +95,17 @@ static UTIL_TRY_CAST_FUNCTION_CONST( PLT_DATA_TYPE_ID) static UTIL_SAFE_CAST_FUNCTION( - ecl_rft_cell, - ECL_RFT_CELL_TYPE_ID) static UTIL_SAFE_CAST_FUNCTION_CONST(ecl_rft_cell, - ECL_RFT_CELL_TYPE_ID) - UTIL_IS_INSTANCE_FUNCTION(ecl_rft_cell, ECL_RFT_CELL_TYPE_ID) - - static ecl_rft_cell_type *ecl_rft_cell_alloc_common( - int i, int j, int k, double depth, double pressure) { - ecl_rft_cell_type *cell = (ecl_rft_cell_type *)util_malloc(sizeof *cell); - UTIL_TYPE_ID_INIT(cell, ECL_RFT_CELL_TYPE_ID); + rd_rft_cell, + RD_RFT_CELL_TYPE_ID) static UTIL_SAFE_CAST_FUNCTION_CONST(rd_rft_cell, + RD_RFT_CELL_TYPE_ID) + UTIL_IS_INSTANCE_FUNCTION(rd_rft_cell, RD_RFT_CELL_TYPE_ID) + + static rd_rft_cell_type *rd_rft_cell_alloc_common(int i, int j, + int k, + double depth, + double pressure) { + rd_rft_cell_type *cell = (rd_rft_cell_type *)util_malloc(sizeof *cell); + UTIL_TYPE_ID_INIT(cell, RD_RFT_CELL_TYPE_ID); cell->i = i; cell->j = j; @@ -114,25 +116,23 @@ static UTIL_TRY_CAST_FUNCTION_CONST( return cell; } -ecl_rft_cell_type *ecl_rft_cell_alloc_RFT(int i, int j, int k, double depth, - double pressure, double swat, - double sgas) { - ecl_rft_cell_type *cell = - ecl_rft_cell_alloc_common(i, j, k, depth, pressure); +rd_rft_cell_type *rd_rft_cell_alloc_RFT(int i, int j, int k, double depth, + double pressure, double swat, + double sgas) { + rd_rft_cell_type *cell = rd_rft_cell_alloc_common(i, j, k, depth, pressure); cell->data = rft_data_alloc(swat, sgas); return cell; } -ecl_rft_cell_type * -ecl_rft_cell_alloc_PLT(int i, int j, int k, double depth, double pressure, - double orat, double grat, double wrat, - double connection_start, double connection_end, - double flowrate, double oil_flowrate, - double gas_flowrate, double water_flowrate) { +rd_rft_cell_type * +rd_rft_cell_alloc_PLT(int i, int j, int k, double depth, double pressure, + double orat, double grat, double wrat, + double connection_start, double connection_end, + double flowrate, double oil_flowrate, double gas_flowrate, + double water_flowrate) { - ecl_rft_cell_type *cell = - ecl_rft_cell_alloc_common(i, j, k, depth, pressure); + rd_rft_cell_type *cell = rd_rft_cell_alloc_common(i, j, k, depth, pressure); cell->data = plt_data_alloc(orat, grat, wrat, connection_start, connection_end, @@ -140,7 +140,7 @@ ecl_rft_cell_alloc_PLT(int i, int j, int k, double depth, double pressure, return cell; } -void ecl_rft_cell_free(ecl_rft_cell_type *cell) { +void rd_rft_cell_free(rd_rft_cell_type *cell) { if (rft_data_is_instance(cell->data)) rft_data_free((rft_data_type *)cell->data); else if (plt_data_is_instance(cell->data)) @@ -149,140 +149,138 @@ void ecl_rft_cell_free(ecl_rft_cell_type *cell) { free(cell); } -void ecl_rft_cell_free__(void *arg) { - ecl_rft_cell_type *cell = ecl_rft_cell_safe_cast(arg); - ecl_rft_cell_free(cell); +void rd_rft_cell_free__(void *arg) { + rd_rft_cell_type *cell = rd_rft_cell_safe_cast(arg); + rd_rft_cell_free(cell); } -int ecl_rft_cell_get_i(const ecl_rft_cell_type *cell) { return cell->i; } +int rd_rft_cell_get_i(const rd_rft_cell_type *cell) { return cell->i; } -int ecl_rft_cell_get_j(const ecl_rft_cell_type *cell) { return cell->j; } +int rd_rft_cell_get_j(const rd_rft_cell_type *cell) { return cell->j; } -int ecl_rft_cell_get_k(const ecl_rft_cell_type *cell) { return cell->k; } +int rd_rft_cell_get_k(const rd_rft_cell_type *cell) { return cell->k; } -void ecl_rft_cell_get_ijk(const ecl_rft_cell_type *cell, int *i, int *j, - int *k) { +void rd_rft_cell_get_ijk(const rd_rft_cell_type *cell, int *i, int *j, int *k) { *i = cell->i; *j = cell->j; *k = cell->k; } -double ecl_rft_cell_get_depth(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_depth(const rd_rft_cell_type *cell) { return cell->depth; } -double ecl_rft_cell_get_pressure(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_pressure(const rd_rft_cell_type *cell) { return cell->pressure; } -double ecl_rft_cell_get_swat(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_swat(const rd_rft_cell_type *cell) { const rft_data_type *data = rft_data_try_cast_const(cell->data); if (data) return data->swat; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_sgas(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_sgas(const rd_rft_cell_type *cell) { const rft_data_type *data = rft_data_try_cast_const(cell->data); if (data) return data->sgas; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_soil(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_soil(const rd_rft_cell_type *cell) { const rft_data_type *data = rft_data_try_cast_const(cell->data); if (data) return 1 - (data->swat + data->sgas); else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_orat(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_orat(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->orat; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_grat(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_grat(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->grat; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_wrat(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_wrat(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->wrat; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_connection_start(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_connection_start(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->connection_start; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_connection_end(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_connection_end(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->connection_end; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_flowrate(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_flowrate(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->flowrate; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_oil_flowrate(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_oil_flowrate(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->oil_flowrate; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_gas_flowrate(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_gas_flowrate(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->gas_flowrate; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -double ecl_rft_cell_get_water_flowrate(const ecl_rft_cell_type *cell) { +double rd_rft_cell_get_water_flowrate(const rd_rft_cell_type *cell) { const plt_data_type *data = plt_data_try_cast_const(cell->data); if (data) return data->water_flowrate; else - return ECL_RFT_CELL_INVALID_VALUE; + return RD_RFT_CELL_INVALID_VALUE; } -bool ecl_rft_cell_ijk_equal(const ecl_rft_cell_type *cell, int i, int j, - int k) { +bool rd_rft_cell_ijk_equal(const rd_rft_cell_type *cell, int i, int j, int k) { return ((i == cell->i) && (j == cell->j) && (k == cell->k)); } /* Currently only comparison based on connection length along PLT is supported. */ -int ecl_rft_cell_cmp(const ecl_rft_cell_type *cell1, - const ecl_rft_cell_type *cell2) { - double val1 = ecl_rft_cell_get_connection_start(cell1); - double val2 = ecl_rft_cell_get_connection_start(cell2); +int rd_rft_cell_cmp(const rd_rft_cell_type *cell1, + const rd_rft_cell_type *cell2) { + double val1 = rd_rft_cell_get_connection_start(cell1); + double val2 = rd_rft_cell_get_connection_start(cell2); if (val1 < val2) return -1; @@ -292,13 +290,13 @@ int ecl_rft_cell_cmp(const ecl_rft_cell_type *cell1, return 1; } -int ecl_rft_cell_cmp__(const void *arg1, const void *arg2) { - const ecl_rft_cell_type *cell1 = ecl_rft_cell_safe_cast_const(arg1); - const ecl_rft_cell_type *cell2 = ecl_rft_cell_safe_cast_const(arg2); - return ecl_rft_cell_cmp(cell1, cell2); +int rd_rft_cell_cmp__(const void *arg1, const void *arg2) { + const rd_rft_cell_type *cell1 = rd_rft_cell_safe_cast_const(arg1); + const rd_rft_cell_type *cell2 = rd_rft_cell_safe_cast_const(arg2); + return rd_rft_cell_cmp(cell1, cell2); } -bool ecl_rft_cell_lt(const ecl_rft_cell_type *cell1, - const ecl_rft_cell_type *cell2) { - return (ecl_rft_cell_cmp(cell1, cell2) < 0); +bool rd_rft_cell_lt(const rd_rft_cell_type *cell1, + const rd_rft_cell_type *cell2) { + return (rd_rft_cell_cmp(cell1, cell2) < 0); } diff --git a/lib/resdata/rd_rft_file.cpp b/lib/resdata/rd_rft_file.cpp index 6e51ef9b91..d69b5f2a63 100644 --- a/lib/resdata/rd_rft_file.cpp +++ b/lib/resdata/rd_rft_file.cpp @@ -14,11 +14,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** This data structure is for loading one eclipse RFT file. One RFT @@ -29,23 +29,23 @@ All of this is just lumped together in one long vector, both in the file, and in this implementation. The data for one specific RFT - (one well, one time) is internalized in the ecl_rft_node type. + (one well, one time) is internalized in the rd_rft_node type. */ -#define ECL_RFT_FILE_ID 6610632 +#define RD_RFT_FILE_ID 6610632 -struct ecl_rft_file_struct { +struct rd_rft_file_struct { UTIL_TYPE_ID_DECLARATION; std::string filename; - std::vector + std::vector data; /* This vector just contains all the rft nodes in one long vector. */ std::map> well_index; }; -static ecl_rft_file_type *ecl_rft_file_alloc_empty(const char *filename) { - ecl_rft_file_type *rft_vector = new ecl_rft_file_type(); +static rd_rft_file_type *rd_rft_file_alloc_empty(const char *filename) { + rd_rft_file_type *rft_vector = new rd_rft_file_type(); - UTIL_TYPE_ID_INIT(rft_vector, ECL_RFT_FILE_ID); + UTIL_TYPE_ID_INIT(rft_vector, RD_RFT_FILE_ID); rft_vector->filename = std::string(filename); return rft_vector; @@ -54,33 +54,33 @@ static ecl_rft_file_type *ecl_rft_file_alloc_empty(const char *filename) { /** Generating the two functions: - bool ecl_rft_file_is_instance( void * ); - ecl_rft_file_type * ecl_rft_file_safe_cast( void * ); + bool rd_rft_file_is_instance( void * ); + rd_rft_file_type * rd_rft_file_safe_cast( void * ); */ -UTIL_SAFE_CAST_FUNCTION(ecl_rft_file, ECL_RFT_FILE_ID); -UTIL_IS_INSTANCE_FUNCTION(ecl_rft_file, ECL_RFT_FILE_ID); +UTIL_SAFE_CAST_FUNCTION(rd_rft_file, RD_RFT_FILE_ID); +UTIL_IS_INSTANCE_FUNCTION(rd_rft_file, RD_RFT_FILE_ID); -static void ecl_rft_file_add_node(ecl_rft_file_type *rft_vector, - ecl_rft_node_type *rft_node) { +static void rd_rft_file_add_node(rd_rft_file_type *rft_vector, + rd_rft_node_type *rft_node) { rft_vector->data.push_back(rft_node); } -ecl_rft_file_type *ecl_rft_file_alloc(const char *filename) { - ecl_rft_file_type *rft_vector = ecl_rft_file_alloc_empty(filename); - ecl_file_type *ecl_file = ecl_file_open(filename, 0); +rd_rft_file_type *rd_rft_file_alloc(const char *filename) { + rd_rft_file_type *rft_vector = rd_rft_file_alloc_empty(filename); + rd_file_type *rd_file = rd_file_open(filename, 0); int global_index = 0; int block_nr = 0; while (true) { - ecl_file_view_type *rft_view = - ecl_file_alloc_global_blockview(ecl_file, TIME_KW, block_nr); + rd_file_view_type *rft_view = + rd_file_alloc_global_blockview(rd_file, TIME_KW, block_nr); if (rft_view) { - ecl_rft_node_type *rft_node = ecl_rft_node_alloc(rft_view); + rd_rft_node_type *rft_node = rd_rft_node_alloc(rft_view); if (rft_node) { - const char *well_name = ecl_rft_node_get_well_name(rft_node); - ecl_rft_file_add_node(rft_vector, rft_node); + const char *well_name = rd_rft_node_get_well_name(rft_node); + rd_rft_file_add_node(rft_vector, rft_node); auto &index_vector = rft_vector->well_index[well_name]; index_vector.push_back(global_index); @@ -90,38 +90,38 @@ ecl_rft_file_type *ecl_rft_file_alloc(const char *filename) { break; block_nr++; - ecl_file_view_free(rft_view); + rd_file_view_free(rft_view); } - ecl_file_close(ecl_file); + rd_file_close(rd_file); return rft_vector; } /** Will look for .RFT / .FRFT files very similar to the - ecl_grid_load_case(). Will return NULL if no RFT file can be found, + rd_grid_load_case(). Will return NULL if no RFT file can be found, and the name of RFT file if it is found. New storage is allocated for the new name. */ -char *ecl_rft_file_alloc_case_filename(const char *case_input) { - ecl_file_enum file_type; +char *rd_rft_file_alloc_case_filename(const char *case_input) { + rd_file_enum file_type; bool fmt_file; - file_type = ecl_util_get_file_type(case_input, &fmt_file, NULL); - if (file_type == ECL_RFT_FILE) + file_type = rd_get_file_type(case_input, &fmt_file, NULL); + if (file_type == RD_RFT_FILE) return util_alloc_string_copy(case_input); else { char *return_file = NULL; char *path; char *basename; util_alloc_file_components(case_input, &path, &basename, NULL); - if ((file_type == ECL_OTHER_FILE) || + if ((file_type == RD_OTHER_FILE) || (file_type == - ECL_DATA_FILE)) { /* Impossible to infer formatted/unformatted from the case_input */ - char *RFT_file = ecl_util_alloc_filename(path, basename, - ECL_RFT_FILE, false, -1); + RD_DATA_FILE)) { /* Impossible to infer formatted/unformatted from the case_input */ + char *RFT_file = + rd_alloc_filename(path, basename, RD_RFT_FILE, false, -1); char *FRFT_file = - ecl_util_alloc_filename(path, basename, ECL_RFT_FILE, true, -1); + rd_alloc_filename(path, basename, RD_RFT_FILE, true, -1); if (util_file_exists(RFT_file)) return_file = util_alloc_string_copy(RFT_file); @@ -131,8 +131,8 @@ char *ecl_rft_file_alloc_case_filename(const char *case_input) { free(RFT_file); free(FRFT_file); } else { - char *RFT_file = ecl_util_alloc_filename( - path, basename, ECL_RFT_FILE, fmt_file, -1); + char *RFT_file = + rd_alloc_filename(path, basename, RD_RFT_FILE, fmt_file, -1); if (util_file_exists(RFT_file)) return_file = util_alloc_string_copy(RFT_file); @@ -143,20 +143,20 @@ char *ecl_rft_file_alloc_case_filename(const char *case_input) { } } -ecl_rft_file_type *ecl_rft_file_alloc_case(const char *case_input) { - ecl_rft_file_type *ecl_rft_file = NULL; - char *file_name = ecl_rft_file_alloc_case_filename(case_input); +rd_rft_file_type *rd_rft_file_alloc_case(const char *case_input) { + rd_rft_file_type *rd_rft_file = NULL; + char *file_name = rd_rft_file_alloc_case_filename(case_input); if (file_name != NULL) { - ecl_rft_file = ecl_rft_file_alloc(file_name); + rd_rft_file = rd_rft_file_alloc(file_name); free(file_name); } - return ecl_rft_file; + return rd_rft_file; } -bool ecl_rft_file_case_has_rft(const char *case_input) { +bool rd_rft_file_case_has_rft(const char *case_input) { bool has_rft = false; - char *file_name = ecl_rft_file_alloc_case_filename(case_input); + char *file_name = rd_rft_file_alloc_case_filename(case_input); if (file_name != NULL) { has_rft = true; @@ -166,15 +166,15 @@ bool ecl_rft_file_case_has_rft(const char *case_input) { return has_rft; } -void ecl_rft_file_free(ecl_rft_file_type *rft_vector) { +void rd_rft_file_free(rd_rft_file_type *rft_vector) { for (auto node_ptr : rft_vector->data) - ecl_rft_node_free(node_ptr); + rd_rft_node_free(node_ptr); delete rft_vector; } -void ecl_rft_file_free__(void *arg) { - ecl_rft_file_free(ecl_rft_file_safe_cast(arg)); +void rd_rft_file_free__(void *arg) { + rd_rft_file_free(rd_rft_file_safe_cast(arg)); } /** @@ -182,7 +182,7 @@ void ecl_rft_file_free__(void *arg) { only wells matching @well be included. The @well variable can contain '*', so the function call - ecl_rft_file_get_size__( rft_file , "OP*" , -1) + rd_rft_file_get_size__( rft_file , "OP*" , -1) will count the number of rft instances with a well name matching well "OP*". @@ -191,24 +191,24 @@ void ecl_rft_file_free__(void *arg) { @recording_time are included. */ -int ecl_rft_file_get_size__(const ecl_rft_file_type *rft_file, - const char *well_pattern, time_t recording_time) { +int rd_rft_file_get_size__(const rd_rft_file_type *rft_file, + const char *well_pattern, time_t recording_time) { if ((well_pattern == NULL) && (recording_time < 0)) return rft_file->data.size(); else { int match_count = 0; for (size_t i = 0; i < rft_file->data.size(); i++) { - const ecl_rft_node_type *rft = rft_file->data[i]; + const rd_rft_node_type *rft = rft_file->data[i]; if (well_pattern) { if (util_fnmatch(well_pattern, - ecl_rft_node_get_well_name(rft)) != 0) + rd_rft_node_get_well_name(rft)) != 0) continue; } /*OK - we either do not care about the well, or alternatively the well matches. */ if (recording_time >= 0) { - if (recording_time != ecl_rft_node_get_date(rft)) + if (recording_time != rd_rft_node_get_date(rft)) continue; } match_count++; @@ -222,11 +222,11 @@ int ecl_rft_file_get_size__(const ecl_rft_file_type *rft_file, the same well occurse many times and so on. */ -int ecl_rft_file_get_size(const ecl_rft_file_type *rft_file) { - return ecl_rft_file_get_size__(rft_file, NULL, -1); +int rd_rft_file_get_size(const rd_rft_file_type *rft_file) { + return rd_rft_file_get_size__(rft_file, NULL, -1); } -const char *ecl_rft_file_get_filename(const ecl_rft_file_type *rft_file) { +const char *rd_rft_file_get_filename(const rd_rft_file_type *rft_file) { return rft_file->filename.c_str(); } @@ -235,17 +235,17 @@ const char *ecl_rft_file_get_filename(const ecl_rft_file_type *rft_file) { particular RFT is from, or which well it is. If you ask for an index which is beyond the size of the vector it will - go up in flames - use ecl_file_get_size() first if you can not + go up in flames - use rd_file_get_size() first if you can not handle that. */ -ecl_rft_node_type *ecl_rft_file_iget_node(const ecl_rft_file_type *rft_file, - int index) { +rd_rft_node_type *rd_rft_file_iget_node(const rd_rft_file_type *rft_file, + int index) { return rft_file->data[index]; } /** - This function will return ecl_rft_node nr index - for well + This function will return rd_rft_node nr index - for well 'well'. I.e. for an RFT file which looks like this: RFT - Well P1: 01/01/2000 @@ -257,26 +257,26 @@ ecl_rft_node_type *ecl_rft_file_iget_node(const ecl_rft_file_type *rft_file, The function call: - ecl_rft_iget_well_rft(rft_file , "P2" , 1) + rd_rft_iget_well_rft(rft_file , "P2" , 1) will return the rft node indicated by the arrow (i.e. the second occurence of well "P2" in the file.) If the rft_file does not have the well, or that occurence, the function will go down in flames with util_abort(). Use - ecl_rft_file_has_well() and ecl_rft_file_get_well_occurences() + rd_rft_file_has_well() and rd_rft_file_get_well_occurences() first if you can not take util_abort(). */ -ecl_rft_node_type *ecl_rft_file_iget_well_rft(const ecl_rft_file_type *rft_file, - const char *well, int index) { +rd_rft_node_type *rd_rft_file_iget_well_rft(const rd_rft_file_type *rft_file, + const char *well, int index) { const auto &index_vector = rft_file->well_index.at(well); - return ecl_rft_file_iget_node(rft_file, index_vector[index]); + return rd_rft_file_iget_node(rft_file, index_vector[index]); } -static int -ecl_rft_file_get_node_index_time_rft(const ecl_rft_file_type *rft_file, - const char *well, time_t recording_time) { +static int rd_rft_file_get_node_index_time_rft(const rd_rft_file_type *rft_file, + const char *well, + time_t recording_time) { const auto &pair_iter = rft_file->well_index.find(well); if (pair_iter == rft_file->well_index.end()) return -1; @@ -289,9 +289,9 @@ ecl_rft_file_get_node_index_time_rft(const ecl_rft_file_type *rft_file, break; { - const ecl_rft_node_type *node = - ecl_rft_file_iget_node(rft_file, index_vector[well_index]); - if (ecl_rft_node_get_date(node) == recording_time) { + const rd_rft_node_type *node = + rd_rft_file_iget_node(rft_file, index_vector[well_index]); + if (rd_rft_node_get_date(node) == recording_time) { global_index = index_vector[well_index]; break; } @@ -308,20 +308,19 @@ ecl_rft_file_get_node_index_time_rft(const ecl_rft_file_type *rft_file, time; the function will return NULL. */ -ecl_rft_node_type * -ecl_rft_file_get_well_time_rft(const ecl_rft_file_type *rft_file, - const char *well, time_t recording_time) { +rd_rft_node_type * +rd_rft_file_get_well_time_rft(const rd_rft_file_type *rft_file, + const char *well, time_t recording_time) { int index = - ecl_rft_file_get_node_index_time_rft(rft_file, well, recording_time); + rd_rft_file_get_node_index_time_rft(rft_file, well, recording_time); if (index != -1) { - return ecl_rft_file_iget_node(rft_file, index); + return rd_rft_file_iget_node(rft_file, index); } else { return NULL; } } -bool ecl_rft_file_has_well(const ecl_rft_file_type *rft_file, - const char *well) { +bool rd_rft_file_has_well(const rd_rft_file_type *rft_file, const char *well) { return (rft_file->well_index.find(well) != rft_file->well_index.end()); } @@ -329,8 +328,8 @@ bool ecl_rft_file_has_well(const ecl_rft_file_type *rft_file, Returns the number of occurences of 'well' in rft_file. */ -int ecl_rft_file_get_well_occurences(const ecl_rft_file_type *rft_file, - const char *well) { +int rd_rft_file_get_well_occurences(const rd_rft_file_type *rft_file, + const char *well) { const auto &pair_iter = rft_file->well_index.find(well); if (pair_iter == rft_file->well_index.end()) return 0; @@ -341,12 +340,11 @@ int ecl_rft_file_get_well_occurences(const ecl_rft_file_type *rft_file, /** Returns the number of distinct wells in RFT file. */ -int ecl_rft_file_get_num_wells(const ecl_rft_file_type *rft_file) { +int rd_rft_file_get_num_wells(const rd_rft_file_type *rft_file) { return rft_file->well_index.size(); } -stringlist_type * -ecl_rft_file_alloc_well_list(const ecl_rft_file_type *rft_file) { +stringlist_type *rd_rft_file_alloc_well_list(const rd_rft_file_type *rft_file) { stringlist_type *well_list = stringlist_alloc_new(); for (const auto &pair : rft_file->well_index) @@ -355,56 +353,55 @@ ecl_rft_file_alloc_well_list(const ecl_rft_file_type *rft_file) { return well_list; } -void ecl_rft_file_update(const char *rft_file_name, ecl_rft_node_type **nodes, - int num_nodes, ert_ecl_unit_enum unit_set) { - ecl_rft_file_type *rft_file; +void rd_rft_file_update(const char *rft_file_name, rd_rft_node_type **nodes, + int num_nodes, ert_rd_unit_enum unit_set) { + rd_rft_file_type *rft_file; if (util_file_exists(rft_file_name)) { int node_index; - rft_file = ecl_rft_file_alloc(rft_file_name); + rft_file = rd_rft_file_alloc(rft_file_name); for (node_index = 0; node_index < num_nodes; node_index++) { - ecl_rft_node_type *new_node = nodes[node_index]; - int storage_index = ecl_rft_file_get_node_index_time_rft( - rft_file, ecl_rft_node_get_well_name(new_node), - ecl_rft_node_get_date(new_node)); + rd_rft_node_type *new_node = nodes[node_index]; + int storage_index = rd_rft_file_get_node_index_time_rft( + rft_file, rd_rft_node_get_well_name(new_node), + rd_rft_node_get_date(new_node)); if (storage_index == -1) { - ecl_rft_file_add_node(rft_file, new_node); + rd_rft_file_add_node(rft_file, new_node); } else { - ecl_rft_node_free(rft_file->data[storage_index]); + rd_rft_node_free(rft_file->data[storage_index]); rft_file->data[storage_index] = new_node; } } } else { int node_index; - rft_file = ecl_rft_file_alloc_empty(rft_file_name); + rft_file = rd_rft_file_alloc_empty(rft_file_name); for (node_index = 0; node_index < num_nodes; node_index++) { - ecl_rft_file_add_node(rft_file, nodes[node_index]); + rd_rft_file_add_node(rft_file, nodes[node_index]); } } { bool fmt_file = false; fortio_type *fortio = - fortio_open_writer(rft_file_name, fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(rft_file_name, fmt_file, RD_ENDIAN_FLIP); /** The sorting here works directly on the internal node storage rft_file->data; that might in principle ruin the indexing of - the ecl_file object - it is therefore absolutely essential - that this ecl_rft_file object does not live beyond this - function, and also that the ecl_rft_file api functions are + the rd_file object - it is therefore absolutely essential + that this rd_rft_file object does not live beyond this + function, and also that the rd_rft_file api functions are avoided for the rest of this function. */ - std::sort(rft_file->data.begin(), rft_file->data.end(), - ecl_rft_node_lt); + std::sort(rft_file->data.begin(), rft_file->data.end(), rd_rft_node_lt); for (size_t node_index = 0; node_index < rft_file->data.size(); node_index++) { - const ecl_rft_node_type *new_node = rft_file->data[node_index]; - ecl_rft_node_fwrite(new_node, fortio, unit_set); + const rd_rft_node_type *new_node = rft_file->data[node_index]; + rd_rft_node_fwrite(new_node, fortio, unit_set); } fortio_fclose(fortio); } - ecl_rft_file_free(rft_file); + rd_rft_file_free(rft_file); } diff --git a/lib/resdata/rd_rft_node.cpp b/lib/resdata/rd_rft_node.cpp index 06b391bec6..f2af6f966c 100644 --- a/lib/resdata/rd_rft_node.cpp +++ b/lib/resdata/rd_rft_node.cpp @@ -11,17 +11,17 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /** The RFT's from several wells, and possibly also several timesteps - are lumped togeheter in one .RFT file. The ecl_rft_node + are lumped togeheter in one .RFT file. The rd_rft_node implemented in this file contains the information for one well/report step. */ @@ -32,17 +32,17 @@ not really supported. */ -#define ECL_RFT_NODE_ID 887195 -struct ecl_rft_node_struct { +#define RD_RFT_NODE_ID 887195 +struct rd_rft_node_struct { UTIL_TYPE_ID_DECLARATION; std::string well_name; - ecl_rft_enum data_type; /* What type of data: RFT|PLT|SEGMENT */ - time_t recording_date; /* When was the RFT recorded - date.*/ + rd_rft_enum data_type; /* What type of data: RFT|PLT|SEGMENT */ + time_t recording_date; /* When was the RFT recorded - date.*/ double days; /* When was the RFT recorded - days after simulaton start. */ bool MSW; - std::vector cells; + std::vector cells; }; /* @@ -62,9 +62,9 @@ struct ecl_rft_node_struct { Will return NULL if the data_type_string is equal to "SEGMENT" - that is not (yet) supported. */ -static ecl_rft_enum -translate_from_sting_to_ecl_rft_enum(const char *data_type_string) { - ecl_rft_enum data_type = SEGMENT; +static rd_rft_enum +translate_from_sting_to_rd_rft_enum(const char *data_type_string) { + rd_rft_enum data_type = SEGMENT; /* According to the ECLIPSE documentaton. */ if (strchr(data_type_string, 'P') != NULL) data_type = PLT; @@ -80,15 +80,15 @@ translate_from_sting_to_ecl_rft_enum(const char *data_type_string) { return data_type; } -ecl_rft_node_type *ecl_rft_node_alloc_new(const char *well_name, - const char *data_type_string, - const time_t recording_date, - const double days) { - ecl_rft_enum data_type = - translate_from_sting_to_ecl_rft_enum(data_type_string); - ecl_rft_node_type *rft_node = new ecl_rft_node_type(); +rd_rft_node_type *rd_rft_node_alloc_new(const char *well_name, + const char *data_type_string, + const time_t recording_date, + const double days) { + rd_rft_enum data_type = + translate_from_sting_to_rd_rft_enum(data_type_string); + rd_rft_node_type *rft_node = new rd_rft_node_type(); - UTIL_TYPE_ID_INIT(rft_node, ECL_RFT_NODE_ID); + UTIL_TYPE_ID_INIT(rft_node, RD_RFT_NODE_ID); rft_node->well_name = std::string(well_name); rft_node->recording_date = recording_date; rft_node->days = days; @@ -97,10 +97,9 @@ ecl_rft_node_type *ecl_rft_node_alloc_new(const char *well_name, return rft_node; } -static ecl_rft_node_type * -ecl_rft_node_alloc_empty(const char *data_type_string) { - ecl_rft_enum data_type = - translate_from_sting_to_ecl_rft_enum(data_type_string); +static rd_rft_node_type *rd_rft_node_alloc_empty(const char *data_type_string) { + rd_rft_enum data_type = + translate_from_sting_to_rd_rft_enum(data_type_string); /* Can return NULL */ if (data_type == SEGMENT) { @@ -112,41 +111,39 @@ ecl_rft_node_alloc_empty(const char *data_type_string) { } { - ecl_rft_node_type *rft_node = new ecl_rft_node_type(); + rd_rft_node_type *rft_node = new rd_rft_node_type(); - UTIL_TYPE_ID_INIT(rft_node, ECL_RFT_NODE_ID); + UTIL_TYPE_ID_INIT(rft_node, RD_RFT_NODE_ID); rft_node->data_type = data_type; return rft_node; } } -UTIL_SAFE_CAST_FUNCTION(ecl_rft_node, ECL_RFT_NODE_ID); -UTIL_IS_INSTANCE_FUNCTION(ecl_rft_node, ECL_RFT_NODE_ID); +UTIL_SAFE_CAST_FUNCTION(rd_rft_node, RD_RFT_NODE_ID); +UTIL_IS_INSTANCE_FUNCTION(rd_rft_node, RD_RFT_NODE_ID); -void ecl_rft_node_append_cell(ecl_rft_node_type *rft_node, - ecl_rft_cell_type *cell) { +void rd_rft_node_append_cell(rd_rft_node_type *rft_node, + rd_rft_cell_type *cell) { if (rft_node->MSW) { auto pos_iter = std::upper_bound(rft_node->cells.begin(), rft_node->cells.end(), - cell, ecl_rft_cell_lt); + cell, rd_rft_cell_lt); rft_node->cells.insert(pos_iter, cell); } else rft_node->cells.push_back(cell); } -static ecl_kw_type * -ecl_rft_node_get_pressure_kw(ecl_rft_node_type *rft_node, - const ecl_file_view_type *rft) { +static rd_kw_type *rd_rft_node_get_pressure_kw(rd_rft_node_type *rft_node, + const rd_file_view_type *rft) { if (rft_node->data_type == RFT) - return ecl_file_view_iget_named_kw(rft, PRESSURE_KW, 0); + return rd_file_view_iget_named_kw(rft, PRESSURE_KW, 0); else { - ecl_kw_type *conpres_kw = - ecl_file_view_iget_named_kw(rft, CONPRES_KW, 0); - if (ecl_kw_element_sum_float(conpres_kw) > 0.0) + rd_kw_type *conpres_kw = rd_file_view_iget_named_kw(rft, CONPRES_KW, 0); + if (rd_kw_element_sum_float(conpres_kw) > 0.0) return conpres_kw; - else if (ecl_file_view_has_kw(rft, PRESSURE_KW)) - return ecl_file_view_iget_named_kw(rft, PRESSURE_KW, 0); + else if (rd_file_view_has_kw(rft, PRESSURE_KW)) + return rd_file_view_iget_named_kw(rft, PRESSURE_KW, 0); else { fprintf(stderr, "WARNING: %s returned a CONPRES_KW with all values at " @@ -157,90 +154,90 @@ ecl_rft_node_get_pressure_kw(ecl_rft_node_type *rft_node, } } -static void ecl_rft_node_init_RFT_cells(ecl_rft_node_type *rft_node, - const ecl_file_view_type *rft_view) { - const ecl_kw_type *conipos = - ecl_file_view_iget_named_kw(rft_view, CONIPOS_KW, 0); - const ecl_kw_type *conjpos = - ecl_file_view_iget_named_kw(rft_view, CONJPOS_KW, 0); - const ecl_kw_type *conkpos = - ecl_file_view_iget_named_kw(rft_view, CONKPOS_KW, 0); - const ecl_kw_type *depth_kw = - ecl_file_view_iget_named_kw(rft_view, DEPTH_KW, 0); - const ecl_kw_type *swat_kw = - ecl_file_view_iget_named_kw(rft_view, SWAT_KW, 0); - const ecl_kw_type *sgas_kw = - ecl_file_view_iget_named_kw(rft_view, SGAS_KW, 0); - const ecl_kw_type *pressure_kw = - ecl_rft_node_get_pressure_kw(rft_node, rft_view); - - const float *SW = ecl_kw_get_float_ptr(swat_kw); - const float *SG = ecl_kw_get_float_ptr(sgas_kw); - const float *P = ecl_kw_get_float_ptr(pressure_kw); - const float *depth = ecl_kw_get_float_ptr(depth_kw); - const int *i = ecl_kw_get_int_ptr(conipos); - const int *j = ecl_kw_get_int_ptr(conjpos); - const int *k = ecl_kw_get_int_ptr(conkpos); +static void rd_rft_node_init_RFT_cells(rd_rft_node_type *rft_node, + const rd_file_view_type *rft_view) { + const rd_kw_type *conipos = + rd_file_view_iget_named_kw(rft_view, CONIPOS_KW, 0); + const rd_kw_type *conjpos = + rd_file_view_iget_named_kw(rft_view, CONJPOS_KW, 0); + const rd_kw_type *conkpos = + rd_file_view_iget_named_kw(rft_view, CONKPOS_KW, 0); + const rd_kw_type *depth_kw = + rd_file_view_iget_named_kw(rft_view, DEPTH_KW, 0); + const rd_kw_type *swat_kw = + rd_file_view_iget_named_kw(rft_view, SWAT_KW, 0); + const rd_kw_type *sgas_kw = + rd_file_view_iget_named_kw(rft_view, SGAS_KW, 0); + const rd_kw_type *pressure_kw = + rd_rft_node_get_pressure_kw(rft_node, rft_view); + + const float *SW = rd_kw_get_float_ptr(swat_kw); + const float *SG = rd_kw_get_float_ptr(sgas_kw); + const float *P = rd_kw_get_float_ptr(pressure_kw); + const float *depth = rd_kw_get_float_ptr(depth_kw); + const int *i = rd_kw_get_int_ptr(conipos); + const int *j = rd_kw_get_int_ptr(conjpos); + const int *k = rd_kw_get_int_ptr(conkpos); { int c; - for (c = 0; c < ecl_kw_get_size(conipos); c++) { + for (c = 0; c < rd_kw_get_size(conipos); c++) { /* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */ - ecl_rft_cell_type *cell = ecl_rft_cell_alloc_RFT( + rd_rft_cell_type *cell = rd_rft_cell_alloc_RFT( i[c] - 1, j[c] - 1, k[c] - 1, depth[c], P[c], SW[c], SG[c]); - ecl_rft_node_append_cell(rft_node, cell); + rd_rft_node_append_cell(rft_node, cell); } } } -static void ecl_rft_node_init_PLT_cells(ecl_rft_node_type *rft_node, - const ecl_file_view_type *rft_view) { +static void rd_rft_node_init_PLT_cells(rd_rft_node_type *rft_node, + const rd_file_view_type *rft_view) { /* For PLT there is quite a lot of extra information which is not yet internalized. */ - const ecl_kw_type *conipos = - ecl_file_view_iget_named_kw(rft_view, CONIPOS_KW, 0); - const ecl_kw_type *conjpos = - ecl_file_view_iget_named_kw(rft_view, CONJPOS_KW, 0); - const ecl_kw_type *conkpos = - ecl_file_view_iget_named_kw(rft_view, CONKPOS_KW, 0); - - const int *i = ecl_kw_get_int_ptr(conipos); - const int *j = ecl_kw_get_int_ptr(conjpos); - const int *k = ecl_kw_get_int_ptr(conkpos); - - const float *WR = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONWRAT_KW, 0)); - const float *GR = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONGRAT_KW, 0)); - const float *OR = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONORAT_KW, 0)); + const rd_kw_type *conipos = + rd_file_view_iget_named_kw(rft_view, CONIPOS_KW, 0); + const rd_kw_type *conjpos = + rd_file_view_iget_named_kw(rft_view, CONJPOS_KW, 0); + const rd_kw_type *conkpos = + rd_file_view_iget_named_kw(rft_view, CONKPOS_KW, 0); + + const int *i = rd_kw_get_int_ptr(conipos); + const int *j = rd_kw_get_int_ptr(conjpos); + const int *k = rd_kw_get_int_ptr(conkpos); + + const float *WR = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONWRAT_KW, 0)); + const float *GR = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONGRAT_KW, 0)); + const float *OR = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONORAT_KW, 0)); const float *P = - ecl_kw_get_float_ptr(ecl_rft_node_get_pressure_kw(rft_node, rft_view)); - const float *depth = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONDEPTH_KW, 0)); - const float *flowrate = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONVTUB_KW, 0)); - const float *oil_flowrate = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONOTUB_KW, 0)); - const float *gas_flowrate = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONGTUB_KW, 0)); - const float *water_flowrate = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONWTUB_KW, 0)); + rd_kw_get_float_ptr(rd_rft_node_get_pressure_kw(rft_node, rft_view)); + const float *depth = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONDEPTH_KW, 0)); + const float *flowrate = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONVTUB_KW, 0)); + const float *oil_flowrate = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONOTUB_KW, 0)); + const float *gas_flowrate = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONGTUB_KW, 0)); + const float *water_flowrate = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONWTUB_KW, 0)); const float *connection_start = NULL; const float *connection_end = NULL; /* The keywords CONLENST_KW and CONLENEN_KW are ONLY present if we are dealing with a MSW well. */ - if (ecl_file_view_has_kw(rft_view, CONLENST_KW)) - connection_start = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONLENST_KW, 0)); + if (rd_file_view_has_kw(rft_view, CONLENST_KW)) + connection_start = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONLENST_KW, 0)); - if (ecl_file_view_has_kw(rft_view, CONLENEN_KW)) - connection_end = ecl_kw_get_float_ptr( - ecl_file_view_iget_named_kw(rft_view, CONLENEN_KW, 0)); + if (rd_file_view_has_kw(rft_view, CONLENEN_KW)) + connection_end = rd_kw_get_float_ptr( + rd_file_view_iget_named_kw(rft_view, CONLENEN_KW, 0)); { int c; - for (c = 0; c < ecl_kw_get_size(conipos); c++) { - ecl_rft_cell_type *cell; + for (c = 0; c < rd_kw_get_size(conipos); c++) { + rd_rft_cell_type *cell; double cs = 0; double ce = 0; @@ -251,119 +248,116 @@ static void ecl_rft_node_init_PLT_cells(ecl_rft_node_type *rft_node, ce = connection_end[c]; /* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */ - cell = ecl_rft_cell_alloc_PLT(i[c] - 1, j[c] - 1, k[c] - 1, - depth[c], P[c], OR[c], GR[c], WR[c], - cs, ce, flowrate[c], oil_flowrate[c], - gas_flowrate[c], water_flowrate[c]); - ecl_rft_node_append_cell(rft_node, cell); + cell = rd_rft_cell_alloc_PLT(i[c] - 1, j[c] - 1, k[c] - 1, depth[c], + P[c], OR[c], GR[c], WR[c], cs, ce, + flowrate[c], oil_flowrate[c], + gas_flowrate[c], water_flowrate[c]); + rd_rft_node_append_cell(rft_node, cell); } } } -static void ecl_rft_node_init_cells(ecl_rft_node_type *rft_node, - const ecl_file_view_type *rft_view) { +static void rd_rft_node_init_cells(rd_rft_node_type *rft_node, + const rd_file_view_type *rft_view) { if (rft_node->data_type == RFT) - ecl_rft_node_init_RFT_cells(rft_node, rft_view); + rd_rft_node_init_RFT_cells(rft_node, rft_view); else if (rft_node->data_type == PLT) - ecl_rft_node_init_PLT_cells(rft_node, rft_view); + rd_rft_node_init_PLT_cells(rft_node, rft_view); } -ecl_rft_node_type *ecl_rft_node_alloc(const ecl_file_view_type *rft_view) { - ecl_kw_type *welletc = ecl_file_view_iget_named_kw(rft_view, WELLETC_KW, 0); - ecl_rft_node_type *rft_node = ecl_rft_node_alloc_empty( - (const char *)ecl_kw_iget_ptr(welletc, WELLETC_TYPE_INDEX)); +rd_rft_node_type *rd_rft_node_alloc(const rd_file_view_type *rft_view) { + rd_kw_type *welletc = rd_file_view_iget_named_kw(rft_view, WELLETC_KW, 0); + rd_rft_node_type *rft_node = rd_rft_node_alloc_empty( + (const char *)rd_kw_iget_ptr(welletc, WELLETC_TYPE_INDEX)); if (rft_node != NULL) { - ecl_kw_type *date_kw = - ecl_file_view_iget_named_kw(rft_view, DATE_KW, 0); + rd_kw_type *date_kw = rd_file_view_iget_named_kw(rft_view, DATE_KW, 0); { char *tmp = util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(welletc, WELLETC_NAME_INDEX)); + (const char *)rd_kw_iget_ptr(welletc, WELLETC_NAME_INDEX)); rft_node->well_name = std::string(tmp); free(tmp); } /* Time information. */ { - int *time = ecl_kw_get_int_ptr(date_kw); + int *time = rd_kw_get_int_ptr(date_kw); rft_node->recording_date = - ecl_util_make_date(time[DATE_DAY_INDEX], time[DATE_MONTH_INDEX], - time[DATE_YEAR_INDEX]); + rd_make_date(time[DATE_DAY_INDEX], time[DATE_MONTH_INDEX], + time[DATE_YEAR_INDEX]); } - rft_node->days = ecl_kw_iget_float( - ecl_file_view_iget_named_kw(rft_view, TIME_KW, 0), 0); - if (ecl_file_view_has_kw(rft_view, CONLENST_KW)) + rft_node->days = rd_kw_iget_float( + rd_file_view_iget_named_kw(rft_view, TIME_KW, 0), 0); + if (rd_file_view_has_kw(rft_view, CONLENST_KW)) rft_node->MSW = true; else rft_node->MSW = false; - ecl_rft_node_init_cells(rft_node, rft_view); + rd_rft_node_init_cells(rft_node, rft_view); } return rft_node; } -const char *ecl_rft_node_get_well_name(const ecl_rft_node_type *rft_node) { +const char *rd_rft_node_get_well_name(const rd_rft_node_type *rft_node) { return rft_node->well_name.c_str(); } -void ecl_rft_node_free(ecl_rft_node_type *rft_node) { +void rd_rft_node_free(rd_rft_node_type *rft_node) { for (auto cell_ptr : rft_node->cells) - ecl_rft_cell_free(cell_ptr); + rd_rft_cell_free(cell_ptr); delete rft_node; } -void ecl_rft_node_free__(void *void_node) { - ecl_rft_node_free(ecl_rft_node_safe_cast(void_node)); +void rd_rft_node_free__(void *void_node) { + rd_rft_node_free(rd_rft_node_safe_cast(void_node)); } -int ecl_rft_node_get_size(const ecl_rft_node_type *rft_node) { +int rd_rft_node_get_size(const rd_rft_node_type *rft_node) { return rft_node->cells.size(); } -time_t ecl_rft_node_get_date(const ecl_rft_node_type *rft_node) { +time_t rd_rft_node_get_date(const rd_rft_node_type *rft_node) { return rft_node->recording_date; } -ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type *rft_node) { +rd_rft_enum rd_rft_node_get_type(const rd_rft_node_type *rft_node) { return rft_node->data_type; } -const ecl_rft_cell_type * -ecl_rft_node_iget_cell(const ecl_rft_node_type *rft_node, int index) { +const rd_rft_cell_type *rd_rft_node_iget_cell(const rd_rft_node_type *rft_node, + int index) { return rft_node->cells[index]; } -const ecl_rft_cell_type * -ecl_rft_node_iget_cell_sorted(ecl_rft_node_type *rft_node, int index) { +const rd_rft_cell_type *rd_rft_node_iget_cell_sorted(rd_rft_node_type *rft_node, + int index) { return rft_node->cells[index]; } -double ecl_rft_node_iget_depth(const ecl_rft_node_type *rft_node, int index) { - const ecl_rft_cell_type *cell = ecl_rft_node_iget_cell(rft_node, index); - return ecl_rft_cell_get_depth(cell); +double rd_rft_node_iget_depth(const rd_rft_node_type *rft_node, int index) { + const rd_rft_cell_type *cell = rd_rft_node_iget_cell(rft_node, index); + return rd_rft_cell_get_depth(cell); } -double ecl_rft_node_iget_pressure(const ecl_rft_node_type *rft_node, - int index) { - const ecl_rft_cell_type *cell = ecl_rft_node_iget_cell(rft_node, index); - return ecl_rft_cell_get_pressure(cell); +double rd_rft_node_iget_pressure(const rd_rft_node_type *rft_node, int index) { + const rd_rft_cell_type *cell = rd_rft_node_iget_cell(rft_node, index); + return rd_rft_cell_get_pressure(cell); } -void ecl_rft_node_iget_ijk(const ecl_rft_node_type *rft_node, int index, int *i, - int *j, int *k) { - const ecl_rft_cell_type *cell = ecl_rft_node_iget_cell(rft_node, index); +void rd_rft_node_iget_ijk(const rd_rft_node_type *rft_node, int index, int *i, + int *j, int *k) { + const rd_rft_cell_type *cell = rd_rft_node_iget_cell(rft_node, index); - ecl_rft_cell_get_ijk(cell, i, j, k); + rd_rft_cell_get_ijk(cell, i, j, k); } -const ecl_rft_cell_type * -ecl_rft_node_lookup_ijk(const ecl_rft_node_type *rft_node, int i, int j, - int k) { +const rd_rft_cell_type *rd_rft_node_lookup_ijk(const rd_rft_node_type *rft_node, + int i, int j, int k) { int index = 0; - int size = ecl_rft_node_get_size(rft_node); + int size = rd_rft_node_get_size(rft_node); while (true) { - const ecl_rft_cell_type *cell = ecl_rft_node_iget_cell(rft_node, index); + const rd_rft_cell_type *cell = rd_rft_node_iget_cell(rft_node, index); - if (ecl_rft_cell_ijk_equal(cell, i, j, k)) + if (rd_rft_cell_ijk_equal(cell, i, j, k)) return cell; index++; @@ -372,8 +366,8 @@ ecl_rft_node_lookup_ijk(const ecl_rft_node_type *rft_node, int i, int j, } } -static void assert_type_and_index(const ecl_rft_node_type *rft_node, - ecl_rft_enum target_type, int index) { +static void assert_type_and_index(const rd_rft_node_type *rft_node, + rd_rft_enum target_type, int index) { if (rft_node->data_type != target_type) util_abort("%s: wrong type \n", __func__); @@ -381,226 +375,225 @@ static void assert_type_and_index(const ecl_rft_node_type *rft_node, util_abort("%s: invalid index:%d \n", __func__, index); } -double ecl_rft_node_iget_sgas(const ecl_rft_node_type *rft_node, int index) { +double rd_rft_node_iget_sgas(const rd_rft_node_type *rft_node, int index) { assert_type_and_index(rft_node, RFT, index); { - const ecl_rft_cell_type *cell = ecl_rft_node_iget_cell(rft_node, index); - return ecl_rft_cell_get_sgas(cell); + const rd_rft_cell_type *cell = rd_rft_node_iget_cell(rft_node, index); + return rd_rft_cell_get_sgas(cell); } } -double ecl_rft_node_iget_swat(const ecl_rft_node_type *rft_node, int index) { +double rd_rft_node_iget_swat(const rd_rft_node_type *rft_node, int index) { assert_type_and_index(rft_node, RFT, index); { - const ecl_rft_cell_type *cell = rft_node->cells[index]; - return ecl_rft_cell_get_swat(cell); + const rd_rft_cell_type *cell = rft_node->cells[index]; + return rd_rft_cell_get_swat(cell); } } -double ecl_rft_node_get_days(const ecl_rft_node_type *rft_node) { +double rd_rft_node_get_days(const rd_rft_node_type *rft_node) { return rft_node->days; } -double ecl_rft_node_iget_soil(const ecl_rft_node_type *rft_node, int index) { +double rd_rft_node_iget_soil(const rd_rft_node_type *rft_node, int index) { assert_type_and_index(rft_node, RFT, index); { - const ecl_rft_cell_type *cell = rft_node->cells[index]; - return ecl_rft_cell_get_soil(cell); + const rd_rft_cell_type *cell = rft_node->cells[index]; + return rd_rft_cell_get_soil(cell); } } -double ecl_rft_node_iget_orat(const ecl_rft_node_type *rft_node, int index) { +double rd_rft_node_iget_orat(const rd_rft_node_type *rft_node, int index) { assert_type_and_index(rft_node, PLT, index); { - const ecl_rft_cell_type *cell = rft_node->cells[index]; - return ecl_rft_cell_get_orat(cell); + const rd_rft_cell_type *cell = rft_node->cells[index]; + return rd_rft_cell_get_orat(cell); } } -double ecl_rft_node_iget_wrat(const ecl_rft_node_type *rft_node, int index) { +double rd_rft_node_iget_wrat(const rd_rft_node_type *rft_node, int index) { assert_type_and_index(rft_node, PLT, index); { - const ecl_rft_cell_type *cell = rft_node->cells[index]; - return ecl_rft_cell_get_wrat(cell); + const rd_rft_cell_type *cell = rft_node->cells[index]; + return rd_rft_cell_get_wrat(cell); } } -double ecl_rft_node_iget_grat(const ecl_rft_node_type *rft_node, int index) { +double rd_rft_node_iget_grat(const rd_rft_node_type *rft_node, int index) { assert_type_and_index(rft_node, PLT, index); { - const ecl_rft_cell_type *cell = rft_node->cells[index]; - return ecl_rft_cell_get_grat(cell); + const rd_rft_cell_type *cell = rft_node->cells[index]; + return rd_rft_cell_get_grat(cell); } } -bool ecl_rft_node_is_MSW(const ecl_rft_node_type *rft_node) { +bool rd_rft_node_is_MSW(const rd_rft_node_type *rft_node) { return rft_node->MSW; } -bool ecl_rft_node_is_PLT(const ecl_rft_node_type *rft_node) { +bool rd_rft_node_is_PLT(const rd_rft_node_type *rft_node) { if (rft_node->data_type == PLT) return true; else return false; } -bool ecl_rft_node_is_SEGMENT(const ecl_rft_node_type *rft_node) { +bool rd_rft_node_is_SEGMENT(const rd_rft_node_type *rft_node) { if (rft_node->data_type == SEGMENT) return true; else return false; } -bool ecl_rft_node_is_RFT(const ecl_rft_node_type *rft_node) { +bool rd_rft_node_is_RFT(const rd_rft_node_type *rft_node) { if (rft_node->data_type == RFT) return true; else return false; } -static void ecl_rft_node_fill_welletc(ecl_kw_type *welletc, - ert_ecl_unit_enum unit_set) { - if (unit_set == ECL_METRIC_UNITS) { - ecl_kw_iset_string8(welletc, 0, " DAYS"); - ecl_kw_iset_string8(welletc, 2, ""); - ecl_kw_iset_string8(welletc, 3, " METRES"); - ecl_kw_iset_string8(welletc, 4, " BARSA"); - ecl_kw_iset_string8(welletc, 6, "STANDARD"); - ecl_kw_iset_string8(welletc, 7, " SM3/DAY"); - ecl_kw_iset_string8(welletc, 8, " SM3/DAY"); - ecl_kw_iset_string8(welletc, 9, " RM3/DAY"); - ecl_kw_iset_string8(welletc, 10, " M/SEC"); - ecl_kw_iset_string8(welletc, 11, ""); - ecl_kw_iset_string8(welletc, 12, " CP"); - ecl_kw_iset_string8(welletc, 13, " KG/SM3"); - ecl_kw_iset_string8(welletc, 14, " KG/DAY"); - ecl_kw_iset_string8(welletc, 15, " KG/KG"); - } else if (unit_set == ECL_FIELD_UNITS) { - ecl_kw_iset_string8(welletc, 0, " DAYS"); - ecl_kw_iset_string8(welletc, 2, ""); - ecl_kw_iset_string8(welletc, 3, " FEET"); - ecl_kw_iset_string8(welletc, 4, " PISA"); - ecl_kw_iset_string8(welletc, 6, "STANDARD"); - ecl_kw_iset_string8(welletc, 7, " STB/DAY"); - ecl_kw_iset_string8(welletc, 8, " MSCF/DAY"); - ecl_kw_iset_string8(welletc, 9, " RB/DAY"); - ecl_kw_iset_string8(welletc, 10, " FT/SEC"); - ecl_kw_iset_string8(welletc, 11, ""); - ecl_kw_iset_string8(welletc, 12, " CP"); - ecl_kw_iset_string8(welletc, 13, " LB/STB"); - ecl_kw_iset_string8(welletc, 14, " LB/DAY"); - ecl_kw_iset_string8(welletc, 15, " LB/LB"); - - } else if (unit_set == ECL_LAB_UNITS) { - ecl_kw_iset_string8(welletc, 0, " HR"); - ecl_kw_iset_string8(welletc, 2, ""); - ecl_kw_iset_string8(welletc, 3, " CM"); - ecl_kw_iset_string8(welletc, 4, " ATMA"); - ecl_kw_iset_string8(welletc, 6, "STANDARD"); - ecl_kw_iset_string8(welletc, 7, " SCC/HR"); - ecl_kw_iset_string8(welletc, 8, " SCC/HR"); - ecl_kw_iset_string8(welletc, 9, " RCC/SCC"); - ecl_kw_iset_string8(welletc, 10, " CM/SEC"); - ecl_kw_iset_string8(welletc, 11, ""); - ecl_kw_iset_string8(welletc, 12, " CP"); - ecl_kw_iset_string8(welletc, 13, " GM/SCC"); - ecl_kw_iset_string8(welletc, 14, " GH/HR"); - ecl_kw_iset_string8(welletc, 15, " GM/GM"); +static void rd_rft_node_fill_welletc(rd_kw_type *welletc, + ert_rd_unit_enum unit_set) { + if (unit_set == RD_METRIC_UNITS) { + rd_kw_iset_string8(welletc, 0, " DAYS"); + rd_kw_iset_string8(welletc, 2, ""); + rd_kw_iset_string8(welletc, 3, " METRES"); + rd_kw_iset_string8(welletc, 4, " BARSA"); + rd_kw_iset_string8(welletc, 6, "STANDARD"); + rd_kw_iset_string8(welletc, 7, " SM3/DAY"); + rd_kw_iset_string8(welletc, 8, " SM3/DAY"); + rd_kw_iset_string8(welletc, 9, " RM3/DAY"); + rd_kw_iset_string8(welletc, 10, " M/SEC"); + rd_kw_iset_string8(welletc, 11, ""); + rd_kw_iset_string8(welletc, 12, " CP"); + rd_kw_iset_string8(welletc, 13, " KG/SM3"); + rd_kw_iset_string8(welletc, 14, " KG/DAY"); + rd_kw_iset_string8(welletc, 15, " KG/KG"); + } else if (unit_set == RD_FIELD_UNITS) { + rd_kw_iset_string8(welletc, 0, " DAYS"); + rd_kw_iset_string8(welletc, 2, ""); + rd_kw_iset_string8(welletc, 3, " FEET"); + rd_kw_iset_string8(welletc, 4, " PISA"); + rd_kw_iset_string8(welletc, 6, "STANDARD"); + rd_kw_iset_string8(welletc, 7, " STB/DAY"); + rd_kw_iset_string8(welletc, 8, " MSCF/DAY"); + rd_kw_iset_string8(welletc, 9, " RB/DAY"); + rd_kw_iset_string8(welletc, 10, " FT/SEC"); + rd_kw_iset_string8(welletc, 11, ""); + rd_kw_iset_string8(welletc, 12, " CP"); + rd_kw_iset_string8(welletc, 13, " LB/STB"); + rd_kw_iset_string8(welletc, 14, " LB/DAY"); + rd_kw_iset_string8(welletc, 15, " LB/LB"); + + } else if (unit_set == RD_LAB_UNITS) { + rd_kw_iset_string8(welletc, 0, " HR"); + rd_kw_iset_string8(welletc, 2, ""); + rd_kw_iset_string8(welletc, 3, " CM"); + rd_kw_iset_string8(welletc, 4, " ATMA"); + rd_kw_iset_string8(welletc, 6, "STANDARD"); + rd_kw_iset_string8(welletc, 7, " SCC/HR"); + rd_kw_iset_string8(welletc, 8, " SCC/HR"); + rd_kw_iset_string8(welletc, 9, " RCC/SCC"); + rd_kw_iset_string8(welletc, 10, " CM/SEC"); + rd_kw_iset_string8(welletc, 11, ""); + rd_kw_iset_string8(welletc, 12, " CP"); + rd_kw_iset_string8(welletc, 13, " GM/SCC"); + rd_kw_iset_string8(welletc, 14, " GH/HR"); + rd_kw_iset_string8(welletc, 15, " GM/GM"); } } -void ecl_rft_node_fwrite(const ecl_rft_node_type *rft_node, fortio_type *fortio, - ert_ecl_unit_enum unit_set) { - ecl_rft_enum type = ecl_rft_node_get_type(rft_node); +void rd_rft_node_fwrite(const rd_rft_node_type *rft_node, fortio_type *fortio, + ert_rd_unit_enum unit_set) { + rd_rft_enum type = rd_rft_node_get_type(rft_node); if (type != RFT) util_abort( "%s: sorry - only writing of simple RFT is currently implemented", __func__); { - ecl_kw_type *time = ecl_kw_alloc(TIME_KW, 1, ECL_FLOAT); - ecl_kw_iset_float(time, 0, ecl_rft_node_get_days(rft_node)); - ecl_kw_fwrite(time, fortio); - ecl_kw_free(time); + rd_kw_type *time = rd_kw_alloc(TIME_KW, 1, RD_FLOAT); + rd_kw_iset_float(time, 0, rd_rft_node_get_days(rft_node)); + rd_kw_fwrite(time, fortio); + rd_kw_free(time); } { - ecl_kw_type *datevalue = ecl_kw_alloc(DATE_KW, 3, ECL_INT); - time_t date = ecl_rft_node_get_date(rft_node); + rd_kw_type *datevalue = rd_kw_alloc(DATE_KW, 3, RD_INT); + time_t date = rd_rft_node_get_date(rft_node); int day; int month; int year; - ecl_util_set_date_values(date, &day, &month, &year); - ecl_kw_iset_int(datevalue, 0, day); - ecl_kw_iset_int(datevalue, 1, month); - ecl_kw_iset_int(datevalue, 2, year); - ecl_kw_fwrite(datevalue, fortio); - ecl_kw_free(datevalue); + rd_set_date_values(date, &day, &month, &year); + rd_kw_iset_int(datevalue, 0, day); + rd_kw_iset_int(datevalue, 1, month); + rd_kw_iset_int(datevalue, 2, year); + rd_kw_fwrite(datevalue, fortio); + rd_kw_free(datevalue); } { - ecl_kw_type *welletc = ecl_kw_alloc(WELLETC_KW, 16, ECL_CHAR); - ecl_rft_enum type = ecl_rft_node_get_type(rft_node); + rd_kw_type *welletc = rd_kw_alloc(WELLETC_KW, 16, RD_CHAR); + rd_rft_enum type = rd_rft_node_get_type(rft_node); - ecl_kw_iset_string8(welletc, 1, ecl_rft_node_get_well_name(rft_node)); + rd_kw_iset_string8(welletc, 1, rd_rft_node_get_well_name(rft_node)); if (type == PLT) { - ecl_kw_iset_string8(welletc, 5, "P"); + rd_kw_iset_string8(welletc, 5, "P"); } else if (type == RFT) { - ecl_kw_iset_string8(welletc, 5, "R"); + rd_kw_iset_string8(welletc, 5, "R"); } else if (type == SEGMENT) { - ecl_kw_iset_string8(welletc, 5, "S"); + rd_kw_iset_string8(welletc, 5, "S"); } - ecl_rft_node_fill_welletc(welletc, unit_set); - ecl_kw_fwrite(welletc, fortio); - ecl_kw_free(welletc); + rd_rft_node_fill_welletc(welletc, unit_set); + rd_kw_fwrite(welletc, fortio); + rd_kw_free(welletc); } { - int size_cells = ecl_rft_node_get_size(rft_node); - ecl_kw_type *conipos = ecl_kw_alloc(CONIPOS_KW, size_cells, ECL_INT); - ecl_kw_type *conjpos = ecl_kw_alloc(CONJPOS_KW, size_cells, ECL_INT); - ecl_kw_type *conkpos = ecl_kw_alloc(CONKPOS_KW, size_cells, ECL_INT); - ecl_kw_type *hostgrid = ecl_kw_alloc(HOSTGRID_KW, size_cells, ECL_CHAR); - ecl_kw_type *depth = ecl_kw_alloc(DEPTH_KW, size_cells, ECL_FLOAT); - ecl_kw_type *pressure = - ecl_kw_alloc(PRESSURE_KW, size_cells, ECL_FLOAT); - ecl_kw_type *swat = ecl_kw_alloc(SWAT_KW, size_cells, ECL_FLOAT); - ecl_kw_type *sgas = ecl_kw_alloc(SGAS_KW, size_cells, ECL_FLOAT); + int size_cells = rd_rft_node_get_size(rft_node); + rd_kw_type *conipos = rd_kw_alloc(CONIPOS_KW, size_cells, RD_INT); + rd_kw_type *conjpos = rd_kw_alloc(CONJPOS_KW, size_cells, RD_INT); + rd_kw_type *conkpos = rd_kw_alloc(CONKPOS_KW, size_cells, RD_INT); + rd_kw_type *hostgrid = rd_kw_alloc(HOSTGRID_KW, size_cells, RD_CHAR); + rd_kw_type *depth = rd_kw_alloc(DEPTH_KW, size_cells, RD_FLOAT); + rd_kw_type *pressure = rd_kw_alloc(PRESSURE_KW, size_cells, RD_FLOAT); + rd_kw_type *swat = rd_kw_alloc(SWAT_KW, size_cells, RD_FLOAT); + rd_kw_type *sgas = rd_kw_alloc(SGAS_KW, size_cells, RD_FLOAT); for (int i = 0; i < size_cells; i++) { - const ecl_rft_cell_type *cell = rft_node->cells[i]; - ecl_kw_iset_int(conipos, i, ecl_rft_cell_get_i(cell) + 1); - ecl_kw_iset_int(conjpos, i, ecl_rft_cell_get_j(cell) + 1); - ecl_kw_iset_int(conkpos, i, ecl_rft_cell_get_k(cell) + 1); - ecl_kw_iset_float(depth, i, ecl_rft_cell_get_depth(cell)); - ecl_kw_iset_float(pressure, i, ecl_rft_cell_get_pressure(cell)); - ecl_kw_iset_float(swat, i, ecl_rft_cell_get_swat(cell)); - ecl_kw_iset_float(sgas, i, ecl_rft_cell_get_sgas(cell)); + const rd_rft_cell_type *cell = rft_node->cells[i]; + rd_kw_iset_int(conipos, i, rd_rft_cell_get_i(cell) + 1); + rd_kw_iset_int(conjpos, i, rd_rft_cell_get_j(cell) + 1); + rd_kw_iset_int(conkpos, i, rd_rft_cell_get_k(cell) + 1); + rd_kw_iset_float(depth, i, rd_rft_cell_get_depth(cell)); + rd_kw_iset_float(pressure, i, rd_rft_cell_get_pressure(cell)); + rd_kw_iset_float(swat, i, rd_rft_cell_get_swat(cell)); + rd_kw_iset_float(sgas, i, rd_rft_cell_get_sgas(cell)); } - ecl_kw_fwrite(conipos, fortio); - ecl_kw_fwrite(conjpos, fortio); - ecl_kw_fwrite(conkpos, fortio); - ecl_kw_fwrite(hostgrid, fortio); - ecl_kw_fwrite(depth, fortio); - ecl_kw_fwrite(pressure, fortio); - ecl_kw_fwrite(swat, fortio); - ecl_kw_fwrite(sgas, fortio); - - ecl_kw_free(conipos); - ecl_kw_free(conjpos); - ecl_kw_free(conkpos); - ecl_kw_free(hostgrid); - ecl_kw_free(depth); - ecl_kw_free(pressure); - ecl_kw_free(swat); - ecl_kw_free(sgas); + rd_kw_fwrite(conipos, fortio); + rd_kw_fwrite(conjpos, fortio); + rd_kw_fwrite(conkpos, fortio); + rd_kw_fwrite(hostgrid, fortio); + rd_kw_fwrite(depth, fortio); + rd_kw_fwrite(pressure, fortio); + rd_kw_fwrite(swat, fortio); + rd_kw_fwrite(sgas, fortio); + + rd_kw_free(conipos); + rd_kw_free(conjpos); + rd_kw_free(conkpos); + rd_kw_free(hostgrid); + rd_kw_free(depth); + rd_kw_free(pressure); + rd_kw_free(swat); + rd_kw_free(sgas); } } -int ecl_rft_node_cmp(const ecl_rft_node_type *n1, const ecl_rft_node_type *n2) { - time_t val1 = ecl_rft_node_get_date(n1); - time_t val2 = ecl_rft_node_get_date(n2); +int rd_rft_node_cmp(const rd_rft_node_type *n1, const rd_rft_node_type *n2) { + time_t val1 = rd_rft_node_get_date(n1); + time_t val2 = rd_rft_node_get_date(n2); if (val1 < val2) return -1; @@ -610,6 +603,6 @@ int ecl_rft_node_cmp(const ecl_rft_node_type *n1, const ecl_rft_node_type *n2) { return 1; } -bool ecl_rft_node_lt(const ecl_rft_node_type *n1, const ecl_rft_node_type *n2) { - return (ecl_rft_node_cmp(n1, n2) < 0); +bool rd_rft_node_lt(const rd_rft_node_type *n1, const rd_rft_node_type *n2) { + return (rd_rft_node_cmp(n1, n2) < 0); } diff --git a/lib/resdata/rd_rst_file.cpp b/lib/resdata/rd_rst_file.cpp index cdee3c9290..4655cb2772 100644 --- a/lib/resdata/rd_rst_file.cpp +++ b/lib/resdata/rd_rst_file.cpp @@ -11,29 +11,29 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct ecl_rst_file_struct { +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct rd_rst_file_struct { fortio_type *fortio; bool unified; bool fmt_file; }; -static ecl_rst_file_type *ecl_rst_file_alloc(const char *filename) { - bool unified = ecl_util_unified_file(filename); +static rd_rst_file_type *rd_rst_file_alloc(const char *filename) { + bool unified = rd_unified_file(filename); bool fmt_file; - ecl_rst_file_type *rst_file = - (ecl_rst_file_type *)util_malloc(sizeof *rst_file); + rd_rst_file_type *rst_file = + (rd_rst_file_type *)util_malloc(sizeof *rst_file); - if (ecl_util_fmt_file(filename, &fmt_file)) { + if (rd_fmt_file(filename, &fmt_file)) { rst_file->unified = unified; rst_file->fmt_file = fmt_file; return rst_file; @@ -51,10 +51,10 @@ static ecl_rst_file_type *ecl_rst_file_alloc(const char *filename) { .UNRST / .Xnnnn / .Fnnnn. */ -ecl_rst_file_type *ecl_rst_file_open_read(const char *filename) { - ecl_rst_file_type *rst_file = ecl_rst_file_alloc(filename); +rd_rst_file_type *rd_rst_file_open_read(const char *filename) { + rd_rst_file_type *rst_file = rd_rst_file_alloc(filename); rst_file->fortio = - fortio_open_reader(filename, rst_file->fmt_file, ECL_ENDIAN_FLIP); + fortio_open_reader(filename, rst_file->fmt_file, RD_ENDIAN_FLIP); return rst_file; } @@ -66,13 +66,13 @@ ecl_rst_file_type *ecl_rst_file_open_read(const char *filename) { when returning. */ -ecl_rst_file_type *ecl_rst_file_open_write_seek(const char *filename, - int report_step) { - ecl_rst_file_type *rst_file = ecl_rst_file_alloc(filename); +rd_rst_file_type *rd_rst_file_open_write_seek(const char *filename, + int report_step) { + rd_rst_file_type *rst_file = rd_rst_file_alloc(filename); offset_type target_pos = 0; bool seqnum_found = false; rst_file->fortio = - fortio_open_readwrite(filename, rst_file->fmt_file, ECL_ENDIAN_FLIP); + fortio_open_readwrite(filename, rst_file->fmt_file, RD_ENDIAN_FLIP); /* If the file does not exist at all the fortio_open_readwrite() will fail, we just try again - opening a new file in normal write @@ -80,13 +80,13 @@ ecl_rst_file_type *ecl_rst_file_open_write_seek(const char *filename, */ if (!rst_file->fortio) { rst_file->fortio = - fortio_open_writer(filename, rst_file->fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, rst_file->fmt_file, RD_ENDIAN_FLIP); return rst_file; } fortio_fseek(rst_file->fortio, 0, SEEK_SET); { - ecl_kw_type *work_kw = ecl_kw_alloc_new("WORK-KW", 0, ECL_INT, NULL); + rd_kw_type *work_kw = rd_kw_alloc_new("WORK-KW", 0, RD_INT, NULL); while (true) { offset_type current_offset = fortio_ftell(rst_file->fortio); @@ -97,23 +97,23 @@ ecl_rst_file_type *ecl_rst_file_open_write_seek(const char *filename, break; } - if (ecl_kw_fread_header(work_kw, rst_file->fortio) == - ECL_KW_READ_FAIL) + if (rd_kw_fread_header(work_kw, rst_file->fortio) == + RD_KW_READ_FAIL) break; - if (ecl_kw_name_equal(work_kw, SEQNUM_KW)) { - ecl_kw_fread_realloc_data(work_kw, rst_file->fortio); - int file_step = ecl_kw_iget_int(work_kw, 0); + if (rd_kw_name_equal(work_kw, SEQNUM_KW)) { + rd_kw_fread_realloc_data(work_kw, rst_file->fortio); + int file_step = rd_kw_iget_int(work_kw, 0); if (file_step >= report_step) { target_pos = current_offset; break; } seqnum_found = true; } else - ecl_kw_fskip_data(work_kw, rst_file->fortio); + rd_kw_fskip_data(work_kw, rst_file->fortio); } - ecl_kw_free(work_kw); + rd_kw_free(work_kw); } fortio_fseek(rst_file->fortio, target_pos, SEEK_SET); @@ -121,58 +121,57 @@ ecl_rst_file_type *ecl_rst_file_open_write_seek(const char *filename, return rst_file; } -ecl_rst_file_type *ecl_rst_file_open_write(const char *filename) { - ecl_rst_file_type *rst_file = ecl_rst_file_alloc(filename); +rd_rst_file_type *rd_rst_file_open_write(const char *filename) { + rd_rst_file_type *rst_file = rd_rst_file_alloc(filename); rst_file->fortio = - fortio_open_writer(filename, rst_file->fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, rst_file->fmt_file, RD_ENDIAN_FLIP); return rst_file; } -ecl_rst_file_type *ecl_rst_file_open_append(const char *filename) { - ecl_rst_file_type *rst_file = ecl_rst_file_alloc(filename); +rd_rst_file_type *rd_rst_file_open_append(const char *filename) { + rd_rst_file_type *rst_file = rd_rst_file_alloc(filename); rst_file->fortio = - fortio_open_append(filename, rst_file->fmt_file, ECL_ENDIAN_FLIP); + fortio_open_append(filename, rst_file->fmt_file, RD_ENDIAN_FLIP); return rst_file; } -void ecl_rst_file_close(ecl_rst_file_type *rst_file) { +void rd_rst_file_close(rd_rst_file_type *rst_file) { fortio_fclose(rst_file->fortio); free(rst_file); } -static void ecl_rst_file_fwrite_SEQNUM(ecl_rst_file_type *rst_file, - int seqnum) { - ecl_kw_type *seqnum_kw = ecl_kw_alloc(SEQNUM_KW, 1, ECL_INT); - ecl_kw_iset_int(seqnum_kw, 0, seqnum); - ecl_kw_fwrite(seqnum_kw, rst_file->fortio); - ecl_kw_free(seqnum_kw); +static void rd_rst_file_fwrite_SEQNUM(rd_rst_file_type *rst_file, int seqnum) { + rd_kw_type *seqnum_kw = rd_kw_alloc(SEQNUM_KW, 1, RD_INT); + rd_kw_iset_int(seqnum_kw, 0, seqnum); + rd_kw_fwrite(seqnum_kw, rst_file->fortio); + rd_kw_free(seqnum_kw); } -void ecl_rst_file_start_solution(ecl_rst_file_type *rst_file) { - ecl_kw_type *startsol_kw = ecl_kw_alloc(STARTSOL_KW, 0, ECL_MESS); - ecl_kw_fwrite(startsol_kw, rst_file->fortio); - ecl_kw_free(startsol_kw); +void rd_rst_file_start_solution(rd_rst_file_type *rst_file) { + rd_kw_type *startsol_kw = rd_kw_alloc(STARTSOL_KW, 0, RD_MESS); + rd_kw_fwrite(startsol_kw, rst_file->fortio); + rd_kw_free(startsol_kw); } -void ecl_rst_file_end_solution(ecl_rst_file_type *rst_file) { - ecl_kw_type *endsol_kw = ecl_kw_alloc(ENDSOL_KW, 0, ECL_MESS); - ecl_kw_fwrite(endsol_kw, rst_file->fortio); - ecl_kw_free(endsol_kw); +void rd_rst_file_end_solution(rd_rst_file_type *rst_file) { + rd_kw_type *endsol_kw = rd_kw_alloc(ENDSOL_KW, 0, RD_MESS); + rd_kw_fwrite(endsol_kw, rst_file->fortio); + rd_kw_free(endsol_kw); } -static ecl_kw_type *ecl_rst_file_alloc_INTEHEAD(ecl_rst_file_type *rst_file, - ecl_rsthead_type *rsthead, - int simulator) { - ecl_kw_type *intehead_kw = - ecl_kw_alloc(INTEHEAD_KW, INTEHEAD_RESTART_SIZE, ECL_INT); - ecl_kw_scalar_set_int(intehead_kw, 0); +static rd_kw_type *rd_rst_file_alloc_INTEHEAD(rd_rst_file_type *rst_file, + rd_rsthead_type *rsthead, + int simulator) { + rd_kw_type *intehead_kw = + rd_kw_alloc(INTEHEAD_KW, INTEHEAD_RESTART_SIZE, RD_INT); + rd_kw_scalar_set_int(intehead_kw, 0); - ecl_kw_iset_int(intehead_kw, INTEHEAD_UNIT_INDEX, rsthead->unit_system); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NX_INDEX, rsthead->nx); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NY_INDEX, rsthead->ny); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NZ_INDEX, rsthead->nz); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NACTIVE_INDEX, rsthead->nactive); - ecl_kw_iset_int(intehead_kw, INTEHEAD_PHASE_INDEX, rsthead->phase_sum); + rd_kw_iset_int(intehead_kw, INTEHEAD_UNIT_INDEX, rsthead->unit_system); + rd_kw_iset_int(intehead_kw, INTEHEAD_NX_INDEX, rsthead->nx); + rd_kw_iset_int(intehead_kw, INTEHEAD_NY_INDEX, rsthead->ny); + rd_kw_iset_int(intehead_kw, INTEHEAD_NZ_INDEX, rsthead->nz); + rd_kw_iset_int(intehead_kw, INTEHEAD_NACTIVE_INDEX, rsthead->nactive); + rd_kw_iset_int(intehead_kw, INTEHEAD_PHASE_INDEX, rsthead->phase_sum); /* All well properties are hardcoded to zero. */ { @@ -183,96 +182,95 @@ static ecl_kw_type *ecl_rst_file_alloc_INTEHEAD(ecl_rst_file_type *rst_file, int NSEGMX = 0; int NISEGZ = 0; - ecl_kw_iset_int(intehead_kw, INTEHEAD_NWELLS_INDEX, rsthead->nwells); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NCWMAX_INDEX, rsthead->ncwmax); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NWGMAX_INDEX, NWGMAX); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NGMAXZ_INDEX, NGMAXZ); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NIWELZ_INDEX, rsthead->niwelz); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NZWELZ_INDEX, rsthead->nzwelz); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NICONZ_INDEX, rsthead->niconz); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NIGRPZ_INDEX, NIGRPZ); + rd_kw_iset_int(intehead_kw, INTEHEAD_NWELLS_INDEX, rsthead->nwells); + rd_kw_iset_int(intehead_kw, INTEHEAD_NCWMAX_INDEX, rsthead->ncwmax); + rd_kw_iset_int(intehead_kw, INTEHEAD_NWGMAX_INDEX, NWGMAX); + rd_kw_iset_int(intehead_kw, INTEHEAD_NGMAXZ_INDEX, NGMAXZ); + rd_kw_iset_int(intehead_kw, INTEHEAD_NIWELZ_INDEX, rsthead->niwelz); + rd_kw_iset_int(intehead_kw, INTEHEAD_NZWELZ_INDEX, rsthead->nzwelz); + rd_kw_iset_int(intehead_kw, INTEHEAD_NICONZ_INDEX, rsthead->niconz); + rd_kw_iset_int(intehead_kw, INTEHEAD_NIGRPZ_INDEX, NIGRPZ); { - ecl_util_set_date_values(rsthead->sim_time, &rsthead->day, - &rsthead->month, &rsthead->year); - ecl_kw_iset_int(intehead_kw, INTEHEAD_DAY_INDEX, rsthead->day); - ecl_kw_iset_int(intehead_kw, INTEHEAD_MONTH_INDEX, rsthead->month); - ecl_kw_iset_int(intehead_kw, INTEHEAD_YEAR_INDEX, rsthead->year); + rd_set_date_values(rsthead->sim_time, &rsthead->day, + &rsthead->month, &rsthead->year); + rd_kw_iset_int(intehead_kw, INTEHEAD_DAY_INDEX, rsthead->day); + rd_kw_iset_int(intehead_kw, INTEHEAD_MONTH_INDEX, rsthead->month); + rd_kw_iset_int(intehead_kw, INTEHEAD_YEAR_INDEX, rsthead->year); } - ecl_kw_iset_int(intehead_kw, INTEHEAD_IPROG_INDEX, simulator); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NSWLMX_INDEX, NSWLMX); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NSEGMX_INDEX, NSEGMX); - ecl_kw_iset_int(intehead_kw, INTEHEAD_NISEGZ_INDEX, NISEGZ); + rd_kw_iset_int(intehead_kw, INTEHEAD_IPROG_INDEX, simulator); + rd_kw_iset_int(intehead_kw, INTEHEAD_NSWLMX_INDEX, NSWLMX); + rd_kw_iset_int(intehead_kw, INTEHEAD_NSEGMX_INDEX, NSEGMX); + rd_kw_iset_int(intehead_kw, INTEHEAD_NISEGZ_INDEX, NISEGZ); } return intehead_kw; } -static ecl_kw_type *ecl_rst_file_alloc_LOGIHEAD(int simulator) { +static rd_kw_type *rd_rst_file_alloc_LOGIHEAD(int simulator) { bool dual_porosity = false; bool radial_grid_ECLIPSE100 = false; bool radial_grid_ECLIPSE300 = false; - ecl_kw_type *logihead_kw = - ecl_kw_alloc(LOGIHEAD_KW, LOGIHEAD_RESTART_SIZE, ECL_BOOL); + rd_kw_type *logihead_kw = + rd_kw_alloc(LOGIHEAD_KW, LOGIHEAD_RESTART_SIZE, RD_BOOL); - ecl_kw_scalar_set_bool(logihead_kw, false); + rd_kw_scalar_set_bool(logihead_kw, false); if (simulator == INTEHEAD_ECLIPSE100_VALUE) - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL100_INDEX, - radial_grid_ECLIPSE100); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL100_INDEX, + radial_grid_ECLIPSE100); else - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL300_INDEX, - radial_grid_ECLIPSE300); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_RADIAL300_INDEX, + radial_grid_ECLIPSE300); - ecl_kw_iset_bool(logihead_kw, LOGIHEAD_DUALP_INDEX, dual_porosity); + rd_kw_iset_bool(logihead_kw, LOGIHEAD_DUALP_INDEX, dual_porosity); return logihead_kw; } -static ecl_kw_type *ecl_rst_file_alloc_DOUBHEAD(ecl_rst_file_type *rst_file, - double days) { - ecl_kw_type *doubhead_kw = - ecl_kw_alloc(DOUBHEAD_KW, DOUBHEAD_RESTART_SIZE, ECL_DOUBLE); +static rd_kw_type *rd_rst_file_alloc_DOUBHEAD(rd_rst_file_type *rst_file, + double days) { + rd_kw_type *doubhead_kw = + rd_kw_alloc(DOUBHEAD_KW, DOUBHEAD_RESTART_SIZE, RD_DOUBLE); - ecl_kw_scalar_set_double(doubhead_kw, 0); - ecl_kw_iset_double(doubhead_kw, DOUBHEAD_DAYS_INDEX, days); + rd_kw_scalar_set_double(doubhead_kw, 0); + rd_kw_iset_double(doubhead_kw, DOUBHEAD_DAYS_INDEX, days); return doubhead_kw; } -void ecl_rst_file_fwrite_header(ecl_rst_file_type *rst_file, int seqnum, - ecl_rsthead_type *rsthead_data) { +void rd_rst_file_fwrite_header(rd_rst_file_type *rst_file, int seqnum, + rd_rsthead_type *rsthead_data) { if (rst_file->unified) - ecl_rst_file_fwrite_SEQNUM(rst_file, seqnum); + rd_rst_file_fwrite_SEQNUM(rst_file, seqnum); { - ecl_kw_type *intehead_kw = ecl_rst_file_alloc_INTEHEAD( + rd_kw_type *intehead_kw = rd_rst_file_alloc_INTEHEAD( rst_file, rsthead_data, INTEHEAD_ECLIPSE100_VALUE); - ecl_kw_fwrite(intehead_kw, rst_file->fortio); - ecl_kw_free(intehead_kw); + rd_kw_fwrite(intehead_kw, rst_file->fortio); + rd_kw_free(intehead_kw); } { - ecl_kw_type *logihead_kw = - ecl_rst_file_alloc_LOGIHEAD(INTEHEAD_ECLIPSE100_VALUE); - ecl_kw_fwrite(logihead_kw, rst_file->fortio); - ecl_kw_free(logihead_kw); + rd_kw_type *logihead_kw = + rd_rst_file_alloc_LOGIHEAD(INTEHEAD_ECLIPSE100_VALUE); + rd_kw_fwrite(logihead_kw, rst_file->fortio); + rd_kw_free(logihead_kw); } { - ecl_kw_type *doubhead_kw = - ecl_rst_file_alloc_DOUBHEAD(rst_file, rsthead_data->sim_days); - ecl_kw_fwrite(doubhead_kw, rst_file->fortio); - ecl_kw_free(doubhead_kw); + rd_kw_type *doubhead_kw = + rd_rst_file_alloc_DOUBHEAD(rst_file, rsthead_data->sim_days); + rd_kw_fwrite(doubhead_kw, rst_file->fortio); + rd_kw_free(doubhead_kw); } } -void ecl_rst_file_add_kw(ecl_rst_file_type *rst_file, - const ecl_kw_type *ecl_kw) { - ecl_kw_fwrite(ecl_kw, rst_file->fortio); +void rd_rst_file_add_kw(rd_rst_file_type *rst_file, const rd_kw_type *rd_kw) { + rd_kw_fwrite(rd_kw, rst_file->fortio); } -offset_type ecl_rst_file_ftell(const ecl_rst_file_type *rst_file) { +offset_type rd_rst_file_ftell(const rd_rst_file_type *rst_file) { return fortio_ftell(rst_file->fortio); } diff --git a/lib/resdata/rd_rsthead.cpp b/lib/resdata/rd_rsthead.cpp index 8f51a73d66..037759c226 100644 --- a/lib/resdata/rd_rsthead.cpp +++ b/lib/resdata/rd_rsthead.cpp @@ -2,43 +2,42 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include static time_t rsthead_date(int day, int month, int year) { - return ecl_util_make_date(day, month, year); + return rd_make_date(day, month, year); } -time_t ecl_rsthead_date(const ecl_kw_type *intehead_kw) { - return rsthead_date(ecl_kw_iget_int(intehead_kw, INTEHEAD_DAY_INDEX), - ecl_kw_iget_int(intehead_kw, INTEHEAD_MONTH_INDEX), - ecl_kw_iget_int(intehead_kw, INTEHEAD_YEAR_INDEX)); +time_t rd_rsthead_date(const rd_kw_type *intehead_kw) { + return rsthead_date(rd_kw_iget_int(intehead_kw, INTEHEAD_DAY_INDEX), + rd_kw_iget_int(intehead_kw, INTEHEAD_MONTH_INDEX), + rd_kw_iget_int(intehead_kw, INTEHEAD_YEAR_INDEX)); } -time_t ecl_rsthead_get_sim_time(const ecl_rsthead_type *header) { +time_t rd_rsthead_get_sim_time(const rd_rsthead_type *header) { return header->sim_time; } -double ecl_rsthead_get_sim_days(const ecl_rsthead_type *header) { +double rd_rsthead_get_sim_days(const rd_rsthead_type *header) { return header->sim_days; } -int ecl_rsthead_get_report_step(const ecl_rsthead_type *header) { +int rd_rsthead_get_report_step(const rd_rsthead_type *header) { return header->report_step; } -ecl_rsthead_type *ecl_rsthead_alloc_from_kw(int report_step, - const ecl_kw_type *intehead_kw, - const ecl_kw_type *doubhead_kw, - const ecl_kw_type *logihead_kw) { - ecl_rsthead_type *rsthead = - (ecl_rsthead_type *)util_malloc(sizeof *rsthead); +rd_rsthead_type *rd_rsthead_alloc_from_kw(int report_step, + const rd_kw_type *intehead_kw, + const rd_kw_type *doubhead_kw, + const rd_kw_type *logihead_kw) { + rd_rsthead_type *rsthead = (rd_rsthead_type *)util_malloc(sizeof *rsthead); rsthead->report_step = report_step; { - const int *data = (const int *)ecl_kw_get_void_ptr(intehead_kw); + const int *data = (const int *)rd_kw_get_void_ptr(intehead_kw); rsthead->day = data[INTEHEAD_DAY_INDEX]; rsthead->month = data[INTEHEAD_MONTH_INDEX]; @@ -69,9 +68,9 @@ ecl_rsthead_type *ecl_rsthead_alloc_from_kw(int report_step, rsthead->sim_time = rsthead_date(rsthead->day, rsthead->month, rsthead->year); } - rsthead->sim_days = ecl_kw_iget_double(doubhead_kw, DOUBHEAD_DAYS_INDEX); + rsthead->sim_days = rd_kw_iget_double(doubhead_kw, DOUBHEAD_DAYS_INDEX); if (logihead_kw) - rsthead->dualp = ecl_kw_iget_bool(logihead_kw, LOGIHEAD_DUALP_INDEX); + rsthead->dualp = rd_kw_iget_bool(logihead_kw, LOGIHEAD_DUALP_INDEX); return rsthead; } @@ -86,30 +85,29 @@ ecl_rsthead_type *ecl_rsthead_alloc_from_kw(int report_step, *prior* to calling this function. */ -ecl_rsthead_type *ecl_rsthead_alloc(const ecl_file_view_type *rst_view, - int report_step) { - const ecl_kw_type *intehead_kw = - ecl_file_view_iget_named_kw(rst_view, INTEHEAD_KW, 0); - const ecl_kw_type *doubhead_kw = - ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); - const ecl_kw_type *logihead_kw = NULL; - - if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) - logihead_kw = ecl_file_view_iget_named_kw(rst_view, LOGIHEAD_KW, 0); - - if (ecl_file_view_has_kw(rst_view, SEQNUM_KW)) { - const ecl_kw_type *seqnum_kw = - ecl_file_view_iget_named_kw(rst_view, SEQNUM_KW, 0); - report_step = ecl_kw_iget_int(seqnum_kw, 0); +rd_rsthead_type *rd_rsthead_alloc(const rd_file_view_type *rst_view, + int report_step) { + const rd_kw_type *intehead_kw = + rd_file_view_iget_named_kw(rst_view, INTEHEAD_KW, 0); + const rd_kw_type *doubhead_kw = + rd_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); + const rd_kw_type *logihead_kw = NULL; + + if (rd_file_view_has_kw(rst_view, LOGIHEAD_KW)) + logihead_kw = rd_file_view_iget_named_kw(rst_view, LOGIHEAD_KW, 0); + + if (rd_file_view_has_kw(rst_view, SEQNUM_KW)) { + const rd_kw_type *seqnum_kw = + rd_file_view_iget_named_kw(rst_view, SEQNUM_KW, 0); + report_step = rd_kw_iget_int(seqnum_kw, 0); } - return ecl_rsthead_alloc_from_kw(report_step, intehead_kw, doubhead_kw, - logihead_kw); + return rd_rsthead_alloc_from_kw(report_step, intehead_kw, doubhead_kw, + logihead_kw); } -ecl_rsthead_type *ecl_rsthead_alloc_empty() { - ecl_rsthead_type *rsthead = - (ecl_rsthead_type *)util_malloc(sizeof *rsthead); +rd_rsthead_type *rd_rsthead_alloc_empty() { + rd_rsthead_type *rsthead = (rd_rsthead_type *)util_malloc(sizeof *rsthead); rsthead->day = 0; rsthead->month = 0; @@ -143,14 +141,14 @@ ecl_rsthead_type *ecl_rsthead_alloc_empty() { return rsthead; } -void ecl_rsthead_fprintf(const ecl_rsthead_type *header, FILE *stream) { +void rd_rsthead_fprintf(const rd_rsthead_type *header, FILE *stream) { fprintf(stream, "nx %d \n", header->nx); fprintf(stream, "nwells %d \n", header->nwells); fprintf(stream, "niwelz %d \n\n", header->niwelz); } -bool ecl_rsthead_equal(const ecl_rsthead_type *header1, - const ecl_rsthead_type *header2) { +bool rd_rsthead_equal(const rd_rsthead_type *header1, + const rd_rsthead_type *header2) { bool equal = true; equal = equal && (header1->day == header2->day); @@ -180,7 +178,7 @@ bool ecl_rsthead_equal(const ecl_rsthead_type *header1, return equal; } -void ecl_rsthead_fprintf_struct(const ecl_rsthead_type *header, FILE *stream) { +void rd_rsthead_fprintf_struct(const rd_rsthead_type *header, FILE *stream) { fprintf(stream, "{.day = %d,\n", header->day); fprintf(stream, ".year = %d,\n", header->year); fprintf(stream, ".month = %d,\n", header->month); @@ -205,12 +203,12 @@ void ecl_rsthead_fprintf_struct(const ecl_rsthead_type *header, FILE *stream) { fprintf(stream, ".sim_days = %g};\n", header->sim_days); } -void ecl_rsthead_free(ecl_rsthead_type *rsthead) { free(rsthead); } +void rd_rsthead_free(rd_rsthead_type *rsthead) { free(rsthead); } -int ecl_rsthead_get_nxconz(const ecl_rsthead_type *rsthead) { +int rd_rsthead_get_nxconz(const rd_rsthead_type *rsthead) { return rsthead->nxconz; } -int ecl_rsthead_get_ncwmax(const ecl_rsthead_type *rsthead) { +int rd_rsthead_get_ncwmax(const rd_rsthead_type *rsthead) { return rsthead->ncwmax; } diff --git a/lib/resdata/rd_smspec.cpp b/lib/resdata/rd_smspec.cpp index c11dc2ba89..e1077b20e7 100644 --- a/lib/resdata/rd_smspec.cpp +++ b/lib/resdata/rd_smspec.cpp @@ -20,14 +20,14 @@ #include #include "detail/util/path.hpp" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_FNMATCH #include @@ -42,32 +42,32 @@ ------------------------------- 1. The function smspec_node_alloc() must be updated to return a valid - ecl::smspec_node instance when called with the new var_type. + rd::smspec_node instance when called with the new var_type. - 2. Update the function ecl_smpec_install_gen_key() to install smpec_index + 2. Update the function rd_smpec_install_gen_key() to install smpec_index instances of this particular type. The format of the general key is implicitly defined in this function. - 3. The ecl_smspec structure supports two different types of lookup: + 3. The rd_smspec structure supports two different types of lookup: a) Lookup based on general key like e.g. WWCT:OP6 b) Specific lookup based on the variable type, i.e. : - ecl_smspec_get_well_var( xxx , well_name , var). + rd_smspec_get_well_var( xxx , well_name , var). Historically everything started with specific lookup as in case b); however the general lookup proved to be very convenient, and the specfic lookup method has seen less use[*]. The final step in supporting a new variable is to update the function - ecl_smspec_fread_header(). + rd_smspec_fread_header(). If you want to support specific lookup of the new variable type you - must add the necessary datastructures to the ecl_smspec_struct + must add the necessary datastructures to the rd_smspec_struct structure and then subsequently fill that structure in the big - switch() in ecl_smspec_fread_header() - if you do not care about + switch() in rd_smspec_fread_header() - if you do not care about specific lookup you just have to add an empty case() slot to the - switch in ecl_smspec_fread_header(). The LGR variables, and also - ECL_SMSPEC_SEGMENT_VAR do not support specific lookup. + switch in rd_smspec_fread_header(). The LGR variables, and also + RD_SMSPEC_SEGMENT_VAR do not support specific lookup. [*]: The advantage of the specific lookup is that it is possible to supply better error messages (The well 'XX' does not @@ -76,16 +76,16 @@ well names. 4. Mark the variable type as supported with a 'X' in the defintion of - ecl_smspec_var_type in ecl_smspec.h. + rd_smspec_var_type in rd_smspec.h. */ -#define ECL_SMSPEC_ID 806647 +#define RD_SMSPEC_ID 806647 #define PARAMS_GLOBAL_DEFAULT -99 -typedef std::map node_map; +typedef std::map node_map; -struct ecl_smspec_struct { +struct rd_smspec_struct { UTIL_TYPE_ID_DECLARATION; /* All the hash tables listed below here are different ways to access @@ -109,7 +109,7 @@ struct ecl_smspec_struct { std::map> well_completion_var_index; /* Indexes for completion indexes .*/ - std::vector> smspec_nodes; + std::vector> smspec_nodes; bool write_mode; bool need_nums; std::vector index_map; @@ -131,14 +131,14 @@ struct ecl_smspec_struct { time_t sim_start_time; /* When did the simulation start - worldtime. */ int time_index; /* The fields time_index, day_index, month_index and year_index */ - int day_index; /* are used by the ecl_sum_data object to locate per. timestep */ + int day_index; /* are used by the rd_sum_data object to locate per. timestep */ int month_index; /* time information. */ int year_index; bool has_lgr; std::vector params_default; std::string restart_case; - ert_ecl_unit_enum unit_system; + ert_rd_unit_enum unit_system; int restart_step; }; @@ -146,7 +146,7 @@ struct ecl_smspec_struct { About indexing: --------------- -The ECLISPE summary files are organised (roughly) like this: +The RDISPE summary files are organised (roughly) like this: 1. A header-file called xxx.SMPSEC is written, which is common to every timestep. @@ -211,8 +211,8 @@ static const char *smspec_required_keywords[] = { namespace { -const ecl::smspec_node *ecl_smspec_get_var_node(const node_map &mp, - const char *var) { +const rd::smspec_node *rd_smspec_get_var_node(const node_map &mp, + const char *var) { const auto it = mp.find(var); if (it == mp.end()) return nullptr; @@ -220,31 +220,31 @@ const ecl::smspec_node *ecl_smspec_get_var_node(const node_map &mp, return it->second; } -const ecl::smspec_node * -ecl_smspec_get_str_key_var_node(const std::map &mp, - const char *key, const char *var) { +const rd::smspec_node * +rd_smspec_get_str_key_var_node(const std::map &mp, + const char *key, const char *var) { const auto key_it = mp.find(key); if (key_it == mp.end()) return nullptr; const node_map &var_map = key_it->second; - return ecl_smspec_get_var_node(var_map, var); + return rd_smspec_get_var_node(var_map, var); } -const ecl::smspec_node * -ecl_smspec_get_int_key_var_node(const std::map &mp, int key, - const char *var) { +const rd::smspec_node * +rd_smspec_get_int_key_var_node(const std::map &mp, int key, + const char *var) { const auto key_it = mp.find(key); if (key_it == mp.end()) return nullptr; const auto &var_map = key_it->second; - return ecl_smspec_get_var_node(var_map, var); + return rd_smspec_get_var_node(var_map, var); } } //end namespace -int ecl_smspec_num_nodes(const ecl_smspec_type *smspec) { +int rd_smspec_num_nodes(const rd_smspec_type *smspec) { return smspec->smspec_nodes.size(); } @@ -255,56 +255,56 @@ int ecl_smspec_num_nodes(const ecl_smspec_type *smspec) { params_size member. */ -int ecl_smspec_get_params_size(const ecl_smspec_type *smspec) { +int rd_smspec_get_params_size(const rd_smspec_type *smspec) { return smspec->params_size; } -ecl_smspec_type *ecl_smspec_alloc_empty(bool write_mode, - const char *key_join_string) { - ecl_smspec_type *ecl_smspec = new ecl_smspec_type(); - UTIL_TYPE_ID_INIT(ecl_smspec, ECL_SMSPEC_ID); +rd_smspec_type *rd_smspec_alloc_empty(bool write_mode, + const char *key_join_string) { + rd_smspec_type *rd_smspec = new rd_smspec_type(); + UTIL_TYPE_ID_INIT(rd_smspec, RD_SMSPEC_ID); - ecl_smspec->sim_start_time = -1; - ecl_smspec->key_join_string = key_join_string; - ecl_smspec->header_file = ""; + rd_smspec->sim_start_time = -1; + rd_smspec->key_join_string = key_join_string; + rd_smspec->header_file = ""; - ecl_smspec->time_index = -1; - ecl_smspec->day_index = -1; - ecl_smspec->year_index = -1; - ecl_smspec->month_index = -1; - ecl_smspec->time_seconds = -1; - ecl_smspec->params_size = -1; + rd_smspec->time_index = -1; + rd_smspec->day_index = -1; + rd_smspec->year_index = -1; + rd_smspec->month_index = -1; + rd_smspec->time_seconds = -1; + rd_smspec->params_size = -1; /* The unit system is given as an integer in the INTEHEAD keyword. The INTEHEAD keyword is optional, and we have for a long time been completely oblivious to the possibility of extracting unit system information from the SMSPEC file. */ - ecl_smspec->unit_system = ECL_METRIC_UNITS; + rd_smspec->unit_system = RD_METRIC_UNITS; - ecl_smspec->restart_step = -1; - ecl_smspec->write_mode = write_mode; - ecl_smspec->need_nums = false; + rd_smspec->restart_step = -1; + rd_smspec->write_mode = write_mode; + rd_smspec->need_nums = false; - return ecl_smspec; + return rd_smspec; } -int *ecl_smspec_alloc_mapping(const ecl_smspec_type *self, - const ecl_smspec_type *other) { - int params_size = ecl_smspec_get_params_size(self); +int *rd_smspec_alloc_mapping(const rd_smspec_type *self, + const rd_smspec_type *other) { + int params_size = rd_smspec_get_params_size(self); int *mapping = (int *)util_malloc(params_size * sizeof *mapping); for (int i = 0; i < params_size; i++) mapping[i] = -1; - for (int i = 0; i < ecl_smspec_num_nodes(self); i++) { - const ecl::smspec_node &self_node = - ecl_smspec_iget_node_w_node_index(self, i); + for (int i = 0; i < rd_smspec_num_nodes(self); i++) { + const rd::smspec_node &self_node = + rd_smspec_iget_node_w_node_index(self, i); int self_index = self_node.get_params_index(); const char *key = self_node.get_gen_key1(); - if (ecl_smspec_has_general_var(other, key)) { - const ecl::smspec_node &other_node = - ecl_smspec_get_general_var_node(other, key); + if (rd_smspec_has_general_var(other, key)) { + const rd::smspec_node &other_node = + rd_smspec_get_general_var_node(other, key); int other_index = other_node.get_params_index(); mapping[self_index] = other_index; } @@ -319,68 +319,67 @@ int *ecl_smspec_alloc_mapping(const ecl_smspec_type *self, params_index of the returned smspec_node instance. */ -const ecl::smspec_node & -ecl_smspec_iget_node_w_node_index(const ecl_smspec_type *smspec, - int node_index) { +const rd::smspec_node & +rd_smspec_iget_node_w_node_index(const rd_smspec_type *smspec, int node_index) { const auto &node = smspec->smspec_nodes[node_index]; return *node.get(); } /* - The ecl_smspec_iget_node() function is only retained for compatibility; should be - replaced with calls to the more explicit: ecl_smspec_iget_node_w_node_index(). + The rd_smspec_iget_node() function is only retained for compatibility; should be + replaced with calls to the more explicit: rd_smspec_iget_node_w_node_index(). */ -const ecl::smspec_node &ecl_smspec_iget_node(const ecl_smspec_type *smspec, - int index) { - return ecl_smspec_iget_node_w_node_index(smspec, index); +const rd::smspec_node &rd_smspec_iget_node(const rd_smspec_type *smspec, + int index) { + return rd_smspec_iget_node_w_node_index(smspec, index); } -const ecl::smspec_node & -ecl_smspec_iget_node_w_params_index(const ecl_smspec_type *smspec, - int params_index) { +const rd::smspec_node & +rd_smspec_iget_node_w_params_index(const rd_smspec_type *smspec, + int params_index) { int node_index = smspec->inv_index_map.at(params_index); - return ecl_smspec_iget_node_w_node_index(smspec, node_index); + return rd_smspec_iget_node_w_node_index(smspec, node_index); } /** * Returns an ecl data type for which all names will fit. If the maximum name - * length is at most 8, an ECL_CHAR is returned and otherwise a large enough - * ECL_STRING. + * length is at most 8, an RD_CHAR is returned and otherwise a large enough + * RD_STRING. */ -static ecl_data_type get_wgnames_type(const ecl_smspec_type *smspec) { +static rd_data_type get_wgnames_type(const rd_smspec_type *smspec) { size_t max_len = 0; - for (int i = 0; i < ecl_smspec_num_nodes(smspec); ++i) { - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(smspec, i); + for (int i = 0; i < rd_smspec_num_nodes(smspec); ++i) { + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(smspec, i); const char *name = smspec_node_get_wgname(&node); if (name) max_len = util_size_t_max(max_len, strlen(name)); } - return max_len <= ECL_STRING8_LENGTH ? ECL_CHAR : ECL_STRING(max_len); + return max_len <= RD_STRING8_LENGTH ? RD_CHAR : RD_STRING(max_len); } -static void ecl_smspec_fwrite_INTEHEAD(const ecl_smspec_type *smspec, - fortio_type *fortio) { - ecl_kw_type *intehead = - ecl_kw_alloc(INTEHEAD_KW, INTEHEAD_SMSPEC_SIZE, ECL_INT); - ecl_kw_iset_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX, smspec->unit_system); +static void rd_smspec_fwrite_INTEHEAD(const rd_smspec_type *smspec, + fortio_type *fortio) { + rd_kw_type *intehead = + rd_kw_alloc(INTEHEAD_KW, INTEHEAD_SMSPEC_SIZE, RD_INT); + rd_kw_iset_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX, smspec->unit_system); /* The simulator type is just hardcoded to ECLIPSE100. */ - ecl_kw_iset_int(intehead, INTEHEAD_SMSPEC_IPROG_INDEX, - INTEHEAD_ECLIPSE100_VALUE); - ecl_kw_fwrite(intehead, fortio); - ecl_kw_free(intehead); + rd_kw_iset_int(intehead, INTEHEAD_SMSPEC_IPROG_INDEX, + INTEHEAD_ECLIPSE100_VALUE); + rd_kw_fwrite(intehead, fortio); + rd_kw_free(intehead); } -static void ecl_smspec_fwrite_RESTART(const ecl_smspec_type *smspec, - fortio_type *fortio) { - ecl_kw_type *restart_kw = - ecl_kw_alloc(RESTART_KW, SUMMARY_RESTART_SIZE, ECL_CHAR); +static void rd_smspec_fwrite_RESTART(const rd_smspec_type *smspec, + fortio_type *fortio) { + rd_kw_type *restart_kw = + rd_kw_alloc(RESTART_KW, SUMMARY_RESTART_SIZE, RD_CHAR); for (int i = 0; i < SUMMARY_RESTART_SIZE; i++) - ecl_kw_iset_string8(restart_kw, i, ""); + rd_kw_iset_string8(restart_kw, i, ""); if (smspec->restart_case.size() > 0) { size_t restart_case_len = smspec->restart_case.size(); @@ -388,79 +387,78 @@ static void ecl_smspec_fwrite_RESTART(const ecl_smspec_type *smspec, size_t offset = 0; for (size_t i = 0; i < SUMMARY_RESTART_SIZE; i++) { if (offset < restart_case_len) - ecl_kw_iset_string8(restart_kw, i, - &smspec->restart_case[offset]); - offset += ECL_STRING8_LENGTH; + rd_kw_iset_string8(restart_kw, i, + &smspec->restart_case[offset]); + offset += RD_STRING8_LENGTH; } } - ecl_kw_fwrite(restart_kw, fortio); - ecl_kw_free(restart_kw); + rd_kw_fwrite(restart_kw, fortio); + rd_kw_free(restart_kw); } -static void ecl_smspec_fwrite_DIMENS(const ecl_smspec_type *smspec, - fortio_type *fortio) { - ecl_kw_type *dimens_kw = ecl_kw_alloc(DIMENS_KW, DIMENS_SIZE, ECL_INT); - int num_nodes = ecl_smspec_num_nodes(smspec); - ecl_kw_iset_int(dimens_kw, DIMENS_SMSPEC_SIZE_INDEX, num_nodes); - ecl_kw_iset_int(dimens_kw, DIMENS_SMSPEC_NX_INDEX, smspec->grid_dims[0]); - ecl_kw_iset_int(dimens_kw, DIMENS_SMSPEC_NY_INDEX, smspec->grid_dims[1]); - ecl_kw_iset_int(dimens_kw, DIMENS_SMSPEC_NZ_INDEX, smspec->grid_dims[2]); - ecl_kw_iset_int(dimens_kw, 4, 0); // Do not know what this is for. - ecl_kw_iset_int(dimens_kw, DIMENS_SMSPEC_RESTART_STEP_INDEX, - smspec->restart_step); - - ecl_kw_fwrite(dimens_kw, fortio); - ecl_kw_free(dimens_kw); -} - -static void ecl_smspec_fwrite_STARTDAT(const ecl_smspec_type *smspec, - fortio_type *fortio) { - ecl_kw_type *startdat_kw = - ecl_kw_alloc(STARTDAT_KW, STARTDAT_SIZE, ECL_INT); +static void rd_smspec_fwrite_DIMENS(const rd_smspec_type *smspec, + fortio_type *fortio) { + rd_kw_type *dimens_kw = rd_kw_alloc(DIMENS_KW, DIMENS_SIZE, RD_INT); + int num_nodes = rd_smspec_num_nodes(smspec); + rd_kw_iset_int(dimens_kw, DIMENS_SMSPEC_SIZE_INDEX, num_nodes); + rd_kw_iset_int(dimens_kw, DIMENS_SMSPEC_NX_INDEX, smspec->grid_dims[0]); + rd_kw_iset_int(dimens_kw, DIMENS_SMSPEC_NY_INDEX, smspec->grid_dims[1]); + rd_kw_iset_int(dimens_kw, DIMENS_SMSPEC_NZ_INDEX, smspec->grid_dims[2]); + rd_kw_iset_int(dimens_kw, 4, 0); // Do not know what this is for. + rd_kw_iset_int(dimens_kw, DIMENS_SMSPEC_RESTART_STEP_INDEX, + smspec->restart_step); + + rd_kw_fwrite(dimens_kw, fortio); + rd_kw_free(dimens_kw); +} + +static void rd_smspec_fwrite_STARTDAT(const rd_smspec_type *smspec, + fortio_type *fortio) { + rd_kw_type *startdat_kw = rd_kw_alloc(STARTDAT_KW, STARTDAT_SIZE, RD_INT); int second, minute, hour, mday, month, year; - ecl_util_set_datetime_values(smspec->sim_start_time, &second, &minute, - &hour, &mday, &month, &year); + rd_set_datetime_values(smspec->sim_start_time, &second, &minute, &hour, + &mday, &month, &year); - ecl_kw_iset_int(startdat_kw, STARTDAT_DAY_INDEX, mday); - ecl_kw_iset_int(startdat_kw, STARTDAT_MONTH_INDEX, month); - ecl_kw_iset_int(startdat_kw, STARTDAT_YEAR_INDEX, year); - ecl_kw_iset_int(startdat_kw, STARTDAT_HOUR_INDEX, hour); - ecl_kw_iset_int(startdat_kw, STARTDAT_MINUTE_INDEX, minute); - ecl_kw_iset_int(startdat_kw, STARTDAT_MICRO_SECOND_INDEX, second * 1000000); + rd_kw_iset_int(startdat_kw, STARTDAT_DAY_INDEX, mday); + rd_kw_iset_int(startdat_kw, STARTDAT_MONTH_INDEX, month); + rd_kw_iset_int(startdat_kw, STARTDAT_YEAR_INDEX, year); + rd_kw_iset_int(startdat_kw, STARTDAT_HOUR_INDEX, hour); + rd_kw_iset_int(startdat_kw, STARTDAT_MINUTE_INDEX, minute); + rd_kw_iset_int(startdat_kw, STARTDAT_MICRO_SECOND_INDEX, second * 1000000); - ecl_kw_fwrite(startdat_kw, fortio); - ecl_kw_free(startdat_kw); + rd_kw_fwrite(startdat_kw, fortio); + rd_kw_free(startdat_kw); } -static void ecl_smspec_fortio_fwrite(const ecl_smspec_type *smspec, - fortio_type *fortio) { - ecl_smspec_fwrite_INTEHEAD(smspec, fortio); - ecl_smspec_fwrite_RESTART(smspec, fortio); - ecl_smspec_fwrite_DIMENS(smspec, fortio); +static void rd_smspec_fortio_fwrite(const rd_smspec_type *smspec, + fortio_type *fortio) { + rd_smspec_fwrite_INTEHEAD(smspec, fortio); + rd_smspec_fwrite_RESTART(smspec, fortio); + rd_smspec_fwrite_DIMENS(smspec, fortio); - int num_nodes = ecl_smspec_num_nodes(smspec); - ecl_kw_type *keywords_kw = ecl_kw_alloc(KEYWORDS_KW, num_nodes, ECL_CHAR); - ecl_kw_type *units_kw = ecl_kw_alloc(UNITS_KW, num_nodes, ECL_CHAR); - ecl_kw_type *nums_kw = NULL; + int num_nodes = rd_smspec_num_nodes(smspec); + rd_kw_type *keywords_kw = rd_kw_alloc(KEYWORDS_KW, num_nodes, RD_CHAR); + rd_kw_type *units_kw = rd_kw_alloc(UNITS_KW, num_nodes, RD_CHAR); + rd_kw_type *nums_kw = NULL; - // If the names_type is an ECL_STRING we expect this to be an INTERSECT + // If the names_type is an RD_STRING we expect this to be an INTERSECT // summary, otherwise an ECLIPSE summary. - ecl_data_type names_type = get_wgnames_type(smspec); - ecl_kw_type *wgnames_kw = - ecl_kw_alloc(ecl_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW, - num_nodes, names_type); + rd_data_type names_type = get_wgnames_type(smspec); + rd_kw_type *wgnames_kw = + rd_kw_alloc(rd_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW, + num_nodes, names_type); if (smspec->need_nums) - nums_kw = ecl_kw_alloc(NUMS_KW, num_nodes, ECL_INT); + nums_kw = rd_kw_alloc(NUMS_KW, num_nodes, RD_INT); - for (int i = 0; i < ecl_smspec_num_nodes(smspec); i++) { - const ecl::smspec_node &smspec_node = - ecl_smspec_iget_node_w_node_index(smspec, i); + for (int i = 0; i < rd_smspec_num_nodes(smspec); i++) { + const rd::smspec_node &smspec_node = + rd_smspec_iget_node_w_node_index(smspec, i); /* It is possible to add variables with deferred initialisation - with the ecl_sum_add_blank_var() function. Before these + with the rd_sum_add_blank_var() function. Before these variables can be actually used for anything interesting they - must be initialized with the ecl_sum_init_var() function. + must be initialized with the rd_sum_init_var() function. If a call to save the smspec file comes before all the variable have been initialized things will potentially go @@ -475,47 +473,46 @@ static void ecl_smspec_fortio_fwrite(const ecl_smspec_type *smspec, ignored when/if this smspec file is read in at a later stage. */ - if (smspec_node.get_var_type() == ECL_SMSPEC_INVALID_VAR) { - ecl_kw_iset_string8(keywords_kw, i, "WWCT"); - ecl_kw_iset_string8(units_kw, i, "????????"); - ecl_kw_iset_string_ptr(wgnames_kw, i, DUMMY_WELL); + if (smspec_node.get_var_type() == RD_SMSPEC_INVALID_VAR) { + rd_kw_iset_string8(keywords_kw, i, "WWCT"); + rd_kw_iset_string8(units_kw, i, "????????"); + rd_kw_iset_string_ptr(wgnames_kw, i, DUMMY_WELL); } else { - ecl_kw_iset_string8(keywords_kw, i, - smspec_node_get_keyword(&smspec_node)); - ecl_kw_iset_string8(units_kw, i, - smspec_node_get_unit(&smspec_node)); + rd_kw_iset_string8(keywords_kw, i, + smspec_node_get_keyword(&smspec_node)); + rd_kw_iset_string8(units_kw, i, smspec_node_get_unit(&smspec_node)); { const char *wgname = DUMMY_WELL; if (smspec_node_get_wgname(&smspec_node)) wgname = smspec_node_get_wgname(&smspec_node); - ecl_kw_iset_string_ptr(wgnames_kw, i, wgname); + rd_kw_iset_string_ptr(wgnames_kw, i, wgname); } } if (nums_kw != NULL) - ecl_kw_iset_int(nums_kw, i, smspec_node.get_num()); + rd_kw_iset_int(nums_kw, i, smspec_node.get_num()); } - ecl_kw_fwrite(keywords_kw, fortio); - ecl_kw_fwrite(wgnames_kw, fortio); + rd_kw_fwrite(keywords_kw, fortio); + rd_kw_fwrite(wgnames_kw, fortio); if (nums_kw != NULL) - ecl_kw_fwrite(nums_kw, fortio); - ecl_kw_fwrite(units_kw, fortio); + rd_kw_fwrite(nums_kw, fortio); + rd_kw_fwrite(units_kw, fortio); - ecl_kw_free(keywords_kw); - ecl_kw_free(wgnames_kw); - ecl_kw_free(units_kw); + rd_kw_free(keywords_kw); + rd_kw_free(wgnames_kw); + rd_kw_free(units_kw); if (nums_kw != NULL) - ecl_kw_free(nums_kw); + rd_kw_free(nums_kw); - ecl_smspec_fwrite_STARTDAT(smspec, fortio); + rd_smspec_fwrite_STARTDAT(smspec, fortio); } -void ecl_smspec_fwrite(const ecl_smspec_type *smspec, const char *ecl_case, - bool fmt_file) { - char *filename = ecl_util_alloc_filename( - NULL, ecl_case, ECL_SUMMARY_HEADER_FILE, fmt_file, 0); +void rd_smspec_fwrite(const rd_smspec_type *smspec, const char *rd_case, + bool fmt_file) { + char *filename = + rd_alloc_filename(NULL, rd_case, RD_SUMMARY_HEADER_FILE, fmt_file, 0); fortio_type *fortio = - fortio_open_writer(filename, fmt_file, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, fmt_file, RD_ENDIAN_FLIP); if (!fortio) { const char *error_fmt_msg = @@ -523,73 +520,72 @@ void ecl_smspec_fwrite(const ecl_smspec_type *smspec, const char *ecl_case, util_abort(error_fmt_msg, __func__, filename, strerror(errno)); } - ecl_smspec_fortio_fwrite(smspec, fortio); + rd_smspec_fortio_fwrite(smspec, fortio); fortio_fclose(fortio); free(filename); } -static ecl_smspec_type * -ecl_smspec_alloc_writer__(const char *key_join_string, const char *restart_case, - int restart_step, time_t sim_start, bool time_in_days, - int nx, int ny, int nz) { - ecl_smspec_type *ecl_smspec = ecl_smspec_alloc_empty(true, key_join_string); +static rd_smspec_type * +rd_smspec_alloc_writer__(const char *key_join_string, const char *restart_case, + int restart_step, time_t sim_start, bool time_in_days, + int nx, int ny, int nz) { + rd_smspec_type *rd_smspec = rd_smspec_alloc_empty(true, key_join_string); /* Only a total of 9 * 8 characters is set aside for the restart keyword, if the supplied restart case is longer than that we silently ignore it. */ if (restart_case) { if (strlen(restart_case) <= - (SUMMARY_RESTART_SIZE * ECL_STRING8_LENGTH)) { - ecl_smspec->restart_case = restart_case; - ecl_smspec->restart_step = restart_step; + (SUMMARY_RESTART_SIZE * RD_STRING8_LENGTH)) { + rd_smspec->restart_case = restart_case; + rd_smspec->restart_step = restart_step; } } - ecl_smspec->grid_dims[0] = nx; - ecl_smspec->grid_dims[1] = ny; - ecl_smspec->grid_dims[2] = nz; - ecl_smspec->sim_start_time = sim_start; + rd_smspec->grid_dims[0] = nx; + rd_smspec->grid_dims[1] = ny; + rd_smspec->grid_dims[2] = nz; + rd_smspec->sim_start_time = sim_start; { - const ecl::smspec_node *time_node; + const rd::smspec_node *time_node; if (time_in_days) { - ecl_smspec->time_seconds = 3600 * 24; - time_node = ecl_smspec_add_node(ecl_smspec, "TIME", "DAYS", 0); + rd_smspec->time_seconds = 3600 * 24; + time_node = rd_smspec_add_node(rd_smspec, "TIME", "DAYS", 0); } else { - ecl_smspec->time_seconds = 3600; - time_node = ecl_smspec_add_node(ecl_smspec, "TIME", "HOURS", 0); + rd_smspec->time_seconds = 3600; + time_node = rd_smspec_add_node(rd_smspec, "TIME", "HOURS", 0); } - ecl_smspec->time_index = time_node->get_params_index(); + rd_smspec->time_index = time_node->get_params_index(); } - return ecl_smspec; + return rd_smspec; } -ecl_smspec_type *ecl_smspec_alloc_restart_writer( +rd_smspec_type *rd_smspec_alloc_restart_writer( const char *key_join_string, const char *restart_case, int restart_step, time_t sim_start, bool time_in_days, int nx, int ny, int nz) { - return ecl_smspec_alloc_writer__(key_join_string, restart_case, - restart_step, sim_start, time_in_days, nx, - ny, nz); + return rd_smspec_alloc_writer__(key_join_string, restart_case, restart_step, + sim_start, time_in_days, nx, ny, nz); } -ecl_smspec_type *ecl_smspec_alloc_writer(const char *key_join_string, - time_t sim_start, bool time_in_days, - int nx, int ny, int nz) { - return ecl_smspec_alloc_writer__(key_join_string, NULL, 0, sim_start, - time_in_days, nx, ny, nz); +rd_smspec_type *rd_smspec_alloc_writer(const char *key_join_string, + time_t sim_start, bool time_in_days, + int nx, int ny, int nz) { + return rd_smspec_alloc_writer__(key_join_string, NULL, 0, sim_start, + time_in_days, nx, ny, nz); } -UTIL_SAFE_CAST_FUNCTION(ecl_smspec, ECL_SMSPEC_ID) +UTIL_SAFE_CAST_FUNCTION(rd_smspec, RD_SMSPEC_ID) -ecl_smspec_var_type ecl_smspec_identify_var_type(const char *var) { - return ecl::smspec_node::identify_var_type(var); +rd_smspec_var_type rd_smspec_identify_var_type(const char *var) { + return rd::smspec_node::identify_var_type(var); } -static bool ecl_smspec_lgr_var_type(ecl_smspec_var_type var_type) { - if ((var_type == ECL_SMSPEC_LOCAL_BLOCK_VAR) || - (var_type == ECL_SMSPEC_LOCAL_WELL_VAR) || - (var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR)) +static bool rd_smspec_lgr_var_type(rd_smspec_var_type var_type) { + if ((var_type == RD_SMSPEC_LOCAL_BLOCK_VAR) || + (var_type == RD_SMSPEC_LOCAL_WELL_VAR) || + (var_type == RD_SMSPEC_LOCAL_COMPLETION_VAR)) return true; else @@ -597,55 +593,55 @@ static bool ecl_smspec_lgr_var_type(ecl_smspec_var_type var_type) { } /** - Takes a ecl_smspec_var_type variable as input, and return a string + Takes a rd_smspec_var_type variable as input, and return a string representation of this var_type. Suitable for debug messages +++ */ -const char *ecl_smspec_get_var_type_name(ecl_smspec_var_type var_type) { +const char *rd_smspec_get_var_type_name(rd_smspec_var_type var_type) { switch (var_type) { - case (ECL_SMSPEC_INVALID_VAR): + case (RD_SMSPEC_INVALID_VAR): return "INVALID_VAR"; break; - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_AQUIFER_VAR): return "AQUIFER_VAR"; break; - case (ECL_SMSPEC_WELL_VAR): + case (RD_SMSPEC_WELL_VAR): return "WELL_VAR"; break; - case (ECL_SMSPEC_REGION_VAR): + case (RD_SMSPEC_REGION_VAR): return "REGION_VAR"; break; - case (ECL_SMSPEC_FIELD_VAR): + case (RD_SMSPEC_FIELD_VAR): return "FIELD_VAR"; break; - case (ECL_SMSPEC_GROUP_VAR): + case (RD_SMSPEC_GROUP_VAR): return "GROUP_VAR"; break; - case (ECL_SMSPEC_BLOCK_VAR): + case (RD_SMSPEC_BLOCK_VAR): return "BLOCK_VAR"; break; - case (ECL_SMSPEC_COMPLETION_VAR): + case (RD_SMSPEC_COMPLETION_VAR): return "COMPLETION_VAR"; break; - case (ECL_SMSPEC_LOCAL_BLOCK_VAR): + case (RD_SMSPEC_LOCAL_BLOCK_VAR): return "LOCAL_BLOCK_VAR"; break; - case (ECL_SMSPEC_LOCAL_COMPLETION_VAR): + case (RD_SMSPEC_LOCAL_COMPLETION_VAR): return "LOCAL_COMPLETION_VAR"; break; - case (ECL_SMSPEC_LOCAL_WELL_VAR): + case (RD_SMSPEC_LOCAL_WELL_VAR): return "LOCAL_WELL_VAR"; break; - case (ECL_SMSPEC_NETWORK_VAR): + case (RD_SMSPEC_NETWORK_VAR): return "NETWORK_VAR"; break; - case (ECL_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): return "REGION_2_REGION_VAR"; break; - case (ECL_SMSPEC_SEGMENT_VAR): + case (RD_SMSPEC_SEGMENT_VAR): return "SEGMENT_VAR"; break; - case (ECL_SMSPEC_MISC_VAR): + case (RD_SMSPEC_MISC_VAR): return "MISC_VAR"; break; default: @@ -660,8 +656,8 @@ const char *ecl_smspec_get_var_type_name(ecl_smspec_var_type var_type) { xxx_block_xxx routines. */ -static int ecl_smspec_get_global_grid_index(const ecl_smspec_type *smspec, - int i, int j, int k) { +static int rd_smspec_get_global_grid_index(const rd_smspec_type *smspec, int i, + int j, int k) { return i + (j - 1) * smspec->grid_dims[0] + (k - 1) * smspec->grid_dims[0] * smspec->grid_dims[1]; } @@ -675,8 +671,8 @@ static int ecl_smspec_get_global_grid_index(const ecl_smspec_type *smspec, defined through the format strings used in this function. */ -static void ecl_smspec_install_gen_keys(ecl_smspec_type *smspec, - const ecl::smspec_node &smspec_node) { +static void rd_smspec_install_gen_keys(rd_smspec_type *smspec, + const rd::smspec_node &smspec_node) { /* Insert the default general mapping. */ { const char *gen_key1 = smspec_node.get_gen_key1(); @@ -692,47 +688,45 @@ static void ecl_smspec_install_gen_keys(ecl_smspec_type *smspec, } } -static void -ecl_smspec_install_special_keys(ecl_smspec_type *ecl_smspec, - const ecl::smspec_node &smspec_node) { +static void rd_smspec_install_special_keys(rd_smspec_type *rd_smspec, + const rd::smspec_node &smspec_node) { /** This large switch is for installing keys which have custom lookup paths, in addition to the lookup based on general keys. Examples of this is e.g. well variables which can be looked up through: - ecl_smspec_get_well_var_index( smspec , well_name , var ); + rd_smspec_get_well_var_index( smspec , well_name , var ); */ const char *well = smspec_node_get_wgname(&smspec_node); const char *group = well; const int num = smspec_node_get_num(&smspec_node); const char *keyword = smspec_node_get_keyword(&smspec_node); - ecl_smspec_var_type var_type = smspec_node_get_var_type(&smspec_node); + rd_smspec_var_type var_type = smspec_node_get_var_type(&smspec_node); switch (var_type) { - case (ECL_SMSPEC_COMPLETION_VAR): - ecl_smspec->well_completion_var_index[well][num][keyword] = - &smspec_node; + case (RD_SMSPEC_COMPLETION_VAR): + rd_smspec->well_completion_var_index[well][num][keyword] = &smspec_node; break; - case (ECL_SMSPEC_FIELD_VAR): - ecl_smspec->field_var_index[keyword] = &smspec_node; + case (RD_SMSPEC_FIELD_VAR): + rd_smspec->field_var_index[keyword] = &smspec_node; break; - case (ECL_SMSPEC_GROUP_VAR): - ecl_smspec->group_var_index[group][keyword] = &smspec_node; + case (RD_SMSPEC_GROUP_VAR): + rd_smspec->group_var_index[group][keyword] = &smspec_node; break; - case (ECL_SMSPEC_REGION_VAR): - ecl_smspec->region_var_index[num][keyword] = &smspec_node; - ecl_smspec->num_regions = util_int_max(ecl_smspec->num_regions, num); + case (RD_SMSPEC_REGION_VAR): + rd_smspec->region_var_index[num][keyword] = &smspec_node; + rd_smspec->num_regions = util_int_max(rd_smspec->num_regions, num); break; - case (ECL_SMSPEC_WELL_VAR): - ecl_smspec->well_var_index[well][keyword] = &smspec_node; + case (RD_SMSPEC_WELL_VAR): + rd_smspec->well_var_index[well][keyword] = &smspec_node; break; - case (ECL_SMSPEC_MISC_VAR): + case (RD_SMSPEC_MISC_VAR): /* Misc variable - i.e. date or CPU time ... */ - ecl_smspec->misc_var_index[keyword] = &smspec_node; + rd_smspec->misc_var_index[keyword] = &smspec_node; break; - case (ECL_SMSPEC_BLOCK_VAR): - ecl_smspec->block_var_index[num][keyword] = &smspec_node; + case (RD_SMSPEC_BLOCK_VAR): + rd_smspec->block_var_index[num][keyword] = &smspec_node; break; /** The variables below are ONLY accesable through the gen_key @@ -740,17 +734,17 @@ ecl_smspec_install_special_keys(ecl_smspec_type *ecl_smspec, otherwise they will induce a hard failure in the default: target below. */ - case (ECL_SMSPEC_LOCAL_BLOCK_VAR): + case (RD_SMSPEC_LOCAL_BLOCK_VAR): break; - case (ECL_SMSPEC_LOCAL_COMPLETION_VAR): + case (RD_SMSPEC_LOCAL_COMPLETION_VAR): break; - case (ECL_SMSPEC_LOCAL_WELL_VAR): + case (RD_SMSPEC_LOCAL_WELL_VAR): break; - case (ECL_SMSPEC_SEGMENT_VAR): + case (RD_SMSPEC_SEGMENT_VAR): break; - case (ECL_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): break; - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_AQUIFER_VAR): break; default: throw std::invalid_argument("Internal error - should not be here \n"); @@ -761,42 +755,42 @@ ecl_smspec_install_special_keys(ecl_smspec_type *ecl_smspec, The usage of this functon breaks down completely if LGR's are involved. */ -bool ecl_smspec_needs_wgname(ecl_smspec_var_type var_type) { +bool rd_smspec_needs_wgname(rd_smspec_var_type var_type) { switch (var_type) { - case (ECL_SMSPEC_COMPLETION_VAR): + case (RD_SMSPEC_COMPLETION_VAR): return true; break; - case (ECL_SMSPEC_FIELD_VAR): + case (RD_SMSPEC_FIELD_VAR): return false; break; - case (ECL_SMSPEC_GROUP_VAR): + case (RD_SMSPEC_GROUP_VAR): return true; break; - case (ECL_SMSPEC_WELL_VAR): + case (RD_SMSPEC_WELL_VAR): return true; break; - case (ECL_SMSPEC_REGION_VAR): + case (RD_SMSPEC_REGION_VAR): return false; break; - case (ECL_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): return false; break; - case (ECL_SMSPEC_MISC_VAR): + case (RD_SMSPEC_MISC_VAR): return false; break; - case (ECL_SMSPEC_BLOCK_VAR): + case (RD_SMSPEC_BLOCK_VAR): return false; break; - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_AQUIFER_VAR): return false; break; - case (ECL_SMSPEC_SEGMENT_VAR): + case (RD_SMSPEC_SEGMENT_VAR): return true; break; default: util_exit("Sorry: support for variables of type:%s is not implemented " "in %s.\n", - ecl_smspec_get_var_type_name(var_type), __FILE__); + rd_smspec_get_var_type_name(var_type), __FILE__); } /* Really should not be here. */ return false; @@ -805,51 +799,50 @@ bool ecl_smspec_needs_wgname(ecl_smspec_var_type var_type) { /** The usage of this functon breaks down completely if LGR's are involved. */ -bool ecl_smspec_needs_num(ecl_smspec_var_type var_type) { +bool rd_smspec_needs_num(rd_smspec_var_type var_type) { switch (var_type) { - case (ECL_SMSPEC_COMPLETION_VAR): + case (RD_SMSPEC_COMPLETION_VAR): return true; break; - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_AQUIFER_VAR): return true; break; - case (ECL_SMSPEC_FIELD_VAR): + case (RD_SMSPEC_FIELD_VAR): return false; break; - case (ECL_SMSPEC_GROUP_VAR): + case (RD_SMSPEC_GROUP_VAR): return false; break; - case (ECL_SMSPEC_WELL_VAR): + case (RD_SMSPEC_WELL_VAR): return false; break; - case (ECL_SMSPEC_REGION_VAR): + case (RD_SMSPEC_REGION_VAR): return true; break; - case (ECL_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): return true; break; - case (ECL_SMSPEC_MISC_VAR): + case (RD_SMSPEC_MISC_VAR): return false; break; - case (ECL_SMSPEC_BLOCK_VAR): + case (RD_SMSPEC_BLOCK_VAR): return true; break; default: util_exit("Sorry: support for variables of type:%s is not implemented " "in %s.\n", - ecl_smspec_get_var_type_name(var_type), __FILE__); + rd_smspec_get_var_type_name(var_type), __FILE__); } return false; } -bool ecl_smspec_equal(const ecl_smspec_type *self, - const ecl_smspec_type *other) { +bool rd_smspec_equal(const rd_smspec_type *self, const rd_smspec_type *other) { if (self->smspec_nodes.size() != other->smspec_nodes.size()) return false; for (size_t i = 0; i < self->smspec_nodes.size(); i++) { - const ecl::smspec_node *node1 = self->smspec_nodes[i].get(); - const ecl::smspec_node *node2 = other->smspec_nodes[i].get(); + const rd::smspec_node *node1 = self->smspec_nodes[i].get(); + const rd::smspec_node *node2 = other->smspec_nodes[i].get(); if (node1->cmp(*node2) != 0) return false; @@ -858,18 +851,18 @@ bool ecl_smspec_equal(const ecl_smspec_type *self, return true; } -static void ecl_smspec_load_restart(ecl_smspec_type *ecl_smspec, - const ecl_file_type *header) { - if (ecl_file_has_kw(header, RESTART_KW)) { - const ecl_kw_type *restart_kw = - ecl_file_iget_named_kw(header, RESTART_KW, 0); +static void rd_smspec_load_restart(rd_smspec_type *rd_smspec, + const rd_file_type *header) { + if (rd_file_has_kw(header, RESTART_KW)) { + const rd_kw_type *restart_kw = + rd_file_iget_named_kw(header, RESTART_KW, 0); char tmp_base [73]; /* To accomodate a maximum of 9 items which consist of 8 characters each. */ char *restart_base; int i; tmp_base[0] = '\0'; - for (i = 0; i < ecl_kw_get_size(restart_kw); i++) - strcat(tmp_base, (const char *)ecl_kw_iget_ptr(restart_kw, i)); + for (i = 0; i < rd_kw_get_size(restart_kw); i++) + strcat(tmp_base, (const char *)rd_kw_iget_ptr(restart_kw, i)); restart_base = util_alloc_strip_copy(tmp_base); if (strlen(restart_base)) { /* We ignore the empty ones. */ @@ -895,24 +888,23 @@ static void ecl_smspec_load_restart(ecl_smspec_type *ecl_smspec, } #endif - std::string path = - ecl::util::path::dirname(ecl_smspec->header_file); - smspec_header = ecl_util_alloc_exfilename( - path.c_str(), restart_base, ECL_SUMMARY_HEADER_FILE, - ecl_smspec->formatted, 0); + std::string path = rd::util::path::dirname(rd_smspec->header_file); + smspec_header = rd_alloc_exfilename(path.c_str(), restart_base, + RD_SUMMARY_HEADER_FILE, + rd_smspec->formatted, 0); if (smspec_header) { if (!util_same_file( smspec_header, - ecl_smspec->header_file + rd_smspec->header_file .c_str())) /* Restart from the current case is ignored. */ { if (util_is_abs_path(restart_base)) - ecl_smspec->restart_case = restart_base; + rd_smspec->restart_case = restart_base; else { char *tmp_path = util_alloc_filename( path.c_str(), restart_base, NULL); char *abs_path = util_alloc_abs_path(tmp_path); - ecl_smspec->restart_case = abs_path; + rd_smspec->restart_case = abs_path; free(abs_path); free(tmp_path); } @@ -924,114 +916,116 @@ static void ecl_smspec_load_restart(ecl_smspec_type *ecl_smspec, } } -static const ecl::smspec_node * -ecl_smspec_insert_node(ecl_smspec_type *ecl_smspec, - std::unique_ptr smspec_node) { +static const rd::smspec_node * +rd_smspec_insert_node(rd_smspec_type *rd_smspec, + std::unique_ptr smspec_node) { int params_index = smspec_node->get_params_index(); /* This indexing must be used when writing. */ - ecl_smspec->index_map.push_back(params_index); - ecl_smspec->params_default.resize(params_index + 1, PARAMS_GLOBAL_DEFAULT); - ecl_smspec->params_default[params_index] = smspec_node->get_default(); - ecl_smspec->inv_index_map.insert( - std::make_pair(params_index, ecl_smspec->smspec_nodes.size())); + rd_smspec->index_map.push_back(params_index); + rd_smspec->params_default.resize(params_index + 1, PARAMS_GLOBAL_DEFAULT); + rd_smspec->params_default[params_index] = smspec_node->get_default(); + rd_smspec->inv_index_map.insert( + std::make_pair(params_index, rd_smspec->smspec_nodes.size())); - ecl_smspec_install_gen_keys(ecl_smspec, *smspec_node.get()); - ecl_smspec_install_special_keys(ecl_smspec, *smspec_node.get()); + rd_smspec_install_gen_keys(rd_smspec, *smspec_node.get()); + rd_smspec_install_special_keys(rd_smspec, *smspec_node.get()); if (smspec_node->need_nums()) - ecl_smspec->need_nums = true; + rd_smspec->need_nums = true; - ecl_smspec->smspec_nodes.push_back(std::move(smspec_node)); + rd_smspec->smspec_nodes.push_back(std::move(smspec_node)); - if (params_index > ecl_smspec->params_size) - ecl_smspec->params_size = params_index + 1; + if (params_index > rd_smspec->params_size) + rd_smspec->params_size = params_index + 1; - if (static_cast(ecl_smspec->smspec_nodes.size()) > - ecl_smspec->params_size) - ecl_smspec->params_size = ecl_smspec->smspec_nodes.size(); + if (static_cast(rd_smspec->smspec_nodes.size()) > + rd_smspec->params_size) + rd_smspec->params_size = rd_smspec->smspec_nodes.size(); - const auto &node = ecl_smspec->smspec_nodes.back(); + const auto &node = rd_smspec->smspec_nodes.back(); return node.get(); } -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, int num, - const char *unit, - float default_value) { - int params_index = ecl_smspec->smspec_nodes.size(); - return ecl_smspec_insert_node( - ecl_smspec, std::unique_ptr(new ecl::smspec_node( - params_index, keyword, num, unit, ecl_smspec->grid_dims, - default_value, ecl_smspec->key_join_string.c_str()))); +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, int num, + const char *unit, + float default_value) { + int params_index = rd_smspec->smspec_nodes.size(); + return rd_smspec_insert_node( + rd_smspec, std::unique_ptr(new rd::smspec_node( + params_index, keyword, num, unit, rd_smspec->grid_dims, + default_value, rd_smspec->key_join_string.c_str()))); } //copy given node with a new index -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const ecl::smspec_node &node) { - int params_index = ecl_smspec->smspec_nodes.size(); - return ecl_smspec_insert_node( - ecl_smspec, std::unique_ptr( - new ecl::smspec_node(node, params_index))); -} - -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, - const char *unit, - float default_value) { - int params_index = ecl_smspec->smspec_nodes.size(); - return ecl_smspec_insert_node( - ecl_smspec, std::unique_ptr(new ecl::smspec_node( - params_index, keyword, unit, default_value))); -} - -const ecl::smspec_node * -ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, const char *keyword, - const char *wgname, const char *unit, float default_value) { - int params_index = ecl_smspec->smspec_nodes.size(); - return ecl_smspec_insert_node( - ecl_smspec, std::unique_ptr(new ecl::smspec_node( - params_index, keyword, wgname, unit, default_value, - ecl_smspec->key_join_string.c_str()))); -} - -const ecl::smspec_node *ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, - const char *keyword, - const char *wgname, int num, - const char *unit, - float default_value) { - int params_index = ecl_smspec->smspec_nodes.size(); - return ecl_smspec_insert_node( - ecl_smspec, - std::unique_ptr(new ecl::smspec_node( - params_index, keyword, wgname, num, unit, ecl_smspec->grid_dims, - default_value, ecl_smspec->key_join_string.c_str()))); -} - -const ecl::smspec_node * -ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, int params_index, - const char *keyword, const char *wgname, int num, - const char *unit, float default_value) { - return ecl_smspec_insert_node( - ecl_smspec, - std::unique_ptr(new ecl::smspec_node( - params_index, keyword, wgname, num, unit, ecl_smspec->grid_dims, - default_value, ecl_smspec->key_join_string.c_str()))); -} - -const ecl::smspec_node * -ecl_smspec_add_node(ecl_smspec_type *ecl_smspec, int params_index, - const char *keyword, const char *wgname, int num, - const char *unit, const char *lgr, int lgr_i, int lgr_j, - int lgr_k, float default_value) { - return ecl_smspec_insert_node( - ecl_smspec, - std::unique_ptr(new ecl::smspec_node( +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const rd::smspec_node &node) { + int params_index = rd_smspec->smspec_nodes.size(); + return rd_smspec_insert_node(rd_smspec, + std::unique_ptr( + new rd::smspec_node(node, params_index))); +} + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, const char *unit, + float default_value) { + int params_index = rd_smspec->smspec_nodes.size(); + return rd_smspec_insert_node( + rd_smspec, std::unique_ptr(new rd::smspec_node( + params_index, keyword, unit, default_value))); +} + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, + const char *wgname, const char *unit, + float default_value) { + int params_index = rd_smspec->smspec_nodes.size(); + return rd_smspec_insert_node( + rd_smspec, std::unique_ptr(new rd::smspec_node( + params_index, keyword, wgname, unit, default_value, + rd_smspec->key_join_string.c_str()))); +} + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + const char *keyword, + const char *wgname, int num, + const char *unit, + float default_value) { + int params_index = rd_smspec->smspec_nodes.size(); + return rd_smspec_insert_node( + rd_smspec, + std::unique_ptr(new rd::smspec_node( + params_index, keyword, wgname, num, unit, rd_smspec->grid_dims, + default_value, rd_smspec->key_join_string.c_str()))); +} + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + int params_index, const char *keyword, + const char *wgname, int num, + const char *unit, + float default_value) { + return rd_smspec_insert_node( + rd_smspec, + std::unique_ptr(new rd::smspec_node( + params_index, keyword, wgname, num, unit, rd_smspec->grid_dims, + default_value, rd_smspec->key_join_string.c_str()))); +} + +const rd::smspec_node *rd_smspec_add_node(rd_smspec_type *rd_smspec, + int params_index, const char *keyword, + const char *wgname, int num, + const char *unit, const char *lgr, + int lgr_i, int lgr_j, int lgr_k, + float default_value) { + return rd_smspec_insert_node( + rd_smspec, + std::unique_ptr(new rd::smspec_node( params_index, keyword, wgname, unit, lgr, lgr_i, lgr_j, lgr_k, - default_value, ecl_smspec->key_join_string.c_str()))); + default_value, rd_smspec->key_join_string.c_str()))); } -const int *ecl_smspec_get_index_map(const ecl_smspec_type *smspec) { +const int *rd_smspec_get_index_map(const rd_smspec_type *smspec) { return smspec->index_map.data(); } @@ -1040,56 +1034,56 @@ const int *ecl_smspec_get_index_map(const ecl_smspec_type *smspec) { * situations occur in the future, this is a sane starting point for general * support. */ -static const char *get_active_keyword_alias(ecl_file_type *header, +static const char *get_active_keyword_alias(rd_file_type *header, const char *keyword) { if (strcmp(keyword, WGNAMES_KW) == 0 || strcmp(keyword, NAMES_KW) == 0) - return ecl_file_has_kw(header, WGNAMES_KW) ? WGNAMES_KW : NAMES_KW; + return rd_file_has_kw(header, WGNAMES_KW) ? WGNAMES_KW : NAMES_KW; return keyword; } -static bool ecl_smspec_check_header(ecl_file_type *header) { +static bool rd_smspec_check_header(rd_file_type *header) { bool OK = true; for (size_t i = 0; i < num_req_keywords && OK; i++) { - OK &= ecl_file_has_kw(header, get_active_keyword_alias( - header, smspec_required_keywords[i])); + OK &= rd_file_has_kw(header, get_active_keyword_alias( + header, smspec_required_keywords[i])); } return OK; } -static bool ecl_smspec_fread_header(ecl_smspec_type *ecl_smspec, - const char *header_file, - bool include_restart) { - ecl_file_type *header = ecl_file_open(header_file, 0); - if (header && ecl_smspec_check_header(header)) { +static bool rd_smspec_fread_header(rd_smspec_type *rd_smspec, + const char *header_file, + bool include_restart) { + rd_file_type *header = rd_file_open(header_file, 0); + if (header && rd_smspec_check_header(header)) { const char *names_alias = get_active_keyword_alias(header, WGNAMES_KW); - ecl_kw_type *wells = ecl_file_iget_named_kw(header, names_alias, 0); - ecl_kw_type *keywords = ecl_file_iget_named_kw(header, KEYWORDS_KW, 0); - ecl_kw_type *startdat = ecl_file_iget_named_kw(header, STARTDAT_KW, 0); - ecl_kw_type *units = ecl_file_iget_named_kw(header, UNITS_KW, 0); - ecl_kw_type *dimens = ecl_file_iget_named_kw(header, DIMENS_KW, 0); - ecl_kw_type *nums = NULL; - ecl_kw_type *lgrs = NULL; - ecl_kw_type *numlx = NULL; - ecl_kw_type *numly = NULL; - ecl_kw_type *numlz = NULL; + rd_kw_type *wells = rd_file_iget_named_kw(header, names_alias, 0); + rd_kw_type *keywords = rd_file_iget_named_kw(header, KEYWORDS_KW, 0); + rd_kw_type *startdat = rd_file_iget_named_kw(header, STARTDAT_KW, 0); + rd_kw_type *units = rd_file_iget_named_kw(header, UNITS_KW, 0); + rd_kw_type *dimens = rd_file_iget_named_kw(header, DIMENS_KW, 0); + rd_kw_type *nums = NULL; + rd_kw_type *lgrs = NULL; + rd_kw_type *numlx = NULL; + rd_kw_type *numly = NULL; + rd_kw_type *numlz = NULL; int params_index; - ecl_smspec->num_regions = 0; - ecl_smspec->params_size = ecl_kw_get_size(keywords); + rd_smspec->num_regions = 0; + rd_smspec->params_size = rd_kw_get_size(keywords); if (startdat == NULL) util_abort( "%s: could not locate STARTDAT keyword in header - aborting \n", __func__); - if (ecl_file_has_kw(header, NUMS_KW)) - nums = ecl_file_iget_named_kw(header, NUMS_KW, 0); + if (rd_file_has_kw(header, NUMS_KW)) + nums = rd_file_iget_named_kw(header, NUMS_KW, 0); - if (ecl_file_has_kw(header, INTEHEAD_KW)) { - const ecl_kw_type *intehead = - ecl_file_iget_named_kw(header, INTEHEAD_KW, 0); - ecl_smspec->unit_system = (ert_ecl_unit_enum)ecl_kw_iget_int( + if (rd_file_has_kw(header, INTEHEAD_KW)) { + const rd_kw_type *intehead = + rd_file_iget_named_kw(header, INTEHEAD_KW, 0); + rd_smspec->unit_system = (ert_rd_unit_enum)rd_kw_iget_int( intehead, INTEHEAD_SMSPEC_UNIT_INDEX); /* The second item in the INTEHEAD vector is an integer designating which @@ -1098,89 +1092,89 @@ static bool ecl_smspec_fread_header(ecl_smspec_type *ecl_smspec, */ } - if (ecl_file_has_kw(header, - LGRS_KW)) { /* The file has LGR information. */ - lgrs = ecl_file_iget_named_kw(header, LGRS_KW, 0); - numlx = ecl_file_iget_named_kw(header, NUMLX_KW, 0); - numly = ecl_file_iget_named_kw(header, NUMLY_KW, 0); - numlz = ecl_file_iget_named_kw(header, NUMLZ_KW, 0); - ecl_smspec->has_lgr = true; + if (rd_file_has_kw(header, + LGRS_KW)) { /* The file has LGR information. */ + lgrs = rd_file_iget_named_kw(header, LGRS_KW, 0); + numlx = rd_file_iget_named_kw(header, NUMLX_KW, 0); + numly = rd_file_iget_named_kw(header, NUMLY_KW, 0); + numlz = rd_file_iget_named_kw(header, NUMLZ_KW, 0); + rd_smspec->has_lgr = true; } else - ecl_smspec->has_lgr = false; + rd_smspec->has_lgr = false; { - int *date = ecl_kw_get_int_ptr(startdat); + int *date = rd_kw_get_int_ptr(startdat); int year = date[STARTDAT_YEAR_INDEX]; int month = date[STARTDAT_MONTH_INDEX]; int day = date[STARTDAT_DAY_INDEX]; int hour = 0; int min = 0; int sec = 0; - if (ecl_kw_get_size(startdat) == 6) { + if (rd_kw_get_size(startdat) == 6) { hour = date[STARTDAT_HOUR_INDEX]; min = date[STARTDAT_MINUTE_INDEX]; sec = date[STARTDAT_MICRO_SECOND_INDEX] / 1000000; } - ecl_smspec->sim_start_time = - ecl_util_make_datetime(sec, min, hour, day, month, year); + rd_smspec->sim_start_time = + rd_make_datetime(sec, min, hour, day, month, year); } - ecl_smspec->grid_dims[0] = - ecl_kw_iget_int(dimens, DIMENS_SMSPEC_NX_INDEX); - ecl_smspec->grid_dims[1] = - ecl_kw_iget_int(dimens, DIMENS_SMSPEC_NY_INDEX); - ecl_smspec->grid_dims[2] = - ecl_kw_iget_int(dimens, DIMENS_SMSPEC_NZ_INDEX); - ecl_smspec->restart_step = - ecl_kw_iget_int(dimens, DIMENS_SMSPEC_RESTART_STEP_INDEX); + rd_smspec->grid_dims[0] = + rd_kw_iget_int(dimens, DIMENS_SMSPEC_NX_INDEX); + rd_smspec->grid_dims[1] = + rd_kw_iget_int(dimens, DIMENS_SMSPEC_NY_INDEX); + rd_smspec->grid_dims[2] = + rd_kw_iget_int(dimens, DIMENS_SMSPEC_NZ_INDEX); + rd_smspec->restart_step = + rd_kw_iget_int(dimens, DIMENS_SMSPEC_RESTART_STEP_INDEX); - ecl_util_get_file_type(header_file, &ecl_smspec->formatted, NULL); + rd_get_file_type(header_file, &rd_smspec->formatted, NULL); { - for (params_index = 0; params_index < ecl_kw_get_size(wells); + for (params_index = 0; params_index < rd_kw_get_size(wells); params_index++) { float default_value = PARAMS_GLOBAL_DEFAULT; int num = SMSPEC_NUMS_INVALID; char *well = (char *)util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(wells, params_index)); + (const char *)rd_kw_iget_ptr(wells, params_index)); char *kw = (char *)util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(keywords, params_index)); + (const char *)rd_kw_iget_ptr(keywords, params_index)); char *unit = (char *)util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(units, params_index)); + (const char *)rd_kw_iget_ptr(units, params_index)); - ecl_smspec_var_type var_type; + rd_smspec_var_type var_type; if (nums != NULL) - num = ecl_kw_iget_int(nums, params_index); - var_type = ecl::smspec_node::valid_type(kw, well, num); - if (var_type == ECL_SMSPEC_INVALID_VAR) { + num = rd_kw_iget_int(nums, params_index); + var_type = rd::smspec_node::valid_type(kw, well, num); + if (var_type == RD_SMSPEC_INVALID_VAR) { free(kw); free(well); free(unit); continue; } - if (ecl_smspec_lgr_var_type(var_type)) { - int lgr_i = ecl_kw_iget_int(numlx, params_index); - int lgr_j = ecl_kw_iget_int(numly, params_index); - int lgr_k = ecl_kw_iget_int(numlz, params_index); + if (rd_smspec_lgr_var_type(var_type)) { + int lgr_i = rd_kw_iget_int(numlx, params_index); + int lgr_j = rd_kw_iget_int(numly, params_index); + int lgr_k = rd_kw_iget_int(numlz, params_index); char *lgr_name = (char *)util_alloc_strip_copy( - (const char *)ecl_kw_iget_ptr(lgrs, params_index)); + (const char *)rd_kw_iget_ptr(lgrs, params_index)); - ecl_smspec_insert_node( - ecl_smspec, - std::unique_ptr(new ecl::smspec_node( + rd_smspec_insert_node( + rd_smspec, + std::unique_ptr(new rd::smspec_node( params_index, kw, well, unit, lgr_name, lgr_i, lgr_j, lgr_k, default_value, - ecl_smspec->key_join_string.c_str()))); + rd_smspec->key_join_string.c_str()))); free(lgr_name); } else - ecl_smspec_insert_node( - ecl_smspec, - std::unique_ptr(new ecl::smspec_node( + rd_smspec_insert_node( + rd_smspec, + std::unique_ptr(new rd::smspec_node( params_index, kw, well, num, unit, - ecl_smspec->grid_dims, default_value, - ecl_smspec->key_join_string.c_str()))); + rd_smspec->grid_dims, default_value, + rd_smspec->key_join_string.c_str()))); free(kw); free(well); @@ -1189,58 +1183,58 @@ static bool ecl_smspec_fread_header(ecl_smspec_type *ecl_smspec, } char *header_str = util_alloc_realpath(header_file); - ecl_smspec->header_file = header_str; + rd_smspec->header_file = header_str; free(header_str); if (include_restart) - ecl_smspec_load_restart(ecl_smspec, header); + rd_smspec_load_restart(rd_smspec, header); - ecl_file_close(header); + rd_file_close(header); return true; } else return false; } -ecl_smspec_type *ecl_smspec_fread_alloc(const char *header_file, - const char *key_join_string, - bool include_restart) { - ecl_smspec_type *ecl_smspec; +rd_smspec_type *rd_smspec_fread_alloc(const char *header_file, + const char *key_join_string, + bool include_restart) { + rd_smspec_type *rd_smspec; { char *path; util_alloc_file_components(header_file, &path, NULL, NULL); - ecl_smspec = ecl_smspec_alloc_empty(false, key_join_string); + rd_smspec = rd_smspec_alloc_empty(false, key_join_string); free(path); } - if (ecl_smspec_fread_header(ecl_smspec, header_file, include_restart)) { + if (rd_smspec_fread_header(rd_smspec, header_file, include_restart)) { - const ecl::smspec_node *time_node = - ecl_smspec_get_var_node(ecl_smspec->misc_var_index, "TIME"); + const rd::smspec_node *time_node = + rd_smspec_get_var_node(rd_smspec->misc_var_index, "TIME"); if (time_node) { const char *time_unit = time_node->get_unit(); - ecl_smspec->time_index = time_node->get_params_index(); + rd_smspec->time_index = time_node->get_params_index(); if (util_string_equal(time_unit, "DAYS")) - ecl_smspec->time_seconds = 3600 * 24; + rd_smspec->time_seconds = 3600 * 24; else if (util_string_equal(time_unit, "HOURS")) - ecl_smspec->time_seconds = 3600; + rd_smspec->time_seconds = 3600; else util_abort("%s: time_unit:%s not recognized \n", __func__, time_unit); } - const ecl::smspec_node *day_node = - ecl_smspec_get_var_node(ecl_smspec->misc_var_index, "DAY"); + const rd::smspec_node *day_node = + rd_smspec_get_var_node(rd_smspec->misc_var_index, "DAY"); if (day_node != NULL) { - ecl_smspec->day_index = smspec_node_get_params_index(day_node); - ecl_smspec->month_index = smspec_node_get_params_index( - &ecl_smspec->misc_var_index["MONTH"]); - ecl_smspec->year_index = smspec_node_get_params_index( - &ecl_smspec->misc_var_index["YEAR"]); + rd_smspec->day_index = smspec_node_get_params_index(day_node); + rd_smspec->month_index = smspec_node_get_params_index( + &rd_smspec->misc_var_index["MONTH"]); + rd_smspec->year_index = smspec_node_get_params_index( + &rd_smspec->misc_var_index["YEAR"]); } - if ((ecl_smspec->time_index == -1) && (ecl_smspec->day_index == -1)) { + if ((rd_smspec->time_index == -1) && (rd_smspec->day_index == -1)) { /* Unusable configuration. Seems the ECLIPSE file can also have time specified with @@ -1253,37 +1247,37 @@ ecl_smspec_type *ecl_smspec_fread_alloc(const char *header_file, __func__); return NULL; } - return ecl_smspec; + return rd_smspec; } else { /** Failed to load from disk. */ - ecl_smspec_free(ecl_smspec); + rd_smspec_free(rd_smspec); return NULL; } } -int ecl_smspec_get_num_groups(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->group_var_index.size(); +int rd_smspec_get_num_groups(const rd_smspec_type *rd_smspec) { + return rd_smspec->group_var_index.size(); } -/*char ** ecl_smspec_alloc_group_names(const ecl_smspec_type * ecl_smspec) { - return hash_alloc_keylist(ecl_smspec->group_var_index); +/*char ** rd_smspec_alloc_group_names(const rd_smspec_type * rd_smspec) { + return hash_alloc_keylist(rd_smspec->group_var_index); }*/ -int ecl_smspec_get_num_regions(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->num_regions; +int rd_smspec_get_num_regions(const rd_smspec_type *rd_smspec) { + return rd_smspec->num_regions; } /* For each type of summary data (according to the types in - ecl_smcspec_var_type there are a set accessor functions: + rd_smcspec_var_type there are a set accessor functions: xx_get_xx: This function will take the apropriate input, and return a double value. The function will fail with util_abort() - if the ecl_smspec object can not recognize the input. THis + if the rd_smspec object can not recognize the input. THis function is not here. xxx_has_xx: Ths will return true / false depending on whether the - ecl_smspec object the variable we ask for. + rd_smspec object the variable we ask for. xxx_get_xxx_index: This function will rerturn an (internal) integer index of where the variable in question is stored, this @@ -1297,14 +1291,14 @@ int ecl_smspec_get_num_regions(const ecl_smspec_type *ecl_smspec) { namespace { -bool node_exists(const ecl::smspec_node *node_ptr) { +bool node_exists(const rd::smspec_node *node_ptr) { if (node_ptr) return true; return false; } -int node_valid_index(const ecl::smspec_node *node_ptr) { +int node_valid_index(const rd::smspec_node *node_ptr) { if (node_ptr) return node_ptr->get_params_index(); @@ -1313,11 +1307,11 @@ int node_valid_index(const ecl::smspec_node *node_ptr) { } // namespace -const ecl::smspec_node & -ecl_smspec_get_well_var_node(const ecl_smspec_type *smspec, const char *well, - const char *var) { +const rd::smspec_node &rd_smspec_get_well_var_node(const rd_smspec_type *smspec, + const char *well, + const char *var) { const auto node_ptr = - ecl_smspec_get_str_key_var_node(smspec->well_var_index, well, var); + rd_smspec_get_str_key_var_node(smspec->well_var_index, well, var); if (!node_ptr) throw std::out_of_range("The well: " + std::string(well) + " variable: " + std::string(var) + @@ -1326,25 +1320,25 @@ ecl_smspec_get_well_var_node(const ecl_smspec_type *smspec, const char *well, return *node_ptr; } -int ecl_smspec_get_well_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var) { +int rd_smspec_get_well_var_params_index(const rd_smspec_type *rd_smspec, + const char *well, const char *var) { const auto node_ptr = - ecl_smspec_get_str_key_var_node(ecl_smspec->well_var_index, well, var); + rd_smspec_get_str_key_var_node(rd_smspec->well_var_index, well, var); return node_valid_index(node_ptr); } -bool ecl_smspec_has_well_var(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var) { +bool rd_smspec_has_well_var(const rd_smspec_type *rd_smspec, const char *well, + const char *var) { const auto node_ptr = - ecl_smspec_get_str_key_var_node(ecl_smspec->well_var_index, well, var); + rd_smspec_get_str_key_var_node(rd_smspec->well_var_index, well, var); return node_exists(node_ptr); } -const ecl::smspec_node & -ecl_smspec_get_group_var_node(const ecl_smspec_type *smspec, const char *group, - const char *var) { +const rd::smspec_node & +rd_smspec_get_group_var_node(const rd_smspec_type *smspec, const char *group, + const char *var) { const auto node_ptr = - ecl_smspec_get_str_key_var_node(smspec->group_var_index, group, var); + rd_smspec_get_str_key_var_node(smspec->group_var_index, group, var); if (!node_ptr) throw std::out_of_range("The group: " + std::string(group) + " variable: " + std::string(var) + @@ -1353,25 +1347,24 @@ ecl_smspec_get_group_var_node(const ecl_smspec_type *smspec, const char *group, return *node_ptr; } -int ecl_smspec_get_group_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *group, const char *var) { - const auto node_ptr = ecl_smspec_get_str_key_var_node( - ecl_smspec->group_var_index, group, var); +int rd_smspec_get_group_var_params_index(const rd_smspec_type *rd_smspec, + const char *group, const char *var) { + const auto node_ptr = + rd_smspec_get_str_key_var_node(rd_smspec->group_var_index, group, var); return node_valid_index(node_ptr); } -bool ecl_smspec_has_group_var(const ecl_smspec_type *ecl_smspec, - const char *group, const char *var) { - const auto node_ptr = ecl_smspec_get_str_key_var_node( - ecl_smspec->group_var_index, group, var); +bool rd_smspec_has_group_var(const rd_smspec_type *rd_smspec, const char *group, + const char *var) { + const auto node_ptr = + rd_smspec_get_str_key_var_node(rd_smspec->group_var_index, group, var); return node_exists(node_ptr); } -const ecl::smspec_node & -ecl_smspec_get_field_var_node(const ecl_smspec_type *ecl_smspec, - const char *var) { +const rd::smspec_node & +rd_smspec_get_field_var_node(const rd_smspec_type *rd_smspec, const char *var) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->field_var_index, var); + rd_smspec_get_var_node(rd_smspec->field_var_index, var); if (!node_ptr) throw std::out_of_range("The field variable: " + std::string(var) + " does not exist."); @@ -1379,17 +1372,16 @@ ecl_smspec_get_field_var_node(const ecl_smspec_type *ecl_smspec, return *node_ptr; } -int ecl_smspec_get_field_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *var) { +int rd_smspec_get_field_var_params_index(const rd_smspec_type *rd_smspec, + const char *var) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->field_var_index, var); + rd_smspec_get_var_node(rd_smspec->field_var_index, var); return node_valid_index(node_ptr); } -bool ecl_smspec_has_field_var(const ecl_smspec_type *ecl_smspec, - const char *var) { +bool rd_smspec_has_field_var(const rd_smspec_type *rd_smspec, const char *var) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->field_var_index, var); + rd_smspec_get_var_node(rd_smspec->field_var_index, var); return node_exists(node_ptr); } @@ -1401,146 +1393,144 @@ bool ecl_smspec_has_field_var(const ecl_smspec_type *ecl_smspec, hash tables. */ -const ecl::smspec_node & -ecl_smspec_get_block_var_node(const ecl_smspec_type *ecl_smspec, - const char *block_var, int block_nr) { - const auto node_ptr = ecl_smspec_get_int_key_var_node( - ecl_smspec->block_var_index, block_nr, block_var); +const rd::smspec_node & +rd_smspec_get_block_var_node(const rd_smspec_type *rd_smspec, + const char *block_var, int block_nr) { + const auto node_ptr = rd_smspec_get_int_key_var_node( + rd_smspec->block_var_index, block_nr, block_var); if (!node_ptr) throw std::out_of_range("No such block variable"); return *node_ptr; } -const ecl::smspec_node & -ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type *ecl_smspec, - const char *block_var, int i, int j, int k) { - return ecl_smspec_get_block_var_node( - ecl_smspec, block_var, - ecl_smspec_get_global_grid_index(ecl_smspec, i, j, k)); +const rd::smspec_node & +rd_smspec_get_block_var_node_ijk(const rd_smspec_type *rd_smspec, + const char *block_var, int i, int j, int k) { + return rd_smspec_get_block_var_node( + rd_smspec, block_var, + rd_smspec_get_global_grid_index(rd_smspec, i, j, k)); } -bool ecl_smspec_has_block_var(const ecl_smspec_type *ecl_smspec, - const char *block_var, int block_nr) { - const auto node_ptr = ecl_smspec_get_int_key_var_node( - ecl_smspec->block_var_index, block_nr, block_var); +bool rd_smspec_has_block_var(const rd_smspec_type *rd_smspec, + const char *block_var, int block_nr) { + const auto node_ptr = rd_smspec_get_int_key_var_node( + rd_smspec->block_var_index, block_nr, block_var); return node_exists(node_ptr); } -bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type *ecl_smspec, - const char *block_var, int i, int j, int k) { - return ecl_smspec_has_block_var( - ecl_smspec, block_var, - ecl_smspec_get_global_grid_index(ecl_smspec, i, j, k)); +bool rd_smspec_has_block_var_ijk(const rd_smspec_type *rd_smspec, + const char *block_var, int i, int j, int k) { + return rd_smspec_has_block_var( + rd_smspec, block_var, + rd_smspec_get_global_grid_index(rd_smspec, i, j, k)); } -int ecl_smspec_get_block_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *block_var, int block_nr) { - const auto node_ptr = ecl_smspec_get_int_key_var_node( - ecl_smspec->block_var_index, block_nr, block_var); +int rd_smspec_get_block_var_params_index(const rd_smspec_type *rd_smspec, + const char *block_var, int block_nr) { + const auto node_ptr = rd_smspec_get_int_key_var_node( + rd_smspec->block_var_index, block_nr, block_var); return node_valid_index(node_ptr); } -int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type *ecl_smspec, - const char *block_var, int i, - int j, int k) { - return ecl_smspec_get_block_var_params_index( - ecl_smspec, block_var, - ecl_smspec_get_global_grid_index(ecl_smspec, i, j, k)); +int rd_smspec_get_block_var_params_index_ijk(const rd_smspec_type *rd_smspec, + const char *block_var, int i, + int j, int k) { + return rd_smspec_get_block_var_params_index( + rd_smspec, block_var, + rd_smspec_get_global_grid_index(rd_smspec, i, j, k)); } /** region_nr: [1...num_regions] (NOT C-based indexing) */ -const ecl::smspec_node & -ecl_smspec_get_region_var_node(const ecl_smspec_type *ecl_smspec, - const char *region_var, int region_nr) { - const auto node_ptr = ecl_smspec_get_int_key_var_node( - ecl_smspec->region_var_index, region_nr, region_var); +const rd::smspec_node & +rd_smspec_get_region_var_node(const rd_smspec_type *rd_smspec, + const char *region_var, int region_nr) { + const auto node_ptr = rd_smspec_get_int_key_var_node( + rd_smspec->region_var_index, region_nr, region_var); if (!node_ptr) throw std::out_of_range("No such block variable"); return *node_ptr; } -bool ecl_smspec_has_region_var(const ecl_smspec_type *ecl_smspec, - const char *region_var, int region_nr) { - const auto node_ptr = ecl_smspec_get_int_key_var_node( - ecl_smspec->region_var_index, region_nr, region_var); +bool rd_smspec_has_region_var(const rd_smspec_type *rd_smspec, + const char *region_var, int region_nr) { + const auto node_ptr = rd_smspec_get_int_key_var_node( + rd_smspec->region_var_index, region_nr, region_var); return node_exists(node_ptr); } -int ecl_smspec_get_region_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *region_var, - int region_nr) { - const auto node_ptr = ecl_smspec_get_int_key_var_node( - ecl_smspec->region_var_index, region_nr, region_var); +int rd_smspec_get_region_var_params_index(const rd_smspec_type *rd_smspec, + const char *region_var, + int region_nr) { + const auto node_ptr = rd_smspec_get_int_key_var_node( + rd_smspec->region_var_index, region_nr, region_var); return node_valid_index(node_ptr); } -const ecl::smspec_node & -ecl_smspec_get_misc_var_node(const ecl_smspec_type *ecl_smspec, - const char *var) { +const rd::smspec_node & +rd_smspec_get_misc_var_node(const rd_smspec_type *rd_smspec, const char *var) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->misc_var_index, var); + rd_smspec_get_var_node(rd_smspec->misc_var_index, var); if (!node_ptr) throw std::out_of_range("No such misc variable"); return *node_ptr; } -bool ecl_smspec_has_misc_var(const ecl_smspec_type *ecl_smspec, - const char *var) { +bool rd_smspec_has_misc_var(const rd_smspec_type *rd_smspec, const char *var) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->misc_var_index, var); + rd_smspec_get_var_node(rd_smspec->misc_var_index, var); return node_exists(node_ptr); } -int ecl_smspec_get_misc_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *var) { +int rd_smspec_get_misc_var_params_index(const rd_smspec_type *rd_smspec, + const char *var) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->misc_var_index, var); + rd_smspec_get_var_node(rd_smspec->misc_var_index, var); return node_valid_index(node_ptr); } -const ecl::smspec_node * -ecl_smspec_get_well_completion_var_node__(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var, - int cell_nr) { - const auto well_iter = ecl_smspec->well_completion_var_index.find(well); - if (well_iter == ecl_smspec->well_completion_var_index.end()) +const rd::smspec_node * +rd_smspec_get_well_completion_var_node__(const rd_smspec_type *rd_smspec, + const char *well, const char *var, + int cell_nr) { + const auto well_iter = rd_smspec->well_completion_var_index.find(well); + if (well_iter == rd_smspec->well_completion_var_index.end()) return nullptr; const auto &num_map = well_iter->second; - return ecl_smspec_get_int_key_var_node(num_map, cell_nr, var); + return rd_smspec_get_int_key_var_node(num_map, cell_nr, var); } -const ecl::smspec_node & -ecl_smspec_get_well_completion_var_node(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var, - int cell_nr) { - const auto node_ptr = ecl_smspec_get_well_completion_var_node__( - ecl_smspec, well, var, cell_nr); +const rd::smspec_node & +rd_smspec_get_well_completion_var_node(const rd_smspec_type *rd_smspec, + const char *well, const char *var, + int cell_nr) { + const auto node_ptr = + rd_smspec_get_well_completion_var_node__(rd_smspec, well, var, cell_nr); if (!node_ptr) throw std::out_of_range("No such well/var/completion"); return *node_ptr; } -bool ecl_smspec_has_well_completion_var(const ecl_smspec_type *ecl_smspec, - const char *well, const char *var, - int cell_nr) { - const auto node_ptr = ecl_smspec_get_well_completion_var_node__( - ecl_smspec, well, var, cell_nr); +bool rd_smspec_has_well_completion_var(const rd_smspec_type *rd_smspec, + const char *well, const char *var, + int cell_nr) { + const auto node_ptr = + rd_smspec_get_well_completion_var_node__(rd_smspec, well, var, cell_nr); return node_exists(node_ptr); } -int ecl_smspec_get_well_completion_var_params_index( - const ecl_smspec_type *ecl_smspec, const char *well, const char *var, +int rd_smspec_get_well_completion_var_params_index( + const rd_smspec_type *rd_smspec, const char *well, const char *var, int cell_nr) { - const auto node_ptr = ecl_smspec_get_well_completion_var_node__( - ecl_smspec, well, var, cell_nr); + const auto node_ptr = + rd_smspec_get_well_completion_var_node__(rd_smspec, well, var, cell_nr); return node_valid_index(node_ptr); } @@ -1548,98 +1538,98 @@ int ecl_smspec_get_well_completion_var_params_index( "Not found" (i.e. -1). */ /* Completions not supported yet. */ -const ecl::smspec_node & -ecl_smspec_get_general_var_node(const ecl_smspec_type *smspec, - const char *lookup_kw) { +const rd::smspec_node & +rd_smspec_get_general_var_node(const rd_smspec_type *smspec, + const char *lookup_kw) { const auto node_ptr = - ecl_smspec_get_var_node(smspec->gen_var_index, lookup_kw); + rd_smspec_get_var_node(smspec->gen_var_index, lookup_kw); if (!node_ptr) throw std::out_of_range("No such variable: " + std::string(lookup_kw)); return *node_ptr; } -int ecl_smspec_get_general_var_params_index(const ecl_smspec_type *ecl_smspec, - const char *lookup_kw) { +int rd_smspec_get_general_var_params_index(const rd_smspec_type *rd_smspec, + const char *lookup_kw) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->gen_var_index, lookup_kw); + rd_smspec_get_var_node(rd_smspec->gen_var_index, lookup_kw); return node_valid_index(node_ptr); } -bool ecl_smspec_has_general_var(const ecl_smspec_type *ecl_smspec, - const char *lookup_kw) { +bool rd_smspec_has_general_var(const rd_smspec_type *rd_smspec, + const char *lookup_kw) { const auto node_ptr = - ecl_smspec_get_var_node(ecl_smspec->gen_var_index, lookup_kw); + rd_smspec_get_var_node(rd_smspec->gen_var_index, lookup_kw); return node_exists(node_ptr); } /** DIES if the lookup_kw is not present. */ -const char *ecl_smspec_get_general_var_unit(const ecl_smspec_type *ecl_smspec, - const char *lookup_kw) { +const char *rd_smspec_get_general_var_unit(const rd_smspec_type *rd_smspec, + const char *lookup_kw) { const auto smspec_node = - ecl_smspec_get_general_var_node(ecl_smspec, lookup_kw); + rd_smspec_get_general_var_node(rd_smspec, lookup_kw); return smspec_node_get_unit(&smspec_node); } -int ecl_smspec_get_time_seconds(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->time_seconds; +int rd_smspec_get_time_seconds(const rd_smspec_type *rd_smspec) { + return rd_smspec->time_seconds; } -int ecl_smspec_get_time_index(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->time_index; +int rd_smspec_get_time_index(const rd_smspec_type *rd_smspec) { + return rd_smspec->time_index; } -time_t ecl_smspec_get_start_time(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->sim_start_time; +time_t rd_smspec_get_start_time(const rd_smspec_type *rd_smspec) { + return rd_smspec->sim_start_time; } -bool ecl_smspec_get_formatted(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->formatted; +bool rd_smspec_get_formatted(const rd_smspec_type *rd_smspec) { + return rd_smspec->formatted; } -const char *ecl_smspec_get_header_file(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->header_file.c_str(); +const char *rd_smspec_get_header_file(const rd_smspec_type *rd_smspec) { + return rd_smspec->header_file.c_str(); } -int ecl_smspec_get_restart_step(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->restart_step; +int rd_smspec_get_restart_step(const rd_smspec_type *rd_smspec) { + return rd_smspec->restart_step; } -int ecl_smspec_get_first_step(const ecl_smspec_type *ecl_smspec) { - if (ecl_smspec->restart_step > 0) - return ecl_smspec->restart_step + 1; +int rd_smspec_get_first_step(const rd_smspec_type *rd_smspec) { + if (rd_smspec->restart_step > 0) + return rd_smspec->restart_step + 1; else return 1; } -const char *ecl_smspec_get_restart_case(const ecl_smspec_type *ecl_smspec) { - if (ecl_smspec->restart_case.size() > 0) - return ecl_smspec->restart_case.c_str(); +const char *rd_smspec_get_restart_case(const rd_smspec_type *rd_smspec) { + if (rd_smspec->restart_case.size() > 0) + return rd_smspec->restart_case.c_str(); else return NULL; } const std::vector & -ecl_smspec_get_params_default(const ecl_smspec_type *ecl_smspec) { - return ecl_smspec->params_default; +rd_smspec_get_params_default(const rd_smspec_type *rd_smspec) { + return rd_smspec->params_default; } -void ecl_smspec_free(ecl_smspec_type *ecl_smspec) { delete ecl_smspec; } +void rd_smspec_free(rd_smspec_type *rd_smspec) { delete rd_smspec; } -void ecl_smspec_free__(void *__ecl_smspec) { - ecl_smspec_type *ecl_smspec = ecl_smspec_safe_cast(__ecl_smspec); - ecl_smspec_free(ecl_smspec); +void rd_smspec_free__(void *__rd_smspec) { + rd_smspec_type *rd_smspec = rd_smspec_safe_cast(__rd_smspec); + rd_smspec_free(rd_smspec); } -int ecl_smspec_get_date_day_index(const ecl_smspec_type *smspec) { +int rd_smspec_get_date_day_index(const rd_smspec_type *smspec) { return smspec->day_index; } -int ecl_smspec_get_date_month_index(const ecl_smspec_type *smspec) { +int rd_smspec_get_date_month_index(const rd_smspec_type *smspec) { return smspec->month_index; } -int ecl_smspec_get_date_year_index(const ecl_smspec_type *smspec) { +int rd_smspec_get_date_year_index(const rd_smspec_type *smspec) { return smspec->year_index; } @@ -1649,10 +1639,10 @@ int ecl_smspec_get_date_year_index(const ecl_smspec_type *smspec) { internalized the function will fail hard. */ -bool ecl_smspec_general_is_total(const ecl_smspec_type *smspec, - const char *gen_key) { - const ecl::smspec_node &smspec_node = - ecl_smspec_get_general_var_node(smspec, gen_key); +bool rd_smspec_general_is_total(const rd_smspec_type *smspec, + const char *gen_key) { + const rd::smspec_node &smspec_node = + rd_smspec_get_general_var_node(smspec, gen_key); return smspec_node_is_total(&smspec_node); } @@ -1660,7 +1650,7 @@ bool ecl_smspec_general_is_total(const ecl_smspec_type *smspec, Fills a stringlist instance with all the gen_key string matching the supplied pattern. I.e. - ecl_smspec_alloc_matching_general_var_list( smspec , "WGOR:*"); + rd_smspec_alloc_matching_general_var_list( smspec , "WGOR:*"); will give a list of WGOR for ALL the wells. The function is unfortunately not as useful as one might think because ECLIPSE @@ -1673,9 +1663,9 @@ bool ecl_smspec_general_is_total(const ecl_smspec_type *smspec, keys will match. */ -void ecl_smspec_select_matching_general_var_list(const ecl_smspec_type *smspec, - const char *pattern, - stringlist_type *keys) { +void rd_smspec_select_matching_general_var_list(const rd_smspec_type *smspec, + const char *pattern, + stringlist_type *keys) { std::set ex_keys; for (int i = 0; i < stringlist_get_size(keys); i++) ex_keys.insert(stringlist_iget(keys, i)); @@ -1705,18 +1695,18 @@ void ecl_smspec_select_matching_general_var_list(const ecl_smspec_type *smspec, /** Allocates a new stringlist and initializes it with the - ecl_smspec_select_matching_general_var_list() function. + rd_smspec_select_matching_general_var_list() function. */ stringlist_type * -ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type *smspec, - const char *pattern) { +rd_smspec_alloc_matching_general_var_list(const rd_smspec_type *smspec, + const char *pattern) { stringlist_type *keys = stringlist_alloc_new(); - ecl_smspec_select_matching_general_var_list(smspec, pattern, keys); + rd_smspec_select_matching_general_var_list(smspec, pattern, keys); return keys; } -const char *ecl_smspec_get_join_string(const ecl_smspec_type *smspec) { +const char *rd_smspec_get_join_string(const rd_smspec_type *smspec) { return smspec->key_join_string.c_str(); } @@ -1733,8 +1723,8 @@ const char *ecl_smspec_get_join_string(const ecl_smspec_type *smspec) { */ static stringlist_type * -ecl_smspec_alloc_map_list(const std::map &mp, - const char *pattern) { +rd_smspec_alloc_map_list(const std::map &mp, + const char *pattern) { stringlist_type *map_list = stringlist_alloc_new(); for (const auto &pair : mp) { @@ -1749,9 +1739,9 @@ ecl_smspec_alloc_map_list(const std::map &mp, return map_list; } -stringlist_type *ecl_smspec_alloc_well_list(const ecl_smspec_type *smspec, - const char *pattern) { - return ecl_smspec_alloc_map_list(smspec->well_var_index, pattern); +stringlist_type *rd_smspec_alloc_well_list(const rd_smspec_type *smspec, + const char *pattern) { + return rd_smspec_alloc_map_list(smspec->well_var_index, pattern); } /** @@ -1760,9 +1750,9 @@ stringlist_type *ecl_smspec_alloc_well_list(const ecl_smspec_type *smspec, with stringlist_free(); */ -stringlist_type *ecl_smspec_alloc_group_list(const ecl_smspec_type *smspec, - const char *pattern) { - return ecl_smspec_alloc_map_list(smspec->group_var_index, pattern); +stringlist_type *rd_smspec_alloc_group_list(const rd_smspec_type *smspec, + const char *pattern) { + return rd_smspec_alloc_map_list(smspec->group_var_index, pattern); } /** @@ -1771,7 +1761,7 @@ stringlist_type *ecl_smspec_alloc_group_list(const ecl_smspec_type *smspec, with stringlist_free(); */ -stringlist_type *ecl_smspec_alloc_well_var_list(const ecl_smspec_type *smspec) { +stringlist_type *rd_smspec_alloc_well_var_list(const rd_smspec_type *smspec) { stringlist_type *stringlist = stringlist_alloc_new(); for (const auto &pair : smspec->well_var_index) stringlist_append_copy(stringlist, pair.first.c_str()); @@ -1779,26 +1769,26 @@ stringlist_type *ecl_smspec_alloc_well_var_list(const ecl_smspec_type *smspec) { return stringlist; } -const int *ecl_smspec_get_grid_dims(const ecl_smspec_type *smspec) { +const int *rd_smspec_get_grid_dims(const rd_smspec_type *smspec) { return smspec->grid_dims; } -char *ecl_smspec_alloc_well_key(const ecl_smspec_type *smspec, - const char *keyword, const char *wgname) { +char *rd_smspec_alloc_well_key(const rd_smspec_type *smspec, + const char *keyword, const char *wgname) { return smspec_alloc_well_key(smspec->key_join_string.c_str(), keyword, wgname); } -/*void ecl_smspec_sort( ecl_smspec_type * smspec ) { +/*void rd_smspec_sort( rd_smspec_type * smspec ) { std::sort(smspec->smspec_nodes.begin(), smspec->smspec_nodes.end(), smspec_node_lt); for (int i=0; i < static_cast(smspec->smspec_nodes.size()); i++) { - ecl::smspec_node& node = *smspec->smspec_nodes[i].get(); + rd::smspec_node& node = *smspec->smspec_nodes[i].get(); smspec_node_set_params_index( &node , i ); } } */ -ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_smspec_type *smspec) { +ert_rd_unit_enum rd_smspec_get_unit_system(const rd_smspec_type *smspec) { return smspec->unit_system; } diff --git a/lib/resdata/rd_subsidence.cpp b/lib/resdata/rd_subsidence.cpp index c2d41a220b..61786ca925 100644 --- a/lib/resdata/rd_subsidence.cpp +++ b/lib/resdata/rd_subsidence.cpp @@ -7,36 +7,36 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "detail/ecl/ecl_grid_cache.hpp" +#include "detail/resdata/rd_grid_cache.hpp" /** This file contains datastructures for calculating changes in subsidence from compression of reservoirs. The main datastructure is the - ecl_subsidence_type structure (which is the only structure which is + rd_subsidence_type structure (which is the only structure which is exported). */ /** - The ecl_subsidence_struct datastructure is the main structure for + The rd_subsidence_struct datastructure is the main structure for calculating the subsidence from time lapse ECLIPSE simulations. */ -struct ecl_subsidence_struct { - const ecl_file_type * +struct rd_subsidence_struct { + const rd_file_type * init_file; /* The init file - a shared reference owned by calling scope. */ - ecl::ecl_grid_cache *grid_cache; + rd::rd_grid_cache *grid_cache; bool *aquifer_cell; hash_type * - surveys; /* A hash table containg ecl_subsidence_survey_type instances; one instance + surveys; /* A hash table containg rd_subsidence_survey_type instances; one instance for each interesting time. */ double *compressibility; /*total compressibility*/ double *poisson_ratio; @@ -46,10 +46,10 @@ struct ecl_subsidence_struct { Data structure representing one subsidence survey. */ -#define ECL_SUBSIDENCE_SURVEY_ID 88517 -struct ecl_subsidence_survey_struct { +#define RD_SUBSIDENCE_SURVEY_ID 88517 +struct rd_subsidence_survey_struct { UTIL_TYPE_ID_DECLARATION; - const ecl::ecl_grid_cache *grid_cache; + const rd::rd_grid_cache *grid_cache; const bool * aquifer_cell; /* Is this cell a numerical aquifer cell - must be disregarded. */ char *name; /* Name of the survey - arbitrary string. */ @@ -59,12 +59,12 @@ struct ecl_subsidence_survey_struct { *dynamic_porevolume; /* Porevolume in each grid cell at survey time */ }; -static ecl_subsidence_survey_type * -ecl_subsidence_survey_alloc_empty(const ecl_subsidence_type *sub, - const char *name) { - ecl_subsidence_survey_type *survey = - (ecl_subsidence_survey_type *)util_malloc(sizeof *survey); - UTIL_TYPE_ID_INIT(survey, ECL_SUBSIDENCE_SURVEY_ID); +static rd_subsidence_survey_type * +rd_subsidence_survey_alloc_empty(const rd_subsidence_type *sub, + const char *name) { + rd_subsidence_survey_type *survey = + (rd_subsidence_survey_type *)util_malloc(sizeof *survey); + UTIL_TYPE_ID_INIT(survey, RD_SUBSIDENCE_SURVEY_ID); survey->grid_cache = sub->grid_cache; survey->aquifer_cell = sub->aquifer_cell; survey->name = util_alloc_string_copy(name); @@ -78,47 +78,47 @@ ecl_subsidence_survey_alloc_empty(const ecl_subsidence_type *sub, return survey; } -static UTIL_SAFE_CAST_FUNCTION(ecl_subsidence_survey, ECL_SUBSIDENCE_SURVEY_ID) +static UTIL_SAFE_CAST_FUNCTION(rd_subsidence_survey, RD_SUBSIDENCE_SURVEY_ID) - static ecl_subsidence_survey_type *ecl_subsidence_survey_alloc_PRESSURE( - ecl_subsidence_type *ecl_subsidence, - const ecl_file_view_type *restart_view, const char *name) { + static rd_subsidence_survey_type *rd_subsidence_survey_alloc_PRESSURE( + rd_subsidence_type *rd_subsidence, + const rd_file_view_type *restart_view, const char *name) { - ecl_subsidence_survey_type *survey = - ecl_subsidence_survey_alloc_empty(ecl_subsidence, name); - const ecl::ecl_grid_cache &grid_cache = *(ecl_subsidence->grid_cache); + rd_subsidence_survey_type *survey = + rd_subsidence_survey_alloc_empty(rd_subsidence, name); + const rd::rd_grid_cache &grid_cache = *(rd_subsidence->grid_cache); const auto &global_index = grid_cache.global_index(); const int size = grid_cache.size(); int active_index; - ecl_kw_type *init_porv_kw = ecl_file_iget_named_kw( - ecl_subsidence->init_file, PORV_KW, 0); /*Global indexing*/ - ecl_kw_type *pressure_kw = ecl_file_view_iget_named_kw( + rd_kw_type *init_porv_kw = rd_file_iget_named_kw( + rd_subsidence->init_file, PORV_KW, 0); /*Global indexing*/ + rd_kw_type *pressure_kw = rd_file_view_iget_named_kw( restart_view, PRESSURE_KW, 0); /*Active indexing*/ - ecl_kw_type *rporv_kw = NULL; - if (ecl_file_view_has_kw(restart_view, RPORV_KW)) { + rd_kw_type *rporv_kw = NULL; + if (rd_file_view_has_kw(restart_view, RPORV_KW)) { survey->dynamic_porevolume = - (double *)util_calloc(ecl_subsidence->grid_cache->size(), + (double *)util_calloc(rd_subsidence->grid_cache->size(), sizeof *survey->dynamic_porevolume); - rporv_kw = ecl_file_view_iget_named_kw(restart_view, RPORV_KW, 0); + rporv_kw = rd_file_view_iget_named_kw(restart_view, RPORV_KW, 0); } for (active_index = 0; active_index < size; active_index++) { survey->porv[active_index] = - ecl_kw_iget_float(init_porv_kw, global_index[active_index]); + rd_kw_iget_float(init_porv_kw, global_index[active_index]); survey->pressure[active_index] = - ecl_kw_iget_float(pressure_kw, active_index); + rd_kw_iget_float(pressure_kw, active_index); if (rporv_kw) survey->dynamic_porevolume[active_index] = - ecl_kw_iget_float(rporv_kw, active_index); + rd_kw_iget_float(rporv_kw, active_index); } return survey; } static void -ecl_subsidence_survey_free(ecl_subsidence_survey_type *subsidence_survey) { +rd_subsidence_survey_free(rd_subsidence_survey_type *subsidence_survey) { free(subsidence_survey->name); free(subsidence_survey->porv); free(subsidence_survey->pressure); @@ -126,20 +126,20 @@ ecl_subsidence_survey_free(ecl_subsidence_survey_type *subsidence_survey) { free(subsidence_survey); } -static void ecl_subsidence_survey_free__(void *__subsidence_survey) { - ecl_subsidence_survey_type *subsidence_survey = - ecl_subsidence_survey_safe_cast(__subsidence_survey); - ecl_subsidence_survey_free(subsidence_survey); +static void rd_subsidence_survey_free__(void *__subsidence_survey) { + rd_subsidence_survey_type *subsidence_survey = + rd_subsidence_survey_safe_cast(__subsidence_survey); + rd_subsidence_survey_free(subsidence_survey); } static double -ecl_subsidence_survey_eval(const ecl_subsidence_survey_type *base_survey, - const ecl_subsidence_survey_type *monitor_survey, - ecl_region_type *region, double utm_x, double utm_y, - double depth, double compressibility, - double poisson_ratio) { +rd_subsidence_survey_eval(const rd_subsidence_survey_type *base_survey, + const rd_subsidence_survey_type *monitor_survey, + rd_region_type *region, double utm_x, double utm_y, + double depth, double compressibility, + double poisson_ratio) { - const ecl::ecl_grid_cache &grid_cache = *(base_survey->grid_cache); + const rd::rd_grid_cache &grid_cache = *(base_survey->grid_cache); const int size = grid_cache.size(); double *weight = (double *)util_calloc(size, sizeof *weight); double deltaz; @@ -157,21 +157,21 @@ ecl_subsidence_survey_eval(const ecl_subsidence_survey_type *base_survey, } deltaz = compressibility * 31.83099 * (1 - poisson_ratio) * - ecl_grav_common_eval_biot_savart(grid_cache, region, - base_survey->aquifer_cell, weight, - utm_x, utm_y, depth); + rd_grav_common_eval_biot_savart(grid_cache, region, + base_survey->aquifer_cell, weight, + utm_x, utm_y, depth); free(weight); return deltaz; } -static double ecl_subsidence_survey_eval_geertsma( - const ecl_subsidence_survey_type *base_survey, - const ecl_subsidence_survey_type *monitor_survey, ecl_region_type *region, +static double rd_subsidence_survey_eval_geertsma( + const rd_subsidence_survey_type *base_survey, + const rd_subsidence_survey_type *monitor_survey, rd_region_type *region, double utm_x, double utm_y, double depth, double youngs_modulus, double poisson_ratio, double seabed) { - const ecl::ecl_grid_cache &grid_cache = *(base_survey->grid_cache); + const rd::rd_grid_cache &grid_cache = *(base_survey->grid_cache); const auto &cell_volume = grid_cache.volume(); const int size = grid_cache.size(); double scale_factor = 1e4 * (1 + poisson_ratio) * (1 - 2 * poisson_ratio) / @@ -190,7 +190,7 @@ static double ecl_subsidence_survey_eval_geertsma( } } - deltaz = ecl_grav_common_eval_geertsma( + deltaz = rd_grav_common_eval_geertsma( grid_cache, region, base_survey->aquifer_cell, weight, utm_x, utm_y, depth, poisson_ratio, seabed); @@ -198,13 +198,13 @@ static double ecl_subsidence_survey_eval_geertsma( return deltaz; } -static double ecl_subsidence_survey_eval_geertsma_rporv( - const ecl_subsidence_survey_type *base_survey, - const ecl_subsidence_survey_type *monitor_survey, ecl_region_type *region, +static double rd_subsidence_survey_eval_geertsma_rporv( + const rd_subsidence_survey_type *base_survey, + const rd_subsidence_survey_type *monitor_survey, rd_region_type *region, double utm_x, double utm_y, double depth, double youngs_modulus, double poisson_ratio, double seabed) { - const ecl::ecl_grid_cache &grid_cache = *(base_survey->grid_cache); + const rd::rd_grid_cache &grid_cache = *(base_survey->grid_cache); std::vector weight(grid_cache.size()); if (!base_survey->dynamic_porevolume) { @@ -230,111 +230,110 @@ static double ecl_subsidence_survey_eval_geertsma_rporv( weight[index] = base_survey->dynamic_porevolume[index] / (4 * M_PI); } - return ecl_grav_common_eval_geertsma( + return rd_grav_common_eval_geertsma( grid_cache, region, base_survey->aquifer_cell, weight.data(), utm_x, utm_y, depth, poisson_ratio, seabed); } /** The grid instance is only used during the construction phase. The - @init_file object is used by the ecl_subsidence_add_survey_XXX() + @init_file object is used by the rd_subsidence_add_survey_XXX() functions; and calling scope must NOT destroy this object before all surveys have been added. */ -ecl_subsidence_type *ecl_subsidence_alloc(const ecl_grid_type *ecl_grid, - const ecl_file_type *init_file) { - ecl_subsidence_type *ecl_subsidence = - (ecl_subsidence_type *)util_malloc(sizeof *ecl_subsidence); - ecl_subsidence->init_file = init_file; - ecl_subsidence->grid_cache = new ecl::ecl_grid_cache(ecl_grid); - ecl_subsidence->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( - *(ecl_subsidence->grid_cache), init_file); - - ecl_subsidence->surveys = hash_alloc(); - return ecl_subsidence; +rd_subsidence_type *rd_subsidence_alloc(const rd_grid_type *rd_grid, + const rd_file_type *init_file) { + rd_subsidence_type *rd_subsidence = + (rd_subsidence_type *)util_malloc(sizeof *rd_subsidence); + rd_subsidence->init_file = init_file; + rd_subsidence->grid_cache = new rd::rd_grid_cache(rd_grid); + rd_subsidence->aquifer_cell = rd_grav_common_alloc_aquifer_cell( + *(rd_subsidence->grid_cache), init_file); + + rd_subsidence->surveys = hash_alloc(); + return rd_subsidence; } -static void ecl_subsidence_add_survey__(ecl_subsidence_type *subsidence, - const char *name, - ecl_subsidence_survey_type *survey) { +static void rd_subsidence_add_survey__(rd_subsidence_type *subsidence, + const char *name, + rd_subsidence_survey_type *survey) { hash_insert_hash_owned_ref(subsidence->surveys, name, survey, - ecl_subsidence_survey_free__); + rd_subsidence_survey_free__); } -ecl_subsidence_survey_type * -ecl_subsidence_add_survey_PRESSURE(ecl_subsidence_type *subsidence, - const char *name, - const ecl_file_view_type *restart_view) { - ecl_subsidence_survey_type *survey = - ecl_subsidence_survey_alloc_PRESSURE(subsidence, restart_view, name); - ecl_subsidence_add_survey__(subsidence, name, survey); +rd_subsidence_survey_type * +rd_subsidence_add_survey_PRESSURE(rd_subsidence_type *subsidence, + const char *name, + const rd_file_view_type *restart_view) { + rd_subsidence_survey_type *survey = + rd_subsidence_survey_alloc_PRESSURE(subsidence, restart_view, name); + rd_subsidence_add_survey__(subsidence, name, survey); return survey; } -bool ecl_subsidence_has_survey(const ecl_subsidence_type *subsidence, - const char *name) { +bool rd_subsidence_has_survey(const rd_subsidence_type *subsidence, + const char *name) { return hash_has_key(subsidence->surveys, name); } -static ecl_subsidence_survey_type * -ecl_subsidence_get_survey(const ecl_subsidence_type *subsidence, - const char *name) { +static rd_subsidence_survey_type * +rd_subsidence_get_survey(const rd_subsidence_type *subsidence, + const char *name) { if (name == NULL) return NULL; // Calling scope must determine if this is OK? else - return (ecl_subsidence_survey_type *)hash_get(subsidence->surveys, - name); + return (rd_subsidence_survey_type *)hash_get(subsidence->surveys, name); } -double ecl_subsidence_eval(const ecl_subsidence_type *subsidence, - const char *base, const char *monitor, - ecl_region_type *region, double utm_x, double utm_y, - double depth, double compressibility, - double poisson_ratio) { - ecl_subsidence_survey_type *base_survey = - ecl_subsidence_get_survey(subsidence, base); - ecl_subsidence_survey_type *monitor_survey = - ecl_subsidence_get_survey(subsidence, monitor); - return ecl_subsidence_survey_eval(base_survey, monitor_survey, region, - utm_x, utm_y, depth, compressibility, - poisson_ratio); +double rd_subsidence_eval(const rd_subsidence_type *subsidence, + const char *base, const char *monitor, + rd_region_type *region, double utm_x, double utm_y, + double depth, double compressibility, + double poisson_ratio) { + rd_subsidence_survey_type *base_survey = + rd_subsidence_get_survey(subsidence, base); + rd_subsidence_survey_type *monitor_survey = + rd_subsidence_get_survey(subsidence, monitor); + return rd_subsidence_survey_eval(base_survey, monitor_survey, region, utm_x, + utm_y, depth, compressibility, + poisson_ratio); } -double ecl_subsidence_eval_geertsma(const ecl_subsidence_type *subsidence, - const char *base, const char *monitor, - ecl_region_type *region, double utm_x, - double utm_y, double depth, - double youngs_modulus, double poisson_ratio, - double seabed) { - ecl_subsidence_survey_type *base_survey = - ecl_subsidence_get_survey(subsidence, base); - ecl_subsidence_survey_type *monitor_survey = - ecl_subsidence_get_survey(subsidence, monitor); - return ecl_subsidence_survey_eval_geertsma( +double rd_subsidence_eval_geertsma(const rd_subsidence_type *subsidence, + const char *base, const char *monitor, + rd_region_type *region, double utm_x, + double utm_y, double depth, + double youngs_modulus, double poisson_ratio, + double seabed) { + rd_subsidence_survey_type *base_survey = + rd_subsidence_get_survey(subsidence, base); + rd_subsidence_survey_type *monitor_survey = + rd_subsidence_get_survey(subsidence, monitor); + return rd_subsidence_survey_eval_geertsma( base_survey, monitor_survey, region, utm_x, utm_y, depth, youngs_modulus, poisson_ratio, seabed); } -double ecl_subsidence_eval_geertsma_rporv(const ecl_subsidence_type *subsidence, - const char *base, const char *monitor, - ecl_region_type *region, double utm_x, - double utm_y, double depth, - double youngs_modulus, - double poisson_ratio, double seabed) { - ecl_subsidence_survey_type *base_survey = - ecl_subsidence_get_survey(subsidence, base); - ecl_subsidence_survey_type *monitor_survey = - ecl_subsidence_get_survey(subsidence, monitor); - return ecl_subsidence_survey_eval_geertsma_rporv( +double rd_subsidence_eval_geertsma_rporv(const rd_subsidence_type *subsidence, + const char *base, const char *monitor, + rd_region_type *region, double utm_x, + double utm_y, double depth, + double youngs_modulus, + double poisson_ratio, double seabed) { + rd_subsidence_survey_type *base_survey = + rd_subsidence_get_survey(subsidence, base); + rd_subsidence_survey_type *monitor_survey = + rd_subsidence_get_survey(subsidence, monitor); + return rd_subsidence_survey_eval_geertsma_rporv( base_survey, monitor_survey, region, utm_x, utm_y, depth, youngs_modulus, poisson_ratio, seabed); } -void ecl_subsidence_free(ecl_subsidence_type *ecl_subsidence) { - delete ecl_subsidence->grid_cache; +void rd_subsidence_free(rd_subsidence_type *rd_subsidence) { + delete rd_subsidence->grid_cache; - free(ecl_subsidence->aquifer_cell); - hash_free(ecl_subsidence->surveys); - free(ecl_subsidence); + free(rd_subsidence->aquifer_cell); + hash_free(rd_subsidence->surveys); + free(rd_subsidence); } diff --git a/lib/resdata/rd_sum.cpp b/lib/resdata/rd_sum.cpp index fc74662398..145b1d1c46 100644 --- a/lib/resdata/rd_sum.cpp +++ b/lib/resdata/rd_sum.cpp @@ -15,22 +15,22 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include "detail/util/path.hpp" /** The ECLIPSE summary data is organised in a header file (.SMSPEC) and the actual summary data. This file implements a data structure - ecl_sum_type which holds ECLIPSE summary data. Most of the actual - implementation is in separate files ecl_smspec.c for the SMSPEC - header, and ecl_sum_data for the actual data. + rd_sum_type which holds ECLIPSE summary data. Most of the actual + implementation is in separate files rd_smspec.c for the SMSPEC + header, and rd_sum_data for the actual data. Observe that this datastructure is built up around internalizing ECLIPSE summary data, the code has NO AMBITION of being able to @@ -59,23 +59,23 @@ summary vector. The INDEX column in the header information is NOT part of the - SMSPEC file, but an important part of the ecl_smspec + SMSPEC file, but an important part of the rd_smspec implementation. The the values from WGNAMES/KEYWORDS/NUMS are combined to create a unique key; and the corresponding index is used to lookup a numerical value from the PARAMS vector with actual data. - These matters are documented further in the ecl_smspec.c and - ecl_sum_data.c files. + These matters are documented further in the rd_smspec.c and + rd_sum_data.c files. */ -#define ECL_SUM_ID 89067 +#define RD_SUM_ID 89067 -struct ecl_sum_struct { +struct rd_sum_struct { UTIL_TYPE_ID_DECLARATION; - ecl_smspec_type *smspec; /* Internalized version of the SMSPEC file. */ - ecl_sum_data_type *data; /* The data - can be NULL. */ - ecl_sum_type *restart_case; + rd_smspec_type *smspec; /* Internalized version of the SMSPEC file. */ + rd_sum_data_type *data; /* The data - can be NULL. */ + rd_sum_type *restart_case; bool fmt_case; bool unified; @@ -85,153 +85,151 @@ struct ecl_sum_struct { char *abs_path; /* Absolute path. */ char *base; /* Only the basename. */ char * - ecl_case; /* This is the current case, with optional path component. == path + base*/ + rd_case; /* This is the current case, with optional path component. == path + base*/ char * ext; /* Only to support selective loading of formatted|unformatted and unified|multiple. (can be NULL) */ }; -UTIL_SAFE_CAST_FUNCTION(ecl_sum, ECL_SUM_ID); -UTIL_IS_INSTANCE_FUNCTION(ecl_sum, ECL_SUM_ID); +UTIL_SAFE_CAST_FUNCTION(rd_sum, RD_SUM_ID); +UTIL_IS_INSTANCE_FUNCTION(rd_sum, RD_SUM_ID); /** Reads the data from ECLIPSE summary files, can either be a list of files BASE.S0000, BASE.S0001, BASE.S0002,.. or one unified file. Formatted/unformatted is detected automagically. - The actual loading is implemented in the ecl_sum_data.c file. + The actual loading is implemented in the rd_sum_data.c file. */ -void ecl_sum_set_case(ecl_sum_type *ecl_sum, const char *input_arg) { - free(ecl_sum->ecl_case); - free(ecl_sum->path); - free(ecl_sum->abs_path); - free(ecl_sum->base); - free(ecl_sum->ext); +void rd_sum_set_case(rd_sum_type *rd_sum, const char *input_arg) { + free(rd_sum->rd_case); + free(rd_sum->path); + free(rd_sum->abs_path); + free(rd_sum->base); + free(rd_sum->ext); { - std::string path = ecl::util::path::dirname(input_arg); - std::string base = ecl::util::path::basename(input_arg); - std::string ext = ecl::util::path::extension(input_arg); + std::string path = rd::util::path::dirname(input_arg); + std::string base = rd::util::path::basename(input_arg); + std::string ext = rd::util::path::extension(input_arg); - ecl_sum->ecl_case = - util_alloc_filename(path.c_str(), base.c_str(), NULL); + rd_sum->rd_case = util_alloc_filename(path.c_str(), base.c_str(), NULL); if (path.size()) - ecl_sum->path = util_alloc_string_copy(path.c_str()); + rd_sum->path = util_alloc_string_copy(path.c_str()); else - ecl_sum->path = NULL; + rd_sum->path = NULL; if (base.size()) - ecl_sum->base = util_alloc_string_copy(base.c_str()); + rd_sum->base = util_alloc_string_copy(base.c_str()); else - ecl_sum->base = NULL; + rd_sum->base = NULL; if (ext.size()) - ecl_sum->ext = util_alloc_string_copy(ext.c_str()); + rd_sum->ext = util_alloc_string_copy(ext.c_str()); else - ecl_sum->ext = NULL; + rd_sum->ext = NULL; if (path.size() > 0) - ecl_sum->abs_path = util_alloc_abs_path(path.c_str()); + rd_sum->abs_path = util_alloc_abs_path(path.c_str()); else - ecl_sum->abs_path = util_alloc_cwd(); + rd_sum->abs_path = util_alloc_cwd(); } } -static ecl_sum_type *ecl_sum_alloc__(const char *input_arg, - const char *key_join_string) { - if (!ecl_util_path_access(input_arg)) +static rd_sum_type *rd_sum_alloc__(const char *input_arg, + const char *key_join_string) { + if (!rd_path_access(input_arg)) return NULL; - ecl_sum_type *ecl_sum = (ecl_sum_type *)util_malloc(sizeof *ecl_sum); - UTIL_TYPE_ID_INIT(ecl_sum, ECL_SUM_ID); + rd_sum_type *rd_sum = (rd_sum_type *)util_malloc(sizeof *rd_sum); + UTIL_TYPE_ID_INIT(rd_sum, RD_SUM_ID); - ecl_sum->ecl_case = NULL; - ecl_sum->path = NULL; - ecl_sum->base = NULL; - ecl_sum->ext = NULL; - ecl_sum->abs_path = NULL; - ecl_sum_set_case(ecl_sum, input_arg); - ecl_sum->key_join_string = util_alloc_string_copy(key_join_string); + rd_sum->rd_case = NULL; + rd_sum->path = NULL; + rd_sum->base = NULL; + rd_sum->ext = NULL; + rd_sum->abs_path = NULL; + rd_sum_set_case(rd_sum, input_arg); + rd_sum->key_join_string = util_alloc_string_copy(key_join_string); - ecl_sum->smspec = NULL; - ecl_sum->data = NULL; - ecl_sum->restart_case = NULL; + rd_sum->smspec = NULL; + rd_sum->data = NULL; + rd_sum->restart_case = NULL; - return ecl_sum; + return rd_sum; } -static bool ecl_sum_fread_data(ecl_sum_type *ecl_sum, - const stringlist_type *data_files, - bool include_restart, bool lazy_load, - int file_options) { - if (ecl_sum->data != NULL) - ecl_sum_free_data(ecl_sum); +static bool rd_sum_fread_data(rd_sum_type *rd_sum, + const stringlist_type *data_files, + bool include_restart, bool lazy_load, + int file_options) { + if (rd_sum->data != NULL) + rd_sum_free_data(rd_sum); - ecl_sum->data = ecl_sum_data_alloc(ecl_sum->smspec); - return ecl_sum_data_fread(ecl_sum->data, data_files, lazy_load, - file_options); + rd_sum->data = rd_sum_data_alloc(rd_sum->smspec); + return rd_sum_data_fread(rd_sum->data, data_files, lazy_load, file_options); } -static void ecl_sum_fread_history(ecl_sum_type *ecl_sum, bool lazy_load, - int file_options) { - char *restart_header = ecl_util_alloc_filename( - NULL, ecl_smspec_get_restart_case(ecl_sum->smspec), - ECL_SUMMARY_HEADER_FILE, ecl_smspec_get_formatted(ecl_sum->smspec), -1); - ecl_sum_type *restart_case = ecl_sum_fread_alloc_case2__( +static void rd_sum_fread_history(rd_sum_type *rd_sum, bool lazy_load, + int file_options) { + char *restart_header = rd_alloc_filename( + NULL, rd_smspec_get_restart_case(rd_sum->smspec), + RD_SUMMARY_HEADER_FILE, rd_smspec_get_formatted(rd_sum->smspec), -1); + rd_sum_type *restart_case = rd_sum_fread_alloc_case2__( restart_header, ":", true, lazy_load, file_options); if (restart_case) { - ecl_sum->restart_case = restart_case; - ecl_sum_data_add_case(ecl_sum->data, restart_case->data); + rd_sum->restart_case = restart_case; + rd_sum_data_add_case(rd_sum->data, restart_case->data); } free(restart_header); } -static bool ecl_sum_fread(ecl_sum_type *ecl_sum, const char *header_file, - const stringlist_type *data_files, - bool include_restart, bool lazy_load, - int file_options) { - ecl_sum->smspec = ecl_smspec_fread_alloc( - header_file, ecl_sum->key_join_string, include_restart); - if (ecl_sum->smspec) { +static bool rd_sum_fread(rd_sum_type *rd_sum, const char *header_file, + const stringlist_type *data_files, + bool include_restart, bool lazy_load, + int file_options) { + rd_sum->smspec = rd_smspec_fread_alloc(header_file, rd_sum->key_join_string, + include_restart); + if (rd_sum->smspec) { bool fmt_file; - ecl_util_get_file_type(header_file, &fmt_file, NULL); - ecl_sum_set_fmt_case(ecl_sum, fmt_file); + rd_get_file_type(header_file, &fmt_file, NULL); + rd_sum_set_fmt_case(rd_sum, fmt_file); } else return false; - if (ecl_sum_fread_data(ecl_sum, data_files, include_restart, lazy_load, - file_options)) { - ecl_file_enum file_type = - ecl_util_get_file_type(stringlist_iget(data_files, 0), NULL, NULL); + if (rd_sum_fread_data(rd_sum, data_files, include_restart, lazy_load, + file_options)) { + rd_file_enum file_type = + rd_get_file_type(stringlist_iget(data_files, 0), NULL, NULL); - if (file_type == ECL_SUMMARY_FILE) - ecl_sum_set_unified(ecl_sum, false); - else if (file_type == ECL_UNIFIED_SUMMARY_FILE) - ecl_sum_set_unified(ecl_sum, true); + if (file_type == RD_SUMMARY_FILE) + rd_sum_set_unified(rd_sum, false); + else if (file_type == RD_UNIFIED_SUMMARY_FILE) + rd_sum_set_unified(rd_sum, true); else - util_abort("%s: FileTypeError, should be ECL_SUMMARY_FILE OR " - "ECL_UNIFIED_SUMMARY_FILE \n", + util_abort("%s: FileTypeError, should be RD_SUMMARY_FILE OR " + "RD_UNIFIED_SUMMARY_FILE \n", __func__); } else return false; - if (include_restart && ecl_smspec_get_restart_case(ecl_sum->smspec)) - ecl_sum_fread_history(ecl_sum, lazy_load, file_options); + if (include_restart && rd_smspec_get_restart_case(rd_sum->smspec)) + rd_sum_fread_history(rd_sum, lazy_load, file_options); return true; } -static bool ecl_sum_fread_case(ecl_sum_type *ecl_sum, bool include_restart, - bool lazy_load, int file_options) { +static bool rd_sum_fread_case(rd_sum_type *rd_sum, bool include_restart, + bool lazy_load, int file_options) { char *header_file; stringlist_type *summary_file_list = stringlist_alloc_new(); bool caseOK = false; - ecl_util_alloc_summary_files(ecl_sum->path, ecl_sum->base, ecl_sum->ext, - &header_file, summary_file_list); + rd_alloc_summary_files(rd_sum->path, rd_sum->base, rd_sum->ext, + &header_file, summary_file_list); if ((header_file != NULL) && (stringlist_get_size(summary_file_list) > 0)) { - caseOK = ecl_sum_fread(ecl_sum, header_file, summary_file_list, - include_restart, lazy_load, file_options); + caseOK = rd_sum_fread(rd_sum, header_file, summary_file_list, + include_restart, lazy_load, file_options); } free(header_file); stringlist_free(summary_file_list); @@ -243,181 +241,180 @@ static bool ecl_sum_fread_case(ecl_sum_type *ecl_sum, bool include_restart, This will explicitly load the summary specified by @header_file and @data_files, i.e. if the case has been restarted from another case, it will NOT look for old summary information - that functionality - is only invoked when using ecl_sum_fread_alloc_case() function; + is only invoked when using rd_sum_fread_alloc_case() function; however the list of data_files could in principle be achieved by initializing the data_files list with files from the restarted case. */ -ecl_sum_type *ecl_sum_fread_alloc(const char *header_file, - const stringlist_type *data_files, - const char *key_join_string, - bool include_restart, bool lazy_load, - int file_options) { - ecl_sum_type *ecl_sum = ecl_sum_alloc__(header_file, key_join_string); - if (ecl_sum) { - if (!ecl_sum_fread(ecl_sum, header_file, data_files, include_restart, - lazy_load, file_options)) { - ecl_sum_free(ecl_sum); - ecl_sum = NULL; +rd_sum_type *rd_sum_fread_alloc(const char *header_file, + const stringlist_type *data_files, + const char *key_join_string, + bool include_restart, bool lazy_load, + int file_options) { + rd_sum_type *rd_sum = rd_sum_alloc__(header_file, key_join_string); + if (rd_sum) { + if (!rd_sum_fread(rd_sum, header_file, data_files, include_restart, + lazy_load, file_options)) { + rd_sum_free(rd_sum); + rd_sum = NULL; } } - return ecl_sum; + return rd_sum; } -void ecl_sum_set_unified(ecl_sum_type *ecl_sum, bool unified) { - ecl_sum->unified = unified; +void rd_sum_set_unified(rd_sum_type *rd_sum, bool unified) { + rd_sum->unified = unified; } -void ecl_sum_set_fmt_case(ecl_sum_type *ecl_sum, bool fmt_case) { - ecl_sum->fmt_case = fmt_case; +void rd_sum_set_fmt_case(rd_sum_type *rd_sum, bool fmt_case) { + rd_sum->fmt_case = fmt_case; } -const ecl::smspec_node *ecl_sum_add_var(ecl_sum_type *ecl_sum, - const char *keyword, const char *wgname, - int num, const char *unit, - float default_value) { - if (ecl_sum_data_get_length(ecl_sum->data) > 0) +const rd::smspec_node *rd_sum_add_var(rd_sum_type *rd_sum, const char *keyword, + const char *wgname, int num, + const char *unit, float default_value) { + if (rd_sum_data_get_length(rd_sum->data) > 0) throw std::invalid_argument( "Can not interchange variable adding and timesteps.\n"); - return ecl_smspec_add_node(ecl_sum->smspec, keyword, wgname, num, unit, - default_value); + return rd_smspec_add_node(rd_sum->smspec, keyword, wgname, num, unit, + default_value); } -const ecl::smspec_node *ecl_sum_add_smspec_node(ecl_sum_type *ecl_sum, - const ecl::smspec_node *node) { - return ecl_smspec_add_node(ecl_sum->smspec, *node); +const rd::smspec_node *rd_sum_add_smspec_node(rd_sum_type *rd_sum, + const rd::smspec_node *node) { + return rd_smspec_add_node(rd_sum->smspec, *node); } /* - Observe the time argument in ecl_sum_add_tstep() and the bool flag - time_in_days in ecl_sum_alloc_writer() can be misleading: + Observe the time argument in rd_sum_add_tstep() and the bool flag + time_in_days in rd_sum_alloc_writer() can be misleading: - - The time argument 'sim_seconds' to ecl_sum_add_tstep() should + - The time argument 'sim_seconds' to rd_sum_add_tstep() should *ALWAYS* be in seconds. - - The 'sim_in_days' argument to the ecl_sum_alloc_writer( ) is just + - The 'sim_in_days' argument to the rd_sum_alloc_writer( ) is just a very very basic unit support in the output. If sim_in_days == true the output time unit will be days, otherwise it will be hours. */ -ecl_sum_tstep_type *ecl_sum_add_tstep(ecl_sum_type *ecl_sum, int report_step, - double sim_seconds) { - ecl_sum_tstep_type *new_tstep = - ecl_sum_data_add_new_tstep(ecl_sum->data, report_step, sim_seconds); +rd_sum_tstep_type *rd_sum_add_tstep(rd_sum_type *rd_sum, int report_step, + double sim_seconds) { + rd_sum_tstep_type *new_tstep = + rd_sum_data_add_new_tstep(rd_sum->data, report_step, sim_seconds); return new_tstep; } -static ecl_sum_type * -ecl_sum_alloc_writer__(const char *ecl_case, const char *restart_case, - int restart_step, bool fmt_output, bool unified, - const char *key_join_string, time_t sim_start, - bool time_in_days, int nx, int ny, int nz) { +static rd_sum_type * +rd_sum_alloc_writer__(const char *rd_case, const char *restart_case, + int restart_step, bool fmt_output, bool unified, + const char *key_join_string, time_t sim_start, + bool time_in_days, int nx, int ny, int nz) { - ecl_sum_type *ecl_sum = ecl_sum_alloc__(ecl_case, key_join_string); - if (ecl_sum) { - ecl_sum_set_unified(ecl_sum, unified); - ecl_sum_set_fmt_case(ecl_sum, fmt_output); + rd_sum_type *rd_sum = rd_sum_alloc__(rd_case, key_join_string); + if (rd_sum) { + rd_sum_set_unified(rd_sum, unified); + rd_sum_set_fmt_case(rd_sum, fmt_output); if (restart_case) - ecl_sum->smspec = ecl_smspec_alloc_restart_writer( + rd_sum->smspec = rd_smspec_alloc_restart_writer( key_join_string, restart_case, restart_step, sim_start, time_in_days, nx, ny, nz); else - ecl_sum->smspec = ecl_smspec_alloc_writer( - key_join_string, sim_start, time_in_days, nx, ny, nz); + rd_sum->smspec = rd_smspec_alloc_writer(key_join_string, sim_start, + time_in_days, nx, ny, nz); - ecl_sum->data = ecl_sum_data_alloc_writer(ecl_sum->smspec); + rd_sum->data = rd_sum_data_alloc_writer(rd_sum->smspec); } - return ecl_sum; + return rd_sum; } -ecl_sum_type * -ecl_sum_alloc_restart_writer2(const char *ecl_case, const char *restart_case, - int restart_step, bool fmt_output, bool unified, - const char *key_join_string, time_t sim_start, - bool time_in_days, int nx, int ny, int nz) { - return ecl_sum_alloc_writer__(ecl_case, restart_case, restart_step, - fmt_output, unified, key_join_string, - sim_start, time_in_days, nx, ny, nz); +rd_sum_type * +rd_sum_alloc_restart_writer2(const char *rd_case, const char *restart_case, + int restart_step, bool fmt_output, bool unified, + const char *key_join_string, time_t sim_start, + bool time_in_days, int nx, int ny, int nz) { + return rd_sum_alloc_writer__(rd_case, restart_case, restart_step, + fmt_output, unified, key_join_string, + sim_start, time_in_days, nx, ny, nz); } /* This does not take in the restart_step argument is depcrecated. You should use the - ecl_sum_alloc_restart_writer2() function. + rd_sum_alloc_restart_writer2() function. */ -ecl_sum_type *ecl_sum_alloc_restart_writer(const char *ecl_case, - const char *restart_case, - bool fmt_output, bool unified, - const char *key_join_string, - time_t sim_start, bool time_in_days, - int nx, int ny, int nz) { +rd_sum_type *rd_sum_alloc_restart_writer(const char *rd_case, + const char *restart_case, + bool fmt_output, bool unified, + const char *key_join_string, + time_t sim_start, bool time_in_days, + int nx, int ny, int nz) { int restart_step = 0; - return ecl_sum_alloc_writer__(ecl_case, restart_case, restart_step, - fmt_output, unified, key_join_string, - sim_start, time_in_days, nx, ny, nz); + return rd_sum_alloc_writer__(rd_case, restart_case, restart_step, + fmt_output, unified, key_join_string, + sim_start, time_in_days, nx, ny, nz); } -ecl_sum_type *ecl_sum_alloc_writer(const char *ecl_case, bool fmt_output, - bool unified, const char *key_join_string, - time_t sim_start, bool time_in_days, int nx, - int ny, int nz) { - return ecl_sum_alloc_writer__(ecl_case, NULL, 0, fmt_output, unified, - key_join_string, sim_start, time_in_days, nx, - ny, nz); +rd_sum_type *rd_sum_alloc_writer(const char *rd_case, bool fmt_output, + bool unified, const char *key_join_string, + time_t sim_start, bool time_in_days, int nx, + int ny, int nz) { + return rd_sum_alloc_writer__(rd_case, NULL, 0, fmt_output, unified, + key_join_string, sim_start, time_in_days, nx, + ny, nz); } -void ecl_sum_fwrite(const ecl_sum_type *ecl_sum) { - ecl_sum_fwrite_smspec(ecl_sum); - ecl_sum_data_fwrite(ecl_sum->data, ecl_sum->ecl_case, ecl_sum->fmt_case, - ecl_sum->unified); +void rd_sum_fwrite(const rd_sum_type *rd_sum) { + rd_sum_fwrite_smspec(rd_sum); + rd_sum_data_fwrite(rd_sum->data, rd_sum->rd_case, rd_sum->fmt_case, + rd_sum->unified); } -bool ecl_sum_can_write(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_can_write(ecl_sum->data); +bool rd_sum_can_write(const rd_sum_type *rd_sum) { + return rd_sum_data_can_write(rd_sum->data); } -void ecl_sum_fwrite_smspec(const ecl_sum_type *ecl_sum) { - ecl_smspec_fwrite(ecl_sum->smspec, ecl_sum->ecl_case, ecl_sum->fmt_case); +void rd_sum_fwrite_smspec(const rd_sum_type *rd_sum) { + rd_smspec_fwrite(rd_sum->smspec, rd_sum->rd_case, rd_sum->fmt_case); } /** - This function frees the data from the ecl_sum instance and sets the + This function frees the data from the rd_sum instance and sets the data pointer to NULL. The SMSPEC data is still valid, and can be - reused with calls to ecl_sum_fread_realloc_data(). + reused with calls to rd_sum_fread_realloc_data(). */ -void ecl_sum_free_data(ecl_sum_type *ecl_sum) { - ecl_sum_data_free(ecl_sum->data); - ecl_sum->data = NULL; +void rd_sum_free_data(rd_sum_type *rd_sum) { + rd_sum_data_free(rd_sum->data); + rd_sum->data = NULL; } -void ecl_sum_free(ecl_sum_type *ecl_sum) { - if (ecl_sum->restart_case) - ecl_sum_free(ecl_sum->restart_case); +void rd_sum_free(rd_sum_type *rd_sum) { + if (rd_sum->restart_case) + rd_sum_free(rd_sum->restart_case); - if (ecl_sum->data) - ecl_sum_free_data(ecl_sum); + if (rd_sum->data) + rd_sum_free_data(rd_sum); - if (ecl_sum->smspec) - ecl_smspec_free(ecl_sum->smspec); + if (rd_sum->smspec) + rd_smspec_free(rd_sum->smspec); - free(ecl_sum->path); - free(ecl_sum->ext); - free(ecl_sum->abs_path); + free(rd_sum->path); + free(rd_sum->ext); + free(rd_sum->abs_path); - free(ecl_sum->base); - free(ecl_sum->ecl_case); + free(rd_sum->base); + free(rd_sum->rd_case); - free(ecl_sum->key_join_string); - free(ecl_sum); + free(rd_sum->key_join_string); + free(rd_sum); } -void ecl_sum_free__(void *__ecl_sum) { - ecl_sum_type *ecl_sum = ecl_sum_safe_cast(__ecl_sum); - ecl_sum_free(ecl_sum); +void rd_sum_free__(void *__rd_sum) { + rd_sum_type *rd_sum = rd_sum_safe_cast(__rd_sum); + rd_sum_free(rd_sum); } /** @@ -439,45 +436,45 @@ void ecl_sum_free__(void *__ecl_sum) { (this is goverened by the local variable include_restart). */ -ecl_sum_type *ecl_sum_fread_alloc_case2__(const char *input_file, - const char *key_join_string, - bool include_restart, bool lazy_load, - int file_options) { - ecl_sum_type *ecl_sum = ecl_sum_alloc__(input_file, key_join_string); - if (!ecl_sum) +rd_sum_type *rd_sum_fread_alloc_case2__(const char *input_file, + const char *key_join_string, + bool include_restart, bool lazy_load, + int file_options) { + rd_sum_type *rd_sum = rd_sum_alloc__(input_file, key_join_string); + if (!rd_sum) return NULL; - if (ecl_sum_fread_case(ecl_sum, include_restart, lazy_load, file_options)) - return ecl_sum; + if (rd_sum_fread_case(rd_sum, include_restart, lazy_load, file_options)) + return rd_sum; else { /* Loading a case failed - we discard the partly initialized - ecl_sum structure and jump ship. + rd_sum structure and jump ship. */ - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); return NULL; } } -ecl_sum_type *ecl_sum_fread_alloc_case__(const char *input_file, - const char *key_join_string, - bool include_restart) { +rd_sum_type *rd_sum_fread_alloc_case__(const char *input_file, + const char *key_join_string, + bool include_restart) { bool lazy_load = true; int file_options = 0; - return ecl_sum_fread_alloc_case2__( - input_file, key_join_string, include_restart, lazy_load, file_options); + return rd_sum_fread_alloc_case2__(input_file, key_join_string, + include_restart, lazy_load, file_options); } -ecl_sum_type *ecl_sum_fread_alloc_case(const char *input_file, - const char *key_join_string) { +rd_sum_type *rd_sum_fread_alloc_case(const char *input_file, + const char *key_join_string) { bool include_restart = true; bool lazy_load = true; int file_options = 0; - return ecl_sum_fread_alloc_case2__( - input_file, key_join_string, include_restart, lazy_load, file_options); + return rd_sum_fread_alloc_case2__(input_file, key_join_string, + include_restart, lazy_load, file_options); } -bool ecl_sum_case_exists(const char *input_file) { +bool rd_sum_case_exists(const char *input_file) { char *smspec_file = NULL; stringlist_type *data_files = stringlist_alloc_new(); char *path; @@ -486,8 +483,8 @@ bool ecl_sum_case_exists(const char *input_file) { bool case_exists; util_alloc_file_components(input_file, &path, &basename, &extension); - case_exists = ecl_util_alloc_summary_files(path, basename, extension, - &smspec_file, data_files); + case_exists = rd_alloc_summary_files(path, basename, extension, + &smspec_file, data_files); free(path); free(basename); @@ -498,293 +495,288 @@ bool ecl_sum_case_exists(const char *input_file) { return case_exists; } -double ecl_sum_get_from_sim_time(const ecl_sum_type *ecl_sum, time_t sim_time, - const ecl::smspec_node *node) { - return ecl_sum_data_get_from_sim_time(ecl_sum->data, sim_time, *node); +double rd_sum_get_from_sim_time(const rd_sum_type *rd_sum, time_t sim_time, + const rd::smspec_node *node) { + return rd_sum_data_get_from_sim_time(rd_sum->data, sim_time, *node); } -double ecl_sum_get_from_sim_days(const ecl_sum_type *ecl_sum, double sim_days, - const ecl::smspec_node *node) { - return ecl_sum_data_get_from_sim_days(ecl_sum->data, sim_days, *node); +double rd_sum_get_from_sim_days(const rd_sum_type *rd_sum, double sim_days, + const rd::smspec_node *node) { + return rd_sum_data_get_from_sim_days(rd_sum->data, sim_days, *node); } -double ecl_sum_time2days(const ecl_sum_type *ecl_sum, time_t sim_time) { - return ecl_sum_data_time2days(ecl_sum->data, sim_time); +double rd_sum_time2days(const rd_sum_type *rd_sum, time_t sim_time) { + return rd_sum_data_time2days(rd_sum->data, sim_time); } -bool ecl_sum_has_well_var(const ecl_sum_type *ecl_sum, const char *well, - const char *var) { - return ecl_smspec_has_well_var(ecl_sum->smspec, well, var); +bool rd_sum_has_well_var(const rd_sum_type *rd_sum, const char *well, + const char *var) { + return rd_smspec_has_well_var(rd_sum->smspec, well, var); } -double ecl_sum_get_well_var(const ecl_sum_type *ecl_sum, int time_index, - const char *well, const char *var) { +double rd_sum_get_well_var(const rd_sum_type *rd_sum, int time_index, + const char *well, const char *var) { int params_index = - ecl_smspec_get_well_var_params_index(ecl_sum->smspec, well, var); - return ecl_sum_data_iget(ecl_sum->data, time_index, params_index); + rd_smspec_get_well_var_params_index(rd_sum->smspec, well, var); + return rd_sum_data_iget(rd_sum->data, time_index, params_index); } -double ecl_sum_get_well_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *well, - const char *var) { - const ecl::smspec_node &node = - ecl_smspec_get_well_var_node(ecl_sum->smspec, well, var); - return ecl_sum_get_from_sim_time(ecl_sum, sim_time, &node); +double rd_sum_get_well_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *well, + const char *var) { + const rd::smspec_node &node = + rd_smspec_get_well_var_node(rd_sum->smspec, well, var); + return rd_sum_get_from_sim_time(rd_sum, sim_time, &node); } -double ecl_sum_get_well_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *well, - const char *var) { - const ecl::smspec_node &node = - ecl_smspec_get_well_var_node(ecl_sum->smspec, well, var); - return ecl_sum_get_from_sim_days(ecl_sum, sim_days, &node); +double rd_sum_get_well_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *well, + const char *var) { + const rd::smspec_node &node = + rd_smspec_get_well_var_node(rd_sum->smspec, well, var); + return rd_sum_get_from_sim_days(rd_sum, sim_days, &node); } -bool ecl_sum_has_group_var(const ecl_sum_type *ecl_sum, const char *group, - const char *var) { - return ecl_smspec_has_group_var(ecl_sum->smspec, group, var); +bool rd_sum_has_group_var(const rd_sum_type *rd_sum, const char *group, + const char *var) { + return rd_smspec_has_group_var(rd_sum->smspec, group, var); } -double ecl_sum_get_group_var(const ecl_sum_type *ecl_sum, int time_index, - const char *group, const char *var) { +double rd_sum_get_group_var(const rd_sum_type *rd_sum, int time_index, + const char *group, const char *var) { int params_index = - ecl_smspec_get_group_var_params_index(ecl_sum->smspec, group, var); - return ecl_sum_data_iget(ecl_sum->data, time_index, params_index); + rd_smspec_get_group_var_params_index(rd_sum->smspec, group, var); + return rd_sum_data_iget(rd_sum->data, time_index, params_index); } -double ecl_sum_get_group_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *group, - const char *var) { - const ecl::smspec_node &node = - ecl_smspec_get_group_var_node(ecl_sum->smspec, group, var); - return ecl_sum_get_from_sim_time(ecl_sum, sim_time, &node); +double rd_sum_get_group_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *group, + const char *var) { + const rd::smspec_node &node = + rd_smspec_get_group_var_node(rd_sum->smspec, group, var); + return rd_sum_get_from_sim_time(rd_sum, sim_time, &node); } -double ecl_sum_get_group_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *group, - const char *var) { - const ecl::smspec_node &node = - ecl_smspec_get_group_var_node(ecl_sum->smspec, group, var); - return ecl_sum_get_from_sim_days(ecl_sum, sim_days, &node); +double rd_sum_get_group_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *group, + const char *var) { + const rd::smspec_node &node = + rd_smspec_get_group_var_node(rd_sum->smspec, group, var); + return rd_sum_get_from_sim_days(rd_sum, sim_days, &node); } -bool ecl_sum_has_field_var(const ecl_sum_type *ecl_sum, const char *var) { - return ecl_smspec_has_field_var(ecl_sum->smspec, var); +bool rd_sum_has_field_var(const rd_sum_type *rd_sum, const char *var) { + return rd_smspec_has_field_var(rd_sum->smspec, var); } -double ecl_sum_get_field_var(const ecl_sum_type *ecl_sum, int time_index, - const char *var) { +double rd_sum_get_field_var(const rd_sum_type *rd_sum, int time_index, + const char *var) { int params_index = - ecl_smspec_get_field_var_params_index(ecl_sum->smspec, var); - return ecl_sum_data_iget(ecl_sum->data, time_index, params_index); + rd_smspec_get_field_var_params_index(rd_sum->smspec, var); + return rd_sum_data_iget(rd_sum->data, time_index, params_index); } -double ecl_sum_get_field_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *var) { - const ecl::smspec_node &node = - ecl_smspec_get_field_var_node(ecl_sum->smspec, var); - return ecl_sum_get_from_sim_time(ecl_sum, sim_time, &node); +double rd_sum_get_field_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *var) { + const rd::smspec_node &node = + rd_smspec_get_field_var_node(rd_sum->smspec, var); + return rd_sum_get_from_sim_time(rd_sum, sim_time, &node); } -double ecl_sum_get_field_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *var) { - const ecl::smspec_node &node = - ecl_smspec_get_field_var_node(ecl_sum->smspec, var); - return ecl_sum_get_from_sim_days(ecl_sum, sim_days, &node); +double rd_sum_get_field_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *var) { + const rd::smspec_node &node = + rd_smspec_get_field_var_node(rd_sum->smspec, var); + return rd_sum_get_from_sim_days(rd_sum, sim_days, &node); } -bool ecl_sum_has_block_var(const ecl_sum_type *ecl_sum, const char *block_var, - int block_nr) { - return ecl_smspec_has_block_var(ecl_sum->smspec, block_var, block_nr); +bool rd_sum_has_block_var(const rd_sum_type *rd_sum, const char *block_var, + int block_nr) { + return rd_smspec_has_block_var(rd_sum->smspec, block_var, block_nr); } -double ecl_sum_get_block_var(const ecl_sum_type *ecl_sum, int time_index, - const char *block_var, int block_nr) { - int params_index = ecl_smspec_get_block_var_params_index( - ecl_sum->smspec, block_var, block_nr); - return ecl_sum_data_iget(ecl_sum->data, time_index, params_index); +double rd_sum_get_block_var(const rd_sum_type *rd_sum, int time_index, + const char *block_var, int block_nr) { + int params_index = rd_smspec_get_block_var_params_index( + rd_sum->smspec, block_var, block_nr); + return rd_sum_data_iget(rd_sum->data, time_index, params_index); } -int ecl_sum_get_block_var_index_ijk(const ecl_sum_type *ecl_sum, - const char *block_var, int i, int j, - int k) { - return ecl_smspec_get_block_var_params_index_ijk(ecl_sum->smspec, block_var, - i, j, k); +int rd_sum_get_block_var_index_ijk(const rd_sum_type *rd_sum, + const char *block_var, int i, int j, int k) { + return rd_smspec_get_block_var_params_index_ijk(rd_sum->smspec, block_var, + i, j, k); } -bool ecl_sum_has_block_var_ijk(const ecl_sum_type *ecl_sum, - const char *block_var, int i, int j, int k) { - return ecl_smspec_has_block_var_ijk(ecl_sum->smspec, block_var, i, j, k); +bool rd_sum_has_block_var_ijk(const rd_sum_type *rd_sum, const char *block_var, + int i, int j, int k) { + return rd_smspec_has_block_var_ijk(rd_sum->smspec, block_var, i, j, k); } -double ecl_sum_get_block_var_ijk(const ecl_sum_type *ecl_sum, int time_index, - const char *block_var, int i, int j, int k) { - int index = ecl_sum_get_block_var_index_ijk(ecl_sum, block_var, i, j, k); - return ecl_sum_data_iget(ecl_sum->data, time_index, index); +double rd_sum_get_block_var_ijk(const rd_sum_type *rd_sum, int time_index, + const char *block_var, int i, int j, int k) { + int index = rd_sum_get_block_var_index_ijk(rd_sum, block_var, i, j, k); + return rd_sum_data_iget(rd_sum->data, time_index, index); } -double ecl_sum_get_block_var_ijk_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, - const char *block_var, int i, - int j, int k) { - const ecl::smspec_node &node = - ecl_smspec_get_block_var_node_ijk(ecl_sum->smspec, block_var, i, j, k); - return ecl_sum_get_from_sim_time(ecl_sum, sim_time, &node); +double rd_sum_get_block_var_ijk_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, + const char *block_var, int i, + int j, int k) { + const rd::smspec_node &node = + rd_smspec_get_block_var_node_ijk(rd_sum->smspec, block_var, i, j, k); + return rd_sum_get_from_sim_time(rd_sum, sim_time, &node); } -double ecl_sum_get_block_var_ijk_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, - const char *block_var, int i, - int j, int k) { - const ecl::smspec_node &node = - ecl_smspec_get_block_var_node_ijk(ecl_sum->smspec, block_var, i, j, k); - return ecl_sum_get_from_sim_days(ecl_sum, sim_days, &node); +double rd_sum_get_block_var_ijk_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, + const char *block_var, int i, + int j, int k) { + const rd::smspec_node &node = + rd_smspec_get_block_var_node_ijk(rd_sum->smspec, block_var, i, j, k); + return rd_sum_get_from_sim_days(rd_sum, sim_days, &node); } /** region_nr: [1...num_regions] (NOT C-based indexing) */ -bool ecl_sum_has_region_var(const ecl_sum_type *ecl_sum, const char *var, - int region_nr) { - return ecl_smspec_has_region_var(ecl_sum->smspec, var, region_nr); +bool rd_sum_has_region_var(const rd_sum_type *rd_sum, const char *var, + int region_nr) { + return rd_smspec_has_region_var(rd_sum->smspec, var, region_nr); } -double ecl_sum_get_region_var(const ecl_sum_type *ecl_sum, int time_index, - const char *var, int region_nr) { +double rd_sum_get_region_var(const rd_sum_type *rd_sum, int time_index, + const char *var, int region_nr) { int params_index = - ecl_smspec_get_region_var_params_index(ecl_sum->smspec, var, region_nr); - return ecl_sum_data_iget(ecl_sum->data, time_index, params_index); + rd_smspec_get_region_var_params_index(rd_sum->smspec, var, region_nr); + return rd_sum_data_iget(rd_sum->data, time_index, params_index); } -double ecl_sum_get_region_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *var, - int region_nr) { - const ecl::smspec_node &node = - ecl_smspec_get_region_var_node(ecl_sum->smspec, var, region_nr); - return ecl_sum_get_from_sim_time(ecl_sum, sim_time, &node); +double rd_sum_get_region_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *var, + int region_nr) { + const rd::smspec_node &node = + rd_smspec_get_region_var_node(rd_sum->smspec, var, region_nr); + return rd_sum_get_from_sim_time(rd_sum, sim_time, &node); } -double ecl_sum_get_region_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *var, - int region_nr) { - const ecl::smspec_node &node = - ecl_smspec_get_region_var_node(ecl_sum->smspec, var, region_nr); - return ecl_sum_get_from_sim_days(ecl_sum, sim_days, &node); +double rd_sum_get_region_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *var, + int region_nr) { + const rd::smspec_node &node = + rd_smspec_get_region_var_node(rd_sum->smspec, var, region_nr); + return rd_sum_get_from_sim_days(rd_sum, sim_days, &node); } -int ecl_sum_get_misc_var_index(const ecl_sum_type *ecl_sum, const char *var) { - return ecl_smspec_get_misc_var_params_index(ecl_sum->smspec, var); +int rd_sum_get_misc_var_index(const rd_sum_type *rd_sum, const char *var) { + return rd_smspec_get_misc_var_params_index(rd_sum->smspec, var); } -bool ecl_sum_has_misc_var(const ecl_sum_type *ecl_sum, const char *var) { - return ecl_smspec_has_misc_var(ecl_sum->smspec, var); +bool rd_sum_has_misc_var(const rd_sum_type *rd_sum, const char *var) { + return rd_smspec_has_misc_var(rd_sum->smspec, var); } -double ecl_sum_get_misc_var(const ecl_sum_type *ecl_sum, int time_index, - const char *var) { - int index = ecl_sum_get_misc_var_index(ecl_sum, var); - return ecl_sum_data_iget(ecl_sum->data, time_index, index); +double rd_sum_get_misc_var(const rd_sum_type *rd_sum, int time_index, + const char *var) { + int index = rd_sum_get_misc_var_index(rd_sum, var); + return rd_sum_data_iget(rd_sum->data, time_index, index); } -int ecl_sum_get_well_completion_var_index(const ecl_sum_type *ecl_sum, - const char *well, const char *var, - int cell_nr) { - return ecl_smspec_get_well_completion_var_params_index(ecl_sum->smspec, - well, var, cell_nr); +int rd_sum_get_well_completion_var_index(const rd_sum_type *rd_sum, + const char *well, const char *var, + int cell_nr) { + return rd_smspec_get_well_completion_var_params_index(rd_sum->smspec, well, + var, cell_nr); } -bool ecl_sum_has_well_completion_var(const ecl_sum_type *ecl_sum, - const char *well, const char *var, - int cell_nr) { - return ecl_smspec_has_well_completion_var(ecl_sum->smspec, well, var, - cell_nr); +bool rd_sum_has_well_completion_var(const rd_sum_type *rd_sum, const char *well, + const char *var, int cell_nr) { + return rd_smspec_has_well_completion_var(rd_sum->smspec, well, var, + cell_nr); } -double ecl_sum_get_well_completion_var(const ecl_sum_type *ecl_sum, - int time_index, const char *well, - const char *var, int cell_nr) { +double rd_sum_get_well_completion_var(const rd_sum_type *rd_sum, int time_index, + const char *well, const char *var, + int cell_nr) { int index = - ecl_sum_get_well_completion_var_index(ecl_sum, well, var, cell_nr); - return ecl_sum_data_iget(ecl_sum->data, time_index, index); + rd_sum_get_well_completion_var_index(rd_sum, well, var, cell_nr); + return rd_sum_data_iget(rd_sum->data, time_index, index); } -const ecl::smspec_node * -ecl_sum_get_general_var_node(const ecl_sum_type *ecl_sum, - const char *lookup_kw) { - const ecl::smspec_node &node = - ecl_smspec_get_general_var_node(ecl_sum->smspec, lookup_kw); +const rd::smspec_node *rd_sum_get_general_var_node(const rd_sum_type *rd_sum, + const char *lookup_kw) { + const rd::smspec_node &node = + rd_smspec_get_general_var_node(rd_sum->smspec, lookup_kw); return &node; } -int ecl_sum_get_general_var_params_index(const ecl_sum_type *ecl_sum, - const char *lookup_kw) { - return ecl_smspec_get_general_var_params_index(ecl_sum->smspec, lookup_kw); +int rd_sum_get_general_var_params_index(const rd_sum_type *rd_sum, + const char *lookup_kw) { + return rd_smspec_get_general_var_params_index(rd_sum->smspec, lookup_kw); } -bool ecl_sum_has_general_var(const ecl_sum_type *ecl_sum, - const char *lookup_kw) { - return ecl_smspec_has_general_var(ecl_sum->smspec, lookup_kw); +bool rd_sum_has_general_var(const rd_sum_type *rd_sum, const char *lookup_kw) { + return rd_smspec_has_general_var(rd_sum->smspec, lookup_kw); } -bool ecl_sum_has_key(const ecl_sum_type *ecl_sum, const char *lookup_kw) { - return ecl_sum_has_general_var(ecl_sum, lookup_kw); +bool rd_sum_has_key(const rd_sum_type *rd_sum, const char *lookup_kw) { + return rd_sum_has_general_var(rd_sum, lookup_kw); } -double ecl_sum_get_general_var(const ecl_sum_type *ecl_sum, int time_index, - const char *lookup_kw) { - int params_index = ecl_sum_get_general_var_params_index(ecl_sum, lookup_kw); - return ecl_sum_data_iget(ecl_sum->data, time_index, params_index); +double rd_sum_get_general_var(const rd_sum_type *rd_sum, int time_index, + const char *lookup_kw) { + int params_index = rd_sum_get_general_var_params_index(rd_sum, lookup_kw); + return rd_sum_data_iget(rd_sum->data, time_index, params_index); } #ifdef __cplusplus extern "C" { -void ecl_sum_get_interp_vector(const ecl_sum_type *ecl_sum, time_t sim_time, - const ecl_sum_vector_type *key_words, - double_vector_type *data) { - ecl_sum_data_get_interp_vector(ecl_sum->data, sim_time, key_words, data); +void rd_sum_get_interp_vector(const rd_sum_type *rd_sum, time_t sim_time, + const rd_sum_vector_type *key_words, + double_vector_type *data) { + rd_sum_data_get_interp_vector(rd_sum->data, sim_time, key_words, data); } -void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type *ecl_sum, - time_t sim_time, - const ecl_sum_vector_type *key_words, - FILE *fp) { - ecl_sum_data_fwrite_interp_csv_line(ecl_sum->data, sim_time, key_words, fp); +void rd_sum_fwrite_interp_csv_line(const rd_sum_type *rd_sum, time_t sim_time, + const rd_sum_vector_type *key_words, + FILE *fp) { + rd_sum_data_fwrite_interp_csv_line(rd_sum->data, sim_time, key_words, fp); } } #endif -double ecl_sum_get_general_var_from_sim_time(const ecl_sum_type *ecl_sum, - time_t sim_time, const char *var) { - const ecl::smspec_node *node = ecl_sum_get_general_var_node(ecl_sum, var); - return ecl_sum_get_from_sim_time(ecl_sum, sim_time, node); +double rd_sum_get_general_var_from_sim_time(const rd_sum_type *rd_sum, + time_t sim_time, const char *var) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, var); + return rd_sum_get_from_sim_time(rd_sum, sim_time, node); } -double ecl_sum_get_general_var_from_sim_days(const ecl_sum_type *ecl_sum, - double sim_days, const char *var) { - const ecl::smspec_node *node = ecl_sum_get_general_var_node(ecl_sum, var); - return ecl_sum_data_get_from_sim_days(ecl_sum->data, sim_days, *node); +double rd_sum_get_general_var_from_sim_days(const rd_sum_type *rd_sum, + double sim_days, const char *var) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, var); + return rd_sum_data_get_from_sim_days(rd_sum->data, sim_days, *node); } -const char *ecl_sum_get_general_var_unit(const ecl_sum_type *ecl_sum, - const char *var) { - const ecl::smspec_node *node = ecl_sum_get_general_var_node(ecl_sum, var); +const char *rd_sum_get_general_var_unit(const rd_sum_type *rd_sum, + const char *var) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, var); return smspec_node_get_unit(node); } -ecl_sum_type *ecl_sum_alloc_resample(const ecl_sum_type *ecl_sum, - const char *ecl_case, - const time_t_vector_type *times, - bool lower_extrapolation, - bool upper_extrapolation) { +rd_sum_type *rd_sum_alloc_resample(const rd_sum_type *rd_sum, + const char *rd_case, + const time_t_vector_type *times, + bool lower_extrapolation, + bool upper_extrapolation) { /* If lower and / or upper extrapolation is set to true it makes sure that resampling returns the first / last value of the simulation or in the case of derivate / rate then it gets zero. if these are set to false, we jus throw exception */ - time_t start_time = ecl_sum_get_data_start(ecl_sum); - time_t end_time = ecl_sum_get_end_time(ecl_sum); + time_t start_time = rd_sum_get_data_start(rd_sum); + time_t end_time = rd_sum_get_end_time(rd_sum); time_t input_start = time_t_vector_get_first(times); time_t input_end = time_t_vector_get_last(times); @@ -795,27 +787,27 @@ ecl_sum_type *ecl_sum_alloc_resample(const ecl_sum_type *ecl_sum, if (!time_t_vector_is_sorted(times, false)) return NULL; - const int *grid_dims = ecl_smspec_get_grid_dims(ecl_sum->smspec); + const int *grid_dims = rd_smspec_get_grid_dims(rd_sum->smspec); bool time_in_days = false; - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, 0); + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(rd_sum->smspec, 0); if (util_string_equal(smspec_node_get_unit(&node), "DAYS")) time_in_days = true; //create elc_sum_resampled with TIME node only - ecl_sum_type *ecl_sum_resampled = ecl_sum_alloc_writer( - ecl_case, ecl_sum->fmt_case, ecl_sum->unified, ecl_sum->key_join_string, + rd_sum_type *rd_sum_resampled = rd_sum_alloc_writer( + rd_case, rd_sum->fmt_case, rd_sum->unified, rd_sum->key_join_string, input_start, time_in_days, grid_dims[0], grid_dims[1], grid_dims[2]); //add remaining nodes - for (int i = 0; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) { - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i); + for (int i = 0; i < rd_smspec_num_nodes(rd_sum->smspec); i++) { + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(rd_sum->smspec, i); if (util_string_equal(smspec_node_get_gen_key1(&node), "TIME")) continue; - ecl_sum_add_smspec_node(ecl_sum_resampled, &node); + rd_sum_add_smspec_node(rd_sum_resampled, &node); } /* @@ -823,186 +815,173 @@ ecl_sum_type *ecl_sum_alloc_resample(const ecl_sum_type *ecl_sum, start filling it up with data. */ - ecl_sum_vector_type *ecl_sum_vector = ecl_sum_vector_alloc(ecl_sum, true); + rd_sum_vector_type *rd_sum_vector = rd_sum_vector_alloc(rd_sum, true); double_vector_type *data = - double_vector_alloc(ecl_sum_vector_get_size(ecl_sum_vector), 0); + double_vector_alloc(rd_sum_vector_get_size(rd_sum_vector), 0); for (int report_step = 0; report_step < time_t_vector_size(times); report_step++) { time_t input_t = time_t_vector_iget(times, report_step); if (input_t < start_time) { //clamping to the first value for t < start_time or if it is a rate than derivative is 0 - for (int i = 1; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) { + for (int i = 1; i < rd_smspec_num_nodes(rd_sum->smspec); i++) { double value = 0; - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i); + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(rd_sum->smspec, i); if (!node.is_rate()) - value = ecl_sum_iget_first_value(ecl_sum, - node.get_params_index()); + value = rd_sum_iget_first_value(rd_sum, + node.get_params_index()); double_vector_iset(data, i - 1, value); } } else if (input_t > end_time) { //clamping to the last value for t > end_time or if it is a rate than derivative is 0 - for (int i = 1; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) { + for (int i = 1; i < rd_smspec_num_nodes(rd_sum->smspec); i++) { double value = 0; - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i); + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(rd_sum->smspec, i); if (!node.is_rate()) - value = ecl_sum_iget_last_value(ecl_sum, - node.get_params_index()); + value = + rd_sum_iget_last_value(rd_sum, node.get_params_index()); double_vector_iset(data, i - 1, value); } } else { /* Look up interpolated data in the original case. */ - ecl_sum_get_interp_vector(ecl_sum, input_t, ecl_sum_vector, data); + rd_sum_get_interp_vector(rd_sum, input_t, rd_sum_vector, data); } /* Add timestep corresponding to the interpolated data in the resampled case. */ - ecl_sum_tstep_type *tstep = ecl_sum_add_tstep( - ecl_sum_resampled, report_step, input_t - input_start); + rd_sum_tstep_type *tstep = rd_sum_add_tstep( + rd_sum_resampled, report_step, input_t - input_start); for (int data_index = 0; - data_index < ecl_sum_vector_get_size(ecl_sum_vector); - data_index++) { + data_index < rd_sum_vector_get_size(rd_sum_vector); data_index++) { double value = double_vector_iget(data, data_index); int params_index = data_index + 1; // The +1 shift is because the first element in the tstep is time value. - ecl_sum_tstep_iset(tstep, params_index, value); + rd_sum_tstep_iset(tstep, params_index, value); } } double_vector_free(data); - ecl_sum_vector_free(ecl_sum_vector); - return ecl_sum_resampled; + rd_sum_vector_free(rd_sum_vector); + return rd_sum_resampled; } -double ecl_sum_iget(const ecl_sum_type *ecl_sum, int time_index, - int param_index) { - return ecl_sum_data_iget(ecl_sum->data, time_index, param_index); +double rd_sum_iget(const rd_sum_type *rd_sum, int time_index, int param_index) { + return rd_sum_data_iget(rd_sum->data, time_index, param_index); } -bool ecl_sum_var_is_rate(const ecl_sum_type *ecl_sum, const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +bool rd_sum_var_is_rate(const rd_sum_type *rd_sum, const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_is_rate(node); } -bool ecl_sum_var_is_total(const ecl_sum_type *ecl_sum, const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +bool rd_sum_var_is_total(const rd_sum_type *rd_sum, const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_is_total(node); } -ecl_smspec_var_type ecl_sum_identify_var_type(const char *var) { - return ecl_smspec_identify_var_type(var); +rd_smspec_var_type rd_sum_identify_var_type(const char *var) { + return rd_smspec_identify_var_type(var); } -ecl_smspec_var_type ecl_sum_get_var_type(const ecl_sum_type *ecl_sum, - const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +rd_smspec_var_type rd_sum_get_var_type(const rd_sum_type *rd_sum, + const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_get_var_type(node); } -const char *ecl_sum_get_unit(const ecl_sum_type *ecl_sum, const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +const char *rd_sum_get_unit(const rd_sum_type *rd_sum, const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_get_unit(node); } -int ecl_sum_get_num(const ecl_sum_type *ecl_sum, const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +int rd_sum_get_num(const rd_sum_type *rd_sum, const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_get_num(node); } -const char *ecl_sum_get_wgname(const ecl_sum_type *ecl_sum, - const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +const char *rd_sum_get_wgname(const rd_sum_type *rd_sum, const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_get_wgname(node); } -const char *ecl_sum_get_keyword(const ecl_sum_type *ecl_sum, - const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); +const char *rd_sum_get_keyword(const rd_sum_type *rd_sum, const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); return smspec_node_get_keyword(node); } -bool ecl_sum_has_report_step(const ecl_sum_type *ecl_sum, int report_step) { - return ecl_sum_data_has_report_step(ecl_sum->data, report_step); +bool rd_sum_has_report_step(const rd_sum_type *rd_sum, int report_step) { + return rd_sum_data_has_report_step(rd_sum->data, report_step); } -int ecl_sum_get_last_report_step(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_get_last_report_step(ecl_sum->data); +int rd_sum_get_last_report_step(const rd_sum_type *rd_sum) { + return rd_sum_data_get_last_report_step(rd_sum->data); } -int ecl_sum_get_first_report_step(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_get_first_report_step(ecl_sum->data); +int rd_sum_get_first_report_step(const rd_sum_type *rd_sum) { + return rd_sum_data_get_first_report_step(rd_sum->data); } -int ecl_sum_iget_report_end(const ecl_sum_type *ecl_sum, int report_step) { - return ecl_sum_data_iget_report_end(ecl_sum->data, report_step); +int rd_sum_iget_report_end(const rd_sum_type *rd_sum, int report_step) { + return rd_sum_data_iget_report_end(rd_sum->data, report_step); } -int ecl_sum_iget_report_step(const ecl_sum_type *ecl_sum, int internal_index) { - return ecl_sum_data_iget_report_step(ecl_sum->data, internal_index); +int rd_sum_iget_report_step(const rd_sum_type *rd_sum, int internal_index) { + return rd_sum_data_iget_report_step(rd_sum->data, internal_index); } -time_t_vector_type *ecl_sum_alloc_time_vector(const ecl_sum_type *ecl_sum, - bool report_only) { - return ecl_sum_data_alloc_time_vector(ecl_sum->data, report_only); +time_t_vector_type *rd_sum_alloc_time_vector(const rd_sum_type *rd_sum, + bool report_only) { + return rd_sum_data_alloc_time_vector(rd_sum->data, report_only); } -void ecl_sum_init_double_vector__(const ecl_sum_type *ecl_sum, int params_index, - double *data) { - ecl_sum_data_init_double_vector(ecl_sum->data, params_index, data); +void rd_sum_init_double_vector__(const rd_sum_type *rd_sum, int params_index, + double *data) { + rd_sum_data_init_double_vector(rd_sum->data, params_index, data); } -void ecl_sum_init_double_vector(const ecl_sum_type *ecl_sum, - const char *gen_key, double *data) { - int params_index = ecl_sum_get_general_var_params_index(ecl_sum, gen_key); - ecl_sum_init_double_vector__(ecl_sum, params_index, data); +void rd_sum_init_double_vector(const rd_sum_type *rd_sum, const char *gen_key, + double *data) { + int params_index = rd_sum_get_general_var_params_index(rd_sum, gen_key); + rd_sum_init_double_vector__(rd_sum, params_index, data); } -void ecl_sum_init_double_vector_interp(const ecl_sum_type *ecl_sum, - const char *gen_key, - const time_t_vector_type *time_points, - double *data) { - const ecl::smspec_node &node = - ecl_smspec_get_general_var_node(ecl_sum->smspec, gen_key); - ecl_sum_data_init_double_vector_interp(ecl_sum->data, node, time_points, - data); +void rd_sum_init_double_vector_interp(const rd_sum_type *rd_sum, + const char *gen_key, + const time_t_vector_type *time_points, + double *data) { + const rd::smspec_node &node = + rd_smspec_get_general_var_node(rd_sum->smspec, gen_key); + rd_sum_data_init_double_vector_interp(rd_sum->data, node, time_points, + data); } -void ecl_sum_init_datetime64_vector(const ecl_sum_type *ecl_sum, int64_t *data, - int multiplier) { - ecl_sum_data_init_datetime64_vector(ecl_sum->data, data, multiplier); +void rd_sum_init_datetime64_vector(const rd_sum_type *rd_sum, int64_t *data, + int multiplier) { + rd_sum_data_init_datetime64_vector(rd_sum->data, data, multiplier); } -void ecl_sum_init_double_frame(const ecl_sum_type *ecl_sum, - const ecl_sum_vector_type *keywords, - double *data) { - ecl_sum_data_init_double_frame(ecl_sum->data, keywords, data); +void rd_sum_init_double_frame(const rd_sum_type *rd_sum, + const rd_sum_vector_type *keywords, + double *data) { + rd_sum_data_init_double_frame(rd_sum->data, keywords, data); } -void ecl_sum_init_double_frame_interp(const ecl_sum_type *ecl_sum, - const ecl_sum_vector_type *keywords, - const time_t_vector_type *time_points, - double *data) { - ecl_sum_data_init_double_frame_interp(ecl_sum->data, keywords, time_points, - data); +void rd_sum_init_double_frame_interp(const rd_sum_type *rd_sum, + const rd_sum_vector_type *keywords, + const time_t_vector_type *time_points, + double *data) { + rd_sum_data_init_double_frame_interp(rd_sum->data, keywords, time_points, + data); } -double_vector_type *ecl_sum_alloc_data_vector(const ecl_sum_type *ecl_sum, - int data_index, - bool report_only) { - return ecl_sum_data_alloc_data_vector(ecl_sum->data, data_index, - report_only); +double_vector_type *rd_sum_alloc_data_vector(const rd_sum_type *rd_sum, + int data_index, bool report_only) { + return rd_sum_data_alloc_data_vector(rd_sum->data, data_index, report_only); } -void ecl_sum_summarize(const ecl_sum_type *ecl_sum, FILE *stream) { - ecl_sum_data_summarize(ecl_sum->data, stream); +void rd_sum_summarize(const rd_sum_type *rd_sum, FILE *stream) { + rd_sum_data_summarize(rd_sum->data, stream); } /** @@ -1011,25 +990,25 @@ void ecl_sum_summarize(const ecl_sum_type *ecl_sum, FILE *stream) { returned. The smspec_index should be calculated first with one of the - ecl_sum_get_XXXX_index() + rd_sum_get_XXXX_index() functions. I.e. the following code will give the first index where the water wut in well PX exceeds 0.25: { - int smspec_index = ecl_sum_get_well_var( ecl_sum , "PX" , "WWCT" ); - int first_index = ecl_sum_get_first_gt( ecl_sum , smspec_index , 0.25); + int smspec_index = rd_sum_get_well_var( rd_sum , "PX" , "WWCT" ); + int first_index = rd_sum_get_first_gt( rd_sum , smspec_index , 0.25); } */ -static int ecl_sum_get_limiting(const ecl_sum_type *ecl_sum, int smspec_index, - double limit, bool gt) { - const int length = ecl_sum_data_get_length(ecl_sum->data); +static int rd_sum_get_limiting(const rd_sum_type *rd_sum, int smspec_index, + double limit, bool gt) { + const int length = rd_sum_data_get_length(rd_sum->data); int internal_index = 0; do { double value = - ecl_sum_data_iget(ecl_sum->data, internal_index, smspec_index); + rd_sum_data_iget(rd_sum->data, internal_index, smspec_index); if (gt) { if (value > limit) break; @@ -1046,52 +1025,52 @@ static int ecl_sum_get_limiting(const ecl_sum_type *ecl_sum, int smspec_index, return internal_index; } -int ecl_sum_get_first_gt(const ecl_sum_type *ecl_sum, int param_index, - double limit) { - return ecl_sum_get_limiting(ecl_sum, param_index, limit, true); +int rd_sum_get_first_gt(const rd_sum_type *rd_sum, int param_index, + double limit) { + return rd_sum_get_limiting(rd_sum, param_index, limit, true); } -int ecl_sum_get_first_lt(const ecl_sum_type *ecl_sum, int param_index, - double limit) { - return ecl_sum_get_limiting(ecl_sum, param_index, limit, false); +int rd_sum_get_first_lt(const rd_sum_type *rd_sum, int param_index, + double limit) { + return rd_sum_get_limiting(rd_sum, param_index, limit, false); } -time_t ecl_sum_get_report_time(const ecl_sum_type *ecl_sum, int report_step) { - return ecl_sum_data_get_report_time(ecl_sum->data, report_step); +time_t rd_sum_get_report_time(const rd_sum_type *rd_sum, int report_step) { + return rd_sum_data_get_report_time(rd_sum->data, report_step); } -time_t ecl_sum_iget_sim_time(const ecl_sum_type *ecl_sum, int index) { - return ecl_sum_data_iget_sim_time(ecl_sum->data, index); +time_t rd_sum_iget_sim_time(const rd_sum_type *rd_sum, int index) { + return rd_sum_data_iget_sim_time(rd_sum->data, index); } -time_t ecl_sum_get_data_start(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_get_data_start(ecl_sum->data); +time_t rd_sum_get_data_start(const rd_sum_type *rd_sum) { + return rd_sum_data_get_data_start(rd_sum->data); } -time_t ecl_sum_get_start_time(const ecl_sum_type *ecl_sum) { - return ecl_smspec_get_start_time(ecl_sum->smspec); +time_t rd_sum_get_start_time(const rd_sum_type *rd_sum) { + return rd_smspec_get_start_time(rd_sum->smspec); } -time_t ecl_sum_get_end_time(const ecl_sum_type *ecl_sum) { +time_t rd_sum_get_end_time(const rd_sum_type *rd_sum) { try { - return ecl_sum_data_get_sim_end(ecl_sum->data); + return rd_sum_data_get_sim_end(rd_sum->data); } catch (std::out_of_range) { - return ecl_smspec_get_start_time(ecl_sum->smspec); + return rd_smspec_get_start_time(rd_sum->smspec); } } -double ecl_sum_iget_sim_days(const ecl_sum_type *ecl_sum, int index) { - return ecl_sum_data_iget_sim_days(ecl_sum->data, index); +double rd_sum_iget_sim_days(const rd_sum_type *rd_sum, int index) { + return rd_sum_data_iget_sim_days(rd_sum->data, index); } -void ecl_sum_fmt_init_summary_x(const ecl_sum_type *ecl_sum, - ecl_sum_fmt_type *fmt) { +void rd_sum_fmt_init_summary_x(const rd_sum_type *rd_sum, + rd_sum_fmt_type *fmt) { fmt->locale = NULL; fmt->sep = ""; fmt->date_fmt = "%d/%m/%Y "; fmt->value_fmt = " %15.6g "; - if (util_string_equal(ecl_sum_get_unit(ecl_sum, "TIME"), "DAYS")) + if (util_string_equal(rd_sum_get_unit(rd_sum, "TIME"), "DAYS")) fmt->days_fmt = "%7.2f "; else fmt->days_fmt = "%7.4f "; @@ -1116,19 +1095,19 @@ void ecl_sum_fmt_init_summary_x(const ecl_sum_type *ecl_sum, #define DATE_HEADER "-- Days dd/mm/yyyy " #define DATE_STRING_LENGTH 128 -static void __ecl_sum_fprintf_line(const ecl_sum_type *ecl_sum, FILE *stream, - int internal_index, - const bool_vector_type *has_var, - const int_vector_type *var_index, - char *date_string, - const ecl_sum_fmt_type *fmt) { +static void __rd_sum_fprintf_line(const rd_sum_type *rd_sum, FILE *stream, + int internal_index, + const bool_vector_type *has_var, + const int_vector_type *var_index, + char *date_string, + const rd_sum_fmt_type *fmt) { fprintf(stream, fmt->days_fmt, - ecl_sum_iget_sim_days(ecl_sum, internal_index)); + rd_sum_iget_sim_days(rd_sum, internal_index)); fprintf(stream, "%s", fmt->sep); { struct tm ts; - time_t sim_time = ecl_sum_iget_sim_time(ecl_sum, internal_index); + time_t sim_time = rd_sum_iget_sim_time(rd_sum, internal_index); util_time_utc(&sim_time, &ts); strftime(date_string, DATE_STRING_LENGTH - 1, fmt->date_fmt, &ts); fprintf(stream, "%s", date_string); @@ -1140,8 +1119,8 @@ static void __ecl_sum_fprintf_line(const ecl_sum_type *ecl_sum, FILE *stream, if (bool_vector_iget(has_var, ivar)) { fprintf(stream, "%s", fmt->sep); fprintf(stream, fmt->value_fmt, - ecl_sum_iget(ecl_sum, internal_index, - int_vector_iget(var_index, ivar))); + rd_sum_iget(rd_sum, internal_index, + int_vector_iget(var_index, ivar))); } } } @@ -1149,10 +1128,10 @@ static void __ecl_sum_fprintf_line(const ecl_sum_type *ecl_sum, FILE *stream, fprintf(stream, "%s", fmt->newline); } -static void ecl_sum_fprintf_header(const ecl_sum_type *ecl_sum, - const stringlist_type *key_list, - const bool_vector_type *has_var, - FILE *stream, const ecl_sum_fmt_type *fmt) { +static void rd_sum_fprintf_header(const rd_sum_type *rd_sum, + const stringlist_type *key_list, + const bool_vector_type *has_var, FILE *stream, + const rd_sum_fmt_type *fmt) { fprintf(stream, "%s", fmt->date_header); { int i; @@ -1177,9 +1156,9 @@ static void ecl_sum_fprintf_header(const ecl_sum_type *ecl_sum, } } -void ecl_sum_fprintf(const ecl_sum_type *ecl_sum, FILE *stream, - const stringlist_type *var_list, bool report_only, - const ecl_sum_fmt_type *fmt) { +void rd_sum_fprintf(const rd_sum_type *rd_sum, FILE *stream, + const stringlist_type *var_list, bool report_only, + const rd_sum_fmt_type *fmt) { bool_vector_type *has_var = bool_vector_alloc(stringlist_get_size(var_list), false); int_vector_type *var_index = @@ -1194,12 +1173,12 @@ void ecl_sum_fprintf(const ecl_sum_type *ecl_sum, FILE *stream, { int ivar; for (ivar = 0; ivar < stringlist_get_size(var_list); ivar++) { - if (ecl_sum_has_general_var(ecl_sum, - stringlist_iget(var_list, ivar))) { + if (rd_sum_has_general_var(rd_sum, + stringlist_iget(var_list, ivar))) { bool_vector_iset(has_var, ivar, true); int_vector_iset(var_index, ivar, - ecl_sum_get_general_var_params_index( - ecl_sum, stringlist_iget(var_list, ivar))); + rd_sum_get_general_var_params_index( + rd_sum, stringlist_iget(var_list, ivar))); } else { fprintf(stderr, "** Warning: could not find variable: \'%s\' in " @@ -1211,28 +1190,27 @@ void ecl_sum_fprintf(const ecl_sum_type *ecl_sum, FILE *stream, } if (fmt->print_header) - ecl_sum_fprintf_header(ecl_sum, var_list, has_var, stream, fmt); + rd_sum_fprintf_header(rd_sum, var_list, has_var, stream, fmt); if (report_only) { - int first_report = ecl_sum_get_first_report_step(ecl_sum); - int last_report = ecl_sum_get_last_report_step(ecl_sum); + int first_report = rd_sum_get_first_report_step(rd_sum); + int last_report = rd_sum_get_last_report_step(rd_sum); int report; for (report = first_report; report <= last_report; report++) { - if (ecl_sum_data_has_report_step(ecl_sum->data, report)) { + if (rd_sum_data_has_report_step(rd_sum->data, report)) { int time_index; - time_index = - ecl_sum_data_iget_report_end(ecl_sum->data, report); - __ecl_sum_fprintf_line(ecl_sum, stream, time_index, has_var, - var_index, date_string, fmt); + time_index = rd_sum_data_iget_report_end(rd_sum->data, report); + __rd_sum_fprintf_line(rd_sum, stream, time_index, has_var, + var_index, date_string, fmt); } } } else { int time_index; - for (time_index = 0; time_index < ecl_sum_get_data_length(ecl_sum); + for (time_index = 0; time_index < rd_sum_get_data_length(rd_sum); time_index++) - __ecl_sum_fprintf_line(ecl_sum, stream, time_index, has_var, - var_index, date_string, fmt); + __rd_sum_fprintf_line(rd_sum, stream, time_index, has_var, + var_index, date_string, fmt); } int_vector_free(var_index); @@ -1243,8 +1221,8 @@ void ecl_sum_fprintf(const ecl_sum_type *ecl_sum, FILE *stream, } #undef DATE_STRING_LENGTH -static void ecl_sum_fmt_init_csv(ecl_sum_fmt_type *fmt, const char *date_format, - const char *date_header, const char *sep) { +static void rd_sum_fmt_init_csv(rd_sum_fmt_type *fmt, const char *date_format, + const char *date_header, const char *sep) { fmt->locale = NULL; //"Norwegian"; fmt->sep = sep; fmt->date_fmt = date_format; @@ -1258,53 +1236,49 @@ static void ecl_sum_fmt_init_csv(ecl_sum_fmt_type *fmt, const char *date_format, fmt->print_dash = false; } -void ecl_sum_export_csv(const ecl_sum_type *ecl_sum, const char *filename, - const stringlist_type *var_list, - const char *date_format, const char *sep) { +void rd_sum_export_csv(const rd_sum_type *rd_sum, const char *filename, + const stringlist_type *var_list, const char *date_format, + const char *sep) { FILE *stream = util_mkdir_fopen(filename, "w"); char *date_header = util_alloc_sprintf("DAYS%sDATE", sep); bool report_only = false; - ecl_sum_fmt_type fmt; - ecl_sum_fmt_init_csv(&fmt, date_format, date_header, sep); - ecl_sum_fprintf(ecl_sum, stream, var_list, report_only, &fmt); + rd_sum_fmt_type fmt; + rd_sum_fmt_init_csv(&fmt, date_format, date_header, sep); + rd_sum_fprintf(rd_sum, stream, var_list, report_only, &fmt); fclose(stream); free(date_header); } -const ecl_sum_type *ecl_sum_get_restart_case(const ecl_sum_type *ecl_sum) { - return ecl_sum->restart_case; +const rd_sum_type *rd_sum_get_restart_case(const rd_sum_type *rd_sum) { + return rd_sum->restart_case; } -int ecl_sum_get_restart_step(const ecl_sum_type *ecl_sum) { - return ecl_smspec_get_restart_step(ecl_sum->smspec); +int rd_sum_get_restart_step(const rd_sum_type *rd_sum) { + return rd_smspec_get_restart_step(rd_sum->smspec); } -const char *ecl_sum_get_case(const ecl_sum_type *ecl_sum) { - return ecl_sum->ecl_case; +const char *rd_sum_get_case(const rd_sum_type *rd_sum) { + return rd_sum->rd_case; } -const char *ecl_sum_get_path(const ecl_sum_type *ecl_sum) { - return ecl_sum->path; -} +const char *rd_sum_get_path(const rd_sum_type *rd_sum) { return rd_sum->path; } -const char *ecl_sum_get_abs_path(const ecl_sum_type *ecl_sum) { - return ecl_sum->abs_path; +const char *rd_sum_get_abs_path(const rd_sum_type *rd_sum) { + return rd_sum->abs_path; } -const char *ecl_sum_get_base(const ecl_sum_type *ecl_sum) { - return ecl_sum->base; -} +const char *rd_sum_get_base(const rd_sum_type *rd_sum) { return rd_sum->base; } /** This function will check if the currently loaded case corresponds to the case specified by @input_file. The extension of @input file can be arbitrary (or nonexistent) and will be ignored (this can lead to errors with formatted/unformatted mixup if the simulation - directory has been changed after the ecl_sum instance has been + directory has been changed after the rd_sum instance has been loaded). */ -bool ecl_sum_same_case(const ecl_sum_type *ecl_sum, const char *input_file) { +bool rd_sum_same_case(const rd_sum_type *rd_sum, const char *input_file) { bool same_case = false; { char *path; @@ -1312,12 +1286,12 @@ bool ecl_sum_same_case(const ecl_sum_type *ecl_sum, const char *input_file) { util_alloc_file_components(input_file, &path, &base, NULL); { - bool fmt_file = ecl_smspec_get_formatted(ecl_sum->smspec); - char *header_file = ecl_util_alloc_exfilename( - path, base, ECL_SUMMARY_HEADER_FILE, fmt_file, -1); + bool fmt_file = rd_smspec_get_formatted(rd_sum->smspec); + char *header_file = rd_alloc_exfilename( + path, base, RD_SUMMARY_HEADER_FILE, fmt_file, -1); if (header_file != NULL) { same_case = util_same_file( - header_file, ecl_smspec_get_header_file(ecl_sum->smspec)); + header_file, rd_smspec_get_header_file(rd_sum->smspec)); free(header_file); } } @@ -1329,113 +1303,111 @@ bool ecl_sum_same_case(const ecl_sum_type *ecl_sum, const char *input_file) { } stringlist_type * -ecl_sum_alloc_matching_general_var_list(const ecl_sum_type *ecl_sum, - const char *pattern) { - return ecl_smspec_alloc_matching_general_var_list(ecl_sum->smspec, pattern); +rd_sum_alloc_matching_general_var_list(const rd_sum_type *rd_sum, + const char *pattern) { + return rd_smspec_alloc_matching_general_var_list(rd_sum->smspec, pattern); } -void ecl_sum_select_matching_general_var_list(const ecl_sum_type *ecl_sum, - const char *pattern, - stringlist_type *keys) { - ecl_smspec_select_matching_general_var_list(ecl_sum->smspec, pattern, keys); +void rd_sum_select_matching_general_var_list(const rd_sum_type *rd_sum, + const char *pattern, + stringlist_type *keys) { + rd_smspec_select_matching_general_var_list(rd_sum->smspec, pattern, keys); } -stringlist_type *ecl_sum_alloc_well_list(const ecl_sum_type *ecl_sum, - const char *pattern) { - return ecl_smspec_alloc_well_list(ecl_sum->smspec, pattern); +stringlist_type *rd_sum_alloc_well_list(const rd_sum_type *rd_sum, + const char *pattern) { + return rd_smspec_alloc_well_list(rd_sum->smspec, pattern); } -stringlist_type *ecl_sum_alloc_group_list(const ecl_sum_type *ecl_sum, - const char *pattern) { - return ecl_smspec_alloc_group_list(ecl_sum->smspec, pattern); +stringlist_type *rd_sum_alloc_group_list(const rd_sum_type *rd_sum, + const char *pattern) { + return rd_smspec_alloc_group_list(rd_sum->smspec, pattern); } -stringlist_type *ecl_sum_alloc_well_var_list(const ecl_sum_type *ecl_sum) { - return ecl_smspec_alloc_well_var_list(ecl_sum->smspec); +stringlist_type *rd_sum_alloc_well_var_list(const rd_sum_type *rd_sum) { + return rd_smspec_alloc_well_var_list(rd_sum->smspec); } -void ecl_sum_resample_from_sim_time(const ecl_sum_type *ecl_sum, - const time_t_vector_type *sim_time, - double_vector_type *value, - const char *gen_key) { - const ecl::smspec_node &node = - ecl_smspec_get_general_var_node(ecl_sum->smspec, gen_key); +void rd_sum_resample_from_sim_time(const rd_sum_type *rd_sum, + const time_t_vector_type *sim_time, + double_vector_type *value, + const char *gen_key) { + const rd::smspec_node &node = + rd_smspec_get_general_var_node(rd_sum->smspec, gen_key); double_vector_reset(value); { int i; for (i = 0; i < time_t_vector_size(sim_time); i++) double_vector_iset( value, i, - ecl_sum_data_get_from_sim_time( - ecl_sum->data, time_t_vector_iget(sim_time, i), node)); + rd_sum_data_get_from_sim_time( + rd_sum->data, time_t_vector_iget(sim_time, i), node)); } } -void ecl_sum_resample_from_sim_days(const ecl_sum_type *ecl_sum, - const double_vector_type *sim_days, - double_vector_type *value, - const char *gen_key) { - const ecl::smspec_node &node = - ecl_smspec_get_general_var_node(ecl_sum->smspec, gen_key); +void rd_sum_resample_from_sim_days(const rd_sum_type *rd_sum, + const double_vector_type *sim_days, + double_vector_type *value, + const char *gen_key) { + const rd::smspec_node &node = + rd_smspec_get_general_var_node(rd_sum->smspec, gen_key); double_vector_reset(value); { int i; for (i = 0; i < double_vector_size(sim_days); i++) double_vector_iset( value, i, - ecl_sum_data_get_from_sim_days( - ecl_sum->data, double_vector_iget(sim_days, i), node)); + rd_sum_data_get_from_sim_days( + rd_sum->data, double_vector_iget(sim_days, i), node)); } } -time_t ecl_sum_time_from_days(const ecl_sum_type *ecl_sum, double sim_days) { - time_t t = ecl_smspec_get_start_time(ecl_sum->smspec); +time_t rd_sum_time_from_days(const rd_sum_type *rd_sum, double sim_days) { + time_t t = rd_smspec_get_start_time(rd_sum->smspec); util_inplace_forward_days_utc(&t, sim_days); return t; } -double ecl_sum_days_from_time(const ecl_sum_type *ecl_sum, time_t sim_time) { +double rd_sum_days_from_time(const rd_sum_type *rd_sum, time_t sim_time) { double seconds_diff = - util_difftime(ecl_smspec_get_start_time(ecl_sum->smspec), sim_time, - NULL, NULL, NULL, NULL); + util_difftime(rd_smspec_get_start_time(rd_sum->smspec), sim_time, NULL, + NULL, NULL, NULL); return seconds_diff * 1.0 / (3600 * 24.0); } -double ecl_sum_get_first_day(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_get_first_day(ecl_sum->data); +double rd_sum_get_first_day(const rd_sum_type *rd_sum) { + return rd_sum_data_get_first_day(rd_sum->data); } -double ecl_sum_get_sim_length(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_get_sim_length(ecl_sum->data); +double rd_sum_get_sim_length(const rd_sum_type *rd_sum) { + return rd_sum_data_get_sim_length(rd_sum->data); } /** Will return the number of data blocks. */ -int ecl_sum_get_data_length(const ecl_sum_type *ecl_sum) { - return ecl_sum_data_get_length(ecl_sum->data); +int rd_sum_get_data_length(const rd_sum_type *rd_sum) { + return rd_sum_data_get_length(rd_sum->data); } -bool ecl_sum_check_sim_time(const ecl_sum_type *sum, time_t sim_time) { - return ecl_sum_data_check_sim_time(sum->data, sim_time); +bool rd_sum_check_sim_time(const rd_sum_type *sum, time_t sim_time) { + return rd_sum_data_check_sim_time(sum->data, sim_time); } -bool ecl_sum_check_sim_days(const ecl_sum_type *sum, double sim_days) { - return ecl_sum_data_check_sim_days(sum->data, sim_days); +bool rd_sum_check_sim_days(const rd_sum_type *sum, double sim_days) { + return rd_sum_data_check_sim_days(sum->data, sim_days); } -int ecl_sum_get_report_step_from_time(const ecl_sum_type *sum, - time_t sim_time) { - return ecl_sum_data_get_report_step_from_time(sum->data, sim_time); +int rd_sum_get_report_step_from_time(const rd_sum_type *sum, time_t sim_time) { + return rd_sum_data_get_report_step_from_time(sum->data, sim_time); } -int ecl_sum_get_report_step_from_days(const ecl_sum_type *sum, - double sim_days) { - return ecl_sum_data_get_report_step_from_days(sum->data, sim_days); +int rd_sum_get_report_step_from_days(const rd_sum_type *sum, double sim_days) { + return rd_sum_data_get_report_step_from_days(sum->data, sim_days); } -ecl_smspec_type *ecl_sum_get_smspec(const ecl_sum_type *ecl_sum) { - return ecl_sum->smspec; +rd_smspec_type *rd_sum_get_smspec(const rd_sum_type *rd_sum) { + return rd_sum->smspec; } /* @@ -1444,18 +1416,18 @@ ecl_smspec_type *ecl_sum_get_smspec(const ecl_sum_type *ecl_sum) { know how to create the various composite keys. */ -char *ecl_sum_alloc_well_key(const ecl_sum_type *ecl_sum, const char *keyword, - const char *wgname) { - return ecl_smspec_alloc_well_key(ecl_sum->smspec, keyword, wgname); +char *rd_sum_alloc_well_key(const rd_sum_type *rd_sum, const char *keyword, + const char *wgname) { + return rd_smspec_alloc_well_key(rd_sum->smspec, keyword, wgname); } -bool ecl_sum_is_oil_producer(const ecl_sum_type *ecl_sum, const char *well) { +bool rd_sum_is_oil_producer(const rd_sum_type *rd_sum, const char *well) { const char *WOPT_KEY = "WOPT"; bool oil_producer = false; - if (ecl_sum_has_well_var(ecl_sum, well, WOPT_KEY)) { - int last_step = ecl_sum_get_data_length(ecl_sum) - 1; - double wopt = ecl_sum_get_well_var(ecl_sum, last_step, well, WOPT_KEY); + if (rd_sum_has_well_var(rd_sum, well, WOPT_KEY)) { + int last_step = rd_sum_get_data_length(rd_sum) - 1; + double wopt = rd_sum_get_well_var(rd_sum, last_step, well, WOPT_KEY); if (wopt > 0) oil_producer = true; @@ -1464,52 +1436,50 @@ bool ecl_sum_is_oil_producer(const ecl_sum_type *ecl_sum, const char *well) { return oil_producer; } -bool ecl_sum_report_step_equal(const ecl_sum_type *ecl_sum1, - const ecl_sum_type *ecl_sum2) { - if (ecl_sum1 == ecl_sum2) +bool rd_sum_report_step_equal(const rd_sum_type *rd_sum1, + const rd_sum_type *rd_sum2) { + if (rd_sum1 == rd_sum2) return true; else - return ecl_sum_data_report_step_equal(ecl_sum1->data, ecl_sum2->data); + return rd_sum_data_report_step_equal(rd_sum1->data, rd_sum2->data); } -bool ecl_sum_report_step_compatible(const ecl_sum_type *ecl_sum1, - const ecl_sum_type *ecl_sum2) { - if (ecl_sum1 == ecl_sum2) +bool rd_sum_report_step_compatible(const rd_sum_type *rd_sum1, + const rd_sum_type *rd_sum2) { + if (rd_sum1 == rd_sum2) return true; else - return ecl_sum_data_report_step_compatible(ecl_sum1->data, - ecl_sum2->data); -} - -double_vector_type *ecl_sum_alloc_seconds_solution(const ecl_sum_type *ecl_sum, - const char *gen_key, - double cmp_value, - bool rates_clamp_lower) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); - return ecl_sum_data_alloc_seconds_solution(ecl_sum->data, *node, cmp_value, - rates_clamp_lower); -} - -double_vector_type *ecl_sum_alloc_days_solution(const ecl_sum_type *ecl_sum, - const char *gen_key, - double cmp_value, - bool rates_clamp_lower) { - double_vector_type *solution = ecl_sum_alloc_seconds_solution( - ecl_sum, gen_key, cmp_value, rates_clamp_lower); + return rd_sum_data_report_step_compatible(rd_sum1->data, rd_sum2->data); +} + +double_vector_type *rd_sum_alloc_seconds_solution(const rd_sum_type *rd_sum, + const char *gen_key, + double cmp_value, + bool rates_clamp_lower) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); + return rd_sum_data_alloc_seconds_solution(rd_sum->data, *node, cmp_value, + rates_clamp_lower); +} + +double_vector_type *rd_sum_alloc_days_solution(const rd_sum_type *rd_sum, + const char *gen_key, + double cmp_value, + bool rates_clamp_lower) { + double_vector_type *solution = rd_sum_alloc_seconds_solution( + rd_sum, gen_key, cmp_value, rates_clamp_lower); double_vector_scale(solution, 1.0 / 86400); return solution; } -time_t_vector_type *ecl_sum_alloc_time_solution(const ecl_sum_type *ecl_sum, - const char *gen_key, - double cmp_value, - bool rates_clamp_lower) { +time_t_vector_type *rd_sum_alloc_time_solution(const rd_sum_type *rd_sum, + const char *gen_key, + double cmp_value, + bool rates_clamp_lower) { time_t_vector_type *solution = time_t_vector_alloc(0, 0); { - double_vector_type *seconds = ecl_sum_alloc_seconds_solution( - ecl_sum, gen_key, cmp_value, rates_clamp_lower); - time_t start_time = ecl_sum_get_start_time(ecl_sum); + double_vector_type *seconds = rd_sum_alloc_seconds_solution( + rd_sum, gen_key, cmp_value, rates_clamp_lower); + time_t start_time = rd_sum_get_start_time(rd_sum); for (int i = 0; i < double_vector_size(seconds); i++) { time_t t = start_time; util_inplace_forward_seconds_utc(&t, @@ -1521,40 +1491,36 @@ time_t_vector_type *ecl_sum_alloc_time_solution(const ecl_sum_type *ecl_sum, return solution; } -ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type *ecl_sum) { - return ecl_smspec_get_unit_system(ecl_sum->smspec); +ert_rd_unit_enum rd_sum_get_unit_system(const rd_sum_type *rd_sum) { + return rd_smspec_get_unit_system(rd_sum->smspec); } -double ecl_sum_iget_last_value(const ecl_sum_type *ecl_sum, int param_index) { - return ecl_sum_data_iget_last_value(ecl_sum->data, param_index); +double rd_sum_iget_last_value(const rd_sum_type *rd_sum, int param_index) { + return rd_sum_data_iget_last_value(rd_sum->data, param_index); } -double ecl_sum_get_last_value_gen_key(const ecl_sum_type *ecl_sum, - const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); - return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node)); +double rd_sum_get_last_value_gen_key(const rd_sum_type *rd_sum, + const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); + return rd_sum_iget_last_value(rd_sum, smspec_node_get_params_index(node)); } -double ecl_sum_get_last_value_node(const ecl_sum_type *ecl_sum, - const ecl::smspec_node *node) { - return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node)); +double rd_sum_get_last_value_node(const rd_sum_type *rd_sum, + const rd::smspec_node *node) { + return rd_sum_iget_last_value(rd_sum, smspec_node_get_params_index(node)); } -double ecl_sum_iget_first_value(const ecl_sum_type *ecl_sum, int param_index) { - return ecl_sum_data_iget_first_value(ecl_sum->data, param_index); +double rd_sum_iget_first_value(const rd_sum_type *rd_sum, int param_index) { + return rd_sum_data_iget_first_value(rd_sum->data, param_index); } -double ecl_sum_get_first_value_gen_key(const ecl_sum_type *ecl_sum, - const char *gen_key) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum, gen_key); - return ecl_sum_iget_first_value(ecl_sum, - smspec_node_get_params_index(node)); +double rd_sum_get_first_value_gen_key(const rd_sum_type *rd_sum, + const char *gen_key) { + const rd::smspec_node *node = rd_sum_get_general_var_node(rd_sum, gen_key); + return rd_sum_iget_first_value(rd_sum, smspec_node_get_params_index(node)); } -double ecl_sum_get_first_value_node(const ecl_sum_type *ecl_sum, - const ecl::smspec_node *node) { - return ecl_sum_iget_first_value(ecl_sum, - smspec_node_get_params_index(node)); +double rd_sum_get_first_value_node(const rd_sum_type *rd_sum, + const rd::smspec_node *node) { + return rd_sum_iget_first_value(rd_sum, smspec_node_get_params_index(node)); } diff --git a/lib/resdata/rd_sum_data.cpp b/lib/resdata/rd_sum_data.cpp index c1a2327111..1345a46d7d 100644 --- a/lib/resdata/rd_sum_data.cpp +++ b/lib/resdata/rd_sum_data.cpp @@ -13,37 +13,37 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "detail/ecl/ecl_sum_file_data.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "detail/resdata/rd_sum_file_data.hpp" /* - This file implements the sruct ecl_sum_data which manages the actual simulated + This file implements the sruct rd_sum_data which manages the actual simulated values from a summary file, including all time-related information. In the case of restarted simulations the different summary cases will be internalized - as separate ecl_sum_file_data instances. The ecl_sum_file_data class is an + as separate rd_sum_file_data instances. The rd_sum_file_data class is an internal implemenation detail which is not exported. More details about the internal storage of summary data can be found in that file. For this file the implementation mainly consists of maintaining an ordered - list of ecl_sum_file_data instances and dispatching method calls to the right - ecl_sum_file_data instance. + list of rd_sum_file_data instances and dispatching method calls to the right + rd_sum_file_data instance. */ namespace { /* The class CaseIndex and the struct IndexNode are used to maintain a list of - the ecl_sum_file_data instances, and lookup the correct one based one various + the rd_sum_file_data instances, and lookup the correct one based one various time related arguments. */ @@ -209,18 +209,18 @@ class CaseIndex { } // namespace -struct ecl_sum_data_struct { - const ecl_smspec_type *smspec; - std::vector - data_files; // List of ecl_sum_file_data instances +struct rd_sum_data_struct { + const rd_smspec_type *smspec; + std::vector + data_files; // List of rd_sum_file_data instances CaseIndex index; }; -static void ecl_sum_data_build_index(ecl_sum_data_type *self); -static double ecl_sum_data_iget_sim_seconds(const ecl_sum_data_type *data, - int internal_index); +static void rd_sum_data_build_index(rd_sum_data_type *self); +static double rd_sum_data_iget_sim_seconds(const rd_sum_data_type *data, + int internal_index); -void ecl_sum_data_free(ecl_sum_data_type *data) { +void rd_sum_data_free(rd_sum_data_type *data) { if (!data) throw std::invalid_argument(__func__ + std::string(": invalid delete")); @@ -230,18 +230,18 @@ void ecl_sum_data_free(ecl_sum_data_type *data) { delete data; } -ecl_sum_data_type *ecl_sum_data_alloc(ecl_smspec_type *smspec) { - ecl_sum_data_type *data = new ecl_sum_data_type(); +rd_sum_data_type *rd_sum_data_alloc(rd_smspec_type *smspec) { + rd_sum_data_type *data = new rd_sum_data_type(); data->smspec = smspec; return data; } -void ecl_sum_data_reset_self_map(ecl_sum_data_type *data) { - ecl_sum_data_build_index(data); +void rd_sum_data_reset_self_map(rd_sum_data_type *data) { + rd_sum_data_build_index(data); } -static void ecl_sum_data_append_file_data(ecl_sum_data_type *sum_data, - ecl::ecl_sum_file_data *file_data) { +static void rd_sum_data_append_file_data(rd_sum_data_type *sum_data, + rd::rd_sum_file_data *file_data) { sum_data->data_files.push_back(file_data); } @@ -263,37 +263,37 @@ static void ecl_sum_data_append_file_data(ecl_sum_data_type *sum_data, return values to -1 (the return value from safe_iget). In that case it is the responsability of the calling scope to check the return values, alternatively one can use the query function - ecl_sum_data_has_report_step() first. + rd_sum_data_has_report_step() first. */ -static double ecl_sum_data_iget_sim_seconds(const ecl_sum_data_type *data, - int internal_index) { +static double rd_sum_data_iget_sim_seconds(const rd_sum_data_type *data, + int internal_index) { const auto index_node = data->index.lookup(internal_index); const auto data_file = data->data_files[index_node.data_index]; return data_file->iget_sim_seconds(internal_index - index_node.offset); } -double ecl_sum_data_iget_sim_days(const ecl_sum_data_type *data, - int internal_index) { +double rd_sum_data_iget_sim_days(const rd_sum_data_type *data, + int internal_index) { const auto index_node = data->index.lookup(internal_index); const auto data_file = data->data_files[index_node.data_index]; return data_file->iget_sim_days(internal_index - index_node.offset); } -ecl_sum_data_type *ecl_sum_data_alloc_writer(ecl_smspec_type *smspec) { - ecl_sum_data_type *data = ecl_sum_data_alloc(smspec); - ecl::ecl_sum_file_data *file_data = new ecl::ecl_sum_file_data(smspec); - ecl_sum_data_append_file_data(data, file_data); - ecl_sum_data_build_index(data); +rd_sum_data_type *rd_sum_data_alloc_writer(rd_smspec_type *smspec) { + rd_sum_data_type *data = rd_sum_data_alloc(smspec); + rd::rd_sum_file_data *file_data = new rd::rd_sum_file_data(smspec); + rd_sum_data_append_file_data(data, file_data); + rd_sum_data_build_index(data); return data; } -static void ecl_sum_data_fwrite_unified(const ecl_sum_data_type *data, - const char *ecl_case, bool fmt_case) { - char *filename = ecl_util_alloc_filename( - NULL, ecl_case, ECL_UNIFIED_SUMMARY_FILE, fmt_case, 0); +static void rd_sum_data_fwrite_unified(const rd_sum_data_type *data, + const char *rd_case, bool fmt_case) { + char *filename = + rd_alloc_filename(NULL, rd_case, RD_UNIFIED_SUMMARY_FILE, fmt_case, 0); fortio_type *fortio = - fortio_open_writer(filename, fmt_case, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, fmt_case, RD_ENDIAN_FLIP); for (size_t index = 0; index < data->data_files.size(); index++) data->data_files[index]->fwrite_unified(fortio); @@ -302,22 +302,22 @@ static void ecl_sum_data_fwrite_unified(const ecl_sum_data_type *data, free(filename); } -static void ecl_sum_data_fwrite_multiple(const ecl_sum_data_type *data, - const char *ecl_case, bool fmt_case) { +static void rd_sum_data_fwrite_multiple(const rd_sum_data_type *data, + const char *rd_case, bool fmt_case) { for (size_t index = 0; index < data->data_files.size(); index++) - data->data_files[index]->fwrite_multiple(ecl_case, fmt_case); + data->data_files[index]->fwrite_multiple(rd_case, fmt_case); } -void ecl_sum_data_fwrite(const ecl_sum_data_type *data, const char *ecl_case, - bool fmt_case, bool unified) { +void rd_sum_data_fwrite(const rd_sum_data_type *data, const char *rd_case, + bool fmt_case, bool unified) { if (unified) - ecl_sum_data_fwrite_unified(data, ecl_case, fmt_case); + rd_sum_data_fwrite_unified(data, rd_case, fmt_case); else - ecl_sum_data_fwrite_multiple(data, ecl_case, fmt_case); + rd_sum_data_fwrite_multiple(data, rd_case, fmt_case); } -bool ecl_sum_data_can_write(const ecl_sum_data_type *data) { +bool rd_sum_data_can_write(const rd_sum_data_type *data) { bool can_write = true; for (const auto &file_ptr : data->data_files) can_write &= file_ptr->can_write(); @@ -325,20 +325,20 @@ bool ecl_sum_data_can_write(const ecl_sum_data_type *data) { return can_write; } -time_t ecl_sum_data_get_sim_end(const ecl_sum_data_type *data) { +time_t rd_sum_data_get_sim_end(const rd_sum_data_type *data) { if (data->data_files.empty()) - throw std::out_of_range("ecl_sum_data_get_sim_end: data_files empty"); + throw std::out_of_range("rd_sum_data_get_sim_end: data_files empty"); const auto &file_data = data->data_files.back(); return file_data->get_sim_end(); } -time_t ecl_sum_data_get_data_start(const ecl_sum_data_type *data) { +time_t rd_sum_data_get_data_start(const rd_sum_data_type *data) { const auto &file_data = data->data_files[0]; return file_data->get_data_start(); } -double ecl_sum_data_get_first_day(const ecl_sum_data_type *data) { +double rd_sum_data_get_first_day(const rd_sum_data_type *data) { const auto &file_data = data->data_files[0]; return file_data->get_days_start(); } @@ -349,7 +349,7 @@ double ecl_sum_data_get_first_day(const ecl_sum_data_type *data) { actually been loaded) to the last loaded simulation step. */ -double ecl_sum_data_get_sim_length(const ecl_sum_data_type *data) { +double rd_sum_data_get_sim_length(const rd_sum_data_type *data) { const auto &file_data = data->data_files.back(); return file_data->get_sim_length(); } @@ -362,21 +362,19 @@ double ecl_sum_data_get_sim_length(const ecl_sum_data_type *data) { start with no data. */ -bool ecl_sum_data_check_sim_time(const ecl_sum_data_type *data, - time_t sim_time) { - if (sim_time < ecl_sum_data_get_data_start(data)) +bool rd_sum_data_check_sim_time(const rd_sum_data_type *data, time_t sim_time) { + if (sim_time < rd_sum_data_get_data_start(data)) return false; - if (sim_time > ecl_sum_data_get_sim_end(data)) + if (sim_time > rd_sum_data_get_sim_end(data)) return false; return true; } -bool ecl_sum_data_check_sim_days(const ecl_sum_data_type *data, - double sim_days) { - return sim_days >= ecl_sum_data_get_first_day(data) && - sim_days <= ecl_sum_data_get_sim_length(data); +bool rd_sum_data_check_sim_days(const rd_sum_data_type *data, double sim_days) { + return sim_days >= rd_sum_data_get_first_day(data) && + sim_days <= rd_sum_data_get_sim_length(data); } /** @@ -385,7 +383,7 @@ bool ecl_sum_data_check_sim_days(const ecl_sum_data_type *data, before the simulation start, or after the end of the simulation. Check with - ecl_smspec_get_start_time() and ecl_sum_data_get_sim_end() + rd_smspec_get_start_time() and rd_sum_data_get_sim_end() first. @@ -422,14 +420,14 @@ static void fprintf_date_utc(time_t t, FILE *stream) { fprintf(stream, "%02d/%02d/%4d", mday, month, year); } -static int ecl_sum_data_get_index_from_sim_time(const ecl_sum_data_type *data, - time_t sim_time) { - if (!ecl_sum_data_check_sim_time(data, sim_time)) { - time_t start_time = ecl_sum_data_get_data_start(data); - time_t end_time = ecl_sum_data_get_sim_end(data); +static int rd_sum_data_get_index_from_sim_time(const rd_sum_data_type *data, + time_t sim_time) { + if (!rd_sum_data_check_sim_time(data, sim_time)) { + time_t start_time = rd_sum_data_get_data_start(data); + time_t end_time = rd_sum_data_get_sim_end(data); fprintf(stderr, "Simulation start: "); - fprintf_date_utc(ecl_smspec_get_start_time(data->smspec), stderr); + fprintf_date_utc(rd_smspec_get_start_time(data->smspec), stderr); fprintf(stderr, "Data start......: "); fprintf_date_utc(start_time, stderr); fprintf(stderr, "Simulation end .: "); @@ -448,13 +446,13 @@ static int ecl_sum_data_get_index_from_sim_time(const ecl_sum_data_type *data, */ int low_index = 0; - int high_index = ecl_sum_data_get_length(data) - 1; + int high_index = rd_sum_data_get_length(data) - 1; // perform binary search while (low_index + 1 < high_index) { int center_index = (low_index + high_index) / 2; const time_t center_time = - ecl_sum_data_iget_sim_time(data, center_index); + rd_sum_data_iget_sim_time(data, center_index); if (sim_time > center_time) low_index = center_index; @@ -462,15 +460,15 @@ static int ecl_sum_data_get_index_from_sim_time(const ecl_sum_data_type *data, high_index = center_index; } - return sim_time <= ecl_sum_data_iget_sim_time(data, low_index) ? low_index - : high_index; + return sim_time <= rd_sum_data_iget_sim_time(data, low_index) ? low_index + : high_index; } -int ecl_sum_data_get_index_from_sim_days(const ecl_sum_data_type *data, - double sim_days) { - time_t sim_time = ecl_smspec_get_start_time(data->smspec); +int rd_sum_data_get_index_from_sim_days(const rd_sum_data_type *data, + double sim_days) { + time_t sim_time = rd_smspec_get_start_time(data->smspec); util_inplace_forward_days_utc(&sim_time, sim_days); - return ecl_sum_data_get_index_from_sim_time(data, sim_time); + return rd_sum_data_get_index_from_sim_time(data, sim_time); } /** @@ -479,7 +477,7 @@ int ecl_sum_data_get_index_from_sim_days(const ecl_sum_data_type *data, corresponding weights are calculated. The actual value we are interested in can then be computed with the - ecl_sum_data_interp_get() function: + rd_sum_data_interp_get() function: int param_index; @@ -488,8 +486,8 @@ int ecl_sum_data_get_index_from_sim_days(const ecl_sum_data_type *data, int ministep1 , ministep2; double weight1 , weight2; - ecl_sum_data_init_interp_from_sim_time( data , sim_time , &ministep1 , &ministep2 , &weight1 , &weight2); - return ecl_sum_data_interp_get( data , ministep1 , ministep2 , weight1 , weight2 , param_index ); + rd_sum_data_init_interp_from_sim_time( data , sim_time , &ministep1 , &ministep2 , &weight1 , &weight2); + return rd_sum_data_interp_get( data , ministep1 , ministep2 , weight1 , weight2 , param_index ); } @@ -498,11 +496,11 @@ int ecl_sum_data_get_index_from_sim_days(const ecl_sum_data_type *data, file. */ -void ecl_sum_data_init_interp_from_sim_time(const ecl_sum_data_type *data, - time_t sim_time, int *index1, - int *index2, double *weight1, - double *weight2) { - int idx = ecl_sum_data_get_index_from_sim_time(data, sim_time); +void rd_sum_data_init_interp_from_sim_time(const rd_sum_data_type *data, + time_t sim_time, int *index1, + int *index2, double *weight1, + double *weight2) { + int idx = rd_sum_data_get_index_from_sim_time(data, sim_time); // if sim_time is first date, idx=0 and then we cannot interpolate, so we give // weight 1 to index1=index2=0. @@ -514,8 +512,8 @@ void ecl_sum_data_init_interp_from_sim_time(const ecl_sum_data_type *data, return; } - time_t sim_time1 = ecl_sum_data_iget_sim_time(data, idx - 1); - time_t sim_time2 = ecl_sum_data_iget_sim_time(data, idx); + time_t sim_time1 = rd_sum_data_iget_sim_time(data, idx - 1); + time_t sim_time2 = rd_sum_data_iget_sim_time(data, idx); *index1 = idx - 1; *index2 = idx; @@ -529,31 +527,31 @@ void ecl_sum_data_init_interp_from_sim_time(const ecl_sum_data_type *data, *weight2 = time_dist1 / time_diff; } -void ecl_sum_data_init_interp_from_sim_days(const ecl_sum_data_type *data, - double sim_days, int *step1, - int *step2, double *weight1, - double *weight2) { - time_t sim_time = ecl_smspec_get_start_time(data->smspec); +void rd_sum_data_init_interp_from_sim_days(const rd_sum_data_type *data, + double sim_days, int *step1, + int *step2, double *weight1, + double *weight2) { + time_t sim_time = rd_smspec_get_start_time(data->smspec); util_inplace_forward_days_utc(&sim_time, sim_days); - ecl_sum_data_init_interp_from_sim_time(data, sim_time, step1, step2, - weight1, weight2); + rd_sum_data_init_interp_from_sim_time(data, sim_time, step1, step2, weight1, + weight2); } double_vector_type * -ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type *data, - const ecl::smspec_node &node, - double cmp_value, bool rates_clamp_lower) { +rd_sum_data_alloc_seconds_solution(const rd_sum_data_type *data, + const rd::smspec_node &node, + double cmp_value, bool rates_clamp_lower) { double_vector_type *solution = double_vector_alloc(0, 0); const int param_index = smspec_node_get_params_index(&node); - const int size = ecl_sum_data_get_length(data); + const int size = rd_sum_data_get_length(data); if (size <= 1) return solution; for (int index = 0; index < size; ++index) { int prev_index = util_int_max(0, index - 1); - double value = ecl_sum_data_iget(data, index, param_index); - double prev_value = ecl_sum_data_iget(data, prev_index, param_index); + double value = rd_sum_data_iget(data, index, param_index); + double prev_value = rd_sum_data_iget(data, prev_index, param_index); // cmp_value in interval value (closed) and prev_value (open) bool contained = (value == cmp_value); @@ -563,8 +561,8 @@ ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type *data, if (!contained) continue; - double prev_time = ecl_sum_data_iget_sim_seconds(data, prev_index); - double time = ecl_sum_data_iget_sim_seconds(data, index); + double prev_time = rd_sum_data_iget_sim_seconds(data, prev_index); + double time = rd_sum_data_iget_sim_seconds(data, index); if (smspec_node_is_rate(&node)) { double_vector_append(solution, @@ -578,10 +576,10 @@ ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type *data, return solution; } -static void ecl_sum_data_build_index(ecl_sum_data_type *self) { +static void rd_sum_data_build_index(rd_sum_data_type *self) { std::sort(self->data_files.begin(), self->data_files.end(), - [](const ecl::ecl_sum_file_data *case1, - const ecl::ecl_sum_file_data *case2) { + [](const rd::rd_sum_file_data *case1, + const rd::rd_sum_file_data *case2) { return case1->get_data_start() < case2->get_data_start(); }); @@ -614,10 +612,9 @@ static void ecl_sum_data_build_index(ecl_sum_data_type *self) { node.days2 = data->get_sim_length(); { int *tmp_map = - ecl_smspec_alloc_mapping(self->smspec, data->smspec()); + rd_smspec_alloc_mapping(self->smspec, data->smspec()); node.params_map.assign( - tmp_map, - tmp_map + ecl_smspec_get_params_size(self->smspec)); + tmp_map, tmp_map + rd_smspec_get_params_size(self->smspec)); free(tmp_map); } } @@ -628,21 +625,21 @@ static void ecl_sum_data_build_index(ecl_sum_data_type *self) { This function is meant to be called in write mode; and will create a new and empty tstep which is appended to the current data. The tstep will also be returned, so the calling scope can call - ecl_sum_tstep_iset() to set elements in the tstep. + rd_sum_tstep_iset() to set elements in the tstep. */ -ecl_sum_tstep_type *ecl_sum_data_add_new_tstep(ecl_sum_data_type *data, - int report_step, - double sim_seconds) { - ecl::ecl_sum_file_data *file_data = data->data_files.back(); - ecl_sum_tstep_type *tstep = +rd_sum_tstep_type *rd_sum_data_add_new_tstep(rd_sum_data_type *data, + int report_step, + double sim_seconds) { + rd::rd_sum_file_data *file_data = data->data_files.back(); + rd_sum_tstep_type *tstep = file_data->add_new_tstep(report_step, sim_seconds); - ecl_sum_data_build_index(data); + rd_sum_data_build_index(data); return tstep; } -int *ecl_sum_data_alloc_param_mapping(int *current_param_mapping, - int *old_param_mapping, size_t size) { +int *rd_sum_data_alloc_param_mapping(int *current_param_mapping, + int *old_param_mapping, size_t size) { int *new_param_mapping = (int *)util_malloc(size * sizeof *new_param_mapping); for (size_t i = 0; i < size; i++) { @@ -654,31 +651,29 @@ int *ecl_sum_data_alloc_param_mapping(int *current_param_mapping, return new_param_mapping; } -void ecl_sum_data_add_case(ecl_sum_data_type *self, - const ecl_sum_data_type *other) { +void rd_sum_data_add_case(rd_sum_data_type *self, + const rd_sum_data_type *other) { for (auto other_file : other->data_files) self->data_files.push_back(other_file); - ecl_sum_data_build_index(self); + rd_sum_data_build_index(self); } /* Observe that this can be called several times (but not with the same data - that will die). - Warning: The index information of the ecl_sum_data instance has + Warning: The index information of the rd_sum_data instance has __NOT__ been updated when leaving this function. That is done with a - call to ecl_sum_data_build_index(). + call to rd_sum_data_build_index(). */ -bool ecl_sum_data_fread(ecl_sum_data_type *data, - const stringlist_type *filelist, bool lazy_load, - int file_options) { - ecl::ecl_sum_file_data *file_data = - new ecl::ecl_sum_file_data(data->smspec); +bool rd_sum_data_fread(rd_sum_data_type *data, const stringlist_type *filelist, + bool lazy_load, int file_options) { + rd::rd_sum_file_data *file_data = new rd::rd_sum_file_data(data->smspec); if (file_data->fread(filelist, lazy_load, file_options)) { - ecl_sum_data_append_file_data(data, file_data); - ecl_sum_data_build_index(data); + rd_sum_data_append_file_data(data, file_data); + rd_sum_data_build_index(data); return true; } return false; @@ -692,22 +687,22 @@ bool ecl_sum_data_fread(ecl_sum_data_type *data, (manually) changed from the historical part. */ -ecl_sum_data_type *ecl_sum_data_fread_alloc(ecl_smspec_type *smspec, - const stringlist_type *filelist, - bool include_restart, - bool lazy_load, int file_options) { - ecl_sum_data_type *data = ecl_sum_data_alloc(smspec); - ecl_sum_data_fread(data, filelist, lazy_load, file_options); +rd_sum_data_type *rd_sum_data_fread_alloc(rd_smspec_type *smspec, + const stringlist_type *filelist, + bool include_restart, bool lazy_load, + int file_options) { + rd_sum_data_type *data = rd_sum_data_alloc(smspec); + rd_sum_data_fread(data, filelist, lazy_load, file_options); /* OK - now we have loaded all the data. Must sort the internal storage vector, and build up various internal indexing vectors; this is done in a sepearate function. */ - ecl_sum_data_build_index(data); + rd_sum_data_build_index(data); return data; } -void ecl_sum_data_summarize(const ecl_sum_data_type *data, FILE *stream) { +void rd_sum_data_summarize(const rd_sum_data_type *data, FILE *stream) { fprintf(stream, "REPORT INDEX DATE DAYS\n"); fprintf( @@ -715,13 +710,13 @@ void ecl_sum_data_summarize(const ecl_sum_data_type *data, FILE *stream) { "---------------------------------------------------------------\n"); { int index; - for (index = 0; index < ecl_sum_data_get_length(data); index++) { - time_t sim_time = ecl_sum_data_iget_sim_time(data, index); - int report_step = ecl_sum_data_iget_report_step(data, index); - double days = ecl_sum_data_iget_sim_days(data, index); + for (index = 0; index < rd_sum_data_get_length(data); index++) { + time_t sim_time = rd_sum_data_iget_sim_time(data, index); + int report_step = rd_sum_data_iget_report_step(data, index); + double days = rd_sum_data_iget_sim_days(data, index); int day, month, year; - ecl_util_set_date_values(sim_time, &day, &month, &year); + rd_set_date_values(sim_time, &day, &month, &year); fprintf(stream, "%04d %6d %02d/%02d/%4d " "%7.2f \n", @@ -733,8 +728,8 @@ void ecl_sum_data_summarize(const ecl_sum_data_type *data, FILE *stream) { "---------------------------------------------------------------\n"); } -bool ecl_sum_data_has_report_step(const ecl_sum_data_type *data, - int report_step) { +bool rd_sum_data_has_report_step(const rd_sum_data_type *data, + int report_step) { if (!data->index.has_report(report_step)) return false; @@ -750,16 +745,15 @@ bool ecl_sum_data_has_report_step(const ecl_sum_data_type *data, calling scope. */ -int ecl_sum_data_iget_report_end(const ecl_sum_data_type *data, - int report_step) { +int rd_sum_data_iget_report_end(const rd_sum_data_type *data, int report_step) { const auto &index_node = data->index.lookup_report(report_step); const auto &file_data = data->data_files[index_node.data_index]; auto range = file_data->report_range(report_step); return range.second; } -int ecl_sum_data_iget_report_step(const ecl_sum_data_type *data, - int internal_index) { +int rd_sum_data_iget_report_step(const rd_sum_data_type *data, + int internal_index) { const auto &index_node = data->index.lookup(internal_index); const auto &file_data = data->data_files[index_node.data_index]; return file_data->iget_report(internal_index - index_node.offset); @@ -771,17 +765,17 @@ int ecl_sum_data_iget_report_step(const ecl_sum_data_type *data, any holes. */ -double ecl_sum_data_iget(const ecl_sum_data_type *data, int time_index, - int params_index) { +double rd_sum_data_iget(const rd_sum_data_type *data, int time_index, + int params_index) { const auto &index_node = data->index.lookup(time_index); - ecl::ecl_sum_file_data *file_data = data->data_files[index_node.data_index]; + rd::rd_sum_file_data *file_data = data->data_files[index_node.data_index]; const auto ¶ms_map = index_node.params_map; if (params_map[params_index] >= 0) return file_data->iget(time_index - index_node.offset, params_map[params_index]); else { - const ecl::smspec_node &smspec_node = - ecl_smspec_iget_node_w_params_index(data->smspec, params_index); + const rd::smspec_node &smspec_node = + rd_smspec_iget_node_w_params_index(data->smspec, params_index); return smspec_node.get_default(); } } @@ -791,56 +785,56 @@ double ecl_sum_data_iget(const ecl_sum_data_type *data, int time_index, @ministep1 and @ministep2. The weights and the ministep indices should (typically) be determined by the - ecl_sum_data_init_interp_from_sim_xxx() + rd_sum_data_init_interp_from_sim_xxx() functions. The function will typically the last function called when we seek a reservoir state variable at an intermediate time between two ministeps. */ -static double ecl_sum_data_interp_get(const ecl_sum_data_type *data, - int time_index1, int time_index2, - double weight1, double weight2, - int params_index) { - return ecl_sum_data_iget(data, time_index1, params_index) * weight1 + - ecl_sum_data_iget(data, time_index2, params_index) * weight2; +static double rd_sum_data_interp_get(const rd_sum_data_type *data, + int time_index1, int time_index2, + double weight1, double weight2, + int params_index) { + return rd_sum_data_iget(data, time_index1, params_index) * weight1 + + rd_sum_data_iget(data, time_index2, params_index) * weight2; } -static double ecl_sum_data_vector_iget(const ecl_sum_data_type *data, - time_t sim_time, int params_index, - bool is_rate, int time_index1, - int time_index2, double weight1, - double weight2) { +static double rd_sum_data_vector_iget(const rd_sum_data_type *data, + time_t sim_time, int params_index, + bool is_rate, int time_index1, + int time_index2, double weight1, + double weight2) { double value = 0.0; if (is_rate) { - int time_index = ecl_sum_data_get_index_from_sim_time(data, sim_time); + int time_index = rd_sum_data_get_index_from_sim_time(data, sim_time); // uses step function since it is a rate - value = ecl_sum_data_iget(data, time_index, params_index); + value = rd_sum_data_iget(data, time_index, params_index); } else { // uses interpolation between timesteps - value = ecl_sum_data_interp_get(data, time_index1, time_index2, weight1, - weight2, params_index); + value = rd_sum_data_interp_get(data, time_index1, time_index2, weight1, + weight2, params_index); } return value; } -void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type *data, - time_t sim_time, - const ecl_sum_vector_type *keylist, - FILE *fp) { - int num_keywords = ecl_sum_vector_get_size(keylist); +void rd_sum_data_fwrite_interp_csv_line(const rd_sum_data_type *data, + time_t sim_time, + const rd_sum_vector_type *keylist, + FILE *fp) { + int num_keywords = rd_sum_vector_get_size(keylist); double weight1, weight2; int time_index1, time_index2; - ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, - &time_index2, &weight1, &weight2); + rd_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, + &time_index2, &weight1, &weight2); for (int i = 0; i < num_keywords; i++) { - if (ecl_sum_vector_iget_valid(keylist, i)) { - int params_index = ecl_sum_vector_iget_param_index(keylist, i); - bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); - double value = ecl_sum_data_vector_iget( + if (rd_sum_vector_iget_valid(keylist, i)) { + int params_index = rd_sum_vector_iget_param_index(keylist, i); + bool is_rate = rd_sum_vector_iget_is_rate(keylist, i); + double value = rd_sum_data_vector_iget( data, sim_time, params_index, is_rate, time_index1, time_index2, weight1, weight2); @@ -862,27 +856,27 @@ void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type *data, results vector will *not* be updated; i.e. it is smart to initialize the results vector with an invalid-value marker before calling this function: - double_vector_type * results = double_vector_alloc( ecl_sum_vector_get_size(keys), NAN); - ecl_sum_data_get_interp_vector( data, sim_time, keys, results); + double_vector_type * results = double_vector_alloc( rd_sum_vector_get_size(keys), NAN); + rd_sum_data_get_interp_vector( data, sim_time, keys, results); */ -void ecl_sum_data_get_interp_vector(const ecl_sum_data_type *data, - time_t sim_time, - const ecl_sum_vector_type *keylist, - double_vector_type *results) { - int num_keywords = ecl_sum_vector_get_size(keylist); +void rd_sum_data_get_interp_vector(const rd_sum_data_type *data, + time_t sim_time, + const rd_sum_vector_type *keylist, + double_vector_type *results) { + int num_keywords = rd_sum_vector_get_size(keylist); double weight1, weight2; int time_index1, time_index2; - ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, - &time_index2, &weight1, &weight2); + rd_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, + &time_index2, &weight1, &weight2); double_vector_reset(results); for (int i = 0; i < num_keywords; i++) { - if (ecl_sum_vector_iget_valid(keylist, i)) { - int params_index = ecl_sum_vector_iget_param_index(keylist, i); - bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); - double value = ecl_sum_data_vector_iget( + if (rd_sum_vector_iget_valid(keylist, i)) { + int params_index = rd_sum_vector_iget_param_index(keylist, i); + bool is_rate = rd_sum_vector_iget_is_rate(keylist, i); + double value = rd_sum_data_vector_iget( data, sim_time, params_index, is_rate, time_index1, time_index2, weight1, weight2); double_vector_iset(results, i, value); @@ -890,9 +884,9 @@ void ecl_sum_data_get_interp_vector(const ecl_sum_data_type *data, } } -double ecl_sum_data_get_from_sim_time(const ecl_sum_data_type *data, - time_t sim_time, - const ecl::smspec_node &smspec_node) { +double rd_sum_data_get_from_sim_time(const rd_sum_data_type *data, + time_t sim_time, + const rd::smspec_node &smspec_node) { int params_index = smspec_node_get_params_index(&smspec_node); if (smspec_node_is_rate(&smspec_node)) { /* @@ -908,24 +902,24 @@ double ecl_sum_data_get_from_sim_time(const ecl_sum_data_type *data, with the ECLIPSE results if you ask for a value interpolated to the starting time. */ - int time_index = ecl_sum_data_get_index_from_sim_time(data, sim_time); - return ecl_sum_data_iget(data, time_index, params_index); + int time_index = rd_sum_data_get_index_from_sim_time(data, sim_time); + return rd_sum_data_iget(data, time_index, params_index); } else { /* Interpolated lookup based on two (hopefully) consecutive ministeps. */ double weight1, weight2; int time_index1, time_index2; - ecl_sum_data_init_interp_from_sim_time( - data, sim_time, &time_index1, &time_index2, &weight1, &weight2); - return ecl_sum_data_interp_get(data, time_index1, time_index2, weight1, - weight2, params_index); + rd_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, + &time_index2, &weight1, &weight2); + return rd_sum_data_interp_get(data, time_index1, time_index2, weight1, + weight2, params_index); } } -int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type *data, - double sim_days) { - if ((sim_days < ecl_sum_data_get_first_day(data)) || - (sim_days > ecl_sum_data_get_sim_length(data))) +int rd_sum_data_get_report_step_from_days(const rd_sum_data_type *data, + double sim_days) { + if ((sim_days < rd_sum_data_get_first_day(data)) || + (sim_days > rd_sum_data_get_sim_length(data))) return -1; else { auto files = data->index.lookup_days(sim_days); @@ -956,9 +950,9 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type *data, report_step input. */ -int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type *data, - time_t sim_time) { - if (!ecl_sum_data_check_sim_time(data, sim_time)) +int rd_sum_data_get_report_step_from_time(const rd_sum_data_type *data, + time_t sim_time) { + if (!rd_sum_data_check_sim_time(data, sim_time)) return -1; else { auto files = data->index.lookup_time(sim_time); @@ -970,32 +964,32 @@ int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type *data, } } -double ecl_sum_data_time2days(const ecl_sum_data_type *data, time_t sim_time) { - time_t start_time = ecl_smspec_get_start_time(data->smspec); +double rd_sum_data_time2days(const rd_sum_data_type *data, time_t sim_time) { + time_t start_time = rd_smspec_get_start_time(data->smspec); return util_difftime_days(start_time, sim_time); } -double ecl_sum_data_get_from_sim_days(const ecl_sum_data_type *data, - double sim_days, - const ecl::smspec_node &smspec_node) { - time_t sim_time = ecl_smspec_get_start_time(data->smspec); +double rd_sum_data_get_from_sim_days(const rd_sum_data_type *data, + double sim_days, + const rd::smspec_node &smspec_node) { + time_t sim_time = rd_smspec_get_start_time(data->smspec); util_inplace_forward_days_utc(&sim_time, sim_days); - return ecl_sum_data_get_from_sim_time(data, sim_time, smspec_node); + return rd_sum_data_get_from_sim_time(data, sim_time, smspec_node); } -time_t ecl_sum_data_iget_sim_time(const ecl_sum_data_type *data, - int ministep_index) { +time_t rd_sum_data_iget_sim_time(const rd_sum_data_type *data, + int ministep_index) { const auto &index_node = data->index.lookup(ministep_index); const auto data_file = data->data_files[index_node.data_index]; return data_file->iget_sim_time(ministep_index - index_node.offset); } -time_t ecl_sum_data_get_report_time(const ecl_sum_data_type *data, - int report_step) { +time_t rd_sum_data_get_report_time(const rd_sum_data_type *data, + int report_step) { if (report_step == 0) - return ecl_smspec_get_start_time(data->smspec); + return rd_smspec_get_start_time(data->smspec); else { - int internal_index = ecl_sum_data_iget_report_end(data, report_step); + int internal_index = rd_sum_data_iget_report_end(data, report_step); if (internal_index == -1) throw std::out_of_range( "Tried to look up step nr: " + std::to_string(report_step) + @@ -1003,23 +997,23 @@ time_t ecl_sum_data_get_report_time(const ecl_sum_data_type *data, "exist. \n" + "The step entries in summary file must cover all entries " "in the restart file."); - return ecl_sum_data_iget_sim_time(data, internal_index); + return rd_sum_data_iget_sim_time(data, internal_index); } } -int ecl_sum_data_get_first_report_step(const ecl_sum_data_type *data) { +int rd_sum_data_get_first_report_step(const rd_sum_data_type *data) { const auto &data_file = data->data_files[0]; return data_file->first_report(); } -int ecl_sum_data_get_last_report_step(const ecl_sum_data_type *data) { +int rd_sum_data_get_last_report_step(const rd_sum_data_type *data) { const auto &data_file = data->data_files.back(); return data_file->last_report(); } -static void ecl_sum_data_init_time_vector__(const ecl_sum_data_type *data, - time_t *output_data, - bool report_only) { +static void rd_sum_data_init_time_vector__(const rd_sum_data_type *data, + time_t *output_data, + bool report_only) { int offset = 0; for (const auto &index_node : data->index) { const auto &data_file = data->data_files[index_node.data_index]; @@ -1034,22 +1028,21 @@ static void ecl_sum_data_init_time_vector__(const ecl_sum_data_type *data, } } -void ecl_sum_data_init_time_vector(const ecl_sum_data_type *data, - time_t *output_data) { - ecl_sum_data_init_time_vector__(data, output_data, false); +void rd_sum_data_init_time_vector(const rd_sum_data_type *data, + time_t *output_data) { + rd_sum_data_init_time_vector__(data, output_data, false); } -time_t_vector_type * -ecl_sum_data_alloc_time_vector(const ecl_sum_data_type *data, - bool report_only) { +time_t_vector_type *rd_sum_data_alloc_time_vector(const rd_sum_data_type *data, + bool report_only) { std::vector output_data; if (report_only) - output_data.resize(1 + ecl_sum_data_get_last_report_step(data) - - ecl_sum_data_get_first_report_step(data)); + output_data.resize(1 + rd_sum_data_get_last_report_step(data) - + rd_sum_data_get_first_report_step(data)); else - output_data.resize(ecl_sum_data_get_length(data)); + output_data.resize(rd_sum_data_get_length(data)); - ecl_sum_data_init_time_vector__(data, output_data.data(), report_only); + rd_sum_data_init_time_vector__(data, output_data.data(), report_only); time_t_vector_type *time_vector = time_t_vector_alloc(output_data.size(), 0); { @@ -1060,10 +1053,10 @@ ecl_sum_data_alloc_time_vector(const ecl_sum_data_type *data, return time_vector; } -static void ecl_sum_data_init_double_vector__(const ecl_sum_data_type *data, - int main_params_index, - double *output_data, - bool report_only) { +static void rd_sum_data_init_double_vector__(const rd_sum_data_type *data, + int main_params_index, + double *output_data, + bool report_only) { int offset = 0; for (const auto &index_node : data->index) { const auto &data_file = data->data_files[index_node.data_index]; @@ -1071,9 +1064,9 @@ static void ecl_sum_data_init_double_vector__(const ecl_sum_data_type *data, int params_index = params_map[main_params_index]; if (report_only) { - const ecl::smspec_node &smspec_node = - ecl_smspec_iget_node_w_params_index(data->smspec, - main_params_index); + const rd::smspec_node &smspec_node = + rd_smspec_iget_node_w_params_index(data->smspec, + main_params_index); double default_value = smspec_node.get_default(); offset += data_file->get_data_report(params_index, index_node.length, @@ -1084,9 +1077,9 @@ static void ecl_sum_data_init_double_vector__(const ecl_sum_data_type *data, data_file->get_data(params_index, index_node.length, &output_data[offset]); else { - const ecl::smspec_node &smspec_node = - ecl_smspec_iget_node_w_params_index(data->smspec, - main_params_index); + const rd::smspec_node &smspec_node = + rd_smspec_iget_node_w_params_index(data->smspec, + main_params_index); for (int i = 0; i < index_node.length; i++) output_data[offset + i] = smspec_node.get_default(); } @@ -1095,32 +1088,32 @@ static void ecl_sum_data_init_double_vector__(const ecl_sum_data_type *data, } } -void ecl_sum_data_init_datetime64_vector(const ecl_sum_data_type *data, - int64_t *output_data, int multiplier) { - for (int i = 0; i < ecl_sum_data_get_length(data); i++) - output_data[i] = ecl_sum_data_iget_sim_time(data, i) * multiplier; +void rd_sum_data_init_datetime64_vector(const rd_sum_data_type *data, + int64_t *output_data, int multiplier) { + for (int i = 0; i < rd_sum_data_get_length(data); i++) + output_data[i] = rd_sum_data_iget_sim_time(data, i) * multiplier; } -void ecl_sum_data_init_double_vector(const ecl_sum_data_type *data, - int params_index, double *output_data) { - ecl_sum_data_init_double_vector__(data, params_index, output_data, false); +void rd_sum_data_init_double_vector(const rd_sum_data_type *data, + int params_index, double *output_data) { + rd_sum_data_init_double_vector__(data, params_index, output_data, false); } -double_vector_type * -ecl_sum_data_alloc_data_vector(const ecl_sum_data_type *data, int params_index, - bool report_only) { +double_vector_type *rd_sum_data_alloc_data_vector(const rd_sum_data_type *data, + int params_index, + bool report_only) { std::vector output_data; if (report_only) - output_data.resize(1 + ecl_sum_data_get_last_report_step(data) - - ecl_sum_data_get_first_report_step(data)); + output_data.resize(1 + rd_sum_data_get_last_report_step(data) - + rd_sum_data_get_first_report_step(data)); else - output_data.resize(ecl_sum_data_get_length(data)); + output_data.resize(rd_sum_data_get_length(data)); - if (params_index >= ecl_smspec_get_params_size(data->smspec)) + if (params_index >= rd_smspec_get_params_size(data->smspec)) throw std::out_of_range("Out of range"); - ecl_sum_data_init_double_vector__(data, params_index, output_data.data(), - report_only); + rd_sum_data_init_double_vector__(data, params_index, output_data.data(), + report_only); double_vector_type *data_vector = double_vector_alloc(output_data.size(), 0); { @@ -1131,19 +1124,19 @@ ecl_sum_data_alloc_data_vector(const ecl_sum_data_type *data, int params_index, return data_vector; } -void ecl_sum_data_init_double_vector_interp( - const ecl_sum_data_type *data, const ecl::smspec_node &smspec_node, +void rd_sum_data_init_double_vector_interp( + const rd_sum_data_type *data, const rd::smspec_node &smspec_node, const time_t_vector_type *time_points, double *output_data) { bool is_rate = smspec_node_is_rate(&smspec_node); int params_index = smspec_node_get_params_index(&smspec_node); - time_t start_time = ecl_sum_data_get_data_start(data); - time_t end_time = ecl_sum_data_get_sim_end(data); + time_t start_time = rd_sum_data_get_data_start(data); + time_t end_time = rd_sum_data_get_sim_end(data); double start_value = 0; double end_value = 0; if (!is_rate) { - start_value = ecl_sum_data_iget_first_value(data, params_index); - end_value = ecl_sum_data_iget_last_value(data, params_index); + start_value = rd_sum_data_iget_first_value(data, params_index); + end_value = rd_sum_data_iget_last_value(data, params_index); } for (int time_index = 0; time_index < time_t_vector_size(time_points); @@ -1159,44 +1152,45 @@ void ecl_sum_data_init_double_vector_interp( else { int time_index1, time_index2; double weight1, weight2; - ecl_sum_data_init_interp_from_sim_time( + rd_sum_data_init_interp_from_sim_time( data, sim_time, &time_index1, &time_index2, &weight1, &weight2); - value = ecl_sum_data_vector_iget(data, sim_time, params_index, - is_rate, time_index1, time_index2, - weight1, weight2); + value = rd_sum_data_vector_iget(data, sim_time, params_index, + is_rate, time_index1, time_index2, + weight1, weight2); } output_data[time_index] = value; } } -void ecl_sum_data_init_double_frame(const ecl_sum_data_type *data, - const ecl_sum_vector_type *keywords, - double *output_data) { - int time_stride = ecl_sum_vector_get_size(keywords); +void rd_sum_data_init_double_frame(const rd_sum_data_type *data, + const rd_sum_vector_type *keywords, + double *output_data) { + int time_stride = rd_sum_vector_get_size(keywords); int key_stride = 1; - for (int time_index = 0; time_index < ecl_sum_data_get_length(data); + for (int time_index = 0; time_index < rd_sum_data_get_length(data); time_index++) { - for (int key_index = 0; key_index < ecl_sum_vector_get_size(keywords); + for (int key_index = 0; key_index < rd_sum_vector_get_size(keywords); key_index++) { int param_index = - ecl_sum_vector_iget_param_index(keywords, key_index); + rd_sum_vector_iget_param_index(keywords, key_index); int data_index = key_index * key_stride + time_index * time_stride; output_data[data_index] = - ecl_sum_data_iget(data, time_index, param_index); + rd_sum_data_iget(data, time_index, param_index); } } } -void ecl_sum_data_init_double_frame_interp( - const ecl_sum_data_type *data, const ecl_sum_vector_type *keywords, - const time_t_vector_type *time_points, double *output_data) { - int num_keywords = ecl_sum_vector_get_size(keywords); +void rd_sum_data_init_double_frame_interp(const rd_sum_data_type *data, + const rd_sum_vector_type *keywords, + const time_t_vector_type *time_points, + double *output_data) { + int num_keywords = rd_sum_vector_get_size(keywords); int time_stride = num_keywords; int key_stride = 1; - time_t start_time = ecl_sum_data_get_data_start(data); - time_t end_time = ecl_sum_data_get_sim_end(data); + time_t start_time = rd_sum_data_get_data_start(data); + time_t end_time = rd_sum_data_get_sim_end(data); for (int time_index = 0; time_index < time_t_vector_size(time_points); time_index++) { @@ -1204,43 +1198,43 @@ void ecl_sum_data_init_double_frame_interp( if (sim_time < start_time) { for (int key_index = 0; key_index < num_keywords; key_index++) { int param_index = - ecl_sum_vector_iget_param_index(keywords, key_index); + rd_sum_vector_iget_param_index(keywords, key_index); int data_index = key_index * key_stride + time_index * time_stride; - bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + bool is_rate = rd_sum_vector_iget_is_rate(keywords, key_index); if (is_rate) output_data[data_index] = 0; else output_data[data_index] = - ecl_sum_data_iget_first_value(data, param_index); + rd_sum_data_iget_first_value(data, param_index); } } else if (sim_time > end_time) { for (int key_index = 0; key_index < num_keywords; key_index++) { int param_index = - ecl_sum_vector_iget_param_index(keywords, key_index); + rd_sum_vector_iget_param_index(keywords, key_index); int data_index = key_index * key_stride + time_index * time_stride; - bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + bool is_rate = rd_sum_vector_iget_is_rate(keywords, key_index); if (is_rate) output_data[data_index] = 0; else output_data[data_index] = - ecl_sum_data_iget_last_value(data, param_index); + rd_sum_data_iget_last_value(data, param_index); } } else { double weight1, weight2; int time_index1, time_index2; - ecl_sum_data_init_interp_from_sim_time( + rd_sum_data_init_interp_from_sim_time( data, sim_time, &time_index1, &time_index2, &weight1, &weight2); for (int key_index = 0; key_index < num_keywords; key_index++) { int param_index = - ecl_sum_vector_iget_param_index(keywords, key_index); + rd_sum_vector_iget_param_index(keywords, key_index); int data_index = key_index * key_stride + time_index * time_stride; - bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); - double value = ecl_sum_data_vector_iget( + bool is_rate = rd_sum_vector_iget_is_rate(keywords, key_index); + double value = rd_sum_data_vector_iget( data, sim_time, param_index, is_rate, time_index1, time_index2, weight1, weight2); output_data[data_index] = value; @@ -1251,17 +1245,17 @@ void ecl_sum_data_init_double_frame_interp( /** This function will return the total number of ministeps in the - current ecl_sum_data instance; but observe that actual series of + current rd_sum_data instance; but observe that actual series of ministeps can have non-zero offset and also "holes" in the series. */ -int ecl_sum_data_get_length(const ecl_sum_data_type *data) { +int rd_sum_data_get_length(const rd_sum_data_type *data) { return data->index.length(); } -static bool ecl_sum_data_report_step_equal__(const ecl_sum_data_type *data1, - const ecl_sum_data_type *data2, - bool strict) { +static bool rd_sum_data_report_step_equal__(const rd_sum_data_type *data1, + const rd_sum_data_type *data2, + bool strict) { if (data1->data_files.size() != data2->data_files.size()) return false; @@ -1276,28 +1270,28 @@ static bool ecl_sum_data_report_step_equal__(const ecl_sum_data_type *data1, return true; } -bool ecl_sum_data_report_step_compatible(const ecl_sum_data_type *data1, - const ecl_sum_data_type *data2) { - return ecl_sum_data_report_step_equal__(data1, data2, false); +bool rd_sum_data_report_step_compatible(const rd_sum_data_type *data1, + const rd_sum_data_type *data2) { + return rd_sum_data_report_step_equal__(data1, data2, false); } -bool ecl_sum_data_report_step_equal(const ecl_sum_data_type *data1, - const ecl_sum_data_type *data2) { - return ecl_sum_data_report_step_equal__(data1, data2, true); +bool rd_sum_data_report_step_equal(const rd_sum_data_type *data1, + const rd_sum_data_type *data2) { + return rd_sum_data_report_step_equal__(data1, data2, true); } -double ecl_sum_data_iget_last_value(const ecl_sum_data_type *data, - int param_index) { - return ecl_sum_data_iget(data, ecl_sum_data_get_length(data) - 1, - param_index); +double rd_sum_data_iget_last_value(const rd_sum_data_type *data, + int param_index) { + return rd_sum_data_iget(data, rd_sum_data_get_length(data) - 1, + param_index); } -double ecl_sum_data_get_last_value(const ecl_sum_data_type *data, - int param_index) { - return ecl_sum_data_iget_last_value(data, param_index); +double rd_sum_data_get_last_value(const rd_sum_data_type *data, + int param_index) { + return rd_sum_data_iget_last_value(data, param_index); } -double ecl_sum_data_iget_first_value(const ecl_sum_data_type *data, - int param_index) { - return ecl_sum_data_iget(data, 0, param_index); +double rd_sum_data_iget_first_value(const rd_sum_data_type *data, + int param_index) { + return rd_sum_data_iget(data, 0, param_index); } diff --git a/lib/resdata/rd_sum_file_data.cpp b/lib/resdata/rd_sum_file_data.cpp index 5f0e03065d..d911ed596a 100644 --- a/lib/resdata/rd_sum_file_data.cpp +++ b/lib/resdata/rd_sum_file_data.cpp @@ -3,23 +3,23 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "detail/ecl/ecl_sum_file_data.hpp" -#include "detail/ecl/ecl_unsmry_loader.hpp" +#include "detail/resdata/rd_sum_file_data.hpp" +#include "detail/resdata/rd_unsmry_loader.hpp" /* - This file implements the type ecl_sum_data_type. The data structure + This file implements the type rd_sum_data_type. The data structure is involved with holding all the actual summary data (i.e. the PARAMS vectors in ECLIPSE speak), in addition the time-information with MINISTEPS / REPORT_STEPS and so on is implemented here. This file has no information about how to index into the PARAMS vector, i.e. at which location can the WWCT for well P6 be found, - that is the responsibility of the ecl_smspec_type. + that is the responsibility of the rd_smspec_type. The time direction in this system is implemented in terms of ministeps. There are some query / convert functions based on report @@ -142,13 +142,13 @@ of 'X' on the timeline, i.e. in the middle of ministep M3. If we are interested in the rate at this time the function: - ecl_sum_data_get_from_sim_time() + rd_sum_data_get_from_sim_time() will just return the M3 value, whereas if you are interested in e.g. pressure at this time the function will return a weighted average of the M2 and M3 values. Whether a variable in question is interpreted as a 'rate' is effectively determined by the - ecl_smspec_set_rate_var() function in ecl_smspec.c. + rd_smspec_set_rate_var() function in rd_smspec.c. @@ -163,32 +163,32 @@ Partly due to EnKF heritage the MINISTEP nr has been the main method to access the time dimension of the data, i.e. all the - functions like ecl_sum_get_general_var() expect the time direction + functions like rd_sum_get_general_var() expect the time direction to be given as a ministep; however it is also possible to get the data by giving an internal (not that internal ...) index. In - ecl_sum_data.c the latter functions have _iget(): + rd_sum_data.c the latter functions have _iget(): - ecl_sum_data_get_xxx : Expects the time direction given as a ministep_nr. - ecl_sum_data_iget_xxx: Expects the time direction given as an internal index. + rd_sum_data_get_xxx : Expects the time direction given as a ministep_nr. + rd_sum_data_iget_xxx: Expects the time direction given as an internal index. */ -namespace ecl { +namespace rd { -ecl_sum_file_data::ecl_sum_file_data(const ecl_smspec_type *smspec) - : ecl_smspec(smspec), data(vector_alloc_new()) {} +rd_sum_file_data::rd_sum_file_data(const rd_smspec_type *smspec) + : rd_smspec(smspec), data(vector_alloc_new()) {} -ecl_sum_file_data::~ecl_sum_file_data() { vector_free(data); } +rd_sum_file_data::~rd_sum_file_data() { vector_free(data); } -int ecl_sum_file_data::length() const { +int rd_sum_file_data::length() const { if (this->loader) return this->loader->length(); else return this->index.size(); } -int ecl_sum_file_data::length_before(time_t end_time) const { +int rd_sum_file_data::length_before(time_t end_time) const { int offset = 0; while (true) { time_t itime = this->iget_sim_time(offset); @@ -201,7 +201,7 @@ int ecl_sum_file_data::length_before(time_t end_time) const { } } -int ecl_sum_file_data::report_before(time_t end_time) const { +int rd_sum_file_data::report_before(time_t end_time) const { if (end_time < this->first_report()) throw std::invalid_argument("time argument before first report step"); @@ -219,30 +219,30 @@ int ecl_sum_file_data::report_before(time_t end_time) const { } } -int ecl_sum_file_data::first_report() const { +int rd_sum_file_data::first_report() const { const auto &node = this->index[0]; return node.report_step; } -int ecl_sum_file_data::last_report() const { +int rd_sum_file_data::last_report() const { const auto &node = this->index.back(); return node.report_step; } -time_t ecl_sum_file_data::get_data_start() const { +time_t rd_sum_file_data::get_data_start() const { const auto &node = this->index[0]; return node.sim_time; } -time_t ecl_sum_file_data::get_sim_end() const { +time_t rd_sum_file_data::get_sim_end() const { if (this->index.size() == 0) throw std::out_of_range( - "ecl_sum_file_data::get_sim_end(): index size is 0"); + "rd_sum_file_data::get_sim_end(): index size is 0"); const auto &node = this->index.back(); return node.sim_time; } -time_t ecl_sum_file_data::iget_sim_time(int time_index) const { +time_t rd_sum_file_data::iget_sim_time(int time_index) const { const auto &node = this->index[time_index]; return node.sim_time; } @@ -250,45 +250,45 @@ time_t ecl_sum_file_data::iget_sim_time(int time_index) const { /* Will return the length of the simulation in whatever units were used in input. */ -double ecl_sum_file_data::get_sim_length() const { +double rd_sum_file_data::get_sim_length() const { const auto &node = this->index.back(); - return node.sim_seconds / ecl_smspec_get_time_seconds(this->ecl_smspec); + return node.sim_seconds / rd_smspec_get_time_seconds(this->rd_smspec); } -double ecl_sum_file_data::iget(int time_index, int params_index) const { +double rd_sum_file_data::iget(int time_index, int params_index) const { if (this->loader) return this->loader->iget(time_index, params_index); else { - const ecl_sum_tstep_type *ministep_data = iget_ministep(time_index); - return ecl_sum_tstep_iget(ministep_data, params_index); + const rd_sum_tstep_type *ministep_data = iget_ministep(time_index); + return rd_sum_tstep_iget(ministep_data, params_index); } } -void ecl_sum_file_data::append_tstep(ecl_sum_tstep_type *tstep) { +void rd_sum_file_data::append_tstep(rd_sum_tstep_type *tstep) { /* Here the tstep is just appended naively, the vector will be sorted by ministep_nr before the data instance is returned. */ - vector_append_owned_ref(data, tstep, ecl_sum_tstep_free__); + vector_append_owned_ref(data, tstep, rd_sum_tstep_free__); } /* This function is meant to be called in write mode; and will create a new and empty tstep which is appended to the current data. The tstep will also be returned, so the calling scope can call - ecl_sum_tstep_iset() to set elements in the tstep. + rd_sum_tstep_iset() to set elements in the tstep. */ -ecl_sum_tstep_type *ecl_sum_file_data::add_new_tstep(int report_step, - double sim_seconds) { +rd_sum_tstep_type *rd_sum_file_data::add_new_tstep(int report_step, + double sim_seconds) { int ministep_nr = vector_get_size(data); - ecl_sum_tstep_type *tstep = ecl_sum_tstep_alloc_new( - report_step, ministep_nr, sim_seconds, ecl_smspec); - ecl_sum_tstep_type *prev_tstep = NULL; + rd_sum_tstep_type *tstep = rd_sum_tstep_alloc_new(report_step, ministep_nr, + sim_seconds, rd_smspec); + rd_sum_tstep_type *prev_tstep = NULL; if (vector_get_size(data) > 0) - prev_tstep = (ecl_sum_tstep_type *)vector_get_last(data); + prev_tstep = (rd_sum_tstep_type *)vector_get_last(data); append_tstep(tstep); @@ -296,21 +296,20 @@ ecl_sum_tstep_type *ecl_sum_file_data::add_new_tstep(int report_step, /* In the simple case that we just add another timestep to the currently active report_step, we do a limited update of the - index, otherwise we call ecl_sum_data_build_index() to get a + index, otherwise we call rd_sum_data_build_index() to get a full recalculation of the index. */ if (!prev_tstep) goto exit; - if (ecl_sum_tstep_get_report(prev_tstep) != ecl_sum_tstep_get_report(tstep)) + if (rd_sum_tstep_get_report(prev_tstep) != rd_sum_tstep_get_report(tstep)) goto exit; - if (ecl_sum_tstep_get_sim_days(prev_tstep) >= - ecl_sum_tstep_get_sim_days(tstep)) + if (rd_sum_tstep_get_sim_days(prev_tstep) >= + rd_sum_tstep_get_sim_days(tstep)) goto exit; - this->index.add(ecl_sum_tstep_get_sim_time(tstep), sim_seconds, - report_step); + this->index.add(rd_sum_tstep_get_sim_time(tstep), sim_seconds, report_step); rebuild_index = false; exit: @@ -320,26 +319,26 @@ ecl_sum_tstep_type *ecl_sum_file_data::add_new_tstep(int report_step, return tstep; } -ecl_sum_tstep_type *ecl_sum_file_data::iget_ministep(int internal_index) const { - return (ecl_sum_tstep_type *)vector_iget(data, internal_index); +rd_sum_tstep_type *rd_sum_file_data::iget_ministep(int internal_index) const { + return (rd_sum_tstep_type *)vector_iget(data, internal_index); } -double ecl_sum_file_data::iget_sim_days(int time_index) const { +double rd_sum_file_data::iget_sim_days(int time_index) const { const auto &node = this->index[time_index]; return node.sim_seconds / 86400; } -double ecl_sum_file_data::iget_sim_seconds(int time_index) const { +double rd_sum_file_data::iget_sim_seconds(int time_index) const { const auto &node = this->index[time_index]; return node.sim_seconds; } static int cmp_ministep(const void *arg1, const void *arg2) { - const ecl_sum_tstep_type *ministep1 = ecl_sum_tstep_safe_cast_const(arg1); - const ecl_sum_tstep_type *ministep2 = ecl_sum_tstep_safe_cast_const(arg2); + const rd_sum_tstep_type *ministep1 = rd_sum_tstep_safe_cast_const(arg1); + const rd_sum_tstep_type *ministep2 = rd_sum_tstep_safe_cast_const(arg2); - time_t time1 = ecl_sum_tstep_get_sim_time(ministep1); - time_t time2 = ecl_sum_tstep_get_sim_time(ministep2); + time_t time1 = rd_sum_tstep_get_sim_time(ministep1); + time_t time2 = rd_sum_tstep_get_sim_time(ministep2); if (time1 < time2) return -1; @@ -349,11 +348,11 @@ static int cmp_ministep(const void *arg1, const void *arg2) { return 1; } -void ecl_sum_file_data::build_index() { +void rd_sum_file_data::build_index() { this->index.clear(); if (this->loader) { - int offset = ecl_smspec_get_first_step(this->ecl_smspec) - 1; + int offset = rd_smspec_get_first_step(this->rd_smspec) - 1; std::vector report_steps = this->loader->report_steps(offset); std::vector sim_time = this->loader->sim_time(); std::vector sim_seconds = this->loader->sim_seconds(); @@ -365,20 +364,20 @@ void ecl_sum_file_data::build_index() { vector_sort(data, cmp_ministep); for (int internal_index = 0; internal_index < vector_get_size(data); internal_index++) { - const ecl_sum_tstep_type *ministep = iget_ministep(internal_index); - this->index.add(ecl_sum_tstep_get_sim_time(ministep), - ecl_sum_tstep_get_sim_seconds(ministep), - ecl_sum_tstep_get_report(ministep)); + const rd_sum_tstep_type *ministep = iget_ministep(internal_index); + this->index.add(rd_sum_tstep_get_sim_time(ministep), + rd_sum_tstep_get_sim_seconds(ministep), + rd_sum_tstep_get_report(ministep)); } } } -void ecl_sum_file_data::get_time(int length, time_t *data) { +void rd_sum_file_data::get_time(int length, time_t *data) { for (int time_index = 0; time_index < length; time_index++) data[time_index] = this->iget_sim_time(time_index); } -int ecl_sum_file_data::get_time_report(int end_index, time_t *data) { +int rd_sum_file_data::get_time_report(int end_index, time_t *data) { int offset = 0; for (int report_step = this->first_report(); @@ -395,7 +394,7 @@ int ecl_sum_file_data::get_time_report(int end_index, time_t *data) { return offset; } -void ecl_sum_file_data::get_data(int params_index, int length, double *data) { +void rd_sum_file_data::get_data(int params_index, int length, double *data) { if (this->loader) { const auto tmp_data = loader->get_vector(params_index); memcpy(data, tmp_data.data(), length * sizeof data); @@ -405,8 +404,8 @@ void ecl_sum_file_data::get_data(int params_index, int length, double *data) { } } -int ecl_sum_file_data::get_data_report(int params_index, int end_index, - double *data, double default_value) { +int rd_sum_file_data::get_data_report(int params_index, int end_index, + double *data, double default_value) { int offset = 0; for (int report_step = this->first_report(); @@ -425,35 +424,35 @@ int ecl_sum_file_data::get_data_report(int params_index, int end_index, return offset; } -bool ecl_sum_file_data::has_report(int report_step) const { +bool rd_sum_file_data::has_report(int report_step) const { return this->index.has_report(report_step); } -std::pair ecl_sum_file_data::report_range(int report_step) const { +std::pair rd_sum_file_data::report_range(int report_step) const { return this->index.report_range(report_step); } -void ecl_sum_file_data::fwrite_report(int report_step, - fortio_type *fortio) const { +void rd_sum_file_data::fwrite_report(int report_step, + fortio_type *fortio) const { { - ecl_kw_type *seqhdr_kw = ecl_kw_alloc(SEQHDR_KW, SEQHDR_SIZE, ECL_INT); - ecl_kw_iset_int(seqhdr_kw, 0, 0); - ecl_kw_fwrite(seqhdr_kw, fortio); - ecl_kw_free(seqhdr_kw); + rd_kw_type *seqhdr_kw = rd_kw_alloc(SEQHDR_KW, SEQHDR_SIZE, RD_INT); + rd_kw_iset_int(seqhdr_kw, 0, 0); + rd_kw_fwrite(seqhdr_kw, fortio); + rd_kw_free(seqhdr_kw); } { auto range = this->report_range(report_step); for (int index = range.first; index <= range.second; index++) { - const ecl_sum_tstep_type *tstep = iget_ministep(index); - //ecl_sum_tstep_fwrite( tstep , ecl_smspec_get_index_map( ecl_smspec ) , fortio ); - ecl_sum_tstep_fwrite(tstep, ecl_smspec_get_index_map(ecl_smspec), - ecl_smspec_num_nodes(ecl_smspec), fortio); + const rd_sum_tstep_type *tstep = iget_ministep(index); + //rd_sum_tstep_fwrite( tstep , rd_smspec_get_index_map( rd_smspec ) , fortio ); + rd_sum_tstep_fwrite(tstep, rd_smspec_get_index_map(rd_smspec), + rd_smspec_num_nodes(rd_smspec), fortio); } } } -void ecl_sum_file_data::fwrite_unified(fortio_type *fortio) const { +void rd_sum_file_data::fwrite_unified(fortio_type *fortio) const { if (this->length() == 0) return; @@ -464,18 +463,18 @@ void ecl_sum_file_data::fwrite_unified(fortio_type *fortio) const { } } -void ecl_sum_file_data::fwrite_multiple(const char *ecl_case, - bool fmt_case) const { +void rd_sum_file_data::fwrite_multiple(const char *rd_case, + bool fmt_case) const { if (this->length() == 0) return; for (int report_step = this->first_report(); report_step <= this->last_report(); report_step++) { if (this->has_report(report_step)) { - char *filename = ecl_util_alloc_filename( - NULL, ecl_case, ECL_SUMMARY_FILE, fmt_case, report_step); + char *filename = rd_alloc_filename(NULL, rd_case, RD_SUMMARY_FILE, + fmt_case, report_step); fortio_type *fortio = - fortio_open_writer(filename, fmt_case, ECL_ENDIAN_FLIP); + fortio_open_writer(filename, fmt_case, RD_ENDIAN_FLIP); fwrite_report(report_step, fortio); @@ -485,22 +484,22 @@ void ecl_sum_file_data::fwrite_multiple(const char *ecl_case, } } -bool ecl_sum_file_data::can_write() const { +bool rd_sum_file_data::can_write() const { if (this->loader) return false; return true; } -double ecl_sum_file_data::get_days_start() const { +double rd_sum_file_data::get_days_start() const { const auto &node = this->index[0]; return node.sim_seconds * 86400; } -bool ecl_sum_file_data::check_file(ecl_file_type *ecl_file) { - return ecl_file_has_kw(ecl_file, PARAMS_KW) && - (ecl_file_get_num_named_kw(ecl_file, PARAMS_KW) == - ecl_file_get_num_named_kw(ecl_file, MINISTEP_KW)); +bool rd_sum_file_data::check_file(rd_file_type *rd_file) { + return rd_file_has_kw(rd_file, PARAMS_KW) && + (rd_file_get_num_named_kw(rd_file, PARAMS_KW) == + rd_file_get_num_named_kw(rd_file, MINISTEP_KW)); } /** @@ -519,33 +518,33 @@ bool ecl_sum_file_data::check_file(ecl_file_type *ecl_file) { Now - if ECLIPSE goes down in flames during step 2 a malformed summary file will be left around, to handle this situation - reasonably gracefully we check that the ecl_file instance has at + reasonably gracefully we check that the rd_file instance has at least one "PARAMS" keyword. - One ecl_file corresponds to one report_step (limited by SEQHDR); in + One rd_file corresponds to one report_step (limited by SEQHDR); in the case of non unfied summary files these objects correspond to one BASE.Annnn or BASE.Snnnn file, in the case of unified files the calling routine will read the unified summary file partly. */ -void ecl_sum_file_data::add_ecl_file(int report_step, - const ecl_file_view_type *summary_view) { +void rd_sum_file_data::add_rd_file(int report_step, + const rd_file_view_type *summary_view) { - int num_ministep = ecl_file_view_get_num_named_kw(summary_view, PARAMS_KW); + int num_ministep = rd_file_view_get_num_named_kw(summary_view, PARAMS_KW); if (num_ministep > 0) { int ikw; for (ikw = 0; ikw < num_ministep; ikw++) { - ecl_kw_type *ministep_kw = - ecl_file_view_iget_named_kw(summary_view, MINISTEP_KW, ikw); - ecl_kw_type *params_kw = - ecl_file_view_iget_named_kw(summary_view, PARAMS_KW, ikw); + rd_kw_type *ministep_kw = + rd_file_view_iget_named_kw(summary_view, MINISTEP_KW, ikw); + rd_kw_type *params_kw = + rd_file_view_iget_named_kw(summary_view, PARAMS_KW, ikw); { - int ministep_nr = ecl_kw_iget_int(ministep_kw, 0); - ecl_sum_tstep_type *tstep = ecl_sum_tstep_alloc_from_file( + int ministep_nr = rd_kw_iget_int(ministep_kw, 0); + rd_sum_tstep_type *tstep = rd_sum_tstep_alloc_from_file( report_step, ministep_nr, params_kw, - ecl_file_view_get_src_file(summary_view), this->ecl_smspec); + rd_file_view_get_src_file(summary_view), this->rd_smspec); if (tstep) append_tstep(tstep); @@ -554,43 +553,43 @@ void ecl_sum_file_data::add_ecl_file(int report_step, } } -bool ecl_sum_file_data::fread(const stringlist_type *filelist, bool lazy_load, - int file_options) { +bool rd_sum_file_data::fread(const stringlist_type *filelist, bool lazy_load, + int file_options) { if (stringlist_get_size(filelist) == 0) return false; - ecl_file_enum file_type = - ecl_util_get_file_type(stringlist_iget(filelist, 0), NULL, NULL); - if ((stringlist_get_size(filelist) > 1) && (file_type != ECL_SUMMARY_FILE)) + rd_file_enum file_type = + rd_get_file_type(stringlist_iget(filelist, 0), NULL, NULL); + if ((stringlist_get_size(filelist) > 1) && (file_type != RD_SUMMARY_FILE)) util_abort("%s: internal error - when calling with more than one file " "- you can not supply a unified file - come on?! \n", __func__); - if (file_type == ECL_SUMMARY_FILE) { + if (file_type == RD_SUMMARY_FILE) { /* Not unified. */ for (int filenr = 0; filenr < stringlist_get_size(filelist); filenr++) { const char *data_file = stringlist_iget(filelist, filenr); - ecl_file_enum file_type; + rd_file_enum file_type; int report_step; - file_type = ecl_util_get_file_type(data_file, NULL, &report_step); - if (file_type != ECL_SUMMARY_FILE) + file_type = rd_get_file_type(data_file, NULL, &report_step); + if (file_type != RD_SUMMARY_FILE) util_abort("%s: file:%s has wrong type \n", __func__, data_file); { - ecl_file_type *ecl_file = ecl_file_open(data_file, 0); - if (ecl_file && check_file(ecl_file)) { - this->add_ecl_file(report_step, - ecl_file_get_global_view(ecl_file)); - ecl_file_close(ecl_file); + rd_file_type *rd_file = rd_file_open(data_file, 0); + if (rd_file && check_file(rd_file)) { + this->add_rd_file(report_step, + rd_file_get_global_view(rd_file)); + rd_file_close(rd_file); } } } - } else if (file_type == ECL_UNIFIED_SUMMARY_FILE) { + } else if (file_type == RD_UNIFIED_SUMMARY_FILE) { if (lazy_load) { try { this->loader.reset(new unsmry_loader( - this->ecl_smspec, stringlist_iget(filelist, 0), + this->rd_smspec, stringlist_iget(filelist, 0), file_options)); } catch (const std::bad_alloc &e) { return false; @@ -599,30 +598,30 @@ bool ecl_sum_file_data::fread(const stringlist_type *filelist, bool lazy_load, // Is this correct for a restarted chain of UNSMRY files? Looks like the // report step sequence will be restarted? - ecl_file_type *ecl_file = - ecl_file_open(stringlist_iget(filelist, 0), 0); - if (ecl_file && check_file(ecl_file)) { + rd_file_type *rd_file = + rd_file_open(stringlist_iget(filelist, 0), 0); + if (rd_file && check_file(rd_file)) { int first_report_step = - ecl_smspec_get_first_step(this->ecl_smspec); + rd_smspec_get_first_step(this->rd_smspec); int block_index = 0; while (true) { /* Observe that there is a number discrepancy between ECLIPSE - and the ecl_file_select_smryblock() function. ECLIPSE + and the rd_file_select_smryblock() function. ECLIPSE starts counting report steps at 1; whereas the first SEQHDR block in the unified summary file is block zero (in ert counting). */ - ecl_file_view_type *summary_view = - ecl_file_get_summary_view(ecl_file, block_index); + rd_file_view_type *summary_view = + rd_file_get_summary_view(rd_file, block_index); if (summary_view) { - this->add_ecl_file(block_index + first_report_step, - summary_view); + this->add_rd_file(block_index + first_report_step, + summary_view); block_index++; } else break; } - ecl_file_close(ecl_file); + rd_file_close(rd_file); } } } @@ -631,12 +630,12 @@ bool ecl_sum_file_data::fread(const stringlist_type *filelist, bool lazy_load, return (length() > 0); } -const ecl_smspec_type *ecl_sum_file_data::smspec() const { - return this->ecl_smspec; +const rd_smspec_type *rd_sum_file_data::smspec() const { + return this->rd_smspec; } -bool ecl_sum_file_data::report_step_equal(const ecl_sum_file_data &other, - bool strict) const { +bool rd_sum_file_data::report_step_equal(const rd_sum_file_data &other, + bool strict) const { if (strict && this->first_report() != other.first_report()) return false; @@ -669,7 +668,7 @@ bool ecl_sum_file_data::report_step_equal(const ecl_sum_file_data &other, return true; } -int ecl_sum_file_data::report_step_from_days(double sim_days) const { +int rd_sum_file_data::report_step_from_days(double sim_days) const { int report_step = this->first_report(); double sim_seconds = sim_days * 86400; while (true) { @@ -688,7 +687,7 @@ int ecl_sum_file_data::report_step_from_days(double sim_days) const { } } -int ecl_sum_file_data::report_step_from_time(time_t sim_time) const { +int rd_sum_file_data::report_step_from_time(time_t sim_time) const { int report_step = this->first_report(); while (true) { const auto &range = this->index.report_range(report_step); @@ -704,9 +703,9 @@ int ecl_sum_file_data::report_step_from_time(time_t sim_time) const { } } -int ecl_sum_file_data::iget_report(int time_index) const { +int rd_sum_file_data::iget_report(int time_index) const { const auto &index_node = this->index[time_index]; return index_node.report_step; } -} // namespace ecl +} // namespace rd diff --git a/lib/resdata/rd_sum_index.cpp b/lib/resdata/rd_sum_index.cpp index c0c0cc4cfa..c14b2af27d 100644 --- a/lib/resdata/rd_sum_index.cpp +++ b/lib/resdata/rd_sum_index.cpp @@ -1,15 +1,15 @@ -#include +#include /* This file contains all the internalized information from parsing a - SMSPEC file. In most cases the ecl_sum object will contain a - ecl_sum_index_type instance, and the end-user will not have direct - interaction with the ecl_sum_index_type - but for instance when + SMSPEC file. In most cases the rd_sum object will contain a + rd_sum_index_type instance, and the end-user will not have direct + interaction with the rd_sum_index_type - but for instance when working with an ensemble of identical summary results one can use a - shared ecl_sum_index instance. + shared rd_sum_index instance. */ -struct ecl_sum_index_type { +struct rd_sum_index_type { hash_type *well_var_index; /* Indexes for all well variables. */ hash_type *well_completion_var_index; /* Indexes for completion indexes .*/ hash_type *group_var_index; /* Indexes for group variables. */ diff --git a/lib/resdata/rd_sum_tstep.cpp b/lib/resdata/rd_sum_tstep.cpp index 3d2fc659bd..58584a250a 100644 --- a/lib/resdata/rd_sum_tstep.cpp +++ b/lib/resdata/rd_sum_tstep.cpp @@ -6,60 +6,60 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#define ECL_SUM_TSTEP_ID 88631 +#define RD_SUM_TSTEP_ID 88631 /* - This file implements the ecl_sum_tstep datatype which contains the + This file implements the rd_sum_tstep datatype which contains the summary information for all summary vectors at one instant in time. If we view the summary data as this: -Header direction: ecl_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25 +Header direction: rd_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25 -------------------------------------------- - /|\ 0.00 0.00 0.00 256.00 <-- One timestep ecl_sum_tstep + /|\ 0.00 0.00 0.00 256.00 <-- One timestep rd_sum_tstep | 10.00 0.56 10.00 255.00 - Time direction: ecl_sum_data 20.00 0.61 18.70 253.00 + Time direction: rd_sum_data 20.00 0.61 18.70 253.00 | 30.00 0.63 21.20 251.00 | ... \|/ 90.00 0.80 39.70 244.00 -------------------------------------------- - The ecl_sum_tstep structure corresponds to one 'horizontal line' in + The rd_sum_tstep structure corresponds to one 'horizontal line' in the summary data. These timesteps correspond exactly to the simulators timesteps, i.e. when convergence is poor they are closely spaced. In the ECLIPSE summary files these time steps are called "MINISTEPS" - and - that term is also used some places in the ecl_sum_xxx codebase. + that term is also used some places in the rd_sum_xxx codebase. */ -struct ecl_sum_tstep_struct { +struct rd_sum_tstep_struct { UTIL_TYPE_ID_DECLARATION; std::vector - data; /* A memcpy copy of the PARAMS vector in ecl_kw instance - the raw data. */ + data; /* A memcpy copy of the PARAMS vector in rd_kw instance - the raw data. */ time_t sim_time; /* The true time (i.e. 20.th of october 2010) of corresponding to this timestep. */ int ministep; /* The ECLIPSE internal time-step number; one ministep per numerical timestep. */ int report_step; /* The report step this time-step is part of - in general there can be many timestep for each report step. */ double sim_seconds; /* Accumulated simulation time up to this ministep. */ int internal_index; /* Used for lookups of the next / previous ministep based on an existing ministep. */ - const ecl_smspec_type * + const rd_smspec_type * smspec; /* The smespec header information for this tstep - must be compatible. */ }; -ecl_sum_tstep_type * -ecl_sum_tstep_alloc_remap_copy(const ecl_sum_tstep_type *src, - const ecl_smspec_type *new_smspec, - float default_value, const int *params_map) { - int params_size = ecl_smspec_get_params_size(new_smspec); - ecl_sum_tstep_type *target = new ecl_sum_tstep_type(); - UTIL_TYPE_ID_INIT(target, ECL_SUM_TSTEP_ID); +rd_sum_tstep_type * +rd_sum_tstep_alloc_remap_copy(const rd_sum_tstep_type *src, + const rd_smspec_type *new_smspec, + float default_value, const int *params_map) { + int params_size = rd_smspec_get_params_size(new_smspec); + rd_sum_tstep_type *target = new rd_sum_tstep_type(); + UTIL_TYPE_ID_INIT(target, RD_SUM_TSTEP_ID); target->report_step = src->report_step; target->ministep = src->ministep; @@ -75,9 +75,9 @@ ecl_sum_tstep_alloc_remap_copy(const ecl_sum_tstep_type *src, return target; } -ecl_sum_tstep_type *ecl_sum_tstep_alloc_copy(const ecl_sum_tstep_type *src) { - ecl_sum_tstep_type *target = new ecl_sum_tstep_type(); - UTIL_TYPE_ID_INIT(target, ECL_SUM_TSTEP_ID); +rd_sum_tstep_type *rd_sum_tstep_alloc_copy(const rd_sum_tstep_type *src) { + rd_sum_tstep_type *target = new rd_sum_tstep_type(); + UTIL_TYPE_ID_INIT(target, RD_SUM_TSTEP_ID); target->smspec = src->smspec; target->report_step = src->report_step; target->ministep = src->ministep; @@ -85,30 +85,30 @@ ecl_sum_tstep_type *ecl_sum_tstep_alloc_copy(const ecl_sum_tstep_type *src) { return target; } -static ecl_sum_tstep_type *ecl_sum_tstep_alloc(int report_step, int ministep_nr, - const ecl_smspec_type *smspec) { - ecl_sum_tstep_type *tstep = new ecl_sum_tstep_type(); - UTIL_TYPE_ID_INIT(tstep, ECL_SUM_TSTEP_ID); +static rd_sum_tstep_type *rd_sum_tstep_alloc(int report_step, int ministep_nr, + const rd_smspec_type *smspec) { + rd_sum_tstep_type *tstep = new rd_sum_tstep_type(); + UTIL_TYPE_ID_INIT(tstep, RD_SUM_TSTEP_ID); tstep->smspec = smspec; tstep->report_step = report_step; tstep->ministep = ministep_nr; - tstep->data.resize(ecl_smspec_get_params_size(smspec)); + tstep->data.resize(rd_smspec_get_params_size(smspec)); return tstep; } -UTIL_SAFE_CAST_FUNCTION(ecl_sum_tstep, ECL_SUM_TSTEP_ID) -UTIL_SAFE_CAST_FUNCTION_CONST(ecl_sum_tstep, ECL_SUM_TSTEP_ID) +UTIL_SAFE_CAST_FUNCTION(rd_sum_tstep, RD_SUM_TSTEP_ID) +UTIL_SAFE_CAST_FUNCTION_CONST(rd_sum_tstep, RD_SUM_TSTEP_ID) -void ecl_sum_tstep_free(ecl_sum_tstep_type *ministep) { delete ministep; } +void rd_sum_tstep_free(rd_sum_tstep_type *ministep) { delete ministep; } -void ecl_sum_tstep_free__(void *__ministep) { - ecl_sum_tstep_type *ministep = ecl_sum_tstep_safe_cast(__ministep); - ecl_sum_tstep_free(ministep); +void rd_sum_tstep_free__(void *__ministep) { + rd_sum_tstep_type *ministep = rd_sum_tstep_safe_cast(__ministep); + rd_sum_tstep_free(ministep); } /** This function sets the internal time representation in the - ecl_sum_tstep. The treatment of time is a bit weird; on the one + rd_sum_tstep. The treatment of time is a bit weird; on the one hand the time elements in the summary data are just like any other element like e.g. the FOPT or GGPR:NAME - on the other hand the time information is strictly required and the summary file will @@ -124,44 +124,44 @@ void ecl_sum_tstep_free__(void *__ministep) { DAY,MONTH,YEAR: The data vector will contain the true date of the tstep. - The ecl_sum_tstep class can utilize both types of information, but + The rd_sum_tstep class can utilize both types of information, but will select the DAYS variety if both are present. */ -static void ecl_sum_tstep_set_time_info_from_seconds(ecl_sum_tstep_type *tstep, - time_t sim_start, - double sim_seconds) { +static void rd_sum_tstep_set_time_info_from_seconds(rd_sum_tstep_type *tstep, + time_t sim_start, + double sim_seconds) { tstep->sim_seconds = sim_seconds; tstep->sim_time = sim_start; util_inplace_forward_seconds_utc(&tstep->sim_time, tstep->sim_seconds); } -static void ecl_sum_tstep_set_time_info_from_date(ecl_sum_tstep_type *tstep, - time_t sim_start, - time_t sim_time) { +static void rd_sum_tstep_set_time_info_from_date(rd_sum_tstep_type *tstep, + time_t sim_start, + time_t sim_time) { tstep->sim_time = sim_time; tstep->sim_seconds = util_difftime_seconds(sim_start, tstep->sim_time); } -static void ecl_sum_tstep_set_time_info(ecl_sum_tstep_type *tstep, - const ecl_smspec_type *smspec) { - int date_day_index = ecl_smspec_get_date_day_index(smspec); - int date_month_index = ecl_smspec_get_date_month_index(smspec); - int date_year_index = ecl_smspec_get_date_year_index(smspec); - int sim_time_index = ecl_smspec_get_time_index(smspec); - time_t sim_start = ecl_smspec_get_start_time(smspec); +static void rd_sum_tstep_set_time_info(rd_sum_tstep_type *tstep, + const rd_smspec_type *smspec) { + int date_day_index = rd_smspec_get_date_day_index(smspec); + int date_month_index = rd_smspec_get_date_month_index(smspec); + int date_year_index = rd_smspec_get_date_year_index(smspec); + int sim_time_index = rd_smspec_get_time_index(smspec); + time_t sim_start = rd_smspec_get_start_time(smspec); if (sim_time_index >= 0) { double sim_time = tstep->data[sim_time_index]; - double sim_seconds = sim_time * ecl_smspec_get_time_seconds(smspec); - ecl_sum_tstep_set_time_info_from_seconds(tstep, sim_start, sim_seconds); + double sim_seconds = sim_time * rd_smspec_get_time_seconds(smspec); + rd_sum_tstep_set_time_info_from_seconds(tstep, sim_start, sim_seconds); } else if (date_day_index >= 0) { int day = util_roundf(tstep->data[date_day_index]); int month = util_roundf(tstep->data[date_month_index]); int year = util_roundf(tstep->data[date_year_index]); - time_t sim_time = ecl_util_make_date(day, month, year); - ecl_sum_tstep_set_time_info_from_date(tstep, sim_start, sim_time); + time_t sim_time = rd_make_date(day, month, year); + rd_sum_tstep_set_time_info_from_date(tstep, sim_start, sim_time); } else util_abort("%s: Hmmm - could not extract date/time information from " "SMSPEC header file? \n", @@ -169,34 +169,36 @@ static void ecl_sum_tstep_set_time_info(ecl_sum_tstep_type *tstep, } /** - If the ecl_kw instance is in some way invalid (i.e. wrong size); + If the rd_kw instance is in some way invalid (i.e. wrong size); the function will return NULL: */ -ecl_sum_tstep_type *ecl_sum_tstep_alloc_from_file( - int report_step, int ministep_nr, const ecl_kw_type *params_kw, - const char *src_file, const ecl_smspec_type *smspec) { +rd_sum_tstep_type *rd_sum_tstep_alloc_from_file(int report_step, + int ministep_nr, + const rd_kw_type *params_kw, + const char *src_file, + const rd_smspec_type *smspec) { - int data_size = ecl_kw_get_size(params_kw); + int data_size = rd_kw_get_size(params_kw); - if (data_size == ecl_smspec_get_params_size(smspec)) { - ecl_sum_tstep_type *ministep = - ecl_sum_tstep_alloc(report_step, ministep_nr, smspec); - ecl_kw_get_memcpy_data(params_kw, ministep->data.data()); - ecl_sum_tstep_set_time_info(ministep, smspec); + if (data_size == rd_smspec_get_params_size(smspec)) { + rd_sum_tstep_type *ministep = + rd_sum_tstep_alloc(report_step, ministep_nr, smspec); + rd_kw_get_memcpy_data(params_kw, ministep->data.data()); + rd_sum_tstep_set_time_info(ministep, smspec); return ministep; } else { /* This is actually a fatal error / bug; the difference in smspec header structure should have been detected already in the - ecl_smspec_load_restart() function and the restart case + rd_smspec_load_restart() function and the restart case discarded. */ fprintf(stderr, "** Warning size mismatch between timestep loaded from:%s(%d) " "and header:%s(%d) - timestep discarded.\n", - src_file, data_size, ecl_smspec_get_header_file(smspec), - ecl_smspec_get_params_size(smspec)); + src_file, data_size, rd_smspec_get_header_file(smspec), + rd_smspec_get_params_size(smspec)); return NULL; } } @@ -205,21 +207,21 @@ ecl_sum_tstep_type *ecl_sum_tstep_alloc_from_file( Should be called in write mode. */ -ecl_sum_tstep_type *ecl_sum_tstep_alloc_new(int report_step, int ministep, - float sim_seconds, - const ecl_smspec_type *smspec) { - ecl_sum_tstep_type *tstep = - ecl_sum_tstep_alloc(report_step, ministep, smspec); - tstep->data = ecl_smspec_get_params_default(smspec); - - ecl_sum_tstep_set_time_info_from_seconds( - tstep, ecl_smspec_get_start_time(smspec), sim_seconds); - ecl_sum_tstep_iset(tstep, ecl_smspec_get_time_index(smspec), - sim_seconds / ecl_smspec_get_time_seconds(smspec)); +rd_sum_tstep_type *rd_sum_tstep_alloc_new(int report_step, int ministep, + float sim_seconds, + const rd_smspec_type *smspec) { + rd_sum_tstep_type *tstep = + rd_sum_tstep_alloc(report_step, ministep, smspec); + tstep->data = rd_smspec_get_params_default(smspec); + + rd_sum_tstep_set_time_info_from_seconds( + tstep, rd_smspec_get_start_time(smspec), sim_seconds); + rd_sum_tstep_iset(tstep, rd_smspec_get_time_index(smspec), + sim_seconds / rd_smspec_get_time_seconds(smspec)); return tstep; } -double ecl_sum_tstep_iget(const ecl_sum_tstep_type *ministep, int index) { +double rd_sum_tstep_iget(const rd_sum_tstep_type *ministep, int index) { if ((index >= 0) && (index < (int)ministep->data.size())) return ministep->data[index]; else { @@ -229,54 +231,53 @@ double ecl_sum_tstep_iget(const ecl_sum_tstep_type *ministep, int index) { } } -time_t ecl_sum_tstep_get_sim_time(const ecl_sum_tstep_type *ministep) { +time_t rd_sum_tstep_get_sim_time(const rd_sum_tstep_type *ministep) { return ministep->sim_time; } -double ecl_sum_tstep_get_sim_days(const ecl_sum_tstep_type *ministep) { +double rd_sum_tstep_get_sim_days(const rd_sum_tstep_type *ministep) { return ministep->sim_seconds / (24 * 3600); } -double ecl_sum_tstep_get_sim_seconds(const ecl_sum_tstep_type *ministep) { +double rd_sum_tstep_get_sim_seconds(const rd_sum_tstep_type *ministep) { return ministep->sim_seconds; } -int ecl_sum_tstep_get_report(const ecl_sum_tstep_type *ministep) { +int rd_sum_tstep_get_report(const rd_sum_tstep_type *ministep) { return ministep->report_step; } -int ecl_sum_tstep_get_ministep(const ecl_sum_tstep_type *ministep) { +int rd_sum_tstep_get_ministep(const rd_sum_tstep_type *ministep) { return ministep->ministep; } -void ecl_sum_tstep_fwrite(const ecl_sum_tstep_type *ministep, - const int *index_map, int index_map_size, - fortio_type *fortio) { +void rd_sum_tstep_fwrite(const rd_sum_tstep_type *ministep, + const int *index_map, int index_map_size, + fortio_type *fortio) { { - ecl_kw_type *ministep_kw = ecl_kw_alloc(MINISTEP_KW, 1, ECL_INT); - ecl_kw_iset_int(ministep_kw, 0, ministep->ministep); - ecl_kw_fwrite(ministep_kw, fortio); - ecl_kw_free(ministep_kw); + rd_kw_type *ministep_kw = rd_kw_alloc(MINISTEP_KW, 1, RD_INT); + rd_kw_iset_int(ministep_kw, 0, ministep->ministep); + rd_kw_fwrite(ministep_kw, fortio); + rd_kw_free(ministep_kw); } { int compact_size = index_map_size; - ecl_kw_type *params_kw = - ecl_kw_alloc(PARAMS_KW, compact_size, ECL_FLOAT); + rd_kw_type *params_kw = rd_kw_alloc(PARAMS_KW, compact_size, RD_FLOAT); - float *data = (float *)ecl_kw_get_ptr(params_kw); + float *data = (float *)rd_kw_get_ptr(params_kw); { int i; for (i = 0; i < compact_size; i++) data[i] = ministep->data[index_map[i]]; } - ecl_kw_fwrite(params_kw, fortio); - ecl_kw_free(params_kw); + rd_kw_fwrite(params_kw, fortio); + rd_kw_free(params_kw); } } -void ecl_sum_tstep_iset(ecl_sum_tstep_type *tstep, int index, float value) { +void rd_sum_tstep_iset(rd_sum_tstep_type *tstep, int index, float value) { if ((index < static_cast(tstep->data.size())) && (index >= 0)) tstep->data[index] = value; else @@ -284,48 +285,47 @@ void ecl_sum_tstep_iset(ecl_sum_tstep_type *tstep, int index, float value) { index, tstep->data.size()); } -void ecl_sum_tstep_iscale(ecl_sum_tstep_type *tstep, int index, float scalar) { - ecl_sum_tstep_iset(tstep, index, ecl_sum_tstep_iget(tstep, index) * scalar); +void rd_sum_tstep_iscale(rd_sum_tstep_type *tstep, int index, float scalar) { + rd_sum_tstep_iset(tstep, index, rd_sum_tstep_iget(tstep, index) * scalar); } -void ecl_sum_tstep_ishift(ecl_sum_tstep_type *tstep, int index, float addend) { - ecl_sum_tstep_iset(tstep, index, ecl_sum_tstep_iget(tstep, index) + addend); +void rd_sum_tstep_ishift(rd_sum_tstep_type *tstep, int index, float addend) { + rd_sum_tstep_iset(tstep, index, rd_sum_tstep_iget(tstep, index) + addend); } -void ecl_sum_tstep_set_from_node(ecl_sum_tstep_type *tstep, - const ecl::smspec_node &smspec_node, - float value) { +void rd_sum_tstep_set_from_node(rd_sum_tstep_type *tstep, + const rd::smspec_node &smspec_node, + float value) { int data_index = smspec_node_get_params_index(&smspec_node); - ecl_sum_tstep_iset(tstep, data_index, value); + rd_sum_tstep_iset(tstep, data_index, value); } -double ecl_sum_tstep_get_from_node(const ecl_sum_tstep_type *tstep, - const ecl::smspec_node &smspec_node) { +double rd_sum_tstep_get_from_node(const rd_sum_tstep_type *tstep, + const rd::smspec_node &smspec_node) { int data_index = smspec_node_get_params_index(&smspec_node); - return ecl_sum_tstep_iget(tstep, data_index); + return rd_sum_tstep_iget(tstep, data_index); } -void ecl_sum_tstep_set_from_key(ecl_sum_tstep_type *tstep, const char *gen_key, - float value) { - const ecl::smspec_node &smspec_node = - ecl_smspec_get_general_var_node(tstep->smspec, gen_key); - ecl_sum_tstep_set_from_node(tstep, smspec_node, value); +void rd_sum_tstep_set_from_key(rd_sum_tstep_type *tstep, const char *gen_key, + float value) { + const rd::smspec_node &smspec_node = + rd_smspec_get_general_var_node(tstep->smspec, gen_key); + rd_sum_tstep_set_from_node(tstep, smspec_node, value); } -double ecl_sum_tstep_get_from_key(const ecl_sum_tstep_type *tstep, - const char *gen_key) { - const ecl::smspec_node &smspec_node = - ecl_smspec_get_general_var_node(tstep->smspec, gen_key); - return ecl_sum_tstep_get_from_node(tstep, smspec_node); +double rd_sum_tstep_get_from_key(const rd_sum_tstep_type *tstep, + const char *gen_key) { + const rd::smspec_node &smspec_node = + rd_smspec_get_general_var_node(tstep->smspec, gen_key); + return rd_sum_tstep_get_from_node(tstep, smspec_node); } -bool ecl_sum_tstep_has_key(const ecl_sum_tstep_type *tstep, - const char *gen_key) { - return ecl_smspec_has_general_var(tstep->smspec, gen_key); +bool rd_sum_tstep_has_key(const rd_sum_tstep_type *tstep, const char *gen_key) { + return rd_smspec_has_general_var(tstep->smspec, gen_key); } -bool ecl_sum_tstep_sim_time_equal(const ecl_sum_tstep_type *tstep1, - const ecl_sum_tstep_type *tstep2) { +bool rd_sum_tstep_sim_time_equal(const rd_sum_tstep_type *tstep1, + const rd_sum_tstep_type *tstep2) { if (tstep1->sim_time == tstep2->sim_time) return true; else diff --git a/lib/resdata/rd_sum_vector.cpp b/lib/resdata/rd_sum_vector.cpp index d74198eeb7..76098f4d46 100644 --- a/lib/resdata/rd_sum_vector.cpp +++ b/lib/resdata/rd_sum_vector.cpp @@ -3,33 +3,33 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include -#define ECL_SUM_VECTOR_TYPE_ID 8768778 +#define RD_SUM_VECTOR_TYPE_ID 8768778 -struct ecl_sum_vector_struct { +struct rd_sum_vector_struct { UTIL_TYPE_ID_DECLARATION; std::vector node_index_list; std::vector is_rate_list; std::vector key_list; - const ecl_sum_type *ecl_sum; + const rd_sum_type *rd_sum; }; -void ecl_sum_vector_free(ecl_sum_vector_type *ecl_sum_vector) { - delete ecl_sum_vector; +void rd_sum_vector_free(rd_sum_vector_type *rd_sum_vector) { + delete rd_sum_vector; } -UTIL_IS_INSTANCE_FUNCTION(ecl_sum_vector, ECL_SUM_VECTOR_TYPE_ID) +UTIL_IS_INSTANCE_FUNCTION(rd_sum_vector, RD_SUM_VECTOR_TYPE_ID) -static void ecl_sum_vector_add_node(ecl_sum_vector_type *vector, - const ecl::smspec_node *node, - const char *key) { +static void rd_sum_vector_add_node(rd_sum_vector_type *vector, + const rd::smspec_node *node, + const char *key) { int params_index = smspec_node_get_params_index(node); bool is_rate_key = smspec_node_is_rate(node); @@ -38,109 +38,108 @@ static void ecl_sum_vector_add_node(ecl_sum_vector_type *vector, vector->key_list.push_back(key); } -ecl_sum_vector_type *ecl_sum_vector_alloc(const ecl_sum_type *ecl_sum, - bool add_keywords) { - ecl_sum_vector_type *ecl_sum_vector = new ecl_sum_vector_type(); - UTIL_TYPE_ID_INIT(ecl_sum_vector, ECL_SUM_VECTOR_TYPE_ID); - ecl_sum_vector->ecl_sum = ecl_sum; +rd_sum_vector_type *rd_sum_vector_alloc(const rd_sum_type *rd_sum, + bool add_keywords) { + rd_sum_vector_type *rd_sum_vector = new rd_sum_vector_type(); + UTIL_TYPE_ID_INIT(rd_sum_vector, RD_SUM_VECTOR_TYPE_ID); + rd_sum_vector->rd_sum = rd_sum; if (add_keywords) { - const ecl_smspec_type *smspec = ecl_sum_get_smspec(ecl_sum); - for (int i = 0; i < ecl_smspec_num_nodes(smspec); i++) { - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(smspec, i); + const rd_smspec_type *smspec = rd_sum_get_smspec(rd_sum); + for (int i = 0; i < rd_smspec_num_nodes(smspec); i++) { + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(smspec, i); const char *key = smspec_node_get_gen_key1(&node); /* The TIME keyword is special case handled to not be included; that is to match the same special casing in the key matching function. */ if (!util_string_equal(key, "TIME")) - ecl_sum_vector_add_node(ecl_sum_vector, &node, key); + rd_sum_vector_add_node(rd_sum_vector, &node, key); } } - return ecl_sum_vector; + return rd_sum_vector; } -static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type *vector, - const char *key) { +static void rd_sum_vector_add_invalid_key(rd_sum_vector_type *vector, + const char *key) { vector->node_index_list.push_back(-1); vector->is_rate_list.push_back(false); vector->key_list.push_back(key); } /* - This function will allocate a keyword vector for the keys in the @ecl_sum + This function will allocate a keyword vector for the keys in the @rd_sum argument passed in, it will contain all the same keys as in the input argument @src_vector. If the @src_vector contains keys which are not present in - @ecl_sum an entry marked as *invalid* will be added. The whole point about + @rd_sum an entry marked as *invalid* will be added. The whole point about this function is to ensure that calls to: - ecl_sum_fwrite_interp_csv_line( ) + rd_sum_fwrite_interp_csv_line( ) will result in nicely aligned output even if the different summary cases do not have the exact same keys. */ -ecl_sum_vector_type * -ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type *src_vector, - const ecl_sum_type *ecl_sum) { - ecl_sum_vector_type *new_vector = ecl_sum_vector_alloc(ecl_sum, false); +rd_sum_vector_type * +rd_sum_vector_alloc_layout_copy(const rd_sum_vector_type *src_vector, + const rd_sum_type *rd_sum) { + rd_sum_vector_type *new_vector = rd_sum_vector_alloc(rd_sum, false); for (size_t i = 0; i < src_vector->key_list.size(); i++) { const char *key = src_vector->key_list[i].c_str(); - if (ecl_sum_has_general_var(ecl_sum, key)) - ecl_sum_vector_add_key(new_vector, key); + if (rd_sum_has_general_var(rd_sum, key)) + rd_sum_vector_add_key(new_vector, key); else - ecl_sum_vector_add_invalid_key(new_vector, key); + rd_sum_vector_add_invalid_key(new_vector, key); } return new_vector; } -bool ecl_sum_vector_add_key(ecl_sum_vector_type *ecl_sum_vector, - const char *key) { - if (ecl_sum_has_general_var(ecl_sum_vector->ecl_sum, key)) { - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum_vector->ecl_sum, key); - ecl_sum_vector_add_node(ecl_sum_vector, node, key); +bool rd_sum_vector_add_key(rd_sum_vector_type *rd_sum_vector, const char *key) { + if (rd_sum_has_general_var(rd_sum_vector->rd_sum, key)) { + const rd::smspec_node *node = + rd_sum_get_general_var_node(rd_sum_vector->rd_sum, key); + rd_sum_vector_add_node(rd_sum_vector, node, key); return true; } else return false; } -void ecl_sum_vector_add_keys(ecl_sum_vector_type *ecl_sum_vector, - const char *pattern) { - stringlist_type *keylist = ecl_sum_alloc_matching_general_var_list( - ecl_sum_vector->ecl_sum, pattern); +void rd_sum_vector_add_keys(rd_sum_vector_type *rd_sum_vector, + const char *pattern) { + stringlist_type *keylist = + rd_sum_alloc_matching_general_var_list(rd_sum_vector->rd_sum, pattern); int num_keywords = stringlist_get_size(keylist); int i; for (i = 0; i < num_keywords; i++) { const char *key = stringlist_iget(keylist, i); - const ecl::smspec_node *node = - ecl_sum_get_general_var_node(ecl_sum_vector->ecl_sum, key); - ecl_sum_vector_add_node(ecl_sum_vector, node, key); + const rd::smspec_node *node = + rd_sum_get_general_var_node(rd_sum_vector->rd_sum, key); + rd_sum_vector_add_node(rd_sum_vector, node, key); } stringlist_free(keylist); } -int ecl_sum_vector_get_size(const ecl_sum_vector_type *ecl_sum_vector) { - return ecl_sum_vector->node_index_list.size(); +int rd_sum_vector_get_size(const rd_sum_vector_type *rd_sum_vector) { + return rd_sum_vector->node_index_list.size(); } -bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type *ecl_sum_vector, - int index) { - return ecl_sum_vector->is_rate_list[index]; +bool rd_sum_vector_iget_is_rate(const rd_sum_vector_type *rd_sum_vector, + int index) { + return rd_sum_vector->is_rate_list[index]; } -bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type *ecl_sum_vector, - int index) { - return (ecl_sum_vector->node_index_list[index] >= 0); +bool rd_sum_vector_iget_valid(const rd_sum_vector_type *rd_sum_vector, + int index) { + return (rd_sum_vector->node_index_list[index] >= 0); } -int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type *ecl_sum_vector, - int index) { - return ecl_sum_vector->node_index_list[index]; +int rd_sum_vector_iget_param_index(const rd_sum_vector_type *rd_sum_vector, + int index) { + return rd_sum_vector->node_index_list[index]; } -const char *ecl_sum_vector_iget_key(const ecl_sum_vector_type *ecl_sum_vector, - int index) { - return ecl_sum_vector->key_list[index].c_str(); +const char *rd_sum_vector_iget_key(const rd_sum_vector_type *rd_sum_vector, + int index) { + return rd_sum_vector->key_list[index].c_str(); } diff --git a/lib/resdata/rd_type.cpp b/lib/resdata/rd_type.cpp index 9392585d4a..bacce4158b 100644 --- a/lib/resdata/rd_type.cpp +++ b/lib/resdata/rd_type.cpp @@ -3,185 +3,185 @@ #include #include -#include +#include /* The string names for the different ECLIPSE low-level types. */ -#define ECL_TYPE_NAME_CHAR "CHAR" -#define ECL_TYPE_NAME_FLOAT "REAL" -#define ECL_TYPE_NAME_INT "INTE" -#define ECL_TYPE_NAME_DOUBLE "DOUB" -#define ECL_TYPE_NAME_BOOL "LOGI" -#define ECL_TYPE_NAME_MESSAGE "MESS" +#define RD_TYPE_NAME_CHAR "CHAR" +#define RD_TYPE_NAME_FLOAT "REAL" +#define RD_TYPE_NAME_INT "INTE" +#define RD_TYPE_NAME_DOUBLE "DOUB" +#define RD_TYPE_NAME_BOOL "LOGI" +#define RD_TYPE_NAME_MESSAGE "MESS" -static char *alloc_string_name(const ecl_data_type ecl_type) { - return util_alloc_sprintf("C%03d", ecl_type_get_sizeof_iotype(ecl_type)); +static char *alloc_string_name(const rd_data_type rd_type) { + return util_alloc_sprintf("C%03d", rd_type_get_sizeof_iotype(rd_type)); } -static bool is_ecl_string_name(const char *type_name) { +static bool is_rd_string_name(const char *type_name) { return (type_name[0] == 'C' && isdigit(type_name[1]) && isdigit(type_name[2]) && isdigit(type_name[3])); } -static size_t get_ecl_string_length(const char *type_name) { - if (!is_ecl_string_name(type_name)) +static size_t get_rd_string_length(const char *type_name) { + if (!is_rd_string_name(type_name)) util_abort("%s: Expected eclipse string (CXXX), received %s\n", __func__, type_name); return atoi(type_name + 1); } -ecl_data_type ecl_type_create(const ecl_type_enum type, - const size_t element_size) { - ecl_data_type ecl_type = - (type == ECL_STRING_TYPE ? ECL_STRING(element_size) - : ecl_type_create_from_type(type)); +rd_data_type rd_type_create(const rd_type_enum type, + const size_t element_size) { + rd_data_type rd_type = + (type == RD_STRING_TYPE ? RD_STRING(element_size) + : rd_type_create_from_type(type)); - if ((size_t)ecl_type_get_sizeof_iotype(ecl_type) != element_size) + if ((size_t)rd_type_get_sizeof_iotype(rd_type) != element_size) util_abort( "%s: element_size mismatch for type %d, was: %d, expected: %d\n", - __func__, type, element_size, ecl_type_get_sizeof_iotype(ecl_type)); + __func__, type, element_size, rd_type_get_sizeof_iotype(rd_type)); - return ecl_type; + return rd_type; } -ecl_data_type ecl_type_create_from_type(const ecl_type_enum type) { +rd_data_type rd_type_create_from_type(const rd_type_enum type) { switch (type) { - case (ECL_CHAR_TYPE): - return ECL_CHAR; - case (ECL_INT_TYPE): - return ECL_INT; - case (ECL_FLOAT_TYPE): - return ECL_FLOAT; - case (ECL_DOUBLE_TYPE): - return ECL_DOUBLE; - case (ECL_BOOL_TYPE): - return ECL_BOOL; - case (ECL_MESS_TYPE): - return ECL_MESS; - case (ECL_STRING_TYPE): + case (RD_CHAR_TYPE): + return RD_CHAR; + case (RD_INT_TYPE): + return RD_INT; + case (RD_FLOAT_TYPE): + return RD_FLOAT; + case (RD_DOUBLE_TYPE): + return RD_DOUBLE; + case (RD_BOOL_TYPE): + return RD_BOOL; + case (RD_MESS_TYPE): + return RD_MESS; + case (RD_STRING_TYPE): util_abort("%s: Variable length string type cannot be created" " from type alone!\n", __func__); - return ECL_STRING(0); /* Dummy */ + return RD_STRING(0); /* Dummy */ default: - util_abort("%s: invalid ecl_type: %d\n", __func__, type); - return ECL_INT; /* Dummy */ + util_abort("%s: invalid rd_type: %d\n", __func__, type); + return RD_INT; /* Dummy */ } } -ecl_type_enum ecl_type_get_type(const ecl_data_type ecl_type) { - return ecl_type.type; -} - -char *ecl_type_alloc_name(const ecl_data_type ecl_type) { - switch (ecl_type.type) { - case (ECL_CHAR_TYPE): - return util_alloc_string_copy(ECL_TYPE_NAME_CHAR); - case (ECL_STRING_TYPE): - return alloc_string_name(ecl_type); - case (ECL_FLOAT_TYPE): - return util_alloc_string_copy(ECL_TYPE_NAME_FLOAT); - case (ECL_DOUBLE_TYPE): - return util_alloc_string_copy(ECL_TYPE_NAME_DOUBLE); - case (ECL_INT_TYPE): - return util_alloc_string_copy(ECL_TYPE_NAME_INT); - case (ECL_BOOL_TYPE): - return util_alloc_string_copy(ECL_TYPE_NAME_BOOL); - case (ECL_MESS_TYPE): - return util_alloc_string_copy(ECL_TYPE_NAME_MESSAGE); +rd_type_enum rd_type_get_type(const rd_data_type rd_type) { + return rd_type.type; +} + +char *rd_type_alloc_name(const rd_data_type rd_type) { + switch (rd_type.type) { + case (RD_CHAR_TYPE): + return util_alloc_string_copy(RD_TYPE_NAME_CHAR); + case (RD_STRING_TYPE): + return alloc_string_name(rd_type); + case (RD_FLOAT_TYPE): + return util_alloc_string_copy(RD_TYPE_NAME_FLOAT); + case (RD_DOUBLE_TYPE): + return util_alloc_string_copy(RD_TYPE_NAME_DOUBLE); + case (RD_INT_TYPE): + return util_alloc_string_copy(RD_TYPE_NAME_INT); + case (RD_BOOL_TYPE): + return util_alloc_string_copy(RD_TYPE_NAME_BOOL); + case (RD_MESS_TYPE): + return util_alloc_string_copy(RD_TYPE_NAME_MESSAGE); default: util_abort("Internal error in %s - internal eclipse_type: %d not " "recognized - aborting \n", - __func__, ecl_type.type); + __func__, rd_type.type); return NULL; /* Dummy */ } } -ecl_data_type ecl_type_create_from_name(const char *type_name) { - if (strncmp(type_name, ECL_TYPE_NAME_FLOAT, ECL_TYPE_LENGTH) == 0) - return ECL_FLOAT; - else if (strncmp(type_name, ECL_TYPE_NAME_INT, ECL_TYPE_LENGTH) == 0) - return ECL_INT; - else if (strncmp(type_name, ECL_TYPE_NAME_DOUBLE, ECL_TYPE_LENGTH) == 0) - return ECL_DOUBLE; - else if (strncmp(type_name, ECL_TYPE_NAME_CHAR, ECL_TYPE_LENGTH) == 0) - return ECL_CHAR; - else if (is_ecl_string_name(type_name)) - return ECL_STRING(get_ecl_string_length(type_name)); - else if (strncmp(type_name, ECL_TYPE_NAME_MESSAGE, ECL_TYPE_LENGTH) == 0) - return ECL_MESS; - else if (strncmp(type_name, ECL_TYPE_NAME_BOOL, ECL_TYPE_LENGTH) == 0) - return ECL_BOOL; +rd_data_type rd_type_create_from_name(const char *type_name) { + if (strncmp(type_name, RD_TYPE_NAME_FLOAT, RD_TYPE_LENGTH) == 0) + return RD_FLOAT; + else if (strncmp(type_name, RD_TYPE_NAME_INT, RD_TYPE_LENGTH) == 0) + return RD_INT; + else if (strncmp(type_name, RD_TYPE_NAME_DOUBLE, RD_TYPE_LENGTH) == 0) + return RD_DOUBLE; + else if (strncmp(type_name, RD_TYPE_NAME_CHAR, RD_TYPE_LENGTH) == 0) + return RD_CHAR; + else if (is_rd_string_name(type_name)) + return RD_STRING(get_rd_string_length(type_name)); + else if (strncmp(type_name, RD_TYPE_NAME_MESSAGE, RD_TYPE_LENGTH) == 0) + return RD_MESS; + else if (strncmp(type_name, RD_TYPE_NAME_BOOL, RD_TYPE_LENGTH) == 0) + return RD_BOOL; else { util_abort("%s: unrecognized type name:%s \n", __func__, type_name); - return ECL_INT; /* Dummy */ + return RD_INT; /* Dummy */ } } -int ecl_type_get_sizeof_ctype(const ecl_data_type ecl_type) { - return ecl_type.element_size; +int rd_type_get_sizeof_ctype(const rd_data_type rd_type) { + return rd_type.element_size; } -int ecl_type_get_sizeof_iotype(const ecl_data_type ecl_type) { - if (ecl_type_is_bool(ecl_type)) +int rd_type_get_sizeof_iotype(const rd_data_type rd_type) { + if (rd_type_is_bool(rd_type)) return sizeof(int); - if (ecl_type_is_char(ecl_type)) - return ecl_type.element_size - 1; + if (rd_type_is_char(rd_type)) + return rd_type.element_size - 1; - if (ecl_type_is_string(ecl_type)) - return ecl_type.element_size - 1; + if (rd_type_is_string(rd_type)) + return rd_type.element_size - 1; - return ecl_type.element_size; + return rd_type.element_size; } -bool ecl_type_is_numeric(const ecl_data_type ecl_type) { - return (ecl_type_is_int(ecl_type) || ecl_type_is_float(ecl_type) || - ecl_type_is_double(ecl_type)); +bool rd_type_is_numeric(const rd_data_type rd_type) { + return (rd_type_is_int(rd_type) || rd_type_is_float(rd_type) || + rd_type_is_double(rd_type)); } -bool ecl_type_is_alpha(const ecl_data_type ecl_type) { - return (ecl_type_is_char(ecl_type) || ecl_type_is_mess(ecl_type) || - ecl_type_is_string(ecl_type)); +bool rd_type_is_alpha(const rd_data_type rd_type) { + return (rd_type_is_char(rd_type) || rd_type_is_mess(rd_type) || + rd_type_is_string(rd_type)); } -bool ecl_type_is_equal(const ecl_data_type ecl_type1, - const ecl_data_type ecl_type2) { - return (ecl_type1.type == ecl_type2.type && - ecl_type1.element_size == ecl_type2.element_size); +bool rd_type_is_equal(const rd_data_type rd_type1, + const rd_data_type rd_type2) { + return (rd_type1.type == rd_type2.type && + rd_type1.element_size == rd_type2.element_size); } -bool ecl_type_is_char(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_CHAR_TYPE); +bool rd_type_is_char(const rd_data_type rd_type) { + return (rd_type.type == RD_CHAR_TYPE); } -bool ecl_type_is_int(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_INT_TYPE); +bool rd_type_is_int(const rd_data_type rd_type) { + return (rd_type.type == RD_INT_TYPE); } -bool ecl_type_is_float(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_FLOAT_TYPE); +bool rd_type_is_float(const rd_data_type rd_type) { + return (rd_type.type == RD_FLOAT_TYPE); } -bool ecl_type_is_double(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_DOUBLE_TYPE); +bool rd_type_is_double(const rd_data_type rd_type) { + return (rd_type.type == RD_DOUBLE_TYPE); } -bool ecl_type_is_mess(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_MESS_TYPE); +bool rd_type_is_mess(const rd_data_type rd_type) { + return (rd_type.type == RD_MESS_TYPE); } -bool ecl_type_is_bool(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_BOOL_TYPE); +bool rd_type_is_bool(const rd_data_type rd_type) { + return (rd_type.type == RD_BOOL_TYPE); } -bool ecl_type_is_string(const ecl_data_type ecl_type) { - return (ecl_type.type == ECL_STRING_TYPE); +bool rd_type_is_string(const rd_data_type rd_type) { + return (rd_type.type == RD_STRING_TYPE); } // Temporary fixup for OPM. -char *ecl_type_get_name(const ecl_data_type ecl_type) { - return ecl_type_alloc_name(ecl_type); +char *rd_type_get_name(const rd_data_type rd_type) { + return rd_type_alloc_name(rd_type); } diff --git a/lib/resdata/rd_type_python.cpp b/lib/resdata/rd_type_python.cpp index 8e62ccb5db..3967aa5c84 100644 --- a/lib/resdata/rd_type_python.cpp +++ b/lib/resdata/rd_type_python.cpp @@ -1,121 +1,118 @@ -#include -#include -#include +#include +#include +#include /** * - * Functions only to be used by the *PYTHON* prototype for EclDataType + * Functions only to be used by the *PYTHON* prototype for ResdataDataType * */ #ifdef __cplusplus extern "C" { -ecl_data_type *ecl_type_alloc_copy_python(const ecl_data_type *src_type) { - ecl_data_type *data_type = (ecl_data_type *)util_malloc(sizeof *src_type); +rd_data_type *rd_type_alloc_copy_python(const rd_data_type *src_type) { + rd_data_type *data_type = (rd_data_type *)util_malloc(sizeof *src_type); memcpy(data_type, src_type, sizeof *data_type); return data_type; } -ecl_data_type *ecl_type_alloc_python(const ecl_type_enum type, - const size_t element_size) { - ecl_data_type src_type = ecl_type_create(type, element_size); - return ecl_type_alloc_copy_python(&src_type); +rd_data_type *rd_type_alloc_python(const rd_type_enum type, + const size_t element_size) { + rd_data_type src_type = rd_type_create(type, element_size); + return rd_type_alloc_copy_python(&src_type); } -ecl_data_type *ecl_type_alloc_from_type_python(const ecl_type_enum type) { - ecl_data_type src_type = ecl_type_create_from_type(type); - return ecl_type_alloc_copy_python(&src_type); +rd_data_type *rd_type_alloc_from_type_python(const rd_type_enum type) { + rd_data_type src_type = rd_type_create_from_type(type); + return rd_type_alloc_copy_python(&src_type); } -ecl_data_type *ecl_type_alloc_from_name_python(const char *name) { - ecl_data_type src_type = ecl_type_create_from_name(name); - return ecl_type_alloc_copy_python(&src_type); +rd_data_type *rd_type_alloc_from_name_python(const char *name) { + rd_data_type src_type = rd_type_create_from_name(name); + return rd_type_alloc_copy_python(&src_type); } -void ecl_type_free_python(ecl_data_type *data_type) { free(data_type); } +void rd_type_free_python(rd_data_type *data_type) { free(data_type); } -ecl_type_enum ecl_type_get_type_python(const ecl_data_type *ecl_type) { - return ecl_type_get_type(*ecl_type); +rd_type_enum rd_type_get_type_python(const rd_data_type *rd_type) { + return rd_type_get_type(*rd_type); } -const char *ecl_type_alloc_name_python(const ecl_data_type *ecl_type) { - return ecl_type_alloc_name(*ecl_type); +const char *rd_type_alloc_name_python(const rd_data_type *rd_type) { + return rd_type_alloc_name(*rd_type); } -int ecl_type_get_sizeof_iotype_python(const ecl_data_type *ecl_type) { - return ecl_type_get_sizeof_iotype(*ecl_type); +int rd_type_get_sizeof_iotype_python(const rd_data_type *rd_type) { + return rd_type_get_sizeof_iotype(*rd_type); } -int ecl_type_get_sizeof_ctype_python(const ecl_data_type *ecl_type) { - return ecl_type_get_sizeof_ctype(*ecl_type); +int rd_type_get_sizeof_ctype_python(const rd_data_type *rd_type) { + return rd_type_get_sizeof_ctype(*rd_type); } -bool ecl_type_is_numeric_python(const ecl_data_type *ecl_type) { - return ecl_type_is_numeric(*ecl_type); +bool rd_type_is_numeric_python(const rd_data_type *rd_type) { + return rd_type_is_numeric(*rd_type); } -bool ecl_type_is_equal_python(const ecl_data_type *ecl_type1, - const ecl_data_type *ecl_type2) { - return ecl_type_is_equal(*ecl_type1, *ecl_type2); +bool rd_type_is_equal_python(const rd_data_type *rd_type1, + const rd_data_type *rd_type2) { + return rd_type_is_equal(*rd_type1, *rd_type2); } -bool ecl_type_is_char_python(const ecl_data_type *ecl_type) { - return ecl_type_is_char(*ecl_type); +bool rd_type_is_char_python(const rd_data_type *rd_type) { + return rd_type_is_char(*rd_type); } -bool ecl_type_is_int_python(const ecl_data_type *ecl_type) { - return ecl_type_is_int(*ecl_type); +bool rd_type_is_int_python(const rd_data_type *rd_type) { + return rd_type_is_int(*rd_type); } -bool ecl_type_is_float_python(const ecl_data_type *ecl_type) { - return ecl_type_is_float(*ecl_type); +bool rd_type_is_float_python(const rd_data_type *rd_type) { + return rd_type_is_float(*rd_type); } -bool ecl_type_is_double_python(const ecl_data_type *ecl_type) { - return ecl_type_is_double(*ecl_type); +bool rd_type_is_double_python(const rd_data_type *rd_type) { + return rd_type_is_double(*rd_type); } -bool ecl_type_is_mess_python(const ecl_data_type *ecl_type) { - return ecl_type_is_mess(*ecl_type); +bool rd_type_is_mess_python(const rd_data_type *rd_type) { + return rd_type_is_mess(*rd_type); } -bool ecl_type_is_bool_python(const ecl_data_type *ecl_type) { - return ecl_type_is_bool(*ecl_type); +bool rd_type_is_bool_python(const rd_data_type *rd_type) { + return rd_type_is_bool(*rd_type); } -bool ecl_type_is_string_python(const ecl_data_type *ecl_type) { - return ecl_type_is_string(*ecl_type); +bool rd_type_is_string_python(const rd_data_type *rd_type) { + return rd_type_is_string(*rd_type); } /** * - * Functions for the EclKw prototype + * Functions for the ResdataKw prototype * */ -ecl_kw_type *ecl_kw_fscanf_alloc_grdecl_dynamic_python( - FILE *stream, const char *kw, bool strict, const ecl_data_type *data_type) { - return ecl_kw_fscanf_alloc_grdecl_dynamic__(stream, kw, strict, *data_type); +rd_kw_type *rd_kw_fscanf_alloc_grdecl_dynamic_python( + FILE *stream, const char *kw, bool strict, const rd_data_type *data_type) { + return rd_kw_fscanf_alloc_grdecl_dynamic__(stream, kw, strict, *data_type); } -ecl_kw_type *ecl_kw_alloc_python(const char *header, int size, - const ecl_data_type *data_type) { - return ecl_kw_alloc(header, size, *data_type); +rd_kw_type *rd_kw_alloc_python(const char *header, int size, + const rd_data_type *data_type) { + return rd_kw_alloc(header, size, *data_type); } -ecl_data_type *ecl_kw_get_data_type_python(const ecl_kw_type *ecl_kw) { - ecl_data_type data_type = ecl_kw_get_data_type(ecl_kw); - return ecl_type_alloc_copy_python(&data_type); +rd_data_type *rd_kw_get_data_type_python(const rd_kw_type *rd_kw) { + rd_data_type data_type = rd_kw_get_data_type(rd_kw); + return rd_type_alloc_copy_python(&data_type); } -void ecl_kw_fread_indexed_data_python(fortio_type *fortio, - offset_type data_offset, - const ecl_data_type *data_type, - int element_count, - const int_vector_type *index_map, - char *buffer) { - return ecl_kw_fread_indexed_data(fortio, data_offset, *data_type, - element_count, index_map, buffer); +void rd_kw_fread_indexed_data_python( + fortio_type *fortio, offset_type data_offset, const rd_data_type *data_type, + int element_count, const int_vector_type *index_map, char *buffer) { + return rd_kw_fread_indexed_data(fortio, data_offset, *data_type, + element_count, index_map, buffer); } } #endif diff --git a/lib/resdata/rd_unsmry_loader.cpp b/lib/resdata/rd_unsmry_loader.cpp index 5ccc99e862..d62deb134f 100644 --- a/lib/resdata/rd_unsmry_loader.cpp +++ b/lib/resdata/rd_unsmry_loader.cpp @@ -4,43 +4,43 @@ #include -#include -#include +#include +#include -#include "detail/ecl/ecl_unsmry_loader.hpp" +#include "detail/resdata/rd_unsmry_loader.hpp" -namespace ecl { +namespace rd { -unsmry_loader::unsmry_loader(const ecl_smspec_type *smspec, +unsmry_loader::unsmry_loader(const rd_smspec_type *smspec, const std::string &filename, int file_options) - : size(ecl_smspec_get_params_size(smspec)), - time_index(ecl_smspec_get_time_index(smspec)), - time_seconds(ecl_smspec_get_time_seconds(smspec)), - sim_start(ecl_smspec_get_start_time(smspec)) { - ecl_file_type *file = ecl_file_open(filename.c_str(), file_options); + : size(rd_smspec_get_params_size(smspec)), + time_index(rd_smspec_get_time_index(smspec)), + time_seconds(rd_smspec_get_time_seconds(smspec)), + sim_start(rd_smspec_get_start_time(smspec)) { + rd_file_type *file = rd_file_open(filename.c_str(), file_options); if (!file) throw std::bad_alloc(); - if (!ecl_file_has_kw(file, PARAMS_KW)) { - ecl_file_close(file); + if (!rd_file_has_kw(file, PARAMS_KW)) { + rd_file_close(file); throw std::bad_alloc(); } - if (ecl_file_get_num_named_kw(file, PARAMS_KW) != - ecl_file_get_num_named_kw(file, MINISTEP_KW)) { - ecl_file_close(file); + if (rd_file_get_num_named_kw(file, PARAMS_KW) != + rd_file_get_num_named_kw(file, MINISTEP_KW)) { + rd_file_close(file); throw std::bad_alloc(); } - this->date_index = {{ecl_smspec_get_date_day_index(smspec), - ecl_smspec_get_date_month_index(smspec), - ecl_smspec_get_date_year_index(smspec)}}; + this->date_index = {{rd_smspec_get_date_day_index(smspec), + rd_smspec_get_date_month_index(smspec), + rd_smspec_get_date_year_index(smspec)}}; this->file = file; - this->file_view = ecl_file_get_global_view(this->file); - this->m_length = ecl_file_view_get_num_named_kw(this->file_view, PARAMS_KW); + this->file_view = rd_file_get_global_view(this->file); + this->m_length = rd_file_view_get_num_named_kw(this->file_view, PARAMS_KW); } -unsmry_loader::~unsmry_loader() { ecl_file_close(file); } +unsmry_loader::~unsmry_loader() { rd_file_close(file); } int unsmry_loader::length() const { return this->m_length; } @@ -55,15 +55,15 @@ std::vector unsmry_loader::get_vector(int pos) const { char buffer[4]; for (int index = 0; index < this->length(); index++) { - ecl_file_view_index_fload_kw(file_view, PARAMS_KW, index, index_map, - buffer); + rd_file_view_index_fload_kw(file_view, PARAMS_KW, index, index_map, + buffer); float *data_value = (float *)buffer; data[index] = *data_value; } int_vector_free(index_map); - if (ecl_file_view_flags_set(file_view, ECL_FILE_CLOSE_STREAM)) - ecl_file_view_fclose_stream(file_view); + if (rd_file_view_flags_set(file_view, RD_FILE_CLOSE_STREAM)) + rd_file_view_fclose_stream(file_view); return data; } @@ -72,8 +72,8 @@ std::vector unsmry_loader::get_vector(int pos) const { double unsmry_loader::iget(int time_index, int params_index) const { int_vector_type *index_map = int_vector_alloc(1, params_index); float value; - ecl_file_view_index_fload_kw(this->file_view, PARAMS_KW, time_index, - index_map, (char *)&value); + rd_file_view_index_fload_kw(this->file_view, PARAMS_KW, time_index, + index_map, (char *)&value); int_vector_free(index_map); return value; } @@ -91,13 +91,12 @@ time_t unsmry_loader::iget_sim_time(int time_index) const { int_vector_iset(index_map, 2, this->date_index[2]); float values[3]; - ecl_file_view_index_fload_kw(this->file_view, PARAMS_KW, time_index, - index_map, (char *)&values); + rd_file_view_index_fload_kw(this->file_view, PARAMS_KW, time_index, + index_map, (char *)&values); int_vector_free(index_map); - return ecl_util_make_date(util_roundf(values[0]), - util_roundf(values[1]), - util_roundf(values[2])); + return rd_make_date(util_roundf(values[0]), util_roundf(values[1]), + util_roundf(values[2])); } } @@ -114,13 +113,13 @@ double unsmry_loader::iget_sim_seconds(int time_index) const { std::vector unsmry_loader::report_steps(int offset) const { std::vector report_steps; int current_step = offset; - for (int i = 0; i < ecl_file_view_get_size(this->file_view); i++) { - const ecl_file_kw_type *file_kw = - ecl_file_view_iget_file_kw(this->file_view, i); - if (util_string_equal(SEQHDR_KW, ecl_file_kw_get_header(file_kw))) + for (int i = 0; i < rd_file_view_get_size(this->file_view); i++) { + const rd_file_kw_type *file_kw = + rd_file_view_iget_file_kw(this->file_view, i); + if (util_string_equal(SEQHDR_KW, rd_file_kw_get_header(file_kw))) current_step++; - if (util_string_equal(PARAMS_KW, ecl_file_kw_get_header(file_kw))) + if (util_string_equal(PARAMS_KW, rd_file_kw_get_header(file_kw))) report_steps.push_back(current_step); } return report_steps; @@ -143,8 +142,8 @@ std::vector unsmry_loader::sim_time() const { std::vector st(this->length()); for (size_t i = 0; i < st.size(); i++) - st[i] = ecl_util_make_date(util_round(day[i]), util_round(month[i]), - util_round(year[i])); + st[i] = rd_make_date(util_round(day[i]), util_round(month[i]), + util_round(year[i])); return st; } @@ -168,4 +167,4 @@ std::vector unsmry_loader::sim_seconds() const { } } -} // namespace ecl +} // namespace rd diff --git a/lib/resdata/rd_util.cpp b/lib/resdata/rd_util.cpp index 564af1c713..4c3325c943 100644 --- a/lib/resdata/rd_util.cpp +++ b/lib/resdata/rd_util.cpp @@ -11,41 +11,41 @@ #include #include -#include -#include +#include +#include -#define ECL_PHASE_NAME_OIL \ +#define RD_PHASE_NAME_OIL \ "SOIL" // SHould match the keywords found in restart file -#define ECL_PHASE_NAME_WATER "SWAT" -#define ECL_PHASE_NAME_GAS "SGAS" - -#define ECL_OTHER_FILE_FMT_PATTERN "*" -#define ECL_UNIFIED_RESTART_FMT_PATTERN "FUNRST" -#define ECL_UNIFIED_SUMMARY_FMT_PATTERN "FUNSMRY" -#define ECL_GRID_FMT_PATTERN "FGRID" -#define ECL_EGRID_FMT_PATTERN "FEGRID" -#define ECL_INIT_FMT_PATTERN "FINIT" -#define ECL_RFT_FMT_PATTERN "FRFT" -#define ECL_DATA_PATTERN "DATA" - -#define ECL_OTHER_FILE_UFMT_PATTERN "*" -#define ECL_UNIFIED_RESTART_UFMT_PATTERN "UNRST" -#define ECL_UNIFIED_SUMMARY_UFMT_PATTERN "UNSMRY" -#define ECL_GRID_UFMT_PATTERN "GRID" -#define ECL_EGRID_UFMT_PATTERN "EGRID" -#define ECL_INIT_UFMT_PATTERN "INIT" -#define ECL_RFT_UFMT_PATTERN "RFT" - -const char *ecl_util_get_phase_name(ecl_phase_enum phase) { +#define RD_PHASE_NAME_WATER "SWAT" +#define RD_PHASE_NAME_GAS "SGAS" + +#define RD_OTHER_FILE_FMT_PATTERN "*" +#define RD_UNIFIED_RESTART_FMT_PATTERN "FUNRST" +#define RD_UNIFIED_SUMMARY_FMT_PATTERN "FUNSMRY" +#define RD_GRID_FMT_PATTERN "FGRID" +#define RD_EGRID_FMT_PATTERN "FEGRID" +#define RD_INIT_FMT_PATTERN "FINIT" +#define RD_RFT_FMT_PATTERN "FRFT" +#define RD_DATA_PATTERN "DATA" + +#define RD_OTHER_FILE_UFMT_PATTERN "*" +#define RD_UNIFIED_RESTART_UFMT_PATTERN "UNRST" +#define RD_UNIFIED_SUMMARY_UFMT_PATTERN "UNSMRY" +#define RD_GRID_UFMT_PATTERN "GRID" +#define RD_EGRID_UFMT_PATTERN "EGRID" +#define RD_INIT_UFMT_PATTERN "INIT" +#define RD_RFT_UFMT_PATTERN "RFT" + +const char *rd_get_phase_name(rd_phase_enum phase) { switch (phase) { - case (ECL_OIL_PHASE): - return ECL_PHASE_NAME_OIL; + case (RD_OIL_PHASE): + return RD_PHASE_NAME_OIL; break; - case (ECL_WATER_PHASE): - return ECL_PHASE_NAME_WATER; + case (RD_WATER_PHASE): + return RD_PHASE_NAME_WATER; break; - case (ECL_GAS_PHASE): - return ECL_PHASE_NAME_GAS; + case (RD_GAS_PHASE): + return RD_PHASE_NAME_GAS; break; default: util_abort("%s: phase enum value:%d not recognized \n", __func__, @@ -54,7 +54,7 @@ const char *ecl_util_get_phase_name(ecl_phase_enum phase) { } } -char *ecl_util_alloc_base_guess(const char *path) { +char *rd_alloc_base_guess(const char *path) { char *base = NULL; stringlist_type *data_files = stringlist_alloc_new(); stringlist_type *DATA_files = stringlist_alloc_new(); @@ -79,90 +79,90 @@ char *ecl_util_alloc_base_guess(const char *path) { return base; } -int ecl_util_filename_report_nr(const char *filename) { +int rd_filename_report_nr(const char *filename) { int report_nr = -1; - ecl_util_get_file_type(filename, NULL, &report_nr); + rd_get_file_type(filename, NULL, &report_nr); return report_nr; } /* We accept mixed lowercase/uppercase Eclipse file extensions even if Eclipse itself does not accept them. */ -ecl_file_enum ecl_util_inspect_extension(const char *ext, bool *_fmt_file, - int *_report_nr) { - ecl_file_enum file_type = ECL_OTHER_FILE; +rd_file_enum rd_inspect_extension(const char *ext, bool *_fmt_file, + int *_report_nr) { + rd_file_enum file_type = RD_OTHER_FILE; bool fmt_file = true; int report_nr = -1; char *upper_ext = util_alloc_strupr_copy(ext); if (strcmp(upper_ext, "UNRST") == 0) { - file_type = ECL_UNIFIED_RESTART_FILE; + file_type = RD_UNIFIED_RESTART_FILE; fmt_file = false; } else if (strcmp(upper_ext, "FUNRST") == 0) { - file_type = ECL_UNIFIED_RESTART_FILE; + file_type = RD_UNIFIED_RESTART_FILE; fmt_file = true; } else if (strcmp(upper_ext, "UNSMRY") == 0) { - file_type = ECL_UNIFIED_SUMMARY_FILE; + file_type = RD_UNIFIED_SUMMARY_FILE; fmt_file = false; } else if (strcmp(upper_ext, "FUNSMRY") == 0) { - file_type = ECL_UNIFIED_SUMMARY_FILE; + file_type = RD_UNIFIED_SUMMARY_FILE; fmt_file = true; } else if (strcmp(upper_ext, "SMSPEC") == 0) { - file_type = ECL_SUMMARY_HEADER_FILE; + file_type = RD_SUMMARY_HEADER_FILE; fmt_file = false; } else if (strcmp(upper_ext, "FSMSPEC") == 0) { - file_type = ECL_SUMMARY_HEADER_FILE; + file_type = RD_SUMMARY_HEADER_FILE; fmt_file = true; } else if (strcmp(upper_ext, "GRID") == 0) { - file_type = ECL_GRID_FILE; + file_type = RD_GRID_FILE; fmt_file = false; } else if (strcmp(upper_ext, "FGRID") == 0) { - file_type = ECL_GRID_FILE; + file_type = RD_GRID_FILE; fmt_file = true; } else if (strcmp(upper_ext, "EGRID") == 0) { - file_type = ECL_EGRID_FILE; + file_type = RD_EGRID_FILE; fmt_file = false; } else if (strcmp(upper_ext, "FEGRID") == 0) { - file_type = ECL_EGRID_FILE; + file_type = RD_EGRID_FILE; fmt_file = true; } else if (strcmp(upper_ext, "INIT") == 0) { - file_type = ECL_INIT_FILE; + file_type = RD_INIT_FILE; fmt_file = false; } else if (strcmp(upper_ext, "FINIT") == 0) { - file_type = ECL_INIT_FILE; + file_type = RD_INIT_FILE; fmt_file = true; } else if (strcmp(upper_ext, "FRFT") == 0) { - file_type = ECL_RFT_FILE; + file_type = RD_RFT_FILE; fmt_file = true; } else if (strcmp(upper_ext, "RFT") == 0) { - file_type = ECL_RFT_FILE; + file_type = RD_RFT_FILE; fmt_file = false; } else if (strcmp(upper_ext, "DATA") == 0) { - file_type = ECL_DATA_FILE; + file_type = RD_DATA_FILE; fmt_file = true; /* Not really relevant ... */ } else { switch (upper_ext[0]) { case ('X'): - file_type = ECL_RESTART_FILE; + file_type = RD_RESTART_FILE; fmt_file = false; break; case ('F'): - file_type = ECL_RESTART_FILE; + file_type = RD_RESTART_FILE; fmt_file = true; break; case ('S'): - file_type = ECL_SUMMARY_FILE; + file_type = RD_SUMMARY_FILE; fmt_file = false; break; case ('A'): - file_type = ECL_SUMMARY_FILE; + file_type = RD_SUMMARY_FILE; fmt_file = true; break; default: - file_type = ECL_OTHER_FILE; + file_type = RD_OTHER_FILE; } - if (file_type != ECL_OTHER_FILE) + if (file_type != RD_OTHER_FILE) if (!util_sscanf_int(&upper_ext[1], &report_nr)) - file_type = ECL_OTHER_FILE; + file_type = RD_OTHER_FILE; } if (_fmt_file != NULL) @@ -183,42 +183,41 @@ ecl_file_enum ecl_util_inspect_extension(const char *ext, bool *_fmt_file, report number this corresponds to. */ -ecl_file_enum ecl_util_get_file_type(const char *filename, bool *fmt_file, - int *report_nr) { +rd_file_enum rd_get_file_type(const char *filename, bool *fmt_file, + int *report_nr) { char *ext = (char *)strrchr(filename, '.'); if (ext == NULL) - return ECL_OTHER_FILE; + return RD_OTHER_FILE; - return ecl_util_inspect_extension(&ext[1], fmt_file, report_nr); + return rd_inspect_extension(&ext[1], fmt_file, report_nr); } -static const char *ecl_util_get_file_pattern(ecl_file_enum file_type, - bool fmt_file) { +static const char *rd_get_file_pattern(rd_file_enum file_type, bool fmt_file) { if (fmt_file) { switch (file_type) { - case (ECL_OTHER_FILE): - return ECL_OTHER_FILE_FMT_PATTERN; /* '*' */ + case (RD_OTHER_FILE): + return RD_OTHER_FILE_FMT_PATTERN; /* '*' */ break; - case (ECL_UNIFIED_RESTART_FILE): - return ECL_UNIFIED_RESTART_FMT_PATTERN; + case (RD_UNIFIED_RESTART_FILE): + return RD_UNIFIED_RESTART_FMT_PATTERN; break; - case (ECL_UNIFIED_SUMMARY_FILE): - return ECL_UNIFIED_SUMMARY_FMT_PATTERN; + case (RD_UNIFIED_SUMMARY_FILE): + return RD_UNIFIED_SUMMARY_FMT_PATTERN; break; - case (ECL_GRID_FILE): - return ECL_GRID_FMT_PATTERN; + case (RD_GRID_FILE): + return RD_GRID_FMT_PATTERN; break; - case (ECL_EGRID_FILE): - return ECL_EGRID_FMT_PATTERN; + case (RD_EGRID_FILE): + return RD_EGRID_FMT_PATTERN; break; - case (ECL_INIT_FILE): - return ECL_INIT_FMT_PATTERN; + case (RD_INIT_FILE): + return RD_INIT_FMT_PATTERN; break; - case (ECL_RFT_FILE): - return ECL_RFT_FMT_PATTERN; + case (RD_RFT_FILE): + return RD_RFT_FMT_PATTERN; break; - case (ECL_DATA_FILE): - return ECL_DATA_PATTERN; + case (RD_DATA_FILE): + return RD_DATA_PATTERN; break; default: util_abort("%s: No pattern defined for til_type:%d \n", __func__, @@ -227,26 +226,26 @@ static const char *ecl_util_get_file_pattern(ecl_file_enum file_type, } } else { switch (file_type) { - case (ECL_OTHER_FILE): - return ECL_OTHER_FILE_UFMT_PATTERN; /* '*' */ + case (RD_OTHER_FILE): + return RD_OTHER_FILE_UFMT_PATTERN; /* '*' */ break; - case (ECL_UNIFIED_RESTART_FILE): - return ECL_UNIFIED_RESTART_UFMT_PATTERN; + case (RD_UNIFIED_RESTART_FILE): + return RD_UNIFIED_RESTART_UFMT_PATTERN; break; - case (ECL_UNIFIED_SUMMARY_FILE): - return ECL_UNIFIED_SUMMARY_UFMT_PATTERN; + case (RD_UNIFIED_SUMMARY_FILE): + return RD_UNIFIED_SUMMARY_UFMT_PATTERN; break; - case (ECL_GRID_FILE): - return ECL_GRID_UFMT_PATTERN; + case (RD_GRID_FILE): + return RD_GRID_UFMT_PATTERN; break; - case (ECL_EGRID_FILE): - return ECL_EGRID_UFMT_PATTERN; + case (RD_EGRID_FILE): + return RD_EGRID_UFMT_PATTERN; break; - case (ECL_INIT_FILE): - return ECL_INIT_UFMT_PATTERN; + case (RD_INIT_FILE): + return RD_INIT_UFMT_PATTERN; break; - case (ECL_RFT_FILE): - return ECL_RFT_UFMT_PATTERN; + case (RD_RFT_FILE): + return RD_RFT_UFMT_PATTERN; break; default: util_abort("%s: No pattern defined for til_type:%d \n", __func__, @@ -257,43 +256,43 @@ static const char *ecl_util_get_file_pattern(ecl_file_enum file_type, } /** - Takes an ecl_file_enum variable and returns string with a + Takes an rd_file_enum variable and returns string with a descriptive name of this file type. */ -const char *ecl_util_file_type_name(ecl_file_enum file_type) { +const char *rd_file_type_name(rd_file_enum file_type) { switch (file_type) { - case (ECL_OTHER_FILE): - return "ECL_OTHER_FILE"; + case (RD_OTHER_FILE): + return "RD_OTHER_FILE"; break; - case (ECL_RESTART_FILE): - return "ECL_RESTART_FILE"; + case (RD_RESTART_FILE): + return "RD_RESTART_FILE"; break; - case (ECL_UNIFIED_RESTART_FILE): - return "ECL_UNIFIED_RESTART_FILE"; + case (RD_UNIFIED_RESTART_FILE): + return "RD_UNIFIED_RESTART_FILE"; break; - case (ECL_SUMMARY_FILE): - return "ECL_SUMMARY_FILE"; + case (RD_SUMMARY_FILE): + return "RD_SUMMARY_FILE"; break; - case (ECL_UNIFIED_SUMMARY_FILE): - return "ECL_UNIFIED_SUMMARY_FILE"; + case (RD_UNIFIED_SUMMARY_FILE): + return "RD_UNIFIED_SUMMARY_FILE"; break; - case (ECL_SUMMARY_HEADER_FILE): - return "ECL_SUMMARY_HEADER_FILE"; + case (RD_SUMMARY_HEADER_FILE): + return "RD_SUMMARY_HEADER_FILE"; break; - case (ECL_GRID_FILE): - return "ECL_GRID_FILE"; + case (RD_GRID_FILE): + return "RD_GRID_FILE"; break; - case (ECL_EGRID_FILE): - return "ECL_EGRID_FILE"; + case (RD_EGRID_FILE): + return "RD_EGRID_FILE"; break; - case (ECL_INIT_FILE): - return "ECL_INIT_FILE"; + case (RD_INIT_FILE): + return "RD_INIT_FILE"; break; - case (ECL_RFT_FILE): - return "ECL_RFT_FILE"; + case (RD_RFT_FILE): + return "RD_RFT_FILE"; break; - case (ECL_DATA_FILE): - return "ECL_DATA_FILE"; + case (RD_DATA_FILE): + return "RD_DATA_FILE"; break; default: util_abort("%s: internal error type.%d not recognizxed \n", __func__, @@ -325,82 +324,81 @@ static bool base_has_upper(const char *input_base) { not exist NULL is returned. */ -static char *ecl_util_alloc_filename_static(const char *path, const char *base, - ecl_file_enum file_type, - bool fmt_file, int report_nr, - bool must_exist) { +static char *rd_alloc_filename_static(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file, + int report_nr, bool must_exist) { char *filename; char *ext; switch (file_type) { - case (ECL_RESTART_FILE): + case (RD_RESTART_FILE): if (fmt_file) ext = util_alloc_sprintf("F%04d", report_nr); else ext = util_alloc_sprintf("X%04d", report_nr); break; - case (ECL_UNIFIED_RESTART_FILE): + case (RD_UNIFIED_RESTART_FILE): if (fmt_file) ext = util_alloc_string_copy("FUNRST"); else ext = util_alloc_string_copy("UNRST"); break; - case (ECL_SUMMARY_FILE): + case (RD_SUMMARY_FILE): if (fmt_file) ext = util_alloc_sprintf("A%04d", report_nr); else ext = util_alloc_sprintf("S%04d", report_nr); break; - case (ECL_UNIFIED_SUMMARY_FILE): + case (RD_UNIFIED_SUMMARY_FILE): if (fmt_file) ext = util_alloc_string_copy("FUNSMRY"); else ext = util_alloc_string_copy("UNSMRY"); break; - case (ECL_SUMMARY_HEADER_FILE): + case (RD_SUMMARY_HEADER_FILE): if (fmt_file) ext = util_alloc_string_copy("FSMSPEC"); else ext = util_alloc_string_copy("SMSPEC"); break; - case (ECL_GRID_FILE): + case (RD_GRID_FILE): if (fmt_file) ext = util_alloc_string_copy("FGRID"); else ext = util_alloc_string_copy("GRID"); break; - case (ECL_EGRID_FILE): + case (RD_EGRID_FILE): if (fmt_file) ext = util_alloc_string_copy("FEGRID"); else ext = util_alloc_string_copy("EGRID"); break; - case (ECL_INIT_FILE): + case (RD_INIT_FILE): if (fmt_file) ext = util_alloc_string_copy("FINIT"); else ext = util_alloc_string_copy("INIT"); break; - case (ECL_RFT_FILE): + case (RD_RFT_FILE): if (fmt_file) ext = util_alloc_string_copy("FRFT"); else ext = util_alloc_string_copy("RFT"); break; - case (ECL_DATA_FILE): + case (RD_DATA_FILE): ext = util_alloc_string_copy("DATA"); break; default: - util_abort("%s: Invalid input file_type to ecl_util_alloc_filename - " + util_abort("%s: Invalid input file_type to rd_alloc_filename - " "aborting \n", __func__); /* Dummy to shut up compiler */ @@ -425,18 +423,17 @@ static char *ecl_util_alloc_filename_static(const char *path, const char *base, return filename; } -char *ecl_util_alloc_filename(const char *path, const char *base, - ecl_file_enum file_type, bool fmt_file, - int report_nr) { - return ecl_util_alloc_filename_static(path, base, file_type, fmt_file, - report_nr, false); +char *rd_alloc_filename(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file, int report_nr) { + return rd_alloc_filename_static(path, base, file_type, fmt_file, report_nr, + false); } -char *ecl_util_alloc_exfilename(const char *path, const char *base, - ecl_file_enum file_type, bool fmt_file, - int report_nr) { - return ecl_util_alloc_filename_static(path, base, file_type, fmt_file, - report_nr, true); +char *rd_alloc_exfilename(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file, + int report_nr) { + return rd_alloc_filename_static(path, base, file_type, fmt_file, report_nr, + true); } /** @@ -445,16 +442,16 @@ char *ecl_util_alloc_exfilename(const char *path, const char *base, will return NULL. */ -char *ecl_util_alloc_exfilename_anyfmt(const char *path, const char *base, - ecl_file_enum file_type, - bool fmt_file_first, int report_nr) { +char *rd_alloc_exfilename_anyfmt(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file_first, + int report_nr) { - char *filename = ecl_util_alloc_filename(path, base, file_type, - fmt_file_first, report_nr); + char *filename = + rd_alloc_filename(path, base, file_type, fmt_file_first, report_nr); if (!util_file_exists(filename)) { free(filename); - filename = ecl_util_alloc_filename(path, base, file_type, - !fmt_file_first, report_nr); + filename = rd_alloc_filename(path, base, file_type, !fmt_file_first, + report_nr); } if (!util_file_exists(filename)) { @@ -472,15 +469,15 @@ char *ecl_util_alloc_exfilename_anyfmt(const char *path, const char *base, is not checked for). o Both files are of type WITH a nnnn number at the end, the - function will fail hard in ecl_util_filename_report_nr() if + function will fail hard in rd_filename_report_nr() if this is not the case. */ -int ecl_util_fname_report_cmp(const void *f1, const void *f2) { +int rd_fname_report_cmp(const void *f1, const void *f2) { - int t1 = ecl_util_filename_report_nr((const char *)f1); - int t2 = ecl_util_filename_report_nr((const char *)f2); + int t1 = rd_filename_report_nr((const char *)f1); + int t2 = rd_filename_report_nr((const char *)f2); if (t1 < t2) return -1; @@ -493,7 +490,7 @@ int ecl_util_fname_report_cmp(const void *f1, const void *f2) { /** This function will scan the directory @path (or cwd if @path == NULL) for all ECLIPSE files of type @file_type. If base == NULL it will use - '*' as pattern for basename. If file_type == ECL_OTHER_FILE it will + '*' as pattern for basename. If file_type == RD_OTHER_FILE it will use '*' as pattern for the extension (as a consequence files which do not originate from ECLIPSE will also be included). @@ -555,11 +552,10 @@ static bool restart_lowercase_BINARY(const char *filename, const void *base) { return numeric_extension_predicate(filename, (const char *)base, 'x'); } -static int ecl_util_select_predicate_filelist(const char *path, - const char *base, - ecl_file_enum file_type, - bool fmt_file, bool upper_case, - stringlist_type *filelist) { +static int rd_select_predicate_filelist(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file, + bool upper_case, + stringlist_type *filelist) { file_pred_ftype *predicate = NULL; char *full_path = NULL; char *pure_base = NULL; @@ -569,7 +565,7 @@ static int ecl_util_select_predicate_filelist(const char *path, free(tmp); } - if (file_type == ECL_SUMMARY_FILE) { + if (file_type == RD_SUMMARY_FILE) { if (fmt_file) { if (upper_case) predicate = summary_UPPERCASE_ASCII; @@ -581,7 +577,7 @@ static int ecl_util_select_predicate_filelist(const char *path, else predicate = summary_lowercase_BINARY; } - } else if (file_type == ECL_RESTART_FILE) { + } else if (file_type == RD_RESTART_FILE) { if (fmt_file) { if (upper_case) predicate = restart_UPPERCASE_ASCII; @@ -599,24 +595,24 @@ static int ecl_util_select_predicate_filelist(const char *path, __func__, file_type); stringlist_select_files(filelist, full_path, predicate, pure_base); - stringlist_sort(filelist, ecl_util_fname_report_cmp); + stringlist_sort(filelist, rd_fname_report_cmp); free(pure_base); free(full_path); return stringlist_get_size(filelist); } -int ecl_util_select_filelist(const char *path, const char *base, - ecl_file_enum file_type, bool fmt_file, - stringlist_type *filelist) { +int rd_select_filelist(const char *path, const char *base, + rd_file_enum file_type, bool fmt_file, + stringlist_type *filelist) { stringlist_clear(filelist); bool upper_case = base_has_upper(base); - if (file_type == ECL_SUMMARY_FILE || file_type == ECL_RESTART_FILE) - return ecl_util_select_predicate_filelist( - path, base, file_type, fmt_file, upper_case, filelist); + if (file_type == RD_SUMMARY_FILE || file_type == RD_RESTART_FILE) + return rd_select_predicate_filelist(path, base, file_type, fmt_file, + upper_case, filelist); char *ext_pattern = - util_alloc_string_copy(ecl_util_get_file_pattern(file_type, fmt_file)); + util_alloc_string_copy(rd_get_file_pattern(file_type, fmt_file)); if (!upper_case) { for (size_t i = 0; i < strlen(ext_pattern); i++) @@ -636,39 +632,39 @@ int ecl_util_select_filelist(const char *path, const char *base, return stringlist_get_size(filelist); } -bool ecl_util_unified_file(const char *filename) { +bool rd_unified_file(const char *filename) { int report_nr; - ecl_file_enum file_type; + rd_file_enum file_type; bool fmt_file; - file_type = ecl_util_get_file_type(filename, &fmt_file, &report_nr); + file_type = rd_get_file_type(filename, &fmt_file, &report_nr); - if ((file_type == ECL_UNIFIED_RESTART_FILE) || - (file_type == ECL_UNIFIED_SUMMARY_FILE)) + if ((file_type == RD_UNIFIED_RESTART_FILE) || + (file_type == RD_UNIFIED_SUMMARY_FILE)) return true; else return false; } -bool ecl_util_fmt_file(const char *filename, bool *__fmt_file) { +bool rd_fmt_file(const char *filename, bool *__fmt_file) { /*const int min_size = 32768;*/ const int min_size = 256; /* Veeeery small */ int report_nr; - ecl_file_enum file_type; + rd_file_enum file_type; bool status = true; bool fmt_file = 0; if (util_file_exists(filename)) { - file_type = ecl_util_get_file_type(filename, &fmt_file, &report_nr); - if (file_type == ECL_OTHER_FILE) { + file_type = rd_get_file_type(filename, &fmt_file, &report_nr); + if (file_type == RD_OTHER_FILE) { if (util_file_size(filename) > min_size) fmt_file = util_fmt_bit8(filename); else status = false; // Do not know ?? } } else { - file_type = ecl_util_get_file_type(filename, &fmt_file, &report_nr); - if (file_type == ECL_OTHER_FILE) + file_type = rd_get_file_type(filename, &fmt_file, &report_nr); + if (file_type == RD_OTHER_FILE) status = false; // Do not know ?? } @@ -682,24 +678,24 @@ bool ecl_util_fmt_file(const char *filename, bool *__fmt_file) { appropriate numerical conversion is applied. */ -void ecl_util_memcpy_typed_data(void *_target_data, const void *_src_data, - ecl_data_type target_type, - ecl_data_type src_type, int size) { +void rd_memcpy_typed_data(void *_target_data, const void *_src_data, + rd_data_type target_type, rd_data_type src_type, + int size) { int i; - if (ecl_type_is_equal(target_type, src_type)) + if (rd_type_is_equal(target_type, src_type)) memcpy(_target_data, _src_data, - size * ecl_type_get_sizeof_ctype(src_type)); + size * rd_type_get_sizeof_ctype(src_type)); else { - switch (ecl_type_get_type(target_type)) { - case (ECL_DOUBLE_TYPE): { + switch (rd_type_get_type(target_type)) { + case (RD_DOUBLE_TYPE): { double *target_data = (double *)_target_data; - switch (ecl_type_get_type(src_type)) { - case (ECL_FLOAT_TYPE): + switch (rd_type_get_type(src_type)) { + case (RD_FLOAT_TYPE): util_float_to_double(target_data, (const float *)_src_data, size); break; - case (ECL_INT_TYPE): + case (RD_INT_TYPE): for (i = 0; i < size; i++) target_data[i] = ((int *)_src_data)[i]; break; @@ -710,14 +706,14 @@ void ecl_util_memcpy_typed_data(void *_target_data, const void *_src_data, } break; } - case (ECL_FLOAT_TYPE): { + case (RD_FLOAT_TYPE): { float *target_data = (float *)_target_data; - switch (ecl_type_get_type(src_type)) { - case (ECL_FLOAT_TYPE): + switch (rd_type_get_type(src_type)) { + case (RD_FLOAT_TYPE): util_double_to_float(target_data, (const double *)_src_data, size); break; - case (ECL_INT_TYPE): + case (RD_INT_TYPE): for (i = 0; i < size; i++) target_data[i] = ((int *)_src_data)[i]; break; @@ -730,8 +726,8 @@ void ecl_util_memcpy_typed_data(void *_target_data, const void *_src_data, } default: util_abort("%s con not convert %s -> %s \n", __func__, - ecl_type_alloc_name(src_type), - ecl_type_alloc_name(target_type)); + rd_type_alloc_name(src_type), + rd_type_alloc_name(target_type)); } } } @@ -742,13 +738,12 @@ void ecl_util_memcpy_typed_data(void *_target_data, const void *_src_data, @base input can contain an embedded path component. */ -void ecl_util_alloc_summary_data_files(const char *path, const char *base, - bool fmt_file, - stringlist_type *filelist) { - char *unif_data_file = ecl_util_alloc_exfilename( - path, base, ECL_UNIFIED_SUMMARY_FILE, fmt_file, -1); - int files = ecl_util_select_filelist(path, base, ECL_SUMMARY_FILE, fmt_file, - filelist); +void rd_alloc_summary_data_files(const char *path, const char *base, + bool fmt_file, stringlist_type *filelist) { + char *unif_data_file = + rd_alloc_exfilename(path, base, RD_UNIFIED_SUMMARY_FILE, fmt_file, -1); + int files = + rd_select_filelist(path, base, RD_SUMMARY_FILE, fmt_file, filelist); if ((files > 0) && (unif_data_file != NULL)) { /* @@ -813,9 +808,9 @@ void ecl_util_alloc_summary_data_files(const char *path, const char *base, surely possible to fool it. */ -bool ecl_util_alloc_summary_files(const char *path, const char *_base, - const char *ext, char **_header_file, - stringlist_type *filelist) { +bool rd_alloc_summary_files(const char *path, const char *_base, + const char *ext, char **_header_file, + stringlist_type *filelist) { bool fmt_input = false; bool fmt_set = false; bool fmt_file = true; @@ -834,33 +829,33 @@ bool ecl_util_alloc_summary_files(const char *path, const char *_base, */ if (_base == NULL) - base = ecl_util_alloc_base_guess(path); + base = rd_alloc_base_guess(path); else base = (char *)_base; if (ext != NULL) { - ecl_file_enum input_type; + rd_file_enum input_type; { char *test_name = util_alloc_filename(NULL, base, ext); - input_type = ecl_util_get_file_type(test_name, &fmt_input, NULL); + input_type = rd_get_file_type(test_name, &fmt_input, NULL); free(test_name); } - if ((input_type != ECL_OTHER_FILE) && (input_type != ECL_DATA_FILE)) { + if ((input_type != RD_OTHER_FILE) && (input_type != RD_DATA_FILE)) { /* The file has been recognized as a file type from which we can at least infer formatted/unformatted inforamtion. */ fmt_set = true; switch (input_type) { - case (ECL_SUMMARY_FILE): - case (ECL_RESTART_FILE): + case (RD_SUMMARY_FILE): + case (RD_RESTART_FILE): unif_input = false; unif_set = true; break; - case (ECL_UNIFIED_SUMMARY_FILE): - case (ECL_UNIFIED_RESTART_FILE): + case (RD_UNIFIED_SUMMARY_FILE): + case (RD_UNIFIED_RESTART_FILE): unif_input = true; unif_set = true; break; @@ -875,10 +870,10 @@ bool ecl_util_alloc_summary_files(const char *path, const char *_base, */ { - char *fsmspec_file = ecl_util_alloc_exfilename( - path, base, ECL_SUMMARY_HEADER_FILE, true, -1); - char *smspec_file = ecl_util_alloc_exfilename( - path, base, ECL_SUMMARY_HEADER_FILE, false, -1); + char *fsmspec_file = + rd_alloc_exfilename(path, base, RD_SUMMARY_HEADER_FILE, true, -1); + char *smspec_file = + rd_alloc_exfilename(path, base, RD_SUMMARY_HEADER_FILE, false, -1); if ((fsmspec_file == NULL) && (smspec_file == NULL)) /* Neither file exists */ @@ -923,17 +918,16 @@ bool ecl_util_alloc_summary_files(const char *path, const char *_base, non-unified input files. */ if (unif_input) { - char *unif_data_file = ecl_util_alloc_exfilename( - path, base, ECL_UNIFIED_SUMMARY_FILE, fmt_file, -1); + char *unif_data_file = rd_alloc_exfilename( + path, base, RD_UNIFIED_SUMMARY_FILE, fmt_file, -1); if (unif_data_file != NULL) { stringlist_append_copy(filelist, unif_data_file); free(unif_data_file); } } else - ecl_util_select_filelist(path, base, ECL_SUMMARY_FILE, fmt_file, - filelist); + rd_select_filelist(path, base, RD_SUMMARY_FILE, fmt_file, filelist); } else - ecl_util_alloc_summary_data_files(path, base, fmt_file, filelist); + rd_alloc_summary_data_files(path, base, fmt_file, filelist); if (_base == NULL) free(base); @@ -943,10 +937,9 @@ bool ecl_util_alloc_summary_files(const char *path, const char *_base, return (stringlist_get_size(filelist) > 0) ? true : false; } -void ecl_util_alloc_restart_files(const char *path, const char *_base, - char ***_restart_files, - int *num_restart_files, bool *_fmt_file, - bool *_unified) { +void rd_alloc_restart_files(const char *path, const char *_base, + char ***_restart_files, int *num_restart_files, + bool *_fmt_file, bool *_unified) { util_exit("Function:%s currently not implemented - sorry \n", __func__); } @@ -959,7 +952,7 @@ safely used as filenames, i.e for instance the substitution: The escape process is done 'in-place' memory-wise. */ -void ecl_util_escape_kw(char *kw) { +void rd_escape_kw(char *kw) { size_t index; for (index = 0; index < strlen(kw); index++) { switch (kw[index]) { @@ -977,7 +970,7 @@ void ecl_util_escape_kw(char *kw) { Will return -1 for an unrecognized month name. */ -static int ecl_util_get_month_nr__(const char *_month_name) { +static int rd_get_month_nr__(const char *_month_name) { int month_nr = -1; char *month_name = util_alloc_string_copy(_month_name); util_strupr(month_name); @@ -1018,8 +1011,8 @@ static int ecl_util_get_month_nr__(const char *_month_name) { return month_nr; } -int ecl_util_get_month_nr(const char *month_name) { - int month_nr = ecl_util_get_month_nr__(month_name); +int rd_get_month_nr(const char *month_name) { + int month_nr = rd_get_month_nr__(month_name); if (month_nr < 0) util_abort("%s: %s not a valid month name - aborting \n", __func__, month_name); @@ -1036,7 +1029,7 @@ int ecl_util_get_month_nr(const char *month_name) { */ -time_t ecl_util_get_start_date(const char *data_file) { +time_t rd_get_start_date(const char *data_file) { basic_parser_type *parser = basic_parser_alloc(" \t\r\n", "\"\'", NULL, NULL, "--", "\n"); time_t start_date = -1; @@ -1071,8 +1064,8 @@ time_t ecl_util_get_start_date(const char *data_file) { int day, year, month_nr; if (util_sscanf_int(stringlist_iget(tokens, 0), &day) && util_sscanf_int(stringlist_iget(tokens, 2), &year)) { - month_nr = ecl_util_get_month_nr(stringlist_iget(tokens, 1)); - start_date = ecl_util_make_date(day, month_nr, year); + month_nr = rd_get_month_nr(stringlist_iget(tokens, 1)); + start_date = rd_make_date(day, month_nr, year); } else util_abort("%s: failed to parse DAY MONTH YEAR from : \"%s\" \n", __func__, buffer); @@ -1086,9 +1079,8 @@ time_t ecl_util_get_start_date(const char *data_file) { return start_date; } -static int ecl_util_get_num_parallel_cpu__(basic_parser_type *parser, - FILE *stream, - const char *data_file) { +static int rd_get_num_parallel_cpu__(basic_parser_type *parser, FILE *stream, + const char *data_file) { int num_cpu = 1; char *buffer; long int start_pos = util_ftell(stream); @@ -1127,8 +1119,8 @@ static int ecl_util_get_num_parallel_cpu__(basic_parser_type *parser, return num_cpu; } -static int ecl_util_get_num_slave_cpu__(basic_parser_type *parser, FILE *stream, - const char *data_file) { +static int rd_get_num_slave_cpu__(basic_parser_type *parser, FILE *stream, + const char *data_file) { int num_cpu = 0; int linecount = 0; @@ -1184,8 +1176,8 @@ static int ecl_util_get_num_slave_cpu__(basic_parser_type *parser, FILE *stream, the first occurence of a keyword outside of titles and comments. This code is somewhat complicated since it seems that the spec allows for multiple titles and (possibly) blank lines between the title keyword and the title. */ -static bool ecl_util_find_keyword__(basic_parser_type *parser, FILE *stream, - const char *keyword) { +static bool rd_find_keyword__(basic_parser_type *parser, FILE *stream, + const char *keyword) { long int title_pos = -1; /* Find the first occurenced of TITLE, if any. */ @@ -1241,16 +1233,16 @@ static bool ecl_util_find_keyword__(basic_parser_type *parser, FILE *stream, return false; } -int ecl_util_get_num_cpu(const char *data_file) { +int rd_get_num_cpu(const char *data_file) { int num_cpu = 1; basic_parser_type *parser = basic_parser_alloc(" \t\r\n", "\"\'", NULL, NULL, "--", "\n"); FILE *stream = util_fopen(data_file, "r"); - if (ecl_util_find_keyword__(parser, stream, "PARALLEL")) { - num_cpu = ecl_util_get_num_parallel_cpu__(parser, stream, data_file); - } else if (ecl_util_find_keyword__(parser, stream, "SLAVES")) { - num_cpu = ecl_util_get_num_slave_cpu__(parser, stream, data_file) + 1; + if (rd_find_keyword__(parser, stream, "PARALLEL")) { + num_cpu = rd_get_num_parallel_cpu__(parser, stream, data_file); + } else if (rd_find_keyword__(parser, stream, "SLAVES")) { + num_cpu = rd_get_num_slave_cpu__(parser, stream, data_file) + 1; fprintf(stderr, "Information: \"SLAVES\" option found, returning %d number " "of CPUs", @@ -1262,18 +1254,18 @@ int ecl_util_get_num_cpu(const char *data_file) { return num_cpu; } -ert_ecl_unit_enum ecl_util_get_unit_set(const char *data_file) { - ert_ecl_unit_enum units = ECL_METRIC_UNITS; +ert_rd_unit_enum rd_get_unit_set(const char *data_file) { + ert_rd_unit_enum units = RD_METRIC_UNITS; basic_parser_type *parser = basic_parser_alloc(" \t\r\n", "\"\'", NULL, NULL, "--", "\n"); FILE *stream = util_fopen(data_file, "r"); if (basic_parser_fseek_string(parser, stream, "FIELD", true, true)) { /* Seeks case insensitive. */ - units = ECL_FIELD_UNITS; + units = RD_FIELD_UNITS; } else if (basic_parser_fseek_string(parser, stream, "LAB", true, true)) { /* Seeks case insensitive. */ - units = ECL_LAB_UNITS; + units = RD_LAB_UNITS; } basic_parser_free(parser); @@ -1281,7 +1273,7 @@ ert_ecl_unit_enum ecl_util_get_unit_set(const char *data_file) { return units; } -bool ecl_util_valid_basename_fmt(const char *basename_fmt) { +bool rd_valid_basename_fmt(const char *basename_fmt) { char *eclbasename_fmt = util_split_alloc_filename(basename_fmt); bool valid = true; @@ -1325,9 +1317,8 @@ bool ecl_util_valid_basename_fmt(const char *basename_fmt) { to insertion. */ -void ecl_util_append_month_range(time_t_vector_type *date_list, - time_t start_date, time_t end_date, - bool force_append_end) { +void rd_append_month_range(time_t_vector_type *date_list, time_t start_date, + time_t end_date, bool force_append_end) { start_date = util_make_pure_date_utc(start_date); end_date = util_make_pure_date_utc(end_date); @@ -1345,7 +1336,7 @@ void ecl_util_append_month_range(time_t_vector_type *date_list, } else month += 1; - current_date = ecl_util_make_date(1, month, year); + current_date = rd_make_date(1, month, year); if (current_date < end_date) time_t_vector_append(date_list, current_date); else { @@ -1359,18 +1350,17 @@ void ecl_util_append_month_range(time_t_vector_type *date_list, } } -void ecl_util_init_month_range(time_t_vector_type *date_list, time_t start_date, - time_t end_date) { +void rd_init_month_range(time_t_vector_type *date_list, time_t start_date, + time_t end_date) { time_t_vector_reset(date_list); if (!util_is_first_day_in_month_utc(start_date)) time_t_vector_append(date_list, util_make_pure_date_utc(start_date)); - ecl_util_append_month_range(date_list, start_date, end_date, true); + rd_append_month_range(date_list, start_date, end_date, true); } -static time_t ecl_util_make_datetime__(int sec, int min, int hour, int mday, - int month, int year, - int *__year_offset) { +static time_t rd_make_datetime__(int sec, int min, int hour, int mday, + int month, int year, int *__year_offset) { time_t date; #ifdef ERT_TIME_T_64BIT_ACCEPT_PRE1970 @@ -1398,28 +1388,27 @@ static time_t ecl_util_make_datetime__(int sec, int min, int hour, int mday, return date; } -time_t ecl_util_make_date__(int mday, int month, int year, int *__year_offset) { - return ecl_util_make_datetime__(0, 0, 0, mday, month, year, __year_offset); +time_t rd_make_date__(int mday, int month, int year, int *__year_offset) { + return rd_make_datetime__(0, 0, 0, mday, month, year, __year_offset); } -time_t ecl_util_make_date(int mday, int month, int year) { +time_t rd_make_date(int mday, int month, int year) { int year_offset; - return ecl_util_make_date__(mday, month, year, &year_offset); + return rd_make_date__(mday, month, year, &year_offset); } -time_t ecl_util_make_datetime(int sec, int min, int hour, int mday, int month, - int year) { +time_t rd_make_datetime(int sec, int min, int hour, int mday, int month, + int year) { int year_offset; - return ecl_util_make_datetime__(sec, min, hour, mday, month, year, - &year_offset); + return rd_make_datetime__(sec, min, hour, mday, month, year, &year_offset); } -void ecl_util_set_date_values(time_t t, int *mday, int *month, int *year) { +void rd_set_date_values(time_t t, int *mday, int *month, int *year) { return util_set_date_values_utc(t, mday, month, year); } -void ecl_util_set_datetime_values(time_t t, int *sec, int *min, int *hour, - int *mday, int *month, int *year) { +void rd_set_datetime_values(time_t t, int *sec, int *min, int *hour, int *mday, + int *month, int *year) { return util_set_datetime_values_utc(t, sec, min, hour, mday, month, year); } @@ -1429,14 +1418,14 @@ void ecl_util_set_datetime_values(time_t t, int *sec, int *min, int *hour, /* This is a small function which tries to give a sensible answer to the - question: Do I have read access to this eclipse simulation? The ecl_case + question: Do I have read access to this eclipse simulation? The rd_case argument can either be a directory or the full path to a file, the filename need not exists. The approach is as follows: - 1. If @ecl_case corresponds to an existing filesystem entry - just return - access(ecl_case, R_OK). + 1. If @rd_case corresponds to an existing filesystem entry - just return + access(rd_case, R_OK). - 2. If @ecl_case corresponds to a non-existing entry: + 2. If @rd_case corresponds to a non-existing entry: a) If there is a directory part - return access(dir, R_OK). b) No directory part - return access(cwd, R_OK); @@ -1445,17 +1434,17 @@ void ecl_util_set_datetime_values(time_t t, int *sec, int *min, int *hour, that could in principle be denied - but that is a highly contrived situation and we just return true. - ecl_util_access_path("PATH") -> access("PATH", R_OK); - ecl_util_access_path("PATH/FILE_EXISTS") -> access("PATH/FILE_EXISTS", R_OK); - ecl_util_access_path("PATH/FILE_DOES_NOT_EXIST") -> access("PATH", R_OK); - ecl_util_access_path("PATH_DOES_NOT_EXIST") -> true + rd_access_path("PATH") -> access("PATH", R_OK); + rd_access_path("PATH/FILE_EXISTS") -> access("PATH/FILE_EXISTS", R_OK); + rd_access_path("PATH/FILE_DOES_NOT_EXIST") -> access("PATH", R_OK); + rd_access_path("PATH_DOES_NOT_EXIST") -> true */ -bool ecl_util_path_access(const char *ecl_case) { - if (util_access(ecl_case, R_OK)) +bool rd_path_access(const char *rd_case) { + if (util_access(rd_case, R_OK)) return true; - if (util_access(ecl_case, F_OK)) + if (util_access(rd_case, F_OK)) return false; /* Check if the input argument corresponds to an existing directory and one @@ -1464,14 +1453,14 @@ bool ecl_util_path_access(const char *ecl_case) { { bool path_access; char *dir_name; - const char *path_sep = strrchr(ecl_case, UTIL_PATH_SEP_CHAR); + const char *path_sep = strrchr(rd_case, UTIL_PATH_SEP_CHAR); if (!path_sep) /* We are trying to access CWD - we return true without actually checking access. */ return true; - dir_name = util_alloc_substring_copy(ecl_case, 0, path_sep - ecl_case); + dir_name = util_alloc_substring_copy(rd_case, 0, path_sep - rd_case); path_access = util_access(dir_name, R_OK); free(dir_name); return path_access; diff --git a/lib/resdata/readme.overview b/lib/resdata/readme.overview index f13e6fb908..a175471b57 100644 --- a/lib/resdata/readme.overview +++ b/lib/resdata/readme.overview @@ -45,7 +45,7 @@ path-config file: LIBUTIL_HOME = /h/a152128/EnKF/EnKF/libutil LIBSCHED_HOME = /h/a152128/EnKF/EnKF/libsched LIBRMS_HOME = /h/a152128/EnKF/EnKF/librms - LIBECL_HOME = /h/a152128/EnKF/EnKF/resdata + LIBRD_HOME = /h/a152128/EnKF/EnKF/resdata LIBENKF_HOME = /h/a152128/EnKF/EnKF/libenkf In this example all libraries have a common path prefix, that is not diff --git a/lib/resdata/smspec_node.cpp b/lib/resdata/smspec_node.cpp index 73c7d80c79..fe3e20220c 100644 --- a/lib/resdata/smspec_node.cpp +++ b/lib/resdata/smspec_node.cpp @@ -20,12 +20,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "detail/util/string_util.hpp" @@ -33,14 +33,14 @@ The special_vars list is used to associate keywords with special types, when the kewyord name is in conflict with the default vector naming convention; all the variables mentioned in the list below - are given the type ECL_SMSPEC_MISC_VAR. + are given the type RD_SMSPEC_MISC_VAR. For instance the keyword 'NEWTON' starts with 'N' and is classified as a NETWORK type variable. However it should rather be classified as a MISC type variable. The special_vars list is used in the functions - ecl_smspec_identify_special_var() and ecl_smspec_identify_var_type(). + rd_smspec_identify_special_var() and rd_smspec_identify_var_type(). */ static const char *special_vars[] = { @@ -61,22 +61,22 @@ static const int nums_unused = 0; Goes through the special_vars static table to check if @var is one the special variables which does not follow normal naming convention. If the test evaluates to true the function will return - ECL_SMSPEC_MISC_VAR, otherwise the function will return - ECL_SMSPEC_INVALID_VAR and the variable type will be determined + RD_SMSPEC_MISC_VAR, otherwise the function will return + RD_SMSPEC_INVALID_VAR and the variable type will be determined from the var name according to standard naming conventions. It is important that this function is called before the standard method. */ -ecl_smspec_var_type ecl::smspec_node::identify_special_var(const char *var) { - ecl_smspec_var_type var_type = ECL_SMSPEC_INVALID_VAR; +rd_smspec_var_type rd::smspec_node::identify_special_var(const char *var) { + rd_smspec_var_type var_type = RD_SMSPEC_INVALID_VAR; int num_special = sizeof(special_vars) / sizeof(special_vars[0]); int i; for (i = 0; i < num_special; i++) { if (strcmp(var, special_vars[i]) == 0) { - var_type = ECL_SMSPEC_MISC_VAR; + var_type = RD_SMSPEC_MISC_VAR; break; } } @@ -87,41 +87,41 @@ ecl_smspec_var_type ecl::smspec_node::identify_special_var(const char *var) { /* See table 3.4 in the ECLIPSE file format reference manual. - Observe that the combined ecl_sum style keys like e.g. WWCT:OP1 + Observe that the combined rd_sum style keys like e.g. WWCT:OP1 should be formatted with the keyword first, so that this function - will identify both 'WWCT' and 'WWCT:OP_1' as a ECL_SMSPEC_WELL_VAR + will identify both 'WWCT' and 'WWCT:OP_1' as a RD_SMSPEC_WELL_VAR instance. */ -ecl_smspec_var_type ecl::smspec_node::identify_var_type(const char *var) { - ecl_smspec_var_type var_type = ecl::smspec_node::identify_special_var(var); - if (var_type == ECL_SMSPEC_INVALID_VAR) { +rd_smspec_var_type rd::smspec_node::identify_var_type(const char *var) { + rd_smspec_var_type var_type = rd::smspec_node::identify_special_var(var); + if (var_type == RD_SMSPEC_INVALID_VAR) { switch (var[0]) { case ('A'): - var_type = ECL_SMSPEC_AQUIFER_VAR; + var_type = RD_SMSPEC_AQUIFER_VAR; break; case ('B'): - var_type = ECL_SMSPEC_BLOCK_VAR; + var_type = RD_SMSPEC_BLOCK_VAR; break; case ('C'): - var_type = ECL_SMSPEC_COMPLETION_VAR; + var_type = RD_SMSPEC_COMPLETION_VAR; break; case ('F'): - var_type = ECL_SMSPEC_FIELD_VAR; + var_type = RD_SMSPEC_FIELD_VAR; break; case ('G'): - var_type = ECL_SMSPEC_GROUP_VAR; + var_type = RD_SMSPEC_GROUP_VAR; break; case ('L'): switch (var[1]) { case ('B'): - var_type = ECL_SMSPEC_LOCAL_BLOCK_VAR; + var_type = RD_SMSPEC_LOCAL_BLOCK_VAR; break; case ('C'): - var_type = ECL_SMSPEC_LOCAL_COMPLETION_VAR; + var_type = RD_SMSPEC_LOCAL_COMPLETION_VAR; break; case ('W'): - var_type = ECL_SMSPEC_LOCAL_WELL_VAR; + var_type = RD_SMSPEC_LOCAL_WELL_VAR; break; default: /* @@ -131,11 +131,11 @@ ecl_smspec_var_type ecl::smspec_node::identify_var_type(const char *var) { category; at least the LLINEAR keyword is an example of such a keyword. */ - var_type = ECL_SMSPEC_MISC_VAR; + var_type = RD_SMSPEC_MISC_VAR; } break; case ('N'): - var_type = ECL_SMSPEC_NETWORK_VAR; + var_type = RD_SMSPEC_NETWORK_VAR; break; case ('R'): { /* @@ -161,24 +161,24 @@ ecl_smspec_var_type ecl::smspec_node::identify_var_type(const char *var) { */ if (strlen(var) == 3 && var[2] == 'F') { - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + var_type = RD_SMSPEC_REGION_2_REGION_VAR; break; } if (util_string_equal(var, "RNLF")) { - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + var_type = RD_SMSPEC_REGION_2_REGION_VAR; break; } if (util_string_equal(var, "RORFR")) { - var_type = ECL_SMSPEC_REGION_VAR; + var_type = RD_SMSPEC_REGION_VAR; break; } if (strlen(var) >= 4) { if (var[2] == 'F') { if (var[3] == 'T' || var[3] == 'R') { - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + var_type = RD_SMSPEC_REGION_2_REGION_VAR; break; } } @@ -187,26 +187,26 @@ ecl_smspec_var_type ecl::smspec_node::identify_var_type(const char *var) { if (strlen(var) >= 5) { if (var[3] == 'F') { if (var[4] == 'T' || var[4] == 'R') { - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + var_type = RD_SMSPEC_REGION_2_REGION_VAR; break; } } } - var_type = ECL_SMSPEC_REGION_VAR; + var_type = RD_SMSPEC_REGION_VAR; } break; case ('S'): - var_type = ECL_SMSPEC_SEGMENT_VAR; + var_type = RD_SMSPEC_SEGMENT_VAR; break; case ('W'): - var_type = ECL_SMSPEC_WELL_VAR; + var_type = RD_SMSPEC_WELL_VAR; break; default: /* It is unfortunately impossible to recognize an error situation - the rest just goes in "other" variables. */ - var_type = ECL_SMSPEC_MISC_VAR; + var_type = RD_SMSPEC_MISC_VAR; } } @@ -216,65 +216,65 @@ ecl_smspec_var_type ecl::smspec_node::identify_var_type(const char *var) { /* The key formats for the combined keys like e.g. 'WWCT:OP_5' should have the keyword, i.e. 'WWCT', as the first part of the string. That - guarantees that the function ecl_smspec_identify_var_type() can take + guarantees that the function rd_smspec_identify_var_type() can take both a pure ECLIPSE variable name, like .e.g 'WWCT' and also an - ecl_sum combined key like 'WWCT:OPX' as input. + rd_sum combined key like 'WWCT:OPX' as input. */ -#define ECL_SUM_KEYFMT_AQUIFER "%s%s%d" -#define ECL_SUM_KEYFMT_BLOCK_IJK "%s%s%d,%d,%d" -#define ECL_SUM_KEYFMT_BLOCK_NUM "%s%s%d" -#define ECL_SUM_KEYFMT_LOCAL_BLOCK "%s%s%s%s%d,%d,%d" -#define ECL_SUM_KEYFMT_COMPLETION_IJK "%s%s%s%s%d,%d,%d" -#define ECL_SUM_KEYFMT_COMPLETION_NUM "%s%s%s%s%d" -#define ECL_SUM_KEYFMT_LOCAL_COMPLETION "%s%s%s%s%s%s%d,%d,%d" -#define ECL_SUM_KEYFMT_GROUP "%s%s%s" -#define ECL_SUM_KEYFMT_WELL "%s%s%s" -#define ECL_SUM_KEYFMT_REGION "%s%s%d" -#define ECL_SUM_KEYFMT_REGION_2_REGION_R1R2 "%s%s%d-%d" -#define ECL_SUM_KEYFMT_REGION_2_REGION_NUM "%s%s%d" -#define ECL_SUM_KEYFMT_SEGMENT "%s%s%s%s%d" -#define ECL_SUM_KEYFMT_LOCAL_WELL "%s%s%s%s%s" +#define RD_SUM_KEYFMT_AQUIFER "%s%s%d" +#define RD_SUM_KEYFMT_BLOCK_IJK "%s%s%d,%d,%d" +#define RD_SUM_KEYFMT_BLOCK_NUM "%s%s%d" +#define RD_SUM_KEYFMT_LOCAL_BLOCK "%s%s%s%s%d,%d,%d" +#define RD_SUM_KEYFMT_COMPLETION_IJK "%s%s%s%s%d,%d,%d" +#define RD_SUM_KEYFMT_COMPLETION_NUM "%s%s%s%s%d" +#define RD_SUM_KEYFMT_LOCAL_COMPLETION "%s%s%s%s%s%s%d,%d,%d" +#define RD_SUM_KEYFMT_GROUP "%s%s%s" +#define RD_SUM_KEYFMT_WELL "%s%s%s" +#define RD_SUM_KEYFMT_REGION "%s%s%d" +#define RD_SUM_KEYFMT_REGION_2_REGION_R1R2 "%s%s%d-%d" +#define RD_SUM_KEYFMT_REGION_2_REGION_NUM "%s%s%d" +#define RD_SUM_KEYFMT_SEGMENT "%s%s%s%s%d" +#define RD_SUM_KEYFMT_LOCAL_WELL "%s%s%s%s%s" std::string smspec_alloc_block_num_key(const char *join_string, const std::string &keyword, int num) { - return ecl::util::string_format(ECL_SUM_KEYFMT_BLOCK_NUM, keyword.c_str(), - join_string, num); + return rd::util::string_format(RD_SUM_KEYFMT_BLOCK_NUM, keyword.c_str(), + join_string, num); } std::string smspec_alloc_aquifer_key(const char *join_string, const std::string &keyword, int num) { - return ecl::util::string_format(ECL_SUM_KEYFMT_AQUIFER, keyword.c_str(), - join_string, num); + return rd::util::string_format(RD_SUM_KEYFMT_AQUIFER, keyword.c_str(), + join_string, num); } std::string smspec_alloc_local_block_key(const char *join_string, const std::string &keyword, const std::string &lgr_name, int i, int j, int k) { - return ecl::util::string_format(ECL_SUM_KEYFMT_LOCAL_BLOCK, keyword.c_str(), - join_string, lgr_name.c_str(), join_string, - i, j, k); + return rd::util::string_format(RD_SUM_KEYFMT_LOCAL_BLOCK, keyword.c_str(), + join_string, lgr_name.c_str(), join_string, + i, j, k); } std::string smspec_alloc_region_key(const char *join_string, const std::string &keyword, int num) { - return ecl::util::string_format(ECL_SUM_KEYFMT_REGION, keyword.c_str(), - join_string, num); + return rd::util::string_format(RD_SUM_KEYFMT_REGION, keyword.c_str(), + join_string, num); } std::string smspec_alloc_region_2_region_r1r2_key(const char *join_string, const std::string &keyword, int r1, int r2) { - return ecl::util::string_format(ECL_SUM_KEYFMT_REGION_2_REGION_R1R2, - keyword.c_str(), join_string, r1, r2); + return rd::util::string_format(RD_SUM_KEYFMT_REGION_2_REGION_R1R2, + keyword.c_str(), join_string, r1, r2); } std::string smspec_alloc_region_2_region_num_key(const char *join_string, const std::string &keyword, int num) { - return ecl::util::string_format(ECL_SUM_KEYFMT_REGION_2_REGION_NUM, - keyword.c_str(), join_string, num); + return rd::util::string_format(RD_SUM_KEYFMT_REGION_2_REGION_NUM, + keyword.c_str(), join_string, num); } char *smspec_alloc_completion_ijk_key(const char *join_string, @@ -282,9 +282,9 @@ char *smspec_alloc_completion_ijk_key(const char *join_string, const std::string &wgname, int i, int j, int k) { if (wgname.size() > 0) - return util_alloc_sprintf(ECL_SUM_KEYFMT_COMPLETION_IJK, - keyword.c_str(), join_string, wgname.c_str(), - join_string, i, j, k); + return util_alloc_sprintf(RD_SUM_KEYFMT_COMPLETION_IJK, keyword.c_str(), + join_string, wgname.c_str(), join_string, i, + j, k); else return NULL; } @@ -293,9 +293,9 @@ char *smspec_alloc_completion_num_key(const char *join_string, const std::string &keyword, const std::string &wgname, int num) { if (wgname.size() > 0) - return util_alloc_sprintf(ECL_SUM_KEYFMT_COMPLETION_NUM, - keyword.c_str(), join_string, wgname.c_str(), - join_string, num); + return util_alloc_sprintf(RD_SUM_KEYFMT_COMPLETION_NUM, keyword.c_str(), + join_string, wgname.c_str(), join_string, + num); else return NULL; } @@ -311,8 +311,8 @@ static std::string smspec_alloc_wgname_key(const char *join_string, const std::string &keyword, const std::string &wgname) { if (wgname.size() > 0) - return ecl::util::string_format(ECL_SUM_KEYFMT_WELL, keyword.c_str(), - join_string, wgname.c_str()); + return rd::util::string_format(RD_SUM_KEYFMT_WELL, keyword.c_str(), + join_string, wgname.c_str()); else return ""; } @@ -335,28 +335,27 @@ std::string smspec_alloc_well_key(const char *join_string, char *smspec_alloc_well_key(const char *join_string, const char *keyword, const char *wgname) { - return util_alloc_sprintf(ECL_SUM_KEYFMT_WELL, keyword, join_string, - wgname); + return util_alloc_sprintf(RD_SUM_KEYFMT_WELL, keyword, join_string, wgname); } char *smspec_alloc_block_ijk_key(const char *join_string, const char *keyword, int i, int j, int k) { - return util_alloc_sprintf(ECL_SUM_KEYFMT_BLOCK_IJK, keyword, join_string, i, + return util_alloc_sprintf(RD_SUM_KEYFMT_BLOCK_IJK, keyword, join_string, i, j, k); } std::string smspec_alloc_block_ijk_key(const char *join_string, const std::string &keyword, int i, int j, int k) { - return ecl::util::string_format(ECL_SUM_KEYFMT_BLOCK_IJK, keyword.c_str(), - join_string, i, j, k); + return rd::util::string_format(RD_SUM_KEYFMT_BLOCK_IJK, keyword.c_str(), + join_string, i, j, k); } char *smspec_alloc_segment_key(const char *join_string, const std::string &keyword, const std::string &wgname, int num) { if (wgname.size() > 0) - return util_alloc_sprintf(ECL_SUM_KEYFMT_SEGMENT, keyword.c_str(), + return util_alloc_sprintf(RD_SUM_KEYFMT_SEGMENT, keyword.c_str(), join_string, wgname.c_str(), join_string, num); else @@ -368,7 +367,7 @@ char *smspec_alloc_local_well_key(const char *join_string, const std::string &lgr_name, const std::string &wgname) { if (wgname.size() > 0) - return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_WELL, keyword.c_str(), + return util_alloc_sprintf(RD_SUM_KEYFMT_LOCAL_WELL, keyword.c_str(), join_string, lgr_name.c_str(), join_string, wgname.c_str()); else @@ -381,7 +380,7 @@ char *smspec_alloc_local_completion_key(const char *join_string, const std::string &wgname, int i, int j, int k) { if (wgname.size() > 0) - return util_alloc_sprintf(ECL_SUM_KEYFMT_LOCAL_COMPLETION, + return util_alloc_sprintf(RD_SUM_KEYFMT_LOCAL_COMPLETION, keyword.c_str(), join_string, lgr_name.c_str(), join_string, wgname.c_str(), join_string, i, j, k); @@ -431,16 +430,16 @@ bool smspec_node_identify_rate(const char *keyword) { Special gas rates (like gas lift, import, export, consumption, sales ++) Solvents, tracers, brines and environmental tracers Production ratios (unitless, not really rates) - ECL_SMSPEC_SEGMENT_VAR and ECL_SMSPEC_REGION_2_REGION_VAR are handled + RD_SMSPEC_SEGMENT_VAR and RD_SMSPEC_REGION_2_REGION_VAR are handled separately as they do not overlap much with the rest. */ - auto var_type = ecl_smspec_identify_var_type(keyword); - if (var_type == ECL_SMSPEC_WELL_VAR || var_type == ECL_SMSPEC_GROUP_VAR || - var_type == ECL_SMSPEC_FIELD_VAR || var_type == ECL_SMSPEC_REGION_VAR || - var_type == ECL_SMSPEC_COMPLETION_VAR || - var_type == ECL_SMSPEC_LOCAL_WELL_VAR || - var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR) { + auto var_type = rd_smspec_identify_var_type(keyword); + if (var_type == RD_SMSPEC_WELL_VAR || var_type == RD_SMSPEC_GROUP_VAR || + var_type == RD_SMSPEC_FIELD_VAR || var_type == RD_SMSPEC_REGION_VAR || + var_type == RD_SMSPEC_COMPLETION_VAR || + var_type == RD_SMSPEC_LOCAL_WELL_VAR || + var_type == RD_SMSPEC_LOCAL_COMPLETION_VAR) { static const std::vector rate_vars{ {"OPR", "OIR", "OVPR", "OVIR", "OFR", "OPP", "OPI", "OMR", "GPR", "GIR", "GVPR", "GVIR", "GFR", "GPP", "GPI", "GMR", @@ -449,14 +448,14 @@ bool smspec_node_identify_rate(const char *keyword) { "RGR", "EGR", "EXGR", "SGR", "GSR", "FGR", "GIMR", "GCR", "NPR", "NIR", "CPR", "CIR", "SIR", "SPR", "TIR", "TPR", "GOR", "WCT", "OGR", "WGR", "GLR"}}; - if (var_type == ECL_SMSPEC_LOCAL_WELL_VAR || - var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR) { + if (var_type == RD_SMSPEC_LOCAL_WELL_VAR || + var_type == RD_SMSPEC_LOCAL_COMPLETION_VAR) { //LOCAL var_type's are prefixed with L (that we ignore) return match_keyword_vector(2, rate_vars, keyword); } return match_keyword_vector(1, rate_vars, keyword); } - if (var_type == ECL_SMSPEC_SEGMENT_VAR) { + if (var_type == RD_SMSPEC_SEGMENT_VAR) { static const std::vector seg_rate_vars{{ "OFR", "GFR", @@ -472,7 +471,7 @@ bool smspec_node_identify_rate(const char *keyword) { }}; return match_keyword_vector(1, seg_rate_vars, keyword); } - if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { + if (var_type == RD_SMSPEC_REGION_2_REGION_VAR) { //Region to region rates are identified by R*FR or R**FR if (match_keyword_string(2, "FR", keyword)) { return true; @@ -483,7 +482,7 @@ bool smspec_node_identify_rate(const char *keyword) { } bool smspec_node_identify_total(const char *keyword, - ecl_smspec_var_type var_type) { + rd_smspec_var_type var_type) { /* Identify vectors that are likely to be cumulative vectors. First input character is ignored (e.g. F, G, W and R for Field, Group, Well and Region) @@ -498,14 +497,14 @@ bool smspec_node_identify_total(const char *keyword, Liquid + reservoir voidage totals Special gas totals (like import, export, consumption, sales ++) Solvents, tracers, brines and environmental tracers - ECL_SMSPEC_SEGMENT_VAR and ECL_SMSPEC_REGION_2_REGION_VAR are handled + RD_SMSPEC_SEGMENT_VAR and RD_SMSPEC_REGION_2_REGION_VAR are handled separately as they do not overlap much with the rest. */ - if (var_type == ECL_SMSPEC_WELL_VAR || var_type == ECL_SMSPEC_GROUP_VAR || - var_type == ECL_SMSPEC_FIELD_VAR || var_type == ECL_SMSPEC_REGION_VAR || - var_type == ECL_SMSPEC_COMPLETION_VAR || - var_type == ECL_SMSPEC_LOCAL_WELL_VAR || - var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR) { + if (var_type == RD_SMSPEC_WELL_VAR || var_type == RD_SMSPEC_GROUP_VAR || + var_type == RD_SMSPEC_FIELD_VAR || var_type == RD_SMSPEC_REGION_VAR || + var_type == RD_SMSPEC_COMPLETION_VAR || + var_type == RD_SMSPEC_LOCAL_WELL_VAR || + var_type == RD_SMSPEC_LOCAL_COMPLETION_VAR) { static const std::vector rate_vars{{ "OPT", "OIT", "OVPT", "OVIT", "OMT", "GPT", "GIT", "GVPT", "GVIT", "GMT", "WGPT", "WGIT", "WPT", "WIT", "WVPT", "WVIT", @@ -514,14 +513,14 @@ bool smspec_node_identify_total(const char *keyword, "SIT", "SPT", "TIT", "TPT", }}; - if (var_type == ECL_SMSPEC_LOCAL_WELL_VAR || - var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR) { + if (var_type == RD_SMSPEC_LOCAL_WELL_VAR || + var_type == RD_SMSPEC_LOCAL_COMPLETION_VAR) { //LOCAL var_type's are prefixed with L (that we ignore) return match_keyword_vector(2, rate_vars, keyword); } return match_keyword_vector(1, rate_vars, keyword); } - if (var_type == ECL_SMSPEC_SEGMENT_VAR) { + if (var_type == RD_SMSPEC_SEGMENT_VAR) { static const std::vector seg_rate_vars{{ "OFT", "GFT", @@ -529,7 +528,7 @@ bool smspec_node_identify_total(const char *keyword, }}; return match_keyword_vector(1, seg_rate_vars, keyword); } - if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { + if (var_type == RD_SMSPEC_REGION_2_REGION_VAR) { //Region to region totals are identified by R*FT or R**FT if (match_keyword_string(2, "FT", keyword)) { return true; @@ -539,7 +538,7 @@ bool smspec_node_identify_total(const char *keyword, return false; } -namespace ecl { +namespace rd { float smspec_node::get_default() const { return this->default_value; } @@ -561,11 +560,11 @@ void smspec_node::set_wgname(const char *wgname) { if (IS_DUMMY_WELL(wgname)) return; - if (this->var_type == ECL_SMSPEC_WELL_VAR || - this->var_type == ECL_SMSPEC_GROUP_VAR || - this->var_type == ECL_SMSPEC_COMPLETION_VAR || - this->var_type == ECL_SMSPEC_SEGMENT_VAR || - this->var_type == ECL_SMSPEC_LOCAL_WELL_VAR) + if (this->var_type == RD_SMSPEC_WELL_VAR || + this->var_type == RD_SMSPEC_GROUP_VAR || + this->var_type == RD_SMSPEC_COMPLETION_VAR || + this->var_type == RD_SMSPEC_SEGMENT_VAR || + this->var_type == RD_SMSPEC_LOCAL_WELL_VAR) this->wgname = wgname; } @@ -575,8 +574,8 @@ void smspec_node::set_num(const int *grid_dims, int num_) { "seems like a bug?!\n", __func__); this->num = num_; - if ((var_type == ECL_SMSPEC_COMPLETION_VAR) || - (var_type == ECL_SMSPEC_BLOCK_VAR)) { + if ((var_type == RD_SMSPEC_COMPLETION_VAR) || + (var_type == RD_SMSPEC_BLOCK_VAR)) { int global_index = this->num - 1; this->ijk[2] = global_index / (grid_dims[0] * grid_dims[1]); global_index -= this->ijk[2] * (grid_dims[0] * grid_dims[1]); @@ -591,7 +590,7 @@ void smspec_node::set_num(const int *grid_dims, int num_) { } void smspec_node::decode_R1R2(int *r1, int *r2) const { - if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { + if (var_type == RD_SMSPEC_REGION_2_REGION_VAR) { *r1 = this->num % 32768; *r2 = ((this->num - (*r1)) / 32768) - 10; } else { @@ -626,35 +625,35 @@ void smspec_node::set_gen_keys(const char *key_join_string_) { auto k2 = std::unique_ptr(nullptr); switch (var_type) { - case (ECL_SMSPEC_COMPLETION_VAR): + case (RD_SMSPEC_COMPLETION_VAR): // KEYWORD:WGNAME:NUM k1.reset(smspec_alloc_completion_ijk_key( key_join_string_, keyword, wgname, ijk[0], ijk[1], ijk[2])); k2.reset(smspec_alloc_completion_num_key(key_join_string_, keyword, wgname, num)); break; - case (ECL_SMSPEC_FIELD_VAR): + case (RD_SMSPEC_FIELD_VAR): // KEYWORD gen_key1 = keyword; break; - case (ECL_SMSPEC_GROUP_VAR): + case (RD_SMSPEC_GROUP_VAR): // KEYWORD:WGNAME gen_key1 = smspec_alloc_group_key(key_join_string_, keyword, wgname); break; - case (ECL_SMSPEC_WELL_VAR): + case (RD_SMSPEC_WELL_VAR): // KEYWORD:WGNAME gen_key1 = smspec_alloc_well_key(key_join_string_, keyword, wgname); break; - case (ECL_SMSPEC_REGION_VAR): + case (RD_SMSPEC_REGION_VAR): // KEYWORD:NUM gen_key1 = smspec_alloc_region_key(key_join_string_, keyword, num); break; - case (ECL_SMSPEC_SEGMENT_VAR): + case (RD_SMSPEC_SEGMENT_VAR): // KEYWORD:WGNAME:NUM k1.reset( smspec_alloc_segment_key(key_join_string_, keyword, wgname, num)); break; - case (ECL_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): // KEYWORDS:RXF:NUM and RXF:R1-R2 { int r1, r2; @@ -665,36 +664,36 @@ void smspec_node::set_gen_keys(const char *key_join_string_) { gen_key2 = smspec_alloc_region_2_region_num_key(key_join_string_, keyword, num); break; - case (ECL_SMSPEC_MISC_VAR): + case (RD_SMSPEC_MISC_VAR): // KEYWORD /* Misc variable - i.e. date or CPU time ... */ gen_key1 = keyword; break; - case (ECL_SMSPEC_BLOCK_VAR): + case (RD_SMSPEC_BLOCK_VAR): // KEYWORD:NUM gen_key1 = smspec_alloc_block_ijk_key(key_join_string_, keyword, ijk[0], ijk[1], ijk[2]); gen_key2 = smspec_alloc_block_num_key(key_join_string_, keyword, num); break; - case (ECL_SMSPEC_LOCAL_WELL_VAR): + case (RD_SMSPEC_LOCAL_WELL_VAR): /** KEYWORD:LGR:WGNAME */ k1.reset(smspec_alloc_local_well_key(key_join_string_, keyword, lgr_name, wgname)); break; - case (ECL_SMSPEC_LOCAL_BLOCK_VAR): + case (RD_SMSPEC_LOCAL_BLOCK_VAR): /* KEYWORD:LGR:i,j,k */ gen_key1 = smspec_alloc_local_block_key(key_join_string_, keyword, lgr_name, lgr_ijk[0], lgr_ijk[1], lgr_ijk[2]); break; - case (ECL_SMSPEC_LOCAL_COMPLETION_VAR): + case (RD_SMSPEC_LOCAL_COMPLETION_VAR): /* KEYWORD:LGR:WELL:i,j,k */ k1.reset(smspec_alloc_local_completion_key(key_join_string_, keyword, lgr_name, wgname, lgr_ijk[0], lgr_ijk[1], lgr_ijk[2])); break; - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_AQUIFER_VAR): gen_key1 = smspec_alloc_aquifer_key(key_join_string_, keyword, num); break; default: @@ -720,24 +719,24 @@ void smspec_node::set_gen_keys(const char *key_join_string_) { */ -ecl_smspec_var_type smspec_node::valid_type(const char *keyword, - const char *wgname, int num) { +rd_smspec_var_type smspec_node::valid_type(const char *keyword, + const char *wgname, int num) { auto var_type = smspec_node::identify_var_type(keyword); - if (var_type == ECL_SMSPEC_MISC_VAR) + if (var_type == RD_SMSPEC_MISC_VAR) return var_type; - if (var_type == ECL_SMSPEC_FIELD_VAR) + if (var_type == RD_SMSPEC_FIELD_VAR) return var_type; - if (var_type == ECL_SMSPEC_LOCAL_BLOCK_VAR) + if (var_type == RD_SMSPEC_LOCAL_BLOCK_VAR) return var_type; - if (var_type == ECL_SMSPEC_WELL_VAR || var_type == ECL_SMSPEC_GROUP_VAR || - var_type == ECL_SMSPEC_LOCAL_WELL_VAR || - var_type == ECL_SMSPEC_LOCAL_COMPLETION_VAR) { + if (var_type == RD_SMSPEC_WELL_VAR || var_type == RD_SMSPEC_GROUP_VAR || + var_type == RD_SMSPEC_LOCAL_WELL_VAR || + var_type == RD_SMSPEC_LOCAL_COMPLETION_VAR) { if (IS_DUMMY_WELL(wgname)) - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; /* In most cases the dummy well ':+:+:+:+' is used in situations where a @@ -747,37 +746,36 @@ ecl_smspec_var_type smspec_node::valid_type(const char *keyword, */ if (!wgname) - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; if (strlen(wgname) == 0) - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; return var_type; } - if (var_type == ECL_SMSPEC_COMPLETION_VAR || - var_type == ECL_SMSPEC_SEGMENT_VAR) { + if (var_type == RD_SMSPEC_COMPLETION_VAR || + var_type == RD_SMSPEC_SEGMENT_VAR) { if (IS_DUMMY_WELL(wgname)) - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; if (num < 0) - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; return var_type; } - if (var_type == ECL_SMSPEC_REGION_VAR || - var_type == ECL_SMSPEC_REGION_2_REGION_VAR || - var_type == ECL_SMSPEC_BLOCK_VAR || - var_type == ECL_SMSPEC_AQUIFER_VAR) { + if (var_type == RD_SMSPEC_REGION_VAR || + var_type == RD_SMSPEC_REGION_2_REGION_VAR || + var_type == RD_SMSPEC_BLOCK_VAR || var_type == RD_SMSPEC_AQUIFER_VAR) { if (num < 0) - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; return var_type; } - return ECL_SMSPEC_INVALID_VAR; + return RD_SMSPEC_INVALID_VAR; } /** @@ -790,8 +788,8 @@ ecl_smspec_var_type smspec_node::valid_type(const char *keyword, This function initializes a valid smspec_node instance based on the supplied var_type, and the input. Observe that when a new variable type is supported, the big switch() statement must be - updated in the functions ecl_smspec_install_gen_key() and - ecl_smspec_fread_header() functions in addition. UGGGLY + updated in the functions rd_smspec_install_gen_key() and + rd_smspec_fread_header() functions in addition. UGGGLY */ smspec_node::smspec_node(int param_index, const char *keyword, int num, @@ -853,7 +851,7 @@ smspec_node::smspec_node(int param_index, const char *keyword, the macro IS_DUMMY_WELL(wgname) can used to compare with the DUMMY_WELL value. - o When the ecl_sum instance is created in write mode; it must be + o When the rd_sum instance is created in write mode; it must be possible to add smspec nodes for wells/groups which do not have a name yet. In this case we accept NULL as input value for the wgname parameter. @@ -863,7 +861,7 @@ smspec_node::smspec_node(int param_index, const char *keyword, completely. */ this->var_type = this->valid_type(keyword, wgname, num); - if (this->var_type == ECL_SMSPEC_INVALID_VAR) + if (this->var_type == RD_SMSPEC_INVALID_VAR) throw std::invalid_argument( "Could not construct smspec_node from this input."); @@ -879,36 +877,36 @@ smspec_node::smspec_node(int param_index, const char *keyword, this->set_wgname(wgname); switch (this->var_type) { - case (ECL_SMSPEC_COMPLETION_VAR): + case (RD_SMSPEC_COMPLETION_VAR): /* Completion variable : WGNAME & NUM */ set_num(grid_dims, num); break; - case (ECL_SMSPEC_GROUP_VAR): + case (RD_SMSPEC_GROUP_VAR): /* Group variable : WGNAME */ break; - case (ECL_SMSPEC_WELL_VAR): + case (RD_SMSPEC_WELL_VAR): /* Well variable : WGNAME */ break; - case (ECL_SMSPEC_SEGMENT_VAR): + case (RD_SMSPEC_SEGMENT_VAR): set_num(grid_dims, num); break; - case (ECL_SMSPEC_FIELD_VAR): + case (RD_SMSPEC_FIELD_VAR): /* Field variable : */ /* Fully initialized with the smspec_common_init() function */ break; - case (ECL_SMSPEC_REGION_VAR): + case (RD_SMSPEC_REGION_VAR): /* Region variable : NUM */ set_num(grid_dims, num); break; - case (ECL_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): /* Region 2 region variable : NUM */ set_num(grid_dims, num); break; - case (ECL_SMSPEC_BLOCK_VAR): + case (RD_SMSPEC_BLOCK_VAR): /* A block variable : NUM*/ set_num(grid_dims, num); break; - case (ECL_SMSPEC_MISC_VAR): + case (RD_SMSPEC_MISC_VAR): /* Misc variable : */ /* @@ -925,7 +923,7 @@ smspec_node::smspec_node(int param_index, const char *keyword, set_num(grid_dims, SMSPEC_YEARS_NUMS_VALUE); break; - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_AQUIFER_VAR): set_num(grid_dims, num); break; default: @@ -941,7 +939,7 @@ smspec_node::smspec_node(int param_index_, const char *keyword_, float default_value_, const char *key_join_string_) { this->var_type = this->valid_type(keyword_, wgname_, -1); - if (this->var_type == ECL_SMSPEC_INVALID_VAR) + if (this->var_type == RD_SMSPEC_INVALID_VAR) throw std::invalid_argument( "Could not construct smspec_node from this input."); @@ -958,12 +956,12 @@ smspec_node::smspec_node(int param_index_, const char *keyword_, this->num = nums_unused; switch (this->var_type) { - case (ECL_SMSPEC_LOCAL_WELL_VAR): + case (RD_SMSPEC_LOCAL_WELL_VAR): break; - case (ECL_SMSPEC_LOCAL_BLOCK_VAR): + case (RD_SMSPEC_LOCAL_BLOCK_VAR): set_lgr_ijk(lgr_i, lgr_j, lgr_k); break; - case (ECL_SMSPEC_LOCAL_COMPLETION_VAR): + case (RD_SMSPEC_LOCAL_COMPLETION_VAR): set_lgr_ijk(lgr_i, lgr_j, lgr_k); break; default: @@ -1006,7 +1004,7 @@ const char *smspec_node::get_keyword() const { return get_cstring(this->keyword); } -ecl_smspec_var_type smspec_node::get_var_type() const { return this->var_type; } +rd_smspec_var_type smspec_node::get_var_type() const { return this->var_type; } int smspec_node::get_num() const { return this->num; } @@ -1033,11 +1031,11 @@ const std::array &smspec_node::get_lgr_ijk() const { /* Will return -1 for smspec_node variables which are not - of type ECL_SMSPEC_REGION_2_REGION_VAR. + of type RD_SMSPEC_REGION_2_REGION_VAR. */ int smspec_node::get_R1() const { - if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { + if (var_type == RD_SMSPEC_REGION_2_REGION_VAR) { int r1, r2; decode_R1R2(&r1, &r2); return r1; @@ -1046,7 +1044,7 @@ int smspec_node::get_R1() const { } int smspec_node::get_R2() const { - if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { + if (var_type == RD_SMSPEC_REGION_2_REGION_VAR) { int r1, r2; decode_R1R2(&r1, &r2); return r2; @@ -1061,12 +1059,12 @@ bool smspec_node::need_nums() const { file. */ { - if (this->var_type == ECL_SMSPEC_COMPLETION_VAR || - this->var_type == ECL_SMSPEC_SEGMENT_VAR || - this->var_type == ECL_SMSPEC_REGION_VAR || - this->var_type == ECL_SMSPEC_REGION_2_REGION_VAR || - this->var_type == ECL_SMSPEC_BLOCK_VAR || - this->var_type == ECL_SMSPEC_AQUIFER_VAR) + if (this->var_type == RD_SMSPEC_COMPLETION_VAR || + this->var_type == RD_SMSPEC_SEGMENT_VAR || + this->var_type == RD_SMSPEC_REGION_VAR || + this->var_type == RD_SMSPEC_REGION_2_REGION_VAR || + this->var_type == RD_SMSPEC_BLOCK_VAR || + this->var_type == RD_SMSPEC_AQUIFER_VAR) return true; else { if (this->num == SMSPEC_NUMS_INVALID) @@ -1235,8 +1233,8 @@ int cmp_key1(const smspec_node &node1, const smspec_node &node2) { int smspec_node::cmp(const smspec_node &node1, const smspec_node &node2) { /* 1: Start with special casing for the MISC variables. */ - if ((node1.var_type == ECL_SMSPEC_MISC_VAR) || - (node2.var_type == ECL_SMSPEC_MISC_VAR)) + if ((node1.var_type == RD_SMSPEC_MISC_VAR) || + (node2.var_type == RD_SMSPEC_MISC_VAR)) return cmp_MISC(node1, node2); /* 2: Sort according to variable type */ @@ -1249,33 +1247,33 @@ int smspec_node::cmp(const smspec_node &node1, const smspec_node &node2) { /* 3: Internal sort of variables of the same type. */ switch (node1.var_type) { - case (ECL_SMSPEC_FIELD_VAR): + case (RD_SMSPEC_FIELD_VAR): return cmp_KEYWORD(node1, node2); - case (ECL_SMSPEC_WELL_VAR): - case (ECL_SMSPEC_GROUP_VAR): + case (RD_SMSPEC_WELL_VAR): + case (RD_SMSPEC_GROUP_VAR): return cmp_KEYWORD_WGNAME(node1, node2); - case (ECL_SMSPEC_BLOCK_VAR): - case (ECL_SMSPEC_REGION_VAR): - case (ECL_SMSPEC_REGION_2_REGION_VAR): - case (ECL_SMSPEC_AQUIFER_VAR): + case (RD_SMSPEC_BLOCK_VAR): + case (RD_SMSPEC_REGION_VAR): + case (RD_SMSPEC_REGION_2_REGION_VAR): + case (RD_SMSPEC_AQUIFER_VAR): return cmp_KEYWORD_NUM(node1, node2); - case (ECL_SMSPEC_COMPLETION_VAR): - case (ECL_SMSPEC_SEGMENT_VAR): + case (RD_SMSPEC_COMPLETION_VAR): + case (RD_SMSPEC_SEGMENT_VAR): return cmp_KEYWORD_WGNAME_NUM(node1, node2); - case (ECL_SMSPEC_NETWORK_VAR): + case (RD_SMSPEC_NETWORK_VAR): return cmp_key1(node1, node2); - case (ECL_SMSPEC_LOCAL_BLOCK_VAR): + case (RD_SMSPEC_LOCAL_BLOCK_VAR): return cmp_KEYWORD_LGR_LGRIJK(node1, node2); - case (ECL_SMSPEC_LOCAL_WELL_VAR): + case (RD_SMSPEC_LOCAL_WELL_VAR): return cmp_KEYWORD_WGNAME_LGR(node1, node2); - case (ECL_SMSPEC_LOCAL_COMPLETION_VAR): + case (RD_SMSPEC_LOCAL_COMPLETION_VAR): return cmp_KEYWORD_WGNAME_LGR_LGRIJK(node1, node2); default: @@ -1288,105 +1286,105 @@ int smspec_node::cmp(const smspec_node &node2) const { return smspec_node::cmp(*this, node2); } -} // end namespace ecl +} // end namespace rd /************************************** OLD API functions ***********************''''' */ void smspec_node_free(void *index) { - delete static_cast(index); + delete static_cast(index); } void smspec_node_free__(void *arg) { smspec_node_free(arg); } float smspec_node_get_default(const void *smspec_node) { - return static_cast(smspec_node)->get_default(); + return static_cast(smspec_node)->get_default(); } int smspec_node_get_params_index(const void *smspec_node) { - return static_cast(smspec_node) + return static_cast(smspec_node) ->get_params_index(); } // void smspec_node_set_params_index( void * smspec_node , int params_index) { -// static_cast(smspec_node)->set_params_index( params_index ); +// static_cast(smspec_node)->set_params_index( params_index ); // } const char *smspec_node_get_gen_key1(const void *smspec_node) { - return static_cast(smspec_node)->get_gen_key1(); + return static_cast(smspec_node)->get_gen_key1(); } const char *smspec_node_get_gen_key2(const void *smspec_node) { - return static_cast(smspec_node)->get_gen_key2(); + return static_cast(smspec_node)->get_gen_key2(); } const char *smspec_node_get_wgname(const void *smspec_node) { - return static_cast(smspec_node)->get_wgname(); + return static_cast(smspec_node)->get_wgname(); } const char *smspec_node_get_keyword(const void *smspec_node) { - return static_cast(smspec_node)->get_keyword(); + return static_cast(smspec_node)->get_keyword(); } -ecl_smspec_var_type smspec_node_get_var_type(const void *smspec_node) { - return static_cast(smspec_node)->get_var_type(); +rd_smspec_var_type smspec_node_get_var_type(const void *smspec_node) { + return static_cast(smspec_node)->get_var_type(); } int smspec_node_get_num(const void *smspec_node) { - return static_cast(smspec_node)->get_num(); + return static_cast(smspec_node)->get_num(); } bool smspec_node_is_rate(const void *smspec_node) { - return static_cast(smspec_node)->is_rate(); + return static_cast(smspec_node)->is_rate(); } bool smspec_node_is_total(const void *smspec_node) { - return static_cast(smspec_node)->is_total(); + return static_cast(smspec_node)->is_total(); } bool smspec_node_is_historical(const void *smspec_node) { - return static_cast(smspec_node)->is_historical(); + return static_cast(smspec_node)->is_historical(); } const char *smspec_node_get_unit(const void *smspec_node) { - return static_cast(smspec_node)->get_unit(); + return static_cast(smspec_node)->get_unit(); } // Will be garbage for smspec_nodes which do not have i,j,k const int *smspec_node_get_ijk(const void *smspec_node) { - return static_cast(smspec_node)->get_ijk().data(); + return static_cast(smspec_node)->get_ijk().data(); } // Will be NULL for smspec_nodes which are not related to an LGR. const char *smspec_node_get_lgr_name(const void *smspec_node) { - return static_cast(smspec_node)->get_lgr_name(); + return static_cast(smspec_node)->get_lgr_name(); } // Will be garbage for smspec_nodes which are not related to an LGR. const int *smspec_node_get_lgr_ijk(const void *smspec_node) { - return static_cast(smspec_node) + return static_cast(smspec_node) ->get_lgr_ijk() .data(); } int smspec_node_get_R1(const void *smspec_node) { - return static_cast(smspec_node)->get_R1(); + return static_cast(smspec_node)->get_R1(); } int smspec_node_get_R2(const void *smspec_node) { - return static_cast(smspec_node)->get_R2(); + return static_cast(smspec_node)->get_R2(); } bool smspec_node_need_nums(const void *smspec_node) { - return static_cast(smspec_node)->need_nums(); + return static_cast(smspec_node)->need_nums(); } void smspec_node_fprintf(const void *smspec_node, FILE *stream) { - static_cast(smspec_node)->fprintf__(stream); + static_cast(smspec_node)->fprintf__(stream); } int smspec_node_cmp(const void *node1, const void *node2) { - return ecl::smspec_node::cmp(static_cast(node1), - static_cast(node2)); + return rd::smspec_node::cmp(static_cast(node1), + static_cast(node2)); } int smspec_node_cmp__(const void *node1, const void *node2) { @@ -1398,40 +1396,40 @@ void *smspec_node_alloc(int param_index, const char *keyword, const int grid_dims[3], float default_value, const char *key_join_string) { - ecl::smspec_node *node = NULL; + rd::smspec_node *node = NULL; try { - node = new ecl::smspec_node(param_index, keyword, wgname, num, unit, - grid_dims, default_value, key_join_string); + node = new rd::smspec_node(param_index, keyword, wgname, num, unit, + grid_dims, default_value, key_join_string); } catch (const std::invalid_argument &e) { node = NULL; } return node; } -void *smspec_node_alloc_lgr(ecl_smspec_var_type var_type, const char *wgname, +void *smspec_node_alloc_lgr(rd_smspec_var_type var_type, const char *wgname, const char *keyword, const char *unit, const char *lgr, const char *key_join_string, int lgr_i, int lgr_j, int lgr_k, int param_index, float default_value) { - return new ecl::smspec_node(param_index, keyword, wgname, unit, lgr, lgr_i, - lgr_j, lgr_k, default_value, key_join_string); + return new rd::smspec_node(param_index, keyword, wgname, unit, lgr, lgr_i, + lgr_j, lgr_k, default_value, key_join_string); } bool smspec_node_equal(const void *node1, const void *node2) { - return ecl::smspec_node::cmp( - static_cast(node1), - static_cast(node2)) == 0; + return rd::smspec_node::cmp(static_cast(node1), + static_cast(node2)) == + 0; } bool smspec_node_gt(const void *node1, const void *node2) { - return ecl::smspec_node::cmp(static_cast(node1), - static_cast(node2)) > + return rd::smspec_node::cmp(static_cast(node1), + static_cast(node2)) > 0; } bool smspec_node_lt(const void *node1, const void *node2) { - return ecl::smspec_node::cmp(static_cast(node1), - static_cast(node2)) < + return rd::smspec_node::cmp(static_cast(node1), + static_cast(node2)) < 0; } diff --git a/lib/resdata/tests/eclxx_filename.cpp b/lib/resdata/tests/eclxx_filename.cpp index 03d431c5f6..d2a11a998d 100644 --- a/lib/resdata/tests/eclxx_filename.cpp +++ b/lib/resdata/tests/eclxx_filename.cpp @@ -1,50 +1,50 @@ #include -#include +#include void cmp(const char *expected, const std::string &value) { test_assert_string_equal(expected, value.c_str()); } int main(int argc, char **argv) { - cmp("BASE.X0067", ERT::EclFilename("BASE", ECL_RESTART_FILE, 67)); - cmp("BASE.F0067", ERT::EclFilename("BASE", ECL_RESTART_FILE, 67, true)); + cmp("BASE.X0067", ERT::ResdataFilename("BASE", RD_RESTART_FILE, 67)); + cmp("BASE.F0067", ERT::ResdataFilename("BASE", RD_RESTART_FILE, 67, true)); - cmp("BASE.EGRID", ERT::EclFilename("BASE", ECL_EGRID_FILE)); - cmp("BASE.FEGRID", ERT::EclFilename("BASE", ECL_EGRID_FILE, true)); + cmp("BASE.EGRID", ERT::ResdataFilename("BASE", RD_EGRID_FILE)); + cmp("BASE.FEGRID", ERT::ResdataFilename("BASE", RD_EGRID_FILE, true)); - cmp("BASE.EGRID", ERT::EclFilename("BASE", ECL_EGRID_FILE, 67)); - cmp("BASE.FEGRID", ERT::EclFilename("BASE", ECL_EGRID_FILE, 67, true)); + cmp("BASE.EGRID", ERT::ResdataFilename("BASE", RD_EGRID_FILE, 67)); + cmp("BASE.FEGRID", ERT::ResdataFilename("BASE", RD_EGRID_FILE, 67, true)); try { - ERT::EclFilename("BASE", ECL_RESTART_FILE); + ERT::ResdataFilename("BASE", RD_RESTART_FILE); test_assert_true(false); } catch (...) { test_assert_true(true); } cmp("PATH/BASE.X0067", - ERT::EclFilename("PATH", "BASE", ECL_RESTART_FILE, 67)); + ERT::ResdataFilename("PATH", "BASE", RD_RESTART_FILE, 67)); cmp("PATH/BASE.F0067", - ERT::EclFilename("PATH", "BASE", ECL_RESTART_FILE, 67, true)); + ERT::ResdataFilename("PATH", "BASE", RD_RESTART_FILE, 67, true)); - cmp("PATH/BASE.EGRID", ERT::EclFilename("PATH", "BASE", ECL_EGRID_FILE)); + cmp("PATH/BASE.EGRID", ERT::ResdataFilename("PATH", "BASE", RD_EGRID_FILE)); cmp("PATH/BASE.FEGRID", - ERT::EclFilename("PATH", "BASE", ECL_EGRID_FILE, true)); + ERT::ResdataFilename("PATH", "BASE", RD_EGRID_FILE, true)); cmp("PATH/BASE.EGRID", - ERT::EclFilename("PATH", "BASE", ECL_EGRID_FILE, 67)); + ERT::ResdataFilename("PATH", "BASE", RD_EGRID_FILE, 67)); cmp("PATH/BASE.FEGRID", - ERT::EclFilename("PATH", "BASE", ECL_EGRID_FILE, 67, true)); + ERT::ResdataFilename("PATH", "BASE", RD_EGRID_FILE, 67, true)); try { - ERT::EclFilename("PATH", "BASE", ECL_RESTART_FILE); + ERT::ResdataFilename("PATH", "BASE", RD_RESTART_FILE); test_assert_true(false); } catch (...) { test_assert_true(true); } - test_assert_int_equal(ECL_EGRID_FILE, ERT::EclFiletype("CASE.EGRID")); - test_assert_int_equal(ECL_RESTART_FILE, ERT::EclFiletype("CASE.F0098")); - test_assert_int_equal(ECL_UNIFIED_RESTART_FILE, - ERT::EclFiletype("CASE.UNRST")); + test_assert_int_equal(RD_EGRID_FILE, ERT::ResdataFiletype("CASE.EGRID")); + test_assert_int_equal(RD_RESTART_FILE, ERT::ResdataFiletype("CASE.F0098")); + test_assert_int_equal(RD_UNIFIED_RESTART_FILE, + ERT::ResdataFiletype("CASE.UNRST")); } diff --git a/lib/resdata/tests/eclxx_fortio.cpp b/lib/resdata/tests/eclxx_fortio.cpp index 114a3c0e57..fcb3b295f2 100644 --- a/lib/resdata/tests/eclxx_fortio.cpp +++ b/lib/resdata/tests/eclxx_fortio.cpp @@ -3,11 +3,11 @@ #include #include -#include -#include +#include +#include void test_open() { - ecl::util::TestArea ta("fortioxx"); + rd::util::TestArea ta("fortioxx"); ERT::FortIO fortio; fortio.open("new_file", std::fstream::out); @@ -53,7 +53,7 @@ void test_open() { } void test_fortio() { - ecl::util::TestArea ta("FORTIO"); + rd::util::TestArea ta("FORTIO"); ERT::FortIO fortio("new_file", std::fstream::out); { std::vector data; @@ -84,13 +84,13 @@ void test_fortio() { } void test_fortio_kw() { - ecl::util::TestArea ta("fortio_kw"); + rd::util::TestArea ta("fortio_kw"); std::vector vec(1000); for (size_t i = 0; i < vec.size(); i++) vec[i] = i; - ERT::EclKW kw("XYZ", vec); + ERT::ResdataKW kw("XYZ", vec); { ERT::FortIO fortio("new_file", std::fstream::out); @@ -100,7 +100,7 @@ void test_fortio_kw() { { ERT::FortIO fortio("new_file", std::fstream::in); - ERT::EclKW kw2 = ERT::EclKW::load(fortio); + ERT::ResdataKW kw2 = ERT::ResdataKW::load(fortio); fortio.close(); for (size_t i = 0; i < kw.size(); i++) test_assert_int_equal(kw.at(i), kw2.at(i)); diff --git a/lib/resdata/tests/eclxx_kw.cpp b/lib/resdata/tests/eclxx_kw.cpp index fef9fa5798..773bc2ce06 100644 --- a/lib/resdata/tests/eclxx_kw.cpp +++ b/lib/resdata/tests/eclxx_kw.cpp @@ -3,15 +3,15 @@ #include -#include +#include -#include -#include +#include +#include #include void test_kw_name() { - ERT::EclKW kw1("short", 1); - ERT::EclKW kw2("verylong", 1); + ERT::ResdataKW kw1("short", 1); + ERT::ResdataKW kw2("verylong", 1); test_assert_string_equal(kw1.name(), "short"); test_assert_string_equal(kw2.name(), "verylong"); @@ -19,7 +19,7 @@ void test_kw_name() { void test_kw_vector_assign() { std::vector vec = {1, 2, 3, 4, 5}; - ERT::EclKW kw("XYZ", vec); + ERT::ResdataKW kw("XYZ", vec); test_assert_size_t_equal(kw.size(), vec.size()); @@ -38,7 +38,7 @@ void test_kw_vector_string() { std::vector vec = {"short", "sweet", "padded "}; std::vector too_long = {"1234567890"}; - ERT::EclKW kw("XYZ", vec); + ERT::ResdataKW kw("XYZ", vec); test_assert_size_t_equal(kw.size(), vec.size()); @@ -46,7 +46,7 @@ void test_kw_vector_string() { test_assert_string_equal(kw.at(1), "sweet "); test_assert_string_equal(kw.at(2), vec.at(2)); - test_assert_throw(ERT::EclKW("XY", too_long), + test_assert_throw(ERT::ResdataKW("XY", too_long), std::range_error); } @@ -57,7 +57,7 @@ void test_kw_vector_std_string() { "padded ", }; std::vector too_long = {"1234567890"}; - ERT::EclKW kw("XYZ", vec); + ERT::ResdataKW kw("XYZ", vec); test_assert_size_t_equal(kw.size(), vec.size()); @@ -65,13 +65,13 @@ void test_kw_vector_std_string() { test_assert_string_equal(kw.at(1).c_str(), "sweet "); test_assert_string_equal(kw.at(2).c_str(), vec.at(2)); - test_assert_throw(ERT::EclKW("XY", too_long), + test_assert_throw(ERT::ResdataKW("XY", too_long), std::range_error); } void test_logical() { //std::vector vec = {true,false,true,false}; - // ERT::EclKW kw("BOOL", vec); + // ERT::ResdataKW kw("BOOL", vec); // test_assert_int_equal(kw.size(), vec.size()); // for (size_t i=0; i < vec.size(); i++) @@ -80,25 +80,25 @@ void test_logical() { void test_move_semantics_no_crash() { std::vector vec = {1, 2, 3, 4, 5}; - ERT::EclKW kw1("XYZ", vec); + ERT::ResdataKW kw1("XYZ", vec); - ERT::EclKW kw2(std::move(kw1)); + ERT::ResdataKW kw2(std::move(kw1)); test_assert_true(kw1.get() == nullptr); } void test_exception_assing_ref_wrong_type() { - auto *ptr = ecl_kw_alloc("XYZ", 1, ECL_INT); + auto *ptr = rd_kw_alloc("XYZ", 1, RD_INT); try { - ERT::EclKW kw(ptr); + ERT::ResdataKW kw(ptr); test_assert_true(false); } catch (...) { - ERT::EclKW kw(ptr); + ERT::ResdataKW kw(ptr); } } void test_resize() { - ERT::EclKW kw1("short", 1); + ERT::ResdataKW kw1("short", 1); test_assert_int_equal(kw1.size(), 1); kw1.resize(100); @@ -112,27 +112,27 @@ void test_data() { std::vector b_data = {true, false}; std::vector s_data = {"S1", "S2", "S3"}; - ERT::EclKW d_kw("DOUBLE", d_data); + ERT::ResdataKW d_kw("DOUBLE", d_data); auto d_data2 = d_kw.data(); for (size_t i = 0; i < d_data.size(); i++) test_assert_true(d_data[i] == d_data2[i]); - ERT::EclKW f_kw("FLOATx", f_data); + ERT::ResdataKW f_kw("FLOATx", f_data); auto f_data2 = f_kw.data(); for (size_t i = 0; i < f_data.size(); i++) test_assert_true(f_data[i] == f_data2[i]); - ERT::EclKW i_kw("INT", i_data); + ERT::ResdataKW i_kw("INT", i_data); auto i_data2 = i_kw.data(); for (size_t i = 0; i < i_data.size(); i++) test_assert_true(i_data[i] == i_data2[i]); - //ERT::EclKW b_kw("bbb", b_data); + //ERT::ResdataKW b_kw("bbb", b_data); //auto b_data2 = b_kw.data(); //for (size_t i=0; i < b_data.size(); i++) // test_assert_true(b_data[i] == b_data2[i]); - ERT::EclKW s_kw("sss", s_data); + ERT::ResdataKW s_kw("sss", s_data); auto s_data2 = s_kw.data(); for (size_t i = 0; i < s_data.size(); i++) test_assert_true(s_data[i] == s_data2[i]); @@ -146,7 +146,7 @@ void test_read_write() { std::vector s_data = {"S1", "S2", "S3"}; { - ecl::util::TestArea ta("kw-read-write"); + rd::util::TestArea ta("kw-read-write"); { ERT::FortIO f("test_file", std::ios_base::out); ERT::write_kw(f, "DOUBLE", d_data); @@ -157,33 +157,33 @@ void test_read_write() { } { - ecl_file_type *f = ecl_file_open("test_file", 0); - ecl_kw_type *d_kw = ecl_file_iget_named_kw(f, "DOUBLE", 0); - ecl_kw_type *f_kw = ecl_file_iget_named_kw(f, "FLOAT", 0); - ecl_kw_type *i_kw = ecl_file_iget_named_kw(f, "INT", 0); - ecl_kw_type *b_kw = ecl_file_iget_named_kw(f, "BOOL", 0); - ecl_kw_type *s_kw = ecl_file_iget_named_kw(f, "STRING", 0); + rd_file_type *f = rd_file_open("test_file", 0); + rd_kw_type *d_kw = rd_file_iget_named_kw(f, "DOUBLE", 0); + rd_kw_type *f_kw = rd_file_iget_named_kw(f, "FLOAT", 0); + rd_kw_type *i_kw = rd_file_iget_named_kw(f, "INT", 0); + rd_kw_type *b_kw = rd_file_iget_named_kw(f, "BOOL", 0); + rd_kw_type *s_kw = rd_file_iget_named_kw(f, "STRING", 0); for (size_t i = 0; i < d_data.size(); i++) - test_assert_true(d_data[i] == ecl_kw_iget_double(d_kw, i)); + test_assert_true(d_data[i] == rd_kw_iget_double(d_kw, i)); for (size_t i = 0; i < f_data.size(); i++) - test_assert_true(f_data[i] == ecl_kw_iget_float(f_kw, i)); + test_assert_true(f_data[i] == rd_kw_iget_float(f_kw, i)); for (size_t i = 0; i < i_data.size(); i++) - test_assert_true(i_data[i] == ecl_kw_iget_int(i_kw, i)); + test_assert_true(i_data[i] == rd_kw_iget_int(i_kw, i)); for (size_t i = 0; i < b_data.size(); i++) - test_assert_true(b_data[i] == ecl_kw_iget_bool(b_kw, i)); + test_assert_true(b_data[i] == rd_kw_iget_bool(b_kw, i)); for (size_t i = 0; i < s_data.size(); i++) { - std::string s8 = ecl_kw_iget_char_ptr(s_kw, i); + std::string s8 = rd_kw_iget_char_ptr(s_kw, i); test_assert_int_equal(s8.size(), 8); s8.erase(s8.find_last_not_of(' ') + 1); test_assert_true(s_data[i] == s8); } - ecl_file_close(f); + rd_file_close(f); } } } diff --git a/lib/resdata/tests/eclxx_types.cpp b/lib/resdata/tests/eclxx_types.cpp index ebaa369b71..0d48e5cf23 100644 --- a/lib/resdata/tests/eclxx_types.cpp +++ b/lib/resdata/tests/eclxx_types.cpp @@ -2,36 +2,36 @@ #include #include -#include -#include +#include +#include -void test_ECL_INT() { - ecl_data_type dt = ECL_INT; +void test_RD_INT() { + rd_data_type dt = RD_INT; test_assert_int_equal(dt.element_size, sizeof(int)); - test_assert_int_equal(dt.type, ECL_INT_TYPE); + test_assert_int_equal(dt.type, RD_INT_TYPE); } -void test_ECL_FLOAT() { - ecl_data_type dt = ECL_FLOAT; +void test_RD_FLOAT() { + rd_data_type dt = RD_FLOAT; test_assert_int_equal(dt.element_size, sizeof(float)); - test_assert_int_equal(dt.type, ECL_FLOAT_TYPE); + test_assert_int_equal(dt.type, RD_FLOAT_TYPE); } -void test_ECL_DOUBLE() { - ecl_data_type dt = ECL_DOUBLE; +void test_RD_DOUBLE() { + rd_data_type dt = RD_DOUBLE; test_assert_int_equal(dt.element_size, sizeof(double)); - test_assert_int_equal(dt.type, ECL_DOUBLE_TYPE); + test_assert_int_equal(dt.type, RD_DOUBLE_TYPE); } -void test_ECL_CHAR() { - ecl_data_type dt = ECL_CHAR; - test_assert_int_equal(dt.element_size, ECL_STRING8_LENGTH + 1); - test_assert_int_equal(dt.type, ECL_CHAR_TYPE); +void test_RD_CHAR() { + rd_data_type dt = RD_CHAR; + test_assert_int_equal(dt.element_size, RD_STRING8_LENGTH + 1); + test_assert_int_equal(dt.type, RD_CHAR_TYPE); } int main(int argc, char **argv) { - test_ECL_INT(); - test_ECL_FLOAT(); - test_ECL_DOUBLE(); - test_ECL_CHAR(); + test_RD_INT(); + test_RD_FLOAT(); + test_RD_DOUBLE(); + test_RD_CHAR(); } diff --git a/lib/resdata/tests/rd_coarse_test.cpp b/lib/resdata/tests/rd_coarse_test.cpp index e1adf9adab..edfb5dc51b 100644 --- a/lib/resdata/tests/rd_coarse_test.cpp +++ b/lib/resdata/tests/rd_coarse_test.cpp @@ -3,24 +3,24 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -void test_coarse_cell(const ecl_grid_type *grid, ecl_coarse_cell_type *cell) { +void test_coarse_cell(const rd_grid_type *grid, rd_coarse_cell_type *cell) { const int_vector_type *global_index_list = - ecl_coarse_cell_get_index_vector(cell); - const int *ijk = ecl_coarse_cell_get_box_ptr(cell); + rd_coarse_cell_get_index_vector(cell); + const int *ijk = rd_coarse_cell_get_box_ptr(cell); int c; int prev_active = 0; - for (c = 0; c < ecl_coarse_cell_get_size(cell); c++) { + for (c = 0; c < rd_coarse_cell_get_size(cell); c++) { int gi = int_vector_iget(global_index_list, c); int i, j, k; /* The coordinates are right */ - ecl_grid_get_ijk1(grid, gi, &i, &j, &k); + rd_grid_get_ijk1(grid, gi, &i, &j, &k); if ((i < ijk[0]) || (i > ijk[1])) test_error_exit("i:%d not inside range [%d,%d] \n", i, ijk[0], ijk[1]); @@ -34,10 +34,10 @@ void test_coarse_cell(const ecl_grid_type *grid, ecl_coarse_cell_type *cell) { ijk[4]); if (c == 0) - prev_active = ecl_grid_get_active_index1(grid, gi); + prev_active = rd_grid_get_active_index1(grid, gi); else { /* All the cells have the same active value */ - int this_active = ecl_grid_get_active_index1(grid, gi); + int this_active = rd_grid_get_active_index1(grid, gi); test_assert_int_equal(prev_active, this_active); prev_active = this_active; } @@ -47,42 +47,42 @@ void test_coarse_cell(const ecl_grid_type *grid, ecl_coarse_cell_type *cell) { int main(int argc, char **argv) { const char *case_path = argv[1]; char *egrid_file = - ecl_util_alloc_filename(NULL, case_path, ECL_EGRID_FILE, false, 0); + rd_alloc_filename(NULL, case_path, RD_EGRID_FILE, false, 0); char *rst_file = - ecl_util_alloc_filename(NULL, case_path, ECL_RESTART_FILE, false, 0); + rd_alloc_filename(NULL, case_path, RD_RESTART_FILE, false, 0); char *init_file = - ecl_util_alloc_filename(NULL, case_path, ECL_INIT_FILE, false, 0); + rd_alloc_filename(NULL, case_path, RD_INIT_FILE, false, 0); - ecl_grid_type *GRID = ecl_grid_alloc(egrid_file); - ecl_file_type *RST_file = ecl_file_open(rst_file, 0); - ecl_file_type *INIT_file = ecl_file_open(init_file, 0); + rd_grid_type *GRID = rd_grid_alloc(egrid_file); + rd_file_type *RST_file = rd_file_open(rst_file, 0); + rd_file_type *INIT_file = rd_file_open(init_file, 0); { - test_assert_true(ecl_grid_have_coarse_cells(GRID)); - test_assert_int_equal(ecl_grid_get_num_coarse_groups(GRID), 3384); + test_assert_true(rd_grid_have_coarse_cells(GRID)); + test_assert_int_equal(rd_grid_get_num_coarse_groups(GRID), 3384); } { - const ecl_kw_type *swat0 = ecl_file_iget_named_kw(RST_file, "SWAT", 0); - const ecl_kw_type *porv = ecl_file_iget_named_kw(INIT_file, "PORV", 0); + const rd_kw_type *swat0 = rd_file_iget_named_kw(RST_file, "SWAT", 0); + const rd_kw_type *porv = rd_file_iget_named_kw(INIT_file, "PORV", 0); - test_assert_int_equal(ecl_kw_get_size(swat0), - ecl_grid_get_active_size(GRID)); - test_assert_int_equal(ecl_kw_get_size(porv), - ecl_grid_get_global_size(GRID)); + test_assert_int_equal(rd_kw_get_size(swat0), + rd_grid_get_active_size(GRID)); + test_assert_int_equal(rd_kw_get_size(porv), + rd_grid_get_global_size(GRID)); } { int ic; - for (ic = 0; ic < ecl_grid_get_num_coarse_groups(GRID); ic++) { - ecl_coarse_cell_type *coarse_cell = - ecl_grid_iget_coarse_group(GRID, ic); + for (ic = 0; ic < rd_grid_get_num_coarse_groups(GRID); ic++) { + rd_coarse_cell_type *coarse_cell = + rd_grid_iget_coarse_group(GRID, ic); test_coarse_cell(GRID, coarse_cell); } } - ecl_file_close(INIT_file); - ecl_file_close(RST_file); - ecl_grid_free(GRID); + rd_file_close(INIT_file); + rd_file_close(RST_file); + rd_grid_free(GRID); exit(0); } diff --git a/lib/resdata/tests/rd_dualp.cpp b/lib/resdata/tests/rd_dualp.cpp index 061744e015..d9301b5b08 100644 --- a/lib/resdata/tests/rd_dualp.cpp +++ b/lib/resdata/tests/rd_dualp.cpp @@ -3,58 +3,57 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { const char *case_path = argv[1]; char *grid_file = - ecl_util_alloc_filename(NULL, case_path, ECL_EGRID_FILE, false, 0); + rd_alloc_filename(NULL, case_path, RD_EGRID_FILE, false, 0); char *init_file = - ecl_util_alloc_filename(NULL, case_path, ECL_INIT_FILE, false, 0); + rd_alloc_filename(NULL, case_path, RD_INIT_FILE, false, 0); char *rst_file = - ecl_util_alloc_filename(NULL, case_path, ECL_RESTART_FILE, false, 0); + rd_alloc_filename(NULL, case_path, RD_RESTART_FILE, false, 0); - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_file); - ecl_file_type *RST_file = ecl_file_open(rst_file, 0); - ecl_file_type *INIT_file = ecl_file_open(init_file, 0); - ecl_file_type *GRID_file = ecl_file_open(grid_file, 0); + rd_grid_type *rd_grid = rd_grid_alloc(grid_file); + rd_file_type *RST_file = rd_file_open(rst_file, 0); + rd_file_type *INIT_file = rd_file_open(init_file, 0); + rd_file_type *GRID_file = rd_file_open(grid_file, 0); { - ecl_kw_type *actnum = ecl_file_iget_named_kw(GRID_file, "ACTNUM", 0); - ecl_kw_type *swat = ecl_file_iget_named_kw(RST_file, "SWAT", 0); - ecl_kw_type *permx = ecl_file_iget_named_kw(INIT_file, "PERMX", 0); - int fracture_size = ecl_grid_get_nactive_fracture(ecl_grid); - int matrix_size = ecl_grid_get_nactive(ecl_grid); + rd_kw_type *actnum = rd_file_iget_named_kw(GRID_file, "ACTNUM", 0); + rd_kw_type *swat = rd_file_iget_named_kw(RST_file, "SWAT", 0); + rd_kw_type *permx = rd_file_iget_named_kw(INIT_file, "PERMX", 0); + int fracture_size = rd_grid_get_nactive_fracture(rd_grid); + int matrix_size = rd_grid_get_nactive(rd_grid); test_assert_int_equal(fracture_size + matrix_size, - ecl_kw_get_size(swat)); + rd_kw_get_size(swat)); test_assert_int_equal(fracture_size + matrix_size, - ecl_kw_get_size(permx)); + rd_kw_get_size(permx)); { int gi; int matrix_index = 0; int fracture_index = 0; - for (gi = 0; gi < ecl_grid_get_global_size(ecl_grid); gi++) { - if (ecl_kw_iget_int(actnum, gi) & CELL_ACTIVE_MATRIX) { + for (gi = 0; gi < rd_grid_get_global_size(rd_grid); gi++) { + if (rd_kw_iget_int(actnum, gi) & CELL_ACTIVE_MATRIX) { test_assert_int_equal( - ecl_grid_get_active_index1(ecl_grid, gi), matrix_index); + rd_grid_get_active_index1(rd_grid, gi), matrix_index); test_assert_int_equal( - ecl_grid_get_global_index1A(ecl_grid, matrix_index), - gi); + rd_grid_get_global_index1A(rd_grid, matrix_index), gi); matrix_index++; } - if (ecl_kw_iget_int(actnum, gi) & CELL_ACTIVE_FRACTURE) { + if (rd_kw_iget_int(actnum, gi) & CELL_ACTIVE_FRACTURE) { test_assert_int_equal( - ecl_grid_get_active_fracture_index1(ecl_grid, gi), + rd_grid_get_active_fracture_index1(rd_grid, gi), fracture_index); test_assert_int_equal( - ecl_grid_get_global_index1F(ecl_grid, fracture_index), + rd_grid_get_global_index1F(rd_grid, fracture_index), gi); fracture_index++; } @@ -62,9 +61,9 @@ int main(int argc, char **argv) { } } - ecl_file_close(RST_file); - ecl_file_close(INIT_file); - ecl_grid_free(ecl_grid); + rd_file_close(RST_file); + rd_file_close(INIT_file); + rd_grid_free(rd_grid); exit(0); } diff --git a/lib/resdata/tests/rd_fault_block_collection_equinor.cpp b/lib/resdata/tests/rd_fault_block_collection_equinor.cpp index ba0d1c38db..adc0cd5622 100644 --- a/lib/resdata/tests/rd_fault_block_collection_equinor.cpp +++ b/lib/resdata/tests/rd_fault_block_collection_equinor.cpp @@ -4,30 +4,30 @@ #include -#include -#include -#include +#include +#include +#include -void test_create(const ecl_grid_type *grid, const ecl_kw_type *fault_block_kw) { +void test_create(const rd_grid_type *grid, const rd_kw_type *fault_block_kw) { fault_block_collection_type *fault_blocks = fault_block_collection_alloc(grid); test_assert_true(fault_block_collection_is_instance(fault_blocks)); - test_assert_int_equal(ecl_grid_get_nz(grid), + test_assert_int_equal(rd_grid_get_nz(grid), fault_block_collection_num_layers(fault_blocks)); fault_block_collection_free(fault_blocks); } -void test_get_layer(const ecl_grid_type *grid, - const ecl_kw_type *fault_block_kw) { +void test_get_layer(const rd_grid_type *grid, + const rd_kw_type *fault_block_kw) { fault_block_collection_type *fault_blocks = fault_block_collection_alloc(grid); test_assert_NULL(fault_block_collection_get_layer(fault_blocks, -1)); test_assert_NULL( - fault_block_collection_get_layer(fault_blocks, ecl_grid_get_nz(grid))); + fault_block_collection_get_layer(fault_blocks, rd_grid_get_nz(grid))); { int k; - for (k = 0; k < ecl_grid_get_nz(grid); k++) { + for (k = 0; k < rd_grid_get_nz(grid); k++) { fault_block_layer_type *layer = fault_block_collection_get_layer(fault_blocks, k); test_assert_true(fault_block_layer_is_instance(layer)); @@ -39,20 +39,19 @@ void test_get_layer(const ecl_grid_type *grid, int main(int argc, char **argv) { const char *grid_file = argv[1]; const char *fault_blk_file = argv[2]; - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_file); - ecl_kw_type *fault_blk_kw; + rd_grid_type *rd_grid = rd_grid_alloc(grid_file); + rd_kw_type *fault_blk_kw; { FILE *stream = util_fopen(fault_blk_file, "r"); - fault_blk_kw = ecl_kw_fscanf_alloc_grdecl( - stream, "FAULTBLK", ecl_grid_get_global_size(ecl_grid), - ECL_INT_TYPE); + fault_blk_kw = rd_kw_fscanf_alloc_grdecl( + stream, "FAULTBLK", rd_grid_get_global_size(rd_grid), RD_INT_TYPE); fclose(stream); } - test_create(ecl_grid, fault_blk_kw); - test_get_layer(ecl_grid, fault_blk_kw); + test_create(rd_grid, fault_blk_kw); + test_get_layer(rd_grid, fault_blk_kw); - ecl_grid_free(ecl_grid); - ecl_kw_free(fault_blk_kw); + rd_grid_free(rd_grid); + rd_kw_free(fault_blk_kw); exit(0); } diff --git a/lib/resdata/tests/rd_fault_block_layer.cpp b/lib/resdata/tests/rd_fault_block_layer.cpp index 2b2187c73d..5350d20736 100644 --- a/lib/resdata/tests/rd_fault_block_layer.cpp +++ b/lib/resdata/tests/rd_fault_block_layer.cpp @@ -6,20 +6,20 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -void test_create(const ecl_grid_type *grid, ecl_kw_type *fault_block_kw) { +void test_create(const rd_grid_type *grid, rd_kw_type *fault_block_kw) { int k = 0; int i, j; - for (j = 0; j < ecl_grid_get_ny(grid); j++) { - for (i = 0; i < ecl_grid_get_nx(grid); i++) { + for (j = 0; j < rd_grid_get_ny(grid); j++) { + for (i = 0; i < rd_grid_get_nx(grid); i++) { - int g = ecl_grid_get_global_index3(grid, i, j, k); - ecl_kw_iset_int(fault_block_kw, g, 9); + int g = rd_grid_get_global_index3(grid, i, j, k); + rd_kw_iset_int(fault_block_kw, g, 9); } } @@ -30,7 +30,7 @@ void test_create(const ecl_grid_type *grid, ecl_kw_type *fault_block_kw) { { fault_block_type *block = fault_block_layer_iget_block(layer, 0); double x, y, z; - ecl_grid_get_xyz3(grid, 4, 4, k, &x, &y, &z); + rd_grid_get_xyz3(grid, 4, 4, k, &x, &y, &z); test_assert_double_equal(x, fault_block_get_xc(block)); test_assert_double_equal(y, fault_block_get_yc(block)); } @@ -39,16 +39,16 @@ void test_create(const ecl_grid_type *grid, ecl_kw_type *fault_block_kw) { } } -void test_create_invalid(const ecl_grid_type *grid) { - ecl_kw_type *fault_blk_kw = - ecl_kw_alloc("FAULTBLK", ecl_grid_get_global_size(grid) - 1, ECL_INT); +void test_create_invalid(const rd_grid_type *grid) { + rd_kw_type *fault_blk_kw = + rd_kw_alloc("FAULTBLK", rd_grid_get_global_size(grid) - 1, RD_INT); test_assert_NULL(fault_block_layer_alloc(grid, 7)); - ecl_kw_free(fault_blk_kw); + rd_kw_free(fault_blk_kw); } -void test_trace_edge(const ecl_grid_type *grid) { +void test_trace_edge(const rd_grid_type *grid) { const int k = 1; fault_block_layer_type *layer = fault_block_layer_alloc(grid, k); double_vector_type *x_list = double_vector_alloc(0, 0); @@ -81,14 +81,14 @@ void test_trace_edge(const ecl_grid_type *grid) { double_vector_free(y_list); } -void test_export(const ecl_grid_type *grid) { +void test_export(const rd_grid_type *grid) { fault_block_layer_type *layer = fault_block_layer_alloc(grid, 0); - ecl_kw_type *ecl_kw1 = - ecl_kw_alloc("FAULTBLK", ecl_grid_get_global_size(grid), ECL_INT); - ecl_kw_type *ecl_kw2 = - ecl_kw_alloc("FAULTBLK", ecl_grid_get_global_size(grid) + 1, ECL_INT); - ecl_kw_type *ecl_kw3 = - ecl_kw_alloc("FAULTBLK", ecl_grid_get_global_size(grid), ECL_FLOAT); + rd_kw_type *rd_kw1 = + rd_kw_alloc("FAULTBLK", rd_grid_get_global_size(grid), RD_INT); + rd_kw_type *rd_kw2 = + rd_kw_alloc("FAULTBLK", rd_grid_get_global_size(grid) + 1, RD_INT); + rd_kw_type *rd_kw3 = + rd_kw_alloc("FAULTBLK", rd_grid_get_global_size(grid), RD_FLOAT); fault_block_type *block = fault_block_layer_add_block(layer, 10); fault_block_add_cell(block, 0, 0); @@ -96,39 +96,39 @@ void test_export(const ecl_grid_type *grid) { fault_block_add_cell(block, 1, 1); fault_block_add_cell(block, 0, 1); - test_assert_true(fault_block_layer_export(layer, ecl_kw1)); - test_assert_false(fault_block_layer_export(layer, ecl_kw2)); - test_assert_false(fault_block_layer_export(layer, ecl_kw3)); + test_assert_true(fault_block_layer_export(layer, rd_kw1)); + test_assert_false(fault_block_layer_export(layer, rd_kw2)); + test_assert_false(fault_block_layer_export(layer, rd_kw3)); { - int nx = ecl_grid_get_nx(grid); + int nx = rd_grid_get_nx(grid); - test_assert_int_equal(ecl_kw_iget_int(ecl_kw1, 0), 10); - test_assert_int_equal(ecl_kw_iget_int(ecl_kw1, 1), 10); - test_assert_int_equal(ecl_kw_iget_int(ecl_kw1, nx), 10); - test_assert_int_equal(ecl_kw_iget_int(ecl_kw1, nx + 1), 10); + test_assert_int_equal(rd_kw_iget_int(rd_kw1, 0), 10); + test_assert_int_equal(rd_kw_iget_int(rd_kw1, 1), 10); + test_assert_int_equal(rd_kw_iget_int(rd_kw1, nx), 10); + test_assert_int_equal(rd_kw_iget_int(rd_kw1, nx + 1), 10); } - test_assert_int_equal(40, ecl_kw_element_sum_int(ecl_kw1)); + test_assert_int_equal(40, rd_kw_element_sum_int(rd_kw1)); fault_block_layer_free(layer); - ecl_kw_free(ecl_kw1); - ecl_kw_free(ecl_kw2); - ecl_kw_free(ecl_kw3); + rd_kw_free(rd_kw1); + rd_kw_free(rd_kw2); + rd_kw_free(rd_kw3); } -void test_neighbours(const ecl_grid_type *grid) { +void test_neighbours(const rd_grid_type *grid) { const int k = 0; fault_block_layer_type *layer = fault_block_layer_alloc(grid, k); geo_polygon_collection_type *polylines = geo_polygon_collection_alloc(); - ecl_kw_type *ecl_kw = - ecl_kw_alloc("FAULTBLK", ecl_grid_get_global_size(grid), ECL_INT); + rd_kw_type *rd_kw = + rd_kw_alloc("FAULTBLK", rd_grid_get_global_size(grid), RD_INT); - ecl_kw_iset_int(ecl_kw, 0, 1); - ecl_kw_iset_int(ecl_kw, ecl_grid_get_global_index3(grid, 3, 3, k), 2); - ecl_kw_iset_int(ecl_kw, ecl_grid_get_global_index3(grid, 4, 3, k), 3); - ecl_kw_iset_int(ecl_kw, ecl_grid_get_global_index3(grid, 5, 3, k), 4); - ecl_kw_iset_int(ecl_kw, ecl_grid_get_global_index3(grid, 4, 2, k), 5); - fault_block_layer_load_kw(layer, ecl_kw); + rd_kw_iset_int(rd_kw, 0, 1); + rd_kw_iset_int(rd_kw, rd_grid_get_global_index3(grid, 3, 3, k), 2); + rd_kw_iset_int(rd_kw, rd_grid_get_global_index3(grid, 4, 3, k), 3); + rd_kw_iset_int(rd_kw, rd_grid_get_global_index3(grid, 5, 3, k), 4); + rd_kw_iset_int(rd_kw, rd_grid_get_global_index3(grid, 4, 2, k), 5); + fault_block_layer_load_kw(layer, rd_kw); { int_vector_type *neighbours = int_vector_alloc(0, 0); @@ -152,22 +152,21 @@ void test_neighbours(const ecl_grid_type *grid) { geo_polygon_collection_free(polylines); fault_block_layer_free(layer); - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); } int main(int argc, char **argv) { - ecl_grid_type *ecl_grid = - ecl_grid_alloc_rectangular(9, 9, 2, 1, 1, 1, NULL); - ecl_kw_type *fault_blk_kw = - ecl_kw_alloc("FAULTBLK", ecl_grid_get_global_size(ecl_grid), ECL_INT); - - test_create(ecl_grid, fault_blk_kw); - test_create_invalid(ecl_grid); - test_trace_edge(ecl_grid); - test_export(ecl_grid); - test_neighbours(ecl_grid); - - ecl_grid_free(ecl_grid); - ecl_kw_free(fault_blk_kw); + rd_grid_type *rd_grid = rd_grid_alloc_rectangular(9, 9, 2, 1, 1, 1, NULL); + rd_kw_type *fault_blk_kw = + rd_kw_alloc("FAULTBLK", rd_grid_get_global_size(rd_grid), RD_INT); + + test_create(rd_grid, fault_blk_kw); + test_create_invalid(rd_grid); + test_trace_edge(rd_grid); + test_export(rd_grid); + test_neighbours(rd_grid); + + rd_grid_free(rd_grid); + rd_kw_free(fault_blk_kw); exit(0); } diff --git a/lib/resdata/tests/rd_fault_block_layer_equinor.cpp b/lib/resdata/tests/rd_fault_block_layer_equinor.cpp index e5b95045b1..13afb72b1c 100644 --- a/lib/resdata/tests/rd_fault_block_layer_equinor.cpp +++ b/lib/resdata/tests/rd_fault_block_layer_equinor.cpp @@ -4,17 +4,17 @@ #include -#include -#include -#include +#include +#include +#include -void test_create(const ecl_grid_type *grid, const ecl_kw_type *fault_block_kw) { +void test_create(const rd_grid_type *grid, const rd_kw_type *fault_block_kw) { test_assert_NULL(fault_block_layer_alloc(grid, -1)); - test_assert_NULL(fault_block_layer_alloc(grid, ecl_grid_get_nz(grid))); + test_assert_NULL(fault_block_layer_alloc(grid, rd_grid_get_nz(grid))); { int k; - for (k = 0; k < ecl_grid_get_nz(grid); k++) { + for (k = 0; k < rd_grid_get_nz(grid); k++) { fault_block_layer_type *layer = fault_block_layer_alloc(grid, k); test_assert_true(fault_block_layer_is_instance(layer)); @@ -52,18 +52,18 @@ void test_create(const ecl_grid_type *grid, const ecl_kw_type *fault_block_kw) { int main(int argc, char **argv) { const char *grid_file = argv[1]; const char *fault_blk_file = argv[2]; - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_file); - ecl_kw_type *fault_blk_kw; + rd_grid_type *rd_grid = rd_grid_alloc(grid_file); + rd_kw_type *fault_blk_kw; { FILE *stream = util_fopen(fault_blk_file, "r"); - fault_blk_kw = ecl_kw_fscanf_alloc_grdecl( - stream, "FAULTBLK", ecl_grid_get_global_size(ecl_grid), ECL_INT); + fault_blk_kw = rd_kw_fscanf_alloc_grdecl( + stream, "FAULTBLK", rd_grid_get_global_size(rd_grid), RD_INT); fclose(stream); } - test_create(ecl_grid, fault_blk_kw); + test_create(rd_grid, fault_blk_kw); - ecl_grid_free(ecl_grid); - ecl_kw_free(fault_blk_kw); + rd_grid_free(rd_grid); + rd_kw_free(fault_blk_kw); exit(0); } diff --git a/lib/resdata/tests/rd_file.cpp b/lib/resdata/tests/rd_file.cpp index 39f032cf3b..bd60bbe6da 100644 --- a/lib/resdata/tests/rd_file.cpp +++ b/lib/resdata/tests/rd_file.cpp @@ -7,53 +7,52 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void test_writable(size_t data_size) { - ecl::util::TestArea ta("file_writable"); + rd::util::TestArea ta("file_writable"); const char *data_file_name = "test_file"; - ecl_kw_type *kw = ecl_kw_alloc("TEST_KW", data_size, ECL_INT); + rd_kw_type *kw = rd_kw_alloc("TEST_KW", data_size, RD_INT); for (size_t i = 0; i < data_size; ++i) - ecl_kw_iset_int(kw, i, ((i * 37) + 11) % data_size); + rd_kw_iset_int(kw, i, ((i * 37) + 11) % data_size); fortio_type *fortio = fortio_open_writer(data_file_name, false, true); - ecl_kw_fwrite(kw, fortio); + rd_kw_fwrite(kw, fortio); fortio_fclose(fortio); for (int i = 0; i < 4; ++i) { - ecl_file_type *ecl_file = - ecl_file_open(data_file_name, ECL_FILE_WRITABLE); - ecl_kw_type *loaded_kw = - ecl_file_view_iget_kw(ecl_file_get_global_view(ecl_file), 0); - test_assert_true(ecl_kw_equal(kw, loaded_kw)); + rd_file_type *rd_file = rd_file_open(data_file_name, RD_FILE_WRITABLE); + rd_kw_type *loaded_kw = + rd_file_view_iget_kw(rd_file_get_global_view(rd_file), 0); + test_assert_true(rd_kw_equal(kw, loaded_kw)); - ecl_file_save_kw(ecl_file, loaded_kw); - ecl_file_close(ecl_file); + rd_file_save_kw(rd_file, loaded_kw); + rd_file_close(rd_file); } - ecl_kw_free(kw); + rd_kw_free(kw); } void test_truncated() { - ecl::util::TestArea ta("truncate_file"); + rd::util::TestArea ta("truncate_file"); int num_kw; { - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(20, 20, 20, 1, 1, 1, NULL); - ecl_grid_fwrite_EGRID2(grid, "TEST.EGRID", ECL_METRIC_UNITS); - ecl_grid_free(grid); + rd_grid_type *grid = + rd_grid_alloc_rectangular(20, 20, 20, 1, 1, 1, NULL); + rd_grid_fwrite_EGRID2(grid, "TEST.EGRID", RD_METRIC_UNITS); + rd_grid_free(grid); } { - ecl_file_type *ecl_file = ecl_file_open("TEST.EGRID", 0); - test_assert_true(ecl_file_is_instance(ecl_file)); - num_kw = ecl_file_get_size(ecl_file); - test_assert_int_equal(ecl_file_get_num_distinct_kw(ecl_file), 11); - ecl_file_close(ecl_file); + rd_file_type *rd_file = rd_file_open("TEST.EGRID", 0); + test_assert_true(rd_file_is_instance(rd_file)); + num_kw = rd_file_get_size(rd_file); + test_assert_int_equal(rd_file_get_num_distinct_kw(rd_file), 11); + rd_file_close(rd_file); } { @@ -63,27 +62,27 @@ void test_truncated() { fclose(stream); } { - ecl_file_type *ecl_file = ecl_file_open("TEST.EGRID", 0); - test_assert_true(ecl_file_get_size(ecl_file) < num_kw); - ecl_file_close(ecl_file); + rd_file_type *rd_file = rd_file_open("TEST.EGRID", 0); + test_assert_true(rd_file_get_size(rd_file) < num_kw); + rd_file_close(rd_file); } } void test_mixed_case() { - ecl::util::TestArea ta("mixed_case_file"); + rd::util::TestArea ta("mixed_case_file"); int num_kw; { - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(20, 20, 20, 1, 1, 1, NULL); - ecl_grid_fwrite_EGRID2(grid, "TESTcase.EGRID", ECL_METRIC_UNITS); - ecl_grid_free(grid); + rd_grid_type *grid = + rd_grid_alloc_rectangular(20, 20, 20, 1, 1, 1, NULL); + rd_grid_fwrite_EGRID2(grid, "TESTcase.EGRID", RD_METRIC_UNITS); + rd_grid_free(grid); } { - ecl_file_type *ecl_file = ecl_file_open("TESTcase.EGRID", 0); - test_assert_true(ecl_file_is_instance(ecl_file)); - num_kw = ecl_file_get_size(ecl_file); - test_assert_int_equal(ecl_file_get_num_distinct_kw(ecl_file), 11); - ecl_file_close(ecl_file); + rd_file_type *rd_file = rd_file_open("TESTcase.EGRID", 0); + test_assert_true(rd_file_is_instance(rd_file)); + num_kw = rd_file_get_size(rd_file); + test_assert_int_equal(rd_file_get_num_distinct_kw(rd_file), 11); + rd_file_close(rd_file); } { @@ -93,9 +92,9 @@ void test_mixed_case() { fclose(stream); } { - ecl_file_type *ecl_file = ecl_file_open("TESTcase.EGRID", 0); - test_assert_true(ecl_file_get_size(ecl_file) < num_kw); - ecl_file_close(ecl_file); + rd_file_type *rd_file = rd_file_open("TESTcase.EGRID", 0); + test_assert_true(rd_file_get_size(rd_file) < num_kw); + rd_file_close(rd_file); } } diff --git a/lib/resdata/tests/rd_file_equinor.cpp b/lib/resdata/tests/rd_file_equinor.cpp index b9f281ee1a..ad890aaebc 100644 --- a/lib/resdata/tests/rd_file_equinor.cpp +++ b/lib/resdata/tests/rd_file_equinor.cpp @@ -7,11 +7,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void test_flags(const char *filename) { int FLAG1 = 1; @@ -21,89 +21,87 @@ void test_flags(const char *filename) { int FLAGS = FLAG1 + FLAG2 + FLAG3; - ecl_file_type *ecl_file = ecl_file_open(filename, FLAGS); + rd_file_type *rd_file = rd_file_open(filename, FLAGS); - test_assert_int_equal(ecl_file_get_flags(ecl_file), FLAGS); - test_assert_true(ecl_file_flags_set(ecl_file, FLAG1)); - test_assert_true(ecl_file_flags_set(ecl_file, FLAG1 | FLAG2)); - test_assert_true(ecl_file_flags_set(ecl_file, FLAG1 | FLAG3)); - test_assert_true(ecl_file_flags_set(ecl_file, FLAG1 | FLAG3 | FLAG2)); - test_assert_false(ecl_file_flags_set(ecl_file, FLAG1 | FLAG3 | FLAG4)); - ecl_file_close(ecl_file); + test_assert_int_equal(rd_file_get_flags(rd_file), FLAGS); + test_assert_true(rd_file_flags_set(rd_file, FLAG1)); + test_assert_true(rd_file_flags_set(rd_file, FLAG1 | FLAG2)); + test_assert_true(rd_file_flags_set(rd_file, FLAG1 | FLAG3)); + test_assert_true(rd_file_flags_set(rd_file, FLAG1 | FLAG3 | FLAG2)); + test_assert_false(rd_file_flags_set(rd_file, FLAG1 | FLAG3 | FLAG4)); + rd_file_close(rd_file); } void test_close_stream2(const char *src_file, const char *target_file) { util_copy_file(src_file, target_file); - ecl_file_type *ecl_file = ecl_file_open(target_file, ECL_FILE_CLOSE_STREAM); + rd_file_type *rd_file = rd_file_open(target_file, RD_FILE_CLOSE_STREAM); - ecl_file_load_all(ecl_file); + rd_file_load_all(rd_file); unlink(target_file); - ecl_kw_type *kw2 = ecl_file_iget_kw(ecl_file, 2); + rd_kw_type *kw2 = rd_file_iget_kw(rd_file, 2); test_assert_not_NULL(kw2); - ecl_file_close(ecl_file); + rd_file_close(rd_file); } void test_loadall(const char *src_file, const char *target_file) { util_copy_file(src_file, target_file); { - ecl_file_type *ecl_file = - ecl_file_open(target_file, ECL_FILE_CLOSE_STREAM); + rd_file_type *rd_file = rd_file_open(target_file, RD_FILE_CLOSE_STREAM); - test_assert_true(ecl_file_load_all(ecl_file)); - ecl_file_close(ecl_file); + test_assert_true(rd_file_load_all(rd_file)); + rd_file_close(rd_file); } { - ecl_file_type *ecl_file = - ecl_file_open(target_file, ECL_FILE_CLOSE_STREAM); + rd_file_type *rd_file = rd_file_open(target_file, RD_FILE_CLOSE_STREAM); unlink(target_file); - test_assert_false(ecl_file_load_all(ecl_file)); - ecl_file_close(ecl_file); + test_assert_false(rd_file_load_all(rd_file)); + rd_file_close(rd_file); } } void test_close_stream1(const char *src_file, const char *target_file) { util_copy_file(src_file, target_file); - ecl_file_type *ecl_file = ecl_file_open(target_file, ECL_FILE_CLOSE_STREAM); - ecl_kw_type *kw0 = ecl_file_iget_kw(ecl_file, 0); - ecl_kw_type *kw1 = ecl_file_iget_kw(ecl_file, 1); + rd_file_type *rd_file = rd_file_open(target_file, RD_FILE_CLOSE_STREAM); + rd_kw_type *kw0 = rd_file_iget_kw(rd_file, 0); + rd_kw_type *kw1 = rd_file_iget_kw(rd_file, 1); unlink(target_file); - ecl_kw_type *kw1b = ecl_file_iget_kw(ecl_file, 1); + rd_kw_type *kw1b = rd_file_iget_kw(rd_file, 1); test_assert_not_NULL(kw0); test_assert_not_NULL(kw1); test_assert_ptr_equal(kw1, kw1b); - ecl_kw_type *kw2 = ecl_file_iget_kw(ecl_file, 2); + rd_kw_type *kw2 = rd_file_iget_kw(rd_file, 2); test_assert_NULL(kw2); - test_assert_false(ecl_file_writable(ecl_file)); + test_assert_false(rd_file_writable(rd_file)); - ecl_file_close(ecl_file); + rd_file_close(rd_file); } void test_writable(const char *src_file) { - ecl::util::TestArea ta("file_writable"); + rd::util::TestArea ta("file_writable"); char *fname = util_split_alloc_filename(src_file); ta.copy_file(src_file); { test_flags(fname); - ecl_file_type *ecl_file = ecl_file_open(fname, ECL_FILE_WRITABLE); - ecl_kw_type *swat = ecl_file_iget_named_kw(ecl_file, "SWAT", 0); - ecl_kw_type *swat0 = ecl_kw_alloc_copy(swat); - test_assert_true(ecl_kw_equal(swat, swat0)); - ecl_kw_iset_float(swat, 0, 1000.0); - ecl_file_save_kw(ecl_file, swat); - test_assert_true(ecl_file_writable(ecl_file)); - ecl_file_close(ecl_file); - - ecl_file = ecl_file_open(fname, 0); - swat = ecl_file_iget_named_kw(ecl_file, "SWAT", 0); + rd_file_type *rd_file = rd_file_open(fname, RD_FILE_WRITABLE); + rd_kw_type *swat = rd_file_iget_named_kw(rd_file, "SWAT", 0); + rd_kw_type *swat0 = rd_kw_alloc_copy(swat); + test_assert_true(rd_kw_equal(swat, swat0)); + rd_kw_iset_float(swat, 0, 1000.0); + rd_file_save_kw(rd_file, swat); + test_assert_true(rd_file_writable(rd_file)); + rd_file_close(rd_file); + + rd_file = rd_file_open(fname, 0); + swat = rd_file_iget_named_kw(rd_file, "SWAT", 0); test_assert_true( - util_double_approx_equal(ecl_kw_iget_float(swat, 0), 1000)); + util_double_approx_equal(rd_kw_iget_float(swat, 0), 1000)); } } @@ -112,7 +110,7 @@ int main(int argc, char **argv) { const char *target_file = argv[2]; { - ecl::util::TestArea ta("file_equinor"); + rd::util::TestArea ta("file_equinor"); ta.copy_file(src_file); test_loadall(src_file, target_file); diff --git a/lib/resdata/tests/rd_file_view.cpp b/lib/resdata/tests/rd_file_view.cpp index b84bce33df..02f0edb27b 100644 --- a/lib/resdata/tests/rd_file_view.cpp +++ b/lib/resdata/tests/rd_file_view.cpp @@ -6,94 +6,93 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include void test_file_kw_equal() { - ecl_file_kw_type *kw1 = ecl_file_kw_alloc0("PRESSURE", ECL_FLOAT, 1000, 66); - ecl_file_kw_type *kw2 = ecl_file_kw_alloc0("PRESSURE", ECL_FLOAT, 1000, 66); - ecl_file_kw_type *kw3 = ecl_file_kw_alloc0("SWAT", ECL_FLOAT, 1000, 66); - ecl_file_kw_type *kw4 = - ecl_file_kw_alloc0("PRESSURE", ECL_DOUBLE, 1000, 66); - ecl_file_kw_type *kw5 = ecl_file_kw_alloc0("PRESSURE", ECL_FLOAT, 10, 66); - ecl_file_kw_type *kw6 = ecl_file_kw_alloc0("PRESSURE", ECL_FLOAT, 1000, 67); + rd_file_kw_type *kw1 = rd_file_kw_alloc0("PRESSURE", RD_FLOAT, 1000, 66); + rd_file_kw_type *kw2 = rd_file_kw_alloc0("PRESSURE", RD_FLOAT, 1000, 66); + rd_file_kw_type *kw3 = rd_file_kw_alloc0("SWAT", RD_FLOAT, 1000, 66); + rd_file_kw_type *kw4 = rd_file_kw_alloc0("PRESSURE", RD_DOUBLE, 1000, 66); + rd_file_kw_type *kw5 = rd_file_kw_alloc0("PRESSURE", RD_FLOAT, 10, 66); + rd_file_kw_type *kw6 = rd_file_kw_alloc0("PRESSURE", RD_FLOAT, 1000, 67); - test_assert_true(ecl_file_kw_equal(kw1, kw1)); - test_assert_true(ecl_file_kw_equal(kw1, kw2)); - test_assert_false(ecl_file_kw_equal(kw1, kw3)); - test_assert_false(ecl_file_kw_equal(kw1, kw4)); - test_assert_false(ecl_file_kw_equal(kw1, kw5)); - test_assert_false(ecl_file_kw_equal(kw1, kw6)); + test_assert_true(rd_file_kw_equal(kw1, kw1)); + test_assert_true(rd_file_kw_equal(kw1, kw2)); + test_assert_false(rd_file_kw_equal(kw1, kw3)); + test_assert_false(rd_file_kw_equal(kw1, kw4)); + test_assert_false(rd_file_kw_equal(kw1, kw5)); + test_assert_false(rd_file_kw_equal(kw1, kw6)); - ecl_file_kw_free(kw6); - ecl_file_kw_free(kw5); - ecl_file_kw_free(kw4); - ecl_file_kw_free(kw3); - ecl_file_kw_free(kw2); - ecl_file_kw_free(kw1); + rd_file_kw_free(kw6); + rd_file_kw_free(kw5); + rd_file_kw_free(kw4); + rd_file_kw_free(kw3); + rd_file_kw_free(kw2); + rd_file_kw_free(kw1); } void test_create_file_kw() { - ecl_file_kw_type *file_kw0 = - ecl_file_kw_alloc0("PRESSURE", ECL_FLOAT, 1000, 66); - ecl_file_kw_type *file_kw1 = - ecl_file_kw_alloc0("TEST1_KW", ECL_FLOAT, 2000, 1066); - ecl_file_kw_type *file_kw2 = - ecl_file_kw_alloc0("TEST2_KW", ECL_FLOAT, 3000, 2066); - test_assert_string_equal(ecl_file_kw_get_header(file_kw0), "PRESSURE"); - test_assert_int_equal(ecl_file_kw_get_size(file_kw0), 1000); + rd_file_kw_type *file_kw0 = + rd_file_kw_alloc0("PRESSURE", RD_FLOAT, 1000, 66); + rd_file_kw_type *file_kw1 = + rd_file_kw_alloc0("TEST1_KW", RD_FLOAT, 2000, 1066); + rd_file_kw_type *file_kw2 = + rd_file_kw_alloc0("TEST2_KW", RD_FLOAT, 3000, 2066); + test_assert_string_equal(rd_file_kw_get_header(file_kw0), "PRESSURE"); + test_assert_int_equal(rd_file_kw_get_size(file_kw0), 1000); test_assert_true( - ecl_type_is_equal(ecl_file_kw_get_data_type(file_kw0), ECL_FLOAT)); + rd_type_is_equal(rd_file_kw_get_data_type(file_kw0), RD_FLOAT)); { - ecl::util::TestArea ta("file_kw"); + rd::util::TestArea ta("file_kw"); { FILE *ostream = util_fopen("file_kw", "w"); - ecl_file_kw_fwrite(file_kw0, ostream); + rd_file_kw_fwrite(file_kw0, ostream); fclose(ostream); } { FILE *istream = util_fopen("file_kw", "r"); - ecl_file_kw_type *disk_kw = ecl_file_kw_fread_alloc(istream); - test_assert_true(ecl_file_kw_equal(file_kw0, disk_kw)); + rd_file_kw_type *disk_kw = rd_file_kw_fread_alloc(istream); + test_assert_true(rd_file_kw_equal(file_kw0, disk_kw)); /* Beyond the end of stream - return NULL */ - test_assert_NULL(ecl_file_kw_fread_alloc(istream)); - ecl_file_kw_free(disk_kw); + test_assert_NULL(rd_file_kw_fread_alloc(istream)); + rd_file_kw_free(disk_kw); fclose(istream); } { FILE *ostream = util_fopen("file_kw", "w"); - ecl_file_kw_fwrite(file_kw0, ostream); - ecl_file_kw_fwrite(file_kw1, ostream); - ecl_file_kw_fwrite(file_kw2, ostream); + rd_file_kw_fwrite(file_kw0, ostream); + rd_file_kw_fwrite(file_kw1, ostream); + rd_file_kw_fwrite(file_kw2, ostream); fclose(ostream); } { FILE *istream = util_fopen("file_kw", "r"); - ecl_file_kw_type **disk_kw = - ecl_file_kw_fread_alloc_multiple(istream, 3); - test_assert_true(ecl_file_kw_equal(file_kw0, disk_kw[0])); - test_assert_true(ecl_file_kw_equal(file_kw1, disk_kw[1])); - test_assert_true(ecl_file_kw_equal(file_kw2, disk_kw[2])); + rd_file_kw_type **disk_kw = + rd_file_kw_fread_alloc_multiple(istream, 3); + test_assert_true(rd_file_kw_equal(file_kw0, disk_kw[0])); + test_assert_true(rd_file_kw_equal(file_kw1, disk_kw[1])); + test_assert_true(rd_file_kw_equal(file_kw2, disk_kw[2])); for (int i = 0; i < 3; i++) - ecl_file_kw_free(disk_kw[i]); + rd_file_kw_free(disk_kw[i]); free(disk_kw); fclose(istream); } { FILE *istream = util_fopen("file_kw", "r"); - test_assert_NULL(ecl_file_kw_fread_alloc_multiple(istream, 10)); + test_assert_NULL(rd_file_kw_fread_alloc_multiple(istream, 10)); fclose(istream); } } - ecl_file_kw_free(file_kw0); - ecl_file_kw_free(file_kw1); - ecl_file_kw_free(file_kw2); + rd_file_kw_free(file_kw0); + rd_file_kw_free(file_kw1); + rd_file_kw_free(file_kw2); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_fmt.cpp b/lib/resdata/tests/rd_fmt.cpp index 15367b0969..adb16b5a33 100644 --- a/lib/resdata/tests/rd_fmt.cpp +++ b/lib/resdata/tests/rd_fmt.cpp @@ -6,9 +6,9 @@ #include #include -#include +#include -void test_content(const ecl::util::TestArea &ta, const char *src_file, +void test_content(const rd::util::TestArea &ta, const char *src_file, bool fmt_file) { ta.copy_file(src_file); { @@ -21,7 +21,7 @@ void test_content(const ecl::util::TestArea &ta, const char *src_file, util_copy_file(file_name, base_name); - test_assert_true(ecl_util_fmt_file(base_name, &fmt)); + test_assert_true(rd_fmt_file(base_name, &fmt)); test_assert_bool_equal(fmt, fmt_file); free(file_name); @@ -37,30 +37,30 @@ void test_small() { fprintf(stream, "Some bytes\n"); fclose(stream); - test_assert_false(ecl_util_fmt_file("small.txt", &fmt)); + test_assert_false(rd_fmt_file("small.txt", &fmt)); } int main(int argc, char **argv) { - ecl::util::TestArea ta("ecl_fmt"); + rd::util::TestArea ta("rd_fmt"); { const char *binary_file = argv[1]; const char *text_file = argv[2]; bool fmt_file; - test_assert_true(ecl_util_fmt_file(binary_file, &fmt_file)); + test_assert_true(rd_fmt_file(binary_file, &fmt_file)); test_assert_false(fmt_file); - test_assert_true(ecl_util_fmt_file(text_file, &fmt_file)); + test_assert_true(rd_fmt_file(text_file, &fmt_file)); test_assert_true(fmt_file); - test_assert_true(ecl_util_fmt_file("TEST.EGRID", &fmt_file)); + test_assert_true(rd_fmt_file("TEST.EGRID", &fmt_file)); test_assert_false(fmt_file); - test_assert_true(ecl_util_fmt_file("TEST.FEGRID", &fmt_file)); + test_assert_true(rd_fmt_file("TEST.FEGRID", &fmt_file)); test_assert_true(fmt_file); - test_assert_false(ecl_util_fmt_file("TEST_DOES_NOT_EXIST", &fmt_file)); + test_assert_false(rd_fmt_file("TEST_DOES_NOT_EXIST", &fmt_file)); test_content(ta, binary_file, false); test_content(ta, text_file, true); diff --git a/lib/resdata/tests/rd_fortio.cpp b/lib/resdata/tests/rd_fortio.cpp index ac8a59b6cd..94185a0b6a 100644 --- a/lib/resdata/tests/rd_fortio.cpp +++ b/lib/resdata/tests/rd_fortio.cpp @@ -6,11 +6,11 @@ #include #include -#include -#include +#include +#include void test_existing_read(const char *filename) { - fortio_type *fortio = fortio_open_reader(filename, false, ECL_ENDIAN_FLIP); + fortio_type *fortio = fortio_open_reader(filename, false, RD_ENDIAN_FLIP); test_assert_not_NULL(fortio); fortio_fclose(fortio); } @@ -18,7 +18,7 @@ void test_existing_read(const char *filename) { void test_fortio_is_instance(const char *filename) { { fortio_type *fortio = - fortio_open_reader(filename, false, ECL_ENDIAN_FLIP); + fortio_open_reader(filename, false, RD_ENDIAN_FLIP); test_assert_not_NULL(fortio); test_assert_true(fortio_is_instance(fortio)); fortio_fclose(fortio); @@ -31,7 +31,7 @@ void test_fortio_is_instance(const char *filename) { } void test_fortio_safe_cast(const char *filename) { - void *i_am_a_fortio = fortio_open_reader(filename, false, ECL_ENDIAN_FLIP); + void *i_am_a_fortio = fortio_open_reader(filename, false, RD_ENDIAN_FLIP); test_assert_not_NULL(i_am_a_fortio); fortio_type *fortio = fortio_safe_cast(i_am_a_fortio); test_assert_true(fortio_is_instance(fortio)); @@ -46,12 +46,12 @@ void test_fortio_unsafe_cast(void *arg) { void test_not_existing_read() { fortio_type *fortio = - fortio_open_reader("/does/not/exist", false, ECL_ENDIAN_FLIP); + fortio_open_reader("/does/not/exist", false, RD_ENDIAN_FLIP); test_assert_NULL(fortio); } void test_write(const char *filename, bool path_exists) { - fortio_type *fortio = fortio_open_writer(filename, false, ECL_ENDIAN_FLIP); + fortio_type *fortio = fortio_open_writer(filename, false, RD_ENDIAN_FLIP); if (path_exists) { test_assert_not_NULL(fortio); fortio_fclose(fortio); @@ -74,7 +74,7 @@ void test_wrapper(const char *filename) { } void test_open_close_read(const char *filename) { - fortio_type *fortio = fortio_open_reader(filename, false, ECL_ENDIAN_FLIP); + fortio_type *fortio = fortio_open_reader(filename, false, RD_ENDIAN_FLIP); test_assert_not_NULL(fortio); test_assert_true(fortio_stream_is_open(fortio)); @@ -89,7 +89,7 @@ void test_open_close_read(const char *filename) { } void test_fread_truncated_data() { - ecl::util::TestArea work_area("fortio_truncated"); + rd::util::TestArea work_area("fortio_truncated"); { const size_t buffer_size = 1000; char *buffer = (char *)util_malloc(buffer_size); @@ -118,7 +118,7 @@ void test_fread_truncated_data() { } void test_fread_truncated_head() { - ecl::util::TestArea work_area("fortio_truncated"); + rd::util::TestArea work_area("fortio_truncated"); { { FILE *stream = util_fopen("PRESSURE", "w"); @@ -137,7 +137,7 @@ void test_fread_truncated_head() { } void test_fread_truncated_tail() { - ecl::util::TestArea work_area("fortio_truncated3"); + rd::util::TestArea work_area("fortio_truncated3"); { const size_t buffer_size = 1000; char *buffer = (char *)util_malloc(buffer_size); @@ -162,7 +162,7 @@ void test_fread_truncated_tail() { } void test_fread_invalid_tail() { - ecl::util::TestArea work_area("fortio_invalid"); + rd::util::TestArea work_area("fortio_invalid"); int record_size = 10; char *buffer = (char *)util_malloc(record_size); { @@ -191,7 +191,7 @@ void test_fread_invalid_tail() { } void test_at_eof() { - ecl::util::TestArea work_area("fortio_truncated3"); + rd::util::TestArea work_area("fortio_truncated3"); { fortio_type *fortio = fortio_open_writer("PRESSURE", false, true); char *buffer = (char *)util_malloc(100); @@ -215,7 +215,7 @@ void test_at_eof() { } void test_fseek() { - ecl::util::TestArea work_area("fortio_fseek"); + rd::util::TestArea work_area("fortio_fseek"); { fortio_type *fortio = fortio_open_writer("PRESSURE", false, true); char *buffer = (char *)util_malloc(100); @@ -238,7 +238,7 @@ void test_fseek() { } void test_write_failure() { - ecl::util::TestArea work_area("fortio_truncated"); + rd::util::TestArea work_area("fortio_truncated"); { fortio_type *fortio = fortio_open_writer("PRESSURE", false, true); char *buffer = (char *)util_malloc(100); @@ -276,7 +276,7 @@ int main(int argc, char **argv) { test_write("/tmp/path/does/not/exist", false); { - ecl::util::TestArea work_area("ecl_fortio_write"); + rd::util::TestArea work_area("rd_fortio_write"); util_make_path("path"); test_write("path/file.x", true); } diff --git a/lib/resdata/tests/rd_get_num_cpu_test.cpp b/lib/resdata/tests/rd_get_num_cpu_test.cpp index 692acf01c6..deef44d2bb 100644 --- a/lib/resdata/tests/rd_get_num_cpu_test.cpp +++ b/lib/resdata/tests/rd_get_num_cpu_test.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include int main(int argc, char **argv) { const char *filename1 = argv[1]; @@ -11,10 +11,10 @@ int main(int argc, char **argv) { const char *filename4 = argv[4]; const char *filename5 = argv[5]; - test_assert_int_equal(ecl_util_get_num_cpu(filename1), 4); - test_assert_int_equal(ecl_util_get_num_cpu(filename2), 4); - test_assert_int_equal(ecl_util_get_num_cpu(filename3), 15); - test_assert_int_equal(ecl_util_get_num_cpu(filename4), 4); - test_assert_int_equal(ecl_util_get_num_cpu(filename5), 4); + test_assert_int_equal(rd_get_num_cpu(filename1), 4); + test_assert_int_equal(rd_get_num_cpu(filename2), 4); + test_assert_int_equal(rd_get_num_cpu(filename3), 15); + test_assert_int_equal(rd_get_num_cpu(filename4), 4); + test_assert_int_equal(rd_get_num_cpu(filename5), 4); exit(0); } diff --git a/lib/resdata/tests/rd_grid_add_nnc.cpp b/lib/resdata/tests/rd_grid_add_nnc.cpp index eb9222fab9..37cf773f6e 100644 --- a/lib/resdata/tests/rd_grid_add_nnc.cpp +++ b/lib/resdata/tests/rd_grid_add_nnc.cpp @@ -5,15 +5,15 @@ #include #include -#include +#include -void verify_simple_nnc(const ecl_grid_type *grid) { - test_assert_not_NULL(ecl_grid_get_cell_nnc_info1(grid, 5)); - test_assert_not_NULL(ecl_grid_get_cell_nnc_info1(grid, 8)); +void verify_simple_nnc(const rd_grid_type *grid) { + test_assert_not_NULL(rd_grid_get_cell_nnc_info1(grid, 5)); + test_assert_not_NULL(rd_grid_get_cell_nnc_info1(grid, 8)); // Cell 5: { - const nnc_info_type *nnc_info = ecl_grid_get_cell_nnc_info1(grid, 5); + const nnc_info_type *nnc_info = rd_grid_get_cell_nnc_info1(grid, 5); const nnc_vector_type *nnc_vector = nnc_info_iget_vector(nnc_info, 0); test_assert_int_equal(2, nnc_vector_get_size(nnc_vector)); test_assert_int_equal(6, nnc_vector_iget_grid_index(nnc_vector, 0)); @@ -25,7 +25,7 @@ void verify_simple_nnc(const ecl_grid_type *grid) { // Cell 8: { - const nnc_info_type *nnc_info = ecl_grid_get_cell_nnc_info1(grid, 8); + const nnc_info_type *nnc_info = rd_grid_get_cell_nnc_info1(grid, 8); const nnc_vector_type *nnc_vector = nnc_info_iget_vector(nnc_info, 0); test_assert_int_equal(1, nnc_vector_get_size(nnc_vector)); test_assert_int_equal(9, nnc_vector_iget_grid_index(nnc_vector, 0)); @@ -34,58 +34,55 @@ void verify_simple_nnc(const ecl_grid_type *grid) { } void simple_test() { - ecl_grid_type *grid0 = - ecl_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); - ecl_grid_add_self_nnc(grid0, 5, 6, 0); - ecl_grid_add_self_nnc(grid0, 5, 7, 1); - ecl_grid_add_self_nnc(grid0, 8, 9, 2); + rd_grid_type *grid0 = rd_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); + rd_grid_add_self_nnc(grid0, 5, 6, 0); + rd_grid_add_self_nnc(grid0, 5, 7, 1); + rd_grid_add_self_nnc(grid0, 8, 9, 2); verify_simple_nnc(grid0); { - ecl::util::TestArea ta("simple_nnc"); - ecl_grid_type *grid1; - ecl_grid_fwrite_EGRID2(grid0, "TEST.EGRID", ECL_METRIC_UNITS); - grid1 = ecl_grid_alloc("TEST.EGRID"); + rd::util::TestArea ta("simple_nnc"); + rd_grid_type *grid1; + rd_grid_fwrite_EGRID2(grid0, "TEST.EGRID", RD_METRIC_UNITS); + grid1 = rd_grid_alloc("TEST.EGRID"); verify_simple_nnc(grid1); - ecl_grid_free(grid1); + rd_grid_free(grid1); } - ecl_grid_free(grid0); + rd_grid_free(grid0); } void overwrite_test() { - ecl_grid_type *grid0 = - ecl_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); + rd_grid_type *grid0 = rd_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); /* This first list of nnc will be overwritten, and will not survive the serialization to disk. */ - ecl_grid_add_self_nnc(grid0, 1, 2, 0); - ecl_grid_add_self_nnc(grid0, 1, 3, 1); - ecl_grid_add_self_nnc(grid0, 1, 4, 2); + rd_grid_add_self_nnc(grid0, 1, 2, 0); + rd_grid_add_self_nnc(grid0, 1, 3, 1); + rd_grid_add_self_nnc(grid0, 1, 4, 2); - ecl_grid_add_self_nnc(grid0, 5, 6, 0); - ecl_grid_add_self_nnc(grid0, 5, 7, 1); - ecl_grid_add_self_nnc(grid0, 8, 9, 2); + rd_grid_add_self_nnc(grid0, 5, 6, 0); + rd_grid_add_self_nnc(grid0, 5, 7, 1); + rd_grid_add_self_nnc(grid0, 8, 9, 2); verify_simple_nnc(grid0); { - ecl::util::TestArea ta("overwrite"); - ecl_grid_type *grid1; - ecl_grid_fwrite_EGRID2(grid0, "TEST.EGRID", ECL_METRIC_UNITS); - grid1 = ecl_grid_alloc("TEST.EGRID"); + rd::util::TestArea ta("overwrite"); + rd_grid_type *grid1; + rd_grid_fwrite_EGRID2(grid0, "TEST.EGRID", RD_METRIC_UNITS); + grid1 = rd_grid_alloc("TEST.EGRID"); verify_simple_nnc(grid1); - ecl_grid_free(grid1); + rd_grid_free(grid1); } - ecl_grid_free(grid0); + rd_grid_free(grid0); } void list_test() { - ecl_grid_type *grid0 = - ecl_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); + rd_grid_type *grid0 = rd_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); int_vector_type *g1 = int_vector_alloc(0, 0); int_vector_type *g2 = int_vector_alloc(0, 0); @@ -96,22 +93,22 @@ void list_test() { int_vector_append(g1, 8); int_vector_append(g2, 9); - ecl_grid_add_self_nnc_list(grid0, int_vector_get_ptr(g1), - int_vector_get_ptr(g2), int_vector_size(g1)); + rd_grid_add_self_nnc_list(grid0, int_vector_get_ptr(g1), + int_vector_get_ptr(g2), int_vector_size(g1)); verify_simple_nnc(grid0); { - ecl::util::TestArea ta("list_test"); - ecl_grid_type *grid1; - ecl_grid_fwrite_EGRID2(grid0, "TEST.EGRID", ECL_METRIC_UNITS); - grid1 = ecl_grid_alloc("TEST.EGRID"); + rd::util::TestArea ta("list_test"); + rd_grid_type *grid1; + rd_grid_fwrite_EGRID2(grid0, "TEST.EGRID", RD_METRIC_UNITS); + grid1 = rd_grid_alloc("TEST.EGRID"); verify_simple_nnc(grid1); - ecl_grid_free(grid1); + rd_grid_free(grid1); } int_vector_free(g1); int_vector_free(g2); - ecl_grid_free(grid0); + rd_grid_free(grid0); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_grid_cell_contains.cpp b/lib/resdata/tests/rd_grid_cell_contains.cpp index 15325f88bb..0cd154cec5 100644 --- a/lib/resdata/tests/rd_grid_cell_contains.cpp +++ b/lib/resdata/tests/rd_grid_cell_contains.cpp @@ -3,9 +3,9 @@ #include #include -#include +#include -bool get_test_point1(const ecl_grid_type *grid, int global_index, double *_xpos, +bool get_test_point1(const rd_grid_type *grid, int global_index, double *_xpos, double *_ypos, double *_zpos) { const int corners[4] = {1, 2, 5, 6}; double xpos = 0; @@ -13,19 +13,19 @@ bool get_test_point1(const ecl_grid_type *grid, int global_index, double *_xpos, double zpos = 0; const double min_volume = 1e-8; - if (fabs(ecl_grid_get_cell_volume1(grid, global_index)) <= min_volume) + if (fabs(rd_grid_get_cell_volume1(grid, global_index)) <= min_volume) return false; - if (ecl_grid_get_cell_twist1(grid, global_index) > 0) + if (rd_grid_get_cell_twist1(grid, global_index) > 0) return false; - if (!ecl_grid_cell_regular1(grid, global_index)) + if (!rd_grid_cell_regular1(grid, global_index)) return false; for (int ci = 0; ci < 4; ci++) { int corner = corners[ci]; double x, y, z; - ecl_grid_get_cell_corner_xyz1(grid, global_index, corner, &x, &y, &z); + rd_grid_get_cell_corner_xyz1(grid, global_index, corner, &x, &y, &z); xpos += x; ypos += y; zpos += z; @@ -35,44 +35,44 @@ bool get_test_point1(const ecl_grid_type *grid, int global_index, double *_xpos, *_ypos = ypos * 0.25; *_zpos = zpos * 0.25; - return ecl_grid_cell_contains_xyz1(grid, global_index, *_xpos, *_ypos, - *_zpos); + return rd_grid_cell_contains_xyz1(grid, global_index, *_xpos, *_ypos, + *_zpos); } -bool get_test_point3(const ecl_grid_type *grid, int i, int j, int k, +bool get_test_point3(const rd_grid_type *grid, int i, int j, int k, double *_xpos, double *_ypos, double *_zpos) { - const int global_index = ecl_grid_get_global_index3(grid, i, j, k); + const int global_index = rd_grid_get_global_index3(grid, i, j, k); return get_test_point1(grid, global_index, _xpos, _ypos, _zpos); } -void test_grid_covering(const ecl_grid_type *grid) { - const int nx = ecl_grid_get_nx(grid); - const int ny = ecl_grid_get_ny(grid); - const int nz = ecl_grid_get_nz(grid); +void test_grid_covering(const rd_grid_type *grid) { + const int nx = rd_grid_get_nx(grid); + const int ny = rd_grid_get_ny(grid); + const int nz = rd_grid_get_nz(grid); for (int k = 0; k < nz - 1; k++) { for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) { - int g1 = ecl_grid_get_global_index3(grid, i, j, k); - int g2 = ecl_grid_get_global_index3(grid, i, j, k + 1); + int g1 = rd_grid_get_global_index3(grid, i, j, k); + int g2 = rd_grid_get_global_index3(grid, i, j, k + 1); double p1[3]; double p2[3]; for (int l = 0; l < 4; l++) { - ecl_grid_get_cell_corner_xyz1(grid, g1, l + 4, &p1[0], - &p1[1], &p1[2]); - ecl_grid_get_cell_corner_xyz1(grid, g2, l, &p2[0], &p2[1], - &p2[2]); + rd_grid_get_cell_corner_xyz1(grid, g1, l + 4, &p1[0], + &p1[1], &p1[2]); + rd_grid_get_cell_corner_xyz1(grid, g2, l, &p2[0], &p2[1], + &p2[2]); test_assert_true(p1[0] == p2[0]); test_assert_true(p1[1] == p2[1]); test_assert_true(p1[2] == p2[2]); } for (int l = 0; l < 4; l++) { - ecl_grid_get_cell_corner_xyz1(grid, g1, l, &p1[0], &p1[1], - &p1[2]); - ecl_grid_get_cell_corner_xyz1(grid, g1, l + 4, &p2[0], - &p2[1], &p2[2]); + rd_grid_get_cell_corner_xyz1(grid, g1, l, &p1[0], &p1[1], + &p1[2]); + rd_grid_get_cell_corner_xyz1(grid, g1, l + 4, &p2[0], + &p2[1], &p2[2]); test_assert_true(p2[2] >= p1[2]); } @@ -81,24 +81,24 @@ void test_grid_covering(const ecl_grid_type *grid) { } } -void assert_contains(const ecl_grid_type *grid, int i, int j, int k, double x, +void assert_contains(const rd_grid_type *grid, int i, int j, int k, double x, double y, double z) { - if (!ecl_grid_cell_contains_xyz3(grid, i, j, k, x, y, z)) + if (!rd_grid_cell_contains_xyz3(grid, i, j, k, x, y, z)) fprintf(stderr, " Point: (%g,%g,%g) not found in cell: (%d,%d,%d) \n", x, y, z, i, j, k); - test_assert_true(ecl_grid_cell_contains_xyz3(grid, i, j, k, x, y, z)); + test_assert_true(rd_grid_cell_contains_xyz3(grid, i, j, k, x, y, z)); } -void test_contains(const ecl_grid_type *grid) { - const int nx = ecl_grid_get_nx(grid); - const int ny = ecl_grid_get_ny(grid); - const int nz = ecl_grid_get_nz(grid); +void test_contains(const rd_grid_type *grid) { + const int nx = rd_grid_get_nx(grid); + const int ny = rd_grid_get_ny(grid); + const int nz = rd_grid_get_nz(grid); for (int k = 0; k < nz; k++) { for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) { - if (ecl_grid_get_cell_twist3(grid, i, j, k) != 0) { + if (rd_grid_get_cell_twist3(grid, i, j, k) != 0) { double x, y, z; if (get_test_point3(grid, i, j, k, &x, &y, &z)) { assert_contains(grid, i, j, k, x, y, z); @@ -118,10 +118,10 @@ void test_contains(const ecl_grid_type *grid) { for (i2 = imin; i2 < imax; i2++) { if ((i != i2) && (j != j2) && (k != k2)) { - if (ecl_grid_get_cell_twist3( + if (rd_grid_get_cell_twist3( grid, i2, j2, k2) == 0) test_assert_false( - ecl_grid_cell_contains_xyz3( + rd_grid_cell_contains_xyz3( grid, i2, j2, k2, x, y, z)); } @@ -136,42 +136,42 @@ void test_contains(const ecl_grid_type *grid) { } } -void test_find(ecl_grid_type *grid) { +void test_find(rd_grid_type *grid) { int init_index; int find_count = 100; - int delta = util_int_max(1, ecl_grid_get_global_size(grid) / find_count); - for (init_index = 0; init_index < ecl_grid_get_global_size(grid); + int delta = util_int_max(1, rd_grid_get_global_size(grid) / find_count); + for (init_index = 0; init_index < rd_grid_get_global_size(grid); init_index += delta) { - if (ecl_grid_get_cell_twist1(grid, init_index) == 0) { + if (rd_grid_get_cell_twist1(grid, init_index) == 0) { double x, y, z; int find_index; int start_index = 0; if (get_test_point1(grid, init_index, &x, &y, &z)) { - find_index = ecl_grid_get_global_index_from_xyz(grid, x, y, z, - start_index); + find_index = rd_grid_get_global_index_from_xyz(grid, x, y, z, + start_index); if (init_index != find_index) { int i1, j1, k1, i2, j2, k2; - ecl_grid_get_ijk1(grid, init_index, &i1, &j1, &k1); - ecl_grid_get_ijk1(grid, find_index, &i2, &j2, &k2); + rd_grid_get_ijk1(grid, init_index, &i1, &j1, &k1); + rd_grid_get_ijk1(grid, find_index, &i2, &j2, &k2); printf(" point: %14.7f %14.7f %14.7f \n", x, y, z); printf(" Regular: %d / %d \n", - ecl_grid_cell_regular3(grid, i1, j1, k1), - ecl_grid_cell_regular3(grid, i2, j2, k2)); + rd_grid_cell_regular3(grid, i1, j1, k1), + rd_grid_cell_regular3(grid, i2, j2, k2)); printf( " init: contains(%7d) : %d (%d,%d,%d) V:%g \n", init_index, - ecl_grid_cell_contains_xyz1(grid, init_index, x, y, z), + rd_grid_cell_contains_xyz1(grid, init_index, x, y, z), i1 + 1, j1 + 1, k1 + 1, - ecl_grid_get_cell_volume1(grid, init_index)); + rd_grid_get_cell_volume1(grid, init_index)); printf( "ERROR: find: contains(%7d) : %d (%d,%d,%d) V:%g " "\n\n", find_index, - ecl_grid_cell_contains_xyz1(grid, find_index, x, y, z), + rd_grid_cell_contains_xyz1(grid, find_index, x, y, z), i2 + 1, j2 + 1, k2 + 1, - ecl_grid_get_cell_volume1(grid, find_index)); + rd_grid_get_cell_volume1(grid, find_index)); test_assert_int_equal(init_index, find_index); } } @@ -180,100 +180,100 @@ void test_find(ecl_grid_type *grid) { } void test_corners() { - ecl_grid_type *grid = ecl_grid_alloc_rectangular(3, 3, 3, 1, 1, 1, NULL); + rd_grid_type *grid = rd_grid_alloc_rectangular(3, 3, 3, 1, 1, 1, NULL); test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, -1, -1, -1, 0)); - test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, -1, 1, 1, 0)); - test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, 1, -1, 1, 0)); - test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, 1, 1, -1, 0)); + -1, rd_grid_get_global_index_from_xyz(grid, -1, -1, -1, 0)); + test_assert_int_equal(-1, + rd_grid_get_global_index_from_xyz(grid, -1, 1, 1, 0)); + test_assert_int_equal(-1, + rd_grid_get_global_index_from_xyz(grid, 1, -1, 1, 0)); + test_assert_int_equal(-1, + rd_grid_get_global_index_from_xyz(grid, 1, 1, -1, 0)); test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, 3.5, 3.5, 3.5, 0)); + -1, rd_grid_get_global_index_from_xyz(grid, 3.5, 3.5, 3.5, 0)); test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, 3.5, 1, 1, 0)); + -1, rd_grid_get_global_index_from_xyz(grid, 3.5, 1, 1, 0)); test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, 1, 3.5, 1, 0)); + -1, rd_grid_get_global_index_from_xyz(grid, 1, 3.5, 1, 0)); test_assert_int_equal( - -1, ecl_grid_get_global_index_from_xyz(grid, 1, 1, 3.5, 0)); + -1, rd_grid_get_global_index_from_xyz(grid, 1, 1, 3.5, 0)); { double x, y, z; int i; - ecl_grid_get_cell_corner_xyz3(grid, 0, 0, 0, 0, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 0, 0, 0, 0, &x, &y, &z); test_assert_int_equal( - 0, ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + 0, rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); for (i = 1; i < 8; i++) { - ecl_grid_get_cell_corner_xyz3(grid, 0, 0, 0, i, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 0, 0, 0, i, &x, &y, &z); test_assert_int_not_equal( - 0, ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + 0, rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); } // Corner 1 - ecl_grid_get_cell_corner_xyz3(grid, 2, 0, 0, 1, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 2, 0, 0, 1, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 2, 0, 0), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 2, 0, 0), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); // Corner 2 - ecl_grid_get_cell_corner_xyz3(grid, 0, 2, 0, 2, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 0, 2, 0, 2, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 0, 2, 0), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 0, 2, 0), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); // Corner 3 - ecl_grid_get_cell_corner_xyz3(grid, 2, 2, 0, 3, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 2, 2, 0, 3, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 2, 2, 0), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 2, 2, 0), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); // Corner 4 - ecl_grid_get_cell_corner_xyz3(grid, 0, 0, 2, 4, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 0, 0, 2, 4, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 0, 0, 2), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 0, 0, 2), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); // Corner 5 - ecl_grid_get_cell_corner_xyz3(grid, 2, 0, 2, 5, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 2, 0, 2, 5, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 2, 0, 2), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 2, 0, 2), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); // Corner 6 - ecl_grid_get_cell_corner_xyz3(grid, 0, 2, 2, 6, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 0, 2, 2, 6, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 0, 2, 2), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 0, 2, 2), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); // Corner 7 - ecl_grid_get_cell_corner_xyz3(grid, 2, 2, 2, 7, &x, &y, &z); + rd_grid_get_cell_corner_xyz3(grid, 2, 2, 2, 7, &x, &y, &z); test_assert_int_equal( - ecl_grid_get_global_index3(grid, 2, 2, 2), - ecl_grid_get_global_index_from_xyz(grid, x, y, z, 0)); + rd_grid_get_global_index3(grid, 2, 2, 2), + rd_grid_get_global_index_from_xyz(grid, x, y, z, 0)); } - ecl_grid_free(grid); + rd_grid_free(grid); } int main(int argc, char **argv) { - ecl_grid_type *grid; + rd_grid_type *grid; util_install_signals(); if (argc == 1) { - grid = ecl_grid_alloc_rectangular(6, 6, 6, 1, 2, 3, NULL); + grid = rd_grid_alloc_rectangular(6, 6, 6, 1, 2, 3, NULL); } else - grid = ecl_grid_alloc(argv[1]); + grid = rd_grid_alloc(argv[1]); test_grid_covering(grid); test_contains(grid); test_find(grid); test_corners(); - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_grid_cell_contains_wellpath.cpp b/lib/resdata/tests/rd_grid_cell_contains_wellpath.cpp index 58188ba23c..7ffbbd9838 100644 --- a/lib/resdata/tests/rd_grid_cell_contains_wellpath.cpp +++ b/lib/resdata/tests/rd_grid_cell_contains_wellpath.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include typedef struct { @@ -19,7 +19,7 @@ typedef struct { bool skip; } point_type; -vector_type *load_expected(const ecl_grid_type *grid, const char *filename) { +vector_type *load_expected(const rd_grid_type *grid, const char *filename) { FILE *stream = util_fopen(filename, "r"); vector_type *expected = vector_alloc_new(); @@ -38,7 +38,7 @@ vector_type *load_expected(const ecl_grid_type *grid, const char *filename) { p->j = j - 1; p->k = k - 1; p->skip = skip; - p->g = ecl_grid_get_global_index3(grid, p->i, p->j, p->k); + p->g = rd_grid_get_global_index3(grid, p->i, p->j, p->k); vector_append_owned_ref(expected, p, free); } else break; @@ -49,28 +49,28 @@ vector_type *load_expected(const ecl_grid_type *grid, const char *filename) { return expected; } -void test_well_point(ecl_grid_type *grid, const point_type *expected) { - int g = ecl_grid_get_global_index_from_xyz(grid, expected->x, expected->y, - expected->z, 0); - if (g != ecl_grid_get_global_index3(grid, expected->i, expected->j, - expected->k)) { +void test_well_point(rd_grid_type *grid, const point_type *expected) { + int g = rd_grid_get_global_index_from_xyz(grid, expected->x, expected->y, + expected->z, 0); + if (g != rd_grid_get_global_index3(grid, expected->i, expected->j, + expected->k)) { int i, j, k; - ecl_grid_get_ijk1(grid, g, &i, &j, &k); - bool g_contains_xyz = ecl_grid_cell_contains_xyz1( + rd_grid_get_ijk1(grid, g, &i, &j, &k); + bool g_contains_xyz = rd_grid_cell_contains_xyz1( grid, expected->g, expected->x, expected->y, expected->z); fprintf(stderr, - "(%g,%g,%g) differs: EclGrid: %d:(%d,%d,%d) Expected: " + "(%g,%g,%g) differs: ResdataGrid: %d:(%d,%d,%d) Expected: " "%d:(%d,%d,%d) contains:%d\n", expected->x, expected->y, expected->z, g, i, j, k, expected->g, expected->i, expected->j, expected->k, g_contains_xyz); } if (!expected->skip) - test_assert_int_equal(g, ecl_grid_get_global_index3(grid, expected->i, - expected->j, - expected->k)); + test_assert_int_equal(g, rd_grid_get_global_index3(grid, expected->i, + expected->j, + expected->k)); else { - if (g != ecl_grid_get_global_index3(grid, expected->i, expected->j, - expected->k)) + if (g != rd_grid_get_global_index3(grid, expected->i, expected->j, + expected->k)) fprintf(stderr, " ** Skipping failed test for point: %g %g %g \n", expected->x, expected->y, expected->z); } @@ -79,7 +79,7 @@ void test_well_point(ecl_grid_type *grid, const point_type *expected) { int main(int argc, char **argv) { util_install_signals(); { - ecl_grid_type *grid = ecl_grid_alloc(argv[1]); + rd_grid_type *grid = rd_grid_alloc(argv[1]); vector_type *expected = load_expected(grid, argv[2]); for (int c = 0; c < vector_get_size(expected); c++) { @@ -87,7 +87,7 @@ int main(int argc, char **argv) { (const point_type *)vector_iget_const(expected, c); test_well_point(grid, p); } - ecl_grid_free(grid); + rd_grid_free(grid); vector_free(expected); } exit(0); diff --git a/lib/resdata/tests/rd_grid_copy.cpp b/lib/resdata/tests/rd_grid_copy.cpp index 869d56dbf6..c96349ca71 100644 --- a/lib/resdata/tests/rd_grid_copy.cpp +++ b/lib/resdata/tests/rd_grid_copy.cpp @@ -5,28 +5,28 @@ #include #include -#include +#include -void test_copy_grid(const ecl_grid_type *grid) { - ecl_grid_type *grid_copy = ecl_grid_alloc_copy(grid); - test_assert_true(ecl_grid_compare(grid, grid_copy, true, true, true)); - ecl_grid_free(grid_copy); +void test_copy_grid(const rd_grid_type *grid) { + rd_grid_type *grid_copy = rd_grid_alloc_copy(grid); + test_assert_true(rd_grid_compare(grid, grid_copy, true, true, true)); + rd_grid_free(grid_copy); } void test_copy_grid_file(const char *filename) { - ecl_grid_type *src_grid = ecl_grid_alloc(filename); - ecl_grid_type *copy_grid = ecl_grid_alloc_copy(src_grid); - test_assert_true(ecl_grid_compare(src_grid, copy_grid, true, true, true)); - ecl_grid_free(copy_grid); - ecl_grid_free(src_grid); + rd_grid_type *src_grid = rd_grid_alloc(filename); + rd_grid_type *copy_grid = rd_grid_alloc_copy(src_grid); + test_assert_true(rd_grid_compare(src_grid, copy_grid, true, true, true)); + rd_grid_free(copy_grid); + rd_grid_free(src_grid); } int main(int argc, char **argv) { if (argc < 2) { - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(10, 11, 12, 1, 2, 3, NULL); + rd_grid_type *grid = + rd_grid_alloc_rectangular(10, 11, 12, 1, 2, 3, NULL); test_copy_grid(grid); - ecl_grid_free(grid); + rd_grid_free(grid); } else { test_copy_grid_file(argv[1]); } diff --git a/lib/resdata/tests/rd_grid_corner.cpp b/lib/resdata/tests/rd_grid_corner.cpp index 1e93b6fafb..44f5b4d586 100644 --- a/lib/resdata/tests/rd_grid_corner.cpp +++ b/lib/resdata/tests/rd_grid_corner.cpp @@ -3,43 +3,43 @@ #include -#include +#include void invalid_call1(void *arg) { - ecl_grid_type *grid = ecl_grid_safe_cast(arg); + rd_grid_type *grid = rd_grid_safe_cast(arg); double x, y, z; - ecl_grid_get_corner_xyz(grid, 10, 10, 11, &x, &y, &z); + rd_grid_get_corner_xyz(grid, 10, 10, 11, &x, &y, &z); } -void test_invalid(ecl_grid_type *grid) { - test_assert_util_abort("ecl_grid_get_corner_xyz", invalid_call1, grid); +void test_invalid(rd_grid_type *grid) { + test_assert_util_abort("rd_grid_get_corner_xyz", invalid_call1, grid); } -void test_OK(const ecl_grid_type *grid) { +void test_OK(const rd_grid_type *grid) { double x, y, z; double x8[8]; double y8[8]; double z8[8]; - ecl_grid_get_corner_xyz(grid, 0, 0, 0, &x, &y, &z); + rd_grid_get_corner_xyz(grid, 0, 0, 0, &x, &y, &z); test_assert_double_equal(x, 0); test_assert_double_equal(y, 0); test_assert_double_equal(z, 0); - ecl_grid_get_corner_xyz(grid, 4, 5, 6, &x, &y, &z); + rd_grid_get_corner_xyz(grid, 4, 5, 6, &x, &y, &z); test_assert_double_equal(x, 4); test_assert_double_equal(y, 5); test_assert_double_equal(z, 6); - ecl_grid_get_corner_xyz(grid, 10, 10, 10, &x, &y, &z); + rd_grid_get_corner_xyz(grid, 10, 10, 10, &x, &y, &z); test_assert_double_equal(x, 10); test_assert_double_equal(y, 10); test_assert_double_equal(z, 10); - ecl_grid_export_cell_corners1(grid, 456, x8, y8, z8); + rd_grid_export_cell_corners1(grid, 456, x8, y8, z8); for (int i = 0; i < 8; i++) { - ecl_grid_get_cell_corner_xyz1(grid, 456, i, &x, &y, &z); + rd_grid_get_cell_corner_xyz1(grid, 456, i, &x, &y, &z); test_assert_double_equal(x, x8[i]); test_assert_double_equal(y, y8[i]); test_assert_double_equal(z, z8[i]); @@ -47,11 +47,11 @@ void test_OK(const ecl_grid_type *grid) { } int main(int argc, char **argv) { - ecl_grid_type *grid = ecl_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); + rd_grid_type *grid = rd_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); test_invalid(grid); test_OK(grid); - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_grid_create.cpp b/lib/resdata/tests/rd_grid_create.cpp index 812498a72c..f925ec76e3 100644 --- a/lib/resdata/tests/rd_grid_create.cpp +++ b/lib/resdata/tests/rd_grid_create.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include void test_create2() { int nx = 10; @@ -32,18 +32,18 @@ void test_create2() { } { - ecl_grid_type *grid = - ecl_grid_alloc_dx_dy_dz_tops(nx, ny, nz, dx, dy, dz, tops, NULL); + rd_grid_type *grid = + rd_grid_alloc_dx_dy_dz_tops(nx, ny, nz, dx, dy, dz, tops, NULL); - test_assert_int_equal(nx * ny * nz, ecl_grid_get_global_size(grid)); - test_assert_int_equal(nx * ny * nz, ecl_grid_get_active_size(grid)); + test_assert_int_equal(nx * ny * nz, rd_grid_get_global_size(grid)); + test_assert_int_equal(nx * ny * nz, rd_grid_get_active_size(grid)); for (int k = 0; k < nz; k++) { for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) { int g = k * nx * ny + j * nx + i; - test_assert_double_equal(ecl_grid_get_cell_volume1(grid, g), + test_assert_double_equal(rd_grid_get_cell_volume1(grid, g), dx[g] * dy[g] * dz[g]); } } @@ -51,12 +51,12 @@ void test_create2() { { double x, y, z; - ecl_grid_get_xyz1(grid, 0, &x, &y, &z); + rd_grid_get_xyz1(grid, 0, &x, &y, &z); test_assert_double_equal(x, dx[0] * 0.5); test_assert_double_equal(y, dy[0] * 0.5); test_assert_double_equal(z, dz[0] * 0.5 + tops[0]); } - ecl_grid_free(grid); + rd_grid_free(grid); } free(tops); free(dx); @@ -89,23 +89,23 @@ void test_create1() { } { - ecl_grid_type *grid = - ecl_grid_alloc_dx_dy_dz_tops(nx, ny, nz, dx, dy, dz, tops, NULL); + rd_grid_type *grid = + rd_grid_alloc_dx_dy_dz_tops(nx, ny, nz, dx, dy, dz, tops, NULL); - test_assert_int_equal(nx * ny * nz, ecl_grid_get_global_size(grid)); - test_assert_int_equal(nx * ny * nz, ecl_grid_get_active_size(grid)); + test_assert_int_equal(nx * ny * nz, rd_grid_get_global_size(grid)); + test_assert_int_equal(nx * ny * nz, rd_grid_get_active_size(grid)); for (int k = 0; k < nz; k++) { for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) { int g = k * nx * ny + j * nx + i; - test_assert_double_equal(ecl_grid_get_cell_volume1(grid, g), + test_assert_double_equal(rd_grid_get_cell_volume1(grid, g), dx[g] * dy[g] * dz[g]); { double x, y, z; - ecl_grid_get_xyz1(grid, g, &x, &y, &z); + rd_grid_get_xyz1(grid, g, &x, &y, &z); test_assert_double_equal(x, i + 0.5); test_assert_double_equal(y, j + 0.5); test_assert_double_equal(z, k + 0.5); @@ -113,7 +113,7 @@ void test_create1() { } } } - ecl_grid_free(grid); + rd_grid_free(grid); } free(tops); free(dx); diff --git a/lib/resdata/tests/rd_grid_dims.cpp b/lib/resdata/tests/rd_grid_dims.cpp index ed8e7e2bd2..1c8a48f54c 100644 --- a/lib/resdata/tests/rd_grid_dims.cpp +++ b/lib/resdata/tests/rd_grid_dims.cpp @@ -5,21 +5,21 @@ #include #include -#include -#include +#include +#include void test_grid(const char *grid_filename, const char *data_filename) { - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_filename); - ecl_grid_dims_type *grid_dims = - ecl_grid_dims_alloc(grid_filename, data_filename); + rd_grid_type *rd_grid = rd_grid_alloc(grid_filename); + rd_grid_dims_type *grid_dims = + rd_grid_dims_alloc(grid_filename, data_filename); test_assert_not_NULL(grid_dims); - test_assert_int_equal(ecl_grid_get_num_lgr(ecl_grid) + 1, - ecl_grid_dims_get_num_grids(grid_dims)); - for (int i = 0; i < ecl_grid_dims_get_num_grids(grid_dims); i++) { + test_assert_int_equal(rd_grid_get_num_lgr(rd_grid) + 1, + rd_grid_dims_get_num_grids(grid_dims)); + for (int i = 0; i < rd_grid_dims_get_num_grids(grid_dims); i++) { - grid_dims_type d1 = ecl_grid_iget_dims(ecl_grid, i); - const grid_dims_type *d2 = ecl_grid_dims_iget_dims(grid_dims, i); + grid_dims_type d1 = rd_grid_iget_dims(rd_grid, i); + const grid_dims_type *d2 = rd_grid_dims_iget_dims(grid_dims, i); test_assert_int_equal(d1.nx, d2->nx); test_assert_int_equal(d1.ny, d2->ny); @@ -50,7 +50,7 @@ int main(int argc, char **argv) { util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ if (argc == 1) { - ecl_grid_dims_type *grid_dims = ecl_grid_dims_alloc(argv[0], NULL); + rd_grid_dims_type *grid_dims = rd_grid_dims_alloc(argv[0], NULL); test_assert_NULL(grid_dims); test_dims(); } else { diff --git a/lib/resdata/tests/rd_grid_dx_dy_dz.cpp b/lib/resdata/tests/rd_grid_dx_dy_dz.cpp index ad73163b8a..97ed7fa8e8 100644 --- a/lib/resdata/tests/rd_grid_dx_dy_dz.cpp +++ b/lib/resdata/tests/rd_grid_dx_dy_dz.cpp @@ -8,8 +8,8 @@ #include #include -#include -#include +#include +#include double err(double a, double b) { return (a - b) / a; } @@ -17,21 +17,21 @@ void test_dxdydz(const std::string &grid_fname, const std::string &init_fname) { double eps_x = 1e-4; double eps_y = 1e-4; double eps_z = 1e-3; - ecl_grid_type *grid = ecl_grid_alloc(grid_fname.c_str()); - ecl_file_type *init_file = ecl_file_open(init_fname.c_str(), 0); - ecl_kw_type *dx = ecl_file_iget_named_kw(init_file, "DX", 0); - ecl_kw_type *dy = ecl_file_iget_named_kw(init_file, "DY", 0); - ecl_kw_type *dz = ecl_file_iget_named_kw(init_file, "DZ", 0); - for (int a = 0; a < ecl_grid_get_active_size(grid); a += 100) { - int g = ecl_grid_get_global_index1A(grid, a); - - double dxg = ecl_grid_get_cell_dx1(grid, g); - double dyg = ecl_grid_get_cell_dy1(grid, g); - double dzg = ecl_grid_get_cell_dz1(grid, g); - - double dxi = ecl_kw_iget_float(dx, a); - double dyi = ecl_kw_iget_float(dy, a); - double dzi = ecl_kw_iget_float(dz, a); + rd_grid_type *grid = rd_grid_alloc(grid_fname.c_str()); + rd_file_type *init_file = rd_file_open(init_fname.c_str(), 0); + rd_kw_type *dx = rd_file_iget_named_kw(init_file, "DX", 0); + rd_kw_type *dy = rd_file_iget_named_kw(init_file, "DY", 0); + rd_kw_type *dz = rd_file_iget_named_kw(init_file, "DZ", 0); + for (int a = 0; a < rd_grid_get_active_size(grid); a += 100) { + int g = rd_grid_get_global_index1A(grid, a); + + double dxg = rd_grid_get_cell_dx1(grid, g); + double dyg = rd_grid_get_cell_dy1(grid, g); + double dzg = rd_grid_get_cell_dz1(grid, g); + + double dxi = rd_kw_iget_float(dx, a); + double dyi = rd_kw_iget_float(dy, a); + double dzi = rd_kw_iget_float(dz, a); double err_x = fabs(err(dxg, dxi)); double err_y = fabs(err(dyg, dyi)); @@ -41,14 +41,14 @@ void test_dxdydz(const std::string &grid_fname, const std::string &init_fname) { test_assert_true(err_y < eps_y); test_assert_true(err_z < eps_z); } - ecl_file_close(init_file); - ecl_grid_free(grid); + rd_file_close(init_file); + rd_grid_free(grid); } int main(int argc, char **argv) { - const std::string ecl_case = argv[1]; - std::string grid_file = ecl_case + ".EGRID"; - std::string init_file = ecl_case + ".INIT"; + const std::string rd_case = argv[1]; + std::string grid_file = rd_case + ".EGRID"; + std::string init_file = rd_case + ".INIT"; test_dxdydz(grid_file, init_file); diff --git a/lib/resdata/tests/rd_grid_export.cpp b/lib/resdata/tests/rd_grid_export.cpp index 2f3b1a5a51..2a9418cb67 100644 --- a/lib/resdata/tests/rd_grid_export.cpp +++ b/lib/resdata/tests/rd_grid_export.cpp @@ -4,36 +4,36 @@ #include #include -#include -#include -#include +#include +#include +#include -void export_actnum(const ecl_grid_type *ecl_grid, ecl_file_type *ecl_file) { - ecl_kw_type *actnum_kw = ecl_file_iget_named_kw(ecl_file, "ACTNUM", 0); +void export_actnum(const rd_grid_type *rd_grid, rd_file_type *rd_file) { + rd_kw_type *actnum_kw = rd_file_iget_named_kw(rd_file, "ACTNUM", 0); int *actnum = - (int *)util_malloc(ecl_kw_get_size(actnum_kw) * sizeof *actnum); + (int *)util_malloc(rd_kw_get_size(actnum_kw) * sizeof *actnum); - ecl_grid_init_actnum_data(ecl_grid, actnum); - for (int i = 0; i < ecl_kw_get_size(actnum_kw); i++) - test_assert_int_equal(actnum[i], ecl_kw_iget_int(actnum_kw, i)); + rd_grid_init_actnum_data(rd_grid, actnum); + for (int i = 0; i < rd_kw_get_size(actnum_kw); i++) + test_assert_int_equal(actnum[i], rd_kw_iget_int(actnum_kw, i)); free(actnum); } -void export_coord(const ecl_grid_type *grid, ecl_file_type *ecl_file) { - ecl_kw_type *coord_kw = ecl_file_iget_named_kw(ecl_file, "COORD", 0); - test_assert_int_equal(ecl_kw_get_size(coord_kw), - ecl_grid_get_coord_size(grid)); +void export_coord(const rd_grid_type *grid, rd_file_type *rd_file) { + rd_kw_type *coord_kw = rd_file_iget_named_kw(rd_file, "COORD", 0); + test_assert_int_equal(rd_kw_get_size(coord_kw), + rd_grid_get_coord_size(grid)); { - float *coord_float = (float *)util_malloc( - ecl_grid_get_coord_size(grid) * sizeof *coord_float); + float *coord_float = (float *)util_malloc(rd_grid_get_coord_size(grid) * + sizeof *coord_float); double *coord_double = (double *)util_malloc( - ecl_grid_get_coord_size(grid) * sizeof *coord_double); + rd_grid_get_coord_size(grid) * sizeof *coord_double); - ecl_grid_init_coord_data(grid, coord_float); - ecl_grid_init_coord_data_double(grid, coord_double); + rd_grid_init_coord_data(grid, coord_float); + rd_grid_init_coord_data_double(grid, coord_double); - for (int i = 0; i < ecl_grid_get_coord_size(grid); i++) + for (int i = 0; i < rd_grid_get_coord_size(grid); i++) test_assert_double_equal(coord_double[i], coord_float[i]); free(coord_float); @@ -41,23 +41,23 @@ void export_coord(const ecl_grid_type *grid, ecl_file_type *ecl_file) { } } -void export_zcorn(const ecl_grid_type *grid, ecl_file_type *ecl_file) { - ecl_kw_type *zcorn_kw = ecl_file_iget_named_kw(ecl_file, "ZCORN", 0); - test_assert_int_equal(ecl_kw_get_size(zcorn_kw), - ecl_grid_get_zcorn_size(grid)); +void export_zcorn(const rd_grid_type *grid, rd_file_type *rd_file) { + rd_kw_type *zcorn_kw = rd_file_iget_named_kw(rd_file, "ZCORN", 0); + test_assert_int_equal(rd_kw_get_size(zcorn_kw), + rd_grid_get_zcorn_size(grid)); { - float *zcorn_float = (float *)util_malloc( - ecl_grid_get_zcorn_size(grid) * sizeof *zcorn_float); + float *zcorn_float = (float *)util_malloc(rd_grid_get_zcorn_size(grid) * + sizeof *zcorn_float); double *zcorn_double = (double *)util_malloc( - ecl_grid_get_zcorn_size(grid) * sizeof *zcorn_double); + rd_grid_get_zcorn_size(grid) * sizeof *zcorn_double); - ecl_grid_init_zcorn_data(grid, zcorn_float); - ecl_grid_init_zcorn_data_double(grid, zcorn_double); + rd_grid_init_zcorn_data(grid, zcorn_float); + rd_grid_init_zcorn_data_double(grid, zcorn_double); - for (int i = 0; i < ecl_grid_get_zcorn_size(grid); i++) { + for (int i = 0; i < rd_grid_get_zcorn_size(grid); i++) { test_assert_double_equal(zcorn_double[i], zcorn_float[i]); test_assert_float_equal(zcorn_float[i], - ecl_kw_iget_float(zcorn_kw, i)); + rd_kw_iget_float(zcorn_kw, i)); } free(zcorn_float); @@ -65,18 +65,18 @@ void export_zcorn(const ecl_grid_type *grid, ecl_file_type *ecl_file) { } } -void copy_processed(const ecl_grid_type *src) { +void copy_processed(const rd_grid_type *src) { { - ecl_grid_type *copy = ecl_grid_alloc_processed_copy(src, NULL, NULL); - test_assert_true(ecl_grid_compare(src, copy, true, true, false)); - ecl_grid_free(copy); + rd_grid_type *copy = rd_grid_alloc_processed_copy(src, NULL, NULL); + test_assert_true(rd_grid_compare(src, copy, true, true, false)); + rd_grid_free(copy); } { int *actnum = - (int *)util_malloc(ecl_grid_get_global_size(src) * sizeof *actnum); + (int *)util_malloc(rd_grid_get_global_size(src) * sizeof *actnum); int index = 0; - ecl_grid_init_actnum_data(src, actnum); + rd_grid_init_actnum_data(src, actnum); while (true) { if (actnum[index] == 1) { @@ -87,93 +87,90 @@ void copy_processed(const ecl_grid_type *src) { } { - ecl_grid_type *copy = - ecl_grid_alloc_processed_copy(src, NULL, actnum); - test_assert_int_equal(1, ecl_grid_get_active_size(src) - - ecl_grid_get_active_size(copy)); - ecl_grid_free(copy); + rd_grid_type *copy = + rd_grid_alloc_processed_copy(src, NULL, actnum); + test_assert_int_equal(1, rd_grid_get_active_size(src) - + rd_grid_get_active_size(copy)); + rd_grid_free(copy); } free(actnum); } { double *zcorn_double = (double *)util_malloc( - ecl_grid_get_zcorn_size(src) * sizeof *zcorn_double); + rd_grid_get_zcorn_size(src) * sizeof *zcorn_double); int i = 0; int j = 0; int k = 0; - ecl_grid_init_zcorn_data_double(src, zcorn_double); + rd_grid_init_zcorn_data_double(src, zcorn_double); { - ecl_grid_type *copy = - ecl_grid_alloc_processed_copy(src, zcorn_double, NULL); - test_assert_double_equal(ecl_grid_get_cell_volume3(src, i, j, k), - ecl_grid_get_cell_volume3(copy, i, j, k)); - ecl_grid_free(copy); + rd_grid_type *copy = + rd_grid_alloc_processed_copy(src, zcorn_double, NULL); + test_assert_double_equal(rd_grid_get_cell_volume3(src, i, j, k), + rd_grid_get_cell_volume3(copy, i, j, k)); + rd_grid_free(copy); } for (int c = 0; c < 4; c++) { - double dz = - zcorn_double[ecl_grid_zcorn_index(src, i, j, k, c + 4)] - - zcorn_double[ecl_grid_zcorn_index(src, i, j, k, c)]; - zcorn_double[ecl_grid_zcorn_index(src, i, j, k, c + 4)] += dz; + double dz = zcorn_double[rd_grid_zcorn_index(src, i, j, k, c + 4)] - + zcorn_double[rd_grid_zcorn_index(src, i, j, k, c)]; + zcorn_double[rd_grid_zcorn_index(src, i, j, k, c + 4)] += dz; } { - ecl_grid_type *copy = - ecl_grid_alloc_processed_copy(src, zcorn_double, NULL); - test_assert_double_equal(ecl_grid_get_cell_volume3(src, i, j, k) * - 2, - ecl_grid_get_cell_volume3(copy, i, j, k)); - ecl_grid_free(copy); + rd_grid_type *copy = + rd_grid_alloc_processed_copy(src, zcorn_double, NULL); + test_assert_double_equal(rd_grid_get_cell_volume3(src, i, j, k) * 2, + rd_grid_get_cell_volume3(copy, i, j, k)); + rd_grid_free(copy); } free(zcorn_double); } } -void export_mapaxes(const ecl_grid_type *grid, ecl_file_type *ecl_file) { - if (ecl_file_has_kw(ecl_file, "MAPAXES")) { - ecl_kw_type *mapaxes_kw = - ecl_file_iget_named_kw(ecl_file, "MAPAXES", 0); +void export_mapaxes(const rd_grid_type *grid, rd_file_type *rd_file) { + if (rd_file_has_kw(rd_file, "MAPAXES")) { + rd_kw_type *mapaxes_kw = rd_file_iget_named_kw(rd_file, "MAPAXES", 0); double mapaxes[6]; int i; - test_assert_true(ecl_grid_use_mapaxes(grid)); - ecl_grid_init_mapaxes_data_double(grid, mapaxes); + test_assert_true(rd_grid_use_mapaxes(grid)); + rd_grid_init_mapaxes_data_double(grid, mapaxes); for (i = 0; i < 6; i++) - test_assert_double_equal(ecl_kw_iget_float(mapaxes_kw, i), + test_assert_double_equal(rd_kw_iget_float(mapaxes_kw, i), mapaxes[i]); } } int main(int argc, char **argv) { - ecl::util::TestArea ta("grid_export"); + rd::util::TestArea ta("grid_export"); { const char *test_grid = "TEST.EGRID"; const char *grid_file; if (argc == 1) { - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(4, 4, 2, 1, 1, 1, NULL); + rd_grid_type *grid = + rd_grid_alloc_rectangular(4, 4, 2, 1, 1, 1, NULL); grid_file = test_grid; - ecl_grid_fwrite_EGRID(grid, grid_file, true); - ecl_grid_free(grid); + rd_grid_fwrite_EGRID(grid, grid_file, true); + rd_grid_free(grid); } else grid_file = argv[1]; { - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_file); + rd_grid_type *rd_grid = rd_grid_alloc(grid_file); if (argc == 1) - test_assert_true(ecl_grid_get_unit_system(ecl_grid) == - ECL_METRIC_UNITS); - ecl_file_type *ecl_file = ecl_file_open(grid_file, 0); - - export_actnum(ecl_grid, ecl_file); - export_coord(ecl_grid, ecl_file); - export_zcorn(ecl_grid, ecl_file); - export_mapaxes(ecl_grid, ecl_file); - copy_processed(ecl_grid); - ecl_file_close(ecl_file); - ecl_grid_free(ecl_grid); + test_assert_true(rd_grid_get_unit_system(rd_grid) == + RD_METRIC_UNITS); + rd_file_type *rd_file = rd_file_open(grid_file, 0); + + export_actnum(rd_grid, rd_file); + export_coord(rd_grid, rd_file); + export_zcorn(rd_grid, rd_file); + export_mapaxes(rd_grid, rd_file); + copy_processed(rd_grid); + rd_file_close(rd_file); + rd_grid_free(rd_grid); } } } diff --git a/lib/resdata/tests/rd_grid_ext_actnum.cpp b/lib/resdata/tests/rd_grid_ext_actnum.cpp index 1cddf94c67..15613367e2 100644 --- a/lib/resdata/tests/rd_grid_ext_actnum.cpp +++ b/lib/resdata/tests/rd_grid_ext_actnum.cpp @@ -3,31 +3,31 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void test_1() { - ecl::util::TestArea ta("test1"); + rd::util::TestArea ta("test1"); { const char *filename = "FILE.EGRID"; - ecl_grid_type *grid_write = - ecl_grid_alloc_rectangular(2, 3, 1, 1, 1, 1, NULL); - ecl_grid_fwrite_EGRID(grid_write, filename, true); - ecl_grid_free(grid_write); + rd_grid_type *grid_write = + rd_grid_alloc_rectangular(2, 3, 1, 1, 1, 1, NULL); + rd_grid_fwrite_EGRID(grid_write, filename, true); + rd_grid_free(grid_write); - ecl_file_type *ecl_file = ecl_file_open(filename, 0); - ecl_kw_type *filehead_kw = - ecl_file_iget_named_kw(ecl_file, FILEHEAD_KW, 0); - int *filehead_data = ecl_kw_get_int_ptr(filehead_kw); + rd_file_type *rd_file = rd_file_open(filename, 0); + rd_kw_type *filehead_kw = + rd_file_iget_named_kw(rd_file, FILEHEAD_KW, 0); + int *filehead_data = rd_kw_get_int_ptr(filehead_kw); filehead_data[FILEHEAD_DUALP_INDEX] = FILEHEAD_DUAL_POROSITY; - ecl_kw_type *actnum_kw = ecl_file_iget_named_kw(ecl_file, ACTNUM_KW, 0); - int *actnum_data = ecl_kw_get_int_ptr(actnum_kw); + rd_kw_type *actnum_kw = rd_file_iget_named_kw(rd_file, ACTNUM_KW, 0); + int *actnum_data = rd_kw_get_int_ptr(actnum_kw); actnum_data[0] = 1; actnum_data[1] = 2; actnum_data[2] = 2; @@ -35,24 +35,24 @@ void test_1() { actnum_data[4] = 1; actnum_data[5] = 1; const char *filename1 = "FILE1.EGRID"; - fortio_type *f = fortio_open_writer(filename1, false, ECL_ENDIAN_FLIP); - ecl_file_fwrite_fortio(ecl_file, f, 0); + fortio_type *f = fortio_open_writer(filename1, false, RD_ENDIAN_FLIP); + rd_file_fwrite_fortio(rd_file, f, 0); fortio_fclose(f); - ecl_file_close(ecl_file); + rd_file_close(rd_file); std::vector ext_actnum = {0, 1, 0, 1, 1, 1}; - ecl_grid_type *grid = - ecl_grid_alloc_ext_actnum(filename1, ext_actnum.data()); - test_assert_int_equal(4, ecl_grid_get_nactive(grid)); - test_assert_int_equal(0, ecl_grid_get_nactive_fracture(grid)); - test_assert_true(!ecl_grid_cell_active1(grid, 0)); - - test_assert_true(!ecl_grid_cell_active1(grid, 2)); - test_assert_true(ecl_grid_cell_active1(grid, 3)); - test_assert_true(ecl_grid_cell_active1(grid, 4)); - test_assert_true(ecl_grid_cell_active1(grid, 5)); - - ecl_grid_free(grid); + rd_grid_type *grid = + rd_grid_alloc_ext_actnum(filename1, ext_actnum.data()); + test_assert_int_equal(4, rd_grid_get_nactive(grid)); + test_assert_int_equal(0, rd_grid_get_nactive_fracture(grid)); + test_assert_true(!rd_grid_cell_active1(grid, 0)); + + test_assert_true(!rd_grid_cell_active1(grid, 2)); + test_assert_true(rd_grid_cell_active1(grid, 3)); + test_assert_true(rd_grid_cell_active1(grid, 4)); + test_assert_true(rd_grid_cell_active1(grid, 5)); + + rd_grid_free(grid); } } diff --git a/lib/resdata/tests/rd_grid_init_fwrite.cpp b/lib/resdata/tests/rd_grid_init_fwrite.cpp index 06a828f29d..085fb320f2 100644 --- a/lib/resdata/tests/rd_grid_init_fwrite.cpp +++ b/lib/resdata/tests/rd_grid_init_fwrite.cpp @@ -5,82 +5,81 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -void test_write_depth(const ecl_grid_type *grid) { - ecl::util::TestArea ta("write_depth"); +void test_write_depth(const rd_grid_type *grid) { + rd::util::TestArea ta("write_depth"); { fortio_type *init_file = - fortio_open_writer("INIT", false, ECL_ENDIAN_FLIP); - ecl_grid_fwrite_depth(grid, init_file, ECL_METRIC_UNITS); + fortio_open_writer("INIT", false, RD_ENDIAN_FLIP); + rd_grid_fwrite_depth(grid, init_file, RD_METRIC_UNITS); fortio_fclose(init_file); } { - ecl_file_type *init_file = ecl_file_open("INIT", 0); - ecl_kw_type *depth = ecl_file_iget_named_kw(init_file, "DEPTH", 0); + rd_file_type *init_file = rd_file_open("INIT", 0); + rd_kw_type *depth = rd_file_iget_named_kw(init_file, "DEPTH", 0); - test_assert_int_equal(ecl_kw_get_size(depth), - ecl_grid_get_nactive(grid)); - for (int i = 0; i < ecl_grid_get_nactive(grid); i++) - test_assert_double_equal(ecl_kw_iget_as_double(depth, i), - ecl_grid_get_cdepth1A(grid, i)); + test_assert_int_equal(rd_kw_get_size(depth), rd_grid_get_nactive(grid)); + for (int i = 0; i < rd_grid_get_nactive(grid); i++) + test_assert_double_equal(rd_kw_iget_as_double(depth, i), + rd_grid_get_cdepth1A(grid, i)); - ecl_file_close(init_file); + rd_file_close(init_file); } } -void test_write_dims(const ecl_grid_type *grid) { - ecl::util::TestArea ta("write_dims"); +void test_write_dims(const rd_grid_type *grid) { + rd::util::TestArea ta("write_dims"); { fortio_type *init_file = - fortio_open_writer("INIT", false, ECL_ENDIAN_FLIP); - ecl_grid_fwrite_dims(grid, init_file, ECL_METRIC_UNITS); + fortio_open_writer("INIT", false, RD_ENDIAN_FLIP); + rd_grid_fwrite_dims(grid, init_file, RD_METRIC_UNITS); fortio_fclose(init_file); } { - ecl_file_type *init_file = ecl_file_open("INIT", 0); - ecl_kw_type *DX = ecl_file_iget_named_kw(init_file, "DX", 0); - ecl_kw_type *DY = ecl_file_iget_named_kw(init_file, "DY", 0); - ecl_kw_type *DZ = ecl_file_iget_named_kw(init_file, "DZ", 0); + rd_file_type *init_file = rd_file_open("INIT", 0); + rd_kw_type *DX = rd_file_iget_named_kw(init_file, "DX", 0); + rd_kw_type *DY = rd_file_iget_named_kw(init_file, "DY", 0); + rd_kw_type *DZ = rd_file_iget_named_kw(init_file, "DZ", 0); - test_assert_int_equal(ecl_kw_get_size(DX), ecl_grid_get_nactive(grid)); - test_assert_int_equal(ecl_kw_get_size(DY), ecl_grid_get_nactive(grid)); - test_assert_int_equal(ecl_kw_get_size(DZ), ecl_grid_get_nactive(grid)); - for (int i = 0; i < ecl_grid_get_nactive(grid); i++) { - test_assert_double_equal(ecl_kw_iget_as_double(DX, i), - ecl_grid_get_cell_dx1A(grid, i)); - test_assert_double_equal(ecl_kw_iget_as_double(DY, i), - ecl_grid_get_cell_dy1A(grid, i)); - test_assert_double_equal(ecl_kw_iget_as_double(DZ, i), - ecl_grid_get_cell_dz1A(grid, i)); + test_assert_int_equal(rd_kw_get_size(DX), rd_grid_get_nactive(grid)); + test_assert_int_equal(rd_kw_get_size(DY), rd_grid_get_nactive(grid)); + test_assert_int_equal(rd_kw_get_size(DZ), rd_grid_get_nactive(grid)); + for (int i = 0; i < rd_grid_get_nactive(grid); i++) { + test_assert_double_equal(rd_kw_iget_as_double(DX, i), + rd_grid_get_cell_dx1A(grid, i)); + test_assert_double_equal(rd_kw_iget_as_double(DY, i), + rd_grid_get_cell_dy1A(grid, i)); + test_assert_double_equal(rd_kw_iget_as_double(DZ, i), + rd_grid_get_cell_dz1A(grid, i)); } - ecl_file_close(init_file); + rd_file_close(init_file); } } -ecl_grid_type *create_grid() { +rd_grid_type *create_grid() { int nx = 10; int ny = 10; int nz = 8; int_vector_type *actnum = int_vector_alloc(nx * ny * nz, 1); - ecl_grid_type *ecl_grid = ecl_grid_alloc_rectangular( + rd_grid_type *rd_grid = rd_grid_alloc_rectangular( nx, ny, nz, 1, 1, 1, int_vector_get_ptr(actnum)); int_vector_free(actnum); - return ecl_grid; + return rd_grid; } int main(int argc, char **argv) { util_install_signals(); { - ecl_grid_type *grid = create_grid(); + rd_grid_type *grid = create_grid(); test_write_depth(grid); test_write_dims(grid); - ecl_grid_free(grid); + rd_grid_free(grid); } } diff --git a/lib/resdata/tests/rd_grid_layer_contains.cpp b/lib/resdata/tests/rd_grid_layer_contains.cpp index 8a8d7df7f4..bbf6237358 100644 --- a/lib/resdata/tests/rd_grid_layer_contains.cpp +++ b/lib/resdata/tests/rd_grid_layer_contains.cpp @@ -3,21 +3,21 @@ #include -#include +#include -void test_layer(const ecl_grid_type *grid) { +void test_layer(const rd_grid_type *grid) { int g; - for (g = 0; g < ecl_grid_get_global_size(grid); g += 25) { + for (g = 0; g < rd_grid_get_global_size(grid); g += 25) { double x, y, z; int i, j, k; - ecl_grid_get_xyz1(grid, g, &x, &y, &z); - ecl_grid_get_ijk1(grid, g, &i, &j, &k); + rd_grid_get_xyz1(grid, g, &x, &y, &z); + rd_grid_get_ijk1(grid, g, &i, &j, &k); { int find_i, find_j; test_assert_true( - ecl_grid_get_ij_from_xy(grid, x, y, k, &find_i, &find_j)); + rd_grid_get_ij_from_xy(grid, x, y, k, &find_i, &find_j)); test_assert_int_equal(i, find_i); test_assert_int_equal(j, find_j); } @@ -25,7 +25,7 @@ void test_layer(const ecl_grid_type *grid) { } int main(int argc, char **argv) { - ecl_grid_type *grid = ecl_grid_alloc(argv[1]); + rd_grid_type *grid = rd_grid_alloc(argv[1]); test_layer(grid); - ecl_grid_free(grid); + rd_grid_free(grid); } diff --git a/lib/resdata/tests/rd_grid_lgr_name.cpp b/lib/resdata/tests/rd_grid_lgr_name.cpp index b7300a3cec..cf95892a10 100644 --- a/lib/resdata/tests/rd_grid_lgr_name.cpp +++ b/lib/resdata/tests/rd_grid_lgr_name.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include /* Name ..................: LG003017 @@ -26,14 +26,14 @@ Grid nr ...............: 110 */ -void test_name(const ecl_grid_type *grid, int lgr_nr, const char *name) { - test_assert_string_equal(name, ecl_grid_get_lgr_name(grid, lgr_nr)); - test_assert_int_equal(lgr_nr, ecl_grid_get_lgr_nr_from_name(grid, name)); +void test_name(const rd_grid_type *grid, int lgr_nr, const char *name) { + test_assert_string_equal(name, rd_grid_get_lgr_name(grid, lgr_nr)); + test_assert_int_equal(lgr_nr, rd_grid_get_lgr_nr_from_name(grid, name)); } int main(int argc, char **argv) { const char *grid_file = argv[1]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); + rd_grid_type *grid = rd_grid_alloc(grid_file); test_name(grid, 104, "LG003017"); test_name(grid, 2, "LG006024"); @@ -43,6 +43,6 @@ int main(int argc, char **argv) { test_name(grid, 110, "LG003014"); test_name(grid, 0, grid_file); - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_grid_reset_actnum.cpp b/lib/resdata/tests/rd_grid_reset_actnum.cpp index 7477fdde70..842b5a339c 100644 --- a/lib/resdata/tests/rd_grid_reset_actnum.cpp +++ b/lib/resdata/tests/rd_grid_reset_actnum.cpp @@ -3,7 +3,7 @@ #include -#include +#include int main(int argc, char **argv) { const int nx = 5; @@ -17,29 +17,29 @@ int main(int argc, char **argv) { const int actnum2[] = {0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0}; - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, actnum1); + rd_grid_type *grid = + rd_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, actnum1); - test_assert_int_equal(g, ecl_grid_get_nactive(grid)); - ecl_grid_reset_actnum(grid, actnum2); - test_assert_int_equal(nactive, ecl_grid_get_nactive(grid)); + test_assert_int_equal(g, rd_grid_get_nactive(grid)); + rd_grid_reset_actnum(grid, actnum2); + test_assert_int_equal(nactive, rd_grid_get_nactive(grid)); - test_assert_int_equal(-1, ecl_grid_get_active_index1(grid, 0)); - test_assert_int_equal(0, ecl_grid_get_active_index1(grid, 1)); - test_assert_int_equal(-1, ecl_grid_get_active_index1(grid, 2)); - test_assert_int_equal(1, ecl_grid_get_global_index1A(grid, 0)); - test_assert_int_equal(3, ecl_grid_get_global_index1A(grid, 1)); - test_assert_int_equal(5, ecl_grid_get_global_index1A(grid, 2)); + test_assert_int_equal(-1, rd_grid_get_active_index1(grid, 0)); + test_assert_int_equal(0, rd_grid_get_active_index1(grid, 1)); + test_assert_int_equal(-1, rd_grid_get_active_index1(grid, 2)); + test_assert_int_equal(1, rd_grid_get_global_index1A(grid, 0)); + test_assert_int_equal(3, rd_grid_get_global_index1A(grid, 1)); + test_assert_int_equal(5, rd_grid_get_global_index1A(grid, 2)); - ecl_grid_reset_actnum(grid, NULL); - test_assert_int_equal(g, ecl_grid_get_nactive(grid)); - test_assert_int_equal(0, ecl_grid_get_active_index1(grid, 0)); - test_assert_int_equal(1, ecl_grid_get_active_index1(grid, 1)); - test_assert_int_equal(2, ecl_grid_get_active_index1(grid, 2)); - test_assert_int_equal(0, ecl_grid_get_global_index1A(grid, 0)); - test_assert_int_equal(1, ecl_grid_get_global_index1A(grid, 1)); - test_assert_int_equal(2, ecl_grid_get_global_index1A(grid, 2)); + rd_grid_reset_actnum(grid, NULL); + test_assert_int_equal(g, rd_grid_get_nactive(grid)); + test_assert_int_equal(0, rd_grid_get_active_index1(grid, 0)); + test_assert_int_equal(1, rd_grid_get_active_index1(grid, 1)); + test_assert_int_equal(2, rd_grid_get_active_index1(grid, 2)); + test_assert_int_equal(0, rd_grid_get_global_index1A(grid, 0)); + test_assert_int_equal(1, rd_grid_get_global_index1A(grid, 1)); + test_assert_int_equal(2, rd_grid_get_global_index1A(grid, 2)); - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_grid_unit_system.cpp b/lib/resdata/tests/rd_grid_unit_system.cpp index 412a137ff2..f12bbc02d5 100644 --- a/lib/resdata/tests/rd_grid_unit_system.cpp +++ b/lib/resdata/tests/rd_grid_unit_system.cpp @@ -4,35 +4,35 @@ #include #include -#include -#include -#include - -void test_EGRID(const char *filename, ert_ecl_unit_enum unit_system) { - ecl_grid_type *grid = ecl_grid_alloc_rectangular(4, 4, 2, 1, 1, 1, NULL); - ecl_grid_fwrite_EGRID2(grid, filename, unit_system); - ecl_grid_free(grid); - - ecl_grid_type *grid2 = ecl_grid_alloc(filename); - test_assert_int_equal(ecl_grid_get_unit_system(grid2), unit_system); - ecl_grid_free(grid2); +#include +#include +#include + +void test_EGRID(const char *filename, ert_rd_unit_enum unit_system) { + rd_grid_type *grid = rd_grid_alloc_rectangular(4, 4, 2, 1, 1, 1, NULL); + rd_grid_fwrite_EGRID2(grid, filename, unit_system); + rd_grid_free(grid); + + rd_grid_type *grid2 = rd_grid_alloc(filename); + test_assert_int_equal(rd_grid_get_unit_system(grid2), unit_system); + rd_grid_free(grid2); } -void test_GRID(const char *filename, ert_ecl_unit_enum unit_system) { - ecl_grid_type *grid = ecl_grid_alloc_rectangular(4, 4, 2, 1, 1, 1, NULL); - ecl_grid_fwrite_GRID2(grid, filename, unit_system); - ecl_grid_free(grid); +void test_GRID(const char *filename, ert_rd_unit_enum unit_system) { + rd_grid_type *grid = rd_grid_alloc_rectangular(4, 4, 2, 1, 1, 1, NULL); + rd_grid_fwrite_GRID2(grid, filename, unit_system); + rd_grid_free(grid); - ecl_grid_type *grid2 = ecl_grid_alloc(filename); - test_assert_int_equal(ecl_grid_get_unit_system(grid2), unit_system); - ecl_grid_free(grid2); + rd_grid_type *grid2 = rd_grid_alloc(filename); + test_assert_int_equal(rd_grid_get_unit_system(grid2), unit_system); + rd_grid_free(grid2); } int main(int argc, char **argv) { - ecl::util::TestArea ta("grid_unit_system"); + rd::util::TestArea ta("grid_unit_system"); - test_EGRID("METRIC.EGRID", ECL_METRIC_UNITS); - test_EGRID("FIELD.EGRID", ECL_FIELD_UNITS); - test_GRID("METRIC.GRID", ECL_METRIC_UNITS); - test_GRID("FIELD.GRID", ECL_FIELD_UNITS); + test_EGRID("METRIC.EGRID", RD_METRIC_UNITS); + test_EGRID("FIELD.EGRID", RD_FIELD_UNITS); + test_GRID("METRIC.GRID", RD_METRIC_UNITS); + test_GRID("FIELD.GRID", RD_FIELD_UNITS); } diff --git a/lib/resdata/tests/rd_grid_volume.cpp b/lib/resdata/tests/rd_grid_volume.cpp index 639600b214..646c1667e3 100644 --- a/lib/resdata/tests/rd_grid_volume.cpp +++ b/lib/resdata/tests/rd_grid_volume.cpp @@ -6,23 +6,23 @@ #include #include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { const char *path_case = argv[1]; char *grid_file = - ecl_util_alloc_filename(NULL, path_case, ECL_EGRID_FILE, false, 0); + rd_alloc_filename(NULL, path_case, RD_EGRID_FILE, false, 0); char *init_file = - ecl_util_alloc_filename(NULL, path_case, ECL_INIT_FILE, false, 0); + rd_alloc_filename(NULL, path_case, RD_INIT_FILE, false, 0); - ecl_file_type *init = ecl_file_open(init_file, 0); - ecl_grid_type *grid = ecl_grid_alloc(grid_file); - const ecl_kw_type *poro_kw = ecl_file_iget_named_kw(init, "PORO", 0); - const ecl_kw_type *porv_kw = ecl_file_iget_named_kw(init, "PORV", 0); - ecl_kw_type *multpv = NULL; - ecl_kw_type *NTG = NULL; + rd_file_type *init = rd_file_open(init_file, 0); + rd_grid_type *grid = rd_grid_alloc(grid_file); + const rd_kw_type *poro_kw = rd_file_iget_named_kw(init, "PORO", 0); + const rd_kw_type *porv_kw = rd_file_iget_named_kw(init, "PORV", 0); + rd_kw_type *multpv = NULL; + rd_kw_type *NTG = NULL; bool error_found = false; double total_volume = 0; @@ -30,23 +30,23 @@ int main(int argc, char **argv) { int error_count = 0; int iactive; - if (ecl_file_has_kw(init, "NTG")) - NTG = ecl_file_iget_named_kw(init, "NTG", 0); + if (rd_file_has_kw(init, "NTG")) + NTG = rd_file_iget_named_kw(init, "NTG", 0); - if (ecl_file_has_kw(init, "MULTPV")) - multpv = ecl_file_iget_named_kw(init, "MULTPV", 0); + if (rd_file_has_kw(init, "MULTPV")) + multpv = rd_file_iget_named_kw(init, "MULTPV", 0); - for (iactive = 0; iactive < ecl_grid_get_nactive(grid); ++iactive) { - int iglobal = ecl_grid_get_global_index1A(grid, iactive); - double grid_volume = ecl_grid_get_cell_volume1(grid, iglobal); - double eclipse_volume = ecl_kw_iget_float(porv_kw, iglobal) / - ecl_kw_iget_float(poro_kw, iactive); + for (iactive = 0; iactive < rd_grid_get_nactive(grid); ++iactive) { + int iglobal = rd_grid_get_global_index1A(grid, iactive); + double grid_volume = rd_grid_get_cell_volume1(grid, iglobal); + double eclipse_volume = rd_kw_iget_float(porv_kw, iglobal) / + rd_kw_iget_float(poro_kw, iactive); if (NTG) - eclipse_volume /= ecl_kw_iget_float(NTG, iactive); + eclipse_volume /= rd_kw_iget_float(NTG, iactive); if (multpv) - eclipse_volume *= ecl_kw_iget_float(multpv, iactive); + eclipse_volume *= rd_kw_iget_float(multpv, iactive); total_volume += grid_volume; total_diff += fabs(eclipse_volume - grid_volume); @@ -62,13 +62,13 @@ int main(int argc, char **argv) { printf("Total volume difference: %g %% \n", 100 * total_diff / total_volume); - ecl_grid_free(grid); - ecl_file_close(init); + rd_grid_free(grid); + rd_file_close(init); free(grid_file); free(init_file); if (error_found) { printf("Error_count: %d / %d \n", error_count, - ecl_grid_get_nactive(grid)); + rd_grid_get_nactive(grid)); exit(1); } else exit(0); diff --git a/lib/resdata/tests/rd_init_file.cpp b/lib/resdata/tests/rd_init_file.cpp index f6ec317dc9..0e04feb3fe 100644 --- a/lib/resdata/tests/rd_init_file.cpp +++ b/lib/resdata/tests/rd_init_file.cpp @@ -5,75 +5,71 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include void test_write_header() { int nx = 10; int ny = 10; int nz = 5; - ecl::util::TestArea ta("WRITE_header"); + rd::util::TestArea ta("WRITE_header"); int_vector_type *actnum = int_vector_alloc(nx * ny * nz, 1); time_t start_time = util_make_date_utc(15, 12, 2010); - ecl_grid_type *ecl_grid; + rd_grid_type *rd_grid; int_vector_iset(actnum, 10, 0); int_vector_iset(actnum, 100, 0); - ecl_grid = ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, - int_vector_get_ptr(actnum)); + rd_grid = rd_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, + int_vector_get_ptr(actnum)); // Write poro with global size. { - fortio_type *f = - fortio_open_writer("FOO1.INIT", false, ECL_ENDIAN_FLIP); - ecl_kw_type *poro = - ecl_kw_alloc("PORO", ecl_grid_get_global_size(ecl_grid), ECL_FLOAT); - ecl_kw_scalar_set_float(poro, 0.10); - ecl_init_file_fwrite_header(f, ecl_grid, poro, ECL_FIELD_UNITS, 7, - start_time); - ecl_kw_free(poro); + fortio_type *f = fortio_open_writer("FOO1.INIT", false, RD_ENDIAN_FLIP); + rd_kw_type *poro = + rd_kw_alloc("PORO", rd_grid_get_global_size(rd_grid), RD_FLOAT); + rd_kw_scalar_set_float(poro, 0.10); + rd_init_file_fwrite_header(f, rd_grid, poro, RD_FIELD_UNITS, 7, + start_time); + rd_kw_free(poro); fortio_fclose(f); } // Write poro with nactive size. { - fortio_type *f = - fortio_open_writer("FOO2.INIT", false, ECL_ENDIAN_FLIP); - ecl_kw_type *poro = - ecl_kw_alloc("PORO", ecl_grid_get_global_size(ecl_grid), ECL_FLOAT); - ecl_kw_scalar_set_float(poro, 0.10); - ecl_init_file_fwrite_header(f, ecl_grid, poro, ECL_FIELD_UNITS, 7, - start_time); - ecl_kw_free(poro); + fortio_type *f = fortio_open_writer("FOO2.INIT", false, RD_ENDIAN_FLIP); + rd_kw_type *poro = + rd_kw_alloc("PORO", rd_grid_get_global_size(rd_grid), RD_FLOAT); + rd_kw_scalar_set_float(poro, 0.10); + rd_init_file_fwrite_header(f, rd_grid, poro, RD_FIELD_UNITS, 7, + start_time); + rd_kw_free(poro); fortio_fclose(f); } { - ecl_file_type *file1 = ecl_file_open("FOO1.INIT", 0); - ecl_file_type *file2 = ecl_file_open("FOO2.INIT", 0); + rd_file_type *file1 = rd_file_open("FOO1.INIT", 0); + rd_file_type *file2 = rd_file_open("FOO2.INIT", 0); - test_assert_true( - ecl_kw_equal(ecl_file_iget_named_kw(file1, "PORV", 0), - ecl_file_iget_named_kw(file2, "PORV", 0))); + test_assert_true(rd_kw_equal(rd_file_iget_named_kw(file1, "PORV", 0), + rd_file_iget_named_kw(file2, "PORV", 0))); - ecl_file_close(file2); - ecl_file_close(file1); + rd_file_close(file2); + rd_file_close(file1); } // Poro == NULL { - fortio_type *f = - fortio_open_writer("FOO3.INIT", false, ECL_ENDIAN_FLIP); - ecl_init_file_fwrite_header(f, ecl_grid, NULL, ECL_METRIC_UNITS, 7, - start_time); + fortio_type *f = fortio_open_writer("FOO3.INIT", false, RD_ENDIAN_FLIP); + rd_init_file_fwrite_header(f, rd_grid, NULL, RD_METRIC_UNITS, 7, + start_time); fortio_fclose(f); } - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); int_vector_free(actnum); } diff --git a/lib/resdata/tests/rd_kw_cmp_string.cpp b/lib/resdata/tests/rd_kw_cmp_string.cpp index dc37039cbc..bad7e1e093 100644 --- a/lib/resdata/tests/rd_kw_cmp_string.cpp +++ b/lib/resdata/tests/rd_kw_cmp_string.cpp @@ -2,25 +2,24 @@ #include #include -#include -#include +#include +#include void test_cmp_string() { - ecl_kw_type *ecl_kw = ecl_kw_alloc("HEADER", 1, ECL_CHAR); + rd_kw_type *rd_kw = rd_kw_alloc("HEADER", 1, RD_CHAR); - ecl_kw_iset_string8(ecl_kw, 0, "ABCD"); + rd_kw_iset_string8(rd_kw, 0, "ABCD"); - test_assert_int_equal(0, - strcmp(ecl_kw_iget_char_ptr(ecl_kw, 0), "ABCD ")); - test_assert_true(ecl_kw_icmp_string(ecl_kw, 0, "ABCD")); - test_assert_true(ecl_kw_icmp_string(ecl_kw, 0, "ABCD ")); - test_assert_true(ecl_kw_icmp_string(ecl_kw, 0, "ABCD ")); + test_assert_int_equal(0, strcmp(rd_kw_iget_char_ptr(rd_kw, 0), "ABCD ")); + test_assert_true(rd_kw_icmp_string(rd_kw, 0, "ABCD")); + test_assert_true(rd_kw_icmp_string(rd_kw, 0, "ABCD ")); + test_assert_true(rd_kw_icmp_string(rd_kw, 0, "ABCD ")); - test_assert_false(ecl_kw_icmp_string(ecl_kw, 0, "Different")); - test_assert_false(ecl_kw_icmp_string(ecl_kw, 0, "")); - test_assert_false(ecl_kw_icmp_string(ecl_kw, 0, "")); + test_assert_false(rd_kw_icmp_string(rd_kw, 0, "Different")); + test_assert_false(rd_kw_icmp_string(rd_kw, 0, "")); + test_assert_false(rd_kw_icmp_string(rd_kw, 0, "")); - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_kw_equal.cpp b/lib/resdata/tests/rd_kw_equal.cpp index 9cf3bfeb52..e915742ba5 100644 --- a/lib/resdata/tests/rd_kw_equal.cpp +++ b/lib/resdata/tests/rd_kw_equal.cpp @@ -3,48 +3,47 @@ #include #include -#include -#include +#include +#include int main(int argc, char **argv) { - ecl_kw_type *ecl_kw1 = ecl_kw_alloc("KW", 10, ECL_INT); + rd_kw_type *rd_kw1 = rd_kw_alloc("KW", 10, RD_INT); int data[10]; int i; for (i = 0; i < 10; i++) { - ecl_kw_iset_int(ecl_kw1, i, i); + rd_kw_iset_int(rd_kw1, i, i); data[i] = i; } { - ecl_kw_type *ecl_kw2 = ecl_kw_alloc_copy(ecl_kw1); + rd_kw_type *rd_kw2 = rd_kw_alloc_copy(rd_kw1); - test_assert_true(ecl_kw_equal(ecl_kw1, ecl_kw2)); + test_assert_true(rd_kw_equal(rd_kw1, rd_kw2)); - ecl_kw_iset_int(ecl_kw2, 1, 77); - test_assert_false(ecl_kw_equal(ecl_kw1, ecl_kw2)); - ecl_kw_iset_int(ecl_kw2, 1, 1); - test_assert_true(ecl_kw_equal(ecl_kw1, ecl_kw2)); + rd_kw_iset_int(rd_kw2, 1, 77); + test_assert_false(rd_kw_equal(rd_kw1, rd_kw2)); + rd_kw_iset_int(rd_kw2, 1, 1); + test_assert_true(rd_kw_equal(rd_kw1, rd_kw2)); - ecl_kw_set_header_name(ecl_kw2, "TEST"); - test_assert_false(ecl_kw_equal(ecl_kw1, ecl_kw2)); - test_assert_true(ecl_kw_content_equal(ecl_kw1, ecl_kw2)); - ecl_kw_free(ecl_kw2); + rd_kw_set_header_name(rd_kw2, "TEST"); + test_assert_false(rd_kw_equal(rd_kw1, rd_kw2)); + test_assert_true(rd_kw_content_equal(rd_kw1, rd_kw2)); + rd_kw_free(rd_kw2); } { - ecl_kw_type *ecl_ikw = ecl_kw_alloc_new_shared("KW", 10, ECL_INT, data); - ecl_kw_type *ecl_fkw = - ecl_kw_alloc_new_shared("KW", 10, ECL_FLOAT, data); + rd_kw_type *rd_ikw = rd_kw_alloc_new_shared("KW", 10, RD_INT, data); + rd_kw_type *rd_fkw = rd_kw_alloc_new_shared("KW", 10, RD_FLOAT, data); - test_assert_true(ecl_kw_content_equal(ecl_kw1, ecl_ikw)); - test_assert_false(ecl_kw_content_equal(ecl_kw1, ecl_fkw)); + test_assert_true(rd_kw_content_equal(rd_kw1, rd_ikw)); + test_assert_false(rd_kw_content_equal(rd_kw1, rd_fkw)); - ecl_kw_free(ecl_ikw); - ecl_kw_free(ecl_fkw); + rd_kw_free(rd_ikw); + rd_kw_free(rd_fkw); } - test_assert_true(ecl_kw_data_equal(ecl_kw1, data)); + test_assert_true(rd_kw_data_equal(rd_kw1, data)); data[0] = 99; - test_assert_false(ecl_kw_data_equal(ecl_kw1, data)); - ecl_kw_free(ecl_kw1); + test_assert_false(rd_kw_data_equal(rd_kw1, data)); + rd_kw_free(rd_kw1); } diff --git a/lib/resdata/tests/rd_kw_fread.cpp b/lib/resdata/tests/rd_kw_fread.cpp index 276f708387..d59429bdbd 100644 --- a/lib/resdata/tests/rd_kw_fread.cpp +++ b/lib/resdata/tests/rd_kw_fread.cpp @@ -5,11 +5,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void test_truncated(const char *filename, offset_type truncate_size) { { @@ -19,30 +19,30 @@ void test_truncated(const char *filename, offset_type truncate_size) { } { fortio_type *fortio = fortio_open_reader(filename, false, true); - ecl_kw_type *kw2 = ecl_kw_fread_alloc(fortio); + rd_kw_type *kw2 = rd_kw_fread_alloc(fortio); test_assert_NULL(kw2); fortio_fclose(fortio); } } void test_fread_alloc() { - ecl::util::TestArea ta("fread_alloc"); + rd::util::TestArea ta("fread_alloc"); { - ecl_kw_type *kw1 = ecl_kw_alloc("INT", 100, ECL_INT); + rd_kw_type *kw1 = rd_kw_alloc("INT", 100, RD_INT); int i; for (i = 0; i < 100; i++) - ecl_kw_iset_int(kw1, i, i); + rd_kw_iset_int(kw1, i, i); { fortio_type *fortio = fortio_open_writer("INT", false, true); - ecl_kw_fwrite(kw1, fortio); + rd_kw_fwrite(kw1, fortio); fortio_fclose(fortio); } { fortio_type *fortio = fortio_open_reader("INT", false, true); - ecl_kw_type *kw2 = ecl_kw_fread_alloc(fortio); - test_assert_true(ecl_kw_is_instance(kw2)); - test_assert_true(ecl_kw_equal(kw1, kw2)); - ecl_kw_free(kw2); + rd_kw_type *kw2 = rd_kw_fread_alloc(fortio); + test_assert_true(rd_kw_is_instance(kw2)); + test_assert_true(rd_kw_equal(kw1, kw2)); + rd_kw_free(kw2); fortio_fclose(fortio); } @@ -53,27 +53,26 @@ void test_fread_alloc() { test_truncated("INT", 5); test_truncated("INT", 0); } - ecl_kw_free(kw1); + rd_kw_free(kw1); } } void test_kw_io_charlength() { - ecl::util::TestArea ta("io_charlength"); + rd::util::TestArea ta("io_charlength"); { const char *KW0 = "QWERTYUI"; const char *KW1 = "ABCDEFGHIJTTTTTTTTTTTTTTTTTTTTTTABCDEFGHIJKLMNOP"; - ecl_kw_type *ecl_kw_out0 = ecl_kw_alloc(KW0, 5, ECL_FLOAT); - ecl_kw_type *ecl_kw_out1 = ecl_kw_alloc(KW1, 5, ECL_FLOAT); - for (int i = 0; i < ecl_kw_get_size(ecl_kw_out1); i++) { - ecl_kw_iset_float(ecl_kw_out0, i, i * 1.5); - ecl_kw_iset_float(ecl_kw_out1, i, i * 1.5); + rd_kw_type *rd_kw_out0 = rd_kw_alloc(KW0, 5, RD_FLOAT); + rd_kw_type *rd_kw_out1 = rd_kw_alloc(KW1, 5, RD_FLOAT); + for (int i = 0; i < rd_kw_get_size(rd_kw_out1); i++) { + rd_kw_iset_float(rd_kw_out0, i, i * 1.5); + rd_kw_iset_float(rd_kw_out1, i, i * 1.5); } { - fortio_type *f = - fortio_open_writer("TEST1", false, ECL_ENDIAN_FLIP); - test_assert_true(ecl_kw_fwrite(ecl_kw_out0, f)); - test_assert_false(ecl_kw_fwrite(ecl_kw_out1, f)); + fortio_type *f = fortio_open_writer("TEST1", false, RD_ENDIAN_FLIP); + test_assert_true(rd_kw_fwrite(rd_kw_out0, f)); + test_assert_false(rd_kw_fwrite(rd_kw_out1, f)); fortio_fclose(f); } @@ -81,26 +80,26 @@ void test_kw_io_charlength() { { FILE *file = util_fopen("TEST2", "w"); - ecl_kw_fprintf_grdecl(ecl_kw_out1, file); + rd_kw_fprintf_grdecl(rd_kw_out1, file); fclose(file); } { FILE *file = util_fopen("TEST2", "r"); - ecl_kw_type *ecl_kw_in = - ecl_kw_fscanf_alloc_grdecl(file, KW1, -1, ECL_FLOAT); - test_assert_string_equal(KW1, ecl_kw_get_header(ecl_kw_in)); - test_assert_int_equal(5, ecl_kw_get_size(ecl_kw_in)); + rd_kw_type *rd_kw_in = + rd_kw_fscanf_alloc_grdecl(file, KW1, -1, RD_FLOAT); + test_assert_string_equal(KW1, rd_kw_get_header(rd_kw_in)); + test_assert_int_equal(5, rd_kw_get_size(rd_kw_in)); - test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 0), 0.0); - test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 4), 6.0); + test_assert_double_equal(rd_kw_iget_as_double(rd_kw_in, 0), 0.0); + test_assert_double_equal(rd_kw_iget_as_double(rd_kw_in, 4), 6.0); - ecl_kw_free(ecl_kw_in); + rd_kw_free(rd_kw_in); fclose(file); } - ecl_kw_free(ecl_kw_out0); - ecl_kw_free(ecl_kw_out1); + rd_kw_free(rd_kw_out0); + rd_kw_free(rd_kw_out1); } } diff --git a/lib/resdata/tests/rd_kw_grdecl.cpp b/lib/resdata/tests/rd_kw_grdecl.cpp index be184c781a..9c15732f0c 100644 --- a/lib/resdata/tests/rd_kw_grdecl.cpp +++ b/lib/resdata/tests/rd_kw_grdecl.cpp @@ -5,54 +5,53 @@ #include #include -#include +#include int main(int argc, char **argv) { int i; - ecl_kw_type *ecl_kw = ecl_kw_alloc("HEAD", 10, ECL_INT); + rd_kw_type *rd_kw = rd_kw_alloc("HEAD", 10, RD_INT); for (i = 0; i < 10; i++) - ecl_kw_iset_int(ecl_kw, i, i); + rd_kw_iset_int(rd_kw, i, i); { - ecl::util::TestArea ta("kw_grdecl"); + rd::util::TestArea ta("kw_grdecl"); FILE *stream = util_fopen("FILE.grdecl", "w"); - ecl_kw_fprintf_grdecl(ecl_kw, stream); + rd_kw_fprintf_grdecl(rd_kw, stream); fclose(stream); stream = util_fopen("FILE.grdecl", "r"); { - ecl_kw_type *ecl_kw2 = - ecl_kw_fscanf_alloc_grdecl(stream, "HEAD", 10, ECL_INT); + rd_kw_type *rd_kw2 = + rd_kw_fscanf_alloc_grdecl(stream, "HEAD", 10, RD_INT); - test_assert_not_NULL(ecl_kw2); - test_assert_true(ecl_kw_equal(ecl_kw, ecl_kw2)); - ecl_kw_free(ecl_kw2); + test_assert_not_NULL(rd_kw2); + test_assert_true(rd_kw_equal(rd_kw, rd_kw2)); + rd_kw_free(rd_kw2); } fclose(stream); stream = util_fopen("FILE.grdecl", "w"); - ecl_kw_fprintf_grdecl__(ecl_kw, "HEAD1234", stream); + rd_kw_fprintf_grdecl__(rd_kw, "HEAD1234", stream); fclose(stream); stream = util_fopen("FILE.grdecl", "r"); { - ecl_kw_type *ecl_kw2 = - ecl_kw_fscanf_alloc_grdecl(stream, "HEAD", 10, ECL_INT); + rd_kw_type *rd_kw2 = + rd_kw_fscanf_alloc_grdecl(stream, "HEAD", 10, RD_INT); - test_assert_NULL(ecl_kw2); - ecl_kw2 = - ecl_kw_fscanf_alloc_grdecl(stream, "HEAD1234", 10, ECL_INT); - test_assert_not_NULL(ecl_kw2); + test_assert_NULL(rd_kw2); + rd_kw2 = rd_kw_fscanf_alloc_grdecl(stream, "HEAD1234", 10, RD_INT); + test_assert_not_NULL(rd_kw2); - test_assert_string_equal(ecl_kw_get_header(ecl_kw2), "HEAD1234"); - test_assert_true(ecl_kw_content_equal(ecl_kw, ecl_kw2)); - ecl_kw_free(ecl_kw2); + test_assert_string_equal(rd_kw_get_header(rd_kw2), "HEAD1234"); + test_assert_true(rd_kw_content_equal(rd_kw, rd_kw2)); + rd_kw_free(rd_kw2); } fclose(stream); } - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); exit(0); } diff --git a/lib/resdata/tests/rd_kw_init.cpp b/lib/resdata/tests/rd_kw_init.cpp index 28ba04cc97..e11b4f04be 100644 --- a/lib/resdata/tests/rd_kw_init.cpp +++ b/lib/resdata/tests/rd_kw_init.cpp @@ -5,54 +5,54 @@ #include #include -#include +#include void test_int() { int N = 1000; int i; - ecl_kw_type *kw = ecl_kw_alloc("KW", N, ECL_INT); + rd_kw_type *kw = rd_kw_alloc("KW", N, RD_INT); for (i = 0; i < N; i++) - test_assert_int_equal(0, ecl_kw_iget_int(kw, i)); + test_assert_int_equal(0, rd_kw_iget_int(kw, i)); - ecl_kw_free(kw); + rd_kw_free(kw); } void test_double() { int N = 1000; double i; - ecl_kw_type *kw = ecl_kw_alloc("KW", N, ECL_DOUBLE); + rd_kw_type *kw = rd_kw_alloc("KW", N, RD_DOUBLE); for (i = 0; i < N; i++) - test_assert_double_equal(0, ecl_kw_iget_double(kw, i)); + test_assert_double_equal(0, rd_kw_iget_double(kw, i)); - ecl_kw_free(kw); + rd_kw_free(kw); } void test_float() { int N = 1000; int i; - ecl_kw_type *kw = ecl_kw_alloc("KW", N, ECL_FLOAT); + rd_kw_type *kw = rd_kw_alloc("KW", N, RD_FLOAT); for (i = 0; i < N; i++) - test_assert_int_equal(0, ecl_kw_iget_float(kw, i)); + test_assert_int_equal(0, rd_kw_iget_float(kw, i)); - ecl_kw_free(kw); + rd_kw_free(kw); } void test_bool() { int N = 100; bool *data = (bool *)util_malloc(N * sizeof *data); - ecl_kw_type *kw = ecl_kw_alloc("BOOL", N, ECL_BOOL); + rd_kw_type *kw = rd_kw_alloc("BOOL", N, RD_BOOL); for (int i = 0; i < N / 2; i++) { - ecl_kw_iset_bool(kw, 2 * i, true); - ecl_kw_iset_bool(kw, 2 * i + 1, false); + rd_kw_iset_bool(kw, 2 * i, true); + rd_kw_iset_bool(kw, 2 * i + 1, false); data[2 * i] = true; data[2 * i + 1] = false; } - const bool *internal_data = ecl_kw_get_bool_ptr(kw); + const bool *internal_data = rd_kw_get_bool_ptr(kw); test_assert_int_equal(memcmp(internal_data, data, N * sizeof *data), 0); - ecl_kw_free(kw); + rd_kw_free(kw); free(data); } diff --git a/lib/resdata/tests/rd_kw_space_pad.cpp b/lib/resdata/tests/rd_kw_space_pad.cpp index af7b079f6d..1b09cc74ce 100644 --- a/lib/resdata/tests/rd_kw_space_pad.cpp +++ b/lib/resdata/tests/rd_kw_space_pad.cpp @@ -4,18 +4,18 @@ #include #include -#include +#include int main(int argc, char **argv) { - ecl::util::TestArea ta("grid_unit_system"); + rd::util::TestArea ta("grid_unit_system"); - // 1. Write a ecl_kw instance with string data - uninitialized. + // 1. Write a rd_kw instance with string data - uninitialized. { - ecl_kw_type *ecl_kw = ecl_kw_alloc("SPACE", 1, ECL_CHAR); + rd_kw_type *rd_kw = rd_kw_alloc("SPACE", 1, RD_CHAR); fortio_type *f = fortio_open_writer("file", false, true); - ecl_kw_fwrite(ecl_kw, f); + rd_kw_fwrite(rd_kw, f); fortio_fclose(f); - ecl_kw_free(ecl_kw); + rd_kw_free(rd_kw); } // 2. Open file with normal fopen() and verify that the data section consists of only spaces. diff --git a/lib/resdata/tests/rd_layer.cpp b/lib/resdata/tests/rd_layer.cpp index 4725bd2717..f93f4678fd 100644 --- a/lib/resdata/tests/rd_layer.cpp +++ b/lib/resdata/tests/rd_layer.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include "detail/ecl/layer_cxx.hpp" +#include +#include "detail/resdata/layer_cxx.hpp" void test_create() { layer_type *layer = layer_alloc(10, 20); diff --git a/lib/resdata/tests/rd_layer_equinor.cpp b/lib/resdata/tests/rd_layer_equinor.cpp index 31f1beec86..fb2fc295b1 100644 --- a/lib/resdata/tests/rd_layer_equinor.cpp +++ b/lib/resdata/tests/rd_layer_equinor.cpp @@ -6,32 +6,32 @@ #include #include -#include -#include -#include +#include +#include +#include -#include "detail/ecl/layer_cxx.hpp" +#include "detail/resdata/layer_cxx.hpp" -ecl_kw_type *alloc_faultblock_kw(const char *filename, int grid_size) { +rd_kw_type *alloc_faultblock_kw(const char *filename, int grid_size) { FILE *stream = util_fopen(filename, "r"); - ecl_kw_type *kw = - ecl_kw_fscanf_alloc_grdecl(stream, "FAULTBLK", grid_size, ECL_INT); + rd_kw_type *kw = + rd_kw_fscanf_alloc_grdecl(stream, "FAULTBLK", grid_size, RD_INT); fclose(stream); return kw; } -void test_layer(const ecl_grid_type *ecl_grid, const ecl_kw_type *faultblock_kw, +void test_layer(const rd_grid_type *rd_grid, const rd_kw_type *faultblock_kw, int k) { - int nx = ecl_grid_get_nx(ecl_grid); - int ny = ecl_grid_get_ny(ecl_grid); + int nx = rd_grid_get_nx(rd_grid); + int ny = rd_grid_get_ny(rd_grid); layer_type *layer = layer_alloc(nx, ny); int i, j; for (j = 0; j < ny; j++) for (i = 0; i < nx; i++) { - int g = ecl_grid_get_global_index3(ecl_grid, i, j, k); - int fblk = ecl_kw_iget_int(faultblock_kw, g); + int g = rd_grid_get_global_index3(rd_grid, i, j, k); + int fblk = rd_kw_iget_int(faultblock_kw, g); layer_iset_cell_value(layer, i, j, fblk); } @@ -62,15 +62,15 @@ void test_layer(const ecl_grid_type *ecl_grid, const ecl_kw_type *faultblock_kw, } int main(int argc, char **argv) { - ecl_grid_type *ecl_grid = ecl_grid_alloc(argv[1]); - ecl_kw_type *faultblock_kw = - alloc_faultblock_kw(argv[2], ecl_grid_get_global_size(ecl_grid)); + rd_grid_type *rd_grid = rd_grid_alloc(argv[1]); + rd_kw_type *faultblock_kw = + alloc_faultblock_kw(argv[2], rd_grid_get_global_size(rd_grid)); int k; - for (k = 0; k < ecl_grid_get_nz(ecl_grid); k++) - test_layer(ecl_grid, faultblock_kw, k); + for (k = 0; k < rd_grid_get_nz(rd_grid); k++) + test_layer(rd_grid, faultblock_kw, k); - ecl_kw_free(faultblock_kw); - ecl_grid_free(ecl_grid); + rd_kw_free(faultblock_kw); + rd_grid_free(rd_grid); exit(0); } diff --git a/lib/resdata/tests/rd_lfs.cpp b/lib/resdata/tests/rd_lfs.cpp index dc1f4d9c72..6599a90c16 100644 --- a/lib/resdata/tests/rd_lfs.cpp +++ b/lib/resdata/tests/rd_lfs.cpp @@ -1,44 +1,44 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { int num_kw = 1000; // Total file size should roughly exceed 2GB int kw_size = 600000; - ecl_kw_type *kw = ecl_kw_alloc("KW", kw_size, ECL_INT); + rd_kw_type *kw = rd_kw_alloc("KW", kw_size, RD_INT); int i; offset_type file_size; for (i = 0; i < kw_size; i++) - ecl_kw_iset_int(kw, i, i); + rd_kw_iset_int(kw, i, i); { fortio_type *fortio = - fortio_open_writer("LARGE_FILE.UNRST", false, ECL_ENDIAN_FLIP); + fortio_open_writer("LARGE_FILE.UNRST", false, RD_ENDIAN_FLIP); for (i = 0; i < num_kw; i++) { printf("Writing keyword %d/%d to file:LARGE_FILE.UNRST \n", i + 1, num_kw); - ecl_kw_fwrite(kw, fortio); + rd_kw_fwrite(kw, fortio); } fortio_fclose(fortio); } /*{ - fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP); + fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , RD_ENDIAN_FLIP); for (i = 0; i < num_kw - 1; i++) { printf("SKipping keyword %d/%d from file:LARGE_FILE.UNRST \n",i+1 , num_kw ); - ecl_kw_fskip( fortio ); + rd_kw_fskip( fortio ); } { - ecl_kw_type * file_kw = ecl_kw_fread_alloc( fortio ); - if (ecl_kw_equal( kw , file_kw )) + rd_kw_type * file_kw = rd_kw_fread_alloc( fortio ); + if (rd_kw_equal( kw , file_kw )) printf("Keyword read back from file correctly :-) \n"); else printf("Fatal error - keyword different on return ...\n"); - ecl_kw_free( file_kw ); + rd_kw_free( file_kw ); } fortio_fclose( fortio ); } @@ -47,22 +47,22 @@ int main(int argc, char **argv) { printf("File size: %lld \n", file_size); { fortio_type *fortio = - fortio_open_reader("LARGE_FILE.UNRST", false, ECL_ENDIAN_FLIP); + fortio_open_reader("LARGE_FILE.UNRST", false, RD_ENDIAN_FLIP); printf("Seeking to file end: "); fortio_fseek(fortio, file_size, SEEK_SET); fortio_fclose(fortio); printf("Seek OK \n"); } - printf("Doing ecl_file_open(..)\n"); + printf("Doing rd_file_open(..)\n"); { - ecl_file_type *file = ecl_file_open("LARGE_FILE.UNRST", 0); - ecl_kw_type *file_kw = ecl_file_iget_named_kw(file, "KW", num_kw - 1); - if (ecl_kw_equal(kw, file_kw)) + rd_file_type *file = rd_file_open("LARGE_FILE.UNRST", 0); + rd_kw_type *file_kw = rd_file_iget_named_kw(file, "KW", num_kw - 1); + if (rd_kw_equal(kw, file_kw)) printf("Keyword read back from file correctly :-) \n"); else printf("Fatal error - keyword different on return ...\n"); - ecl_file_close(file); + rd_file_close(file); } remove("LARGE_FILE.UNRST"); diff --git a/lib/resdata/tests/rd_lgr_name.cpp b/lib/resdata/tests/rd_lgr_name.cpp index e79f33a792..14d9f120df 100644 --- a/lib/resdata/tests/rd_lgr_name.cpp +++ b/lib/resdata/tests/rd_lgr_name.cpp @@ -3,26 +3,26 @@ #include -#include +#include int main(int argc, char **argv) { - ecl_grid_type *grid = ecl_grid_alloc(argv[1]); + rd_grid_type *grid = rd_grid_alloc(argv[1]); - int num_lgr = ecl_grid_get_num_lgr(grid); + int num_lgr = rd_grid_get_num_lgr(grid); int lgr_index; for (lgr_index = 0; lgr_index < num_lgr; lgr_index++) { - ecl_grid_type *lgr_from_index = ecl_grid_iget_lgr(grid, lgr_index); - int lgr_nr = ecl_grid_get_lgr_nr(lgr_from_index); - ecl_grid_type *lgr_from_nr = ecl_grid_get_lgr_from_lgr_nr(grid, lgr_nr); + rd_grid_type *lgr_from_index = rd_grid_iget_lgr(grid, lgr_index); + int lgr_nr = rd_grid_get_lgr_nr(lgr_from_index); + rd_grid_type *lgr_from_nr = rd_grid_get_lgr_from_lgr_nr(grid, lgr_nr); test_assert_ptr_equal(lgr_from_index, lgr_from_nr); - test_assert_string_equal(ecl_grid_get_lgr_name(grid, lgr_nr), - ecl_grid_iget_lgr_name(grid, lgr_index)); + test_assert_string_equal(rd_grid_get_lgr_name(grid, lgr_nr), + rd_grid_iget_lgr_name(grid, lgr_index)); printf("Grid[%d:%d] : %s \n", lgr_index, lgr_nr, - ecl_grid_iget_lgr_name(grid, lgr_index)); + rd_grid_iget_lgr_name(grid, lgr_index)); } - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_lgr_test.cpp b/lib/resdata/tests/rd_lgr_test.cpp index ba5c2a4c7e..a20ae7881a 100644 --- a/lib/resdata/tests/rd_lgr_test.cpp +++ b/lib/resdata/tests/rd_lgr_test.cpp @@ -4,22 +4,22 @@ #include #include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { const char *grid_file = argv[1]; - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_file); - ecl_file_type *ecl_file = ecl_file_open(grid_file, 0); + rd_grid_type *rd_grid = rd_grid_alloc(grid_file); + rd_file_type *rd_file = rd_file_open(grid_file, 0); - ecl_grid_test_lgr_consistency(ecl_grid); + rd_grid_test_lgr_consistency(rd_grid); - if (ecl_file_get_num_named_kw(ecl_file, COORD_KW)) - test_assert_int_equal(ecl_file_get_num_named_kw(ecl_file, COORD_KW) - 1, - ecl_grid_get_num_lgr(ecl_grid)); + if (rd_file_get_num_named_kw(rd_file, COORD_KW)) + test_assert_int_equal(rd_file_get_num_named_kw(rd_file, COORD_KW) - 1, + rd_grid_get_num_lgr(rd_grid)); - ecl_grid_free(ecl_grid); - ecl_file_close(ecl_file); + rd_grid_free(rd_grid); + rd_file_close(rd_file); exit(0); } diff --git a/lib/resdata/tests/rd_nnc_data_equinor_root.cpp b/lib/resdata/tests/rd_nnc_data_equinor_root.cpp index f11f24d9ee..abf660f452 100644 --- a/lib/resdata/tests/rd_nnc_data_equinor_root.cpp +++ b/lib/resdata/tests/rd_nnc_data_equinor_root.cpp @@ -1,22 +1,22 @@ -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include -int find_index(ecl_nnc_geometry_type *nnc_geo, int grid1, int grid2, int indx1, +int find_index(rd_nnc_geometry_type *nnc_geo, int grid1, int grid2, int indx1, int indx2) { int index = -1; - int nnc_size = ecl_nnc_geometry_size(nnc_geo); + int nnc_size = rd_nnc_geometry_size(nnc_geo); for (int n = 0; n < nnc_size; n++) { - const ecl_nnc_pair_type *pair = ecl_nnc_geometry_iget(nnc_geo, n); + const rd_nnc_pair_type *pair = rd_nnc_geometry_iget(nnc_geo, n); if (pair->grid_nr1 == grid1 && pair->grid_nr2 == grid2) if (pair->global_index1 == indx1 && pair->global_index2 == indx2) { index = n; @@ -28,18 +28,18 @@ int find_index(ecl_nnc_geometry_type *nnc_geo, int grid1, int grid2, int indx1, void test_alloc_file_tran(char *filename) { char *grid_file_name = - ecl_util_alloc_filename(NULL, filename, ECL_EGRID_FILE, false, -1); + rd_alloc_filename(NULL, filename, RD_EGRID_FILE, false, -1); char *init_file_name = - ecl_util_alloc_filename(NULL, filename, ECL_INIT_FILE, false, -1); - ecl_file_type *init_file = ecl_file_open(init_file_name, 0); - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_nnc_geometry_type *nnc_geo = ecl_nnc_geometry_alloc(grid); - ecl_file_view_type *view_file = ecl_file_get_global_view(init_file); + rd_alloc_filename(NULL, filename, RD_INIT_FILE, false, -1); + rd_file_type *init_file = rd_file_open(init_file_name, 0); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_nnc_geometry_type *nnc_geo = rd_nnc_geometry_alloc(grid); + rd_file_view_type *view_file = rd_file_get_global_view(init_file); - ecl_nnc_data_type *nnc_geo_data = - ecl_nnc_data_alloc_tran(grid, nnc_geo, view_file); - test_assert_true(ecl_nnc_geometry_size(nnc_geo) == - ecl_nnc_data_get_size(nnc_geo_data)); + rd_nnc_data_type *nnc_geo_data = + rd_nnc_data_alloc_tran(grid, nnc_geo, view_file); + test_assert_true(rd_nnc_geometry_size(nnc_geo) == + rd_nnc_data_get_size(nnc_geo_data)); //These numerical values are hand-tuned the specific input file at: //${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3 @@ -47,60 +47,60 @@ void test_alloc_file_tran(char *filename) { index = find_index(nnc_geo, 0, 0, 541, 14507); test_assert_double_equal(13.784438, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); index = find_index(nnc_geo, 0, 0, 48365, 118191); test_assert_double_equal(0.580284, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); index = find_index(nnc_geo, 0, 19, 42830, 211); test_assert_double_equal(0.571021, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); index = find_index(nnc_geo, 0, 79, 132406, 76); test_assert_double_equal(37.547710, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); index = find_index(nnc_geo, 18, 12, 303, 115); test_assert_double_equal(0.677443, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); index = find_index(nnc_geo, 72, 71, 255, 179); test_assert_double_equal(0.045813, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); index = find_index(nnc_geo, 110, 109, 271, 275); test_assert_double_equal(16.372242, - ecl_nnc_data_iget_value(nnc_geo_data, index)); + rd_nnc_data_iget_value(nnc_geo_data, index)); - ecl_nnc_data_free(nnc_geo_data); - ecl_nnc_geometry_free(nnc_geo); - ecl_grid_free(grid); - ecl_file_close(init_file); + rd_nnc_data_free(nnc_geo_data); + rd_nnc_geometry_free(nnc_geo); + rd_grid_free(grid); + rd_file_close(init_file); free(grid_file_name); free(init_file_name); } void test_alloc_file_flux(char *filename, int file_num) { char *grid_file_name = - ecl_util_alloc_filename(NULL, filename, ECL_EGRID_FILE, false, -1); - char *restart_file_name = ecl_util_alloc_filename( - NULL, filename, ECL_RESTART_FILE, false, file_num); + rd_alloc_filename(NULL, filename, RD_EGRID_FILE, false, -1); + char *restart_file_name = + rd_alloc_filename(NULL, filename, RD_RESTART_FILE, false, file_num); - ecl_file_type *restart_file = ecl_file_open(restart_file_name, 0); - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_nnc_geometry_type *nnc_geo = ecl_nnc_geometry_alloc(grid); + rd_file_type *restart_file = rd_file_open(restart_file_name, 0); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_nnc_geometry_type *nnc_geo = rd_nnc_geometry_alloc(grid); { - ecl_file_view_type *view_file = ecl_file_get_global_view(restart_file); + rd_file_view_type *view_file = rd_file_get_global_view(restart_file); - ecl_nnc_data_type *nnc_flux_data = - ecl_nnc_data_alloc_wat_flux(grid, nnc_geo, view_file); + rd_nnc_data_type *nnc_flux_data = + rd_nnc_data_alloc_wat_flux(grid, nnc_geo, view_file); test_assert_not_NULL(nnc_flux_data); - ecl_nnc_data_free(nnc_flux_data); + rd_nnc_data_free(nnc_flux_data); } - ecl_nnc_geometry_free(nnc_geo); - ecl_grid_free(grid); - ecl_file_close(restart_file); + rd_nnc_geometry_free(nnc_geo); + rd_grid_free(grid); + rd_file_close(restart_file); free(grid_file_name); free(restart_file_name); } diff --git a/lib/resdata/tests/rd_nnc_export.cpp b/lib/resdata/tests/rd_nnc_export.cpp index 9ddcf7bece..beacceb5b2 100644 --- a/lib/resdata/tests/rd_nnc_export.cpp +++ b/lib/resdata/tests/rd_nnc_export.cpp @@ -6,45 +6,45 @@ #include #include -#include -#include -#include -#include -#include -#include - -int count_kw_data(const ecl_file_type *file, ecl_grid_type *grid, - const char *kw1, const char *kw2) { +#include +#include +#include +#include +#include +#include + +int count_kw_data(const rd_file_type *file, rd_grid_type *grid, const char *kw1, + const char *kw2) { int i, j; int count = 0; - for (i = 0; i < ecl_file_get_num_named_kw(file, kw1); i++) { - ecl_kw_type *ecl_kw1 = ecl_file_iget_named_kw(file, kw1, i); - ecl_kw_type *ecl_kw2 = NULL; + for (i = 0; i < rd_file_get_num_named_kw(file, kw1); i++) { + rd_kw_type *rd_kw1 = rd_file_iget_named_kw(file, kw1, i); + rd_kw_type *rd_kw2 = NULL; if (kw2) - ecl_kw2 = ecl_file_iget_named_kw(file, kw2, i); + rd_kw2 = rd_file_iget_named_kw(file, kw2, i); { - if (ecl_kw2) { + if (rd_kw2) { int global_size; - ecl_grid_type *igrid; + rd_grid_type *igrid; if (i == 0) igrid = grid; else - igrid = ecl_grid_iget_lgr(grid, i - 1); + igrid = rd_grid_iget_lgr(grid, i - 1); - global_size = ecl_grid_get_global_size(igrid); + global_size = rd_grid_get_global_size(igrid); - for (j = 0; j < ecl_kw_get_size(ecl_kw1); j++) { - int g1 = ecl_kw_iget_int(ecl_kw1, j); - int g2 = ecl_kw_iget_int(ecl_kw2, j); + for (j = 0; j < rd_kw_get_size(rd_kw1); j++) { + int g1 = rd_kw_iget_int(rd_kw1, j); + int g2 = rd_kw_iget_int(rd_kw2, j); if (g1 <= global_size && g2 <= global_size) count += 1; } } else - count += ecl_kw_get_size(ecl_kw1); + count += rd_kw_get_size(rd_kw1); } } return count; @@ -52,12 +52,12 @@ int count_kw_data(const ecl_file_type *file, ecl_grid_type *grid, void test_count(const char *name) { char *grid_file_name = - ecl_util_alloc_filename(NULL, name, ECL_EGRID_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_EGRID_FILE, false, -1); char *init_file_name = - ecl_util_alloc_filename(NULL, name, ECL_INIT_FILE, false, -1); - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_file_type *grid_file = ecl_file_open(grid_file_name, 0); - ecl_file_type *init_file = ecl_file_open(init_file_name, 0); + rd_alloc_filename(NULL, name, RD_INIT_FILE, false, -1); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_file_type *grid_file = rd_file_open(grid_file_name, 0); + rd_file_type *init_file = rd_file_open(init_file_name, 0); int num_nnc = 0; @@ -65,65 +65,65 @@ void test_count(const char *name) { num_nnc += count_kw_data(grid_file, grid, "NNCG", NULL); num_nnc += count_kw_data(grid_file, grid, "NNA1", NULL); - test_assert_int_equal(num_nnc, ecl_nnc_export_get_size(grid, init_file)); + test_assert_int_equal(num_nnc, rd_nnc_export_get_size(grid, init_file)); free(grid_file_name); - ecl_grid_free(grid); - ecl_file_close(grid_file); + rd_grid_free(grid); + rd_file_close(grid_file); } void test_nnc_export_missing_TRANX(const char *name) { char *grid_file_name = - ecl_util_alloc_filename(NULL, name, ECL_EGRID_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_EGRID_FILE, false, -1); char *init_file_name = - ecl_util_alloc_filename(NULL, name, ECL_INIT_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_INIT_FILE, false, -1); if (util_entry_exists(init_file_name)) { - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_file_type *init_file = ecl_file_open(init_file_name, 0); - ecl_nnc_type *nnc_data1 = (ecl_nnc_type *)util_calloc( - ecl_nnc_export_get_size(grid, init_file), sizeof *nnc_data1); - int count = ecl_nnc_export(grid, init_file, nnc_data1); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_file_type *init_file = rd_file_open(init_file_name, 0); + rd_nnc_type *nnc_data1 = (rd_nnc_type *)util_calloc( + rd_nnc_export_get_size(grid, init_file), sizeof *nnc_data1); + int count = rd_nnc_export(grid, init_file, nnc_data1); int i; test_assert_int_equal(count, 0); for (i = 0; i < count; i++) test_assert_double_equal(nnc_data1[i].trans, - ERT_ECL_DEFAULT_NNC_TRANS); + ERT_RD_DEFAULT_NNC_TRANS); } } void test_export(const char *name, bool have_tran_data) { char *grid_file_name = - ecl_util_alloc_filename(NULL, name, ECL_EGRID_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_EGRID_FILE, false, -1); char *init_file_name = - ecl_util_alloc_filename(NULL, name, ECL_INIT_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_INIT_FILE, false, -1); if (util_entry_exists(init_file_name)) { - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_file_type *grid_file = ecl_file_open(grid_file_name, 0); - ecl_file_type *init_file = ecl_file_open(init_file_name, 0); - ecl_nnc_type *nnc_data1 = (ecl_nnc_type *)util_calloc( - ecl_nnc_export_get_size(grid, init_file), sizeof *nnc_data1); - ecl_nnc_type *nnc_data2 = (ecl_nnc_type *)util_calloc( - ecl_nnc_export_get_size(grid, init_file), sizeof *nnc_data2); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_file_type *grid_file = rd_file_open(grid_file_name, 0); + rd_file_type *init_file = rd_file_open(init_file_name, 0); + rd_nnc_type *nnc_data1 = (rd_nnc_type *)util_calloc( + rd_nnc_export_get_size(grid, init_file), sizeof *nnc_data1); + rd_nnc_type *nnc_data2 = (rd_nnc_type *)util_calloc( + rd_nnc_export_get_size(grid, init_file), sizeof *nnc_data2); { int nnc_offset = 0; int block_nr = 0; for (block_nr = 0; - block_nr < ecl_file_get_num_named_kw(grid_file, NNCHEAD_KW); + block_nr < rd_file_get_num_named_kw(grid_file, NNCHEAD_KW); block_nr++) { - ecl_file_view_type *nnc_view = ecl_file_alloc_global_blockview( + rd_file_view_type *nnc_view = rd_file_alloc_global_blockview( grid_file, NNCHEAD_KW, block_nr); - if (ecl_file_view_has_kw(nnc_view, NNC1_KW)) { - ecl_kw_type *nnc1_kw = - ecl_file_view_iget_named_kw(nnc_view, NNC1_KW, 0); - ecl_kw_type *nnc2_kw = - ecl_file_view_iget_named_kw(nnc_view, NNC2_KW, 0); - ecl_kw_type *nnchead = - ecl_file_view_iget_named_kw(nnc_view, NNCHEAD_KW, 0); - int lgr_nr1 = ecl_kw_iget_int(nnchead, NNCHEAD_LGR_INDEX); - int lgr_nr2 = ecl_kw_iget_int(nnchead, NNCHEAD_LGR_INDEX); - ecl_kw_type *nnc_tran = ecl_nnc_export_get_tranx_kw( + if (rd_file_view_has_kw(nnc_view, NNC1_KW)) { + rd_kw_type *nnc1_kw = + rd_file_view_iget_named_kw(nnc_view, NNC1_KW, 0); + rd_kw_type *nnc2_kw = + rd_file_view_iget_named_kw(nnc_view, NNC2_KW, 0); + rd_kw_type *nnchead = + rd_file_view_iget_named_kw(nnc_view, NNCHEAD_KW, 0); + int lgr_nr1 = rd_kw_iget_int(nnchead, NNCHEAD_LGR_INDEX); + int lgr_nr2 = rd_kw_iget_int(nnchead, NNCHEAD_LGR_INDEX); + rd_kw_type *nnc_tran = rd_nnc_export_get_tranx_kw( grid, init_file, lgr_nr1, lgr_nr2); if (!have_tran_data) { test_assert_NULL(nnc_tran); @@ -131,27 +131,27 @@ void test_export(const char *name, bool have_tran_data) { } test_assert_not_NULL(nnc_tran); - test_assert_int_equal(ecl_kw_get_size(nnc1_kw), - ecl_kw_get_size(nnc_tran)); + test_assert_int_equal(rd_kw_get_size(nnc1_kw), + rd_kw_get_size(nnc_tran)); { - ecl_grid_type *lgr = grid; + rd_grid_type *lgr = grid; int num_nnc = 0; int i = 0; if (lgr_nr1 > 0) - lgr = ecl_grid_get_lgr_from_lgr_nr(grid, lgr_nr1); + lgr = rd_grid_get_lgr_from_lgr_nr(grid, lgr_nr1); - while (i < ecl_kw_get_size(nnc1_kw)) { - int g1 = ecl_kw_iget_int(nnc1_kw, i) - 1; - int g2 = ecl_kw_iget_int(nnc2_kw, i) - 1; + while (i < rd_kw_get_size(nnc1_kw)) { + int g1 = rd_kw_iget_int(nnc1_kw, i) - 1; + int g2 = rd_kw_iget_int(nnc2_kw, i) - 1; - if (g1 < ecl_grid_get_global_size(lgr) && - g2 < ecl_grid_get_global_size(lgr)) { + if (g1 < rd_grid_get_global_size(lgr) && + g2 < rd_grid_get_global_size(lgr)) { nnc_data1[i + nnc_offset].grid_nr1 = lgr_nr1; nnc_data1[i + nnc_offset].grid_nr2 = lgr_nr2; nnc_data1[i + nnc_offset].global_index1 = g1; nnc_data1[i + nnc_offset].global_index2 = g2; nnc_data1[i + nnc_offset].trans = - ecl_kw_iget_as_double(nnc_tran, i); + rd_kw_iget_as_double(nnc_tran, i); nnc_data1[i + nnc_offset].input_index = i; num_nnc++; } @@ -161,109 +161,107 @@ void test_export(const char *name, bool have_tran_data) { } } - if (ecl_file_view_has_kw(nnc_view, NNCL_KW)) { - ecl_kw_type *nncl_kw = - ecl_file_view_iget_named_kw(nnc_view, NNCL_KW, 0); - ecl_kw_type *nncg_kw = - ecl_file_view_iget_named_kw(nnc_view, NNCG_KW, 0); - ecl_kw_type *nnchead = - ecl_file_view_iget_named_kw(nnc_view, NNCHEAD_KW, 0); + if (rd_file_view_has_kw(nnc_view, NNCL_KW)) { + rd_kw_type *nncl_kw = + rd_file_view_iget_named_kw(nnc_view, NNCL_KW, 0); + rd_kw_type *nncg_kw = + rd_file_view_iget_named_kw(nnc_view, NNCG_KW, 0); + rd_kw_type *nnchead = + rd_file_view_iget_named_kw(nnc_view, NNCHEAD_KW, 0); int lgr_nr1 = 0; - int lgr_nr2 = ecl_kw_iget_int(nnchead, NNCHEAD_LGR_INDEX); - ecl_kw_type *nnc_tran = ecl_nnc_export_get_tranx_kw( - grid, init_file, 0, lgr_nr2); + int lgr_nr2 = rd_kw_iget_int(nnchead, NNCHEAD_LGR_INDEX); + rd_kw_type *nnc_tran = + rd_nnc_export_get_tranx_kw(grid, init_file, 0, lgr_nr2); int i; - test_assert_int_equal(ecl_kw_get_size(nncl_kw), - ecl_kw_get_size(nnc_tran)); - for (i = 0; i < ecl_kw_get_size(nncl_kw); i++) { + test_assert_int_equal(rd_kw_get_size(nncl_kw), + rd_kw_get_size(nnc_tran)); + for (i = 0; i < rd_kw_get_size(nncl_kw); i++) { nnc_data1[i + nnc_offset].grid_nr1 = lgr_nr1; nnc_data1[i + nnc_offset].grid_nr2 = lgr_nr2; nnc_data1[i + nnc_offset].global_index1 = - ecl_kw_iget_int(nncg_kw, i) - 1; + rd_kw_iget_int(nncg_kw, i) - 1; nnc_data1[i + nnc_offset].global_index2 = - ecl_kw_iget_int(nncl_kw, i) - 1; + rd_kw_iget_int(nncl_kw, i) - 1; nnc_data1[i + nnc_offset].trans = - ecl_kw_iget_as_double(nnc_tran, i); + rd_kw_iget_as_double(nnc_tran, i); nnc_data1[i + nnc_offset].input_index = i; } - nnc_offset += ecl_kw_get_size(nncl_kw); + nnc_offset += rd_kw_get_size(nncl_kw); } - ecl_file_view_free(nnc_view); + rd_file_view_free(nnc_view); } { - for (block_nr = 0; block_nr < ecl_file_get_num_named_kw( + for (block_nr = 0; block_nr < rd_file_get_num_named_kw( grid_file, NNCHEADA_KW); block_nr++) { - ecl_kw_type *nnc1_kw = - ecl_file_iget_named_kw(grid_file, NNA1_KW, block_nr); - ecl_kw_type *nnc2_kw = - ecl_file_iget_named_kw(grid_file, NNA2_KW, block_nr); - ecl_kw_type *nnchead = ecl_file_iget_named_kw( - grid_file, NNCHEADA_KW, block_nr); - int lgr_nr1 = - ecl_kw_iget_int(nnchead, NNCHEADA_ILOC1_INDEX); - int lgr_nr2 = - ecl_kw_iget_int(nnchead, NNCHEADA_ILOC2_INDEX); - ecl_kw_type *nnc_tran; + rd_kw_type *nnc1_kw = + rd_file_iget_named_kw(grid_file, NNA1_KW, block_nr); + rd_kw_type *nnc2_kw = + rd_file_iget_named_kw(grid_file, NNA2_KW, block_nr); + rd_kw_type *nnchead = + rd_file_iget_named_kw(grid_file, NNCHEADA_KW, block_nr); + int lgr_nr1 = rd_kw_iget_int(nnchead, NNCHEADA_ILOC1_INDEX); + int lgr_nr2 = rd_kw_iget_int(nnchead, NNCHEADA_ILOC2_INDEX); + rd_kw_type *nnc_tran; int i; - nnc_tran = ecl_nnc_export_get_tranx_kw(grid, init_file, - lgr_nr1, lgr_nr2); + nnc_tran = rd_nnc_export_get_tranx_kw(grid, init_file, + lgr_nr1, lgr_nr2); test_assert_not_NULL(nnc_tran); - test_assert_int_equal(ecl_kw_get_size(nnc1_kw), - ecl_kw_get_size(nnc_tran)); - for (i = 0; i < ecl_kw_get_size(nnc1_kw); i++) { + test_assert_int_equal(rd_kw_get_size(nnc1_kw), + rd_kw_get_size(nnc_tran)); + for (i = 0; i < rd_kw_get_size(nnc1_kw); i++) { nnc_data1[i + nnc_offset].grid_nr1 = lgr_nr1; nnc_data1[i + nnc_offset].grid_nr2 = lgr_nr2; nnc_data1[i + nnc_offset].global_index1 = - ecl_kw_iget_int(nnc1_kw, i) - 1; + rd_kw_iget_int(nnc1_kw, i) - 1; nnc_data1[i + nnc_offset].global_index2 = - ecl_kw_iget_int(nnc2_kw, i) - 1; + rd_kw_iget_int(nnc2_kw, i) - 1; nnc_data1[i + nnc_offset].trans = - ecl_kw_iget_as_double(nnc_tran, i); + rd_kw_iget_as_double(nnc_tran, i); nnc_data1[i + nnc_offset].input_index = i; } - nnc_offset += ecl_kw_get_size(nnc1_kw); + nnc_offset += rd_kw_get_size(nnc1_kw); } } test_assert_int_equal(nnc_offset, - ecl_nnc_export_get_size(grid, init_file)); - ecl_nnc_sort(nnc_data1, nnc_offset); + rd_nnc_export_get_size(grid, init_file)); + rd_nnc_sort(nnc_data1, nnc_offset); } { - int export_size = ecl_nnc_export(grid, init_file, nnc_data2); + int export_size = rd_nnc_export(grid, init_file, nnc_data2); test_assert_int_equal(export_size, - ecl_nnc_export_get_size(grid, init_file)); + rd_nnc_export_get_size(grid, init_file)); } { int i; - int size = ecl_nnc_export_get_size(grid, init_file); + int size = rd_nnc_export_get_size(grid, init_file); for (i = 0; i < size; i++) test_assert_int_equal( - 0, ecl_nnc_sort_cmp(&nnc_data1[i], &nnc_data2[i])); + 0, rd_nnc_sort_cmp(&nnc_data1[i], &nnc_data2[i])); } - for (int i = 0; i < ecl_nnc_export_get_size(grid, init_file); i++) - test_assert_true(ecl_nnc_equal(&nnc_data1[i], &nnc_data2[i])); + for (int i = 0; i < rd_nnc_export_get_size(grid, init_file); i++) + test_assert_true(rd_nnc_equal(&nnc_data1[i], &nnc_data2[i])); { - ecl_nnc_geometry_type *nnc_geo = ecl_nnc_geometry_alloc(grid); - ecl_file_view_type *view_file = ecl_file_get_global_view(init_file); - ecl_nnc_data_type *nnc_geo_data = - ecl_nnc_data_alloc_tran(grid, nnc_geo, view_file); - - test_assert_int_equal(ecl_nnc_export_get_size(grid, init_file), - ecl_nnc_geometry_size(nnc_geo)); - for (int i = 0; i < ecl_nnc_geometry_size(nnc_geo); i++) { - const ecl_nnc_pair_type *nnc_pair = - ecl_nnc_geometry_iget(nnc_geo, i); - ecl_nnc_type *nnc1 = &nnc_data1[i]; + rd_nnc_geometry_type *nnc_geo = rd_nnc_geometry_alloc(grid); + rd_file_view_type *view_file = rd_file_get_global_view(init_file); + rd_nnc_data_type *nnc_geo_data = + rd_nnc_data_alloc_tran(grid, nnc_geo, view_file); + + test_assert_int_equal(rd_nnc_export_get_size(grid, init_file), + rd_nnc_geometry_size(nnc_geo)); + for (int i = 0; i < rd_nnc_geometry_size(nnc_geo); i++) { + const rd_nnc_pair_type *nnc_pair = + rd_nnc_geometry_iget(nnc_geo, i); + rd_nnc_type *nnc1 = &nnc_data1[i]; test_assert_int_equal(nnc_pair->grid_nr1, nnc1->grid_nr1); test_assert_int_equal(nnc_pair->grid_nr2, nnc1->grid_nr2); @@ -272,17 +270,17 @@ void test_export(const char *name, bool have_tran_data) { test_assert_int_equal(nnc_pair->global_index2, nnc1->global_index2); test_assert_double_equal( - ecl_nnc_data_iget_value(nnc_geo_data, i), nnc1->trans); + rd_nnc_data_iget_value(nnc_geo_data, i), nnc1->trans); } - ecl_nnc_data_free(nnc_geo_data); - ecl_nnc_geometry_free(nnc_geo); + rd_nnc_data_free(nnc_geo_data); + rd_nnc_geometry_free(nnc_geo); } free(nnc_data2); free(nnc_data1); - ecl_grid_free(grid); - ecl_file_close(grid_file); - ecl_file_close(init_file); + rd_grid_free(grid); + rd_file_close(grid_file); + rd_file_close(init_file); } else fprintf(stderr, " Could not find init file:%s - export test skipped \n", init_file_name); @@ -293,27 +291,27 @@ void test_export(const char *name, bool have_tran_data) { void test_cmp() { - ecl_nnc_type nnc1 = {1, 1, 1, 1}; - ecl_nnc_type nnc2 = {1, 1, 1, 1}; - ecl_nnc_type nnc3 = {4, 1, 1, 1}; - ecl_nnc_type nnc4 = {4, 2, 1, 1}; - ecl_nnc_type nnc5 = {4, 2, 3, 1}; - ecl_nnc_type nnc6 = {4, 2, 3, 5}; - - test_assert_int_equal(0, ecl_nnc_sort_cmp(&nnc1, &nnc2)); - test_assert_int_equal(1, ecl_nnc_sort_cmp(&nnc3, &nnc1)); - test_assert_int_equal(1, ecl_nnc_sort_cmp(&nnc4, &nnc1)); - test_assert_int_equal(1, ecl_nnc_sort_cmp(&nnc5, &nnc4)); - test_assert_int_equal(-1, ecl_nnc_sort_cmp(&nnc4, &nnc5)); - test_assert_int_equal(-1, ecl_nnc_sort_cmp(&nnc5, &nnc6)); + rd_nnc_type nnc1 = {1, 1, 1, 1}; + rd_nnc_type nnc2 = {1, 1, 1, 1}; + rd_nnc_type nnc3 = {4, 1, 1, 1}; + rd_nnc_type nnc4 = {4, 2, 1, 1}; + rd_nnc_type nnc5 = {4, 2, 3, 1}; + rd_nnc_type nnc6 = {4, 2, 3, 5}; + + test_assert_int_equal(0, rd_nnc_sort_cmp(&nnc1, &nnc2)); + test_assert_int_equal(1, rd_nnc_sort_cmp(&nnc3, &nnc1)); + test_assert_int_equal(1, rd_nnc_sort_cmp(&nnc4, &nnc1)); + test_assert_int_equal(1, rd_nnc_sort_cmp(&nnc5, &nnc4)); + test_assert_int_equal(-1, rd_nnc_sort_cmp(&nnc4, &nnc5)); + test_assert_int_equal(-1, rd_nnc_sort_cmp(&nnc5, &nnc6)); } void test_sort() { const int N = 1000; - ecl_nnc_type *nnc_list = (ecl_nnc_type *)util_calloc(N, sizeof *nnc_list); + rd_nnc_type *nnc_list = (rd_nnc_type *)util_calloc(N, sizeof *nnc_list); int i; for (i = 0; i < N; i++) { - ecl_nnc_type nnc; + rd_nnc_type nnc; nnc.grid_nr1 = (i % 19); nnc.grid_nr2 = (i % 3); @@ -322,10 +320,10 @@ void test_sort() { nnc_list[i] = nnc; } - ecl_nnc_sort(nnc_list, N); + rd_nnc_sort(nnc_list, N); for (i = 0; i < (N - 1); i++) test_assert_int_equal(-1, - ecl_nnc_sort_cmp(&nnc_list[i], &nnc_list[i + 1])); + rd_nnc_sort_cmp(&nnc_list[i], &nnc_list[i + 1])); free(nnc_list); } diff --git a/lib/resdata/tests/rd_nnc_export_get_tran.cpp b/lib/resdata/tests/rd_nnc_export_get_tran.cpp index 538d1e6cb8..6cb3ee6600 100644 --- a/lib/resdata/tests/rd_nnc_export_get_tran.cpp +++ b/lib/resdata/tests/rd_nnc_export_get_tran.cpp @@ -5,149 +5,141 @@ #include #include -#include -#include -#include +#include +#include +#include void test_get_tran(const char *name) { char *grid_file_name = - ecl_util_alloc_filename(NULL, name, ECL_EGRID_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_EGRID_FILE, false, -1); char *init_file_name = - ecl_util_alloc_filename(NULL, name, ECL_INIT_FILE, false, -1); - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_file_type *grid_file = ecl_file_open(grid_file_name, 0); - ecl_file_type *init_file = ecl_file_open(init_file_name, 0); + rd_alloc_filename(NULL, name, RD_INIT_FILE, false, -1); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_file_type *grid_file = rd_file_open(grid_file_name, 0); + rd_file_type *init_file = rd_file_open(init_file_name, 0); /* Get global */ { - ecl_kw_type *tran_kw = - ecl_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 0); - test_assert_true(ecl_kw_is_instance(tran_kw)); - test_assert_double_equal(0.85582769, ecl_kw_iget_as_double(tran_kw, 0)); + rd_kw_type *tran_kw = + rd_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 0); + test_assert_true(rd_kw_is_instance(tran_kw)); + test_assert_double_equal(0.85582769, rd_kw_iget_as_double(tran_kw, 0)); test_assert_double_equal(0.24635284, - ecl_kw_iget_as_double(tran_kw, 7184)); + rd_kw_iget_as_double(tran_kw, 7184)); } - test_assert_NULL(ecl_nnc_export_get_tran_kw(init_file, TRANGL_KW, 0)); - test_assert_NULL(ecl_nnc_export_get_tran_kw(init_file, TRANLL_KW, 0)); - test_assert_NULL(ecl_nnc_export_get_tran_kw(init_file, "INVALID", 1)); + test_assert_NULL(rd_nnc_export_get_tran_kw(init_file, TRANGL_KW, 0)); + test_assert_NULL(rd_nnc_export_get_tran_kw(init_file, TRANLL_KW, 0)); + test_assert_NULL(rd_nnc_export_get_tran_kw(init_file, "INVALID", 1)); /* Get lgr_nr: 48 */ { - ecl_kw_type *tran_kw = - ecl_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 48); - test_assert_true(ecl_kw_is_instance(tran_kw)); - test_assert_int_equal(0, ecl_kw_get_size(tran_kw)); - - tran_kw = ecl_nnc_export_get_tran_kw(init_file, TRANGL_KW, 48); - test_assert_int_equal(282, ecl_kw_get_size(tran_kw)); - test_assert_double_equal(22.922695, ecl_kw_iget_as_double(tran_kw, 0)); - test_assert_double_equal(16.720325, - ecl_kw_iget_as_double(tran_kw, 281)); + rd_kw_type *tran_kw = + rd_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 48); + test_assert_true(rd_kw_is_instance(tran_kw)); + test_assert_int_equal(0, rd_kw_get_size(tran_kw)); + + tran_kw = rd_nnc_export_get_tran_kw(init_file, TRANGL_KW, 48); + test_assert_int_equal(282, rd_kw_get_size(tran_kw)); + test_assert_double_equal(22.922695, rd_kw_iget_as_double(tran_kw, 0)); + test_assert_double_equal(16.720325, rd_kw_iget_as_double(tran_kw, 281)); } /* Get lgr_nr: 99 */ { - ecl_kw_type *tran_kw = - ecl_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 99); - test_assert_true(ecl_kw_is_instance(tran_kw)); - test_assert_int_equal(0, ecl_kw_get_size(tran_kw)); - - tran_kw = ecl_nnc_export_get_tran_kw(init_file, TRANGL_KW, 99); - test_assert_int_equal(693, ecl_kw_get_size(tran_kw)); - test_assert_double_equal(0.25534782, ecl_kw_iget_as_double(tran_kw, 0)); + rd_kw_type *tran_kw = + rd_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 99); + test_assert_true(rd_kw_is_instance(tran_kw)); + test_assert_int_equal(0, rd_kw_get_size(tran_kw)); + + tran_kw = rd_nnc_export_get_tran_kw(init_file, TRANGL_KW, 99); + test_assert_int_equal(693, rd_kw_get_size(tran_kw)); + test_assert_double_equal(0.25534782, rd_kw_iget_as_double(tran_kw, 0)); test_assert_double_equal(0.12677453, - ecl_kw_iget_as_double(tran_kw, 692)); + rd_kw_iget_as_double(tran_kw, 692)); } /* Get lgr_nr: 10 */ { - ecl_kw_type *tran_kw = - ecl_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 10); - test_assert_true(ecl_kw_is_instance(tran_kw)); - test_assert_int_equal(0, ecl_kw_get_size(tran_kw)); - - tran_kw = ecl_nnc_export_get_tran_kw(init_file, TRANGL_KW, 10); - test_assert_int_equal(260, ecl_kw_get_size(tran_kw)); - test_assert_double_equal(0.87355447, ecl_kw_iget_as_double(tran_kw, 0)); - test_assert_double_equal(26.921568, - ecl_kw_iget_as_double(tran_kw, 259)); + rd_kw_type *tran_kw = + rd_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 10); + test_assert_true(rd_kw_is_instance(tran_kw)); + test_assert_int_equal(0, rd_kw_get_size(tran_kw)); + + tran_kw = rd_nnc_export_get_tran_kw(init_file, TRANGL_KW, 10); + test_assert_int_equal(260, rd_kw_get_size(tran_kw)); + test_assert_double_equal(0.87355447, rd_kw_iget_as_double(tran_kw, 0)); + test_assert_double_equal(26.921568, rd_kw_iget_as_double(tran_kw, 259)); } /* Get lgr_nr: 110 */ { - ecl_kw_type *tran_kw = - ecl_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 110); - test_assert_true(ecl_kw_is_instance(tran_kw)); - test_assert_int_equal(0, ecl_kw_get_size(tran_kw)); - - tran_kw = ecl_nnc_export_get_tran_kw(init_file, TRANGL_KW, 110); - test_assert_int_equal(208, ecl_kw_get_size(tran_kw)); - test_assert_double_equal(17.287283, ecl_kw_iget_as_double(tran_kw, 0)); - test_assert_double_equal(569.26312, - ecl_kw_iget_as_double(tran_kw, 207)); + rd_kw_type *tran_kw = + rd_nnc_export_get_tran_kw(init_file, TRANNNC_KW, 110); + test_assert_true(rd_kw_is_instance(tran_kw)); + test_assert_int_equal(0, rd_kw_get_size(tran_kw)); + + tran_kw = rd_nnc_export_get_tran_kw(init_file, TRANGL_KW, 110); + test_assert_int_equal(208, rd_kw_get_size(tran_kw)); + test_assert_double_equal(17.287283, rd_kw_iget_as_double(tran_kw, 0)); + test_assert_double_equal(569.26312, rd_kw_iget_as_double(tran_kw, 207)); } free(init_file_name); free(grid_file_name); - ecl_grid_free(grid); - ecl_file_close(grid_file); - ecl_file_close(init_file); + rd_grid_free(grid); + rd_file_close(grid_file); + rd_file_close(init_file); } -void test_tranLL(const ecl_grid_type *grid, const ecl_file_type *init_file, +void test_tranLL(const rd_grid_type *grid, const rd_file_type *init_file, int lgr_nr1, int lgr_nr2, int size, double first, double last) { - ecl_kw_type *ecl_kw = - ecl_nnc_export_get_tranll_kw(grid, init_file, lgr_nr1, lgr_nr2); + rd_kw_type *rd_kw = + rd_nnc_export_get_tranll_kw(grid, init_file, lgr_nr1, lgr_nr2); printf("lgr: %d -> %d \n", lgr_nr1, lgr_nr2); - test_assert_not_NULL(ecl_kw); - test_assert_true(ecl_kw_is_instance(ecl_kw)); - test_assert_int_equal(size, ecl_kw_get_size(ecl_kw)); - test_assert_double_equal(first, ecl_kw_iget_as_double(ecl_kw, 0)); - test_assert_double_equal(last, ecl_kw_iget_as_double(ecl_kw, size - 1)); + test_assert_not_NULL(rd_kw); + test_assert_true(rd_kw_is_instance(rd_kw)); + test_assert_int_equal(size, rd_kw_get_size(rd_kw)); + test_assert_double_equal(first, rd_kw_iget_as_double(rd_kw, 0)); + test_assert_double_equal(last, rd_kw_iget_as_double(rd_kw, size - 1)); } void test_get_tranLL(const char *name) { char *grid_file_name = - ecl_util_alloc_filename(NULL, name, ECL_EGRID_FILE, false, -1); + rd_alloc_filename(NULL, name, RD_EGRID_FILE, false, -1); char *init_file_name = - ecl_util_alloc_filename(NULL, name, ECL_INIT_FILE, false, -1); - ecl_grid_type *grid = ecl_grid_alloc(grid_file_name); - ecl_file_type *grid_file = ecl_file_open(grid_file_name, 0); - ecl_file_type *init_file = ecl_file_open(init_file_name, 0); - - test_tranLL(grid, init_file, - ecl_grid_get_lgr_nr_from_name(grid, "LG003017"), - ecl_grid_get_lgr_nr_from_name(grid, "LG003018"), 172, 5.3957253, + rd_alloc_filename(NULL, name, RD_INIT_FILE, false, -1); + rd_grid_type *grid = rd_grid_alloc(grid_file_name); + rd_file_type *grid_file = rd_file_open(grid_file_name, 0); + rd_file_type *init_file = rd_file_open(init_file_name, 0); + + test_tranLL(grid, init_file, rd_grid_get_lgr_nr_from_name(grid, "LG003017"), + rd_grid_get_lgr_nr_from_name(grid, "LG003018"), 172, 5.3957253, 1.0099934); - test_tranLL(grid, init_file, - ecl_grid_get_lgr_nr_from_name(grid, "LG002016"), - ecl_grid_get_lgr_nr_from_name(grid, "LG002017"), 93, 1.4638059, + test_tranLL(grid, init_file, rd_grid_get_lgr_nr_from_name(grid, "LG002016"), + rd_grid_get_lgr_nr_from_name(grid, "LG002017"), 93, 1.4638059, 0.36407200); - test_tranLL(grid, init_file, - ecl_grid_get_lgr_nr_from_name(grid, "LG002016"), - ecl_grid_get_lgr_nr_from_name(grid, "LG003016"), 56, 2.7360380, + test_tranLL(grid, init_file, rd_grid_get_lgr_nr_from_name(grid, "LG002016"), + rd_grid_get_lgr_nr_from_name(grid, "LG003016"), 56, 2.7360380, 10.053267); - test_tranLL(grid, init_file, - ecl_grid_get_lgr_nr_from_name(grid, "LG009027"), - ecl_grid_get_lgr_nr_from_name(grid, "LG009026"), 152, 155.47754, + test_tranLL(grid, init_file, rd_grid_get_lgr_nr_from_name(grid, "LG009027"), + rd_grid_get_lgr_nr_from_name(grid, "LG009026"), 152, 155.47754, 219.23553); - test_tranLL(grid, init_file, - ecl_grid_get_lgr_nr_from_name(grid, "LG009027"), - ecl_grid_get_lgr_nr_from_name(grid, "LG008027"), 317, + test_tranLL(grid, init_file, rd_grid_get_lgr_nr_from_name(grid, "LG009027"), + rd_grid_get_lgr_nr_from_name(grid, "LG008027"), 317, 0.040260997, 0.0066288318); free(init_file_name); free(grid_file_name); - ecl_grid_free(grid); - ecl_file_close(grid_file); - ecl_file_close(init_file); + rd_grid_free(grid); + rd_file_close(grid_file); + rd_file_close(init_file); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_nnc_export_intersect.cpp b/lib/resdata/tests/rd_nnc_export_intersect.cpp index 2df6fd17e0..32fb7f7799 100644 --- a/lib/resdata/tests/rd_nnc_export_intersect.cpp +++ b/lib/resdata/tests/rd_nnc_export_intersect.cpp @@ -4,12 +4,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include @@ -20,41 +20,41 @@ const auto GRIDX = 10, GRIDY = 10, GRIDZ = 10; const auto GRID_NNC_NUM = 342; const auto INIT_NNC_NUM = 298; -ERT::ert_unique_ptr make_intersect_grid() { - auto out = ERT::ert_unique_ptr( - ecl_grid_alloc_rectangular(GRIDX, GRIDY, GRIDZ, 1., 1., 1., nullptr)); +ERT::ert_unique_ptr make_intersect_grid() { + auto out = ERT::ert_unique_ptr( + rd_grid_alloc_rectangular(GRIDX, GRIDY, GRIDZ, 1., 1., 1., nullptr)); for (auto i = 0; i < GRID_NNC_NUM; ++i) - ecl_grid_add_self_nnc(out.get(), 2 * i + 1, 2 * i, i); + rd_grid_add_self_nnc(out.get(), 2 * i + 1, 2 * i, i); return out; } -ERT::ert_unique_ptr make_intersect_init_file() { +ERT::ert_unique_ptr make_intersect_init_file() { // Create keywords with useless data - auto nnc1_kw = ecl_kw_alloc(NNC1_KW, INIT_NNC_NUM, ECL_INT); - auto nnc2_kw = ecl_kw_alloc(NNC2_KW, INIT_NNC_NUM, ECL_INT); - auto tran_kw = ecl_kw_alloc(TRANNNC_KW, INIT_NNC_NUM, ECL_DOUBLE); + auto nnc1_kw = rd_kw_alloc(NNC1_KW, INIT_NNC_NUM, RD_INT); + auto nnc2_kw = rd_kw_alloc(NNC2_KW, INIT_NNC_NUM, RD_INT); + auto tran_kw = rd_kw_alloc(TRANNNC_KW, INIT_NNC_NUM, RD_DOUBLE); for (auto i = 0; i < INIT_NNC_NUM; ++i) { - ecl_kw_iset_int(nnc1_kw, i, 2 * i); - ecl_kw_iset_int(nnc2_kw, i, 2 * i + 1); - ecl_kw_iset_double(tran_kw, i, 2.5 * i); + rd_kw_iset_int(nnc1_kw, i, 2 * i); + rd_kw_iset_int(nnc2_kw, i, 2 * i + 1); + rd_kw_iset_double(tran_kw, i, 2.5 * i); } // write to file directly using fortio - auto init_filename = util_alloc_tmp_file( - "/tmp", "ecl_nnc_export_intersect_init_file", false); - auto fortio = fortio_open_writer(init_filename, false, ECL_ENDIAN_FLIP); - ecl_kw_fwrite(nnc1_kw, fortio); - ecl_kw_fwrite(nnc2_kw, fortio); - ecl_kw_fwrite(tran_kw, fortio); + auto init_filename = + util_alloc_tmp_file("/tmp", "rd_nnc_export_intersect_init_file", false); + auto fortio = fortio_open_writer(init_filename, false, RD_ENDIAN_FLIP); + rd_kw_fwrite(nnc1_kw, fortio); + rd_kw_fwrite(nnc2_kw, fortio); + rd_kw_fwrite(tran_kw, fortio); fortio_fclose(fortio); // reopen the file as an ecl file - auto out = ERT::ert_unique_ptr( - ecl_file_open(init_filename, 0)); + auto out = ERT::ert_unique_ptr( + rd_file_open(init_filename, 0)); - ecl_kw_free(nnc1_kw); - ecl_kw_free(nnc2_kw); - ecl_kw_free(tran_kw); + rd_kw_free(nnc1_kw); + rd_kw_free(nnc2_kw); + rd_kw_free(tran_kw); free(init_filename); return out; } @@ -66,14 +66,14 @@ int main(int argc, char **argv) { const auto grid = make_intersect_grid(); const auto init_file = make_intersect_init_file(); - test_assert_true(ecl_nnc_intersect_format(grid.get(), init_file.get())); - test_assert_int_equal(ecl_nnc_export_get_size(grid.get(), init_file.get()), + test_assert_true(rd_nnc_intersect_format(grid.get(), init_file.get())); + test_assert_int_equal(rd_nnc_export_get_size(grid.get(), init_file.get()), INIT_NNC_NUM); - auto nnc_data = std::vector( - ecl_nnc_export_get_size(grid.get(), init_file.get())); + auto nnc_data = std::vector( + rd_nnc_export_get_size(grid.get(), init_file.get())); auto const total_valid_trans = - ecl_nnc_export(grid.get(), init_file.get(), nnc_data.data()); + rd_nnc_export(grid.get(), init_file.get(), nnc_data.data()); test_assert_int_equal(total_valid_trans, INIT_NNC_NUM); test_assert_int_equal(int(nnc_data.size()), INIT_NNC_NUM); diff --git a/lib/resdata/tests/rd_nnc_geometry.cpp b/lib/resdata/tests/rd_nnc_geometry.cpp index 9f90b606f8..fa4a1cdc48 100644 --- a/lib/resdata/tests/rd_nnc_geometry.cpp +++ b/lib/resdata/tests/rd_nnc_geometry.cpp @@ -1,57 +1,57 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include void test_create_empty() { - ecl_grid_type *grid = ecl_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); - ecl_nnc_geometry_type *nnc_geo = ecl_nnc_geometry_alloc(grid); - test_assert_true(ecl_nnc_geometry_is_instance(nnc_geo)); - test_assert_int_equal(ecl_nnc_geometry_size(nnc_geo), 0); - ecl_nnc_geometry_free(nnc_geo); - ecl_grid_free(grid); + rd_grid_type *grid = rd_grid_alloc_rectangular(10, 10, 10, 1, 1, 1, NULL); + rd_nnc_geometry_type *nnc_geo = rd_nnc_geometry_alloc(grid); + test_assert_true(rd_nnc_geometry_is_instance(nnc_geo)); + test_assert_int_equal(rd_nnc_geometry_size(nnc_geo), 0); + rd_nnc_geometry_free(nnc_geo); + rd_grid_free(grid); } void test_create_simple() { - ecl::util::TestArea ta("nnc_geometry"); + rd::util::TestArea ta("nnc_geometry"); { int nx = 10; int ny = 10; int nz = 10; - ecl_grid_type *grid0 = - ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); + rd_grid_type *grid0 = + rd_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); - ecl_grid_add_self_nnc(grid0, 0, nx * ny + 0, 0); - ecl_grid_add_self_nnc(grid0, 1, nx * ny + 1, 1); - ecl_grid_add_self_nnc(grid0, 2, nx * ny + 2, 2); + rd_grid_add_self_nnc(grid0, 0, nx * ny + 0, 0); + rd_grid_add_self_nnc(grid0, 1, nx * ny + 1, 1); + rd_grid_add_self_nnc(grid0, 2, nx * ny + 2, 2); { - ecl_nnc_geometry_type *nnc_geo = ecl_nnc_geometry_alloc(grid0); - test_assert_int_equal(ecl_nnc_geometry_size(nnc_geo), 3); + rd_nnc_geometry_type *nnc_geo = rd_nnc_geometry_alloc(grid0); + test_assert_int_equal(rd_nnc_geometry_size(nnc_geo), 3); /* Create a dummy INIT file which *ony* contains a TRANNC keyword with the correct size. */ { - ecl_kw_type *trann_nnc = ecl_kw_alloc( - TRANNNC_KW, ecl_nnc_geometry_size(nnc_geo), ECL_FLOAT); + rd_kw_type *trann_nnc = rd_kw_alloc( + TRANNNC_KW, rd_nnc_geometry_size(nnc_geo), RD_FLOAT); fortio_type *f = - fortio_open_writer("TEST.INIT", false, ECL_ENDIAN_FLIP); + fortio_open_writer("TEST.INIT", false, RD_ENDIAN_FLIP); - for (int i = 0; i < ecl_kw_get_size(trann_nnc); i++) - ecl_kw_iset_float(trann_nnc, i, i * 1.0); + for (int i = 0; i < rd_kw_get_size(trann_nnc); i++) + rd_kw_iset_float(trann_nnc, i, i * 1.0); - ecl_kw_fwrite(trann_nnc, f); + rd_kw_fwrite(trann_nnc, f); fortio_fclose(f); - ecl_kw_free(trann_nnc); + rd_kw_free(trann_nnc); } - ecl_nnc_geometry_free(nnc_geo); + rd_nnc_geometry_free(nnc_geo); } - ecl_grid_free(grid0); + rd_grid_free(grid0); } } diff --git a/lib/resdata/tests/rd_nnc_index_list.cpp b/lib/resdata/tests/rd_nnc_index_list.cpp index 4ec6aa906f..0f49f48f96 100644 --- a/lib/resdata/tests/rd_nnc_index_list.cpp +++ b/lib/resdata/tests/rd_nnc_index_list.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include void test_create() { nnc_index_list_type *index_list = nnc_index_list_alloc(); diff --git a/lib/resdata/tests/rd_nnc_index_list_grid.cpp b/lib/resdata/tests/rd_nnc_index_list_grid.cpp index ef1a4129d7..6ec6ffd4f7 100644 --- a/lib/resdata/tests/rd_nnc_index_list_grid.cpp +++ b/lib/resdata/tests/rd_nnc_index_list_grid.cpp @@ -5,26 +5,26 @@ #include #include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { const char *egrid_file = argv[1]; - ecl_grid_type *grid = ecl_grid_alloc(egrid_file); - ecl_file_type *gfile = ecl_file_open(egrid_file, 0); - const ecl_kw_type *nnc1_kw = ecl_file_iget_named_kw(gfile, "NNC1", 0); - const ecl_kw_type *nnc2_kw = ecl_file_iget_named_kw(gfile, "NNC2", 0); - const int_vector_type *index_list = ecl_grid_get_nnc_index_list(grid); + rd_grid_type *grid = rd_grid_alloc(egrid_file); + rd_file_type *gfile = rd_file_open(egrid_file, 0); + const rd_kw_type *nnc1_kw = rd_file_iget_named_kw(gfile, "NNC1", 0); + const rd_kw_type *nnc2_kw = rd_file_iget_named_kw(gfile, "NNC2", 0); + const int_vector_type *index_list = rd_grid_get_nnc_index_list(grid); { int_vector_type *nnc = int_vector_alloc(0, 0); - int_vector_set_many(nnc, 0, ecl_kw_get_ptr(nnc1_kw), - ecl_kw_get_size(nnc1_kw)); - int_vector_append_many(nnc, ecl_kw_get_ptr(nnc2_kw), - ecl_kw_get_size(nnc2_kw)); + int_vector_set_many(nnc, 0, rd_kw_get_ptr(nnc1_kw), + rd_kw_get_size(nnc1_kw)); + int_vector_append_many(nnc, rd_kw_get_ptr(nnc2_kw), + rd_kw_get_size(nnc2_kw)); int_vector_select_unique(nnc); test_assert_int_equal(int_vector_size(index_list), int_vector_size(nnc)); @@ -38,8 +38,8 @@ int main(int argc, char **argv) { int_vector_free(nnc); } - ecl_file_close(gfile); - ecl_grid_free(grid); + rd_file_close(gfile); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_nnc_info_test.cpp b/lib/resdata/tests/rd_nnc_info_test.cpp index 02dc6ce600..085f1f1a0b 100644 --- a/lib/resdata/tests/rd_nnc_info_test.cpp +++ b/lib/resdata/tests/rd_nnc_info_test.cpp @@ -7,10 +7,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include void test_equal() { diff --git a/lib/resdata/tests/rd_nnc_pair.cpp b/lib/resdata/tests/rd_nnc_pair.cpp index 1811ca785c..f8f0f39e9d 100644 --- a/lib/resdata/tests/rd_nnc_pair.cpp +++ b/lib/resdata/tests/rd_nnc_pair.cpp @@ -4,14 +4,14 @@ #include #include -#include +#include void test_pair(int grid1_1, int grid1_2, int grid2_1, int grid2_2, bool expected) { - ecl_nnc_pair_type pair1 = {grid1_1, grid1_2, 0, 0}; - ecl_nnc_pair_type pair2 = {grid2_1, grid2_2, 0, 0}; + rd_nnc_pair_type pair1 = {grid1_1, grid1_2, 0, 0}; + rd_nnc_pair_type pair2 = {grid2_1, grid2_2, 0, 0}; - test_assert_bool_equal(ecl_nnc_geometry_same_kw(&pair1, &pair2), expected); + test_assert_bool_equal(rd_nnc_geometry_same_kw(&pair1, &pair2), expected); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_nnc_test.cpp b/lib/resdata/tests/rd_nnc_test.cpp index fc78698d4a..db8b29cd85 100644 --- a/lib/resdata/tests/rd_nnc_test.cpp +++ b/lib/resdata/tests/rd_nnc_test.cpp @@ -8,46 +8,46 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void test_scan(const char *grid_filename) { - ecl_grid_type *ecl_grid = ecl_grid_alloc(grid_filename); - ecl_file_type *grid_file = ecl_file_open(grid_filename, 0); + rd_grid_type *rd_grid = rd_grid_alloc(grid_filename); + rd_file_type *grid_file = rd_file_open(grid_filename, 0); int block_nr; for (block_nr = 0; - block_nr < ecl_file_get_num_named_kw(grid_file, NNCHEAD_KW); + block_nr < rd_file_get_num_named_kw(grid_file, NNCHEAD_KW); block_nr++) { - ecl_grid_type *lgr = ecl_grid; + rd_grid_type *lgr = rd_grid; int lgr_nr; - ecl_file_view_type *nnc_view = - ecl_file_alloc_global_blockview(grid_file, NNCHEAD_KW, block_nr); + rd_file_view_type *nnc_view = + rd_file_alloc_global_blockview(grid_file, NNCHEAD_KW, block_nr); { if (block_nr > 0) - lgr = ecl_grid_iget_lgr(ecl_grid, block_nr - 1); - lgr_nr = ecl_grid_get_lgr_nr(lgr); + lgr = rd_grid_iget_lgr(rd_grid, block_nr - 1); + lgr_nr = rd_grid_get_lgr_nr(lgr); /* Internal nnc */ { - if (ecl_file_view_has_kw(nnc_view, NNC1_KW)) { - ecl_kw_type *nnc1_kw = - ecl_file_view_iget_named_kw(nnc_view, NNC1_KW, 0); - ecl_kw_type *nnc2_kw = - ecl_file_view_iget_named_kw(nnc_view, NNC2_KW, 0); + if (rd_file_view_has_kw(nnc_view, NNC1_KW)) { + rd_kw_type *nnc1_kw = + rd_file_view_iget_named_kw(nnc_view, NNC1_KW, 0); + rd_kw_type *nnc2_kw = + rd_file_view_iget_named_kw(nnc_view, NNC2_KW, 0); int i; - for (i = 0; i < ecl_kw_get_size(nnc1_kw); i++) { - const int g1 = ecl_kw_iget_int(nnc1_kw, i) - 1; - const int g2 = ecl_kw_iget_int(nnc2_kw, i) - 1; + for (i = 0; i < rd_kw_get_size(nnc1_kw); i++) { + const int g1 = rd_kw_iget_int(nnc1_kw, i) - 1; + const int g2 = rd_kw_iget_int(nnc2_kw, i) - 1; if (g2 < - ecl_grid_get_global_size( + rd_grid_get_global_size( lgr)) { // Skipping matrix <-> fracture link in dual poro. const nnc_info_type *nnc_info = - ecl_grid_get_cell_nnc_info1(lgr, g1); + rd_grid_get_cell_nnc_info1(lgr, g1); const std::vector &index_list = nnc_info_get_grid_index_list(nnc_info, lgr_nr); test_assert_not_NULL(nnc_info); @@ -61,21 +61,21 @@ void test_scan(const char *grid_filename) { /* Global -> lgr */ { - if (ecl_file_view_has_kw(nnc_view, NNCG_KW)) { - ecl_kw_type *nnchead_kw = - ecl_file_view_iget_named_kw(nnc_view, NNCHEAD_KW, 0); - ecl_kw_type *nncg_kw = - ecl_file_view_iget_named_kw(nnc_view, NNCG_KW, 0); - ecl_kw_type *nncl_kw = - ecl_file_view_iget_named_kw(nnc_view, NNCL_KW, 0); + if (rd_file_view_has_kw(nnc_view, NNCG_KW)) { + rd_kw_type *nnchead_kw = + rd_file_view_iget_named_kw(nnc_view, NNCHEAD_KW, 0); + rd_kw_type *nncg_kw = + rd_file_view_iget_named_kw(nnc_view, NNCG_KW, 0); + rd_kw_type *nncl_kw = + rd_file_view_iget_named_kw(nnc_view, NNCL_KW, 0); int i; - int lgr_nr = ecl_kw_iget_int(nnchead_kw, NNCHEAD_LGR_INDEX); - for (i = 0; i < ecl_kw_get_size(nncg_kw); i++) { - const int g = ecl_kw_iget_int(nncg_kw, i) - 1; - const int l = ecl_kw_iget_int(nncl_kw, i) - 1; + int lgr_nr = rd_kw_iget_int(nnchead_kw, NNCHEAD_LGR_INDEX); + for (i = 0; i < rd_kw_get_size(nncg_kw); i++) { + const int g = rd_kw_iget_int(nncg_kw, i) - 1; + const int l = rd_kw_iget_int(nncl_kw, i) - 1; const nnc_info_type *nnc_info = - ecl_grid_get_cell_nnc_info1(ecl_grid, g); + rd_grid_get_cell_nnc_info1(rd_grid, g); test_assert_not_NULL(nnc_info); { const std::vector &index_list = @@ -91,26 +91,24 @@ void test_scan(const char *grid_filename) { /* Amalgamated: LGR -> LGR */ { - if (ecl_file_view_has_kw(nnc_view, NNCHEADA_KW)) { - ecl_kw_type *nncheada_kw = - ecl_file_view_iget_named_kw(nnc_view, NNCHEADA_KW, 0); - ecl_kw_type *nnc1_kw = - ecl_file_view_iget_named_kw(nnc_view, NNA1_KW, 0); - ecl_kw_type *nnc2_kw = - ecl_file_view_iget_named_kw(nnc_view, NNA2_KW, 0); - int lgr_nr1 = - ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX); - int lgr_nr2 = - ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX); + if (rd_file_view_has_kw(nnc_view, NNCHEADA_KW)) { + rd_kw_type *nncheada_kw = + rd_file_view_iget_named_kw(nnc_view, NNCHEADA_KW, 0); + rd_kw_type *nnc1_kw = + rd_file_view_iget_named_kw(nnc_view, NNA1_KW, 0); + rd_kw_type *nnc2_kw = + rd_file_view_iget_named_kw(nnc_view, NNA2_KW, 0); + int lgr_nr1 = rd_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX); + int lgr_nr2 = rd_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX); - ecl_grid_type *lgr1 = - ecl_grid_get_lgr_from_lgr_nr(ecl_grid, lgr_nr1); - for (int i = 0; i < ecl_kw_get_size(nnc1_kw); i++) { - const int g1 = ecl_kw_iget_int(nnc1_kw, i) - 1; - const int g2 = ecl_kw_iget_int(nnc2_kw, i) - 1; + rd_grid_type *lgr1 = + rd_grid_get_lgr_from_lgr_nr(rd_grid, lgr_nr1); + for (int i = 0; i < rd_kw_get_size(nnc1_kw); i++) { + const int g1 = rd_kw_iget_int(nnc1_kw, i) - 1; + const int g2 = rd_kw_iget_int(nnc2_kw, i) - 1; const nnc_info_type *nnc_info = - ecl_grid_get_cell_nnc_info1(lgr1, g1); + rd_grid_get_cell_nnc_info1(lgr1, g1); const std::vector &index_list = nnc_info_get_grid_index_list(nnc_info, lgr_nr2); test_assert_not_NULL(nnc_info); @@ -120,7 +118,7 @@ void test_scan(const char *grid_filename) { } } - ecl_file_view_free(nnc_view); + rd_file_view_free(nnc_view); } } diff --git a/lib/resdata/tests/rd_nnc_vector.cpp b/lib/resdata/tests/rd_nnc_vector.cpp index d7085cebdc..5a3595ceab 100644 --- a/lib/resdata/tests/rd_nnc_vector.cpp +++ b/lib/resdata/tests/rd_nnc_vector.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include void test_basic() { int lgr_nr = 100; diff --git a/lib/resdata/tests/rd_region.cpp b/lib/resdata/tests/rd_region.cpp index 0b6cc32ae1..6447b8d657 100644 --- a/lib/resdata/tests/rd_region.cpp +++ b/lib/resdata/tests/rd_region.cpp @@ -3,47 +3,47 @@ #include -#include -#include +#include +#include -void test_list(int volume, int nactive, ecl_region_type *region) { +void test_list(int volume, int nactive, rd_region_type *region) { const int_vector_type *active_list; const int_vector_type *global_list; - active_list = ecl_region_get_active_list(region); - global_list = ecl_region_get_global_list(region); + active_list = rd_region_get_active_list(region); + global_list = rd_region_get_global_list(region); test_assert_int_equal(nactive, int_vector_size(active_list)); test_assert_int_equal(volume, int_vector_size(global_list)); - ecl_region_deselect_all(region); - active_list = ecl_region_get_active_list(region); - global_list = ecl_region_get_global_list(region); + rd_region_deselect_all(region); + active_list = rd_region_get_active_list(region); + global_list = rd_region_get_global_list(region); test_assert_int_equal(0, int_vector_size(active_list)); test_assert_int_equal(0, int_vector_size(global_list)); } -void test_slice(const ecl_grid_type *grid) { - int nx = ecl_grid_get_nx(grid); - int ny = ecl_grid_get_ny(grid); - int nz = ecl_grid_get_nz(grid); - int nactive = ecl_grid_get_nactive(grid); - ecl_region_type *region = ecl_region_alloc(grid, false); +void test_slice(const rd_grid_type *grid) { + int nx = rd_grid_get_nx(grid); + int ny = rd_grid_get_ny(grid); + int nz = rd_grid_get_nz(grid); + int nactive = rd_grid_get_nactive(grid); + rd_region_type *region = rd_region_alloc(grid, false); - ecl_region_select_i1i2(region, 0, nx - 1); + rd_region_select_i1i2(region, 0, nx - 1); test_list(nx * ny * nz, nactive, region); - ecl_region_select_j1j2(region, 0, ny - 1); + rd_region_select_j1j2(region, 0, ny - 1); test_list(nx * ny * nz, nactive, region); - ecl_region_select_k1k2(region, 0, nz - 1); + rd_region_select_k1k2(region, 0, nz - 1); test_list(nx * ny * nz, nactive, region); - ecl_region_free(region); + rd_region_free(region); } int main(int argc, char **argv) { const char *grid_file = argv[1]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); + rd_grid_type *grid = rd_grid_alloc(grid_file); test_slice(grid); - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/rd_region2region.cpp b/lib/resdata/tests/rd_region2region.cpp index a710a7e0c0..87bb979ef7 100644 --- a/lib/resdata/tests/rd_region2region.cpp +++ b/lib/resdata/tests/rd_region2region.cpp @@ -2,52 +2,52 @@ #include #include -#include - -void has_r2r_key(const ecl_sum_type *ecl_sum) { - test_assert_true(ecl_sum_has_key(ecl_sum, "RGF:393217")); - test_assert_true(ecl_sum_has_key(ecl_sum, "RGF:1-2")); - test_assert_true(ecl_sum_has_key(ecl_sum, "ROF:524291")); - test_assert_true(ecl_sum_has_key(ecl_sum, "RWF:393222")); - test_assert_true(ecl_sum_has_key(ecl_sum, "RWF:6-2")); - test_assert_true(ecl_sum_has_key(ecl_sum, "ROF:3-6")); - test_assert_true(ecl_sum_has_key(ecl_sum, "RNLF:458753")); - test_assert_true(ecl_sum_has_key(ecl_sum, "RNLF:1-4")); +#include + +void has_r2r_key(const rd_sum_type *rd_sum) { + test_assert_true(rd_sum_has_key(rd_sum, "RGF:393217")); + test_assert_true(rd_sum_has_key(rd_sum, "RGF:1-2")); + test_assert_true(rd_sum_has_key(rd_sum, "ROF:524291")); + test_assert_true(rd_sum_has_key(rd_sum, "RWF:393222")); + test_assert_true(rd_sum_has_key(rd_sum, "RWF:6-2")); + test_assert_true(rd_sum_has_key(rd_sum, "ROF:3-6")); + test_assert_true(rd_sum_has_key(rd_sum, "RNLF:458753")); + test_assert_true(rd_sum_has_key(rd_sum, "RNLF:1-4")); } -void get_unit(const ecl_sum_type *ecl_sum) { - test_assert_string_equal(ecl_sum_get_unit(ecl_sum, "RGF:1-2"), "GFLOW"); - test_assert_string_equal(ecl_sum_get_unit(ecl_sum, "ROF:3-6"), "OFLOW"); - test_assert_string_equal(ecl_sum_get_unit(ecl_sum, "RWF:6-2"), "WFLOW"); - test_assert_string_equal(ecl_sum_get_unit(ecl_sum, "RNLF:1-4"), "NLFLOW"); +void get_unit(const rd_sum_type *rd_sum) { + test_assert_string_equal(rd_sum_get_unit(rd_sum, "RGF:1-2"), "GFLOW"); + test_assert_string_equal(rd_sum_get_unit(rd_sum, "ROF:3-6"), "OFLOW"); + test_assert_string_equal(rd_sum_get_unit(rd_sum, "RWF:6-2"), "WFLOW"); + test_assert_string_equal(rd_sum_get_unit(rd_sum, "RNLF:1-4"), "NLFLOW"); } -void get_var_params_index(const ecl_sum_type *ecl_sum) { +void get_var_params_index(const rd_sum_type *rd_sum) { test_assert_int_equal( - ecl_sum_get_general_var_params_index(ecl_sum, "RGF:1-2"), 21917); + rd_sum_get_general_var_params_index(rd_sum, "RGF:1-2"), 21917); test_assert_int_equal( - ecl_sum_get_general_var_params_index(ecl_sum, "ROF:3-6"), 21918); + rd_sum_get_general_var_params_index(rd_sum, "ROF:3-6"), 21918); test_assert_int_equal( - ecl_sum_get_general_var_params_index(ecl_sum, "RWF:6-2"), 21919); + rd_sum_get_general_var_params_index(rd_sum, "RWF:6-2"), 21919); test_assert_int_equal( - ecl_sum_get_general_var_params_index(ecl_sum, "RNLF:1-4"), 21920); + rd_sum_get_general_var_params_index(rd_sum, "RNLF:1-4"), 21920); } int main(int argc, char **argv) { const char *headerfile = argv[1]; - ecl_sum_type *ecl_sum = ecl_sum_fread_alloc_case(headerfile, ":"); + rd_sum_type *rd_sum = rd_sum_fread_alloc_case(headerfile, ":"); - if (ecl_sum) { - has_r2r_key(ecl_sum); - get_unit(ecl_sum); - get_var_params_index(ecl_sum); + if (rd_sum) { + has_r2r_key(rd_sum); + get_unit(rd_sum); + get_var_params_index(rd_sum); } else - test_error_exit("ecl_region2region_test: Test file not read correctly"); + test_error_exit("rd_region2region_test: Test file not read correctly"); - if (ecl_sum) - ecl_sum_free(ecl_sum); + if (rd_sum) + rd_sum_free(rd_sum); exit(0); } diff --git a/lib/resdata/tests/rd_restart_test.cpp b/lib/resdata/tests/rd_restart_test.cpp index d590f79e6f..b8d669d89a 100644 --- a/lib/resdata/tests/rd_restart_test.cpp +++ b/lib/resdata/tests/rd_restart_test.cpp @@ -3,12 +3,12 @@ #include -#include +#include -bool test_get(ecl_file_type *rst_file, int day, int month, int year, +bool test_get(rd_file_type *rst_file, int day, int month, int year, int expected_index) { - time_t sim_time = ecl_util_make_date(day, month, year); - int seqnum_index = ecl_file_get_restart_index(rst_file, sim_time); + time_t sim_time = rd_make_date(day, month, year); + int seqnum_index = rd_file_get_restart_index(rst_file, sim_time); if (seqnum_index == expected_index) return true; else { @@ -22,7 +22,7 @@ int main(int argc, char **argv) { bool OK = true; const char *unrst_file = argv[1]; - ecl_file_type *rst_file = ecl_file_open(unrst_file, 0); + rd_file_type *rst_file = rd_file_open(unrst_file, 0); OK = OK && test_get(rst_file, 1, 1, 1998, -1); OK = OK && test_get(rst_file, 17, 9, 2003, -1); diff --git a/lib/resdata/tests/rd_rft.cpp b/lib/resdata/tests/rd_rft.cpp index 1394024852..c2790112aa 100644 --- a/lib/resdata/tests/rd_rft.cpp +++ b/lib/resdata/tests/rd_rft.cpp @@ -5,139 +5,137 @@ #include #include -#include +#include #include #include #include -#include +#include void test_rft_read_write(const char *rft_file) { - ecl_rft_file_type *rft = ecl_rft_file_alloc(rft_file); - ecl_rft_node_type **nodes = - (ecl_rft_node_type **)malloc(sizeof(ecl_rft_node_type *) * 3); - int size = ecl_rft_file_get_size(rft); + rd_rft_file_type *rft = rd_rft_file_alloc(rft_file); + rd_rft_node_type **nodes = + (rd_rft_node_type **)malloc(sizeof(rd_rft_node_type *) * 3); + int size = rd_rft_file_get_size(rft); for (int i = 0; i < size; i++) { - ecl_rft_node_type *rft_node = ecl_rft_file_iget_node(rft, i); + rd_rft_node_type *rft_node = rd_rft_file_iget_node(rft, i); nodes[i] = rft_node; } - ecl_rft_node_type *old_node = ecl_rft_file_iget_node(rft, 0); - ecl_rft_node_type *new_node = - ecl_rft_node_alloc_new("DUMMY", "R", ecl_rft_node_get_date(old_node), - ecl_rft_node_get_days(old_node)); + rd_rft_node_type *old_node = rd_rft_file_iget_node(rft, 0); + rd_rft_node_type *new_node = + rd_rft_node_alloc_new("DUMMY", "R", rd_rft_node_get_date(old_node), + rd_rft_node_get_days(old_node)); nodes[2] = new_node; - ecl::util::TestArea ta("rft"); + rd::util::TestArea ta("rft"); - ecl_rft_file_update("eclipse.rft", nodes, 3, ECL_METRIC_UNITS); + rd_rft_file_update("eclipse.rft", nodes, 3, RD_METRIC_UNITS); free(nodes); } // Hardcoded GURBAT values void test_rft(const char *rft_file) { - ecl_rft_file_type *rft = ecl_rft_file_alloc(rft_file); - ecl_rft_node_type *rft_node = ecl_rft_file_iget_node(rft, 0); + rd_rft_file_type *rft = rd_rft_file_alloc(rft_file); + rd_rft_node_type *rft_node = rd_rft_file_iget_node(rft, 0); - test_assert_true(ecl_rft_node_is_RFT(rft_node)); - test_assert_int_equal(14, ecl_rft_node_get_size(rft_node)); - test_assert_false(ecl_rft_node_is_MSW(rft_node)); + test_assert_true(rd_rft_node_is_RFT(rft_node)); + test_assert_int_equal(14, rd_rft_node_get_size(rft_node)); + test_assert_false(rd_rft_node_is_MSW(rft_node)); - test_assert_double_equal(260.6111, ecl_rft_node_iget_pressure(rft_node, 0)); - test_assert_double_equal(0.0581993, ecl_rft_node_iget_soil(rft_node, 0)); - test_assert_double_equal(0.9405648, ecl_rft_node_iget_swat(rft_node, 0)); - test_assert_double_equal(0.00123579, ecl_rft_node_iget_sgas(rft_node, 0)); + test_assert_double_equal(260.6111, rd_rft_node_iget_pressure(rft_node, 0)); + test_assert_double_equal(0.0581993, rd_rft_node_iget_soil(rft_node, 0)); + test_assert_double_equal(0.9405648, rd_rft_node_iget_swat(rft_node, 0)); + test_assert_double_equal(0.00123579, rd_rft_node_iget_sgas(rft_node, 0)); { int i, j, k; - ecl_rft_node_iget_ijk(rft_node, 0, &i, &j, &k); + rd_rft_node_iget_ijk(rft_node, 0, &i, &j, &k); test_assert_int_equal(32, i); test_assert_int_equal(53, j); test_assert_int_equal(0, k); - ecl_rft_node_iget_ijk(rft_node, 13, &i, &j, &k); + rd_rft_node_iget_ijk(rft_node, 13, &i, &j, &k); test_assert_int_equal(32, i); test_assert_int_equal(54, j); test_assert_int_equal(12, k); - for (i = 0; i < ecl_rft_node_get_size(rft_node); i++) { - const ecl_rft_cell_type *cell1 = - ecl_rft_node_iget_cell(rft_node, i); - const ecl_rft_cell_type *cell2 = - ecl_rft_node_iget_cell_sorted(rft_node, i); + for (i = 0; i < rd_rft_node_get_size(rft_node); i++) { + const rd_rft_cell_type *cell1 = rd_rft_node_iget_cell(rft_node, i); + const rd_rft_cell_type *cell2 = + rd_rft_node_iget_cell_sorted(rft_node, i); test_assert_ptr_equal(cell1, cell2); } } - ecl_rft_file_free(rft); + rd_rft_file_free(rft); } void test_plt_msw(const char *plt_file) { - ecl_rft_file_type *plt = ecl_rft_file_alloc(plt_file); - ecl_rft_node_type *plt_node = ecl_rft_file_iget_node(plt, 11); + rd_rft_file_type *plt = rd_rft_file_alloc(plt_file); + rd_rft_node_type *plt_node = rd_rft_file_iget_node(plt, 11); - test_assert_true(ecl_rft_node_is_PLT(plt_node)); - test_assert_true(ecl_rft_node_is_MSW(plt_node)); - test_assert_int_equal(22, ecl_rft_node_get_size(plt_node)); + test_assert_true(rd_rft_node_is_PLT(plt_node)); + test_assert_true(rd_rft_node_is_MSW(plt_node)); + test_assert_int_equal(22, rd_rft_node_get_size(plt_node)); { int i; - for (i = 1; i < ecl_rft_node_get_size(plt_node); i++) { - const ecl_rft_cell_type *prev_cell = - ecl_rft_node_iget_cell(plt_node, i - 1); - const ecl_rft_cell_type *this_cell = - ecl_rft_node_iget_cell(plt_node, i); - - test_assert_true(ecl_rft_cell_get_connection_start(prev_cell) < - ecl_rft_cell_get_connection_start(this_cell)); - test_assert_true(ecl_rft_cell_get_connection_end(prev_cell) < - ecl_rft_cell_get_connection_end(this_cell)); + for (i = 1; i < rd_rft_node_get_size(plt_node); i++) { + const rd_rft_cell_type *prev_cell = + rd_rft_node_iget_cell(plt_node, i - 1); + const rd_rft_cell_type *this_cell = + rd_rft_node_iget_cell(plt_node, i); + + test_assert_true(rd_rft_cell_get_connection_start(prev_cell) < + rd_rft_cell_get_connection_start(this_cell)); + test_assert_true(rd_rft_cell_get_connection_end(prev_cell) < + rd_rft_cell_get_connection_end(this_cell)); } } - ecl_rft_file_free(plt); + rd_rft_file_free(plt); } // Hardcoded values from a test case with a PLT. void test_plt(const char *plt_file) { - ecl_rft_file_type *plt = ecl_rft_file_alloc(plt_file); - ecl_rft_node_type *plt_node = ecl_rft_file_iget_node(plt, 11); + rd_rft_file_type *plt = rd_rft_file_alloc(plt_file); + rd_rft_node_type *plt_node = rd_rft_file_iget_node(plt, 11); - test_assert_true(ecl_rft_node_is_PLT(plt_node)); - test_assert_false(ecl_rft_node_is_MSW(plt_node)); - test_assert_int_equal(22, ecl_rft_node_get_size(plt_node)); + test_assert_true(rd_rft_node_is_PLT(plt_node)); + test_assert_false(rd_rft_node_is_MSW(plt_node)); + test_assert_int_equal(22, rd_rft_node_get_size(plt_node)); - test_assert_double_equal(244.284, ecl_rft_node_iget_pressure(plt_node, 0)); - test_assert_double_equal(167.473, ecl_rft_node_iget_orat(plt_node, 0)); - test_assert_double_equal(41682.2, ecl_rft_node_iget_grat(plt_node, 0)); - test_assert_double_equal(0.958927, ecl_rft_node_iget_wrat(plt_node, 0)); + test_assert_double_equal(244.284, rd_rft_node_iget_pressure(plt_node, 0)); + test_assert_double_equal(167.473, rd_rft_node_iget_orat(plt_node, 0)); + test_assert_double_equal(41682.2, rd_rft_node_iget_grat(plt_node, 0)); + test_assert_double_equal(0.958927, rd_rft_node_iget_wrat(plt_node, 0)); { int i, j, k; - ecl_rft_node_iget_ijk(plt_node, 0, &i, &j, &k); + rd_rft_node_iget_ijk(plt_node, 0, &i, &j, &k); test_assert_int_equal(39, i); test_assert_int_equal(33, j); test_assert_int_equal(16, k); - ecl_rft_node_iget_ijk(plt_node, 21, &i, &j, &k); + rd_rft_node_iget_ijk(plt_node, 21, &i, &j, &k); test_assert_int_equal(44, i); test_assert_int_equal(34, j); test_assert_int_equal(7, k); - for (i = 0; i < ecl_rft_node_get_size(plt_node); i++) { - const ecl_rft_cell_type *cell1 = - ecl_rft_node_iget_cell(plt_node, i); - const ecl_rft_cell_type *cell2 = - ecl_rft_node_iget_cell_sorted(plt_node, i); + for (i = 0; i < rd_rft_node_get_size(plt_node); i++) { + const rd_rft_cell_type *cell1 = rd_rft_node_iget_cell(plt_node, i); + const rd_rft_cell_type *cell2 = + rd_rft_node_iget_cell_sorted(plt_node, i); test_assert_ptr_equal(cell1, cell2); } } - ecl_rft_file_free(plt); + rd_rft_file_free(plt); } void test_simple_load_rft(const char *filename) { - ecl_rft_file_type *rft_file = ecl_rft_file_alloc_case(filename); - ecl_rft_file_free(rft_file); + rd_rft_file_type *rft_file = rd_rft_file_alloc_case(filename); + rd_rft_file_free(rft_file); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_rft_cell.cpp b/lib/resdata/tests/rd_rft_cell.cpp index 80f2f122b1..c4a37afba8 100644 --- a/lib/resdata/tests/rd_rft_cell.cpp +++ b/lib/resdata/tests/rd_rft_cell.cpp @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include void test_rft_cell() { const int i = 10; @@ -18,55 +18,55 @@ void test_rft_cell() { const double swat = 0.25; const double sgas = 0.35; - ecl_rft_cell_type *cell = - ecl_rft_cell_alloc_RFT(i, j, k, depth, pressure, swat, sgas); + rd_rft_cell_type *cell = + rd_rft_cell_alloc_RFT(i, j, k, depth, pressure, swat, sgas); - test_assert_int_equal(i, ecl_rft_cell_get_i(cell)); - test_assert_int_equal(j, ecl_rft_cell_get_j(cell)); - test_assert_int_equal(k, ecl_rft_cell_get_k(cell)); + test_assert_int_equal(i, rd_rft_cell_get_i(cell)); + test_assert_int_equal(j, rd_rft_cell_get_j(cell)); + test_assert_int_equal(k, rd_rft_cell_get_k(cell)); { int ii, jj, kk; - ecl_rft_cell_get_ijk(cell, &ii, &jj, &kk); + rd_rft_cell_get_ijk(cell, &ii, &jj, &kk); test_assert_int_equal(i, ii); test_assert_int_equal(j, jj); test_assert_int_equal(k, kk); } - test_assert_double_equal(depth, ecl_rft_cell_get_depth(cell)); - test_assert_double_equal(pressure, ecl_rft_cell_get_pressure(cell)); - test_assert_double_equal(swat, ecl_rft_cell_get_swat(cell)); - test_assert_double_equal(sgas, ecl_rft_cell_get_sgas(cell)); - test_assert_double_equal(1 - (swat + sgas), ecl_rft_cell_get_soil(cell)); - - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_orat(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_grat(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_wrat(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_flowrate(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_connection_start(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_connection_end(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_oil_flowrate(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_gas_flowrate(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_water_flowrate(cell)); - - ecl_rft_cell_free(cell); + test_assert_double_equal(depth, rd_rft_cell_get_depth(cell)); + test_assert_double_equal(pressure, rd_rft_cell_get_pressure(cell)); + test_assert_double_equal(swat, rd_rft_cell_get_swat(cell)); + test_assert_double_equal(sgas, rd_rft_cell_get_sgas(cell)); + test_assert_double_equal(1 - (swat + sgas), rd_rft_cell_get_soil(cell)); + + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_orat(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_grat(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_wrat(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_flowrate(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_connection_start(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_connection_end(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_oil_flowrate(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_gas_flowrate(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_water_flowrate(cell)); + + rd_rft_cell_free(cell); { - ecl_rft_cell_type *cell = - ecl_rft_cell_alloc_RFT(i, j, k, depth, pressure, swat, sgas); + rd_rft_cell_type *cell = + rd_rft_cell_alloc_RFT(i, j, k, depth, pressure, swat, sgas); - test_assert_true(ecl_rft_cell_ijk_equal(cell, i, j, k)); - test_assert_false(ecl_rft_cell_ijk_equal(cell, i, j, k + 1)); + test_assert_true(rd_rft_cell_ijk_equal(cell, i, j, k)); + test_assert_false(rd_rft_cell_ijk_equal(cell, i, j, k + 1)); - ecl_rft_cell_free__(cell); + rd_rft_cell_free__(cell); } } @@ -87,47 +87,47 @@ void test_plt_cell() { const double gas_flowrate = 7771; const double water_flowrate = 77614; - ecl_rft_cell_type *cell = ecl_rft_cell_alloc_PLT( + rd_rft_cell_type *cell = rd_rft_cell_alloc_PLT( i, j, k, depth, pressure, orat, grat, wrat, connection_start, connection_end, flowrate, oil_flowrate, gas_flowrate, water_flowrate); - test_assert_int_equal(i, ecl_rft_cell_get_i(cell)); - test_assert_int_equal(j, ecl_rft_cell_get_j(cell)); - test_assert_int_equal(k, ecl_rft_cell_get_k(cell)); + test_assert_int_equal(i, rd_rft_cell_get_i(cell)); + test_assert_int_equal(j, rd_rft_cell_get_j(cell)); + test_assert_int_equal(k, rd_rft_cell_get_k(cell)); { int ii, jj, kk; - ecl_rft_cell_get_ijk(cell, &ii, &jj, &kk); + rd_rft_cell_get_ijk(cell, &ii, &jj, &kk); test_assert_int_equal(i, ii); test_assert_int_equal(j, jj); test_assert_int_equal(k, kk); } - test_assert_double_equal(depth, ecl_rft_cell_get_depth(cell)); - test_assert_double_equal(pressure, ecl_rft_cell_get_pressure(cell)); + test_assert_double_equal(depth, rd_rft_cell_get_depth(cell)); + test_assert_double_equal(pressure, rd_rft_cell_get_pressure(cell)); - test_assert_double_equal(orat, ecl_rft_cell_get_orat(cell)); - test_assert_double_equal(grat, ecl_rft_cell_get_grat(cell)); - test_assert_double_equal(wrat, ecl_rft_cell_get_wrat(cell)); + test_assert_double_equal(orat, rd_rft_cell_get_orat(cell)); + test_assert_double_equal(grat, rd_rft_cell_get_grat(cell)); + test_assert_double_equal(wrat, rd_rft_cell_get_wrat(cell)); test_assert_double_equal(connection_start, - ecl_rft_cell_get_connection_start(cell)); + rd_rft_cell_get_connection_start(cell)); test_assert_double_equal(connection_end, - ecl_rft_cell_get_connection_end(cell)); - test_assert_double_equal(flowrate, ecl_rft_cell_get_flowrate(cell)); + rd_rft_cell_get_connection_end(cell)); + test_assert_double_equal(flowrate, rd_rft_cell_get_flowrate(cell)); - test_assert_double_equal(oil_flowrate, ecl_rft_cell_get_oil_flowrate(cell)); - test_assert_double_equal(gas_flowrate, ecl_rft_cell_get_gas_flowrate(cell)); + test_assert_double_equal(oil_flowrate, rd_rft_cell_get_oil_flowrate(cell)); + test_assert_double_equal(gas_flowrate, rd_rft_cell_get_gas_flowrate(cell)); test_assert_double_equal(water_flowrate, - ecl_rft_cell_get_water_flowrate(cell)); + rd_rft_cell_get_water_flowrate(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_swat(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_sgas(cell)); - test_assert_double_equal(ECL_RFT_CELL_INVALID_VALUE, - ecl_rft_cell_get_soil(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_swat(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_sgas(cell)); + test_assert_double_equal(RD_RFT_CELL_INVALID_VALUE, + rd_rft_cell_get_soil(cell)); - ecl_rft_cell_free(cell); + rd_rft_cell_free(cell); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/rd_rst_file.cpp b/lib/resdata/tests/rd_rst_file.cpp index 074f6f961a..94f47ee5fd 100644 --- a/lib/resdata/tests/rd_rst_file.cpp +++ b/lib/resdata/tests/rd_rst_file.cpp @@ -4,59 +4,58 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void write_keyword(fortio_type *fortio, const char *kw, - ecl_data_type data_type) { - ecl_kw_type *ecl_kw = ecl_kw_alloc(kw, 1000, data_type); - ecl_kw_fwrite(ecl_kw, fortio); - ecl_kw_free(ecl_kw); + rd_data_type data_type) { + rd_kw_type *rd_kw = rd_kw_alloc(kw, 1000, data_type); + rd_kw_fwrite(rd_kw, fortio); + rd_kw_free(rd_kw); } void write_seqnum(fortio_type *fortio, int report_step) { - ecl_kw_type *ecl_kw = ecl_kw_alloc(SEQNUM_KW, 1, ECL_INT); - ecl_kw_iset_int(ecl_kw, 0, report_step); - ecl_kw_fwrite(ecl_kw, fortio); - ecl_kw_free(ecl_kw); + rd_kw_type *rd_kw = rd_kw_alloc(SEQNUM_KW, 1, RD_INT); + rd_kw_iset_int(rd_kw, 0, report_step); + rd_kw_fwrite(rd_kw, fortio); + rd_kw_free(rd_kw); } void test_empty() { - ecl_rst_file_type *rst_file = - ecl_rst_file_open_write_seek("EMPTY.UNRST", 0); - test_assert_int_equal(ecl_rst_file_ftell(rst_file), 0); - ecl_rst_file_close(rst_file); + rd_rst_file_type *rst_file = rd_rst_file_open_write_seek("EMPTY.UNRST", 0); + test_assert_int_equal(rd_rst_file_ftell(rst_file), 0); + rd_rst_file_close(rst_file); } void test_file(const char *src_file, const char *target_file, int report_step, offset_type expected_offset) { util_copy_file(src_file, target_file); { - ecl_rst_file_type *rst_file = - ecl_rst_file_open_write_seek(target_file, report_step); - test_assert_true(ecl_rst_file_ftell(rst_file) == expected_offset); - ecl_rst_file_close(rst_file); + rd_rst_file_type *rst_file = + rd_rst_file_open_write_seek(target_file, report_step); + test_assert_true(rd_rst_file_ftell(rst_file) == expected_offset); + rd_rst_file_close(rst_file); test_assert_true(util_file_size(target_file) == (size_t)expected_offset); } } void test_Xfile() { - ecl::util::TestArea ta("xfile"); + rd::util::TestArea ta("xfile"); { fortio_type *f = - fortio_open_writer("TEST.X0010", false, ECL_ENDIAN_FLIP); + fortio_open_writer("TEST.X0010", false, RD_ENDIAN_FLIP); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); fortio_fclose(f); } @@ -64,29 +63,29 @@ void test_Xfile() { } void test_UNRST0() { - ecl::util::TestArea ta("rst-file"); + rd::util::TestArea ta("rst-file"); offset_type pos10; offset_type pos20; offset_type pos_end; { fortio_type *f = - fortio_open_writer("TEST.UNRST", false, ECL_ENDIAN_FLIP); + fortio_open_writer("TEST.UNRST", false, RD_ENDIAN_FLIP); write_seqnum(f, 0); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); pos10 = fortio_ftell(f); write_seqnum(f, 10); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); pos20 = fortio_ftell(f); write_seqnum(f, 20); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); pos_end = fortio_ftell(f); fortio_fclose(f); @@ -100,31 +99,31 @@ void test_UNRST0() { } void test_UNRST1() { - ecl::util::TestArea ta("rst-file"); + rd::util::TestArea ta("rst-file"); offset_type pos5; offset_type pos10; offset_type pos20; offset_type pos_end; { fortio_type *f = - fortio_open_writer("TEST.UNRST", false, ECL_ENDIAN_FLIP); + fortio_open_writer("TEST.UNRST", false, RD_ENDIAN_FLIP); pos5 = fortio_ftell(f); write_seqnum(f, 5); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); pos10 = fortio_ftell(f); write_seqnum(f, 10); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); pos20 = fortio_ftell(f); write_seqnum(f, 20); - write_keyword(f, "INTEHEAD", ECL_INT); - write_keyword(f, "PRESSURE", ECL_FLOAT); - write_keyword(f, "SWAT", ECL_FLOAT); + write_keyword(f, "INTEHEAD", RD_INT); + write_keyword(f, "PRESSURE", RD_FLOAT); + write_keyword(f, "SWAT", RD_FLOAT); pos_end = fortio_ftell(f); fortio_fclose(f); diff --git a/lib/resdata/tests/rd_rsthead.cpp b/lib/resdata/tests/rd_rsthead.cpp index 1eea183793..a3ea5bbb5b 100644 --- a/lib/resdata/tests/rd_rsthead.cpp +++ b/lib/resdata/tests/rd_rsthead.cpp @@ -3,46 +3,46 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include void test_file(const char *filename, int occurence, bool exists, - const ecl_rsthead_type *true_header) { - int report_step = ecl_util_filename_report_nr(filename); - ecl_file_type *rst_file = ecl_file_open(filename, 0); - ecl_file_enum file_type = ecl_util_get_file_type(filename, NULL, NULL); - ecl_file_view_type *rst_view; - ecl_rsthead_type *rst_head; + const rd_rsthead_type *true_header) { + int report_step = rd_filename_report_nr(filename); + rd_file_type *rst_file = rd_file_open(filename, 0); + rd_file_enum file_type = rd_get_file_type(filename, NULL, NULL); + rd_file_view_type *rst_view; + rd_rsthead_type *rst_head; - if (file_type == ECL_RESTART_FILE) - rst_view = ecl_file_get_global_view(rst_file); + if (file_type == RD_RESTART_FILE) + rst_view = rd_file_get_global_view(rst_file); else - rst_view = ecl_file_get_restart_view(rst_file, occurence, -1, -1, -1); + rst_view = rd_file_get_restart_view(rst_file, occurence, -1, -1, -1); if (exists) { test_assert_not_NULL(rst_view); - rst_head = ecl_rsthead_alloc(rst_view, report_step); + rst_head = rd_rsthead_alloc(rst_view, report_step); test_assert_not_NULL(rst_head); if (occurence == 0) { - ecl_rsthead_type *rst_head0 = - ecl_rsthead_alloc(rst_view, report_step); + rd_rsthead_type *rst_head0 = + rd_rsthead_alloc(rst_view, report_step); - test_assert_true(ecl_rsthead_equal(rst_head, rst_head0)); - ecl_rsthead_free(rst_head0); + test_assert_true(rd_rsthead_equal(rst_head, rst_head0)); + rd_rsthead_free(rst_head0); } - test_assert_true(ecl_rsthead_equal(rst_head, true_header)); + test_assert_true(rd_rsthead_equal(rst_head, true_header)); - ecl_rsthead_free(rst_head); + rd_rsthead_free(rst_head); } else test_assert_NULL(rst_view); } int main(int argc, char **argv) { - ecl_rsthead_type true1; + rd_rsthead_type true1; true1.report_step = 1; true1.day = 1; true1.year = 2000; @@ -67,7 +67,7 @@ int main(int argc, char **argv) { true1.dualp = 0; true1.sim_days = 0; - ecl_rsthead_type true2; + rd_rsthead_type true2; true2.report_step = 5; true2.day = 22; true2.year = 1990; diff --git a/lib/resdata/tests/rd_smspec.cpp b/lib/resdata/tests/rd_smspec.cpp index 8af380dfe0..71451537a4 100644 --- a/lib/resdata/tests/rd_smspec.cpp +++ b/lib/resdata/tests/rd_smspec.cpp @@ -2,34 +2,34 @@ #include #include -#include -#include +#include +#include -void test_copy(const ecl_smspec_type *smspec1) { - ecl_sum_type *ecl_sum2 = - ecl_sum_alloc_writer("CASE", false, true, ":", 0, true, 100, 100, 100); - const ecl_smspec_type *smspec2 = ecl_sum_get_smspec(ecl_sum2); - for (int i = 0; i < ecl_smspec_num_nodes(smspec1); i++) { - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_node_index(smspec1, i); - ecl_sum_add_smspec_node(ecl_sum2, &node); +void test_copy(const rd_smspec_type *smspec1) { + rd_sum_type *rd_sum2 = + rd_sum_alloc_writer("CASE", false, true, ":", 0, true, 100, 100, 100); + const rd_smspec_type *smspec2 = rd_sum_get_smspec(rd_sum2); + for (int i = 0; i < rd_smspec_num_nodes(smspec1); i++) { + const rd::smspec_node &node = + rd_smspec_iget_node_w_node_index(smspec1, i); + rd_sum_add_smspec_node(rd_sum2, &node); } - test_assert_true(ecl_smspec_equal(smspec1, smspec2)); - ecl_sum_free(ecl_sum2); + test_assert_true(rd_smspec_equal(smspec1, smspec2)); + rd_sum_free(rd_sum2); } int main(int argc, char **argv) { const char *case1 = argv[1]; const char *case2 = argv[2]; - ecl_smspec_type *smspec1 = ecl_smspec_fread_alloc(case1, ":", false); - ecl_smspec_type *smspec2 = ecl_smspec_fread_alloc(case2, ":", false); + rd_smspec_type *smspec1 = rd_smspec_fread_alloc(case1, ":", false); + rd_smspec_type *smspec2 = rd_smspec_fread_alloc(case2, ":", false); - test_assert_true(ecl_smspec_equal(smspec2, smspec2)); - test_assert_true(ecl_smspec_equal(smspec1, smspec1)); + test_assert_true(rd_smspec_equal(smspec2, smspec2)); + test_assert_true(rd_smspec_equal(smspec1, smspec1)); - test_assert_false(ecl_smspec_equal(smspec1, smspec2)); - test_assert_false(ecl_smspec_equal(smspec2, smspec1)); + test_assert_false(rd_smspec_equal(smspec1, smspec2)); + test_assert_false(rd_smspec_equal(smspec2, smspec1)); - ecl_smspec_free(smspec1); - ecl_smspec_free(smspec2); + rd_smspec_free(smspec1); + rd_smspec_free(smspec2); } diff --git a/lib/resdata/tests/rd_smspec_node.cpp b/lib/resdata/tests/rd_smspec_node.cpp index 921a340917..6ca5458fbb 100644 --- a/lib/resdata/tests/rd_smspec_node.cpp +++ b/lib/resdata/tests/rd_smspec_node.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include static void test_identify_rate_variable() { /* @@ -105,93 +105,90 @@ static void test_identify_total_variable() { NOTE: Not all of the following vectors are actual Eclipse vectors, but they are patterns that are supposed to be recognized as (likely) totals. */ - test_assert_true(smspec_node_identify_total("ROPT", ECL_SMSPEC_REGION_VAR)); - test_assert_true(smspec_node_identify_total("WOIT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GOVPT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FOVIT", ECL_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("ROPT", RD_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("WOIT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GOVPT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FOVIT", RD_SMSPEC_FIELD_VAR)); test_assert_true( - smspec_node_identify_total("COMT", ECL_SMSPEC_COMPLETION_VAR)); - - test_assert_true(smspec_node_identify_total("RGPT", ECL_SMSPEC_REGION_VAR)); - test_assert_true(smspec_node_identify_total("WGIT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GGVPT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FGVIT", ECL_SMSPEC_FIELD_VAR)); - test_assert_true(smspec_node_identify_total("WGMT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GWGPT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FWGPT", ECL_SMSPEC_FIELD_VAR)); - - test_assert_true(smspec_node_identify_total("RWPT", ECL_SMSPEC_REGION_VAR)); - test_assert_true(smspec_node_identify_total("WWIT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GWVPT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FWVIT", ECL_SMSPEC_FIELD_VAR)); - test_assert_true(smspec_node_identify_total("WWMT", ECL_SMSPEC_WELL_VAR)); - - test_assert_true(smspec_node_identify_total("RLPT", ECL_SMSPEC_REGION_VAR)); - test_assert_true(smspec_node_identify_total("GVPT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FVIT", ECL_SMSPEC_FIELD_VAR)); - - test_assert_true(smspec_node_identify_total("WRGT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GEGT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FEXGT", ECL_SMSPEC_FIELD_VAR)); + smspec_node_identify_total("COMT", RD_SMSPEC_COMPLETION_VAR)); + + test_assert_true(smspec_node_identify_total("RGPT", RD_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("WGIT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GGVPT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FGVIT", RD_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("WGMT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GWGPT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FWGPT", RD_SMSPEC_FIELD_VAR)); + + test_assert_true(smspec_node_identify_total("RWPT", RD_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("WWIT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GWVPT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FWVIT", RD_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("WWMT", RD_SMSPEC_WELL_VAR)); + + test_assert_true(smspec_node_identify_total("RLPT", RD_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("GVPT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FVIT", RD_SMSPEC_FIELD_VAR)); + + test_assert_true(smspec_node_identify_total("WRGT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GEGT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FEXGT", RD_SMSPEC_FIELD_VAR)); test_assert_true( - smspec_node_identify_total("CSGT", ECL_SMSPEC_COMPLETION_VAR)); + smspec_node_identify_total("CSGT", RD_SMSPEC_COMPLETION_VAR)); test_assert_true( - smspec_node_identify_total("LWGST", ECL_SMSPEC_LOCAL_WELL_VAR)); + smspec_node_identify_total("LWGST", RD_SMSPEC_LOCAL_WELL_VAR)); test_assert_true( - smspec_node_identify_total("LCFGT", ECL_SMSPEC_LOCAL_COMPLETION_VAR)); - test_assert_true(smspec_node_identify_total("WGIMT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GGCT", ECL_SMSPEC_GROUP_VAR)); - - test_assert_true(smspec_node_identify_total("RNPT", ECL_SMSPEC_REGION_VAR)); - test_assert_true(smspec_node_identify_total("WNIT", ECL_SMSPEC_WELL_VAR)); - test_assert_true(smspec_node_identify_total("GCPT", ECL_SMSPEC_GROUP_VAR)); - test_assert_true(smspec_node_identify_total("FCIT", ECL_SMSPEC_FIELD_VAR)); + smspec_node_identify_total("LCFGT", RD_SMSPEC_LOCAL_COMPLETION_VAR)); + test_assert_true(smspec_node_identify_total("WGIMT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GGCT", RD_SMSPEC_GROUP_VAR)); + + test_assert_true(smspec_node_identify_total("RNPT", RD_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("WNIT", RD_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GCPT", RD_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FCIT", RD_SMSPEC_FIELD_VAR)); test_assert_true( - smspec_node_identify_total("CSIT", ECL_SMSPEC_COMPLETION_VAR)); + smspec_node_identify_total("CSIT", RD_SMSPEC_COMPLETION_VAR)); test_assert_true( - smspec_node_identify_total("LWSPT", ECL_SMSPEC_LOCAL_WELL_VAR)); + smspec_node_identify_total("LWSPT", RD_SMSPEC_LOCAL_WELL_VAR)); test_assert_true( - smspec_node_identify_total("LCTIT", ECL_SMSPEC_LOCAL_COMPLETION_VAR)); - test_assert_true(smspec_node_identify_total("WTPT", ECL_SMSPEC_WELL_VAR)); + smspec_node_identify_total("LCTIT", RD_SMSPEC_LOCAL_COMPLETION_VAR)); + test_assert_true(smspec_node_identify_total("WTPT", RD_SMSPEC_WELL_VAR)); - test_assert_true( - smspec_node_identify_total("SOFT", ECL_SMSPEC_SEGMENT_VAR)); - test_assert_true( - smspec_node_identify_total("SGFT", ECL_SMSPEC_SEGMENT_VAR)); - test_assert_true( - smspec_node_identify_total("SWFT", ECL_SMSPEC_SEGMENT_VAR)); + test_assert_true(smspec_node_identify_total("SOFT", RD_SMSPEC_SEGMENT_VAR)); + test_assert_true(smspec_node_identify_total("SGFT", RD_SMSPEC_SEGMENT_VAR)); + test_assert_true(smspec_node_identify_total("SWFT", RD_SMSPEC_SEGMENT_VAR)); test_assert_true( - smspec_node_identify_total("RGFT", ECL_SMSPEC_REGION_2_REGION_VAR)); + smspec_node_identify_total("RGFT", RD_SMSPEC_REGION_2_REGION_VAR)); test_assert_true( - smspec_node_identify_total("RWFT-", ECL_SMSPEC_REGION_2_REGION_VAR)); + smspec_node_identify_total("RWFT-", RD_SMSPEC_REGION_2_REGION_VAR)); test_assert_true( - smspec_node_identify_total("RNLFT", ECL_SMSPEC_REGION_2_REGION_VAR)); + smspec_node_identify_total("RNLFT", RD_SMSPEC_REGION_2_REGION_VAR)); test_assert_true( - smspec_node_identify_total("RNLFT+", ECL_SMSPEC_REGION_2_REGION_VAR)); + smspec_node_identify_total("RNLFT+", RD_SMSPEC_REGION_2_REGION_VAR)); - test_assert_false(smspec_node_identify_total("", ECL_SMSPEC_REGION_VAR)); - test_assert_false(smspec_node_identify_total("HEI", ECL_SMSPEC_WELL_VAR)); - test_assert_false(smspec_node_identify_total("GBHP", ECL_SMSPEC_GROUP_VAR)); - test_assert_false(smspec_node_identify_total("FOPR", ECL_SMSPEC_FIELD_VAR)); + test_assert_false(smspec_node_identify_total("", RD_SMSPEC_REGION_VAR)); + test_assert_false(smspec_node_identify_total("HEI", RD_SMSPEC_WELL_VAR)); + test_assert_false(smspec_node_identify_total("GBHP", RD_SMSPEC_GROUP_VAR)); + test_assert_false(smspec_node_identify_total("FOPR", RD_SMSPEC_FIELD_VAR)); test_assert_false( - smspec_node_identify_total("CWIR", ECL_SMSPEC_COMPLETION_VAR)); + smspec_node_identify_total("CWIR", RD_SMSPEC_COMPLETION_VAR)); test_assert_false( - smspec_node_identify_total("LWGPR", ECL_SMSPEC_LOCAL_WELL_VAR)); + smspec_node_identify_total("LWGPR", RD_SMSPEC_LOCAL_WELL_VAR)); test_assert_false( - smspec_node_identify_total("CWCT", ECL_SMSPEC_LOCAL_COMPLETION_VAR)); + smspec_node_identify_total("CWCT", RD_SMSPEC_LOCAL_COMPLETION_VAR)); test_assert_false( - smspec_node_identify_total("SGPT", ECL_SMSPEC_SEGMENT_VAR)); + smspec_node_identify_total("SGPT", RD_SMSPEC_SEGMENT_VAR)); test_assert_false( - smspec_node_identify_total("RFT", ECL_SMSPEC_REGION_2_REGION_VAR)); + smspec_node_identify_total("RFT", RD_SMSPEC_REGION_2_REGION_VAR)); test_assert_false( - smspec_node_identify_total("ROFR", ECL_SMSPEC_REGION_2_REGION_VAR)); + smspec_node_identify_total("ROFR", RD_SMSPEC_REGION_2_REGION_VAR)); } void test_nums_default() { - ecl::smspec_node field_node(0, "FOPT", "UNIT", 0); - ecl::smspec_node group_node(0, "GOPR", "G1", "UNIT", 0, ":"); - ecl::smspec_node well_node(0, "WOPR", "W1", "UNIT", 0, ":"); + rd::smspec_node field_node(0, "FOPT", "UNIT", 0); + rd::smspec_node group_node(0, "GOPR", "G1", "UNIT", 0, ":"); + rd::smspec_node well_node(0, "WOPR", "W1", "UNIT", 0, ":"); int default_nums = 0; /* @@ -207,15 +204,15 @@ void test_nums_default() { void test_cmp_types() { const int dims[3] = {10, 10, 10}; - ecl::smspec_node field_node(0, "FOPT", "UNIT", 0); - ecl::smspec_node region_node(0, "RPR", 10, "UNIT", dims, 0, ":"); - ecl::smspec_node group_node(0, "GOPR", "G1", "UNIT", 0, ":"); - ecl::smspec_node well_node(0, "WOPR", "W1", "UNIT", 0, ":"); - ecl::smspec_node block_node(0, "BPR", 10, "UNIT", dims, 0, ":"); - ecl::smspec_node aquifer_node(0, "AAQP", 10, "UNIT", dims, 0, ":"); - ecl::smspec_node segment_node(0, "SGOR", "W1", 10, "UNIT", dims, 0, ":"); - ecl::smspec_node misc_node1(0, "TIME", "UNIT", 0); - ecl::smspec_node misc_node2(0, "TCPU", "UNIT", 0); + rd::smspec_node field_node(0, "FOPT", "UNIT", 0); + rd::smspec_node region_node(0, "RPR", 10, "UNIT", dims, 0, ":"); + rd::smspec_node group_node(0, "GOPR", "G1", "UNIT", 0, ":"); + rd::smspec_node well_node(0, "WOPR", "W1", "UNIT", 0, ":"); + rd::smspec_node block_node(0, "BPR", 10, "UNIT", dims, 0, ":"); + rd::smspec_node aquifer_node(0, "AAQP", 10, "UNIT", dims, 0, ":"); + rd::smspec_node segment_node(0, "SGOR", "W1", 10, "UNIT", dims, 0, ":"); + rd::smspec_node misc_node1(0, "TIME", "UNIT", 0); + rd::smspec_node misc_node2(0, "TCPU", "UNIT", 0); test_assert_int_equal(field_node.cmp(field_node), 0); test_assert_int_equal(region_node.cmp(region_node), 0); @@ -239,10 +236,10 @@ void test_cmp_types() { } void test_cmp_well() { - ecl::smspec_node well_node1_1(0, "WOPR", "W1", "UNIT", 10, ":"); - ecl::smspec_node well_node1_2(0, "WOPR", "W2", "UNIT", 10, ":"); - ecl::smspec_node well_node2_1(0, "WWCT", "W1", "UNIT", 10, ":"); - ecl::smspec_node well_node2_2(0, "WWWT", "W2", "UNIT", 10, ":"); + rd::smspec_node well_node1_1(0, "WOPR", "W1", "UNIT", 10, ":"); + rd::smspec_node well_node1_2(0, "WOPR", "W2", "UNIT", 10, ":"); + rd::smspec_node well_node2_1(0, "WWCT", "W1", "UNIT", 10, ":"); + rd::smspec_node well_node2_2(0, "WWWT", "W2", "UNIT", 10, ":"); test_assert_int_equal(well_node1_1.cmp(well_node1_1), 0); test_assert_int_equal(well_node2_2.cmp(well_node2_2), 0); @@ -257,10 +254,10 @@ void test_cmp_well() { void test_cmp_region() { const int dims[3] = {10, 10, 10}; - ecl::smspec_node region_node1_1(0, "ROIP", 10, "UNIT", dims, 0, ":"); - ecl::smspec_node region_node1_2(0, "ROIP", 11, "UNIT", dims, 0, ":"); - ecl::smspec_node region_node2_1(0, "RPR", 10, "UNIT", dims, 0, ":"); - ecl::smspec_node region_node2_2(0, "RPR", 12, "UNIT", dims, 0, ":"); + rd::smspec_node region_node1_1(0, "ROIP", 10, "UNIT", dims, 0, ":"); + rd::smspec_node region_node1_2(0, "ROIP", 11, "UNIT", dims, 0, ":"); + rd::smspec_node region_node2_1(0, "RPR", 10, "UNIT", dims, 0, ":"); + rd::smspec_node region_node2_2(0, "RPR", 12, "UNIT", dims, 0, ":"); test_assert_true(region_node1_1.cmp(region_node1_2) < 0); test_assert_true(region_node1_1.cmp(region_node2_1) < 0); diff --git a/lib/resdata/tests/rd_sum_alloc_resampled_test.cpp b/lib/resdata/tests/rd_sum_alloc_resampled_test.cpp index 710b81f72a..e817f3f4ad 100644 --- a/lib/resdata/tests/rd_sum_alloc_resampled_test.cpp +++ b/lib/resdata/tests/rd_sum_alloc_resampled_test.cpp @@ -1,136 +1,133 @@ #include -#include -#include -#include +#include +#include +#include -ecl_sum_type *test_alloc_ecl_sum() { +rd_sum_type *test_alloc_rd_sum() { time_t start_time = util_make_date_utc(1, 1, 2010); - ecl_sum_type *ecl_sum = ecl_sum_alloc_writer("/tmp/CASE", false, true, ":", - start_time, true, 10, 10, 10); + rd_sum_type *rd_sum = rd_sum_alloc_writer("/tmp/CASE", false, true, ":", + start_time, true, 10, 10, 10); double sim_seconds = 0; int num_dates = 4; double ministep_length = 86400; // seconds in a day - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "FOPT", NULL, 0, "Barrels", 99.0); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 567, "BARS", 0.0); - const ecl::smspec_node *node3 = - ecl_sum_add_var(ecl_sum, "WWCT", "OP-1", 0, "(1)", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "FOPT", NULL, 0, "Barrels", 99.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 567, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_sum_add_var(rd_sum, "WWCT", "OP-1", 0, "(1)", 0.0); for (int report_step = 0; report_step < num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, report_step * 2.0); - ecl_sum_tstep_set_from_node(tstep, *node2, report_step * 4.0 + 2.0); - ecl_sum_tstep_set_from_node(tstep, *node3, report_step * 6.0 + 4.0); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, report_step * 2.0); + rd_sum_tstep_set_from_node(tstep, *node2, report_step * 4.0 + 2.0); + rd_sum_tstep_set_from_node(tstep, *node3, report_step * 6.0 + 4.0); } sim_seconds += ministep_length * 3; } - return ecl_sum; + return rd_sum; } void test_correct_time_vector() { - ecl_sum_type *ecl_sum = test_alloc_ecl_sum(); + rd_sum_type *rd_sum = test_alloc_rd_sum(); time_t_vector_type *t = time_t_vector_alloc(0, 0); time_t_vector_append(t, util_make_date_utc(2, 1, 2010)); time_t_vector_append(t, util_make_date_utc(4, 1, 2010)); time_t_vector_append(t, util_make_date_utc(6, 1, 2010)); time_t_vector_append(t, util_make_date_utc(8, 1, 2010)); - ecl_sum_type *ecl_sum_resampled = - ecl_sum_alloc_resample(ecl_sum, "kk", t, false, false); - test_assert_int_equal(ecl_sum_get_report_time(ecl_sum_resampled, 2), + rd_sum_type *rd_sum_resampled = + rd_sum_alloc_resample(rd_sum, "kk", t, false, false); + test_assert_int_equal(rd_sum_get_report_time(rd_sum_resampled, 2), util_make_date_utc(6, 1, 2010)); - const ecl_smspec_type *smspec_resampled = - ecl_sum_get_smspec(ecl_sum_resampled); - const ecl::smspec_node &node1 = - ecl_smspec_iget_node_w_params_index(smspec_resampled, 1); - const ecl::smspec_node &node2 = - ecl_smspec_iget_node_w_params_index(smspec_resampled, 2); - const ecl::smspec_node &node3 = - ecl_smspec_iget_node_w_params_index(smspec_resampled, 3); + const rd_smspec_type *smspec_resampled = + rd_sum_get_smspec(rd_sum_resampled); + const rd::smspec_node &node1 = + rd_smspec_iget_node_w_params_index(smspec_resampled, 1); + const rd::smspec_node &node2 = + rd_smspec_iget_node_w_params_index(smspec_resampled, 2); + const rd::smspec_node &node3 = + rd_smspec_iget_node_w_params_index(smspec_resampled, 3); test_assert_string_equal("BPR", smspec_node_get_keyword(&node2)); test_assert_string_equal("BARS", smspec_node_get_unit(&node2)); test_assert_double_equal( - 3.33333, - ecl_sum_get_from_sim_time(ecl_sum_resampled, - util_make_date_utc(6, 1, 2010), &node1)); + 3.33333, rd_sum_get_from_sim_time( + rd_sum_resampled, util_make_date_utc(6, 1, 2010), &node1)); test_assert_double_equal( - 3.33333, - ecl_sum_get_from_sim_time(ecl_sum_resampled, - util_make_date_utc(2, 1, 2010), &node2)); + 3.33333, rd_sum_get_from_sim_time( + rd_sum_resampled, util_make_date_utc(2, 1, 2010), &node2)); test_assert_double_equal( - 10.0000, - ecl_sum_get_from_sim_time(ecl_sum_resampled, - util_make_date_utc(4, 1, 2010), &node3)); + 10.0000, rd_sum_get_from_sim_time( + rd_sum_resampled, util_make_date_utc(4, 1, 2010), &node3)); - ecl_sum_free(ecl_sum_resampled); + rd_sum_free(rd_sum_resampled); time_t_vector_free(t); - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); } void test_resample_extrapolate_rate() { - ecl_sum_type *ecl_sum = test_alloc_ecl_sum(); + rd_sum_type *rd_sum = test_alloc_rd_sum(); time_t_vector_type *t = time_t_vector_alloc(0, 0); time_t_vector_append(t, util_make_date_utc(1, 1, 2009)); time_t_vector_append(t, util_make_date_utc(4, 1, 2010)); time_t_vector_append(t, util_make_date_utc(12, 1, 2010)); - ecl_sum_type *ecl_sum_resampled = - ecl_sum_alloc_resample(ecl_sum, "kk", t, true, true); + rd_sum_type *rd_sum_resampled = + rd_sum_alloc_resample(rd_sum, "kk", t, true, true); - const ecl_smspec_type *smspec_resampled = - ecl_sum_get_smspec(ecl_sum_resampled); - const ecl::smspec_node &node1 = - ecl_smspec_iget_node_w_params_index(smspec_resampled, 1); - const ecl::smspec_node &node3 = - ecl_smspec_iget_node_w_params_index(smspec_resampled, 3); + const rd_smspec_type *smspec_resampled = + rd_sum_get_smspec(rd_sum_resampled); + const rd::smspec_node &node1 = + rd_smspec_iget_node_w_params_index(smspec_resampled, 1); + const rd::smspec_node &node3 = + rd_smspec_iget_node_w_params_index(smspec_resampled, 3); //testing extrapolation for rate wrt. 3 dates: lower, inside and upper test_assert_double_equal( - 0, ecl_sum_get_from_sim_time(ecl_sum_resampled, - util_make_date_utc(1, 1, 2009), &node3)); + 0, rd_sum_get_from_sim_time(rd_sum_resampled, + util_make_date_utc(1, 1, 2009), &node3)); test_assert_double_equal( - 10.000, ecl_sum_get_from_sim_time( - ecl_sum_resampled, util_make_date_utc(4, 1, 2010), &node3)); + 10.000, rd_sum_get_from_sim_time( + rd_sum_resampled, util_make_date_utc(4, 1, 2010), &node3)); test_assert_double_equal( - 0, ecl_sum_get_from_sim_time(ecl_sum_resampled, - util_make_date_utc(12, 1, 2010), &node3)); + 0, rd_sum_get_from_sim_time(rd_sum_resampled, + util_make_date_utc(12, 1, 2010), &node3)); //testing extrapolation for variable wrt. 3 dates: lower, inside and upper test_assert_double_equal( - 0, ecl_sum_get_from_sim_time(ecl_sum_resampled, - util_make_date_utc(1, 1, 2009), &node1)); + 0, rd_sum_get_from_sim_time(rd_sum_resampled, + util_make_date_utc(1, 1, 2009), &node1)); test_assert_double_equal( - 2.000, ecl_sum_get_from_sim_time( - ecl_sum_resampled, util_make_date_utc(4, 1, 2010), &node1)); + 2.000, rd_sum_get_from_sim_time( + rd_sum_resampled, util_make_date_utc(4, 1, 2010), &node1)); test_assert_double_equal( - 6.000, ecl_sum_get_from_sim_time( - ecl_sum_resampled, util_make_date_utc(12, 1, 2010), &node1)); + 6.000, rd_sum_get_from_sim_time( + rd_sum_resampled, util_make_date_utc(12, 1, 2010), &node1)); - ecl_sum_free(ecl_sum_resampled); + rd_sum_free(rd_sum_resampled); time_t_vector_free(t); - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); } void test_not_sorted() { - ecl_sum_type *ecl_sum = test_alloc_ecl_sum(); + rd_sum_type *rd_sum = test_alloc_rd_sum(); time_t_vector_type *t = time_t_vector_alloc(0, 0); time_t_vector_append(t, util_make_date_utc(1, 1, 2010)); time_t_vector_append(t, util_make_date_utc(3, 1, 2010)); time_t_vector_append(t, util_make_date_utc(2, 1, 2010)); - test_assert_NULL(ecl_sum_alloc_resample(ecl_sum, "kk", t, false, false)); + test_assert_NULL(rd_sum_alloc_resample(rd_sum, "kk", t, false, false)); time_t_vector_free(t); - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); } int main() { diff --git a/lib/resdata/tests/rd_sum_case_exists.cpp b/lib/resdata/tests/rd_sum_case_exists.cpp index 09ef321a5d..2fc5eb826b 100644 --- a/lib/resdata/tests/rd_sum_case_exists.cpp +++ b/lib/resdata/tests/rd_sum_case_exists.cpp @@ -7,12 +7,12 @@ #include #include -#include -#include -#include +#include +#include +#include void test_case(const char *sum_case, bool expected_exist) { - test_assert_bool_equal(expected_exist, ecl_sum_case_exists(sum_case)); + test_assert_bool_equal(expected_exist, rd_sum_case_exists(sum_case)); } void test_case_no_path(const char *sum_case, bool expected_exist) { @@ -24,7 +24,7 @@ void test_case_no_path(const char *sum_case, bool expected_exist) { util_alloc_file_components(sum_case, &path, &basename, NULL); if (path) chdir(path); - test_assert_bool_equal(expected_exist, ecl_sum_case_exists(basename)); + test_assert_bool_equal(expected_exist, rd_sum_case_exists(basename)); free(path); free(basename); @@ -37,7 +37,7 @@ int main(int argc, char **argv) { const char *existing_case = argv[1]; const char *missing_header = argv[2]; const char *missing_data = argv[3]; - test_assert_false(ecl_sum_case_exists("/does/not/exist")); + test_assert_false(rd_sum_case_exists("/does/not/exist")); test_case(existing_case, true); test_case_no_path(existing_case, true); diff --git a/lib/resdata/tests/rd_sum_data_intermediate_test.cpp b/lib/resdata/tests/rd_sum_data_intermediate_test.cpp index 3f3e89ed6c..47e9d66d57 100644 --- a/lib/resdata/tests/rd_sum_data_intermediate_test.cpp +++ b/lib/resdata/tests/rd_sum_data_intermediate_test.cpp @@ -5,12 +5,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* @@ -54,11 +54,11 @@ Total CASE3: #define ieq(d, i, v) test_assert_double_equal(double_vector_iget(d, (i)), v) void verify_CASE1(int length) { - ecl_sum_type *sum = ecl_sum_fread_alloc_case("CASE1", ":"); + rd_sum_type *sum = rd_sum_fread_alloc_case("CASE1", ":"); int params_size = 4; // TIME, BPR:1, BPR:2, BPR:3 for (int i = 1; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i, false); test_assert_int_equal(length, double_vector_size(d)); for (int j = 0; j < length; j++) { test_assert_double_equal(double_vector_iget(d, j), @@ -66,50 +66,49 @@ void verify_CASE1(int length) { } double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); } void write_CASE1(bool unified) { time_t start_time = util_make_date_utc(1, 1, 2010); - ecl_sum_type *ecl_sum = ecl_sum_alloc_writer("CASE1", false, unified, ":", - start_time, true, 10, 10, 10); + rd_sum_type *rd_sum = rd_sum_alloc_writer("CASE1", false, unified, ":", + start_time, true, 10, 10, 10); double sim_seconds = 0; int num_dates = 100; double ministep_length = 86400; // seconds in a day - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 1, "BARS", 0.0); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 2, "BARS", 0.0); - const ecl::smspec_node *node3 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 3, "BARS", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "BPR", NULL, 1, "BARS", 0.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 2, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_sum_add_var(rd_sum, "BPR", NULL, 3, "BARS", 0.0); for (int report_step = 0; report_step < num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, (1 + report_step) * 100); - ecl_sum_tstep_set_from_node(tstep, *node2, - (1 + report_step) * 100 + 10.0); - ecl_sum_tstep_set_from_node(tstep, *node3, - (1 + report_step) * 100 + 20.0); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, (1 + report_step) * 100); + rd_sum_tstep_set_from_node(tstep, *node2, + (1 + report_step) * 100 + 10.0); + rd_sum_tstep_set_from_node(tstep, *node3, + (1 + report_step) * 100 + 20.0); } sim_seconds += ministep_length * 3; } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); verify_CASE1(num_dates); } void verify_CASE2(int length) { - ecl_sum_type *sum = - ecl_sum_fread_alloc_case2__("CASE2", ":", false, true, 0); + rd_sum_type *sum = rd_sum_fread_alloc_case2__("CASE2", ":", false, true, 0); const int params_size = 2; // TIME, BPR:2, BPR:1 for (int i = 0; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i + 1, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i + 1, false); test_assert_int_equal(length, double_vector_size(d)); for (int j = 1; j < length; j++) test_assert_double_equal(double_vector_iget(d, j - 1), @@ -117,11 +116,11 @@ void verify_CASE2(int length) { double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); - sum = ecl_sum_fread_alloc_case("CASE2", ":"); + sum = rd_sum_fread_alloc_case("CASE2", ":"); for (int i = 0; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i + 1, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i + 1, false); test_assert_int_equal(double_vector_size(d), 7); ieq(d, 0, (1 - i) * 10 + 100); ieq(d, 1, (1 - i) * 10 + 200); @@ -133,7 +132,7 @@ void verify_CASE2(int length) { double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); } void write_CASE2(bool unified) { @@ -143,37 +142,36 @@ void write_CASE2(bool unified) { int num_dates = 4; double ministep_length = 86400; // seconds in a day double sim_seconds = ministep_length * 2.5 * 3; - ecl_sum_type *ecl_sum = ecl_sum_alloc_restart_writer( + rd_sum_type *rd_sum = rd_sum_alloc_restart_writer( "CASE2", "CASE1", false, true, ":", start_time, true, 10, 10, 10); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 2, "BARS", 0.0); - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 1, "BARS", 0.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 2, "BARS", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "BPR", NULL, 1, "BARS", 0.0); for (int report_step = 1; report_step <= num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 3, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, report_step * 1000); - ecl_sum_tstep_set_from_node(tstep, *node2, - report_step * 1000 + 100); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 3, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, report_step * 1000); + rd_sum_tstep_set_from_node(tstep, *node2, + report_step * 1000 + 100); } sim_seconds += ministep_length * 3; } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); verify_CASE2(num_dates); } } void verify_CASE3(int length) { const int params_size = 3; - ecl_sum_type *sum = - ecl_sum_fread_alloc_case2__("CASE3", ":", false, true, 0); + rd_sum_type *sum = rd_sum_fread_alloc_case2__("CASE3", ":", false, true, 0); for (int i = 0; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i + 1, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i + 1, false); test_assert_int_equal(length, double_vector_size(d)); for (int j = 0; j < length; j++) { test_assert_double_equal(double_vector_iget(d, j), @@ -181,18 +179,18 @@ void verify_CASE3(int length) { } double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); - sum = ecl_sum_fread_alloc_case("CASE3", ":"); + sum = rd_sum_fread_alloc_case("CASE3", ":"); for (int i = 0; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i + 1, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i + 1, false); ieq(d, 0, (2 - i) * 10 + 100); ieq(d, 1, (2 - i) * 10 + 200); ieq(d, 2, (2 - i) * 10 + 300); if (i == 0) { - const ecl::smspec_node &node = - ecl_smspec_iget_node_w_params_index(ecl_sum_get_smspec(sum), i); + const rd::smspec_node &node = + rd_smspec_iget_node_w_params_index(rd_sum_get_smspec(sum), i); double default_value = node.get_default(); ieq(d, 3, default_value); ieq(d, 4, default_value); @@ -207,12 +205,12 @@ void verify_CASE3(int length) { double_vector_free(d); } - ecl_sum_vector_type *vector = ecl_sum_vector_alloc(sum, true); + rd_sum_vector_type *vector = rd_sum_vector_alloc(sum, true); double frame[27]; //3 vectors X 9 data points pr. vector - ecl_sum_init_double_frame(sum, vector, frame); - ecl_sum_vector_free(vector); + rd_sum_init_double_frame(sum, vector, frame); + rd_sum_vector_free(vector); - ecl_sum_free(sum); + rd_sum_free(sum); } void write_CASE3(bool unified) { @@ -222,111 +220,110 @@ void write_CASE3(bool unified) { int num_dates = 4; double ministep_length = 86400; // seconds in a day double sim_seconds = ministep_length * 4.0 * 3; - ecl_sum_type *ecl_sum = ecl_sum_alloc_restart_writer( + rd_sum_type *rd_sum = rd_sum_alloc_restart_writer( "CASE3", "CASE2", false, true, ":", start_time, true, 10, 10, 10); - const ecl::smspec_node *node3 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 3, "BARS", 0.0); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 2, "BARS", 0.0); - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 1, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_sum_add_var(rd_sum, "BPR", NULL, 3, "BARS", 0.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 2, "BARS", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "BPR", NULL, 1, "BARS", 0.0); for (int report_step = 1; report_step <= num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 5, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, report_step * 10000); - ecl_sum_tstep_set_from_node(tstep, *node2, - report_step * 10000 + 1000); - ecl_sum_tstep_set_from_node(tstep, *node3, - report_step * 10000 + 2000); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 5, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, report_step * 10000); + rd_sum_tstep_set_from_node(tstep, *node2, + report_step * 10000 + 1000); + rd_sum_tstep_set_from_node(tstep, *node3, + report_step * 10000 + 2000); } sim_seconds += ministep_length * 3; } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); verify_CASE3(num_dates); } } void verify_CASE4() { - ecl_sum_type *sum = ecl_sum_fread_alloc_case("CASE4", ":"); + rd_sum_type *sum = rd_sum_fread_alloc_case("CASE4", ":"); double_vector_type *d; - d = ecl_sum_alloc_data_vector(sum, 0, false); + d = rd_sum_alloc_data_vector(sum, 0, false); double_vector_free(d); - d = ecl_sum_alloc_data_vector(sum, 1, false); + d = rd_sum_alloc_data_vector(sum, 1, false); double_vector_free(d); - d = ecl_sum_alloc_data_vector(sum, 2, false); + d = rd_sum_alloc_data_vector(sum, 2, false); double_vector_free(d); - d = ecl_sum_alloc_data_vector(sum, 4, false); + d = rd_sum_alloc_data_vector(sum, 4, false); ieq(d, 0, -99); ieq(d, 4, -99); ieq(d, 5, 10000); ieq(d, 8, 40000); double_vector_free(d); - ecl_sum_vector_type *vector = ecl_sum_vector_alloc(sum, true); + rd_sum_vector_type *vector = rd_sum_vector_alloc(sum, true); double frame[27]; //3 vectors X 9 data points pr. vector - ecl_sum_init_double_frame(sum, vector, frame); + rd_sum_init_double_frame(sum, vector, frame); test_assert_double_equal(frame[26], 40000); - ecl_sum_vector_free(vector); + rd_sum_vector_free(vector); - ecl_sum_free(sum); + rd_sum_free(sum); } void write_CASE4(bool unified) { - ecl::util::TestArea ta("case4"); + rd::util::TestArea ta("case4"); write_CASE3(unified); { - ecl_file_type *sum_file = ecl_file_open("CASE3.UNSMRY", 0); - ecl_file_type *smspec_file = ecl_file_open("CASE3.SMSPEC", 0); - - ecl_kw_type *keywords = - ecl_file_iget_named_kw(smspec_file, "KEYWORDS", 0); - ecl_kw_resize(keywords, 5); - ecl_kw_iset_char_ptr(keywords, 3, "WTPRWI1"); - ecl_kw_iset_char_ptr(keywords, 4, "BPR"); - - ecl_kw_type *nums = ecl_file_iget_named_kw(smspec_file, "NUMS", 0); - ecl_kw_resize(nums, 5); - unsigned int *nums_ptr = (unsigned int *)ecl_kw_get_int_ptr(nums); + rd_file_type *sum_file = rd_file_open("CASE3.UNSMRY", 0); + rd_file_type *smspec_file = rd_file_open("CASE3.SMSPEC", 0); + + rd_kw_type *keywords = + rd_file_iget_named_kw(smspec_file, "KEYWORDS", 0); + rd_kw_resize(keywords, 5); + rd_kw_iset_char_ptr(keywords, 3, "WTPRWI1"); + rd_kw_iset_char_ptr(keywords, 4, "BPR"); + + rd_kw_type *nums = rd_file_iget_named_kw(smspec_file, "NUMS", 0); + rd_kw_resize(nums, 5); + unsigned int *nums_ptr = (unsigned int *)rd_kw_get_int_ptr(nums); nums_ptr[3] = 5; nums_ptr[4] = 8; //a different - ecl_kw_type *wgnames = - ecl_file_iget_named_kw(smspec_file, "WGNAMES", 0); - ecl_kw_resize(wgnames, 5); - ecl_kw_iset_char_ptr(wgnames, 4, ":+:+:+:+"); + rd_kw_type *wgnames = rd_file_iget_named_kw(smspec_file, "WGNAMES", 0); + rd_kw_resize(wgnames, 5); + rd_kw_iset_char_ptr(wgnames, 4, ":+:+:+:+"); - ecl_kw_type *units = ecl_file_iget_named_kw(smspec_file, "UNITS", 0); - ecl_kw_resize(units, 5); - ecl_kw_iset_char_ptr(units, 4, "BARS"); + rd_kw_type *units = rd_file_iget_named_kw(smspec_file, "UNITS", 0); + rd_kw_resize(units, 5); + rd_kw_iset_char_ptr(units, 4, "BARS"); - int num_params = ecl_file_get_num_named_kw(sum_file, "PARAMS"); + int num_params = rd_file_get_num_named_kw(sum_file, "PARAMS"); for (int i = 0; i < num_params; i++) { - ecl_kw_type *params_kw = - ecl_file_iget_named_kw(sum_file, "PARAMS", i); - ecl_kw_resize(params_kw, 5); - float *ptr = (float *)ecl_kw_get_void_ptr(params_kw); + rd_kw_type *params_kw = + rd_file_iget_named_kw(sum_file, "PARAMS", i); + rd_kw_resize(params_kw, 5); + float *ptr = (float *)rd_kw_get_void_ptr(params_kw); ptr[4] = ptr[3]; ptr[3] = -1; } fortio_type *f; const char *filename_sum = "CASE4.UNSMRY"; - f = fortio_open_writer(filename_sum, false, ECL_ENDIAN_FLIP); - ecl_file_fwrite_fortio(sum_file, f, 0); + f = fortio_open_writer(filename_sum, false, RD_ENDIAN_FLIP); + rd_file_fwrite_fortio(sum_file, f, 0); fortio_fclose(f); const char *filename_smspec = "CASE4.SMSPEC"; - f = fortio_open_writer(filename_smspec, false, ECL_ENDIAN_FLIP); - ecl_file_fwrite_fortio(smspec_file, f, 0); + f = fortio_open_writer(filename_smspec, false, RD_ENDIAN_FLIP); + rd_file_fwrite_fortio(smspec_file, f, 0); fortio_fclose(f); - ecl_file_close(smspec_file); - ecl_file_close(sum_file); + rd_file_close(smspec_file); + rd_file_close(sum_file); verify_CASE4(); } } diff --git a/lib/resdata/tests/rd_sum_report_step_compatible.cpp b/lib/resdata/tests/rd_sum_report_step_compatible.cpp index ae2257cb12..ceb38042d8 100644 --- a/lib/resdata/tests/rd_sum_report_step_compatible.cpp +++ b/lib/resdata/tests/rd_sum_report_step_compatible.cpp @@ -5,27 +5,27 @@ #include #include -#include +#include int main(int argc, char **argv) { const char *case1 = argv[1]; const char *case2 = argv[2]; const char *compatible_string = argv[3]; - ecl_sum_type *ecl_sum1 = ecl_sum_fread_alloc_case(case1, ":"); - ecl_sum_type *ecl_sum2 = ecl_sum_fread_alloc_case(case2, ":"); + rd_sum_type *rd_sum1 = rd_sum_fread_alloc_case(case1, ":"); + rd_sum_type *rd_sum2 = rd_sum_fread_alloc_case(case2, ":"); - test_assert_true(ecl_sum_is_instance(ecl_sum1)); - test_assert_true(ecl_sum_is_instance(ecl_sum2)); - test_assert_true(ecl_sum_report_step_compatible(ecl_sum1, ecl_sum1)); - test_assert_true(ecl_sum_report_step_compatible(ecl_sum2, ecl_sum2)); + test_assert_true(rd_sum_is_instance(rd_sum1)); + test_assert_true(rd_sum_is_instance(rd_sum2)); + test_assert_true(rd_sum_report_step_compatible(rd_sum1, rd_sum1)); + test_assert_true(rd_sum_report_step_compatible(rd_sum2, rd_sum2)); { bool compatible; test_assert_true(util_sscanf_bool(compatible_string, &compatible)); - test_assert_bool_equal( - compatible, ecl_sum_report_step_compatible(ecl_sum1, ecl_sum2)); + test_assert_bool_equal(compatible, + rd_sum_report_step_compatible(rd_sum1, rd_sum2)); } - ecl_sum_free(ecl_sum1); - ecl_sum_free(ecl_sum2); + rd_sum_free(rd_sum1); + rd_sum_free(rd_sum2); exit(0); } diff --git a/lib/resdata/tests/rd_sum_report_step_equal.cpp b/lib/resdata/tests/rd_sum_report_step_equal.cpp index 1c0a788b38..b6e13fe453 100644 --- a/lib/resdata/tests/rd_sum_report_step_equal.cpp +++ b/lib/resdata/tests/rd_sum_report_step_equal.cpp @@ -5,27 +5,26 @@ #include #include -#include +#include int main(int argc, char **argv) { const char *case1 = argv[1]; const char *case2 = argv[2]; const char *equal_string = argv[3]; bool equal; - ecl_sum_type *ecl_sum1 = ecl_sum_fread_alloc_case(case1, ":"); - ecl_sum_type *ecl_sum2 = ecl_sum_fread_alloc_case(case2, ":"); + rd_sum_type *rd_sum1 = rd_sum_fread_alloc_case(case1, ":"); + rd_sum_type *rd_sum2 = rd_sum_fread_alloc_case(case2, ":"); - test_assert_true(ecl_sum_is_instance(ecl_sum1)); - test_assert_true(ecl_sum_is_instance(ecl_sum2)); - test_assert_true(ecl_sum_report_step_equal(ecl_sum1, ecl_sum1)); + test_assert_true(rd_sum_is_instance(rd_sum1)); + test_assert_true(rd_sum_is_instance(rd_sum2)); + test_assert_true(rd_sum_report_step_equal(rd_sum1, rd_sum1)); test_assert_true(util_sscanf_bool(equal_string, &equal)); - test_assert_true(ecl_sum_report_step_equal(ecl_sum1, ecl_sum1)); - test_assert_true(ecl_sum_report_step_equal(ecl_sum2, ecl_sum2)); - test_assert_bool_equal(equal, - ecl_sum_report_step_equal(ecl_sum1, ecl_sum2)); + test_assert_true(rd_sum_report_step_equal(rd_sum1, rd_sum1)); + test_assert_true(rd_sum_report_step_equal(rd_sum2, rd_sum2)); + test_assert_bool_equal(equal, rd_sum_report_step_equal(rd_sum1, rd_sum2)); - ecl_sum_free(ecl_sum1); - ecl_sum_free(ecl_sum2); + rd_sum_free(rd_sum1); + rd_sum_free(rd_sum2); exit(0); } diff --git a/lib/resdata/tests/rd_sum_restart.cpp b/lib/resdata/tests/rd_sum_restart.cpp index 7471123944..7ae66d687e 100644 --- a/lib/resdata/tests/rd_sum_restart.cpp +++ b/lib/resdata/tests/rd_sum_restart.cpp @@ -5,12 +5,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* @@ -54,11 +54,11 @@ Total CASE3: #define ieq(d, i, v) test_assert_double_equal(double_vector_iget(d, (i)), v) void verify_CASE1(int length) { - ecl_sum_type *sum = ecl_sum_fread_alloc_case("CASE1", ":"); + rd_sum_type *sum = rd_sum_fread_alloc_case("CASE1", ":"); int params_size = 4; // TIME, BPR:1, BPR:2, BPR:3 for (int i = 1; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i, false); test_assert_int_equal(length, double_vector_size(d)); for (int j = 0; j < length; j++) { test_assert_double_equal(double_vector_iget(d, j), @@ -66,16 +66,15 @@ void verify_CASE1(int length) { } double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); } void verify_CASE2(int length) { - ecl_sum_type *sum = - ecl_sum_fread_alloc_case2__("CASE2", ":", false, true, 0); + rd_sum_type *sum = rd_sum_fread_alloc_case2__("CASE2", ":", false, true, 0); const int params_size = 2; // TIME, BPR:2, BPR:1 for (int i = 0; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i + 1, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i + 1, false); test_assert_int_equal(length, double_vector_size(d)); for (int j = 1; j < length; j++) test_assert_double_equal(double_vector_iget(d, j - 1), @@ -83,11 +82,11 @@ void verify_CASE2(int length) { double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); - sum = ecl_sum_fread_alloc_case("CASE2", ":"); + sum = rd_sum_fread_alloc_case("CASE2", ":"); for (int i = 0; i < params_size; i++) { - double_vector_type *d = ecl_sum_alloc_data_vector(sum, i + 1, false); + double_vector_type *d = rd_sum_alloc_data_vector(sum, i + 1, false); test_assert_int_equal(double_vector_size(d), 4); ieq(d, 0, (1 - i) * 100 + 1000); ieq(d, 1, (1 - i) * 100 + 2000); @@ -96,39 +95,39 @@ void verify_CASE2(int length) { double_vector_free(d); } - ecl_sum_free(sum); + rd_sum_free(sum); } void write_CASE1(bool unified) { time_t start_time = util_make_date_utc(1, 1, 2010); - ecl_sum_type *ecl_sum = ecl_sum_alloc_writer("CASE1", false, unified, ":", - start_time, true, 10, 10, 10); + rd_sum_type *rd_sum = rd_sum_alloc_writer("CASE1", false, unified, ":", + start_time, true, 10, 10, 10); double sim_seconds = 0; int num_dates = 100; double ministep_length = 86400; // seconds in a day - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 1, "BARS", 0.0); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 2, "BARS", 0.0); - const ecl::smspec_node *node3 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 3, "BARS", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "BPR", NULL, 1, "BARS", 0.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 2, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_sum_add_var(rd_sum, "BPR", NULL, 3, "BARS", 0.0); for (int report_step = 0; report_step < num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, (1 + report_step) * 100); - ecl_sum_tstep_set_from_node(tstep, *node2, - (1 + report_step) * 100 + 10.0); - ecl_sum_tstep_set_from_node(tstep, *node3, - (1 + report_step) * 100 + 20.0); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, (1 + report_step) * 100); + rd_sum_tstep_set_from_node(tstep, *node2, + (1 + report_step) * 100 + 10.0); + rd_sum_tstep_set_from_node(tstep, *node3, + (1 + report_step) * 100 + 20.0); } sim_seconds += ministep_length * 3; } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); verify_CASE1(num_dates); } @@ -141,26 +140,26 @@ void write_CASE2() { int num_dates = 4; double ministep_length = 86400; // seconds in a day double sim_seconds = ministep_length * 2.5 * 3; - ecl_sum_type *ecl_sum = ecl_sum_alloc_restart_writer( + rd_sum_type *rd_sum = rd_sum_alloc_restart_writer( "CASE2", "CASE1", false, true, ":", start_time, true, 10, 10, 10); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 2, "BARS", 0.0); - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 1, "BARS", 0.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 2, "BARS", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "BPR", NULL, 1, "BARS", 0.0); for (int report_step = 1; report_step <= num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 3, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, report_step * 1000); - ecl_sum_tstep_set_from_node(tstep, *node2, - report_step * 1000 + 100); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 3, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, report_step * 1000); + rd_sum_tstep_set_from_node(tstep, *node2, + report_step * 1000 + 100); } sim_seconds += ministep_length * 3; } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); util_unlink("CASE1.SMSPEC"); diff --git a/lib/resdata/tests/rd_sum_test.cpp b/lib/resdata/tests/rd_sum_test.cpp index 824263b49f..e119cace2e 100644 --- a/lib/resdata/tests/rd_sum_test.cpp +++ b/lib/resdata/tests/rd_sum_test.cpp @@ -5,47 +5,47 @@ #include #include -#include +#include -void test_time_range(const ecl_sum_type *ecl_sum) { +void test_time_range(const rd_sum_type *rd_sum) { // Hardcoded Gurbat case values - time_t start = ecl_util_make_date(1, 1, 2000); - time_t end = ecl_util_make_date(31, 12, 2004); + time_t start = rd_make_date(1, 1, 2000); + time_t end = rd_make_date(31, 12, 2004); - test_assert_time_t_equal(ecl_sum_get_start_time(ecl_sum), start); - test_assert_time_t_equal(ecl_sum_get_end_time(ecl_sum), end); - test_assert_time_t_equal(ecl_sum_get_data_start(ecl_sum), start); + test_assert_time_t_equal(rd_sum_get_start_time(rd_sum), start); + test_assert_time_t_equal(rd_sum_get_end_time(rd_sum), end); + test_assert_time_t_equal(rd_sum_get_data_start(rd_sum), start); } -void test_days(const ecl_sum_type *ecl_sum) { - time_t date1 = ecl_util_make_date(1, 1, 2000); - time_t date2 = ecl_util_make_date(31, 12, 2004); - time_t date3 = ecl_util_make_date(2, 1, 2000); +void test_days(const rd_sum_type *rd_sum) { + time_t date1 = rd_make_date(1, 1, 2000); + time_t date2 = rd_make_date(31, 12, 2004); + time_t date3 = rd_make_date(2, 1, 2000); - double days1 = ecl_sum_time2days(ecl_sum, date1); - double days2 = ecl_sum_time2days(ecl_sum, date2); - double days3 = ecl_sum_time2days(ecl_sum, date3); + double days1 = rd_sum_time2days(rd_sum, date1); + double days2 = rd_sum_time2days(rd_sum, date2); + double days3 = rd_sum_time2days(rd_sum, date3); test_assert_double_equal(days1, 0); test_assert_double_equal(days2, 1826); test_assert_double_equal(days3, 1); } -void test_is_oil_producer(const ecl_sum_type *ecl_sum) { - test_assert_true(ecl_sum_is_oil_producer(ecl_sum, "OP_1")); - test_assert_false(ecl_sum_is_oil_producer(ecl_sum, "WI_1")); - test_assert_false(ecl_sum_is_oil_producer(ecl_sum, "DoesNotExist")); +void test_is_oil_producer(const rd_sum_type *rd_sum) { + test_assert_true(rd_sum_is_oil_producer(rd_sum, "OP_1")); + test_assert_false(rd_sum_is_oil_producer(rd_sum, "WI_1")); + test_assert_false(rd_sum_is_oil_producer(rd_sum, "DoesNotExist")); } int main(int argc, char **argv) { const char *case1 = argv[1]; - ecl_sum_type *ecl_sum1 = ecl_sum_fread_alloc_case(case1, ":"); + rd_sum_type *rd_sum1 = rd_sum_fread_alloc_case(case1, ":"); - test_assert_true(ecl_sum_is_instance(ecl_sum1)); - test_time_range(ecl_sum1); - test_days(ecl_sum1); - test_is_oil_producer(ecl_sum1); - ecl_sum_free(ecl_sum1); + test_assert_true(rd_sum_is_instance(rd_sum1)); + test_time_range(rd_sum1); + test_days(rd_sum1); + test_is_oil_producer(rd_sum1); + rd_sum_free(rd_sum1); exit(0); } diff --git a/lib/resdata/tests/rd_sum_writer.cpp b/lib/resdata/tests/rd_sum_writer.cpp index fb4f1ccc10..f4d95304dd 100644 --- a/lib/resdata/tests/rd_sum_writer.cpp +++ b/lib/resdata/tests/rd_sum_writer.cpp @@ -7,53 +7,53 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include double write_summary(const char *name, time_t start_time, int nx, int ny, int nz, int num_dates, int num_ministep, double ministep_length) { - ecl_sum_type *ecl_sum = ecl_sum_alloc_writer(name, false, true, ":", - start_time, true, nx, ny, nz); + rd_sum_type *rd_sum = rd_sum_alloc_writer(name, false, true, ":", + start_time, true, nx, ny, nz); double sim_seconds = 0; - ecl_smspec_type *smspec = ecl_sum_get_smspec(ecl_sum); + rd_smspec_type *smspec = rd_sum_get_smspec(rd_sum); - test_assert_int_equal(ecl_smspec_get_params_size(smspec), 1); - const ecl::smspec_node *node1 = - ecl_smspec_add_node(smspec, "FOPT", "Barrels", 99.0); - const ecl::smspec_node *node2 = - ecl_smspec_add_node(smspec, "BPR", 567, "BARS", 0.0); - const ecl::smspec_node *node3 = - ecl_smspec_add_node(smspec, "WWCT", "OP-1", "(1)", 0.0); - test_assert_int_equal(ecl_smspec_get_params_size(smspec), 4); + test_assert_int_equal(rd_smspec_get_params_size(smspec), 1); + const rd::smspec_node *node1 = + rd_smspec_add_node(smspec, "FOPT", "Barrels", 99.0); + const rd::smspec_node *node2 = + rd_smspec_add_node(smspec, "BPR", 567, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_smspec_add_node(smspec, "WWCT", "OP-1", "(1)", 0.0); + test_assert_int_equal(rd_smspec_get_params_size(smspec), 4); for (int report_step = 0; report_step < num_dates; report_step++) { for (int step = 0; step < num_ministep; step++) { /* Simulate .... */ { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node2, 10 * sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node3, 100 * sim_seconds); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node2, 10 * sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node3, 100 * sim_seconds); test_assert_double_equal( - ecl_sum_tstep_get_from_node(tstep, *node1), sim_seconds); + rd_sum_tstep_get_from_node(tstep, *node1), sim_seconds); test_assert_double_equal( - ecl_sum_tstep_get_from_node(tstep, *node2), + rd_sum_tstep_get_from_node(tstep, *node2), sim_seconds * 10); test_assert_double_equal( - ecl_sum_tstep_get_from_node(tstep, *node3), + rd_sum_tstep_get_from_node(tstep, *node3), sim_seconds * 100); } sim_seconds += ministep_length; } } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); return sim_seconds; } @@ -62,33 +62,33 @@ int write_restart_summary(const char *name, const char *restart_name, time_t start_time, int nx, int ny, int nz, int num_dates, int num_ministep, double ministep_length) { - ecl_sum_type *ecl_sum = ecl_sum_alloc_restart_writer( + rd_sum_type *rd_sum = rd_sum_alloc_restart_writer( name, restart_name, false, true, ":", start_time, true, nx, ny, nz); - ecl_smspec_type *smspec = ecl_sum_get_smspec(ecl_sum); + rd_smspec_type *smspec = rd_sum_get_smspec(rd_sum); - const ecl::smspec_node *node1 = - ecl_smspec_add_node(smspec, "FOPT", "Barrels", 99.0); - const ecl::smspec_node *node2 = - ecl_smspec_add_node(smspec, "BPR", 567, "BARS", 0.0); - const ecl::smspec_node *node3 = - ecl_smspec_add_node(smspec, "WWCT", "OP-1", "(1)", 0.0); + const rd::smspec_node *node1 = + rd_smspec_add_node(smspec, "FOPT", "Barrels", 99.0); + const rd::smspec_node *node2 = + rd_smspec_add_node(smspec, "BPR", 567, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_smspec_add_node(smspec, "WWCT", "OP-1", "(1)", 0.0); int num_report_steps = start_report_step + num_dates; for (int report_step = start_report_step; report_step < num_report_steps; report_step++) { for (int step = 0; step < num_ministep; step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node2, 10 * sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node3, 100 * sim_seconds); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node2, 10 * sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node3, 100 * sim_seconds); } sim_seconds += ministep_length; } } - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); return sim_seconds; } @@ -104,46 +104,46 @@ void test_write_read() { double ministep_length = 86400; // Seconds - numerical value chosen to avoid rounding problems when converting between seconds and days. { - ecl::util::TestArea ta("write_read"); - ecl_sum_type *ecl_sum; + rd::util::TestArea ta("write_read"); + rd_sum_type *rd_sum; write_summary(name, start_time, nx, ny, nz, num_dates, num_ministep, ministep_length); - ecl_sum = ecl_sum_fread_alloc_case(name, ":"); - test_assert_true(ecl_sum_is_instance(ecl_sum)); - test_assert_true(ecl_sum_get_start_time(ecl_sum) == start_time); + rd_sum = rd_sum_fread_alloc_case(name, ":"); + test_assert_true(rd_sum_is_instance(rd_sum)); + test_assert_true(rd_sum_get_start_time(rd_sum) == start_time); /* Time direction */ - test_assert_time_t_equal(start_time, ecl_sum_get_start_time(ecl_sum)); - test_assert_time_t_equal(start_time, ecl_sum_get_data_start(ecl_sum)); + test_assert_time_t_equal(start_time, rd_sum_get_start_time(rd_sum)); + test_assert_time_t_equal(start_time, rd_sum_get_data_start(rd_sum)); util_inplace_forward_seconds_utc( &end_time, (num_dates * num_ministep - 1) * ministep_length); - test_assert_time_t_equal(end_time, ecl_sum_get_end_time(ecl_sum)); + test_assert_time_t_equal(end_time, rd_sum_get_end_time(rd_sum)); /* Keys */ - test_assert_true(ecl_sum_has_key(ecl_sum, "FOPT")); - test_assert_true(ecl_sum_has_key(ecl_sum, "WWCT:OP-1")); - test_assert_true(ecl_sum_has_key(ecl_sum, "BPR:567")); + test_assert_true(rd_sum_has_key(rd_sum, "FOPT")); + test_assert_true(rd_sum_has_key(rd_sum, "WWCT:OP-1")); + test_assert_true(rd_sum_has_key(rd_sum, "BPR:567")); { - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); + rd_grid_type *grid = + rd_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); int i, j, k; char *ijk_key; - ecl_grid_get_ijk1(grid, 567 - 1, &i, &j, &k); + rd_grid_get_ijk1(grid, 567 - 1, &i, &j, &k); ijk_key = util_alloc_sprintf("BPR:%d,%d,%d", i + 1, j + 1, k + 1); free(ijk_key); - ecl_grid_free(grid); + rd_grid_free(grid); } - test_assert_throw(ecl_sum_get_general_var(ecl_sum, 1, "NO_SUCH_KEY"), + test_assert_throw(rd_sum_get_general_var(rd_sum, 1, "NO_SUCH_KEY"), std::out_of_range); - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); } } -void test_ecl_sum_alloc_restart_writer() { - ecl::util::TestArea ta("sum_write_restart"); +void test_rd_sum_alloc_restart_writer() { + rd::util::TestArea ta("sum_write_restart"); { const char *name1 = "CASE1"; const char *name2 = "CASE2"; @@ -162,32 +162,32 @@ void test_ecl_sum_alloc_restart_writer() { name2, name1, num_dates, sim_seconds, start_time, nx, ny, nz, num_dates, num_ministep, ministep_length); - ecl_sum_type *case1 = ecl_sum_fread_alloc_case(name1, ":"); - ecl_sum_type *case2 = ecl_sum_fread_alloc_case(name2, ":"); - test_assert_true(ecl_sum_is_instance(case2)); + rd_sum_type *case1 = rd_sum_fread_alloc_case(name1, ":"); + rd_sum_type *case2 = rd_sum_fread_alloc_case(name2, ":"); + test_assert_true(rd_sum_is_instance(case2)); - test_assert_true(ecl_sum_has_key(case2, "FOPT")); + test_assert_true(rd_sum_has_key(case2, "FOPT")); - ecl_file_type *restart_file = ecl_file_open("CASE2.SMSPEC", 0); - ecl_file_view_type *view_file = ecl_file_get_global_view(restart_file); - test_assert_true(ecl_file_view_has_kw(view_file, RESTART_KW)); - ecl_kw_type *restart_kw = - ecl_file_view_iget_named_kw(view_file, "RESTART", 0); - test_assert_int_equal(8, ecl_kw_get_size(restart_kw)); + rd_file_type *restart_file = rd_file_open("CASE2.SMSPEC", 0); + rd_file_view_type *view_file = rd_file_get_global_view(restart_file); + test_assert_true(rd_file_view_has_kw(view_file, RESTART_KW)); + rd_kw_type *restart_kw = + rd_file_view_iget_named_kw(view_file, "RESTART", 0); + test_assert_int_equal(8, rd_kw_get_size(restart_kw)); test_assert_string_equal("CASE1 ", - (const char *)ecl_kw_iget_ptr(restart_kw, 0)); + (const char *)rd_kw_iget_ptr(restart_kw, 0)); test_assert_string_equal(" ", - (const char *)ecl_kw_iget_ptr(restart_kw, 1)); + (const char *)rd_kw_iget_ptr(restart_kw, 1)); - for (int time_index = 0; time_index < ecl_sum_get_data_length(case1); + for (int time_index = 0; time_index < rd_sum_get_data_length(case1); time_index++) test_assert_double_equal( - ecl_sum_get_general_var(case1, time_index, "FOPT"), - ecl_sum_get_general_var(case2, time_index, "FOPT")); + rd_sum_get_general_var(case1, time_index, "FOPT"), + rd_sum_get_general_var(case2, time_index, "FOPT")); - ecl_sum_free(case2); - ecl_sum_free(case1); - ecl_file_close(restart_file); + rd_sum_free(case2); + rd_sum_free(case1); + rd_file_close(restart_file); } } @@ -199,31 +199,31 @@ void test_long_restart_names() { strcat(restart_case, s); } const char *name = "THE_CASE"; - ecl::util::TestArea ta("suM_write_restart_long_name"); + rd::util::TestArea ta("suM_write_restart_long_name"); { int restart_step = 77; time_t start_time = util_make_date_utc(1, 1, 2010); - ecl_sum_type *ecl_sum = ecl_sum_alloc_restart_writer2( + rd_sum_type *rd_sum = rd_sum_alloc_restart_writer2( name, restart_case, restart_step, false, true, ":", start_time, true, 3, 3, 3); - ecl_sum_fwrite(ecl_sum); - ecl_sum_free(ecl_sum); + rd_sum_fwrite(rd_sum); + rd_sum_free(rd_sum); - ecl_file_type *smspec_file = ecl_file_open("THE_CASE.SMSPEC", 0); - ecl_file_view_type *view_file = ecl_file_get_global_view(smspec_file); - test_assert_true(ecl_file_view_has_kw(view_file, RESTART_KW)); - ecl_kw_type *restart_kw = - ecl_file_view_iget_named_kw(view_file, "RESTART", 0); - test_assert_int_equal(8, ecl_kw_get_size(restart_kw)); + rd_file_type *smspec_file = rd_file_open("THE_CASE.SMSPEC", 0); + rd_file_view_type *view_file = rd_file_get_global_view(smspec_file); + test_assert_true(rd_file_view_has_kw(view_file, RESTART_KW)); + rd_kw_type *restart_kw = + rd_file_view_iget_named_kw(view_file, "RESTART", 0); + test_assert_int_equal(8, rd_kw_get_size(restart_kw)); for (int n = 0; n < 8; n++) { char s[9]; sprintf(s, "WWWWGGG%d", n); - test_assert_string_equal(s, ecl_kw_iget_char_ptr(restart_kw, n)); + test_assert_string_equal(s, rd_kw_iget_char_ptr(restart_kw, n)); } - ecl_file_close(smspec_file); + rd_file_close(smspec_file); { - ecl_smspec_type *smspec = ecl_smspec_alloc_restart_writer( + rd_smspec_type *smspec = rd_smspec_alloc_restart_writer( ":", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ" "KLMNOPQRSTUVWXYZ", @@ -231,8 +231,8 @@ void test_long_restart_names() { /* Restart case is too long - it is ignored. */ - test_assert_NULL(ecl_smspec_get_restart_case(smspec)); - ecl_smspec_free(smspec); + test_assert_NULL(rd_smspec_get_restart_case(smspec)); + rd_smspec_free(smspec); } } } @@ -240,7 +240,7 @@ void test_long_restart_names() { int main(int argc, char **argv) { util_install_signals(); test_write_read(); - test_ecl_sum_alloc_restart_writer(); + test_rd_sum_alloc_restart_writer(); test_long_restart_names(); exit(0); } diff --git a/lib/resdata/tests/rd_unsmry_loader_test.cpp b/lib/resdata/tests/rd_unsmry_loader_test.cpp index 88b7a75f2e..976034667e 100644 --- a/lib/resdata/tests/rd_unsmry_loader_test.cpp +++ b/lib/resdata/tests/rd_unsmry_loader_test.cpp @@ -3,47 +3,47 @@ #include #include -#include +#include -#include "detail/ecl/ecl_unsmry_loader.hpp" +#include "detail/resdata/rd_unsmry_loader.hpp" -ecl_sum_type *write_ecl_sum() { +rd_sum_type *write_rd_sum() { time_t start_time = util_make_date_utc(1, 1, 2010); - ecl_sum_type *ecl_sum = ecl_sum_alloc_writer("CASE", false, true, ":", - start_time, true, 10, 10, 10); + rd_sum_type *rd_sum = rd_sum_alloc_writer("CASE", false, true, ":", + start_time, true, 10, 10, 10); double sim_seconds = 0; int num_dates = 4; double ministep_length = 86400; // seconds in a day - const ecl::smspec_node *node1 = - ecl_sum_add_var(ecl_sum, "FOPT", NULL, 0, "Barrels", 99.0); - const ecl::smspec_node *node2 = - ecl_sum_add_var(ecl_sum, "BPR", NULL, 567, "BARS", 0.0); - const ecl::smspec_node *node3 = - ecl_sum_add_var(ecl_sum, "WWCT", "OP-1", 0, "(1)", 0.0); + const rd::smspec_node *node1 = + rd_sum_add_var(rd_sum, "FOPT", NULL, 0, "Barrels", 99.0); + const rd::smspec_node *node2 = + rd_sum_add_var(rd_sum, "BPR", NULL, 567, "BARS", 0.0); + const rd::smspec_node *node3 = + rd_sum_add_var(rd_sum, "WWCT", "OP-1", 0, "(1)", 0.0); for (int report_step = 0; report_step < num_dates; report_step++) { { - ecl_sum_tstep_type *tstep = - ecl_sum_add_tstep(ecl_sum, report_step + 1, sim_seconds); - ecl_sum_tstep_set_from_node(tstep, *node1, report_step * 2.0); - ecl_sum_tstep_set_from_node(tstep, *node2, report_step * 4.0 + 2.0); - ecl_sum_tstep_set_from_node(tstep, *node3, report_step * 6.0 + 4.0); + rd_sum_tstep_type *tstep = + rd_sum_add_tstep(rd_sum, report_step + 1, sim_seconds); + rd_sum_tstep_set_from_node(tstep, *node1, report_step * 2.0); + rd_sum_tstep_set_from_node(tstep, *node2, report_step * 4.0 + 2.0); + rd_sum_tstep_set_from_node(tstep, *node3, report_step * 6.0 + 4.0); } sim_seconds += ministep_length * 3; } - ecl_sum_fwrite(ecl_sum); - return ecl_sum; + rd_sum_fwrite(rd_sum); + return rd_sum; } void test_load() { - ecl::util::TestArea ta("ecl_sum_loader"); - ecl_sum_type *ecl_sum = write_ecl_sum(); + rd::util::TestArea ta("rd_sum_loader"); + rd_sum_type *rd_sum = write_rd_sum(); test_assert_true(util_file_exists("CASE.SMSPEC")); test_assert_true(util_file_exists("CASE.UNSMRY")); - ecl::unsmry_loader *loader = - new ecl::unsmry_loader(ecl_sum_get_smspec(ecl_sum), "CASE.UNSMRY", 0); + rd::unsmry_loader *loader = + new rd::unsmry_loader(rd_sum_get_smspec(rd_sum), "CASE.UNSMRY", 0); const std::vector FOPT_value = loader->get_vector(1); const std::vector BPR_value = loader->get_vector(2); @@ -54,7 +54,7 @@ void test_load() { test_assert_double_equal(WWCT_value[1], 10.0); delete loader; - ecl_sum_free(ecl_sum); + rd_sum_free(rd_sum); } int main() { diff --git a/lib/resdata/tests/rd_util_filenames.cpp b/lib/resdata/tests/rd_util_filenames.cpp index 0570a0962f..1311f5581e 100644 --- a/lib/resdata/tests/rd_util_filenames.cpp +++ b/lib/resdata/tests/rd_util_filenames.cpp @@ -6,28 +6,23 @@ #include #include -#include +#include void test_filename_report_nr() { test_assert_int_equal( - 78, ecl_util_filename_report_nr("Path/with/mixedCASE/case.x0078")); - test_assert_int_equal(78, ecl_util_filename_report_nr("Case.X0078")); + 78, rd_filename_report_nr("Path/with/mixedCASE/case.x0078")); + test_assert_int_equal(78, rd_filename_report_nr("Case.X0078")); test_assert_int_equal( - ECL_EGRID_FILE, - ecl_util_get_file_type("path/WITH/xase/MyGrid.EGrid", NULL, NULL)); + RD_EGRID_FILE, + rd_get_file_type("path/WITH/xase/MyGrid.EGrid", NULL, NULL)); } void test_filename_case() { - char *f1 = - ecl_util_alloc_filename(NULL, "mixedBase", ECL_EGRID_FILE, false, -1); - char *f2 = - ecl_util_alloc_filename(NULL, "UPPER", ECL_EGRID_FILE, false, -1); - char *f3 = - ecl_util_alloc_filename(NULL, "lower", ECL_EGRID_FILE, false, -1); - char *f4 = - ecl_util_alloc_filename(NULL, "lower1", ECL_EGRID_FILE, false, -1); - char *f5 = - ecl_util_alloc_filename(NULL, "UPPER1", ECL_EGRID_FILE, false, -1); + char *f1 = rd_alloc_filename(NULL, "mixedBase", RD_EGRID_FILE, false, -1); + char *f2 = rd_alloc_filename(NULL, "UPPER", RD_EGRID_FILE, false, -1); + char *f3 = rd_alloc_filename(NULL, "lower", RD_EGRID_FILE, false, -1); + char *f4 = rd_alloc_filename(NULL, "lower1", RD_EGRID_FILE, false, -1); + char *f5 = rd_alloc_filename(NULL, "UPPER1", RD_EGRID_FILE, false, -1); test_assert_string_equal(f1, "mixedBase.EGRID"); test_assert_string_equal(f2, "UPPER.EGRID"); @@ -43,12 +38,11 @@ void test_filename_case() { } void test_file_list() { - ecl::util::TestArea ta("file_list"); + rd::util::TestArea ta("file_list"); stringlist_type *s = stringlist_alloc_new(); for (int i = 0; i < 10; i += 2) { - char *fname = - ecl_util_alloc_filename(NULL, "case", ECL_RESTART_FILE, true, i); + char *fname = rd_alloc_filename(NULL, "case", RD_RESTART_FILE, true, i); FILE *stream = util_fopen(fname, "w"); fclose(stream); free(fname); @@ -68,26 +62,26 @@ void test_file_list() { free(fname); } - ecl_util_select_filelist(NULL, "case", ECL_RESTART_FILE, true, s); + rd_select_filelist(NULL, "case", RD_RESTART_FILE, true, s); test_assert_int_equal(stringlist_get_size(s), 5); for (int i = 0; i < 5; i++) { - char *fname = ecl_util_alloc_filename(NULL, "case", ECL_RESTART_FILE, - true, 2 * i); + char *fname = + rd_alloc_filename(NULL, "case", RD_RESTART_FILE, true, 2 * i); test_assert_string_equal(fname, stringlist_iget(s, i)); free(fname); } - ecl_util_select_filelist(NULL, "CaseMiXed", ECL_RESTART_FILE, true, s); + rd_select_filelist(NULL, "CaseMiXed", RD_RESTART_FILE, true, s); test_assert_int_equal(stringlist_get_size(s), 5); util_make_path("path"); for (int i = 0; i < 10; i++) { - char *summary_file1 = ecl_util_alloc_filename( - "path", "CASE1", ECL_SUMMARY_FILE, false, i); + char *summary_file1 = + rd_alloc_filename("path", "CASE1", RD_SUMMARY_FILE, false, i); char *summary_file2 = - ecl_util_alloc_filename("path", "CASE2", ECL_SUMMARY_FILE, true, i); - char *restart_file1 = ecl_util_alloc_filename( - "path", "CASE1", ECL_RESTART_FILE, false, i); + rd_alloc_filename("path", "CASE2", RD_SUMMARY_FILE, true, i); + char *restart_file1 = + rd_alloc_filename("path", "CASE1", RD_RESTART_FILE, false, i); FILE *f1 = fopen(summary_file1, "w"); fclose(f1); @@ -104,22 +98,22 @@ void test_file_list() { } printf( "-----------------------------------------------------------------\n"); - ecl_util_select_filelist(NULL, "path/CASE1", ECL_SUMMARY_FILE, false, s); + rd_select_filelist(NULL, "path/CASE1", RD_SUMMARY_FILE, false, s); test_assert_int_equal(stringlist_get_size(s), 10); - ecl_util_select_filelist(NULL, "path/CASE1", ECL_SUMMARY_FILE, true, s); + rd_select_filelist(NULL, "path/CASE1", RD_SUMMARY_FILE, true, s); test_assert_int_equal(stringlist_get_size(s), 0); - ecl_util_select_filelist(NULL, "path/CASE2", ECL_SUMMARY_FILE, true, s); + rd_select_filelist(NULL, "path/CASE2", RD_SUMMARY_FILE, true, s); test_assert_int_equal(stringlist_get_size(s), 10); - ecl_util_select_filelist("path", "CASE1", ECL_SUMMARY_FILE, false, s); + rd_select_filelist("path", "CASE1", RD_SUMMARY_FILE, false, s); test_assert_int_equal(stringlist_get_size(s), 10); - ecl_util_select_filelist("path", "CASE1", ECL_SUMMARY_FILE, true, s); + rd_select_filelist("path", "CASE1", RD_SUMMARY_FILE, true, s); test_assert_int_equal(stringlist_get_size(s), 0); - ecl_util_select_filelist("path", "CASE2", ECL_SUMMARY_FILE, true, s); + rd_select_filelist("path", "CASE2", RD_SUMMARY_FILE, true, s); test_assert_int_equal(stringlist_get_size(s), 10); stringlist_free(s); diff --git a/lib/resdata/tests/rd_util_make_date_no_shift.cpp b/lib/resdata/tests/rd_util_make_date_no_shift.cpp index 20466a714e..78bd60d578 100644 --- a/lib/resdata/tests/rd_util_make_date_no_shift.cpp +++ b/lib/resdata/tests/rd_util_make_date_no_shift.cpp @@ -5,10 +5,10 @@ #include #include -#include +#include void test_date(int mday, int month, int year) { - time_t t0 = ecl_util_make_date(mday, month, year); + time_t t0 = rd_make_date(mday, month, year); time_t t1 = util_make_date_utc(mday, month, year); test_assert_time_t_equal(t0, t1); @@ -16,7 +16,7 @@ void test_date(int mday, int month, int year) { void test_offset(int mday, int month, int year) { int year_offset; - ecl_util_make_date__(mday, month, year, &year_offset); + rd_make_date__(mday, month, year, &year_offset); test_assert_int_equal(0, year_offset); } diff --git a/lib/resdata/tests/rd_util_make_date_shift.cpp b/lib/resdata/tests/rd_util_make_date_shift.cpp index ef90275bfa..b745bc39ca 100644 --- a/lib/resdata/tests/rd_util_make_date_shift.cpp +++ b/lib/resdata/tests/rd_util_make_date_shift.cpp @@ -5,17 +5,17 @@ #include #include -#include +#include void test_date(int mday, int month, int year, int *year_offset) { - time_t t0 = ecl_util_make_date__(mday, month, year, year_offset); + time_t t0 = rd_make_date__(mday, month, year, year_offset); time_t t1 = util_make_date_utc(mday, month, year + *year_offset); test_assert_time_t_equal(t0, t1); } void test_offset(int mday, int month, int year, int current_offset) { int year_offset; - time_t t0 = ecl_util_make_date__(mday, month, year, &year_offset); + time_t t0 = rd_make_date__(mday, month, year, &year_offset); time_t t1 = util_make_date_utc(mday, month, year + current_offset); test_assert_time_t_equal(t0, t1); diff --git a/lib/resdata/tests/rd_util_month_range.cpp b/lib/resdata/tests/rd_util_month_range.cpp index d12d3c46e3..b9cede0b21 100644 --- a/lib/resdata/tests/rd_util_month_range.cpp +++ b/lib/resdata/tests/rd_util_month_range.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include void test_body(time_t_vector_type *date_list, int offset) { int i; @@ -39,7 +39,7 @@ void test_append(const char *name, time_t_vector_type *date_list, time_t date1, printf("%s ...", name); fflush(stdout); - ecl_util_append_month_range(date_list, date1, date2, force_append_end); + rd_append_month_range(date_list, date1, date2, force_append_end); // The start: test_assert_true(util_make_pure_date_utc(date1) <= @@ -64,7 +64,7 @@ void test_init(const char *name, time_t_vector_type *date_list, printf("%s ...", name); fflush(stdout); { - ecl_util_init_month_range(date_list, start_date, end_date); + rd_init_month_range(date_list, start_date, end_date); test_assert_time_t_equal(time_t_vector_get_first(date_list), util_make_pure_date_utc(start_date)); test_body(date_list, 1); diff --git a/lib/resdata/tests/rd_util_path_access.cpp b/lib/resdata/tests/rd_util_path_access.cpp index 1bb8882f5b..bf8fb997cc 100644 --- a/lib/resdata/tests/rd_util_path_access.cpp +++ b/lib/resdata/tests/rd_util_path_access.cpp @@ -6,26 +6,26 @@ #include #include -#include +#include void test_relative_access() { - ecl::util::TestArea ta("ecl_access"); - test_assert_false(ecl_util_path_access("No/directory/does/not/exist")); + rd::util::TestArea ta("rd_access"); + test_assert_false(rd_path_access("No/directory/does/not/exist")); util_make_path("path"); - test_assert_true(ecl_util_path_access("path")); - test_assert_true(ecl_util_path_access("path/FILE_DOES_NOT_EXIST")); + test_assert_true(rd_path_access("path")); + test_assert_true(rd_path_access("path/FILE_DOES_NOT_EXIST")); { FILE *f = util_fopen("path/file", "w"); fprintf(f, "Hello\n"); fclose(f); } - test_assert_true(ecl_util_path_access("path/file")); + test_assert_true(rd_path_access("path/file")); chmod("path/file", 0); - test_assert_false(ecl_util_path_access("path/file")); + test_assert_false(rd_path_access("path/file")); - test_assert_true(ecl_util_path_access("ECLIPSE_CASE")); + test_assert_true(rd_path_access("ECLIPSE_CASE")); } int main(int argc, char **argv) { test_relative_access(); } diff --git a/lib/resdata/tests/rd_valid_basename.cpp b/lib/resdata/tests/rd_valid_basename.cpp index 7c8823a9b3..b19e84e9ed 100644 --- a/lib/resdata/tests/rd_valid_basename.cpp +++ b/lib/resdata/tests/rd_valid_basename.cpp @@ -1,17 +1,17 @@ #include -#include +#include int main(int argc, char **argv) { - test_assert_true(ecl_util_valid_basename_fmt("ecl_%d.data")); - test_assert_true(ecl_util_valid_basename_fmt("ECL_%d.DATA")); - test_assert_true(ecl_util_valid_basename_fmt("ECL_%04d.DATA")); - test_assert_true(ecl_util_valid_basename_fmt("mypath/ECL_%04d.DATA")); - test_assert_true(ecl_util_valid_basename_fmt("MYPATH/ECL_%04d.DATA")); - test_assert_true(ecl_util_valid_basename_fmt("MYPATH/ECL_%04d.DATA")); - test_assert_true(ecl_util_valid_basename_fmt("ECL_%d.dATA")); - test_assert_false(ecl_util_valid_basename_fmt("ECL_%s.DATA")); - test_assert_false(ecl_util_valid_basename_fmt("ECL_%f.DATA")); - test_assert_true(ecl_util_valid_basename_fmt("mypath/ECL_%d.dATA")); + test_assert_true(rd_valid_basename_fmt("rd_%d.data")); + test_assert_true(rd_valid_basename_fmt("RD_%d.DATA")); + test_assert_true(rd_valid_basename_fmt("RD_%04d.DATA")); + test_assert_true(rd_valid_basename_fmt("mypath/RD_%04d.DATA")); + test_assert_true(rd_valid_basename_fmt("MYPATH/RD_%04d.DATA")); + test_assert_true(rd_valid_basename_fmt("MYPATH/RD_%04d.DATA")); + test_assert_true(rd_valid_basename_fmt("RD_%d.dATA")); + test_assert_false(rd_valid_basename_fmt("RD_%s.DATA")); + test_assert_false(rd_valid_basename_fmt("RD_%f.DATA")); + test_assert_true(rd_valid_basename_fmt("mypath/RD_%d.dATA")); exit(0); } diff --git a/lib/resdata/tests/rft_test.cpp b/lib/resdata/tests/rft_test.cpp index 21123afe90..15fe4a7a8d 100644 --- a/lib/resdata/tests/rft_test.cpp +++ b/lib/resdata/tests/rft_test.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include @@ -8,8 +8,8 @@ int main(int argc, char **argv) { util_exit("I want one RFT file - try again \n"); { const char *filename = argv[1]; - ecl_rft_file_type *rft_file = ecl_rft_file_alloc(filename); - stringlist_type *wells = ecl_rft_file_alloc_well_list(rft_file); + rd_rft_file_type *rft_file = rd_rft_file_alloc(filename); + stringlist_type *wells = rd_rft_file_alloc_well_list(rft_file); printf("\n"); { @@ -20,11 +20,11 @@ int main(int argc, char **argv) { { int it; for (it = 0; - it < ecl_rft_file_get_well_occurences(rft_file, well); + it < rd_rft_file_get_well_occurences(rft_file, well); it++) { - const ecl_rft_node_type *node = - ecl_rft_file_iget_well_rft(rft_file, well, it); - time_t date = ecl_rft_node_get_date(node); + const rd_rft_node_type *node = + rd_rft_file_iget_well_rft(rft_file, well, it); + time_t date = rd_rft_node_get_date(node); { int mday, year, month; util_set_date_values(date, &mday, &month, &year); @@ -32,21 +32,20 @@ int main(int argc, char **argv) { printf(" %02d/%02d/%4d \n", mday, month, year); { - int num_cells = ecl_rft_node_get_size(node); + int num_cells = rd_rft_node_get_size(node); int icell; for (icell = 0; icell < num_cells; icell++) { int i, j, k; - ecl_rft_node_iget_ijk(node, icell, &i, &j, - &k); + rd_rft_node_iget_ijk(node, icell, &i, &j, + &k); printf(" \n"); - printf(" %g " - " \n", - ecl_rft_node_iget_pressure(node, - icell)); printf( - " %g " - " \n", - ecl_rft_node_iget_depth(node, icell)); + " %g " + " \n", + rd_rft_node_iget_pressure(node, icell)); + printf(" %g " + " \n", + rd_rft_node_iget_depth(node, icell)); printf(" %3d,%3d,%3d " " \n", i, j, k); @@ -61,6 +60,6 @@ int main(int argc, char **argv) { } } printf("\n"); - ecl_rft_file_free(rft_file); + rd_rft_file_free(rft_file); } } diff --git a/lib/resdata/tests/test_rd_file_index.cpp b/lib/resdata/tests/test_rd_file_index.cpp index e8bdc82be5..145e791b7b 100644 --- a/lib/resdata/tests/test_rd_file_index.cpp +++ b/lib/resdata/tests/test_rd_file_index.cpp @@ -5,82 +5,82 @@ #include #include -#include -#include +#include +#include void test_load_nonexisting_file() { - ecl_file_type *ecl_file = ecl_file_fast_open( - "base_file", "a_file_that_does_not_exist_2384623", 0); - test_assert_NULL(ecl_file); + rd_file_type *rd_file = + rd_file_fast_open("base_file", "a_file_that_does_not_exist_2384623", 0); + test_assert_NULL(rd_file); } void test_create_and_load_index_file() { - ecl::util::TestArea ta("Load_index"); + rd::util::TestArea ta("Load_index"); { const char *file_name = "initial_data_file"; const char *index_file_name = "index_file"; //creating the data file int data_size = 10; - ecl_kw_type *kw1 = ecl_kw_alloc("TEST1_KW", data_size, ECL_INT); + rd_kw_type *kw1 = rd_kw_alloc("TEST1_KW", data_size, RD_INT); for (int i = 0; i < data_size; ++i) - ecl_kw_iset_int(kw1, i, 537 + i); + rd_kw_iset_int(kw1, i, 537 + i); fortio_type *fortio = - fortio_open_writer(file_name, false, ECL_ENDIAN_FLIP); - ecl_kw_fwrite(kw1, fortio); + fortio_open_writer(file_name, false, RD_ENDIAN_FLIP); + rd_kw_fwrite(kw1, fortio); data_size = 5; - ecl_kw_type *kw2 = ecl_kw_alloc("TEST2_KW", data_size, ECL_FLOAT); + rd_kw_type *kw2 = rd_kw_alloc("TEST2_KW", data_size, RD_FLOAT); for (int i = 0; i < data_size; ++i) - ecl_kw_iset_float(kw2, i, 0.15 * i); - ecl_kw_fwrite(kw2, fortio); + rd_kw_iset_float(kw2, i, 0.15 * i); + rd_kw_fwrite(kw2, fortio); fortio_fclose(fortio); //finished creating data file - //creating ecl_file - ecl_file_type *ecl_file = ecl_file_open(file_name, 0); - test_assert_true(ecl_file_has_kw(ecl_file, "TEST1_KW")); - ecl_file_write_index(ecl_file, index_file_name); - int ecl_file_size = ecl_file_get_size(ecl_file); - ecl_file_close(ecl_file); - //finished using ecl_file + //creating rd_file + rd_file_type *rd_file = rd_file_open(file_name, 0); + test_assert_true(rd_file_has_kw(rd_file, "TEST1_KW")); + rd_file_write_index(rd_file, index_file_name); + int rd_file_size = rd_file_get_size(rd_file); + rd_file_close(rd_file); + //finished using rd_file - test_assert_false(ecl_file_index_valid(file_name, "nofile")); - test_assert_false(ecl_file_index_valid("nofile", index_file_name)); + test_assert_false(rd_file_index_valid(file_name, "nofile")); + test_assert_false(rd_file_index_valid("nofile", index_file_name)); struct utimbuf tm1 = {1, 1}; struct utimbuf tm2 = {2, 2}; utime(file_name, &tm2); utime(index_file_name, &tm1); - test_assert_false(ecl_file_index_valid(file_name, index_file_name)); + test_assert_false(rd_file_index_valid(file_name, index_file_name)); utime(file_name, &tm1); utime(index_file_name, &tm2); - test_assert_true(ecl_file_index_valid(file_name, index_file_name)); + test_assert_true(rd_file_index_valid(file_name, index_file_name)); - ecl_file_type *ecl_file_index = - ecl_file_fast_open(file_name, index_file_name, 0); - test_assert_true(ecl_file_is_instance(ecl_file_index)); - test_assert_true(ecl_file_get_global_view(ecl_file_index)); + rd_file_type *rd_file_index = + rd_file_fast_open(file_name, index_file_name, 0); + test_assert_true(rd_file_is_instance(rd_file_index)); + test_assert_true(rd_file_get_global_view(rd_file_index)); - test_assert_int_equal(ecl_file_size, ecl_file_get_size(ecl_file_index)); + test_assert_int_equal(rd_file_size, rd_file_get_size(rd_file_index)); - test_assert_true(ecl_file_has_kw(ecl_file_index, "TEST1_KW")); - test_assert_true(ecl_file_has_kw(ecl_file_index, "TEST2_KW")); + test_assert_true(rd_file_has_kw(rd_file_index, "TEST1_KW")); + test_assert_true(rd_file_has_kw(rd_file_index, "TEST2_KW")); - ecl_kw_type *kwi1 = ecl_file_iget_kw(ecl_file_index, 0); - test_assert_true(ecl_kw_equal(kw1, kwi1)); - test_assert_double_equal(537.0, ecl_kw_iget_as_double(kwi1, 0)); - test_assert_double_equal(546.0, ecl_kw_iget_as_double(kwi1, 9)); + rd_kw_type *kwi1 = rd_file_iget_kw(rd_file_index, 0); + test_assert_true(rd_kw_equal(kw1, kwi1)); + test_assert_double_equal(537.0, rd_kw_iget_as_double(kwi1, 0)); + test_assert_double_equal(546.0, rd_kw_iget_as_double(kwi1, 9)); - ecl_kw_type *kwi2 = ecl_file_iget_kw(ecl_file_index, 1); - test_assert_true(ecl_kw_equal(kw2, kwi2)); - test_assert_double_equal(0.15, ecl_kw_iget_as_double(kwi2, 1)); - test_assert_double_equal(0.60, ecl_kw_iget_as_double(kwi2, 4)); + rd_kw_type *kwi2 = rd_file_iget_kw(rd_file_index, 1); + test_assert_true(rd_kw_equal(kw2, kwi2)); + test_assert_double_equal(0.15, rd_kw_iget_as_double(kwi2, 1)); + test_assert_double_equal(0.60, rd_kw_iget_as_double(kwi2, 4)); - ecl_kw_free(kw1); - ecl_kw_free(kw2); - ecl_file_close(ecl_file_index); + rd_kw_free(kw1); + rd_kw_free(kw2); + rd_file_close(rd_file_index); } } diff --git a/lib/resdata/tests/test_rd_nnc_data.cpp b/lib/resdata/tests/test_rd_nnc_data.cpp index 5be67eb1c1..a9ed959598 100644 --- a/lib/resdata/tests/test_rd_nnc_data.cpp +++ b/lib/resdata/tests/test_rd_nnc_data.cpp @@ -1,62 +1,62 @@ -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include void test_alloc_global_only(bool data_in_file) { - ecl::util::TestArea ta("nnc-INIT"); + rd::util::TestArea ta("nnc-INIT"); { int nx = 10; int ny = 10; int nz = 10; - ecl_grid_type *grid0 = - ecl_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); + rd_grid_type *grid0 = + rd_grid_alloc_rectangular(nx, ny, nz, 1, 1, 1, NULL); - ecl_grid_add_self_nnc(grid0, 0, nx * ny + 0, 0); - ecl_grid_add_self_nnc(grid0, 1, nx * ny + 1, 1); - ecl_grid_add_self_nnc(grid0, 2, nx * ny + 2, 2); + rd_grid_add_self_nnc(grid0, 0, nx * ny + 0, 0); + rd_grid_add_self_nnc(grid0, 1, nx * ny + 1, 1); + rd_grid_add_self_nnc(grid0, 2, nx * ny + 2, 2); { - ecl_nnc_geometry_type *nnc_geo = ecl_nnc_geometry_alloc(grid0); - test_assert_int_equal(ecl_nnc_geometry_size(nnc_geo), 3); + rd_nnc_geometry_type *nnc_geo = rd_nnc_geometry_alloc(grid0); + test_assert_int_equal(rd_nnc_geometry_size(nnc_geo), 3); /* Create a dummy INIT file which *ony* contains a TRANNC keyword with the correct size. */ { - ecl_kw_type *trann_nnc = ecl_kw_alloc( - TRANNNC_KW, ecl_nnc_geometry_size(nnc_geo), ECL_FLOAT); + rd_kw_type *trann_nnc = rd_kw_alloc( + TRANNNC_KW, rd_nnc_geometry_size(nnc_geo), RD_FLOAT); fortio_type *f = - fortio_open_writer("TEST.INIT", false, ECL_ENDIAN_FLIP); + fortio_open_writer("TEST.INIT", false, RD_ENDIAN_FLIP); if (data_in_file) { - for (int i = 0; i < ecl_kw_get_size(trann_nnc); i++) - ecl_kw_iset_float(trann_nnc, i, i * 1.5); + for (int i = 0; i < rd_kw_get_size(trann_nnc); i++) + rd_kw_iset_float(trann_nnc, i, i * 1.5); - ecl_kw_fwrite(trann_nnc, f); + rd_kw_fwrite(trann_nnc, f); } fortio_fclose(f); - ecl_kw_free(trann_nnc); + rd_kw_free(trann_nnc); } - ecl_file_type *init_file = ecl_file_open("TEST.INIT", 0); - ecl_file_view_type *view_file = ecl_file_get_global_view(init_file); + rd_file_type *init_file = rd_file_open("TEST.INIT", 0); + rd_file_view_type *view_file = rd_file_get_global_view(init_file); - ecl_nnc_data_type *nnc_geo_data = - ecl_nnc_data_alloc_tran(grid0, nnc_geo, view_file); + rd_nnc_data_type *nnc_geo_data = + rd_nnc_data_alloc_tran(grid0, nnc_geo, view_file); if (data_in_file) { - int nnc_data_size = ecl_nnc_data_get_size(nnc_geo_data); - test_assert_true(ecl_file_view_has_kw(view_file, TRANNNC_KW)); + int nnc_data_size = rd_nnc_data_get_size(nnc_geo_data); + test_assert_true(rd_file_view_has_kw(view_file, TRANNNC_KW)); test_assert_true(nnc_data_size == 3); - const double *values = ecl_nnc_data_get_values(nnc_geo_data); + const double *values = rd_nnc_data_get_values(nnc_geo_data); test_assert_double_equal(values[0], 0); test_assert_double_equal(values[1], 1.5); test_assert_double_equal(values[2], 3.0); @@ -64,11 +64,11 @@ void test_alloc_global_only(bool data_in_file) { test_assert_NULL(nnc_geo_data); if (data_in_file) - ecl_nnc_data_free(nnc_geo_data); - ecl_nnc_geometry_free(nnc_geo); - ecl_file_close(init_file); + rd_nnc_data_free(nnc_geo_data); + rd_nnc_geometry_free(nnc_geo); + rd_file_close(init_file); } - ecl_grid_free(grid0); + rd_grid_free(grid0); } } diff --git a/lib/resdata/tests/test_transactions.cpp b/lib/resdata/tests/test_transactions.cpp index 181a72e0d6..bd04f0632c 100644 --- a/lib/resdata/tests/test_transactions.cpp +++ b/lib/resdata/tests/test_transactions.cpp @@ -7,12 +7,12 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* This test is slightly awkward beacuse it tests quite internal implementation details. @@ -20,73 +20,73 @@ void test_transaction() { - ecl::util::TestArea ta("index_testing"); + rd::util::TestArea ta("index_testing"); { const char *file_name = "data_file"; fortio_type *fortio = - fortio_open_writer(file_name, false, ECL_ENDIAN_FLIP); + fortio_open_writer(file_name, false, RD_ENDIAN_FLIP); //creating the data file int data_size = 10; - ecl_kw_type *kw1 = ecl_kw_alloc("TEST1_KW", data_size, ECL_INT); + rd_kw_type *kw1 = rd_kw_alloc("TEST1_KW", data_size, RD_INT); for (int i = 0; i < data_size; ++i) - ecl_kw_iset_int(kw1, i, 537 + i); - ecl_kw_fwrite(kw1, fortio); + rd_kw_iset_int(kw1, i, 537 + i); + rd_kw_fwrite(kw1, fortio); data_size = 5; - ecl_kw_type *kw2 = ecl_kw_alloc("TEST2_KW", data_size, ECL_FLOAT); + rd_kw_type *kw2 = rd_kw_alloc("TEST2_KW", data_size, RD_FLOAT); for (int i = 0; i < data_size; ++i) - ecl_kw_iset_float(kw2, i, 0.15 * i); - ecl_kw_fwrite(kw2, fortio); + rd_kw_iset_float(kw2, i, 0.15 * i); + rd_kw_fwrite(kw2, fortio); data_size = 3; - ecl_kw_type *kw3 = ecl_kw_alloc("TEST3_KW", data_size, ECL_FLOAT); + rd_kw_type *kw3 = rd_kw_alloc("TEST3_KW", data_size, RD_FLOAT); for (int i = 0; i < data_size; i++) - ecl_kw_iset_float(kw3, i, 0.45 * i); - ecl_kw_fwrite(kw3, fortio); + rd_kw_iset_float(kw3, i, 0.45 * i); + rd_kw_fwrite(kw3, fortio); fortio_fclose(fortio); //finished creating data file - ecl_file_type *file = ecl_file_open(file_name, 0); - ecl_file_view_type *file_view = ecl_file_get_global_view(file); - ecl_file_kw_type *file_kw0 = ecl_file_view_iget_file_kw(file_view, 0); - ecl_file_kw_type *file_kw1 = ecl_file_view_iget_file_kw(file_view, 1); - ecl_file_kw_type *file_kw2 = ecl_file_view_iget_file_kw(file_view, 2); - - ecl_file_view_iget_kw(file_view, 0); - test_assert_true(ecl_file_kw_get_kw_ptr(file_kw0)); - test_assert_false(ecl_file_kw_get_kw_ptr(file_kw1)); - test_assert_false(ecl_file_kw_get_kw_ptr(file_kw2)); - ecl_file_transaction_type *t1 = - ecl_file_view_start_transaction(file_view); - - ecl_file_view_iget_kw(file_view, 0); - ecl_file_view_iget_kw(file_view, 1); - ecl_file_transaction_type *t2 = - ecl_file_view_start_transaction(file_view); - - ecl_file_view_iget_kw(file_view, 0); - ecl_file_view_iget_kw(file_view, 1); - ecl_file_view_iget_kw(file_view, 1); - ecl_file_view_iget_kw(file_view, 2); - - ecl_file_view_end_transaction(file_view, t2); - - test_assert_true(ecl_file_kw_get_kw_ptr(file_kw0)); - test_assert_true(ecl_file_kw_get_kw_ptr(file_kw1)); - test_assert_false(ecl_file_kw_get_kw_ptr(file_kw2)); - ecl_file_view_iget_kw(file_view, 2); - - ecl_file_view_end_transaction(file_view, t1); - test_assert_true(ecl_file_kw_get_kw_ptr(file_kw0)); - test_assert_false(ecl_file_kw_get_kw_ptr(file_kw1)); - test_assert_false(ecl_file_kw_get_kw_ptr(file_kw2)); - - ecl_file_close(file); - ecl_kw_free(kw1); - ecl_kw_free(kw2); - ecl_kw_free(kw3); + rd_file_type *file = rd_file_open(file_name, 0); + rd_file_view_type *file_view = rd_file_get_global_view(file); + rd_file_kw_type *file_kw0 = rd_file_view_iget_file_kw(file_view, 0); + rd_file_kw_type *file_kw1 = rd_file_view_iget_file_kw(file_view, 1); + rd_file_kw_type *file_kw2 = rd_file_view_iget_file_kw(file_view, 2); + + rd_file_view_iget_kw(file_view, 0); + test_assert_true(rd_file_kw_get_kw_ptr(file_kw0)); + test_assert_false(rd_file_kw_get_kw_ptr(file_kw1)); + test_assert_false(rd_file_kw_get_kw_ptr(file_kw2)); + rd_file_transaction_type *t1 = + rd_file_view_start_transaction(file_view); + + rd_file_view_iget_kw(file_view, 0); + rd_file_view_iget_kw(file_view, 1); + rd_file_transaction_type *t2 = + rd_file_view_start_transaction(file_view); + + rd_file_view_iget_kw(file_view, 0); + rd_file_view_iget_kw(file_view, 1); + rd_file_view_iget_kw(file_view, 1); + rd_file_view_iget_kw(file_view, 2); + + rd_file_view_end_transaction(file_view, t2); + + test_assert_true(rd_file_kw_get_kw_ptr(file_kw0)); + test_assert_true(rd_file_kw_get_kw_ptr(file_kw1)); + test_assert_false(rd_file_kw_get_kw_ptr(file_kw2)); + rd_file_view_iget_kw(file_view, 2); + + rd_file_view_end_transaction(file_view, t1); + test_assert_true(rd_file_kw_get_kw_ptr(file_kw0)); + test_assert_false(rd_file_kw_get_kw_ptr(file_kw1)); + test_assert_false(rd_file_kw_get_kw_ptr(file_kw2)); + + rd_file_close(file); + rd_kw_free(kw1); + rd_kw_free(kw2); + rd_kw_free(kw3); } } diff --git a/lib/resdata/tests/well_branch_collection.cpp b/lib/resdata/tests/well_branch_collection.cpp index d67e03b945..3644d4f1c9 100644 --- a/lib/resdata/tests/well_branch_collection.cpp +++ b/lib/resdata/tests/well_branch_collection.cpp @@ -5,11 +5,11 @@ #include #include -#include +#include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); diff --git a/lib/resdata/tests/well_conn.cpp b/lib/resdata/tests/well_conn.cpp index 67a2b76a97..60612a1c37 100644 --- a/lib/resdata/tests/well_conn.cpp +++ b/lib/resdata/tests/well_conn.cpp @@ -5,10 +5,10 @@ #include #include -#include +#include -#include -#include +#include +#include void test_conn_rate() { int i = 10; diff --git a/lib/resdata/tests/well_conn_CF.cpp b/lib/resdata/tests/well_conn_CF.cpp index 193f8f9145..c316289d83 100644 --- a/lib/resdata/tests/well_conn_CF.cpp +++ b/lib/resdata/tests/well_conn_CF.cpp @@ -5,18 +5,18 @@ #include #include -#include -#include -#include -#include - -#include -#include -#include - -void well_conn_test_CF(const ecl_kw_type *iwel_kw, const ecl_kw_type *icon_kw, - const ecl_kw_type *scon_kw, const ecl_kw_type *xcon_kw, - const ecl_rsthead_type *rst_head, int iwell, int iconn, +#include +#include +#include +#include + +#include +#include +#include + +void well_conn_test_CF(const rd_kw_type *iwel_kw, const rd_kw_type *icon_kw, + const rd_kw_type *scon_kw, const rd_kw_type *xcon_kw, + const rd_rsthead_type *rst_head, int iwell, int iconn, double CF) { well_conn_type *conn = well_conn_alloc_from_kw(icon_kw, scon_kw, xcon_kw, rst_head, iwell, iconn); @@ -26,13 +26,13 @@ void well_conn_test_CF(const ecl_kw_type *iwel_kw, const ecl_kw_type *icon_kw, int main(int argc, char **argv) { const char *Xfile = argv[1]; - ecl_file_type *rst_file = ecl_file_open(Xfile, 0); - ecl_rsthead_type *rst_head = ecl_rsthead_alloc( - ecl_file_get_global_view(rst_file), ecl_util_filename_report_nr(Xfile)); - const ecl_kw_type *iwel_kw = ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - const ecl_kw_type *icon_kw = ecl_file_iget_named_kw(rst_file, ICON_KW, 0); - const ecl_kw_type *scon_kw = ecl_file_iget_named_kw(rst_file, SCON_KW, 0); - const ecl_kw_type *xcon_kw = 0; + rd_file_type *rst_file = rd_file_open(Xfile, 0); + rd_rsthead_type *rst_head = rd_rsthead_alloc( + rd_file_get_global_view(rst_file), rd_filename_report_nr(Xfile)); + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + const rd_kw_type *icon_kw = rd_file_iget_named_kw(rst_file, ICON_KW, 0); + const rd_kw_type *scon_kw = rd_file_iget_named_kw(rst_file, SCON_KW, 0); + const rd_kw_type *xcon_kw = 0; well_conn_test_CF(iwel_kw, icon_kw, scon_kw, xcon_kw, rst_head, 0, 0, 32.948); @@ -55,7 +55,7 @@ int main(int argc, char **argv) { well_conn_test_CF(iwel_kw, icon_kw, scon_kw, xcon_kw, rst_head, 2, 2, 18.032); - ecl_file_close(rst_file); - ecl_rsthead_free(rst_head); + rd_file_close(rst_file); + rd_rsthead_free(rst_head); exit(0); } diff --git a/lib/resdata/tests/well_conn_collection.cpp b/lib/resdata/tests/well_conn_collection.cpp index 67dd5278d9..7c1258a754 100644 --- a/lib/resdata/tests/well_conn_collection.cpp +++ b/lib/resdata/tests/well_conn_collection.cpp @@ -5,10 +5,10 @@ #include #include -#include +#include -#include -#include +#include +#include void test_empty() { well_conn_collection_type *wellcc = well_conn_collection_alloc(); diff --git a/lib/resdata/tests/well_conn_load.cpp b/lib/resdata/tests/well_conn_load.cpp index 593dedf785..085ed9e7a6 100644 --- a/lib/resdata/tests/well_conn_load.cpp +++ b/lib/resdata/tests/well_conn_load.cpp @@ -5,21 +5,21 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include int main(int argc, char **argv) { const char *Xfile = argv[1]; bool MSW; - ecl_file_type *rst_file = ecl_file_open(Xfile, 0); - ecl_rsthead_type *rst_head = ecl_rsthead_alloc( - ecl_file_get_global_view(rst_file), ecl_util_filename_report_nr(Xfile)); + rd_file_type *rst_file = rd_file_open(Xfile, 0); + rd_rsthead_type *rst_head = rd_rsthead_alloc( + rd_file_get_global_view(rst_file), rd_filename_report_nr(Xfile)); test_install_SIGNALS(); test_assert_true(util_sscanf_bool(argv[2], &MSW)); @@ -28,19 +28,17 @@ int main(int argc, char **argv) { { int iwell; - const ecl_kw_type *iwel_kw = - ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - const ecl_kw_type *icon_kw = - ecl_file_iget_named_kw(rst_file, ICON_KW, 0); - ecl_kw_type *scon_kw = NULL; - ecl_kw_type *xcon_kw = NULL; + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + const rd_kw_type *icon_kw = rd_file_iget_named_kw(rst_file, ICON_KW, 0); + rd_kw_type *scon_kw = NULL; + rd_kw_type *xcon_kw = NULL; bool caseMSW = false; for (iwell = 0; iwell < rst_head->nwells; iwell++) { const int iwel_offset = rst_head->niwelz * iwell; int num_connections = - ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_CONNECTIONS_INDEX); + rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_CONNECTIONS_INDEX); int iconn; well_conn_collection_type *wellcc = well_conn_collection_alloc(); well_conn_collection_type *wellcc_ref = diff --git a/lib/resdata/tests/well_dualp.cpp b/lib/resdata/tests/well_dualp.cpp index 353161ecea..a7102c8288 100644 --- a/lib/resdata/tests/well_dualp.cpp +++ b/lib/resdata/tests/well_dualp.cpp @@ -5,19 +5,18 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include void test_rstfile(const char *filename, bool fracture_connection) { - ecl_file_type *rst_file = ecl_file_open(filename, 0); - const ecl_kw_type *iwel_kw = ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - ecl_rsthead_type *header = - ecl_rsthead_alloc(ecl_file_get_global_view(rst_file), - ecl_util_filename_report_nr(filename)); + rd_file_type *rst_file = rd_file_open(filename, 0); + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + rd_rsthead_type *header = rd_rsthead_alloc( + rd_file_get_global_view(rst_file), rd_filename_report_nr(filename)); well_conn_type *wellhead = well_conn_alloc_wellhead(iwel_kw, header, 0); @@ -31,9 +30,9 @@ void test_rstfile(const char *filename, bool fracture_connection) { test_assert_true(well_conn_get_k(wellhead) < header->nz); - ecl_rsthead_free(header); + rd_rsthead_free(header); well_conn_free(wellhead); - ecl_file_close(rst_file); + rd_file_close(rst_file); } int main(int argc, char **argv) { diff --git a/lib/resdata/tests/well_info.cpp b/lib/resdata/tests/well_info.cpp index ba8c7f83b3..cc00e01e6a 100644 --- a/lib/resdata/tests/well_info.cpp +++ b/lib/resdata/tests/well_info.cpp @@ -5,16 +5,16 @@ #include #include -#include -#include +#include +#include -#include +#include int main(int argc, char **argv) { util_install_signals(); const char *grid_file = argv[1]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); + rd_grid_type *grid = rd_grid_alloc(grid_file); test_assert_not_NULL(grid); { well_info_type *well_info = well_info_alloc(grid); @@ -24,6 +24,6 @@ int main(int argc, char **argv) { well_info_free(well_info); } - ecl_grid_free(grid); + rd_grid_free(grid); exit(0); } diff --git a/lib/resdata/tests/well_lgr_load.cpp b/lib/resdata/tests/well_lgr_load.cpp index bdf824384e..ebb43aa09b 100644 --- a/lib/resdata/tests/well_lgr_load.cpp +++ b/lib/resdata/tests/well_lgr_load.cpp @@ -6,15 +6,15 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { signal(SIGSEGV, util_abort_signal); /* Segmentation violation, @@ -26,7 +26,7 @@ int main(int argc, char **argv) { backtrace.*/ signal(SIGABRT, util_abort_signal); /* Signal abort. */ { - ecl_grid_type *grid = ecl_grid_alloc(argv[1]); + rd_grid_type *grid = rd_grid_alloc(argv[1]); well_info_type *well_info = well_info_alloc(grid); well_info_load_rstfile(well_info, argv[2], true); diff --git a/lib/resdata/tests/well_segment.cpp b/lib/resdata/tests/well_segment.cpp index ce29c34c04..7639a74317 100644 --- a/lib/resdata/tests/well_segment.cpp +++ b/lib/resdata/tests/well_segment.cpp @@ -5,10 +5,10 @@ #include #include -#include +#include -#include -#include +#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); diff --git a/lib/resdata/tests/well_segment_branch_conn_load.cpp b/lib/resdata/tests/well_segment_branch_conn_load.cpp index df959f57a3..f471c7754f 100644 --- a/lib/resdata/tests/well_segment_branch_conn_load.cpp +++ b/lib/resdata/tests/well_segment_branch_conn_load.cpp @@ -6,30 +6,30 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include int main(int argc, char **argv) { const char *Xfile = argv[1]; - ecl_file_type *rst_file = ecl_file_open(Xfile, 0); - ecl_file_view_type *rst_view = ecl_file_get_active_view(rst_file); - ecl_rsthead_type *rst_head = - ecl_rsthead_alloc(rst_view, ecl_util_filename_report_nr(Xfile)); - const ecl_kw_type *iwel_kw = ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - const ecl_kw_type *iseg_kw = ecl_file_iget_named_kw(rst_file, ISEG_KW, 0); + rd_file_type *rst_file = rd_file_open(Xfile, 0); + rd_file_view_type *rst_view = rd_file_get_active_view(rst_file); + rd_rsthead_type *rst_head = + rd_rsthead_alloc(rst_view, rd_filename_report_nr(Xfile)); + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + const rd_kw_type *iseg_kw = rd_file_iget_named_kw(rst_file, ISEG_KW, 0); well_rseg_loader_type *rseg_loader = well_rseg_loader_alloc(rst_view); - const ecl_kw_type *icon_kw = ecl_file_iget_named_kw(rst_file, ICON_KW, 0); - const ecl_kw_type *scon_kw = NULL; - const ecl_kw_type *xcon_kw = NULL; + const rd_kw_type *icon_kw = rd_file_iget_named_kw(rst_file, ICON_KW, 0); + const rd_kw_type *scon_kw = NULL; + const rd_kw_type *xcon_kw = NULL; test_install_SIGNALS(); test_assert_not_NULL(rst_file); @@ -99,7 +99,7 @@ int main(int argc, char **argv) { } } well_segment_collection_add_connections( - segments, ECL_GRID_GLOBAL_GRID, connections); + segments, RD_GRID_GLOBAL_GRID, connections); well_branch_collection_free(branches); } else test_assert_false( @@ -111,7 +111,7 @@ int main(int argc, char **argv) { } } - ecl_file_close(rst_file); - ecl_rsthead_free(rst_head); + rd_file_close(rst_file); + rd_rsthead_free(rst_head); exit(0); } diff --git a/lib/resdata/tests/well_segment_collection.cpp b/lib/resdata/tests/well_segment_collection.cpp index 8b21937782..a6b8b28e39 100644 --- a/lib/resdata/tests/well_segment_collection.cpp +++ b/lib/resdata/tests/well_segment_collection.cpp @@ -5,10 +5,10 @@ #include #include -#include +#include -#include -#include +#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); diff --git a/lib/resdata/tests/well_segment_conn.cpp b/lib/resdata/tests/well_segment_conn.cpp index cda41ee9f5..ec54918cc0 100644 --- a/lib/resdata/tests/well_segment_conn.cpp +++ b/lib/resdata/tests/well_segment_conn.cpp @@ -5,13 +5,13 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); @@ -31,18 +31,18 @@ int main(int argc, char **argv) { test_assert_false(well_segment_has_global_grid_connections(ws)); test_assert_true( - well_segment_add_connection(ws, ECL_GRID_GLOBAL_GRID, conn1)); + well_segment_add_connection(ws, RD_GRID_GLOBAL_GRID, conn1)); test_assert_false( - well_segment_add_connection(ws, ECL_GRID_GLOBAL_GRID, conn2)); + well_segment_add_connection(ws, RD_GRID_GLOBAL_GRID, conn2)); test_assert_true( - well_segment_has_grid_connections(ws, ECL_GRID_GLOBAL_GRID)); + well_segment_has_grid_connections(ws, RD_GRID_GLOBAL_GRID)); test_assert_true(well_segment_has_global_grid_connections(ws)); test_assert_false( well_segment_has_grid_connections(ws, "DoesNotExist")); test_assert_true(well_conn_collection_is_instance( - well_segment_get_connections(ws, ECL_GRID_GLOBAL_GRID))); + well_segment_get_connections(ws, RD_GRID_GLOBAL_GRID))); test_assert_true(well_conn_collection_is_instance( well_segment_get_global_connections(ws))); test_assert_NULL(well_segment_get_connections(ws, "doesNotExist")); diff --git a/lib/resdata/tests/well_segment_conn_load.cpp b/lib/resdata/tests/well_segment_conn_load.cpp index a0ea9f0002..ee8567692c 100644 --- a/lib/resdata/tests/well_segment_conn_load.cpp +++ b/lib/resdata/tests/well_segment_conn_load.cpp @@ -6,25 +6,25 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { const char *Xfile = argv[1]; - ecl_file_type *rst_file = ecl_file_open(Xfile, 0); - ecl_rsthead_type *rst_head = ecl_rsthead_alloc(rst_file); - const ecl_kw_type *iwel_kw = ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - const ecl_kw_type *iseg_kw = ecl_file_iget_named_kw(rst_file, ISEG_KW, 0); - const ecl_kw_type *rseg_kw = ecl_file_iget_named_kw(rst_file, RSEG_KW, 0); - const ecl_kw_type *icon_kw = ecl_file_iget_named_kw(rst_file, ICON_KW, 0); + rd_file_type *rst_file = rd_file_open(Xfile, 0); + rd_rsthead_type *rst_head = rd_rsthead_alloc(rst_file); + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + const rd_kw_type *iseg_kw = rd_file_iget_named_kw(rst_file, ISEG_KW, 0); + const rd_kw_type *rseg_kw = rd_file_iget_named_kw(rst_file, RSEG_KW, 0); + const rd_kw_type *icon_kw = rd_file_iget_named_kw(rst_file, ICON_KW, 0); test_install_SIGNALS(); test_assert_not_NULL(rst_file); @@ -92,7 +92,7 @@ int main(int argc, char **argv) { } } well_segment_collection_add_connections( - segments, ECL_GRID_GLOBAL_GRID, connections); + segments, RD_GRID_GLOBAL_GRID, connections); well_branch_collection_free(branches); } else test_assert_false( @@ -104,7 +104,7 @@ int main(int argc, char **argv) { } } - ecl_file_close(rst_file); - ecl_rsthead_free(rst_head); + rd_file_close(rst_file); + rd_rsthead_free(rst_head); exit(0); } diff --git a/lib/resdata/tests/well_segment_load.cpp b/lib/resdata/tests/well_segment_load.cpp index bdf6d876b3..dab23e7095 100644 --- a/lib/resdata/tests/well_segment_load.cpp +++ b/lib/resdata/tests/well_segment_load.cpp @@ -5,24 +5,24 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include int main(int argc, char **argv) { const char *Xfile = argv[1]; - ecl_file_type *rst_file = ecl_file_open(Xfile, 0); - ecl_file_view_type *rst_view = ecl_file_get_active_view(rst_file); - ecl_rsthead_type *rst_head = - ecl_rsthead_alloc(rst_view, ecl_util_filename_report_nr(Xfile)); - const ecl_kw_type *iwel_kw = ecl_file_iget_named_kw(rst_file, IWEL_KW, 0); - const ecl_kw_type *iseg_kw = ecl_file_iget_named_kw(rst_file, ISEG_KW, 0); + rd_file_type *rst_file = rd_file_open(Xfile, 0); + rd_file_view_type *rst_view = rd_file_get_active_view(rst_file); + rd_rsthead_type *rst_head = + rd_rsthead_alloc(rst_view, rd_filename_report_nr(Xfile)); + const rd_kw_type *iwel_kw = rd_file_iget_named_kw(rst_file, IWEL_KW, 0); + const rd_kw_type *iseg_kw = rd_file_iget_named_kw(rst_file, ISEG_KW, 0); well_rseg_loader_type *rseg_loader = well_rseg_loader_alloc(rst_view); test_install_SIGNALS(); @@ -37,8 +37,8 @@ int main(int argc, char **argv) { well_segment_collection_type *segments = well_segment_collection_alloc(); int seg_well_nr = - ecl_kw_iget_int(iwel_kw, - iwel_offset + IWEL_SEGMENTED_WELL_NR_INDEX) - + rd_kw_iget_int(iwel_kw, + iwel_offset + IWEL_SEGMENTED_WELL_NR_INDEX) - 1; // -1: Ordinary well. if (seg_well_nr >= 0) { int segment_index; @@ -90,7 +90,7 @@ int main(int argc, char **argv) { } } } - ecl_file_close(rst_file); - ecl_rsthead_free(rst_head); + rd_file_close(rst_file); + rd_rsthead_free(rst_head); exit(0); } diff --git a/lib/resdata/tests/well_state.cpp b/lib/resdata/tests/well_state.cpp index b6a996128e..a4a0cac2b3 100644 --- a/lib/resdata/tests/well_state.cpp +++ b/lib/resdata/tests/well_state.cpp @@ -5,25 +5,23 @@ #include #include -#include +#include -#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); test_assert_int_equal( - well_state_translate_ecl_type_int(IWEL_UNDOCUMENTED_ZERO), - ECL_WELL_ZERO); - test_assert_int_equal(well_state_translate_ecl_type_int(IWEL_PRODUCER), - ECL_WELL_PRODUCER); - test_assert_int_equal( - well_state_translate_ecl_type_int(IWEL_WATER_INJECTOR), - ECL_WELL_WATER_INJECTOR); - test_assert_int_equal(well_state_translate_ecl_type_int(IWEL_GAS_INJECTOR), - ECL_WELL_GAS_INJECTOR); - test_assert_int_equal(well_state_translate_ecl_type_int(IWEL_OIL_INJECTOR), - ECL_WELL_OIL_INJECTOR); + well_state_translate_rd_type_int(IWEL_UNDOCUMENTED_ZERO), RD_WELL_ZERO); + test_assert_int_equal(well_state_translate_rd_type_int(IWEL_PRODUCER), + RD_WELL_PRODUCER); + test_assert_int_equal(well_state_translate_rd_type_int(IWEL_WATER_INJECTOR), + RD_WELL_WATER_INJECTOR); + test_assert_int_equal(well_state_translate_rd_type_int(IWEL_GAS_INJECTOR), + RD_WELL_GAS_INJECTOR); + test_assert_int_equal(well_state_translate_rd_type_int(IWEL_OIL_INJECTOR), + RD_WELL_OIL_INJECTOR); { const char *well_name = "WELL"; @@ -31,7 +29,7 @@ int main(int argc, char **argv) { int global_well_nr = 67; time_t valid_from = -1; bool open = false; - well_type_enum type = ECL_WELL_GAS_INJECTOR; + well_type_enum type = RD_WELL_GAS_INJECTOR; well_state_type *well_state = well_state_alloc( well_name, global_well_nr, open, type, report_nr, valid_from); diff --git a/lib/resdata/tests/well_state_load.cpp b/lib/resdata/tests/well_state_load.cpp index 500fbd6378..444acf6a9e 100644 --- a/lib/resdata/tests/well_state_load.cpp +++ b/lib/resdata/tests/well_state_load.cpp @@ -5,12 +5,12 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); @@ -18,19 +18,19 @@ int main(int argc, char **argv) { const char *grid_file = argv[1]; const char *rst_file_name = argv[2]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); - ecl_file_type *rst_file = ecl_file_open(rst_file_name, 0); - ecl_rsthead_type *header = - ecl_rsthead_alloc(ecl_file_get_global_view(rst_file), - ecl_util_filename_report_nr(rst_file_name)); + rd_grid_type *grid = rd_grid_alloc(grid_file); + rd_file_type *rst_file = rd_file_open(rst_file_name, 0); + rd_rsthead_type *header = + rd_rsthead_alloc(rd_file_get_global_view(rst_file), + rd_filename_report_nr(rst_file_name)); const char *well_name = "WELL"; int report_nr = 100; time_t valid_from = -1; bool open = false; - well_type_enum type = ECL_WELL_GAS_INJECTOR; + well_type_enum type = RD_WELL_GAS_INJECTOR; int global_well_nr = 0; bool load_segment_information = true; - ecl_file_view_type *rst_view = ecl_file_get_global_view(rst_file); + rd_file_view_type *rst_view = rd_file_get_global_view(rst_file); for (global_well_nr = 0; global_well_nr < header->nwells; global_well_nr++) { @@ -40,7 +40,7 @@ int main(int argc, char **argv) { well_state_add_connections2(well_state, grid, rst_view, 0); test_assert_true(well_state_has_grid_connections( - well_state, ECL_GRID_GLOBAL_GRID)); + well_state, RD_GRID_GLOBAL_GRID)); test_assert_false( well_state_has_grid_connections(well_state, "???")); test_assert_true(well_state_has_global_connections(well_state)); @@ -54,7 +54,7 @@ int main(int argc, char **argv) { well_state_get_branches(well_state); if (well_state_is_MSW(well_state)) { - test_assert_true(ecl_file_has_kw(rst_file, ISEG_KW)); + test_assert_true(rd_file_has_kw(rst_file, ISEG_KW)); test_assert_int_not_equal( well_segment_collection_get_size(segments), 0); test_assert_int_not_equal( diff --git a/lib/resdata/tests/well_state_load_missing_RSEG.cpp b/lib/resdata/tests/well_state_load_missing_RSEG.cpp index 10912c6d87..80bb85925c 100644 --- a/lib/resdata/tests/well_state_load_missing_RSEG.cpp +++ b/lib/resdata/tests/well_state_load_missing_RSEG.cpp @@ -5,12 +5,12 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include int main(int argc, char **argv) { test_install_SIGNALS(); @@ -18,16 +18,16 @@ int main(int argc, char **argv) { const char *grid_file = argv[1]; const char *rst_file_name = argv[2]; - ecl_grid_type *grid = ecl_grid_alloc(grid_file); - ecl_file_type *rst_file = ecl_file_open(rst_file_name, 0); - ecl_file_view_type *rst_view = ecl_file_get_active_view(rst_file); - ecl_rsthead_type *header = ecl_rsthead_alloc( - rst_view, ecl_util_filename_report_nr(rst_file_name)); + rd_grid_type *grid = rd_grid_alloc(grid_file); + rd_file_type *rst_file = rd_file_open(rst_file_name, 0); + rd_file_view_type *rst_view = rd_file_get_active_view(rst_file); + rd_rsthead_type *header = + rd_rsthead_alloc(rst_view, rd_filename_report_nr(rst_file_name)); const char *well_name = "WELL"; int report_nr = 100; time_t valid_from = -1; bool open = false; - well_type_enum type = ECL_WELL_GAS_INJECTOR; + well_type_enum type = RD_WELL_GAS_INJECTOR; int global_well_nr = 0; bool load_segment_information = false; @@ -44,7 +44,7 @@ int main(int argc, char **argv) { const well_segment_collection_type *segments = well_state_get_segments(well_state); - if (!ecl_file_view_has_kw(rst_view, RSEG_KW)) + if (!rd_file_view_has_kw(rst_view, RSEG_KW)) test_assert_int_equal( 0, well_segment_collection_get_size(segments)); } diff --git a/lib/resdata/tests/well_ts.cpp b/lib/resdata/tests/well_ts.cpp index 1d6c377dab..3549884775 100644 --- a/lib/resdata/tests/well_ts.cpp +++ b/lib/resdata/tests/well_ts.cpp @@ -5,18 +5,17 @@ #include #include -#include -#include +#include +#include -#include +#include int main(int argc, char **argv) { const char *case_path = argv[1]; char *grid_file = util_alloc_filename(NULL, case_path, "EGRID"); stringlist_type *file_list = stringlist_alloc_new(); - ecl_grid_type *grid = ecl_grid_alloc(grid_file); - ecl_util_select_filelist(NULL, case_path, ECL_RESTART_FILE, false, - file_list); + rd_grid_type *grid = rd_grid_alloc(grid_file); + rd_select_filelist(NULL, case_path, RD_RESTART_FILE, false, file_list); printf("Searching in:%s \n", case_path); test_assert_int_equal(4, stringlist_get_size(file_list)); @@ -55,7 +54,7 @@ int main(int argc, char **argv) { true); well_info_free(well_info); } - ecl_grid_free(grid); + rd_grid_free(grid); free(grid_file); exit(0); diff --git a/lib/resdata/well_branch_collection.cpp b/lib/resdata/well_branch_collection.cpp index b4f8d9393e..f18e0c8684 100644 --- a/lib/resdata/well_branch_collection.cpp +++ b/lib/resdata/well_branch_collection.cpp @@ -5,9 +5,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define WELL_BRANCH_COLLECTION_TYPE_ID 67177087 diff --git a/lib/resdata/well_conn.cpp b/lib/resdata/well_conn.cpp index 9e665f2599..b35794144a 100644 --- a/lib/resdata/well_conn.cpp +++ b/lib/resdata/well_conn.cpp @@ -4,11 +4,11 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include #define WELL_CONN_NORMAL_WELL_SEGMENT_ID -999 //#define ECLIPSE_NORMAL_WELL_SEGMENT_ID -1 @@ -133,15 +133,15 @@ well_conn_type *well_conn_alloc_fracture_MSW(int i, int j, int k, Observe that the (ijk) and branch values are shifted to zero offset to be aligned with the rest of the ert libraries. */ -well_conn_type *well_conn_alloc_from_kw(const ecl_kw_type *icon_kw, - const ecl_kw_type *scon_kw, - const ecl_kw_type *xcon_kw, - const ecl_rsthead_type *header, +well_conn_type *well_conn_alloc_from_kw(const rd_kw_type *icon_kw, + const rd_kw_type *scon_kw, + const rd_kw_type *xcon_kw, + const rd_rsthead_type *header, int well_nr, int conn_nr) { const int icon_offset = header->niconz * (header->ncwmax * well_nr + conn_nr); - int IC = ecl_kw_iget_int(icon_kw, icon_offset + ICON_IC_INDEX); + int IC = rd_kw_iget_int(icon_kw, icon_offset + ICON_IC_INDEX); if (IC <= 0) return NULL; /* IC < 0: Connection not in current LGR. */ @@ -151,7 +151,7 @@ well_conn_type *well_conn_alloc_from_kw(const ecl_kw_type *icon_kw, case we just return NULL and forget about the connection - it seems to work. */ int int_direction = - ecl_kw_iget_int(icon_kw, icon_offset + ICON_DIRECTION_INDEX); + rd_kw_iget_int(icon_kw, icon_offset + ICON_DIRECTION_INDEX); if ((int_direction < 0) || (int_direction > ICON_FRACY)) { fprintf(stderr, "Invalid direction value:%d encountered for well - connection " @@ -160,13 +160,13 @@ well_conn_type *well_conn_alloc_from_kw(const ecl_kw_type *icon_kw, return NULL; } - int i = ecl_kw_iget_int(icon_kw, icon_offset + ICON_I_INDEX) - 1; - int j = ecl_kw_iget_int(icon_kw, icon_offset + ICON_J_INDEX) - 1; - int k = ecl_kw_iget_int(icon_kw, icon_offset + ICON_K_INDEX) - 1; + int i = rd_kw_iget_int(icon_kw, icon_offset + ICON_I_INDEX) - 1; + int j = rd_kw_iget_int(icon_kw, icon_offset + ICON_J_INDEX) - 1; + int k = rd_kw_iget_int(icon_kw, icon_offset + ICON_K_INDEX) - 1; double connection_factor = -1; bool matrix_connection = true; bool is_open = - (ecl_kw_iget_int(icon_kw, icon_offset + ICON_STATUS_INDEX) > 0); + (rd_kw_iget_int(icon_kw, icon_offset + ICON_STATUS_INDEX) > 0); well_conn_dir_enum dir = well_conn_fracX; /* Set the K value and fracture flag. */ @@ -206,12 +206,12 @@ well_conn_type *well_conn_alloc_from_kw(const ecl_kw_type *icon_kw, const int scon_offset = header->nsconz * (header->ncwmax * well_nr + conn_nr); connection_factor = - ecl_kw_iget_as_double(scon_kw, scon_offset + SCON_CF_INDEX); + rd_kw_iget_as_double(scon_kw, scon_offset + SCON_CF_INDEX); } { int segment_id = - ecl_kw_iget_int(icon_kw, icon_offset + ICON_SEGMENT_INDEX) - + rd_kw_iget_int(icon_kw, icon_offset + ICON_SEGMENT_INDEX) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET; well_conn_type *conn = well_conn_alloc__(i, j, k, connection_factor, dir, is_open, @@ -222,13 +222,13 @@ well_conn_type *well_conn_alloc_from_kw(const ecl_kw_type *icon_kw, header->nxconz * (header->ncwmax * well_nr + conn_nr); conn->water_rate = - ecl_kw_iget_as_double(xcon_kw, xcon_offset + XCON_WRAT_INDEX); + rd_kw_iget_as_double(xcon_kw, xcon_offset + XCON_WRAT_INDEX); conn->gas_rate = - ecl_kw_iget_as_double(xcon_kw, xcon_offset + XCON_GRAT_INDEX); + rd_kw_iget_as_double(xcon_kw, xcon_offset + XCON_GRAT_INDEX); conn->oil_rate = - ecl_kw_iget_as_double(xcon_kw, xcon_offset + XCON_ORAT_INDEX); + rd_kw_iget_as_double(xcon_kw, xcon_offset + XCON_ORAT_INDEX); conn->volume_rate = - ecl_kw_iget_double(xcon_kw, xcon_offset + XCON_QR_INDEX); + rd_kw_iget_double(xcon_kw, xcon_offset + XCON_QR_INDEX); } /** @@ -249,18 +249,18 @@ void well_conn_free__(void *arg) { well_conn_free(conn); } -well_conn_type *well_conn_alloc_wellhead(const ecl_kw_type *iwel_kw, - const ecl_rsthead_type *header, +well_conn_type *well_conn_alloc_wellhead(const rd_kw_type *iwel_kw, + const rd_rsthead_type *header, int well_nr) { const int iwel_offset = header->niwelz * well_nr; - int conn_i = ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_HEADI_INDEX) - 1; + int conn_i = rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_HEADI_INDEX) - 1; if (conn_i >= 0) { //well_conn_type * conn = util_malloc( sizeof * conn ); int conn_j = - ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_HEADJ_INDEX) - 1; + rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_HEADJ_INDEX) - 1; int conn_k = - ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_HEADK_INDEX) - 1; + rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_HEADK_INDEX) - 1; bool matrix_connection = true; bool open = true; double connection_factor = -1; diff --git a/lib/resdata/well_conn_collection.cpp b/lib/resdata/well_conn_collection.cpp index 57c525d884..c21580c31d 100644 --- a/lib/resdata/well_conn_collection.cpp +++ b/lib/resdata/well_conn_collection.cpp @@ -5,12 +5,12 @@ #include #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #define WELL_CONN_COLLECTION_TYPE_ID 67150087 @@ -87,15 +87,15 @@ well_conn_collection_iget(const well_conn_collection_type *wellcc, int index) { } int well_conn_collection_load_from_kw(well_conn_collection_type *wellcc, - const ecl_kw_type *iwel_kw, - const ecl_kw_type *icon_kw, - const ecl_kw_type *scon_kw, - const ecl_kw_type *xcon_kw, int iwell, - const ecl_rsthead_type *rst_head) { + const rd_kw_type *iwel_kw, + const rd_kw_type *icon_kw, + const rd_kw_type *scon_kw, + const rd_kw_type *xcon_kw, int iwell, + const rd_rsthead_type *rst_head) { const int iwel_offset = rst_head->niwelz * iwell; int num_connections = - ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_CONNECTIONS_INDEX); + rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_CONNECTIONS_INDEX); int iconn; for (iconn = 0; iconn < num_connections; iconn++) { diff --git a/lib/resdata/well_info.cpp b/lib/resdata/well_info.cpp index 58f20ad263..4b2bbbe138 100644 --- a/lib/resdata/well_info.cpp +++ b/lib/resdata/well_info.cpp @@ -8,18 +8,18 @@ #include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include /* The library libwell contains functionality to read and interpret @@ -137,8 +137,8 @@ 2. Add restart data - using one of the three functions: - - well_info_add_wells() - ecl_file: One report step - - well_info_add_UNRST_wells() - ecl_file: Many report steps + - well_info_add_wells() - rd_file: One report step + - well_info_add_UNRST_wells() - rd_file: Many report steps - well_info_load_rstfile() - Restart file name; single file or unified There are more details about this in a comment section above the @@ -164,7 +164,7 @@ struct well_info_struct { std::map wells; /* std::map of well_ts_type instances; indexed by well name. */ std::vector well_names; /* A list of all the well names. */ - const ecl_grid_type *grid; + const rd_grid_type *grid; }; /** @@ -172,7 +172,7 @@ struct well_info_struct { it to resolve lgr names. */ -well_info_type *well_info_alloc(const ecl_grid_type *grid) { +well_info_type *well_info_alloc(const rd_grid_type *grid) { well_info_type *well_info = new well_info_type(); well_info->grid = grid; return well_info; @@ -219,18 +219,18 @@ static void well_info_add_state(well_info_type *well_info, - well_info_add_UNRST_wells() - well_info_load_rstfile() - The two first functions expect an open ecl_file instance as input; + The two first functions expect an open rd_file instance as input; whereas the last funtion expects the name of a restart file as input. - If you need ecl_file access to the restart files for another reason + If you need rd_file access to the restart files for another reason it might be convenient to use one of the first functions; however - due to the workings of the ecl_file type it might not be entirely - obvious: The ecl_file structure will load the needed keywords on + due to the workings of the rd_file type it might not be entirely + obvious: The rd_file structure will load the needed keywords on demand; the keywords needed to initialize well structures will typically not be loaded for other purposes, so the only gain from - using an existing ecl_file instance is that you do not have to - rebuild the index. The disadvantage of using an existing ecl_file + using an existing rd_file instance is that you do not have to + rebuild the index. The disadvantage of using an existing rd_file instance is that after the call to add_wells() the well related kewywords will stay in (probaly unused) in memory. @@ -242,7 +242,7 @@ static void well_info_add_state(well_info_type *well_info, /** This function assumes that (sub)select_block() has been used on the - ecl_file instance @rst_file; and the function will load well + rd_file instance @rst_file; and the function will load well information from the first block available in the file only. To load all the well information from a unified restart file it is easier to use the well_info_add_UNRST_wells() function; which works @@ -257,11 +257,10 @@ static void well_info_add_state(well_info_type *well_info, */ void well_info_add_wells2(well_info_type *well_info, - ecl_file_view_type *rst_view, int report_nr, + rd_file_view_type *rst_view, int report_nr, bool load_segment_information) { - bool close_stream = - ecl_file_view_drop_flag(rst_view, ECL_FILE_CLOSE_STREAM); - ecl_rsthead_type *global_header = ecl_rsthead_alloc(rst_view, report_nr); + bool close_stream = rd_file_view_drop_flag(rst_view, RD_FILE_CLOSE_STREAM); + rd_rsthead_type *global_header = rd_rsthead_alloc(rst_view, report_nr); int well_nr; for (well_nr = 0; well_nr < global_header->nwells; well_nr++) { well_state_type *well_state = @@ -270,14 +269,14 @@ void well_info_add_wells2(well_info_type *well_info, if (well_state != NULL) well_info_add_state(well_info, well_state); } - ecl_rsthead_free(global_header); + rd_rsthead_free(global_header); if (close_stream) - ecl_file_view_add_flag(rst_view, ECL_FILE_CLOSE_STREAM); + rd_file_view_add_flag(rst_view, RD_FILE_CLOSE_STREAM); } -void well_info_add_wells(well_info_type *well_info, ecl_file_type *rst_file, +void well_info_add_wells(well_info_type *well_info, rd_file_type *rst_file, int report_nr, bool load_segment_information) { - well_info_add_wells2(well_info, ecl_file_get_active_view(rst_file), + well_info_add_wells2(well_info, rd_file_get_active_view(rst_file), report_nr, load_segment_information); } @@ -288,30 +287,29 @@ void well_info_add_wells(well_info_type *well_info, ecl_file_type *rst_file, */ void well_info_add_UNRST_wells2(well_info_type *well_info, - ecl_file_view_type *rst_view, + rd_file_view_type *rst_view, bool load_segment_information) { - int num_blocks = ecl_file_view_get_num_named_kw(rst_view, SEQNUM_KW); + int num_blocks = rd_file_view_get_num_named_kw(rst_view, SEQNUM_KW); int block_nr; for (block_nr = 0; block_nr < num_blocks; block_nr++) { - ecl_file_view_type *step_view = - ecl_file_view_add_restart_view(rst_view, block_nr, -1, -1, -1); - const ecl_kw_type *seqnum_kw = - ecl_file_view_iget_named_kw(step_view, SEQNUM_KW, 0); - int report_nr = ecl_kw_iget_int(seqnum_kw, 0); + rd_file_view_type *step_view = + rd_file_view_add_restart_view(rst_view, block_nr, -1, -1, -1); + const rd_kw_type *seqnum_kw = + rd_file_view_iget_named_kw(step_view, SEQNUM_KW, 0); + int report_nr = rd_kw_iget_int(seqnum_kw, 0); - ecl_file_transaction_type *t = - ecl_file_view_start_transaction(rst_view); + rd_file_transaction_type *t = rd_file_view_start_transaction(rst_view); well_info_add_wells2(well_info, step_view, report_nr, load_segment_information); - ecl_file_view_end_transaction(rst_view, t); + rd_file_view_end_transaction(rst_view, t); } } void well_info_add_UNRST_wells(well_info_type *well_info, - ecl_file_type *rst_file, + rd_file_type *rst_file, bool load_segment_information) { - well_info_add_UNRST_wells2(well_info, ecl_file_get_global_view(rst_file), + well_info_add_UNRST_wells2(well_info, rd_file_get_global_view(rst_file), load_segment_information); } @@ -323,25 +321,24 @@ void well_info_add_UNRST_wells(well_info_type *well_info, void well_info_load_rstfile(well_info_type *well_info, const char *filename, bool load_segment_information) { - ecl_file_type *ecl_file = ecl_file_open(filename, 0); - well_info_load_rst_eclfile(well_info, ecl_file, load_segment_information); - ecl_file_close(ecl_file); + rd_file_type *rd_file = rd_file_open(filename, 0); + well_info_load_rst_eclfile(well_info, rd_file, load_segment_information); + rd_file_close(rd_file); } void well_info_load_rst_eclfile(well_info_type *well_info, - ecl_file_type *ecl_file, + rd_file_type *rd_file, bool load_segment_information) { int report_nr; - const char *filename = ecl_file_get_src_file(ecl_file); - ecl_file_enum file_type = - ecl_util_get_file_type(filename, NULL, &report_nr); - if ((file_type == ECL_RESTART_FILE) || - (file_type == ECL_UNIFIED_RESTART_FILE)) { - if (file_type == ECL_RESTART_FILE) - well_info_add_wells(well_info, ecl_file, report_nr, + const char *filename = rd_file_get_src_file(rd_file); + rd_file_enum file_type = rd_get_file_type(filename, NULL, &report_nr); + if ((file_type == RD_RESTART_FILE) || + (file_type == RD_UNIFIED_RESTART_FILE)) { + if (file_type == RD_RESTART_FILE) + well_info_add_wells(well_info, rd_file, report_nr, load_segment_information); else - well_info_add_UNRST_wells(well_info, ecl_file, + well_info_add_UNRST_wells(well_info, rd_file, load_segment_information); } else diff --git a/lib/resdata/well_rseg_loader.cpp b/lib/resdata/well_rseg_loader.cpp index 81840a119d..a8203f0e19 100644 --- a/lib/resdata/well_rseg_loader.cpp +++ b/lib/resdata/well_rseg_loader.cpp @@ -3,24 +3,24 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include +#include struct well_rseg_loader_struct { - ecl_file_view_type *rst_view; + rd_file_view_type *rst_view; int_vector_type *relative_index_map; int_vector_type *absolute_index_map; char *buffer; const char *kw; }; -well_rseg_loader_type *well_rseg_loader_alloc(ecl_file_view_type *rst_view) { +well_rseg_loader_type *well_rseg_loader_alloc(rd_file_view_type *rst_view) { well_rseg_loader_type *loader = (well_rseg_loader_type *)util_malloc(sizeof *loader); @@ -47,8 +47,8 @@ int well_rseg_loader_element_count( void well_rseg_loader_free(well_rseg_loader_type *loader) { - if (ecl_file_view_flags_set(loader->rst_view, ECL_FILE_CLOSE_STREAM)) - ecl_file_view_fclose_stream(loader->rst_view); + if (rd_file_view_flags_set(loader->rst_view, RD_FILE_CLOSE_STREAM)) + rd_file_view_fclose_stream(loader->rst_view); int_vector_free(loader->relative_index_map); int_vector_free(loader->absolute_index_map); @@ -69,8 +69,8 @@ double *well_rseg_loader_load_values(const well_rseg_loader_type *loader, int_vector_iset(index_map, index, relative_index + rseg_offset); } - ecl_file_view_index_fload_kw(loader->rst_view, loader->kw, 0, index_map, - loader->buffer); + rd_file_view_index_fload_kw(loader->rst_view, loader->kw, 0, index_map, + loader->buffer); return (double *)loader->buffer; } diff --git a/lib/resdata/well_segment.cpp b/lib/resdata/well_segment.cpp index d2fb823eb7..aa99a4e49e 100644 --- a/lib/resdata/well_segment.cpp +++ b/lib/resdata/well_segment.cpp @@ -5,14 +5,14 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define WELL_SEGMENT_TYPE_ID 2209166 @@ -65,9 +65,9 @@ static UTIL_SAFE_CAST_FUNCTION(well_segment, WELL_SEGMENT_TYPE_ID) } well_segment_type * -well_segment_alloc_from_kw(const ecl_kw_type *iseg_kw, +well_segment_alloc_from_kw(const rd_kw_type *iseg_kw, const well_rseg_loader_type *rseg_loader, - const ecl_rsthead_type *header, int well_nr, + const rd_rsthead_type *header, int well_nr, int segment_index, int segment_id) { if (rseg_loader == NULL) { util_abort("%s: fatal internal error - tried to create well_segment " @@ -80,10 +80,10 @@ well_segment_alloc_from_kw(const ecl_kw_type *iseg_kw, const int rseg_offset = header->nrsegz * (header->nsegmx * well_nr + segment_index); int outlet_segment_id = - ecl_kw_iget_int(iseg_kw, iseg_offset + ISEG_OUTLET_INDEX) - + rd_kw_iget_int(iseg_kw, iseg_offset + ISEG_OUTLET_INDEX) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET; // -1 int branch_id = - ecl_kw_iget_int(iseg_kw, iseg_offset + ISEG_BRANCH_INDEX) - + rd_kw_iget_int(iseg_kw, iseg_offset + ISEG_BRANCH_INDEX) - ECLIPSE_WELL_BRANCH_OFFSET + WELL_BRANCH_OFFSET; // -1 const double *rseg_data = well_rseg_loader_load_values(rseg_loader, rseg_offset); @@ -199,7 +199,7 @@ bool well_segment_has_grid_connections(const well_segment_type *segment, bool well_segment_has_global_grid_connections( const well_segment_type *segment) { - return well_segment_has_grid_connections(segment, ECL_GRID_GLOBAL_GRID); + return well_segment_has_grid_connections(segment, RD_GRID_GLOBAL_GRID); } bool well_segment_add_connection(well_segment_type *segment, @@ -227,15 +227,14 @@ well_segment_get_connections(const well_segment_type *segment, const well_conn_collection_type * well_segment_get_global_connections(const well_segment_type *segment) { - return well_segment_get_connections(segment, ECL_GRID_GLOBAL_GRID); + return well_segment_get_connections(segment, RD_GRID_GLOBAL_GRID); } -bool well_segment_well_is_MSW(int well_nr, const ecl_kw_type *iwel_kw, - const ecl_rsthead_type *rst_head) { +bool well_segment_well_is_MSW(int well_nr, const rd_kw_type *iwel_kw, + const rd_rsthead_type *rst_head) { int iwel_offset = rst_head->niwelz * well_nr; int segment_well_nr = - ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_SEGMENTED_WELL_NR_INDEX) - - 1; + rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_SEGMENTED_WELL_NR_INDEX) - 1; if (segment_well_nr == IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE) return false; diff --git a/lib/resdata/well_segment_collection.cpp b/lib/resdata/well_segment_collection.cpp index 5deff46d9b..2549f69ced 100644 --- a/lib/resdata/well_segment_collection.cpp +++ b/lib/resdata/well_segment_collection.cpp @@ -5,15 +5,15 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct well_segment_collection_struct { std::vector segment_index_map; @@ -92,14 +92,13 @@ bool well_segment_collection_has_segment( int well_segment_collection_load_from_kw( well_segment_collection_type *segment_collection, int well_nr, - const ecl_kw_type *iwel_kw, const ecl_kw_type *iseg_kw, - const well_rseg_loader_type *rseg_loader, const ecl_rsthead_type *rst_head, + const rd_kw_type *iwel_kw, const rd_kw_type *iseg_kw, + const well_rseg_loader_type *rseg_loader, const rd_rsthead_type *rst_head, bool load_segments, bool *is_MSW_well) { int iwel_offset = rst_head->niwelz * well_nr; int segment_well_nr = - ecl_kw_iget_int(iwel_kw, iwel_offset + IWEL_SEGMENTED_WELL_NR_INDEX) - - 1; + rd_kw_iget_int(iwel_kw, iwel_offset + IWEL_SEGMENTED_WELL_NR_INDEX) - 1; int segments_added = 0; if (segment_well_nr != IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE) { diff --git a/lib/resdata/well_state.cpp b/lib/resdata/well_state.cpp index 042252cc13..a5534c166f 100644 --- a/lib/resdata/well_state.cpp +++ b/lib/resdata/well_state.cpp @@ -16,21 +16,21 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include /* @@ -116,7 +116,7 @@ coupledte implementation these objects are modelled as such: } The connections to the global grid are stored with the 'LGR' name - given by the symbole ECL_GRID_GLOBAL_GRID, or alternatively the + given by the symbole RD_GRID_GLOBAL_GRID, or alternatively the function well_state_get_global_connections( well_state ) can be used. @@ -159,7 +159,7 @@ struct well_state_struct { double gas_rate; double water_rate; double volume_rate; - ert_ecl_unit_enum unit_system; + ert_rd_unit_enum unit_system; std::map connections; // hash @@ -193,10 +193,10 @@ well_state_type *well_state_alloc(const char *well_name, int global_well_nr, well_state->gas_rate = 0; well_state->water_rate = 0; well_state->volume_rate = 0; - well_state->unit_system = ECL_METRIC_UNITS; + well_state->unit_system = RD_METRIC_UNITS; /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ - if ((type == ECL_WELL_ZERO) && open) + if ((type == RD_WELL_ZERO) && open) util_abort("%s: Invalid type value for open wells.\n", __func__); return well_state; } @@ -220,12 +220,12 @@ double well_state_get_volume_rate(const well_state_type *well_state) { double well_state_get_oil_rate_si(const well_state_type *well_state) { double conversion_factor = 1; - if (well_state->unit_system == ECL_METRIC_UNITS) - conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_FIELD_UNITS) - conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_LAB_UNITS) - conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; + if (well_state->unit_system == RD_METRIC_UNITS) + conversion_factor = 1.0 / RD_UNITS_TIME_DAY; + else if (well_state->unit_system == RD_FIELD_UNITS) + conversion_factor = RD_UNITS_VOLUME_BARREL / RD_UNITS_TIME_DAY; + else if (well_state->unit_system == RD_LAB_UNITS) + conversion_factor = RD_UNITS_VOLUME_MILLI_LITER / RD_UNITS_TIME_HOUR; return well_state->oil_rate * conversion_factor; } @@ -233,12 +233,12 @@ double well_state_get_oil_rate_si(const well_state_type *well_state) { double well_state_get_gas_rate_si(const well_state_type *well_state) { double conversion_factor = 1; - if (well_state->unit_system == ECL_METRIC_UNITS) - conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_FIELD_UNITS) - conversion_factor = ECL_UNITS_VOLUME_GAS_FIELD / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_LAB_UNITS) - conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; + if (well_state->unit_system == RD_METRIC_UNITS) + conversion_factor = 1.0 / RD_UNITS_TIME_DAY; + else if (well_state->unit_system == RD_FIELD_UNITS) + conversion_factor = RD_UNITS_VOLUME_GAS_FIELD / RD_UNITS_TIME_DAY; + else if (well_state->unit_system == RD_LAB_UNITS) + conversion_factor = RD_UNITS_VOLUME_MILLI_LITER / RD_UNITS_TIME_HOUR; return well_state->gas_rate * conversion_factor; } @@ -246,12 +246,12 @@ double well_state_get_gas_rate_si(const well_state_type *well_state) { double well_state_get_water_rate_si(const well_state_type *well_state) { double conversion_factor = 1; - if (well_state->unit_system == ECL_METRIC_UNITS) - conversion_factor = 1.0 / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_FIELD_UNITS) - conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY; - else if (well_state->unit_system == ECL_LAB_UNITS) - conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR; + if (well_state->unit_system == RD_METRIC_UNITS) + conversion_factor = 1.0 / RD_UNITS_TIME_DAY; + else if (well_state->unit_system == RD_FIELD_UNITS) + conversion_factor = RD_UNITS_VOLUME_BARREL / RD_UNITS_TIME_DAY; + else if (well_state->unit_system == RD_LAB_UNITS) + conversion_factor = RD_UNITS_VOLUME_MILLI_LITER / RD_UNITS_TIME_HOUR; return well_state->water_rate * conversion_factor; } @@ -261,8 +261,8 @@ double well_state_get_volume_rate_si(const well_state_type *well_state) { } void well_state_add_wellhead(well_state_type *well_state, - const ecl_rsthead_type *header, - const ecl_kw_type *iwel_kw, int well_nr, + const rd_rsthead_type *header, + const rd_kw_type *iwel_kw, int well_nr, const char *grid_name, int grid_nr) { well_conn_type *wellhead = well_conn_alloc_wellhead(iwel_kw, header, well_nr); @@ -276,53 +276,53 @@ void well_state_add_wellhead(well_state_type *well_state, } static bool well_state_add_rates(well_state_type *well_state, - ecl_file_view_type *rst_view, int well_nr) { + rd_file_view_type *rst_view, int well_nr) { - bool has_xwel_kw = ecl_file_view_has_kw(rst_view, XWEL_KW); + bool has_xwel_kw = rd_file_view_has_kw(rst_view, XWEL_KW); if (has_xwel_kw) { - const ecl_kw_type *xwel_kw = - ecl_file_view_iget_named_kw(rst_view, XWEL_KW, 0); - ecl_rsthead_type *header = ecl_rsthead_alloc(rst_view, -1); + const rd_kw_type *xwel_kw = + rd_file_view_iget_named_kw(rst_view, XWEL_KW, 0); + rd_rsthead_type *header = rd_rsthead_alloc(rst_view, -1); int offset = header->nxwelz * well_nr; well_state->unit_system = header->unit_system; well_state->oil_rate = - ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_ORAT_ITEM); + rd_kw_iget_double(xwel_kw, offset + XWEL_RES_ORAT_ITEM); well_state->gas_rate = - ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_GRAT_ITEM); + rd_kw_iget_double(xwel_kw, offset + XWEL_RES_GRAT_ITEM); well_state->water_rate = - ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_WRAT_ITEM); + rd_kw_iget_double(xwel_kw, offset + XWEL_RES_WRAT_ITEM); well_state->volume_rate = - ecl_kw_iget_double(xwel_kw, offset + XWEL_RESV_ITEM); + rd_kw_iget_double(xwel_kw, offset + XWEL_RESV_ITEM); - ecl_rsthead_free(header); + rd_rsthead_free(header); } return has_xwel_kw; } /* - This function assumes that the ecl_file state has been restricted - to one LGR block with the ecl_file_subselect_block() function. + This function assumes that the rd_file state has been restricted + to one LGR block with the rd_file_subselect_block() function. Return value: -1 means that the well is not found in this LGR at all. */ static int well_state_get_lgr_well_nr(const well_state_type *well_state, - const ecl_file_view_type *file_view) { + const rd_file_view_type *file_view) { int well_nr = -1; - if (ecl_file_view_has_kw(file_view, ZWEL_KW)) { - ecl_rsthead_type *header = ecl_rsthead_alloc(file_view, -1); - const ecl_kw_type *zwel_kw = - ecl_file_view_iget_named_kw(file_view, ZWEL_KW, 0); + if (rd_file_view_has_kw(file_view, ZWEL_KW)) { + rd_rsthead_type *header = rd_rsthead_alloc(file_view, -1); + const rd_kw_type *zwel_kw = + rd_file_view_iget_named_kw(file_view, ZWEL_KW, 0); int num_wells = header->nwells; well_nr = 0; while (true) { bool found = false; { char *lgr_well_name = - (char *)util_alloc_strip_copy((const char *)ecl_kw_iget_ptr( + (char *)util_alloc_strip_copy((const char *)rd_kw_iget_ptr( zwel_kw, well_nr * header->nzwelz)); if (well_state->name == lgr_well_name) @@ -341,30 +341,30 @@ static int well_state_get_lgr_well_nr(const well_state_type *well_state, break; } } - ecl_rsthead_free(header); + rd_rsthead_free(header); } return well_nr; } -well_type_enum well_state_translate_ecl_type_int(int int_type) { - well_type_enum type = ECL_WELL_ZERO; +well_type_enum well_state_translate_rd_type_int(int int_type) { + well_type_enum type = RD_WELL_ZERO; switch (int_type) { /* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */ case (IWEL_UNDOCUMENTED_ZERO): - type = ECL_WELL_ZERO; + type = RD_WELL_ZERO; break; case (IWEL_PRODUCER): - type = ECL_WELL_PRODUCER; + type = RD_WELL_PRODUCER; break; case (IWEL_OIL_INJECTOR): - type = ECL_WELL_OIL_INJECTOR; + type = RD_WELL_OIL_INJECTOR; break; case (IWEL_GAS_INJECTOR): - type = ECL_WELL_GAS_INJECTOR; + type = RD_WELL_GAS_INJECTOR; break; case (IWEL_WATER_INJECTOR): - type = ECL_WELL_WATER_INJECTOR; + type = RD_WELL_WATER_INJECTOR; break; default: util_abort("%s: Invalid type value %d\n", __func__, int_type); @@ -373,36 +373,36 @@ well_type_enum well_state_translate_ecl_type_int(int int_type) { } /* - This function assumes that the ecl_file state has been restricted - to one LGR block with the ecl_file_subselect_block() function. + This function assumes that the rd_file state has been restricted + to one LGR block with the rd_file_subselect_block() function. */ static void well_state_add_connections__(well_state_type *well_state, - const ecl_file_view_type *rst_view, + const rd_file_view_type *rst_view, const char *grid_name, int grid_nr, int well_nr) { - ecl_rsthead_type *header = ecl_rsthead_alloc(rst_view, -1); - const ecl_kw_type *iwel_kw = - ecl_file_view_iget_named_kw(rst_view, IWEL_KW, 0); + rd_rsthead_type *header = rd_rsthead_alloc(rst_view, -1); + const rd_kw_type *iwel_kw = + rd_file_view_iget_named_kw(rst_view, IWEL_KW, 0); well_state_add_wellhead(well_state, header, iwel_kw, well_nr, grid_name, grid_nr); - if (ecl_file_view_has_kw(rst_view, ICON_KW)) { - const ecl_kw_type *icon_kw = - ecl_file_view_iget_named_kw(rst_view, ICON_KW, 0); + if (rd_file_view_has_kw(rst_view, ICON_KW)) { + const rd_kw_type *icon_kw = + rd_file_view_iget_named_kw(rst_view, ICON_KW, 0); if (!well_state_has_grid_connections(well_state, grid_name)) well_state->connections[grid_name] = well_conn_collection_alloc(); { - ecl_kw_type *scon_kw = NULL; - if (ecl_file_view_has_kw(rst_view, SCON_KW)) - scon_kw = ecl_file_view_iget_named_kw(rst_view, SCON_KW, 0); + rd_kw_type *scon_kw = NULL; + if (rd_file_view_has_kw(rst_view, SCON_KW)) + scon_kw = rd_file_view_iget_named_kw(rst_view, SCON_KW, 0); - ecl_kw_type *xcon_kw = NULL; - if (ecl_file_view_has_kw(rst_view, XCON_KW)) { - xcon_kw = ecl_file_view_iget_named_kw(rst_view, XCON_KW, 0); + rd_kw_type *xcon_kw = NULL; + if (rd_file_view_has_kw(rst_view, XCON_KW)) { + xcon_kw = rd_file_view_iget_named_kw(rst_view, XCON_KW, 0); } well_conn_collection_type *wellcc = @@ -411,27 +411,26 @@ static void well_state_add_connections__(well_state_type *well_state, xcon_kw, well_nr, header); } } - ecl_rsthead_free(header); + rd_rsthead_free(header); } -static void -well_state_add_global_connections(well_state_type *well_state, - const ecl_file_view_type *rst_view, - int well_nr) { - well_state_add_connections__(well_state, rst_view, ECL_GRID_GLOBAL_GRID, 0, +static void well_state_add_global_connections(well_state_type *well_state, + const rd_file_view_type *rst_view, + int well_nr) { + well_state_add_connections__(well_state, rst_view, RD_GRID_GLOBAL_GRID, 0, well_nr); } static void well_state_add_LGR_connections(well_state_type *well_state, - const ecl_grid_type *grid, - ecl_file_view_type *file_view) { + const rd_grid_type *grid, + rd_file_view_type *file_view) { // Go through all the LGRs and add connections; both in the bulk // grid and as wellhead. - int num_lgr = ecl_grid_get_num_lgr(grid); + int num_lgr = rd_grid_get_num_lgr(grid); for (int lgr_index = 0; lgr_index < num_lgr; lgr_index++) { - ecl_file_view_type *lgr_view = - ecl_file_view_add_blockview(file_view, LGR_KW, lgr_index); + rd_file_view_type *lgr_view = + rd_file_view_add_blockview(file_view, LGR_KW, lgr_index); /* Even though the grid has LGR information the restart file is not required to have corresponding LGR information. This has for a long time been @@ -440,7 +439,7 @@ static void well_state_add_LGR_connections(well_state_type *well_state, information can also be found in the restart file. */ if (lgr_view) { - const char *grid_name = ecl_grid_iget_lgr_name(grid, lgr_index); + const char *grid_name = rd_grid_iget_lgr_name(grid, lgr_index); int well_nr = well_state_get_lgr_well_nr(well_state, lgr_view); if (well_nr >= 0) well_state_add_connections__(well_state, lgr_view, grid_name, @@ -450,45 +449,45 @@ static void well_state_add_LGR_connections(well_state_type *well_state, } void well_state_add_connections( - well_state_type *well_state, const ecl_grid_type *grid, - ecl_file_type * + well_state_type *well_state, const rd_grid_type *grid, + rd_file_type * rst_file, // Either an open .Xnnnn file or UNRST file restricted to one report step int well_nr) { well_state_add_connections2(well_state, grid, - ecl_file_get_active_view(rst_file), well_nr); + rd_file_get_active_view(rst_file), well_nr); } void well_state_add_connections2(well_state_type *well_state, - const ecl_grid_type *grid, - ecl_file_view_type *rst_view, int well_nr) { + const rd_grid_type *grid, + rd_file_view_type *rst_view, int well_nr) { well_state_add_global_connections(well_state, rst_view, well_nr); well_state_add_LGR_connections(well_state, grid, rst_view); } -bool well_state_add_MSW(well_state_type *well_state, ecl_file_type *rst_file, +bool well_state_add_MSW(well_state_type *well_state, rd_file_type *rst_file, int well_nr, bool load_segment_information) { - return well_state_add_MSW2(well_state, ecl_file_get_active_view(rst_file), + return well_state_add_MSW2(well_state, rd_file_get_active_view(rst_file), well_nr, load_segment_information); } bool well_state_add_MSW2(well_state_type *well_state, - ecl_file_view_type *rst_view, int well_nr, + rd_file_view_type *rst_view, int well_nr, bool load_segment_information) { - if (ecl_file_view_has_kw(rst_view, ISEG_KW)) { - ecl_rsthead_type *rst_head = ecl_rsthead_alloc(rst_view, -1); - const ecl_kw_type *iwel_kw = - ecl_file_view_iget_named_kw(rst_view, IWEL_KW, 0); - const ecl_kw_type *iseg_kw = - ecl_file_view_iget_named_kw(rst_view, ISEG_KW, 0); + if (rd_file_view_has_kw(rst_view, ISEG_KW)) { + rd_rsthead_type *rst_head = rd_rsthead_alloc(rst_view, -1); + const rd_kw_type *iwel_kw = + rd_file_view_iget_named_kw(rst_view, IWEL_KW, 0); + const rd_kw_type *iseg_kw = + rd_file_view_iget_named_kw(rst_view, ISEG_KW, 0); well_rseg_loader_type *rseg_loader = NULL; int segment_count; - if (ecl_file_view_has_kw(rst_view, RSEG_KW)) { + if (rd_file_view_has_kw(rst_view, RSEG_KW)) { if (load_segment_information) rseg_loader = well_rseg_loader_alloc(rst_view); @@ -509,7 +508,7 @@ bool well_state_add_MSW2(well_state_type *well_state, well_segment_collection_add_branches(well_state->segments, well_state->branches); } - ecl_rsthead_free(rst_head); + rd_rsthead_free(rst_head); if (rseg_loader != NULL) { well_rseg_loader_free(rseg_loader); @@ -532,35 +531,35 @@ bool well_state_has_segment_data(const well_state_type *well_state) { return false; } -well_state_type *well_state_alloc_from_file(ecl_file_type *ecl_file, - const ecl_grid_type *grid, +well_state_type *well_state_alloc_from_file(rd_file_type *rd_file, + const rd_grid_type *grid, int report_nr, int global_well_nr, bool load_segment_information) { - return well_state_alloc_from_file2(ecl_file_get_active_view(ecl_file), grid, + return well_state_alloc_from_file2(rd_file_get_active_view(rd_file), grid, report_nr, global_well_nr, load_segment_information); } -well_state_type *well_state_alloc_from_file2(ecl_file_view_type *file_view, - const ecl_grid_type *grid, +well_state_type *well_state_alloc_from_file2(rd_file_view_type *file_view, + const rd_grid_type *grid, int report_nr, int global_well_nr, bool load_segment_information) { - if (ecl_file_view_has_kw(file_view, IWEL_KW)) { + if (rd_file_view_has_kw(file_view, IWEL_KW)) { well_state_type *well_state = NULL; - ecl_rsthead_type *global_header = ecl_rsthead_alloc(file_view, -1); - const ecl_kw_type *global_iwel_kw = - ecl_file_view_iget_named_kw(file_view, IWEL_KW, 0); - const ecl_kw_type *global_zwel_kw = - ecl_file_view_iget_named_kw(file_view, ZWEL_KW, 0); + rd_rsthead_type *global_header = rd_rsthead_alloc(file_view, -1); + const rd_kw_type *global_iwel_kw = + rd_file_view_iget_named_kw(file_view, IWEL_KW, 0); + const rd_kw_type *global_zwel_kw = + rd_file_view_iget_named_kw(file_view, ZWEL_KW, 0); const int iwel_offset = global_header->niwelz * global_well_nr; { char *name; bool open; - well_type_enum type = ECL_WELL_ZERO; + well_type_enum type = RD_WELL_ZERO; { - int int_state = ecl_kw_iget_int( - global_iwel_kw, iwel_offset + IWEL_STATUS_INDEX); + int int_state = rd_kw_iget_int(global_iwel_kw, + iwel_offset + IWEL_STATUS_INDEX); if (int_state > 0) open = true; else @@ -568,15 +567,15 @@ well_state_type *well_state_alloc_from_file2(ecl_file_view_type *file_view, } { - int int_type = ecl_kw_iget_int(global_iwel_kw, - iwel_offset + IWEL_TYPE_INDEX); - type = well_state_translate_ecl_type_int(int_type); + int int_type = rd_kw_iget_int(global_iwel_kw, + iwel_offset + IWEL_TYPE_INDEX); + type = well_state_translate_rd_type_int(int_type); } { const int zwel_offset = global_header->nzwelz * global_well_nr; name = - (char *)util_alloc_strip_copy((const char *)ecl_kw_iget_ptr( + (char *)util_alloc_strip_copy((const char *)rd_kw_iget_ptr( global_zwel_kw, zwel_offset)); // Hardwired max 8 characters in Well Name } @@ -587,13 +586,13 @@ well_state_type *well_state_alloc_from_file2(ecl_file_view_type *file_view, well_state_add_connections2(well_state, grid, file_view, global_well_nr); - if (ecl_file_view_has_kw(file_view, ISEG_KW)) + if (rd_file_view_has_kw(file_view, ISEG_KW)) well_state_add_MSW2(well_state, file_view, global_well_nr, load_segment_information); well_state_add_rates(well_state, file_view, global_well_nr); } - ecl_rsthead_free(global_header); + rd_rsthead_free(global_header); return well_state; } else /* This seems a bit weird - have come over E300 restart files without the IWEL keyword. */ @@ -653,7 +652,7 @@ const well_conn_type *well_state_get_wellhead(const well_state_type *well_state, const well_conn_type * well_state_get_global_wellhead(const well_state_type *well_state) { - return well_state_get_wellhead(well_state, ECL_GRID_GLOBAL_GRID); + return well_state_get_wellhead(well_state, RD_GRID_GLOBAL_GRID); } well_type_enum well_state_get_type(const well_state_type *well_state) { @@ -683,7 +682,7 @@ well_state_get_grid_connections(const well_state_type *well_state, const well_conn_collection_type * well_state_get_global_connections(const well_state_type *well_state) { - return well_state_get_grid_connections(well_state, ECL_GRID_GLOBAL_GRID); + return well_state_get_grid_connections(well_state, RD_GRID_GLOBAL_GRID); } bool well_state_has_grid_connections(const well_state_type *well_state, @@ -696,7 +695,7 @@ bool well_state_has_grid_connections(const well_state_type *well_state, } bool well_state_has_global_connections(const well_state_type *well_state) { - return well_state_has_grid_connections(well_state, ECL_GRID_GLOBAL_GRID); + return well_state_has_grid_connections(well_state, RD_GRID_GLOBAL_GRID); } well_segment_collection_type * diff --git a/lib/resdata/well_ts.cpp b/lib/resdata/well_ts.cpp index cb56270bae..a10267226d 100644 --- a/lib/resdata/well_ts.cpp +++ b/lib/resdata/well_ts.cpp @@ -49,9 +49,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define WELL_TS_TYPE_ID 6613005 #define WELL_NODE_TYPE_ID 1114652 diff --git a/lib/tests/test_rd_grid.cpp b/lib/tests/test_rd_grid.cpp index 033d31f8b3..d3c9c7edf4 100644 --- a/lib/tests/test_rd_grid.cpp +++ b/lib/tests/test_rd_grid.cpp @@ -1,7 +1,7 @@ #include -#include -#include -#include +#include +#include +#include #include #include "tmpdir.hpp" @@ -11,17 +11,17 @@ using namespace Matchers; TEST_CASE("Test unfractured grids", "[unittest]") { GIVEN("An unfractured grid") { - ecl_grid_type *grid = - ecl_grid_alloc_rectangular(21, 11, 12, 1, 2, 3, NULL); + rd_grid_type *grid = + rd_grid_alloc_rectangular(21, 11, 12, 1, 2, 3, NULL); - REQUIRE(ecl_grid_get_nactive_fracture(grid) == 0); + REQUIRE(rd_grid_get_nactive_fracture(grid) == 0); THEN("It should return -1 on any fracture index") { auto i = GENERATE(0, 1, 10, 20); - REQUIRE(ecl_grid_get_active_fracture_index1(grid, i) == -1); + REQUIRE(rd_grid_get_active_fracture_index1(grid, i) == -1); } - ecl_grid_free(grid); + rd_grid_free(grid); } } @@ -45,9 +45,9 @@ double center_of_cell(double cell_width, int index) { * all width the given x, y, and z dimensions. depth is set by * the depth function applied to the center of the cell. */ -ecl_grid_type *generate_dxv_dyv_dzv_depthz_grid(int num_x, int num_y, int num_z, - double x_width, double y_width, - double z_width) { +rd_grid_type *generate_dxv_dyv_dzv_depthz_grid(int num_x, int num_y, int num_z, + double x_width, double y_width, + double z_width) { auto x_widths = std::vector(num_x + 1, x_width); auto y_widths = std::vector(num_y + 1, y_width); auto z_widths = std::vector(num_z, z_width); @@ -61,7 +61,7 @@ ecl_grid_type *generate_dxv_dyv_dzv_depthz_grid(int num_x, int num_y, int num_z, } } - auto grid = ecl_grid_alloc_dxv_dyv_dzv_depthz( + auto grid = rd_grid_alloc_dxv_dyv_dzv_depthz( num_x, num_y, num_z, x_widths.data(), y_widths.data(), z_widths.data(), z_depths.data(), NULL); return grid; @@ -77,7 +77,7 @@ TEST_CASE("Test dxv_dyv_dzv grids", "[unittest]") { double y_width = 1.0 / ny; double z_width = 3.0 / nz; - ecl_grid_type *grid = generate_dxv_dyv_dzv_depthz_grid( + rd_grid_type *grid = generate_dxv_dyv_dzv_depthz_grid( nx, ny, nz, x_width, y_width, z_width); AND_GIVEN("Any cell in that grid") { @@ -87,7 +87,7 @@ TEST_CASE("Test dxv_dyv_dzv grids", "[unittest]") { THEN("get_xyz3 should return cell center in x, y plane") { double xc, yc, zc; - ecl_grid_get_xyz3(grid, i, j, k, &xc, &yc, &zc); + rd_grid_get_xyz3(grid, i, j, k, &xc, &yc, &zc); REQUIRE_THAT(xc, WithinAbs(center_of_cell(x_width, i), 0.000001)); @@ -96,7 +96,7 @@ TEST_CASE("Test dxv_dyv_dzv grids", "[unittest]") { THEN("The top cell corner has z offset by depth function") { double xc, yc, zc; - ecl_grid_get_cell_corner_xyz3(grid, i, j, k, 0, &xc, &yc, &zc); + rd_grid_get_cell_corner_xyz3(grid, i, j, k, 0, &xc, &yc, &zc); double x_center = center_of_cell(x_width, i); double y_center = center_of_cell(y_width, j); @@ -109,7 +109,7 @@ TEST_CASE("Test dxv_dyv_dzv grids", "[unittest]") { THEN("The bottom cell corner has z offset by depth function") { double xc, yc, zc; - ecl_grid_get_cell_corner_xyz3(grid, i, j, k, 4, &xc, &yc, &zc); + rd_grid_get_cell_corner_xyz3(grid, i, j, k, 4, &xc, &yc, &zc); double x_center = center_of_cell(x_width, i); double y_center = center_of_cell(y_width, j); @@ -120,25 +120,25 @@ TEST_CASE("Test dxv_dyv_dzv grids", "[unittest]") { } THEN("The volume should be simple multiplication") { - double volume = ecl_grid_get_cell_volume3(grid, i, j, k); + double volume = rd_grid_get_cell_volume3(grid, i, j, k); REQUIRE_THAT(volume, WithinAbs(z_width * x_width * y_width, 1e-4)); } } AND_GIVEN("A grid constructed in the same way") { - ecl_grid_type *grid2 = generate_dxv_dyv_dzv_depthz_grid( + rd_grid_type *grid2 = generate_dxv_dyv_dzv_depthz_grid( nx, ny, nz, x_width, y_width, z_width); THEN("Those grids are equal") { - REQUIRE(ecl_grid_compare(grid, grid2, false, false, true)); + REQUIRE(rd_grid_compare(grid, grid2, false, false, true)); } - ecl_grid_free(grid2); + rd_grid_free(grid2); } - ecl_grid_free(grid); + rd_grid_free(grid); } } /** - * Generates a grid, using the ecl_grid_alloc_GRDECL_kw constructor, + * Generates a grid, using the rd_grid_alloc_GRDECL_kw constructor, * with the x,y,z coordinates of the 0th corner of the ijkth cel is * i,j,k. In other words this is a grid where the corners are on the * whole numbers. @@ -146,57 +146,57 @@ TEST_CASE("Test dxv_dyv_dzv grids", "[unittest]") { * Takes a vector of i,j,k,c,z tuples which changes the corner c of cell * at i,j,k z value. */ -ecl_grid_type *generate_coordkw_grid( +rd_grid_type *generate_coordkw_grid( int num_x, int num_y, int num_z, const std::vector> &z_vector) { - ecl_kw_type *coord_kw = - ecl_kw_alloc(COORD_KW, ECL_GRID_COORD_SIZE(num_x, num_y), ECL_FLOAT); - ecl_kw_type *zcorn_kw = ecl_kw_alloc( - ZCORN_KW, ECL_GRID_ZCORN_SIZE(num_x, num_y, num_z), ECL_FLOAT); + rd_kw_type *coord_kw = + rd_kw_alloc(COORD_KW, RD_GRID_COORD_SIZE(num_x, num_y), RD_FLOAT); + rd_kw_type *zcorn_kw = rd_kw_alloc( + ZCORN_KW, RD_GRID_ZCORN_SIZE(num_x, num_y, num_z), RD_FLOAT); for (int j = 0; j < num_y; j++) { for (int i = 0; i < num_x; i++) { int offset = 6 * (i + j * num_x); - ecl_kw_iset_float(coord_kw, offset, i); - ecl_kw_iset_float(coord_kw, offset + 1, j); - ecl_kw_iset_float(coord_kw, offset + 2, -1); + rd_kw_iset_float(coord_kw, offset, i); + rd_kw_iset_float(coord_kw, offset + 1, j); + rd_kw_iset_float(coord_kw, offset + 2, -1); - ecl_kw_iset_float(coord_kw, offset + 3, i); - ecl_kw_iset_float(coord_kw, offset + 4, j); - ecl_kw_iset_float(coord_kw, offset + 5, -1); + rd_kw_iset_float(coord_kw, offset + 3, i); + rd_kw_iset_float(coord_kw, offset + 4, j); + rd_kw_iset_float(coord_kw, offset + 5, -1); for (int k = 0; k < num_z; k++) { for (int c = 0; c < 4; c++) { - int zi1 = ecl_grid_zcorn_index__(num_x, num_y, i, j, k, c); + int zi1 = rd_grid_zcorn_index__(num_x, num_y, i, j, k, c); int zi2 = - ecl_grid_zcorn_index__(num_x, num_y, i, j, k, c + 4); + rd_grid_zcorn_index__(num_x, num_y, i, j, k, c + 4); double z1 = k; double z2 = k + 1; - ecl_kw_iset_float(zcorn_kw, zi1, z1); - ecl_kw_iset_float(zcorn_kw, zi2, z2); + rd_kw_iset_float(zcorn_kw, zi1, z1); + rd_kw_iset_float(zcorn_kw, zi2, z2); } } } } for (const auto &[i, j, k, c, z] : z_vector) { - auto index = ecl_grid_zcorn_index__(num_x, num_y, i, j, k, c); - ecl_kw_iset_float(zcorn_kw, index, z); + auto index = rd_grid_zcorn_index__(num_x, num_y, i, j, k, c); + rd_kw_iset_float(zcorn_kw, index, z); } - ecl_grid_type *grid = ecl_grid_alloc_GRDECL_kw( - num_x, num_y, num_z, zcorn_kw, coord_kw, NULL, NULL); - ecl_kw_free(coord_kw); - ecl_kw_free(zcorn_kw); + rd_grid_type *grid = rd_grid_alloc_GRDECL_kw(num_x, num_y, num_z, zcorn_kw, + coord_kw, NULL, NULL); + rd_kw_free(coord_kw); + rd_kw_free(zcorn_kw); return grid; } TEST_CASE("Test no twistedness", "[unittest]") { GIVEN("A grid with untwisted cells") { - ecl_grid_type *grid = generate_coordkw_grid(10, 7, 8, {}); + rd_grid_type *grid = generate_coordkw_grid(10, 7, 8, {}); AND_GIVEN("Any cell in that grid") { auto i = GENERATE(take(3, random(0, 9))); @@ -204,11 +204,11 @@ TEST_CASE("Test no twistedness", "[unittest]") { auto k = GENERATE(take(3, random(0, 7))); THEN("That cell should have a twist score of 0") { - REQUIRE(ecl_grid_get_cell_twist3(grid, i, j, k) == 0); + REQUIRE(rd_grid_get_cell_twist3(grid, i, j, k) == 0); } } - ecl_grid_free(grid); + rd_grid_free(grid); } } @@ -218,13 +218,13 @@ TEST_CASE("Test simple twistedness", "[unittest]") { {0, 0, 0, 0, 0.0}, {0, 0, 0, 4, -0.25}, }; - ecl_grid_type *grid = generate_coordkw_grid(10, 7, 8, z_vector); + rd_grid_type *grid = generate_coordkw_grid(10, 7, 8, z_vector); THEN("That cell should have a twist score of 1") { - REQUIRE(ecl_grid_get_cell_twist3(grid, 0, 0, 0) == 1); + REQUIRE(rd_grid_get_cell_twist3(grid, 0, 0, 0) == 1); } - ecl_grid_free(grid); + rd_grid_free(grid); } } @@ -236,43 +236,43 @@ TEST_CASE("Test double twistedness", "[unittest]") { {0, 0, 0, 3, 0.0}, {0, 0, 0, 7, -0.25}, }; - ecl_grid_type *grid = generate_coordkw_grid(10, 7, 8, z_vector); + rd_grid_type *grid = generate_coordkw_grid(10, 7, 8, z_vector); THEN("That cell should have a twist score of 2") { - REQUIRE(ecl_grid_get_cell_twist3(grid, 0, 0, 0) == 2); + REQUIRE(rd_grid_get_cell_twist3(grid, 0, 0, 0) == 2); } - ecl_grid_free(grid); + rd_grid_free(grid); } } TEST_CASE_METHOD(Tmpdir, "Test case loading", "[unittest]") { GIVEN("A grid on disc") { auto filename = dirname / "GRID.EGRID"; - ecl_grid_type *ecl_grid = - ecl_grid_alloc_rectangular(5, 5, 5, 1, 1, 1, nullptr); - ecl_grid_fwrite_EGRID2(ecl_grid, filename.c_str(), ECL_METRIC_UNITS); - ecl_grid_free(ecl_grid); + rd_grid_type *rd_grid = + rd_grid_alloc_rectangular(5, 5, 5, 1, 1, 1, nullptr); + rd_grid_fwrite_EGRID2(rd_grid, filename.c_str(), RD_METRIC_UNITS); + rd_grid_free(rd_grid); THEN("Loading that grid gives a non-null grid as a case") { - ecl_grid_type *grid = ecl_grid_load_case(filename.c_str()); + rd_grid_type *grid = rd_grid_load_case(filename.c_str()); REQUIRE(grid != NULL); - ecl_grid_free(grid); + rd_grid_free(grid); } THEN("Loading it as without extension also gives non-null grid") { auto no_ext_file_name = dirname / "GRID"; - ecl_grid_type *grid = ecl_grid_load_case(no_ext_file_name.c_str()); + rd_grid_type *grid = rd_grid_load_case(no_ext_file_name.c_str()); REQUIRE(grid != NULL); - ecl_grid_free(grid); + rd_grid_free(grid); } THEN("Loadinging a non-existent grid gives NULL") { auto does_not_exist = dirname / "DOES_NOT_EXIST.EGRID"; - ecl_grid_type *grid = ecl_grid_load_case(does_not_exist.c_str()); + rd_grid_type *grid = rd_grid_load_case(does_not_exist.c_str()); REQUIRE(grid == NULL); } THEN("Loading non-existent grid without extension gives NULL") { auto does_not_exist = dirname / "DOES_NOT_EXIST"; - ecl_grid_type *grid = ecl_grid_load_case(does_not_exist.c_str()); + rd_grid_type *grid = rd_grid_load_case(does_not_exist.c_str()); REQUIRE(grid == NULL); } } @@ -280,47 +280,46 @@ TEST_CASE_METHOD(Tmpdir, "Test case loading", "[unittest]") { TEST_CASE_METHOD(Tmpdir, "Test format writing grid", "[unittest]") { GIVEN("A Grid") { - ecl_grid_type *ecl_grid = - ecl_grid_alloc_rectangular(5, 5, 5, 1, 1, 1, nullptr); + rd_grid_type *rd_grid = + rd_grid_alloc_rectangular(5, 5, 5, 1, 1, 1, nullptr); THEN("Writing that file as a FEGRID is a formatted file") { - ecl_grid_fwrite_EGRID2(ecl_grid, (dirname / "CASE.FEGRID").c_str(), - ECL_METRIC_UNITS); + rd_grid_fwrite_EGRID2(rd_grid, (dirname / "CASE.FEGRID").c_str(), + RD_METRIC_UNITS); REQUIRE(util_fmt_bit8((dirname / "CASE.FEGRID").c_str())); } THEN("Writing that file as a EGRID is an unformatted file") { - ecl_grid_fwrite_EGRID2(ecl_grid, (dirname / "CASE.EGRID").c_str(), - ECL_METRIC_UNITS); + rd_grid_fwrite_EGRID2(rd_grid, (dirname / "CASE.EGRID").c_str(), + RD_METRIC_UNITS); REQUIRE(!util_fmt_bit8((dirname / "CASE.EGRID").c_str())); } THEN( "Writing that file with unknown extension is an unformatted file") { - ecl_grid_fwrite_EGRID2(ecl_grid, (dirname / "CASE.UNKNOWN").c_str(), - ECL_METRIC_UNITS); + rd_grid_fwrite_EGRID2(rd_grid, (dirname / "CASE.UNKNOWN").c_str(), + RD_METRIC_UNITS); REQUIRE(!util_fmt_bit8((dirname / "CASE.UNKNOWN").c_str())); } - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } } TEST_CASE_METHOD(Tmpdir, "Writing and reading grid", "[unittest]") { GIVEN("A Grid") { - ecl_grid_type *ecl_grid = - ecl_grid_alloc_rectangular(5, 5, 5, 1, 1, 1, nullptr); + rd_grid_type *rd_grid = + rd_grid_alloc_rectangular(5, 5, 5, 1, 1, 1, nullptr); THEN("Writing and reading that grid gives equal grid") { auto filename = (dirname / "CASE.EGRID"); - ecl_grid_fwrite_EGRID2(ecl_grid, filename.c_str(), - ECL_METRIC_UNITS); - ecl_grid_type *read_grid = ecl_grid_alloc(filename.c_str()); + rd_grid_fwrite_EGRID2(rd_grid, filename.c_str(), RD_METRIC_UNITS); + rd_grid_type *read_grid = rd_grid_alloc(filename.c_str()); - REQUIRE(ecl_grid_compare(ecl_grid, read_grid, false, false, true)); + REQUIRE(rd_grid_compare(rd_grid, read_grid, false, false, true)); - ecl_grid_free(read_grid); + rd_grid_free(read_grid); } - ecl_grid_free(ecl_grid); + rd_grid_free(rd_grid); } } diff --git a/lib/tests/test_rd_util.cpp b/lib/tests/test_rd_util.cpp index e05c9dc0a9..9d24e853ba 100644 --- a/lib/tests/test_rd_util.cpp +++ b/lib/tests/test_rd_util.cpp @@ -1,5 +1,5 @@ #include -#include +#include using namespace Catch; using namespace Matchers; @@ -7,27 +7,27 @@ using namespace Matchers; TEST_CASE("Test file type format check", "[unittest]") { bool is_fmt = false; SECTION("A FUNRST file is a formatted file") { - ecl_util_get_file_type("CASE.FUNRST", &is_fmt, NULL); + rd_get_file_type("CASE.FUNRST", &is_fmt, NULL); REQUIRE(is_fmt); } SECTION("A FMSPEC file is a formatted file") { - ecl_util_get_file_type("CASE.FMSPEC", &is_fmt, NULL); + rd_get_file_type("CASE.FMSPEC", &is_fmt, NULL); REQUIRE(is_fmt); } SECTION("A .F0001 file is a formatted file") { - ecl_util_get_file_type("CASE.F0001", &is_fmt, NULL); + rd_get_file_type("CASE.F0001", &is_fmt, NULL); REQUIRE(is_fmt); } SECTION("A .X1234 file is an unformatted file") { - ecl_util_get_file_type("CASE.X1234", &is_fmt, NULL); + rd_get_file_type("CASE.X1234", &is_fmt, NULL); REQUIRE(!is_fmt); } SECTION("A .UNSMRY file is an unformatted file") { - ecl_util_get_file_type("CASE.UNSMRY", &is_fmt, NULL); + rd_get_file_type("CASE.UNSMRY", &is_fmt, NULL); REQUIRE(!is_fmt); } } diff --git a/lib/tests/tmpdir.hpp b/lib/tests/tmpdir.hpp index ef70e18e61..d402ca2f4b 100644 --- a/lib/tests/tmpdir.hpp +++ b/lib/tests/tmpdir.hpp @@ -17,7 +17,7 @@ class Tmpdir { static bool delete_temporary_files; fs::path dirname; Tmpdir() { - auto parentdir = fs::temp_directory_path() / "ecl_test"; + auto parentdir = fs::temp_directory_path() / "rd_test"; do { dirname = parentdir / std::to_string(rand()); diff --git a/lib/util/cxx_string_util.cpp b/lib/util/cxx_string_util.cpp index 48cbe0db0b..f7f1afd733 100644 --- a/lib/util/cxx_string_util.cpp +++ b/lib/util/cxx_string_util.cpp @@ -1,7 +1,7 @@ #include #include -namespace ecl { +namespace rd { namespace util { std::string string_format(const char *fmt, ...) { @@ -23,4 +23,4 @@ std::string string_format(const char *fmt, ...) { return s; } } // namespace util -} // namespace ecl +} // namespace rd diff --git a/lib/util/path.cpp b/lib/util/path.cpp index 1ee79d960a..6ca190cdb8 100644 --- a/lib/util/path.cpp +++ b/lib/util/path.cpp @@ -6,7 +6,7 @@ #include "detail/util/path.hpp" -namespace ecl { +namespace rd { namespace util { @@ -72,4 +72,4 @@ std::string extension(const std::string &fname) { } // namespace path } // namespace util -} // namespace ecl +} // namespace rd diff --git a/lib/util/rd_version.cpp b/lib/util/rd_version.cpp index 620b41bb7a..0b187d77f1 100644 --- a/lib/util/rd_version.cpp +++ b/lib/util/rd_version.cpp @@ -1,10 +1,10 @@ #include -#include +#include #define xstr(s) #s #define str(s) xstr(s) -const char *ecl_version_get_git_commit() { +const char *rd_version_get_git_commit() { #ifdef GIT_COMMIT return str(GIT_COMMIT); #else @@ -12,7 +12,7 @@ const char *ecl_version_get_git_commit() { #endif } -const char *ecl_version_get_git_commit_short() { +const char *rd_version_get_git_commit_short() { #ifdef GIT_COMMIT_SHORT return str(GIT_COMMIT_SHORT); #else @@ -20,7 +20,7 @@ const char *ecl_version_get_git_commit_short() { #endif } -const char *ecl_version_get_build_time() { +const char *rd_version_get_build_time() { #ifdef COMPILE_TIME_STAMP return COMPILE_TIME_STAMP; #else @@ -28,12 +28,12 @@ const char *ecl_version_get_build_time() { #endif } -int ecl_version_get_major_version() { return ECL_VERSION_MAJOR; } +int rd_version_get_major_version() { return RD_VERSION_MAJOR; } -int ecl_version_get_minor_version() { return ECL_VERSION_MINOR; } +int rd_version_get_minor_version() { return RD_VERSION_MINOR; } -const char *ecl_version_get_micro_version() { return str(ECL_VERSION_MICRO); } +const char *rd_version_get_micro_version() { return str(RD_VERSION_MICRO); } -bool ecl_version_is_devel_version() { - return util_sscanf_int(str(ECL_VERSION_MICRO), NULL); +bool rd_version_is_devel_version() { + return util_sscanf_int(str(RD_VERSION_MICRO), NULL); } diff --git a/lib/util/test_work_area.cpp b/lib/util/test_work_area.cpp index fef6f48d04..f238c2ea69 100644 --- a/lib/util/test_work_area.cpp +++ b/lib/util/test_work_area.cpp @@ -100,7 +100,7 @@ static char *test_work_area_alloc_prefix() { #endif } -namespace ecl { +namespace rd { namespace util { static bool test_work_area_copy_parent__(const TestArea *work_area, @@ -169,7 +169,7 @@ TestArea::TestArea(const std::string &test_name, bool store_area) char *user_name = util_alloc_sprintf("ert-test-%08u", random_int); #endif - char *test_cwd = ecl::util::create_test_path(test_name, prefix, user_name); + char *test_cwd = rd::util::create_test_path(test_name, prefix, user_name); { char *cwd_tmp = util_alloc_cwd(); @@ -244,12 +244,12 @@ bool TestArea::copy_parent_content(const std::string input_path) const { } } // namespace util -} // namespace ecl +} // namespace rd test_work_area_type *test_work_area_alloc__(const char *test_name, bool store_area) { if (test_name) - return new ecl::util::TestArea(test_name, store_area); + return new rd::util::TestArea(test_name, store_area); else return NULL; } @@ -290,7 +290,7 @@ void test_work_area_install_file(const test_work_area_type *work_area, return; else { std::string src_file = work_area->original_path(input_src_file); - std::string src_path = ecl::util::path::dirname(input_src_file); + std::string src_path = rd::util::path::dirname(input_src_file); if (!util_entry_exists(src_path.c_str())) util_make_path(src_path.c_str()); diff --git a/lib/util/tests/ert_util_chdir.cpp b/lib/util/tests/ert_util_chdir.cpp index 500f67ec22..f44d4dda03 100644 --- a/lib/util/tests/ert_util_chdir.cpp +++ b/lib/util/tests/ert_util_chdir.cpp @@ -6,7 +6,7 @@ #include void test_chdir() { - ecl::util::TestArea ta("chdir"); + rd::util::TestArea ta("chdir"); const char *cwd = ta.test_cwd().c_str(); test_assert_false(util_chdir_file("/file/does/not/exist")); diff --git a/lib/util/tests/ert_util_copy_file.cpp b/lib/util/tests/ert_util_copy_file.cpp index 7cb93c58eb..73a22e12c0 100644 --- a/lib/util/tests/ert_util_copy_file.cpp +++ b/lib/util/tests/ert_util_copy_file.cpp @@ -17,7 +17,7 @@ void test_copy_file(const char *executable) { mode0 = stat_buf.st_mode; { - ecl::util::TestArea ta("copy_file"); + rd::util::TestArea ta("copy_file"); util_copy_file(executable, "test.x"); test_assert_true(util_file_exists("test.x")); diff --git a/lib/util/tests/ert_util_mkdir_p.cpp b/lib/util/tests/ert_util_mkdir_p.cpp index b1e5c8c10e..bfcdf13b91 100644 --- a/lib/util/tests/ert_util_mkdir_p.cpp +++ b/lib/util/tests/ert_util_mkdir_p.cpp @@ -6,7 +6,7 @@ #include int main(int argc, char **argv) { - ecl::util::TestArea ta("mkdir"); + rd::util::TestArea ta("mkdir"); // Regular use test_assert_true(util_mkdir_p("some/path/with/many/levels")); diff --git a/lib/util/tests/ert_util_normal_path.cpp b/lib/util/tests/ert_util_normal_path.cpp index 1eb9325502..5d9be97a7a 100644 --- a/lib/util/tests/ert_util_normal_path.cpp +++ b/lib/util/tests/ert_util_normal_path.cpp @@ -12,7 +12,7 @@ void test_path(const char *input_path, const char *expected_path) { } void test_relative() { - ecl::util::TestArea ta("relative_path"); + rd::util::TestArea ta("relative_path"); util_make_path("level0/level1/level2"); test_path("level0/level1/../", "level0"); @@ -32,7 +32,7 @@ void test_relative() { } void test_beyond_root() { - ecl::util::TestArea("beyond_root"); + rd::util::TestArea("beyond_root"); char *cwd = util_alloc_cwd(); char *backref_cwd1 = util_alloc_sprintf("../../../../../../../../../../../%s", cwd); diff --git a/lib/util/tests/ert_util_spawn.cpp b/lib/util/tests/ert_util_spawn.cpp index b0cf560625..9573dd7ecb 100644 --- a/lib/util/tests/ert_util_spawn.cpp +++ b/lib/util/tests/ert_util_spawn.cpp @@ -40,7 +40,7 @@ bool check_script(const char *script) { } void test_spawn_no_redirect() { - ecl::util::TestArea ta("spawn1"); + rd::util::TestArea ta("spawn1"); { int status; make_script("script", stdout_msg, stderr_msg); @@ -116,7 +116,7 @@ void *test_spawn_redirect__(const char *path) { } void test_spawn_redirect() { - ecl::util::TestArea ta("test_redirect"); + rd::util::TestArea ta("test_redirect"); { make_script("script", stdout_msg, stderr_msg); util_addmode_if_owner("script", S_IRUSR + S_IWUSR + S_IXUSR + S_IRGRP + @@ -132,7 +132,7 @@ void test_spawn_redirect_threaded() { const int num = 128; // Generate the scripts on disk first - ecl::util::TestArea("spawn1_threaded"); + rd::util::TestArea("spawn1_threaded"); int *path_codes = (int *)util_calloc(num, sizeof *path_codes); stringlist_type *script_fullpaths = stringlist_alloc_new(); for (int i = 0; i < num; i++) { diff --git a/lib/util/tests/ert_util_split_path.cpp b/lib/util/tests/ert_util_split_path.cpp index 7b08ef1bfc..468f97891b 100644 --- a/lib/util/tests/ert_util_split_path.cpp +++ b/lib/util/tests/ert_util_split_path.cpp @@ -2,7 +2,7 @@ #include "detail/util/path.hpp" -using namespace ecl::util; +using namespace rd::util; int main(int argc, char **argv) { diff --git a/lib/util/tests/ert_util_stringlist_test.cpp b/lib/util/tests/ert_util_stringlist_test.cpp index 9e54f2e621..218f9b479a 100644 --- a/lib/util/tests/ert_util_stringlist_test.cpp +++ b/lib/util/tests/ert_util_stringlist_test.cpp @@ -337,7 +337,7 @@ bool not_FILE_predicate(const char *name, const void *arg) { } void test_predicate_matching() { - ecl::util::TestArea ta("stringlist"); + rd::util::TestArea ta("stringlist"); stringlist_type *s = stringlist_alloc_new(); stringlist_append_copy(s, "s"); stringlist_select_files(s, "does/not/exist", NULL, NULL); diff --git a/lib/util/tests/test_area.cpp b/lib/util/tests/test_area.cpp index 3476d8d05a..6a3b07208d 100644 --- a/lib/util/tests/test_area.cpp +++ b/lib/util/tests/test_area.cpp @@ -4,7 +4,7 @@ #include void test_create() { - ecl::util::TestArea ta("Name"); + rd::util::TestArea ta("Name"); test_assert_true(ta.test_cwd() != ta.original_cwd()); } diff --git a/python/cmake/Modules/init_python.cmake b/python/cmake/Modules/init_python.cmake index e17286711f..89b1dc0eda 100644 --- a/python/cmake/Modules/init_python.cmake +++ b/python/cmake/Modules/init_python.cmake @@ -120,7 +120,7 @@ def update_path(): if __name__ == '__main__': update_path( ) - from ecl.util.test import ErtTestRunner + from resdata.util.test import ErtTestRunner for test_class in sys.argv[1:]: tests = ErtTestRunner.getTestsFromTestClass(test_class) diff --git a/python/docs/CMakeLists.txt b/python/docs/CMakeLists.txt index e5a81cf123..32626b5804 100644 --- a/python/docs/CMakeLists.txt +++ b/python/docs/CMakeLists.txt @@ -12,7 +12,7 @@ add_custom_target( COMMAND sphinx-apidoc -e -o "${doc_build}/api" ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} tests WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} - DEPENDS ecl) + DEPENDS resdata) add_custom_target( html-doc ALL diff --git a/python/docs/code/python/index.rst b/python/docs/code/python/index.rst index c48e272c63..e9c94df8de 100644 --- a/python/docs/code/python/index.rst +++ b/python/docs/code/python/index.rst @@ -56,7 +56,7 @@ Here we see that the name of keyword is 'PORV', and it consists of (BASE.SMSPEC / BASE.UNSMRY / BASE.Snnnn), restart (BASE.UNRST / BASE.Xnnnn), grid (BASE.EGRID / BASE.GRID), rft (BASE.RFT) and init (BASE.INIT) consist of collections of such keywords. In the -:code:`ert.ecl` code the classes :code:`EclKW` and :code:`Ecl3DKW` are +:code:`ert.ecl` code the classes :code:`ResdataKW` and :code:`Resdata3DKW` are designed to work with *one* such keyword. @@ -92,38 +92,38 @@ you are advised to use :code:`pydoc ert.ecl.FortIO` or browse the API documentation at :ref:`python_documentation` for further details. -EclKW/Ecl3DKW - work with one keyword +ResdataKW/Resdata3DKW - work with one keyword ------------------------------------- -The :code:`EclKW` class represents one keyword [1]_ from an Eclipse -result file. The :code:`EclKW` class is essentially a vector of data, +The :code:`ResdataKW` class represents one keyword [1]_ from an Eclipse +result file. The :code:`ResdataKW` class is essentially a vector of data, along with header with the size and type of data, and the name of the -vector. Mostly you will get :code:`EclKW` instances by querying a -:code:`EclFile` instance - but you can also instantiate -:code:`EclKW` instances manually. The :code:`Ecl3DKW` class is for +vector. Mostly you will get :code:`ResdataKW` instances by querying a +:code:`ResdataFile` instance - but you can also instantiate +:code:`ResdataKW` instances manually. The :code:`Resdata3DKW` class is for keywords which represent 3D properties like e.g. PRESSURE and PORO, this class requires a grid instance, and is documented with the -:code:`EclGrid` documentation. +:code:`ResdataGrid` documentation. Special methods - container ........................... -The :code:`EclKW` class implements the :code:`__getitem__()` and +The :code:`ResdataKW` class implements the :code:`__getitem__()` and :code:`__setitem__()` methods which are used to implement access using the :code:`[ ]` notation, and the :code:`__len__()` method which gives -the size of the :code:`EclKW` instance. In the example below we load +the size of the :code:`ResdataKW` instance. In the example below we load an INIT file and extract the PERMX and PORO keywords, we then forcefully set permeability to zero for all elements where the porosity is below a limit: .. code:: python - from ert.ecl import EclFile,EclGrid + from ert.ecl import ResdataFile,ResdataGrid poro_limit = 0.05 - grid = EclGrid("CASE.EGRID") - init_file = EclFile("CASE.INIT") + grid = ResdataGrid("CASE.EGRID") + init_file = ResdataFile("CASE.INIT") permx = init_file["PERMX][0] poro = init_file["PORO"][0] @@ -135,22 +135,22 @@ porosity is below a limit: with open("permx.grdecl" , "w") as fileH: grid.write_grdecl( permx , fileH ) -In addition to the :code:`EclKW` class this example uses the classes -:code:`EclGrid` and :code:`EclFile` - see the documentation of them +In addition to the :code:`ResdataKW` class this example uses the classes +:code:`ResdataGrid` and :code:`ResdataFile` - see the documentation of them below. Furthermore this example demonstrates an important point: even -though the :code:`EclKW` class is an important "workhorse" - we mostly -get it from an :code:`EclFile` instance and do not instantiate it +though the :code:`ResdataKW` class is an important "workhorse" - we mostly +get it from an :code:`ResdataFile` instance and do not instantiate it directly. -For more details type :code:`pydoc ert.ecl.EclKW` or browse the API +For more details type :code:`pydoc ert.ecl.ResdataKW` or browse the API documentation at :ref:`python_documentation`. Special methods - arithmetic ............................ -The :code:`EclKW` class implements all the arithmetic operators, -meaning that :code:`EclKW` instances can be added, multiplied and +The :code:`ResdataKW` class implements all the arithmetic operators, +meaning that :code:`ResdataKW` instances can be added, multiplied and shifted. In the example below we load all INIT files with a matching filename pattern and then calculate the mean and standard deviation of the permeability: @@ -159,19 +159,19 @@ the permeability: import glob import math - from ert.ecl import EclFile, EclTypeEnum + from ert.ecl import ResdataFile, ResdataTypeEnum initfile_pattern = "/path/to/files/real*/CASE-*.INIT" kw_list = [] for init_file in glob.glob(initfile_pattern): - ecl_file = EclFile(init_file) - kw_list.append( ecl_file["PERMX"][0] ) + rd_file = ResdataFile(init_file) + kw_list.append( rd_file["PERMX"][0] ) - mean = EclKW.create("AVG-PERMX" , len(kw_list[0]) , EclTypeEnum.ECL_FLOAT_TYPE) - std = EclKW.create("STD-PERMX" , len(kw_list[0]) , EclTypeEnum.ECL_FLOAT_TYPE) + mean = ResdataKW.create("AVG-PERMX" , len(kw_list[0]) , ResdataTypeEnum.RD_FLOAT_TYPE) + std = ResdataKW.create("STD-PERMX" , len(kw_list[0]) , ResdataTypeEnum.RD_FLOAT_TYPE) - # Here we do normal arithmetic calculations with the EclKW instances + # Here we do normal arithmetic calculations with the ResdataKW instances for kw in kw_list: mean += kw std += kw * kw @@ -187,28 +187,28 @@ the permeability: Observe that for the arithmetic operations you can also call the inplace methods (*without* leading 'i') :code:`add()`, :code:`mul()`, :code:`sub` and :code:`div()` directly - in this form the methods also -accept a *mask* parameter as an :code:`EclRegion` instance which can +accept a *mask* parameter as an :code:`ResdataRegion` instance which can limit the operation to only a subset of the elements. -EclFile - an arbitrary binary Eclipse file +ResdataFile - an arbitrary binary Eclipse file ------------------------------------------ -The :code:`EclFile` class loads an arbitrary binary Eclipse file, and +The :code:`ResdataFile` class loads an arbitrary binary Eclipse file, and creates an index of all the keywords in the file. The main reason for -opening an Eclipse file with an :code:`EclFile` instance is to look up -keywords in the file as :code:`EclKW` instances. The :code:`EclFile` +opening an Eclipse file with an :code:`ResdataFile` instance is to look up +keywords in the file as :code:`ResdataKW` instances. The :code:`ResdataFile` is general and can be used to open any file, but in addition there are -specialized classes :code:`EclInitFile` and :code:`EclRestartFile` +specialized classes :code:`ResdataInitFile` and :code:`ResdataRestartFile` which can be used to open :code:`INIT` and restart files respectively; -these are documented along with the :code:`Ecl3DKW` class after the -:code:`EclGrid` documentation. +these are documented along with the :code:`Resdata3DKW` class after the +:code:`ResdataGrid` documentation. Special method __contains__() ............................. -The :code:`EclFile` class implements the :code:`__contains__` method +The :code:`ResdataFile` class implements the :code:`__contains__` method which is typically used to check if a file contains a certain keyword. The following example is a small script which will load an Eclipse binary file given as a command line argument, and check if the @@ -225,13 +225,13 @@ keywords :code:`SWAT`, :code:`SGAS` and :code:`SOIL`: #!/usr/bin/env python import sys - from ert.ecl import EclFile + from ert.ecl import ResdataFile - # Open the file, EclFile will raise the IOError exception + # Open the file, ResdataFile will raise the IOError exception # if the open fails. try: - file = EclFile( sys.argv[1] ) + file = ResdataFile( sys.argv[1] ) except IOError: sys.exit("Could not open file: %s" % sys.argv[1]) @@ -247,16 +247,16 @@ keywords :code:`SWAT`, :code:`SGAS` and :code:`SOIL`: Special method __getitem__() ............................ -The :code:`__getitem__()` method is used to get an :code:`EclKW` +The :code:`__getitem__()` method is used to get an :code:`ResdataKW` instance from a file through the :code:`[]` operator. The argument to the :code:`[]` operator can either be an integer to get a keywords by plain index order, or a keyword name. .. code:: python - from ert.ecl import EclFile + from ert.ecl import ResdataFile - file = EclFile("CASE.UNRST") + file = ResdataFile("CASE.UNRST") first_kw = file[0] swat_kw = file["SWAT"] @@ -268,30 +268,30 @@ keywords with the same name in a file. Restart specials ................ -The :code:`EclFile` class has many specialized methods for to perform +The :code:`ResdataFile` class has many specialized methods for to perform queries on the time direction of restart files. These methods should -be moved to :code:`EclRestartFile` class, and are documented there. +be moved to :code:`ResdataRestartFile` class, and are documented there. -For more details type :code:`pydoc ert.ecl.EclFile` or browse the API +For more details type :code:`pydoc ert.ecl.ResdataFile` or browse the API documentation at :ref:`python_documentation`. -EclGrid - load a grid +ResdataGrid - load a grid --------------------- -The :code:`EclGrid` class is used to load an Eclipse Grid, the main +The :code:`ResdataGrid` class is used to load an Eclipse Grid, the main way to load a grid is from a :code:`EGRID` or :code:`GRID` file, but as an alternative it is also possible to create a grid from a .grdecl formatted *input* file [3]_, or a simple rectangualar grid can be -*created* without an input file. In most cases the :code:`EclGrid` +*created* without an input file. In most cases the :code:`ResdataGrid` instance will be created as simple as: .. code:: python - from ert.ecl import EclGrid + from ert.ecl import ResdataGrid - grid = EclGrid("ECLIPSE.EGRID") + grid = ResdataGrid("ECLIPSE.EGRID") @@ -324,7 +324,7 @@ cells are active: The 0 or 1 in the upper left corner of each cell indicates whether the cell is active(1) or inactive(0) [4]_. When working with the -:code:`EclGrid` there are generally *three* different ways to refer to +:code:`ResdataGrid` there are generally *three* different ways to refer to a specific cell - these are: 1. A triplet of :code:`(i,j,k)` values - in the example above @@ -338,7 +338,7 @@ a specific cell - these are: uniquely identifies an *active* cell. In the figure above the active indices are the integers with a trailing 'a'. -All the methods on the :code:`EclGrid` object which evaluate +All the methods on the :code:`ResdataGrid` object which evaluate properties for a particular cell can take the cell coordinate in any of the three formats above. In addition there are conversion functions between the three. Observe that all the indexing methods assume that @@ -354,11 +354,11 @@ and then we print the (i,j,k) values for all the cells with .. code:: python - from ert.ecl import EclGrid,EclFile + from ert.ecl import ResdataGrid,ResdataFile permx_limit = 1e-2 - grid = EclGrid( "CASE.EGRID" ) - init = EclFile( "CASE.INIT" ) + grid = ResdataGrid( "CASE.EGRID" ) + init = ResdataFile( "CASE.INIT" ) permx_kw = init["PERMX"][0] @@ -376,31 +376,31 @@ cells. When working interchangebly with properties defined over all cells or only the active cells it is very important to think straight. -Ecl3DKW - a grid aware EclKW class +Resdata3DKW - a grid aware ResdataKW class .................................. -The :code:`Ecl3DKW` class is derived from the :code:`EclKW` class, but -the instance has a :code:`EclGrid` and optionally a default value +The :code:`Resdata3DKW` class is derived from the :code:`ResdataKW` class, but +the instance has a :code:`ResdataGrid` and optionally a default value associated to it. The purpose of this is to be able to use :code:`(i,j,k)` as index when looking up values. When :code:`(i,j,k)` -is used to identify the cell the, :code:`Ecl3DKW` class can +is used to identify the cell the, :code:`Resdata3DKW` class can transparently handle the active/inactive cells issue - returning a default value in the case of undefined inactive cells. -When the :code:`[]` argument is a single integer the :code:`Ecl3DKW` +When the :code:`[]` argument is a single integer the :code:`Resdata3DKW` class can not know whether the index supplied is an active or a global index, and it will be a simple index lookup - which properties are determined by the length of the underlying data. -The :code:`Ecl3DKW` class is mainly convenience compared to the pure -:code:`EclKW` class - for performance reasons it should probably not +The :code:`Resdata3DKW` class is mainly convenience compared to the pure +:code:`ResdataKW` class - for performance reasons it should probably not be used if you wish to run through all the cells. Using the grid object ..................... -The :code:`EclGrid` object has a long range of methods for extracting +The :code:`ResdataGrid` object has a long range of methods for extracting grid properties: 1. Many different methods for working with cell data like position, @@ -411,23 +411,23 @@ grid properties: 3. *Some* functionality for working with LGRs, coarse groups and fractured grid. - 4. Methods for exporting a :code:`EclKW` defined over + 4. Methods for exporting a :code:`ResdataKW` defined over :code:`nactive` elements to a :code:`grdecl` formatted file with :code:`nx*ny*nz` elements. -In addition the :code:`EclGrid` is used as an input for the -:code:`Ecl3DKW` properties and also for the :code:`EclRegion` -class. For further details please type :code:`pydoc ert.ecl.EclGrid` +In addition the :code:`ResdataGrid` is used as an input for the +:code:`Resdata3DKW` properties and also for the :code:`ResdataRegion` +class. For further details please type :code:`pydoc ert.ecl.ResdataGrid` or browse the API documentation at :ref:`python_documentation`. -EclInitFile and EclRestartFile - grid aware files +ResdataInitFile and ResdataRestartFile - grid aware files ------------------------------------------------- For restart and init files you can optionally choose to use -:code:`EclInitFile` and :code:`EclRestartFile` classes instead of the -basic :code:`EclFile` class. These two derived classes have a grid -attached, and will return a :code:`Ecl3DKW` instance instead of a -:code:`EclKW` instance for keywords with either :code:`nx*ny*nz` or +:code:`ResdataInitFile` and :code:`ResdataRestartFile` classes instead of the +basic :code:`ResdataFile` class. These two derived classes have a grid +attached, and will return a :code:`Resdata3DKW` instance instead of a +:code:`ResdataKW` instance for keywords with either :code:`nx*ny*nz` or :code:`nactive` elements. In the example below we have a list of :code:`(i,j,k)` triplets and we @@ -436,23 +436,23 @@ the :code:`(i,j,k) -> active_index` transformation: .. code:: python - from ert.ecl import EclGrid,EclInitFile + from ert.ecl import ResdataGrid,ResdataInitFile - grid = EclGrid( "CASE.EGRID" ) - init = EclInitFile( "CASE.INIT" ) + grid = ResdataGrid( "CASE.EGRID" ) + init = ResdataInitFile( "CASE.INIT" ) cell_list = [(1,2,3), (1,4,5), (2,2,7)] - # The permx_kw will now be a Ecl3DKW instance + # The permx_kw will now be a Resdata3DKW instance permx_kw = init["PERMX"][0] for ijk in cell_list: print("permx : %g" % permx_kw[ijk]) -Time queries in EclRestartFile +Time queries in ResdataRestartFile .............................. -The :code:`EclRestartFile` class has many methods for queries on the +The :code:`ResdataRestartFile` class has many methods for queries on the temporal content of a restart file [5]_. Classmethods @@ -460,10 +460,10 @@ Classmethods Several of the methods giving temporal information on restart files are *classmethods* - which means that an be invoked *without* creating -the :code:`EclRestartFile` instance first: +the :code:`ResdataRestartFile` instance first: -EclRestartFile.file_report_list +ResdataRestartFile.file_report_list ******************************* The classmethod :code:`file_report_list` will scan through a file and @@ -473,28 +473,28 @@ file. .. code:: python - from ert.ecl import EclRestartFile + from ert.ecl import ResdataRestartFile - report_list = EclRestartFile.file_report_list("ECLIPSE.UNRST") + report_list = ResdataRestartFile.file_report_list("ECLIPSE.UNRST") print("The file: %s contains the following report steps: ") print( ", ".join(report_list)) -EclRestartFile.contains_report_step +ResdataRestartFile.contains_report_step *********************************** The classmethod :code:`contains_report_step` will check if the file *filename* contains the report_step *report_step*: - if EclRestartFile.contains_report_step( "ECLIPSE.UNRST" , 100): + if ResdataRestartFile.contains_report_step( "ECLIPSE.UNRST" , 100): print("The file has a section for report step=100") else: print("No - the file does not have report_step = 100") -EclRestartFile.contains_sim_time +ResdataRestartFile.contains_sim_time ******************************** The classmethod :code:`contains_report_step` will check if the file @@ -503,24 +503,24 @@ be given as a normal Python :code:`datetime`: .. code:: python - from ert.ecl import EclRestartFile + from ert.ecl import ResdataRestartFile import datetime sim_time = datetime.datetime( 2010 , 6 , 15 ) - if EclRestartFile.contains_sim_time( "ECLIPSE.UNRST" , sim_time ): + if ResdataRestartFile.contains_sim_time( "ECLIPSE.UNRST" , sim_time ): print("The file has a section date: %s" % sim_time) else: print("No - the file does not have data at: %s" % sim_time) -EclRegion - a method to select cells +ResdataRegion - a method to select cells ------------------------------------ -The purpose of the :code:`EclRegion` class is to build up a set of set +The purpose of the :code:`ResdataRegion` class is to build up a set of set cells in a *region* [6]_ based on various selection criteria. That selection is then typically used to update a set of cells in a -:code:`EclKW` instance, either as a :code:`mask=region` parameter in +:code:`ResdataKW` instance, either as a :code:`mask=region` parameter in one of the arithmetic operators or by directly looping through the index set. @@ -536,19 +536,21 @@ apply is: .. code:: python - from ert.ecl import EclGrid, EclRegion, EclKW, EclTypeEnum + from ert.ecl import ResdataGrid, ResdataRegion, ResdataKW, ResdataTypeEnum + + grid = ResdataGrid( "CASE.EGRID" ) grid = EclGrid( "CASE.EGRID" ) with open("poro.grdecl") as f: - poro = EclKW.read_grdecl( f , "PORO") + poro = ResdataKW.read_grdecl( f , "PORO") with open("permx.grdecl") as f: - permx = EclKW.read_grdecl( f , "PERMX") + permx = ResdataKW.read_grdecl( f , "PERMX") # Create an initially empty region, and select all the cells where # PORO is below 0.01 - reg1 = EclRegion( grid , False ) + reg1 = ResdataRegion( grid , False ) reg1.select_less( poro , 0.01 ) @@ -556,20 +558,20 @@ apply is: # PORO is above 0.01. Then we select all the cells where PERMX is # above 200. Since the flag intersect is True this second selection # is only among the already selected cells. - reg2 = EclRegion( grid , False ) + reg2 = ResdataRegion( grid , False ) reg2.select_more( poro , 0.01 ) reg2.select_more( permx , 200 , intersect = True ) # Create a region where all cells are initially selected, # then subtract the regions reg1 and reg2. - reg3 = EclRegion( grid , True ) + reg3 = ResdataRegion( grid , True ) reg3 -= (reg1 + reg2) # Create a new satnum keyword and use the assign() method with a # mask parameter. - satnum = EclKW.create( "SATNUM" , grid.getGlobalSize() , EclTypeEnum.ECL_INT_TYPE) + satnum = ResdataKW.create( "SATNUM" , grid.getGlobalSize() , ResdataTypeEnum.RD_INT_TYPE) satnum.assign( 1, mask = reg1 ) satnum.assign( 2, mask = reg2 ) satnum.assign( 3, mask = reg3 ) @@ -578,7 +580,7 @@ apply is: satnum.write_grdecl( f ) -EclRegion - selectors +ResdataRegion - selectors ..................... A region can be constructed in many different ways: @@ -586,8 +588,8 @@ A region can be constructed in many different ways: 1. Based on slices of :code:`i,j,k` values. 2. Inside or outside a polygon; or alternatively "above" or "below" a line. - 3. Based on comparing a :code:`EclKW` instance with a scalar value. - 4. Based on comparing two :code:`EclKW` instances. + 3. Based on comparing a :code:`ResdataKW` instance with a scalar value. + 4. Based on comparing two :code:`ResdataKW` instances. 5. Based on cell geometry - i.e. size, depth or thickness. Observe the following: @@ -601,10 +603,10 @@ Observe the following: cells. -EclRegion - special methods +ResdataRegion - special methods ........................... -The :code:`EclRegion` class implements the special methods required to +The :code:`ResdataRegion` class implements the special methods required to view the regions as set; i.e. you can add and subtract regions and form the union and intersection of regions. @@ -628,41 +630,41 @@ form the union and intersection of regions. reg3 = reg1 & reg2 For further details, specially of the various select methods, please -type :code:`pydoc ert.ecl.EclRegion` or browse the API documentation +type :code:`pydoc ert.ecl.ResdataRegion` or browse the API documentation at :ref:`python_documentation`. RFT --- The support for RFT files in :code:`ert.ecl` is split among the three -classes :code:`EclRFTFile`, :code:`EclRFT` and :code:`EclRFTCell`. The -:code:`EclRFTFile` class is used to load an ECLIPSE RFT file. The RFT +classes :code:`ResdataRFTFile`, :code:`ResdataRFT` and :code:`ResdataRFTCell`. The +:code:`ResdataRFTFile` class is used to load an ECLIPSE RFT file. The RFT files will generally contain results for several wells, and several -times, the :code:`EclRFTFile` class will load them all - and then +times, the :code:`ResdataRFTFile` class will load them all - and then supplies an interface to query for individual RFT results based on wellname and/or date; the individual RFT results will be in the form -of :code:`EclRFT` instances. +of :code:`ResdataRFT` instances. .. code:: python - from ert.ecl import EclRFTFile + from ert.ecl import ResdataRFTFile # Load the RFT file - rft_file = EclRFTFile("ECLIPSE.RFT") + rft_file = ResdataRFTFile("ECLIPSE.RFT") # Extract the RFT results for well 'OP-X' at date 2010-01-15; # will return None if no such RFT exists - should probably raise an # exception. rft = rft_file.get("OP-X" , datetime.date(2010,1,15)) -In addition to the main method: :code:`EclRFTFile.get()` the -:code:`EclRFTFile` class has utility methods to list all the well and +In addition to the main method: :code:`ResdataRFTFile.get()` the +:code:`ResdataRFTFile` class has utility methods to list all the well and date values present in the RFT file, the number of wells and so on. -EclRFT +ResdataRFT ...... -From the :code:`EclRFTFile.get()` method we get a :code:`EclRFT` +From the :code:`ResdataRFTFile.get()` method we get a :code:`ResdataRFT` instance. Observe that one RFT file can contain a lump of different data RFT types: @@ -674,19 +676,19 @@ data RFT types: SEGMENT: Not implemented. -The :code:`EclRFT` object has some metadata describing which type +The :code:`ResdataRFT` object has some metadata describing which type of data it represents, and there is some special functionality related -to MSW wells; but the main purpose of the :code:`EclRFT` class is to -serve as container holding a list of :code:`EclRFTCell` instances - -one for each perforated cell in the RFT. The :code:`EclRFT` class has +to MSW wells; but the main purpose of the :code:`ResdataRFT` class is to +serve as container holding a list of :code:`ResdataRFTCell` instances - +one for each perforated cell in the RFT. The :code:`ResdataRFT` class has implemented the :code:`__getitem__()` method, so the following code will loop identify an RFT from a file and then loop through all the cells for that RFT. .. code:: python - from ert.ecl import EclRFTFile - rft_file = EclRFTFile("ECLIPSE.RFT") + from resdata.rft import ResdataRFTFile + rft_file = ResdataRFTFile("ECLIPSE.RFT") rft = rft_file.get("OP-X" , datetime.date(2010,1,15)) for cell in rft: @@ -694,53 +696,53 @@ cells for that RFT. cell.get_i() , cell.get_j() , cell.get_k() , cell.depth , cell.pressure)) Depending on whether this is RFT or a PLT the exact type of the cell -object will be either :code:`EclRFTCell` or :code:`EclPLTCell`, the -:code:`EclPLTCell` has many extra properties not in the -:code:`EclRFTCell` class. For more detail use :code:`pydoc` to look at -the classes :code:`ert.ecl.EclRFTFile`, :code:`ert.ecl.EclRFT`, -:code:`ert.EclRFTCell` or :code:`ert.ecl.EclPLTCell` - or the API +object will be either :code:`ResdataRFTCell` or :code:`ResdataPLTCell`, the +:code:`ResdataPLTCell` has many extra properties not in the +:code:`ResdataRFTCell` class. For more detail use :code:`pydoc` to look at +the classes :code:`ert.ecl.ResdataRFTFile`, :code:`ert.ecl.ResdataRFT`, +:code:`ert.ResdataRFTCell` or :code:`ert.ecl.ResdataPLTCell` - or the API documentation at :ref:`python_documentation`. -EclSum - working with summary files +RdSum - working with summary files ----------------------------------- -Summary files are loaded with the :code:`EclSum` class. The -:code:`EclSum` class is a quite complete implementation for working +Summary files are loaded with the :code:`RdSum` class. The +:code:`RdSum` class is a quite complete implementation for working with Eclipse summary data, but it should also be said the -:code:`EclSum` class is one of the oldest classes in the +:code:`RdSum` class is one of the oldest classes in the :code:`ert.ecl` package and the api could have been cleaner. -Creating a :code:`EclSum` instance +Creating a :code:`RdSum` instance .................................. In more than 99% of the cases the assumption is that we want to create -a :code:`EclSum` instance by loading read-only summary results from -disk, however it is also possible to assemble a :code:`EclSum` +a :code:`RdSum` instance by loading read-only summary results from +disk, however it is also possible to assemble a :code:`RdSum` instance using the api - that is not covered in this documentation. The summary results from ECLIPSE come in two different types of files; the :code:`ECLIPSE.SMSEPEC` file is a *header file* with all the properties of the variables, and the :code:`ECLIPSE.UNSMRY` (or alternatively :code:`ECLIPSE.S0000, ECLIPSE.S0001, ECLIPSE.S0002, -...`) file contains the actual values. Creating a :code:`EclSum` +...`) file contains the actual values. Creating a :code:`RdSum` instance from this is as simple as: .. code:: python - from ert.ecl import EclSum + from ert.ecl import RdSum - ecl_sum = EclSum("ECLIPSE") + rd_sum = RdSum("ECLIPSE") -As is clear from the example the :code:`EclSum` instance is created +As is clear from the example the :code:`RdSum` instance is created based only on the basename of the simulation, you can optionally have -an extension like :code:`ecl_sum = EclSum("ECLIPSE.UNSMRY")` - but +an extension like :code:`rd_sum = RdSum("ECLIPSE.UNSMRY")` - but that is *mostly* [7]_ ignored. -If your case is restarted from an another case the :code:`EclSum` +If your case is restarted from an another case the :code:`RdSum` cconstructor will by default try to locate the historical case, and load the summary results from that as well. Alternatively you can pass -the argument :code:`include_restart = False` to the :code:`EclSum` +the argument :code:`include_restart = False` to the :code:`RdSum` constructor. The loading of historical case will fail with an error message if: @@ -757,7 +759,7 @@ About summary keys The header file :code:`CASE.SMSPEC` has all the information *about* the summary data. The :code:`CASE.SMSPEC` file consists of several -:code:`EclKW` instances, where the three most important one are: +:code:`ResdataKW` instances, where the three most important one are: :code:`KEYWORDS` which contains the variable names like :code:`FOPT`, :code:`WGOR` and :code:`BPR`, the :code:`WGNAMES` vector which contains names of groups and wells, and :code:`NUMS` which @@ -833,7 +835,7 @@ the value of the PARAMS keyword at index 2. By default the SUMMARY data will be created and stored for every timestep of the simulator, i.e. the raw time resolution is directly given by the simulators performance, in ECLIPSE parlance these are called ministeps. When the -:code:`EclSum` class loads a summary all the ECLIPSE ministeps are +:code:`RdSum` class loads a summary all the ECLIPSE ministeps are stacked together in one long vector, observe that e.g. when the keyword RPTONLY is used in the ECLIPSE data file there can be "holes" in the ministep sequence. @@ -896,8 +898,8 @@ summary or not: .. code:: python import sys - from ert.ecl import EclSum - sum = ecl.EclSum("ECLIPSE") + from ert.ecl import RdSum + sum = RdSum("ECLIPSE") for key in sys.argv[1:] if key in sum: @@ -918,8 +920,8 @@ variables for the group "NORTH" we can use the :code:`keys()` function as: .. code:: python - from ert.ecl import EclSum - sum = ecl.EclSum("ECLIPSE") + from ert.ecl import RdSum + sum = ecl.RdSum("ECLIPSE") matching = sum.keys( "BPR:*" ) + sum.keys( "G*H:NORTH" ) @@ -980,7 +982,7 @@ supplied. The date parameter is a normal python import datetime import ert.ecl.ecl as ecl - sum = ecl.EclSum( case ) + sum = ecl.RdSum( case ) print "FWCT after 1000 days: %g" % sum.get_interp( "FWCT" , days = 1000 ) print "Total oil production at 10.10.2010: %g" % sum.get_interp( "FOPT" , date = datetime.date( 2010 , 10 , 10) ) @@ -1008,7 +1010,7 @@ every 6 months: import datetime import ert.ecl.ecl as ecl - sum = EclSum( "ECLIPSE" ) + sum = RdSum( "ECLIPSE" ) # Building up the list of dates: date = sum.start_date @@ -1035,20 +1037,20 @@ Methods to get a vector of the complete time series get_vector( key , report_only = False) ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -The get_vector function will return a EclSumVector instance +The get_vector function will return a RdSumVector instance corresponding to key. The __getitem__ function is also implemented in terms of the get_vector function, i.e. the same behaviour can be achieved with the [] operator: import ert.ecl as ecl .. code:: python - sum = ecl.EclSum( "/path/simuluation/BASE" ) + sum = ecl.RdSum( "/path/simuluation/BASE" ) wwct = ecl.get_vector("WWCT:C-1") wopr = ecl["WOPR:C-1"] If the summary variable key does not exist in the case the exception -KeyError will be raised. By default EclSumVector will have full +KeyError will be raised. By default RdSumVector will have full temporal resolution; but if the optional argument report_only is set to True the vector will only contain data from the report times. This option is not available when the [] operator is used. Properties @@ -1086,7 +1088,7 @@ These two functions will return the index of the first "time" where the summary vector corresponding to key goes above (first_gt()) or falls below a limit (first_lt). If the limit is not reached the function will return -1; if the -1 is used as index in a subsequent -call to an EclSum method, it will fail hard. +call to an RdSum method, it will fail hard. .. code:: python @@ -1120,9 +1122,9 @@ example below we fetch two vectors, and the simulation days from a summary, and then print it all to the screen: .. code:: python - from ert.ecl import EclSum + from ert.ecl import RdSum - sum = EclSum( "/path/ECLIPSE.DATA" ) + sum = RdSum( "/path/ECLIPSE.DATA" ) days = sum.days wwct = sum.numpy_value("WWCT:OP_1") wopr = sum.numpy_value("WOPR:OP_1") @@ -1134,57 +1136,57 @@ summary, and then print it all to the screen: Special functions/operators [] : get The [] operator is mapped to the get_vector() method and will -return the EclSumVector corresponding to the key entered, i.e. the -EclSum instance will behave much like a dictionary. I.e. to get a -EclSumVector corresponding to field oil production rate you can do: -sum = ecl.EclSum( "ECLIPSE" ) fopr = sum["FOPR"] If you give a key +return the RdSumVector corresponding to the key entered, i.e. the +RdSum instance will behave much like a dictionary. I.e. to get a +RdSumVector corresponding to field oil production rate you can do: +sum = ecl.RdSum( "ECLIPSE" ) fopr = sum["FOPR"] If you give a key which does not exist in the summary the KeyError exception will be raised. -EclSumVector +RdSumVector ............ -The EclSumVector class is a small convenience class to work with only -one summary vector. It is not necessary to use the EclSumVector -class - everything can be accessed directly from the EclSum -class. Many of the methods and properties of the EclSumVector are very -similar or actually identical to methods in the EclSum class: +The RdSumVector class is a small convenience class to work with only +one summary vector. It is not necessary to use the RdSumVector +class - everything can be accessed directly from the RdSum +class. Many of the methods and properties of the RdSumVector are very +similar or actually identical to methods in the RdSum class: The methods/properties which access the timeseries are the same. Many -of the methods which take key input argument in the EclSum case -obviously take no key argument in the case of EclSumVector; if there +of the methods which take key input argument in the RdSum case +obviously take no key argument in the case of RdSumVector; if there are no arguments left these methods will typically be converted to read-only properties. Constructor -EclSumVector( parent , key , report_only ) The default constructor -EclSumVector() will create a new EclSumVector instance, but the -intentition is that the EclSumVector instances should be constructed -via the EclSum parent instance, and not explicitly by the user. +RdSumVector( parent , key , report_only ) The default constructor +RdSumVector() will create a new RdSumVector instance, but the +intentition is that the RdSumVector instances should be constructed +via the RdSum parent instance, and not explicitly by the user. Methods -The EclSumVector class has all the same methods as the EclSum class; +The RdSumVector class has all the same methods as the RdSum class; with the obvious exceptions of has_key() and keys(). The key argument -present in the methods ... is removed in the EclSumVector incarnation. +present in the methods ... is removed in the RdSumVector incarnation. Properties Special functions/operators [] : get -The EclSumVector implements the __getitem__() method to support +The RdSumVector implements the __getitem__() method to support iteration and the [] operator. The __getitem__ method supports negative indices and partly slicing. When slicing the returned value -will not be reduced EclSumVector instance, but rather a plain Python +will not be reduced RdSumVector instance, but rather a plain Python list with the correct set of elements. The elements returned from the -__getitem__ method are EclSumNode instances. +__getitem__ method are RdSumNode instances. .. code:: python - from ert.ecl import EclSum + from ert.ecl import RdSum - eclsum = EclSum( "ECLIPSE" ) + eclsum = RdSum( "ECLIPSE" ) wwct = eclsum["WWCT:OP-5"] print "First value element: " wwct[0].value @@ -1192,13 +1194,13 @@ __getitem__ method are EclSumNode instances. print "List of every third: " wwct[0::3] -EclSumNode +RdSumNode .......... -The EclSumNode class is very small, more like a C struct. It contains +The RdSumNode class is very small, more like a C struct. It contains 11the value, along with time in different units for one summary vector -at one point in time; the content of the EclSumNode is plain field -variables; no properties or anything fancy. The EclSumNode has the +at one point in time; the content of the RdSumNode is plain field +variables; no properties or anything fancy. The RdSumNode has the following fields: value : The actual value @@ -1208,15 +1210,15 @@ following fields: date : The simulation date mpl_date : A date format suitable for matplotlib -When iterating over a EclSumVector the return values will be in the -form EclSumNode instances. The EclSumNode instances are created on -demand by a EclSumVector instance. The example below show how the -EclSumNode instances arise when iterating over the content of a -EclSumVector: +When iterating over a RdSumVector the return values will be in the +form RdSumNode instances. The RdSumNode instances are created on +demand by a RdSumVector instance. The example below show how the +RdSumNode instances arise when iterating over the content of a +RdSumVector: .. code:: python - wwct = ecl_sum["WWCT:C-1A"] + wwct = rd_sum["WWCT:C-1A"] for node in wwct: print "Days:%g value:%g" % (node.days , node.value) @@ -1243,8 +1245,8 @@ EclSumVector: by Eclipse to denote active/inactive status. .. [5] The methods are currently implemented in the base class - :code:`EclFile` - but they should be moved to the - :code:`EclRestartFile` class. + :code:`ResdataFile` - but they should be moved to the + :code:`ResdataRestartFile` class. .. [6] Observe that the set of cells need *not* form a singly connected set. @@ -1252,9 +1254,9 @@ EclSumVector: .. [7] Since the summary files can be both formatted and unformatted, and also both unified and non-unified there can potentially be several datasets with the same basename present in the - directory. The :code:`EclSum` loader will by default use the + directory. The :code:`RdSum` loader will by default use the latest version, but by supplying an extension you can control which files should be loaded; i.e. when calling as - :code:`EclSum("ECLIPSE.A0056")` the loader will *only* look for + :code:`RdSum("ECLIPSE.A0056")` the loader will *only* look for multiple formatted files. diff --git a/python/docs/conf.py.in b/python/docs/conf.py.in index c6116f8b63..ddcf5f8c01 100644 --- a/python/docs/conf.py.in +++ b/python/docs/conf.py.in @@ -55,9 +55,9 @@ copyright = u'2014, Equinor ASA' # built documents. # # The short X.Y version. -version = '${LIBECL_VERSION_MAJOR}.${LIBECL_VERSION_MINOR}' +version = '${LIBRD_VERSION_MAJOR}.${LIBRD_VERSION_MINOR}' # The full version, including alpha/beta/rc tags. -release = '${LIBECL_VERSION_MAJOR}.${LIBECL_VERSION_MINOR}.${LIBECL_VERSION_MICRO}' +release = '${LIBRD_VERSION_MAJOR}.${LIBRD_VERSION_MINOR}.${LIBRD_VERSION_MICRO}' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/python/docs/examples/avg_pressure.py b/python/docs/examples/avg_pressure.py index 1e45c1248e..649f7814c8 100755 --- a/python/docs/examples/avg_pressure.py +++ b/python/docs/examples/avg_pressure.py @@ -3,8 +3,8 @@ import matplotlib.pyplot as plt # Import the required symbols from the ecl.ecl package. -from ecl.eclfile import EclFile, EclRestartFile -from ecl.grid import EclGrid, EclRegion +from resdata.eclfile import ResdataFile, ResdataRestartFile +from resdata.grid import ResdataGrid, ResdataRegion # Calculate the average pressure for all the cells in the region using @@ -46,9 +46,9 @@ def avg_pressure(p, sw, pv, region, region_id, result): if __name__ == "__main__": case = sys.argv[1] - grid = EclGrid("%s.EGRID" % case) - rst_file = EclRestartFile(grid, "%s.UNRST" % case) - init_file = EclFile("%s.INIT" % case) + grid = ResdataGrid("%s.EGRID" % case) + rst_file = ResdataRestartFile(grid, "%s.UNRST" % case) + init_file = ResdataFile("%s.INIT" % case) # Create PORV keyword where all the inactive cells have been removed. pv = grid.compressed_kw_copy(init_file["PORV"][0]) @@ -65,11 +65,11 @@ def avg_pressure(p, sw, pv, region, region_id, result): sw = rst_block["SWAT"][0] for region_id in range(region_kw.get_max() + 1): - region = EclRegion(grid, False) + region = ResdataRegion(grid, False) region.select_equal(region_kw, region_id) avg_pressure(p, sw, pv, region, region_id, result) - avg_pressure(p, sw, pv, EclRegion(grid, True), "field", result) + avg_pressure(p, sw, pv, ResdataRegion(grid, True), "field", result) sim_days.append(header.get_sim_days()) for key in result.keys(): diff --git a/python/docs/examples/cmp_nnc.py b/python/docs/examples/cmp_nnc.py index 098c553baa..6108fa9f81 100755 --- a/python/docs/examples/cmp_nnc.py +++ b/python/docs/examples/cmp_nnc.py @@ -1,15 +1,15 @@ #!/usr/bin/env python import sys from operator import itemgetter -from ecl.eclfile import EclFile -from ecl.grid import EclGrid +from resdata.eclfile import ResdataFile +from resdata.grid import ResdataGrid if __name__ == "__main__": case = sys.argv[1] - grid_file = EclFile(f"{case}.EGRID") - init_file = EclFile(f"{case}.INIT") - grid = EclGrid(f"{case}.EGRID") + grid_file = ResdataFile(f"{case}.EGRID") + init_file = ResdataFile(f"{case}.INIT") + grid = ResdataGrid(f"{case}.EGRID") nnc1 = grid_file["NNC1"][0] nnc2 = grid_file["NNC2"][0] diff --git a/python/docs/examples/grid_info.py b/python/docs/examples/grid_info.py index b569b18255..86fc0c6689 100755 --- a/python/docs/examples/grid_info.py +++ b/python/docs/examples/grid_info.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import sys -from ecl.grid import EclRegion, EclGrid +from resdata.grid import ResdataRegion, ResdataGrid def volume_min_max(grid): @@ -12,7 +12,7 @@ def main(grid): vmin, vmax = volume_min_max(grid) dz_limit = 0.3 - region = EclRegion(grid, False) + region = ResdataRegion(grid, False) region.select_thin(dz_limit) print(f"Smallest cell : {vmin}") @@ -28,5 +28,5 @@ def main(grid): if len(sys.argv) < 2: exit("usage: grid_info.py path/to/file.EGRID") case = sys.argv[1] - grid = EclGrid(case) + grid = ResdataGrid(case) main(grid) diff --git a/python/resdata/CMakeLists.txt b/python/resdata/CMakeLists.txt index 2b7cb92fb4..3bc32edea7 100644 --- a/python/resdata/CMakeLists.txt +++ b/python/resdata/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PYTHON_SOURCES __init__.py ecl_type.py ecl_util.py) +set(PYTHON_SOURCES __init__.py rd_type.py rd_util.py) add_python_package("python.ecl" ${PYTHON_INSTALL_PREFIX}/ecl "${PYTHON_SOURCES}" True) @@ -12,7 +12,7 @@ add_subdirectory(well) configure_file( resdata_info_build.py.in - ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl/__resdata_info.py) + ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/resdata/__resdata_info.py) configure_file( resdata_info_install.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/resdata_info_install.py) diff --git a/python/resdata/__init__.py b/python/resdata/__init__.py index 4b8336ff79..1d4d4bad49 100644 --- a/python/resdata/__init__.py +++ b/python/resdata/__init__.py @@ -52,10 +52,10 @@ from cwrap import Prototype -ECL_LEGACY_INSTALLED = not os.path.isdir( +RD_LEGACY_INSTALLED = not os.path.isdir( os.path.join(os.path.dirname(__file__), ".libs") ) -if not ECL_LEGACY_INSTALLED: +if not RD_LEGACY_INSTALLED: from .version import version as __version__ def get_include(): @@ -101,13 +101,15 @@ def set_abort_handler(function): global _abort_handler _abort_handler = function - EclPrototype.lib.util_set_abort_handler(_c_abort_handler) + ResdataPrototype.lib.util_set_abort_handler(_c_abort_handler) - class EclPrototype(Prototype): + class ResdataPrototype(Prototype): lib = dlopen_resdata() def __init__(self, prototype, bind=True): - super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind) + super(ResdataPrototype, self).__init__( + ResdataPrototype.lib, prototype, bind=bind + ) else: # @@ -177,27 +179,29 @@ def load(name): own_dir = os.path.dirname(os.path.abspath(__file__)) return cwrapload(name, path=own_dir, so_version=ert_so_version) - class EclPrototype(Prototype): + class ResdataPrototype(Prototype): lib = load("resdata") def __init__(self, prototype, bind=True): - super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind) + super(ResdataPrototype, self).__init__( + ResdataPrototype.lib, prototype, bind=bind + ) # # Common # -from .ecl_type import EclTypeEnum, EclDataType -from .ecl_util import ( - EclFileEnum, - EclFileFlagEnum, - EclPhaseEnum, - EclUnitTypeEnum, - EclUtil, +from .rd_type import ResdataTypeEnum, ResdataDataType +from .rd_util import ( + ResdataFileEnum, + ResdataFileFlagEnum, + ResdataPhaseEnum, + ResdataUnitTypeEnum, + ResdataUtil, ) -from .util.util import EclVersion +from .util.util import ResdataVersion from .util.util import updateAbortSignals diff --git a/python/resdata/gravimetry/CMakeLists.txt b/python/resdata/gravimetry/CMakeLists.txt index 31cbfa2f16..da5dbba9ca 100644 --- a/python/resdata/gravimetry/CMakeLists.txt +++ b/python/resdata/gravimetry/CMakeLists.txt @@ -1,5 +1,5 @@ -set(PYTHON_SOURCES __init__.py ecl_grav.py ecl_grav_calc.py ecl_subsidence.py) +set(PYTHON_SOURCES __init__.py rd_grav.py rd_grav_calc.py rd_subsidence.py) add_python_package( - "python.ecl.gravimetry" ${PYTHON_INSTALL_PREFIX}/ecl/gravimetry + "python.ecl.gravimetry" ${PYTHON_INSTALL_PREFIX}/resdata/gravimetry "${PYTHON_SOURCES}" True) diff --git a/python/resdata/gravimetry/__init__.py b/python/resdata/gravimetry/__init__.py index fbacda4c20..a81be28263 100644 --- a/python/resdata/gravimetry/__init__.py +++ b/python/resdata/gravimetry/__init__.py @@ -1,12 +1,12 @@ """ - ecl_grav/EclGrav: Class used to simplify evaluation of ECLIPSE + rd_grav/ResdataGrav: Class used to simplify evaluation of ECLIPSE modelling time-lapse gravitational surveys. - ecl_subsidence/EclSubsidence: Small class used to evaluate simulated + rd_subsidence/ResdataSubsidence: Small class used to evaluate simulated subsidence from ECLIPSE simulations; analogous to the EcLGrav functionality. """ -from .ecl_subsidence import EclSubsidence -from .ecl_grav_calc import phase_deltag, deltag -from .ecl_grav import EclGrav +from .rd_subsidence import ResdataSubsidence +from .rd_grav_calc import phase_deltag, deltag +from .rd_grav import ResdataGrav diff --git a/python/resdata/gravimetry/rd_grav.py b/python/resdata/gravimetry/rd_grav.py index 55f4f19dce..967b965336 100644 --- a/python/resdata/gravimetry/rd_grav.py +++ b/python/resdata/gravimetry/rd_grav.py @@ -1,72 +1,70 @@ """ Calculate dynamic change in gravitational strength. -The ecl_grav module contains functionality to load time-lapse ECLIPSE +The rd_grav module contains functionality to load time-lapse ECLIPSE results and calculate the change in gravitational strength between the different surveys. The implementation is a thin wrapper around the -ecl_grav.c implementation in the resdata library. +rd_grav.c implementation in the resdata library. """ +import resdata.resfile from cwrap import BaseCClass +from resdata import ResdataPhaseEnum, ResdataPrototype +from resdata.util.util import monkey_the_camel -from ecl import EclPrototype -from ecl.util.util import monkey_the_camel -from ecl import EclPhaseEnum -import ecl.eclfile - -class EclGrav(BaseCClass): +class ResdataGrav(BaseCClass): """ Holding ECLIPSE results for calculating gravity changes. - The EclGrav class is a collection class holding the results from + The ResdataGrav class is a collection class holding the results from ECLIPSE forward modelling of gravity surveys. Observe that the class is focused on the ECLIPSE side of things, and does not have any notion of observed values or measurement locations; that - should be handled by the scope using the EclGrav class. + should be handled by the scope using the ResdataGrav class. - Typical use of the EclGrav class involves the following steps: + Typical use of the ResdataGrav class involves the following steps: - 1. Create the EclGrav instance. + 1. Create the ResdataGrav instance. 2. Add surveys with the add_survey_XXXX() methods. 3. Evalute the gravitational response with the eval() method. """ - TYPE_NAME = "ecl_grav" - _grav_alloc = EclPrototype("void* ecl_grav_alloc(ecl_grid, ecl_file)", bind=False) - _free = EclPrototype("void ecl_grav_free(ecl_grav)") - _add_survey_RPORV = EclPrototype( - "void* ecl_grav_add_survey_RPORV(ecl_grav, char*, ecl_file_view)" + TYPE_NAME = "rd_grav" + _grav_alloc = ResdataPrototype("void* rd_grav_alloc(rd_grid, rd_file)", bind=False) + _free = ResdataPrototype("void rd_grav_free(rd_grav)") + _add_survey_RPORV = ResdataPrototype( + "void* rd_grav_add_survey_RPORV(rd_grav, char*, rd_file_view)" ) - _add_survey_PORMOD = EclPrototype( - "void* ecl_grav_add_survey_PORMOD(ecl_grav, char*, ecl_file_view)" + _add_survey_PORMOD = ResdataPrototype( + "void* rd_grav_add_survey_PORMOD(rd_grav, char*, rd_file_view)" ) - _add_survey_FIP = EclPrototype( - "void* ecl_grav_add_survey_FIP(ecl_grav, char*, ecl_file_view)" + _add_survey_FIP = ResdataPrototype( + "void* rd_grav_add_survey_FIP(rd_grav, char*, rd_file_view)" ) - _add_survey_RFIP = EclPrototype( - "void* ecl_grav_add_survey_RFIP(ecl_grav, char*, ecl_file_view)" + _add_survey_RFIP = ResdataPrototype( + "void* rd_grav_add_survey_RFIP(rd_grav, char*, rd_file_view)" ) - _new_std_density = EclPrototype( - "void ecl_grav_new_std_density(ecl_grav, int, double)" + _new_std_density = ResdataPrototype( + "void rd_grav_new_std_density(rd_grav, int, double)" ) - _add_std_density = EclPrototype( - "void ecl_grav_add_std_density(ecl_grav, int, int, double)" + _add_std_density = ResdataPrototype( + "void rd_grav_add_std_density(rd_grav, int, int, double)" ) - _eval = EclPrototype( - "double ecl_grav_eval(ecl_grav, char*, char*, ecl_region, double, double, double, int)" + _eval = ResdataPrototype( + "double rd_grav_eval(rd_grav, char*, char*, rd_region, double, double, double, int)" ) def __init__(self, grid, init_file): """ - Creates a new EclGrav instance. + Creates a new ResdataGrav instance. The input arguments @grid and @init_file should be instances - of EclGrid and EclFile respectively. + of ResdataGrid and ResdataFile respectively. """ self.init_file = init_file # Inhibit premature garbage collection of init_file c_ptr = self._grav_alloc(grid, init_file) - super(EclGrav, self).__init__(c_ptr) + super(ResdataGrav, self).__init__(c_ptr) self.dispatch = { "FIP": self.add_survey_FIP, @@ -83,15 +81,15 @@ def add_survey_RPORV(self, survey_name, restart_view): reservoir, i.e. an ECLIPSE restart file. The @survey_name input argument will be used when refering to this survey at a later stage. The @restart_view input argument should be an - EclFile instance with data from one report step. A typical way + ResdataFile instance with data from one report step. A typical way to load the @restart_view argument is: import datetime - from ecl.ecl import EclRestartFile + from resdata.ecl import ResdataRestartFile ... ... date = datetime.datetime(year, month, day) - rst_file = EclRestartFile("ECLIPSE.UNRST") + rst_file = ResdataRestartFile("ECLIPSE.UNRST") restart_view1 = rst_file.restartView(sim_time=date) restart_view2 = rst_file.restartView(report_step=67) @@ -148,9 +146,9 @@ def eval( monitor_survey, pos, region=None, - phase_mask=EclPhaseEnum.ECL_OIL_PHASE - + EclPhaseEnum.ECL_GAS_PHASE - + EclPhaseEnum.ECL_WATER_PHASE, + phase_mask=ResdataPhaseEnum.RD_OIL_PHASE + + ResdataPhaseEnum.RD_GAS_PHASE + + ResdataPhaseEnum.RD_WATER_PHASE, ): """ Calculates the gravity change between two surveys. @@ -170,13 +168,13 @@ def eval( change in gravitational strength. If supplied the optional argument @region should be an - EclRegion() instance; this region will be used to limit the + ResdataRegion() instance; this region will be used to limit the part of the reserviour included in the gravity calculations. The optional argument @phase_mask is an integer flag to indicate which phases you are interested in. It should be a - sum of the relevant integer constants 'ECL_OIL_PHASE', - 'ECL_GAS_PHASE' and 'ECL_WATER_PHASE'. + sum of the relevant integer constants 'RD_OIL_PHASE', + 'RD_GAS_PHASE' and 'RD_WATER_PHASE'. """ return self._eval( base_survey, monitor_survey, region, pos[0], pos[1], pos[2], phase_mask @@ -186,9 +184,9 @@ def new_std_density(self, phase_enum, default_density): """ Adds a new phase with a corresponding density. - @phase_enum is one of the integer constants ECL_OIL_PHASE, - ECL_GAS_PHASE or ECL_WATER_PHASE, all available in the - ecl_util and also ecl modules. + @phase_enum is one of the integer constants RD_OIL_PHASE, + RD_GAS_PHASE or RD_WATER_PHASE, all available in the + rd_util and also ecl modules. @default_density is the density, at standard conditions, for this particular phase. By default @default_density will be @@ -226,4 +224,4 @@ def free(self): self._free() -monkey_the_camel(EclGrav, "addSurvey", EclGrav.add_survey) +monkey_the_camel(ResdataGrav, "addSurvey", ResdataGrav.add_survey) diff --git a/python/resdata/gravimetry/rd_grav_calc.py b/python/resdata/gravimetry/rd_grav_calc.py index 418a9e2c4c..5ec66c75c8 100644 --- a/python/resdata/gravimetry/rd_grav_calc.py +++ b/python/resdata/gravimetry/rd_grav_calc.py @@ -1,9 +1,9 @@ -from ecl import EclPrototype +from resdata import ResdataPrototype __arglist = "double, double, double, " -__arglist += "ecl_grid, ecl_file, " -__arglist += "ecl_kw, ecl_kw, ecl_kw, ecl_kw, ecl_kw, ecl_kw" -_phase_deltag = EclPrototype("double ecl_grav_phase_deltag(%s)" % __arglist) +__arglist += "rd_grid, rd_file, " +__arglist += "rd_kw, rd_kw, rd_kw, rd_kw, rd_kw, rd_kw" +_phase_deltag = ResdataPrototype("double rd_grav_phase_deltag(%s)" % __arglist) def phase_deltag(xyz, grid, init, sat1, rho1, porv1, sat2, rho2, porv2): diff --git a/python/resdata/gravimetry/rd_subsidence.py b/python/resdata/gravimetry/rd_subsidence.py index a93d26511b..956ce6645a 100644 --- a/python/resdata/gravimetry/rd_subsidence.py +++ b/python/resdata/gravimetry/rd_subsidence.py @@ -1,65 +1,65 @@ """ Calculate dynamic change in gravitational strength. -The ecl_subsidence module contains functionality to load time-lapse ECLIPSE +The rd_subsidence module contains functionality to load time-lapse ECLIPSE results and calculate the change in seafloor subsidence between the different surveys. The implementation is a thin wrapper around the -ecl_subsidence.c implementation in the resdata library. +rd_subsidence.c implementation in the resdata library. """ from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.util.util import monkey_the_camel -import ecl.grid +from resdata import ResdataPrototype +from resdata.util.util import monkey_the_camel +import resdata.grid -class EclSubsidence(BaseCClass): +class ResdataSubsidence(BaseCClass): """ Holding ECLIPSE results for calculating subsidence changes. - The EclSubsidence class is a collection class holding the results from + The ResdataSubsidence class is a collection class holding the results from ECLIPSE forward modelling of subsidence surveys. Observe that the class is focused on the ECLIPSE side of things, and does not have any notion of observed values or measurement locations; that - should be handled by the scope using the EclSubsidence class. + should be handled by the scope using the ResdataSubsidence class. - Typical use of the EclSubsidence class involves the following steps: + Typical use of the ResdataSubsidence class involves the following steps: - 1. Create the EclSubsidence instance. + 1. Create the ResdataSubsidence instance. 2. Add surveys with the add_survey_XXXX() methods. 3. Evalute the subsidence response with the eval() method. """ - TYPE_NAME = "ecl_subsidence" - _alloc = EclPrototype( - "void* ecl_subsidence_alloc( ecl_grid , ecl_file )", bind=False + TYPE_NAME = "rd_subsidence" + _alloc = ResdataPrototype( + "void* rd_subsidence_alloc( rd_grid , rd_file )", bind=False ) - _free = EclPrototype("void ecl_subsidence_free( ecl_subsidence )") - _add_survey_PRESSURE = EclPrototype( - "void* ecl_subsidence_add_survey_PRESSURE( ecl_subsidence , char* , ecl_file_view )" + _free = ResdataPrototype("void rd_subsidence_free( rd_subsidence )") + _add_survey_PRESSURE = ResdataPrototype( + "void* rd_subsidence_add_survey_PRESSURE( rd_subsidence , char* , rd_file_view )" ) - _eval = EclPrototype( - "double ecl_subsidence_eval( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double)" + _eval = ResdataPrototype( + "double rd_subsidence_eval( rd_subsidence , char* , char* , rd_region , double , double , double, double, double)" ) - _eval_geertsma = EclPrototype( - "double ecl_subsidence_eval_geertsma( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double, double)" + _eval_geertsma = ResdataPrototype( + "double rd_subsidence_eval_geertsma( rd_subsidence , char* , char* , rd_region , double , double , double, double, double, double)" ) - _eval_geertsma_rporv = EclPrototype( - "double ecl_subsidence_eval_geertsma_rporv( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double, double)" + _eval_geertsma_rporv = ResdataPrototype( + "double rd_subsidence_eval_geertsma_rporv( rd_subsidence , char* , char* , rd_region , double , double , double, double, double, double)" ) - _has_survey = EclPrototype( - "bool ecl_subsidence_has_survey( ecl_subsidence , char*)" + _has_survey = ResdataPrototype( + "bool rd_subsidence_has_survey( rd_subsidence , char*)" ) def __init__(self, grid, init_file): """ - Creates a new EclSubsidence instance. + Creates a new ResdataSubsidence instance. The input arguments @grid and @init_file should be instances - of EclGrid and EclFile respectively. + of ResdataGrid and ResdataFile respectively. """ self.init_file = init_file # Inhibit premature garbage collection of init_file c_ptr = self._alloc(grid, init_file) - super(EclSubsidence, self).__init__(c_ptr) + super(ResdataSubsidence, self).__init__(c_ptr) def __contains__(self, survey_name): return self._has_survey(survey_name) @@ -72,16 +72,16 @@ def add_survey_PRESSURE(self, survey_name, restart_file): reservoir, i.e. an ECLIPSE restart file. The @survey_name input argument will be used when refering to this survey at a later stage. The @restart_file input argument should be an - EclFile instance with data from one report step. A typical way + ResdataFile instance with data from one report step. A typical way to load the @restart_file argument is: import datetime - import ecl.ecl.ecl as ecl + import resdata.ecl.ecl as ecl ... ... date = datetime.datetime( year , month , day ) - restart_file1 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , dtime = date) - restart_file2 = ecl.EclFile.restart_block( "ECLIPSE.UNRST" , report_step = 67 ) + restart_file1 = ecl.ResdataFile.restart_block( "ECLIPSE.UNRST" , dtime = date) + restart_file2 = ecl.ResdataFile.restart_block( "ECLIPSE.UNRST" , report_step = 67 ) The pore volume is calculated from the initial pore volume and the PRESSURE keyword from the restart file. @@ -173,7 +173,7 @@ def eval( change in subsidence. If supplied the optional argument @region should be an - EclRegion() instance; this region will be used to limit the + ResdataRegion() instance; this region will be used to limit the part of the reserviour included in the subsidence calculations. The argument @compressibility is the total reservoir compressibility. @@ -199,4 +199,4 @@ def free(self): self._free() -monkey_the_camel(EclSubsidence, "evalGeertsma", EclSubsidence.eval_geertsma) +monkey_the_camel(ResdataSubsidence, "evalGeertsma", ResdataSubsidence.eval_geertsma) diff --git a/python/resdata/grid/CMakeLists.txt b/python/resdata/grid/CMakeLists.txt index 0ddb3c434d..8b162c96d3 100644 --- a/python/resdata/grid/CMakeLists.txt +++ b/python/resdata/grid/CMakeLists.txt @@ -1,7 +1,7 @@ -set(PYTHON_SOURCES __init__.py cell.py ecl_grid.py ecl_region.py - ecl_grid_generator.py) +set(PYTHON_SOURCES __init__.py cell.py rd_grid.py rd_region.py + rd_grid_generator.py) -add_python_package("python.ecl.grid" ${PYTHON_INSTALL_PREFIX}/ecl/grid +add_python_package("python.ecl.grid" ${PYTHON_INSTALL_PREFIX}/resdata/grid "${PYTHON_SOURCES}" True) add_subdirectory(faults) diff --git a/python/resdata/grid/__init__.py b/python/resdata/grid/__init__.py index 81e294a659..615ce4abd3 100644 --- a/python/resdata/grid/__init__.py +++ b/python/resdata/grid/__init__.py @@ -1,19 +1,19 @@ """ - ecl_grid/EclGrid: This will load an ECLIPSE GRID or EGRID file, and + rd_grid/ResdataGrid: This will load an ECLIPSE GRID or EGRID file, and can then subsequently be used for queries about the grid. - ecl_region/EclRegion: Convenience class to support selecting cells + rd_region/ResdataRegion: Convenience class to support selecting cells in a grid based on a wide range of criteria. Can be used as a - mask in operations on EclKW instances. + mask in operations on ResdataKW instances. - ecl_grid_generator/EclGridGenerator: This can be used to generate various + rd_grid_generator/ResdataGridGenerator: This can be used to generate various grids. """ -import ecl.util.util -import ecl.util.geometry +import resdata.util.util +import resdata.util.geometry from .cell import Cell -from .ecl_grid import EclGrid -from .ecl_region import EclRegion -from .ecl_grid_generator import EclGridGenerator +from .rd_grid import ResdataGrid +from .rd_region import ResdataRegion +from .rd_grid_generator import ResdataGridGenerator diff --git a/python/resdata/grid/faults/CMakeLists.txt b/python/resdata/grid/faults/CMakeLists.txt index 716c8faea0..8e75cc2b4e 100644 --- a/python/resdata/grid/faults/CMakeLists.txt +++ b/python/resdata/grid/faults/CMakeLists.txt @@ -9,5 +9,5 @@ set(PYTHON_SOURCES layer.py) add_python_package( - "python.ecl.grid.faults" ${PYTHON_INSTALL_PREFIX}/ecl/grid/faults + "python.ecl.grid.faults" ${PYTHON_INSTALL_PREFIX}/resdata/grid/faults "${PYTHON_SOURCES}" True) diff --git a/python/resdata/grid/faults/fault.py b/python/resdata/grid/faults/fault.py index b5cf34ec7c..e4c1fb564c 100644 --- a/python/resdata/grid/faults/fault.py +++ b/python/resdata/grid/faults/fault.py @@ -1,7 +1,7 @@ import numpy as np -from ecl.util.util import monkey_the_camel -from ecl.util.geometry import Polyline, CPolyline, GeometryTools +from resdata.util.util import monkey_the_camel +from resdata.util.geometry import Polyline, CPolyline, GeometryTools from .fault_line import FaultLine from .fault_segments import FaultSegment, SegmentMap diff --git a/python/resdata/grid/faults/fault_block.py b/python/resdata/grid/faults/fault_block.py index ec460e3d99..cbd18ba707 100644 --- a/python/resdata/grid/faults/fault_block.py +++ b/python/resdata/grid/faults/fault_block.py @@ -1,10 +1,10 @@ import ctypes from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl.util.util import DoubleVector, IntVector -from ecl import EclPrototype -from ecl.util.geometry import Polyline, GeometryTools, CPolylineCollection +from resdata.util.util import monkey_the_camel +from resdata.util.util import DoubleVector, IntVector +from resdata import ResdataPrototype +from resdata.util.geometry import Polyline, GeometryTools, CPolylineCollection class FaultBlockCell(object): @@ -24,32 +24,32 @@ def __str__(self): class FaultBlock(BaseCClass): TYPE_NAME = "fault_block" - _get_xc = EclPrototype("double fault_block_get_xc(fault_block)") - _get_yc = EclPrototype("double fault_block_get_yc(fault_block)") - _get_block_id = EclPrototype("int fault_block_get_id(fault_block)") - _get_size = EclPrototype("int fault_block_get_size(fault_block)") - _export_cell = EclPrototype( + _get_xc = ResdataPrototype("double fault_block_get_xc(fault_block)") + _get_yc = ResdataPrototype("double fault_block_get_yc(fault_block)") + _get_block_id = ResdataPrototype("int fault_block_get_id(fault_block)") + _get_size = ResdataPrototype("int fault_block_get_size(fault_block)") + _export_cell = ResdataPrototype( "void fault_block_export_cell(fault_block, int, int*, int*, int*, double*, double*, double*)" ) - _assign_to_region = EclPrototype( + _assign_to_region = ResdataPrototype( "void fault_block_assign_to_region(fault_block, int)" ) - _get_region_list = EclPrototype( + _get_region_list = ResdataPrototype( "int_vector_ref fault_block_get_region_list(fault_block)" ) - _add_cell = EclPrototype( + _add_cell = ResdataPrototype( "void fault_block_add_cell(fault_block, int, int)" ) - _get_global_index_list = EclPrototype( + _get_global_index_list = ResdataPrototype( "int_vector_ref fault_block_get_global_index_list(fault_block)" ) - _trace_edge = EclPrototype( + _trace_edge = ResdataPrototype( "void fault_block_trace_edge(fault_block, double_vector, double_vector, int_vector)" ) - _get_neighbours = EclPrototype( + _get_neighbours = ResdataPrototype( "void fault_block_list_neighbours(fault_block, bool, geo_polygon_collection, int_vector)" ) - _free = EclPrototype("void fault_block_free__(fault_block)") + _free = ResdataPrototype("void fault_block_free__(fault_block)") def __init__(self, *args, **kwargs): raise NotImplementedError("Class can not be instantiated directly!") diff --git a/python/resdata/grid/faults/fault_block_collection.py b/python/resdata/grid/faults/fault_block_collection.py index 14d061e5f3..5b85769d23 100644 --- a/python/resdata/grid/faults/fault_block_collection.py +++ b/python/resdata/grid/faults/fault_block_collection.py @@ -1,20 +1,22 @@ from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata import ResdataPrototype class FaultBlockCollection(BaseCClass): TYPE_NAME = "fault_block_collection" - _alloc = EclPrototype("void* fault_block_collection_alloc(ecl_grid)", bind=False) - _free = EclPrototype("void fault_block_collection_free(fault_block_collection)") - _num_layers = EclPrototype( + _alloc = ResdataPrototype("void* fault_block_collection_alloc(rd_grid)", bind=False) + _free = ResdataPrototype( + "void fault_block_collection_free(fault_block_collection)" + ) + _num_layers = ResdataPrototype( "int fault_block_collection_num_layers(fault_block_collection)" ) - _scan_keyword = EclPrototype( - "bool fault_block_collection_scan_kw(fault_block_collection, ecl_kw)" + _scan_keyword = ResdataPrototype( + "bool fault_block_collection_scan_kw(fault_block_collection, rd_kw)" ) - _get_layer = EclPrototype( + _get_layer = ResdataPrototype( "fault_block_layer_ref fault_block_collection_get_layer(fault_block_collection, int)" ) diff --git a/python/resdata/grid/faults/fault_block_layer.py b/python/resdata/grid/faults/fault_block_layer.py index 76b5082a89..8ac8ab8442 100644 --- a/python/resdata/grid/faults/fault_block_layer.py +++ b/python/resdata/grid/faults/fault_block_layer.py @@ -1,56 +1,60 @@ from __future__ import print_function from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl import EclDataType -from ecl import EclPrototype -from ecl.grid.faults import Fault +from resdata.util.util import monkey_the_camel +from resdata import ResdataDataType +from resdata import ResdataPrototype +from resdata.grid.faults import Fault class FaultBlockLayer(BaseCClass): TYPE_NAME = "fault_block_layer" - _alloc = EclPrototype( - "void* fault_block_layer_alloc(ecl_grid, int)", bind=False + _alloc = ResdataPrototype( + "void* fault_block_layer_alloc(rd_grid, int)", bind=False ) - _free = EclPrototype("void fault_block_layer_free(fault_block_layer)") - _size = EclPrototype( + _free = ResdataPrototype( + "void fault_block_layer_free(fault_block_layer)" + ) + _size = ResdataPrototype( "int fault_block_layer_get_size(fault_block_layer)" ) - _iget_block = EclPrototype( + _iget_block = ResdataPrototype( "fault_block_ref fault_block_layer_iget_block(fault_block_layer, int)" ) - _add_block = EclPrototype( + _add_block = ResdataPrototype( "fault_block_ref fault_block_layer_add_block(fault_block_layer, int)" ) - _get_block = EclPrototype( + _get_block = ResdataPrototype( "fault_block_ref fault_block_layer_get_block(fault_block_layer, int)" ) - _del_block = EclPrototype( + _del_block = ResdataPrototype( "void fault_block_layer_del_block(fault_block_layer, int)" ) - _has_block = EclPrototype( + _has_block = ResdataPrototype( "bool fault_block_layer_has_block(fault_block_layer, int)" ) - _scan_keyword = EclPrototype( - "bool fault_block_layer_scan_kw(fault_block_layer, ecl_kw)" + _scan_keyword = ResdataPrototype( + "bool fault_block_layer_scan_kw(fault_block_layer, rd_kw)" + ) + _load_keyword = ResdataPrototype( + "bool fault_block_layer_load_kw(fault_block_layer, rd_kw)" ) - _load_keyword = EclPrototype( - "bool fault_block_layer_load_kw(fault_block_layer, ecl_kw)" + _getK = ResdataPrototype( + "int fault_block_layer_get_k(fault_block_layer)" ) - _getK = EclPrototype("int fault_block_layer_get_k(fault_block_layer)") - _get_next_id = EclPrototype( + _get_next_id = ResdataPrototype( "int fault_block_layer_get_next_id(fault_block_layer)" ) - _scan_layer = EclPrototype( + _scan_layer = ResdataPrototype( "void fault_block_layer_scan_layer(fault_block_layer, layer)" ) - _insert_block_content = EclPrototype( + _insert_block_content = ResdataPrototype( "void fault_block_layer_insert_block_content(fault_block_layer, fault_block)" ) - _export_kw = EclPrototype( - "bool fault_block_layer_export(fault_block_layer, ecl_kw)" + _export_kw = ResdataPrototype( + "bool fault_block_layer_export(fault_block_layer, rd_kw)" ) - _get_layer = EclPrototype( + _get_layer = ResdataPrototype( "layer_ref fault_block_layer_get_layer(fault_block_layer)" ) diff --git a/python/resdata/grid/faults/fault_collection.py b/python/resdata/grid/faults/fault_collection.py index e6c76b5489..c237e33274 100644 --- a/python/resdata/grid/faults/fault_collection.py +++ b/python/resdata/grid/faults/fault_collection.py @@ -1,7 +1,7 @@ import re -from ecl.util.util import monkey_the_camel -from ecl.grid import EclGrid +from resdata.util.util import monkey_the_camel +from resdata.grid import ResdataGrid from .fault import Fault comment_regexp = re.compile("--.*") @@ -24,7 +24,7 @@ def __init__(self, grid=None, *file_list): self.__grid = grid if self.__grid is not None: - if not isinstance(self.__grid, EclGrid): + if not isinstance(self.__grid, ResdataGrid): raise ValueError( "When supplying a list of files to load - you must have a grid" ) diff --git a/python/resdata/grid/faults/fault_line.py b/python/resdata/grid/faults/fault_line.py index 35dc6334cf..6fdc299196 100644 --- a/python/resdata/grid/faults/fault_line.py +++ b/python/resdata/grid/faults/fault_line.py @@ -1,8 +1,8 @@ import sys -from ecl.util.util import monkey_the_camel -from ecl.util.util import DoubleVector -from ecl.util.geometry import CPolyline +from resdata.util.util import monkey_the_camel +from resdata.util.util import DoubleVector +from resdata.util.geometry import CPolyline from .fault_segments import FaultSegment diff --git a/python/resdata/grid/faults/fault_segments.py b/python/resdata/grid/faults/fault_segments.py index d42d760fe4..b5ff6e91a3 100644 --- a/python/resdata/grid/faults/fault_segments.py +++ b/python/resdata/grid/faults/fault_segments.py @@ -1,6 +1,6 @@ from __future__ import print_function -from ecl.util.util import monkey_the_camel +from resdata.util.util import monkey_the_camel class FaultSegment(object): diff --git a/python/resdata/grid/faults/layer.py b/python/resdata/grid/faults/layer.py index 326680eea1..1fe6daeb98 100644 --- a/python/resdata/grid/faults/layer.py +++ b/python/resdata/grid/faults/layer.py @@ -1,45 +1,49 @@ import ctypes -from ecl.grid import EclGrid +from resdata.grid import ResdataGrid from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl.util.util import IntVector -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata.util.util import IntVector +from resdata import ResdataPrototype class Layer(BaseCClass): TYPE_NAME = "layer" - _alloc = EclPrototype("void* layer_alloc(int, int)", bind=False) - _copy = EclPrototype("void layer_memcpy(layer, layer)") - _free = EclPrototype("void layer_free(layer)") - _get_nx = EclPrototype("int layer_get_nx(layer)") - _get_ny = EclPrototype("int layer_get_ny(layer)") - _set_cell = EclPrototype("void layer_iset_cell_value(layer, int, int, int)") - _get_cell = EclPrototype("int layer_iget_cell_value(layer, int, int)") - _get_bottom_barrier = EclPrototype( + _alloc = ResdataPrototype("void* layer_alloc(int, int)", bind=False) + _copy = ResdataPrototype("void layer_memcpy(layer, layer)") + _free = ResdataPrototype("void layer_free(layer)") + _get_nx = ResdataPrototype("int layer_get_nx(layer)") + _get_ny = ResdataPrototype("int layer_get_ny(layer)") + _set_cell = ResdataPrototype("void layer_iset_cell_value(layer, int, int, int)") + _get_cell = ResdataPrototype("int layer_iget_cell_value(layer, int, int)") + _get_bottom_barrier = ResdataPrototype( "bool layer_iget_bottom_barrier(layer, int, int)" ) - _get_left_barrier = EclPrototype("bool layer_iget_left_barrier(layer, int, int)") - _cell_contact = EclPrototype("bool layer_cell_contact(layer, int, int, int, int)") - _add_barrier = EclPrototype("void layer_add_barrier(layer, int, int)") - _add_ijbarrier = EclPrototype( + _get_left_barrier = ResdataPrototype( + "bool layer_iget_left_barrier(layer, int, int)" + ) + _cell_contact = ResdataPrototype( + "bool layer_cell_contact(layer, int, int, int, int)" + ) + _add_barrier = ResdataPrototype("void layer_add_barrier(layer, int, int)") + _add_ijbarrier = ResdataPrototype( "void layer_add_ijbarrier(layer, int, int, int, int)" ) - _add_interp_barrier = EclPrototype( + _add_interp_barrier = ResdataPrototype( "void layer_add_interp_barrier(layer, int, int)" ) - _clear_cells = EclPrototype("void layer_clear_cells(layer)") - _assign = EclPrototype("void layer_assign(layer, int)") - _cell_sum = EclPrototype("int layer_get_cell_sum(layer)") - _update_connected = EclPrototype( + _clear_cells = ResdataPrototype("void layer_clear_cells(layer)") + _assign = ResdataPrototype("void layer_assign(layer, int)") + _cell_sum = ResdataPrototype("int layer_get_cell_sum(layer)") + _update_connected = ResdataPrototype( "void layer_update_connected_cells(layer,int,int,int,int)" ) - _cells_equal = EclPrototype( + _cells_equal = ResdataPrototype( "void layer_cells_equal(layer, int,int_vector,int_vector)" ) - _count_equal = EclPrototype("int layer_count_equal(layer, int)") - _active_cell = EclPrototype("bool layer_iget_active(layer, int,int)") - _update_active = EclPrototype("bool layer_update_active(layer, ecl_grid, int)") + _count_equal = ResdataPrototype("int layer_count_equal(layer, int)") + _active_cell = ResdataPrototype("bool layer_iget_active(layer, int,int)") + _update_active = ResdataPrototype("bool layer_update_active(layer, rd_grid, int)") def __init__(self, nx, ny): c_ptr = self._alloc(nx, ny) diff --git a/python/resdata/grid/rd_grid.py b/python/resdata/grid/rd_grid.py index 1ab3d8a6f1..8328df8892 100644 --- a/python/resdata/grid/rd_grid.py +++ b/python/resdata/grid/rd_grid.py @@ -1,11 +1,11 @@ """ Module to load and query ECLIPSE GRID/EGRID files. -The ecl_grid module contains functionality to load and query an +The rd_grid module contains functionality to load and query an ECLIPSE grid file; it is currently not possible to manipulate or let -alone create a grid with ecl_grid module. The functionality is -implemented in the EclGrid class. The ecl_grid module is a thin -wrapper around the ecl_grid.c implementation from the resdata library. +alone create a grid with rd_grid module. The functionality is +implemented in the ResdataGrid class. The rd_grid module is a thin +wrapper around the rd_grid.c implementation from the resdata library. """ import ctypes @@ -18,167 +18,177 @@ import itertools from cwrap import CFILE, BaseCClass, load, open as copen -from ecl import EclPrototype -from ecl.util.util import monkey_the_camel -from ecl.util.util import IntVector -from ecl import EclDataType, EclUnitTypeEnum, EclTypeEnum -from ecl.eclfile import EclKW, FortIO -from ecl.grid import Cell +from resdata import ResdataPrototype +from resdata.util.util import monkey_the_camel +from resdata.util.util import IntVector +from resdata import ResdataDataType, ResdataUnitTypeEnum, ResdataTypeEnum +from resdata.eclfile import ResdataKW, FortIO +from resdata.grid import Cell -class EclGrid(BaseCClass): +class ResdataGrid(BaseCClass): """ Class for loading and internalizing ECLIPSE GRID/EGRID files. """ - TYPE_NAME = "ecl_grid" - _fread_alloc = EclPrototype("void* ecl_grid_load_case__(char*, bool)", bind=False) - _grdecl_create = EclPrototype( - "ecl_grid_obj ecl_grid_alloc_GRDECL_kw(int, int, int, ecl_kw, ecl_kw, ecl_kw, ecl_kw)", + TYPE_NAME = "rd_grid" + _fread_alloc = ResdataPrototype( + "void* rd_grid_load_case__(char*, bool)", bind=False + ) + _grdecl_create = ResdataPrototype( + "rd_grid_obj rd_grid_alloc_GRDECL_kw(int, int, int, rd_kw, rd_kw, rd_kw, rd_kw)", bind=False, ) - _alloc_rectangular = EclPrototype( - "ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", + _alloc_rectangular = ResdataPrototype( + "rd_grid_obj rd_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind=False, ) - _exists = EclPrototype("bool ecl_grid_exists(char*)", bind=False) + _exists = ResdataPrototype("bool rd_grid_exists(char*)", bind=False) - _get_numbered_lgr = EclPrototype( - "ecl_grid_ref ecl_grid_get_lgr_from_lgr_nr(ecl_grid, int)" + _get_numbered_lgr = ResdataPrototype( + "rd_grid_ref rd_grid_get_lgr_from_lgr_nr(rd_grid, int)" + ) + _get_named_lgr = ResdataPrototype("rd_grid_ref rd_grid_get_lgr(rd_grid, char*)") + _get_cell_lgr = ResdataPrototype("rd_grid_ref rd_grid_get_cell_lgr1(rd_grid, int)") + _num_coarse_groups = ResdataPrototype("int rd_grid_get_num_coarse_groups(rd_grid)") + _in_coarse_group1 = ResdataPrototype( + "bool rd_grid_cell_in_coarse_group1(rd_grid, int)" + ) + _free = ResdataPrototype("void rd_grid_free(rd_grid)") + _get_nx = ResdataPrototype("int rd_grid_get_nx(rd_grid)") + _get_ny = ResdataPrototype("int rd_grid_get_ny(rd_grid)") + _get_nz = ResdataPrototype("int rd_grid_get_nz(rd_grid)") + _get_global_size = ResdataPrototype("int rd_grid_get_global_size(rd_grid)") + _get_active = ResdataPrototype("int rd_grid_get_active_size(rd_grid)") + _get_active_fracture = ResdataPrototype("int rd_grid_get_nactive_fracture(rd_grid)") + _get_name = ResdataPrototype("char* rd_grid_get_name(rd_grid)") + _ijk_valid = ResdataPrototype("bool rd_grid_ijk_valid(rd_grid, int, int, int)") + _get_active_index3 = ResdataPrototype( + "int rd_grid_get_active_index3(rd_grid, int, int, int)" + ) + _get_global_index3 = ResdataPrototype( + "int rd_grid_get_global_index3(rd_grid, int, int, int)" + ) + _get_active_index1 = ResdataPrototype("int rd_grid_get_active_index1(rd_grid, int)") + _get_active_fracture_index1 = ResdataPrototype( + "int rd_grid_get_active_fracture_index1(rd_grid, int)" ) - _get_named_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_lgr(ecl_grid, char*)") - _get_cell_lgr = EclPrototype("ecl_grid_ref ecl_grid_get_cell_lgr1(ecl_grid, int)") - _num_coarse_groups = EclPrototype("int ecl_grid_get_num_coarse_groups(ecl_grid)") - _in_coarse_group1 = EclPrototype( - "bool ecl_grid_cell_in_coarse_group1(ecl_grid, int)" + _get_global_index1A = ResdataPrototype( + "int rd_grid_get_global_index1A(rd_grid, int)" ) - _free = EclPrototype("void ecl_grid_free(ecl_grid)") - _get_nx = EclPrototype("int ecl_grid_get_nx(ecl_grid)") - _get_ny = EclPrototype("int ecl_grid_get_ny(ecl_grid)") - _get_nz = EclPrototype("int ecl_grid_get_nz(ecl_grid)") - _get_global_size = EclPrototype("int ecl_grid_get_global_size(ecl_grid)") - _get_active = EclPrototype("int ecl_grid_get_active_size(ecl_grid)") - _get_active_fracture = EclPrototype("int ecl_grid_get_nactive_fracture(ecl_grid)") - _get_name = EclPrototype("char* ecl_grid_get_name(ecl_grid)") - _ijk_valid = EclPrototype("bool ecl_grid_ijk_valid(ecl_grid, int, int, int)") - _get_active_index3 = EclPrototype( - "int ecl_grid_get_active_index3(ecl_grid, int, int, int)" + _get_global_index1F = ResdataPrototype( + "int rd_grid_get_global_index1F(rd_grid, int)" ) - _get_global_index3 = EclPrototype( - "int ecl_grid_get_global_index3(ecl_grid, int, int, int)" + _get_ijk1 = ResdataPrototype( + "void rd_grid_get_ijk1(rd_grid, int, int*, int*, int*)" ) - _get_active_index1 = EclPrototype("int ecl_grid_get_active_index1(ecl_grid, int)") - _get_active_fracture_index1 = EclPrototype( - "int ecl_grid_get_active_fracture_index1(ecl_grid, int)" + _get_ijk1A = ResdataPrototype( + "void rd_grid_get_ijk1A(rd_grid, int, int*, int*, int*)" ) - _get_global_index1A = EclPrototype("int ecl_grid_get_global_index1A(ecl_grid, int)") - _get_global_index1F = EclPrototype("int ecl_grid_get_global_index1F(ecl_grid, int)") - _get_ijk1 = EclPrototype("void ecl_grid_get_ijk1(ecl_grid, int, int*, int*, int*)") - _get_ijk1A = EclPrototype( - "void ecl_grid_get_ijk1A(ecl_grid, int, int*, int*, int*)" + _get_xyz3 = ResdataPrototype( + "void rd_grid_get_xyz3(rd_grid, int, int, int, double*, double*, double*)" ) - _get_xyz3 = EclPrototype( - "void ecl_grid_get_xyz3(ecl_grid, int, int, int, double*, double*, double*)" + _get_xyz1 = ResdataPrototype( + "void rd_grid_get_xyz1(rd_grid, int, double*, double*, double*)" ) - _get_xyz1 = EclPrototype( - "void ecl_grid_get_xyz1(ecl_grid, int, double*, double*, double*)" + _get_cell_corner_xyz1 = ResdataPrototype( + "void rd_grid_get_cell_corner_xyz1(rd_grid, int, int, double*, double*, double*)" ) - _get_cell_corner_xyz1 = EclPrototype( - "void ecl_grid_get_cell_corner_xyz1(ecl_grid, int, int, double*, double*, double*)" + _get_corner_xyz = ResdataPrototype( + "void rd_grid_get_corner_xyz(rd_grid, int, int, int, double*, double*, double*)" ) - _get_corner_xyz = EclPrototype( - "void ecl_grid_get_corner_xyz(ecl_grid, int, int, int, double*, double*, double*)" + _get_xyz1A = ResdataPrototype( + "void rd_grid_get_xyz1A(rd_grid, int, double*, double*, double*)" ) - _get_xyz1A = EclPrototype( - "void ecl_grid_get_xyz1A(ecl_grid, int, double*, double*, double*)" + _get_ij_xy = ResdataPrototype( + "bool rd_grid_get_ij_from_xy(rd_grid, double, double, int, int*, int*)" ) - _get_ij_xy = EclPrototype( - "bool ecl_grid_get_ij_from_xy(ecl_grid, double, double, int, int*, int*)" + _get_ijk_xyz = ResdataPrototype( + "int rd_grid_get_global_index_from_xyz(rd_grid, double, double, double, int)" ) - _get_ijk_xyz = EclPrototype( - "int ecl_grid_get_global_index_from_xyz(ecl_grid, double, double, double, int)" + _cell_contains = ResdataPrototype( + "bool rd_grid_cell_contains_xyz1(rd_grid, int, double, double, double)" ) - _cell_contains = EclPrototype( - "bool ecl_grid_cell_contains_xyz1(ecl_grid, int, double, double, double)" + _cell_regular = ResdataPrototype("bool rd_grid_cell_regular1(rd_grid, int)") + _num_lgr = ResdataPrototype("int rd_grid_get_num_lgr(rd_grid)") + _has_numbered_lgr = ResdataPrototype("bool rd_grid_has_lgr_nr(rd_grid, int)") + _has_named_lgr = ResdataPrototype("bool rd_grid_has_lgr(rd_grid, char*)") + _grid_value = ResdataPrototype( + "double rd_grid_get_property(rd_grid, rd_kw, int, int, int)" ) - _cell_regular = EclPrototype("bool ecl_grid_cell_regular1(ecl_grid, int)") - _num_lgr = EclPrototype("int ecl_grid_get_num_lgr(ecl_grid)") - _has_numbered_lgr = EclPrototype("bool ecl_grid_has_lgr_nr(ecl_grid, int)") - _has_named_lgr = EclPrototype("bool ecl_grid_has_lgr(ecl_grid, char*)") - _grid_value = EclPrototype( - "double ecl_grid_get_property(ecl_grid, ecl_kw, int, int, int)" + _get_cell_volume = ResdataPrototype("double rd_grid_get_cell_volume1(rd_grid, int)") + _get_cell_thickness = ResdataPrototype( + "double rd_grid_get_cell_thickness1(rd_grid, int)" ) - _get_cell_volume = EclPrototype("double ecl_grid_get_cell_volume1(ecl_grid, int)") - _get_cell_thickness = EclPrototype( - "double ecl_grid_get_cell_thickness1(ecl_grid, int)" + _get_cell_dx = ResdataPrototype("double rd_grid_get_cell_dx1(rd_grid, int)") + _get_cell_dy = ResdataPrototype("double rd_grid_get_cell_dy1(rd_grid, int)") + _get_depth = ResdataPrototype("double rd_grid_get_cdepth1(rd_grid, int)") + _fwrite_grdecl = ResdataPrototype( + "void rd_grid_grdecl_fprintf_kw(rd_grid, rd_kw, char*, FILE, double)" ) - _get_cell_dx = EclPrototype("double ecl_grid_get_cell_dx1(ecl_grid, int)") - _get_cell_dy = EclPrototype("double ecl_grid_get_cell_dy1(ecl_grid, int)") - _get_depth = EclPrototype("double ecl_grid_get_cdepth1(ecl_grid, int)") - _fwrite_grdecl = EclPrototype( - "void ecl_grid_grdecl_fprintf_kw(ecl_grid, ecl_kw, char*, FILE, double)" + _load_column = ResdataPrototype( + "void rd_grid_get_column_property(rd_grid, rd_kw, int, int, double_vector)" ) - _load_column = EclPrototype( - "void ecl_grid_get_column_property(ecl_grid, ecl_kw, int, int, double_vector)" + _get_top = ResdataPrototype("double rd_grid_get_top2(rd_grid, int, int)") + _get_top1A = ResdataPrototype("double rd_grid_get_top1A(rd_grid, int)") + _get_bottom = ResdataPrototype("double rd_grid_get_bottom2(rd_grid, int, int)") + _locate_depth = ResdataPrototype( + "int rd_grid_locate_depth(rd_grid, double, int, int)" ) - _get_top = EclPrototype("double ecl_grid_get_top2(ecl_grid, int, int)") - _get_top1A = EclPrototype("double ecl_grid_get_top1A(ecl_grid, int)") - _get_bottom = EclPrototype("double ecl_grid_get_bottom2(ecl_grid, int, int)") - _locate_depth = EclPrototype( - "int ecl_grid_locate_depth(ecl_grid, double, int, int)" + _invalid_cell = ResdataPrototype("bool rd_grid_cell_invalid1(rd_grid, int)") + _valid_cell = ResdataPrototype("bool rd_grid_cell_valid1(rd_grid, int)") + _get_distance = ResdataPrototype( + "void rd_grid_get_distance(rd_grid, int, int, double*, double*, double*)" ) - _invalid_cell = EclPrototype("bool ecl_grid_cell_invalid1(ecl_grid, int)") - _valid_cell = EclPrototype("bool ecl_grid_cell_valid1(ecl_grid, int)") - _get_distance = EclPrototype( - "void ecl_grid_get_distance(ecl_grid, int, int, double*, double*, double*)" + _fprintf_grdecl2 = ResdataPrototype( + "void rd_grid_fprintf_grdecl2(rd_grid, FILE, rd_unit_enum) " ) - _fprintf_grdecl2 = EclPrototype( - "void ecl_grid_fprintf_grdecl2(ecl_grid, FILE, ecl_unit_enum) " + _fwrite_GRID2 = ResdataPrototype( + "void rd_grid_fwrite_GRID2(rd_grid, char*, rd_unit_enum)" ) - _fwrite_GRID2 = EclPrototype( - "void ecl_grid_fwrite_GRID2(ecl_grid, char*, ecl_unit_enum)" + _fwrite_EGRID2 = ResdataPrototype( + "void rd_grid_fwrite_EGRID2(rd_grid, char*, rd_unit_enum)" ) - _fwrite_EGRID2 = EclPrototype( - "void ecl_grid_fwrite_EGRID2(ecl_grid, char*, ecl_unit_enum)" + _equal = ResdataPrototype("bool rd_grid_compare(rd_grid, rd_grid, bool, bool)") + _dual_grid = ResdataPrototype("bool rd_grid_dual_grid(rd_grid)") + _init_actnum = ResdataPrototype("void rd_grid_init_actnum_data(rd_grid, int*)") + _compressed_kw_copy = ResdataPrototype( + "void rd_grid_compressed_kw_copy(rd_grid, rd_kw, rd_kw)" ) - _equal = EclPrototype("bool ecl_grid_compare(ecl_grid, ecl_grid, bool, bool)") - _dual_grid = EclPrototype("bool ecl_grid_dual_grid(ecl_grid)") - _init_actnum = EclPrototype("void ecl_grid_init_actnum_data(ecl_grid, int*)") - _compressed_kw_copy = EclPrototype( - "void ecl_grid_compressed_kw_copy(ecl_grid, ecl_kw, ecl_kw)" + _global_kw_copy = ResdataPrototype( + "void rd_grid_global_kw_copy(rd_grid, rd_kw, rd_kw)" ) - _global_kw_copy = EclPrototype( - "void ecl_grid_global_kw_copy(ecl_grid, ecl_kw, ecl_kw)" + _create_volume_keyword = ResdataPrototype( + "rd_kw_obj rd_grid_alloc_volume_kw(rd_grid, bool)" ) - _create_volume_keyword = EclPrototype( - "ecl_kw_obj ecl_grid_alloc_volume_kw(ecl_grid, bool)" + _use_mapaxes = ResdataPrototype("bool rd_grid_use_mapaxes(rd_grid)") + _export_coord = ResdataPrototype("rd_kw_obj rd_grid_alloc_coord_kw(rd_grid)") + _export_zcorn = ResdataPrototype("rd_kw_obj rd_grid_alloc_zcorn_kw(rd_grid)") + _export_actnum = ResdataPrototype("rd_kw_obj rd_grid_alloc_actnum_kw(rd_grid)") + _export_mapaxes = ResdataPrototype("rd_kw_obj rd_grid_alloc_mapaxes_kw(rd_grid)") + _get_unit_system = ResdataPrototype("rd_unit_enum rd_grid_get_unit_system(rd_grid)") + _export_index_frame = ResdataPrototype( + "void rd_grid_export_index(rd_grid, int*, int*, bool)" ) - _use_mapaxes = EclPrototype("bool ecl_grid_use_mapaxes(ecl_grid)") - _export_coord = EclPrototype("ecl_kw_obj ecl_grid_alloc_coord_kw(ecl_grid)") - _export_zcorn = EclPrototype("ecl_kw_obj ecl_grid_alloc_zcorn_kw(ecl_grid)") - _export_actnum = EclPrototype("ecl_kw_obj ecl_grid_alloc_actnum_kw(ecl_grid)") - _export_mapaxes = EclPrototype("ecl_kw_obj ecl_grid_alloc_mapaxes_kw(ecl_grid)") - _get_unit_system = EclPrototype("ecl_unit_enum ecl_grid_get_unit_system(ecl_grid)") - _export_index_frame = EclPrototype( - "void ecl_grid_export_index(ecl_grid, int*, int*, bool)" + _export_data_as_int = ResdataPrototype( + "void rd_grid_export_data_as_int(int, int*, rd_kw, int*)", bind=False ) - _export_data_as_int = EclPrototype( - "void ecl_grid_export_data_as_int(int, int*, ecl_kw, int*)", bind=False + _export_data_as_double = ResdataPrototype( + "void rd_grid_export_data_as_double(int, int*, rd_kw, double*)", bind=False ) - _export_data_as_double = EclPrototype( - "void ecl_grid_export_data_as_double(int, int*, ecl_kw, double*)", bind=False + _export_volume = ResdataPrototype( + "void rd_grid_export_volume(rd_grid, int, int*, double*)" ) - _export_volume = EclPrototype( - "void ecl_grid_export_volume(ecl_grid, int, int*, double*)" + _export_position = ResdataPrototype( + "void rd_grid_export_position(rd_grid, int, int*, double*)" ) - _export_position = EclPrototype( - "void ecl_grid_export_position(ecl_grid, int, int*, double*)" + _export_corners = ResdataPrototype( + "void export_corners(rd_grid, int, int*, double*)" ) - _export_corners = EclPrototype("void export_corners(ecl_grid, int, int*, double*)") @classmethod def load_from_grdecl(cls, filename): - """Will create a new EclGrid instance from grdecl file. + """Will create a new ResdataGrid instance from grdecl file. This function will scan the input file @filename and look for the keywords required to build a grid. The following keywords @@ -193,61 +203,61 @@ def load_from_grdecl(cls, filename): Slightly more exotic grid concepts like dual porosity, NNC mapping, LGR and coarsened cells will be completely ignored; if you need such concepts you must have an EGRID file and use - the default EclGrid() constructor - that is also considerably + the default ResdataGrid() constructor - that is also considerably faster. """ if os.path.isfile(filename): with copen(filename) as f: - specgrid = EclKW.read_grdecl( - f, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False + specgrid = ResdataKW.read_grdecl( + f, "SPECGRID", rd_type=ResdataDataType.RD_INT, strict=False ) - zcorn = EclKW.read_grdecl(f, "ZCORN") - coord = EclKW.read_grdecl(f, "COORD") + zcorn = ResdataKW.read_grdecl(f, "ZCORN") + coord = ResdataKW.read_grdecl(f, "COORD") try: - actnum = EclKW.read_grdecl( - f, "ACTNUM", ecl_type=EclDataType.ECL_INT + actnum = ResdataKW.read_grdecl( + f, "ACTNUM", rd_type=ResdataDataType.RD_INT ) except ValueError: actnum = None try: - mapaxes = EclKW.read_grdecl(f, "MAPAXES") + mapaxes = ResdataKW.read_grdecl(f, "MAPAXES") except ValueError: mapaxes = None - return EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes) + return ResdataGrid.create(specgrid, zcorn, coord, actnum, mapaxes) else: raise IOError("No such file:%s" % filename) @classmethod def load_from_file(cls, filename): """ - Will inspect the @filename argument and create a new EclGrid instance. + Will inspect the @filename argument and create a new ResdataGrid instance. """ if FortIO.isFortranFile(filename): - return EclGrid(filename) + return ResdataGrid(filename) else: - return EclGrid.loadFromGrdecl(filename) + return ResdataGrid.loadFromGrdecl(filename) @classmethod def create(cls, specgrid, zcorn, coord, actnum, mapaxes=None): """ Create a new grid instance from existing keywords. - This is a class method which can be used to create an EclGrid - instance based on the EclKW instances @specgrid, @zcorn, + This is a class method which can be used to create an ResdataGrid + instance based on the ResdataKW instances @specgrid, @zcorn, @coord and @actnum. An ECLIPSE EGRID file contains the SPECGRID, ZCORN, COORD and ACTNUM keywords, so a somewhat - involved way to create a EclGrid instance could be: + involved way to create a ResdataGrid instance could be: - file = ecl.EclFile("ECLIPSE.EGRID") + file = ecl.ResdataFile("ECLIPSE.EGRID") specgrid_kw = file.iget_named_kw("SPECGRID", 0) zcorn_kw = file.iget_named_kw("ZCORN", 0) coord_kw = file.iget_named_kw("COORD", 0) actnum_kw = file.iget_named_kw("ACTNUM", 0) - grid = EclGrid.create(specgrid_kw, zcorn_kw, coord_kw, actnum_kw) + grid = ResdataGrid.create(specgrid_kw, zcorn_kw, coord_kw, actnum_kw) If you are so inclined ... """ @@ -264,13 +274,13 @@ def create_rectangular(cls, dims, dV, actnum=None): """ warnings.warn( - "EclGrid.createRectangular is deprecated. " - + "Please use the similar method: EclGridGenerator.createRectangular.", + "ResdataGrid.createRectangular is deprecated. " + + "Please use the similar method: ResdataGridGenerator.createRectangular.", DeprecationWarning, ) if actnum is None: - ecl_grid = cls._alloc_rectangular( + rd_grid = cls._alloc_rectangular( dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], None ) else: @@ -285,16 +295,16 @@ def create_rectangular(cls, dims, dV, actnum=None): "ACTNUM size mismatch: len(ACTNUM):%d Expected:%d" % (len(actnum), dims[0] * dims[1] * dims[2]) ) - ecl_grid = cls._alloc_rectangular( + rd_grid = cls._alloc_rectangular( dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], actnum.getDataPtr() ) # If we have not succeeded in creatin the grid we *assume* the # error is due to a failed malloc. - if ecl_grid is None: + if rd_grid is None: raise MemoryError("Failed to allocated regualar grid") - return ecl_grid + return rd_grid def __init__(self, filename, apply_mapaxes=True): """ @@ -302,7 +312,7 @@ def __init__(self, filename, apply_mapaxes=True): """ c_ptr = self._fread_alloc(filename, apply_mapaxes) if c_ptr: - super(EclGrid, self).__init__(c_ptr) + super(ResdataGrid, self).__init__(c_ptr) else: raise IOError("Loading grid from:%s failed" % filename) @@ -318,7 +328,7 @@ def _nicename(self): def __repr__(self): """Returns, e.g.: - EclGrid("NORNE_ATW2013.EGRID", 46x112x22, global_size=113344, active_size=44431) at 0x28c4a70 + ResdataGrid("NORNE_ATW2013.EGRID", 46x112x22, global_size=113344, active_size=44431) at 0x28c4a70 """ name = self._nicename() if name: @@ -340,8 +350,8 @@ def equal(self, other, include_lgr=True, include_nnc=False, verbose=False): """ Compare the current grid with the other grid. """ - if not isinstance(other, EclGrid): - raise TypeError("The other argument must be an EclGrid instance") + if not isinstance(other, ResdataGrid): + raise TypeError("The other argument must be an ResdataGrid instance") return self._equal(other, include_lgr, include_nnc, verbose) def dual_grid(self): @@ -502,7 +512,7 @@ def __global_index(self, active_index=None, global_index=None, ijk=None): index. Exactly one of the arguments @active_index, @global_index or @ijk must be supplied. - The method is used extensively internally in the EclGrid + The method is used extensively internally in the ResdataGrid class; most methods which take coordinate input pass through this method to normalize the coordinate representation. """ @@ -670,7 +680,7 @@ def get_xyz(self, active_index=None, global_index=None, ijk=None): active_index : A number in the range [0,nactive). - For many of the EclGrid methods a cell can be specified using + For many of the ResdataGrid methods a cell can be specified using any of these three methods. Observe that one and only method is allowed: @@ -682,7 +692,7 @@ def get_xyz(self, active_index=None, global_index=None, ijk=None): pos3 = grid.get_xyz(ijk=(10,20,7), global_index=10) pos4 = grid.get_xyz() - All the indices in the EclGrid() class are zero offset, this + All the indices in the ResdataGrid() class are zero offset, this is in contrast to ECLIPSE which has an offset 1 interface. """ gi = self.__global_index( @@ -1033,9 +1043,9 @@ def has_lgr(self, lgr_name): return False def get_lgr(self, lgr_key): - """Get EclGrid instance with LGR content. + """Get ResdataGrid instance with LGR content. - Return an EclGrid instance based on the LGR @lgr, the input + Return an ResdataGrid instance based on the LGR @lgr, the input argument can either be the name of an LGR or the grid number of the LGR. The LGR grid instance is mostly like an ordinary grid instance; the only difference is that it can not be used @@ -1061,7 +1071,7 @@ def get_lgr(self, lgr_key): def get_cell_lgr(self, active_index=None, global_index=None, ijk=None): """ - Get EclGrid instance located in cell. + Get ResdataGrid instance located in cell. Will query the current grid instance if the cell given by @active_index, @global_index or @ijk has been refined with an @@ -1115,10 +1125,10 @@ def load_column(self, kw, i, j, column): def create_kw(self, array, kw_name, pack): """ - Creates an EclKW instance based on existing 3D numpy object. + Creates an ResdataKW instance based on existing 3D numpy object. The method create3D() does the inverse operation; creating a - 3D numpy object from an EclKW instance. If the argument @pack + 3D numpy object from an ResdataKW instance. If the argument @pack is true the resulting keyword will have length 'nactive', otherwise the element will have length nx*ny*nz. """ @@ -1131,13 +1141,13 @@ def create_kw(self, array, kw_name, pack): ): dtype = array.dtype if dtype == numpy.int32: - type = EclDataType.ECL_INT + type = ResdataDataType.RD_INT elif dtype == numpy.float32: - type = EclDataType.ECL_FLOAT + type = ResdataDataType.RD_FLOAT elif dtype == numpy.float64: - type = EclDataType.ECL_DOUBLE + type = ResdataDataType.RD_DOUBLE else: - sys.exit("Do not know how to create ecl_kw from type:%s" % dtype) + sys.exit("Do not know how to create rd_kw from type:%s" % dtype) if pack: size = self.getNumActive() @@ -1148,7 +1158,7 @@ def create_kw(self, array, kw_name, pack): # Silently truncate to length 8 - ECLIPSE has it's challenges. kw_name = kw_name[0:8] - kw = EclKW(kw_name, size, type) + kw = ResdataKW(kw_name, size, type) active_index = 0 global_index = 0 for k in range(self.getNZ()): @@ -1183,29 +1193,29 @@ def in_coarse_group(self, global_index=None, ijk=None, active_index=None): ) return self._in_coarse_group1(global_index) - def create_3d(self, ecl_kw, default=0): + def create_3d(self, rd_kw, default=0): """ - Creates a 3D numpy array object with the data from @ecl_kw. + Creates a 3D numpy array object with the data from @rd_kw. Observe that 3D numpy object is a copy of the data in the - EclKW instance, i.e. modification to the numpy object will not + ResdataKW instance, i.e. modification to the numpy object will not be reflected in the ECLIPSE keyword. The methods createKW() does the inverse operation; creating an - EclKW instance from a 3D numpy object. + ResdataKW instance from a 3D numpy object. Alternative: Creating the numpy array object is not very efficient; if you only need a limited number of elements from - the ecl_kw instance it might be wiser to use the grid_value() + the rd_kw instance it might be wiser to use the grid_value() method: - value = grid.grid_value(ecl_kw, i, j, k) + value = grid.grid_value(rd_kw, i, j, k) """ - if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize(): - array = numpy.ones([self.getGlobalSize()], dtype=ecl_kw.dtype) * default - kwa = ecl_kw.array - if len(ecl_kw) == self.getGlobalSize(): + if len(rd_kw) == self.getNumActive() or len(rd_kw) == self.getGlobalSize(): + array = numpy.ones([self.getGlobalSize()], dtype=rd_kw.dtype) * default + kwa = rd_kw.array + if len(rd_kw) == self.getGlobalSize(): for i in range(kwa.size): array[i] = kwa[i] else: @@ -1218,14 +1228,14 @@ def create_3d(self, ecl_kw, default=0): else: err_msg_fmt = 'Keyword "%s" has invalid size %d; must be either nactive=%d or nx*ny*nz=%d' err_msg = err_msg_fmt % ( - ecl_kw, - len(ecl_kw), + rd_kw, + len(rd_kw), self.getNumActive(), self.getGlobalSize(), ) raise ValueError(err_msg) - def save_grdecl(self, pyfile, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): + def save_grdecl(self, pyfile, output_unit=ResdataUnitTypeEnum.RD_METRIC_UNITS): """ Will write the the grid content as grdecl formatted keywords. @@ -1239,22 +1249,22 @@ def save_EGRID(self, filename, output_unit=None): output_unit = self.unit_system self._fwrite_EGRID2(filename, output_unit) - def save_GRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): + def save_GRID(self, filename, output_unit=ResdataUnitTypeEnum.RD_METRIC_UNITS): """ Will save the current grid as a GRID file. """ self._fwrite_GRID2(filename, output_unit) - def write_grdecl(self, ecl_kw, pyfile, special_header=None, default_value=0): + def write_grdecl(self, rd_kw, pyfile, special_header=None, default_value=0): """ - Writes an EclKW instance as an ECLIPSE grdecl formatted file. + Writes an ResdataKW instance as an ECLIPSE grdecl formatted file. - The input argument @ecl_kw must be an EclKW instance of size + The input argument @rd_kw must be an ResdataKW instance of size nactive or nx*ny*nz. If the size is nactive the inactive cells will be filled with @default_value; hence the function will always write nx*ny*nz elements. - The data in the @ecl_kw argument can be of type integer, + The data in the @rd_kw argument can be of type integer, float, double or bool. In the case of bool the default value must be specified as 1 (True) or 0 (False). @@ -1268,15 +1278,15 @@ def write_grdecl(self, ecl_kw, pyfile, special_header=None, default_value=0): """ - if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize(): + if len(rd_kw) == self.getNumActive() or len(rd_kw) == self.getGlobalSize(): cfile = CFILE(pyfile) - self._fwrite_grdecl(ecl_kw, special_header, cfile, default_value) + self._fwrite_grdecl(rd_kw, special_header, cfile, default_value) else: raise ValueError( "Keyword: %s has invalid size(%d), must be either nactive:%d or nx*ny*nz:%d" % ( - ecl_kw.getName(), - len(ecl_kw), + rd_kw.getName(), + len(rd_kw), self.getNumActive(), self.getGlobalSize(), ) @@ -1291,7 +1301,7 @@ def compressed_kw_copy(self, kw): if len(kw) == self.getNumActive(): return kw.copy() elif len(kw) == self.getGlobalSize(): - kw_copy = EclKW(kw.getName(), self.getNumActive(), kw.data_type) + kw_copy = ResdataKW(kw.getName(), self.getNumActive(), kw.data_type) self._compressed_kw_copy(kw_copy, kw) return kw_copy else: @@ -1304,7 +1314,7 @@ def global_kw_copy(self, kw, default_value): if len(kw) == self.getGlobalSize(): return kw.copy() elif len(kw) == self.getNumActive(): - kw_copy = EclKW(kw.getName(), self.getGlobalSize(), kw.data_type) + kw_copy = ResdataKW(kw.getName(), self.getGlobalSize(), kw.data_type) kw_copy.assign(default_value) self._global_kw_copy(kw_copy, kw) return kw_copy @@ -1315,14 +1325,14 @@ def global_kw_copy(self, kw, default_value): ) def export_ACTNUM_kw(self): - actnum = EclKW("ACTNUM", self.getGlobalSize(), EclDataType.ECL_INT) + actnum = ResdataKW("ACTNUM", self.getGlobalSize(), ResdataDataType.RD_INT) self._init_actnum(actnum.getDataPtr()) return actnum def create_volume_keyword(self, active_size=True): - """Will create a EclKW initialized with cell volumes. + """Will create a ResdataKW initialized with cell volumes. - The purpose of this method is to create a EclKW instance which + The purpose of this method is to create a ResdataKW instance which is initialized with all the cell volumes, this can then be used to perform volume summation; i.e. to calculate the total oil volume: @@ -1395,7 +1405,7 @@ def export_data(self, index_frame, kw, default=0): else: raise ValueError("The keyword must have a 3D compatible length") - if kw.type is EclTypeEnum.ECL_INT_TYPE: + if kw.type is ResdataTypeEnum.RD_INT_TYPE: data = numpy.full(len(index), default, dtype=numpy.int32) self._export_data_as_int( len(index), @@ -1405,8 +1415,8 @@ def export_data(self, index_frame, kw, default=0): ) return data elif ( - kw.type is EclTypeEnum.ECL_FLOAT_TYPE - or kw.type is EclTypeEnum.ECL_DOUBLE_TYPE + kw.type is ResdataTypeEnum.RD_FLOAT_TYPE + or kw.type is ResdataTypeEnum.RD_DOUBLE_TYPE ): data = numpy.full(len(index), default, dtype=numpy.float64) self._export_data_as_double( @@ -1515,31 +1525,37 @@ def unit_system(self): return self._get_unit_system() -monkey_the_camel(EclGrid, "loadFromGrdecl", EclGrid.load_from_grdecl, classmethod) -monkey_the_camel(EclGrid, "loadFromFile", EclGrid.load_from_file, classmethod) -monkey_the_camel(EclGrid, "createRectangular", EclGrid.create_rectangular, classmethod) -monkey_the_camel(EclGrid, "dualGrid", EclGrid.dual_grid) -monkey_the_camel(EclGrid, "getDims", EclGrid.get_dims) -monkey_the_camel(EclGrid, "getNX", EclGrid.get_nx) -monkey_the_camel(EclGrid, "getNY", EclGrid.get_ny) -monkey_the_camel(EclGrid, "getNZ", EclGrid.get_nz) -monkey_the_camel(EclGrid, "getGlobalSize", EclGrid.get_global_size) -monkey_the_camel(EclGrid, "getNumActive", EclGrid.get_num_active) -monkey_the_camel(EclGrid, "getNumActiveFracture", EclGrid.get_num_active_fracture) -monkey_the_camel(EclGrid, "getBoundingBox2D", EclGrid.get_bounding_box_2d) -monkey_the_camel(EclGrid, "getName", EclGrid.get_name) -monkey_the_camel(EclGrid, "validCellGeometry", EclGrid.valid_cell_geometry) -monkey_the_camel(EclGrid, "getNodePos", EclGrid.get_node_pos) -monkey_the_camel(EclGrid, "getCellCorner", EclGrid.get_cell_corner) -monkey_the_camel(EclGrid, "getNodeXYZ", EclGrid.get_node_xyz) -monkey_the_camel(EclGrid, "getLayerXYZ", EclGrid.get_layer_xyz) -monkey_the_camel(EclGrid, "findCellXY", EclGrid.find_cell_xy) -monkey_the_camel(EclGrid, "findCellCornerXY", EclGrid.find_cell_corner_xy) -monkey_the_camel(EclGrid, "getCellDims", EclGrid.get_cell_dims) -monkey_the_camel(EclGrid, "getNumLGR", EclGrid.get_num_lgr) -monkey_the_camel(EclGrid, "createKW", EclGrid.create_kw) -monkey_the_camel(EclGrid, "create3D", EclGrid.create_3d) -monkey_the_camel(EclGrid, "compressedKWCopy", EclGrid.compressed_kw_copy) -monkey_the_camel(EclGrid, "globalKWCopy", EclGrid.global_kw_copy) -monkey_the_camel(EclGrid, "exportACTNUMKw", EclGrid.export_ACTNUM_kw) -monkey_the_camel(EclGrid, "createVolumeKeyword", EclGrid.create_volume_keyword) +monkey_the_camel( + ResdataGrid, "loadFromGrdecl", ResdataGrid.load_from_grdecl, classmethod +) +monkey_the_camel(ResdataGrid, "loadFromFile", ResdataGrid.load_from_file, classmethod) +monkey_the_camel( + ResdataGrid, "createRectangular", ResdataGrid.create_rectangular, classmethod +) +monkey_the_camel(ResdataGrid, "dualGrid", ResdataGrid.dual_grid) +monkey_the_camel(ResdataGrid, "getDims", ResdataGrid.get_dims) +monkey_the_camel(ResdataGrid, "getNX", ResdataGrid.get_nx) +monkey_the_camel(ResdataGrid, "getNY", ResdataGrid.get_ny) +monkey_the_camel(ResdataGrid, "getNZ", ResdataGrid.get_nz) +monkey_the_camel(ResdataGrid, "getGlobalSize", ResdataGrid.get_global_size) +monkey_the_camel(ResdataGrid, "getNumActive", ResdataGrid.get_num_active) +monkey_the_camel( + ResdataGrid, "getNumActiveFracture", ResdataGrid.get_num_active_fracture +) +monkey_the_camel(ResdataGrid, "getBoundingBox2D", ResdataGrid.get_bounding_box_2d) +monkey_the_camel(ResdataGrid, "getName", ResdataGrid.get_name) +monkey_the_camel(ResdataGrid, "validCellGeometry", ResdataGrid.valid_cell_geometry) +monkey_the_camel(ResdataGrid, "getNodePos", ResdataGrid.get_node_pos) +monkey_the_camel(ResdataGrid, "getCellCorner", ResdataGrid.get_cell_corner) +monkey_the_camel(ResdataGrid, "getNodeXYZ", ResdataGrid.get_node_xyz) +monkey_the_camel(ResdataGrid, "getLayerXYZ", ResdataGrid.get_layer_xyz) +monkey_the_camel(ResdataGrid, "findCellXY", ResdataGrid.find_cell_xy) +monkey_the_camel(ResdataGrid, "findCellCornerXY", ResdataGrid.find_cell_corner_xy) +monkey_the_camel(ResdataGrid, "getCellDims", ResdataGrid.get_cell_dims) +monkey_the_camel(ResdataGrid, "getNumLGR", ResdataGrid.get_num_lgr) +monkey_the_camel(ResdataGrid, "createKW", ResdataGrid.create_kw) +monkey_the_camel(ResdataGrid, "create3D", ResdataGrid.create_3d) +monkey_the_camel(ResdataGrid, "compressedKWCopy", ResdataGrid.compressed_kw_copy) +monkey_the_camel(ResdataGrid, "globalKWCopy", ResdataGrid.global_kw_copy) +monkey_the_camel(ResdataGrid, "exportACTNUMKw", ResdataGrid.export_ACTNUM_kw) +monkey_the_camel(ResdataGrid, "createVolumeKeyword", ResdataGrid.create_volume_keyword) diff --git a/python/resdata/grid/rd_grid_generator.py b/python/resdata/grid/rd_grid_generator.py index fa8284ef82..8f3a1bc6b5 100644 --- a/python/resdata/grid/rd_grid_generator.py +++ b/python/resdata/grid/rd_grid_generator.py @@ -1,12 +1,12 @@ import itertools, numpy from math import sqrt -from ecl import EclPrototype -from ecl.util.util import monkey_the_camel -from ecl.util.util import IntVector -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid +from resdata import ResdataPrototype +from resdata.util.util import monkey_the_camel +from resdata.util.util import IntVector +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid def flatten(l): @@ -22,7 +22,7 @@ def duplicate_inner(l): def construct_floatKW(name, values): - kw = EclKW(name, len(values), EclDataType.ECL_FLOAT) + kw = ResdataKW(name, len(values), ResdataDataType.RD_FLOAT) for i, value in enumerate(values): kw[i] = value return kw @@ -49,9 +49,9 @@ def pre_mapaxes_translation(translation, mapaxes): ) -class EclGridGenerator: - _alloc_rectangular = EclPrototype( - "ecl_grid_obj ecl_grid_alloc_rectangular(int, int, int, double, double, double, int*)", +class ResdataGridGenerator: + _alloc_rectangular = ResdataPrototype( + "rd_grid_obj rd_grid_alloc_rectangular(int, int, int, double, double, double, int*)", bind=False, ) @@ -63,7 +63,7 @@ def create_rectangular(cls, dims, dV, actnum=None): With the default value @actnum == None all cells will be active, """ if actnum is None: - ecl_grid = cls._alloc_rectangular( + rd_grid = cls._alloc_rectangular( dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], None ) else: @@ -79,16 +79,16 @@ def create_rectangular(cls, dims, dV, actnum=None): % (len(actnum), dims[0] * dims[1] * dims[2]) ) - ecl_grid = cls._alloc_rectangular( + rd_grid = cls._alloc_rectangular( dims[0], dims[1], dims[2], dV[0], dV[1], dV[2], actnum.getDataPtr() ) # If we have not succeeded in creatin the grid we *assume* the # error is due to a failed malloc. - if ecl_grid is None: + if rd_grid is None: raise MemoryError("Failed to allocated regualar grid") - return ecl_grid + return rd_grid @classmethod def create_single_cell_grid(cls, corners): @@ -104,12 +104,12 @@ def create_single_cell_grid(cls, corners): coord = flatten(flatten(coord)) def construct_floatKW(name, values): - kw = EclKW(name, len(values), EclDataType.ECL_FLOAT) + kw = ResdataKW(name, len(values), ResdataDataType.RD_FLOAT) for i in range(len(values)): kw[i] = values[i] return kw - grid = EclGrid.create( + grid = ResdataGrid.create( (1, 1, 1), construct_floatKW("ZCORN", zcorn), construct_floatKW("COORD", coord), @@ -288,7 +288,7 @@ def create_grid( particular, if set to False, all cells of the grid will be concave. @escape_origo_shift is used to prevent any cell of having corners in (0,0,z) - as there is a heuristic in ecl_grid.c that marks such cells as tainted. + as there is a heuristic in rd_grid.c that marks such cells as tainted. @faults decides if there are to be faults in the grid. @@ -329,7 +329,7 @@ def create_grid( dims, dV, escape_origo_shift, scale, translation, rotate, misalign ) - return EclGrid.create(dims, zcorn, coord, None) + return ResdataGrid.create(dims, zcorn, coord, None) @classmethod def __create_faults(cls, nx, ny, nz, zcorn, drop): @@ -564,7 +564,7 @@ def extract_actnum(cls, dims, actnum, ijk_bounds): new_actnum = flatten(new_actnum) cls.assert_actnum(new_nx, new_ny, new_nz, new_actnum) - actnumkw = EclKW("ACTNUM", len(new_actnum), EclDataType.ECL_INT) + actnumkw = ResdataKW("ACTNUM", len(new_actnum), ResdataDataType.RD_INT) for i, value in enumerate(new_actnum): actnumkw[i] = value @@ -637,7 +637,9 @@ def extract_subgrid( sdim = tuple([b - a + 1 for a, b in ijk_bounds]) sub_coord, sub_zcorn, sub_actnum = sub_data - return EclGrid.create(sdim, sub_zcorn, sub_coord, sub_actnum, mapaxes=mapaxes) + return ResdataGrid.create( + sdim, sub_zcorn, sub_coord, sub_actnum, mapaxes=mapaxes + ) @classmethod def extract_subgrid_data( @@ -757,8 +759,8 @@ def assert_decomposition_change(cls, ijk_bounds, decomposition_change): monkey_the_camel( - EclGridGenerator, + ResdataGridGenerator, "createRectangular", - EclGridGenerator.create_rectangular, + ResdataGridGenerator.create_rectangular, classmethod, ) diff --git a/python/resdata/grid/rd_region.py b/python/resdata/grid/rd_region.py index 904c3efa18..f5061d2b90 100644 --- a/python/resdata/grid/rd_region.py +++ b/python/resdata/grid/rd_region.py @@ -1,7 +1,7 @@ """ Module used to select cells based on many different criteria. -This module implements the class EclRegion which can be used to select +This module implements the class ResdataRegion which can be used to select cells in a grid matching a criteria. A wide range of different criteria are supported. Many of the special functions for implementing mathematical operations are implemented, so that regions can be @@ -15,15 +15,15 @@ from cwrap import BaseCClass -import ecl -from ecl.util.util import monkey_the_camel -from ecl.util.util import IntVector +import resdata +from resdata.util.util import monkey_the_camel +from resdata.util.util import IntVector -from ecl import EclPrototype -from ecl.grid.faults import Layer -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.util.geometry import CPolyline +from resdata import ResdataPrototype +from resdata.grid.faults import Layer +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.util.geometry import CPolyline def select_method(select): @@ -37,7 +37,7 @@ def select_method(select): Consider this example: - region = EclRegion( grid , False ) + region = ResdataRegion( grid , False ) region.select_islice(0, 5) # Selects all cells with i[0:5] region.select_jslice(0, 5) # Selects all cells with j[0:5] @@ -47,7 +47,7 @@ def select_method(select): second call the j selection will only be applied to the cells in i[0:5] interval: - region = EclRegion( grid , False ) + region = ResdataRegion( grid , False ) # Select all cells with i[0:5]: region.select_islice(0, 5) @@ -60,7 +60,7 @@ def select_method(select): def select_wrapper(self, *args, **kwargs): intersect = "intersect" in kwargs and kwargs["intersect"] if intersect: - new_region = EclRegion(self.grid, False) + new_region = ResdataRegion(self.grid, False) select(new_region, *args) self &= new_region @@ -70,241 +70,245 @@ def select_wrapper(self, *args, **kwargs): return select_wrapper -class EclRegion(BaseCClass): - TYPE_NAME = "ecl_region" - _alloc = EclPrototype("void* ecl_region_alloc( ecl_grid , bool )", bind=False) - _alloc_copy = EclPrototype("ecl_region_obj ecl_region_alloc_copy( ecl_region )") +class ResdataRegion(BaseCClass): + TYPE_NAME = "rd_region" + _alloc = ResdataPrototype("void* rd_region_alloc( rd_grid , bool )", bind=False) + _alloc_copy = ResdataPrototype("rd_region_obj rd_region_alloc_copy( rd_region )") - _set_kw_int = EclPrototype( - "void ecl_region_set_kw_int( ecl_region , ecl_kw , int, bool) " + _set_kw_int = ResdataPrototype( + "void rd_region_set_kw_int( rd_region , rd_kw , int, bool) " ) - _set_kw_float = EclPrototype( - "void ecl_region_set_kw_float( ecl_region , ecl_kw , float, bool ) " + _set_kw_float = ResdataPrototype( + "void rd_region_set_kw_float( rd_region , rd_kw , float, bool ) " ) - _set_kw_double = EclPrototype( - "void ecl_region_set_kw_double( ecl_region , ecl_kw , double , bool) " + _set_kw_double = ResdataPrototype( + "void rd_region_set_kw_double( rd_region , rd_kw , double , bool) " ) - _shift_kw_int = EclPrototype( - "void ecl_region_shift_kw_int( ecl_region , ecl_kw , int, bool) " + _shift_kw_int = ResdataPrototype( + "void rd_region_shift_kw_int( rd_region , rd_kw , int, bool) " ) - _shift_kw_float = EclPrototype( - "void ecl_region_shift_kw_float( ecl_region , ecl_kw , float, bool ) " + _shift_kw_float = ResdataPrototype( + "void rd_region_shift_kw_float( rd_region , rd_kw , float, bool ) " ) - _shift_kw_double = EclPrototype( - "void ecl_region_shift_kw_double( ecl_region , ecl_kw , double , bool) " + _shift_kw_double = ResdataPrototype( + "void rd_region_shift_kw_double( rd_region , rd_kw , double , bool) " ) - _scale_kw_int = EclPrototype( - "void ecl_region_scale_kw_int( ecl_region , ecl_kw , int, bool) " + _scale_kw_int = ResdataPrototype( + "void rd_region_scale_kw_int( rd_region , rd_kw , int, bool) " ) - _scale_kw_float = EclPrototype( - "void ecl_region_scale_kw_float( ecl_region , ecl_kw , float, bool ) " + _scale_kw_float = ResdataPrototype( + "void rd_region_scale_kw_float( rd_region , rd_kw , float, bool ) " ) - _scale_kw_double = EclPrototype( - "void ecl_region_scale_kw_double( ecl_region , ecl_kw , double , bool) " + _scale_kw_double = ResdataPrototype( + "void rd_region_scale_kw_double( rd_region , rd_kw , double , bool) " ) - _sum_kw_int = EclPrototype( - "int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) " + _sum_kw_int = ResdataPrototype( + "int rd_region_sum_kw_int( rd_region , rd_kw , bool) " ) - _sum_kw_float = EclPrototype( - "float ecl_region_sum_kw_float( ecl_region , ecl_kw , bool ) " + _sum_kw_float = ResdataPrototype( + "float rd_region_sum_kw_float( rd_region , rd_kw , bool ) " ) - _sum_kw_double = EclPrototype( - "double ecl_region_sum_kw_double( ecl_region , ecl_kw , bool) " + _sum_kw_double = ResdataPrototype( + "double rd_region_sum_kw_double( rd_region , rd_kw , bool) " ) - _sum_kw_bool = EclPrototype( - "int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) " + _sum_kw_bool = ResdataPrototype( + "int rd_region_sum_kw_int( rd_region , rd_kw , bool) " ) - _free = EclPrototype("void ecl_region_free( ecl_region )") - _reset = EclPrototype("void ecl_region_reset( ecl_region )") - _select_all = EclPrototype("void ecl_region_select_all( ecl_region )") - _deselect_all = EclPrototype("void ecl_region_deselect_all( ecl_region )") - _select_equal = EclPrototype( - "void ecl_region_select_equal( ecl_region , ecl_kw , int )" + _free = ResdataPrototype("void rd_region_free( rd_region )") + _reset = ResdataPrototype("void rd_region_reset( rd_region )") + _select_all = ResdataPrototype("void rd_region_select_all( rd_region )") + _deselect_all = ResdataPrototype("void rd_region_deselect_all( rd_region )") + _select_equal = ResdataPrototype( + "void rd_region_select_equal( rd_region , rd_kw , int )" ) - _deselect_equal = EclPrototype( - "void ecl_region_deselect_equal( ecl_region , ecl_kw , int)" + _deselect_equal = ResdataPrototype( + "void rd_region_deselect_equal( rd_region , rd_kw , int)" ) - _select_less = EclPrototype( - "void ecl_region_select_smaller( ecl_region , ecl_kw , float )" + _select_less = ResdataPrototype( + "void rd_region_select_smaller( rd_region , rd_kw , float )" ) - _deselect_less = EclPrototype( - "void ecl_region_deselect_smaller( ecl_region , ecl_kw , float )" + _deselect_less = ResdataPrototype( + "void rd_region_deselect_smaller( rd_region , rd_kw , float )" ) - _select_more = EclPrototype( - "void ecl_region_select_larger( ecl_region , ecl_kw , float )" + _select_more = ResdataPrototype( + "void rd_region_select_larger( rd_region , rd_kw , float )" ) - _deselect_more = EclPrototype( - "void ecl_region_deselect_larger( ecl_region , ecl_kw , float )" + _deselect_more = ResdataPrototype( + "void rd_region_deselect_larger( rd_region , rd_kw , float )" ) - _select_in_interval = EclPrototype( - "void ecl_region_select_in_interval( ecl_region, ecl_kw , float , float )" + _select_in_interval = ResdataPrototype( + "void rd_region_select_in_interval( rd_region, rd_kw , float , float )" ) - _deselect_in_interval = EclPrototype( - "void ecl_region_deselect_in_interval( ecl_region, ecl_kw, float , float )" + _deselect_in_interval = ResdataPrototype( + "void rd_region_deselect_in_interval( rd_region, rd_kw, float , float )" ) - _invert_selection = EclPrototype("void ecl_region_invert_selection( ecl_region )") + _invert_selection = ResdataPrototype("void rd_region_invert_selection( rd_region )") - _select_box = EclPrototype( - "void ecl_region_select_from_ijkbox(ecl_region , int , int , int , int , int , int)" + _select_box = ResdataPrototype( + "void rd_region_select_from_ijkbox(rd_region , int , int , int , int , int , int)" ) - _deselect_box = EclPrototype( - "void ecl_region_deselect_from_ijkbox(ecl_region , int , int , int , int , int , int)" + _deselect_box = ResdataPrototype( + "void rd_region_deselect_from_ijkbox(rd_region , int , int , int , int , int , int)" ) - _imul_kw = EclPrototype( - "void ecl_region_kw_imul( ecl_region , ecl_kw , ecl_kw , bool)" + _imul_kw = ResdataPrototype( + "void rd_region_kw_imul( rd_region , rd_kw , rd_kw , bool)" ) - _idiv_kw = EclPrototype( - "void ecl_region_kw_idiv( ecl_region , ecl_kw , ecl_kw , bool)" + _idiv_kw = ResdataPrototype( + "void rd_region_kw_idiv( rd_region , rd_kw , rd_kw , bool)" ) - _iadd_kw = EclPrototype( - "void ecl_region_kw_iadd( ecl_region , ecl_kw , ecl_kw , bool)" + _iadd_kw = ResdataPrototype( + "void rd_region_kw_iadd( rd_region , rd_kw , rd_kw , bool)" ) - _isub_kw = EclPrototype( - "void ecl_region_kw_isub( ecl_region , ecl_kw , ecl_kw , bool)" + _isub_kw = ResdataPrototype( + "void rd_region_kw_isub( rd_region , rd_kw , rd_kw , bool)" ) - _copy_kw = EclPrototype( - "void ecl_region_kw_copy( ecl_region , ecl_kw , ecl_kw , bool)" + _copy_kw = ResdataPrototype( + "void rd_region_kw_copy( rd_region , rd_kw , rd_kw , bool)" ) - _intersect = EclPrototype("void ecl_region_intersection( ecl_region , ecl_region )") - _combine = EclPrototype("void ecl_region_union( ecl_region , ecl_region )") - _subtract = EclPrototype("void ecl_region_subtract( ecl_region , ecl_region )") - _xor = EclPrototype("void ecl_region_xor( ecl_region , ecl_region )") - _get_kw_index_list = EclPrototype( - "int_vector_ref ecl_region_get_kw_index_list( ecl_region , ecl_kw , bool )" + _intersect = ResdataPrototype( + "void rd_region_intersection( rd_region , rd_region )" ) - _get_active_list = EclPrototype( - "int_vector_ref ecl_region_get_active_list( ecl_region )" + _combine = ResdataPrototype("void rd_region_union( rd_region , rd_region )") + _subtract = ResdataPrototype("void rd_region_subtract( rd_region , rd_region )") + _xor = ResdataPrototype("void rd_region_xor( rd_region , rd_region )") + _get_kw_index_list = ResdataPrototype( + "int_vector_ref rd_region_get_kw_index_list( rd_region , rd_kw , bool )" ) - _get_global_list = EclPrototype( - "int_vector_ref ecl_region_get_global_list( ecl_region )" + _get_active_list = ResdataPrototype( + "int_vector_ref rd_region_get_active_list( rd_region )" ) - _get_active_global = EclPrototype( - "int_vector_ref ecl_region_get_global_active_list( ecl_region )" + _get_global_list = ResdataPrototype( + "int_vector_ref rd_region_get_global_list( rd_region )" ) - _select_cmp_less = EclPrototype( - "void ecl_region_cmp_select_less( ecl_region , ecl_kw , ecl_kw)" + _get_active_global = ResdataPrototype( + "int_vector_ref rd_region_get_global_active_list( rd_region )" ) - _select_cmp_more = EclPrototype( - "void ecl_region_cmp_select_more( ecl_region , ecl_kw , ecl_kw)" + _select_cmp_less = ResdataPrototype( + "void rd_region_cmp_select_less( rd_region , rd_kw , rd_kw)" ) - _deselect_cmp_less = EclPrototype( - "void ecl_region_cmp_deselect_less( ecl_region , ecl_kw , ecl_kw)" + _select_cmp_more = ResdataPrototype( + "void rd_region_cmp_select_more( rd_region , rd_kw , rd_kw)" ) - _deselect_cmp_more = EclPrototype( - "void ecl_region_cmp_deselect_more( ecl_region , ecl_kw , ecl_kw)" + _deselect_cmp_less = ResdataPrototype( + "void rd_region_cmp_deselect_less( rd_region , rd_kw , rd_kw)" ) - _select_islice = EclPrototype( - "void ecl_region_select_i1i2( ecl_region , int , int )" + _deselect_cmp_more = ResdataPrototype( + "void rd_region_cmp_deselect_more( rd_region , rd_kw , rd_kw)" ) - _deselect_islice = EclPrototype( - "void ecl_region_deselect_i1i2( ecl_region , int , int )" + _select_islice = ResdataPrototype( + "void rd_region_select_i1i2( rd_region , int , int )" ) - _select_jslice = EclPrototype( - "void ecl_region_select_j1j2( ecl_region , int , int )" + _deselect_islice = ResdataPrototype( + "void rd_region_deselect_i1i2( rd_region , int , int )" ) - _deselect_jslice = EclPrototype( - "void ecl_region_deselect_j1j2( ecl_region , int , int )" + _select_jslice = ResdataPrototype( + "void rd_region_select_j1j2( rd_region , int , int )" ) - _select_kslice = EclPrototype( - "void ecl_region_select_k1k2( ecl_region , int , int )" + _deselect_jslice = ResdataPrototype( + "void rd_region_deselect_j1j2( rd_region , int , int )" ) - _deselect_kslice = EclPrototype( - "void ecl_region_deselect_k1k2( ecl_region , int , int )" + _select_kslice = ResdataPrototype( + "void rd_region_select_k1k2( rd_region , int , int )" ) - _select_deep_cells = EclPrototype( - "void ecl_region_select_deep_cells( ecl_region , double )" + _deselect_kslice = ResdataPrototype( + "void rd_region_deselect_k1k2( rd_region , int , int )" ) - _deselect_deep_cells = EclPrototype( - "void ecl_region_select_deep_cells( ecl_region , double )" + _select_deep_cells = ResdataPrototype( + "void rd_region_select_deep_cells( rd_region , double )" ) - _select_shallow_cells = EclPrototype( - "void ecl_region_select_shallow_cells( ecl_region , double )" + _deselect_deep_cells = ResdataPrototype( + "void rd_region_select_deep_cells( rd_region , double )" ) - _deselect_shallow_cells = EclPrototype( - "void ecl_region_select_shallow_cells( ecl_region , double )" + _select_shallow_cells = ResdataPrototype( + "void rd_region_select_shallow_cells( rd_region , double )" ) - _select_small = EclPrototype( - "void ecl_region_select_small_cells( ecl_region , double )" + _deselect_shallow_cells = ResdataPrototype( + "void rd_region_select_shallow_cells( rd_region , double )" ) - _deselect_small = EclPrototype( - "void ecl_region_deselect_small_cells( ecl_region , double )" + _select_small = ResdataPrototype( + "void rd_region_select_small_cells( rd_region , double )" ) - _select_large = EclPrototype( - "void ecl_region_select_large_cells( ecl_region , double )" + _deselect_small = ResdataPrototype( + "void rd_region_deselect_small_cells( rd_region , double )" ) - _deselect_large = EclPrototype( - "void ecl_region_deselect_large_cells( ecl_region , double )" + _select_large = ResdataPrototype( + "void rd_region_select_large_cells( rd_region , double )" ) - _select_thin = EclPrototype( - "void ecl_region_select_thin_cells( ecl_region , double )" + _deselect_large = ResdataPrototype( + "void rd_region_deselect_large_cells( rd_region , double )" ) - _deselect_thin = EclPrototype( - "void ecl_region_deselect_thin_cells( ecl_region , double )" + _select_thin = ResdataPrototype( + "void rd_region_select_thin_cells( rd_region , double )" ) - _select_thick = EclPrototype( - "void ecl_region_select_thick_cells( ecl_region , double )" + _deselect_thin = ResdataPrototype( + "void rd_region_deselect_thin_cells( rd_region , double )" ) - _deselect_thick = EclPrototype( - "void ecl_region_deselect_thick_cells( ecl_region , double )" + _select_thick = ResdataPrototype( + "void rd_region_select_thick_cells( rd_region , double )" ) - _select_active = EclPrototype("void ecl_region_select_active_cells( ecl_region )") - _select_inactive = EclPrototype( - "void ecl_region_select_inactive_cells( ecl_region )" + _deselect_thick = ResdataPrototype( + "void rd_region_deselect_thick_cells( rd_region , double )" ) - _deselect_active = EclPrototype( - "void ecl_region_deselect_active_cells( ecl_region )" + _select_active = ResdataPrototype("void rd_region_select_active_cells( rd_region )") + _select_inactive = ResdataPrototype( + "void rd_region_select_inactive_cells( rd_region )" ) - _deselect_inactive = EclPrototype( - "void ecl_region_deselect_inactive_cells( ecl_region )" + _deselect_active = ResdataPrototype( + "void rd_region_deselect_active_cells( rd_region )" ) - _select_above_plane = EclPrototype( - "void ecl_region_select_above_plane( ecl_region , double* , double* )" + _deselect_inactive = ResdataPrototype( + "void rd_region_deselect_inactive_cells( rd_region )" ) - _select_below_plane = EclPrototype( - "void ecl_region_select_below_plane( ecl_region , double* , double* )" + _select_above_plane = ResdataPrototype( + "void rd_region_select_above_plane( rd_region , double* , double* )" ) - _deselect_above_plane = EclPrototype( - "void ecl_region_deselect_above_plane( ecl_region, double* , double* )" + _select_below_plane = ResdataPrototype( + "void rd_region_select_below_plane( rd_region , double* , double* )" ) - _deselect_below_plane = EclPrototype( - "void ecl_region_deselect_below_plane( ecl_region, double* , double* )" + _deselect_above_plane = ResdataPrototype( + "void rd_region_deselect_above_plane( rd_region, double* , double* )" ) - _select_inside_polygon = EclPrototype( - "void ecl_region_select_inside_polygon( ecl_region , geo_polygon)" + _deselect_below_plane = ResdataPrototype( + "void rd_region_deselect_below_plane( rd_region, double* , double* )" ) - _select_outside_polygon = EclPrototype( - "void ecl_region_select_outside_polygon( ecl_region , geo_polygon)" + _select_inside_polygon = ResdataPrototype( + "void rd_region_select_inside_polygon( rd_region , geo_polygon)" ) - _deselect_inside_polygon = EclPrototype( - "void ecl_region_deselect_inside_polygon( ecl_region , geo_polygon)" + _select_outside_polygon = ResdataPrototype( + "void rd_region_select_outside_polygon( rd_region , geo_polygon)" ) - _deselect_outside_polygon = EclPrototype( - "void ecl_region_deselect_outside_polygon( ecl_region , geo_polygon)" + _deselect_inside_polygon = ResdataPrototype( + "void rd_region_deselect_inside_polygon( rd_region , geo_polygon)" ) - _set_name = EclPrototype("void ecl_region_set_name( ecl_region , char*)") - _get_name = EclPrototype("char* ecl_region_get_name( ecl_region )") - _contains_ijk = EclPrototype( - "void ecl_region_contains_ijk( ecl_region , int , int , int)" + _deselect_outside_polygon = ResdataPrototype( + "void rd_region_deselect_outside_polygon( rd_region , geo_polygon)" ) - _contains_global = EclPrototype( - "void ecl_region_contains_global( ecl_region, int )" + _set_name = ResdataPrototype("void rd_region_set_name( rd_region , char*)") + _get_name = ResdataPrototype("char* rd_region_get_name( rd_region )") + _contains_ijk = ResdataPrototype( + "void rd_region_contains_ijk( rd_region , int , int , int)" ) - _contains_active = EclPrototype( - "void ecl_region_contains_active( ecl_region , int )" + _contains_global = ResdataPrototype( + "void rd_region_contains_global( rd_region, int )" ) - _equal = EclPrototype("bool ecl_region_equal( ecl_region , ecl_region )") - _select_true = EclPrototype("void ecl_region_select_true( ecl_region , ecl_kw)") - _select_false = EclPrototype("void ecl_region_select_false( ecl_region , ecl_kw)") - _deselect_true = EclPrototype("void ecl_region_deselect_true( ecl_region , ecl_kw)") - _deselect_false = EclPrototype( - "void ecl_region_deselect_false( ecl_region , ecl_kw)" + _contains_active = ResdataPrototype( + "void rd_region_contains_active( rd_region , int )" ) - _select_from_layer = EclPrototype( - "void ecl_region_select_from_layer( ecl_region , layer , int , int)" + _equal = ResdataPrototype("bool rd_region_equal( rd_region , rd_region )") + _select_true = ResdataPrototype("void rd_region_select_true( rd_region , rd_kw)") + _select_false = ResdataPrototype("void rd_region_select_false( rd_region , rd_kw)") + _deselect_true = ResdataPrototype( + "void rd_region_deselect_true( rd_region , rd_kw)" ) - _deselect_from_layer = EclPrototype( - "void ecl_region_deselect_from_layer( ecl_region , layer , int , int)" + _deselect_false = ResdataPrototype( + "void rd_region_deselect_false( rd_region , rd_kw)" + ) + _select_from_layer = ResdataPrototype( + "void rd_region_select_from_layer( rd_region , layer , int , int)" + ) + _deselect_from_layer = ResdataPrototype( + "void rd_region_deselect_from_layer( rd_region , layer , int , int)" ) def __init__(self, grid, preselect): @@ -313,7 +317,7 @@ def __init__(self, grid, preselect): Will create a new region selector to select and deselect the cells in the grid given by @grid. The input argument @grid - should be a EclGrid instance. You can start with either all + should be a ResdataGrid instance. You can start with either all cells, or no cells, selected, depending on the value of @preselect. """ @@ -321,7 +325,7 @@ def __init__(self, grid, preselect): self.grid = grid self.active_index = False c_ptr = self._alloc(grid, preselect) - super(EclRegion, self).__init__(c_ptr) + super(ResdataRegion, self).__init__(c_ptr) def free(self): self._free() @@ -357,11 +361,11 @@ def __iand__(self, other): will eventually call this method. """ - if isinstance(other, EclRegion): + if isinstance(other, ResdataRegion): self._intersect(other) else: raise TypeError( - "Ecl region can only intersect with other EclRegion instances" + "Resdata region can only intersect with other ResdataRegion instances" ) return self @@ -372,11 +376,11 @@ def __isub__(self, other): Bound to reg -= reg2 """ - if isinstance(other, EclRegion): + if isinstance(other, ResdataRegion): self._subtract(other) else: raise TypeError( - "Ecl region can only subtract with other EclRegion instances" + "Resdata region can only subtract with other ResdataRegion instances" ) return self @@ -393,11 +397,11 @@ def __ior__(self, other): to update reg1 with the selections from reg2. """ - if isinstance(other, EclRegion): + if isinstance(other, ResdataRegion): self._combine(other) else: raise TypeError( - "Ecl region can only be combined with other EclRegion instances" + "Resdata region can only be combined with other ResdataRegion instances" ) return self @@ -486,123 +490,123 @@ def reset(self): ################################################################## @select_method - def select_more(self, ecl_kw, limit, intersect=False): + def select_more(self, rd_kw, limit, intersect=False): """ - Select all cells where keyword @ecl_kw is above @limit. + Select all cells where keyword @rd_kw is above @limit. This method is used to select all the cells where an arbitrary - field, contained in @ecl_kw, is above a limiting value - @limit. The EclKW instance must have either nactive or + field, contained in @rd_kw, is above a limiting value + @limit. The ResdataKW instance must have either nactive or nx*ny*nz elements; if this is not satisfied method will fail - hard. The datatype of @ecl_kw must be numeric, - i.e. ECL_INT_TYPE, ECL_DOUBLE_TYPE or ECL_FLOAT_TYPE. In the + hard. The datatype of @rd_kw must be numeric, + i.e. RD_INT_TYPE, RD_DOUBLE_TYPE or RD_FLOAT_TYPE. In the example below we select all the cells with water saturation above 0.85: - restart_file = ecl.EclFile( "ECLIPSE.X0067" ) + restart_file = ecl.ResdataFile( "ECLIPSE.X0067" ) swat_kw = restart_file["SWAT"][0] - grid = ecl.EclGrid( "ECLIPSE.EGRID" ) - region = ecl.EclRegion( grid , False ) + grid = ecl.ResdataGrid( "ECLIPSE.EGRID" ) + region = ecl.ResdataRegion( grid , False ) region.select_more( swat_kw , 0.85 ) """ - self._select_more(ecl_kw, limit) + self._select_more(rd_kw, limit) - def deselect_more(self, ecl_kw, limit): + def deselect_more(self, rd_kw, limit): """ Deselects cells with value above limit. See select_more() for further documentation. """ - self._deselect_more(ecl_kw, limit) + self._deselect_more(rd_kw, limit) @select_method - def select_less(self, ecl_kw, limit, intersect=False): + def select_less(self, rd_kw, limit, intersect=False): """ - Select all cells where keyword @ecl_kw is below @limit. + Select all cells where keyword @rd_kw is below @limit. See select_more() for further documentation. """ - self._select_less(ecl_kw, limit) + self._select_less(rd_kw, limit) - def deselect_less(self, ecl_kw, limit): + def deselect_less(self, rd_kw, limit): """ - Deselect all cells where keyword @ecl_kw is below @limit. + Deselect all cells where keyword @rd_kw is below @limit. See select_more() for further documentation. """ - self._deselect_less(ecl_kw, limit) + self._deselect_less(rd_kw, limit) @select_method - def select_equal(self, ecl_kw, value, intersect=False): + def select_equal(self, rd_kw, value, intersect=False): """ - Select all cells where @ecl_kw is equal to @value. + Select all cells where @rd_kw is equal to @value. - The EclKW instance @ecl_kw must be of size nactive or + The ResdataKW instance @rd_kw must be of size nactive or nx*ny*nz, and it must be of integer type; testing for equality is not supported for floating point numbers. In the example below we select all the cells in PVT regions 2 and 4: - init_file = ecl.EclFile( "ECLIPSE.INIT" ) + init_file = ecl.ResdataFile( "ECLIPSE.INIT" ) pvtnum_kw = init_file.iget_named_kw( "PVTNUM" , 0 ) - grid = ecl.EclGrid( "ECLIPSE.GRID" ) - region = ecl.EclRegion( grid , False ) + grid = ecl.ResdataGrid( "ECLIPSE.GRID" ) + region = ecl.ResdataRegion( grid , False ) region.select_equal( pvtnum_kw , 2 ) region.select_equal( pvtnum_kw , 4 ) """ - if not ecl_kw.data_type.is_int(): + if not rd_kw.data_type.is_int(): raise ValueError( "The select_equal method must have an integer valued keyword - got:%s" - % ecl_kw.typeName() + % rd_kw.typeName() ) - self._select_equal(ecl_kw, value) + self._select_equal(rd_kw, value) - def deselect_equal(self, ecl_kw, value): + def deselect_equal(self, rd_kw, value): """ - Select all cells where @ecl_kw is equal to @value. + Select all cells where @rd_kw is equal to @value. See select_equal() for further documentation. """ - if not ecl_kw.data_type.is_int(): + if not rd_kw.data_type.is_int(): raise ValueError( "The select_equal method must have an integer valued keyword - got:%s" - % ecl_kw.typeName() + % rd_kw.typeName() ) - self._deselect_equal(ecl_kw, value) + self._deselect_equal(rd_kw, value) @select_method - def select_in_range(self, ecl_kw, lower_limit, upper_limit, select=False): + def select_in_range(self, rd_kw, lower_limit, upper_limit, select=False): """ - Select all cells where @ecl_kw is in the half-open interval [ , ). + Select all cells where @rd_kw is in the half-open interval [ , ). - Will select all the cells where EclKW instance @ecl_kw has + Will select all the cells where ResdataKW instance @rd_kw has value in the half-open interval [@lower_limit , - @upper_limit). The input argument @ecl_kw must have size - nactive or nx*ny*nz, and it must be of type ECL_FLOAT_TYPE. + @upper_limit). The input argument @rd_kw must have size + nactive or nx*ny*nz, and it must be of type RD_FLOAT_TYPE. The following example will select all cells with porosity in the range [0.15,0.20): - init_file = ecl.EclFile( "ECLIPSE.INIT" ) + init_file = ecl.ResdataFile( "ECLIPSE.INIT" ) poro_kw = init_file.iget_named_kw( "PORO" , 0 ) - grid = ecl.EclGrid( "ECLIPSE.GRID" ) - region = ecl.EclRegion( grid , False ) + grid = ecl.ResdataGrid( "ECLIPSE.GRID" ) + region = ecl.ResdataRegion( grid , False ) region.select_in_range( poro_kw , 0.15, 0.20 ) """ - self._select_in_interval(ecl_kw, lower_limit, upper_limit) + self._select_in_interval(rd_kw, lower_limit, upper_limit) - def deselect_in_range(self, ecl_kw, lower_limit, upper_limit): + def deselect_in_range(self, rd_kw, lower_limit, upper_limit): """ - Deselect all cells where @ecl_kw is in the half-open interval [ , ). + Deselect all cells where @rd_kw is in the half-open interval [ , ). See select_in_range() for further documentation. """ - self._deselect_in_interval(ecl_kw, lower_limit, upper_limit) + self._deselect_in_interval(rd_kw, lower_limit, upper_limit) @select_method def select_cmp_less(self, kw1, kw2, intersect=False): @@ -613,11 +617,11 @@ def select_cmp_less(self, kw1, kw2, intersect=False): all the cells where the numerical value of @kw1 is less than the numerical value of @kw2. The ECLIPSE keywords @kw1 and @kw2 must both be of the same size, nactive or nx*ny*nz. In - addition they must both be of type type ECL_FLOAT_TYPE. In the + addition they must both be of type type RD_FLOAT_TYPE. In the example below we select all the cells where the pressure has dropped: - restart_file = ecl.EclFile("ECLIPSE.UNRST") + restart_file = ecl.ResdataFile("ECLIPSE.UNRST") pressure1 = restart_file.iget_named_kw( "PRESSURE" , 0) pressure2 = restart_file.iget_named_kw( "PRESSURE" , 100) @@ -941,18 +945,18 @@ def deselect_outside_polygon(self, points): self._deselect_outside_polygon(CPolyline(init_points=points)) @select_method - def select_true(self, ecl_kw, intersect=False): + def select_true(self, rd_kw, intersect=False): """ - Assume that input ecl_kw is a boolean mask. + Assume that input rd_kw is a boolean mask. """ - self._select_true(ecl_kw) + self._select_true(rd_kw) @select_method - def select_false(self, ecl_kw, intersect=False): + def select_false(self, rd_kw, intersect=False): """ - Assume that input ecl_kw is a boolean mask. + Assume that input rd_kw is a boolean mask. """ - self._select_false(ecl_kw) + self._select_false(rd_kw) @select_method def select_from_layer(self, layer, k, value, intersect=False): @@ -1001,14 +1005,14 @@ def iadd_kw(self, target_kw, delta_kw, force_active=False): """ The functions iadd_kw(), copy_kw(), set_kw(), scale_kw() and shift_kw() are not meant to be used as methods of the - EclRegion class (altough that is of course perfectly OK) - - rather a EclRegion instance is passed as an argument to an - EclKW method, and then that method "flips things around" and - calls one of these methods with the EclKW instance as - argument. This applies to all the EclKW methods which take an + ResdataRegion class (altough that is of course perfectly OK) - + rather a ResdataRegion instance is passed as an argument to an + ResdataKW method, and then that method "flips things around" and + calls one of these methods with the ResdataKW instance as + argument. This applies to all the ResdataKW methods which take an optional "mask" argument. """ - if isinstance(delta_kw, EclKW): + if isinstance(delta_kw, ResdataKW): if target_kw.assert_binary(delta_kw): self._iadd_kw(target_kw, delta_kw, force_active) else: @@ -1016,23 +1020,23 @@ def iadd_kw(self, target_kw, delta_kw, force_active=False): else: self.shift_kw(target_kw, delta_kw, force_active=force_active) - def shift_kw(self, ecl_kw, shift, force_active=False): + def shift_kw(self, rd_kw, shift, force_active=False): """ See usage documentation on iadd_kw(). """ self.scalar_apply_kw( - ecl_kw, + rd_kw, shift, { - EclDataType.ECL_INT: self._shift_kw_int, - EclDataType.ECL_FLOAT: self._shift_kw_float, - EclDataType.ECL_DOUBLE: self._shift_kw_double, + ResdataDataType.RD_INT: self._shift_kw_int, + ResdataDataType.RD_FLOAT: self._shift_kw_float, + ResdataDataType.RD_DOUBLE: self._shift_kw_double, }, force_active, ) def isub_kw(self, target_kw, delta_kw, force_active=False): - if isinstance(delta_kw, EclKW): + if isinstance(delta_kw, ResdataKW): if target_kw.assert_binary(delta_kw): self._isub_kw(target_kw, delta_kw, force_active) else: @@ -1040,23 +1044,23 @@ def isub_kw(self, target_kw, delta_kw, force_active=False): else: self.shift_kw(target_kw, -delta_kw, force_active=force_active) - def scale_kw(self, ecl_kw, scale, force_active=False): + def scale_kw(self, rd_kw, scale, force_active=False): """ See usage documentation on iadd_kw(). """ self.scalar_apply_kw( - ecl_kw, + rd_kw, scale, { - EclDataType.ECL_INT: self._scale_kw_int, - EclDataType.ECL_FLOAT: self._scale_kw_float, - EclDataType.ECL_DOUBLE: self._scale_kw_double, + ResdataDataType.RD_INT: self._scale_kw_int, + ResdataDataType.RD_FLOAT: self._scale_kw_float, + ResdataDataType.RD_DOUBLE: self._scale_kw_double, }, force_active, ) def imul_kw(self, target_kw, other, force_active=False): - if isinstance(other, EclKW): + if isinstance(other, ResdataKW): if target_kw.assert_binary(other): self._imul_kw(target_kw, other) else: @@ -1065,7 +1069,7 @@ def imul_kw(self, target_kw, other, force_active=False): self.scale_kw(target_kw, other, force_active) def idiv_kw(self, target_kw, other, force_active=False): - if isinstance(other, EclKW): + if isinstance(other, ResdataKW): if target_kw.assert_binary(other): self._idiv_kw(target_kw, other) else: @@ -1086,40 +1090,40 @@ def copy_kw(self, target_kw, src_kw, force_active=False): else: raise TypeError("Type mismatch") - def set_kw(self, ecl_kw, value, force_active=False): + def set_kw(self, rd_kw, value, force_active=False): """ See usage documentation on iadd_kw(). """ self.scalar_apply_kw( - ecl_kw, + rd_kw, value, { - EclDataType.ECL_INT: self._set_kw_int, - EclDataType.ECL_FLOAT: self._set_kw_float, - EclDataType.ECL_DOUBLE: self._set_kw_double, + ResdataDataType.RD_INT: self._set_kw_int, + ResdataDataType.RD_FLOAT: self._set_kw_float, + ResdataDataType.RD_DOUBLE: self._set_kw_double, }, force_active, ) def sum_kw(self, kw, force_active=False): data_type = kw.data_type - if data_type == EclDataType.ECL_FLOAT: + if data_type == ResdataDataType.RD_FLOAT: return self._sum_kw_float(kw, force_active) - if data_type == EclDataType.ECL_INT: + if data_type == ResdataDataType.RD_INT: return self._sum_kw_int(kw, force_active) - if data_type == EclDataType.ECL_DOUBLE: + if data_type == ResdataDataType.RD_DOUBLE: return self._sum_kw_double(kw, force_active) - if data_type == EclDataType.ECL_BOOL: + if data_type == ResdataDataType.RD_BOOL: return self._sum_kw_bool(kw, force_active) raise ValueError("sum_kw only supported for; INT/FLOAT/DOUBLE/BOOL") ################################################################# - def ecl_region_instance(self): + def rd_region_instance(self): """ Helper function (attribute) to support run-time typechecking. """ @@ -1176,8 +1180,8 @@ def contains_active(self, active_index): """ return self._contains_active(active_index) - def kw_index_list(self, ecl_kw, force_active): - c_ptr = self._get_kw_index_list(ecl_kw, force_active) + def kw_index_list(self, rd_kw, force_active): + c_ptr = self._get_kw_index_list(rd_kw, force_active) index_list = IntVector.createCReference(c_ptr, self) return index_list @@ -1192,11 +1196,11 @@ def set_name(self, name): self._set_name(name) -monkey_the_camel(EclRegion, "selectTrue", EclRegion.select_true) -monkey_the_camel(EclRegion, "selectFalse", EclRegion.select_false) -monkey_the_camel(EclRegion, "selectFromLayer", EclRegion.select_from_layer) -monkey_the_camel(EclRegion, "getActiveList", EclRegion.get_active_list) -monkey_the_camel(EclRegion, "getGlobalList", EclRegion.get_global_list) -monkey_the_camel(EclRegion, "getIJKList", EclRegion.get_ijk_list) -monkey_the_camel(EclRegion, "getName", EclRegion.get_name) -monkey_the_camel(EclRegion, "setName", EclRegion.set_name) +monkey_the_camel(ResdataRegion, "selectTrue", ResdataRegion.select_true) +monkey_the_camel(ResdataRegion, "selectFalse", ResdataRegion.select_false) +monkey_the_camel(ResdataRegion, "selectFromLayer", ResdataRegion.select_from_layer) +monkey_the_camel(ResdataRegion, "getActiveList", ResdataRegion.get_active_list) +monkey_the_camel(ResdataRegion, "getGlobalList", ResdataRegion.get_global_list) +monkey_the_camel(ResdataRegion, "getIJKList", ResdataRegion.get_ijk_list) +monkey_the_camel(ResdataRegion, "getName", ResdataRegion.get_name) +monkey_the_camel(ResdataRegion, "setName", ResdataRegion.set_name) diff --git a/python/resdata/rd_type.py b/python/resdata/rd_type.py index e978f58ae5..a545774326 100644 --- a/python/resdata/rd_type.py +++ b/python/resdata/rd_type.py @@ -1,57 +1,57 @@ from cwrap import BaseCClass, BaseCEnum -from ecl import EclPrototype +from resdata import ResdataPrototype -class EclTypeEnum(BaseCEnum): - TYPE_NAME = "ecl_type_enum" - ECL_CHAR_TYPE = None - ECL_FLOAT_TYPE = None - ECL_DOUBLE_TYPE = None - ECL_INT_TYPE = None - ECL_BOOL_TYPE = None - ECL_MESS_TYPE = None - ECL_STRING_TYPE = None +class ResdataTypeEnum(BaseCEnum): + TYPE_NAME = "rd_type_enum" + RD_CHAR_TYPE = None + RD_FLOAT_TYPE = None + RD_DOUBLE_TYPE = None + RD_INT_TYPE = None + RD_BOOL_TYPE = None + RD_MESS_TYPE = None + RD_STRING_TYPE = None -EclTypeEnum.addEnum("ECL_CHAR_TYPE", 0) -EclTypeEnum.addEnum("ECL_FLOAT_TYPE", 1) -EclTypeEnum.addEnum("ECL_DOUBLE_TYPE", 2) -EclTypeEnum.addEnum("ECL_INT_TYPE", 3) -EclTypeEnum.addEnum("ECL_BOOL_TYPE", 4) -EclTypeEnum.addEnum("ECL_MESS_TYPE", 5) -EclTypeEnum.addEnum("ECL_STRING_TYPE", 7) +ResdataTypeEnum.addEnum("RD_CHAR_TYPE", 0) +ResdataTypeEnum.addEnum("RD_FLOAT_TYPE", 1) +ResdataTypeEnum.addEnum("RD_DOUBLE_TYPE", 2) +ResdataTypeEnum.addEnum("RD_INT_TYPE", 3) +ResdataTypeEnum.addEnum("RD_BOOL_TYPE", 4) +ResdataTypeEnum.addEnum("RD_MESS_TYPE", 5) +ResdataTypeEnum.addEnum("RD_STRING_TYPE", 7) # ----------------------------------------------------------------- -class EclDataType(BaseCClass): - TYPE_NAME = "ecl_data_type" +class ResdataDataType(BaseCClass): + TYPE_NAME = "rd_data_type" - _alloc = EclPrototype( - "void* ecl_type_alloc_python(ecl_type_enum, size_t)", bind=False + _alloc = ResdataPrototype( + "void* rd_type_alloc_python(rd_type_enum, size_t)", bind=False ) - _alloc_from_type = EclPrototype( - "void* ecl_type_alloc_from_type_python(ecl_type_enum)", bind=False + _alloc_from_type = ResdataPrototype( + "void* rd_type_alloc_from_type_python(rd_type_enum)", bind=False ) - _alloc_from_name = EclPrototype( - "void* ecl_type_alloc_from_name_python(char*)", bind=False + _alloc_from_name = ResdataPrototype( + "void* rd_type_alloc_from_name_python(char*)", bind=False ) - _free = EclPrototype("void ecl_type_free_python(ecl_data_type)") - _get_type = EclPrototype("ecl_type_enum ecl_type_get_type_python(ecl_data_type)") - _get_element_size = EclPrototype( - "size_t ecl_type_get_sizeof_iotype_python(ecl_data_type)" + _free = ResdataPrototype("void rd_type_free_python(rd_data_type)") + _get_type = ResdataPrototype("rd_type_enum rd_type_get_type_python(rd_data_type)") + _get_element_size = ResdataPrototype( + "size_t rd_type_get_sizeof_iotype_python(rd_data_type)" ) - _is_int = EclPrototype("bool ecl_type_is_int_python(ecl_data_type)") - _is_char = EclPrototype("bool ecl_type_is_char_python(ecl_data_type)") - _is_float = EclPrototype("bool ecl_type_is_float_python(ecl_data_type)") - _is_double = EclPrototype("bool ecl_type_is_double_python(ecl_data_type)") - _is_mess = EclPrototype("bool ecl_type_is_mess_python(ecl_data_type)") - _is_bool = EclPrototype("bool ecl_type_is_bool_python(ecl_data_type)") - _is_string = EclPrototype("bool ecl_type_is_string_python(ecl_data_type)") - _get_name = EclPrototype("char* ecl_type_alloc_name_python(ecl_data_type)") - _is_numeric = EclPrototype("bool ecl_type_is_numeric_python(ecl_data_type)") - _is_equal = EclPrototype( - "bool ecl_type_is_equal_python(ecl_data_type, ecl_data_type)" + _is_int = ResdataPrototype("bool rd_type_is_int_python(rd_data_type)") + _is_char = ResdataPrototype("bool rd_type_is_char_python(rd_data_type)") + _is_float = ResdataPrototype("bool rd_type_is_float_python(rd_data_type)") + _is_double = ResdataPrototype("bool rd_type_is_double_python(rd_data_type)") + _is_mess = ResdataPrototype("bool rd_type_is_mess_python(rd_data_type)") + _is_bool = ResdataPrototype("bool rd_type_is_bool_python(rd_data_type)") + _is_string = ResdataPrototype("bool rd_type_is_string_python(rd_data_type)") + _get_name = ResdataPrototype("char* rd_type_alloc_name_python(rd_data_type)") + _is_numeric = ResdataPrototype("bool rd_type_is_numeric_python(rd_data_type)") + _is_equal = ResdataPrototype( + "bool rd_type_is_equal_python(rd_data_type, rd_data_type)" ) def __init__(self, type_enum=None, element_size=None, type_name=None): @@ -64,7 +64,7 @@ def __init__(self, type_enum=None, element_size=None, type_name=None): else: c_ptr = self._alloc(type_enum, element_size) - super(EclDataType, self).__init__(c_ptr) + super(ResdataDataType, self).__init__(c_ptr) def _assert_valid_arguments(self, type_enum, element_size, type_name): if type_name is not None: @@ -78,10 +78,10 @@ def _assert_valid_arguments(self, type_enum, element_size, type_name): elif type_enum is None: raise ValueError("Both type_enum and type_name is None!") - elif type_enum == EclTypeEnum.ECL_STRING_TYPE: + elif type_enum == ResdataTypeEnum.RD_STRING_TYPE: if element_size is None: raise ValueError( - "When creating an ECL_STRING one must " + "provide an element size!" + "When creating an RD_STRING one must " + "provide an element size!" ) if not (0 <= element_size <= 999): @@ -145,9 +145,9 @@ def __hash__(self): @classmethod def create_from_type_name(cls, name): - return EclDataType(type_name=name) + return ResdataDataType(type_name=name) - # Enables one to fetch a type as EclDataType.ECL_XXXX + # Enables one to fetch a type as ResdataDataType.RD_XXXX class classproperty(object): def __init__(self, fget): self.fget = fget @@ -156,29 +156,29 @@ def __get__(self, owner_self, owner_cls): return self.fget(owner_cls) @classproperty - def ECL_INT(cls): - return EclDataType(EclTypeEnum.ECL_INT_TYPE) + def RD_INT(cls): + return ResdataDataType(ResdataTypeEnum.RD_INT_TYPE) @classproperty - def ECL_FLOAT(cls): - return EclDataType(EclTypeEnum.ECL_FLOAT_TYPE) + def RD_FLOAT(cls): + return ResdataDataType(ResdataTypeEnum.RD_FLOAT_TYPE) @classproperty - def ECL_DOUBLE(cls): - return EclDataType(EclTypeEnum.ECL_DOUBLE_TYPE) + def RD_DOUBLE(cls): + return ResdataDataType(ResdataTypeEnum.RD_DOUBLE_TYPE) @classproperty - def ECL_BOOL(cls): - return EclDataType(EclTypeEnum.ECL_BOOL_TYPE) + def RD_BOOL(cls): + return ResdataDataType(ResdataTypeEnum.RD_BOOL_TYPE) @classproperty - def ECL_MESS(cls): - return EclDataType(EclTypeEnum.ECL_MESS_TYPE) + def RD_MESS(cls): + return ResdataDataType(ResdataTypeEnum.RD_MESS_TYPE) @classproperty - def ECL_CHAR(cls): - return EclDataType(EclTypeEnum.ECL_CHAR_TYPE) + def RD_CHAR(cls): + return ResdataDataType(ResdataTypeEnum.RD_CHAR_TYPE) @classmethod - def ECL_STRING(cls, elem_size): - return EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size) + def RD_STRING(cls, elem_size): + return ResdataDataType(ResdataTypeEnum.RD_STRING_TYPE, elem_size) diff --git a/python/resdata/rd_util.py b/python/resdata/rd_util.py index cd018d5fa6..d7038d08e9 100644 --- a/python/resdata/rd_util.py +++ b/python/resdata/rd_util.py @@ -1,109 +1,107 @@ """ -Constants from the header ecl_util.h - some stateless functions. +Constants from the header rd_util.h - some stateless functions. This module does not contain any class definitions; it mostly consists -of enum definitions/values from ecl_util.h; the enum values are +of enum definitions/values from rd_util.h; the enum values are extracted from the shared library in a semi-automagic manner using the BaseCEnum class from cwrap. In addition to the enum definitions there are a few stateless -functions from ecl_util.c which are not bound to any class type. +functions from rd_util.c which are not bound to any class type. """ from __future__ import absolute_import import ctypes from cwrap import BaseCEnum -from ecl.util.util import monkey_the_camel -from ecl import EclPrototype - - -class EclFileEnum(BaseCEnum): - TYPE_NAME = "ecl_file_enum" - ECL_OTHER_FILE = None - ECL_RESTART_FILE = None - ECL_UNIFIED_RESTART_FILE = None - ECL_SUMMARY_FILE = None - ECL_UNIFIED_SUMMARY_FILE = None - ECL_GRID_FILE = None - ECL_EGRID_FILE = None - ECL_INIT_FILE = None - ECL_RFT_FILE = None - ECL_DATA_FILE = None - - -EclFileEnum.addEnum("ECL_OTHER_FILE", 0) -EclFileEnum.addEnum("ECL_RESTART_FILE", 1) -EclFileEnum.addEnum("ECL_UNIFIED_RESTART_FILE", 2) -EclFileEnum.addEnum("ECL_SUMMARY_FILE", 4) -EclFileEnum.addEnum("ECL_UNIFIED_SUMMARY_FILE", 8) -EclFileEnum.addEnum("ECL_SUMMARY_HEADER_FILE", 16) -EclFileEnum.addEnum("ECL_GRID_FILE", 32) -EclFileEnum.addEnum("ECL_EGRID_FILE", 64) -EclFileEnum.addEnum("ECL_INIT_FILE", 128) -EclFileEnum.addEnum("ECL_RFT_FILE", 256) -EclFileEnum.addEnum("ECL_DATA_FILE", 512) +from resdata.util.util import monkey_the_camel +from resdata import ResdataPrototype + + +class ResdataFileEnum(BaseCEnum): + TYPE_NAME = "rd_file_enum" + RD_OTHER_FILE = None + RD_RESTART_FILE = None + RD_UNIFIED_RESTART_FILE = None + RD_SUMMARY_FILE = None + RD_UNIFIED_SUMMARY_FILE = None + RD_GRID_FILE = None + RD_EGRID_FILE = None + RD_INIT_FILE = None + RD_RFT_FILE = None + RD_DATA_FILE = None + + +ResdataFileEnum.addEnum("RD_OTHER_FILE", 0) +ResdataFileEnum.addEnum("RD_RESTART_FILE", 1) +ResdataFileEnum.addEnum("RD_UNIFIED_RESTART_FILE", 2) +ResdataFileEnum.addEnum("RD_SUMMARY_FILE", 4) +ResdataFileEnum.addEnum("RD_UNIFIED_SUMMARY_FILE", 8) +ResdataFileEnum.addEnum("RD_SUMMARY_HEADER_FILE", 16) +ResdataFileEnum.addEnum("RD_GRID_FILE", 32) +ResdataFileEnum.addEnum("RD_EGRID_FILE", 64) +ResdataFileEnum.addEnum("RD_INIT_FILE", 128) +ResdataFileEnum.addEnum("RD_RFT_FILE", 256) +ResdataFileEnum.addEnum("RD_DATA_FILE", 512) # ----------------------------------------------------------------- -class EclPhaseEnum(BaseCEnum): - TYPE_NAME = "ecl_phase_enum" - ECL_OIL_PHASE = None - ECL_GAS_PHASE = None - ECL_WATER_PHASE = None +class ResdataPhaseEnum(BaseCEnum): + TYPE_NAME = "rd_phase_enum" + RD_OIL_PHASE = None + RD_GAS_PHASE = None + RD_WATER_PHASE = None -EclPhaseEnum.addEnum("ECL_OIL_PHASE", 1) -EclPhaseEnum.addEnum("ECL_GAS_PHASE", 2) -EclPhaseEnum.addEnum("ECL_WATER_PHASE", 4) +ResdataPhaseEnum.addEnum("RD_OIL_PHASE", 1) +ResdataPhaseEnum.addEnum("RD_GAS_PHASE", 2) +ResdataPhaseEnum.addEnum("RD_WATER_PHASE", 4) # ----------------------------------------------------------------- -class EclUnitTypeEnum(BaseCEnum): - TYPE_NAME = "ecl_unit_enum" +class ResdataUnitTypeEnum(BaseCEnum): + TYPE_NAME = "rd_unit_enum" - ECL_METRIC_UNITS = None - ECL_FIELD_UNITS = None - ECL_LAB_UNITS = None - ECL_PVT_M_UNITS = None + RD_METRIC_UNITS = None + RD_FIELD_UNITS = None + RD_LAB_UNITS = None + RD_PVT_M_UNITS = None -EclUnitTypeEnum.addEnum("ECL_METRIC_UNITS", 1) -EclUnitTypeEnum.addEnum("ECL_FIELD_UNITS", 2) -EclUnitTypeEnum.addEnum("ECL_LAB_UNITS", 3) -EclUnitTypeEnum.addEnum("ECL_PVT_M_UNITS", 4) +ResdataUnitTypeEnum.addEnum("RD_METRIC_UNITS", 1) +ResdataUnitTypeEnum.addEnum("RD_FIELD_UNITS", 2) +ResdataUnitTypeEnum.addEnum("RD_LAB_UNITS", 3) +ResdataUnitTypeEnum.addEnum("RD_PVT_M_UNITS", 4) # ----------------------------------------------------------------- -class EclFileFlagEnum(BaseCEnum): - TYPE_NAME = "ecl_file_flag_enum" - ECL_FILE_DEFAULT = None - ECL_FILE_CLOSE_STREAM = None - ECL_FILE_WRITABLE = None +class ResdataFileFlagEnum(BaseCEnum): + TYPE_NAME = "rd_file_flag_enum" + RD_FILE_DEFAULT = None + RD_FILE_CLOSE_STREAM = None + RD_FILE_WRITABLE = None -EclFileFlagEnum.addEnum("ECL_FILE_DEFAULT", 0) -EclFileFlagEnum.addEnum("ECL_FILE_CLOSE_STREAM", 1) -EclFileFlagEnum.addEnum("ECL_FILE_WRITABLE", 2) +ResdataFileFlagEnum.addEnum("RD_FILE_DEFAULT", 0) +ResdataFileFlagEnum.addEnum("RD_FILE_CLOSE_STREAM", 1) +ResdataFileFlagEnum.addEnum("RD_FILE_WRITABLE", 2) # ----------------------------------------------------------------- -class EclUtil(object): - _get_num_cpu = EclPrototype("int ecl_util_get_num_cpu(char*)", bind=False) - _get_file_type = EclPrototype( - "ecl_file_enum ecl_util_get_file_type(char*, bool*, int*)", bind=False - ) - _get_start_date = EclPrototype("time_t ecl_util_get_start_date(char*)", bind=False) - _get_report_step = EclPrototype( - "int ecl_util_filename_report_nr(char*)", bind=False +class ResdataUtil(object): + _get_num_cpu = ResdataPrototype("int rd_get_num_cpu(char*)", bind=False) + _get_file_type = ResdataPrototype( + "rd_file_enum rd_get_file_type(char*, bool*, int*)", bind=False ) + _get_start_date = ResdataPrototype("time_t rd_get_start_date(char*)", bind=False) + _get_report_step = ResdataPrototype("int rd_filename_report_nr(char*)", bind=False) @staticmethod def get_num_cpu(datafile): @@ -114,30 +112,30 @@ def get_num_cpu(datafile): number of CPUs required. Will return one if no PARALLELL keyword is found. """ - return EclUtil._get_num_cpu(datafile) + return ResdataUtil._get_num_cpu(datafile) @staticmethod def get_file_type(filename): """ Will inspect an ECLIPSE filename and return an integer type flag. """ - file_type, fmt, step = EclUtil.inspectExtension(filename) + file_type, fmt, step = ResdataUtil.inspectExtension(filename) return file_type @staticmethod def get_start_date(datafile): - return EclUtil._get_start_date(datafile).datetime() + return ResdataUtil._get_start_date(datafile).datetime() @staticmethod def inspect_extension(filename): """Will inspect an ECLIPSE filename and return a tuple consisting of - file type (EclFileEnum), a bool for formatted or not, and an + file type (ResdataFileEnum), a bool for formatted or not, and an integer for the step number. """ fmt_file = ctypes.c_bool() report_step = ctypes.c_int(-1) - file_type = EclUtil._get_file_type( + file_type = ResdataUtil._get_file_type( filename, ctypes.byref(fmt_file), ctypes.byref(report_step) ) if report_step.value == -1: @@ -149,16 +147,18 @@ def inspect_extension(filename): @staticmethod def report_step(filename): - report_step = EclUtil._get_report_step(filename) + report_step = ResdataUtil._get_report_step(filename) if report_step < 0: raise ValueError("Could not infer report step from: %s" % filename) return report_step -get_num_cpu = EclUtil.get_num_cpu -get_file_type = EclUtil.get_file_type -get_start_date = EclUtil.get_start_date +get_num_cpu = ResdataUtil.get_num_cpu +get_file_type = ResdataUtil.get_file_type +get_start_date = ResdataUtil.get_start_date -monkey_the_camel(EclUtil, "inspectExtension", EclUtil.inspect_extension, staticmethod) -monkey_the_camel(EclUtil, "reportStep", EclUtil.report_step, staticmethod) +monkey_the_camel( + ResdataUtil, "inspectExtension", ResdataUtil.inspect_extension, staticmethod +) +monkey_the_camel(ResdataUtil, "reportStep", ResdataUtil.report_step, staticmethod) diff --git a/python/resdata/resdata_info_build.py.in b/python/resdata/resdata_info_build.py.in index 129af6cf43..55b5ac2cf0 100644 --- a/python/resdata/resdata_info_build.py.in +++ b/python/resdata/resdata_info_build.py.in @@ -2,8 +2,8 @@ class ResdataInfo(object): lib_path = "${LIBRARY_OUTPUT_PATH}" - so_version = "${ECL_BINARY_POSTFIX}" - __version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + so_version = "${RD_BINARY_POSTFIX}" + __version__ = "${RD_VERSION_MAJOR}.${RD_VERSION_MINOR}.${RD_VERSION_MICRO}" def __init__(self): pass diff --git a/python/resdata/resdata_info_install.py.in b/python/resdata/resdata_info_install.py.in index b37ba12c85..29c317cc63 100644 --- a/python/resdata/resdata_info_install.py.in +++ b/python/resdata/resdata_info_install.py.in @@ -2,8 +2,8 @@ class ResdataInfo(object): lib_path = "../../../../${CMAKE_INSTALL_LIBDIR}" - so_version = "${ECL_BINARY_POSTFIX}" - __version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + so_version = "${RD_BINARY_POSTFIX}" + __version__ = "${RD_VERSION_MAJOR}.${RD_VERSION_MINOR}.${RD_VERSION_MICRO}" def __init__(self): pass diff --git a/python/resdata/resfile/CMakeLists.txt b/python/resdata/resfile/CMakeLists.txt index b720f6aab1..0321d989fb 100644 --- a/python/resdata/resfile/CMakeLists.txt +++ b/python/resdata/resfile/CMakeLists.txt @@ -1,13 +1,13 @@ set(PYTHON_SOURCES __init__.py - ecl_3d_file.py - ecl_file.py - ecl_file_view.py - ecl_init_file.py - ecl_restart_file.py - ecl_kw.py + rd_3d_file.py + rd_file.py + rd_file_view.py + rd_init_file.py + rd_restart_file.py + rd_kw.py fortio.py - ecl_3dkw.py) + rd_3dkw.py) -add_python_package("python.ecl.eclfile" ${PYTHON_INSTALL_PREFIX}/ecl/eclfile +add_python_package("python.ecl.eclfile" ${PYTHON_INSTALL_PREFIX}/resdata/eclfile "${PYTHON_SOURCES}" True) diff --git a/python/resdata/resfile/__init__.py b/python/resdata/resfile/__init__.py index ee2ea9f7a4..0e7bcbd676 100644 --- a/python/resdata/resfile/__init__.py +++ b/python/resdata/resfile/__init__.py @@ -5,25 +5,25 @@ fortio/FortIO: This is functionality to read and write binary fortran files. - ecl_kw/EclKW: This class holds one ECLIPSE keyword, like SWAT, in + rd_kw/ResdataKW: This class holds one ECLIPSE keyword, like SWAT, in restart format. - ecl_type/EclDataType: This class is used to represent the data type - of the elements in EclKW. + rd_type/ResdataDataType: This class is used to represent the data type + of the elements in ResdataKW. - ecl_file/EclFile: This class is used to load an ECLIPSE file in + rd_file/ResdataFile: This class is used to load an ECLIPSE file in restart format, alternatively only parts of the file can be - loaded. Internally it consists of a collection of EclKW + loaded. Internally it consists of a collection of ResdataKW instances. """ -import ecl.util.util +import resdata.util.util from .fortio import FortIO, openFortIO -from .ecl_kw import EclKW -from .ecl_file_view import EclFileView -from .ecl_file import EclFile, openEclFile -from .ecl_3dkw import Ecl3DKW -from .ecl_3d_file import Ecl3DFile -from .ecl_init_file import EclInitFile -from .ecl_restart_file import EclRestartFile +from .rd_kw import ResdataKW +from .rd_file_view import ResdataFileView +from .rd_file import ResdataFile, openResdataFile +from .rd_3dkw import Resdata3DKW +from .rd_3d_file import Resdata3DFile +from .rd_init_file import ResdataInitFile +from .rd_restart_file import ResdataRestartFile diff --git a/python/resdata/resfile/fortio.py b/python/resdata/resfile/fortio.py index b489e59b1d..2262f3f706 100644 --- a/python/resdata/resfile/fortio.py +++ b/python/resdata/resfile/fortio.py @@ -25,8 +25,8 @@ import os from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata import ResdataPrototype class FortIO(BaseCClass): @@ -37,28 +37,28 @@ class FortIO(BaseCClass): READ_AND_WRITE_MODE = 3 APPEND_MODE = 4 - _open_reader = EclPrototype( + _open_reader = ResdataPrototype( "void* fortio_open_reader(char*, bool, bool)", bind=False ) - _open_writer = EclPrototype( + _open_writer = ResdataPrototype( "void* fortio_open_writer(char*, bool, bool)", bind=False ) - _open_readwrite = EclPrototype( + _open_readwrite = ResdataPrototype( "void* fortio_open_readwrite(char*, bool, bool)", bind=False ) - _open_append = EclPrototype( + _open_append = ResdataPrototype( "void* fortio_open_append(char*, bool, bool)", bind=False ) - _guess_fortran = EclPrototype( + _guess_fortran = ResdataPrototype( "bool fortio_looks_like_fortran_file(char*, bool)", bind=False ) - _write_record = EclPrototype("void fortio_fwrite_record(fortio, char*, int)") - _get_position = EclPrototype("long fortio_ftell(fortio)") - _seek = EclPrototype("void fortio_fseek(fortio, long, int)") - _close = EclPrototype("bool fortio_fclose(fortio)") - _truncate = EclPrototype("bool fortio_ftruncate(fortio, long)") - _filename = EclPrototype("char* fortio_filename_ref(fortio)") + _write_record = ResdataPrototype("void fortio_fwrite_record(fortio, char*, int)") + _get_position = ResdataPrototype("long fortio_ftell(fortio)") + _seek = ResdataPrototype("void fortio_fseek(fortio, long, int)") + _close = ResdataPrototype("bool fortio_fclose(fortio)") + _truncate = ResdataPrototype("bool fortio_ftruncate(fortio, long)") + _filename = ResdataPrototype("char* fortio_filename_ref(fortio)") def __init__( self, file_name, mode=READ_MODE, fmt_file=False, endian_flip_header=True @@ -82,9 +82,9 @@ def __init__( all the pressure keywords to another file: import sys - from ecl.ecl import FortIO, EclFile + from resdata.ecl import FortIO, ResdataFile - rst_file = EclFile(sys.argv[1]) + rst_file = ResdataFile(sys.argv[1]) fortio = FortIO("PRESSURE", mode=FortIO.WRITE_MODE) for kw in rst_file: @@ -183,9 +183,9 @@ def openFortIO( the situation where you need to ensure resource cleanup. import sys - from ecl.ecl import FortIO, EclFile + from resdata.ecl import FortIO, ResdataFile - rst_file = EclFile(sys.argv[1]) + rst_file = ResdataFile(sys.argv[1]) with openFortIO("PRESSURE", mode=FortIO.WRITE_MODE) as fortio: for kw in rst_file: if kw.name() == "PRESSURE": diff --git a/python/resdata/resfile/rd_3d_file.py b/python/resdata/resfile/rd_3d_file.py index 430f992ae9..fad7ea4f9f 100644 --- a/python/resdata/resfile/rd_3d_file.py +++ b/python/resdata/resfile/rd_3d_file.py @@ -1,22 +1,22 @@ -from ecl.eclfile import EclFile, Ecl3DKW +from resdata.eclfile import ResdataFile, Resdata3DKW -class Ecl3DFile(EclFile): +class Resdata3DFile(ResdataFile): def __init__(self, grid, filename, flags=0): self.grid = grid - super(Ecl3DFile, self).__init__(filename, flags) + super(Resdata3DFile, self).__init__(filename, flags) def __getitem__(self, index): - return_arg = super(Ecl3DFile, self).__getitem__(index) + return_arg = super(Resdata3DFile, self).__getitem__(index) if isinstance(return_arg, list): kw_list = return_arg else: kw_list = [return_arg] - # Go through all the keywords and try inplace promotion to Ecl3DKW + # Go through all the keywords and try inplace promotion to Resdata3DKW for kw in kw_list: try: - Ecl3DKW.castFromKW(kw, self.grid) + Resdata3DKW.castFromKW(kw, self.grid) except ValueError: pass diff --git a/python/resdata/resfile/rd_3dkw.py b/python/resdata/resfile/rd_3dkw.py index fa54781f33..4dc9881522 100644 --- a/python/resdata/resfile/rd_3dkw.py +++ b/python/resdata/resfile/rd_3dkw.py @@ -1,29 +1,29 @@ -from ecl.util.util import monkey_the_camel -from .ecl_kw import EclKW +from resdata.util.util import monkey_the_camel +from .rd_kw import ResdataKW -class Ecl3DKW(EclKW): +class Resdata3DKW(ResdataKW): """ Class for working with Eclipse keywords defined over a grid - The Ecl3DKW class is derived from the EclKW class, and most of the - methods are implemented in the EclKW base class. The purpose of - the Ecl3DKW class is to simplify working with 3D properties like + The Resdata3DKW class is derived from the ResdataKW class, and most of the + methods are implemented in the ResdataKW base class. The purpose of + the Resdata3DKW class is to simplify working with 3D properties like PORO or SATNUM. - The Ecl3DKW class has an attached EclGrid which is used to support + The Resdata3DKW class has an attached ResdataGrid which is used to support [i,j,k] indexing, and a defined default value which is used when - reading an inactive value. The Ecl3DKW keyword instances are - returned from the EclInitFile and EclRestartFile classes, in - addition you can excplicitly \"cast\" a EclKW keyword to Ecl3DKW - with the Ecl3DKW.castFromKW() classmethod. + reading an inactive value. The Resdata3DKW keyword instances are + returned from the ResdataInitFile and ResdataRestartFile classes, in + addition you can excplicitly \"cast\" a ResdataKW keyword to Resdata3DKW + with the Resdata3DKW.castFromKW() classmethod. Usage example: - from ecl.ecl import EclInitFile,EclGrid + from resdata.ecl import ResdataInitFile,ResdataGrid - grid = EclGrid("ECLIPSE.EGRID") - file = EclInitFile(grid , "ECLIPSE.INIT") + grid = ResdataGrid("ECLIPSE.EGRID") + file = ResdataInitFile(grid , "ECLIPSE.INIT") permx_kw = file["PORO"][0] porv_kw = file["PORV"][0] @@ -55,25 +55,25 @@ def __init__(self, kw, grid, value_type, default_value=0, global_active=False): size = grid.getGlobalSize() else: size = grid.getNumActive() - super(Ecl3DKW, self).__init__(kw, size, value_type) + super(Resdata3DKW, self).__init__(kw, size, value_type) self.grid = grid self.global_active = global_active self.setDefault(default_value) @classmethod def create(cls, kw, grid, value_type, default_value=0, global_active=False): - new_kw = Ecl3DKW(kw, grid, value_type, default_value, global_active) + new_kw = Resdata3DKW(kw, grid, value_type, default_value, global_active) return new_kw @classmethod - def read_grdecl(cls, grid, fileH, kw, strict=True, ecl_type=None): + def read_grdecl(cls, grid, fileH, kw, strict=True, rd_type=None): """ - Will load an Ecl3DKW instance from a grdecl formatted filehandle. + Will load an Resdata3DKW instance from a grdecl formatted filehandle. - See the base class EclKW.read_grdecl() for more documentation. + See the base class ResdataKW.read_grdecl() for more documentation. """ - kw = super(Ecl3DKW, cls).read_grdecl(fileH, kw, strict, ecl_type) - Ecl3DKW.castFromKW(kw, grid) + kw = super(Resdata3DKW, cls).read_grdecl(fileH, kw, strict, rd_type) + Resdata3DKW.castFromKW(kw, grid) return kw def __getitem__(self, index): @@ -99,7 +99,7 @@ def __getitem__(self, index): else: index = self.grid.get_active_index(ijk=index) - return super(Ecl3DKW, self).__getitem__(index) + return super(Resdata3DKW, self).__getitem__(index) def __setitem__(self, index, value): """Set the value of at index [g] or [i,j,k]. @@ -124,13 +124,13 @@ def __setitem__(self, index, value): else: index = self.grid.get_active_index(ijk=index) - return super(Ecl3DKW, self).__setitem__(index, value) + return super(Resdata3DKW, self).__setitem__(index, value) @classmethod def cast_from_kw(cls, kw, grid, default_value=0): - """Will convert a normal EclKW to a Ecl3DKW. + """Will convert a normal ResdataKW to a Resdata3DKW. - The method will convert a normal EclKW instance to Ecl3DKw + The method will convert a normal ResdataKW instance to Resdata3DKw instance with an attached grid and a default value. The method will check that size of the keyword is compatible @@ -145,11 +145,11 @@ def cast_from_kw(cls, kw, grid, default_value=0): 2. Convert the keyword to a 3D keyword. - from ecl.ecl import EclGrid,EclKW,Ecl3DKW + from resdata.ecl import ResdataGrid,ResdataKW,Resdata3DKW - grid = EclGrid("ECLIPSE.EGRID") - poro = EclKW.read_grdecl(open("poro.grdecl") , "PORO") - Ecl3DKW.castFromKW( poro , grid ) + grid = ResdataGrid("ECLIPSE.EGRID") + poro = ResdataKW.read_grdecl(open("poro.grdecl") , "PORO") + Resdata3DKW.castFromKW( poro , grid ) print('Porosity in cell (10,11,12):%g' % poro[10,11,12]) """ @@ -174,9 +174,9 @@ def cast_from_kw(cls, kw, grid, default_value=0): return kw def compressed_copy(self): - """Will return a EclKW copy with nactive elements. + """Will return a ResdataKW copy with nactive elements. - The returned copy will be of type EclKW; i.e. no default + The returned copy will be of type ResdataKW; i.e. no default interpolation and only linear access in the [] operator. The main purpose of this is to facilitate iteration over the active index, and for writing binary files. @@ -184,9 +184,9 @@ def compressed_copy(self): return self.grid.compressedKWCopy(self) def global_copy(self): - """Will return a EclKW copy with nx*ny*nz elements. + """Will return a ResdataKW copy with nx*ny*nz elements. - The returned copy will be of type EclKW; i.e. no default + The returned copy will be of type ResdataKW; i.e. no default interpolation and only linear access in the [] operator. The main purpose of this is to facilitate iteration over the global index, and for writing binary files. @@ -203,8 +203,8 @@ def get_default(self): return self.default_value -monkey_the_camel(Ecl3DKW, "castFromKW", Ecl3DKW.cast_from_kw, classmethod) -monkey_the_camel(Ecl3DKW, "compressedCopy", Ecl3DKW.compressed_copy) -monkey_the_camel(Ecl3DKW, "globalCopy", Ecl3DKW.global_copy) -monkey_the_camel(Ecl3DKW, "setDefault", Ecl3DKW.set_default) -monkey_the_camel(Ecl3DKW, "getDefault", Ecl3DKW.get_default) +monkey_the_camel(Resdata3DKW, "castFromKW", Resdata3DKW.cast_from_kw, classmethod) +monkey_the_camel(Resdata3DKW, "compressedCopy", Resdata3DKW.compressed_copy) +monkey_the_camel(Resdata3DKW, "globalCopy", Resdata3DKW.global_copy) +monkey_the_camel(Resdata3DKW, "setDefault", Resdata3DKW.set_default) +monkey_the_camel(Resdata3DKW, "getDefault", Resdata3DKW.get_default) diff --git a/python/resdata/resfile/rd_file.py b/python/resdata/resfile/rd_file.py index bc02e845ce..4729e4e113 100644 --- a/python/resdata/resfile/rd_file.py +++ b/python/resdata/resfile/rd_file.py @@ -1,80 +1,77 @@ """ -The ecl_file module contains functionality to load a an ECLIPSE file +The rd_file module contains functionality to load a an ECLIPSE file in 'restart format'. Files of 'restart format' include restart files, init files, grid files, summary files and RFT files. -The ecl_file implementation is agnostic[1] to the content and -structure of the file; more specialized classes like EclSum and -EclGrid use the EclFile functionality for low level file loading. +The rd_file implementation is agnostic[1] to the content and +structure of the file; more specialized classes like RdSum and +ResdataGrid use the ResdataFile functionality for low level file loading. The typical usage involves loading a complete file, and then subsequently querying for various keywords. In the example below we load a restart file, and ask for the SWAT keyword: - file = EclFile( "ECLIPSE.X0067" ) + file = ResdataFile( "ECLIPSE.X0067" ) swat_kw = file.iget_named_kw( "SWAT" , 0 ) -The ecl_file module is a thin wrapper around the ecl_file.c +The rd_file module is a thin wrapper around the rd_file.c implementation from the resdata library. [1]: In particular for restart files, which do not have a special RestartFile class, there is some specialized functionality. """ +import ctypes +import datetime import re import types -import datetime -import ctypes from cwrap import BaseCClass +from resdata import ResdataFileEnum, ResdataFileFlagEnum, ResdataPrototype +from resdata.eclfile import ResdataFileView, ResdataKW +from resdata.util.util import CTime, monkey_the_camel -from ecl import EclPrototype -from ecl.util.util import CTime -from ecl.util.util import monkey_the_camel -from ecl import EclFileFlagEnum, EclFileEnum -from ecl.eclfile import EclKW, EclFileView +RD_FILE_DEFAULT = ResdataFileFlagEnum.RD_FILE_DEFAULT -ECL_FILE_DEFAULT = EclFileFlagEnum.ECL_FILE_DEFAULT - -class EclFile(BaseCClass): - TYPE_NAME = "ecl_file" - _open = EclPrototype( - "void* ecl_file_open( char* , ecl_file_flag_enum )", bind=False +class ResdataFile(BaseCClass): + TYPE_NAME = "rd_file" + _open = ResdataPrototype( + "void* rd_file_open( char* , rd_file_flag_enum )", bind=False ) - _get_file_type = EclPrototype( - "ecl_file_enum ecl_util_get_file_type( char* , bool* , int*)", bind=False + _get_file_type = ResdataPrototype( + "rd_file_enum rd_get_file_type( char* , bool* , int*)", bind=False ) - _writable = EclPrototype("bool ecl_file_writable( ecl_file )") - _save_kw = EclPrototype("void ecl_file_save_kw( ecl_file , ecl_kw )") - _close = EclPrototype("void ecl_file_close( ecl_file )") - _iget_restart_time = EclPrototype( - "time_t ecl_file_iget_restart_sim_date( ecl_file , int )" + _writable = ResdataPrototype("bool rd_file_writable( rd_file )") + _save_kw = ResdataPrototype("void rd_file_save_kw( rd_file , rd_kw )") + _close = ResdataPrototype("void rd_file_close( rd_file )") + _iget_restart_time = ResdataPrototype( + "time_t rd_file_iget_restart_sim_date( rd_file , int )" ) - _iget_restart_days = EclPrototype( - "double ecl_file_iget_restart_sim_days( ecl_file , int )" + _iget_restart_days = ResdataPrototype( + "double rd_file_iget_restart_sim_days( rd_file , int )" ) - _get_restart_index = EclPrototype( - "int ecl_file_get_restart_index( ecl_file , time_t)" + _get_restart_index = ResdataPrototype( + "int rd_file_get_restart_index( rd_file , time_t)" ) - _get_src_file = EclPrototype("char* ecl_file_get_src_file( ecl_file )") - _replace_kw = EclPrototype( - "void ecl_file_replace_kw( ecl_file , ecl_kw , ecl_kw , bool)" + _get_src_file = ResdataPrototype("char* rd_file_get_src_file( rd_file )") + _replace_kw = ResdataPrototype( + "void rd_file_replace_kw( rd_file , rd_kw , rd_kw , bool)" ) - _fwrite = EclPrototype( - "void ecl_file_fwrite_fortio( ecl_file , fortio , int)" + _fwrite = ResdataPrototype( + "void rd_file_fwrite_fortio( rd_file , fortio , int)" ) - _has_report_step = EclPrototype( - "bool ecl_file_has_report_step( ecl_file , int)" + _has_report_step = ResdataPrototype( + "bool rd_file_has_report_step( rd_file , int)" ) - _has_sim_time = EclPrototype( - "bool ecl_file_has_sim_time( ecl_file , time_t )" + _has_sim_time = ResdataPrototype( + "bool rd_file_has_sim_time( rd_file , time_t )" ) - _get_global_view = EclPrototype( - "ecl_file_view_ref ecl_file_get_global_view( ecl_file )" + _get_global_view = ResdataPrototype( + "rd_file_view_ref rd_file_get_global_view( rd_file )" ) - _write_index = EclPrototype("bool ecl_file_write_index( ecl_file , char*)") - _fast_open = EclPrototype( - "void* ecl_file_fast_open( char* , char* , int )", bind=False + _write_index = ResdataPrototype("bool rd_file_write_index( rd_file , char*)") + _fast_open = ResdataPrototype( + "void* rd_file_fast_open( char* , char* , int )", bind=False ) @staticmethod @@ -82,15 +79,18 @@ def get_filetype(filename): fmt_file = ctypes.c_bool() report_step = ctypes.c_int() - file_type = EclFile._get_file_type( + file_type = ResdataFile._get_file_type( filename, ctypes.byref(fmt_file), ctypes.byref(report_step) ) - if file_type in [EclFileEnum.ECL_RESTART_FILE, EclFileEnum.ECL_SUMMARY_FILE]: + if file_type in [ + ResdataFileEnum.RD_RESTART_FILE, + ResdataFileEnum.RD_SUMMARY_FILE, + ]: report_step = report_step.value else: report_step = None - if file_type in [EclFileEnum.ECL_OTHER_FILE, EclFileEnum.ECL_DATA_FILE]: + if file_type in [ResdataFileEnum.RD_OTHER_FILE, ResdataFileEnum.RD_DATA_FILE]: fmt_file = None else: fmt_file = fmt_file.value @@ -100,7 +100,7 @@ def get_filetype(filename): @classmethod def restart_block(cls, filename, dtime=None, report_step=None): raise NotImplementedError( - "The restart_block implementation has been removed - open file normally and use EclFileView." + "The restart_block implementation has been removed - open file normally and use ResdataFileView." ) @classmethod @@ -109,21 +109,13 @@ def contains_report_step(cls, filename, report_step): Will check if the @filename contains @report_step. This classmethod works by opening the file @filename and - searching through linearly to see if an ecl_kw with value - corresponding to @report_step can be found. Since this is a - classmethod it is invoked like this: - - import ecl.ecl.ecl as ecl - .... - if ecl.EclFile.contains_report_step("ECLIPSE.UNRST" , 20): - print "OK - file contains report step 20" - else: - print "File does not contain report step 20" - - If you have already loaded the file into an EclFile instance + searching through linearly to see if an rd_kw with value + corresponding to @report_step can be found. + + If you have already loaded the file into an ResdataFile instance you should use the has_report_step() method instead. """ - obj = EclFile(filename) + obj = ResdataFile(filename) return obj.has_report_step(report_step) @classmethod @@ -133,20 +125,12 @@ def contains_sim_time(cls, filename, dtime): This classmethod works by opening the file @filename and searching through linearly to see if a result block at the - time corresponding to @dtime can be found. Since this is a - classmethod it is invoked like this: - - import ecl.ecl.ecl as ecl - .... - if ecl.EclFile.contains_sim_time("ECLIPSE.UNRST" , datetime.datetime( 2007 , 10 , 10) ): - print "OK - file contains 10th of October 2007" - else: - print "File does not contain 10th of October 2007" + time corresponding to @dtime can be found. - If you have already loaded the file into an EclFile instance + If you have already loaded the file into an ResdataFile instance you should use the has_sim_time() method instead. """ - obj = EclFile(filename) + obj = ResdataFile(filename) return obj.has_sim_time(dtime) @property @@ -178,7 +162,7 @@ def file_report_list(cls, filename): Will identify the available report_steps from @filename. """ - file = EclFile(filename) + file = ResdataFile(filename) return file.report_list def __repr__(self): @@ -186,27 +170,27 @@ def __repr__(self): wr = ", read/write" if self._writable() else "" return self._create_repr('"%s"%s' % (fn, wr)) - def __init__(self, filename, flags=ECL_FILE_DEFAULT, index_filename=None): + def __init__(self, filename, flags=RD_FILE_DEFAULT, index_filename=None): """ Loads the complete file @filename. - Will create a new EclFile instance with the content of file + Will create a new ResdataFile instance with the content of file @filename. The file @filename must be in 'restart format' - otherwise it will be crash and burn. The optional argument flags can be an or'ed combination of the flags: - ecl.ECL_FILE_WRITABLE : It is possible to update the + ecl.RD_FILE_WRITABLE : It is possible to update the content of the keywords in the file. - ecl.ECL_FILE_CLOSE_STREAM : The underlying FILE * is closed + ecl.RD_FILE_CLOSE_STREAM : The underlying FILE * is closed when not used; to save number of open file descriptors - in cases where a high number of EclFile instances are + in cases where a high number of ResdataFile instances are open concurrently. - When the file has been loaded the EclFile instance can be used - to query for and get reference to the EclKW instances + When the file has been loaded the ResdataFile instance can be used + to query for and get reference to the ResdataKW instances constituting the file, like e.g. SWAT from a restart file or FIPNUM from an INIT file. """ @@ -218,7 +202,7 @@ def __init__(self, filename, flags=ECL_FILE_DEFAULT, index_filename=None): if c_ptr is None: raise IOError('Failed to open file "%s"' % filename) else: - super(EclFile, self).__init__(c_ptr) + super(ResdataFile, self).__init__(c_ptr) self.global_view = self._get_global_view() self.global_view.setParent(self) @@ -228,13 +212,13 @@ def save_kw(self, kw): This function should typically be used in situations like this: - 1. Create an EclFile instance around an ECLIPSE output file. + 1. Create an ResdataFile instance around an ECLIPSE output file. 2. Extract a keyword of interest and modify it. 3. Call this method to save the modifications to disk. There are several restrictions to the use of this function: - 1. The EclFile instance must have been created with the + 1. The ResdataFile instance must have been created with the optional read_only flag set to False. 2. You can only modify the content of the keyword; if you @@ -242,7 +226,7 @@ def save_kw(self, kw): or name) the function will fail. 3. The keyword you are trying to save must be exactly the - keyword you got from this EclFile instance, otherwise the + keyword you got from this ResdataFile instance, otherwise the function will fail. """ if self._writable(): @@ -288,17 +272,17 @@ def restart_view( def select_block(self, kw, kw_index): raise NotImplementedError( - "The select_block implementation has been removed - use EclFileView" + "The select_block implementation has been removed - use ResdataFileView" ) def select_global(self): raise NotImplementedError( - "The select_global implementation has been removed - use EclFileView" + "The select_global implementation has been removed - use ResdataFileView" ) def select_restart_section(self, index=None, report_step=None, sim_time=None): raise NotImplementedError( - "The select_restart_section implementation has been removed - use EclFileView" + "The select_restart_section implementation has been removed - use ResdataFileView" ) """ Will select a restart section as the active section. @@ -324,7 +308,7 @@ def select_restart_section(self, index=None, report_step=None, sim_time=None): def select_last_restart(self): raise NotImplementedError( - "The select_restart_section implementation has been removed - use EclFileView" + "The select_restart_section implementation has been removed - use ResdataFileView" ) """ Will select the last SEQNUM block in restart file. @@ -339,18 +323,18 @@ def __getitem__(self, index): """ Implements [] operator; index can be integer or key. - Will look up EclKW instances from the current EclFile + Will look up ResdataKW instances from the current ResdataFile instance. The @index argument can either be an integer, in - which case the method will return EclKW number @index, or + which case the method will return ResdataKW number @index, or alternatively a keyword string, in which case the method will - return a list of EclKW instances with that keyword: + return a list of ResdataKW instances with that keyword: - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + restart_file = rd_file.ResdataFile("ECLIPSE.UNRST") kw9 = restart_file[9] swat_list = restart_file["SWAT"] The keyword based lookup can be combined with an extra [] to - get EclKW instance nr: + get ResdataKW instance nr: swat9 = restart_file["SWAT"][9] @@ -358,7 +342,7 @@ def __getitem__(self, index): following example will iterate over all the SWAT keywords in a restart file: - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + restart_file = rd_file.ResdataFile("ECLIPSE.UNRST") for swat in restart_file["SWAT"]: .... """ @@ -375,9 +359,9 @@ def __getitem__(self, index): def iget_kw(self, index, copy=False): """ - Will return EclKW instance nr @index. + Will return ResdataKW instance nr @index. - In the files loaded with the EclFile implementation the + In the files loaded with the ResdataFile implementation the ECLIPSE keywords come sequentially in a long series, an INIT file might have the following keywords: @@ -395,16 +379,16 @@ def iget_kw(self, index, copy=False): MULTY ..... - The iget_kw() method will give you a EclKW reference to + The iget_kw() method will give you a ResdataKW reference to keyword nr @index. This functionality is also available through the index operator []: - file = EclFile( "ECLIPSE.INIT" ) + file = ResdataFile( "ECLIPSE.INIT" ) permx = file.iget_kw( 7 ) permz = file[ 9 ] - Observe that the returned EclKW instance is only a reference - to the data owned by the EclFile instance. + Observe that the returned ResdataKW instance is only a reference + to the data owned by the ResdataFile instance. The method iget_named_kw() which lets you specify the name of the keyword you are interested in is in general more useful @@ -412,7 +396,7 @@ def iget_kw(self, index, copy=False): """ kw = self[index] if copy: - return EclKW.copy(kw) + return ResdataKW.copy(kw) else: return kw @@ -420,19 +404,19 @@ def iget_named_kw(self, kw_name, index, copy=False): return self.global_view.iget_named_kw(kw_name, index) def restart_get_kw(self, kw_name, dtime, copy=False): - """Will return EclKW @kw_name from restart file at time @dtime. + """Will return ResdataKW @kw_name from restart file at time @dtime. - This function assumes that the current EclFile instance + This function assumes that the current ResdataFile instance represents a restart file. It will then look for keyword @kw_name exactly at the time @dtime; @dtime is a datetime instance: - file = EclFile( "ECLIPSE.UNRST" ) + file = ResdataFile( "ECLIPSE.UNRST" ) swat2010 = file.restart_get_kw( "SWAT" , datetime.datetime( 2000 , 1 , 1 )) By default the returned kw instance is a reference to the - ecl_kw still contained in the EclFile instance; i.e. the kw - will become a dangling reference if the EclFile instance goes + rd_kw still contained in the ResdataFile instance; i.e. the kw + will become a dangling reference if the ResdataFile instance goes out of scope. If the optional argument @copy is True the returned kw will be a true copy. @@ -445,7 +429,7 @@ def restart_get_kw(self, kw_name, dtime, copy=False): if self.num_named_kw(kw_name) > index: kw = self.iget_named_kw(kw_name, index) if copy: - return EclKW.copy(kw) + return ResdataKW.copy(kw) else: return kw else: @@ -462,14 +446,14 @@ def restart_get_kw(self, kw_name, dtime, copy=False): def replace_kw(self, old_kw, new_kw): """ - Will replace @old_kw with @new_kw in current EclFile instance. + Will replace @old_kw with @new_kw in current ResdataFile instance. - This method can be used to replace one of the EclKW instances - in the current EclFile. The @old_kw reference must be to the - actual EclKW instance in the current EclFile instance (the + This method can be used to replace one of the ResdataKW instances + in the current ResdataFile. The @old_kw reference must be to the + actual ResdataKW instance in the current ResdataFile instance (the final comparison is based on C pointer equality!), i.e. it must be a reference (not a copy) from one of the ??get_kw?? - methods of the EclFile class. In the example below we replace + methods of the ResdataFile class. In the example below we replace the SWAT keyword from a restart file: swat = file.iget_named_kw( "SWAT" , 0 ) @@ -477,34 +461,34 @@ def replace_kw(self, old_kw, new_kw): file.replace_kw( swat , new_swat ) - The C-level ecl_file_type structure takes full ownership of - all installed ecl_kw instances; mixing the garbage collector + The C-level rd_file_type structure takes full ownership of + all installed rd_kw instances; mixing the garbage collector into it means that this is quite low level - and potentially dangerous! """ # We ensure that this scope owns the new_kw instance; the - # new_kw will be handed over to the ecl_file instance, and we + # new_kw will be handed over to the rd_file instance, and we # can not give away something we do not alreeady own. if not new_kw.data_owner: - new_kw = EclKW.copy(new_kw) + new_kw = ResdataKW.copy(new_kw) - # The ecl_file instance will take responsability for freeing - # this ecl_kw instance. + # The rd_file instance will take responsability for freeing + # this rd_kw instance. new_kw.data_owner = False self._replace_kw(old_kw, new_kw, False) @property def size(self): """ - The number of keywords in the current EclFile object. + The number of keywords in the current ResdataFile object. """ return len(self) @property def unique_size(self): """ - The number of unique keyword (names) in the current EclFile object. + The number of unique keyword (names) in the current ResdataFile object. """ return self.global_view.uniqueSize() @@ -535,7 +519,7 @@ def report_steps(self): Will return a list of all report steps. The method works by iterating through the whole restart file - looking for 'SEQNUM' keywords; if the current EclFile instance + looking for 'SEQNUM' keywords; if the current ResdataFile instance is not a restart file it will not contain any 'SEQNUM' keywords and the method will simply return an empty list. """ @@ -561,7 +545,7 @@ def report_dates(self): dates.append(self.iget_restart_sim_time(index)) return dates elif "INTEHEAD" in self: - # This is a uber-hack; should export the ecl_rsthead + # This is a uber-hack; should export the rd_rsthead # object as ctypes structure. intehead = self["INTEHEAD"][0] year = intehead[66] @@ -580,16 +564,16 @@ def dates(self): def num_named_kw(self, kw): """ - The number of keywords with name == @kw in the current EclFile object. + The number of keywords with name == @kw in the current ResdataFile object. """ return self.global_view.numKeywords(kw) def has_kw(self, kw, num=0): """ - Check if current EclFile instance has a keyword @kw. + Check if current ResdataFile instance has a keyword @kw. If the optional argument @num is given it will check if the - EclFile has at least @num occurences of @kw. + ResdataFile has at least @num occurences of @kw. """ return self.num_named_kw(kw) > num @@ -602,9 +586,9 @@ def __contains__(self, kw): def has_report_step(self, report_step): """ - Checks if the current EclFile has report step @report_step. + Checks if the current ResdataFile has report step @report_step. - If the EclFile in question is not a restart file, you will + If the ResdataFile in question is not a restart file, you will just get False. If you want to check if the file contains the actual report_step before loading the file, you should use the classmethod contains_report_step() instead. @@ -625,11 +609,11 @@ def num_report_steps(self): def has_sim_time(self, dtime): """ - Checks if the current EclFile has data for time @dtime. + Checks if the current ResdataFile has data for time @dtime. The implementation goes through all the INTEHEAD headers in - the EclFile, i.e. it can be fooled (and probably crash and - burn) if the EclFile instance in question is has INTEHEAD + the ResdataFile, i.e. it can be fooled (and probably crash and + burn) if the ResdataFile instance in question is has INTEHEAD keyword(s), but is still not a restart file. The @dtime argument should be a normal python datetime instance. """ @@ -660,14 +644,14 @@ def get_filename(self): def fwrite(self, fortio): """ - Will write current EclFile instance to fortio stream. + Will write current ResdataFile instance to fortio stream. ECLIPSE is written in Fortran; and a "special" handle for Fortran IO must be used when reading and writing these files. - This method will write the current EclFile instance to a + This method will write the current ResdataFile instance to a FortIO stream already opened for writing: - import ecl.ecl.ecl as ecl + import resdata.ecl.ecl as ecl ... fortio = ecl.FortIO( "FILE.XX" ) file.fwrite( fortio ) @@ -681,29 +665,29 @@ def write_index(self, index_file_name): raise IOError("Failed to write index file:%s" % index_file_name) -class EclFileContextManager(object): - def __init__(self, ecl_file): - self.__ecl_file = ecl_file +class ResdataFileContextManager(object): + def __init__(self, rd_file): + self.__rd_file = rd_file def __enter__(self): - return self.__ecl_file + return self.__rd_file def __exit__(self, exc_type, exc_val, exc_tb): - self.__ecl_file.close() + self.__rd_file.close() return False -def openEclFile(file_name, flags=ECL_FILE_DEFAULT): - print("The function openEclFile is deprecated, use open_ecl_file.") - return open_ecl_file(file_name, flags) +def openResdataFile(file_name, flags=RD_FILE_DEFAULT): + print("The function openResdataFile is deprecated, use open_rd_file.") + return open_rd_file(file_name, flags) -def open_ecl_file(file_name, flags=ECL_FILE_DEFAULT): - return EclFileContextManager(EclFile(file_name, flags)) +def open_rd_file(file_name, flags=RD_FILE_DEFAULT): + return ResdataFileContextManager(ResdataFile(file_name, flags)) -monkey_the_camel(EclFile, "getFileType", EclFile.get_filetype, staticmethod) -monkey_the_camel(EclFile, "blockView", EclFile.block_view) -monkey_the_camel(EclFile, "blockView2", EclFile.block_view2) -monkey_the_camel(EclFile, "restartView", EclFile.restart_view) -monkey_the_camel(EclFile, "getFilename", EclFile.get_filename) +monkey_the_camel(ResdataFile, "getFileType", ResdataFile.get_filetype, staticmethod) +monkey_the_camel(ResdataFile, "blockView", ResdataFile.block_view) +monkey_the_camel(ResdataFile, "blockView2", ResdataFile.block_view2) +monkey_the_camel(ResdataFile, "restartView", ResdataFile.restart_view) +monkey_the_camel(ResdataFile, "getFilename", ResdataFile.get_filename) diff --git a/python/resdata/resfile/rd_file_view.py b/python/resdata/resfile/rd_file_view.py index 0a59b06a94..8a65fdf8b7 100644 --- a/python/resdata/resfile/rd_file_view.py +++ b/python/resdata/resfile/rd_file_view.py @@ -1,35 +1,37 @@ from __future__ import absolute_import, division, print_function, unicode_literals from six import string_types from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl.util.util import CTime -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata.util.util import CTime +from resdata import ResdataPrototype -class EclFileView(BaseCClass): - TYPE_NAME = "ecl_file_view" - _iget_kw = EclPrototype("ecl_kw_ref ecl_file_view_iget_kw( ecl_file_view , int)") - _iget_named_kw = EclPrototype( - "ecl_kw_ref ecl_file_view_iget_named_kw( ecl_file_view , char* , int)" +class ResdataFileView(BaseCClass): + TYPE_NAME = "rd_file_view" + _iget_kw = ResdataPrototype( + "rd_kw_ref rd_file_view_iget_kw( rd_file_view , int)" ) - _get_unique_kw = EclPrototype( - "char* ecl_file_view_iget_distinct_kw( ecl_file_view, int )" + _iget_named_kw = ResdataPrototype( + "rd_kw_ref rd_file_view_iget_named_kw( rd_file_view , char* , int)" ) - _get_size = EclPrototype("int ecl_file_view_get_size( ecl_file_view )") - _get_num_named_kw = EclPrototype( - "int ecl_file_view_get_num_named_kw( ecl_file_view , char* )" + _get_unique_kw = ResdataPrototype( + "char* rd_file_view_iget_distinct_kw( rd_file_view, int )" ) - _get_unique_size = EclPrototype( - "int ecl_file_view_get_num_distinct_kw( ecl_file_view )" + _get_size = ResdataPrototype("int rd_file_view_get_size( rd_file_view )") + _get_num_named_kw = ResdataPrototype( + "int rd_file_view_get_num_named_kw( rd_file_view , char* )" ) - _create_block_view = EclPrototype( - "ecl_file_view_ref ecl_file_view_add_blockview( ecl_file_view , char*, int )" + _get_unique_size = ResdataPrototype( + "int rd_file_view_get_num_distinct_kw( rd_file_view )" ) - _create_block_view2 = EclPrototype( - "ecl_file_view_ref ecl_file_view_add_blockview2( ecl_file_view , char*, char*, int )" + _create_block_view = ResdataPrototype( + "rd_file_view_ref rd_file_view_add_blockview( rd_file_view , char*, int )" ) - _restart_view = EclPrototype( - "ecl_file_view_ref ecl_file_view_add_restart_view( ecl_file_view , int, int, time_t, double )" + _create_block_view2 = ResdataPrototype( + "rd_file_view_ref rd_file_view_add_blockview2( rd_file_view , char*, char*, int )" + ) + _restart_view = ResdataPrototype( + "rd_file_view_ref rd_file_view_add_restart_view( rd_file_view , int, int, time_t, double )" ) def __init__(self): @@ -39,7 +41,7 @@ def __iget(self, index): return self._iget_kw(index).setParent(parent=self) def __repr__(self): - return "EclFileView(size=%d) %s" % (len(self), self._ad_str()) + return "ResdataFileView(size=%d) %s" % (len(self), self._ad_str()) def iget_named_kw(self, kw_name, index): if not kw_name in self: @@ -54,18 +56,18 @@ def __getitem__(self, index): """ Implements [] operator; index can be integer or key. - Will look up EclKW instances from the current EclFile + Will look up ResdataKW instances from the current ResdataFile instance. The @index argument can either be an integer, in - which case the method will return EclKW number @index, or + which case the method will return ResdataKW number @index, or alternatively a keyword string, in which case the method will - return a list of EclKW instances with that keyword: + return a list of ResdataKW instances with that keyword: - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + restart_file = rd_file.ResdataFile("ECLIPSE.UNRST") kw9 = restart_file[9] swat_list = restart_file["SWAT"] The keyword based lookup can be combined with an extra [] to - get EclKW instance nr: + get ResdataKW instance nr: swat9 = restart_file["SWAT"][9] @@ -73,7 +75,7 @@ def __getitem__(self, index): following example will iterate over all the SWAT keywords in a restart file: - restart_file = ecl_file.EclFile("ECLIPSE.UNRST") + restart_file = rd_file.ResdataFile("ECLIPSE.UNRST") for swat in restart_file["SWAT"]: .... """ @@ -189,8 +191,8 @@ def restart_view( return view -monkey_the_camel(EclFileView, "numKeywords", EclFileView.num_keywords) -monkey_the_camel(EclFileView, "uniqueSize", EclFileView.unique_size) -monkey_the_camel(EclFileView, "blockView2", EclFileView.block_view2) -monkey_the_camel(EclFileView, "blockView", EclFileView.block_view) -monkey_the_camel(EclFileView, "restartView", EclFileView.restart_view) +monkey_the_camel(ResdataFileView, "numKeywords", ResdataFileView.num_keywords) +monkey_the_camel(ResdataFileView, "uniqueSize", ResdataFileView.unique_size) +monkey_the_camel(ResdataFileView, "blockView2", ResdataFileView.block_view2) +monkey_the_camel(ResdataFileView, "blockView", ResdataFileView.block_view) +monkey_the_camel(ResdataFileView, "restartView", ResdataFileView.restart_view) diff --git a/python/resdata/resfile/rd_init_file.py b/python/resdata/resfile/rd_init_file.py index 723ec1fc04..b9b7999094 100644 --- a/python/resdata/resfile/rd_init_file.py +++ b/python/resdata/resfile/rd_init_file.py @@ -1,14 +1,14 @@ -from ecl import EclFileEnum, EclFileFlagEnum -from ecl.eclfile import Ecl3DFile, EclFile +from resdata import ResdataFileEnum, ResdataFileFlagEnum +from resdata.eclfile import Resdata3DFile, ResdataFile -ECL_FILE_DEFAULT = EclFileFlagEnum.ECL_FILE_DEFAULT +RD_FILE_DEFAULT = ResdataFileFlagEnum.RD_FILE_DEFAULT -class EclInitFile(Ecl3DFile): - def __init__(self, grid, filename, flags=ECL_FILE_DEFAULT): - file_type, report_step, fmt_file = EclFile.getFileType(filename) - if file_type == EclFileEnum.ECL_INIT_FILE: - super(EclInitFile, self).__init__(grid, filename, flags) +class ResdataInitFile(Resdata3DFile): + def __init__(self, grid, filename, flags=RD_FILE_DEFAULT): + file_type, report_step, fmt_file = ResdataFile.getFileType(filename) + if file_type == ResdataFileEnum.RD_INIT_FILE: + super(ResdataInitFile, self).__init__(grid, filename, flags) else: err = 'The input filename "%s" does not correspond to an init file.' err += " Please follow the Eclipse naming conventions." diff --git a/python/resdata/resfile/rd_kw.py b/python/resdata/resfile/rd_kw.py index 1fd57d339b..798ffcab8a 100644 --- a/python/resdata/resfile/rd_kw.py +++ b/python/resdata/resfile/rd_kw.py @@ -19,7 +19,7 @@ files. This module also has (some) support for working with GRDECL 'formatted' files. -The ecl_kw.py implementation wraps the ecl_kw.c implementation from +The rd_kw.py implementation wraps the rd_kw.c implementation from the resdata library. """ @@ -29,60 +29,61 @@ from cwrap import CFILE, BaseCClass -from ecl import EclPrototype -from ecl.util.util import monkey_the_camel -from ecl import EclDataType -from ecl import EclTypeEnum, EclUtil +from resdata import ResdataPrototype +from resdata.util.util import monkey_the_camel +from resdata import ResdataDataType +from resdata import ResdataTypeEnum, ResdataUtil from .fortio import FortIO def dump_type_deprecation_warning(): warnings.warn( - "EclTypeEnum is deprecated. " + "You should instead provide an EclDataType", + "ResdataTypeEnum is deprecated. " + + "You should instead provide an ResdataDataType", DeprecationWarning, ) -def constant_size_data_type(ecl_type): - return ecl_type in [ - EclTypeEnum.ECL_CHAR_TYPE, - EclTypeEnum.ECL_FLOAT_TYPE, - EclTypeEnum.ECL_DOUBLE_TYPE, - EclTypeEnum.ECL_INT_TYPE, - EclTypeEnum.ECL_BOOL_TYPE, - EclTypeEnum.ECL_MESS_TYPE, +def constant_size_data_type(rd_type): + return rd_type in [ + ResdataTypeEnum.RD_CHAR_TYPE, + ResdataTypeEnum.RD_FLOAT_TYPE, + ResdataTypeEnum.RD_DOUBLE_TYPE, + ResdataTypeEnum.RD_INT_TYPE, + ResdataTypeEnum.RD_BOOL_TYPE, + ResdataTypeEnum.RD_MESS_TYPE, ] def warn_and_cast_data_type(data_type): - if isinstance(data_type, EclDataType): + if isinstance(data_type, ResdataDataType): return data_type - if isinstance(data_type, EclTypeEnum): + if isinstance(data_type, ResdataTypeEnum): if not constant_size_data_type(data_type): raise ValueError( - "Cannot cast EclTypeEnum (%d) to EclDataType due " - "to non-constant size. Please provide an EclDataType instead." + "Cannot cast ResdataTypeEnum (%d) to ResdataDataType due " + "to non-constant size. Please provide an ResdataDataType instead." ) dump_type_deprecation_warning() - return EclDataType(data_type) + return ResdataDataType(data_type) -class EclKW(BaseCClass): +class ResdataKW(BaseCClass): """ - The EclKW class contains the information from one ECLIPSE keyword. + The ResdataKW class contains the information from one ECLIPSE keyword. - The ecl_kw type is the lowest level type in the resdata C library, - and all the other datatypes like e.g. ecl_grid and ecl_sum are - based on collections of ecl_kw instances, and interpreting the - content of the ecl_kw keywords. + The rd_kw type is the lowest level type in the resdata C library, + and all the other datatypes like e.g. rd_grid and rd_sum are + based on collections of rd_kw instances, and interpreting the + content of the rd_kw keywords. Many of the special __xxx___() functions have been implemented, so - that the EclKW class supports both numerical operations and also + that the ResdataKW class supports both numerical operations and also [] based lookup. Many of the methods accept an optional @mask - argument; this should be a EclRegion instance which can be used to - limit the operation to a part of the EclKW. + argument; this should be a ResdataRegion instance which can be used to + limit the operation to a part of the ResdataKW. """ int_kw_set = set( @@ -98,116 +99,120 @@ class EclKW(BaseCClass): ] ) - TYPE_NAME = "ecl_kw" - _alloc_new = EclPrototype( - "void* ecl_kw_alloc_python(char*, int, ecl_data_type)", bind=False + TYPE_NAME = "rd_kw" + _alloc_new = ResdataPrototype( + "void* rd_kw_alloc_python(char*, int, rd_data_type)", bind=False ) - _fread_alloc = EclPrototype("ecl_kw_obj ecl_kw_fread_alloc(fortio)", bind=False) - _load_grdecl = EclPrototype( - "ecl_kw_obj ecl_kw_fscanf_alloc_grdecl_dynamic_python(FILE, char*, bool, ecl_data_type)", + _fread_alloc = ResdataPrototype("rd_kw_obj rd_kw_fread_alloc(fortio)", bind=False) + _load_grdecl = ResdataPrototype( + "rd_kw_obj rd_kw_fscanf_alloc_grdecl_dynamic_python(FILE, char*, bool, rd_data_type)", bind=False, ) - _fseek_grdecl = EclPrototype( - "bool ecl_kw_grdecl_fseek_kw(char*, bool, FILE)", bind=False + _fseek_grdecl = ResdataPrototype( + "bool rd_kw_grdecl_fseek_kw(char*, bool, FILE)", bind=False ) - _sub_copy = EclPrototype( - "ecl_kw_obj ecl_kw_alloc_sub_copy(ecl_kw, char*, int, int)" + _sub_copy = ResdataPrototype( + "rd_kw_obj rd_kw_alloc_sub_copy(rd_kw, char*, int, int)" ) - _copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_copy(ecl_kw)") - _slice_copyc = EclPrototype( - "ecl_kw_obj ecl_kw_alloc_slice_copy(ecl_kw, int, int, int)" + _copyc = ResdataPrototype("rd_kw_obj rd_kw_alloc_copy(rd_kw)") + _slice_copyc = ResdataPrototype( + "rd_kw_obj rd_kw_alloc_slice_copy(rd_kw, int, int, int)" ) - _global_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_global_copy(ecl_kw, ecl_kw)") - _fprintf_grdecl = EclPrototype("void ecl_kw_fprintf_grdecl(ecl_kw, FILE)") - _fprintf_data = EclPrototype("void ecl_kw_fprintf_data(ecl_kw, char*, FILE)") - - _get_size = EclPrototype("int ecl_kw_get_size(ecl_kw)") - _get_fortio_size = EclPrototype("size_t ecl_kw_fortio_size(ecl_kw)") - _get_type = EclPrototype("ecl_type_enum ecl_kw_get_type(ecl_kw)") - _iget_char_ptr = EclPrototype("char* ecl_kw_iget_char_ptr(ecl_kw, int)") - _iset_char_ptr = EclPrototype("void ecl_kw_iset_char_ptr(ecl_kw, int, char*)") - _iget_string_ptr = EclPrototype("char* ecl_kw_iget_string_ptr(ecl_kw, int)") - _iset_string_ptr = EclPrototype( - "void ecl_kw_iset_string_ptr(ecl_kw, int, char*)" + _global_copy = ResdataPrototype("rd_kw_obj rd_kw_alloc_global_copy(rd_kw, rd_kw)") + _fprintf_grdecl = ResdataPrototype("void rd_kw_fprintf_grdecl(rd_kw, FILE)") + _fprintf_data = ResdataPrototype("void rd_kw_fprintf_data(rd_kw, char*, FILE)") + + _get_size = ResdataPrototype("int rd_kw_get_size(rd_kw)") + _get_fortio_size = ResdataPrototype("size_t rd_kw_fortio_size(rd_kw)") + _get_type = ResdataPrototype("rd_type_enum rd_kw_get_type(rd_kw)") + _iget_char_ptr = ResdataPrototype("char* rd_kw_iget_char_ptr(rd_kw, int)") + _iset_char_ptr = ResdataPrototype("void rd_kw_iset_char_ptr(rd_kw, int, char*)") + _iget_string_ptr = ResdataPrototype("char* rd_kw_iget_string_ptr(rd_kw, int)") + _iset_string_ptr = ResdataPrototype( + "void rd_kw_iset_string_ptr(rd_kw, int, char*)" ) - _iget_bool = EclPrototype("bool ecl_kw_iget_bool(ecl_kw, int)") - _iset_bool = EclPrototype("bool ecl_kw_iset_bool(ecl_kw, int, bool)") - _iget_int = EclPrototype("int ecl_kw_iget_int(ecl_kw, int)") - _iget_double = EclPrototype("double ecl_kw_iget_double(ecl_kw, int)") - _iget_float = EclPrototype("float ecl_kw_iget_float(ecl_kw, int)") - _float_ptr = EclPrototype("float* ecl_kw_get_float_ptr(ecl_kw)") - _int_ptr = EclPrototype("int* ecl_kw_get_int_ptr(ecl_kw)") - _double_ptr = EclPrototype("double* ecl_kw_get_double_ptr(ecl_kw)") - _free = EclPrototype("void ecl_kw_free(ecl_kw)") - _fwrite = EclPrototype("void ecl_kw_fwrite(ecl_kw, fortio)") - _get_header = EclPrototype("char* ecl_kw_get_header (ecl_kw)") - _set_header = EclPrototype("void ecl_kw_set_header_name (ecl_kw, char*)") - _get_data_type = EclPrototype( - "ecl_data_type_obj ecl_kw_get_data_type_python(ecl_kw)" + _iget_bool = ResdataPrototype("bool rd_kw_iget_bool(rd_kw, int)") + _iset_bool = ResdataPrototype("bool rd_kw_iset_bool(rd_kw, int, bool)") + _iget_int = ResdataPrototype("int rd_kw_iget_int(rd_kw, int)") + _iget_double = ResdataPrototype("double rd_kw_iget_double(rd_kw, int)") + _iget_float = ResdataPrototype("float rd_kw_iget_float(rd_kw, int)") + _float_ptr = ResdataPrototype("float* rd_kw_get_float_ptr(rd_kw)") + _int_ptr = ResdataPrototype("int* rd_kw_get_int_ptr(rd_kw)") + _double_ptr = ResdataPrototype("double* rd_kw_get_double_ptr(rd_kw)") + _free = ResdataPrototype("void rd_kw_free(rd_kw)") + _fwrite = ResdataPrototype("void rd_kw_fwrite(rd_kw, fortio)") + _get_header = ResdataPrototype("char* rd_kw_get_header (rd_kw)") + _set_header = ResdataPrototype("void rd_kw_set_header_name (rd_kw, char*)") + _get_data_type = ResdataPrototype( + "rd_data_type_obj rd_kw_get_data_type_python(rd_kw)" ) - _int_sum = EclPrototype("int ecl_kw_element_sum_int(ecl_kw)") - _float_sum = EclPrototype("double ecl_kw_element_sum_float(ecl_kw)") - _iadd_squared = EclPrototype("void ecl_kw_inplace_add_squared(ecl_kw, ecl_kw)") - _isqrt = EclPrototype("void ecl_kw_inplace_sqrt(ecl_kw)") - _iadd = EclPrototype("void ecl_kw_inplace_add(ecl_kw, ecl_kw)") - _imul = EclPrototype("void ecl_kw_inplace_mul(ecl_kw, ecl_kw)") - _idiv = EclPrototype("void ecl_kw_inplace_div(ecl_kw, ecl_kw)") - _isub = EclPrototype("void ecl_kw_inplace_sub(ecl_kw, ecl_kw)") - _iabs = EclPrototype("void ecl_kw_inplace_abs(ecl_kw)") - _equal = EclPrototype("bool ecl_kw_equal(ecl_kw, ecl_kw)") - _equal_numeric = EclPrototype( - "bool ecl_kw_numeric_equal(ecl_kw, ecl_kw, double, double)" + _int_sum = ResdataPrototype("int rd_kw_element_sum_int(rd_kw)") + _float_sum = ResdataPrototype("double rd_kw_element_sum_float(rd_kw)") + _iadd_squared = ResdataPrototype("void rd_kw_inplace_add_squared(rd_kw, rd_kw)") + _isqrt = ResdataPrototype("void rd_kw_inplace_sqrt(rd_kw)") + _iadd = ResdataPrototype("void rd_kw_inplace_add(rd_kw, rd_kw)") + _imul = ResdataPrototype("void rd_kw_inplace_mul(rd_kw, rd_kw)") + _idiv = ResdataPrototype("void rd_kw_inplace_div(rd_kw, rd_kw)") + _isub = ResdataPrototype("void rd_kw_inplace_sub(rd_kw, rd_kw)") + _iabs = ResdataPrototype("void rd_kw_inplace_abs(rd_kw)") + _equal = ResdataPrototype("bool rd_kw_equal(rd_kw, rd_kw)") + _equal_numeric = ResdataPrototype( + "bool rd_kw_numeric_equal(rd_kw, rd_kw, double, double)" ) - _assert_binary = EclPrototype( - "bool ecl_kw_size_and_numeric_type_equal(ecl_kw, ecl_kw)" + _assert_binary = ResdataPrototype( + "bool rd_kw_size_and_numeric_type_equal(rd_kw, rd_kw)" ) - _scale_int = EclPrototype("void ecl_kw_scale_int(ecl_kw, int)") - _scale_float = EclPrototype("void ecl_kw_scale_float_or_double(ecl_kw, double)") - _shift_int = EclPrototype("void ecl_kw_shift_int(ecl_kw, int)") - _shift_float = EclPrototype("void ecl_kw_shift_float_or_double(ecl_kw, double)") - _copy_data = EclPrototype("void ecl_kw_memcpy_data(ecl_kw, ecl_kw)") - _set_int = EclPrototype("void ecl_kw_scalar_set_int(ecl_kw, int)") - _set_float = EclPrototype( - "void ecl_kw_scalar_set_float_or_double(ecl_kw, double)" + _scale_int = ResdataPrototype("void rd_kw_scale_int(rd_kw, int)") + _scale_float = ResdataPrototype( + "void rd_kw_scale_float_or_double(rd_kw, double)" + ) + _shift_int = ResdataPrototype("void rd_kw_shift_int(rd_kw, int)") + _shift_float = ResdataPrototype( + "void rd_kw_shift_float_or_double(rd_kw, double)" + ) + _copy_data = ResdataPrototype("void rd_kw_memcpy_data(rd_kw, rd_kw)") + _set_int = ResdataPrototype("void rd_kw_scalar_set_int(rd_kw, int)") + _set_float = ResdataPrototype( + "void rd_kw_scalar_set_float_or_double(rd_kw, double)" ) - _max_min_int = EclPrototype("void ecl_kw_max_min_int(ecl_kw, int*, int*)") - _max_min_float = EclPrototype( - "void ecl_kw_max_min_float(ecl_kw, float*, float*)" + _max_min_int = ResdataPrototype("void rd_kw_max_min_int(rd_kw, int*, int*)") + _max_min_float = ResdataPrototype( + "void rd_kw_max_min_float(rd_kw, float*, float*)" ) - _max_min_double = EclPrototype( - "void ecl_kw_max_min_double(ecl_kw, double*, double*)" + _max_min_double = ResdataPrototype( + "void rd_kw_max_min_double(rd_kw, double*, double*)" ) - _fix_uninitialized = EclPrototype( - "void ecl_kw_fix_uninitialized(ecl_kw,int, int, int, int*)" + _fix_uninitialized = ResdataPrototype( + "void rd_kw_fix_uninitialized(rd_kw,int, int, int, int*)" ) - _create_actnum = EclPrototype("ecl_kw_obj ecl_kw_alloc_actnum(ecl_kw, float)") - _first_different = EclPrototype( - "int ecl_kw_first_different(ecl_kw, ecl_kw, int, double, double)" + _create_actnum = ResdataPrototype("rd_kw_obj rd_kw_alloc_actnum(rd_kw, float)") + _first_different = ResdataPrototype( + "int rd_kw_first_different(rd_kw, rd_kw, int, double, double)" ) - _resize = EclPrototype("void ecl_kw_resize(ecl_kw, int)") - _safe_div = EclPrototype("bool ecl_kw_inplace_safe_div(ecl_kw,ecl_kw)") + _resize = ResdataPrototype("void rd_kw_resize(rd_kw, int)") + _safe_div = ResdataPrototype("bool rd_kw_inplace_safe_div(rd_kw,rd_kw)") @classmethod def createCReference(cls, c_ptr, parent=None): - ecl_kw = super(EclKW, cls).createCReference(c_ptr, parent=parent) - if ecl_kw is None: - raise ValueError("Failed to create EclKW instance") + rd_kw = super(ResdataKW, cls).createCReference(c_ptr, parent=parent) + if rd_kw is None: + raise ValueError("Failed to create ResdataKW instance") - ecl_kw.__private_init() - return ecl_kw + rd_kw.__private_init() + return rd_kw @classmethod def createPythonObject(cls, c_ptr): - ecl_kw = super(EclKW, cls).createPythonObject(c_ptr) - if ecl_kw is None: - raise ValueError("Failed to create EclKW instance") + rd_kw = super(ResdataKW, cls).createPythonObject(c_ptr) + if rd_kw is None: + raise ValueError("Failed to create ResdataKW instance") - ecl_kw.__private_init() - return ecl_kw + rd_kw.__private_init() + return rd_kw @classmethod def add_int_kw(cls, kw): @@ -238,11 +243,11 @@ def copy(self): return self._copyc() @classmethod - def read_grdecl(cls, fileH, kw, strict=True, ecl_type=None): + def read_grdecl(cls, fileH, kw, strict=True, rd_type=None): """ - Function to load an EclKW instance from a grdecl formatted filehandle. + Function to load an ResdataKW instance from a grdecl formatted filehandle. - This constructor can be used to load an EclKW instance from a + This constructor can be used to load an ResdataKW instance from a grdecl formatted file; the input files for petrophysical properties are typically given as grdecl files. @@ -270,32 +275,32 @@ def read_grdecl(cls, fileH, kw, strict=True, ecl_type=None): reading the file. The algorithm for specifying type, in order of presedence, is as follows: - 1. The optional argument @ecl_type can be used to specify + 1. The optional argument @rd_type can be used to specify the type: - special_int_kw = EclKW.read_grdecl(fileH, 'INTKW', ecl_type=ECL_INT) + special_int_kw = ResdataKW.read_grdecl(fileH, 'INTKW', rd_type=RD_INT) - If ecl_type is different from ECL_INT or - ECL_FLOAT a TypeError exception will be raised. + If rd_type is different from RD_INT or + RD_FLOAT a TypeError exception will be raised. - If ecl_type == None (the default), the method will continue + If rd_type == None (the default), the method will continue to point 2. or 3. to determine the correct type. 2. If the keyword is included in the set built in set - 'int_kw_set' the type will be ECL_INT_TYPE. + 'int_kw_set' the type will be RD_INT_TYPE. - pvtnum_kw = EclKW.read_grdecl(fileH, 'PVTNUM') + pvtnum_kw = ResdataKW.read_grdecl(fileH, 'PVTNUM') Observe that (currently) no case conversions take place when checking the 'int_kw_set'. The current built in set is accesible through the int_kw property. - 3. Otherwise the default is float, i.e. ECL_FLOAT. + 3. Otherwise the default is float, i.e. RD_FLOAT. - EclKw reads grdecl with EclDataType - poro_kw = EclKW.read_grdecl(fileH, 'PORO') + ResdataKw reads grdecl with ResdataDataType + poro_kw = ResdataKW.read_grdecl(fileH, 'PORO') Observe that since the grdecl files are quite weakly @@ -316,24 +321,24 @@ def read_grdecl(cls, fileH, kw, strict=True, ecl_type=None): % kw ) - if ecl_type is None: + if rd_type is None: if cls.int_kw_set.__contains__(kw): - ecl_type = EclDataType.ECL_INT + rd_type = ResdataDataType.RD_INT else: - ecl_type = EclDataType.ECL_FLOAT + rd_type = ResdataDataType.RD_FLOAT - ecl_type = warn_and_cast_data_type(ecl_type) + rd_type = warn_and_cast_data_type(rd_type) - if not isinstance(ecl_type, EclDataType): - raise TypeError("Expected EclDataType, was: %s" % type(ecl_type)) + if not isinstance(rd_type, ResdataDataType): + raise TypeError("Expected ResdataDataType, was: %s" % type(rd_type)) - if not ecl_type in [EclDataType.ECL_FLOAT, EclDataType.ECL_INT]: + if not rd_type in [ResdataDataType.RD_FLOAT, ResdataDataType.RD_INT]: raise ValueError( "The type:%s is invalid when loading keyword:%s" - % (ecl_type.type_name, kw) + % (rd_type.type_name, kw) ) - return cls._load_grdecl(cfile, kw, strict, ecl_type) + return cls._load_grdecl(cfile, kw, strict, rd_type) @classmethod def fseek_grdecl(cls, fileH, kw, rewind=False): @@ -366,7 +371,7 @@ def fseek_grdecl(cls, fileH, kw, rewind=False): @classmethod def fread(cls, fortio): """ - Will read a new EclKW instance from the open FortIO file. + Will read a new ResdataKW instance from the open FortIO file. """ return cls._fread_alloc(fortio) @@ -381,18 +386,18 @@ def __repr__(self): mi, ma = self.getMinMax() mm = "min=%.2f, max=%.2f" % (mi, ma) ad = self._ad_str() - fmt = 'EclKW(size=%d, name="%s", %s) %s' + fmt = 'ResdataKW(size=%d, name="%s", %s) %s' return fmt % (si, nm, mm, ad) def __init__(self, name, size, data_type): - """Creates a brand new EclKW instance. + """Creates a brand new ResdataKW instance. - This method will create a grand spanking new EclKW + This method will create a grand spanking new ResdataKW instance. The instance will get name @name @size elements and datatype @data_type. Using this method you could create a SOIL keyword with: - soil_kw = EclKW("SOIL", 10000, ECL_FLOAT_TYPE) + soil_kw = ResdataKW("SOIL", 10000, RD_FLOAT_TYPE) """ if len(name) > 8: @@ -400,11 +405,13 @@ def __init__(self, name, size, data_type): data_type = warn_and_cast_data_type(data_type) - if not isinstance(data_type, EclDataType): - raise TypeError("Expected an EclDataType, received: %s" % type(data_type)) + if not isinstance(data_type, ResdataDataType): + raise TypeError( + "Expected an ResdataDataType, received: %s" % type(data_type) + ) c_ptr = self._alloc_new(name, size, data_type) - super(EclKW, self).__init__(c_ptr) + super(ResdataKW, self).__init__(c_ptr) self.__private_init() def __private_init(self): @@ -435,7 +442,9 @@ def __private_init(self): elif self.data_type.is_string(): self.str_fmt = "%" + str(self.data_type.element_size) + "s" else: - raise ValueError("Unknown EclDataType (%s)!" % self.data_type.type_name) + raise ValueError( + "Unknown ResdataDataType (%s)!" % self.data_type.type_name + ) def sub_copy(self, offset, count, new_header=None): """ @@ -471,7 +480,7 @@ def is_numeric(self): """ return self.data_type.is_numeric() - def ecl_kw_instance(self): + def rd_kw_instance(self): return True def __len__(self): @@ -484,8 +493,8 @@ def __deep_copy__(self, memo): """ Python special routine used to perform deep copy. """ - ecl_kw = self.copy() - return ecl_kw + rd_kw = self.copy() + return rd_kw def __getitem__(self, index): """ @@ -553,7 +562,7 @@ def __setitem__(self, index, value): def __IMUL__(self, factor, mul=True): if self.isNumeric(): - if hasattr(factor, "ecl_kw_instance"): + if hasattr(factor, "rd_kw_instance"): if self.assert_binary(factor): if mul: self._imul(factor) @@ -724,23 +733,23 @@ def assign(self, value, mask=None, force_active=False): """ Assign a value to current kw instance. - This method is used to assign value(s) to the current EclKW + This method is used to assign value(s) to the current ResdataKW instance. The @value parameter can either be a scalar, or - another EclKW instance. To set all elements of a keyword to + another ResdataKW instance. To set all elements of a keyword to 1.0: kw.assign(1.0) The numerical type of @value must be compatible with the current keyword. The optional @mask argument should be an - EclRegion instance which can be used to limit the assignment - to only parts of the EclKW. In the example below we select all + ResdataRegion instance which can be used to limit the assignment + to only parts of the ResdataKW. In the example below we select all the elements with PORO below 0.10, and then assign EQLNUM value 88 to those cells: - grid = ecl.EclGrid("ECLIPSE.EGRID") - reg = ecl.EclRegion(grid, false) - init = ecl.EclFile("ECLIPSE.INIT") + grid = ecl.ResdataGrid("ECLIPSE.EGRID") + reg = ecl.ResdataRegion(grid, false) + init = ecl.ResdataFile("ECLIPSE.INIT") poro = init["PORO"][0] eqlnum = init["EQLNUM"][0] @@ -748,7 +757,7 @@ def assign(self, value, mask=None, force_active=False): eqlnum.assign(88, mask = reg) - The EclRegion instance has two equivalent sets of selected + The ResdataRegion instance has two equivalent sets of selected indices; one consisting of active indices and one consisting of global indices. By default the assign() method will select the global indices if the keyword has nx*ny*nz elements and @@ -826,7 +835,7 @@ def apply(self, func, arg=None, mask=None, force_active=False): """ Will apply the function @func on the keyword - inplace. - The function @func should take a scalar value from the ecl_kw + The function @func should take a scalar value from the rd_kw vector as input, and return a scalar value of the same type; optionally you can supply a second argument with the @arg attribute: @@ -868,10 +877,10 @@ def equal(self, other): The check is based on the content of the keywords, and not pointer comparison. """ - if isinstance(other, EclKW): + if isinstance(other, ResdataKW): return self._equal(other) else: - raise TypeError("Can only compare with another EclKW") + raise TypeError("Can only compare with another ResdataKW") def __eq__(self, other): return self.equal(other) @@ -890,7 +899,7 @@ def equal_numeric(self, other, epsilon=1e-6, abs_epsilon=None, rel_epsilon=None) ignored in the test. """ - if isinstance(other, EclKW): + if isinstance(other, ResdataKW): if abs_epsilon is None: abs_epsilon = epsilon @@ -899,13 +908,13 @@ def equal_numeric(self, other, epsilon=1e-6, abs_epsilon=None, rel_epsilon=None) return self._equal_numeric(other, abs_epsilon, rel_epsilon) else: - raise TypeError("Can only compare with another EclKW") + raise TypeError("Can only compare with another ResdataKW") ################################################################# def deep_copy(self): - ecl_kw = self.__deep_copy__({}) - return ecl_kw + rd_kw = self.__deep_copy__({}) + return rd_kw def fort_io_size(self): """ @@ -979,7 +988,7 @@ def get_min(self): @property def type(self): - warnings.warn("ecl_kw.type is deprecated, use .data_type", DeprecationWarning) + warnings.warn("rd_kw.type is deprecated, use .data_type", DeprecationWarning) return self._get_type() @property @@ -993,9 +1002,10 @@ def type_name(self): def type_name(self): return self.data_type.type_name - def get_ecl_type(self): + def get_rd_type(self): warnings.warn( - "EclTypeEnum is deprecated. " + "You should instead provide an EclDataType", + "ResdataTypeEnum is deprecated. " + + "You should instead provide an ResdataDataType", DeprecationWarning, ) @@ -1069,7 +1079,7 @@ def __str__(self): def numpy_view(self): """Will return a numpy view to the underlying data. - The data in this numpy array is *shared* with the EclKW + The data in this numpy array is *shared* with the ResdataKW instance, meaning that updates in one will be reflected in the other. """ @@ -1089,12 +1099,12 @@ def numpy_view(self): return numpy.frombuffer(ap.contents, dtype=self.dtype) def numpy_copy(self): - """Will return a numpy array which contains a copy of the EclKW data. + """Will return a numpy array which contains a copy of the ResdataKW data. The numpy array has a separate copy of the data, so that - changes to either the numpy array or the EclKW will *not* be + changes to either the numpy array or the ResdataKW will *not* be reflected in the other datastructure. This is in contrast to - the EclKW.numpyView() method where the underlying data is + the ResdataKW.numpyView() method where the underlying data is shared. """ view = self.numpyView() @@ -1113,9 +1123,9 @@ def write_grdecl(self, file): existing GRDECL file, set all poro values below 0.05 to 0.00 and write back an updated GRDECL file. - poro = ecl.EclKW.read_grdecl(open("poro1.grdecl", "r"), "PORO") - grid = ecl.EclGrid("ECLIPSE.EGRID") - reg = ecl.EclRegion(grid, False) + poro = ecl.ResdataKW.read_grdecl(open("poro1.grdecl", "r"), "PORO") + grid = ecl.ResdataGrid("ECLIPSE.EGRID") + reg = ecl.ResdataRegion(grid, False) reg.select_below(poro, 0.05) poro.assign(0.0, mask=reg) @@ -1207,8 +1217,8 @@ def first_different( return self._first_different(other, offset, abs_epsilon, rel_epsilon) def scatter_copy(self, actnum): - if not isinstance(actnum, EclKW): - raise TypeError("The actnum argument must be of type EclKW") + if not isinstance(actnum, ResdataKW): + raise TypeError("The actnum argument must be of type ResdataKW") return self._global_copy(actnum) @@ -1231,18 +1241,18 @@ def safe_div(self, divisor): ) -monkey_the_camel(EclKW, "intKeywords", EclKW.int_keywords, classmethod) -monkey_the_camel(EclKW, "isNumeric", EclKW.is_numeric) -monkey_the_camel(EclKW, "fortIOSize", EclKW.fort_io_size) -monkey_the_camel(EclKW, "setName", EclKW.set_name) -monkey_the_camel(EclKW, "getName", EclKW.get_name) -monkey_the_camel(EclKW, "getMinMax", EclKW.get_min_max) -monkey_the_camel(EclKW, "getMax", EclKW.get_max) -monkey_the_camel(EclKW, "getMin", EclKW.get_min) -monkey_the_camel(EclKW, "typeName", EclKW.type_name) -monkey_the_camel(EclKW, "getEclType", EclKW.get_ecl_type) -monkey_the_camel(EclKW, "numpyView", EclKW.numpy_view) -monkey_the_camel(EclKW, "numpyCopy", EclKW.numpy_copy) -monkey_the_camel(EclKW, "fixUninitialized", EclKW.fix_uninitialized) -monkey_the_camel(EclKW, "getDataPtr", EclKW.get_data_ptr) -monkey_the_camel(EclKW, "firstDifferent", EclKW.first_different) +monkey_the_camel(ResdataKW, "intKeywords", ResdataKW.int_keywords, classmethod) +monkey_the_camel(ResdataKW, "isNumeric", ResdataKW.is_numeric) +monkey_the_camel(ResdataKW, "fortIOSize", ResdataKW.fort_io_size) +monkey_the_camel(ResdataKW, "setName", ResdataKW.set_name) +monkey_the_camel(ResdataKW, "getName", ResdataKW.get_name) +monkey_the_camel(ResdataKW, "getMinMax", ResdataKW.get_min_max) +monkey_the_camel(ResdataKW, "getMax", ResdataKW.get_max) +monkey_the_camel(ResdataKW, "getMin", ResdataKW.get_min) +monkey_the_camel(ResdataKW, "typeName", ResdataKW.type_name) +monkey_the_camel(ResdataKW, "getResdataType", ResdataKW.get_rd_type) +monkey_the_camel(ResdataKW, "numpyView", ResdataKW.numpy_view) +monkey_the_camel(ResdataKW, "numpyCopy", ResdataKW.numpy_copy) +monkey_the_camel(ResdataKW, "fixUninitialized", ResdataKW.fix_uninitialized) +monkey_the_camel(ResdataKW, "getDataPtr", ResdataKW.get_data_ptr) +monkey_the_camel(ResdataKW, "firstDifferent", ResdataKW.first_different) diff --git a/python/resdata/resfile/rd_restart_file.py b/python/resdata/resfile/rd_restart_file.py index 1063d0bded..1b601aeb98 100644 --- a/python/resdata/resfile/rd_restart_file.py +++ b/python/resdata/resfile/rd_restart_file.py @@ -1,26 +1,28 @@ from cwrap import BaseCClass -from ecl import EclFileEnum, EclFileFlagEnum, EclPrototype -from ecl.eclfile import Ecl3DFile, EclFile -from ecl.util.util import CTime, monkey_the_camel +from resdata import ResdataFileEnum, ResdataFileFlagEnum, ResdataPrototype +from resdata.eclfile import Resdata3DFile, ResdataFile +from resdata.util.util import CTime, monkey_the_camel -class EclRestartHead(BaseCClass): - TYPE_NAME = "ecl_rsthead" - _alloc = EclPrototype("void* ecl_rsthead_alloc(ecl_file_view , int )", bind=False) - _alloc_from_kw = EclPrototype( - "void* ecl_rsthead_alloc_from_kw(int , ecl_kw , ecl_kw , ecl_kw )", bind=False +class ResdataRestartHead(BaseCClass): + TYPE_NAME = "rd_rsthead" + _alloc = ResdataPrototype( + "void* rd_rsthead_alloc(rd_file_view , int )", bind=False ) - _free = EclPrototype("void ecl_rsthead_free(ecl_rsthead)") - _get_report_step = EclPrototype("int ecl_rsthead_get_report_step(ecl_rsthead)") - _get_sim_time = EclPrototype("time_t ecl_rsthead_get_sim_time(ecl_rsthead)") - _get_sim_days = EclPrototype("double ecl_rsthead_get_sim_days(ecl_rsthead)") - _get_nxconz = EclPrototype("int ecl_rsthead_get_nxconz(ecl_rsthead)") - _get_ncwmax = EclPrototype("int ecl_rsthead_get_ncwmax(ecl_rsthead)") + _alloc_from_kw = ResdataPrototype( + "void* rd_rsthead_alloc_from_kw(int , rd_kw , rd_kw , rd_kw )", bind=False + ) + _free = ResdataPrototype("void rd_rsthead_free(rd_rsthead)") + _get_report_step = ResdataPrototype("int rd_rsthead_get_report_step(rd_rsthead)") + _get_sim_time = ResdataPrototype("time_t rd_rsthead_get_sim_time(rd_rsthead)") + _get_sim_days = ResdataPrototype("double rd_rsthead_get_sim_days(rd_rsthead)") + _get_nxconz = ResdataPrototype("int rd_rsthead_get_nxconz(rd_rsthead)") + _get_ncwmax = ResdataPrototype("int rd_rsthead_get_ncwmax(rd_rsthead)") def __init__(self, kw_arg=None, rst_view=None): if kw_arg is None and rst_view is None: raise ValueError( - "Cannot construct EclRestartHead without one of kw_arg and rst_view, both were None!" + "Cannot construct ResdataRestartHead without one of kw_arg and rst_view, both were None!" ) if not kw_arg is None: @@ -31,7 +33,7 @@ def __init__(self, kw_arg=None, rst_view=None): else: c_ptr = self._alloc(rst_view, -1) - super(EclRestartHead, self).__init__(c_ptr) + super(ResdataRestartHead, self).__init__(c_ptr) def free(self): self._free() @@ -50,37 +52,37 @@ def well_details(self): return {"NXCONZ": self._get_nxconz(), "NCWMAX": self._get_ncwmax()} -ECL_FILE_DEFAULT = EclFileFlagEnum.ECL_FILE_DEFAULT +RD_FILE_DEFAULT = ResdataFileFlagEnum.RD_FILE_DEFAULT -class EclRestartFile(Ecl3DFile): - def __init__(self, grid, filename, flags=ECL_FILE_DEFAULT): +class ResdataRestartFile(Resdata3DFile): + def __init__(self, grid, filename, flags=RD_FILE_DEFAULT): """Will open an Eclipse restart file. - The EclRestartFile class will open an eclipse restart file, in + The ResdataRestartFile class will open an eclipse restart file, in unified or non unified format. The constructor will infer the file type based on the filename, and will raise a ValueError - exception if the file type is not ECL_RESTART_FILE or - ECL_UNIFIED_RESTART_FILE. + exception if the file type is not RD_RESTART_FILE or + RD_UNIFIED_RESTART_FILE. - The EclRestartFile will use a grid reference to create Ecl3DKw + The ResdataRestartFile will use a grid reference to create Resdata3DKw instances for all the keyword elements which have either 'nactive' or 'nx*ny*nz' elements. """ - file_type, report_step, fmt_file = EclFile.getFileType(filename) + file_type, report_step, fmt_file = ResdataFile.getFileType(filename) if not file_type in [ - EclFileEnum.ECL_RESTART_FILE, - EclFileEnum.ECL_UNIFIED_RESTART_FILE, + ResdataFileEnum.RD_RESTART_FILE, + ResdataFileEnum.RD_UNIFIED_RESTART_FILE, ]: raise ValueError( 'The input filename "%s" does not correspond to a restart file. Please follow the Eclipse naming conventions' % filename ) - super(EclRestartFile, self).__init__(grid, filename, flags) + super(ResdataRestartFile, self).__init__(grid, filename, flags) self.rst_headers = None - if file_type == EclFileEnum.ECL_RESTART_FILE: + if file_type == ResdataFileEnum.RD_RESTART_FILE: self.is_unified = False self.report_step = report_step else: @@ -98,7 +100,9 @@ def assert_headers(self): if self.unified(): for index in range(self.num_named_kw("SEQNUM")): self.rst_headers.append( - EclRestartHead(rst_view=self.restartView(seqnum_index=index)) + ResdataRestartHead( + rst_view=self.restartView(seqnum_index=index) + ) ) else: intehead_kw = self["INTEHEAD"][0] @@ -109,7 +113,7 @@ def assert_headers(self): logihead_kw = None self.rst_headers.append( - EclRestartHead( + ResdataRestartHead( kw_arg=(self.report_step, intehead_kw, doubhead_kw, logihead_kw) ) ) @@ -145,9 +149,11 @@ def get_header(self, index): return self.rst_headers[index] -monkey_the_camel(EclRestartHead, "getReportStep", EclRestartHead.get_report_step) -monkey_the_camel(EclRestartHead, "getSimDate", EclRestartHead.get_sim_date) -monkey_the_camel(EclRestartHead, "getSimDays", EclRestartHead.get_sim_days) +monkey_the_camel( + ResdataRestartHead, "getReportStep", ResdataRestartHead.get_report_step +) +monkey_the_camel(ResdataRestartHead, "getSimDate", ResdataRestartHead.get_sim_date) +monkey_the_camel(ResdataRestartHead, "getSimDays", ResdataRestartHead.get_sim_days) -monkey_the_camel(EclRestartFile, "assertHeaders", EclRestartFile.assert_headers) -monkey_the_camel(EclRestartFile, "timeList", EclRestartFile.time_list) +monkey_the_camel(ResdataRestartFile, "assertHeaders", ResdataRestartFile.assert_headers) +monkey_the_camel(ResdataRestartFile, "timeList", ResdataRestartFile.time_list) diff --git a/python/resdata/rft/CMakeLists.txt b/python/resdata/rft/CMakeLists.txt index 448009803c..8532520172 100644 --- a/python/resdata/rft/CMakeLists.txt +++ b/python/resdata/rft/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PYTHON_SOURCES __init__.py well_trajectory.py ecl_rft.py ecl_rft_cell.py) +set(PYTHON_SOURCES __init__.py well_trajectory.py rd_rft.py rd_rft_cell.py) -add_python_package("python.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ecl/rft +add_python_package("python.ecl.rft" ${PYTHON_INSTALL_PREFIX}/resdata/rft "${PYTHON_SOURCES}" True) diff --git a/python/resdata/rft/__init__.py b/python/resdata/rft/__init__.py index d68d815af1..1743f103b3 100644 --- a/python/resdata/rft/__init__.py +++ b/python/resdata/rft/__init__.py @@ -1,8 +1,8 @@ """ - ecl_rft/[EclRFTFile , EclRFT , EclRFTCell]: Loads an ECLIPSE RFT/PLT + rd_rft/[ResdataRFTFile , ResdataRFT , ResdataRFTCell]: Loads an ECLIPSE RFT/PLT file, and can afterwords be used to support various queries. """ from .well_trajectory import WellTrajectory -from .ecl_rft_cell import EclPLTCell, EclRFTCell -from .ecl_rft import EclRFT, EclRFTFile +from .rd_rft_cell import ResdataPLTCell, ResdataRFTCell +from .rd_rft import ResdataRFT, ResdataRFTFile diff --git a/python/resdata/rft/rd_rft.py b/python/resdata/rft/rd_rft.py index 58ec88d63e..71cb46d353 100644 --- a/python/resdata/rft/rd_rft.py +++ b/python/resdata/rft/rd_rft.py @@ -4,17 +4,17 @@ from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.util.util import monkey_the_camel -from ecl.util.util import CTime -from ecl.rft import EclRFTCell, EclPLTCell +from resdata import ResdataPrototype +from resdata.util.util import monkey_the_camel +from resdata.util.util import CTime +from resdata.rft import ResdataRFTCell, ResdataPLTCell -class EclRFT(BaseCClass): - """The EclRFT class contains the information for *one* RFT. +class ResdataRFT(BaseCClass): + """The ResdataRFT class contains the information for *one* RFT. The ECLIPSE RFT file can contain three different types of RFT like - objects which are lumped together; the EclRFTClass is a container + objects which are lumped together; the ResdataRFTClass is a container for such objects. The three different object types which can be found in an RFT file are: @@ -30,37 +30,37 @@ class EclRFT(BaseCClass): has coordinates, pressure and depth. """ - TYPE_NAME = "ecl_rft" - _alloc = EclPrototype( - "void* ecl_rft_node_alloc_new( char* , char* , time_t , double)", bind=False + TYPE_NAME = "rd_rft" + _alloc = ResdataPrototype( + "void* rd_rft_node_alloc_new( char* , char* , time_t , double)", bind=False ) - _free = EclPrototype("void ecl_rft_node_free( ecl_rft )") - _get_type = EclPrototype("int ecl_rft_node_get_type( ecl_rft )") - _get_well = EclPrototype("char* ecl_rft_node_get_well_name( ecl_rft )") - _get_date = EclPrototype("time_t ecl_rft_node_get_date( ecl_rft )") - _get_size = EclPrototype("int ecl_rft_node_get_size( ecl_rft )") - _iget_cell = EclPrototype("void* ecl_rft_node_iget_cell( ecl_rft )") - _iget_depth = EclPrototype("double ecl_rft_node_iget_depth( ecl_rft )") - _iget_pressure = EclPrototype("double ecl_rft_node_iget_pressure(ecl_rft)") - _iget_ijk = EclPrototype( - "void ecl_rft_node_iget_ijk( ecl_rft , int , int*, int*, int*)" + _free = ResdataPrototype("void rd_rft_node_free( rd_rft )") + _get_type = ResdataPrototype("int rd_rft_node_get_type( rd_rft )") + _get_well = ResdataPrototype("char* rd_rft_node_get_well_name( rd_rft )") + _get_date = ResdataPrototype("time_t rd_rft_node_get_date( rd_rft )") + _get_size = ResdataPrototype("int rd_rft_node_get_size( rd_rft )") + _iget_cell = ResdataPrototype("void* rd_rft_node_iget_cell( rd_rft )") + _iget_depth = ResdataPrototype("double rd_rft_node_iget_depth( rd_rft )") + _iget_pressure = ResdataPrototype("double rd_rft_node_iget_pressure(rd_rft)") + _iget_ijk = ResdataPrototype( + "void rd_rft_node_iget_ijk( rd_rft , int , int*, int*, int*)" ) - _iget_swat = EclPrototype("double ecl_rft_node_iget_swat(ecl_rft)") - _iget_sgas = EclPrototype("double ecl_rft_node_iget_sgas(ecl_rft)") - _iget_orat = EclPrototype("double ecl_rft_node_iget_orat(ecl_rft)") - _iget_wrat = EclPrototype("double ecl_rft_node_iget_wrat(ecl_rft)") - _iget_grat = EclPrototype("double ecl_rft_node_iget_grat(ecl_rft)") - _lookup_ijk = EclPrototype( - "void* ecl_rft_node_lookup_ijk( ecl_rft , int , int , int)" + _iget_swat = ResdataPrototype("double rd_rft_node_iget_swat(rd_rft)") + _iget_sgas = ResdataPrototype("double rd_rft_node_iget_sgas(rd_rft)") + _iget_orat = ResdataPrototype("double rd_rft_node_iget_orat(rd_rft)") + _iget_wrat = ResdataPrototype("double rd_rft_node_iget_wrat(rd_rft)") + _iget_grat = ResdataPrototype("double rd_rft_node_iget_grat(rd_rft)") + _lookup_ijk = ResdataPrototype( + "void* rd_rft_node_lookup_ijk( rd_rft , int , int , int)" ) - _is_RFT = EclPrototype("bool ecl_rft_node_is_RFT( ecl_rft )") - _is_PLT = EclPrototype("bool ecl_rft_node_is_PLT( ecl_rft )") - _is_SEGMENT = EclPrototype("bool ecl_rft_node_is_SEGMENT( ecl_rft )") - _is_MSW = EclPrototype("bool ecl_rft_node_is_MSW( ecl_rft )") + _is_RFT = ResdataPrototype("bool rd_rft_node_is_RFT( rd_rft )") + _is_PLT = ResdataPrototype("bool rd_rft_node_is_PLT( rd_rft )") + _is_SEGMENT = ResdataPrototype("bool rd_rft_node_is_SEGMENT( rd_rft )") + _is_MSW = ResdataPrototype("bool rd_rft_node_is_MSW( rd_rft )") def __init__(self, name, type_string, date, days): c_ptr = self._alloc(name, type_string, CTime(date), days) - super(EclRFT, self).__init__(c_ptr) + super(ResdataRFT, self).__init__(c_ptr) def free(self): self._free() @@ -88,13 +88,13 @@ def __len__(self): def is_RFT(self): """ - Is instance an RFT; in that case all the cells will be EclRFTCell instances. + Is instance an RFT; in that case all the cells will be ResdataRFTCell instances. """ return self._is_RFT() def is_PLT(self): """ - Is instance a PLT; in that case all the cells will be EclPLTCell instances. + Is instance a PLT; in that case all the cells will be ResdataPLTCell instances. """ return self._is_PLT() @@ -125,9 +125,9 @@ def get_date(self): def __cell_ref(self, cell_ptr): if self.is_RFT(): - return EclRFTCell.createCReference(cell_ptr, self) + return ResdataRFTCell.createCReference(cell_ptr, self) elif self.is_PLT(): - return EclPLTCell.createCReference(cell_ptr, self) + return ResdataPLTCell.createCReference(cell_ptr, self) else: raise NotImplementedError("Only RFT and PLT cells are implemented") @@ -147,7 +147,7 @@ def __getitem__(self, index): cell = rft[4] The return value from the __getitem__() method is either an - EclRFTCell instance or a EclPLTCell instance, depending on the + ResdataRFTCell instance or a ResdataPLTCell instance, depending on the type of this particular RFT object. For MSW wells the cells will come in sorted order along the wellpath, @@ -176,37 +176,37 @@ def ijkget(self, ijk): return None -class EclRFTFile(BaseCClass): - TYPE_NAME = "ecl_rft_file" - _load = EclPrototype("void* ecl_rft_file_alloc_case( char* )", bind=False) - _iget = EclPrototype("ecl_rft_ref ecl_rft_file_iget_node( ecl_rft_file , int )") - _get_rft = EclPrototype( - "ecl_rft_ref ecl_rft_file_get_well_time_rft( ecl_rft_file , char* , time_t)" +class ResdataRFTFile(BaseCClass): + TYPE_NAME = "rd_rft_file" + _load = ResdataPrototype("void* rd_rft_file_alloc_case( char* )", bind=False) + _iget = ResdataPrototype("rd_rft_ref rd_rft_file_iget_node( rd_rft_file , int )") + _get_rft = ResdataPrototype( + "rd_rft_ref rd_rft_file_get_well_time_rft( rd_rft_file , char* , time_t)" ) - _has_rft = EclPrototype("bool ecl_rft_file_case_has_rft( char* )", bind=False) - _free = EclPrototype("void ecl_rft_file_free( ecl_rft_file )") - _get_size = EclPrototype( - "int ecl_rft_file_get_size__( ecl_rft_file , char* , time_t)" + _has_rft = ResdataPrototype("bool rd_rft_file_case_has_rft( char* )", bind=False) + _free = ResdataPrototype("void rd_rft_file_free( rd_rft_file )") + _get_size = ResdataPrototype( + "int rd_rft_file_get_size__( rd_rft_file , char* , time_t)" ) - _get_num_wells = EclPrototype("int ecl_rft_file_get_num_wells( ecl_rft_file )") + _get_num_wells = ResdataPrototype("int rd_rft_file_get_num_wells( rd_rft_file )") """ - The EclRFTFile class is used to load an ECLIPSE RFT file. + The ResdataRFTFile class is used to load an ECLIPSE RFT file. - The EclRFTFile serves as a container which can load and hold the + The ResdataRFTFile serves as a container which can load and hold the content of an ECLIPSE RFT file. The RFT files will in general contain data for several wells and several times in one large - container. The EclRFTClass class contains methods get the the RFT + container. The ResdataRFTClass class contains methods get the the RFT results for a specific time and/or well. - The EclRFTFile class can in general contain a mix of RFT and PLT + The ResdataRFTFile class can in general contain a mix of RFT and PLT measurements. The class does not really differentiate between these. """ def __init__(self, case): c_ptr = self._load(case) - super(EclRFTFile, self).__init__(c_ptr) + super(ResdataRFTFile, self).__init__(c_ptr) def __len__(self): return self._get_size(None, CTime(-1)) @@ -226,7 +226,7 @@ def __getitem__(self, index): def size(self, well=None, date=None): """ - The number of elements in EclRFTFile container. + The number of elements in ResdataRFTFile container. By default the size() method will return the total number of RFTs/PLTs in the container, but by specifying the optional @@ -234,7 +234,7 @@ def size(self, well=None, date=None): number of well measurements matching that time or well name. The well argument can contain wildcards. - rftFile = ecl.EclRFTFile( "ECLIPSE.RFT" ) + rftFile = ecl.ResdataRFTFile( "ECLIPSE.RFT" ) print "Total number of RFTs : %d" % rftFile.size( ) print "RFTs matching OP* : %d" % rftFile.size( well = "OP*" ) print "RFTs at 01/01/2010 : %d" % rftFile.size( date = datetime.date( 2010 , 1 , 1 )) @@ -290,8 +290,8 @@ def __repr__(self): return self._create_repr("wells = %d" % w) -monkey_the_camel(EclRFT, "getWellName", EclRFT.get_well_name) -monkey_the_camel(EclRFT, "getDate", EclRFT.get_date) +monkey_the_camel(ResdataRFT, "getWellName", ResdataRFT.get_well_name) +monkey_the_camel(ResdataRFT, "getDate", ResdataRFT.get_date) -monkey_the_camel(EclRFTFile, "getNumWells", EclRFTFile.get_num_wells) -monkey_the_camel(EclRFTFile, "getHeaders", EclRFTFile.get_headers) +monkey_the_camel(ResdataRFTFile, "getNumWells", ResdataRFTFile.get_num_wells) +monkey_the_camel(ResdataRFTFile, "getHeaders", ResdataRFTFile.get_headers) diff --git a/python/resdata/rft/rd_rft_cell.py b/python/resdata/rft/rd_rft_cell.py index d367815f5a..0e9f45bf2e 100644 --- a/python/resdata/rft/rd_rft_cell.py +++ b/python/resdata/rft/rd_rft_cell.py @@ -1,5 +1,5 @@ from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class RFTCell(BaseCClass): @@ -8,7 +8,7 @@ class RFTCell(BaseCClass): The RFTCell class contains the elements which are common to both RFT and PLT. The list of common elements include the corrdinates (i,j,k) the pressure and the depth of the cell. Actual user access - should be based on the derived classes EclRFTCell and EclPLTCell. + should be based on the derived classes ResdataRFTCell and ResdataPLTCell. Observe that from june 2013 the properties i,j and k which return offset 1 coordinate values are deprecated, and you should rather @@ -17,12 +17,12 @@ class RFTCell(BaseCClass): """ TYPE_NAME = "rft_cell" - _free = EclPrototype("void ecl_rft_cell_free(rft_cell)") - _get_pressure = EclPrototype("double ecl_rft_cell_get_pressure(rft_cell)") - _get_depth = EclPrototype("double ecl_rft_cell_get_depth(rft_cell)") - _get_i = EclPrototype("int ecl_rft_cell_get_i(rft_cell)") - _get_j = EclPrototype("int ecl_rft_cell_get_j(rft_cell)") - _get_k = EclPrototype("int ecl_rft_cell_get_k(rft_cell)") + _free = ResdataPrototype("void rd_rft_cell_free(rft_cell)") + _get_pressure = ResdataPrototype("double rd_rft_cell_get_pressure(rft_cell)") + _get_depth = ResdataPrototype("double rd_rft_cell_get_depth(rft_cell)") + _get_i = ResdataPrototype("int rd_rft_cell_get_i(rft_cell)") + _get_j = ResdataPrototype("int rd_rft_cell_get_j(rft_cell)") + _get_k = ResdataPrototype("int rd_rft_cell_get_k(rft_cell)") def free(self): self._free() @@ -51,19 +51,19 @@ def depth(self): ################################################################# -class EclRFTCell(RFTCell): - TYPE_NAME = "ecl_rft_cell" - _alloc_RFT = EclPrototype( - "void* ecl_rft_cell_alloc_RFT(int, int, int, double, double, double, double)", +class ResdataRFTCell(RFTCell): + TYPE_NAME = "rd_rft_cell" + _alloc_RFT = ResdataPrototype( + "void* rd_rft_cell_alloc_RFT(int, int, int, double, double, double, double)", bind=False, ) - _get_swat = EclPrototype("double ecl_rft_cell_get_swat(ecl_rft_cell)") - _get_soil = EclPrototype("double ecl_rft_cell_get_soil(ecl_rft_cell)") - _get_sgas = EclPrototype("double ecl_rft_cell_get_sgas(ecl_rft_cell)") + _get_swat = ResdataPrototype("double rd_rft_cell_get_swat(rd_rft_cell)") + _get_soil = ResdataPrototype("double rd_rft_cell_get_soil(rd_rft_cell)") + _get_sgas = ResdataPrototype("double rd_rft_cell_get_sgas(rd_rft_cell)") def __init__(self, i, j, k, depth, pressure, swat, sgas): c_ptr = self._alloc_RFT(i, j, k, depth, pressure, swat, sgas) - super(EclRFTCell, self).__init__(c_ptr) + super(ResdataRFTCell, self).__init__(c_ptr) @property def swat(self): @@ -81,31 +81,33 @@ def soil(self): ################################################################# -class EclPLTCell(RFTCell): - TYPE_NAME = "ecl_plt_cell" - _alloc_PLT = EclPrototype( - "void* ecl_rft_cell_alloc_PLT(int, int, int, double, double, double, double, double, double, double, double, double, double, double)", +class ResdataPLTCell(RFTCell): + TYPE_NAME = "rd_plt_cell" + _alloc_PLT = ResdataPrototype( + "void* rd_rft_cell_alloc_PLT(int, int, int, double, double, double, double, double, double, double, double, double, double, double)", bind=False, ) - _get_orat = EclPrototype("double ecl_rft_cell_get_orat(ecl_plt_cell)") - _get_grat = EclPrototype("double ecl_rft_cell_get_grat(ecl_plt_cell)") - _get_wrat = EclPrototype("double ecl_rft_cell_get_wrat(ecl_plt_cell)") + _get_orat = ResdataPrototype("double rd_rft_cell_get_orat(rd_plt_cell)") + _get_grat = ResdataPrototype("double rd_rft_cell_get_grat(rd_plt_cell)") + _get_wrat = ResdataPrototype("double rd_rft_cell_get_wrat(rd_plt_cell)") - _get_flowrate = EclPrototype("double ecl_rft_cell_get_flowrate(ecl_plt_cell)") - _get_oil_flowrate = EclPrototype( - "double ecl_rft_cell_get_oil_flowrate(ecl_plt_cell)" + _get_flowrate = ResdataPrototype("double rd_rft_cell_get_flowrate(rd_plt_cell)") + _get_oil_flowrate = ResdataPrototype( + "double rd_rft_cell_get_oil_flowrate(rd_plt_cell)" ) - _get_gas_flowrate = EclPrototype( - "double ecl_rft_cell_get_gas_flowrate(ecl_plt_cell)" + _get_gas_flowrate = ResdataPrototype( + "double rd_rft_cell_get_gas_flowrate(rd_plt_cell)" ) - _get_water_flowrate = EclPrototype( - "double ecl_rft_cell_get_water_flowrate(ecl_plt_cell)" + _get_water_flowrate = ResdataPrototype( + "double rd_rft_cell_get_water_flowrate(rd_plt_cell)" ) - _get_conn_start = EclPrototype( - "double ecl_rft_cell_get_connection_start(ecl_plt_cell)" + _get_conn_start = ResdataPrototype( + "double rd_rft_cell_get_connection_start(rd_plt_cell)" + ) + _get_conn_end = ResdataPrototype( + "double rd_rft_cell_get_connection_end(rd_plt_cell)" ) - _get_conn_end = EclPrototype("double ecl_rft_cell_get_connection_end(ecl_plt_cell)") def __init__( self, @@ -140,7 +142,7 @@ def __init__( gas_flowrate, water_flowrate, ) - super(EclPLTCell, self).__init__(c_ptr) + super(ResdataPLTCell, self).__init__(c_ptr) @property def orat(self): diff --git a/python/resdata/summary/CMakeLists.txt b/python/resdata/summary/CMakeLists.txt index 06441f2f67..a4653116cd 100644 --- a/python/resdata/summary/CMakeLists.txt +++ b/python/resdata/summary/CMakeLists.txt @@ -1,14 +1,14 @@ set(PYTHON_SOURCES __init__.py - ecl_npv.py - ecl_smspec_node.py - ecl_sum.py - ecl_sum_keyword_vector.py - ecl_sum_node.py - ecl_sum_tstep.py - ecl_sum_vector.py - ecl_cmp.py - ecl_sum_var_type.py) + rd_npv.py + rd_smspec_node.py + rd_sum.py + rd_sum_keyword_vector.py + rd_sum_node.py + rd_sum_tstep.py + rd_sum_vector.py + rd_cmp.py + rd_sum_var_type.py) -add_python_package("python.ecl.summary" ${PYTHON_INSTALL_PREFIX}/ecl/summary +add_python_package("python.ecl.summary" ${PYTHON_INSTALL_PREFIX}/resdata/summary "${PYTHON_SOURCES}" True) diff --git a/python/resdata/summary/__init__.py b/python/resdata/summary/__init__.py index 064ac29c9e..900f437750 100644 --- a/python/resdata/summary/__init__.py +++ b/python/resdata/summary/__init__.py @@ -1,18 +1,18 @@ """ - ecl_sum/EclSum: This will load summary results from an ECLIPSE run; - both data file(s) and the SMSPEC file. The EclSum object can be + rd_sum/RdSum: This will load summary results from an ECLIPSE run; + both data file(s) and the SMSPEC file. The RdSum object can be used as basis for queries on summary vectors. """ -import ecl.util.util -import ecl.util.geometry +import resdata.util.util +import resdata.util.geometry -from .ecl_sum_var_type import EclSumVarType -from .ecl_sum_tstep import EclSumTStep -from .ecl_sum import EclSum # , EclSumVector, EclSumNode, EclSMSPECNode -from .ecl_sum_keyword_vector import EclSumKeyWordVector -from .ecl_sum_node import EclSumNode -from .ecl_sum_vector import EclSumVector -from .ecl_npv import EclNPV, NPVPriceVector -from .ecl_cmp import EclCmp +from .rd_sum_var_type import RdSumVarType +from .rd_sum_tstep import RdSumTStep +from .rd_sum import RdSum # , RdSumVector, RdSumNode, ResdataSMSPECNode +from .rd_sum_keyword_vector import RdSumKeyWordVector +from .rd_sum_node import RdSumNode +from .rd_sum_vector import RdSumVector +from .rd_npv import ResdataNPV, NPVPriceVector +from .rd_cmp import ResdataCmp diff --git a/python/resdata/summary/rd_cmp.py b/python/resdata/summary/rd_cmp.py index e91b86cf99..1f671a9cf7 100644 --- a/python/resdata/summary/rd_cmp.py +++ b/python/resdata/summary/rd_cmp.py @@ -1,8 +1,8 @@ -from ecl.util.util import monkey_the_camel -from ecl.summary import EclSum +from resdata.util.util import monkey_the_camel +from resdata.summary import RdSum -class EclCase(object): +class ResdataCase(object): def __init__(self, case): self.case = case @@ -23,7 +23,7 @@ def wells(self): return self.summary.wells() def load_summary(self): - self.summary = EclSum(self.case) + self.summary = RdSum(self.case) def start_time_equal(self, other): if self.summary.getDataStartTime() == other.summary.getDataStartTime(): @@ -56,7 +56,7 @@ def cmp_summary_vector(self, other, key, sample=100): raise KeyError("Key:%s was not present in both cases" % key) -class EclCmp(object): +class ResdataCmp(object): def __init__(self, test_case, ref_case): """Class to compare to simulation cases with Eclipse formatted result files. @@ -68,8 +68,8 @@ def __init__(self, test_case, ref_case): The constructor will start be calling the method initCheck() to check that the two cases are 'in the same ballpark'. """ - self.test_case = EclCase(test_case) - self.ref_case = EclCase(ref_case) + self.test_case = ResdataCase(test_case) + self.ref_case = ResdataCase(ref_case) self.initCheck() @@ -111,7 +111,7 @@ def cmp_summary_vector(self, key, sample=100): So that a natural way to evaluate the check for numerical equality, based on the relative error could be: - delta, scale = ecl_cmp.cmpSummaryVector("WWCT:OP_1") + delta, scale = rd_cmp.cmpSummaryVector("WWCT:OP_1") if delta/scale < 0.0001: print("Equal enough") @@ -142,14 +142,14 @@ def test_wells(self): return self.test_case.wells() -monkey_the_camel(EclCase, "loadSummary", EclCase.load_summary) -monkey_the_camel(EclCase, "startTimeEqual", EclCase.start_time_equal) -monkey_the_camel(EclCase, "endTimeEqual", EclCase.end_time_equal) -monkey_the_camel(EclCase, "cmpSummaryVector", EclCase.cmp_summary_vector) +monkey_the_camel(ResdataCase, "loadSummary", ResdataCase.load_summary) +monkey_the_camel(ResdataCase, "startTimeEqual", ResdataCase.start_time_equal) +monkey_the_camel(ResdataCase, "endTimeEqual", ResdataCase.end_time_equal) +monkey_the_camel(ResdataCase, "cmpSummaryVector", ResdataCase.cmp_summary_vector) -monkey_the_camel(EclCmp, "initCheck", EclCmp.init_check) -monkey_the_camel(EclCmp, "hasSummaryVector", EclCmp.has_summary_vector) -monkey_the_camel(EclCmp, "endTimeEqual", EclCmp.end_time_equal) -monkey_the_camel(EclCmp, "cmpSummaryVector", EclCmp.cmp_summary_vector) -monkey_the_camel(EclCmp, "testKeys", EclCmp.test_keys) -monkey_the_camel(EclCmp, "testWells", EclCmp.test_wells) +monkey_the_camel(ResdataCmp, "initCheck", ResdataCmp.init_check) +monkey_the_camel(ResdataCmp, "hasSummaryVector", ResdataCmp.has_summary_vector) +monkey_the_camel(ResdataCmp, "endTimeEqual", ResdataCmp.end_time_equal) +monkey_the_camel(ResdataCmp, "cmpSummaryVector", ResdataCmp.cmp_summary_vector) +monkey_the_camel(ResdataCmp, "testKeys", ResdataCmp.test_keys) +monkey_the_camel(ResdataCmp, "testWells", ResdataCmp.test_wells) diff --git a/python/resdata/summary/rd_npv.py b/python/resdata/summary/rd_npv.py index 39952f7d2a..261a9f21c8 100644 --- a/python/resdata/summary/rd_npv.py +++ b/python/resdata/summary/rd_npv.py @@ -2,8 +2,8 @@ import datetime import numbers -from ecl.util.util import monkey_the_camel -from ecl.summary import EclSum +from resdata.util.util import monkey_the_camel +from resdata.summary import RdSum class NPVParseKey(object): @@ -111,11 +111,11 @@ def eval(self, date): raise ValueError("Input date:%s before start of vector" % date) -class EclNPV(object): +class ResdataNPV(object): sumKeyRE = re.compile("[\[]([\w:,]+)[\]]") def __init__(self, baseCase): - sum = EclSum(baseCase) + sum = RdSum(baseCase) if sum: self.baseCase = sum else: @@ -187,9 +187,9 @@ def eval_npv(self): monkey_the_camel(NPVPriceVector, "assertDate", NPVPriceVector.assert_date, staticmethod) monkey_the_camel(NPVPriceVector, "evalDate", NPVPriceVector.eval_date) -monkey_the_camel(EclNPV, "getExpression", EclNPV.get_expression) -monkey_the_camel(EclNPV, "setExpression", EclNPV.set_expression) -monkey_the_camel(EclNPV, "getKeyList", EclNPV.get_key_list) -monkey_the_camel(EclNPV, "addKey", EclNPV.add_key) -monkey_the_camel(EclNPV, "parseExpression", EclNPV.parse_expression) -monkey_the_camel(EclNPV, "evalNPV", EclNPV.eval_npv) +monkey_the_camel(ResdataNPV, "getExpression", ResdataNPV.get_expression) +monkey_the_camel(ResdataNPV, "setExpression", ResdataNPV.set_expression) +monkey_the_camel(ResdataNPV, "getKeyList", ResdataNPV.get_key_list) +monkey_the_camel(ResdataNPV, "addKey", ResdataNPV.add_key) +monkey_the_camel(ResdataNPV, "parseExpression", ResdataNPV.parse_expression) +monkey_the_camel(ResdataNPV, "evalNPV", ResdataNPV.eval_npv) diff --git a/python/resdata/summary/rd_smspec_node.py b/python/resdata/summary/rd_smspec_node.py index 3af23ae4a7..86e99ae13a 100644 --- a/python/resdata/summary/rd_smspec_node.py +++ b/python/resdata/summary/rd_smspec_node.py @@ -1,9 +1,9 @@ from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata import ResdataPrototype -class EclSMSPECNode(BaseCClass): +class ResdataSMSPECNode(BaseCClass): """ Small class with some meta information about a summary variable. @@ -15,29 +15,33 @@ class EclSMSPECNode(BaseCClass): """ TYPE_NAME = "smspec_node" - _node_is_total = EclPrototype("bool smspec_node_is_total( smspec_node )") - _node_is_historical = EclPrototype("bool smspec_node_is_historical( smspec_node )") - _node_is_rate = EclPrototype("bool smspec_node_is_rate( smspec_node )") - _node_unit = EclPrototype("char* smspec_node_get_unit( smspec_node )") - _node_wgname = EclPrototype("char* smspec_node_get_wgname( smspec_node )") - _node_keyword = EclPrototype("char* smspec_node_get_keyword( smspec_node )") - _node_num = EclPrototype("int smspec_node_get_num( smspec_node )") - _node_need_num = EclPrototype("bool smspec_node_need_nums( smspec_node )") - _gen_key1 = EclPrototype("char* smspec_node_get_gen_key1( smspec_node )") - _gen_key2 = EclPrototype("char* smspec_node_get_gen_key2( smspec_node )") - _var_type = EclPrototype("ecl_sum_var_type smspec_node_get_var_type( smspec_node )") - _cmp = EclPrototype("int smspec_node_cmp( smspec_node , smspec_node)") - _get_default = EclPrototype("float smspec_node_get_default(smspec_node)") + _node_is_total = ResdataPrototype("bool smspec_node_is_total( smspec_node )") + _node_is_historical = ResdataPrototype( + "bool smspec_node_is_historical( smspec_node )" + ) + _node_is_rate = ResdataPrototype("bool smspec_node_is_rate( smspec_node )") + _node_unit = ResdataPrototype("char* smspec_node_get_unit( smspec_node )") + _node_wgname = ResdataPrototype("char* smspec_node_get_wgname( smspec_node )") + _node_keyword = ResdataPrototype("char* smspec_node_get_keyword( smspec_node )") + _node_num = ResdataPrototype("int smspec_node_get_num( smspec_node )") + _node_need_num = ResdataPrototype("bool smspec_node_need_nums( smspec_node )") + _gen_key1 = ResdataPrototype("char* smspec_node_get_gen_key1( smspec_node )") + _gen_key2 = ResdataPrototype("char* smspec_node_get_gen_key2( smspec_node )") + _var_type = ResdataPrototype( + "rd_sum_var_type smspec_node_get_var_type( smspec_node )" + ) + _cmp = ResdataPrototype("int smspec_node_cmp( smspec_node , smspec_node)") + _get_default = ResdataPrototype("float smspec_node_get_default(smspec_node)") def __init__(self): - super(EclSMSPECNode, self).__init__(0) # null pointer + super(ResdataSMSPECNode, self).__init__(0) # null pointer raise NotImplementedError("Class can not be instantiated directly!") def cmp(self, other): - if isinstance(other, EclSMSPECNode): + if isinstance(other, ResdataSMSPECNode): return self._cmp(other) else: - raise TypeError("Other argument must be of type EclSMSPECNode") + raise TypeError("Other argument must be of type ResdataSMSPECNode") def __lt__(self, other): return self.cmp(other) < 0 @@ -173,10 +177,10 @@ def is_historical(self): return self._node_is_historical() -monkey_the_camel(EclSMSPECNode, "getKey1", EclSMSPECNode.get_key1) -monkey_the_camel(EclSMSPECNode, "getKey2", EclSMSPECNode.get_key2) -monkey_the_camel(EclSMSPECNode, "varType", EclSMSPECNode.var_type) -monkey_the_camel(EclSMSPECNode, "getNum", EclSMSPECNode.get_num) -monkey_the_camel(EclSMSPECNode, "isRate", EclSMSPECNode.is_rate) -monkey_the_camel(EclSMSPECNode, "isTotal", EclSMSPECNode.is_total) -monkey_the_camel(EclSMSPECNode, "isHistorical", EclSMSPECNode.is_historical) +monkey_the_camel(ResdataSMSPECNode, "getKey1", ResdataSMSPECNode.get_key1) +monkey_the_camel(ResdataSMSPECNode, "getKey2", ResdataSMSPECNode.get_key2) +monkey_the_camel(ResdataSMSPECNode, "varType", ResdataSMSPECNode.var_type) +monkey_the_camel(ResdataSMSPECNode, "getNum", ResdataSMSPECNode.get_num) +monkey_the_camel(ResdataSMSPECNode, "isRate", ResdataSMSPECNode.is_rate) +monkey_the_camel(ResdataSMSPECNode, "isTotal", ResdataSMSPECNode.is_total) +monkey_the_camel(ResdataSMSPECNode, "isHistorical", ResdataSMSPECNode.is_historical) diff --git a/python/resdata/summary/rd_sum.py b/python/resdata/summary/rd_sum.py index 34bcdf53c8..178f999d81 100644 --- a/python/resdata/summary/rd_sum.py +++ b/python/resdata/summary/rd_sum.py @@ -2,7 +2,7 @@ Module for loading and querying summary data. The low-level organisation of summary data is extensively documented -in the C source files ecl_sum.c, ecl_smspec.c and ecl_sum_data in the +in the C source files rd_sum.c, rd_smspec.c and rd_sum_data in the resdata/src directory. """ @@ -20,19 +20,19 @@ # argument. In the python code this order has been reversed. from cwrap import BaseCClass, CFILE -from ecl.util.util import monkey_the_camel -from ecl.util.util import StringList, CTime, DoubleVector, TimeVector, IntVector +from resdata.util.util import monkey_the_camel +from resdata.util.util import StringList, CTime, DoubleVector, TimeVector, IntVector -from ecl.summary import EclSumTStep -from ecl.summary import EclSumVarType -from ecl.summary.ecl_sum_vector import EclSumVector -from ecl.summary.ecl_smspec_node import EclSMSPECNode -from ecl import EclPrototype, EclUnitTypeEnum +from resdata.summary import RdSumTStep +from resdata.summary import RdSumVarType +from resdata.summary.rd_sum_vector import RdSumVector +from resdata.summary.rd_smspec_node import ResdataSMSPECNode +from resdata import ResdataPrototype, ResdataUnitTypeEnum -# , EclSumKeyWordVector +# , RdSumKeyWordVector -# import ecl.ecl_plot.sum_plot as sum_plot +# import resdata.rd_plot.sum_plot as sum_plot # The date2num function is a verbatim copy of the _to_ordinalf() # function from the matplotlib.dates module. Inserted here only to @@ -74,133 +74,139 @@ def date2num(dt): return base -class EclSum(BaseCClass): - TYPE_NAME = "ecl_sum" - _fread_alloc_case2 = EclPrototype( - "void* ecl_sum_fread_alloc_case2__(char*, char*, bool, bool, int)", +class RdSum(BaseCClass): + TYPE_NAME = "rd_sum" + _fread_alloc_case2 = ResdataPrototype( + "void* rd_sum_fread_alloc_case2__(char*, char*, bool, bool, int)", bind=False, ) - _fread_alloc = EclPrototype( - "void* ecl_sum_fread_alloc(char*, stringlist, char*, bool)", bind=False + _fread_alloc = ResdataPrototype( + "void* rd_sum_fread_alloc(char*, stringlist, char*, bool)", bind=False ) - _create_restart_writer = EclPrototype( - "ecl_sum_obj ecl_sum_alloc_restart_writer2(char*, char*, int, bool, bool, char*, time_t, bool, int, int, int)", + _create_restart_writer = ResdataPrototype( + "rd_sum_obj rd_sum_alloc_restart_writer2(char*, char*, int, bool, bool, char*, time_t, bool, int, int, int)", bind=False, ) - _create_writer = EclPrototype( - "ecl_sum_obj ecl_sum_alloc_writer(char*, bool, bool, char*, time_t, bool, int, int, int)", + _create_writer = ResdataPrototype( + "rd_sum_obj rd_sum_alloc_writer(char*, bool, bool, char*, time_t, bool, int, int, int)", bind=False, ) - _resample = EclPrototype( - "ecl_sum_obj ecl_sum_alloc_resample( ecl_sum, char*, time_t_vector, bool, bool)" + _resample = ResdataPrototype( + "rd_sum_obj rd_sum_alloc_resample( rd_sum, char*, time_t_vector, bool, bool)" ) - _iiget = EclPrototype("double ecl_sum_iget(ecl_sum, int, int)") - _free = EclPrototype("void ecl_sum_free(ecl_sum)") - _data_length = EclPrototype("int ecl_sum_get_data_length(ecl_sum)") - _iget_sim_days = EclPrototype("double ecl_sum_iget_sim_days(ecl_sum, int) ") - _iget_report_step = EclPrototype("int ecl_sum_iget_report_step(ecl_sum, int) ") - _iget_sim_time = EclPrototype("time_t ecl_sum_iget_sim_time(ecl_sum, int) ") - _get_report_end = EclPrototype("int ecl_sum_iget_report_end(ecl_sum, int)") - _get_general_var = EclPrototype( - "double ecl_sum_get_general_var(ecl_sum, int, char*)" + _iiget = ResdataPrototype("double rd_sum_iget(rd_sum, int, int)") + _free = ResdataPrototype("void rd_sum_free(rd_sum)") + _data_length = ResdataPrototype("int rd_sum_get_data_length(rd_sum)") + _iget_sim_days = ResdataPrototype("double rd_sum_iget_sim_days(rd_sum, int) ") + _iget_report_step = ResdataPrototype( + "int rd_sum_iget_report_step(rd_sum, int) " ) - _get_general_var_index = EclPrototype( - "int ecl_sum_get_general_var_params_index(ecl_sum, char*)" + _iget_sim_time = ResdataPrototype("time_t rd_sum_iget_sim_time(rd_sum, int) ") + _get_report_end = ResdataPrototype("int rd_sum_iget_report_end(rd_sum, int)") + _get_general_var = ResdataPrototype( + "double rd_sum_get_general_var(rd_sum, int, char*)" ) - _get_general_var_from_sim_days = EclPrototype( - "double ecl_sum_get_general_var_from_sim_days(ecl_sum, double, char*)" + _get_general_var_index = ResdataPrototype( + "int rd_sum_get_general_var_params_index(rd_sum, char*)" ) - _get_general_var_from_sim_time = EclPrototype( - "double ecl_sum_get_general_var_from_sim_time(ecl_sum, time_t, char*)" + _get_general_var_from_sim_days = ResdataPrototype( + "double rd_sum_get_general_var_from_sim_days(rd_sum, double, char*)" ) - _solve_days = EclPrototype( - "double_vector_obj ecl_sum_alloc_days_solution(ecl_sum, char*, double, bool)" + _get_general_var_from_sim_time = ResdataPrototype( + "double rd_sum_get_general_var_from_sim_time(rd_sum, time_t, char*)" ) - _solve_dates = EclPrototype( - "time_t_vector_obj ecl_sum_alloc_time_solution(ecl_sum, char*, double, bool)" + _solve_days = ResdataPrototype( + "double_vector_obj rd_sum_alloc_days_solution(rd_sum, char*, double, bool)" ) - _get_first_gt = EclPrototype("int ecl_sum_get_first_gt(ecl_sum, int, double)") - _get_first_lt = EclPrototype("int ecl_sum_get_first_lt(ecl_sum, int, double)") - _get_start_date = EclPrototype("time_t ecl_sum_get_start_time(ecl_sum)") - _get_end_date = EclPrototype("time_t ecl_sum_get_end_time(ecl_sum)") - _get_last_report_step = EclPrototype( - "int ecl_sum_get_last_report_step(ecl_sum)" + _solve_dates = ResdataPrototype( + "time_t_vector_obj rd_sum_alloc_time_solution(rd_sum, char*, double, bool)" ) - _get_first_report_step = EclPrototype( - "int ecl_sum_get_first_report_step(ecl_sum)" + _get_first_gt = ResdataPrototype( + "int rd_sum_get_first_gt(rd_sum, int, double)" ) - _select_matching_keys = EclPrototype( - "void ecl_sum_select_matching_general_var_list(ecl_sum, char*, stringlist)" + _get_first_lt = ResdataPrototype( + "int rd_sum_get_first_lt(rd_sum, int, double)" ) - _has_key = EclPrototype("bool ecl_sum_has_general_var(ecl_sum, char*)") - _check_sim_time = EclPrototype("bool ecl_sum_check_sim_time(ecl_sum, time_t)") - _check_sim_days = EclPrototype("bool ecl_sum_check_sim_days(ecl_sum, double)") - _sim_length = EclPrototype("double ecl_sum_get_sim_length(ecl_sum)") - _get_first_day = EclPrototype("double ecl_sum_get_first_day(ecl_sum)") - _get_data_start = EclPrototype("time_t ecl_sum_get_data_start(ecl_sum)") - _get_unit = EclPrototype("char* ecl_sum_get_unit(ecl_sum, char*)") - _get_restart_case = EclPrototype("ecl_sum_ref ecl_sum_get_restart_case(ecl_sum)") - _get_restart_step = EclPrototype("int ecl_sum_get_restart_step(ecl_sum)") - _get_simcase = EclPrototype("char* ecl_sum_get_case(ecl_sum)") - _get_unit_system = EclPrototype("ecl_unit_enum ecl_sum_get_unit_system(ecl_sum)") - _get_base = EclPrototype("char* ecl_sum_get_base(ecl_sum)") - _get_path = EclPrototype("char* ecl_sum_get_path(ecl_sum)") - _get_abs_path = EclPrototype("char* ecl_sum_get_abs_path(ecl_sum)") - _get_report_step_from_time = EclPrototype( - "int ecl_sum_get_report_step_from_time(ecl_sum, time_t)" + _get_start_date = ResdataPrototype("time_t rd_sum_get_start_time(rd_sum)") + _get_end_date = ResdataPrototype("time_t rd_sum_get_end_time(rd_sum)") + _get_last_report_step = ResdataPrototype( + "int rd_sum_get_last_report_step(rd_sum)" ) - _get_report_step_from_days = EclPrototype( - "int ecl_sum_get_report_step_from_days(ecl_sum, double)" + _get_first_report_step = ResdataPrototype( + "int rd_sum_get_first_report_step(rd_sum)" ) - _get_report_time = EclPrototype("time_t ecl_sum_get_report_time(ecl_sum, int)") - _fwrite_sum = EclPrototype("void ecl_sum_fwrite(ecl_sum)") - _can_write = EclPrototype("bool ecl_sum_can_write(ecl_sum)") - _set_case = EclPrototype("void ecl_sum_set_case(ecl_sum, char*)") - _alloc_time_vector = EclPrototype( - "time_t_vector_obj ecl_sum_alloc_time_vector(ecl_sum, bool)" + _select_matching_keys = ResdataPrototype( + "void rd_sum_select_matching_general_var_list(rd_sum, char*, stringlist)" ) - _alloc_data_vector = EclPrototype( - "double_vector_obj ecl_sum_alloc_data_vector(ecl_sum, int, bool)" + _has_key = ResdataPrototype("bool rd_sum_has_general_var(rd_sum, char*)") + _check_sim_time = ResdataPrototype("bool rd_sum_check_sim_time(rd_sum, time_t)") + _check_sim_days = ResdataPrototype("bool rd_sum_check_sim_days(rd_sum, double)") + _sim_length = ResdataPrototype("double rd_sum_get_sim_length(rd_sum)") + _get_first_day = ResdataPrototype("double rd_sum_get_first_day(rd_sum)") + _get_data_start = ResdataPrototype("time_t rd_sum_get_data_start(rd_sum)") + _get_unit = ResdataPrototype("char* rd_sum_get_unit(rd_sum, char*)") + _get_restart_case = ResdataPrototype("rd_sum_ref rd_sum_get_restart_case(rd_sum)") + _get_restart_step = ResdataPrototype("int rd_sum_get_restart_step(rd_sum)") + _get_simcase = ResdataPrototype("char* rd_sum_get_case(rd_sum)") + _get_unit_system = ResdataPrototype("rd_unit_enum rd_sum_get_unit_system(rd_sum)") + _get_base = ResdataPrototype("char* rd_sum_get_base(rd_sum)") + _get_path = ResdataPrototype("char* rd_sum_get_path(rd_sum)") + _get_abs_path = ResdataPrototype("char* rd_sum_get_abs_path(rd_sum)") + _get_report_step_from_time = ResdataPrototype( + "int rd_sum_get_report_step_from_time(rd_sum, time_t)" ) - _get_var_node = EclPrototype( - "smspec_node_ref ecl_sum_get_general_var_node(ecl_sum, char*)" + _get_report_step_from_days = ResdataPrototype( + "int rd_sum_get_report_step_from_days(rd_sum, double)" ) - _create_well_list = EclPrototype( - "stringlist_obj ecl_sum_alloc_well_list(ecl_sum, char*)" + _get_report_time = ResdataPrototype("time_t rd_sum_get_report_time(rd_sum, int)") + _fwrite_sum = ResdataPrototype("void rd_sum_fwrite(rd_sum)") + _can_write = ResdataPrototype("bool rd_sum_can_write(rd_sum)") + _set_case = ResdataPrototype("void rd_sum_set_case(rd_sum, char*)") + _alloc_time_vector = ResdataPrototype( + "time_t_vector_obj rd_sum_alloc_time_vector(rd_sum, bool)" ) - _create_group_list = EclPrototype( - "stringlist_obj ecl_sum_alloc_group_list(ecl_sum, char*)" + _alloc_data_vector = ResdataPrototype( + "double_vector_obj rd_sum_alloc_data_vector(rd_sum, int, bool)" ) - _add_variable = EclPrototype( - "smspec_node_ref ecl_sum_add_var(ecl_sum, char*, char*, int, char*, double)" + _get_var_node = ResdataPrototype( + "smspec_node_ref rd_sum_get_general_var_node(rd_sum, char*)" ) - _add_tstep = EclPrototype( - "ecl_sum_tstep_ref ecl_sum_add_tstep(ecl_sum, int, double)" + _create_well_list = ResdataPrototype( + "stringlist_obj rd_sum_alloc_well_list(rd_sum, char*)" ) - _export_csv = EclPrototype( - "void ecl_sum_export_csv(ecl_sum, char*, stringlist, char*, char*)" + _create_group_list = ResdataPrototype( + "stringlist_obj rd_sum_alloc_group_list(rd_sum, char*)" ) - _identify_var_type = EclPrototype( - "ecl_sum_var_type ecl_sum_identify_var_type(char*)", bind=False + _add_variable = ResdataPrototype( + "smspec_node_ref rd_sum_add_var(rd_sum, char*, char*, int, char*, double)" ) - _is_rate = EclPrototype("bool smspec_node_identify_rate(char*)", bind=False) - _is_total = EclPrototype( - "bool smspec_node_identify_total(char*, ecl_sum_var_type)", bind=False + _add_tstep = ResdataPrototype( + "rd_sum_tstep_ref rd_sum_add_tstep(rd_sum, int, double)" ) - _get_last_value = EclPrototype( - "double ecl_sum_get_last_value_gen_key(ecl_sum, char*)" + _export_csv = ResdataPrototype( + "void rd_sum_export_csv(rd_sum, char*, stringlist, char*, char*)" ) - _get_first_value = EclPrototype( - "double ecl_sum_get_first_value_gen_key(ecl_sum, char*)" + _identify_var_type = ResdataPrototype( + "rd_sum_var_type rd_sum_identify_var_type(char*)", bind=False ) - _init_numpy_vector = EclPrototype( - "void ecl_sum_init_double_vector(ecl_sum, char*, double*)" + _is_rate = ResdataPrototype("bool smspec_node_identify_rate(char*)", bind=False) + _is_total = ResdataPrototype( + "bool smspec_node_identify_total(char*, rd_sum_var_type)", bind=False ) - _init_numpy_vector_interp = EclPrototype( - "void ecl_sum_init_double_vector_interp(ecl_sum, char*, time_t_vector, double*)" + _get_last_value = ResdataPrototype( + "double rd_sum_get_last_value_gen_key(rd_sum, char*)" ) - _init_numpy_datetime64 = EclPrototype( - "void ecl_sum_init_datetime64_vector(ecl_sum, int64*, int)" + _get_first_value = ResdataPrototype( + "double rd_sum_get_first_value_gen_key(rd_sum, char*)" + ) + _init_numpy_vector = ResdataPrototype( + "void rd_sum_init_double_vector(rd_sum, char*, double*)" + ) + _init_numpy_vector_interp = ResdataPrototype( + "void rd_sum_init_double_vector_interp(rd_sum, char*, time_t_vector, double*)" + ) + _init_numpy_datetime64 = ResdataPrototype( + "void rd_sum_init_datetime64_vector(rd_sum, int64*, int)" ) def __init__( @@ -211,7 +217,7 @@ def __init__( lazy_load=True, file_options=0, ): - """Loads a new EclSum instance with summary data. + """Loads a new RdSum instance with summary data. Loads a new summary results from the ECLIPSE case given by argument @load_case; @load_case should be the basename of the ECLIPSE @@ -247,7 +253,7 @@ def __init__( "Failed to create summary instance from argument:%s" % load_case ) - super(EclSum, self).__init__(c_pointer) + super(RdSum, self).__init__(c_pointer) self._load_case = load_case @classmethod @@ -266,31 +272,31 @@ def load(cls, smspec_file, unsmry_file, key_join_string=":", include_restart=Tru if c_ptr is None: raise IOError("Failed to create summary instance") - ecl_sum = cls.createPythonObject(c_ptr) - ecl_sum._load_case = smspec_file - return ecl_sum + rd_sum = cls.createPythonObject(c_ptr) + rd_sum._load_case = smspec_file + return rd_sum @classmethod def createCReference(cls, c_pointer, parent=None): - result = super(EclSum, cls).createCReference(c_pointer, parent) + result = super(RdSum, cls).createCReference(c_pointer, parent) return result @classmethod def createPythonObject(cls, c_pointer): - result = super(EclSum, cls).createPythonObject(c_pointer) + result = super(RdSum, cls).createPythonObject(c_pointer) return result @staticmethod def var_type(keyword): - return EclSum._identify_var_type(keyword) + return RdSum._identify_var_type(keyword) @staticmethod def is_rate(keyword): - return EclSum._is_rate(keyword) + return RdSum._is_rate(keyword) @staticmethod def is_total(keyword): - return EclSum._is_total(keyword, EclSum.var_type(keyword)) + return RdSum._is_total(keyword, RdSum.var_type(keyword)) @staticmethod def writer( @@ -306,12 +312,12 @@ def writer( ): """ The writer is not generally usable. - @rtype: EclSum + @rtype: RdSum """ start = CTime(start_time) - smry = EclSum._create_writer( + smry = RdSum._create_writer( case, fmt_output, unified, key_join_string, start, time_in_days, nx, ny, nz ) smry._load_case = "writer" @@ -333,12 +339,12 @@ def restart_writer( ): """ The writer is not generally usable. - @rtype: EclSum + @rtype: RdSum """ start = CTime(start_time) - smry = EclSum._create_restart_writer( + smry = RdSum._create_restart_writer( case, restart_case, restart_step, @@ -360,7 +366,7 @@ def add_variable(self, variable, wgname=None, num=0, unit="None", default_value= ) def add_t_step(self, report_step, sim_days): - """@rtype: EclSumTStep""" + """@rtype: RdSumTStep""" # report_step int if not isinstance(report_step, int): raise TypeError("Parameter report_step should be int, was %r" % report_step) @@ -375,7 +381,7 @@ def add_t_step(self, report_step, sim_days): def get_vector(self, key, report_only=False): """ - Will return EclSumVector according to @key. + Will return RdSumVector according to @key. Will raise exception KeyError if the summary object does not have @key. @@ -386,9 +392,9 @@ def get_vector(self, key, report_only=False): ) self.assertKeyValid(key) if report_only: - return EclSumVector(self, key, report_only=True) + return RdSumVector(self, key, report_only=True) else: - return EclSumVector(self, key) + return RdSumVector(self, key) def report_index_list(self): """ @@ -428,7 +434,7 @@ def get_values(self, key, report_only=False): If the optional argument report_only is true only the values corresponding to report steps are included. The method is - also available as the 'values' property of an EclSumVector + also available as the 'values' property of an RdSumVector instance. """ warnings.warn( @@ -557,7 +563,7 @@ def pandas_frame(self, time_index=None, column_keys=None): summary keys you will get a ValueError exception. - sum = EclSum(case) + sum = RdSum(case) monthly_dates = sum.time_range(interval="1M") data = sum.pandas_frame(time_index = monthly_dates, column_keys=["F*PT"]) @@ -568,12 +574,12 @@ def pandas_frame(self, time_index=None, column_keys=None): 2010-04-01 672.7 620.4 78.7 .... """ - from ecl.summary import EclSumKeyWordVector + from resdata.summary import RdSumKeyWordVector if column_keys is None: - keywords = EclSumKeyWordVector(self, add_keywords=True) + keywords = RdSumKeyWordVector(self, add_keywords=True) else: - keywords = EclSumKeyWordVector(self) + keywords = RdSumKeyWordVector(self) for key in column_keys: keywords.add_keywords(key) @@ -583,13 +589,13 @@ def pandas_frame(self, time_index=None, column_keys=None): if time_index is None: time_index = self.dates data = numpy.zeros([len(time_index), len(keywords)]) - EclSum._init_pandas_frame( + RdSum._init_pandas_frame( self, keywords, data.ctypes.data_as(ctypes.POINTER(ctypes.c_double)) ) else: time_points = self._make_time_vector(time_index) data = numpy.zeros([len(time_points), len(keywords)]) - EclSum._init_pandas_frame_interp( + RdSum._init_pandas_frame_interp( self, keywords, time_points, @@ -644,25 +650,25 @@ def from_pandas(cls, case, frame, dims=None, headers=None): var_list = [] if headers is None: - header_list = EclSum._compile_headers_list(frame.columns.values, dims) + header_list = RdSum._compile_headers_list(frame.columns.values, dims) else: - header_list = EclSum._compile_headers_list(headers, dims) + header_list = RdSum._compile_headers_list(headers, dims) if dims is None: dims = [1, 1, 1] - ecl_sum = EclSum.writer(case, start_time, dims[0], dims[1], dims[2]) + rd_sum = RdSum.writer(case, start_time, dims[0], dims[1], dims[2]) for kw, wgname, num, unit in header_list: var_list.append( - ecl_sum.addVariable(kw, wgname=wgname, num=num, unit=unit).getKey1() + rd_sum.addVariable(kw, wgname=wgname, num=num, unit=unit).getKey1() ) for i, time in enumerate(frame.index): days = (time - start_time).days - t_step = ecl_sum.addTStep(i + 1, days) + t_step = rd_sum.addTStep(i + 1, days) for var in var_list: t_step[var] = frame.iloc[i][var] - return ecl_sum + return rd_sum def get_key_index(self, key): """ @@ -675,13 +681,13 @@ def get_key_index(self, key): minor optimization in the case of many lookups of the same key: - sum = ecl.EclSum(case) + sum = ecl.RdSum(case) key_index = sum.get_key_index(key) for time_index in range(sum.length): value = sum.iiget(time_index, key_index) Quite low-level function, should probably rather use a - EclSumVector based function? + RdSumVector based function? """ index = self._get_general_var_index(key) if index >= 0: @@ -698,7 +704,7 @@ def last_value(self, key): total_production = sum.last_value("FOPT") - The alternative method 'last' will return a EclSumNode + The alternative method 'last' will return a RdSumNode instance with some extra time related information. """ if not key in self: @@ -724,7 +730,7 @@ def get_last_value(self, key): def get_last(self, key): """ - Will return the last EclSumNode corresponding to @key. + Will return the last RdSumNode corresponding to @key. If you are only interested in the final value, you can use the last_value() method. @@ -743,7 +749,7 @@ def iiget(self, time_index, key_index): with the get_key_index() method first. This is a quite low level function, in most cases it will be - natural to go via e.g. an EclSumVector instance. + natural to go via e.g. an RdSumVector instance. """ return self._iiget(time_index, key_index) @@ -759,7 +765,7 @@ def iget(self, key, time_index): wwct = sum.iget("WWCT:W5", time_index) This is a quite low level function, in most cases it will be - natural to go via e.g. an EclSumVector instance. + natural to go via e.g. an RdSumVector instance. """ return self._get_general_var(time_index, key) @@ -788,7 +794,7 @@ def __getitem__(self, key): """ Implements [] operator - @key should be a summary key. - The returned value will be a EclSumVector instance. + The returned value will be a RdSumVector instance. """ warnings.warn( "The method the [] operator will change behaviour in the future. It will then return a plain numpy vector. You are advised to change to use the numpy_vector() method right away", @@ -797,20 +803,20 @@ def __getitem__(self, key): return self.get_vector(key) def scale_vector(self, key, scalar): - msg = """The function EclSum.scale_vector has been removed. As an alternative you + msg = """The function RdSum.scale_vector has been removed. As an alternative you are advised to fetch vector as a numpy vector and then scale that yourself: - vec = ecl_sum.numpy_vector(key) + vec = rd_sum.numpy_vector(key) vec *= scalar """ raise NotImplementedError(msg) def shift_vector(self, key, addend): - msg = """The function EclSum.shift_vector has been removed. As an alternative you + msg = """The function RdSum.shift_vector has been removed. As an alternative you are advised to fetch vector as a numpy vector and then scale that yourself: - vec = ecl_sum.numpy_vector(key) + vec = rd_sum.numpy_vector(key) vec += scalar """ @@ -840,7 +846,7 @@ def get_interp(self, key, days=None, date=None): time limits of the simulation; if else the method will raise exception ValueError. - Also available as method get_interp() on the EclSumVector + Also available as method get_interp() on the RdSumVector class. """ self.assertKeyValid(key) @@ -867,7 +873,7 @@ def get_interp(self, key, days=None, date=None): def get_interp_row(self, key_list, sim_time, invalid_value=-1): ctime = CTime(sim_time) data = DoubleVector(initial_size=len(key_list), default_value=invalid_value) - EclSum._get_interp_vector(self, ctime, key_list, data) + RdSum._get_interp_vector(self, ctime, key_list, data) return data def time_range( @@ -1006,7 +1012,7 @@ def get_interp_vector(self, key, days_list=None, date_list=None): exception ValueError. Also available as method get_interp_vector() on the - EclSumVector class. + RdSumVector class. """ self.assertKeyValid(key) if days_list: @@ -1055,9 +1061,9 @@ def has_key(self, key): def smspec_node(self, key): """ - Will return a EclSMSPECNode instance corresponding to @key. + Will return a ResdataSMSPECNode instance corresponding to @key. - The returned EclSMPECNode instance can then be used to ask for + The returned ResdataSMPECNode instance can then be used to ask for various properties of the variable; i.e. if it is a rate variable, what is the unit, if it is a total variable and so on. @@ -1380,14 +1386,14 @@ def first_lt_index(self, key, limit): def first_gt(self, key, limit): """ - First EclSumNode of @key which is above @limit. + First RdSumNode of @key which is above @limit. """ vector = self[key] return vector.first_gt(limit) def first_lt(self, key, limit): """ - First EclSumNode of @key which is below @limit. + First RdSumNode of @key which is below @limit. """ vector = self[key] return vector.first_lt(limit) @@ -1412,7 +1418,7 @@ def solve_days(self, key, value, rates_clamp_lower=True): where the vector @key is equal @value. The method will return a list of values, which can have zero, one or multiple values: - case = EclSum("CASE") + case = RdSum("CASE") days = case.solveDays("RPR:2", 200) if len(days) == 0: @@ -1515,14 +1521,14 @@ def keys(self, pattern=None): def can_write(self): return self._can_write() - def fwrite(self, ecl_case=None): + def fwrite(self, rd_case=None): if not self.can_write(): raise NotImplementedError( "Write method is not implemented for this case. lazy_load=True??" ) - if ecl_case: - self._set_case(ecl_case) + if rd_case: + self._set_case(rd_case) self._fwrite_sum() @@ -1549,7 +1555,7 @@ def _nicename(self): def __repr__(self): """Returns, e.g. - EclSum("NORNE_ATW2013.UNSMRY", [1997-11-06 00:00:00, 2006-12-01 00:00:00], keys=3781) at 0x1609e20 + RdSum("NORNE_ATW2013.UNSMRY", [1997-11-06 00:00:00, 2006-12-01 00:00:00], keys=3781) at 0x1609e20 """ name = self._nicename() s_time = self.getStartTime() @@ -1565,7 +1571,7 @@ def dump_csv_line(self, time, keywords, pfile): """ cfile = CFILE(pfile) ctime = CTime(time) - EclSum._dump_csv_line(self, ctime, keywords, cfile) + RdSum._dump_csv_line(self, ctime, keywords, cfile) def export_csv(self, filename, keys=None, date_format="%Y-%m-%d", sep=";"): """Will create a CSV file with summary data. @@ -1574,8 +1580,8 @@ def export_csv(self, filename, keys=None, date_format="%Y-%m-%d", sep=";"): exported, but by using the optional keys parameter you can limit the keys which are exported: - ecl_sum = EclSum("CASE") - ecl_sum.exportCSV("case.csv", keys=["W*:OP1", "W*:OP2", "F*T"]) + rd_sum = RdSum("CASE") + rd_sum.exportCSV("case.csv", keys=["W*:OP1", "W*:OP2", "F*T"]) Will export all well related variables for wells 'OP1' and 'OP2' and all total field vectors. @@ -1607,36 +1613,36 @@ def resample( return new_case -import ecl.summary.ecl_sum_keyword_vector +import resdata.summary.rd_sum_keyword_vector -EclSum._dump_csv_line = EclPrototype( - "void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", +RdSum._dump_csv_line = ResdataPrototype( + "void rd_sum_fwrite_interp_csv_line(rd_sum, time_t, rd_sum_vector, FILE)", bind=False, ) -EclSum._get_interp_vector = EclPrototype( - "void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", +RdSum._get_interp_vector = ResdataPrototype( + "void rd_sum_get_interp_vector(rd_sum, time_t, rd_sum_vector, double_vector)", bind=False, ) -EclSum._init_pandas_frame = EclPrototype( - "void ecl_sum_init_double_frame(ecl_sum, ecl_sum_vector, double*)", bind=False +RdSum._init_pandas_frame = ResdataPrototype( + "void rd_sum_init_double_frame(rd_sum, rd_sum_vector, double*)", bind=False ) -EclSum._init_pandas_frame_interp = EclPrototype( - "void ecl_sum_init_double_frame_interp(ecl_sum, ecl_sum_vector, time_t_vector, double*)", +RdSum._init_pandas_frame_interp = ResdataPrototype( + "void rd_sum_init_double_frame_interp(rd_sum, rd_sum_vector, time_t_vector, double*)", bind=False, ) -monkey_the_camel(EclSum, "varType", EclSum.var_type, classmethod) -monkey_the_camel(EclSum, "addVariable", EclSum.add_variable) -monkey_the_camel(EclSum, "addTStep", EclSum.add_t_step) -monkey_the_camel(EclSum, "assertKeyValid", EclSum.assert_key_valid) -monkey_the_camel(EclSum, "scaleVector", EclSum.scale_vector) -monkey_the_camel(EclSum, "shiftVector", EclSum.shift_vector) -monkey_the_camel(EclSum, "timeRange", EclSum.time_range) -monkey_the_camel(EclSum, "blockedProduction", EclSum.blocked_production) -monkey_the_camel(EclSum, "getDataStartTime", EclSum.get_data_start_time) -monkey_the_camel(EclSum, "getStartTime", EclSum.get_start_time) -monkey_the_camel(EclSum, "getEndTime", EclSum.get_end_time) -monkey_the_camel(EclSum, "solveDates", EclSum.solve_dates) -monkey_the_camel(EclSum, "solveDays", EclSum.solve_days) -monkey_the_camel(EclSum, "dumpCSVLine", EclSum.dump_csv_line) -monkey_the_camel(EclSum, "exportCSV", EclSum.export_csv) +monkey_the_camel(RdSum, "varType", RdSum.var_type, classmethod) +monkey_the_camel(RdSum, "addVariable", RdSum.add_variable) +monkey_the_camel(RdSum, "addTStep", RdSum.add_t_step) +monkey_the_camel(RdSum, "assertKeyValid", RdSum.assert_key_valid) +monkey_the_camel(RdSum, "scaleVector", RdSum.scale_vector) +monkey_the_camel(RdSum, "shiftVector", RdSum.shift_vector) +monkey_the_camel(RdSum, "timeRange", RdSum.time_range) +monkey_the_camel(RdSum, "blockedProduction", RdSum.blocked_production) +monkey_the_camel(RdSum, "getDataStartTime", RdSum.get_data_start_time) +monkey_the_camel(RdSum, "getStartTime", RdSum.get_start_time) +monkey_the_camel(RdSum, "getEndTime", RdSum.get_end_time) +monkey_the_camel(RdSum, "solveDates", RdSum.solve_dates) +monkey_the_camel(RdSum, "solveDays", RdSum.solve_days) +monkey_the_camel(RdSum, "dumpCSVLine", RdSum.dump_csv_line) +monkey_the_camel(RdSum, "exportCSV", RdSum.export_csv) diff --git a/python/resdata/summary/rd_sum_keyword_vector.py b/python/resdata/summary/rd_sum_keyword_vector.py index e8de2c09d7..1808815687 100644 --- a/python/resdata/summary/rd_sum_keyword_vector.py +++ b/python/resdata/summary/rd_sum_keyword_vector.py @@ -7,25 +7,27 @@ # argument. In the python code this order has been reversed. from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata import ResdataPrototype -class EclSumKeyWordVector(BaseCClass): - TYPE_NAME = "ecl_sum_vector" - _alloc = EclPrototype("void* ecl_sum_vector_alloc(ecl_sum, bool)", bind=False) - _alloc_copy = EclPrototype( - "ecl_sum_vector_obj ecl_sum_vector_alloc_layout_copy(ecl_sum_vector, ecl_sum)" +class RdSumKeyWordVector(BaseCClass): + TYPE_NAME = "rd_sum_vector" + _alloc = ResdataPrototype("void* rd_sum_vector_alloc(rd_sum, bool)", bind=False) + _alloc_copy = ResdataPrototype( + "rd_sum_vector_obj rd_sum_vector_alloc_layout_copy(rd_sum_vector, rd_sum)" ) - _free = EclPrototype("void ecl_sum_vector_free(ecl_sum_vector)") - _add = EclPrototype("bool ecl_sum_vector_add_key(ecl_sum_vector, char*)") - _add_multiple = EclPrototype("void ecl_sum_vector_add_keys(ecl_sum_vector, char*)") - _get_size = EclPrototype("int ecl_sum_vector_get_size(ecl_sum_vector)") - _iget_key = EclPrototype("char* ecl_sum_vector_iget_key(ecl_sum_vector, int)") + _free = ResdataPrototype("void rd_sum_vector_free(rd_sum_vector)") + _add = ResdataPrototype("bool rd_sum_vector_add_key(rd_sum_vector, char*)") + _add_multiple = ResdataPrototype( + "void rd_sum_vector_add_keys(rd_sum_vector, char*)" + ) + _get_size = ResdataPrototype("int rd_sum_vector_get_size(rd_sum_vector)") + _iget_key = ResdataPrototype("char* rd_sum_vector_iget_key(rd_sum_vector, int)") - def __init__(self, ecl_sum, add_keywords=False): - c_pointer = self._alloc(ecl_sum, add_keywords) - super(EclSumKeyWordVector, self).__init__(c_pointer) + def __init__(self, rd_sum, add_keywords=False): + c_pointer = self._alloc(rd_sum, add_keywords) + super(RdSumKeyWordVector, self).__init__(c_pointer) def __getitem__(self, index): if index < 0: @@ -53,9 +55,9 @@ def add_keywords(self, keyword_pattern): def __repr__(self): return self._create_repr("len=%d" % len(self)) - def copy(self, ecl_sum): - return self._alloc_copy(ecl_sum) + def copy(self, rd_sum): + return self._alloc_copy(rd_sum) -monkey_the_camel(EclSumKeyWordVector, "addKeyword", EclSumKeyWordVector.add_keyword) -monkey_the_camel(EclSumKeyWordVector, "addKeywords", EclSumKeyWordVector.add_keywords) +monkey_the_camel(RdSumKeyWordVector, "addKeyword", RdSumKeyWordVector.add_keyword) +monkey_the_camel(RdSumKeyWordVector, "addKeywords", RdSumKeyWordVector.add_keywords) diff --git a/python/resdata/summary/rd_sum_node.py b/python/resdata/summary/rd_sum_node.py index f5188e21fb..d35d08f0da 100644 --- a/python/resdata/summary/rd_sum_node.py +++ b/python/resdata/summary/rd_sum_node.py @@ -1,12 +1,12 @@ -class EclSumNode(object): +class RdSumNode(object): def __init__(self, report_step, days, date, mpl_date, value): """ - EclSumNode is a 'struct' with a summary value and time. + RdSumNode is a 'struct' with a summary value and time. - EclSumNode - a small 'struct' with a summary value and time in - several formats. When iterating over a EclSumVector instance - you will get EclSumNode instances. The content of the - EclSumNode type is stored as plain attributes: + RdSumNode - a small 'struct' with a summary value and time in + several formats. When iterating over a RdSumVector instance + you will get RdSumNode instances. The content of the + RdSumNode type is stored as plain attributes: value : The actual value report_step : The report step @@ -22,4 +22,4 @@ def __init__(self, report_step, days, date, mpl_date, value): self.mpl_date = mpl_date def __repr__(self): - return "EclSumNode(days=%d, value=%g)" % (self.days, self.value) + return "RdSumNode(days=%d, value=%g)" % (self.days, self.value) diff --git a/python/resdata/summary/rd_sum_tstep.py b/python/resdata/summary/rd_sum_tstep.py index ff460d20e9..f0fde5399c 100644 --- a/python/resdata/summary/rd_sum_tstep.py +++ b/python/resdata/summary/rd_sum_tstep.py @@ -1,32 +1,32 @@ from cwrap import BaseCClass -from ecl.util.util import monkey_the_camel -from ecl.util.util import CTime -from ecl import EclPrototype +from resdata.util.util import monkey_the_camel +from resdata.util.util import CTime +from resdata import ResdataPrototype -class EclSumTStep(BaseCClass): - TYPE_NAME = "ecl_sum_tstep" - _alloc = EclPrototype( - "void* ecl_sum_tstep_alloc_new(int, int, float, void*)", bind=False +class RdSumTStep(BaseCClass): + TYPE_NAME = "rd_sum_tstep" + _alloc = ResdataPrototype( + "void* rd_sum_tstep_alloc_new(int, int, float, void*)", bind=False ) - _free = EclPrototype("void ecl_sum_tstep_free(ecl_sum_tstep)") - _get_sim_days = EclPrototype("double ecl_sum_tstep_get_sim_days(ecl_sum_tstep)") - _get_sim_time = EclPrototype("time_t ecl_sum_tstep_get_sim_time(ecl_sum_tstep)") - _get_report = EclPrototype("int ecl_sum_tstep_get_report(ecl_sum_tstep)") - _get_ministep = EclPrototype("int ecl_sum_tstep_get_ministep(ecl_sum_tstep)") - _set_from_key = EclPrototype( - "void ecl_sum_tstep_set_from_key(ecl_sum_tstep, char*, float)" + _free = ResdataPrototype("void rd_sum_tstep_free(rd_sum_tstep)") + _get_sim_days = ResdataPrototype("double rd_sum_tstep_get_sim_days(rd_sum_tstep)") + _get_sim_time = ResdataPrototype("time_t rd_sum_tstep_get_sim_time(rd_sum_tstep)") + _get_report = ResdataPrototype("int rd_sum_tstep_get_report(rd_sum_tstep)") + _get_ministep = ResdataPrototype("int rd_sum_tstep_get_ministep(rd_sum_tstep)") + _set_from_key = ResdataPrototype( + "void rd_sum_tstep_set_from_key(rd_sum_tstep, char*, float)" ) - _get_from_key = EclPrototype( - "double ecl_sum_tstep_get_from_key(ecl_sum_tstep, char*)" + _get_from_key = ResdataPrototype( + "double rd_sum_tstep_get_from_key(rd_sum_tstep, char*)" ) - _has_key = EclPrototype("bool ecl_sum_tstep_has_key(ecl_sum_tstep, char*)") + _has_key = ResdataPrototype("bool rd_sum_tstep_has_key(rd_sum_tstep, char*)") def __init__(self, report_step, mini_step, sim_days, smspec): sim_seconds = sim_days * 24 * 60 * 60 c_pointer = self._alloc(report_step, mini_step, sim_seconds, smspec) - super(EclSumTStep, self).__init__(c_pointer) + super(RdSumTStep, self).__init__(c_pointer) def get_sim_days(self): """@rtype: double""" @@ -72,7 +72,7 @@ def __repr__(self): return self._create_repr(cnt.format(d, t, r, m)) -monkey_the_camel(EclSumTStep, "getSimDays", EclSumTStep.get_sim_days) -monkey_the_camel(EclSumTStep, "getReport", EclSumTStep.get_report) -monkey_the_camel(EclSumTStep, "getMiniStep", EclSumTStep.get_mini_step) -monkey_the_camel(EclSumTStep, "getSimTime", EclSumTStep.get_sim_time) +monkey_the_camel(RdSumTStep, "getSimDays", RdSumTStep.get_sim_days) +monkey_the_camel(RdSumTStep, "getReport", RdSumTStep.get_report) +monkey_the_camel(RdSumTStep, "getMiniStep", RdSumTStep.get_mini_step) +monkey_the_camel(RdSumTStep, "getSimTime", RdSumTStep.get_sim_time) diff --git a/python/resdata/summary/rd_sum_var_type.py b/python/resdata/summary/rd_sum_var_type.py index 5c38cbc0c3..dd63522832 100644 --- a/python/resdata/summary/rd_sum_var_type.py +++ b/python/resdata/summary/rd_sum_var_type.py @@ -1,37 +1,37 @@ from cwrap import BaseCEnum -class EclSumVarType(BaseCEnum): - TYPE_NAME = "ecl_sum_var_type" - ECL_SMSPEC_INVALID_VAR = None - ECL_SMSPEC_FIELD_VAR = None - ECL_SMSPEC_REGION_VAR = None - ECL_SMSPEC_GROUP_VAR = None - ECL_SMSPEC_WELL_VAR = None - ECL_SMSPEC_SEGMENT_VAR = None - ECL_SMSPEC_BLOCK_VAR = None - ECL_SMSPEC_AQUIFER_VAR = None - ECL_SMSPEC_COMPLETION_VAR = None - ECL_SMSPEC_NETWORK_VAR = None - ECL_SMSPEC_REGION_2_REGION_VAR = None - ECL_SMSPEC_LOCAL_BLOCK_VAR = None - ECL_SMSPEC_LOCAL_COMPLETION_VAR = None - ECL_SMSPEC_LOCAL_WELL_VAR = None - ECL_SMSPEC_MISC_VAR = None +class RdSumVarType(BaseCEnum): + TYPE_NAME = "rd_sum_var_type" + RD_SMSPEC_INVALID_VAR = None + RD_SMSPEC_FIELD_VAR = None + RD_SMSPEC_REGION_VAR = None + RD_SMSPEC_GROUP_VAR = None + RD_SMSPEC_WELL_VAR = None + RD_SMSPEC_SEGMENT_VAR = None + RD_SMSPEC_BLOCK_VAR = None + RD_SMSPEC_AQUIFER_VAR = None + RD_SMSPEC_COMPLETION_VAR = None + RD_SMSPEC_NETWORK_VAR = None + RD_SMSPEC_REGION_2_REGION_VAR = None + RD_SMSPEC_LOCAL_BLOCK_VAR = None + RD_SMSPEC_LOCAL_COMPLETION_VAR = None + RD_SMSPEC_LOCAL_WELL_VAR = None + RD_SMSPEC_MISC_VAR = None -EclSumVarType.addEnum("ECL_SMSPEC_INVALID_VAR", 0) -EclSumVarType.addEnum("ECL_SMSPEC_FIELD_VAR", 1) -EclSumVarType.addEnum("ECL_SMSPEC_REGION_VAR", 2) -EclSumVarType.addEnum("ECL_SMSPEC_GROUP_VAR", 3) -EclSumVarType.addEnum("ECL_SMSPEC_WELL_VAR", 4) -EclSumVarType.addEnum("ECL_SMSPEC_SEGMENT_VAR", 5) -EclSumVarType.addEnum("ECL_SMSPEC_BLOCK_VAR", 6) -EclSumVarType.addEnum("ECL_SMSPEC_AQUIFER_VAR", 7) -EclSumVarType.addEnum("ECL_SMSPEC_COMPLETION_VAR", 8) -EclSumVarType.addEnum("ECL_SMSPEC_NETWORK_VAR", 9) -EclSumVarType.addEnum("ECL_SMSPEC_REGION_2_REGION_VAR", 10) -EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_BLOCK_VAR", 11) -EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_COMPLETION_VAR", 12) -EclSumVarType.addEnum("ECL_SMSPEC_LOCAL_WELL_VAR", 13) -EclSumVarType.addEnum("ECL_SMSPEC_MISC_VAR", 14) +RdSumVarType.addEnum("RD_SMSPEC_INVALID_VAR", 0) +RdSumVarType.addEnum("RD_SMSPEC_FIELD_VAR", 1) +RdSumVarType.addEnum("RD_SMSPEC_REGION_VAR", 2) +RdSumVarType.addEnum("RD_SMSPEC_GROUP_VAR", 3) +RdSumVarType.addEnum("RD_SMSPEC_WELL_VAR", 4) +RdSumVarType.addEnum("RD_SMSPEC_SEGMENT_VAR", 5) +RdSumVarType.addEnum("RD_SMSPEC_BLOCK_VAR", 6) +RdSumVarType.addEnum("RD_SMSPEC_AQUIFER_VAR", 7) +RdSumVarType.addEnum("RD_SMSPEC_COMPLETION_VAR", 8) +RdSumVarType.addEnum("RD_SMSPEC_NETWORK_VAR", 9) +RdSumVarType.addEnum("RD_SMSPEC_REGION_2_REGION_VAR", 10) +RdSumVarType.addEnum("RD_SMSPEC_LOCAL_BLOCK_VAR", 11) +RdSumVarType.addEnum("RD_SMSPEC_LOCAL_COMPLETION_VAR", 12) +RdSumVarType.addEnum("RD_SMSPEC_LOCAL_WELL_VAR", 13) +RdSumVarType.addEnum("RD_SMSPEC_MISC_VAR", 14) diff --git a/python/resdata/summary/rd_sum_vector.py b/python/resdata/summary/rd_sum_vector.py index 3d8aa303ae..26711170eb 100644 --- a/python/resdata/summary/rd_sum_vector.py +++ b/python/resdata/summary/rd_sum_vector.py @@ -1,9 +1,9 @@ from __future__ import print_function import warnings -from ecl.summary.ecl_sum_node import EclSumNode +from resdata.summary.rd_sum_node import RdSumNode -class EclSumVector(object): +class RdSumVector(object): def __init__(self, parent, key, report_only=False): """ A summary vector with a vector of values and time. @@ -11,15 +11,15 @@ def __init__(self, parent, key, report_only=False): A summary vector contains the the full time history of one key, along with the corresponding time vectors in several different time formats. Depending on the report_only argument - the data vectors in the EclSumVector can either contain all + the data vectors in the RdSumVector can either contain all the time values, or only those corresponding to report_steps. - The EclSumVector contains a reference to the parent EclSum + The RdSumVector contains a reference to the parent RdSum structure and this is used to implement several of the - properties and methods of the object; the EclSum vector + properties and methods of the object; the RdSum vector instances should therefore only be instantiated through the - EclSum.get_vector() method, and not manually with the - EclSumVector() constructor. + RdSum.get_vector() method, and not manually with the + RdSumVector() constructor. """ self.parent = parent self.key = key @@ -27,7 +27,7 @@ def __init__(self, parent, key, report_only=False): if report_only: warnings.warn( - "The report_only flag to the EclSumVector will be removed", + "The report_only flag to the RdSumVector will be removed", DeprecationWarning, ) @@ -41,7 +41,7 @@ def __str__(self): return "" % self.key def __repr__(self): - return "EclSumVector(key = %s, size = %d, unit = %s)" % ( + return "RdSumVector(key = %s, size = %d, unit = %s)" % ( self.key, len(self), self.unit, @@ -118,11 +118,11 @@ def report_step(self): def __iget(self, index): """ - Will return an EclSumNode for element @index; should be called + Will return an RdSumNode for element @index; should be called through the [] operator, otherwise you can come across unitialized data. """ - return EclSumNode( + return RdSumNode( self.__report_step[index], self.__days[index], self.__dates[index], @@ -140,14 +140,14 @@ def __getitem__(self, index): """ Implements the [] operator. - Will return EclSumNode instance according to @index. The index + Will return RdSumNode instance according to @index. The index value will be interpreted as in a normal python [] lookup, i.e. negative values will be interpreted as starting from the right and also slice notation is allowed[*]. [*] Observe that in the case of slices the return value will - not be a proper EclSumVector instance, but rather a normal - Python list of EclSumNode instances. + not be a proper RdSumVector instance, but rather a normal + Python list of RdSumNode instances. """ self.assert_values() length = len(self.values) @@ -160,8 +160,8 @@ def __getitem__(self, index): return self.__iget(index) elif isinstance(index, slice): # Observe that the slice based lookup does __not__ return - # a proper EclSumVector instance; it will merely return - # a simple Python list with EclSumNode instances. + # a proper RdSumVector instance; it will merely return + # a simple Python list with RdSumNode instances. (start, stop, step) = index.indices(length) index = start sub_vector = [] @@ -175,7 +175,7 @@ def __getitem__(self, index): @property def first(self): """ - Will return the first EclSumNode in this vector. + Will return the first RdSumNode in this vector. """ self.assert_values() return self.__iget(0) @@ -183,7 +183,7 @@ def first(self): @property def last(self): """ - Will return the last EclSumNode in this vector. + Will return the last RdSumNode in this vector. """ self.assert_values() @@ -251,7 +251,7 @@ def first_gt_index(self, limit): def first_gt(self, limit): """ - Locate the first EclSumNode where value is above @limit. + Locate the first RdSumNode where value is above @limit. vec = sum["WWCT:A-3"] w = vec.first_gt(0.50) diff --git a/python/resdata/util/CMakeLists.txt b/python/resdata/util/CMakeLists.txt index 03e9105a60..ef13d33ba2 100644 --- a/python/resdata/util/CMakeLists.txt +++ b/python/resdata/util/CMakeLists.txt @@ -1,6 +1,6 @@ set(PYTHON_SOURCES __init__.py) -add_python_package("python.ecl.util" ${PYTHON_INSTALL_PREFIX}/ecl/util +add_python_package("python.ecl.util" ${PYTHON_INSTALL_PREFIX}/resdata/util "${PYTHON_SOURCES}" True) add_subdirectory(enums) diff --git a/python/resdata/util/enums/CMakeLists.txt b/python/resdata/util/enums/CMakeLists.txt index a0598cf056..17fad42404 100644 --- a/python/resdata/util/enums/CMakeLists.txt +++ b/python/resdata/util/enums/CMakeLists.txt @@ -1,5 +1,5 @@ set(PYTHON_SOURCES __init__.py rng_alg_type_enum.py rng_init_mode_enum.py) add_python_package( - "python.ecl.util.enums" ${PYTHON_INSTALL_PREFIX}/ecl/util/enums + "python.ecl.util.enums" ${PYTHON_INSTALL_PREFIX}/resdata/util/enums "${PYTHON_SOURCES}" True) diff --git a/python/resdata/util/geometry/CMakeLists.txt b/python/resdata/util/geometry/CMakeLists.txt index d3daad88ea..f62d5bd6b1 100644 --- a/python/resdata/util/geometry/CMakeLists.txt +++ b/python/resdata/util/geometry/CMakeLists.txt @@ -10,5 +10,5 @@ set(PYTHON_SOURCES surface.py) add_python_package( - "python.ecl.util.geometry" ${PYTHON_INSTALL_PREFIX}/ecl/util/geometry + "python.ecl.util.geometry" ${PYTHON_INSTALL_PREFIX}/resdata/util/geometry "${PYTHON_SOURCES}" True) diff --git a/python/resdata/util/geometry/__init__.py b/python/resdata/util/geometry/__init__.py index 5ab3e170ba..83851e7d6e 100644 --- a/python/resdata/util/geometry/__init__.py +++ b/python/resdata/util/geometry/__init__.py @@ -2,7 +2,7 @@ Simple package for working with 2D geometry. """ -import ecl +import resdata from cwrap import Prototype from .geo_pointset import GeoPointset diff --git a/python/resdata/util/geometry/cpolyline.py b/python/resdata/util/geometry/cpolyline.py index d77450d527..7806898074 100644 --- a/python/resdata/util/geometry/cpolyline.py +++ b/python/resdata/util/geometry/cpolyline.py @@ -5,35 +5,39 @@ import os.path from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype from .geometry_tools import GeometryTools class CPolyline(BaseCClass): TYPE_NAME = "geo_polygon" - _alloc_new = EclPrototype("void* geo_polygon_alloc( char* )", bind=False) - _fread_alloc_irap = EclPrototype( + _alloc_new = ResdataPrototype( + "void* geo_polygon_alloc( char* )", bind=False + ) + _fread_alloc_irap = ResdataPrototype( "geo_polygon_obj geo_polygon_fload_alloc_irap( char* )", bind=False ) - _add_point = EclPrototype( + _add_point = ResdataPrototype( "void geo_polygon_add_point( geo_polygon , double , double )" ) - _add_point_front = EclPrototype( + _add_point_front = ResdataPrototype( "void geo_polygon_add_point_front( geo_polygon , double , double )" ) - _free = EclPrototype("void geo_polygon_free( geo_polygon )") - _size = EclPrototype("int geo_polygon_get_size( geo_polygon )") - _iget_xy = EclPrototype( + _free = ResdataPrototype("void geo_polygon_free( geo_polygon )") + _size = ResdataPrototype("int geo_polygon_get_size( geo_polygon )") + _iget_xy = ResdataPrototype( "void geo_polygon_iget_xy( geo_polygon , int , double* , double* )" ) - _segment_intersects = EclPrototype( + _segment_intersects = ResdataPrototype( "bool geo_polygon_segment_intersects( geo_polygon , double , double, double , double)" ) - _get_name = EclPrototype("char* geo_polygon_get_name( geo_polygon )") - _set_name = EclPrototype("void geo_polygon_set_name( geo_polygon , char* )") - _segment_length = EclPrototype("double geo_polygon_get_length( geo_polygon)") - _equal = EclPrototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") + _get_name = ResdataPrototype("char* geo_polygon_get_name( geo_polygon )") + _set_name = ResdataPrototype( + "void geo_polygon_set_name( geo_polygon , char* )" + ) + _segment_length = ResdataPrototype("double geo_polygon_get_length( geo_polygon)") + _equal = ResdataPrototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") def __init__(self, name=None, init_points=()): c_ptr = self._alloc_new(name) diff --git a/python/resdata/util/geometry/cpolyline_collection.py b/python/resdata/util/geometry/cpolyline_collection.py index 1d7a27259c..6ecdbf4470 100644 --- a/python/resdata/util/geometry/cpolyline_collection.py +++ b/python/resdata/util/geometry/cpolyline_collection.py @@ -4,35 +4,35 @@ import ctypes from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.util.geometry import CPolyline +from resdata import ResdataPrototype +from resdata.util.geometry import CPolyline class CPolylineCollection(BaseCClass): TYPE_NAME = "geo_polygon_collection" - _alloc_new = EclPrototype( + _alloc_new = ResdataPrototype( "void* geo_polygon_collection_alloc( )", bind=False ) - _free = EclPrototype( + _free = ResdataPrototype( "void geo_polygon_collection_free( geo_polygon_collection )" ) - _size = EclPrototype( + _size = ResdataPrototype( "int geo_polygon_collection_size( geo_polygon_collection)" ) - _create_polyline = EclPrototype( + _create_polyline = ResdataPrototype( "geo_polygon_ref geo_polygon_collection_create_polygon(geo_polygon_collection , char*)" ) - _has_polyline = EclPrototype( + _has_polyline = ResdataPrototype( "bool geo_polygon_collection_has_polygon(geo_polygon_collection , char*)" ) - _iget = EclPrototype( + _iget = ResdataPrototype( "geo_polygon_ref geo_polygon_collection_iget_polygon(geo_polygon_collection , int)" ) - _get = EclPrototype( + _get = ResdataPrototype( "geo_polygon_ref geo_polygon_collection_get_polygon(geo_polygon_collection , char*)" ) - _add_polyline = EclPrototype( + _add_polyline = ResdataPrototype( "void geo_polygon_collection_add_polygon(geo_polygon_collection , geo_polygon , bool)" ) diff --git a/python/resdata/util/geometry/geo_pointset.py b/python/resdata/util/geometry/geo_pointset.py index cf41666cc1..64ac90b009 100644 --- a/python/resdata/util/geometry/geo_pointset.py +++ b/python/resdata/util/geometry/geo_pointset.py @@ -1,27 +1,27 @@ from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class GeoPointset(BaseCClass): TYPE_NAME = "geo_pointset" - _alloc = EclPrototype("void* geo_pointset_alloc(bool)", bind=False) - _free = EclPrototype("void geo_pointset_free(geo_pointset)") - # _add_xyz = EclPrototype("void geo_pointset_add_xyz(geo_pointset, double, double, double)") - _get_size = EclPrototype("int geo_pointset_get_size(geo_pointset)") - # _iget_xy = EclPrototype("void geo_pointset_iget_xy(geo_pointset, int, double*, double*)") - # _get_zcoord = EclPrototype("double* geo_pointset_get_zcoord(geo_pointset)") - _equal = EclPrototype("bool geo_pointset_equal(geo_pointset, geo_pointset)") - _iget_z = EclPrototype("double geo_pointset_iget_z(geo_pointset, int)") - # _iset_z = EclPrototype("void geo_pointset_iset_z(geo_pointset, int, double)") - # _memcpy = EclPrototype("void geo_pointset_memcpy(geo_pointset, geo_pointset, bool)") - # _shift_z = EclPrototype("void geo_pointset_shift_z(geo_pointset, double)") - # _assign_z = EclPrototype("void geo_pointset_assign_z(geo_pointset, double)") - # _scale_z = EclPrototype("void geo_pointset_scale_z(geo_pointset, double)") - # _imul = EclPrototype("void geo_pointset_imul(geo_pointset, geo_pointset)") - # _iadd = EclPrototype("void geo_pointset_iadd(geo_pointset, geo_pointset)") - # _isub = EclPrototype("void geo_pointset_isub(geo_pointset, geo_pointset)") - # _isqrt = EclPrototype("void geo_pointset_isqrt(geo_pointset)") + _alloc = ResdataPrototype("void* geo_pointset_alloc(bool)", bind=False) + _free = ResdataPrototype("void geo_pointset_free(geo_pointset)") + # _add_xyz = ResdataPrototype("void geo_pointset_add_xyz(geo_pointset, double, double, double)") + _get_size = ResdataPrototype("int geo_pointset_get_size(geo_pointset)") + # _iget_xy = ResdataPrototype("void geo_pointset_iget_xy(geo_pointset, int, double*, double*)") + # _get_zcoord = ResdataPrototype("double* geo_pointset_get_zcoord(geo_pointset)") + _equal = ResdataPrototype("bool geo_pointset_equal(geo_pointset, geo_pointset)") + _iget_z = ResdataPrototype("double geo_pointset_iget_z(geo_pointset, int)") + # _iset_z = ResdataPrototype("void geo_pointset_iset_z(geo_pointset, int, double)") + # _memcpy = ResdataPrototype("void geo_pointset_memcpy(geo_pointset, geo_pointset, bool)") + # _shift_z = ResdataPrototype("void geo_pointset_shift_z(geo_pointset, double)") + # _assign_z = ResdataPrototype("void geo_pointset_assign_z(geo_pointset, double)") + # _scale_z = ResdataPrototype("void geo_pointset_scale_z(geo_pointset, double)") + # _imul = ResdataPrototype("void geo_pointset_imul(geo_pointset, geo_pointset)") + # _iadd = ResdataPrototype("void geo_pointset_iadd(geo_pointset, geo_pointset)") + # _isub = ResdataPrototype("void geo_pointset_isub(geo_pointset, geo_pointset)") + # _isqrt = ResdataPrototype("void geo_pointset_isqrt(geo_pointset)") def __init__(self, external_z=False): c_ptr = self._alloc(external_z) diff --git a/python/resdata/util/geometry/geo_region.py b/python/resdata/util/geometry/geo_region.py index 7c03818187..21bb3f9545 100644 --- a/python/resdata/util/geometry/geo_region.py +++ b/python/resdata/util/geometry/geo_region.py @@ -1,6 +1,6 @@ from cwrap import BaseCClass -from ecl.util.util import IntVector -from ecl import EclPrototype +from resdata.util.util import IntVector +from resdata import ResdataPrototype from .cpolyline import CPolyline from ctypes import c_double @@ -10,34 +10,34 @@ class GeoRegion(BaseCClass): TYPE_NAME = "geo_region" - _alloc = EclPrototype("void* geo_region_alloc(geo_pointset, bool)", bind=False) - _free = EclPrototype("void geo_region_free(geo_region)") - _reset = EclPrototype("void geo_region_reset(geo_region)") - _get_index_list = EclPrototype( + _alloc = ResdataPrototype("void* geo_region_alloc(geo_pointset, bool)", bind=False) + _free = ResdataPrototype("void geo_region_free(geo_region)") + _reset = ResdataPrototype("void geo_region_reset(geo_region)") + _get_index_list = ResdataPrototype( "int_vector_ref geo_region_get_index_list(geo_region)" ) - _select_inside_polygon = EclPrototype( + _select_inside_polygon = ResdataPrototype( "void geo_region_select_inside_polygon(geo_region, geo_polygon)" ) - _select_outside_polygon = EclPrototype( + _select_outside_polygon = ResdataPrototype( "void geo_region_select_outside_polygon(geo_region, geo_polygon)" ) - _deselect_inside_polygon = EclPrototype( + _deselect_inside_polygon = ResdataPrototype( "void geo_region_deselect_inside_polygon(geo_region, geo_polygon)" ) - _deselect_outside_polygon = EclPrototype( + _deselect_outside_polygon = ResdataPrototype( "void geo_region_deselect_outside_polygon(geo_region, geo_polygon)" ) - _select_above_line = EclPrototype( + _select_above_line = ResdataPrototype( "void geo_region_select_above_line(geo_region, double*, double*)" ) - _select_below_line = EclPrototype( + _select_below_line = ResdataPrototype( "void geo_region_select_below_line(geo_region, double*, double*)" ) - _deselect_above_line = EclPrototype( + _deselect_above_line = ResdataPrototype( "void geo_region_deselect_above_line(geo_region, double*, double*)" ) - _deselect_below_line = EclPrototype( + _deselect_below_line = ResdataPrototype( "void geo_region_deselect_below_line(geo_region, double*, double*)" ) diff --git a/python/resdata/util/geometry/surface.py b/python/resdata/util/geometry/surface.py index afa4da67cd..80a91fc654 100644 --- a/python/resdata/util/geometry/surface.py +++ b/python/resdata/util/geometry/surface.py @@ -7,42 +7,46 @@ import ctypes from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.util.geometry import GeoPointset +from resdata import ResdataPrototype +from resdata.util.geometry import GeoPointset class Surface(BaseCClass): TYPE_NAME = "surface" - _alloc = EclPrototype( + _alloc = ResdataPrototype( "void* geo_surface_fload_alloc_irap( char* , bool )", bind=False ) - _free = EclPrototype("void geo_surface_free( surface )") - _new = EclPrototype( + _free = ResdataPrototype("void geo_surface_free( surface )") + _new = ResdataPrototype( "void* geo_surface_alloc_new( int, int, double, double, double, double, double )", bind=False, ) - _get_nx = EclPrototype("int geo_surface_get_nx( surface )") - _get_ny = EclPrototype("int geo_surface_get_ny( surface )") - _iget_zvalue = EclPrototype("double geo_surface_iget_zvalue( surface , int)") - _iset_zvalue = EclPrototype( + _get_nx = ResdataPrototype("int geo_surface_get_nx( surface )") + _get_ny = ResdataPrototype("int geo_surface_get_ny( surface )") + _iget_zvalue = ResdataPrototype("double geo_surface_iget_zvalue( surface , int)") + _iset_zvalue = ResdataPrototype( "void geo_surface_iset_zvalue( surface , int , double)" ) - _write = EclPrototype("void geo_surface_fprintf_irap( surface , char* )") - _equal = EclPrototype("bool geo_surface_equal( surface , surface )") - _header_equal = EclPrototype("bool geo_surface_equal_header( surface , surface )") - _copy = EclPrototype("surface_obj geo_surface_alloc_copy( surface , bool )") - _assign = EclPrototype("void geo_surface_assign_value( surface , double )") - _scale = EclPrototype("void geo_surface_scale( surface , double )") - _shift = EclPrototype("void geo_surface_shift( surface , double )") - _iadd = EclPrototype("void geo_surface_iadd( surface , surface )") - _imul = EclPrototype("void geo_surface_imul( surface , surface )") - _isub = EclPrototype("void geo_surface_isub( surface , surface )") - _isqrt = EclPrototype("void geo_surface_isqrt( surface )") - _iget_xy = EclPrototype( + _write = ResdataPrototype("void geo_surface_fprintf_irap( surface , char* )") + _equal = ResdataPrototype("bool geo_surface_equal( surface , surface )") + _header_equal = ResdataPrototype( + "bool geo_surface_equal_header( surface , surface )" + ) + _copy = ResdataPrototype("surface_obj geo_surface_alloc_copy( surface , bool )") + _assign = ResdataPrototype("void geo_surface_assign_value( surface , double )") + _scale = ResdataPrototype("void geo_surface_scale( surface , double )") + _shift = ResdataPrototype("void geo_surface_shift( surface , double )") + _iadd = ResdataPrototype("void geo_surface_iadd( surface , surface )") + _imul = ResdataPrototype("void geo_surface_imul( surface , surface )") + _isub = ResdataPrototype("void geo_surface_isub( surface , surface )") + _isqrt = ResdataPrototype("void geo_surface_isqrt( surface )") + _iget_xy = ResdataPrototype( "void geo_surface_iget_xy(surface, int, double*, double*)" ) - _get_pointset = EclPrototype("geo_pointset_ref geo_surface_get_pointset(surface)") + _get_pointset = ResdataPrototype( + "geo_pointset_ref geo_surface_get_pointset(surface)" + ) def __init__( self, diff --git a/python/resdata/util/test/CMakeLists.txt b/python/resdata/util/test/CMakeLists.txt index 019dabe3f9..36c71b1215 100644 --- a/python/resdata/util/test/CMakeLists.txt +++ b/python/resdata/util/test/CMakeLists.txt @@ -12,7 +12,7 @@ set(PYTHON_SOURCES debug_msg.py) add_python_package( - "python.ecl.util.test" ${PYTHON_INSTALL_PREFIX}/ecl/util/test + "python.ecl.util.test" ${PYTHON_INSTALL_PREFIX}/resdata/util/test "${PYTHON_SOURCES}" True) -add_subdirectory(ecl_mock) +add_subdirectory(rd_mock) diff --git a/python/resdata/util/test/extended_testcase.py b/python/resdata/util/test/extended_testcase.py index fa3ce7334b..d1c1e1caf4 100644 --- a/python/resdata/util/test/extended_testcase.py +++ b/python/resdata/util/test/extended_testcase.py @@ -10,8 +10,8 @@ from unittest import TestCase from .source_enumerator import SourceEnumerator -from ecl.util.util import installAbortSignals -from ecl.util.util import Version +from resdata.util.util import installAbortSignals +from resdata.util.util import Version # Function wrapper which can be used to add decorator @log_test to test diff --git a/python/resdata/util/test/mock/CMakeLists.txt b/python/resdata/util/test/mock/CMakeLists.txt index 72463edee6..0cbc38efa3 100644 --- a/python/resdata/util/test/mock/CMakeLists.txt +++ b/python/resdata/util/test/mock/CMakeLists.txt @@ -1,5 +1,5 @@ -set(PYTHON_SOURCES __init__.py ecl_sum_mock.py) +set(PYTHON_SOURCES __init__.py rd_sum_mock.py) add_python_package( - "python.ecl.util.test.ecl_mock" - ${PYTHON_INSTALL_PREFIX}/ecl/util/test/ecl_mock "${PYTHON_SOURCES}" True) + "python.ecl.util.test.rd_mock" + ${PYTHON_INSTALL_PREFIX}/resdata/util/test/rd_mock "${PYTHON_SOURCES}" True) diff --git a/python/resdata/util/test/mock/__init__.py b/python/resdata/util/test/mock/__init__.py index eb49177fc0..77bcbd21ad 100644 --- a/python/resdata/util/test/mock/__init__.py +++ b/python/resdata/util/test/mock/__init__.py @@ -1 +1 @@ -from .ecl_sum_mock import createEclSum +from .rd_sum_mock import createRdSum diff --git a/python/resdata/util/test/mock/rd_sum_mock.py b/python/resdata/util/test/mock/rd_sum_mock.py index 95402f7ac5..e0f0917371 100644 --- a/python/resdata/util/test/mock/rd_sum_mock.py +++ b/python/resdata/util/test/mock/rd_sum_mock.py @@ -1,12 +1,12 @@ import datetime -from ecl.summary import EclSum +from resdata.summary import RdSum -def mock_func(ecl_sum, key, days): +def mock_func(rd_sum, key, days): return days * 10 -def createEclSum( +def createRdSum( case, keys, sim_start=datetime.date(2010, 1, 1), @@ -19,12 +19,12 @@ def createEclSum( restart_case=None, restart_step=-1, ): - ecl_sum = EclSum.restart_writer( + rd_sum = RdSum.restart_writer( case, restart_case, restart_step, sim_start, dims[0], dims[1], dims[2] ) var_list = [] for kw, wgname, num, unit in keys: - var_list.append(ecl_sum.addVariable(kw, wgname=wgname, num=num, unit=unit)) + var_list.append(rd_sum.addVariable(kw, wgname=wgname, num=num, unit=unit)) # This is a bug! This should not be integer division, but tests are written # around that assumption. @@ -44,7 +44,7 @@ def createEclSum( + report_step * report_step_length + mini_step * mini_step_length ) - t_step = ecl_sum.addTStep(report_step + 1, sim_days=days) + t_step = rd_sum.addTStep(report_step + 1, sim_days=days) for var in var_list: key = var.getKey1() @@ -53,6 +53,6 @@ def createEclSum( func = func_table[key] t_step[key] = func(days) else: - t_step[key] = mock_func(ecl_sum, key, days) + t_step[key] = mock_func(rd_sum, key, days) - return ecl_sum + return rd_sum diff --git a/python/resdata/util/test/test_area.py b/python/resdata/util/test/test_area.py index 0e0159b141..29c75c0c20 100644 --- a/python/resdata/util/test/test_area.py +++ b/python/resdata/util/test/test_area.py @@ -1,34 +1,34 @@ import os.path from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class TestArea(BaseCClass): __test__ = False - _test_area_alloc = EclPrototype( + _test_area_alloc = ResdataPrototype( "void* test_work_area_alloc__( char*, bool )", bind=False ) - _free = EclPrototype("void test_work_area_free( test_area )") - _install_file = EclPrototype( + _free = ResdataPrototype("void test_work_area_free( test_area )") + _install_file = ResdataPrototype( "void test_work_area_install_file( test_area , char* )" ) - _copy_directory = EclPrototype( + _copy_directory = ResdataPrototype( "void test_work_area_copy_directory( test_area , char* )" ) - _copy_file = EclPrototype("void test_work_area_copy_file( test_area , char* )") - _copy_directory_content = EclPrototype( + _copy_file = ResdataPrototype("void test_work_area_copy_file( test_area , char* )") + _copy_directory_content = ResdataPrototype( "void test_work_area_copy_directory_content( test_area , char* )" ) - _copy_parent_directory = EclPrototype( + _copy_parent_directory = ResdataPrototype( "void test_work_area_copy_parent_directory( test_area , char* )" ) - _copy_parent_content = EclPrototype( + _copy_parent_content = ResdataPrototype( "void test_work_area_copy_parent_content( test_area , char* )" ) - _get_cwd = EclPrototype("char* test_work_area_get_cwd( test_area )") - _get_original_cwd = EclPrototype( + _get_cwd = ResdataPrototype("char* test_work_area_get_cwd( test_area )") + _get_original_cwd = ResdataPrototype( "char* test_work_area_get_original_cwd( test_area )" ) diff --git a/python/resdata/util/util/CMakeLists.txt b/python/resdata/util/util/CMakeLists.txt index f1c4436329..1aa4392015 100644 --- a/python/resdata/util/util/CMakeLists.txt +++ b/python/resdata/util/util/CMakeLists.txt @@ -19,5 +19,5 @@ set(PYTHON_SOURCES cwd_context.py) add_python_package( - "python.ecl.util.util" ${PYTHON_INSTALL_PREFIX}/ecl/util/util + "python.ecl.util.util" ${PYTHON_INSTALL_PREFIX}/resdata/util/util "${PYTHON_SOURCES}" True) diff --git a/python/resdata/util/util/__init__.py b/python/resdata/util/util/__init__.py index 02afd46138..a3b20cb432 100644 --- a/python/resdata/util/util/__init__.py +++ b/python/resdata/util/util/__init__.py @@ -23,13 +23,13 @@ from __future__ import absolute_import, division, print_function, unicode_literals -import ecl +import resdata from cwrap import Prototype -from .version import Version, EclVersion +from .version import Version, ResdataVersion -from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum +from resdata.util.enums import RngAlgTypeEnum, RngInitModeEnum from .ctime import CTime @@ -60,7 +60,7 @@ import os import warnings -__cc = os.environ.get("ECLWARNING", None) # __cc in (None, 'user', 'dev', 'hard') +__cc = os.environ.get("RDWARNING", None) # __cc in (None, 'user', 'dev', 'hard') def __silencio(msg): @@ -79,13 +79,13 @@ def __hard_warning(msg): raise UserWarning("CamelCase exception: " + msg) -__ecl_camel_case_warning = __silencio +__rd_camel_case_warning = __silencio if __cc == "user": - __ecl_camel_case_warning = __user_warning + __rd_camel_case_warning = __user_warning elif __cc == "dev": - __ecl_camel_case_warning = __dev_warning + __rd_camel_case_warning = __dev_warning elif __cc == "hard": - __ecl_camel_case_warning = __hard_warning + __rd_camel_case_warning = __hard_warning def monkey_the_camel(class_, camel, method_, method_type=None): @@ -98,7 +98,7 @@ def shift(*args): return args if (method_type != classmethod) else args[1:] def warned_method(*args, **kwargs): - __ecl_camel_case_warning( + __rd_camel_case_warning( "Warning, %s is deprecated, use %s" % (camel, str(method_)) ) return method_(*shift(*args), **kwargs) diff --git a/python/resdata/util/util/arg_pack.py b/python/resdata/util/util/arg_pack.py index a4135ba599..f4af42d0ba 100644 --- a/python/resdata/util/util/arg_pack.py +++ b/python/resdata/util/util/arg_pack.py @@ -1,17 +1,17 @@ from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class ArgPack(BaseCClass): TYPE_NAME = "arg_pack" - _alloc = EclPrototype("void* arg_pack_alloc()", bind=False) - _append_int = EclPrototype("void arg_pack_append_int(arg_pack, int)") - _append_double = EclPrototype("void arg_pack_append_double(arg_pack, double)") - _append_ptr = EclPrototype("void arg_pack_append_ptr(arg_pack, void*)") + _alloc = ResdataPrototype("void* arg_pack_alloc()", bind=False) + _append_int = ResdataPrototype("void arg_pack_append_int(arg_pack, int)") + _append_double = ResdataPrototype("void arg_pack_append_double(arg_pack, double)") + _append_ptr = ResdataPrototype("void arg_pack_append_ptr(arg_pack, void*)") - _size = EclPrototype("int arg_pack_size(arg_pack)") - _free = EclPrototype("void arg_pack_free(arg_pack)") + _size = ResdataPrototype("int arg_pack_size(arg_pack)") + _free = ResdataPrototype("void arg_pack_free(arg_pack)") def __init__(self, *args): c_ptr = self._alloc() diff --git a/python/resdata/util/util/bool_vector.py b/python/resdata/util/util/bool_vector.py index 4a0f3c2b54..a261124cdb 100644 --- a/python/resdata/util/util/bool_vector.py +++ b/python/resdata/util/util/bool_vector.py @@ -1,91 +1,97 @@ -from ecl import EclPrototype -from ecl.util.util import VectorTemplate +from resdata import ResdataPrototype +from resdata.util.util import VectorTemplate class BoolVector(VectorTemplate): default_format = "%8d" - _alloc = EclPrototype("void* bool_vector_alloc( int , bool )", bind=False) - _create_active_mask = EclPrototype( + _alloc = ResdataPrototype("void* bool_vector_alloc( int , bool )", bind=False) + _create_active_mask = ResdataPrototype( "bool_vector_obj string_util_alloc_active_mask( char* )", bind=False ) - _active_list = EclPrototype( + _active_list = ResdataPrototype( "int_vector_obj bool_vector_alloc_active_list(bool_vector)" ) - _alloc_copy = EclPrototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )") - _update_active_mask = EclPrototype( + _alloc_copy = ResdataPrototype( + "bool_vector_obj bool_vector_alloc_copy( bool_vector )" + ) + _update_active_mask = ResdataPrototype( "bool string_util_update_active_mask(char*, bool_vector)", bind=False ) - _strided_copy = EclPrototype( + _strided_copy = ResdataPrototype( "bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)" ) - _free = EclPrototype("void bool_vector_free( bool_vector )") - _iget = EclPrototype("bool bool_vector_iget( bool_vector , int )") - _safe_iget = EclPrototype("bool bool_vector_safe_iget( bool_vector , int )") - _iset = EclPrototype("void bool_vector_iset( bool_vector , int , bool)") - _size = EclPrototype("int bool_vector_size( bool_vector )") - _append = EclPrototype("void bool_vector_append( bool_vector , bool )") - _idel_block = EclPrototype( + _free = ResdataPrototype("void bool_vector_free( bool_vector )") + _iget = ResdataPrototype("bool bool_vector_iget( bool_vector , int )") + _safe_iget = ResdataPrototype("bool bool_vector_safe_iget( bool_vector , int )") + _iset = ResdataPrototype("void bool_vector_iset( bool_vector , int , bool)") + _size = ResdataPrototype("int bool_vector_size( bool_vector )") + _append = ResdataPrototype("void bool_vector_append( bool_vector , bool )") + _idel_block = ResdataPrototype( "void bool_vector_idel_block( bool_vector , bool , bool )" ) - _idel = EclPrototype("void bool_vector_idel( bool_vector , int )") - _pop = EclPrototype("bool bool_vector_pop( bool_vector )") - _lshift = EclPrototype("void bool_vector_lshift( bool_vector , int )") - _rshift = EclPrototype("void bool_vector_rshift( bool_vector , int )") - _insert = EclPrototype("void bool_vector_insert( bool_vector , int , bool)") - _fprintf = EclPrototype( + _idel = ResdataPrototype("void bool_vector_idel( bool_vector , int )") + _pop = ResdataPrototype("bool bool_vector_pop( bool_vector )") + _lshift = ResdataPrototype("void bool_vector_lshift( bool_vector , int )") + _rshift = ResdataPrototype("void bool_vector_rshift( bool_vector , int )") + _insert = ResdataPrototype("void bool_vector_insert( bool_vector , int , bool)") + _fprintf = ResdataPrototype( "void bool_vector_fprintf( bool_vector , FILE , char* , char*)" ) - _sort = EclPrototype("void bool_vector_sort( bool_vector )") - _rsort = EclPrototype("void bool_vector_rsort( bool_vector )") - _reset = EclPrototype("void bool_vector_reset( bool_vector )") - _set_read_only = EclPrototype( + _sort = ResdataPrototype("void bool_vector_sort( bool_vector )") + _rsort = ResdataPrototype("void bool_vector_rsort( bool_vector )") + _reset = ResdataPrototype("void bool_vector_reset( bool_vector )") + _set_read_only = ResdataPrototype( "void bool_vector_set_read_only( bool_vector , bool )" ) - _get_read_only = EclPrototype("bool bool_vector_get_read_only( bool_vector )") - _get_max = EclPrototype("bool bool_vector_get_max( bool_vector )") - _get_min = EclPrototype("bool bool_vector_get_min( bool_vector )") - _get_max_index = EclPrototype( + _get_read_only = ResdataPrototype("bool bool_vector_get_read_only( bool_vector )") + _get_max = ResdataPrototype("bool bool_vector_get_max( bool_vector )") + _get_min = ResdataPrototype("bool bool_vector_get_min( bool_vector )") + _get_max_index = ResdataPrototype( "int bool_vector_get_max_index( bool_vector , bool)" ) - _get_min_index = EclPrototype( + _get_min_index = ResdataPrototype( "int bool_vector_get_min_index( bool_vector , bool)" ) - _shift = EclPrototype("void bool_vector_shift( bool_vector , bool )") - _scale = EclPrototype("void bool_vector_scale( bool_vector , bool )") - _div = EclPrototype("void bool_vector_div( bool_vector , bool )") - _inplace_add = EclPrototype( + _shift = ResdataPrototype("void bool_vector_shift( bool_vector , bool )") + _scale = ResdataPrototype("void bool_vector_scale( bool_vector , bool )") + _div = ResdataPrototype("void bool_vector_div( bool_vector , bool )") + _inplace_add = ResdataPrototype( "void bool_vector_inplace_add( bool_vector , bool_vector )" ) - _inplace_mul = EclPrototype( + _inplace_mul = ResdataPrototype( "void bool_vector_inplace_mul( bool_vector , bool_vector )" ) - _assign = EclPrototype("void bool_vector_set_all( bool_vector , bool)") - _memcpy = EclPrototype("void bool_vector_memcpy(bool_vector , bool_vector )") - _set_default = EclPrototype("void bool_vector_set_default( bool_vector , bool)") - _get_default = EclPrototype("bool bool_vector_get_default( bool_vector )") - _element_size = EclPrototype("int bool_vector_element_size( bool_vector )") + _assign = ResdataPrototype("void bool_vector_set_all( bool_vector , bool)") + _memcpy = ResdataPrototype("void bool_vector_memcpy(bool_vector , bool_vector )") + _set_default = ResdataPrototype( + "void bool_vector_set_default( bool_vector , bool)" + ) + _get_default = ResdataPrototype("bool bool_vector_get_default( bool_vector )") + _element_size = ResdataPrototype("int bool_vector_element_size( bool_vector )") - _permute = EclPrototype("void bool_vector_permute(bool_vector, permutation_vector)") - _sort_perm = EclPrototype( + _permute = ResdataPrototype( + "void bool_vector_permute(bool_vector, permutation_vector)" + ) + _sort_perm = ResdataPrototype( "permutation_vector_obj bool_vector_alloc_sort_perm(bool_vector)" ) - _rsort_perm = EclPrototype( + _rsort_perm = ResdataPrototype( "permutation_vector_obj bool_vector_alloc_rsort_perm(bool_vector)" ) - _contains = EclPrototype("bool bool_vector_contains(bool_vector, bool)") - _select_unique = EclPrototype("void bool_vector_select_unique(bool_vector)") - _element_sum = EclPrototype("bool bool_vector_sum(bool_vector)") - _get_data_ptr = EclPrototype("bool* bool_vector_get_ptr(bool_vector)") - _count_equal = EclPrototype("int bool_vector_count_equal(bool_vector, bool)") + _contains = ResdataPrototype("bool bool_vector_contains(bool_vector, bool)") + _select_unique = ResdataPrototype("void bool_vector_select_unique(bool_vector)") + _element_sum = ResdataPrototype("bool bool_vector_sum(bool_vector)") + _get_data_ptr = ResdataPrototype("bool* bool_vector_get_ptr(bool_vector)") + _count_equal = ResdataPrototype("int bool_vector_count_equal(bool_vector, bool)") _init_linear = None - _equal = EclPrototype("bool bool_vector_equal(bool_vector, bool_vector)") - _first_eq = EclPrototype( + _equal = ResdataPrototype("bool bool_vector_equal(bool_vector, bool_vector)") + _first_eq = ResdataPrototype( "int bool_vector_first_equal(bool_vector, bool_vector, int)" ) - _first_neq = EclPrototype( + _first_neq = ResdataPrototype( "int bool_vector_first_not_equal(bool_vector, bool_vector, int)" ) diff --git a/python/resdata/util/util/cthread_pool.py b/python/resdata/util/util/cthread_pool.py index ec846cf6df..e3aaac6768 100644 --- a/python/resdata/util/util/cthread_pool.py +++ b/python/resdata/util/util/cthread_pool.py @@ -1,7 +1,7 @@ import ctypes from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype import weakref @@ -9,10 +9,10 @@ class CThreadPool(BaseCClass): TYPE_NAME = "thread_pool" - _alloc = EclPrototype("void* thread_pool_alloc(int, bool)", bind=False) - _free = EclPrototype("void thread_pool_free(thread_pool)") - _add_job = EclPrototype("void thread_pool_add_job(thread_pool, void*, void*)") - _join = EclPrototype("void thread_pool_join(thread_pool)") + _alloc = ResdataPrototype("void* thread_pool_alloc(int, bool)", bind=False) + _free = ResdataPrototype("void thread_pool_free(thread_pool)") + _add_job = ResdataPrototype("void thread_pool_add_job(thread_pool, void*, void*)") + _join = ResdataPrototype("void thread_pool_join(thread_pool)") def __init__(self, pool_size, start=True): c_ptr = self._alloc(pool_size, start) diff --git a/python/resdata/util/util/ctime.py b/python/resdata/util/util/ctime.py index 1500c3247a..53037b1b17 100644 --- a/python/resdata/util/util/ctime.py +++ b/python/resdata/util/util/ctime.py @@ -3,14 +3,14 @@ import time from cwrap import BaseCValue -from ecl import EclPrototype +from resdata import ResdataPrototype class CTime(BaseCValue): TYPE_NAME = "time_t" DATA_TYPE = ctypes.c_long - _timezone = EclPrototype("char* util_get_timezone()", bind=False) - _timegm = EclPrototype( + _timezone = ResdataPrototype("char* util_get_timezone()", bind=False) + _timegm = ResdataPrototype( "long util_make_datetime_utc(int, int, int, int, int, int)", bind=False ) diff --git a/python/resdata/util/util/double_vector.py b/python/resdata/util/util/double_vector.py index 0d84597441..c027bfb950 100644 --- a/python/resdata/util/util/double_vector.py +++ b/python/resdata/util/util/double_vector.py @@ -1,93 +1,103 @@ -from ecl import EclPrototype -from ecl.util.util import VectorTemplate +from resdata import ResdataPrototype +from resdata.util.util import VectorTemplate class DoubleVector(VectorTemplate): default_format = "%8.4f" - _alloc = EclPrototype("void* double_vector_alloc( int , double )", bind=False) - _alloc_copy = EclPrototype( + _alloc = ResdataPrototype("void* double_vector_alloc( int , double )", bind=False) + _alloc_copy = ResdataPrototype( "double_vector_obj double_vector_alloc_copy( double_vector )" ) - _strided_copy = EclPrototype( + _strided_copy = ResdataPrototype( "double_vector_obj double_vector_alloc_strided_copy( double_vector , int , int , int)" ) - _free = EclPrototype("void double_vector_free( double_vector )") - _iget = EclPrototype("double double_vector_iget( double_vector , int )") - _safe_iget = EclPrototype("double double_vector_safe_iget(double_vector , int )") - _iset = EclPrototype("double double_vector_iset( double_vector , int , double)") - _size = EclPrototype("int double_vector_size( double_vector )") - _append = EclPrototype("void double_vector_append( double_vector , double )") - _idel_block = EclPrototype( + _free = ResdataPrototype("void double_vector_free( double_vector )") + _iget = ResdataPrototype("double double_vector_iget( double_vector , int )") + _safe_iget = ResdataPrototype( + "double double_vector_safe_iget(double_vector , int )" + ) + _iset = ResdataPrototype("double double_vector_iset( double_vector , int , double)") + _size = ResdataPrototype("int double_vector_size( double_vector )") + _append = ResdataPrototype("void double_vector_append( double_vector , double )") + _idel_block = ResdataPrototype( "void double_vector_idel_block( double_vector , int , int )" ) - _pop = EclPrototype("double double_vector_pop( double_vector )") - _idel = EclPrototype("void double_vector_idel( double_vector , int )") - _lshift = EclPrototype("void double_vector_lshift( double_vector , int )") - _rshift = EclPrototype("void double_vector_rshift( double_vector , int )") - _insert = EclPrototype("void double_vector_insert( double_vector , int , double)") - _fprintf = EclPrototype( + _pop = ResdataPrototype("double double_vector_pop( double_vector )") + _idel = ResdataPrototype("void double_vector_idel( double_vector , int )") + _lshift = ResdataPrototype("void double_vector_lshift( double_vector , int )") + _rshift = ResdataPrototype("void double_vector_rshift( double_vector , int )") + _insert = ResdataPrototype( + "void double_vector_insert( double_vector , int , double)" + ) + _fprintf = ResdataPrototype( "void double_vector_fprintf( double_vector , FILE , char* , char*)" ) - _sort = EclPrototype("void double_vector_sort( double_vector )") - _rsort = EclPrototype("void double_vector_rsort( double_vector )") - _reset = EclPrototype("void double_vector_reset( double_vector )") - _get_read_only = EclPrototype("bool double_vector_get_read_only( double_vector )") - _set_read_only = EclPrototype( + _sort = ResdataPrototype("void double_vector_sort( double_vector )") + _rsort = ResdataPrototype("void double_vector_rsort( double_vector )") + _reset = ResdataPrototype("void double_vector_reset( double_vector )") + _get_read_only = ResdataPrototype( + "bool double_vector_get_read_only( double_vector )" + ) + _set_read_only = ResdataPrototype( "void double_vector_set_read_only( double_vector , bool )" ) - _get_max = EclPrototype("double double_vector_get_max( double_vector )") - _get_min = EclPrototype("double double_vector_get_min( double_vector )") - _get_max_index = EclPrototype( + _get_max = ResdataPrototype("double double_vector_get_max( double_vector )") + _get_min = ResdataPrototype("double double_vector_get_min( double_vector )") + _get_max_index = ResdataPrototype( "int double_vector_get_max_index( double_vector , bool)" ) - _get_min_index = EclPrototype( + _get_min_index = ResdataPrototype( "int double_vector_get_min_index( double_vector , bool)" ) - _shift = EclPrototype("void double_vector_shift( double_vector , double )") - _scale = EclPrototype("void double_vector_scale( double_vector , double )") - _div = EclPrototype("void double_vector_div( double_vector , double )") - _inplace_add = EclPrototype( + _shift = ResdataPrototype("void double_vector_shift( double_vector , double )") + _scale = ResdataPrototype("void double_vector_scale( double_vector , double )") + _div = ResdataPrototype("void double_vector_div( double_vector , double )") + _inplace_add = ResdataPrototype( "void double_vector_inplace_add( double_vector , double_vector )" ) - _inplace_mul = EclPrototype( + _inplace_mul = ResdataPrototype( "void double_vector_inplace_mul( double_vector , double_vector )" ) - _assign = EclPrototype("void double_vector_set_all( double_vector , double)") - _memcpy = EclPrototype( + _assign = ResdataPrototype("void double_vector_set_all( double_vector , double)") + _memcpy = ResdataPrototype( "void double_vector_memcpy(double_vector , double_vector )" ) - _set_default = EclPrototype( + _set_default = ResdataPrototype( "void double_vector_set_default( double_vector , double)" ) - _get_default = EclPrototype("double double_vector_get_default( double_vector )") - _element_size = EclPrototype("int double_vector_element_size( double_vector )") + _get_default = ResdataPrototype("double double_vector_get_default( double_vector )") + _element_size = ResdataPrototype( + "int double_vector_element_size( double_vector )" + ) - _permute = EclPrototype( + _permute = ResdataPrototype( "void double_vector_permute(double_vector, permutation_vector)" ) - _sort_perm = EclPrototype( + _sort_perm = ResdataPrototype( "permutation_vector_obj double_vector_alloc_sort_perm(double_vector)" ) - _rsort_perm = EclPrototype( + _rsort_perm = ResdataPrototype( "permutation_vector_obj double_vector_alloc_rsort_perm(double_vector)" ) - _contains = EclPrototype("bool double_vector_contains(double_vector, double)") - _select_unique = EclPrototype("void double_vector_select_unique(double_vector)") - _element_sum = EclPrototype("double double_vector_sum(double_vector)") - _get_data_ptr = EclPrototype("double* double_vector_get_ptr(double_vector)") - _count_equal = EclPrototype("int double_vector_count_equal(double_vector, double)") - _init_range = EclPrototype( + _contains = ResdataPrototype("bool double_vector_contains(double_vector, double)") + _select_unique = ResdataPrototype("void double_vector_select_unique(double_vector)") + _element_sum = ResdataPrototype("double double_vector_sum(double_vector)") + _get_data_ptr = ResdataPrototype("double* double_vector_get_ptr(double_vector)") + _count_equal = ResdataPrototype( + "int double_vector_count_equal(double_vector, double)" + ) + _init_range = ResdataPrototype( "void double_vector_init_range(double_vector, double , double , double)" ) - _init_linear = EclPrototype( + _init_linear = ResdataPrototype( "bool double_vector_init_linear(double_vector, double, double, int)" ) - _equal = EclPrototype("bool double_vector_equal(double_vector, double_vector)") - _first_eq = EclPrototype( + _equal = ResdataPrototype("bool double_vector_equal(double_vector, double_vector)") + _first_eq = ResdataPrototype( "int double_vector_first_equal(double_vector, double_vector, int)" ) - _first_neq = EclPrototype( + _first_neq = ResdataPrototype( "int double_vector_first_not_equal(double_vector, double_vector, int)" ) diff --git a/python/resdata/util/util/hash.py b/python/resdata/util/util/hash.py index b0f78a3093..3f2a5509f7 100644 --- a/python/resdata/util/util/hash.py +++ b/python/resdata/util/util/hash.py @@ -1,18 +1,18 @@ from ctypes import c_void_p from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.util.util import StringList +from resdata import ResdataPrototype +from resdata.util.util import StringList class Hash(BaseCClass): - _alloc = EclPrototype("void* hash_alloc()", bind=False) - _free = EclPrototype("void hash_free(hash)") - _size = EclPrototype("int hash_get_size(hash)") - _keys = EclPrototype("stringlist_obj hash_alloc_stringlist(hash)") - _has_key = EclPrototype("bool hash_has_key(hash, char*)") - _get = EclPrototype("void* hash_get(hash, char*)") - _insert_ref = EclPrototype("void hash_insert_ref(hash, char*, void*)") + _alloc = ResdataPrototype("void* hash_alloc()", bind=False) + _free = ResdataPrototype("void hash_free(hash)") + _size = ResdataPrototype("int hash_get_size(hash)") + _keys = ResdataPrototype("stringlist_obj hash_alloc_stringlist(hash)") + _has_key = ResdataPrototype("bool hash_has_key(hash, char*)") + _get = ResdataPrototype("void* hash_get(hash, char*)") + _insert_ref = ResdataPrototype("void hash_insert_ref(hash, char*, void*)") """ Base hash class that supports string:void* values @@ -57,8 +57,8 @@ def __str__(self): class StringHash(Hash): - _get_string = EclPrototype("char* hash_get_string(hash, char*)") - _insert_string = EclPrototype("void hash_insert_string(hash, char*, char*)") + _get_string = ResdataPrototype("char* hash_get_string(hash, char*)") + _insert_string = ResdataPrototype("void hash_insert_string(hash, char*, char*)") def __init__(self): super(StringHash, self).__init__() @@ -77,8 +77,8 @@ def __getitem__(self, key): class IntegerHash(Hash): - _get_int = EclPrototype("int hash_get_int(hash, char*)") - _insert_int = EclPrototype("void hash_insert_int(hash, char*, int)") + _get_int = ResdataPrototype("int hash_get_int(hash, char*)") + _insert_int = ResdataPrototype("void hash_insert_int(hash, char*, int)") def __init__(self): super(IntegerHash, self).__init__() @@ -97,8 +97,8 @@ def __getitem__(self, key): class DoubleHash(Hash): - _get_double = EclPrototype("double hash_get_double(hash, char*)") - _insert_double = EclPrototype("void hash_insert_double(hash, char*, double)") + _get_double = ResdataPrototype("double hash_get_double(hash, char*)") + _insert_double = ResdataPrototype("void hash_insert_double(hash, char*, double)") def __init__(self): super(DoubleHash, self).__init__() diff --git a/python/resdata/util/util/install_abort_signals.py b/python/resdata/util/util/install_abort_signals.py index b71effd737..56439e8708 100644 --- a/python/resdata/util/util/install_abort_signals.py +++ b/python/resdata/util/util/install_abort_signals.py @@ -1,11 +1,11 @@ -from ecl import EclPrototype +from resdata import ResdataPrototype import sys import os def installAbortSignals(): - if sys.version_info.major < 3 and not os.getenv("ECL_SKIP_SIGNAL"): - install_signals = EclPrototype("void util_install_signals()") + if sys.version_info.major < 3 and not os.getenv("RD_SKIP_SIGNAL"): + install_signals = ResdataPrototype("void util_install_signals()") install_signals() @@ -13,6 +13,6 @@ def updateAbortSignals(): """ Will install the util_abort_signal for all UNMODIFIED signals. """ - if sys.version_info.major < 3 and not os.getenv("ECL_SKIP_SIGNAL"): - update_signals = EclPrototype("void util_update_signals()") + if sys.version_info.major < 3 and not os.getenv("RD_SKIP_SIGNAL"): + update_signals = ResdataPrototype("void util_update_signals()") update_signals() diff --git a/python/resdata/util/util/int_vector.py b/python/resdata/util/util/int_vector.py index 62b453ccec..666e2a5bc5 100644 --- a/python/resdata/util/util/int_vector.py +++ b/python/resdata/util/util/int_vector.py @@ -1,83 +1,93 @@ -from ecl import EclPrototype -from ecl.util.util import VectorTemplate +from resdata import ResdataPrototype +from resdata.util.util import VectorTemplate class IntVector(VectorTemplate): default_format = "%d" - _alloc = EclPrototype("void* int_vector_alloc( int , int )", bind=False) - _create_active_list = EclPrototype( + _alloc = ResdataPrototype("void* int_vector_alloc( int , int )", bind=False) + _create_active_list = ResdataPrototype( "int_vector_obj string_util_alloc_active_list( char*)", bind=False ) - _create_value_list = EclPrototype( + _create_value_list = ResdataPrototype( "int_vector_obj string_util_alloc_value_list( char*)", bind=False ) - _alloc_copy = EclPrototype("int_vector_obj int_vector_alloc_copy( int_vector )") - _strided_copy = EclPrototype( + _alloc_copy = ResdataPrototype("int_vector_obj int_vector_alloc_copy( int_vector )") + _strided_copy = ResdataPrototype( "int_vector_obj int_vector_alloc_strided_copy( int_vector , int , int , int)" ) - _free = EclPrototype("void int_vector_free( int_vector )") - _iget = EclPrototype("int int_vector_iget( int_vector , int )") - _safe_iget = EclPrototype("int int_vector_safe_iget( int_vector , int )") - _iset = EclPrototype("int int_vector_iset( int_vector , int , int)") - _size = EclPrototype("int int_vector_size( int_vector )") - _append = EclPrototype("void int_vector_append( int_vector , int )") - _idel_block = EclPrototype("void int_vector_idel_block( int_vector , int , int )") - _pop = EclPrototype("int int_vector_pop( int_vector )") - _idel = EclPrototype("void int_vector_idel( int_vector , int )") - _insert = EclPrototype("void int_vector_insert( int_vector , int , int)") - _lshift = EclPrototype("void int_vector_lshift( int_vector , int )") - _rshift = EclPrototype("void int_vector_rshift( int_vector , int )") - _fprintf = EclPrototype( + _free = ResdataPrototype("void int_vector_free( int_vector )") + _iget = ResdataPrototype("int int_vector_iget( int_vector , int )") + _safe_iget = ResdataPrototype("int int_vector_safe_iget( int_vector , int )") + _iset = ResdataPrototype("int int_vector_iset( int_vector , int , int)") + _size = ResdataPrototype("int int_vector_size( int_vector )") + _append = ResdataPrototype("void int_vector_append( int_vector , int )") + _idel_block = ResdataPrototype( + "void int_vector_idel_block( int_vector , int , int )" + ) + _pop = ResdataPrototype("int int_vector_pop( int_vector )") + _idel = ResdataPrototype("void int_vector_idel( int_vector , int )") + _insert = ResdataPrototype("void int_vector_insert( int_vector , int , int)") + _lshift = ResdataPrototype("void int_vector_lshift( int_vector , int )") + _rshift = ResdataPrototype("void int_vector_rshift( int_vector , int )") + _fprintf = ResdataPrototype( "void int_vector_fprintf( int_vector , FILE , char* , char*)" ) - _sort = EclPrototype("void int_vector_sort( int_vector )") - _rsort = EclPrototype("void int_vector_rsort( int_vector )") - _reset = EclPrototype("void int_vector_reset( int_vector )") - _set_read_only = EclPrototype( + _sort = ResdataPrototype("void int_vector_sort( int_vector )") + _rsort = ResdataPrototype("void int_vector_rsort( int_vector )") + _reset = ResdataPrototype("void int_vector_reset( int_vector )") + _set_read_only = ResdataPrototype( "void int_vector_set_read_only( int_vector , bool )" ) - _get_read_only = EclPrototype("bool int_vector_get_read_only( int_vector )") - _get_max = EclPrototype("int int_vector_get_max( int_vector )") - _get_min = EclPrototype("int int_vector_get_min( int_vector )") - _get_max_index = EclPrototype("int int_vector_get_max_index( int_vector , bool)") - _get_min_index = EclPrototype("int int_vector_get_min_index( int_vector , bool)") - _shift = EclPrototype("void int_vector_shift( int_vector , int )") - _scale = EclPrototype("void int_vector_scale( int_vector , int )") - _div = EclPrototype("void int_vector_div( int_vector , int )") - _inplace_add = EclPrototype( + _get_read_only = ResdataPrototype("bool int_vector_get_read_only( int_vector )") + _get_max = ResdataPrototype("int int_vector_get_max( int_vector )") + _get_min = ResdataPrototype("int int_vector_get_min( int_vector )") + _get_max_index = ResdataPrototype( + "int int_vector_get_max_index( int_vector , bool)" + ) + _get_min_index = ResdataPrototype( + "int int_vector_get_min_index( int_vector , bool)" + ) + _shift = ResdataPrototype("void int_vector_shift( int_vector , int )") + _scale = ResdataPrototype("void int_vector_scale( int_vector , int )") + _div = ResdataPrototype("void int_vector_div( int_vector , int )") + _inplace_add = ResdataPrototype( "void int_vector_inplace_add( int_vector , int_vector )" ) - _inplace_mul = EclPrototype( + _inplace_mul = ResdataPrototype( "void int_vector_inplace_mul( int_vector , int_vector )" ) - _assign = EclPrototype("void int_vector_set_all( int_vector , int)") - _memcpy = EclPrototype("void int_vector_memcpy(int_vector , int_vector )") - _set_default = EclPrototype("void int_vector_set_default( int_vector , int)") - _get_default = EclPrototype("int int_vector_get_default( int_vector )") - _element_size = EclPrototype("int int_vector_element_size( int_vector )") + _assign = ResdataPrototype("void int_vector_set_all( int_vector , int)") + _memcpy = ResdataPrototype("void int_vector_memcpy(int_vector , int_vector )") + _set_default = ResdataPrototype("void int_vector_set_default( int_vector , int)") + _get_default = ResdataPrototype("int int_vector_get_default( int_vector )") + _element_size = ResdataPrototype("int int_vector_element_size( int_vector )") - _permute = EclPrototype("void int_vector_permute(int_vector, permutation_vector)") - _sort_perm = EclPrototype( + _permute = ResdataPrototype( + "void int_vector_permute(int_vector, permutation_vector)" + ) + _sort_perm = ResdataPrototype( "permutation_vector_obj int_vector_alloc_sort_perm(int_vector)" ) - _rsort_perm = EclPrototype( + _rsort_perm = ResdataPrototype( "permutation_vector_obj int_vector_alloc_rsort_perm(int_vector)" ) - _contains = EclPrototype("bool int_vector_contains(int_vector, int)") - _select_unique = EclPrototype("void int_vector_select_unique(int_vector)") - _element_sum = EclPrototype("int int_vector_sum(int_vector)") - _get_data_ptr = EclPrototype("int* int_vector_get_ptr(int_vector)") - _count_equal = EclPrototype("int int_vector_count_equal(int_vector, int)") - _init_range = EclPrototype( + _contains = ResdataPrototype("bool int_vector_contains(int_vector, int)") + _select_unique = ResdataPrototype("void int_vector_select_unique(int_vector)") + _element_sum = ResdataPrototype("int int_vector_sum(int_vector)") + _get_data_ptr = ResdataPrototype("int* int_vector_get_ptr(int_vector)") + _count_equal = ResdataPrototype("int int_vector_count_equal(int_vector, int)") + _init_range = ResdataPrototype( "void int_vector_init_range(int_vector, int , int , int)" ) - _init_linear = EclPrototype( + _init_linear = ResdataPrototype( "bool int_vector_init_linear(int_vector, int, int, int)" ) - _equal = EclPrototype("bool int_vector_equal(int_vector, int_vector)") - _first_eq = EclPrototype("int int_vector_first_equal(int_vector, int_vector, int)") - _first_neq = EclPrototype( + _equal = ResdataPrototype("bool int_vector_equal(int_vector, int_vector)") + _first_eq = ResdataPrototype( + "int int_vector_first_equal(int_vector, int_vector, int)" + ) + _first_neq = ResdataPrototype( "int int_vector_first_not_equal(int_vector, int_vector, int)" ) diff --git a/python/resdata/util/util/lookup_table.py b/python/resdata/util/util/lookup_table.py index 61ce2d72be..65e8292c9a 100644 --- a/python/resdata/util/util/lookup_table.py +++ b/python/resdata/util/util/lookup_table.py @@ -1,25 +1,29 @@ from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class LookupTable(BaseCClass): - _alloc = EclPrototype("void* lookup_table_alloc_empty()", bind=False) - _max = EclPrototype("double lookup_table_get_max_value( lookup_table )") - _min = EclPrototype("double lookup_table_get_min_value( lookup_table )") - _arg_max = EclPrototype("double lookup_table_get_max_arg( lookup_table )") - _arg_min = EclPrototype("double lookup_table_get_min_arg( lookup_table )") - _append = EclPrototype("void lookup_table_append( lookup_table , double , double )") - _size = EclPrototype("int lookup_table_get_size( lookup_table )") - _interp = EclPrototype("double lookup_table_interp( lookup_table , double)") - _free = EclPrototype("void lookup_table_free( lookup_table )") - _set_low_limit = EclPrototype( + _alloc = ResdataPrototype("void* lookup_table_alloc_empty()", bind=False) + _max = ResdataPrototype("double lookup_table_get_max_value( lookup_table )") + _min = ResdataPrototype("double lookup_table_get_min_value( lookup_table )") + _arg_max = ResdataPrototype("double lookup_table_get_max_arg( lookup_table )") + _arg_min = ResdataPrototype("double lookup_table_get_min_arg( lookup_table )") + _append = ResdataPrototype( + "void lookup_table_append( lookup_table , double , double )" + ) + _size = ResdataPrototype("int lookup_table_get_size( lookup_table )") + _interp = ResdataPrototype("double lookup_table_interp( lookup_table , double)") + _free = ResdataPrototype("void lookup_table_free( lookup_table )") + _set_low_limit = ResdataPrototype( "void lookup_table_set_low_limit( lookup_table , double)" ) - _set_high_limit = EclPrototype( + _set_high_limit = ResdataPrototype( "void lookup_table_set_high_limit( lookup_table , double)" ) - _has_low_limit = EclPrototype("bool lookup_table_has_low_limit( lookup_table)") - _has_high_limit = EclPrototype("bool lookup_table_has_high_limit( lookup_table)") + _has_low_limit = ResdataPrototype("bool lookup_table_has_low_limit( lookup_table)") + _has_high_limit = ResdataPrototype( + "bool lookup_table_has_high_limit( lookup_table)" + ) def __init__(self, lower_limit=None, upper_limit=None): super(LookupTable, self).__init__(self._alloc()) diff --git a/python/resdata/util/util/permutation_vector.py b/python/resdata/util/util/permutation_vector.py index 60ae241d2c..16016a47d9 100644 --- a/python/resdata/util/util/permutation_vector.py +++ b/python/resdata/util/util/permutation_vector.py @@ -1,12 +1,12 @@ from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class PermutationVector(BaseCClass): TYPE_NAME = "permutation_vector" - _free = EclPrototype("void perm_vector_free( permutation_vector )") - _size = EclPrototype("int perm_vector_get_size( permutation_vector )") - _iget = EclPrototype("int perm_vector_iget( permutation_vector , int)") + _free = ResdataPrototype("void perm_vector_free( permutation_vector )") + _size = ResdataPrototype("int perm_vector_get_size( permutation_vector )") + _iget = ResdataPrototype("int perm_vector_iget( permutation_vector , int)") def __init__(self): raise NotImplementedError("Can not instantiate PermutationVector directly") diff --git a/python/resdata/util/util/rng.py b/python/resdata/util/util/rng.py index 09933522d2..426568f5fd 100644 --- a/python/resdata/util/util/rng.py +++ b/python/resdata/util/util/rng.py @@ -1,25 +1,25 @@ import os.path from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.util.enums import RngInitModeEnum, RngAlgTypeEnum +from resdata import ResdataPrototype +from resdata.util.enums import RngInitModeEnum, RngAlgTypeEnum class RandomNumberGenerator(BaseCClass): TYPE_NAME = "rng" - _rng_alloc = EclPrototype( + _rng_alloc = ResdataPrototype( "void* rng_alloc(rng_alg_type_enum, rng_init_mode_enum)", bind=False ) - _free = EclPrototype("void rng_free(rng)") - _get_double = EclPrototype("double rng_get_double(rng)") - _get_int = EclPrototype("int rng_get_int(rng, int)") - _forward = EclPrototype("uint rng_forward(rng)") - _get_max_int = EclPrototype("uint rng_get_max_int(rng)") - _state_size = EclPrototype("int rng_state_size(rng)") - _set_state = EclPrototype("void rng_set_state(rng , char*)") - _load_state = EclPrototype("void rng_load_state(rng , char*)") - _save_state = EclPrototype("void rng_save_state(rng , char*)") + _free = ResdataPrototype("void rng_free(rng)") + _get_double = ResdataPrototype("double rng_get_double(rng)") + _get_int = ResdataPrototype("int rng_get_int(rng, int)") + _forward = ResdataPrototype("uint rng_forward(rng)") + _get_max_int = ResdataPrototype("uint rng_get_max_int(rng)") + _state_size = ResdataPrototype("int rng_state_size(rng)") + _set_state = ResdataPrototype("void rng_set_state(rng , char*)") + _load_state = ResdataPrototype("void rng_load_state(rng , char*)") + _save_state = ResdataPrototype("void rng_save_state(rng , char*)") def __init__( self, alg_type=RngAlgTypeEnum.MZRAN, init_mode=RngInitModeEnum.INIT_CLOCK diff --git a/python/resdata/util/util/stringlist.py b/python/resdata/util/util/stringlist.py index 5130c98097..91cf383ee0 100644 --- a/python/resdata/util/util/stringlist.py +++ b/python/resdata/util/util/stringlist.py @@ -15,28 +15,28 @@ return a normal python list of string objects, used in this way you hardly need to notice that the StringList class is at play. """ -from ecl import EclPrototype +from resdata import ResdataPrototype from cwrap import BaseCClass class StringList(BaseCClass): TYPE_NAME = "stringlist" - _alloc = EclPrototype("void* stringlist_alloc_new( )", bind=False) - _free = EclPrototype("void stringlist_free(stringlist )") - _append = EclPrototype("void stringlist_append_copy(stringlist , char* )") - _iget = EclPrototype("char* stringlist_iget(stringlist , int )") - _front = EclPrototype("char* stringlist_front( stringlist )") - _back = EclPrototype("char* stringlist_back( stringlist )") - _iget_copy = EclPrototype("char* stringlist_iget_copy(stringlist, int)") - _iset = EclPrototype("void stringlist_iset_copy( stringlist , int , char* )") - _get_size = EclPrototype("int stringlist_get_size( stringlist )") - _contains = EclPrototype("bool stringlist_contains(stringlist , char*)") - _equal = EclPrototype("bool stringlist_equal(stringlist , stringlist)") - _sort = EclPrototype("void stringlist_python_sort( stringlist , int)") - _pop = EclPrototype("char* stringlist_pop(stringlist)") - _last = EclPrototype("char* stringlist_get_last(stringlist)") - _find_first = EclPrototype("int stringlist_find_first(stringlist, char*)") + _alloc = ResdataPrototype("void* stringlist_alloc_new( )", bind=False) + _free = ResdataPrototype("void stringlist_free(stringlist )") + _append = ResdataPrototype("void stringlist_append_copy(stringlist , char* )") + _iget = ResdataPrototype("char* stringlist_iget(stringlist , int )") + _front = ResdataPrototype("char* stringlist_front( stringlist )") + _back = ResdataPrototype("char* stringlist_back( stringlist )") + _iget_copy = ResdataPrototype("char* stringlist_iget_copy(stringlist, int)") + _iset = ResdataPrototype("void stringlist_iset_copy( stringlist , int , char* )") + _get_size = ResdataPrototype("int stringlist_get_size( stringlist )") + _contains = ResdataPrototype("bool stringlist_contains(stringlist , char*)") + _equal = ResdataPrototype("bool stringlist_equal(stringlist , stringlist)") + _sort = ResdataPrototype("void stringlist_python_sort( stringlist , int)") + _pop = ResdataPrototype("char* stringlist_pop(stringlist)") + _last = ResdataPrototype("char* stringlist_get_last(stringlist)") + _find_first = ResdataPrototype("int stringlist_find_first(stringlist, char*)") def __init__(self, initial=None): """ diff --git a/python/resdata/util/util/time_vector.py b/python/resdata/util/util/time_vector.py index c8eb09084b..7109932dce 100644 --- a/python/resdata/util/util/time_vector.py +++ b/python/resdata/util/util/time_vector.py @@ -1,100 +1,114 @@ import datetime import re -from ecl import EclPrototype -from ecl.util.util import VectorTemplate, CTime +from resdata import ResdataPrototype +from resdata.util.util import VectorTemplate, CTime class TimeVector(VectorTemplate): TYPE_NAME = "time_t_vector" default_format = "%d" - _alloc = EclPrototype("void* time_t_vector_alloc(int, time_t )", bind=False) - _alloc_copy = EclPrototype( + _alloc = ResdataPrototype("void* time_t_vector_alloc(int, time_t )", bind=False) + _alloc_copy = ResdataPrototype( "time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )" ) - _strided_copy = EclPrototype( + _strided_copy = ResdataPrototype( "time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , int , int , int)" ) - _free = EclPrototype("void time_t_vector_free( time_t_vector )") - _iget = EclPrototype("time_t time_t_vector_iget( time_t_vector , int )") - _safe_iget = EclPrototype("time_t time_t_vector_safe_iget( time_t_vector , int )") - _iset = EclPrototype("time_t time_t_vector_iset( time_t_vector , int , time_t)") - _size = EclPrototype("int time_t_vector_size( time_t_vector )") - _append = EclPrototype("void time_t_vector_append( time_t_vector , time_t )") - _idel_block = EclPrototype( + _free = ResdataPrototype("void time_t_vector_free( time_t_vector )") + _iget = ResdataPrototype("time_t time_t_vector_iget( time_t_vector , int )") + _safe_iget = ResdataPrototype( + "time_t time_t_vector_safe_iget( time_t_vector , int )" + ) + _iset = ResdataPrototype( + "time_t time_t_vector_iset( time_t_vector , int , time_t)" + ) + _size = ResdataPrototype("int time_t_vector_size( time_t_vector )") + _append = ResdataPrototype( + "void time_t_vector_append( time_t_vector , time_t )" + ) + _idel_block = ResdataPrototype( "void time_t_vector_idel_block( time_t_vector , int , int )" ) - _idel = EclPrototype("void time_t_vector_idel( time_t_vector , int )") - _pop = EclPrototype("time_t time_t_vector_pop( time_t_vector )") - _lshift = EclPrototype("void time_t_vector_lshift( time_t_vector , int )") - _rshift = EclPrototype("void time_t_vector_rshift( time_t_vector , int )") - _insert = EclPrototype( + _idel = ResdataPrototype("void time_t_vector_idel( time_t_vector , int )") + _pop = ResdataPrototype("time_t time_t_vector_pop( time_t_vector )") + _lshift = ResdataPrototype("void time_t_vector_lshift( time_t_vector , int )") + _rshift = ResdataPrototype("void time_t_vector_rshift( time_t_vector , int )") + _insert = ResdataPrototype( "void time_t_vector_insert( time_t_vector , int , time_t)" ) - _fprintf = EclPrototype( + _fprintf = ResdataPrototype( "void time_t_vector_fprintf( time_t_vector , FILE , char* , char*)" ) - _sort = EclPrototype("void time_t_vector_sort( time_t_vector )") - _rsort = EclPrototype("void time_t_vector_rsort( time_t_vector )") - _reset = EclPrototype("void time_t_vector_reset( time_t_vector )") - _set_read_only = EclPrototype( + _sort = ResdataPrototype("void time_t_vector_sort( time_t_vector )") + _rsort = ResdataPrototype("void time_t_vector_rsort( time_t_vector )") + _reset = ResdataPrototype("void time_t_vector_reset( time_t_vector )") + _set_read_only = ResdataPrototype( "void time_t_vector_set_read_only( time_t_vector , bool )" ) - _get_read_only = EclPrototype( + _get_read_only = ResdataPrototype( "bool time_t_vector_get_read_only( time_t_vector )" ) - _get_max = EclPrototype("time_t time_t_vector_get_max( time_t_vector )") - _get_min = EclPrototype("time_t time_t_vector_get_min( time_t_vector )") - _get_max_index = EclPrototype( + _get_max = ResdataPrototype("time_t time_t_vector_get_max( time_t_vector )") + _get_min = ResdataPrototype("time_t time_t_vector_get_min( time_t_vector )") + _get_max_index = ResdataPrototype( "int time_t_vector_get_max_index( time_t_vector , bool)" ) - _get_min_index = EclPrototype( + _get_min_index = ResdataPrototype( "int time_t_vector_get_min_index( time_t_vector , bool)" ) - _shift = EclPrototype("void time_t_vector_shift( time_t_vector , time_t )") - _scale = EclPrototype("void time_t_vector_scale( time_t_vector , time_t )") - _div = EclPrototype("void time_t_vector_div( time_t_vector , time_t )") - _inplace_add = EclPrototype( + _shift = ResdataPrototype("void time_t_vector_shift( time_t_vector , time_t )") + _scale = ResdataPrototype("void time_t_vector_scale( time_t_vector , time_t )") + _div = ResdataPrototype("void time_t_vector_div( time_t_vector , time_t )") + _inplace_add = ResdataPrototype( "void time_t_vector_inplace_add( time_t_vector , time_t_vector )" ) - _inplace_mul = EclPrototype( + _inplace_mul = ResdataPrototype( "void time_t_vector_inplace_mul( time_t_vector , time_t_vector )" ) - _assign = EclPrototype("void time_t_vector_set_all( time_t_vector , time_t)") - _memcpy = EclPrototype( + _assign = ResdataPrototype( + "void time_t_vector_set_all( time_t_vector , time_t)" + ) + _memcpy = ResdataPrototype( "void time_t_vector_memcpy(time_t_vector , time_t_vector )" ) - _set_default = EclPrototype( + _set_default = ResdataPrototype( "void time_t_vector_set_default( time_t_vector , time_t)" ) - _get_default = EclPrototype("time_t time_t_vector_get_default( time_t_vector )") - _element_size = EclPrototype("int time_t_vector_element_size( time_t_vector )") + _get_default = ResdataPrototype( + "time_t time_t_vector_get_default( time_t_vector )" + ) + _element_size = ResdataPrototype( + "int time_t_vector_element_size( time_t_vector )" + ) - _permute = EclPrototype( + _permute = ResdataPrototype( "void time_t_vector_permute(time_t_vector, permutation_vector)" ) - _sort_perm = EclPrototype( + _sort_perm = ResdataPrototype( "permutation_vector_obj time_t_vector_alloc_sort_perm(time_t_vector)" ) - _rsort_perm = EclPrototype( + _rsort_perm = ResdataPrototype( "permutation_vector_obj time_t_vector_alloc_rsort_perm(time_t_vector)" ) - _contains = EclPrototype("bool time_t_vector_contains(time_t_vector, time_t)") - _select_unique = EclPrototype("void time_t_vector_select_unique(time_t_vector)") - _element_sum = EclPrototype("time_t time_t_vector_sum(time_t_vector)") - _count_equal = EclPrototype("int time_t_vector_count_equal(time_t_vector, time_t)") - _init_range = EclPrototype( + _contains = ResdataPrototype("bool time_t_vector_contains(time_t_vector, time_t)") + _select_unique = ResdataPrototype("void time_t_vector_select_unique(time_t_vector)") + _element_sum = ResdataPrototype("time_t time_t_vector_sum(time_t_vector)") + _count_equal = ResdataPrototype( + "int time_t_vector_count_equal(time_t_vector, time_t)" + ) + _init_range = ResdataPrototype( "void time_t_vector_init_range(time_t_vector, time_t , time_t , time_t)" ) - _init_linear = EclPrototype( + _init_linear = ResdataPrototype( "bool time_t_vector_init_linear(time_t_vector, time_t, time_t, int)" ) - _equal = EclPrototype("bool time_t_vector_equal(time_t_vector, time_t_vector)") - _first_eq = EclPrototype( + _equal = ResdataPrototype("bool time_t_vector_equal(time_t_vector, time_t_vector)") + _first_eq = ResdataPrototype( "int time_t_vector_first_equal(time_t_vector, time_t_vector, int)" ) - _first_neq = EclPrototype( + _first_neq = ResdataPrototype( "int time_t_vector_first_not_equal(time_t_vector, time_t_vector, int)" ) diff --git a/python/resdata/util/util/util_func.py b/python/resdata/util/util/util_func.py index 8094ef6006..8af0ff2cd9 100644 --- a/python/resdata/util/util/util_func.py +++ b/python/resdata/util/util/util_func.py @@ -2,9 +2,9 @@ Module with utility functions from util.c """ -from ecl import EclPrototype +from resdata import ResdataPrototype -strcmp_int = EclPrototype("int util_strcmp_int( char* , char* )") +strcmp_int = ResdataPrototype("int util_strcmp_int( char* , char* )") """ Function to compare strings with embedded integers. @@ -30,7 +30,7 @@ @type: (str, str) -> int """ -strcmp_float = EclPrototype("int util_strcmp_float( char* , char* )") +strcmp_float = ResdataPrototype("int util_strcmp_float( char* , char* )") """ Function to compare strings with embedded numbers. diff --git a/python/resdata/util/util/vector_template.py b/python/resdata/util/util/vector_template.py index f9a004c3e6..a519f1f1d8 100644 --- a/python/resdata/util/util/vector_template.py +++ b/python/resdata/util/util/vector_template.py @@ -154,7 +154,7 @@ def str_data(self, width, index1, index2, fmt): return s # The str() method is a verbatim copy of the implementation in - # ecl_kw.py. + # rd_kw.py. def str(self, width=5, max_lines=10, fmt=None): """ Return string representation of vector for pretty printing. diff --git a/python/resdata/util/util/version.py b/python/resdata/util/util/version.py index 3a75b7cb0d..cd32d6e712 100644 --- a/python/resdata/util/util/version.py +++ b/python/resdata/util/util/version.py @@ -1,6 +1,6 @@ from functools import wraps -from ecl import EclPrototype +from resdata import ResdataPrototype def cmp_method(method): @@ -63,7 +63,7 @@ def __hash__(self): # All development versions are compared with micro version == -1; # i.e. the two versions version(1,2,"Alpha") and - # ecl_version(1,2,"Beta") compare as equal in the >= and <= tests - + # rd_version(1,2,"Beta") compare as equal in the >= and <= tests - # but not in the == test. @cmp_method @@ -98,13 +98,15 @@ def getGitCommit(self, short=False): return self.git_commit -class EclVersion(Version): - _build_time = EclPrototype("char* ecl_version_get_build_time()", bind=False) - _git_commit = EclPrototype("char* ecl_version_get_git_commit()", bind=False) - _major_version = EclPrototype("int ecl_version_get_major_version()", bind=False) - _minor_version = EclPrototype("int ecl_version_get_minor_version()", bind=False) - _micro_version = EclPrototype("char* ecl_version_get_micro_version()", bind=False) - _is_devel = EclPrototype("bool ecl_version_is_devel_version()", bind=False) +class ResdataVersion(Version): + _build_time = ResdataPrototype("char* rd_version_get_build_time()", bind=False) + _git_commit = ResdataPrototype("char* rd_version_get_git_commit()", bind=False) + _major_version = ResdataPrototype("int rd_version_get_major_version()", bind=False) + _minor_version = ResdataPrototype("int rd_version_get_minor_version()", bind=False) + _micro_version = ResdataPrototype( + "char* rd_version_get_micro_version()", bind=False + ) + _is_devel = ResdataPrototype("bool rd_version_is_devel_version()", bind=False) def __init__(self): major = self._major_version() @@ -112,4 +114,6 @@ def __init__(self): micro = self._micro_version() git_commit = self._git_commit() build_time = self._build_time() - super(EclVersion, self).__init__(major, minor, micro, git_commit, build_time) + super(ResdataVersion, self).__init__( + major, minor, micro, git_commit, build_time + ) diff --git a/python/resdata/well/CMakeLists.txt b/python/resdata/well/CMakeLists.txt index 305d079a26..04183a1d6b 100644 --- a/python/resdata/well/CMakeLists.txt +++ b/python/resdata/well/CMakeLists.txt @@ -8,5 +8,5 @@ set(PYTHON_SOURCES well_time_line.py well_type_enum.py) -add_python_package("python.ecl.well" ${PYTHON_INSTALL_PREFIX}/ecl/well +add_python_package("python.ecl.well" ${PYTHON_INSTALL_PREFIX}/resdata/well "${PYTHON_SOURCES}" True) diff --git a/python/resdata/well/__init__.py b/python/resdata/well/__init__.py index 71a0ebd3be..9243a12993 100644 --- a/python/resdata/well/__init__.py +++ b/python/resdata/well/__init__.py @@ -1,6 +1,6 @@ -import ecl -import ecl.util.util -import ecl.util.geometry +import resdata +import resdata.util.util +import resdata.util.geometry from cwrap import Prototype diff --git a/python/resdata/well/well_connection.py b/python/resdata/well/well_connection.py index 67a3504a4a..09e02960a0 100644 --- a/python/resdata/well/well_connection.py +++ b/python/resdata/well/well_connection.py @@ -1,37 +1,41 @@ from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.well import WellConnectionDirectionEnum +from resdata import ResdataPrototype +from resdata.well import WellConnectionDirectionEnum class WellConnection(BaseCClass): TYPE_NAME = "well_connection" - _i = EclPrototype("int well_conn_get_i(well_connection)") - _j = EclPrototype("int well_conn_get_j(well_connection)") - _k = EclPrototype("int well_conn_get_k(well_connection)") - _segment_id = EclPrototype("int well_conn_get_segment_id(well_connection)") - _is_open = EclPrototype("bool well_conn_open(well_connection)") - _is_msw = EclPrototype("bool well_conn_MSW(well_connection)") - _fracture_connection = EclPrototype( + _i = ResdataPrototype("int well_conn_get_i(well_connection)") + _j = ResdataPrototype("int well_conn_get_j(well_connection)") + _k = ResdataPrototype("int well_conn_get_k(well_connection)") + _segment_id = ResdataPrototype("int well_conn_get_segment_id(well_connection)") + _is_open = ResdataPrototype("bool well_conn_open(well_connection)") + _is_msw = ResdataPrototype("bool well_conn_MSW(well_connection)") + _fracture_connection = ResdataPrototype( "bool well_conn_fracture_connection(well_connection)" ) - _matrix_connection = EclPrototype( + _matrix_connection = ResdataPrototype( "bool well_conn_matrix_connection(well_connection)" ) - _connection_factor = EclPrototype( + _connection_factor = ResdataPrototype( "double well_conn_get_connection_factor(well_connection)" ) - _equal = EclPrototype("bool well_conn_equal(well_connection, well_connection)") - _get_dir = EclPrototype("void* well_conn_get_dir(well_connection)") - _oil_rate = EclPrototype("double well_conn_get_oil_rate(well_connection)") - _gas_rate = EclPrototype("double well_conn_get_gas_rate(well_connection)") - _water_rate = EclPrototype("double well_conn_get_water_rate(well_connection)") - _volume_rate = EclPrototype("double well_conn_get_volume_rate(well_connection)") - - _oil_rate_si = EclPrototype("double well_conn_get_oil_rate_si(well_connection)") - _gas_rate_si = EclPrototype("double well_conn_get_gas_rate_si(well_connection)") - _water_rate_si = EclPrototype("double well_conn_get_water_rate_si(well_connection)") - _volume_rate_si = EclPrototype( + _equal = ResdataPrototype( + "bool well_conn_equal(well_connection, well_connection)" + ) + _get_dir = ResdataPrototype("void* well_conn_get_dir(well_connection)") + _oil_rate = ResdataPrototype("double well_conn_get_oil_rate(well_connection)") + _gas_rate = ResdataPrototype("double well_conn_get_gas_rate(well_connection)") + _water_rate = ResdataPrototype("double well_conn_get_water_rate(well_connection)") + _volume_rate = ResdataPrototype("double well_conn_get_volume_rate(well_connection)") + + _oil_rate_si = ResdataPrototype("double well_conn_get_oil_rate_si(well_connection)") + _gas_rate_si = ResdataPrototype("double well_conn_get_gas_rate_si(well_connection)") + _water_rate_si = ResdataPrototype( + "double well_conn_get_water_rate_si(well_connection)" + ) + _volume_rate_si = ResdataPrototype( "double well_conn_get_volume_rate_si(well_connection)" ) diff --git a/python/resdata/well/well_info.py b/python/resdata/well/well_info.py index 536d6c6988..579b6209fc 100644 --- a/python/resdata/well/well_info.py +++ b/python/resdata/well/well_info.py @@ -1,29 +1,31 @@ from os.path import isfile from cwrap import BaseCClass -from ecl.grid import EclGrid -from ecl.eclfile.ecl_file import EclFile -from ecl.well import WellTimeLine -from ecl import EclPrototype +from resdata.grid import ResdataGrid +from resdata.eclfile.rd_file import ResdataFile +from resdata.well import WellTimeLine +from resdata import ResdataPrototype class WellInfo(BaseCClass): TYPE_NAME = "well_info" - _alloc = EclPrototype("void* well_info_alloc(ecl_grid)", bind=False) - _free = EclPrototype("void well_info_free(well_info)") - _load_rstfile = EclPrototype("void well_info_load_rstfile(well_info, char*, bool)") - _load_rst_eclfile = EclPrototype( - "void well_info_load_rst_eclfile(well_info, ecl_file, bool)" + _alloc = ResdataPrototype("void* well_info_alloc(rd_grid)", bind=False) + _free = ResdataPrototype("void well_info_free(well_info)") + _load_rstfile = ResdataPrototype( + "void well_info_load_rstfile(well_info, char*, bool)" ) - _get_well_count = EclPrototype("int well_info_get_num_wells(well_info)") - _iget_well_name = EclPrototype("char* well_info_iget_well_name(well_info, int)") - _has_well = EclPrototype("bool well_info_has_well(well_info, char*)") - _get_ts = EclPrototype("well_time_line_ref well_info_get_ts(well_info, char*)") + _load_rst_eclfile = ResdataPrototype( + "void well_info_load_rst_eclfile(well_info, rd_file, bool)" + ) + _get_well_count = ResdataPrototype("int well_info_get_num_wells(well_info)") + _iget_well_name = ResdataPrototype("char* well_info_iget_well_name(well_info, int)") + _has_well = ResdataPrototype("bool well_info_has_well(well_info, char*)") + _get_ts = ResdataPrototype("well_time_line_ref well_info_get_ts(well_info, char*)") def __init__(self, grid, rst_file=None, load_segment_information=True): """ - @type grid: EclGrid - @type rst_file: str or EclFile or list of str or list of EclFile + @type grid: ResdataGrid + @type rst_file: str or ResdataFile or list of str or list of ResdataFile """ c_ptr = self._alloc(grid) super(WellInfo, self).__init__(c_ptr) @@ -88,15 +90,15 @@ def _assert_file_exists(self, rst_file): raise IOError("No such file %s" % rst_file) def addWellFile(self, rst_file, load_segment_information): - """@type rstfile: str or EclFile""" + """@type rstfile: str or ResdataFile""" if isinstance(rst_file, str): self._assert_file_exists(rst_file) self._load_rstfile(rst_file, load_segment_information) - elif isinstance(rst_file, EclFile): + elif isinstance(rst_file, ResdataFile): self._load_rst_eclfile(rst_file, load_segment_information) else: raise TypeError( - "Expected the RST file to be a filename or an EclFile instance." + "Expected the RST file to be a filename or an ResdataFile instance." ) def hasWell(self, well_name): diff --git a/python/resdata/well/well_segment.py b/python/resdata/well/well_segment.py index e3560f56f7..2e34e921a0 100644 --- a/python/resdata/well/well_segment.py +++ b/python/resdata/well/well_segment.py @@ -1,21 +1,25 @@ from cwrap import BaseCClass -from ecl import EclPrototype +from resdata import ResdataPrototype class WellSegment(BaseCClass): TYPE_NAME = "well_segment" - _active = EclPrototype("bool well_segment_active(well_segment)") - _main_stem = EclPrototype("bool well_segment_main_stem(well_segment)") - _nearest_wellhead = EclPrototype("bool well_segment_nearest_wellhead(well_segment)") - _id = EclPrototype("int well_segment_get_id(well_segment)") - _link_count = EclPrototype("int well_segment_get_link_count(well_segment)") - _branch_id = EclPrototype("int well_segment_get_branch_id(well_segment)") - _outlet_id = EclPrototype("int well_segment_get_outlet_id(well_segment)") - _depth = EclPrototype("double well_segment_get_depth(well_segment)") - _length = EclPrototype("double well_segment_get_length(well_segment)") - _total_length = EclPrototype("double well_segment_get_total_length(well_segment)") - _diameter = EclPrototype("double well_segment_get_diameter(well_segment)") + _active = ResdataPrototype("bool well_segment_active(well_segment)") + _main_stem = ResdataPrototype("bool well_segment_main_stem(well_segment)") + _nearest_wellhead = ResdataPrototype( + "bool well_segment_nearest_wellhead(well_segment)" + ) + _id = ResdataPrototype("int well_segment_get_id(well_segment)") + _link_count = ResdataPrototype("int well_segment_get_link_count(well_segment)") + _branch_id = ResdataPrototype("int well_segment_get_branch_id(well_segment)") + _outlet_id = ResdataPrototype("int well_segment_get_outlet_id(well_segment)") + _depth = ResdataPrototype("double well_segment_get_depth(well_segment)") + _length = ResdataPrototype("double well_segment_get_length(well_segment)") + _total_length = ResdataPrototype( + "double well_segment_get_total_length(well_segment)" + ) + _diameter = ResdataPrototype("double well_segment_get_diameter(well_segment)") def __init__(self): raise NotImplementedError("Class can not be instantiated directly") diff --git a/python/resdata/well/well_state.py b/python/resdata/well/well_state.py index a40d847dee..f1814e225b 100644 --- a/python/resdata/well/well_state.py +++ b/python/resdata/well/well_state.py @@ -1,51 +1,57 @@ from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.well import WellTypeEnum, WellConnection -from ecl.util.util import CTime +from resdata import ResdataPrototype +from resdata.well import WellTypeEnum, WellConnection +from resdata.util.util import CTime class WellState(BaseCClass): TYPE_NAME = "well_state" - _global_connections_size = EclPrototype( + _global_connections_size = ResdataPrototype( "int well_conn_collection_get_size(void*)", bind=False ) - _global_connections_iget = EclPrototype( + _global_connections_iget = ResdataPrototype( "well_connection_ref well_conn_collection_iget(void*, int)", bind=False ) - _segment_collection_size = EclPrototype( + _segment_collection_size = ResdataPrototype( "int well_segment_collection_get_size(void*)", bind=False ) - _segment_collection_iget = EclPrototype( + _segment_collection_iget = ResdataPrototype( "well_segment_ref well_segment_collection_iget(void*, int)", bind=False ) - _has_global_connections = EclPrototype( + _has_global_connections = ResdataPrototype( "bool well_state_has_global_connections(well_state)" ) - _get_global_connections = EclPrototype( + _get_global_connections = ResdataPrototype( "void* well_state_get_global_connections(well_state)" ) - _get_segment_collection = EclPrototype("void* well_state_get_segments(well_state)") - _branches = EclPrototype("void* well_state_get_branches(well_state)") - _segments = EclPrototype("void* well_state_get_segments(well_state)") - _get_name = EclPrototype("char* well_state_get_name(well_state)") - _is_open = EclPrototype("bool well_state_is_open(well_state)") - _is_msw = EclPrototype("bool well_state_is_MSW(well_state)") - _well_number = EclPrototype("int well_state_get_well_nr(well_state)") - _report_number = EclPrototype("int well_state_get_report_nr(well_state)") - _has_segment_data = EclPrototype("bool well_state_has_segment_data(well_state)") - _sim_time = EclPrototype("time_t well_state_get_sim_time(well_state)") - _well_type = EclPrototype("well_type_enum well_state_get_type(well_state)") - _oil_rate = EclPrototype("double well_state_get_oil_rate(well_state)") - _gas_rate = EclPrototype("double well_state_get_gas_rate(well_state)") - _water_rate = EclPrototype("double well_state_get_water_rate(well_state)") - _volume_rate = EclPrototype("double well_state_get_volume_rate(well_state)") - _oil_rate_si = EclPrototype("double well_state_get_oil_rate_si(well_state)") - _gas_rate_si = EclPrototype("double well_state_get_gas_rate_si(well_state)") - _water_rate_si = EclPrototype("double well_state_get_water_rate_si(well_state)") - _volume_rate_si = EclPrototype("double well_state_get_volume_rate_si(well_state)") - _get_global_well_head = EclPrototype( + _get_segment_collection = ResdataPrototype( + "void* well_state_get_segments(well_state)" + ) + _branches = ResdataPrototype("void* well_state_get_branches(well_state)") + _segments = ResdataPrototype("void* well_state_get_segments(well_state)") + _get_name = ResdataPrototype("char* well_state_get_name(well_state)") + _is_open = ResdataPrototype("bool well_state_is_open(well_state)") + _is_msw = ResdataPrototype("bool well_state_is_MSW(well_state)") + _well_number = ResdataPrototype("int well_state_get_well_nr(well_state)") + _report_number = ResdataPrototype("int well_state_get_report_nr(well_state)") + _has_segment_data = ResdataPrototype( + "bool well_state_has_segment_data(well_state)" + ) + _sim_time = ResdataPrototype("time_t well_state_get_sim_time(well_state)") + _well_type = ResdataPrototype("well_type_enum well_state_get_type(well_state)") + _oil_rate = ResdataPrototype("double well_state_get_oil_rate(well_state)") + _gas_rate = ResdataPrototype("double well_state_get_gas_rate(well_state)") + _water_rate = ResdataPrototype("double well_state_get_water_rate(well_state)") + _volume_rate = ResdataPrototype("double well_state_get_volume_rate(well_state)") + _oil_rate_si = ResdataPrototype("double well_state_get_oil_rate_si(well_state)") + _gas_rate_si = ResdataPrototype("double well_state_get_gas_rate_si(well_state)") + _water_rate_si = ResdataPrototype("double well_state_get_water_rate_si(well_state)") + _volume_rate_si = ResdataPrototype( + "double well_state_get_volume_rate_si(well_state)" + ) + _get_global_well_head = ResdataPrototype( "well_connection_ref well_state_get_global_wellhead(well_state)" ) diff --git a/python/resdata/well/well_time_line.py b/python/resdata/well/well_time_line.py index 3cbeee5166..cd5cb325b4 100644 --- a/python/resdata/well/well_time_line.py +++ b/python/resdata/well/well_time_line.py @@ -1,13 +1,13 @@ from cwrap import BaseCClass -from ecl import EclPrototype -from ecl.well import WellState +from resdata import ResdataPrototype +from resdata.well import WellState class WellTimeLine(BaseCClass): TYPE_NAME = "well_time_line" - _size = EclPrototype("int well_ts_get_size(well_time_line)") - _name = EclPrototype("char* well_ts_get_name(well_time_line)") - _iget = EclPrototype("well_state_ref well_ts_iget_state(well_time_line, int)") + _size = ResdataPrototype("int well_ts_get_size(well_time_line)") + _name = ResdataPrototype("char* well_ts_get_name(well_time_line)") + _iget = ResdataPrototype("well_state_ref well_ts_iget_state(well_time_line, int)") def __init__(self): raise NotImplementedError("Class can not be instantiated directly") diff --git a/python/resdata/well/well_type_enum.py b/python/resdata/well/well_type_enum.py index adfc807ebb..08b2a29cf6 100644 --- a/python/resdata/well/well_type_enum.py +++ b/python/resdata/well/well_type_enum.py @@ -3,15 +3,15 @@ class WellTypeEnum(BaseCEnum): TYPE_NAME = "well_type_enum" - ECL_WELL_ZERO = None - ECL_WELL_PRODUCER = None - ECL_WELL_WATER_INJECTOR = None - ECL_WELL_GAS_INJECTOR = None - ECL_WELL_OIL_INJECTOR = None + RD_WELL_ZERO = None + RD_WELL_PRODUCER = None + RD_WELL_WATER_INJECTOR = None + RD_WELL_GAS_INJECTOR = None + RD_WELL_OIL_INJECTOR = None -WellTypeEnum.addEnum("ECL_WELL_ZERO", 0) -WellTypeEnum.addEnum("ECL_WELL_PRODUCER", 1) -WellTypeEnum.addEnum("ECL_WELL_OIL_INJECTOR", 2) -WellTypeEnum.addEnum("ECL_WELL_WATER_INJECTOR", 3) -WellTypeEnum.addEnum("ECL_WELL_GAS_INJECTOR", 4) +WellTypeEnum.addEnum("RD_WELL_ZERO", 0) +WellTypeEnum.addEnum("RD_WELL_PRODUCER", 1) +WellTypeEnum.addEnum("RD_WELL_OIL_INJECTOR", 2) +WellTypeEnum.addEnum("RD_WELL_WATER_INJECTOR", 3) +WellTypeEnum.addEnum("RD_WELL_GAS_INJECTOR", 4) diff --git a/python/tests/__init__.py b/python/tests/__init__.py index c6002e0af0..709e3de3f5 100644 --- a/python/tests/__init__.py +++ b/python/tests/__init__.py @@ -1,6 +1,6 @@ import os.path import types -from ecl.util.test import ExtendedTestCase +from resdata.util.test import ExtendedTestCase from functools import wraps from functools import partial import unittest @@ -29,7 +29,7 @@ def source_root(): # # Ideally the equinor_test() implementation should just be a suitable wrapper of: # -# skipUnless(EclTest.EQUINOR_DATA, "Missing Equinor testdata") +# skipUnless(ResdataTest.EQUINOR_DATA, "Missing Equinor testdata") # # but that has been surprisingly difficult to achieve. The current # implemenation is based on the skip() function from the unittest/case.py @@ -44,12 +44,12 @@ def source_root(): # # # @equinor_test() -# class EquinorTest(EclTest): +# class EquinorTest(ResdataTest): # # This test class will be skipped entirely if we do not have access to # # Equinor testdata. # # -# class XTest(EclTest): +# class XTest(ResdataTest): # # @equinor_test # def test_method(self): @@ -62,7 +62,7 @@ def equinor_test(): def decorator(test_item): if not isinstance(test_item, type): - if not EclTest.EQUINOR_DATA: + if not ResdataTest.EQUINOR_DATA: @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): @@ -70,7 +70,7 @@ def skip_wrapper(*args, **kwargs): test_item = skip_wrapper - if not EclTest.EQUINOR_DATA: + if not ResdataTest.EQUINOR_DATA: test_item.__unittest_skip__ = True test_item.__unittest_skip_why__ = "Missing Equinor testdata" return test_item @@ -78,7 +78,7 @@ def skip_wrapper(*args, **kwargs): return decorator -class EclTest(ExtendedTestCase): +class ResdataTest(ExtendedTestCase): SOURCE_ROOT = source_root() TESTDATA_ROOT = os.path.join(SOURCE_ROOT, "test-data") EQUINOR_DATA = os.path.islink(os.path.join(TESTDATA_ROOT, "Equinor")) diff --git a/python/tests/bin_tests/test_summary_resample.py b/python/tests/bin_tests/test_summary_resample.py index 57e749c264..1095b8b6d3 100644 --- a/python/tests/bin_tests/test_summary_resample.py +++ b/python/tests/bin_tests/test_summary_resample.py @@ -2,11 +2,11 @@ import subprocess from subprocess import CalledProcessError as CallError -from ecl.grid import Cell, EclGrid -from ecl.summary import EclSum -from tests import EclTest -from ecl.util.test.ecl_mock import createEclSum -from ecl.util.test import TestAreaContext +from resdata.grid import Cell, ResdataGrid +from resdata.summary import RdSum +from tests import ResdataTest +from resdata.util.test.rd_mock import createRdSum +from resdata.util.test import TestAreaContext def fopr(days): @@ -26,7 +26,7 @@ def fgpt(days): def create_case(num_mini_step=10, case="CSV"): length = 100 - return createEclSum( + return createRdSum( case, [ ("FOPT", None, 0, "SM3"), @@ -40,7 +40,7 @@ def create_case(num_mini_step=10, case="CSV"): ) -class SummaryResampleTest(EclTest): +class SummaryResampleTest(ResdataTest): @classmethod def setUpClass(cls): cls.script = os.path.join(cls.SOURCE_ROOT, "bin/summary_resample") @@ -64,7 +64,7 @@ def test_run_default(self): # Should run OK: subprocess.check_call([self.script, "CSV", "OUTPUT"]) - output_case = EclSum("OUTPUT") + output_case = RdSum("OUTPUT") self.assertEqual( output_case.get_data_start_time(), self.case.get_data_start_time() ) @@ -78,7 +78,7 @@ def test_run_default(self): refcase = create_case(num_mini_step=7, case="REFCASE") refcase.fwrite() subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=REFCASE"]) - output_case = EclSum("OUTPUT") + output_case = RdSum("OUTPUT") self.assertEqual( output_case.get_data_start_time(), refcase.get_data_start_time() ) diff --git a/python/tests/geometry_tests/test_convex_hull.py b/python/tests/geometry_tests/test_convex_hull.py index df25197429..8d08efd4a1 100644 --- a/python/tests/geometry_tests/test_convex_hull.py +++ b/python/tests/geometry_tests/test_convex_hull.py @@ -1,8 +1,8 @@ -from ecl.util.geometry.geometry_tools import GeometryTools -from tests import EclTest +from resdata.util.geometry.geometry_tools import GeometryTools +from tests import ResdataTest -class ConvexHullTest(EclTest): +class ConvexHullTest(ResdataTest): def test_ccw(self): p1 = (0, 0) p2 = (1, 0) diff --git a/python/tests/geometry_tests/test_cpolyline.py b/python/tests/geometry_tests/test_cpolyline.py index 02768296cc..807da0c52b 100644 --- a/python/tests/geometry_tests/test_cpolyline.py +++ b/python/tests/geometry_tests/test_cpolyline.py @@ -1,12 +1,12 @@ import math -from ecl.util.geometry import CPolyline, Polyline -from ecl.util.geometry.xyz_io import XYZIo -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.geometry import CPolyline, Polyline +from resdata.util.geometry.xyz_io import XYZIo +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class CPolylineTest(EclTest): +class CPolylineTest(ResdataTest): def setUp(self): self.polyline1 = self.createTestPath("local/geometry/pol11.xyz") self.polyline2 = self.createTestPath("local/geometry/pol8.xyz") diff --git a/python/tests/geometry_tests/test_cpolyline_collection.py b/python/tests/geometry_tests/test_cpolyline_collection.py index 93c61cca05..fb939b6c68 100644 --- a/python/tests/geometry_tests/test_cpolyline_collection.py +++ b/python/tests/geometry_tests/test_cpolyline_collection.py @@ -1,13 +1,13 @@ import gc -from ecl.util.geometry import CPolylineCollection, CPolyline -from ecl.util.geometry.xyz_io import XYZIo -from ecl.util.test import TestAreaContext -from tests import EclTest -from ecl.util.util import DoubleVector +from resdata.util.geometry import CPolylineCollection, CPolyline +from resdata.util.geometry.xyz_io import XYZIo +from resdata.util.test import TestAreaContext +from tests import ResdataTest +from resdata.util.util import DoubleVector -class CPolylineCollectionTest(EclTest): +class CPolylineCollectionTest(ResdataTest): def test_construction(self): pc = CPolylineCollection() self.assertEqual(len(pc), 0) diff --git a/python/tests/geometry_tests/test_geo_pointset.py b/python/tests/geometry_tests/test_geo_pointset.py index 5734bf9618..c12362b6fd 100644 --- a/python/tests/geometry_tests/test_geo_pointset.py +++ b/python/tests/geometry_tests/test_geo_pointset.py @@ -1,9 +1,9 @@ -from ecl.util.geometry import GeoPointset, Surface -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.geometry import GeoPointset, Surface +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class GeoPointsetTest(EclTest): +class GeoPointsetTest(ResdataTest): def test_init(self): gp = GeoPointset() self.assertEqual(0, len(gp)) diff --git a/python/tests/geometry_tests/test_geo_region.py b/python/tests/geometry_tests/test_geo_region.py index b1145076f7..a7d4363a06 100644 --- a/python/tests/geometry_tests/test_geo_region.py +++ b/python/tests/geometry_tests/test_geo_region.py @@ -1,9 +1,9 @@ -from ecl.util.geometry import GeoRegion, GeoPointset, CPolyline, Surface -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.geometry import GeoRegion, GeoPointset, CPolyline, Surface +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class GeoRegionTest(EclTest): +class GeoRegionTest(ResdataTest): def test_init(self): pointset = GeoPointset() georegion = GeoRegion(pointset) diff --git a/python/tests/geometry_tests/test_geometry_tools.py b/python/tests/geometry_tests/test_geometry_tools.py index 21bb6bfc7b..1beb288328 100644 --- a/python/tests/geometry_tests/test_geometry_tools.py +++ b/python/tests/geometry_tests/test_geometry_tools.py @@ -1,12 +1,12 @@ import math -from ecl.util.geometry import Polyline, GeometryTools, CPolyline -from ecl.util.geometry.xyz_io import XYZIo -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.geometry import Polyline, GeometryTools, CPolyline +from resdata.util.geometry.xyz_io import XYZIo +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class GeometryToolsTest(EclTest): +class GeometryToolsTest(ResdataTest): def test_distance(self): p1 = (1, 1) p2 = (1, 2, 3) diff --git a/python/tests/geometry_tests/test_intersection.py b/python/tests/geometry_tests/test_intersection.py index 7b18a63c45..c14fa8036e 100644 --- a/python/tests/geometry_tests/test_intersection.py +++ b/python/tests/geometry_tests/test_intersection.py @@ -1,8 +1,8 @@ -from ecl.util.geometry import GeometryTools -from tests import EclTest +from resdata.util.geometry import GeometryTools +from tests import ResdataTest -class IntersectionTest(EclTest): +class IntersectionTest(ResdataTest): def test_intersection(self): p1 = (0.0, 0.0) p2 = (10.0, 0.0) diff --git a/python/tests/geometry_tests/test_point_in_polygon.py b/python/tests/geometry_tests/test_point_in_polygon.py index dbbadaae3f..371dc6f519 100644 --- a/python/tests/geometry_tests/test_point_in_polygon.py +++ b/python/tests/geometry_tests/test_point_in_polygon.py @@ -1,9 +1,9 @@ -from ecl.util.geometry.geometry_tools import GeometryTools -from ecl.util.geometry.polyline import Polyline -from tests import EclTest +from resdata.util.geometry.geometry_tools import GeometryTools +from resdata.util.geometry.polyline import Polyline +from tests import ResdataTest -class PointInPolygonTest(EclTest): +class PointInPolygonTest(ResdataTest): def test_point_in_polygon(self): p1 = (0.5, 0.5) p2 = (2, 2) diff --git a/python/tests/geometry_tests/test_polygon_slicing.py b/python/tests/geometry_tests/test_polygon_slicing.py index 2b9fba92dd..3ebdc1963a 100644 --- a/python/tests/geometry_tests/test_polygon_slicing.py +++ b/python/tests/geometry_tests/test_polygon_slicing.py @@ -1,9 +1,9 @@ from math import sqrt -from ecl.util.geometry.geometry_tools import GeometryTools -from tests import EclTest +from resdata.util.geometry.geometry_tools import GeometryTools +from tests import ResdataTest -class PolygonSlicingTest(EclTest): +class PolygonSlicingTest(ResdataTest): def test_slicing_internal_hull(self): polygon = [(2, 2), (2, 1), (1, 1), (1, 5), (5, 5), (5, 4), (4, 4)] edge = [(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)] diff --git a/python/tests/geometry_tests/test_polyline.py b/python/tests/geometry_tests/test_polyline.py index 88796e7748..f7da748ef4 100644 --- a/python/tests/geometry_tests/test_polyline.py +++ b/python/tests/geometry_tests/test_polyline.py @@ -1,10 +1,10 @@ -from ecl.util.geometry import Polyline, GeometryTools -from ecl.util.geometry.xyz_io import XYZIo -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.geometry import Polyline, GeometryTools +from resdata.util.geometry.xyz_io import XYZIo +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class PolylineTest(EclTest): +class PolylineTest(ResdataTest): def setUp(self): self.polyline = self.createTestPath("local/geometry/pol11.xyz") self.closed_polyline = self.createTestPath("local/geometry/pol8.xyz") diff --git a/python/tests/geometry_tests/test_surface.py b/python/tests/geometry_tests/test_surface.py index 01302e9809..057846dec1 100644 --- a/python/tests/geometry_tests/test_surface.py +++ b/python/tests/geometry_tests/test_surface.py @@ -1,10 +1,10 @@ import random -from ecl.util.geometry import Surface -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.geometry import Surface +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class SurfaceTest(EclTest): +class SurfaceTest(ResdataTest): def setUp(self): self.surface_valid = self.createTestPath( "local/geometry/surface/valid_ascii.irap" diff --git a/python/tests/global_tests/test_pylint.py b/python/tests/global_tests/test_pylint.py index b2a60477f7..9b700ff27f 100644 --- a/python/tests/global_tests/test_pylint.py +++ b/python/tests/global_tests/test_pylint.py @@ -1,20 +1,20 @@ -from ecl.util.test import LintTestCase +from resdata.util.test import LintTestCase class LintErt(LintTestCase): """Tests that no file in ert needs linting""" def test_lint_ecl(self): - # white = ['ecl_kw.py', 'ecl_type.py', 'ecl_sum.py', 'ecl_grid.py', 'ecl_npv.py'] # TODO fix issues and remove - # self.assertLinted('ecl/ecl', whitelist=white) + # white = ['rd_kw.py', 'rd_type.py', 'rd_sum.py', 'rd_grid.py', 'rd_npv.py'] # TODO fix issues and remove + # self.assertLinted('resdata/ecl', whitelist=white) pass # temporarily disable linting due to monkey patching def test_lint_geo(self): - self.assertLinted("ecl/geo") + self.assertLinted("resdata/geo") def test_lint_util(self): self.assertLinted( - "ecl/util", + "resdata/util", whitelist=[ "vector_template.py", "test_area.py", @@ -30,4 +30,4 @@ def test_lint_util(self): ) def test_lint_well(self): - self.assertLinted("ecl/well") + self.assertLinted("resdata/well") diff --git a/python/tests/rd_tests/test_cell.py b/python/tests/rd_tests/test_cell.py index f2304c45ea..959adc5a82 100644 --- a/python/tests/rd_tests/test_cell.py +++ b/python/tests/rd_tests/test_cell.py @@ -1,13 +1,13 @@ #!/usr/bin/env python -from ecl.grid import Cell, EclGrid -from tests import EclTest +from resdata.grid import Cell, ResdataGrid +from tests import ResdataTest from unittest import skipUnless -class CellTest(EclTest): +class CellTest(ResdataTest): def setUp(self): fk = self.createTestPath("local/ECLIPSE/faarikaal/faarikaal1.EGRID") - self.grid = EclGrid(fk) + self.grid = ResdataGrid(fk) self.cell = self.grid[3455] self.actives = [c for c in self.grid if c.active] diff --git a/python/tests/rd_tests/test_debug.py b/python/tests/rd_tests/test_debug.py index f6df9addd5..d836cf296e 100644 --- a/python/tests/rd_tests/test_debug.py +++ b/python/tests/rd_tests/test_debug.py @@ -1,8 +1,8 @@ -from ecl.util.test import debug_msg -from tests import EclTest +from resdata.util.test import debug_msg +from tests import ResdataTest -class DebugTest(EclTest): +class DebugTest(ResdataTest): def test_create(self): msg = debug_msg("DEBUG") self.assertIn(__file__[:-1], msg) diff --git a/python/tests/rd_tests/test_deprecation.py b/python/tests/rd_tests/test_deprecation.py index f2216068db..da52fd7d61 100644 --- a/python/tests/rd_tests/test_deprecation.py +++ b/python/tests/rd_tests/test_deprecation.py @@ -3,14 +3,14 @@ import time import datetime -from ecl.util.test import TestAreaContext -from ecl import EclDataType -from ecl.eclfile import EclFile, EclKW, FortIO, openFortIO -from ecl.grid import EclGrid, EclGrid, EclRegion, EclGridGenerator -from ecl.rft import EclRFT -from ecl.util.test.ecl_mock import createEclSum -from ecl.util.util import BoolVector -from tests import EclTest +from resdata.util.test import TestAreaContext +from resdata import ResdataDataType +from resdata.eclfile import ResdataFile, ResdataKW, FortIO, openFortIO +from resdata.grid import ResdataGrid, ResdataGrid, ResdataRegion, ResdataGridGenerator +from resdata.rft import ResdataRFT +from resdata.util.test.rd_mock import createRdSum +from resdata.util.util import BoolVector +from tests import ResdataTest # The class Deprecation_1_9_Test contains methods which will be marked # as deprecated in the 1.9.x versions. @@ -18,21 +18,21 @@ warnings.simplefilter("error", DeprecationWarning) -class Deprecation_2_1_Test(EclTest): +class Deprecation_2_1_Test(ResdataTest): pass -class Deprecation_2_0_Test(EclTest): - def test_EclFile_name_property(self): +class Deprecation_2_0_Test(ResdataTest): + def test_ResdataFile_name_property(self): with TestAreaContext("name") as t: - kw = EclKW("TEST", 3, EclDataType.ECL_INT) + kw = ResdataKW("TEST", 3, ResdataDataType.RD_INT) with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: kw.fwrite(f) - f = EclFile("TEST") + f = ResdataFile("TEST") -class Deprecation_1_9_Test(EclTest): - def test_EclRegion_properties(self): - grid = EclGridGenerator.createRectangular((10, 10, 10), (1, 1, 1)) - region = EclRegion(grid, False) +class Deprecation_1_9_Test(ResdataTest): + def test_ResdataRegion_properties(self): + grid = ResdataGridGenerator.createRectangular((10, 10, 10), (1, 1, 1)) + region = ResdataRegion(grid, False) diff --git a/python/tests/rd_tests/test_equinor_faults.py b/python/tests/rd_tests/test_equinor_faults.py index 8d42c953f9..55e1ed1d75 100644 --- a/python/tests/rd_tests/test_equinor_faults.py +++ b/python/tests/rd_tests/test_equinor_faults.py @@ -7,26 +7,26 @@ from cwrap import open as copen import time -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid -from ecl.grid.faults import FaultCollection, Fault, FaultLine, FaultSegment -from tests import EclTest, equinor_test +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid +from resdata.grid.faults import FaultCollection, Fault, FaultLine, FaultSegment +from tests import ResdataTest, equinor_test @equinor_test() -class EquinorFaultTest(EclTest): +class EquinorFaultTest(ResdataTest): def loadGrid(self): grid_file = self.createTestPath("Equinor/ECLIPSE/Faults/grid.grdecl") fileH = copen(grid_file, "r") - specgrid = EclKW.read_grdecl( - fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False + specgrid = ResdataKW.read_grdecl( + fileH, "SPECGRID", rd_type=ResdataDataType.RD_INT, strict=False ) - zcorn = EclKW.read_grdecl(fileH, "ZCORN") - coord = EclKW.read_grdecl(fileH, "COORD") - actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) + zcorn = ResdataKW.read_grdecl(fileH, "ZCORN") + coord = ResdataKW.read_grdecl(fileH, "COORD") + actnum = ResdataKW.read_grdecl(fileH, "ACTNUM", rd_type=ResdataDataType.RD_INT) - return EclGrid.create(specgrid, zcorn, coord, actnum) + return ResdataGrid.create(specgrid, zcorn, coord, actnum) def test_load(self): grid = self.loadGrid() diff --git a/python/tests/rd_tests/test_fault_blocks.py b/python/tests/rd_tests/test_fault_blocks.py index acdbeddbbb..3cadd567db 100644 --- a/python/tests/rd_tests/test_fault_blocks.py +++ b/python/tests/rd_tests/test_fault_blocks.py @@ -2,22 +2,24 @@ from unittest import skipIf import cwrap -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid, EclRegion -from ecl.grid.faults import FaultBlock, FaultBlockLayer, FaultCollection -from ecl.util.geometry import Polyline, CPolylineCollection -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid, ResdataRegion +from resdata.grid.faults import FaultBlock, FaultBlockLayer, FaultCollection +from resdata.util.geometry import Polyline, CPolylineCollection +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class FaultBlockTest(EclTest): +class FaultBlockTest(ResdataTest): def setUp(self): - self.grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1)) - self.kw = EclKW("FAULTBLK", self.grid.getGlobalSize(), EclDataType.ECL_INT) + self.grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1)) + self.kw = ResdataKW( + "FAULTBLK", self.grid.getGlobalSize(), ResdataDataType.RD_INT + ) self.kw.assign(1) - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) for k in range(self.grid.getNZ()): reg.clear() @@ -26,8 +28,8 @@ def setUp(self): self.kw[k * self.grid.getNX() * self.grid.getNY() + 7] = 177 def test_fault_block(self): - grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1)) - kw = EclKW("FAULTBLK", grid.getGlobalSize(), EclDataType.ECL_INT) + grid = ResdataGrid.createRectangular((5, 5, 1), (1, 1, 1)) + kw = ResdataKW("FAULTBLK", grid.getGlobalSize(), ResdataDataType.RD_INT) kw.assign(0) for j in range(1, 4): for i in range(1, 4): @@ -53,9 +55,11 @@ def test_get_ijk(self): fileH.write("4 4 4 0 5\n") fileH.write("/\n") with cwrap.open("kw.grdecl") as f: - kw = EclKW.read_grdecl(f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + kw = ResdataKW.read_grdecl( + f, "FAULTBLK", rd_type=ResdataDataType.RD_INT + ) - grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((5, 5, 1), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) layer.loadKeyword(kw) @@ -83,9 +87,11 @@ def test_neighbours(self): fileH.write("/\n") with cwrap.open("kw.grdecl") as f: - kw = EclKW.read_grdecl(f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + kw = ResdataKW.read_grdecl( + f, "FAULTBLK", rd_type=ResdataDataType.RD_INT + ) - grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((5, 5, 1), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) layer.loadKeyword(kw) @@ -125,7 +131,7 @@ def test_neighbours2(self): nx = 8 ny = 8 nz = 1 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) with TestAreaContext("python/FaultBlocks/neighbours"): with open("faultblock.grdecl", "w") as fileH: @@ -141,7 +147,9 @@ def test_neighbours2(self): fileH.write("/\n") with cwrap.open("faultblock.grdecl") as f: - kw = EclKW.read_grdecl(f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + kw = ResdataKW.read_grdecl( + f, "FAULTBLK", rd_type=ResdataDataType.RD_INT + ) with open("faults.grdecl", "w") as f: f.write("FAULTS\n") @@ -189,7 +197,7 @@ def test_neighbours3(self): nx = 8 ny = 8 nz = 1 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) with TestAreaContext("python/FaultBlocks/neighbours"): with open("faultblock.grdecl", "w") as fileH: @@ -205,7 +213,9 @@ def test_neighbours3(self): fileH.write("/\n") with cwrap.open("faultblock.grdecl") as f: - kw = EclKW.read_grdecl(f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + kw = ResdataKW.read_grdecl( + f, "FAULTBLK", rd_type=ResdataDataType.RD_INT + ) with open("faults.grdecl", "w") as f: f.write("FAULTS\n") f.write("'FX' 4 4 1 4 1 1 'X' /\n") @@ -225,8 +235,8 @@ def test_neighbours3(self): self.assertTrue(b2 in nb) def test_fault_block_edge(self): - grid = EclGrid.createRectangular((5, 5, 1), (1, 1, 1)) - kw = EclKW("FAULTBLK", grid.getGlobalSize(), EclDataType.ECL_INT) + grid = ResdataGrid.createRectangular((5, 5, 1), (1, 1, 1)) + kw = ResdataKW("FAULTBLK", grid.getGlobalSize(), ResdataDataType.RD_INT) kw.assign(0) for j in range(1, 4): for i in range(1, 4): @@ -247,7 +257,7 @@ def test_fault_block_layer(self): layer = FaultBlockLayer(self.grid, 1) self.assertEqual(1, layer.getK()) - kw = EclKW("FAULTBLK", self.grid.getGlobalSize(), EclDataType.ECL_FLOAT) + kw = ResdataKW("FAULTBLK", self.grid.getGlobalSize(), ResdataDataType.RD_FLOAT) with self.assertRaises(ValueError): layer.scanKeyword(kw) @@ -326,7 +336,7 @@ def test_fault_block_layer(self): self.assertEqual([1, 2, 3], list(fault_block.getRegionList())) def test_add_polyline_barrier1(self): - grid = EclGrid.createRectangular((4, 1, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((4, 1, 1), (1, 1, 1)) layer = FaultBlockLayer(self.grid, 0) polyline = Polyline(init_points=[(1.99, 0.001), (2.01, 0.99)]) @@ -342,7 +352,7 @@ def test_add_polyline_barrier1(self): self.assertFalse(geo_layer.cellContact(p1, p2)) def test_add_polyline_barrier2(self): - grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((10, 10, 1), (1, 1, 1)) layer = FaultBlockLayer(self.grid, 0) polyline = Polyline(init_points=[(0.1, 0.9), (8.9, 0.9), (8.9, 8.9)]) @@ -370,11 +380,13 @@ def test_add_polyline_barrier2(self): def test_fault_block_layer_export(self): layer = FaultBlockLayer(self.grid, 1) - kw1 = EclKW("FAULTBLK", self.grid.getGlobalSize() + 1, EclDataType.ECL_INT) + kw1 = ResdataKW( + "FAULTBLK", self.grid.getGlobalSize() + 1, ResdataDataType.RD_INT + ) with self.assertRaises(ValueError): layer.exportKeyword(kw1) - kw2 = EclKW("FAULTBLK", self.grid.getGlobalSize(), EclDataType.ECL_FLOAT) + kw2 = ResdataKW("FAULTBLK", self.grid.getGlobalSize(), ResdataDataType.RD_FLOAT) with self.assertRaises(TypeError): layer.exportKeyword(kw2) @@ -382,7 +394,7 @@ def test_internal_blocks(self): nx = 8 ny = 8 nz = 1 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) layer = FaultBlockLayer(grid, 0) with TestAreaContext("python/FaultBlocks/internal_blocks"): with open("faultblock.grdecl", "w") as fileH: @@ -398,7 +410,9 @@ def test_internal_blocks(self): fileH.write("/\n") with cwrap.open("faultblock.grdecl") as f: - kw = EclKW.read_grdecl(f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + kw = ResdataKW.read_grdecl( + f, "FAULTBLK", rd_type=ResdataDataType.RD_INT + ) with open("faults.grdecl", "w") as f: f.write("FAULTS\n") diff --git a/python/tests/rd_tests/test_fault_blocks_equinor.py b/python/tests/rd_tests/test_fault_blocks_equinor.py index 9da3fc3985..e029520269 100644 --- a/python/tests/rd_tests/test_fault_blocks_equinor.py +++ b/python/tests/rd_tests/test_fault_blocks_equinor.py @@ -4,23 +4,25 @@ except ImportError: from unittest import skipIf -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid -from tests import EclTest, equinor_test -from ecl.grid.faults import FaultBlock, FaultBlockLayer +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid +from tests import ResdataTest, equinor_test +from resdata.grid.faults import FaultBlock, FaultBlockLayer from cwrap import open as copen @equinor_test() -class FaultBlockTest(EclTest): +class FaultBlockTest(ResdataTest): def setUp(self): - self.grid = EclGrid( + self.grid = ResdataGrid( self.createTestPath("Equinor/ECLIPSE/Mariner/MARINER.EGRID") ) fileH = copen(self.createTestPath("Equinor/ECLIPSE/Mariner/faultblock.grdecl")) - self.kw = EclKW.read_grdecl(fileH, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + self.kw = ResdataKW.read_grdecl( + fileH, "FAULTBLK", rd_type=ResdataDataType.RD_INT + ) def test_load(self): for k in range(self.grid.getNZ()): diff --git a/python/tests/rd_tests/test_faults.py b/python/tests/rd_tests/test_faults.py index 0aced05095..d92cd099af 100644 --- a/python/tests/rd_tests/test_faults.py +++ b/python/tests/rd_tests/test_faults.py @@ -1,27 +1,27 @@ #!/usr/bin/env python from unittest import skipIf import time -from ecl import util +from resdata import util -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid -from ecl.grid.faults import ( +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid +from resdata.grid.faults import ( FaultCollection, Fault, FaultLine, FaultSegment, FaultBlockLayer, ) -from ecl.util.test import TestAreaContext -from ecl.util.geometry import Polyline, CPolyline -from tests import EclTest +from resdata.util.test import TestAreaContext +from resdata.util.geometry import Polyline, CPolyline +from tests import ResdataTest -class FaultTest(EclTest): +class FaultTest(ResdataTest): @classmethod def setUpClass(cls): - cls.grid = EclGrid.createRectangular((151, 100, 50), (1, 1, 1)) + cls.grid = ResdataGrid.createRectangular((151, 100, 50), (1, 1, 1)) def setUp(self): self.faults1 = self.createTestPath("local/ECLIPSE/FAULTS/fault1.grdecl") @@ -31,7 +31,7 @@ def test_PolylineIJ(self): nx = 10 ny = 10 nz = 10 - grid = EclGrid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) f = Fault(grid, "F") f.addRecord(0, 1, 0, 0, 0, 0, "Y-") f.addRecord(2, 2, 0, 1, 0, 0, "X-") @@ -112,7 +112,7 @@ def test_faultLine_center(self): nx = 10 ny = 10 nz = 2 - grid = EclGrid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (0.1, 0.1, 0.1)) fl = FaultLine(grid, 0) C1 = (nx + 1) * 5 + 3 C2 = C1 + 2 @@ -191,7 +191,7 @@ def test_load(self): faults.load(self.grid, "No/this/does/not/exist") def test_connect_faults(self): - grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1)) + grid = ResdataGrid.createRectangular((100, 100, 10), (1, 1, 1)) # Fault1 Fault4 # | | @@ -342,7 +342,7 @@ def test_intersect_intRays(self): self.assertEqual(join, [p1, p2]) def test_join_faults(self): - grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1)) + grid = ResdataGrid.createRectangular((100, 100, 10), (1, 1, 1)) # Fault1 Fault4 # | | @@ -373,7 +373,7 @@ def test_join_faults(self): self.assertEqual(extra, [(2, 10), (2, 6), (5, 6)]) def test_contact(self): - grid = EclGrid.createRectangular((100, 100, 10), (1, 1, 1)) + grid = ResdataGrid.createRectangular((100, 100, 10), (1, 1, 1)) # Fault1 Fault4 # | | @@ -471,7 +471,7 @@ def test_fault_line_order(self): nx = 120 ny = 60 nz = 43 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) with TestAreaContext("python/faults/line_order"): with open("faults.grdecl", "w") as f: f.write( @@ -509,7 +509,7 @@ def test_neighbour_cells(self): nx = 10 ny = 8 nz = 7 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) faults_file = self.createTestPath("local/ECLIPSE/FAULTS/faults_nb.grdecl") faults = FaultCollection(grid, faults_file) @@ -570,7 +570,7 @@ def test_neighbour_cells(self): self.assertListEqual(nb_cells1, true_nb_cells1) def test_polyline_intersection(self): - grid = EclGrid.createRectangular((100, 100, 10), (0.25, 0.25, 1)) + grid = ResdataGrid.createRectangular((100, 100, 10), (0.25, 0.25, 1)) # Fault1 Fault4 # | | @@ -609,7 +609,7 @@ def test_num_linesegment(self): nx = 10 ny = 10 nz = 1 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) with TestAreaContext("python/faults/line_order"): with open("faults.grdecl", "w") as f: f.write( @@ -628,7 +628,7 @@ def test_num_linesegment(self): self.assertEqual(1, f2.numLines(0)) def test_extend_to_polyline(self): - grid = EclGrid.createRectangular((3, 3, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((3, 3, 1), (1, 1, 1)) # o o o o # @@ -655,7 +655,7 @@ def test_extend_to_polyline(self): self.assertIsNone(end_join) def test_extend_polyline_on(self): - grid = EclGrid.createRectangular((3, 3, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((3, 3, 1), (1, 1, 1)) # o o o o # @@ -686,13 +686,13 @@ def test_extend_polyline_on(self): self.assertIsNone(points) def test_stepped(self): - grid = EclGrid.createRectangular((6, 1, 4), (1, 1, 1)) + grid = ResdataGrid.createRectangular((6, 1, 4), (1, 1, 1)) f = Fault(grid, "F") f.addRecord(4, 4, 0, 0, 0, 1, "X") f.addRecord(2, 2, 0, 0, 1, 1, "Z") f.addRecord(1, 1, 0, 0, 2, 3, "X") - block_kw = EclKW("FAULTBLK", grid.getGlobalSize(), EclDataType.ECL_INT) + block_kw = ResdataKW("FAULTBLK", grid.getGlobalSize(), ResdataDataType.RD_INT) block_kw.assign(1) block_kw[5] = 2 block_kw[11] = 2 @@ -725,7 +725,7 @@ def test_stepped(self): self.assertFalse(layer3.cellContact((1, 0), (2, 0))) def test_connectWithPolyline(self): - grid = EclGrid.createRectangular((4, 4, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((4, 4, 1), (1, 1, 1)) # o o o o o # diff --git a/python/tests/rd_tests/test_fk_user_data.py b/python/tests/rd_tests/test_fk_user_data.py index b96e6368d3..3a5386dc72 100644 --- a/python/tests/rd_tests/test_fk_user_data.py +++ b/python/tests/rd_tests/test_fk_user_data.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -from ecl.grid import EclGrid -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.grid import ResdataGrid +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class FKTest(EclTest): +class FKTest(ResdataTest): def test_cell_containment(self): grid_location = "local/ECLIPSE/faarikaal/faarikaal%d.EGRID" well_location = "local/ECLIPSE/faarikaal/faarikaal%d.txt" @@ -13,7 +13,7 @@ def test_cell_containment(self): grid_file = self.createTestPath(grid_location % i) well_file = self.createTestPath(well_location % i) - grid = EclGrid(grid_file) + grid = ResdataGrid(grid_file) # Load well data with open(well_file, "r") as f: diff --git a/python/tests/rd_tests/test_fortio.py b/python/tests/rd_tests/test_fortio.py index ff413c32b3..7d57bc51e8 100755 --- a/python/tests/rd_tests/test_fortio.py +++ b/python/tests/rd_tests/test_fortio.py @@ -2,13 +2,13 @@ import os import cwrap from random import randint -from ecl import EclDataType -from ecl.eclfile import FortIO, EclKW, openFortIO, EclFile -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata import ResdataDataType +from resdata.eclfile import FortIO, ResdataKW, openFortIO, ResdataFile +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class FortIOTest(EclTest): +class FortIOTest(ResdataTest): def test_open_write(self): with TestAreaContext("python/fortio/write"): f = FortIO("newfile", FortIO.WRITE_MODE) @@ -19,8 +19,8 @@ def test_noex(self): f = FortIO("odes_not_exist", FortIO.READ_MODE) def test_kw(self): - kw1 = EclKW("KW1", 2, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 2, EclDataType.ECL_INT) + kw1 = ResdataKW("KW1", 2, ResdataDataType.RD_INT) + kw2 = ResdataKW("KW2", 2, ResdataDataType.RD_INT) kw1[0] = 99 kw1[1] = 77 @@ -35,15 +35,15 @@ def test_kw(self): kw2.fwrite(f) f = FortIO("test", fmt_file=False) - k1 = EclKW.fread(f) - k2 = EclKW.fread(f) + k1 = ResdataKW.fread(f) + k2 = ResdataKW.fread(f) self.assertTrue(k1.equal(kw1)) self.assertTrue(k2.equal(kw2)) def test_truncate(self): - kw1 = EclKW("KW1", 2, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 2, EclDataType.ECL_INT) + kw1 = ResdataKW("KW1", 2, ResdataDataType.RD_INT) + kw2 = ResdataKW("KW2", 2, ResdataDataType.RD_INT) kw1[0] = 99 kw1[1] = 77 @@ -65,7 +65,7 @@ def test_truncate(self): f.seek(pos1) f.truncate() - f = EclFile("file") + f = ResdataFile("file") self.assertEqual(len(f), 1) kw1_ = f[0] self.assertEqual(kw1, kw1_) @@ -82,7 +82,7 @@ def test_fortio_creation(self): def test_context(self): with TestAreaContext("python/fortio/context") as t: - kw1 = EclKW("KW", 2456, EclDataType.ECL_FLOAT) + kw1 = ResdataKW("KW", 2456, ResdataDataType.RD_FLOAT) for i in range(len(kw1)): kw1[i] = randint(0, 1000) @@ -91,13 +91,13 @@ def test_context(self): self.assertEqual(f.filename(), "file") with openFortIO("file") as f: - kw2 = EclKW.fread(f) + kw2 = ResdataKW.fread(f) self.assertTrue(kw1 == kw2) def test_is_fortran_file(self): with TestAreaContext("python/fortio/guess"): - kw1 = EclKW("KW", 12345, EclDataType.ECL_FLOAT) + kw1 = ResdataKW("KW", 12345, ResdataDataType.RD_FLOAT) with openFortIO("fortran_file", mode=FortIO.WRITE_MODE) as f: kw1.fwrite(f) diff --git a/python/tests/rd_tests/test_geertsma.py b/python/tests/rd_tests/test_geertsma.py index e5d1994fe6..c4e5bab688 100644 --- a/python/tests/rd_tests/test_geertsma.py +++ b/python/tests/rd_tests/test_geertsma.py @@ -1,17 +1,17 @@ import datetime -from ecl import EclDataType -from ecl.eclfile import EclKW, openFortIO, FortIO, EclFile -from ecl.grid import EclGrid -from ecl.gravimetry import EclSubsidence +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW, openFortIO, FortIO, ResdataFile +from resdata.grid import ResdataGrid +from resdata.gravimetry import ResdataSubsidence -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.test import TestAreaContext +from tests import ResdataTest import numpy as np def create_init(grid, case): - poro = EclKW("PORO", grid.getNumActive(), EclDataType.ECL_FLOAT) + poro = ResdataKW("PORO", grid.getNumActive(), ResdataDataType.RD_FLOAT) porv = poro.copy() porv.setName("PORV") for g in range(grid.getGlobalSize()): @@ -24,13 +24,13 @@ def create_init(grid, case): def create_restart(grid, case, p1, p2=None, rporv1=None, rporv2=None): with openFortIO("%s.UNRST" % case, mode=FortIO.WRITE_MODE) as f: - seq_hdr = EclKW("SEQNUM", 1, EclDataType.ECL_FLOAT) + seq_hdr = ResdataKW("SEQNUM", 1, ResdataDataType.RD_FLOAT) seq_hdr[0] = 10 - p = EclKW("PRESSURE", grid.getNumActive(), EclDataType.ECL_FLOAT) + p = ResdataKW("PRESSURE", grid.getNumActive(), ResdataDataType.RD_FLOAT) for i in range(len(p1)): p[i] = p1[i] - header = EclKW("INTEHEAD", 67, EclDataType.ECL_INT) + header = ResdataKW("INTEHEAD", 67, ResdataDataType.RD_INT) header[64] = 1 header[65] = 1 header[66] = 2000 @@ -40,7 +40,7 @@ def create_restart(grid, case, p1, p2=None, rporv1=None, rporv2=None): p.fwrite(f) if rporv1: - rp = EclKW("RPORV", grid.getNumActive(), EclDataType.ECL_FLOAT) + rp = ResdataKW("RPORV", grid.getNumActive(), ResdataDataType.RD_FLOAT) for idx, val in enumerate(rporv1): rp[idx] = val @@ -57,28 +57,28 @@ def create_restart(grid, case, p1, p2=None, rporv1=None, rporv2=None): p.fwrite(f) if rporv2: - rp = EclKW("RPORV", grid.getNumActive(), EclDataType.ECL_FLOAT) + rp = ResdataKW("RPORV", grid.getNumActive(), ResdataDataType.RD_FLOAT) for idx, val in enumerate(rporv2): rp[idx] = val rp.fwrite(f) -class GeertsmaTest(EclTest): +class GeertsmaTest(ResdataTest): @staticmethod def test_geertsma_kernel(): - grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + grid = ResdataGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) with TestAreaContext("Subsidence"): p1 = [1] create_restart(grid, "TEST", p1) create_init(grid, "TEST") - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") + init = ResdataFile("TEST.INIT") + restart_file = ResdataFile("TEST.UNRST") restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) - subsidence = EclSubsidence(grid, init) + subsidence = ResdataSubsidence(grid, init) subsidence.add_survey_PRESSURE("S1", restart_view1) youngs_modulus = 5e8 @@ -102,7 +102,7 @@ def test_geertsma_kernel(): @staticmethod def test_geertsma_kernel_2_source_points_2_vintages(): - grid = EclGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) + grid = ResdataGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) with TestAreaContext("Subsidence"): p1 = [1, 10] @@ -110,13 +110,13 @@ def test_geertsma_kernel_2_source_points_2_vintages(): create_restart(grid, "TEST", p1, p2) create_init(grid, "TEST") - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") + init = ResdataFile("TEST.INIT") + restart_file = ResdataFile("TEST.UNRST") restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) restart_view2 = restart_file.restartView(sim_time=datetime.date(2010, 1, 1)) - subsidence = EclSubsidence(grid, init) + subsidence = ResdataSubsidence(grid, init) subsidence.add_survey_PRESSURE("S1", restart_view1) subsidence.add_survey_PRESSURE("S2", restart_view2) @@ -144,18 +144,18 @@ def test_geertsma_kernel_2_source_points_2_vintages(): @staticmethod def test_geertsma_kernel_seabed(): - grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + grid = ResdataGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) with TestAreaContext("Subsidence"): p1 = [1] create_restart(grid, "TEST", p1) create_init(grid, "TEST") - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") + init = ResdataFile("TEST.INIT") + restart_file = ResdataFile("TEST.UNRST") restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) - subsidence = EclSubsidence(grid, init) + subsidence = ResdataSubsidence(grid, init) subsidence.add_survey_PRESSURE("S1", restart_view1) youngs_modulus = 5e8 @@ -172,18 +172,18 @@ def test_geertsma_kernel_seabed(): @staticmethod def test_geertsma_kernel_seabed(): - grid = EclGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) + grid = ResdataGrid.createRectangular(dims=(1, 1, 1), dV=(50, 50, 50)) with TestAreaContext("Subsidence"): p1 = [1] create_restart(grid, "TEST", p1) create_init(grid, "TEST") - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") + init = ResdataFile("TEST.INIT") + restart_file = ResdataFile("TEST.UNRST") restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) - subsidence = EclSubsidence(grid, init) + subsidence = ResdataSubsidence(grid, init) subsidence.add_survey_PRESSURE("S1", restart_view1) youngs_modulus = 5e8 @@ -199,7 +199,7 @@ def test_geertsma_kernel_seabed(): np.testing.assert_almost_equal(dz, 5.819790154474284e-08) def test_geertsma_rporv_kernel_2_source_points_2_vintages(self): - grid = EclGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) + grid = ResdataGrid.createRectangular(dims=(2, 1, 1), dV=(100, 100, 100)) with TestAreaContext("Subsidence"): p1 = [1, 10] @@ -214,13 +214,13 @@ def test_geertsma_rporv_kernel_2_source_points_2_vintages(self): ) create_init(grid, "TEST") - init = EclFile("TEST.INIT") - restart_file = EclFile("TEST.UNRST") + init = ResdataFile("TEST.INIT") + restart_file = ResdataFile("TEST.UNRST") restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) restart_view2 = restart_file.restartView(sim_time=datetime.date(2010, 1, 1)) - subsidence = EclSubsidence(grid, init) + subsidence = ResdataSubsidence(grid, init) subsidence.add_survey_PRESSURE("S1", restart_view1) subsidence.add_survey_PRESSURE("S2", restart_view2) diff --git a/python/tests/rd_tests/test_grav.py b/python/tests/rd_tests/test_grav.py index 5522236e50..d8a950fbdc 100644 --- a/python/tests/rd_tests/test_grav.py +++ b/python/tests/rd_tests/test_grav.py @@ -1,24 +1,24 @@ import time -from ecl import EclDataType -from ecl.eclfile import EclKW, EclFile, openFortIO, FortIO -from ecl.grid import EclGrid -from ecl.gravimetry import EclGrav -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW, ResdataFile, openFortIO, FortIO +from resdata.grid import ResdataGrid +from resdata.gravimetry import ResdataGrav +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class EclGravTest(EclTest): +class ResdataGravTest(ResdataTest): def setUp(self): - self.grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1)) + self.grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1)) def test_create(self): # The init file created here only contains a PORO field. More # properties must be added to this before it can be used for # any usefull gravity calculations. - poro = EclKW("PORO", self.grid.getGlobalSize(), EclDataType.ECL_FLOAT) + poro = ResdataKW("PORO", self.grid.getGlobalSize(), ResdataDataType.RD_FLOAT) with TestAreaContext("grav_init"): with openFortIO("TEST.INIT", mode=FortIO.WRITE_MODE) as f: poro.fwrite(f) - self.init = EclFile("TEST.INIT") + self.init = ResdataFile("TEST.INIT") - grav = EclGrav(self.grid, self.init) + grav = ResdataGrav(self.grid, self.init) diff --git a/python/tests/rd_tests/test_grdecl.py b/python/tests/rd_tests/test_grdecl.py index 8621f0c15c..d8ae234820 100644 --- a/python/tests/rd_tests/test_grdecl.py +++ b/python/tests/rd_tests/test_grdecl.py @@ -1,7 +1,7 @@ from numpy import allclose import cwrap -from ecl.eclfile import EclKW +from resdata.eclfile import ResdataKW def test_eclkw_read_grdecl(tmp_path): @@ -15,7 +15,7 @@ def test_eclkw_read_grdecl(tmp_path): f.write("/\n") with cwrap.open(str(tmp_path / "test.grdecl")) as f: - kw = EclKW.read_grdecl(f, "COORD") + kw = ResdataKW.read_grdecl(f, "COORD") assert kw.get_name() == "COORD" assert len(kw.numpy_view()) == block_size * num_blocks diff --git a/python/tests/rd_tests/test_grdrd_equinor.py b/python/tests/rd_tests/test_grdrd_equinor.py index 547b43cf75..ca40355d69 100755 --- a/python/tests/rd_tests/test_grdrd_equinor.py +++ b/python/tests/rd_tests/test_grdrd_equinor.py @@ -1,14 +1,14 @@ #!/usr/bin/env python import os -from ecl.eclfile import EclKW, Ecl3DKW -from ecl.grid import EclGrid -from tests import EclTest, equinor_test +from resdata.eclfile import ResdataKW, Resdata3DKW +from resdata.grid import ResdataGrid +from tests import ResdataTest, equinor_test from cwrap import open as copen @equinor_test() -class GRDECLEquinorTest(EclTest): +class GRDECLEquinorTest(ResdataTest): def setUp(self): self.src_file = self.createTestPath( "Equinor/ECLIPSE/Gurbat/include/example_permx.GRDECL" @@ -24,15 +24,15 @@ def tearDown(self): os.unlink(f) def test_Load(self): - kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") + kw = ResdataKW.read_grdecl(copen(self.src_file, "r"), "PERMX") self.assertTrue(kw) - grid = EclGrid(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE")) - kw = Ecl3DKW.read_grdecl(grid, copen(self.src_file, "r"), "PERMX") - self.assertTrue(isinstance(kw, Ecl3DKW)) + grid = ResdataGrid(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE")) + kw = Resdata3DKW.read_grdecl(grid, copen(self.src_file, "r"), "PERMX") + self.assertTrue(isinstance(kw, Resdata3DKW)) def test_reload(self): - kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") + kw = ResdataKW.read_grdecl(copen(self.src_file, "r"), "PERMX") tmp_file1 = "/tmp/permx1.grdecl" tmp_file2 = "/tmp/permx2.grdecl" self.addFile(tmp_file1) @@ -42,7 +42,7 @@ def test_reload(self): kw.write_grdecl(fileH) fileH.close() - kw1 = EclKW.read_grdecl(copen(tmp_file1, "r"), "PERMX") + kw1 = ResdataKW.read_grdecl(copen(tmp_file1, "r"), "PERMX") fileH = copen(tmp_file2, "w") kw1.write_grdecl(fileH) @@ -52,36 +52,36 @@ def test_reload(self): def test_fseek(self): file = copen(self.src_file, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "PERMX")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMY")) file.close() file = copen(self.src_file, "r") - kw1 = EclKW.read_grdecl(file, "PERMX") - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX")) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + kw1 = ResdataKW.read_grdecl(file, "PERMX") + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMX")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "PERMX", rewind=True)) file.close() def test_fseek2(self): test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl") # Test kw at the the very start file = copen(test_src, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "PERMX")) # Test commented out kw: - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMY")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMZ")) # Test ignore not start of line: - self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "MARKER")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMXYZ")) # Test rewind - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMX", rewind=False)) + self.assertTrue(ResdataKW.fseek_grdecl(file, "PERMX", rewind=True)) # Test multiline comments + blanks - self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "LASTKW")) def test_fseek_dos(self): test_src = self.createTestPath( @@ -89,19 +89,19 @@ def test_fseek_dos(self): ) # File formatted with \r\n line endings. # Test kw at the the very start file = copen(test_src, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "PERMX")) # Test commented out kw: - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMY")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMZ")) # Test ignore not start of line: - self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "MARKER")) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMXYZ")) # Test rewind - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + self.assertFalse(ResdataKW.fseek_grdecl(file, "PERMX", rewind=False)) + self.assertTrue(ResdataKW.fseek_grdecl(file, "PERMX", rewind=True)) # Test multiline comments + blanks - self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) + self.assertTrue(ResdataKW.fseek_grdecl(file, "LASTKW")) diff --git a/python/tests/rd_tests/test_grid.py b/python/tests/rd_tests/test_grid.py index 91a0269e72..018f3fdbf8 100644 --- a/python/tests/rd_tests/test_grid.py +++ b/python/tests/rd_tests/test_grid.py @@ -6,13 +6,13 @@ import six from numpy import linspace, allclose -from ecl.util.util import IntVector -from ecl import EclDataType, EclUnitTypeEnum -from ecl.eclfile import EclKW, EclFile -from ecl.grid import EclGrid -from ecl.grid import EclGridGenerator as GridGen -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.util import IntVector +from resdata import ResdataDataType, ResdataUnitTypeEnum +from resdata.eclfile import ResdataKW, ResdataFile +from resdata.grid import ResdataGrid +from resdata.grid import ResdataGridGenerator as GridGen +from resdata.util.test import TestAreaContext +from tests import ResdataTest # This dict is used to verify that corners are mapped to the correct # cell with respect to containment. @@ -186,7 +186,7 @@ def average(points): # This test class should only have test cases which do not require # external test data. Tests involving Equinor test data are in the # test_grid_equinor module. -class GridTest(EclTest): +class GridTest(ResdataTest): def test_oom_grid(self): nx = 2000 ny = 2000 @@ -251,7 +251,7 @@ def test_create(self): def test_all_iters(self): fk = self.createTestPath("local/ECLIPSE/faarikaal/faarikaal1.EGRID") - grid = EclGrid(fk) + grid = ResdataGrid(fk) cell = grid[3455] self.assertEqual(3455, cell.global_index) cell = grid[(4, 1, 82)] @@ -274,14 +274,14 @@ def test_repr_and_name(self): grid = GridGen.createRectangular( (2, 2, 2), (10, 10, 10), actnum=[0, 0, 0, 0, 1, 1, 1, 1] ) - pfx = "EclGrid(" + pfx = "ResdataGrid(" rep = repr(grid) self.assertEqual(pfx, rep[: len(pfx)]) self.assertEqual(type(rep), type("")) self.assertEqual(type(grid.getName()), type("")) - with TestAreaContext("python/ecl_grid/repr"): + with TestAreaContext("python/rd_grid/repr"): grid.save_EGRID("CASE.EGRID") - g2 = EclGrid("CASE.EGRID") + g2 = ResdataGrid("CASE.EGRID") r2 = repr(g2) self.assertEqual(pfx, r2[: len(pfx)]) self.assertEqual(type(r2), type("")) @@ -301,13 +301,13 @@ def test_node_pos(self): p7 = grid.getNodePos(10, 20, 30) self.assertEqual(p7, (10, 20, 30)) - # The broken file was previously handled by the ecl_file_open() call internally - # in the ecl_grid implementation. That will now not fail for a broken file, and then + # The broken file was previously handled by the rd_file_open() call internally + # in the rd_grid implementation. That will now not fail for a broken file, and then # the grid class needs to do more/better checking itself. - @skip("Needs better error checking inside in the ecl_grid") + @skip("Needs better error checking inside in the rd_grid") def test_truncated_file(self): grid = GridGen.createRectangular((10, 20, 30), (1, 1, 1)) - with TestAreaContext("python/ecl_grid/truncated"): + with TestAreaContext("python/rd_grid/truncated"): grid.save_EGRID("TEST.EGRID") size = os.path.getsize("TEST.EGRID") @@ -315,7 +315,7 @@ def test_truncated_file(self): f.truncate(size / 2) with self.assertRaises(IOError): - EclGrid("TEST.EGRID") + ResdataGrid("TEST.EGRID") def test_posXY1(self): nx = 4 @@ -390,7 +390,7 @@ def test_compressed_copy(self): ny = 10 nz = 10 grid = GridGen.createRectangular((nx, ny, nz), (1, 1, 1)) - kw1 = EclKW("KW", 1001, EclDataType.ECL_INT) + kw1 = ResdataKW("KW", 1001, ResdataDataType.RD_INT) with self.assertRaises(ValueError): cp = grid.compressedKWCopy(kw1) @@ -410,7 +410,7 @@ def test_create_3d_is_create_kw_inverse(self): ny = 7 nz = 5 grid = GridGen.create_rectangular((nx, ny, nz), (1, 1, 1)) - kw1 = EclKW("SWAT", nx * ny * nz, EclDataType.ECL_FLOAT) + kw1 = ResdataKW("SWAT", nx * ny * nz, ResdataDataType.RD_FLOAT) for k, j, i in itertools.product(range(nz), range(ny), range(nx)): kw1[i + j * nx + nx * ny * k] = i * j * k numpy_3d = grid.create3D(kw1) @@ -423,7 +423,7 @@ def test_create_3d_agrees_with_get_value(self): ny = 3 nz = 2 grid = GridGen.createRectangular((nx, ny, nz), (1, 1, 1)) - kw = EclKW("SWAT", nx * ny * nz, EclDataType.ECL_FLOAT) + kw = ResdataKW("SWAT", nx * ny * nz, ResdataDataType.RD_FLOAT) for k, j, i in itertools.product(range(nz), range(ny), range(nx)): kw[i + j * nx + nx * ny * k] = i * j * k numpy_3d = grid.create3D(kw) @@ -434,7 +434,7 @@ def test_len(self): nx = 10 ny = 11 nz = 12 - actnum = EclKW("ACTNUM", nx * ny * nz, EclDataType.ECL_INT) + actnum = ResdataKW("ACTNUM", nx * ny * nz, ResdataDataType.RD_INT) actnum[0] = 1 actnum[1] = 1 actnum[2] = 1 @@ -449,7 +449,7 @@ def test_export(self): coord = GridGen.create_coord(dims, (1, 1, 1)) zcorn = GridGen.create_zcorn(dims, (1, 1, 1), offset=0) - grid = EclGrid.create(dims, zcorn, coord, None) + grid = ResdataGrid.create(dims, zcorn, coord, None) self.assertEqual(zcorn, grid.export_zcorn()) self.assertEqual(coord, grid.export_coord()) @@ -459,26 +459,28 @@ def test_output_units(self): a = 1 grid = GridGen.createRectangular((n, n, n), (a, a, a)) - with TestAreaContext("python/ecl_grid/units"): - grid.save_EGRID("CASE.EGRID", output_unit=EclUnitTypeEnum.ECL_FIELD_UNITS) - f = EclFile("CASE.EGRID") + with TestAreaContext("python/rd_grid/units"): + grid.save_EGRID( + "CASE.EGRID", output_unit=ResdataUnitTypeEnum.RD_FIELD_UNITS + ) + f = ResdataFile("CASE.EGRID") g = f["GRIDUNIT"][0] self.assertEqual(g[0].strip(), "FEET") - g2 = EclGrid("CASE.EGRID") + g2 = ResdataGrid("CASE.EGRID") self.assertFloatEqual( g2.cell_volume(global_index=0), 3.28084 * 3.28084 * 3.28084 ) grid.save_EGRID("CASE.EGRID") - f = EclFile("CASE.EGRID") + f = ResdataFile("CASE.EGRID") g = f["GRIDUNIT"][0] self.assertEqual(g[0].strip(), "METRES") - grid.save_EGRID("CASE.EGRID", output_unit=EclUnitTypeEnum.ECL_LAB_UNITS) - f = EclFile("CASE.EGRID") + grid.save_EGRID("CASE.EGRID", output_unit=ResdataUnitTypeEnum.RD_LAB_UNITS) + f = ResdataFile("CASE.EGRID") g = f["GRIDUNIT"][0] self.assertEqual(g[0].strip(), "CM") - g2 = EclGrid("CASE.EGRID") + g2 = ResdataGrid("CASE.EGRID") self.assertFloatEqual(g2.cell_volume(global_index=0), 100 * 100 * 100) def test_volume(self): diff --git a/python/tests/rd_tests/test_grid_equinor.py b/python/tests/rd_tests/test_grid_equinor.py index a105f7c33c..2b5eaf5c1f 100755 --- a/python/tests/rd_tests/test_grid_equinor.py +++ b/python/tests/rd_tests/test_grid_equinor.py @@ -10,16 +10,16 @@ from cwrap import open as copen import time -from ecl import EclDataType, EclUnitTypeEnum -from ecl.eclfile import EclKW, EclFile, openEclFile -from ecl.grid import EclGrid -from ecl.util.util import DoubleVector, IntVector -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata import ResdataDataType, ResdataUnitTypeEnum +from resdata.eclfile import ResdataKW, ResdataFile, openResdataFile +from resdata.grid import ResdataGrid +from resdata.util.util import DoubleVector, IntVector +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test @equinor_test() -class GridTest(EclTest): +class GridTest(ResdataTest): def egrid_file(self): return self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") @@ -32,14 +32,14 @@ def grdecl_file(self): ) def test_loadFromFile(self): - g1 = EclGrid.loadFromFile(self.egrid_file()) - g2 = EclGrid.loadFromFile(self.grdecl_file()) + g1 = ResdataGrid.loadFromFile(self.egrid_file()) + g2 = ResdataGrid.loadFromFile(self.grdecl_file()) - self.assertTrue(isinstance(g1, EclGrid)) - self.assertTrue(isinstance(g2, EclGrid)) + self.assertTrue(isinstance(g1, ResdataGrid)) + self.assertTrue(isinstance(g2, ResdataGrid)) def test_corner(self): - grid = EclGrid(self.egrid_file()) + grid = ResdataGrid(self.egrid_file()) nx = grid.getNX() ny = grid.getNY() nz = grid.getNZ() @@ -87,11 +87,11 @@ def test_corner(self): grid.getLayerXYZ(0, nz + 1) def test_GRID(self): - grid = EclGrid(self.grid_file()) + grid = ResdataGrid(self.grid_file()) self.assertTrue(grid) def test_EGRID(self): - grid = EclGrid(self.egrid_file()) + grid = ResdataGrid(self.egrid_file()) self.assertTrue(grid) dims = grid.getDims() self.assertEqual(dims[0], grid.getNX()) @@ -100,18 +100,20 @@ def test_EGRID(self): def create(self, filename, load_actnum=True): fileH = copen(filename, "r") - specgrid = EclKW.read_grdecl( - fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False + specgrid = ResdataKW.read_grdecl( + fileH, "SPECGRID", rd_type=ResdataDataType.RD_INT, strict=False ) - zcorn = EclKW.read_grdecl(fileH, "ZCORN") - coord = EclKW.read_grdecl(fileH, "COORD") + zcorn = ResdataKW.read_grdecl(fileH, "ZCORN") + coord = ResdataKW.read_grdecl(fileH, "COORD") if load_actnum: - actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) + actnum = ResdataKW.read_grdecl( + fileH, "ACTNUM", rd_type=ResdataDataType.RD_INT + ) else: actnum = None - mapaxes = EclKW.read_grdecl(fileH, "MAPAXES") - grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes) + mapaxes = ResdataKW.read_grdecl(fileH, "MAPAXES") + grid = ResdataGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes) return grid def test_rect(self): @@ -119,9 +121,9 @@ def test_rect(self): a1 = 1.0 a2 = 2.0 a3 = 3.0 - grid = EclGrid.createRectangular((9, 9, 9), (a1, a2, a3)) + grid = ResdataGrid.createRectangular((9, 9, 9), (a1, a2, a3)) grid.save_EGRID("rect.EGRID") - grid2 = EclGrid("rect.EGRID") + grid2 = ResdataGrid("rect.EGRID") self.assertTrue(grid) self.assertTrue(grid2) @@ -152,18 +154,18 @@ def test_create(self): def test_grdecl_load(self): with self.assertRaises(IOError): - grid = EclGrid.loadFromGrdecl("/file/does/not/exists") + grid = ResdataGrid.loadFromGrdecl("/file/does/not/exists") with TestAreaContext("python/grid-test/grdeclLoad"): with open("grid.grdecl", "w") as f: f.write("Hei ...") with self.assertRaises(ValueError): - grid = EclGrid.loadFromGrdecl("grid.grdecl") + grid = ResdataGrid.loadFromGrdecl("grid.grdecl") actnum = IntVector(default_value=1, initial_size=1000) actnum[0] = 0 - g1 = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + g1 = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) self.assertEqual(g1.getNumActive(), actnum.elementSum()) g1.save_EGRID("G.EGRID") @@ -171,7 +173,7 @@ def test_grdecl_load(self): f2.write("SPECGRID\n") f2.write(" 10 10 10 'F' /\n") - with openEclFile("G.EGRID") as f: + with openResdataFile("G.EGRID") as f: with copen("grid.grdecl", "a") as f2: coord_kw = f["COORD"][0] coord_kw.write_grdecl(f2) @@ -182,7 +184,7 @@ def test_grdecl_load(self): actnum_kw = f["ACTNUM"][0] actnum_kw.write_grdecl(f2) - g2 = EclGrid.loadFromGrdecl("grid.grdecl") + g2 = ResdataGrid.loadFromGrdecl("grid.grdecl") self.assertTrue(g1.equal(g2)) def test_ACTNUM(self): @@ -192,21 +194,21 @@ def test_ACTNUM(self): def test_time(self): t0 = time.perf_counter() - g1 = EclGrid(self.egrid_file()) + g1 = ResdataGrid(self.egrid_file()) t1 = time.perf_counter() t = t1 - t0 self.assertTrue(t < 1.0) def test_save(self): with TestAreaContext("python/grid-test/testSave"): - g1 = EclGrid(self.egrid_file()) + g1 = ResdataGrid(self.egrid_file()) g1.save_EGRID("test.EGRID") - g2 = EclGrid("test.EGRID") + g2 = ResdataGrid("test.EGRID") self.assertTrue(g1.equal(g2)) g1.save_GRID("test.GRID") - g2 = EclGrid("test.GRID") + g2 = ResdataGrid("test.GRID") self.assertTrue(g1.equal(g2)) fileH = copen("test.grdecl", "w") @@ -217,10 +219,10 @@ def test_save(self): def test_raise_IO_error(self): with self.assertRaises(IOError): - g = EclGrid("/does/not/exist.EGRID") + g = ResdataGrid("/does/not/exist.EGRID") def test_boundingBox(self): - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1)) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1)) with self.assertRaises(ValueError): bbox = grid.getBoundingBox2D(layer=-1) @@ -246,7 +248,8 @@ def test_boundingBox(self): self.assertEqual(bbox, ((3, 3), (7, 3), (7, 7), (3, 7))) @skipIf( - EclTest.slowTestShouldNotRun(), "Slow test of numActive large memory skipped!" + ResdataTest.slowTestShouldNotRun(), + "Slow test of numActive large memory skipped!", ) def test_num_active_large_memory(self): case = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE") @@ -256,8 +259,8 @@ def test_num_active_large_memory(self): vec[81920] = 0 vecList.append(vec) - grid1 = EclGrid(case) - grid2 = EclGrid(case) + grid1 = ResdataGrid(case) + grid2 = ResdataGrid(case) self.assertEqual(grid1.getNumActive(), grid2.getNumActive()) self.assertEqual(grid1.getNumActive(), 34770) @@ -269,7 +272,7 @@ def test_no_mapaxes_check_for_nan(self): for grid_path in grid_paths: test_grid_path = self.createTestPath(grid_path) - grid = EclGrid(test_grid_path) + grid = ResdataGrid(test_grid_path) xyz = grid.get_xyz(ijk=(0, 0, 0)) self.assertFalse(math.isnan(xyz[0])) @@ -282,7 +285,7 @@ def test_no_mapaxes_check_for_nan(self): self.assertFalse(math.isnan(xyz[2])) def test_valid_geometry(self): - grid = EclGrid( + grid = ResdataGrid( self.createTestPath( "Equinor/ECLIPSE/GRID_INVALID_CELL/PRED_RESEST_0_R_13_0.GRID" ) @@ -291,7 +294,7 @@ def test_valid_geometry(self): self.assertFalse(grid.validCellGeometry(ijk=(0, 0, 0))) def test_volume_kw(self): - grid = EclGrid(self.egrid_file()) + grid = ResdataGrid(self.egrid_file()) vol = grid.createVolumeKeyword() self.assertEqual(len(vol), grid.getNumActive()) for active_index, volume in enumerate(vol): @@ -303,7 +306,7 @@ def test_volume_kw(self): self.assertEqual(volume, grid.cell_volume(global_index=global_index)) def test_lgr_get(self): - grid = EclGrid( + grid = ResdataGrid( self.createTestPath( "Equinor/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID" ) diff --git a/python/tests/rd_tests/test_grid_equinor_coarse.py b/python/tests/rd_tests/test_grid_equinor_coarse.py index 29f3aa10e3..7db0c1a9e8 100644 --- a/python/tests/rd_tests/test_grid_equinor_coarse.py +++ b/python/tests/rd_tests/test_grid_equinor_coarse.py @@ -1,20 +1,20 @@ import itertools -from ecl.eclfile import EclRestartFile -from ecl.grid import EclGrid -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata.eclfile import ResdataRestartFile +from resdata.grid import ResdataGrid +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test @equinor_test() -class GridCoarceTest(EclTest): +class GridCoarceTest(ResdataTest): def lgc_grid(self): - return EclGrid( + return ResdataGrid( self.createTestPath("Equinor/ECLIPSE/LGCcase/LGC_TESTCASE2.EGRID") ) def lgc_restart(self, grid): - return EclRestartFile( + return ResdataRestartFile( grid, self.createTestPath("Equinor/ECLIPSE/LGCcase/LGC_TESTCASE2.UNRST") ) @@ -23,7 +23,7 @@ def test_save_roundtrip(self): g1 = self.lgc_grid() g1.save_EGRID("LGC.EGRID") - g2 = EclGrid("LGC.EGRID") + g2 = ResdataGrid("LGC.EGRID") self.assertTrue(g1.equal(g2, verbose=True)) self.assertEqual(g1.coarse_groups(), g2.coarse_groups()) diff --git a/python/tests/rd_tests/test_grid_equinor_dual.py b/python/tests/rd_tests/test_grid_equinor_dual.py index 2f64175a68..b88f0eb64e 100644 --- a/python/tests/rd_tests/test_grid_equinor_dual.py +++ b/python/tests/rd_tests/test_grid_equinor_dual.py @@ -1,13 +1,13 @@ import math -from ecl.util.test import TestAreaContext -from ecl.grid import EclGrid +from resdata.util.test import TestAreaContext +from resdata.grid import ResdataGrid -from tests import EclTest, equinor_test +from tests import ResdataTest, equinor_test @equinor_test() -class GridDualTest(EclTest): +class GridDualTest(ResdataTest): def egrid_file(self): return self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") @@ -16,21 +16,21 @@ def grid_file(self): def test_dual(self): with TestAreaContext("python/grid-test/testDual"): - grid = EclGrid(self.egrid_file()) + grid = ResdataGrid(self.egrid_file()) self.assertFalse(grid.dualGrid()) self.assertTrue(grid.getNumActiveFracture() == 0) - grid2 = EclGrid(self.grid_file()) + grid2 = ResdataGrid(self.grid_file()) self.assertFalse(grid.dualGrid()) self.assertTrue(grid.getNumActiveFracture() == 0) - dgrid = EclGrid( + dgrid = ResdataGrid( self.createTestPath("Equinor/ECLIPSE/DualPoro/DUALPOR_MSW.EGRID") ) self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) self.assertTrue(dgrid.getNumActive() == 46118) - dgrid2 = EclGrid( + dgrid2 = ResdataGrid( self.createTestPath("Equinor/ECLIPSE/DualPoro/DUALPOR_MSW.GRID") ) self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) @@ -40,7 +40,7 @@ def test_dual(self): # The DUAL_DIFF grid has been manipulated to create a # situation where some cells are only matrix active, and some # cells are only fracture active. - dgrid = EclGrid( + dgrid = ResdataGrid( self.createTestPath("Equinor/ECLIPSE/DualPoro/DUAL_DIFF.EGRID") ) self.assertTrue(dgrid.getNumActive() == 106) @@ -57,5 +57,5 @@ def test_dual(self): self.assertTrue(dgrid.get_global_index1F(2) == 5) dgrid.save_EGRID("DUAL_DIFF.EGRID") - dgrid2 = EclGrid("DUAL_DIFF.EGRID") + dgrid2 = ResdataGrid("DUAL_DIFF.EGRID") self.assertTrue(dgrid.equal(dgrid2, verbose=True)) diff --git a/python/tests/rd_tests/test_grid_generator.py b/python/tests/rd_tests/test_grid_generator.py index 52d232b942..1c87bf363b 100644 --- a/python/tests/rd_tests/test_grid_generator.py +++ b/python/tests/rd_tests/test_grid_generator.py @@ -5,12 +5,12 @@ import numpy import six -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid -from ecl.grid import EclGridGenerator as GridGen -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid +from resdata.grid import ResdataGridGenerator as GridGen +from resdata.util.test import TestAreaContext +from tests import ResdataTest def generate_ijk_bounds(dims): @@ -24,7 +24,7 @@ def decomposition_preserving(ijk_bound): return sum(list(zip(*ijk_bound))[0]) % 2 is 0 -class GridGeneratorTest(EclTest): +class GridGeneratorTest(ResdataTest): def setUp(self): self.test_base = [ ( @@ -130,7 +130,7 @@ def test_validate_cells(self): grid_dims, coord, zcorn, ijk_bound ) - subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, None) + subgrid = ResdataGrid.create(sub_dims, sub_zcorn, sub_coord, None) self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) self.assertSubgrid(grid, subgrid, ijk_bound) @@ -140,14 +140,14 @@ def test_actnum_extraction(self): coord = GridGen.create_coord(dims, (1, 1, 1)) zcorn = GridGen.create_zcorn(dims, (1, 1, 1), offset=0) - actnum = EclKW( - "ACTNUM", six.functools.reduce(operator.mul, dims), EclDataType.ECL_INT + actnum = ResdataKW( + "ACTNUM", six.functools.reduce(operator.mul, dims), ResdataDataType.RD_INT ) random.seed(1337) for i in range(len(actnum)): actnum[i] = random.randint(0, 1) - grid = EclGrid.create(dims, zcorn, coord, actnum) + grid = ResdataGrid.create(dims, zcorn, coord, actnum) ijk_bounds = generate_ijk_bounds(dims) for ijk_bound in ijk_bounds: @@ -160,7 +160,7 @@ def test_actnum_extraction(self): sub_coord, sub_zcorn, sub_actnum = sub sub_dims = tuple([u - l + 1 for l, u in ijk_bound]) - subgrid = EclGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum) + subgrid = ResdataGrid.create(sub_dims, sub_zcorn, sub_coord, sub_actnum) self.assertEqual(sub_dims, subgrid.getDims()[:-1:]) self.assertSubgrid(grid, subgrid, ijk_bound) @@ -169,7 +169,7 @@ def test_translation(self): coord = GridGen.create_coord(dims, (1, 1, 1)) zcorn = GridGen.create_zcorn(dims, (1, 1, 1), offset=0) - grid = EclGrid.create(dims, zcorn, coord, None) + grid = ResdataGrid.create(dims, zcorn, coord, None) ijk_bound = [(0, d - 1) for d in dims] translation = (1, 2, 3) @@ -177,7 +177,7 @@ def test_translation(self): dims, coord, zcorn, ijk_bound, translation=translation ) - tgrid = EclGrid.create(dims, sub_zcorn, sub_coord, None) + tgrid = ResdataGrid.create(dims, sub_zcorn, sub_coord, None) self.assertEqual(grid.getGlobalSize(), tgrid.getGlobalSize()) for gi in range(grid.getGlobalSize()): @@ -215,11 +215,11 @@ def test_subgrid_translation(self): ) # Create grid with MAPAXES - mapaxes = EclKW("MAPAXES", 6, EclDataType.ECL_FLOAT) + mapaxes = ResdataKW("MAPAXES", 6, ResdataDataType.RD_FLOAT) for i, val in enumerate([1200, 1400, 2500, 2500, 3700, 4000]): mapaxes[i] = val - grid = EclGrid.create( + grid = ResdataGrid.create( grid.getDims(), grid.export_zcorn(), grid.export_coord(), diff --git a/python/tests/rd_tests/test_grid_large_case.py b/python/tests/rd_tests/test_grid_large_case.py index 5c028108cd..b8dbc9786d 100644 --- a/python/tests/rd_tests/test_grid_large_case.py +++ b/python/tests/rd_tests/test_grid_large_case.py @@ -1,7 +1,7 @@ import itertools import pytest -from ecl.grid import EclGrid +from resdata.grid import ResdataGrid def write_zero_grdecl(file_path, num_x, num_y, num_z): @@ -54,7 +54,7 @@ def test_large_case(tmp_path): write_zero_grdecl(big_grdecl, num_x, num_y, num_z) - grid = EclGrid.load_from_grdecl(str(big_grdecl)) + grid = ResdataGrid.load_from_grdecl(str(big_grdecl)) assert grid.get_nx() == num_x assert grid.get_ny() == num_y assert grid.get_nz() == num_z diff --git a/python/tests/rd_tests/test_grid_pandas.py b/python/tests/rd_tests/test_grid_pandas.py index 6332592b73..851e12ee60 100644 --- a/python/tests/rd_tests/test_grid_pandas.py +++ b/python/tests/rd_tests/test_grid_pandas.py @@ -2,18 +2,18 @@ import numpy as np import pandas as pd -from ecl import EclTypeEnum +from resdata import ResdataTypeEnum -from ecl.eclfile import EclKW +from resdata.eclfile import ResdataKW -from ecl.grid import EclGrid +from resdata.grid import ResdataGrid -from tests import EclTest +from tests import ResdataTest -class GridPandasTest(EclTest): +class GridPandasTest(ResdataTest): def test_dataframe_actnum(self): - grid = EclGrid.create_rectangular( + grid = ResdataGrid.create_rectangular( (2, 3, 1), (1, 1, 1), actnum=[1, 1, 0, 0, 1, 1] ) df = grid.export_index(True) @@ -22,7 +22,7 @@ def test_dataframe_actnum(self): ) assert np.array_equal(df.values, index_matrix) - kw_int_active = EclKW("int_act", 4, EclTypeEnum.ECL_INT_TYPE) + kw_int_active = ResdataKW("int_act", 4, ResdataTypeEnum.RD_INT_TYPE) kw_int_active[0] = 9 kw_int_active[1] = 8 kw_int_active[2] = 7 @@ -31,7 +31,7 @@ def test_dataframe_actnum(self): assert len(data) == 4 assert np.array_equal(data, np.array([9, 8, 7, 6])) - kw_float_active = EclKW("float_at", 4, EclTypeEnum.ECL_FLOAT_TYPE) + kw_float_active = ResdataKW("float_at", 4, ResdataTypeEnum.RD_FLOAT_TYPE) kw_float_active[0] = 10.5 kw_float_active[1] = 9.25 kw_float_active[2] = 2.0 @@ -40,7 +40,7 @@ def test_dataframe_actnum(self): assert len(data) == 4 assert np.array_equal(data, np.array([10.5, 9.25, 2.0, 1.625])) - kw_int_global = EclKW("int_glob", 6, EclTypeEnum.ECL_INT_TYPE) + kw_int_global = ResdataKW("int_glob", 6, ResdataTypeEnum.RD_INT_TYPE) kw_int_global[0] = 0 kw_int_global[1] = 2 kw_int_global[2] = 4 @@ -51,7 +51,7 @@ def test_dataframe_actnum(self): assert len(data) == 4 assert np.array_equal(data, np.array([0, 2, 8, 9])) - kw_double_global = EclKW("double_g", 6, EclTypeEnum.ECL_DOUBLE_TYPE) + kw_double_global = ResdataKW("double_g", 6, ResdataTypeEnum.RD_DOUBLE_TYPE) kw_double_global[0] = 1.1 kw_double_global[1] = 2.2 kw_double_global[2] = 3.3 @@ -72,7 +72,7 @@ def test_dataframe_actnum(self): assert np.array_equal(data, np.array([10.5, 9.25, 2222.0, 2222.0, 2.0, 1.625])) def test_dataframe_grid_data(self): - grid = EclGrid.create_rectangular( + grid = ResdataGrid.create_rectangular( (2, 3, 1), (1, 1, 1), actnum=[1, 1, 0, 0, 1, 1] ) index_frame = grid.export_index() diff --git a/python/tests/rd_tests/test_indexed_read.py b/python/tests/rd_tests/test_indexed_read.py index 2952f3aa7c..0554f75ead 100644 --- a/python/tests/rd_tests/test_indexed_read.py +++ b/python/tests/rd_tests/test_indexed_read.py @@ -1,44 +1,44 @@ import ctypes -import ecl +import resdata -from ecl import EclPrototype -from ecl import EclDataType -from ecl.eclfile import EclKW, EclFile, FortIO -from ecl.util.test import TestAreaContext -from tests import EclTest -from ecl.util.util import IntVector +from resdata import ResdataPrototype +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW, ResdataFile, FortIO +from resdata.util.test import TestAreaContext +from tests import ResdataTest +from resdata.util.util import IntVector -class EclIndexedReadTest(EclTest): - _freadIndexedData = EclPrototype( - "void ecl_kw_fread_indexed_data_python(fortio, int, ecl_data_type, int, int_vector, char*)", +class ResdataIndexedReadTest(ResdataTest): + _freadIndexedData = ResdataPrototype( + "void rd_kw_fread_indexed_data_python(fortio, int, rd_data_type, int, int_vector, char*)", bind=False, ) # fortio, offset, type, count, index_map, buffer - _eclFileIndexedRead = EclPrototype( - "void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)", + _eclFileIndexedRead = ResdataPrototype( + "void rd_file_indexed_read(rd_file, char*, int, int_vector, char*)", bind=False, - ) # ecl_file, kw, index, index_map, buffer + ) # rd_file, kw, index, index_map, buffer - def test_ecl_kw_indexed_read(self): - with TestAreaContext("ecl_kw_indexed_read") as area: + def test_rd_kw_indexed_read(self): + with TestAreaContext("rd_kw_indexed_read") as area: fortio = FortIO("index_test", mode=FortIO.WRITE_MODE) element_count = 100000 - ecl_kw = EclKW("TEST", element_count, EclDataType.ECL_INT) + rd_kw = ResdataKW("TEST", element_count, ResdataDataType.RD_INT) for index in range(element_count): - ecl_kw[index] = index + rd_kw[index] = index - ecl_kw.fwrite(fortio) + rd_kw.fwrite(fortio) fortio.close() fortio = FortIO("index_test", mode=FortIO.READ_MODE) - new_ecl_kw = EclKW.fread(fortio) + new_rd_kw = ResdataKW.fread(fortio) for index in range(element_count): - self.assertEqual(new_ecl_kw[index], index) + self.assertEqual(new_rd_kw[index], index) index_map = IntVector() index_map.append(2) @@ -65,7 +65,12 @@ def test_ecl_kw_indexed_read(self): ) self._freadIndexedData( - fortio, 24, EclDataType.ECL_INT, element_count, index_map, char_buffer + fortio, + 24, + ResdataDataType.RD_INT, + element_count, + index_map, + char_buffer, ) int_buffer = ctypes.cast(char_buffer, ctypes.POINTER(ctypes.c_int)) @@ -73,24 +78,24 @@ def test_ecl_kw_indexed_read(self): for index, index_map_value in enumerate(index_map): self.assertEqual(index_map_value, int_buffer[index]) - def test_ecl_file_indexed_read(self): - with TestAreaContext("ecl_file_indexed_read") as area: - fortio = FortIO("ecl_file_index_test", mode=FortIO.WRITE_MODE) + def test_rd_file_indexed_read(self): + with TestAreaContext("rd_file_indexed_read") as area: + fortio = FortIO("rd_file_index_test", mode=FortIO.WRITE_MODE) element_count = 100000 - ecl_kw_1 = EclKW("TEST1", element_count, EclDataType.ECL_INT) - ecl_kw_2 = EclKW("TEST2", element_count, EclDataType.ECL_INT) + rd_kw_1 = ResdataKW("TEST1", element_count, ResdataDataType.RD_INT) + rd_kw_2 = ResdataKW("TEST2", element_count, ResdataDataType.RD_INT) for index in range(element_count): - ecl_kw_1[index] = index - ecl_kw_2[index] = index + 3 + rd_kw_1[index] = index + rd_kw_2[index] = index + 3 - ecl_kw_1.fwrite(fortio) - ecl_kw_2.fwrite(fortio) + rd_kw_1.fwrite(fortio) + rd_kw_2.fwrite(fortio) fortio.close() - ecl_file = EclFile("ecl_file_index_test") + rd_file = ResdataFile("rd_file_index_test") index_map = IntVector() index_map.append(2) @@ -119,8 +124,8 @@ def test_ecl_file_indexed_read(self): len(index_map) * ctypes.sizeof(ctypes.c_int) ) - self._eclFileIndexedRead(ecl_file, "TEST2", 0, index_map, char_buffer_2) - self._eclFileIndexedRead(ecl_file, "TEST1", 0, index_map, char_buffer_1) + self._eclFileIndexedRead(rd_file, "TEST2", 0, index_map, char_buffer_2) + self._eclFileIndexedRead(rd_file, "TEST1", 0, index_map, char_buffer_1) int_buffer_1 = ctypes.cast(char_buffer_1, ctypes.POINTER(ctypes.c_int)) int_buffer_2 = ctypes.cast(char_buffer_2, ctypes.POINTER(ctypes.c_int)) diff --git a/python/tests/rd_tests/test_kw_function.py b/python/tests/rd_tests/test_kw_function.py index b44f36ff91..8dfce85c7c 100644 --- a/python/tests/rd_tests/test_kw_function.py +++ b/python/tests/rd_tests/test_kw_function.py @@ -1,14 +1,14 @@ #!/usr/bin/env python import os import random -from ecl import EclDataType -from ecl.eclfile import EclKW, Ecl3DKW -from ecl.grid import EclGrid -from ecl.util.util import IntVector -from tests import EclTest +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW, Resdata3DKW +from resdata.grid import ResdataGrid +from resdata.util.util import IntVector +from tests import ResdataTest -class KWFunctionTest(EclTest): +class KWFunctionTest(ResdataTest): def test_region_filter(self): nx = 10 ny = 10 @@ -16,10 +16,12 @@ def test_region_filter(self): actnum = IntVector(initial_size=nx * ny * nz, default_value=1) actnum[nx * ny - 1] = 0 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1), actnum=actnum) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1), actnum=actnum) self.assertEqual(grid.getNumActive(), nx * ny * nz - 1) - kw = Ecl3DKW.create("REGIONS", grid, EclDataType.ECL_INT, global_active=True) + kw = Resdata3DKW.create( + "REGIONS", grid, ResdataDataType.RD_INT, global_active=True + ) kw.assign(0) kw[0 : int(nx * ny / 2)] = 1 kw[5, 2, 0] = 0 @@ -43,15 +45,15 @@ def test_region_filter(self): self.assertEqual(kw[i, 7, 0], 1) def test_porv_kw(self): - porv_int = EclKW("PORV", 100, EclDataType.ECL_INT) + porv_int = ResdataKW("PORV", 100, ResdataDataType.RD_INT) with self.assertRaises(TypeError): actnum = porv_int.create_actnum() - prv = EclKW("PRV", 100, EclDataType.ECL_FLOAT) + prv = ResdataKW("PRV", 100, ResdataDataType.RD_FLOAT) with self.assertRaises(ValueError): actnum = prv.create_actnum() - porv = EclKW("PORV", 4, EclDataType.ECL_FLOAT) + porv = ResdataKW("PORV", 4, ResdataDataType.RD_FLOAT) porv[0] = 0 porv[1] = 0.50 porv[2] = 0.50 diff --git a/python/tests/rd_tests/test_layer.py b/python/tests/rd_tests/test_layer.py index 028b02c34e..0645ff67f3 100644 --- a/python/tests/rd_tests/test_layer.py +++ b/python/tests/rd_tests/test_layer.py @@ -2,15 +2,15 @@ from unittest import skipIf import time -from ecl.util.util import IntVector -from ecl.grid import EclGrid -from ecl.util.geometry import CPolyline -from ecl.grid.faults import Layer, FaultCollection -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.util import IntVector +from resdata.grid import ResdataGrid +from resdata.util.geometry import CPolyline +from resdata.grid.faults import Layer, FaultCollection +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class LayerTest(EclTest): +class LayerTest(ResdataTest): def setUp(self): pass @@ -36,7 +36,7 @@ def test_contact(self): nx = 20 ny = 10 layer = Layer(nx, ny) - grid = EclGrid.createRectangular((nx, ny, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, 1), (1, 1, 1)) with self.assertRaises(IndexError): layer.cellContact((-1, 0), (1, 1)) @@ -90,7 +90,7 @@ def test_fault_barrier(self): nx = 120 ny = 60 nz = 43 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) with TestAreaContext("python/faults/line_order"): with open("faults.grdecl", "w") as f: f.write( @@ -149,7 +149,7 @@ def test_contact2(self): nx = 10 ny = 10 layer = Layer(nx, ny) - grid = EclGrid.createRectangular((nx, ny, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((nx, ny, 1), (1, 1, 1)) # Too short with self.assertRaises(ValueError): @@ -228,7 +228,7 @@ def test_matching(self): def test_add_polyline_barrier(self): d = 10 layer = Layer(d, d) - grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((d, d, 1), (1, 1, 1)) pl = CPolyline(init_points=[(0, 0), (d / 2, d / 2), (d, d)]) layer.addPolylineBarrier(pl, grid, 0) for i in range(d): @@ -244,17 +244,17 @@ def test_active(self): self.assertTrue(layer.activeCell(1, 2)) - grid = EclGrid.createRectangular((d, d + 1, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((d, d + 1, 1), (1, 1, 1)) with self.assertRaises(ValueError): layer.updateActive(grid, 0) - grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1)) + grid = ResdataGrid.createRectangular((d, d, 1), (1, 1, 1)) with self.assertRaises(ValueError): layer.updateActive(grid, 10) actnum = IntVector(initial_size=d * d * 1, default_value=1) actnum[0] = 0 - grid = EclGrid.createRectangular((d, d, 1), (1, 1, 1), actnum=actnum) + grid = ResdataGrid.createRectangular((d, d, 1), (1, 1, 1), actnum=actnum) layer.updateActive(grid, 0) self.assertTrue(layer.activeCell(1, 2)) self.assertFalse(layer.activeCell(0, 0)) diff --git a/python/tests/rd_tests/test_npv.py b/python/tests/rd_tests/test_npv.py index a3e6a57b42..cc191089ac 100644 --- a/python/tests/rd_tests/test_npv.py +++ b/python/tests/rd_tests/test_npv.py @@ -8,12 +8,12 @@ except ImportError: from unittest import skipIf, skipUnless, skipIf -from ecl.summary import EclSum -from ecl.summary import EclNPV, NPVPriceVector +from resdata.summary import RdSum +from resdata.summary import ResdataNPV, NPVPriceVector -from ecl.util.util import StringList, TimeVector, DoubleVector, CTime -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata.util.util import StringList, TimeVector, DoubleVector, CTime +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test base = "ECLIPSE" @@ -34,23 +34,23 @@ def linear2(x): @equinor_test() -class NPVTest(EclTest): +class NPVTest(ResdataTest): def setUp(self): self.case = self.createTestPath(case) def test_create(self): with self.assertRaises(Exception): - npv = EclNPV("/does/not/exist") + npv = ResdataNPV("/does/not/exist") - npv = EclNPV(self.case) + npv = ResdataNPV(self.case) def test_eval_npv(self): - npv = EclNPV(self.case) + npv = ResdataNPV(self.case) with self.assertRaises(ValueError): npv.eval() def test_expression(self): - npv = EclNPV(self.case) + npv = ResdataNPV(self.case) self.assertIsNone(npv.getExpression()) npv.setExpression("[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE") self.assertEqual(npv.getExpression(), "[FOPT]*$OIL_PRICE - [FGIT]*$GAS_PRICE") @@ -82,18 +82,18 @@ def test_expression(self): self.assertIn("WOPT:OP_1", keyList) def test_period(self): - npv = EclNPV(self.case) + npv = ResdataNPV(self.case) self.assertIsNone(npv.start) self.assertIsNone(npv.end) self.assertEqual("1Y", npv.interval) def test_eval(self): - npv = EclNPV(self.case) + npv = ResdataNPV(self.case) npv.compile("[FOPT]") npv1 = npv.evalNPV() npv2 = 0 - sum = EclSum(self.case) + sum = RdSum(self.case) trange = sum.timeRange() fopr = sum.blockedProduction("FOPT", trange) for v in fopr: diff --git a/python/tests/rd_tests/test_rd_3dkw.py b/python/tests/rd_tests/test_rd_3dkw.py index 758ad791c7..aec536791e 100644 --- a/python/tests/rd_tests/test_rd_3dkw.py +++ b/python/tests/rd_tests/test_rd_3dkw.py @@ -2,22 +2,22 @@ import os import random -from ecl.util.util import IntVector -from ecl import EclDataType, EclFileFlagEnum -from ecl.eclfile import Ecl3DKW, EclKW, EclFile, FortIO -from ecl.grid import EclGrid -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.util import IntVector +from resdata import ResdataDataType, ResdataFileFlagEnum +from resdata.eclfile import Resdata3DKW, ResdataKW, ResdataFile, FortIO +from resdata.grid import ResdataGrid +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class Ecl3DKWTest(EclTest): +class Resdata3DKWTest(ResdataTest): def test_create(self): actnum = IntVector(default_value=1, initial_size=1000) for i in range(100): actnum[i] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_FLOAT) self.assertEqual(len(kw), grid.getNumActive()) self.assertEqual((10, 10, 10), kw.dims()) @@ -27,8 +27,8 @@ def test_create_global_size(self): for i in range(100): actnum[i] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT, global_active=True) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_FLOAT, global_active=True) self.assertEqual(len(kw), grid.getGlobalSize()) kw.assign(50) @@ -41,8 +41,8 @@ def test_fix_uninitialized(self): nx = 10 ny = 11 nz = 12 - grid = EclGrid.createRectangular((nx, ny, nz), (1, 1, 1)) - kw = Ecl3DKW("REGIONS", grid, EclDataType.ECL_INT, global_active=True) + grid = ResdataGrid.createRectangular((nx, ny, nz), (1, 1, 1)) + kw = Resdata3DKW("REGIONS", grid, ResdataDataType.RD_INT, global_active=True) kw.assign(3) self.assertEqual(3 * nx * ny * nz, sum(kw)) @@ -59,8 +59,8 @@ def test_getitem(self): for i in range(100): actnum[i] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT, default_value=77) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_FLOAT, default_value=77) with self.assertRaises(IndexError): kw[1000] @@ -84,8 +84,8 @@ def test_setitem(self): for i in range(100): actnum[i] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT, default_value=77) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_FLOAT, default_value=77) with self.assertRaises(IndexError): kw[1000] @@ -114,27 +114,27 @@ def test_cast(self): for i in range(100): actnum[i] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw_wrong_size = EclKW("KW", 27, EclDataType.ECL_FLOAT) - kw_global_size = EclKW("KW", grid.getGlobalSize(), EclDataType.ECL_FLOAT) - kw_active_size = EclKW("KW", grid.getNumActive(), EclDataType.ECL_FLOAT) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw_wrong_size = ResdataKW("KW", 27, ResdataDataType.RD_FLOAT) + kw_global_size = ResdataKW("KW", grid.getGlobalSize(), ResdataDataType.RD_FLOAT) + kw_active_size = ResdataKW("KW", grid.getNumActive(), ResdataDataType.RD_FLOAT) with self.assertRaises(ValueError): - Ecl3DKW.castFromKW(kw_wrong_size, grid) + Resdata3DKW.castFromKW(kw_wrong_size, grid) - Ecl3DKW.castFromKW(kw_global_size, grid) - self.assertTrue(isinstance(kw_global_size, Ecl3DKW)) + Resdata3DKW.castFromKW(kw_global_size, grid) + self.assertTrue(isinstance(kw_global_size, Resdata3DKW)) - Ecl3DKW.castFromKW(kw_active_size, grid, default_value=66) - self.assertTrue(isinstance(kw_active_size, Ecl3DKW)) + Resdata3DKW.castFromKW(kw_active_size, grid, default_value=66) + self.assertTrue(isinstance(kw_active_size, Resdata3DKW)) self.assertEqual(kw_active_size[0, 0, 0], 66) with self.assertRaises(ValueError): kw_active_size[0, 0, 0] = 88 def test_default(self): - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1)) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_FLOAT) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1)) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_FLOAT) kw.setDefault(55) self.assertTrue(55, kw.getDefault()) @@ -143,13 +143,13 @@ def test_compressed_copy(self): for i in range(500): actnum[2 * i + 1] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_INT, global_active=True) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_INT, global_active=True) for i in range(len(kw)): kw[i] = i kw_copy = kw.compressedCopy() - self.assertTrue(isinstance(kw_copy, EclKW)) + self.assertTrue(isinstance(kw_copy, ResdataKW)) self.assertEqual(len(kw_copy), 500) for i in range(len(kw_copy)): @@ -160,14 +160,14 @@ def test_global_copy(self): for i in range(500): actnum[2 * i + 1] = 0 - grid = EclGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) - kw = Ecl3DKW("KW", grid, EclDataType.ECL_INT, global_active=False) + grid = ResdataGrid.createRectangular((10, 10, 10), (1, 1, 1), actnum=actnum) + kw = Resdata3DKW("KW", grid, ResdataDataType.RD_INT, global_active=False) for i in range(len(kw)): kw[i] = i kw.setDefault(177) kw_copy = kw.globalCopy() - self.assertTrue(isinstance(kw_copy, EclKW)) + self.assertTrue(isinstance(kw_copy, ResdataKW)) self.assertEqual(len(kw_copy), 1000) for i in range(len(kw)): diff --git a/python/tests/rd_tests/test_rd_cmp.py b/python/tests/rd_tests/test_rd_cmp.py index 3690936777..fc1609edc2 100644 --- a/python/tests/rd_tests/test_rd_cmp.py +++ b/python/tests/rd_tests/test_rd_cmp.py @@ -1,47 +1,47 @@ -from ecl.util.test import TestAreaContext -from ecl.util.test.ecl_mock import createEclSum -from ecl.summary import EclCmp -from tests import EclTest, equinor_test +from resdata.util.test import TestAreaContext +from resdata.util.test.rd_mock import createRdSum +from resdata.summary import ResdataCmp +from tests import ResdataTest, equinor_test @equinor_test() -class EclCmpTest(EclTest): +class ResdataCmpTest(ResdataTest): def setUp(self): self.root1 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE") self.root2 = self.createTestPath("Equinor/ECLIPSE/Oseberg/F8MLT/F8MLT-F4") def test_not_existing(self): with self.assertRaises(IOError): - ecl_cmp = EclCmp("missing/case1", "missing/case2") + rd_cmp = ResdataCmp("missing/case1", "missing/case2") with self.assertRaises(IOError): - ecl_cmp = EclCmp("missing/case1", self.root1) + rd_cmp = ResdataCmp("missing/case1", self.root1) with self.assertRaises(IOError): - ecl_cmp = EclCmp(self.root1, "missing/case1") + rd_cmp = ResdataCmp(self.root1, "missing/case1") - ecl_cmp = EclCmp(self.root1, self.root1) - ecl_cmp = EclCmp(self.root2, self.root2) + rd_cmp = ResdataCmp(self.root1, self.root1) + rd_cmp = ResdataCmp(self.root2, self.root2) def test_different_start(self): with self.assertRaises(ValueError): - ecl_cmp = EclCmp(self.root1, self.root2) + rd_cmp = ResdataCmp(self.root1, self.root2) def test_summary_cmp(self): - ecl_cmp = EclCmp(self.root1, self.root1) - self.assertEqual((False, False), ecl_cmp.hasSummaryVector("MISSING")) - self.assertEqual((True, True), ecl_cmp.hasSummaryVector("FOPT")) + rd_cmp = ResdataCmp(self.root1, self.root1) + self.assertEqual((False, False), rd_cmp.hasSummaryVector("MISSING")) + self.assertEqual((True, True), rd_cmp.hasSummaryVector("FOPT")) with self.assertRaises(KeyError): - diff = ecl_cmp.cmpSummaryVector("MISSING") + diff = rd_cmp.cmpSummaryVector("MISSING") - diff_sum, ref_sum = ecl_cmp.cmpSummaryVector("FOPT") + diff_sum, ref_sum = rd_cmp.cmpSummaryVector("FOPT") self.assertEqual(diff_sum, 0.0) - self.assertTrue(ecl_cmp.endTimeEqual()) + self.assertTrue(rd_cmp.endTimeEqual()) def test_wells(self): - ecl_cmp = EclCmp(self.root1, self.root1) - wells = ecl_cmp.testWells() + rd_cmp = ResdataCmp(self.root1, self.root1) + wells = rd_cmp.testWells() well_set = set(["OP_1", "OP_2", "OP_3", "OP_4", "OP_5", "WI_1", "WI_2", "WI_3"]) self.assertEqual(len(wells), len(well_set)) diff --git a/python/tests/rd_tests/test_rd_file.py b/python/tests/rd_tests/test_rd_file.py index 8d8656d08f..6722ec1cd8 100644 --- a/python/tests/rd_tests/test_rd_file.py +++ b/python/tests/rd_tests/test_rd_file.py @@ -4,11 +4,11 @@ import gc from unittest import skipIf -from ecl import EclFileFlagEnum, EclDataType, EclFileEnum -from ecl.eclfile import EclFile, FortIO, EclKW, openFortIO, openEclFile -from ecl.util.util import CWDContext -from ecl.util.test import TestAreaContext, PathContext -from tests import EclTest +from resdata import ResdataFileFlagEnum, ResdataDataType, ResdataFileEnum +from resdata.eclfile import ResdataFile, FortIO, ResdataKW, openFortIO, openResdataFile +from resdata.util.util import CWDContext +from resdata.util.test import TestAreaContext, PathContext +from tests import ResdataTest def createFile(name, kw_list): @@ -19,86 +19,92 @@ def createFile(name, kw_list): def loadKeywords(name): kw_list = [] - f = EclFile(name) + f = ResdataFile(name) for kw in f: kw_list.append(kw) return kw_list -class EclFileTest(EclTest): +class ResdataFileTest(ResdataTest): def assertFileType(self, filename, expected): - file_type, step, fmt_file = EclFile.getFileType(filename) + file_type, step, fmt_file = ResdataFile.getFileType(filename) self.assertEqual(file_type, expected[0]) self.assertEqual(fmt_file, expected[1]) self.assertEqual(step, expected[2]) def test_file_type(self): self.assertFileType( - "ECLIPSE.UNRST", (EclFileEnum.ECL_UNIFIED_RESTART_FILE, False, None) + "ECLIPSE.UNRST", (ResdataFileEnum.RD_UNIFIED_RESTART_FILE, False, None) + ) + self.assertFileType( + "ECLIPSE.X0030", (ResdataFileEnum.RD_RESTART_FILE, False, 30) + ) + self.assertFileType("ECLIPSE.DATA", (ResdataFileEnum.RD_DATA_FILE, None, None)) + self.assertFileType("ECLIPSE.FINIT", (ResdataFileEnum.RD_INIT_FILE, True, None)) + self.assertFileType( + "ECLIPSE.A0010", (ResdataFileEnum.RD_SUMMARY_FILE, True, 10) + ) + self.assertFileType( + "ECLIPSE.EGRID", (ResdataFileEnum.RD_EGRID_FILE, False, None) ) - self.assertFileType("ECLIPSE.X0030", (EclFileEnum.ECL_RESTART_FILE, False, 30)) - self.assertFileType("ECLIPSE.DATA", (EclFileEnum.ECL_DATA_FILE, None, None)) - self.assertFileType("ECLIPSE.FINIT", (EclFileEnum.ECL_INIT_FILE, True, None)) - self.assertFileType("ECLIPSE.A0010", (EclFileEnum.ECL_SUMMARY_FILE, True, 10)) - self.assertFileType("ECLIPSE.EGRID", (EclFileEnum.ECL_EGRID_FILE, False, None)) def test_IOError(self): with self.assertRaises(IOError): - EclFile("No/Does/not/exist") + ResdataFile("No/Does/not/exist") def test_context(self): - with TestAreaContext("python/ecl_file/context"): - kw1 = EclKW("KW1", 100, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 100, EclDataType.ECL_INT) + with TestAreaContext("python/rd_file/context"): + kw1 = ResdataKW("KW1", 100, ResdataDataType.RD_INT) + kw2 = ResdataKW("KW2", 100, ResdataDataType.RD_INT) with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: kw1.fwrite(f) kw2.fwrite(f) - with openEclFile("TEST") as ecl_file: - self.assertEqual(len(ecl_file), 2) - self.assertTrue(ecl_file.has_kw("KW1")) - self.assertTrue(ecl_file.has_kw("KW2")) - self.assertEqual(ecl_file[1], ecl_file[-1]) - - def test_ecl_index(self): - with TestAreaContext("python/ecl_file/context"): - kw1 = EclKW("KW1", 100, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 100, EclDataType.ECL_FLOAT) - kw3 = EclKW("KW3", 100, EclDataType.ECL_CHAR) - kw4 = EclKW("KW4", 100, EclDataType.ECL_STRING(23)) + with openResdataFile("TEST") as rd_file: + self.assertEqual(len(rd_file), 2) + self.assertTrue(rd_file.has_kw("KW1")) + self.assertTrue(rd_file.has_kw("KW2")) + self.assertEqual(rd_file[1], rd_file[-1]) + + def test_rd_index(self): + with TestAreaContext("python/rd_file/context"): + kw1 = ResdataKW("KW1", 100, ResdataDataType.RD_INT) + kw2 = ResdataKW("KW2", 100, ResdataDataType.RD_FLOAT) + kw3 = ResdataKW("KW3", 100, ResdataDataType.RD_CHAR) + kw4 = ResdataKW("KW4", 100, ResdataDataType.RD_STRING(23)) with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: kw1.fwrite(f) kw2.fwrite(f) kw3.fwrite(f) kw4.fwrite(f) - ecl_file = EclFile("TEST") - ecl_file.write_index("INDEX_FILE") - ecl_file.close() + rd_file = ResdataFile("TEST") + rd_file.write_index("INDEX_FILE") + rd_file.close() - ecl_file_index = EclFile("TEST", 0, "INDEX_FILE") + rd_file_index = ResdataFile("TEST", 0, "INDEX_FILE") for kw in ["KW1", "KW2", "KW3", "KW4"]: - self.assertIn(kw, ecl_file_index) + self.assertIn(kw, rd_file_index) with self.assertRaises(IOError): - ecl_file.write_index("does-not-exist/INDEX") + rd_file.write_index("does-not-exist/INDEX") with self.assertRaises(IOError): - ecl_file_index = EclFile("TEST", 0, "index_does_not_exist") + rd_file_index = ResdataFile("TEST", 0, "index_does_not_exist") os.mkdir("path") shutil.copyfile("TEST", "path/TEST") - ecl_file = EclFile("path/TEST") - ecl_file.write_index("path/index") + rd_file = ResdataFile("path/TEST") + rd_file.write_index("path/index") with CWDContext("path"): - ecl_file = EclFile("TEST", 0, "index") + rd_file = ResdataFile("TEST", 0, "index") def test_save_kw(self): - with TestAreaContext("python/ecl_file/save_kw"): + with TestAreaContext("python/rd_file/save_kw"): data = range(1000) - kw = EclKW("MY_KEY", len(data), EclDataType.ECL_INT) + kw = ResdataKW("MY_KEY", len(data), ResdataDataType.RD_INT) for index, val in enumerate(data): kw[index] = val @@ -114,23 +120,23 @@ def test_save_kw(self): self.assertFilesAreEqual(clean_dump, test_file) - ecl_file = EclFile(test_file, flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - loaded_kw = ecl_file["MY_KEY"][0] + rd_file = ResdataFile(test_file, flags=ResdataFileFlagEnum.RD_FILE_WRITABLE) + loaded_kw = rd_file["MY_KEY"][0] self.assertTrue(kw.equal(loaded_kw)) - ecl_file.save_kw(loaded_kw) - ecl_file.close() + rd_file.save_kw(loaded_kw) + rd_file.close() self.assertFilesAreEqual(clean_dump, test_file) - ecl_file = EclFile(test_file) - loaded_kw = ecl_file["MY_KEY"][0] + rd_file = ResdataFile(test_file) + loaded_kw = rd_file["MY_KEY"][0] self.assertTrue(kw.equal(loaded_kw)) def test_gc(self): - kw1 = EclKW("KW1", 100, EclDataType.ECL_INT) - kw2 = EclKW("KW2", 100, EclDataType.ECL_INT) - kw3 = EclKW("KW3", 100, EclDataType.ECL_INT) + kw1 = ResdataKW("KW1", 100, ResdataDataType.RD_INT) + kw2 = ResdataKW("KW2", 100, ResdataDataType.RD_INT) + kw3 = ResdataKW("KW3", 100, ResdataDataType.RD_INT) for i in range(len(kw1)): kw1[i] = i @@ -151,12 +157,12 @@ def test_broken_file(self): with TestAreaContext("test_broken_file"): with open("CASE.FINIT", "w") as f: f.write( - "This - is not a ECLISPE file\nsdlcblhcdbjlwhc\naschscbasjhcasc\nascasck c s s aiasic asc" + "This - is not a RDISPE file\nsdlcblhcdbjlwhc\naschscbasjhcasc\nascasck c s s aiasic asc" ) - f = EclFile("CASE.FINIT") + f = ResdataFile("CASE.FINIT") self.assertEqual(len(f), 0) - kw = EclKW("HEADER", 100, EclDataType.ECL_INT) + kw = ResdataKW("HEADER", 100, ResdataDataType.RD_INT) with openFortIO("FILE", mode=FortIO.WRITE_MODE) as f: kw.fwrite(f) kw.fwrite(f) @@ -164,7 +170,7 @@ def test_broken_file(self): with open("FILE", "a+") as f: f.write("Seom random gibberish") - f = EclFile("FILE") + f = ResdataFile("FILE") self.assertEqual(len(f), 2) with openFortIO("FILE", mode=FortIO.WRITE_MODE) as f: @@ -175,42 +181,42 @@ def test_broken_file(self): with open("FILE", "a+") as f: f.truncate(int(file_size * 0.75)) - f = EclFile("FILE") + f = ResdataFile("FILE") self.assertEqual(len(f), 1) def test_block_view(self): - with TestAreaContext("python/ecl_file/view"): + with TestAreaContext("python/rd_file/view"): with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: for i in range(5): - header = EclKW("HEADER", 1, EclDataType.ECL_INT) + header = ResdataKW("HEADER", 1, ResdataDataType.RD_INT) header[0] = i - data1 = EclKW("DATA1", 100, EclDataType.ECL_INT) + data1 = ResdataKW("DATA1", 100, ResdataDataType.RD_INT) data1.assign(i) - data2 = EclKW("DATA2", 100, EclDataType.ECL_INT) + data2 = ResdataKW("DATA2", 100, ResdataDataType.RD_INT) data2.assign(i * 10) header.fwrite(f) data1.fwrite(f) data2.fwrite(f) - ecl_file = EclFile("TEST") - pfx = "EclFile(" - self.assertEqual(pfx, repr(ecl_file)[: len(pfx)]) + rd_file = ResdataFile("TEST") + pfx = "ResdataFile(" + self.assertEqual(pfx, repr(rd_file)[: len(pfx)]) with self.assertRaises(KeyError): - ecl_file.blockView("NO", 1) + rd_file.blockView("NO", 1) with self.assertRaises(IndexError): - ecl_file.blockView("HEADER", 100) + rd_file.blockView("HEADER", 100) with self.assertRaises(IndexError): - ecl_file.blockView("HEADER", 1000) + rd_file.blockView("HEADER", 1000) - bv = ecl_file.blockView("HEADER", -1) + bv = rd_file.blockView("HEADER", -1) for i in range(5): - view = ecl_file.blockView("HEADER", i) + view = rd_file.blockView("HEADER", i) self.assertEqual(len(view), 3) header = view["HEADER"][0] data1 = view["DATA1"][0] @@ -221,7 +227,7 @@ def test_block_view(self): self.assertEqual(data2[99], i * 10) for i in range(5): - view = ecl_file.blockView2("HEADER", "DATA2", i) + view = rd_file.blockView2("HEADER", "DATA2", i) self.assertEqual(len(view), 2) header = view["HEADER"][0] data1 = view["DATA1"][0] @@ -231,10 +237,10 @@ def test_block_view(self): self.assertFalse("DATA2" in view) - view = ecl_file.blockView2("HEADER", None, 0) - self.assertEqual(len(view), len(ecl_file)) + view = rd_file.blockView2("HEADER", None, 0) + self.assertEqual(len(view), len(rd_file)) - view = ecl_file.blockView2(None, "DATA2", 0) + view = rd_file.blockView2(None, "DATA2", 0) # self.assertEqual( len(view) , 2) # self.assertTrue( "HEADER" in view ) # self.assertTrue( "DATA1" in view ) diff --git a/python/tests/rd_tests/test_rd_file_equinor.py b/python/tests/rd_tests/test_rd_file_equinor.py index 2dbe668397..f76bcc916e 100755 --- a/python/tests/rd_tests/test_rd_file_equinor.py +++ b/python/tests/rd_tests/test_rd_file_equinor.py @@ -3,15 +3,15 @@ import os.path from unittest import skipIf -from ecl import EclFileFlagEnum, EclFileEnum -from ecl.eclfile import EclFile, FortIO, EclKW, openFortIO, openEclFile +from resdata import ResdataFileFlagEnum, ResdataFileEnum +from resdata.eclfile import ResdataFile, FortIO, ResdataKW, openFortIO, openResdataFile -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test @equinor_test() -class EclFileEquinorTest(EclTest): +class ResdataFileEquinorTest(ResdataTest): def setUp(self): self.test_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") self.test_fmt_file = self.createTestPath( @@ -19,21 +19,21 @@ def setUp(self): ) def assertFileType(self, filename, expected): - file_type, step, fmt_file = EclFile.getFileType(filename) + file_type, step, fmt_file = ResdataFile.getFileType(filename) self.assertEqual(file_type, expected[0]) self.assertEqual(fmt_file, expected[1]) self.assertEqual(step, expected[2]) def test_fast_open(self): with TestAreaContext("index"): - f0 = EclFile(self.test_file) + f0 = ResdataFile(self.test_file) f0.write_index("index") - f1 = EclFile(self.test_file, 0, "index") + f1 = ResdataFile(self.test_file, 0, "index") for kw0, kw1 in zip(f0, f1): self.assertEqual(kw0, kw1) def test_restart_days(self): - rst_file = EclFile(self.test_file) + rst_file = ResdataFile(self.test_file) self.assertAlmostEqual(0.0, rst_file.iget_restart_sim_days(0)) self.assertAlmostEqual(31.0, rst_file.iget_restart_sim_days(1)) self.assertAlmostEqual(274.0, rst_file.iget_restart_sim_days(10)) @@ -45,36 +45,38 @@ def test_restart_days(self): rst_file.restart_get_kw("SWAT", dtime=datetime.date(1985, 1, 1)) def test_iget_named(self): - f = EclFile(self.test_file) + f = ResdataFile(self.test_file) N = f.num_named_kw("SWAT") with self.assertRaises(IndexError): s = f.iget_named_kw("SWAT", N + 1) def test_fwrite(self): - # work_area = TestArea("python/ecl_file/fwrite") - with TestAreaContext("python/ecl_file/fwrite"): - rst_file = EclFile(self.test_file) + # work_area = TestArea("python/rd_file/fwrite") + with TestAreaContext("python/rd_file/fwrite"): + rst_file = ResdataFile(self.test_file) fortio = FortIO("ECLIPSE.UNRST", FortIO.WRITE_MODE) rst_file.fwrite(fortio) fortio.close() rst_file.close() self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) - @skipIf(EclTest.slowTestShouldNotRun(), "Slow file test skipped!") + @skipIf(ResdataTest.slowTestShouldNotRun(), "Slow file test skipped!") def test_save(self): - # work_area = TestArea("python/ecl_file/save") - with TestAreaContext("python/ecl_file/save", store_area=False) as work_area: + # work_area = TestArea("python/rd_file/save") + with TestAreaContext("python/rd_file/save", store_area=False) as work_area: work_area.copy_file(self.test_file) - rst_file = EclFile("ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) + rst_file = ResdataFile( + "ECLIPSE.UNRST", flags=ResdataFileFlagEnum.RD_FILE_WRITABLE + ) swat0 = rst_file["SWAT"][0] swat0.assign(0.75) rst_file.save_kw(swat0) rst_file.close() self.assertFilesAreNotEqual("ECLIPSE.UNRST", self.test_file) - rst_file1 = EclFile(self.test_file) - rst_file2 = EclFile( - "ECLIPSE.UNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE + rst_file1 = ResdataFile(self.test_file) + rst_file2 = ResdataFile( + "ECLIPSE.UNRST", flags=ResdataFileFlagEnum.RD_FILE_WRITABLE ) swat1 = rst_file1["SWAT"][0] @@ -89,13 +91,13 @@ def test_save(self): # Random failure .... self.assertFilesAreEqual("ECLIPSE.UNRST", self.test_file) - @skipIf(EclTest.slowTestShouldNotRun(), "Slow file test skipped!") + @skipIf(ResdataTest.slowTestShouldNotRun(), "Slow file test skipped!") def test_save_fmt(self): - # work_area = TestArea("python/ecl_file/save_fmt") - with TestAreaContext("python/ecl_file/save_fmt") as work_area: + # work_area = TestArea("python/rd_file/save_fmt") + with TestAreaContext("python/rd_file/save_fmt") as work_area: work_area.copy_file(self.test_fmt_file) - rst_file = EclFile( - "ECLIPSE.FUNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE + rst_file = ResdataFile( + "ECLIPSE.FUNRST", flags=ResdataFileFlagEnum.RD_FILE_WRITABLE ) swat0 = rst_file["SWAT"][0] swat0.assign(0.75) @@ -103,9 +105,9 @@ def test_save_fmt(self): rst_file.close() self.assertFilesAreNotEqual("ECLIPSE.FUNRST", self.test_fmt_file) - rst_file1 = EclFile(self.test_fmt_file) - rst_file2 = EclFile( - "ECLIPSE.FUNRST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE + rst_file1 = ResdataFile(self.test_fmt_file) + rst_file2 = ResdataFile( + "ECLIPSE.FUNRST", flags=ResdataFileFlagEnum.RD_FILE_WRITABLE ) swat1 = rst_file1["SWAT"][0] @@ -121,7 +123,7 @@ def test_save_fmt(self): self.assertFilesAreEqual("ECLIPSE.FUNRST", self.test_fmt_file) def test_restart_view(self): - f = EclFile(self.test_file) + f = ResdataFile(self.test_file) with self.assertRaises(ValueError): v = f.restartView() @@ -131,16 +133,16 @@ def test_restart_view(self): v = f.restartView(seqnum_index=30) def test_index(self): - with TestAreaContext("python/ecl_file/truncated"): - f0 = EclFile(self.test_file) + with TestAreaContext("python/rd_file/truncated"): + f0 = ResdataFile(self.test_file) f0.write_index("index") - f1 = EclFile(self.test_file, index_filename="index") + f1 = ResdataFile(self.test_file, index_filename="index") for kw0, kw1 in zip(f0, f1): self.assertEqual(kw0, kw1) def test_ix_case(self): - f = EclFile( + f = ResdataFile( self.createTestPath( "Equinor/ECLIPSE/ix/summary/Create_Region_Around_Well.SMSPEC" ) diff --git a/python/tests/rd_tests/test_rd_init_file.py b/python/tests/rd_tests/test_rd_init_file.py index 6df1fd7340..6fc5eb9415 100644 --- a/python/tests/rd_tests/test_rd_init_file.py +++ b/python/tests/rd_tests/test_rd_init_file.py @@ -1,29 +1,29 @@ -from tests import EclTest, equinor_test -from ecl import EclFileFlagEnum -from ecl.eclfile import Ecl3DKW, EclKW, EclInitFile, EclFile, FortIO -from ecl.grid import EclGrid +from tests import ResdataTest, equinor_test +from resdata import ResdataFileFlagEnum +from resdata.eclfile import Resdata3DKW, ResdataKW, ResdataInitFile, ResdataFile, FortIO +from resdata.grid import ResdataGrid @equinor_test() -class InitFileTest(EclTest): +class InitFileTest(ResdataTest): def setUp(self): self.grid_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") self.init_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.INIT") def test_wrong_type(self): - g = EclGrid(self.grid_file) + g = ResdataGrid(self.grid_file) with self.assertRaises(ValueError): - f = EclInitFile(g, self.grid_file) + f = ResdataInitFile(g, self.grid_file) def test_load(self): - g = EclGrid(self.grid_file) - f = EclInitFile(g, self.init_file) + g = ResdataGrid(self.grid_file) + f = ResdataInitFile(g, self.init_file) head = f["INTEHEAD"][0] - self.assertTrue(isinstance(head, EclKW)) + self.assertTrue(isinstance(head, ResdataKW)) porv = f["PORV"][0] - self.assertTrue(isinstance(porv, Ecl3DKW)) + self.assertTrue(isinstance(porv, Resdata3DKW)) poro = f["PORO"][0] - self.assertTrue(isinstance(poro, Ecl3DKW)) + self.assertTrue(isinstance(poro, Resdata3DKW)) diff --git a/python/tests/rd_tests/test_rd_kw.py b/python/tests/rd_tests/test_rd_kw.py index f3d6d86183..03ed6a04b8 100644 --- a/python/tests/rd_tests/test_rd_kw.py +++ b/python/tests/rd_tests/test_rd_kw.py @@ -4,27 +4,27 @@ import cwrap import random -from ecl import EclDataType, EclTypeEnum, EclFileFlagEnum -from ecl.eclfile import EclKW, EclFile, FortIO, openFortIO +from resdata import ResdataDataType, ResdataTypeEnum, ResdataFileFlagEnum +from resdata.eclfile import ResdataKW, ResdataFile, FortIO, openFortIO -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.test import TestAreaContext +from tests import ResdataTest def copy_long(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + src = ResdataKW("NAME", 100, ResdataDataType.RD_FLOAT) copy = src.sub_copy(0, 2000) def copy_offset(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + src = ResdataKW("NAME", 100, ResdataDataType.RD_FLOAT) copy = src.sub_copy(200, 100) -class KWTest(EclTest): +class KWTest(ResdataTest): def test_name(self): - kw = EclKW("TEST", 3, EclDataType.ECL_INT) + kw = ResdataKW("TEST", 3, ResdataDataType.RD_INT) self.assertEqual(kw.name, "TEST") self.assertIn("TEST", repr(kw)) kw.name = "SCHMEST" @@ -32,7 +32,7 @@ def test_name(self): self.assertIn("SCHMEST", repr(kw)) def test_min_max(self): - kw = EclKW("TEST", 3, EclDataType.ECL_INT) + kw = ResdataKW("TEST", 3, ResdataDataType.RD_INT) kw[0] = 10 kw[1] = 5 kw[2] = 0 @@ -44,23 +44,23 @@ def test_min_max(self): def test_deprecated_datatypes(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - kw = EclKW("Test", 10, EclTypeEnum.ECL_INT_TYPE) + kw = ResdataKW("Test", 10, ResdataTypeEnum.RD_INT_TYPE) self.assertTrue(len(w) > 0) self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - kw = EclKW("Test", 10, EclDataType.ECL_INT) + kw = ResdataKW("Test", 10, ResdataDataType.RD_INT) self.assertTrue(len(w) == 0) - self.assertEqual(EclTypeEnum.ECL_INT_TYPE, kw.type) + self.assertEqual(ResdataTypeEnum.RD_INT_TYPE, kw.type) self.assertTrue(len(w) == 1) def kw_test(self, data_type, data, fmt): name1 = "file1.txt" name2 = "file2.txt" - kw = EclKW("TEST", len(data), data_type) + kw = ResdataKW("TEST", len(data), data_type) for i, d in enumerate(data): kw[i] = d @@ -77,36 +77,36 @@ def kw_test(self, data_type, data, fmt): def test_create(self): with self.assertRaises(ValueError): - EclKW("ThisIsTooLong", 100, EclDataType.ECL_CHAR) + ResdataKW("ThisIsTooLong", 100, ResdataDataType.RD_CHAR) def test_sum(self): - for ecl_type in [EclDataType.ECL_CHAR, EclDataType.ECL_STRING(42)]: - kw_string = EclKW("STRING", 100, ecl_type) + for rd_type in [ResdataDataType.RD_CHAR, ResdataDataType.RD_STRING(42)]: + kw_string = ResdataKW("STRING", 100, rd_type) with self.assertRaises(ValueError): kw_string.sum() - kw_int = EclKW("INT", 4, EclDataType.ECL_INT) + kw_int = ResdataKW("INT", 4, ResdataDataType.RD_INT) kw_int[0] = 1 kw_int[1] = 2 kw_int[2] = 3 kw_int[3] = 4 self.assertEqual(kw_int.sum(), 10) - kw_d = EclKW("D", 4, EclDataType.ECL_DOUBLE) + kw_d = ResdataKW("D", 4, ResdataDataType.RD_DOUBLE) kw_d[0] = 1 kw_d[1] = 2 kw_d[2] = 3 kw_d[3] = 4 self.assertEqual(kw_d.sum(), 10) - kw_f = EclKW("F", 4, EclDataType.ECL_FLOAT) + kw_f = ResdataKW("F", 4, ResdataDataType.RD_FLOAT) kw_f[0] = 1 kw_f[1] = 2 kw_f[2] = 3 kw_f[3] = 4 self.assertEqual(kw_f.sum(), 10) - kw_b = EclKW("F", 4, EclDataType.ECL_BOOL) + kw_b = ResdataKW("F", 4, ResdataDataType.RD_BOOL) kw_b[0] = False kw_b[1] = True kw_b[2] = False @@ -114,71 +114,75 @@ def test_sum(self): self.assertEqual(kw_b.sum(), 2) def test_fprintf(self): - with TestAreaContext("python.ecl_kw"): - self.kw_test(EclDataType.ECL_INT, [0, 1, 2, 3, 4, 5], "%4d\n") + with TestAreaContext("python.rd_kw"): + self.kw_test(ResdataDataType.RD_INT, [0, 1, 2, 3, 4, 5], "%4d\n") self.kw_test( - EclDataType.ECL_FLOAT, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n" + ResdataDataType.RD_FLOAT, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n" ) self.kw_test( - EclDataType.ECL_DOUBLE, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n" + ResdataDataType.RD_DOUBLE, [0.0, 1.1, 2.2, 3.3, 4.4, 5.5], "%12.6f\n" ) - self.kw_test(EclDataType.ECL_BOOL, [True, True, True, False, True], "%4d\n") self.kw_test( - EclDataType.ECL_CHAR, + ResdataDataType.RD_BOOL, [True, True, True, False, True], "%4d\n" + ) + self.kw_test( + ResdataDataType.RD_CHAR, ["1", "22", "4444", "666666", "88888888"], "%-8s\n", ) for str_len in range(1000): self.kw_test( - EclDataType.ECL_STRING(str_len), + ResdataDataType.RD_STRING(str_len), [str(i) * str_len for i in range(10)], "%s\n", ) def test_kw_write(self): - with TestAreaContext("python/ecl_kw/writing"): + with TestAreaContext("python/rd_kw/writing"): data = [random.random() for i in range(10000)] - kw = EclKW("TEST", len(data), EclDataType.ECL_DOUBLE) + kw = ResdataKW("TEST", len(data), ResdataDataType.RD_DOUBLE) i = 0 for d in data: kw[i] = d i += 1 - pfx = "EclKW(" + pfx = "ResdataKW(" self.assertEqual(pfx, repr(kw)[: len(pfx)]) - fortio = FortIO("ECL_KW_TEST", FortIO.WRITE_MODE) + fortio = FortIO("RD_KW_TEST", FortIO.WRITE_MODE) kw.fwrite(fortio) fortio.close() - fortio = FortIO("ECL_KW_TEST") + fortio = FortIO("RD_KW_TEST") - kw2 = EclKW.fread(fortio) + kw2 = ResdataKW.fread(fortio) self.assertTrue(kw.equal(kw2)) - ecl_file = EclFile("ECL_KW_TEST", flags=EclFileFlagEnum.ECL_FILE_WRITABLE) - kw3 = ecl_file["TEST"][0] + rd_file = ResdataFile( + "RD_KW_TEST", flags=ResdataFileFlagEnum.RD_FILE_WRITABLE + ) + kw3 = rd_file["TEST"][0] self.assertTrue(kw.equal(kw3)) - ecl_file.save_kw(kw3) - ecl_file.close() + rd_file.save_kw(kw3) + rd_file.close() - fortio = FortIO("ECL_KW_TEST", FortIO.READ_AND_WRITE_MODE) - kw4 = EclKW.fread(fortio) + fortio = FortIO("RD_KW_TEST", FortIO.READ_AND_WRITE_MODE) + kw4 = ResdataKW.fread(fortio) self.assertTrue(kw.equal(kw4)) fortio.seek(0) kw4.fwrite(fortio) fortio.close() - ecl_file = EclFile("ECL_KW_TEST") - kw5 = ecl_file["TEST"][0] + rd_file = ResdataFile("RD_KW_TEST") + kw5 = rd_file["TEST"][0] self.assertTrue(kw.equal(kw5)) def test_fprintf_data(self): with TestAreaContext("kw_no_header"): - kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) + kw = ResdataKW("REGIONS", 10, ResdataDataType.RD_INT) for i in range(len(kw)): kw[i] = i @@ -197,7 +201,7 @@ def test_fprintf_data(self): self.assertEqual(v1, v2) def test_sliced_set(self): - kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) + kw = ResdataKW("REGIONS", 10, ResdataDataType.RD_INT) kw.assign(99) kw[0:5] = 66 self.assertEqual(kw[0], 66) @@ -206,23 +210,23 @@ def test_sliced_set(self): def test_long_name(self): with self.assertRaises(ValueError): - EclKW("LONGLONGNAME", 10, EclDataType.ECL_INT) + ResdataKW("LONGLONGNAME", 10, ResdataDataType.RD_INT) - kw = EclKW("REGIONS", 10, EclDataType.ECL_INT) + kw = ResdataKW("REGIONS", 10, ResdataDataType.RD_INT) with self.assertRaises(ValueError): kw.name = "LONGLONGNAME" def test_abs(self): - for ecl_type in [ - EclDataType.ECL_CHAR, - EclDataType.ECL_BOOL, - EclDataType.ECL_STRING(32), + for rd_type in [ + ResdataDataType.RD_CHAR, + ResdataDataType.RD_BOOL, + ResdataDataType.RD_STRING(32), ]: - kw = EclKW("NAME", 10, ecl_type) + kw = ResdataKW("NAME", 10, rd_type) with self.assertRaises(TypeError): abs_kw = abs(kw) - kw = EclKW("NAME", 10, EclDataType.ECL_INT) + kw = ResdataKW("NAME", 10, ResdataDataType.RD_INT) for i in range(len(kw)): kw[i] = -i @@ -232,44 +236,44 @@ def test_abs(self): self.assertEqual(abs_kw[i], i) def test_fmt(self): - kw1 = EclKW("NAME1", 100, EclDataType.ECL_INT) - kw2 = EclKW("NAME2", 100, EclDataType.ECL_INT) + kw1 = ResdataKW("NAME1", 100, ResdataDataType.RD_INT) + kw2 = ResdataKW("NAME2", 100, ResdataDataType.RD_INT) for i in range(len(kw1)): kw1[i] = i + 1 kw2[i] = len(kw1) - kw1[i] - with TestAreaContext("ecl_kw/fmt") as ta: + with TestAreaContext("rd_kw/fmt") as ta: with openFortIO("TEST.FINIT", FortIO.WRITE_MODE, fmt_file=True) as f: kw1.fwrite(f) kw2.fwrite(f) with openFortIO("TEST.FINIT", fmt_file=True) as f: - kw1b = EclKW.fread(f) - kw2b = EclKW.fread(f) + kw1b = ResdataKW.fread(f) + kw2b = ResdataKW.fread(f) self.assertTrue(kw1 == kw1b) self.assertTrue(kw2 == kw2b) - f = EclFile("TEST.FINIT") + f = ResdataFile("TEST.FINIT") self.assertTrue(kw1 == f[0]) self.assertTrue(kw2 == f[1]) def test_first_different(self): - kw1 = EclKW("NAME1", 100, EclDataType.ECL_INT) - kw2 = EclKW("NAME2", 100, EclDataType.ECL_INT) - kw3 = EclKW("NAME2", 200, EclDataType.ECL_INT) - kw4 = EclKW("NAME2", 100, EclDataType.ECL_FLOAT) - kw5 = EclKW("NAME2", 100, EclDataType.ECL_FLOAT) + kw1 = ResdataKW("NAME1", 100, ResdataDataType.RD_INT) + kw2 = ResdataKW("NAME2", 100, ResdataDataType.RD_INT) + kw3 = ResdataKW("NAME2", 200, ResdataDataType.RD_INT) + kw4 = ResdataKW("NAME2", 100, ResdataDataType.RD_FLOAT) + kw5 = ResdataKW("NAME2", 100, ResdataDataType.RD_FLOAT) with self.assertRaises(IndexError): - EclKW.firstDifferent(kw1, kw2, offset=100) + ResdataKW.firstDifferent(kw1, kw2, offset=100) with self.assertRaises(ValueError): - EclKW.firstDifferent(kw1, kw3) + ResdataKW.firstDifferent(kw1, kw3) with self.assertRaises(TypeError): - EclKW.firstDifferent(kw1, kw4) + ResdataKW.firstDifferent(kw1, kw4) with self.assertRaises(IndexError): kw1.firstDifferent(kw2, offset=100) @@ -302,8 +306,8 @@ def test_first_different(self): self.assertEqual(kw4.firstDifferent(kw5, epsilon=0.0000001), 10) def test_numeric_equal(self): - kw1 = EclKW("Name1", 10, EclDataType.ECL_DOUBLE) - kw2 = EclKW("Name1", 10, EclDataType.ECL_DOUBLE) + kw1 = ResdataKW("Name1", 10, ResdataDataType.RD_DOUBLE) + kw2 = ResdataKW("Name1", 10, ResdataDataType.RD_DOUBLE) shift = 0.0001 value = 1000 @@ -336,10 +340,10 @@ def test_numeric_equal(self): ) def test_mul(self): - kw1 = EclKW("Name1", 10, EclDataType.ECL_INT) + kw1 = ResdataKW("Name1", 10, ResdataDataType.RD_INT) kw1.assign(10) - kw2 = EclKW("Name1", 10, EclDataType.ECL_INT) + kw2 = ResdataKW("Name1", 10, ResdataDataType.RD_INT) kw2.assign(2) kw3 = kw1 * kw2 @@ -353,7 +357,7 @@ def test_mul(self): self.assertEqual(v, 12) def test_numpy(self): - kw1 = EclKW("DOUBLE", 10, EclDataType.ECL_DOUBLE) + kw1 = ResdataKW("DOUBLE", 10, ResdataDataType.RD_DOUBLE) view = kw1.numpyView() copy = kw1.numpyCopy() @@ -365,18 +369,18 @@ def test_numpy(self): self.assertTrue(view[0] == kw1[0]) self.assertTrue(copy[0] == kw1[0] - 1) - for ecl_type in [ - EclDataType.ECL_CHAR, - EclDataType.ECL_BOOL, - EclDataType.ECL_STRING(19), + for rd_type in [ + ResdataDataType.RD_CHAR, + ResdataDataType.RD_BOOL, + ResdataDataType.RD_STRING(19), ]: - kw2 = EclKW("TEST_KW", 10, ecl_type) + kw2 = ResdataKW("TEST_KW", 10, rd_type) with self.assertRaises(ValueError): kw2.numpyView() def test_slice(self): N = 100 - kw = EclKW("KW", N, EclDataType.ECL_INT) + kw = ResdataKW("KW", N, ResdataDataType.RD_INT) for i in range(len(kw)): kw[i] = i @@ -392,7 +396,7 @@ def test_slice(self): def test_resize(self): N = 4 - kw = EclKW("KW", N, EclDataType.ECL_INT) + kw = ResdataKW("KW", N, ResdataDataType.RD_INT) for i in range(N): kw[i] = i @@ -407,12 +411,12 @@ def test_resize(self): self.assertEqual(kw[i], i) def test_typename(self): - kw = EclKW("KW", 100, EclDataType.ECL_INT) + kw = ResdataKW("KW", 100, ResdataDataType.RD_INT) self.assertEqual(kw.typeName(), "INTE") def test_string_alloc(self): - kw = EclKW("KW", 10, EclDataType.ECL_STRING(30)) + kw = ResdataKW("KW", 10, ResdataDataType.RD_STRING(30)) for i in range(10): kw[i] = str(i) * 30 @@ -423,64 +427,64 @@ def test_string_alloc(self): def test_string_write_read_unformatted(self): for str_len in range(1000): with TestAreaContext("my_space"): - kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len)) + kw = ResdataKW("TEST_KW", 10, ResdataDataType.RD_STRING(str_len)) for i in range(10): kw[i] = str(i) * str_len - file_name = "ecl_kw_test" + file_name = "rd_kw_test" with openFortIO(file_name, mode=FortIO.WRITE_MODE) as fortio: kw.fwrite(fortio) with openFortIO(file_name) as fortio: - loaded_kw = EclKW.fread(fortio) + loaded_kw = ResdataKW.fread(fortio) self.assertEqual(kw, loaded_kw) def test_string_write_read_formatted(self): for str_len in range(1000): with TestAreaContext("my_space"): - kw = EclKW("TEST_KW", 10, EclDataType.ECL_STRING(str_len)) + kw = ResdataKW("TEST_KW", 10, ResdataDataType.RD_STRING(str_len)) for i in range(10): kw[i] = str(i) * str_len - file_name = "ecl_kw_test" + file_name = "rd_kw_test" with openFortIO( file_name, mode=FortIO.WRITE_MODE, fmt_file=True ) as fortio: kw.fwrite(fortio) with openFortIO(file_name, fmt_file=True) as fortio: - loaded_kw = EclKW.fread(fortio) + loaded_kw = ResdataKW.fread(fortio) self.assertEqual(kw, loaded_kw) def test_string_padding(self): - kw = EclKW("TEST_KW", 1, EclDataType.ECL_STRING(4)) + kw = ResdataKW("TEST_KW", 1, ResdataDataType.RD_STRING(4)) kw[0] = "AB" self.assertEqual(kw[0], "AB ") - kw = EclKW("TEST_KW", 1, EclDataType.ECL_CHAR) + kw = ResdataKW("TEST_KW", 1, ResdataDataType.RD_CHAR) kw[0] = "ABCD" self.assertEqual(kw[0], "ABCD ") def test_add_squared(self): - kw1 = EclKW("TEST_KW", 3, EclDataType.ECL_STRING(4)) - kw2 = EclKW("TEST_KW", 3, EclDataType.ECL_STRING(4)) + kw1 = ResdataKW("TEST_KW", 3, ResdataDataType.RD_STRING(4)) + kw2 = ResdataKW("TEST_KW", 3, ResdataDataType.RD_STRING(4)) with self.assertRaises(TypeError): kw1.add_squared(kw2) - kw1 = EclKW("T1", 10, EclDataType.ECL_INT) - kw2 = EclKW("T2", 11, EclDataType.ECL_INT) + kw1 = ResdataKW("T1", 10, ResdataDataType.RD_INT) + kw2 = ResdataKW("T2", 11, ResdataDataType.RD_INT) with self.assertRaises(ValueError): kw1.add_squared(kw2) - kw2 = EclKW("T", 10, EclDataType.ECL_FLOAT) + kw2 = ResdataKW("T", 10, ResdataDataType.RD_FLOAT) with self.assertRaises(ValueError): kw1.add_squared(kw2) - kw2 = EclKW("T2", 10, EclDataType.ECL_INT) + kw2 = ResdataKW("T2", 10, ResdataDataType.RD_INT) kw2.assign(2) kw1.add_squared(kw2) @@ -488,15 +492,15 @@ def test_add_squared(self): self.assertEqual(elm, 4) def test_scatter_copy(self): - source = EclKW("SOURCE", 4, EclDataType.ECL_INT) + source = ResdataKW("SOURCE", 4, ResdataDataType.RD_INT) with self.assertRaises(TypeError): copy = source.scatter_copy([1, 1, 1, 1]) - actnum = EclKW("ACTNUM", 6, EclDataType.ECL_FLOAT) + actnum = ResdataKW("ACTNUM", 6, ResdataDataType.RD_FLOAT) with self.assertRaises(ValueError): copy = source.scatter_copy(actnum) - actnum = EclKW("ACTNUM", 8, EclDataType.ECL_INT) + actnum = ResdataKW("ACTNUM", 8, ResdataDataType.RD_INT) actnum[0] = 1 actnum[1] = 1 with self.assertRaises(ValueError): @@ -518,16 +522,16 @@ def test_scatter_copy(self): self.assertEqual(copy[2 * i + 1], i + 1) def test_safe_div(self): - kw1 = EclKW("SOURCE", 10, EclDataType.ECL_INT) - kw2 = EclKW("XXX", 11, EclDataType.ECL_INT) + kw1 = ResdataKW("SOURCE", 10, ResdataDataType.RD_INT) + kw2 = ResdataKW("XXX", 11, ResdataDataType.RD_INT) with self.assertRaises(ValueError): kw1.safe_div(kw2) - kw1 = EclKW("SOURCE", 2, EclDataType.ECL_FLOAT) + kw1 = ResdataKW("SOURCE", 2, ResdataDataType.RD_FLOAT) kw1.assign(10) - kw2 = EclKW("DIV", 2, EclDataType.ECL_INT) + kw2 = ResdataKW("DIV", 2, ResdataDataType.RD_INT) kw2[0] = 0 kw2[1] = 2 @@ -541,9 +545,9 @@ def test_fmu_stat_workflow(self): active_size = 50 with TestAreaContext("FMU_FILES"): for i in range(N): - permx = EclKW("PERMX", active_size, EclDataType.ECL_FLOAT) - poro = EclKW("PORO", active_size, EclDataType.ECL_FLOAT) - porv = EclKW("PORV", global_size, EclDataType.ECL_FLOAT) + permx = ResdataKW("PERMX", active_size, ResdataDataType.RD_FLOAT) + poro = ResdataKW("PORO", active_size, ResdataDataType.RD_FLOAT) + porv = ResdataKW("PORV", global_size, ResdataDataType.RD_FLOAT) porv.assign(0) for g in random.sample(range(global_size), active_size): @@ -557,14 +561,14 @@ def test_fmu_stat_workflow(self): poro.fwrite(f) porv.fwrite(f) - mean_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT) - std_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT) - mean_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT) - std_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT) + mean_permx = ResdataKW("PERMX", global_size, ResdataDataType.RD_FLOAT) + std_permx = ResdataKW("PERMX", global_size, ResdataDataType.RD_FLOAT) + mean_poro = ResdataKW("PORO", global_size, ResdataDataType.RD_FLOAT) + std_poro = ResdataKW("PORO", global_size, ResdataDataType.RD_FLOAT) - count = EclKW("COUNT", global_size, EclDataType.ECL_INT) + count = ResdataKW("COUNT", global_size, ResdataDataType.RD_INT) for i in range(N): - f = EclFile("TEST%d.INIT" % i) + f = ResdataFile("TEST%d.INIT" % i) porv = f["PORV"][0] permx = f["PERMX"][0] diff --git a/python/tests/rd_tests/test_rd_kw_equinor.py b/python/tests/rd_tests/test_rd_kw_equinor.py index 1c3d0f276c..c12a6ed03a 100755 --- a/python/tests/rd_tests/test_rd_kw_equinor.py +++ b/python/tests/rd_tests/test_rd_kw_equinor.py @@ -1,28 +1,28 @@ #!/usr/bin/env python import os import random -from ecl import EclDataType, EclFileFlagEnum -from ecl.eclfile import EclKW, EclFile, FortIO +from resdata import ResdataDataType, ResdataFileFlagEnum +from resdata.eclfile import ResdataKW, ResdataFile, FortIO -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test def copy_long(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + src = ResdataKW("NAME", 100, ResdataDataType.RD_FLOAT) copy = src.sub_copy(0, 2000) def copy_offset(): - src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) + src = ResdataKW("NAME", 100, ResdataDataType.RD_FLOAT) copy = src.sub_copy(200, 100) @equinor_test() -class KWTest(EclTest): +class KWTest(ResdataTest): def test_fortio_size(self): unrst_file_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") - unrst_file = EclFile(unrst_file_path) + unrst_file = ResdataFile(unrst_file_path) size = 0 for kw in unrst_file: size += kw.fortIOSize() @@ -32,7 +32,7 @@ def test_fortio_size(self): def test_sub_copy(self): unrst_file_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") - unrst_file = EclFile(unrst_file_path) + unrst_file = ResdataFile(unrst_file_path) swat = unrst_file["SWAT"][0] swat1 = swat.sub_copy(0, -1) @@ -54,12 +54,12 @@ def test_sub_copy(self): self.assertRaises(IndexError, copy_offset) def test_equal(self): - kw1 = EclKW("TEST", 3, EclDataType.ECL_CHAR) + kw1 = ResdataKW("TEST", 3, ResdataDataType.RD_CHAR) kw1[0] = "Test1" kw1[1] = "Test13" kw1[2] = "Test15" - kw2 = EclKW("TEST", 3, EclDataType.ECL_CHAR) + kw2 = ResdataKW("TEST", 3, ResdataDataType.RD_CHAR) kw2[0] = "Test1" kw2[1] = "Test13" kw2[2] = "Test15" @@ -72,7 +72,7 @@ def test_equal(self): self.assertFalse(kw1.equal_numeric(kw2)) unrst_file_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") - unrst_file = EclFile(unrst_file_path) + unrst_file = ResdataFile(unrst_file_path) kw1 = unrst_file["PRESSURE"][0] kw2 = kw1.deep_copy() diff --git a/python/tests/rd_tests/test_rd_restart_file.py b/python/tests/rd_tests/test_rd_restart_file.py index 4799a6a506..73cfd3bfae 100644 --- a/python/tests/rd_tests/test_rd_restart_file.py +++ b/python/tests/rd_tests/test_rd_restart_file.py @@ -1,13 +1,19 @@ import datetime -from tests import EclTest, equinor_test -from ecl import EclFileFlagEnum -from ecl.eclfile import Ecl3DKW, EclKW, EclRestartFile, EclFile, FortIO -from ecl.grid import EclGrid +from tests import ResdataTest, equinor_test +from resdata import ResdataFileFlagEnum +from resdata.eclfile import ( + Resdata3DKW, + ResdataKW, + ResdataRestartFile, + ResdataFile, + FortIO, +) +from resdata.grid import ResdataGrid @equinor_test() -class RestartFileTest(EclTest): +class RestartFileTest(ResdataTest): def setUp(self): self.grid_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") self.unrst_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") @@ -16,29 +22,29 @@ def setUp(self): self.xrst_file20 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0020") def test_load(self): - g = EclGrid(self.grid_file) - f = EclRestartFile(g, self.unrst_file) + g = ResdataGrid(self.grid_file) + f = ResdataRestartFile(g, self.unrst_file) head = f["INTEHEAD"][0] - self.assertTrue(isinstance(head, EclKW)) + self.assertTrue(isinstance(head, ResdataKW)) swat = f["SWAT"][0] - self.assertTrue(isinstance(swat, Ecl3DKW)) + self.assertTrue(isinstance(swat, Resdata3DKW)) pressure = f["PRESSURE"][0] - self.assertTrue(isinstance(pressure, Ecl3DKW)) + self.assertTrue(isinstance(pressure, Resdata3DKW)) def test_type(self): - g = EclGrid(self.grid_file) + g = ResdataGrid(self.grid_file) with self.assertRaises(ValueError): - f = EclRestartFile(g, "NOT_A_RESTART_FILE") + f = ResdataRestartFile(g, "NOT_A_RESTART_FILE") def test_unified(self): - g = EclGrid(self.grid_file) - f_unrst = EclRestartFile(g, self.unrst_file) - f_x0 = EclRestartFile(g, self.xrst_file0) - f_x10 = EclRestartFile(g, self.xrst_file10) - f_x20 = EclRestartFile(g, self.xrst_file20) + g = ResdataGrid(self.grid_file) + f_unrst = ResdataRestartFile(g, self.unrst_file) + f_x0 = ResdataRestartFile(g, self.xrst_file0) + f_x10 = ResdataRestartFile(g, self.xrst_file10) + f_x20 = ResdataRestartFile(g, self.xrst_file20) self.assertTrue(f_unrst.unified()) self.assertFalse(f_x0.unified()) diff --git a/python/tests/rd_tests/test_rd_sum.py b/python/tests/rd_tests/test_rd_sum.py index cfd1495dbf..34ed9b7d5e 100644 --- a/python/tests/rd_tests/test_rd_sum.py +++ b/python/tests/rd_tests/test_rd_sum.py @@ -7,17 +7,17 @@ from cwrap import CFILE from cwrap import Prototype, load, open as copen -from ecl.eclfile import EclFile, FortIO, openFortIO, openEclFile, EclKW -from ecl.summary import EclSum, EclSumKeyWordVector -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata.eclfile import ResdataFile, FortIO, openFortIO, openResdataFile, ResdataKW +from resdata.summary import RdSum, RdSumKeyWordVector +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test def test_write_repr(): - """repr(EclSum) used to segfault when there is only a startdate""" - writer = EclSum.writer("TEST", datetime.date(2000, 2, 3), 10, 10, 10) + """repr(RdSum) used to segfault when there is only a startdate""" + writer = RdSum.writer("TEST", datetime.date(2000, 2, 3), 10, 10, 10) assert repr(writer).startswith( - 'EclSum(name="writer", time=[2000-02-03 00:00:00, 2000-02-03 00:00:00], keys=0) at 0x' + 'RdSum(name="writer", time=[2000-02-03 00:00:00, 2000-02-03 00:00:00], keys=0) at 0x' ) @@ -25,7 +25,7 @@ def test_that_year2263_through_pandas_works(): """Date 2262-04-11 is the upper limit for nanosecond 64-bit timestamps, which is what pandas<2 prefers. """ - eclsum = EclSum.from_pandas( + eclsum = RdSum.from_pandas( "TESTCASE", pd.DataFrame( [ @@ -44,42 +44,42 @@ def test_that_year2263_through_pandas_works(): @equinor_test() -class EclSumTest(EclTest): +class RdSumTest(ResdataTest): def setUp(self): self.test_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - self.ecl_sum = EclSum(self.test_file) + self.rd_sum = RdSum(self.test_file) def test_time_range_year(self): - real_range = self.ecl_sum.timeRange(interval="1y", extend_end=False) - extended_range = self.ecl_sum.timeRange(interval="1y", extend_end=True) + real_range = self.rd_sum.timeRange(interval="1y", extend_end=False) + extended_range = self.rd_sum.timeRange(interval="1y", extend_end=True) assert real_range[-1] < extended_range[-1] def test_time_range_day(self): - real_range = self.ecl_sum.timeRange(interval="1d", extend_end=False) - extended_range = self.ecl_sum.timeRange(interval="1d", extend_end=True) + real_range = self.rd_sum.timeRange(interval="1d", extend_end=False) + extended_range = self.rd_sum.timeRange(interval="1d", extend_end=True) assert real_range[-1] == extended_range[-1] def test_time_range_month(self): - real_range = self.ecl_sum.timeRange(interval="1m", extend_end=False) - extended_range = self.ecl_sum.timeRange(interval="1m", extend_end=True) + real_range = self.rd_sum.timeRange(interval="1m", extend_end=False) + extended_range = self.rd_sum.timeRange(interval="1m", extend_end=True) assert real_range[-1] < extended_range[-1] def test_dump_csv_line(self): - ecl_sum_vector = EclSumKeyWordVector(self.ecl_sum) - ecl_sum_vector.addKeywords("F*") + rd_sum_vector = RdSumKeyWordVector(self.rd_sum) + rd_sum_vector.addKeywords("F*") with self.assertRaises(KeyError): - ecl_sum_vector.addKeyword("MISSING") + rd_sum_vector.addKeyword("MISSING") dtime = datetime.datetime(2002, 1, 1, 0, 0, 0) - with TestAreaContext("EclSum/csv_dump"): + with TestAreaContext("RdSum/csv_dump"): test_file_name = self.createTestPath("dump.csv") outputH = copen(test_file_name, "w") - self.ecl_sum.dumpCSVLine(dtime, ecl_sum_vector, outputH) + self.rd_sum.dumpCSVLine(dtime, rd_sum_vector, outputH) assert os.path.isfile(test_file_name) def test_truncated_smspec(self): - with TestAreaContext("EclSum/truncated_smspec") as ta: + with TestAreaContext("RdSum/truncated_smspec") as ta: ta.copy_file(self.test_file) ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) @@ -88,10 +88,10 @@ def test_truncated_smspec(self): f.truncate(file_size / 2) with self.assertRaises(IOError): - EclSum("ECLIPSE") + RdSum("ECLIPSE") def test_truncated_data(self): - with TestAreaContext("EclSum/truncated_data") as ta: + with TestAreaContext("RdSum/truncated_data") as ta: ta.copy_file(self.test_file) ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) @@ -100,17 +100,17 @@ def test_truncated_data(self): f.truncate(file_size / 2) with self.assertRaises(IOError): - EclSum("ECLIPSE") + RdSum("ECLIPSE") def test_missing_smspec_keyword(self): - with TestAreaContext("EclSum/truncated_data") as ta: + with TestAreaContext("RdSum/truncated_data") as ta: ta.copy_file(self.test_file) ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) - with openEclFile("ECLIPSE.SMSPEC") as f: + with openResdataFile("ECLIPSE.SMSPEC") as f: kw_list = [] for kw in f: - kw_list.append(EclKW.copy(kw)) + kw_list.append(ResdataKW.copy(kw)) with openFortIO("ECLIPSE.SMSPEC", mode=FortIO.WRITE_MODE) as f: for kw in kw_list: @@ -119,17 +119,17 @@ def test_missing_smspec_keyword(self): kw.fwrite(f) with self.assertRaises(IOError): - EclSum("ECLIPSE") + RdSum("ECLIPSE") def test_missing_unsmry_keyword(self): - with TestAreaContext("EclSum/truncated_data") as ta: + with TestAreaContext("RdSum/truncated_data") as ta: ta.copy_file(self.test_file) ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) - with openEclFile("ECLIPSE.UNSMRY") as f: + with openResdataFile("ECLIPSE.UNSMRY") as f: kw_list = [] for kw in f: - kw_list.append(EclKW.copy(kw)) + kw_list.append(ResdataKW.copy(kw)) with openFortIO("ECLIPSE.UNSMRY", mode=FortIO.WRITE_MODE) as f: c = 0 @@ -141,16 +141,16 @@ def test_missing_unsmry_keyword(self): kw.fwrite(f) with self.assertRaises(IOError): - EclSum("ECLIPSE") + RdSum("ECLIPSE") def test_labscale(self): case = self.createTestPath("Equinor/ECLIPSE/LabScale/HDMODEL") - sum = EclSum(case, lazy_load=True) + sum = RdSum(case, lazy_load=True) self.assertEqual(sum.getStartTime(), datetime.datetime(2013, 1, 1, 0, 0, 0)) self.assertEqual(sum.getEndTime(), datetime.datetime(2013, 1, 1, 19, 30, 0)) self.assertFloatEqual(sum.getSimulationLength(), 19.50) - sum = EclSum(case, lazy_load=False) + sum = RdSum(case, lazy_load=False) self.assertEqual(sum.getStartTime(), datetime.datetime(2013, 1, 1, 0, 0, 0)) self.assertEqual(sum.getEndTime(), datetime.datetime(2013, 1, 1, 19, 30, 0)) self.assertFloatEqual(sum.getSimulationLength(), 19.50) diff --git a/python/tests/rd_tests/test_rd_sum_vector.py b/python/tests/rd_tests/test_rd_sum_vector.py index 1317d7eb2a..028b1aee4f 100644 --- a/python/tests/rd_tests/test_rd_sum_vector.py +++ b/python/tests/rd_tests/test_rd_sum_vector.py @@ -6,32 +6,32 @@ import warnings -from ecl.summary import EclSumVector, EclSum -from tests import EclTest, equinor_test +from resdata.summary import RdSumVector, RdSum +from tests import ResdataTest, equinor_test @equinor_test() -class EclSumVectorTest(EclTest): +class RdSumVectorTest(ResdataTest): def setUp(self): self.test_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - self.ecl_sum = EclSum(self.test_file) + self.rd_sum = RdSum(self.test_file) def test_reportOnly_warns(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - vector = EclSumVector(self.ecl_sum, "FOPT", True) + vector = RdSumVector(self.rd_sum, "FOPT", True) self.assertEqual(len(w), 1) assert issubclass(w[-1].category, DeprecationWarning) def test_basic(self): - self.assertEqual(512, len(self.ecl_sum.keys())) - pfx = "EclSum(name" - self.assertEqual(pfx, repr(self.ecl_sum)[: len(pfx)]) - it = iter(self.ecl_sum) - # t = self.ecl_sum[it.next()] # EclSumVector - t = self.ecl_sum[next(it)] # EclSumVector + self.assertEqual(512, len(self.rd_sum.keys())) + pfx = "RdSum(name" + self.assertEqual(pfx, repr(self.rd_sum)[: len(pfx)]) + it = iter(self.rd_sum) + # t = self.rd_sum[it.next()] # RdSumVector + t = self.rd_sum[next(it)] # RdSumVector self.assertEqual(63, len(t)) self.assertEqual("BARSA", t.unit) - pfx = "EclSumVector(key = " + pfx = "RdSumVector(key = " self.assertEqual(pfx, repr(t)[: len(pfx)]) diff --git a/python/tests/rd_tests/test_rd_type.py b/python/tests/rd_tests/test_rd_type.py index 5cf4b4ea23..fc14c120d1 100644 --- a/python/tests/rd_tests/test_rd_type.py +++ b/python/tests/rd_tests/test_rd_type.py @@ -1,27 +1,27 @@ -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.test import TestAreaContext +from tests import ResdataTest -from ecl import EclDataType, EclTypeEnum +from resdata import ResdataDataType, ResdataTypeEnum def get_const_size_types(): - return EclTypeEnum.enums()[:-1:] + return ResdataTypeEnum.enums()[:-1:] -class EclDataTypeTest(EclTest): +class ResdataDataTypeTest(ResdataTest): # All of the below should list their elements in the same order as - # EclTypeEnum! + # ResdataTypeEnum! # [char, float, double, int, bool, mess] CONST_SIZES = [8, 4, 8, 4, 4, 0] CONST_VERIFIERS = [ - EclDataType.is_char, - EclDataType.is_float, - EclDataType.is_double, - EclDataType.is_int, - EclDataType.is_bool, - EclDataType.is_mess, + ResdataDataType.is_char, + ResdataDataType.is_float, + ResdataDataType.is_double, + ResdataDataType.is_int, + ResdataDataType.is_bool, + ResdataDataType.is_mess, ] CONST_NAMES = ["CHAR", "REAL", "DOUB", "INTE", "LOGI", "MESS"] @@ -30,7 +30,9 @@ class EclDataTypeTest(EclTest): STRING_SIZES = [0, 10, 20, 42, 999] - TYPES = get_const_size_types() + len(STRING_SIZES) * [EclTypeEnum.ECL_STRING_TYPE] + TYPES = get_const_size_types() + len(STRING_SIZES) * [ + ResdataTypeEnum.RD_STRING_TYPE + ] SIZES = CONST_SIZES + STRING_SIZES @@ -38,37 +40,37 @@ class EclDataTypeTest(EclTest): def test_alloc_from_type(self): types, sizes = get_const_size_types(), self.CONST_SIZES - for ecl_type, element_size in zip(types, sizes): - data_type = EclDataType(ecl_type) - self.assertEqual(ecl_type, data_type.type) + for rd_type, element_size in zip(types, sizes): + data_type = ResdataDataType(rd_type) + self.assertEqual(rd_type, data_type.type) self.assertEqual(element_size, data_type.element_size) def test_invalid_string_alloc(self): with self.assertRaises(ValueError): - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE) + data_type = ResdataDataType(ResdataTypeEnum.RD_STRING_TYPE) with self.assertRaises(ValueError): - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, -1) + data_type = ResdataDataType(ResdataTypeEnum.RD_STRING_TYPE, -1) with self.assertRaises(ValueError): - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, 1000) + data_type = ResdataDataType(ResdataTypeEnum.RD_STRING_TYPE, 1000) def test_alloc(self): - for ecl_type, element_size in zip(self.TYPES, self.SIZES): - data_type = EclDataType(ecl_type, element_size) - self.assertEqual(ecl_type, data_type.type) + for rd_type, element_size in zip(self.TYPES, self.SIZES): + data_type = ResdataDataType(rd_type, element_size) + self.assertEqual(rd_type, data_type.type) self.assertEqual(element_size, data_type.element_size) def test_type_verifiers(self): test_base = zip(self.TYPES, self.SIZES, self.CONST_VERIFIERS) - for ecl_type, elem_size, verifier in test_base: - data_type = EclDataType(ecl_type, elem_size) + for rd_type, elem_size, verifier in test_base: + data_type = ResdataDataType(rd_type, elem_size) self.assertTrue(verifier(data_type)) def test_get_type_name(self): test_base = zip(self.TYPES, self.SIZES, self.NAMES) - for ecl_type, elem_size, type_name in test_base: - data_type = EclDataType(ecl_type, elem_size) + for rd_type, elem_size, type_name in test_base: + data_type = ResdataDataType(rd_type, elem_size) self.assertEqual(type_name, data_type.type_name) def test_initialization_validation(self): @@ -82,58 +84,58 @@ def test_initialization_validation(self): for inv_arg in invalid_args: with self.assertRaises(ValueError): - EclDataType(inv_arg[0], inv_arg[1], inv_arg[2]) + ResdataDataType(inv_arg[0], inv_arg[1], inv_arg[2]) def test_create_from_type_name(self): test_base = zip(self.TYPES, self.SIZES, self.NAMES) - for ecl_type, elem_size, type_name in test_base: - data_type = EclDataType.create_from_type_name(type_name) - self.assertEqual(ecl_type, data_type.type) + for rd_type, elem_size, type_name in test_base: + data_type = ResdataDataType.create_from_type_name(type_name) + self.assertEqual(rd_type, data_type.type) self.assertEqual(elem_size, data_type.element_size) self.assertEqual(type_name, data_type.type_name) def test_is_numeric(self): numeric_types = [ - EclTypeEnum.ECL_INT_TYPE, - EclTypeEnum.ECL_FLOAT_TYPE, - EclTypeEnum.ECL_DOUBLE_TYPE, + ResdataTypeEnum.RD_INT_TYPE, + ResdataTypeEnum.RD_FLOAT_TYPE, + ResdataTypeEnum.RD_DOUBLE_TYPE, ] - for ecl_type in numeric_types: - self.assertTrue(EclDataType(ecl_type).is_numeric()) + for rd_type in numeric_types: + self.assertTrue(ResdataDataType(rd_type).is_numeric()) - for ecl_type in set(get_const_size_types()) - set(numeric_types): - self.assertFalse(EclDataType(ecl_type).is_numeric()) + for rd_type in set(get_const_size_types()) - set(numeric_types): + self.assertFalse(ResdataDataType(rd_type).is_numeric()) for elem_size in self.STRING_SIZES: - data_type = EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size) + data_type = ResdataDataType(ResdataTypeEnum.RD_STRING_TYPE, elem_size) self.assertFalse(data_type.is_numeric()) def test_equals(self): test_base = zip(self.TYPES, self.SIZES) - for ecl_type, elem_size in test_base: - a = EclDataType(ecl_type, elem_size) - b = EclDataType(ecl_type, elem_size) + for rd_type, elem_size in test_base: + a = ResdataDataType(rd_type, elem_size) + b = ResdataDataType(rd_type, elem_size) self.assertTrue(a.is_equal(b)) self.assertEqual(a, b) - for otype, osize in set(test_base) - set([(ecl_type, elem_size)]): - self.assertFalse(a.is_equal(EclDataType(otype, osize))) - self.assertNotEqual(a, EclDataType(otype, osize)) + for otype, osize in set(test_base) - set([(rd_type, elem_size)]): + self.assertFalse(a.is_equal(ResdataDataType(otype, osize))) + self.assertNotEqual(a, ResdataDataType(otype, osize)) def test_hash(self): all_types = set() test_base = list(zip(self.TYPES, self.SIZES)) - for index, (ecl_type, elem_size) in enumerate(test_base): - all_types.add(EclDataType(ecl_type, elem_size)) + for index, (rd_type, elem_size) in enumerate(test_base): + all_types.add(ResdataDataType(rd_type, elem_size)) self.assertEqual(index + 1, len(all_types)) - for index, (ecl_type, elem_size) in enumerate(test_base): - all_types.add(EclDataType(ecl_type, elem_size)) + for index, (rd_type, elem_size) in enumerate(test_base): + all_types.add(ResdataDataType(rd_type, elem_size)) - for index, ecl_type in enumerate(get_const_size_types()): - all_types.add(EclDataType(ecl_type)) + for index, rd_type in enumerate(get_const_size_types()): + all_types.add(ResdataDataType(rd_type)) self.assertEqual(len(test_base), len(all_types)) diff --git a/python/tests/rd_tests/test_rd_util.py b/python/tests/rd_tests/test_rd_util.py index 7baf9226bf..383f482cae 100644 --- a/python/tests/rd_tests/test_rd_util.py +++ b/python/tests/rd_tests/test_rd_util.py @@ -1,27 +1,35 @@ -from ecl import EclTypeEnum, EclFileEnum, EclPhaseEnum, EclUnitTypeEnum, EclUtil -from ecl.grid import EclGrid -from tests import EclTest +from resdata import ( + ResdataTypeEnum, + ResdataFileEnum, + ResdataPhaseEnum, + ResdataUnitTypeEnum, + ResdataUtil, +) +from resdata.grid import ResdataGrid +from tests import ResdataTest -class EclUtilTest(EclTest): +class ResdataUtilTest(ResdataTest): def test_enums(self): - source_file_path = "lib/include/ert/ecl/ecl_util.hpp" - self.assertEnumIsFullyDefined(EclFileEnum, "ecl_file_enum", source_file_path) - self.assertEnumIsFullyDefined(EclPhaseEnum, "ecl_phase_enum", source_file_path) + source_file_path = "lib/include/resdata/rd_util.hpp" + self.assertEnumIsFullyDefined(ResdataFileEnum, "rd_file_enum", source_file_path) self.assertEnumIsFullyDefined( - EclUnitTypeEnum, "ert_ecl_unit_enum", source_file_path + ResdataPhaseEnum, "rd_phase_enum", source_file_path + ) + self.assertEnumIsFullyDefined( + ResdataUnitTypeEnum, "ert_rd_unit_enum", source_file_path ) - source_file_path = "lib/include/ert/ecl/ecl_type.hpp" - self.assertEnumIsFullyDefined(EclTypeEnum, "ecl_type_enum", source_file_path) + source_file_path = "lib/include/resdata/rd_type.hpp" + self.assertEnumIsFullyDefined(ResdataTypeEnum, "rd_type_enum", source_file_path) def test_file_type(self): - file_type, fmt, report = EclUtil.inspectExtension("CASE.X0078") - self.assertEqual(file_type, EclFileEnum.ECL_RESTART_FILE) + file_type, fmt, report = ResdataUtil.inspectExtension("CASE.X0078") + self.assertEqual(file_type, ResdataFileEnum.RD_RESTART_FILE) def test_file_report_nr(self): - report_nr = EclUtil.reportStep("CASE.X0080") + report_nr = ResdataUtil.reportStep("CASE.X0080") self.assertEqual(report_nr, 80) with self.assertRaises(ValueError): - EclUtil.reportStep("CASE.EGRID") + ResdataUtil.reportStep("CASE.EGRID") diff --git a/python/tests/rd_tests/test_region.py b/python/tests/rd_tests/test_region.py index f6ef6af1e5..1c6d93ccfb 100644 --- a/python/tests/rd_tests/test_region.py +++ b/python/tests/rd_tests/test_region.py @@ -1,19 +1,19 @@ -from ecl import EclDataType -from ecl.eclfile import EclKW -from ecl.grid import EclGrid, EclRegion -from ecl.grid.faults import Layer -from ecl.util.util import IntVector -from tests import EclTest +from resdata import ResdataDataType +from resdata.eclfile import ResdataKW +from resdata.grid import ResdataGrid, ResdataRegion +from resdata.grid.faults import Layer +from resdata.util.util import IntVector +from tests import ResdataTest -class RegionTest(EclTest): +class RegionTest(ResdataTest): def test_equal(self): - grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1)) - kw_int = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT) - kw_float = EclKW("FLOAT", grid.getGlobalSize(), EclDataType.ECL_FLOAT) + grid = ResdataGrid.createRectangular((10, 10, 1), (1, 1, 1)) + kw_int = ResdataKW("INT", grid.getGlobalSize(), ResdataDataType.RD_INT) + kw_float = ResdataKW("FLOAT", grid.getGlobalSize(), ResdataDataType.RD_FLOAT) kw_int[0:49] = 1 - region = EclRegion(grid, False) + region = ResdataRegion(grid, False) region.select_equal(kw_int, 1) glist = region.getGlobalList() for g in glist: @@ -23,12 +23,14 @@ def test_equal(self): region.select_equal(kw_float, 1) def test_sum(self): - grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1)) - kw_mask = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT) - int_value = EclKW("INT", grid.getGlobalSize(), EclDataType.ECL_INT) - float_value = EclKW("FLOAT", grid.getGlobalSize(), EclDataType.ECL_FLOAT) - double_value = EclKW("DOUBLE", grid.getGlobalSize(), EclDataType.ECL_DOUBLE) - bool_value = EclKW("BOOL", grid.getGlobalSize(), EclDataType.ECL_BOOL) + grid = ResdataGrid.createRectangular((10, 10, 1), (1, 1, 1)) + kw_mask = ResdataKW("INT", grid.getGlobalSize(), ResdataDataType.RD_INT) + int_value = ResdataKW("INT", grid.getGlobalSize(), ResdataDataType.RD_INT) + float_value = ResdataKW("FLOAT", grid.getGlobalSize(), ResdataDataType.RD_FLOAT) + double_value = ResdataKW( + "DOUBLE", grid.getGlobalSize(), ResdataDataType.RD_DOUBLE + ) + bool_value = ResdataKW("BOOL", grid.getGlobalSize(), ResdataDataType.RD_BOOL) kw_mask[0:50] = 1 @@ -38,7 +40,7 @@ def test_sum(self): int_value[i] = i bool_value[i] = True - region = EclRegion(grid, False) + region = ResdataRegion(grid, False) region.select_equal(kw_mask, 1) self.assertEqual(int_value.sum(), 99 * 100 / 2) @@ -50,8 +52,8 @@ def test_sum(self): def test_truth_and_size(self): actnum = IntVector(initial_size=100, default_value=0) actnum[0:50] = 1 - grid = EclGrid.createRectangular((10, 10, 1), (1, 1, 1), actnum=actnum) - region = EclRegion(grid, False) + grid = ResdataGrid.createRectangular((10, 10, 1), (1, 1, 1), actnum=actnum) + region = ResdataRegion(grid, False) self.assertFalse(region) self.assertEqual(0, region.active_size()) @@ -67,7 +69,7 @@ def test_truth_and_size(self): self.assertEqual(0, region.active_size()) self.assertEqual(0, region.global_size()) - region = EclRegion(grid, False) + region = ResdataRegion(grid, False) region.select_inactive() self.assertTrue(region) self.assertEqual(0, region.active_size()) diff --git a/python/tests/rd_tests/test_region_equinor.py b/python/tests/rd_tests/test_region_equinor.py index afa9239c3b..41816d1c35 100755 --- a/python/tests/rd_tests/test_region_equinor.py +++ b/python/tests/rd_tests/test_region_equinor.py @@ -1,24 +1,24 @@ #!/usr/bin/env python -from ecl.eclfile import EclFile -from ecl.grid import EclGrid, EclRegion -from ecl.grid.faults import Layer -from tests import EclTest, equinor_test +from resdata.eclfile import ResdataFile +from resdata.grid import ResdataGrid, ResdataRegion +from resdata.grid.faults import Layer +from tests import ResdataTest, equinor_test @equinor_test() -class RegionTest(EclTest): +class RegionTest(ResdataTest): def setUp(self): case = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE") - self.grid = EclGrid(case) - self.rst_file = EclFile("%s.UNRST" % case) - self.init_file = EclFile("%s.INIT" % case) + self.grid = ResdataGrid(case) + self.rst_file = ResdataFile("%s.UNRST" % case) + self.init_file = ResdataFile("%s.INIT" % case) def test_kw_imul(self): P = self.rst_file["PRESSURE"][5] fipnum = self.init_file["FIPNUM"][0] fipnum_copy = fipnum.deep_copy() - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) reg.select_more(P, 260) fipnum.mul(-1, mask=reg) self.assertFalse(fipnum.equal(fipnum_copy)) @@ -27,8 +27,8 @@ def test_kw_imul(self): self.assertTrue(fipnum.equal(fipnum_copy)) def test_equal(self): - reg1 = EclRegion(self.grid, False) - reg2 = EclRegion(self.grid, False) + reg1 = ResdataRegion(self.grid, False) + reg2 = ResdataRegion(self.grid, False) self.assertTrue(reg1 == reg2) @@ -44,7 +44,7 @@ def test_kw_idiv(self): fipnum = self.init_file["FIPNUM"][0] fipnum_copy = fipnum.deep_copy() - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) reg.select_more(P, 260) fipnum.div(-1, mask=reg) self.assertFalse(fipnum.equal(fipnum_copy)) @@ -57,7 +57,7 @@ def test_kw_iadd(self): fipnum = self.init_file["FIPNUM"][0] fipnum_copy = fipnum.deep_copy() - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) reg.select_more(P, 260) fipnum.add(1, mask=reg) self.assertFalse(fipnum.equal(fipnum_copy)) @@ -73,7 +73,7 @@ def test_kw_isub(self): fipnum = self.init_file["FIPNUM"][0] fipnum_copy = fipnum.deep_copy() - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) reg.select_more(P, 260) fipnum.sub(1, mask=reg) self.assertFalse(fipnum.equal(fipnum_copy)) @@ -81,7 +81,7 @@ def test_kw_isub(self): self.assertTrue(fipnum.equal(fipnum_copy)) def test_slice(self): - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) reg.select_islice(0, 5) OK = True @@ -110,7 +110,7 @@ def test_slice(self): self.assertTrue(OK) self.assertTrue(2 * self.grid.getNZ() * 6 == len(reg.getGlobalList())) - reg2 = EclRegion(self.grid, False) + reg2 = ResdataRegion(self.grid, False) reg2.select_kslice(3, 5) reg &= reg2 OK = True @@ -129,13 +129,13 @@ def test_slice(self): self.assertTrue(2 * 3 * 6 == len(reg.getGlobalList())) def test_index_list(self): - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) reg.select_islice(0, 5) active_list = reg.getActiveList() global_list = reg.getGlobalList() def test_polygon(self): - reg = EclRegion(self.grid, False) + reg = ResdataRegion(self.grid, False) (x, y, z) = self.grid.get_xyz(ijk=(10, 10, 0)) dx = 0.1 dy = 0.1 @@ -146,7 +146,7 @@ def test_polygon(self): def test_heidrun(self): root = self.createTestPath("Equinor/ECLIPSE/Heidrun") - grid = EclGrid("%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root) + grid = ResdataGrid("%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root) polygon = [] with open("%s/polygon.ply" % root) as fileH: @@ -155,12 +155,12 @@ def test_heidrun(self): polygon.append((float(tmp[0]), float(tmp[1]))) self.assertEqual(len(polygon), 11) - reg = EclRegion(grid, False) + reg = ResdataRegion(grid, False) reg.select_inside_polygon(polygon) self.assertEqual(0, len(reg.getGlobalList()) % grid.getNZ()) def test_layer(self): - region = EclRegion(self.grid, False) + region = ResdataRegion(self.grid, False) layer = Layer(self.grid.getNX(), self.grid.getNY() + 1) with self.assertRaises(ValueError): region.selectFromLayer(layer, 0, 1) diff --git a/python/tests/rd_tests/test_removed.py b/python/tests/rd_tests/test_removed.py index 2fea80ca50..15074b2228 100644 --- a/python/tests/rd_tests/test_removed.py +++ b/python/tests/rd_tests/test_removed.py @@ -1,20 +1,20 @@ import time import datetime -from ecl.util.test import TestAreaContext -from tests import EclTest -from ecl import EclDataType -from ecl.eclfile import EclFile, EclKW, openFortIO, FortIO +from resdata.util.test import TestAreaContext +from tests import ResdataTest +from resdata import ResdataDataType +from resdata.eclfile import ResdataFile, ResdataKW, openFortIO, FortIO -class Removed_2_1_Test(EclTest): - def test_ecl_file_block(self): +class Removed_2_1_Test(ResdataTest): + def test_rd_file_block(self): with TestAreaContext("name") as t: - kw = EclKW("TEST", 3, EclDataType.ECL_INT) + kw = ResdataKW("TEST", 3, ResdataDataType.RD_INT) with openFortIO("TEST", mode=FortIO.WRITE_MODE) as f: kw.fwrite(f) - f = EclFile("TEST") + f = ResdataFile("TEST") with self.assertRaises(NotImplementedError): f.select_block("KW", 100) @@ -28,4 +28,4 @@ def test_ecl_file_block(self): f.select_restart_section() with self.assertRaises(NotImplementedError): - EclFile.restart_block("TEST") + ResdataFile.restart_block("TEST") diff --git a/python/tests/rd_tests/test_restart.py b/python/tests/rd_tests/test_restart.py index 1845abbc98..33983ea205 100755 --- a/python/tests/rd_tests/test_restart.py +++ b/python/tests/rd_tests/test_restart.py @@ -2,12 +2,12 @@ from _ctypes import ArgumentError import os import datetime -from ecl.eclfile import EclFile -from tests import EclTest, equinor_test +from resdata.eclfile import ResdataFile +from tests import ResdataTest, equinor_test @equinor_test() -class RestartTest(EclTest): +class RestartTest(ResdataTest): def setUp(self): self.xfile0 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0000") self.u_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") @@ -24,13 +24,13 @@ def tearDown(self): os.unlink(f) def report_file_test(self, fname): - self.assertTrue(EclFile.contains_report_step(fname, 4)) - self.assertTrue(EclFile.contains_report_step(fname, 0)) - self.assertTrue(EclFile.contains_report_step(fname, 62)) - self.assertFalse(EclFile.contains_report_step(fname, -1)) - self.assertFalse(EclFile.contains_report_step(fname, 100)) + self.assertTrue(ResdataFile.contains_report_step(fname, 4)) + self.assertTrue(ResdataFile.contains_report_step(fname, 0)) + self.assertTrue(ResdataFile.contains_report_step(fname, 62)) + self.assertFalse(ResdataFile.contains_report_step(fname, -1)) + self.assertFalse(ResdataFile.contains_report_step(fname, 100)) - f = EclFile(fname) + f = ResdataFile(fname) self.assertTrue(f.has_report_step(4)) self.assertTrue(f.has_report_step(0)) self.assertTrue(f.has_report_step(62)) @@ -42,30 +42,30 @@ def test_report(self): self.report_file_test(self.u_file) def test_date(self): - f = EclFile(self.u_file) + f = ResdataFile(self.u_file) self.assertTrue(f.has_sim_time(datetime.datetime(2001, 6, 1))) self.assertFalse(f.has_sim_time(datetime.datetime(2005, 6, 1))) self.assertFalse(f.has_sim_time(datetime.datetime(1999, 6, 1))) self.assertFalse(f.has_sim_time(datetime.datetime(2001, 6, 11))) self.assertTrue( - EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 1)) + ResdataFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 1)) ) self.assertFalse( - EclFile.contains_sim_time(self.u_file, datetime.datetime(2005, 6, 1)) + ResdataFile.contains_sim_time(self.u_file, datetime.datetime(2005, 6, 1)) ) self.assertFalse( - EclFile.contains_sim_time(self.u_file, datetime.datetime(1999, 6, 1)) + ResdataFile.contains_sim_time(self.u_file, datetime.datetime(1999, 6, 1)) ) self.assertFalse( - EclFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 11)) + ResdataFile.contains_sim_time(self.u_file, datetime.datetime(2001, 6, 11)) ) def report_list_file_test(self, fname, rlist0): - rlist = EclFile.file_report_list(fname) + rlist = ResdataFile.file_report_list(fname) self.assertListEqual(rlist, rlist0) - f = EclFile(fname) + f = ResdataFile(fname) rlist = f.report_list self.assertListEqual(rlist, rlist0) @@ -77,24 +77,24 @@ def test_report_list(self): self.report_list_file_test(self.xfile0, rlist0) def test_dates(self): - f = EclFile(self.u_file) + f = ResdataFile(self.u_file) dates = f.dates self.assertTrue(len(dates) == 63) - f = EclFile(self.xfile0) + f = ResdataFile(self.xfile0) dates = f.dates self.assertTrue(len(dates) == 1) self.assertTrue(dates[0] == datetime.datetime(2000, 1, 1)) def test_name(self): - f = EclFile(self.u_file) + f = ResdataFile(self.u_file) self.assertTrue(f.getFilename() == self.u_file) - f = EclFile(self.xfile0) + f = ResdataFile(self.xfile0) self.assertTrue(f.getFilename() == self.xfile0) def test_kw(self): - f = EclFile(self.u_file) + f = ResdataFile(self.u_file) kw1 = f["SWAT"][40] kw2 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1)) kw3 = f.restart_get_kw("SWAT", datetime.datetime(2003, 3, 1), copy=True) diff --git a/python/tests/rd_tests/test_restart_head.py b/python/tests/rd_tests/test_restart_head.py index db0150fd7b..d0173f84dc 100644 --- a/python/tests/rd_tests/test_restart_head.py +++ b/python/tests/rd_tests/test_restart_head.py @@ -1,21 +1,27 @@ import datetime -from tests import EclTest, equinor_test -from ecl import EclFileFlagEnum -from ecl.eclfile import Ecl3DKW, EclKW, EclRestartFile, EclFile, FortIO -from ecl.grid import EclGrid +from tests import ResdataTest, equinor_test +from resdata import ResdataFileFlagEnum +from resdata.eclfile import ( + Resdata3DKW, + ResdataKW, + ResdataRestartFile, + ResdataFile, + FortIO, +) +from resdata.grid import ResdataGrid @equinor_test() -class RestartHeadTest(EclTest): +class RestartHeadTest(ResdataTest): def setUp(self): self.grid_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") self.unrst_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") self.xrst_file0 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0000") def test_headers(self): - g = EclGrid(self.grid_file) - f = EclRestartFile(g, self.unrst_file) + g = ResdataGrid(self.grid_file) + f = ResdataRestartFile(g, self.unrst_file) headers = f.headers() self.assertEqual(len(headers), 63) diff --git a/python/tests/rd_tests/test_rft.py b/python/tests/rd_tests/test_rft.py index 177fd804a4..7ffab89327 100644 --- a/python/tests/rd_tests/test_rft.py +++ b/python/tests/rd_tests/test_rft.py @@ -1,19 +1,25 @@ #!/usr/bin/env python import datetime -from ecl.util.util import CTime -from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, EclRFT, WellTrajectory -from tests import EclTest +from resdata.util.util import CTime +from resdata.rft import ( + ResdataRFTFile, + ResdataRFTCell, + ResdataPLTCell, + ResdataRFT, + WellTrajectory, +) +from tests import ResdataTest -class RFTTest(EclTest): +class RFTTest(ResdataTest): def test_create(self): - rft = EclRFT("WELL", "RFT", datetime.date(2015, 10, 1), 100) + rft = ResdataRFT("WELL", "RFT", datetime.date(2015, 10, 1), 100) self.assertEqual(len(rft), 0) with self.assertRaises(IndexError): cell = rft[5] def test_repr(self): - rft = EclRFT("WELL", "RFT", datetime.date(2015, 10, 1), 100) - pfx = "EclRFT(completed_cells = 0, date = 2015-10-01, RFT)" + rft = ResdataRFT("WELL", "RFT", datetime.date(2015, 10, 1), 100) + pfx = "ResdataRFT(completed_cells = 0, date = 2015-10-01, RFT)" self.assertEqual(pfx, repr(rft)[: len(pfx)]) diff --git a/python/tests/rd_tests/test_rft_cell.py b/python/tests/rd_tests/test_rft_cell.py index 6be5463161..7fe1ecc2ec 100644 --- a/python/tests/rd_tests/test_rft_cell.py +++ b/python/tests/rd_tests/test_rft_cell.py @@ -1,14 +1,14 @@ #!/usr/bin/env python -from ecl.rft import EclRFTCell, EclPLTCell -from tests import EclTest +from resdata.rft import ResdataRFTCell, ResdataPLTCell +from tests import ResdataTest # def out_of_range(): -# rftFile = ecl.EclRFTFile(RFT_file) +# rftFile = ecl.ResdataRFTFile(RFT_file) # rft = rftFile[100] -class RFTCellTest(EclTest): +class RFTCellTest(ResdataTest): def setUp(self): self.RFT_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.RFT") self.PLT_file = self.createTestPath("Equinor/ECLIPSE/RFT/TEST1_1A.RFT") @@ -21,7 +21,7 @@ def test_RFT_cell(self): pressure = 65 swat = 0.56 sgas = 0.10 - cell = EclRFTCell(i, j, k, depth, pressure, swat, sgas) + cell = ResdataRFTCell(i, j, k, depth, pressure, swat, sgas) self.assertEqual(i, cell.get_i()) self.assertEqual(j, cell.get_j()) @@ -49,7 +49,7 @@ def test_PLT_cell(self): gas_flowrate = 132 water_flowrate = 13344 - cell = EclPLTCell( + cell = ResdataPLTCell( i, j, k, diff --git a/python/tests/rd_tests/test_rft_equinor.py b/python/tests/rd_tests/test_rft_equinor.py index 9c62fe1dae..ef76a3738c 100644 --- a/python/tests/rd_tests/test_rft_equinor.py +++ b/python/tests/rd_tests/test_rft_equinor.py @@ -1,22 +1,22 @@ #!/usr/bin/env python from __future__ import print_function import datetime -from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, WellTrajectory -from tests import EclTest, equinor_test +from resdata.rft import ResdataRFTFile, ResdataRFTCell, ResdataPLTCell, WellTrajectory +from tests import ResdataTest, equinor_test @equinor_test() -class RFTTest(EclTest): +class RFTTest(ResdataTest): def setUp(self): self.RFT_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.RFT") self.PLT_file = self.createTestPath("Equinor/ECLIPSE/RFT/TEST1_1A.RFT") def test_RFT_load(self): - rftFile = EclRFTFile(self.RFT_file) + rftFile = ResdataRFTFile(self.RFT_file) rft = rftFile[0] cell = rft.ijkget((32, 53, 0)) - self.assertIsInstance(cell, EclRFTCell) + self.assertIsInstance(cell, ResdataRFTCell) self.assertEqual(2, rftFile.size()) self.assertEqual(0, rftFile.size(well="OP*")) @@ -34,14 +34,14 @@ def test_RFT_load(self): self.assertFalse(rft.is_MSW()) for cell in rft: - self.assertIsInstance(cell, EclRFTCell) + self.assertIsInstance(cell, ResdataRFTCell) for h in rftFile.getHeaders(): print(h) self.assertIsInstance(h[1], datetime.date) def test_PLT_load(self): - pltFile = EclRFTFile(self.PLT_file) + pltFile = ResdataRFTFile(self.PLT_file) plt = pltFile[11] self.assertTrue(plt.is_PLT()) self.assertFalse(plt.is_SEGMENT()) @@ -49,11 +49,11 @@ def test_PLT_load(self): self.assertFalse(plt.is_MSW()) for cell in plt: - self.assertIsInstance(cell, EclPLTCell) + self.assertIsInstance(cell, ResdataPLTCell) def test_exceptions(self): with self.assertRaises(IndexError): - rftFile = EclRFTFile(self.RFT_file) + rftFile = ResdataRFTFile(self.RFT_file) rft = rftFile[100] def test_basics(self): @@ -101,7 +101,7 @@ def test_trajectory(self): self.assertEqual(p37, pm1) def test_PLT(self): - rft_file = EclRFTFile( + rft_file = ResdataRFTFile( self.createTestPath("Equinor/ECLIPSE/Heidrun/RFT/2C3_MR61.RFT") ) diff --git a/python/tests/rd_tests/test_sum.py b/python/tests/rd_tests/test_sum.py index 0508f72589..dbb384f302 100644 --- a/python/tests/rd_tests/test_sum.py +++ b/python/tests/rd_tests/test_sum.py @@ -22,13 +22,13 @@ def assert_frame_equal(a, b): from contextlib import contextmanager from unittest import skipIf, skipUnless -from ecl import EclUnitTypeEnum -from ecl import EclDataType -from ecl.eclfile import FortIO, openFortIO, EclKW, EclFile -from ecl.summary import EclSum, EclSumVarType, EclSumKeyWordVector -from ecl.util.test import TestAreaContext -from tests import EclTest -from ecl.util.test.ecl_mock import createEclSum +from resdata import ResdataUnitTypeEnum +from resdata import ResdataDataType +from resdata.eclfile import FortIO, openFortIO, ResdataKW, ResdataFile +from resdata.summary import RdSum, RdSumVarType, RdSumKeyWordVector +from resdata.util.test import TestAreaContext +from tests import ResdataTest +from resdata.util.test.rd_mock import createRdSum @contextmanager @@ -73,7 +73,7 @@ def fgpt(days): def create_case(case="CSV", restart_case=None, restart_step=-1, data_start=None): length = 100 - return createEclSum( + return createRdSum( case, [ ("FOPT", None, 0, "SM3"), @@ -92,7 +92,7 @@ def create_case(case="CSV", restart_case=None, restart_step=-1, data_start=None) def create_case2(case="CSV", restart_case=None, restart_step=-1, data_start=None): length = 100 - return createEclSum( + return createRdSum( case, [ ("WOPT", "OPX", 0, "SM3"), @@ -111,16 +111,16 @@ def create_case2(case="CSV", restart_case=None, restart_step=-1, data_start=None ) -class SumTest(EclTest): +class SumTest(ResdataTest): def test_mock(self): - case = createEclSum( + case = createRdSum( "CSV", [("FOPT", None, 0, "SM3"), ("FOPR", None, 0, "SM3/DAY")] ) self.assertTrue("FOPT" in case) self.assertFalse("WWCT:OPX" in case) def test_TIME_special_case(self): - case = createEclSum( + case = createRdSum( "CSV", [("FOPT", None, 0, "SM3"), ("FOPR", None, 0, "SM3/DAY")] ) keys = case.keys() @@ -135,28 +135,28 @@ def test_TIME_special_case(self): def test_identify_var_type(self): self.assertEnumIsFullyDefined( - EclSumVarType, "ecl_smspec_var_type", "lib/include/ert/ecl/smspec_node.h" + RdSumVarType, "rd_smspec_var_type", "lib/include/resdata/smspec_node.h" ) - self.assertEqual(EclSum.varType("WWCT:OP_X"), EclSumVarType.ECL_SMSPEC_WELL_VAR) - self.assertEqual(EclSum.varType("RPR"), EclSumVarType.ECL_SMSPEC_REGION_VAR) - self.assertEqual(EclSum.varType("WNEWTON"), EclSumVarType.ECL_SMSPEC_MISC_VAR) - self.assertEqual(EclSum.varType("AARQ:4"), EclSumVarType.ECL_SMSPEC_AQUIFER_VAR) + self.assertEqual(RdSum.varType("WWCT:OP_X"), RdSumVarType.RD_SMSPEC_WELL_VAR) + self.assertEqual(RdSum.varType("RPR"), RdSumVarType.RD_SMSPEC_REGION_VAR) + self.assertEqual(RdSum.varType("WNEWTON"), RdSumVarType.RD_SMSPEC_MISC_VAR) + self.assertEqual(RdSum.varType("AARQ:4"), RdSumVarType.RD_SMSPEC_AQUIFER_VAR) self.assertEqual( - EclSum.varType("RXFT"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR + RdSum.varType("RXFT"), RdSumVarType.RD_SMSPEC_REGION_2_REGION_VAR ) self.assertEqual( - EclSum.varType("RxxFT"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR + RdSum.varType("RxxFT"), RdSumVarType.RD_SMSPEC_REGION_2_REGION_VAR ) self.assertEqual( - EclSum.varType("RXFR"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR + RdSum.varType("RXFR"), RdSumVarType.RD_SMSPEC_REGION_2_REGION_VAR ) self.assertEqual( - EclSum.varType("RxxFR"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR + RdSum.varType("RxxFR"), RdSumVarType.RD_SMSPEC_REGION_2_REGION_VAR ) - self.assertEqual(EclSum.varType("RORFR"), EclSumVarType.ECL_SMSPEC_REGION_VAR) + self.assertEqual(RdSum.varType("RORFR"), RdSumVarType.RD_SMSPEC_REGION_VAR) - case = createEclSum( + case = createRdSum( "CSV", [ ("FOPT", None, 0, "SM3"), @@ -167,15 +167,15 @@ def test_identify_var_type(self): ) node1 = case.smspec_node("FOPT") - self.assertEqual(node1.varType(), EclSumVarType.ECL_SMSPEC_FIELD_VAR) + self.assertEqual(node1.varType(), RdSumVarType.RD_SMSPEC_FIELD_VAR) self.assertIsNone(node1.wgname) node2 = case.smspec_node("AARQ:10") - self.assertEqual(node2.varType(), EclSumVarType.ECL_SMSPEC_AQUIFER_VAR) + self.assertEqual(node2.varType(), RdSumVarType.RD_SMSPEC_AQUIFER_VAR) self.assertEqual(node2.getNum(), 10) node3 = case.smspec_node("RGPT:1") - self.assertEqual(node3.varType(), EclSumVarType.ECL_SMSPEC_REGION_VAR) + self.assertEqual(node3.varType(), RdSumVarType.RD_SMSPEC_REGION_VAR) self.assertEqual(node3.getNum(), 1) self.assertTrue(node3.isTotal()) @@ -188,11 +188,11 @@ def test_identify_var_type(self): a = node1 < 1 def test_csv_export(self): - case = createEclSum( + case = createRdSum( "CSV", [("FOPT", None, 0, "SM3"), ("FOPR", None, 0, "SM3/DAY")] ) sep = ";" - with TestAreaContext("ecl/csv"): + with TestAreaContext("resdata/csv"): case.exportCSV("file.csv", sep=sep) self.assertTrue(os.path.isfile("file.csv")) input_file = csv.DictReader(open("file.csv"), delimiter=sep) @@ -206,7 +206,7 @@ def test_csv_export(self): self.assertEqual(case.unit("FOPT"), "SM3") - with TestAreaContext("ecl/csv"): + with TestAreaContext("resdata/csv"): case.exportCSV("file.csv", keys=["FOPT"], sep=sep) self.assertTrue(os.path.isfile("file.csv")) input_file = csv.DictReader(open("file.csv"), delimiter=sep) @@ -217,7 +217,7 @@ def test_csv_export(self): self.assertEqual(len(row), 3) break - with TestAreaContext("ecl/csv"): + with TestAreaContext("resdata/csv"): date_format = "%y-%m-%d" sep = "," case.exportCSV("file.csv", keys=["F*"], sep=sep, date_format=date_format) @@ -292,12 +292,12 @@ def test_different_names(self): case.fwrite() shutil.move("CSV.SMSPEC", "CSVX.SMSPEC") with self.assertRaises(IOError): - case2 = EclSum.load("Does/not/exist", "CSV.UNSMRY") + case2 = RdSum.load("Does/not/exist", "CSV.UNSMRY") with self.assertRaises(IOError): - case2 = EclSum.load("CSVX.SMSPEC", "CSVX.UNSMRY") + case2 = RdSum.load("CSVX.SMSPEC", "CSVX.UNSMRY") - case2 = EclSum.load("CSVX.SMSPEC", "CSV.UNSMRY") + case2 = RdSum.load("CSVX.SMSPEC", "CSV.UNSMRY") self.assert_solve(case2) self.assertEqual(case.unit("FOPR"), "SM3/DAY") @@ -306,30 +306,30 @@ def test_invalid(self): with TestAreaContext("sum_invalid"): case.fwrite() with open("CASE.txt", "w") as f: - f.write("No - this is not EclKW file ....") + f.write("No - this is not ResdataKW file ....") with self.assertRaises(IOError): - case2 = EclSum.load("CSV.SMSPEC", "CASE.txt") + case2 = RdSum.load("CSV.SMSPEC", "CASE.txt") with self.assertRaises(IOError): - case2 = EclSum.load("CASE.txt", "CSV.UNSMRY") + case2 = RdSum.load("CASE.txt", "CSV.UNSMRY") - kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT) - kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT) + kw1 = ResdataKW("TEST1", 30, ResdataDataType.RD_INT) + kw2 = ResdataKW("TEST2", 30, ResdataDataType.RD_INT) with openFortIO("CASE.KW", FortIO.WRITE_MODE) as f: kw1.fwrite(f) kw2.fwrite(f) with self.assertRaises(IOError): - case2 = EclSum.load("CSV.SMSPEC", "CASE.KW") + case2 = RdSum.load("CSV.SMSPEC", "CASE.KW") with self.assertRaises(IOError): - case2 = EclSum.load("CASE.KW", "CSV.UNSMRY") + case2 = RdSum.load("CASE.KW", "CSV.UNSMRY") def test_kw_vector(self): case1 = create_case() - case2 = createEclSum( + case2 = createRdSum( "CSV", [ ("FOPR", None, 0, "SM3/DAY"), @@ -342,7 +342,7 @@ def test_kw_vector(self): func_table={"FOPT": fopt, "FOPR": fopr, "FWPT": fgpt}, ) - kw_list = EclSumKeyWordVector(case1) + kw_list = RdSumKeyWordVector(case1) kw_list.add_keyword("FOPT") kw_list.add_keyword("FGPT") kw_list.add_keyword("FOPR") @@ -395,11 +395,11 @@ def test_kw_vector(self): def test_vector_select_all(self): case = create_case() - ecl_sum_vector = EclSumKeyWordVector(case, True) + rd_sum_vector = RdSumKeyWordVector(case, True) keys = case.keys() - self.assertEqual(len(keys), len(ecl_sum_vector)) + self.assertEqual(len(keys), len(rd_sum_vector)) for key in keys: - self.assertIn(key, ecl_sum_vector) + self.assertIn(key, rd_sum_vector) def test_first_last(self): case = create_case() @@ -455,12 +455,12 @@ def test_restart_abs_path(self): pred_path = "prediction" create_prediction(history, pred_path) - pred = EclSum(os.path.join(pred_path, "PREDICTION")) + pred = RdSum(os.path.join(pred_path, "PREDICTION")) # The restart case has a maximum length of 72 characters, depending # on the path used for $TMP and so on we do not really know here if # the restart_case has been set or not. if pred.restart_case: - self.assertTrue(isinstance(pred.restart_case, EclSum)) + self.assertTrue(isinstance(pred.restart_case, RdSum)) self.assertEqual( pred.restart_case.case, os.path.join(os.getcwd(), history.case) ) @@ -483,7 +483,7 @@ def test_restart_too_long_history_path(self): pred_path = "prediction" create_prediction(history, pred_path) - pred = EclSum(os.path.join(pred_path, "PREDICTION")) + pred = RdSum(os.path.join(pred_path, "PREDICTION")) self.assertIsNone(pred.restart_case) def test_restart_perm_denied(self): @@ -503,13 +503,13 @@ def test_restart_perm_denied(self): # This just tests that we can create a summary instance even if we do not # have access to load the history case. - pred = EclSum("PREDICTION") + pred = RdSum("PREDICTION") os.chmod("history", stat.S_IRWXU) def test_units(self): case = create_case() - self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) + self.assertEqual(case.unit_system, ResdataUnitTypeEnum.RD_METRIC_UNITS) # We do not really have support for writing anything else than the # default MERIC unit system. To be able to test the read functionality @@ -517,10 +517,10 @@ def test_units(self): with TestAreaContext("unit_test"): case = create_case("UNITS") case.fwrite() - case2 = EclSum("UNITS") + case2 = RdSum("UNITS") kw_list = [] - f = EclFile("UNITS.SMSPEC") + f = ResdataFile("UNITS.SMSPEC") for kw in f: if kw.name == "INTEHEAD": kw[0] = 3 @@ -531,8 +531,8 @@ def test_units(self): for kw in kw_list: kw.fwrite(f) - case = EclSum("UNITS") - self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_LAB_UNITS) + case = RdSum("UNITS") + self.assertEqual(case.unit_system, ResdataUnitTypeEnum.RD_LAB_UNITS) def test_numpy_vector(self): case = create_case() @@ -614,15 +614,15 @@ def test_pandas(self): def test_csv_load(self): case = create_case2() frame = case.pandas_frame() - ecl_sum = EclSum.from_pandas("PANDAS", frame, dims=[20, 10, 5]) + rd_sum = RdSum.from_pandas("PANDAS", frame, dims=[20, 10, 5]) for key in frame.columns: - self.assertTrue(key in ecl_sum) + self.assertTrue(key in rd_sum) - df = ecl_sum.pandas_frame() + df = rd_sum.pandas_frame() assert_frame_equal(frame, df) - ecl_sum_less = EclSum.from_pandas( + rd_sum_less = RdSum.from_pandas( "PANDAS", frame, dims=[20, 10, 5], @@ -630,23 +630,23 @@ def test_csv_load(self): ) del frame["WOPT:OPX"] del frame["FOPR"] - df_less = ecl_sum_less.pandas_frame() + df_less = rd_sum_less.pandas_frame() assert_frame_equal(frame, df_less) def test_total_and_rate(self): - self.assertTrue(EclSum.is_total("FOPT")) - self.assertTrue(EclSum.is_total("WWPT:OP_3")) - self.assertFalse(EclSum.is_total("RPR:2")) + self.assertTrue(RdSum.is_total("FOPT")) + self.assertTrue(RdSum.is_total("WWPT:OP_3")) + self.assertFalse(RdSum.is_total("RPR:2")) - self.assertTrue(EclSum.is_rate("WOPR:OP_4")) - self.assertFalse(EclSum.is_rate("BPR:123")) - self.assertTrue(EclSum.is_rate("FWIR")) + self.assertTrue(RdSum.is_rate("WOPR:OP_4")) + self.assertFalse(RdSum.is_rate("BPR:123")) + self.assertTrue(RdSum.is_rate("FWIR")) def test_load_case(self): path = os.path.join( self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3" ) - case = EclSum(path) + case = RdSum(path) self.assertFloatEqual(case.sim_length, 545.0) fopr = case.numpy_vector("FOPR") @@ -655,8 +655,8 @@ def test_load_case(self): def test_load_case_lazy_and_eager(self): path = os.path.join(self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SHORT.UNSMRY") - lazy_dates = EclSum(path, lazy_load=True).numpy_dates - eager_dates = EclSum(path, lazy_load=False).numpy_dates + lazy_dates = RdSum(path, lazy_load=True).numpy_dates + eager_dates = RdSum(path, lazy_load=False).numpy_dates self.assertEqual(len(lazy_dates), 107) self.assertEqual(len(eager_dates), 107) for l, e in zip(lazy_dates, eager_dates): @@ -666,7 +666,7 @@ def test_write_not_implemented(self): path = os.path.join( self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3" ) - case = EclSum(path, lazy_load=True) + case = RdSum(path, lazy_load=True) self.assertFalse(case.can_write()) with self.assertRaises(NotImplementedError): case.fwrite() @@ -676,23 +676,23 @@ def test_directory_conflict(self): case = create_case("UNITS") case.fwrite() os.mkdir("UNITS") - case2 = EclSum("./UNITS") + case2 = RdSum("./UNITS") def test_resample_extrapolate(self): """ Test resampling of summary with extrapolate option of lower and upper boundaries enabled """ - from ecl.util.util import TimeVector, CTime + from resdata.util.util import TimeVector, CTime time_points = TimeVector() path = os.path.join( self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3" ) - ecl_sum = EclSum(path, lazy_load=True) + rd_sum = RdSum(path, lazy_load=True) - start_time = ecl_sum.get_data_start_time() - datetime.timedelta(seconds=86400) - end_time = ecl_sum.get_end_time() + datetime.timedelta(seconds=86400) + start_time = rd_sum.get_data_start_time() - datetime.timedelta(seconds=86400) + end_time = rd_sum.get_end_time() + datetime.timedelta(seconds=86400) delta = end_time - start_time N = 25 @@ -702,47 +702,47 @@ def test_resample_extrapolate(self): CTime(int(delta.total_seconds() / (N - 1))), ) time_points.append(CTime(end_time)) - resampled = ecl_sum.resample( + resampled = rd_sum.resample( "OUTPUT_CASE", time_points, lower_extrapolation=True, upper_extrapolation=True, ) - for key in ecl_sum.keys(): + for key in rd_sum.keys(): self.assertIn(key, resampled) self.assertEqual( - ecl_sum.get_data_start_time() - datetime.timedelta(seconds=86400), + rd_sum.get_data_start_time() - datetime.timedelta(seconds=86400), resampled.get_data_start_time(), ) key_not_rate = "FOPT" for time_index, t in enumerate(time_points): - if t < ecl_sum.get_data_start_time(): + if t < rd_sum.get_data_start_time(): self.assertFloatEqual( resampled.iget(key_not_rate, time_index), - ecl_sum._get_first_value(key_not_rate), + rd_sum._get_first_value(key_not_rate), ) - elif t > ecl_sum.get_end_time(): + elif t > rd_sum.get_end_time(): self.assertFloatEqual( resampled.iget(key_not_rate, time_index), - ecl_sum.get_last_value(key_not_rate), + rd_sum.get_last_value(key_not_rate), ) else: self.assertFloatEqual( resampled.iget(key_not_rate, time_index), - ecl_sum.get_interp_direct(key_not_rate, t), + rd_sum.get_interp_direct(key_not_rate, t), ) key_rate = "FOPR" for time_index, t in enumerate(time_points): - if t < ecl_sum.get_data_start_time(): + if t < rd_sum.get_data_start_time(): self.assertFloatEqual(resampled.iget(key_rate, time_index), 0) - elif t > ecl_sum.get_end_time(): + elif t > rd_sum.get_end_time(): self.assertFloatEqual(resampled.iget(key_rate, time_index), 0) else: self.assertFloatEqual( resampled.iget(key_rate, time_index), - ecl_sum.get_interp_direct(key_rate, t), + rd_sum.get_interp_direct(key_rate, t), ) diff --git a/python/tests/rd_tests/test_sum_equinor.py b/python/tests/rd_tests/test_sum_equinor.py index 7a16581b7d..b7158653e7 100755 --- a/python/tests/rd_tests/test_sum_equinor.py +++ b/python/tests/rd_tests/test_sum_equinor.py @@ -3,14 +3,14 @@ from unittest import skipIf, skipUnless, skipIf -from ecl.eclfile import EclFile -from ecl.summary import EclSum -from ecl import EclUnitTypeEnum +from resdata.eclfile import ResdataFile +from resdata.summary import RdSum +from resdata import ResdataUnitTypeEnum -from ecl.util.util import StringList, TimeVector, DoubleVector, CTime +from resdata.util.util import StringList, TimeVector, DoubleVector, CTime -from ecl.util.test import TestAreaContext -from tests import EclTest, equinor_test +from resdata.util.test import TestAreaContext +from tests import ResdataTest, equinor_test import csv base = "ECLIPSE" @@ -25,22 +25,22 @@ def sum_get(*args): @equinor_test() -class SumTest(EclTest): +class SumTest(ResdataTest): def setUp(self): self.case = self.createTestPath(case) - self.ecl_sum = EclSum(self.case) + self.rd_sum = RdSum(self.case) - self.assertIsInstance(self.ecl_sum, EclSum) + self.assertIsInstance(self.rd_sum, RdSum) def test_load(self): - self.assertIsNotNone(self.ecl_sum, "Load failed") + self.assertIsNotNone(self.rd_sum, "Load failed") def test_invalid(self): with self.assertRaises(IOError): - sum = EclSum("Does/not/exist") + sum = RdSum("Does/not/exist") def test_KeyError(self): - sum = self.ecl_sum + sum = self.rd_sum with self.assertRaises(KeyError): v = sum.numpy_vector("KeyMissing") @@ -51,11 +51,11 @@ def test_KeyError(self): v = sum.get_interp_vector("Missing", days_list=[750]) def test_contains(self): - self.assertTrue("FOPT" in self.ecl_sum) - self.assertFalse("MISSING" in self.ecl_sum) + self.assertTrue("FOPT" in self.rd_sum) + self.assertFalse("MISSING" in self.rd_sum) def test_interp(self): - sum = self.ecl_sum + sum = self.rd_sum self.assertAlmostEqual(sum.get_interp("WWCT:OP_3", days=750), 0.11719122) self.assertAlmostEqual( @@ -98,7 +98,7 @@ def test_interp(self): sum.get_interp("WOPR:OP_1", days=10, date=datetime.date(2000, 1, 1)) def test_LLINEAR(self): - sum = EclSum( + sum = RdSum( self.createTestPath( "Equinor/ECLIPSE/Heidrun/LGRISSUE/EM-LTAA-ISEG_CARFIN_NWPROPS" ) @@ -106,32 +106,32 @@ def test_LLINEAR(self): self.assertTrue(sum.has_key("LLINEARS")) def test_wells(self): - wells = self.ecl_sum.wells() + wells = self.rd_sum.wells() wells.sort() self.assertListEqual( [well for well in wells], ["OP_1", "OP_2", "OP_3", "OP_4", "OP_5", "WI_1", "WI_2", "WI_3"], ) - wells = self.ecl_sum.wells(pattern="*_3") + wells = self.rd_sum.wells(pattern="*_3") wells.sort() self.assertListEqual([well for well in wells], ["OP_3", "WI_3"]) - groups = self.ecl_sum.groups() + groups = self.rd_sum.groups() groups.sort() self.assertListEqual([group for group in groups], ["GMWIN", "OP", "WI"]) def test_last(self): - last = self.ecl_sum.get_last("FOPT") + last = self.rd_sum.get_last("FOPT") self.assertFloatEqual(last.value, 38006336.0) self.assertFloatEqual(last.days, 1826.0) self.assertEqual(last.date, datetime.datetime(2004, 12, 31, 0, 0, 0)) - self.assertFloatEqual(self.ecl_sum.last_value("FGPT"), 6605249024.0) - self.assertEqual(len(self.ecl_sum), 63) + self.assertFloatEqual(self.rd_sum.last_value("FGPT"), 6605249024.0) + self.assertEqual(len(self.rd_sum), 63) def test_dates(self): - sum = self.ecl_sum + sum = self.rd_sum d = sum.dates self.assertEqual(d[0], datetime.datetime(2000, 1, 1, 0, 0, 0)) @@ -152,23 +152,23 @@ def test_dates(self): self.assertEqual(sum.end_date, datetime.date(2004, 12, 31)) def test_dates2(self): - sum = EclSum(self.createTestPath("Equinor/ECLIPSE/FF12/FF12_2013B3_AMAP2")) + sum = RdSum(self.createTestPath("Equinor/ECLIPSE/FF12/FF12_2013B3_AMAP2")) self.assertEqual(sum.end_date, datetime.date(2045, 1, 1)) def test_keys(self): - sum = self.ecl_sum + sum = self.rd_sum self.assertRaises(KeyError, sum.__getitem__, "BJARNE") v = sum["FOPT"] self.assertEqual(len(v), 63) def test_index(self): - sum = self.ecl_sum + sum = self.rd_sum index = sum.get_key_index("TCPUDAY") self.assertEqual(index, 10239) def test_report(self): - sum = self.ecl_sum + sum = self.rd_sum self.assertEqual(sum.get_report(date=datetime.date(2000, 10, 1)), 10) self.assertEqual(sum.get_report(date=datetime.date(2000, 10, 3)), -1) self.assertEqual(sum.get_report(date=datetime.date(1980, 10, 3)), -1) @@ -187,27 +187,27 @@ def test_report(self): self.assertFloatEqual(sum.get_from_report("FOPT", 10), 6.67447e06) def test_fwrite(self): - ecl_sum = EclSum(self.case, lazy_load=False) + rd_sum = RdSum(self.case, lazy_load=False) with TestAreaContext("python/sum-test/fwrite") as work_area: - ecl_sum.fwrite(ecl_case="CASE") + rd_sum.fwrite(rd_case="CASE") self.assertTrue(True) def test_block(self): - sum = self.ecl_sum + sum = self.rd_sum index_ijk = sum.get_key_index("BPR:15,28,1") index_num = sum.get_key_index("BPR:1095") self.assertEqual(index_ijk, index_num) def test_restart(self): - hist = EclSum( + hist = RdSum( self.createTestPath( "Equinor/ECLIPSE/sum-restart/history/T07-4A-W2011-18-P1" ) ) - base = EclSum( + base = RdSum( self.createTestPath("Equinor/ECLIPSE/sum-restart/prediction/BASECASE") ) - pred = EclSum( + pred = RdSum( self.createTestPath("Equinor/ECLIPSE/sum-restart/prediction/BASECASE"), include_restart=False, ) @@ -217,15 +217,15 @@ def test_restart(self): self.assertIsNotNone(pred) def test_case1(self): - self.assertTrue(self.ecl_sum.path == self.createTestPath(path)) - self.assertTrue(self.ecl_sum.base == base) - self.assertTrue(self.ecl_sum.case == self.createTestPath(case)) - self.assertTrue(self.ecl_sum.abs_path == self.createTestPath(path)) + self.assertTrue(self.rd_sum.path == self.createTestPath(path)) + self.assertTrue(self.rd_sum.base == base) + self.assertTrue(self.rd_sum.case == self.createTestPath(case)) + self.assertTrue(self.rd_sum.abs_path == self.createTestPath(path)) def test_case2(self): cwd = os.getcwd() os.chdir(self.createTestPath(path)) - sum = EclSum(base) + sum = RdSum(base) self.assertIsNone(sum.path) self.assertTrue(sum.base == base) self.assertTrue(sum.case == base) @@ -233,7 +233,7 @@ def test_case2(self): os.chdir(cwd) def test_var_properties(self): - sum = self.ecl_sum + sum = self.rd_sum self.assertRaises(KeyError, sum.smspec_node, "BJARNE") node = sum.smspec_node("FOPT") @@ -273,14 +273,14 @@ def test_var_properties(self): self.assertEqual(node.num, 1095) def test_stringlist_gc(self): - sum = EclSum(self.case) + sum = RdSum(self.case) wells = sum.wells() well1 = wells[0] del wells self.assertTrue(well1 == "OP_1") def test_stringlist_reference(self): - sum = EclSum(self.case) + sum = RdSum(self.case) wells = sum.wells() self.assertListEqual( [well for well in wells], @@ -289,7 +289,7 @@ def test_stringlist_reference(self): self.assertIsInstance(wells, StringList) def test_stringlist_setitem(self): - sum = EclSum(self.case) + sum = RdSum(self.case) wells = sum.wells() wells[0] = "Bjarne" well0 = wells[0] @@ -300,7 +300,7 @@ def test_stringlist_setitem(self): self.assertTrue(wells[0] == "XXX") def test_segment(self): - sum = EclSum(self.createTestPath("Equinor/ECLIPSE/Oseberg/F8MLT/F8MLT-F4")) + sum = RdSum(self.createTestPath("Equinor/ECLIPSE/Oseberg/F8MLT/F8MLT-F4")) segment_vars = sum.keys("SOFR:F-8:*") self.assertIn("SOFR:F-8:1", segment_vars) for var in segment_vars: @@ -309,14 +309,14 @@ def test_segment(self): self.assertTrue(nr >= 0) def test_return_types(self): - self.assertIsInstance(self.ecl_sum.alloc_time_vector(True), TimeVector) - key_index = self.ecl_sum.get_general_var_index("FOPT") + self.assertIsInstance(self.rd_sum.alloc_time_vector(True), TimeVector) + key_index = self.rd_sum.get_general_var_index("FOPT") self.assertIsInstance( - self.ecl_sum.alloc_data_vector(key_index, True), DoubleVector + self.rd_sum.alloc_data_vector(key_index, True), DoubleVector ) def test_timeRange(self): - sum = EclSum(self.case) + sum = RdSum(self.case) with self.assertRaises(TypeError): trange = sum.timeRange(interval="1") trange = sum.timeRange(interval="1X") @@ -364,7 +364,7 @@ def test_timeRange(self): # Loading this dataset is a test of loading a case where one report step is missing. def test_Heidrun(self): - sum = EclSum( + sum = RdSum( self.createTestPath("Equinor/ECLIPSE/Heidrun/Summary/FF12_2013B3_CLEAN_RS") ) self.assertEqual(452, len(sum)) @@ -376,7 +376,7 @@ def test_Heidrun(self): sum.get_interp("FOPT", date=t) def test_regularProduction(self): - sum = EclSum(self.case) + sum = RdSum(self.case) with self.assertRaises(TypeError): trange = TimeVector.createRegular(sum.start_time, sum.end_time, "1M") prod = sum.blockedProduction("FOPR", trange) @@ -408,8 +408,8 @@ def test_regularProduction(self): self.assertFloatEqual(w, g) def test_writer(self): - writer = EclSum.writer("CASE", datetime.date(2000, 1, 1), 10, 10, 5) - self.assertIsInstance(self.ecl_sum, EclSum) + writer = RdSum.writer("CASE", datetime.date(2000, 1, 1), 10, 10, 5) + self.assertIsInstance(self.rd_sum, RdSum) writer.addVariable("FOPT") self.assertTrue(writer.has_key("FOPT")) @@ -417,16 +417,16 @@ def test_writer(self): writer.addTStep(1, 100) def test_aquifer(self): - case = EclSum(self.createTestPath("Equinor/ECLIPSE/Aquifer/06_PRESSURE_R009-0")) + case = RdSum(self.createTestPath("Equinor/ECLIPSE/Aquifer/06_PRESSURE_R009-0")) self.assertTrue("AAQR:2" in case) def test_restart_mapping(self): - history = EclSum( + history = RdSum( self.createTestPath( "Equinor/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0" ) ) - total = EclSum( + total = RdSum( self.createTestPath( "Equinor/ECLIPSE/SummaryRestart/Prediction/NOR-2013A_R007_PRED-0" ), @@ -451,7 +451,7 @@ def test_restart_mapping(self): def test_write(self): with TestAreaContext("my_space") as area: - intersect_summary = EclSum( + intersect_summary = RdSum( self.createTestPath( "Equinor/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0" ), @@ -460,13 +460,13 @@ def test_write(self): self.assertIsNotNone(intersect_summary) write_location = os.path.join(os.getcwd(), "CASE") - intersect_summary.fwrite(ecl_case=write_location) + intersect_summary.fwrite(rd_case=write_location) - reloaded_summary = EclSum(write_location) + reloaded_summary = RdSum(write_location) self.assertEqual(intersect_summary.keys(), reloaded_summary.keys()) def test_ix_case(self): - intersect_summary = EclSum( + intersect_summary = RdSum( self.createTestPath("Equinor/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL") ) self.assertIsNotNone(intersect_summary) @@ -479,9 +479,9 @@ def test_ix_case(self): ] ) - eclipse_summary = EclSum( + eclipse_summary = RdSum( self.createTestPath( - "Equinor/ECLIPSE/ix/summary/ECL100/E100_CREATE_REGION_AROUND_WELL" + "Equinor/ECLIPSE/ix/summary/RD100/E100_CREATE_REGION_AROUND_WELL" ) ) self.assertIsNotNone(eclipse_summary) @@ -500,21 +500,21 @@ def test_ix_write(self): "Equinor/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC", ]: with TestAreaContext("my_space" + data_set.split("/")[-1]) as area: - intersect_summary = EclSum( + intersect_summary = RdSum( self.createTestPath(data_set), lazy_load=False ) self.assertIsNotNone(intersect_summary) write_location = os.path.join(os.getcwd(), "CASE") - intersect_summary.fwrite(ecl_case=write_location) + intersect_summary.fwrite(rd_case=write_location) - reloaded_summary = EclSum(write_location) + reloaded_summary = RdSum(write_location) self.assertEqual( list(intersect_summary.keys()), list(reloaded_summary.keys()) ) def test_ix_caseII(self): - troll_summary = EclSum( + troll_summary = RdSum( self.createTestPath( "Equinor/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC" ) @@ -524,8 +524,8 @@ def test_ix_caseII(self): def test_resample(self): time_points = TimeVector() - start_time = self.ecl_sum.get_data_start_time() - end_time = self.ecl_sum.get_end_time() + start_time = self.rd_sum.get_data_start_time() + end_time = self.rd_sum.get_end_time() delta = end_time - start_time N = 25 time_points.initRange( @@ -534,15 +534,15 @@ def test_resample(self): CTime(int(delta.total_seconds() / (N - 1))), ) time_points.append(CTime(end_time)) - resampled = self.ecl_sum.resample("OUTPUT_CASE", time_points) + resampled = self.rd_sum.resample("OUTPUT_CASE", time_points) - for key in self.ecl_sum.keys(): + for key in self.rd_sum.keys(): self.assertIn(key, resampled) self.assertEqual( - self.ecl_sum.get_data_start_time(), resampled.get_data_start_time() + self.rd_sum.get_data_start_time(), resampled.get_data_start_time() ) - delta = self.ecl_sum.get_end_time() - resampled.get_end_time() + delta = self.rd_sum.get_end_time() - resampled.get_end_time() self.assertTrue(delta.total_seconds() <= 1) keys = ["FOPT", "FOPR", "BPR:15,28,1", "WGOR:OP_1"] @@ -550,17 +550,17 @@ def test_resample(self): for time_index, t in enumerate(time_points): self.assertFloatEqual( resampled.iget(key, time_index), - self.ecl_sum.get_interp_direct(key, t), + self.rd_sum.get_interp_direct(key, t), ) def test_summary_units(self): - self.assertEqual(self.ecl_sum.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) + self.assertEqual(self.rd_sum.unit_system, ResdataUnitTypeEnum.RD_METRIC_UNITS) # The case loaded in this test originates in a simulation # which was shut down brutally. This test verifies that we - # can create a valid ecl_sum instance from what we find. + # can create a valid rd_sum instance from what we find. def test_broken_case(self): - ecl_sum = EclSum( + rd_sum = RdSum( self.createTestPath( "Equinor/ECLIPSE/SummaryFail3/COMBINED-AUTUMN2018_CARBSENS-0" ) diff --git a/python/tests/test_bin.py b/python/tests/test_bin.py index e0741a1767..40fcf5f297 100644 --- a/python/tests/test_bin.py +++ b/python/tests/test_bin.py @@ -12,8 +12,8 @@ [ ("CF_dump", -signal.SIGSEGV, b""), ("convert.x", 1, b"Usage: convert.x"), - ("ecl_pack.x", 0, b""), - ("ecl_unpack.x", 1, b"ecl_unpack UNIFIED_FILE1"), + ("rd_pack.x", 0, b""), + ("rd_unpack.x", 1, b"rd_unpack UNIFIED_FILE1"), ("grdecl_grid", -signal.SIGABRT, b"util_fopen: failed to open:(null)"), ("grdecl_test.x", -signal.SIGABRT, b"util_fopen: failed to open:(null)"), ("grid_dump.x", 1, b"grid_dump.x: filename"), diff --git a/python/tests/util_tests/test_ctime.py b/python/tests/util_tests/test_ctime.py index efe38ac8e3..141bb0bb13 100644 --- a/python/tests/util_tests/test_ctime.py +++ b/python/tests/util_tests/test_ctime.py @@ -1,7 +1,7 @@ import time from datetime import datetime, date -from ecl.util.util import CTime +from resdata.util.util import CTime try: diff --git a/python/tests/util_tests/test_hash.py b/python/tests/util_tests/test_hash.py index a8111a164f..285432efec 100644 --- a/python/tests/util_tests/test_hash.py +++ b/python/tests/util_tests/test_hash.py @@ -1,10 +1,10 @@ from ctypes import c_void_p -from tests import EclTest -from ecl.util.util import Hash, StringHash, DoubleHash, IntegerHash +from tests import ResdataTest +from resdata.util.util import Hash, StringHash, DoubleHash, IntegerHash -class HashTest(EclTest): +class HashTest(ResdataTest): def test_string_hash(self): hash = StringHash() diff --git a/python/tests/util_tests/test_lookup_table.py b/python/tests/util_tests/test_lookup_table.py index 48d7c827f7..e9370dcb22 100644 --- a/python/tests/util_tests/test_lookup_table.py +++ b/python/tests/util_tests/test_lookup_table.py @@ -3,7 +3,7 @@ except ImportError: from unittest import TestCase -from ecl.util.util import LookupTable +from resdata.util.util import LookupTable class LookupTableTest(TestCase): diff --git a/python/tests/util_tests/test_path_context.py b/python/tests/util_tests/test_path_context.py index 4ebba75ab4..acd181ddce 100644 --- a/python/tests/util_tests/test_path_context.py +++ b/python/tests/util_tests/test_path_context.py @@ -1,9 +1,9 @@ import os -from ecl.util.test import PathContext, TestAreaContext -from tests import EclTest +from resdata.util.test import PathContext, TestAreaContext +from tests import ResdataTest -class PathContextTest(EclTest): +class PathContextTest(ResdataTest): def test_error(self): with TestAreaContext("pathcontext"): # Test failure on creating PathContext with an existing path diff --git a/python/tests/util_tests/test_rng.py b/python/tests/util_tests/test_rng.py index 40d634e733..8674302a75 100644 --- a/python/tests/util_tests/test_rng.py +++ b/python/tests/util_tests/test_rng.py @@ -1,10 +1,10 @@ -from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum -from ecl.util.util import RandomNumberGenerator -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.enums import RngAlgTypeEnum, RngInitModeEnum +from resdata.util.util import RandomNumberGenerator +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class RngTest(EclTest): +class RngTest(ResdataTest): def test_enums(self): self.assertEnumIsFullyDefined( RngAlgTypeEnum, "rng_alg_type", "lib/include/ert/util/rng.hpp" diff --git a/python/tests/util_tests/test_spawn.py b/python/tests/util_tests/test_spawn.py index 8830dfc8b5..a1d7b4a309 100644 --- a/python/tests/util_tests/test_spawn.py +++ b/python/tests/util_tests/test_spawn.py @@ -2,16 +2,16 @@ import stat import sys -import ecl -from ecl import EclPrototype -from tests import EclTest -from ecl.util.test.test_area import TestAreaContext +import resdata +from resdata import ResdataPrototype +from tests import ResdataTest +from resdata.util.test.test_area import TestAreaContext from cwrap import Prototype class _TestSpawnPrototype(Prototype): - lib = EclPrototype.lib + lib = ResdataPrototype.lib def __init__(self, prototype, bind=True): super(_TestSpawnPrototype, self).__init__( @@ -19,7 +19,7 @@ def __init__(self, prototype, bind=True): ) -class SpawnTest(EclTest): +class SpawnTest(ResdataTest): _spawn = _TestSpawnPrototype( "int util_spawn_blocking(char*, int, void*, char*, char*)", bind=False ) diff --git a/python/tests/util_tests/test_string_list.py b/python/tests/util_tests/test_string_list.py index 5c4c13c1de..b4c6119834 100644 --- a/python/tests/util_tests/test_string_list.py +++ b/python/tests/util_tests/test_string_list.py @@ -1,6 +1,6 @@ from unittest import TestCase -from ecl.util.util import StringList +from resdata.util.util import StringList class StringListTest(TestCase): diff --git a/python/tests/util_tests/test_thread_pool.py b/python/tests/util_tests/test_thread_pool.py index 327b52a369..8e3b2aa1a2 100644 --- a/python/tests/util_tests/test_thread_pool.py +++ b/python/tests/util_tests/test_thread_pool.py @@ -1,10 +1,10 @@ import time -from ecl.util.util import ThreadPool -from ecl.util.util.thread_pool import Task -from tests import EclTest +from resdata.util.util import ThreadPool +from resdata.util.util.thread_pool import Task +from tests import ResdataTest -class ThreadPoolTest(EclTest): +class ThreadPoolTest(ResdataTest): def sleepTask(self, *args, **kwargs): time.sleep(args[0]) diff --git a/python/tests/util_tests/test_vectors.py b/python/tests/util_tests/test_vectors.py index 42141e3101..602e898075 100755 --- a/python/tests/util_tests/test_vectors.py +++ b/python/tests/util_tests/test_vectors.py @@ -8,7 +8,7 @@ except ImportError: from unittest import TestCase -from ecl.util.util import ( +from resdata.util.util import ( DoubleVector, IntVector, BoolVector, diff --git a/python/tests/util_tests/test_version.py b/python/tests/util_tests/test_version.py index 2125f77b1c..e57bfb8f11 100644 --- a/python/tests/util_tests/test_version.py +++ b/python/tests/util_tests/test_version.py @@ -1,11 +1,11 @@ import os.path -import ecl -from tests import EclTest -from ecl.util.util import Version, EclVersion +import resdata +from tests import ResdataTest +from resdata.util.util import Version, ResdataVersion -class VersionTest(EclTest): +class VersionTest(ResdataTest): def setUp(self): pass @@ -77,11 +77,11 @@ def test_ge(self): self.assertNotEqual(repr(v1), repr(v2)) def test_current(self): - current = EclVersion() + current = ResdataVersion() self.assertTrue(current > (0, 0, 0)) pfx = "Version(major=" self.assertEqual(pfx, repr(current)[: len(pfx)]) def test_root_version(self): - cv = EclVersion() + cv = ResdataVersion() self.assertEqual(ecl.__version__, cv.versionString()) diff --git a/python/tests/util_tests/test_work_area.py b/python/tests/util_tests/test_work_area.py index 8a429a3c3f..8b9f2124a5 100644 --- a/python/tests/util_tests/test_work_area.py +++ b/python/tests/util_tests/test_work_area.py @@ -7,11 +7,11 @@ except ImportError: from unittest import skipIf -from ecl.util.test import TestAreaContext -from tests import EclTest +from resdata.util.test import TestAreaContext +from tests import ResdataTest -class WorkAreaTest(EclTest): +class WorkAreaTest(ResdataTest): def test_full_path(self): with TestAreaContext("TestArea") as test_area: with open("test_file", "w") as fileH: diff --git a/python/tests/well_tests/test_rd_well.py b/python/tests/well_tests/test_rd_well.py index 8a75812e86..78ab4fcb59 100644 --- a/python/tests/well_tests/test_rd_well.py +++ b/python/tests/well_tests/test_rd_well.py @@ -1,10 +1,10 @@ import datetime -from ecl import EclFileFlagEnum -from ecl.eclfile import EclFile -from ecl.grid import EclGrid -from tests import EclTest, equinor_test -from ecl.util.util.ctime import CTime -from ecl.well import ( +from resdata import ResdataFileFlagEnum +from resdata.eclfile import ResdataFile +from resdata.grid import ResdataGrid +from tests import ResdataTest, equinor_test +from resdata.util.util.ctime import CTime +from resdata.well import ( WellInfo, WellConnection, WellTypeEnum, @@ -14,7 +14,7 @@ @equinor_test() -class EclWellTest(EclTest): +class ResdataWellTest(ResdataTest): ALL_WELLS = [ "E5H", "G1H", @@ -242,12 +242,12 @@ class EclWellTest(EclTest): @classmethod def setUpClass(cls): - EclWellTest.__well_info = None - EclWellTest.__well_info_with_no_well_segments = None + ResdataWellTest.__well_info = None + ResdataWellTest.__well_info_with_no_well_segments = None def getWellInfoWithNoWellSegments(self): """@rtype: WellInfo""" - if EclWellTest.__well_info_with_no_well_segments is None: + if ResdataWellTest.__well_info_with_no_well_segments is None: grid_path = self.createTestPath( "Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID" ) @@ -255,19 +255,19 @@ def getWellInfoWithNoWellSegments(self): "Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135" ) - grid = EclGrid(grid_path) + grid = ResdataGrid(grid_path) - rst_file = EclFile(rst_path_1, EclFileFlagEnum.ECL_FILE_CLOSE_STREAM) + rst_file = ResdataFile(rst_path_1, ResdataFileFlagEnum.RD_FILE_CLOSE_STREAM) - EclWellTest.__well_info_with_no_well_segments = WellInfo( + ResdataWellTest.__well_info_with_no_well_segments = WellInfo( grid, rst_file, False ) - return EclWellTest.__well_info_with_no_well_segments + return ResdataWellTest.__well_info_with_no_well_segments def getWellInfo(self): """@rtype: WellInfo""" - if EclWellTest.__well_info is None: + if ResdataWellTest.__well_info is None: grid_path = self.createTestPath( "Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID" ) @@ -275,19 +275,19 @@ def getWellInfo(self): "Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135" ) - grid = EclGrid(grid_path) + grid = ResdataGrid(grid_path) - rst_file = EclFile(rst_path_1, EclFileFlagEnum.ECL_FILE_CLOSE_STREAM) + rst_file = ResdataFile(rst_path_1, ResdataFileFlagEnum.RD_FILE_CLOSE_STREAM) - EclWellTest.__well_info = WellInfo(grid, rst_file) + ResdataWellTest.__well_info = WellInfo(grid, rst_file) - return EclWellTest.__well_info + return ResdataWellTest.__well_info def test_no_such_well(self): grid_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") rst_path1 = self.createTestPath("nosuch/path/ECLIPSE.X001") rst_path2 = self.createTestPath("nosuch/path/ECLIPSE.X002") - grid = EclGrid(grid_path) + grid = ResdataGrid(grid_path) with self.assertRaises(IOError): _ = WellInfo(grid, rst_path1) with self.assertRaises(IOError): @@ -300,7 +300,7 @@ def test_construction(self): rst_path_3 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0035") rst_path_4 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0061") - grid = EclGrid(grid_path) + grid = ResdataGrid(grid_path) def checkWellInfo(well_info, well_count, report_step_count): self.assertEqual(len(well_info), well_count) @@ -311,7 +311,7 @@ def checkWellInfo(well_info, well_count, report_step_count): well_info = WellInfo(grid, rst_path_1) checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) - well_info = WellInfo(grid, EclFile(rst_path_1)) + well_info = WellInfo(grid, ResdataFile(rst_path_1)) checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) well_info = WellInfo(grid, [rst_path_1, rst_path_2, rst_path_3]) @@ -321,7 +321,12 @@ def checkWellInfo(well_info, well_count, report_step_count): well_info = WellInfo( grid, - [EclFile(rst_path_1), EclFile(rst_path_2), rst_path_3, EclFile(rst_path_4)], + [ + ResdataFile(rst_path_1), + ResdataFile(rst_path_2), + rst_path_3, + ResdataFile(rst_path_4), + ], ) checkWellInfo( well_info, well_count=8, report_step_count=[4, 4, 4, 4, 4, 3, 3, 3] @@ -332,12 +337,12 @@ def checkWellInfo(well_info, well_count, report_step_count): checkWellInfo(well_info, well_count=5, report_step_count=[1, 1, 1, 1, 1]) - well_info.addWellFile(EclFile(rst_path_2), True) + well_info.addWellFile(ResdataFile(rst_path_2), True) checkWellInfo( well_info, well_count=8, report_step_count=[2, 2, 2, 2, 2, 1, 1, 1] ) - well_info.addWellFile(EclFile(rst_path_3), True) + well_info.addWellFile(ResdataFile(rst_path_3), True) checkWellInfo( well_info, well_count=8, report_step_count=[3, 3, 3, 3, 3, 2, 2, 2] ) @@ -348,12 +353,12 @@ def checkWellInfo(well_info, well_count, report_step_count): ) def test_well_type_enum(self): - source_file_path = "lib/include/ert/ecl_well/well_conn.hpp" + source_file_path = "lib/include/resdata/well/well_conn.hpp" # The header file has duplicated symbols, so the simple test fails. # self.assertEnumIsFullyDefined(WellTypeEnum, "well_type_enum", source_file_path) def test_well_connection_direction_enum(self): - source_file_path = "lib/include/ert/ecl_well/well_conn.hpp" + source_file_path = "lib/include/resdata/well/well_conn.hpp" self.assertEnumIsFullyDefined( WellConnectionDirectionEnum, "well_conn_dir_enum", source_file_path ) @@ -365,7 +370,7 @@ def test_well_info(self): all_well_names = well_info.allWellNames() self.assertEqual(len(well_info), len(all_well_names)) - self.assertEqual(EclWellTest.ALL_WELLS, all_well_names) + self.assertEqual(ResdataWellTest.ALL_WELLS, all_well_names) for well_name in all_well_names: self.assertTrue(well_name in well_info) @@ -392,14 +397,14 @@ def test_well_time_line(self): self.assertEqual(len(well_time_line), 1) well_states = set() - for well_name in EclWellTest.ALL_WELLS: + for well_name in ResdataWellTest.ALL_WELLS: well_time_line = well_info[well_name] well_states.add(well_time_line[0]) with self.assertRaises(IndexError): err = well_time_line[1] - self.assertEqual(len(well_states), len(EclWellTest.ALL_WELLS)) + self.assertEqual(len(well_states), len(ResdataWellTest.ALL_WELLS)) # testing name and repr info = self.getWellInfo() @@ -413,7 +418,7 @@ def test_well_time_line(self): # testing __getitem__ and its well state ws = wtl[0] self.assertTrue(ws.isOpen()) - self.assertEqual(ws.wellType(), WellTypeEnum.ECL_WELL_PRODUCER) + self.assertEqual(ws.wellType(), WellTypeEnum.RD_WELL_PRODUCER) self.assertTrue(ws.isMultiSegmentWell()) pfx = "WellState(" self.assertEqual(pfx, repr(ws)[: len(pfx)]) @@ -425,11 +430,11 @@ def test_well_state(self): open_states = {True: 0, False: 0} msw_states = {True: 0, False: 0} well_types = { - WellTypeEnum.ECL_WELL_ZERO: 0, - WellTypeEnum.ECL_WELL_PRODUCER: 0, - WellTypeEnum.ECL_WELL_GAS_INJECTOR: 0, - WellTypeEnum.ECL_WELL_OIL_INJECTOR: 0, - WellTypeEnum.ECL_WELL_WATER_INJECTOR: 0, + WellTypeEnum.RD_WELL_ZERO: 0, + WellTypeEnum.RD_WELL_PRODUCER: 0, + WellTypeEnum.RD_WELL_GAS_INJECTOR: 0, + WellTypeEnum.RD_WELL_OIL_INJECTOR: 0, + WellTypeEnum.RD_WELL_WATER_INJECTOR: 0, } segments = set() @@ -437,7 +442,7 @@ def test_well_state(self): connections = set() connections_count = 0 - for index, well_name in enumerate(EclWellTest.ALL_WELLS): + for index, well_name in enumerate(ResdataWellTest.ALL_WELLS): well_time_line = well_info[well_name] well_state = well_time_line[0] @@ -467,11 +472,11 @@ def test_well_state(self): self.assertEqual(msw_states[True], 169) self.assertEqual(msw_states[False], 53) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_ZERO], 0) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_WATER_INJECTOR], 0) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_OIL_INJECTOR], 0) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_GAS_INJECTOR], 1) - self.assertEqual(well_types[WellTypeEnum.ECL_WELL_PRODUCER], 221) + self.assertEqual(well_types[WellTypeEnum.RD_WELL_ZERO], 0) + self.assertEqual(well_types[WellTypeEnum.RD_WELL_WATER_INJECTOR], 0) + self.assertEqual(well_types[WellTypeEnum.RD_WELL_OIL_INJECTOR], 0) + self.assertEqual(well_types[WellTypeEnum.RD_WELL_GAS_INJECTOR], 1) + self.assertEqual(well_types[WellTypeEnum.RD_WELL_PRODUCER], 221) self.assertEqual(len(connections), connections_count) @@ -1364,5 +1369,5 @@ def test_load_broken_direction(self): rst_path = self.createTestPath( "Equinor/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.UNRST" ) - grid = EclGrid(grid_path) + grid = ResdataGrid(grid_path) well_info = WellInfo(grid, rst_path) diff --git a/python/tests/well_tests/test_rd_well2.py b/python/tests/well_tests/test_rd_well2.py index d27f409391..e3a48c671d 100644 --- a/python/tests/well_tests/test_rd_well2.py +++ b/python/tests/well_tests/test_rd_well2.py @@ -1,12 +1,12 @@ import datetime import os.path -from ecl import EclFileFlagEnum -from ecl.eclfile import EclFile -from ecl.grid import EclGrid -from tests import EclTest, equinor_test -from ecl.util.util.ctime import CTime -from ecl.well import ( +from resdata import ResdataFileFlagEnum +from resdata.eclfile import ResdataFile +from resdata.grid import ResdataGrid +from tests import ResdataTest, equinor_test +from resdata.util.util.ctime import CTime +from resdata.well import ( WellInfo, WellConnection, WellTypeEnum, @@ -16,18 +16,18 @@ @equinor_test() -class EclWellTest2(EclTest): +class ResdataWellTest2(ResdataTest): grid = None def getGrid(self): - if EclWellTest2.grid is None: - EclWellTest2.grid = EclGrid( + if ResdataWellTest2.grid is None: + ResdataWellTest2.grid = ResdataGrid( self.createTestPath( "Equinor/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID" ) ) - return EclWellTest2.grid + return ResdataWellTest2.grid def checkWell(self, rst_file): segment_length = [ diff --git a/python/tests/well_tests/test_rd_well3.py b/python/tests/well_tests/test_rd_well3.py index 16056fb6f2..8d4840b5b5 100644 --- a/python/tests/well_tests/test_rd_well3.py +++ b/python/tests/well_tests/test_rd_well3.py @@ -1,12 +1,12 @@ import datetime import os.path -from ecl.eclfile import EclFile -from ecl.grid import EclGrid -from ecl.summary import EclSum -from tests import EclTest, equinor_test -from ecl.util.util.ctime import CTime -from ecl.well import ( +from resdata.eclfile import ResdataFile +from resdata.grid import ResdataGrid +from resdata.summary import RdSum +from tests import ResdataTest, equinor_test +from resdata.util.util.ctime import CTime +from resdata.well import ( WellInfo, WellConnection, WellTypeEnum, @@ -16,7 +16,7 @@ @equinor_test() -class EclWellTest3(EclTest): +class ResdataWellTest3(ResdataTest): grid = None def test_rates(self): @@ -24,9 +24,9 @@ def test_rates(self): rst_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") sum_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") - grid = EclGrid(grid_path) + grid = ResdataGrid(grid_path) well_info = WellInfo(grid, rst_path) - sum = EclSum(sum_path) + sum = RdSum(sum_path) for wtl in well_info: for well_state in wtl: diff --git a/python/tests/well_tests/test_well_missing_ICON.py b/python/tests/well_tests/test_well_missing_ICON.py index 3f269f2882..c128dd5fc9 100644 --- a/python/tests/well_tests/test_well_missing_ICON.py +++ b/python/tests/well_tests/test_well_missing_ICON.py @@ -1,7 +1,7 @@ import datetime -from tests import EclTest -from ecl.grid import EclGridGenerator -from ecl.well import ( +from tests import ResdataTest +from resdata.grid import ResdataGridGenerator +from resdata.well import ( WellInfo, WellConnection, WellTypeEnum, @@ -10,9 +10,9 @@ ) -class EclWellICONTest(EclTest): +class ResdataWellICONTest(ResdataTest): def setUp(self): - self.grid = EclGridGenerator.create_rectangular((46, 112, 22), (1, 1, 1)) + self.grid = ResdataGridGenerator.create_rectangular((46, 112, 22), (1, 1, 1)) self.rst_file_ICON0 = self.createTestPath( "local/ECLIPSE/well/missing-ICON/ICON0.X0027" ) diff --git a/python/txt-doc/devel.txt b/python/txt-doc/devel.txt index 5721bffbf3..a5811c2590 100644 --- a/python/txt-doc/devel.txt +++ b/python/txt-doc/devel.txt @@ -180,7 +180,7 @@ file implements one struct; this struct is wrapped in a Python module with the same name and a Python class with CamelCaps naming: C Python - ecl_kw.c implements ecl_kw_type ecl_kw.py implements EclKW + rd_kw.c implements rd_kw_type rd_kw.py implements ResdataKW @@ -204,26 +204,26 @@ to complete) follow roughly the same structure: } -The following excerpt from ecl_kw.y illustrates this: +The following excerpt from rd_kw.y illustrates this: ------------------------------------------------------------ # Load the shared library import resdata <--- Step 1 - Class EclKW: <-------------� - # Pure Python code to implement the EclKW class, | + Class ResdataKW: <-------------� + # Pure Python code to implement the ResdataKW class, | # based on the functions prototyped below. | Step 3 .... <-------------� # Create a wrapper instance which wraps the resdata library. <-------� cwrapper = CWrapper( resdata.lib ) | | - # Register the type mapping "ecl_kw" <-> EclKW | Step 2 - cwrapper.registerType( "ecl_kw" , EclKW ) | + # Register the type mapping "rd_kw" <-> ResdataKW | Step 2 + cwrapper.registerType( "rd_kw" , ResdataKW ) | | # Prototype the functions needed to implement the Python class | - cfunc.alloc_new = cwrapper.prototype("long ecl_kw_alloc( char* , int , int )") - cfunc.free = cwrapper.prototype("void ecl_kw_free( ecl_kw )") | + cfunc.alloc_new = cwrapper.prototype("long rd_kw_alloc( char* , int , int )") + cfunc.free = cwrapper.prototype("void rd_kw_free( rd_kw )") | .... <--------� ------------------------------------------------------------ @@ -273,31 +273,31 @@ string and assigns the correct restype and argtypes attributes. All the calls to the prototype() method are typically assembled in the bottom of the file implementing a class defintion. E.g. the bottom of -the ecl_kw.py file looks like this: +the rd_kw.py file looks like this: # 1: Load the shared library cwrapper = CWrapper( resdata.lib ) - # 2: Register type mapping ecl_kw <--> EclKW - cwrapper.registerType( "ecl_kw" , EclKW ) + # 2: Register type mapping rd_kw <--> ResdataKW + cwrapper.registerType( "rd_kw" , ResdataKW ) # 3: Prototype the C functions we will use from Python - cfunc = CWrapperNameSpace("ecl_kw") - cfunc.get_size = cwrapper.prototype("int ecl_kw_get_size( ecl_kw )") - cfunc.get_type = cwrapper.prototype("int ecl_kw_get_type( ecl_kw )") - cfunc.iget_char_ptr = cwrapper.prototype("char* ecl_kw_iget_char_ptr( ecl_kw , int )") - cfunc.iset_char_ptr = cwrapper.prototype("void ecl_kw_iset_char_ptr( ecl_kw , int , char*)") - cfunc.iget_bool = cwrapper.prototype("bool ecl_kw_iget_bool( ecl_kw , int)") - cfunc.iset_bool = cwrapper.prototype("bool ecl_kw_iset_bool( ecl_kw , int, bool)") - cfunc.alloc_new = cwrapper.prototype("c_void_p ecl_kw_alloc( char* , int , int )") + cfunc = CWrapperNameSpace("rd_kw") + cfunc.get_size = cwrapper.prototype("int rd_kw_get_size( rd_kw )") + cfunc.get_type = cwrapper.prototype("int rd_kw_get_type( rd_kw )") + cfunc.iget_char_ptr = cwrapper.prototype("char* rd_kw_iget_char_ptr( rd_kw , int )") + cfunc.iset_char_ptr = cwrapper.prototype("void rd_kw_iset_char_ptr( rd_kw , int , char*)") + cfunc.iget_bool = cwrapper.prototype("bool rd_kw_iget_bool( rd_kw , int)") + cfunc.iset_bool = cwrapper.prototype("bool rd_kw_iset_bool( rd_kw , int, bool)") + cfunc.alloc_new = cwrapper.prototype("c_void_p rd_kw_alloc( char* , int , int )") .... .... This makes the function cfunc.get_size, cfunc.get_type, cfunc.iget_char_ptr, ... available as first class Python functions, and the Python classes can be implemented based on these -functions. Observe that the return value from "ecl_kw_alloc()" is -c_void_p' and not ecl_kw - that is because this return value is +functions. Observe that the return value from "rd_kw_alloc()" is +c_void_p' and not rd_kw - that is because this return value is internalized in the c_ptr of the object (this is not particularly elegant, and could probably be improved upon..??). @@ -326,13 +326,13 @@ roughly the same structure: * The __init__() function, or alternatively a classmethod constructor calls the C based constructor, like - e.g. ecl_grid_alloc() and internalize the return value in the + e.g. rd_grid_alloc() and internalize the return value in the attribute 'c_ptr'; alternatively the c_ptr might come as a shared reference from another function. * The __del__ function is called when the Python object is garbage collected, then the corresponding C free function should be - called, e.g. ecl_grid_free(). + called, e.g. rd_grid_free(). @@ -353,18 +353,18 @@ the C based destructor can be called. The important point is that it differs from case to case whether the C based constructor should indeed be called. -The EclKW class illustrates this quite well. Broadly speaking you can -instantiate an EclKW instance in two ways: +The ResdataKW class illustrates this quite well. Broadly speaking you can +instantiate an ResdataKW instance in two ways: - * Through the EclwKW.new() function - * As a reference to an existing ecl_kw through an EclFile instance. + * Through the ResdatawKW.new() function + * As a reference to an existing rd_kw through an ResdataFile instance. -In the first case the c_ptr of the EclKW instance will point to fresh -storage dedicated to this EclKW, and when the EclKW instance goes out +In the first case the c_ptr of the ResdataKW instance will point to fresh +storage dedicated to this ResdataKW, and when the ResdataKW instance goes out of scope the memory should be freed with a call to the C function -ecl_kw_free(). +rd_kw_free(). - EclKW (Python) ecl_kw (C) + ResdataKW (Python) rd_kw (C) c_ptr | --------- \--------------->| PORO | @@ -377,14 +377,14 @@ ecl_kw_free(). --------- -In the second case an EclFile instance has been created, and this -object points to ecl_file C struct which is essentially a container -containing many ecl_kw instances. We can then query the EclFile -instance to get reference to the various ecl_kw keywords, i.e. for a +In the second case an ResdataFile instance has been created, and this +object points to rd_file C struct which is essentially a container +containing many rd_kw instances. We can then query the ResdataFile +instance to get reference to the various rd_kw keywords, i.e. for a small restart file: -EclFile (Python) ecl_file (C) EclKW (Python) +ResdataFile (Python) rd_file (C) ResdataKW (Python) c_ptr c_ptr | ------------ | \---------------->| PRESSURE | | @@ -396,17 +396,17 @@ EclFile (Python) ecl_file (C) EclKW (Python) The situaton above (which is quite typical) could for instance come about from: - restart_file = ecl.EclFile( "ECLIPSE.X0057" ) + restart_file = ecl.ResdataFile( "ECLIPSE.X0057" ) sgas_kw = restart_file.iget_named_kw( "SGAS" , 0 ) Now, when the sgas_kw object goes out of scope it is important that -the SGAS ecl_kw in the ecl_file file container is _NOT_ deleted, that -keyword is owned by the ecl_file container and the whole thing will -crash and burn if the ecl_kw is destroyed bypassing the container. The +the SGAS rd_kw in the rd_file file container is _NOT_ deleted, that +keyword is owned by the rd_file container and the whole thing will +crash and burn if the rd_kw is destroyed bypassing the container. The sgas keyword will be destroyed when the restart_file object goes out scope at a later stage. -To facilitate this difference in behaviour when an EclKW goes out +To facilitate this difference in behaviour when an ResdataKW goes out scope the object contains a field 'data_owner', and the __del__() method looks like this: diff --git a/python/txt-doc/import.txt b/python/txt-doc/import.txt index acfb489690..f8e3327148 100644 --- a/python/txt-doc/import.txt +++ b/python/txt-doc/import.txt @@ -93,10 +93,10 @@ look something like this: ert/ <-- Top level package / directory. ert/__init__.py <-- Magic file signalling that 'ert' is a package. - ert/ecl/ <-- ecl is subpackage. - ert/ecl/__init__.py <-- Magic file signalling that 'ecl' is a package. - ert/ecl/ecl_grid.py <-- Normal module in the ecl package. - ert/ecl/ecl_sum.py <-- Normal module in the ecl package. + resdata/ <-- ecl is subpackage. + resdata/__init__.py <-- Magic file signalling that 'ecl' is a package. + resdata/rd_grid.py <-- Normal module in the ecl package. + resdata/rd_sum.py <-- Normal module in the ecl package. .... ert/util/ <-- The util subpackage. ert/util/__init__.py <-- Magic file that 'util' is a package. @@ -126,32 +126,32 @@ translated to a dotted notation in package/module space. The statement 'import ert.ecl' will import the ert.ecl subpackage, but this is still not any symbols usable for anything. Observe that the 'import ert.ecl' statement will evaluate the '__init__.py' files found along the -way. ecl_grid.py is a module in the ecl package, so this statement will +way. rd_grid.py is a module in the ecl package, so this statement will finally give us something usable: - import ert.ecl.ecl_grid + import ert.ecl.rd_grid -The module ecl_grid contains the implementation of the EclGrid class -which can actually be used for something. To instantiate an EclGrid +The module rd_grid contains the implementation of the ResdataGrid class +which can actually be used for something. To instantiate an ResdataGrid instance we have to go through the following hoops: - import ert.ecl.ecl_grid + import ert.ecl.rd_grid .... .... - grid = ert.ecl.ecl_grid.EclGrid( "ECLIPSE.EGRID" ) + grid = ert.ecl.rd_grid.ResdataGrid( "ECLIPSE.EGRID" ) | | | | | | | | Package--/ | | \-------- Symbol (Class definition) | | Subpackage ---/ \---- Module -The 'ert.ecl.ecl_grid' namespace is quite massive. It is easy to +The 'ert.ecl.rd_grid' namespace is quite massive. It is easy to simplify this using the from import as: - from ert.ecl.ecl_grid import EclGrid <-- Explicitly import symbol + from ert.ecl.rd_grid import ResdataGrid <-- Explicitly import symbol .... into current namespace. .... - grid = EclGrid( "ECLIPSE.EGRID" ) + grid = ResdataGrid( "ECLIPSE.EGRID" ) By convention the ert python distribution offers some limited simplifications of this procedure. @@ -161,17 +161,17 @@ simplifications of this procedure. When issuing the import statement: - import ert.ecl.ecl_grid + import ert.ecl.rd_grid The directory 'ert/' must be on PYTHONPATH. In principle it is possible to circumvent the lowest level packge, and go directly to the 'ecl' subpackage: - import ecl.ecl_grid + import resdata.rd_grid -but then the 'ecl/' directory must be on PYTHONPATH. For the default +but then the 'resdata/' directory must be on PYTHONPATH. For the default ert-python distribution only the 'ert/' directory will be on the import -path, i.e. the "import ecl.ecl_grid' will not work directly. +path, i.e. the "import resdata.rd_grid' will not work directly. 4. Conventions applied in ert @@ -191,9 +191,9 @@ they can of course be changed: the symbols from all the modules in the package with no namespace prefix, i.e. the ecl module looks like: - from ecl_grid import EclGrid - from ecl_region import EclRegion - from ecl_kw import EclKW + from rd_grid import ResdataGrid + from rd_region import ResdataRegion + from rd_kw import ResdataKW ..... The point of this is a minor simplification, you can then issue @@ -201,14 +201,14 @@ they can of course be changed: from ert.ecl.ecl import * .... - grid = EclGrid("ECLIPSE.EGRID") + grid = ResdataGrid("ECLIPSE.EGRID") To get all the symbols from the ecl package directly into the current namespace, or alternatively you can use import ert.ecl.ecl as ecl .... - grid = ecl.EclGrid("ECLIPSE.EGRID") + grid = ecl.ResdataGrid("ECLIPSE.EGRID") and then use all the symbols from the ecl package under the common 'ecl' prefix. The functionality of the xxx module in the diff --git a/python/txt-doc/install.txt b/python/txt-doc/install.txt index b75ce33687..149b1f9b80 100644 --- a/python/txt-doc/install.txt +++ b/python/txt-doc/install.txt @@ -71,10 +71,10 @@ ert-python: 2. The runtime linker can not find one of the shared libraries: - import ert.ecl.ecl_grid + import resdata.grid.rd_grid Traceback (most recent call last): File "", line 1, in - File "ert/ecl/ecl_grid.py", line 30, in + File "resdata/rd_grid.py", line 30, in from ert.util.tvector import DoubleVector # Requires merging of typemaps .... File "ert/util/tvector.py", line 46, in import libutil diff --git a/python/txt-doc/tips.txt b/python/txt-doc/tips.txt index 4ad2935ccf..e898e3ebf3 100644 --- a/python/txt-doc/tips.txt +++ b/python/txt-doc/tips.txt @@ -345,7 +345,7 @@ restart information. The story goes about like this: c) Keywords which can be ignored, e.g. SOMAX and RPORV. - ERT uses the function ecl_config_include_static_kw() to + ERT uses the function rd_config_include_static_kw() to differentiate between cases b) and c). 2. For the static keywords which ERT determines it needs to store, diff --git a/setup.py b/setup.py index ce048a0df0..6279b0eda7 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ import os import sys -import skbuild + import setuptools +import skbuild from setuptools_scm import get_version - -version = get_version(relative_to=__file__, write_to="python/ecl/version.py") +version = get_version(relative_to=__file__, write_to="python/resdata/version.py") # Corporate networks tend to be behind a proxy server with their own non-public @@ -25,19 +25,19 @@ def utility_wrappers(): """ - Wrappers around ecl's "application" utilities. These are only supported on + Wrappers around resdata's "application" utilities. These are only supported on Linux at this time so only create the wrapper when on Linux. """ if sys.platform != "linux": return [] return [ - name + " = ecl.bin:main" + name + " = resdata.bin:main" for name in ( "CF_dump", "convert.x", - "ecl_pack.x", - "ecl_unpack.x", + "rd_pack.x", + "rd_unpack.x", "grdecl_grid", "grdecl_test.x", "grid_dump.x", @@ -56,13 +56,13 @@ def utility_wrappers(): skbuild.setup( - name="ecl", + name="resdata", author="Equinor ASA", author_email="fg_sib-scout@equinor.com", - description="Package for reading and writing the result files from the ECLIPSE reservoir simulator", + description="Package for reading and writing the fortran result files from reservoir simulators", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/equinor/ecl", + url="https://github.com/equinor/resdata", packages=setuptools.find_packages( where="python", exclude=["*.tests", "*.tests.*", "tests.*", "tests", "ert.*", "ert"], @@ -77,12 +77,12 @@ def utility_wrappers(): ], entry_points={"console_scripts": utility_wrappers()}, cmake_args=[ - "-DECL_VERSION=" + version, + "-DRD_VERSION=" + version, "-DBUILD_APPLICATIONS=" + ("ON" if sys.platform == "linux" else "OFF"), "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", - "-DCMAKE_INSTALL_BINDIR=python/ecl/.bin", - "-DCMAKE_INSTALL_LIBDIR=python/ecl/.libs", - "-DCMAKE_INSTALL_INCLUDEDIR=python/ecl/.include", + "-DCMAKE_INSTALL_BINDIR=python/resdata/.bin", + "-DCMAKE_INSTALL_LIBDIR=python/resdata/.libs", + "-DCMAKE_INSTALL_INCLUDEDIR=python/resdata/.include", # we can safely pass OSX_DEPLOYMENT_TARGET as it's ignored on # everything not OS X. We depend on C++11, which makes our minimum # supported OS X release 10.9 diff --git a/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA b/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA index d1447bee5a..5f88d3f294 100644 --- a/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA +++ b/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA @@ -650,7 +650,7 @@ COMPSEGS / -WELSPECL +WELSPRD 'I1' 'WIA' 'WELLI1' 5 5 1* 'WATER' / Injector 'I1_GI' 'WIA' 'WELLI1' 5 5 1* 'GAS' / Injector /