diff --git a/ThirdParty/Ert/.github/CODEOWNERS b/ThirdParty/Ert/.github/CODEOWNERS new file mode 100644 index 0000000000..a931a3003f --- /dev/null +++ b/ThirdParty/Ert/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# These owners will be the default owners for everything in the repo. +* @markusdregi @lars-petter-hauge @andreabrambilla @pgdr @jokva @xjules diff --git a/ThirdParty/Ert/.github/PULL_REQUEST_TEMPLATE.md b/ThirdParty/Ert/.github/PULL_REQUEST_TEMPLATE.md index adf85eaeb6..3ea367d2a9 100644 --- a/ThirdParty/Ert/.github/PULL_REQUEST_TEMPLATE.md +++ b/ThirdParty/Ert/.github/PULL_REQUEST_TEMPLATE.md @@ -1,10 +1,5 @@ -**Task** -_Short description of the task_ - +**Issue** +Resolves # **Approach** _Short description of the approach_ - - -**Pre un-WIP checklist** -- [ ] Statoil tests pass locally diff --git a/ThirdParty/Ert/.gitignore b/ThirdParty/Ert/.gitignore index b835bff007..b92bed604e 100644 --- a/ThirdParty/Ert/.gitignore +++ b/ThirdParty/Ert/.gitignore @@ -11,8 +11,9 @@ python/lib64 /libenkf/src/.faultlist /develbranch/libenkf/src/.faultlist /build +/temp-build /libert_util/tests/data/latex_OK.pdf -/test-data/Statoil +/test-data/Equinor /python/python/ert/ecl/ecl_local.py /GPATH /GRTAGS diff --git a/ThirdParty/Ert/.gitmodules b/ThirdParty/Ert/.gitmodules new file mode 100644 index 0000000000..347fe93043 --- /dev/null +++ b/ThirdParty/Ert/.gitmodules @@ -0,0 +1,3 @@ +[submodule "multibuild"] + path = multibuild + url = https://github.com/matthew-brett/multibuild.git diff --git a/ThirdParty/Ert/.travis.yml b/ThirdParty/Ert/.travis.yml index 6fdc81f1a6..9bef0ca2d6 100644 --- a/ThirdParty/Ert/.travis.yml +++ b/ThirdParty/Ert/.travis.yml @@ -1,82 +1,70 @@ -language: c - -compiler: - - gcc - - clang +language: python +python: + - 2.7 + - 3.6 os: - linux - - osx -osx_image: xcode7.3 -sudo: false -dist: trusty +sudo: required +services: docker env: global: - ERT_SHOW_BACKTRACE=1 - - LD_LIBRARY_PATH="$(pwd)/install/lib64" + - MB_PYTHON_VERSION=$TRAVIS_PYTHON_VERSION matrix: - - PYTHON_VERSION=2.7 TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow - - PYTHON_VERSION=2.7 TEST_SUITE="-L SLOW_1" # Run all tests labeled as SLOW in group 1 - - PYTHON_VERSION=2.7 TEST_SUITE="-L SLOW_2" # Run all tests labeled as SLOW in group 2 - - PYTHON_VERSION=3.6 # Run all tests + - TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow + - TEST_SUITE="-L SLOW_1" # Run all tests labeled as SLOW in group 1 + - TEST_SUITE="-L SLOW_2" # Run all tests labeled as SLOW in group 2 matrix: fast_finish: true - exclude: + include: - os: osx - compiler: gcc - - os: linux - compiler: clang + language: generic + python: 2.7 + env: + - MB_PYTHON_VERSION=2.7 + - TEST_SUITE="" + - os: osx + language: generic + python: 3.6 + env: + - MB_PYTHON_VERSION=3.6 + - TEST_SUITE="" addons: apt: - sources: - - ubuntu-toolchain-r-test packages: - liblapack-dev - - valgrind - - gcc-4.8 - - g++-4.8 - - clang - - cmake - - cmake-data +before_install: + - unset -f pushd + - unset -f popd + - source multibuild/common_utils.sh + - source multibuild/travis_steps.sh + - before_install install: - - if [[ "$CC" == "gcc" ]]; then export CXX="g++-4.8"; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - export CONDA_OS=MacOSX; - else - export CONDA_OS=Linux; - fi - - if [[ $PYTHON_VERSION == 2.7 ]]; then - export TRAVIS_PYTHON_VERSION="2.7"; - fi - - if [[ $PYTHON_VERSION == 3.6 ]]; then - export TRAVIS_PYTHON_VERSION="3.6"; - fi - # We do this conditionally because it saves us some downloading if the version is the same. - - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then - wget https://repo.continuum.io/miniconda/Miniconda2-latest-${CONDA_OS}-x86_64.sh -O miniconda.sh; - else - wget https://repo.continuum.io/miniconda/Miniconda3-4.4.10-${CONDA_OS}-x86_64.sh -O miniconda.sh; - fi - - bash miniconda.sh -b -p $HOME/miniconda - - export CONDA_HOME="$HOME/miniconda" - - export PATH="$CONDA_HOME/bin:$PATH" - - hash -r - - python --version - pip install -r requirements.txt - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - - conda info -a # Useful for debugging any issues with conda - - wget https://raw.githubusercontent.com/Statoil/ert/master/travis/install_python_packages.py - - python install_python_packages.py - -before_script: - - wget https://raw.githubusercontent.com/Statoil/ert/master/travis/build_total.py script: - - python build_total.py ecl ${TEST_SUITE} + - mkdir build + - pushd build + - cmake .. -DBUILD_TESTS=ON + -DENABLE_PYTHON=ON + -DINSTALL_CWRAP=OFF + -DBUILD_APPLICATIONS=ON + -DINSTALL_ERT_LEGACY=ON + -DERT_USE_OPENMP=ON + -DCMAKE_C_FLAGS='-Werror=all' + -DCMAKE_CXX_FLAGS='-Werror -Wno-unused-result' + - make + - sudo make install + - which python + - export PYTHONPATH="/usr/local/lib/python$MB_PYTHON_VERSION/site-packages:/usr/local/lib/python$MB_PYTHON_VERSION/dist-packages:$PYTHONPATH" + - python -c "import sys; print('\n'.join(sys.path))" + - set -e; python -c "import ecl"; set +e + - ctest --output-on-failure $TEST_SUITE + - popd diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 5e2e1e42b4..36417d18e7 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -11,7 +11,7 @@ endif() #----------------------------------------------------------------- set( ECL_VERSION_MAJOR 2 ) # Remember to update release notes whenever -set( ECL_VERSION_MINOR 3 ) # you change the ERT_VERSION_MINOR or MAJOR +set( ECL_VERSION_MINOR 4 ) # you change the ERT_VERSION_MINOR or MAJOR set( ECL_VERSION_MICRO git ) # with "new in Ert Version X.X.X"! # If the micro version is not integer, that should be interpreted as a @@ -51,23 +51,22 @@ option( ENABLE_PYTHON "Build and install the Python wrappers" option( BUILD_SHARED_LIBS "Build shared libraries" ON ) option( ERT_USE_OPENMP "Use OpenMP" OFF ) option( RST_DOC "Build RST documentation" OFF) -option( ERT_BUILD_CXX "Build some CXX wrappers" ON) option( USE_RPATH "Don't strip RPATH from libraries and binaries" OFF) option( INSTALL_ERT_LEGACY "Add ert legacy wrappers" OFF) -set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata") -if (EXISTS ${STATOIL_TESTDATA_ROOT}) - set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Statoil" ) +set(EQUINOR_TESTDATA_ROOT "" CACHE PATH "Root to Equinor internal testdata") +if (EXISTS ${EQUINOR_TESTDATA_ROOT}) + set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Equinor" ) if (EXISTS ${LINK}) EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${LINK}") endif() - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${STATOIL_TESTDATA_ROOT}" "${LINK}") - message(STATUS "Linking testdata: ${LINK} -> ${STATOIL_TESTDATA_ROOT}") + EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${EQUINOR_TESTDATA_ROOT}" "${LINK}") + message(STATUS "Linking testdata: ${LINK} -> ${EQUINOR_TESTDATA_ROOT}") - set(_statoil_test_data ${CMAKE_SOURCE_DIR}/test-data/Statoil) - set(_eclpath ${_statoil_test_data}/ECLIPSE) - set(_geopath ${_statoil_test_data}/Geometry) + set(_equinor_test_data ${CMAKE_SOURCE_DIR}/test-data/Equinor) + set(_eclpath ${_equinor_test_data}/ECLIPSE) + set(_geopath ${_equinor_test_data}/Geometry) endif() @@ -116,7 +115,7 @@ endif() # Treat warnings as errors if not on Windows if (NOT ERT_WINDOWS) set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wno-unknown-pragmas ") - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas -Wno-unused-result -Wno-unused-parameter" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -Wall -Wno-unknown-pragmas -Wno-unused-result -Wno-unused-parameter" ) endif() if (MSVC) @@ -339,11 +338,6 @@ if (ENABLE_PYTHON) # fails in the python/CMakeLists.txt file the ENABLE_PYTHON # will be set to OFF. add_subdirectory( python ) - - if(RST_DOC) - add_subdirectory( docs ) - endif() - endif() if (ENABLE_PYTHON) @@ -352,9 +346,6 @@ if (ENABLE_PYTHON) endif() endif() -if (INSTALL_ERT) - install(EXPORT ecl-config DESTINATION share/cmake/ecl) -endif() - +install(EXPORT ecl-config DESTINATION share/cmake/ecl) export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/README.md b/ThirdParty/Ert/README.md index 07d72dec3a..37cb5a42dd 100644 --- a/ThirdParty/Ert/README.md +++ b/ThirdParty/Ert/README.md @@ -1,4 +1,4 @@ -# libecl [![Build Status](https://travis-ci.org/Statoil/libecl.svg?branch=master)](https://travis-ci.org/Statoil/libecl) +# libecl [![Build Status](https://travis-ci.org/Equinor/libecl.svg?branch=master)](https://travis-ci.org/Equinor/libecl) *libecl* is a package for reading and writing the result files from @@ -11,7 +11,7 @@ is a portability layer which ensures that most of the functionality is available on *Windows*. The main functionality is written in C/C++, and should typically be linked in in other compiled programs. *libecl* was initially developed as part of the [Ensemble Reservoir -Tool](http://github.com/Statoil/ert), other applications using +Tool](http://github.com/Equinor/ert), other applications using *libecl* are the reservoir simulator flow and Resinsight from the [OPM project](http://github.com/OPM/). @@ -30,7 +30,7 @@ configured with `-DCMAKE_INSTALL_PREFIX=/path/to/install`. *libecl* uses CMake as build system: ```bash -git clone https://github.com/Statoil/libecl +git clone https://github.com/Equinor/libecl cd libecl mkdir build cd build @@ -50,7 +50,7 @@ rudimentary "build system" which does a basic Python syntax check and configures files to correctly set up the interaction between the Python classes and the shared libraries built from the C code: ```bash -git clone https://github.com/Statoil/libecl +git clone https://github.com/Equinor/libecl cd libecl sudo pip install -r requirements.txt mkdir build @@ -78,5 +78,6 @@ fopt = summary.numpy_vector("FOPT") ``` +The installation with Python enabled is described in a [YouTube video](https://www.youtube.com/watch?v=Qqy1vA1PSk8) by Carl Fredrik Berg. [1]: The exact paths here will depend on your system and Python version. The example given is for a RedHat system with Python version 2.7. diff --git a/ThirdParty/Ert/WINDOWS.md b/ThirdParty/Ert/WINDOWS.md new file mode 100644 index 0000000000..2bfb46b95b --- /dev/null +++ b/ThirdParty/Ert/WINDOWS.md @@ -0,0 +1,27 @@ +# Compiling and Installing **_libecl_** on Windows + +## Prerequisits: +* Python 2.7 or 3.x https://www.python.org/ or https://anaconda.org/ +* Microsoft Visual Studio https://visualstudio.microsoft.com/downloads/ +* Local copy of **_libecl_** + +## Instructions: +1. Download or clone the **_libecl_** Github repository to your local disk. + +2. Python 2.7 or 3.x installation + - Download a python instalation or a python environment solution such as Anaconda. + +3. Download and install Microsoft Visual Studio . At a minimum **_libecl_** requires the VS Studio packages for cmake, msbuild, c and c++ compilers (CL.exe). + +4. Open a MSVC command prompt such as _x64 Native Tools Command Prompt for VS 2017_ from your start menu. In the open prompt, navigate to the **_libecl_** source directory you created in step 1. Use the Python package manager **pip** to install **_libecl_** requirements via `pip install -r requirements.txt`. If Python is not accessible from the prompt it may be necessary to add the Python environment location to your system path variable `PATH`. + +5. Execute the build commands with the desired CMAKE parameters from `README.md`. The cmake generator can be _`NMake Makefiles`_ , _`Ninja`_ or an appropriate version of _`MSVC`_. For the availble options type `cmake -G` in the MSVC command prompt. + + An example build and install is provided below where %VARIABLE% are user defined directory paths: +~~~~ + cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=%INSTALLPATH% -DBUILD_SHARED_LIBS="ON" -DENABLE_PYTHON="ON" -DCMAKE_BUILD_TYPE="Release" %SOURCEPATH% + cmake --build %BUILDPATH% --config Release --target install +~~~~ +6. For **_libecl_** 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._ (`python2.7`, `python3.6` _etc._) . + +8. Open a Python interactive session and run `import ecl` to check that the install and paths are now set. \ No newline at end of file diff --git a/ThirdParty/Ert/Windows.txt b/ThirdParty/Ert/Windows.txt deleted file mode 100644 index 7eda76b091..0000000000 --- a/ThirdParty/Ert/Windows.txt +++ /dev/null @@ -1,90 +0,0 @@ -Preparations: -------------- - -1. Install the CMake build system from www.cmake.org - -2. Install the MinGW and MSYS packages from www.mingw.org - this a - collection of gnu tools built for windows. Observe that these tools - behave like they do on linux, but they are native windows - applications and the compilers produce native windows binaries, not - like Cygwin which is based on a portability layer. - - Make sure to install at least the C and Fortran compilers. - -3. Install lapack; download and install instructions can be found on - http://icl.cs.utk.edu/lapack-for-windows/ The text says that you - will need the Intel Fortran compiler, but the Fortran compiler from - MinGW works fine. The distribution contains a cmake CMakeLists.txt - file, and build with Cmake is easy altough time consuming. - - To make sure the system can find your libraries you should update - the windows PATH variable to include the location of your - libblas.dll and liblapack.dll files; if you fail to do this CMake - will fail to generate a valid set of makefiles for building libutil - and libecl. - - -Building libecl / libutil -------------------------- - -1. Go to the root directory of the ert distribution and create a - directory to hold the files created by the build - - e.g. 'tmp-build'. - -2. Open the cmake gui and give the path to the source (i.e. the root - of the ert distribution) and the path to the build directory. - -3. Press the [Configure] button and select the "MSys Makefiles" - option. Cmake will inspect your system and set build configuration - variables accordingly. Cmake will fail with a beep and large red - warnings. Scroll down to the variables: - - USE_LSF - USE_PTHREAD - USE_ZLIB - - and uncheck them. In addition you might want to modify some other - variables? Press the [Configure] button again, and then finally the - [Generate] button to create makefiles. - -4. Start up the MSys shell, go to the build directory, - e.g. 'tmp-build', and type: - - make ; make install - - :-) - - -Using from VisualStudio ------------------------ -The ERT code itself can unfortunately not be compiled with the -VisualStudio C++ compiler, however you can link against the ert -libraries. In that case you will need the dummy header file -VisualStudio/stdbool.h - - - -About the portabaility and features ------------------------------------ - -The libecl library is virtually unmodified for compiling on windows, -but the libutil library (in particular the util.c file) has quite many - - #ifdef HAVE_FEATUREXX - - #endif - -codeblocks. The symbols HAVE_FEATUREXX are defined during the CMake -configure process. The system inspection is linux centric in the sense -that the features it is checked for are mostly present/defined on -linux. If FEATUREXX is not present it is sometimes completely ignore, -e.g. pthreads, or a windows alternative is compiled in. In the case of -windows alternative it is just assumed that the feature in question is -present on the other (i.e. Windows) platform. - - - - - - - diff --git a/ThirdParty/Ert/applications/CMakeLists.txt b/ThirdParty/Ert/applications/CMakeLists.txt index d2a2ed6e8c..37b624e75f 100644 --- a/ThirdParty/Ert/applications/CMakeLists.txt +++ b/ThirdParty/Ert/applications/CMakeLists.txt @@ -1,10 +1,10 @@ project(libecl-applications) if (BUILD_APPLICATIONS) - add_executable(sum_write ecl/sum_write.c) + 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.c) + add_executable(summary ecl/view_summary.cpp) target_link_libraries(sum_write ecl) target_link_libraries(make_grid ecl) target_link_libraries(grdecl_grid ecl) @@ -13,16 +13,16 @@ if (BUILD_APPLICATIONS) list(APPEND apps make_grid grdecl_grid summary) - foreach (app ecl_pack - ecl_unpack - kw_extract - grid_info - grid_dump - grid_dump_ascii - select_test - load_test + foreach (app ecl_pack.c + ecl_unpack.c + kw_extract.cpp + grid_info.c + grid_dump.c + grid_dump_ascii.c + select_test.c + load_test.c ) - add_executable(${app} ecl/${app}.c) + add_executable(${app} ecl/${app}) target_link_libraries(${app} ecl) list(APPEND apps ${app}) if (ERT_LINUX) @@ -71,7 +71,7 @@ if (BUILD_APPLICATIONS) endif() if (BUILD_ECL_SUMMARY) - add_executable(ecl_summary ecl/view_summary.c) + add_executable(ecl_summary ecl/view_summary.cpp) target_link_libraries(ecl_summary ecl) list(APPEND apps ecl_summary) diff --git a/ThirdParty/Ert/applications/ecl/convert.c b/ThirdParty/Ert/applications/ecl/convert.c index 104a432b3f..f593c283f6 100644 --- a/ThirdParty/Ert/applications/ecl/convert.c +++ b/ThirdParty/Ert/applications/ecl/convert.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'convert.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/ecl_pack.c b/ThirdParty/Ert/applications/ecl/ecl_pack.c index 9cd98fc5a3..337a327577 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_pack.c +++ b/ThirdParty/Ert/applications/ecl/ecl_pack.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/ecl_quantile.c b/ThirdParty/Ert/applications/ecl/ecl_quantile.c index e98ea5d1e6..116006eef5 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_quantile.c +++ b/ThirdParty/Ert/applications/ecl/ecl_quantile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_quantile.c' is part of ERT - Ensemble based Reservoir Tool. @@ -812,7 +812,6 @@ void usage() { printf("All filenames in the configuration file will be interpreted relative to\n"); printf("the location of the configuration file, i.e. irrespective of the current\n"); printf("working directory when invoking the ecl_quantile program.\n\n"); - printf("ecl_quantile is written by Joakim Hove / joaho@statoil.com / 92 68 57 04.\n"); exit(0); } diff --git a/ThirdParty/Ert/applications/ecl/ecl_unpack.c b/ThirdParty/Ert/applications/ecl/ecl_unpack.c index fa08a9042f..87f9c2dae3 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_unpack.c +++ b/ThirdParty/Ert/applications/ecl/ecl_unpack.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/grdecl_grid.c b/ThirdParty/Ert/applications/ecl/grdecl_grid.c index f961118ef6..672bba80a1 100644 --- a/ThirdParty/Ert/applications/ecl/grdecl_grid.c +++ b/ThirdParty/Ert/applications/ecl/grdecl_grid.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'grdecl_grid.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/grdecl_test.c b/ThirdParty/Ert/applications/ecl/grdecl_test.c index 8e73a7db4c..2646a13083 100644 --- a/ThirdParty/Ert/applications/ecl/grdecl_test.c +++ b/ThirdParty/Ert/applications/ecl/grdecl_test.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'grdecl_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/grid_dump.c b/ThirdParty/Ert/applications/ecl/grid_dump.c index 8d405a2323..592d328ba1 100644 --- a/ThirdParty/Ert/applications/ecl/grid_dump.c +++ b/ThirdParty/Ert/applications/ecl/grid_dump.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'grid_info.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/grid_dump_ascii.c b/ThirdParty/Ert/applications/ecl/grid_dump_ascii.c index e9e05964be..c639d7bc1a 100644 --- a/ThirdParty/Ert/applications/ecl/grid_dump_ascii.c +++ b/ThirdParty/Ert/applications/ecl/grid_dump_ascii.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'grid_dump_ascii.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/grid_info.c b/ThirdParty/Ert/applications/ecl/grid_info.c index 9754a109f0..c191e77cee 100644 --- a/ThirdParty/Ert/applications/ecl/grid_info.c +++ b/ThirdParty/Ert/applications/ecl/grid_info.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'grid_info.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/grid_layer.c b/ThirdParty/Ert/applications/ecl/grid_layer.c index 05b5d2875e..8f6a11189d 100644 --- a/ThirdParty/Ert/applications/ecl/grid_layer.c +++ b/ThirdParty/Ert/applications/ecl/grid_layer.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'grid_layer.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/key_list.c b/ThirdParty/Ert/applications/ecl/key_list.c index e1ab0bb831..6dbb6bb419 100644 --- a/ThirdParty/Ert/applications/ecl/key_list.c +++ b/ThirdParty/Ert/applications/ecl/key_list.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'key_list.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/kw_extract.c b/ThirdParty/Ert/applications/ecl/kw_extract.cpp similarity index 98% rename from ThirdParty/Ert/applications/ecl/kw_extract.c rename to ThirdParty/Ert/applications/ecl/kw_extract.cpp index 9247ff073a..1b7db47b62 100644 --- a/ThirdParty/Ert/applications/ecl/kw_extract.c +++ b/ThirdParty/Ert/applications/ecl/kw_extract.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'kw_extract.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/kw_list.c b/ThirdParty/Ert/applications/ecl/kw_list.c index 482c3c096c..7f159cfda0 100644 --- a/ThirdParty/Ert/applications/ecl/kw_list.c +++ b/ThirdParty/Ert/applications/ecl/kw_list.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'kw_list.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/load_test.c b/ThirdParty/Ert/applications/ecl/load_test.c index 9a02887de2..669a8a90a1 100644 --- a/ThirdParty/Ert/applications/ecl/load_test.c +++ b/ThirdParty/Ert/applications/ecl/load_test.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'load_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/make_grid.c b/ThirdParty/Ert/applications/ecl/make_grid.c index f3c7adfd4e..636608cf7b 100644 --- a/ThirdParty/Ert/applications/ecl/make_grid.c +++ b/ThirdParty/Ert/applications/ecl/make_grid.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'make_grid.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/run_gravity.c b/ThirdParty/Ert/applications/ecl/run_gravity.c index f2ea723750..d0b3c17fca 100644 --- a/ThirdParty/Ert/applications/ecl/run_gravity.c +++ b/ThirdParty/Ert/applications/ecl/run_gravity.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'run_gravity.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/select_test.c b/ThirdParty/Ert/applications/ecl/select_test.c index 61acc18034..f23021f483 100644 --- a/ThirdParty/Ert/applications/ecl/select_test.c +++ b/ThirdParty/Ert/applications/ecl/select_test.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'select_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/sum_write.c b/ThirdParty/Ert/applications/ecl/sum_write.cpp similarity index 96% rename from ThirdParty/Ert/applications/ecl/sum_write.c rename to ThirdParty/Ert/applications/ecl/sum_write.cpp index 77234e4800..3bdf552d56 100644 --- a/ThirdParty/Ert/applications/ecl/sum_write.c +++ b/ThirdParty/Ert/applications/ecl/sum_write.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'sum_write' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify @@ -223,7 +223,7 @@ int main( int argc , char ** argv) { /* The return value from the ecl_sum_add_var() function is an - smspec_node_type instance (implemented in file smspec_node.c); + ecl::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 @@ -243,8 +243,8 @@ int main( int argc , char ** argv) { */ - smspec_node_type * wwct_wellx = ecl_sum_add_var( ecl_sum , "WWCT" , NULL , 0 , "(1)" , 0.0); - smspec_node_type * wopr_wellx = ecl_sum_add_var( ecl_sum , "WOPR" , NULL , 0 , "Barrels" , 0.0); + 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); { @@ -297,8 +297,8 @@ int main( int argc , char ** argv) { We can use the smspec_node value from the ecl_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); + ecl_sum_tstep_set_from_node( tstep , *wwct_wellx , sim_days ); + ecl_sum_tstep_set_from_node( tstep, *wopr_wellx, sim_days * 100); } } } diff --git a/ThirdParty/Ert/applications/ecl/summary2csv2.c b/ThirdParty/Ert/applications/ecl/summary2csv2.c index 7655f1f02b..6ffae8c815 100644 --- a/ThirdParty/Ert/applications/ecl/summary2csv2.c +++ b/ThirdParty/Ert/applications/ecl/summary2csv2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'summary2csv2.c' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify diff --git a/ThirdParty/Ert/applications/ecl/view_restart.c b/ThirdParty/Ert/applications/ecl/view_restart.c index 7b18b622c6..16217677d5 100644 --- a/ThirdParty/Ert/applications/ecl/view_restart.c +++ b/ThirdParty/Ert/applications/ecl/view_restart.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'view_restart.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/view_rft.c b/ThirdParty/Ert/applications/ecl/view_rft.c index 358c8bf2d5..ffe43131da 100644 --- a/ThirdParty/Ert/applications/ecl/view_rft.c +++ b/ThirdParty/Ert/applications/ecl/view_rft.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'view_rft.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/ecl/view_summary.c b/ThirdParty/Ert/applications/ecl/view_summary.cpp similarity index 97% rename from ThirdParty/Ert/applications/ecl/view_summary.c rename to ThirdParty/Ert/applications/ecl/view_summary.cpp index 986f390db4..e139b44563 100644 --- a/ThirdParty/Ert/applications/ecl/view_summary.c +++ b/ThirdParty/Ert/applications/ecl/view_summary.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'view_summary.c' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify @@ -110,10 +110,7 @@ void print_help_and_exit() { printf("\n"); printf("* If the extension corresponds to a unified file, summary.x will\n"); printf(" only look for unified files.\n"); - printf("\n"); - printf("\n"); - printf("Contact Joakim Hove / joaho@statoil.com / 92 68 57 04 for bugs\n"); - printf("and feature requests.\n"); + printf("\n"); exit(1); } diff --git a/ThirdParty/Ert/applications/ecl/vprofile.c b/ThirdParty/Ert/applications/ecl/vprofile.c index e6edb40b55..5264fcca97 100644 --- a/ThirdParty/Ert/applications/ecl/vprofile.c +++ b/ThirdParty/Ert/applications/ecl/vprofile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'vprofile.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/man/man1/ecl_summary.1 b/ThirdParty/Ert/applications/man/man1/ecl_summary.1 index 66b5ad9351..f881dc0efc 100644 --- a/ThirdParty/Ert/applications/man/man1/ecl_summary.1 +++ b/ThirdParty/Ert/applications/man/man1/ecl_summary.1 @@ -99,9 +99,6 @@ will only look for unformatted files. .IP only look for unified files. .PP -Contact Joakim Hove / joaho@statoil.com / 92 68 57 04 for bugs -and feature requests. -.PP The ecl_summary program is used to quickly extract summary vectors from ECLIPSE summary files. The program is invoked as: .PP @@ -183,6 +180,6 @@ will only look for unformatted files. .IP only look for unified files. .PP -Contact Joakim Hove / joaho@statoil.com / 92 68 57 04 for bugs +Contact Joakim Hove / joaho@equinor.com / 92 68 57 04 for bugs and feature requests. diff --git a/ThirdParty/Ert/applications/well/ri_well_test.c b/ThirdParty/Ert/applications/well/ri_well_test.c index 66e4b8d830..cc46160617 100644 --- a/ThirdParty/Ert/applications/well/ri_well_test.c +++ b/ThirdParty/Ert/applications/well/ri_well_test.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_CF_dump.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/well/segment_info.c b/ThirdParty/Ert/applications/well/segment_info.c index 2a445c2637..0d6e403273 100644 --- a/ThirdParty/Ert/applications/well/segment_info.c +++ b/ThirdParty/Ert/applications/well/segment_info.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'segment_info.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/applications/well/well_CF_dump.c b/ThirdParty/Ert/applications/well/well_CF_dump.c index 433aab6559..1fe2749cdc 100644 --- a/ThirdParty/Ert/applications/well/well_CF_dump.c +++ b/ThirdParty/Ert/applications/well/well_CF_dump.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_CF_dump.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/appveyor.yml b/ThirdParty/Ert/appveyor.yml index 73887395f0..c1dddec4e4 100644 --- a/ThirdParty/Ert/appveyor.yml +++ b/ThirdParty/Ert/appveyor.yml @@ -19,7 +19,6 @@ build_script: - cmake %W64% -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON - -DERT_BUILD_CXX=OFF -DBUILD_APPLICATIONS=ON - cmake --build . --config %configuration% --target install diff --git a/ThirdParty/Ert/bin/summary_resample b/ThirdParty/Ert/bin/summary_resample index eb6cf5521f..1a08006d2f 100644 --- a/ThirdParty/Ert/bin/summary_resample +++ b/ThirdParty/Ert/bin/summary_resample @@ -11,6 +11,7 @@ parser.add_argument("input_case", metavar="input_case", type=str) parser.add_argument("output_case", metavar="output_case", type=str) parser.add_argument("--num-timestep", type=int, default=50) 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) @@ -23,5 +24,8 @@ else: end_time = input_case.get_end_time() time_points = TimeVector.create_linear(CTime(start_time), CTime(end_time), args.num_timestep) -output_case = input_case.resample(args.output_case, time_points) +output_case = input_case.resample(args.output_case, + time_points, + lower_extrapolation=args.extrapolation, + upper_extrapolation=args.extrapolation) output_case.fwrite( ) diff --git a/ThirdParty/Ert/config.sh b/ThirdParty/Ert/config.sh new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/debian/README.Debian b/ThirdParty/Ert/debian/README.Debian index ce79dec2d5..4660ad0d8e 100644 --- a/ThirdParty/Ert/debian/README.Debian +++ b/ThirdParty/Ert/debian/README.Debian @@ -7,7 +7,3 @@ working with ECLIPSE output files. The package contains functionality for reading, and partly writing, ECLIPSE INIT/GRID/EGRID/RFT and summary and restart files. There is also some functionality for working with .grdecl formatted ECLIPSE input files. - - -- Joakim Hove Wed, 23 Jan 2013 13:41:00 +0100 - - -- Arne Morten Kvarving Wed, 16 Jan 2013 11:21:17 +0100 diff --git a/ThirdParty/Ert/debian/changelog b/ThirdParty/Ert/debian/changelog index f12cdfca3a..71b218f1f9 100644 --- a/ThirdParty/Ert/debian/changelog +++ b/ThirdParty/Ert/debian/changelog @@ -1,4 +1,4 @@ -ecl (2018.10-rfinal-1~xenial) xenial; urgency=low +ecl (2018.10-rc1-1~xenial) xenial; urgency=low * New release diff --git a/ThirdParty/Ert/debian/copyright b/ThirdParty/Ert/debian/copyright index a8797ba46b..94d51ad9e4 100644 --- a/ThirdParty/Ert/debian/copyright +++ b/ThirdParty/Ert/debian/copyright @@ -3,7 +3,7 @@ Upstream-Name: libert.ecl Source: https://github.com/Ensembles/ert Files: * -Copyright: 2013 Statoil +Copyright: 2013 Equinor License: GPL-3+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/ThirdParty/Ert/docs/CMakeLists.txt b/ThirdParty/Ert/docs/CMakeLists.txt deleted file mode 100644 index 833ce3a56e..0000000000 --- a/ThirdParty/Ert/docs/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -find_package(Sphinx REQUIRED) -if (SPHINX_FOUND) - set( ERT_DOC_EXTERNAL_ROOT "" CACHE PATH "Path to site local ERT documentation") - - file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc-src") - file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc-src/_static") - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/user" "${PROJECT_BINARY_DIR}/doc-src/user") - - if (ERT_DOC_EXTERNAL_ROOT) - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ERT_DOC_EXTERNAL_ROOT}" "${PROJECT_BINARY_DIR}/doc-src/external-doc") - message(STATUS "Adding documentation link ${PROJECT_BINARY_DIR}/doc-src/external-doc -> ${ERT_DOC_EXTERNAL_ROOT}") - set( ERT_DOC_LINK external-doc/index ) - else() - set( ERT_DOC_LINK "" ) - endif() - - configure_file(index.rst.in ${PROJECT_BINARY_DIR}/doc-src/index.rst) - configure_file(conf.py.in ${PROJECT_BINARY_DIR}/doc-src/conf.py) - - if (ENABLE_PYTHON) - add_custom_target(api-doc ALL - COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/code" "${PROJECT_BINARY_DIR}/doc-src/code" - COMMAND sphinx-apidoc -e -o doc-src/API/python/ecl ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} - DEPENDS ecl - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) - endif() - - add_custom_target(rst-doc ALL - COMMAND sphinx-build -b html -d doc-src/doctrees doc-src documentation/rst - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - DEPENDS api-doc - ) - -else() - message(STATUS "Sphinx documentation tool not found - documentation not generated") -endif() - -INSTALL( DIRECTORY ${PROJECT_BINARY_DIR}/documentation DESTINATION ${CMAKE_INSTALL_PREFIX} ) diff --git a/ThirdParty/Ert/docs/code/C/index.rst b/ThirdParty/Ert/docs/code/C/index.rst deleted file mode 100644 index 60f6a764b1..0000000000 --- a/ThirdParty/Ert/docs/code/C/index.rst +++ /dev/null @@ -1,4 +0,0 @@ -Low level C libraries -===================== - -How to use the C libraries diff --git a/ThirdParty/Ert/docs/code/python/eclipse/API/index.rst b/ThirdParty/Ert/docs/code/python/eclipse/API/index.rst deleted file mode 100644 index 4e61a4fb95..0000000000 --- a/ThirdParty/Ert/docs/code/python/eclipse/API/index.rst +++ /dev/null @@ -1,9 +0,0 @@ -The ert Python API -================== - -.. toctree:: - :maxdepth: 2 - - ../../API/python/ert - ../../API/python/ert_gui - diff --git a/ThirdParty/Ert/docs/code/python/examples/ert/index.rst b/ThirdParty/Ert/docs/code/python/examples/ert/index.rst deleted file mode 100644 index f7a37bfe3d..0000000000 --- a/ThirdParty/Ert/docs/code/python/examples/ert/index.rst +++ /dev/null @@ -1,3 +0,0 @@ -Working with full ert cases -=========================== - diff --git a/ThirdParty/Ert/docs/code/python/packages/geometry/index.rst b/ThirdParty/Ert/docs/code/python/packages/geometry/index.rst deleted file mode 100644 index 89c51ef2c5..0000000000 --- a/ThirdParty/Ert/docs/code/python/packages/geometry/index.rst +++ /dev/null @@ -1,2 +0,0 @@ -The ert.geo package -=================== diff --git a/ThirdParty/Ert/docs/code/python/packages/util/index.rst b/ThirdParty/Ert/docs/code/python/packages/util/index.rst deleted file mode 100644 index 83bd652b28..0000000000 --- a/ThirdParty/Ert/docs/code/python/packages/util/index.rst +++ /dev/null @@ -1,2 +0,0 @@ -The ert.util package -=================== diff --git a/ThirdParty/Ert/docs/code/python/packages/well/index.rst b/ThirdParty/Ert/docs/code/python/packages/well/index.rst deleted file mode 100644 index 9a3ea2c9a1..0000000000 --- a/ThirdParty/Ert/docs/code/python/packages/well/index.rst +++ /dev/null @@ -1,2 +0,0 @@ -The ert.well package -==================== diff --git a/ThirdParty/Ert/docs/course/config/config.ert b/ThirdParty/Ert/docs/course/config/config.ert deleted file mode 100644 index ec14cc6def..0000000000 --- a/ThirdParty/Ert/docs/course/config/config.ert +++ /dev/null @@ -1,34 +0,0 @@ -QUEUE_SYSTEM LOCAL - -JOBNAME SNAKE_OIL_%d -NUM_REALIZATIONS 25 - -DEFINE storage/ - -RUNPATH_FILE directory/test_runpath_list.txt -RUNPATH /runpath/realisation-%d/iter-%d -ENSPATH /ensemble -ECLBASE SNAKE_OIL_FIELD -SUMMARY * - -HISTORY_SOURCE REFCASE_HISTORY -REFCASE refcase/SNAKE_OIL_FIELD - -TIME_MAP refcase/time_map.txt - -INSTALL_JOB SNAKE_OIL_SIMULATOR jobs/SNAKE_OIL_SIMULATOR -INSTALL_JOB SNAKE_OIL_NPV jobs/SNAKE_OIL_NPV -INSTALL_JOB SNAKE_OIL_DIFF jobs/SNAKE_OIL_DIFF - -FORWARD_MODEL SNAKE_OIL_SIMULATOR -FORWARD_MODEL SNAKE_OIL_NPV -FORWARD_MODEL SNAKE_OIL_DIFF - -RUN_TEMPLATE templates/seed_template.txt seed.txt - -GEN_KW SNAKE_OIL_PARAM templates/snake_oil_template.txt snake_oil_params.txt parameters/snake_oil_parameters.txt -CUSTOM_KW SNAKE_OIL_NPV snake_oil_npv.txt -GEN_DATA SNAKE_OIL_OPR_DIFF INPUT_FORMAT:ASCII RESULT_FILE:snake_oil_opr_diff_%d.txt REPORT_STEPS:199 -GEN_DATA SNAKE_OIL_WPR_DIFF INPUT_FORMAT:ASCII RESULT_FILE:snake_oil_wpr_diff_%d.txt REPORT_STEPS:199 -GEN_DATA SNAKE_OIL_GPR_DIFF INPUT_FORMAT:ASCII RESULT_FILE:snake_oil_gpr_diff_%d.txt REPORT_STEPS:199 - diff --git a/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_DIFF b/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_DIFF deleted file mode 100644 index 98a867d959..0000000000 --- a/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_DIFF +++ /dev/null @@ -1,4 +0,0 @@ -STDOUT snake_oil_diff.stdout -STDERR snake_oil_diff.stderr - -EXECUTABLE snake_oil_diff.py \ No newline at end of file diff --git a/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_NPV b/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_NPV deleted file mode 100644 index 887830c756..0000000000 --- a/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_NPV +++ /dev/null @@ -1,4 +0,0 @@ -STDOUT snake_oil_npv.stdout -STDERR snake_oil_npv.stderr - -EXECUTABLE snake_oil_npv.py \ No newline at end of file diff --git a/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_SIMULATOR b/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_SIMULATOR deleted file mode 100644 index b4b7f9928f..0000000000 --- a/ThirdParty/Ert/docs/course/config/jobs/SNAKE_OIL_SIMULATOR +++ /dev/null @@ -1,4 +0,0 @@ -STDOUT snake_oil.stdout -STDERR snake_oil.stderr - -EXECUTABLE snake_oil_simulator.py \ No newline at end of file diff --git a/ThirdParty/Ert/docs/course/config/jobs/snake_oil_diff.py b/ThirdParty/Ert/docs/course/config/jobs/snake_oil_diff.py deleted file mode 100644 index 51ef5d472f..0000000000 --- a/ThirdParty/Ert/docs/course/config/jobs/snake_oil_diff.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -from ecl.ecl import EclSum - -def writeDiff(filename, vector1, vector2): - with open(filename, "w") as f: - for index in range(len(vector1)): - node1 = vector1[index] - node2 = vector2[index] - - diff = node1.value - node2.value - f.write("%f\n" % diff) - - -if __name__ == '__main__': - ecl_sum = EclSum("SNAKE_OIL_FIELD") - - report_step = 199 - writeDiff("snake_oil_opr_diff_%d.txt" % report_step, ecl_sum["WOPR:OP1"], ecl_sum["WOPR:OP2"]) - writeDiff("snake_oil_wpr_diff_%d.txt" % report_step, ecl_sum["WWPR:OP1"], ecl_sum["WWPR:OP2"]) - writeDiff("snake_oil_gpr_diff_%d.txt" % report_step, ecl_sum["WGPR:OP1"], ecl_sum["WGPR:OP2"]) - - - - diff --git a/ThirdParty/Ert/docs/course/config/jobs/snake_oil_npv.py b/ThirdParty/Ert/docs/course/config/jobs/snake_oil_npv.py deleted file mode 100644 index 126c917725..0000000000 --- a/ThirdParty/Ert/docs/course/config/jobs/snake_oil_npv.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python -from ecl.ecl import EclSum - -OIL_PRICES = {"2010-01-01": 78.33, - "2010-02-01": 76.39, - "2010-03-01": 81.20, - "2010-04-01": 84.29, - "2010-05-01": 73.74, - "2010-06-01": 75.34, - "2010-07-01": 76.32, - "2010-08-01": 76.60, - "2010-09-01": 75.24, - "2010-10-01": 81.89, - "2010-11-01": 84.25, - "2010-12-01": 89.15, - "2011-01-01": 89.17, - "2011-02-01": 88.58, - "2011-03-01": 102.86, - "2011-04-01": 109.53, - "2011-05-01": 100.90, - "2011-06-01": 96.26, - "2011-07-01": 97.30, - "2011-08-01": 86.33, - "2011-09-01": 85.52, - "2011-10-01": 86.32, - "2011-11-01": 97.16, - "2011-12-01": 98.56, - "2012-01-01": 100.27, - "2012-02-01": 102.20, - "2012-03-01": 106.16, - "2012-04-01": 103.32, - "2012-05-01": 94.65, - "2012-06-01": 82.30, - "2012-07-01": 87.90, - "2012-08-01": 94.13, - "2012-09-01": 94.51, - "2012-10-01": 89.49, - "2012-11-01": 86.53, - "2012-12-01": 87.86, - "2013-01-01": 94.76, - "2013-02-01": 95.31, - "2013-03-01": 92.94, - "2013-04-01": 92.02, - "2013-05-01": 94.51, - "2013-06-01": 95.77, - "2013-07-01": 104.67, - "2013-08-01": 106.57, - "2013-09-01": 106.29, - "2013-10-01": 100.54, - "2013-11-01": 93.86, - "2013-12-01": 97.63, - "2014-01-01": 94.62, - "2014-02-01": 100.82, - "2014-03-01": 100.80, - "2014-04-01": 102.07, - "2014-05-01": 102.18, - "2014-06-01": 105.79, - "2014-07-01": 103.59, - "2014-08-01": 96.54, - "2014-09-01": 93.21, - "2014-10-01": 84.40, - "2014-11-01": 75.79, - "2014-12-01": 59.29, - "2015-01-01": 47.22, - "2015-02-01": 50.58, - "2015-03-01": 47.82, - "2015-04-01": 54.45, - "2015-05-01": 59.27, - "2015-06-01": 59.82, - "2015-07-01": 50.90, - "2015-08-01": 42.87, - "2015-09-01": 45.48} - -if __name__ == '__main__': - ecl_sum = EclSum("SNAKE_OIL_FIELD") - start_time = ecl_sum.getStartTime() - date_ranges = ecl_sum.timeRange(start_time, interval="1M") - production_sums = ecl_sum.blockedProduction("FOPT", date_ranges) - - npv = 0.0 - for index in range(0, len(date_ranges) - 1): - date = date_ranges[index + 1] # end of period - production_sum = production_sums[index] - - oil_price = OIL_PRICES[date.date().strftime("%Y-%m-%d")] - - production_value = oil_price * production_sum - npv += production_value - - with open("snake_oil_npv.txt", "w") as output_file: - output_file.write("NPV %s\n" % npv) - - if npv < 80000: - rating = "POOR" - elif 80000 <= npv < 100000: - rating = "AVERAGE" - elif 100000 <= npv < 120000: - rating = "GOOD" - else: - rating = "EXCELLENT" - - output_file.write("RATING %s\n" % rating) - diff --git a/ThirdParty/Ert/docs/course/config/jobs/snake_oil_simulator.py b/ThirdParty/Ert/docs/course/config/jobs/snake_oil_simulator.py deleted file mode 100644 index 40b4d4a6a1..0000000000 --- a/ThirdParty/Ert/docs/course/config/jobs/snake_oil_simulator.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env python -from datetime import datetime -import os -import sys - -from ecl.ecl import EclSum, EclSumTStep -from ecl.test import ExtendedTestCase - -try: - from synthesizer import OilSimulator -except ImportError as e: - share_lib_path = ExtendedTestCase.createShareRoot("lib") - - sys.path.insert(0, share_lib_path) - synthesizer_module = __import__("synthesizer") - OilSimulator = synthesizer_module.OilSimulator - sys.path.pop(0) - - -def globalIndex(i, j, k, nx=10, ny=10, nz=10): - return i + nx * (j - 1) + nx * ny * (k - 1) - - -def readParameters(filename): - params = {} - with open(filename, "r") as f: - for line in f: - key, value = line.split(":", 1) - params[key] = value.strip() - - return params - - -def runSimulator(simulator, history_simulator, time_step_count): - """ @rtype: EclSum """ - ecl_sum = EclSum.writer("SNAKE_OIL_FIELD", datetime(2010, 1, 1), 10, 10, 10) - - ecl_sum.addVariable("FOPT") - ecl_sum.addVariable("FOPR") - ecl_sum.addVariable("FGPT") - ecl_sum.addVariable("FGPR") - ecl_sum.addVariable("FWPT") - ecl_sum.addVariable("FWPR") - ecl_sum.addVariable("FGOR") - ecl_sum.addVariable("FWCT") - - ecl_sum.addVariable("FOPTH") - ecl_sum.addVariable("FOPRH") - ecl_sum.addVariable("FGPTH") - ecl_sum.addVariable("FGPRH") - ecl_sum.addVariable("FWPTH") - ecl_sum.addVariable("FWPRH") - ecl_sum.addVariable("FGORH") - ecl_sum.addVariable("FWCTH") - - ecl_sum.addVariable("WOPR", wgname="OP1") - ecl_sum.addVariable("WOPR", wgname="OP2") - ecl_sum.addVariable("WWPR", wgname="OP1") - ecl_sum.addVariable("WWPR", wgname="OP2") - ecl_sum.addVariable("WGPR", wgname="OP1") - ecl_sum.addVariable("WGPR", wgname="OP2") - ecl_sum.addVariable("WGOR", wgname="OP1") - ecl_sum.addVariable("WGOR", wgname="OP2") - ecl_sum.addVariable("WWCT", wgname="OP1") - ecl_sum.addVariable("WWCT", wgname="OP2") - - ecl_sum.addVariable("WOPRH", wgname="OP1") - ecl_sum.addVariable("WOPRH", wgname="OP2") - ecl_sum.addVariable("WWPRH", wgname="OP1") - ecl_sum.addVariable("WWPRH", wgname="OP2") - ecl_sum.addVariable("WGPRH", wgname="OP1") - ecl_sum.addVariable("WGPRH", wgname="OP2") - ecl_sum.addVariable("WGORH", wgname="OP1") - ecl_sum.addVariable("WGORH", wgname="OP2") - ecl_sum.addVariable("WWCTH", wgname="OP1") - ecl_sum.addVariable("WWCTH", wgname="OP2") - - ecl_sum.addVariable("BPR", num=globalIndex(5, 5, 5)) - ecl_sum.addVariable("BPR", num=globalIndex(1, 3, 8)) - - time_map = [] - mini_step_count = 10 - total_step_count = time_step_count * mini_step_count - - for report_step in range(time_step_count): - for mini_step in range(mini_step_count): - t_step = ecl_sum.addTStep(report_step + 1, sim_days=report_step * mini_step_count + mini_step) - - time_map.append(t_step.getSimTime().datetime().strftime("%d/%m/%Y")) - - simulator.step(scale=1.0 / total_step_count) - history_simulator.step(scale=1.0 / total_step_count) - - t_step["FOPR"] = simulator.fopr() - t_step["FOPT"] = simulator.fopt() - t_step["FGPR"] = simulator.fgpr() - t_step["FGPT"] = simulator.fgpt() - t_step["FWPR"] = simulator.fwpr() - t_step["FWPT"] = simulator.fwpt() - t_step["FGOR"] = simulator.fgor() - t_step["FWCT"] = simulator.fwct() - - t_step["WOPR:OP1"] = simulator.opr("OP1") - t_step["WOPR:OP2"] = simulator.opr("OP2") - - t_step["WGPR:OP1"] = simulator.gpr("OP1") - t_step["WGPR:OP2"] = simulator.gpr("OP2") - - t_step["WWPR:OP1"] = simulator.wpr("OP1") - t_step["WWPR:OP2"] = simulator.wpr("OP2") - - t_step["WGOR:OP1"] = simulator.gor("OP1") - t_step["WGOR:OP2"] = simulator.gor("OP2") - - t_step["WWCT:OP1"] = simulator.wct("OP1") - t_step["WWCT:OP2"] = simulator.wct("OP2") - - t_step["BPR:5,5,5"] = simulator.bpr("5,5,5") - t_step["BPR:1,3,8"] = simulator.bpr("1,3,8") - - t_step["FOPRH"] = history_simulator.fopr() - t_step["FOPTH"] = history_simulator.fopt() - t_step["FGPRH"] = history_simulator.fgpr() - t_step["FGPTH"] = history_simulator.fgpt() - t_step["FWPRH"] = history_simulator.fwpr() - t_step["FWPTH"] = history_simulator.fwpt() - t_step["FGORH"] = history_simulator.fgor() - t_step["FWCTH"] = history_simulator.fwct() - - t_step["WOPRH:OP1"] = history_simulator.opr("OP1") - t_step["WOPRH:OP2"] = history_simulator.opr("OP2") - - t_step["WGPRH:OP1"] = history_simulator.gpr("OP1") - t_step["WGPRH:OP2"] = history_simulator.gpr("OP2") - - t_step["WWPRH:OP1"] = history_simulator.wpr("OP1") - t_step["WWPRH:OP2"] = history_simulator.wpr("OP2") - - t_step["WGORH:OP1"] = history_simulator.gor("OP1") - t_step["WGORH:OP2"] = history_simulator.gor("OP2") - - t_step["WWCTH:OP1"] = history_simulator.wct("OP1") - t_step["WWCTH:OP2"] = history_simulator.wct("OP2") - - return ecl_sum, time_map - - -def roundedInt(value): - return int(round(float(value))) - - -if __name__ == '__main__': - seed = int(readParameters("seed.txt")["SEED"]) - parameters = readParameters("snake_oil_params.txt") - - op1_divergence_scale = float(parameters["OP1_DIVERGENCE_SCALE"]) - op2_divergence_scale = float(parameters["OP2_DIVERGENCE_SCALE"]) - op1_persistence = float(parameters["OP1_PERSISTENCE"]) - op2_persistence = float(parameters["OP2_PERSISTENCE"]) - op1_offset = float(parameters["OP1_OFFSET"]) - op2_offset = float(parameters["OP2_OFFSET"]) - bpr_138_persistence = float(parameters["BPR_138_PERSISTENCE"]) - bpr_555_persistence = float(parameters["BPR_555_PERSISTENCE"]) - - op1_octaves = roundedInt(parameters["OP1_OCTAVES"]) - op2_octaves = roundedInt(parameters["OP2_OCTAVES"]) - - simulator = OilSimulator() - simulator.addWell("OP1", seed * 997, persistence=op1_persistence, octaves=op1_octaves, divergence_scale=op1_divergence_scale, offset=op1_offset) - simulator.addWell("OP2", seed * 13, persistence=op2_persistence, octaves=op2_octaves, divergence_scale=op2_divergence_scale, offset=op2_offset) - simulator.addBlock("5,5,5", seed * 37, persistence=bpr_555_persistence) - simulator.addBlock("1,3,8", seed * 31, persistence=bpr_138_persistence) - - history_simulator = OilSimulator() - history_simulator.addWell("OP1", 222118781) - history_simulator.addWell("OP2", 118116362) - - report_step_count = 200 - ecl_sum, time_map = runSimulator(simulator, history_simulator, report_step_count) - - ecl_sum.fwrite() - - with open("time_map.txt", "w") as f: - for t in time_map: - f.write("%s\n" % t) diff --git a/ThirdParty/Ert/docs/course/config/parameters/snake_oil_parameters.txt b/ThirdParty/Ert/docs/course/config/parameters/snake_oil_parameters.txt deleted file mode 100644 index 64573d0058..0000000000 --- a/ThirdParty/Ert/docs/course/config/parameters/snake_oil_parameters.txt +++ /dev/null @@ -1,11 +0,0 @@ -OP1_PERSISTENCE UNIFORM 0.01 0.4 -OP1_OCTAVES UNIFORM 3 5 -OP1_DIVERGENCE_SCALE UNIFORM 0.25 1.25 -OP1_OFFSET UNIFORM -0.1 0.1 -OP2_PERSISTENCE UNIFORM 0.1 0.6 -OP2_OCTAVES UNIFORM 5 12 -OP2_DIVERGENCE_SCALE UNIFORM 0.5 1.5 -OP2_OFFSET UNIFORM -0.2 0.2 -BPR_555_PERSISTENCE UNIFORM 0.1 0.5 -BPR_138_PERSISTENCE UNIFORM 0.2 0.7 - diff --git a/ThirdParty/Ert/docs/course/config/refcase/SNAKE_OIL_FIELD.SMSPEC b/ThirdParty/Ert/docs/course/config/refcase/SNAKE_OIL_FIELD.SMSPEC deleted file mode 100644 index 5a29e043b2..0000000000 Binary files a/ThirdParty/Ert/docs/course/config/refcase/SNAKE_OIL_FIELD.SMSPEC and /dev/null differ diff --git a/ThirdParty/Ert/docs/course/config/refcase/SNAKE_OIL_FIELD.UNSMRY b/ThirdParty/Ert/docs/course/config/refcase/SNAKE_OIL_FIELD.UNSMRY deleted file mode 100644 index dfa04f8002..0000000000 Binary files a/ThirdParty/Ert/docs/course/config/refcase/SNAKE_OIL_FIELD.UNSMRY and /dev/null differ diff --git a/ThirdParty/Ert/docs/course/config/refcase/refcase_readme.txt b/ThirdParty/Ert/docs/course/config/refcase/refcase_readme.txt deleted file mode 100644 index a3d0fe6058..0000000000 --- a/ThirdParty/Ert/docs/course/config/refcase/refcase_readme.txt +++ /dev/null @@ -1 +0,0 @@ -To create a refcase run the snake_oil_simulator.py job with the this as working directory. \ No newline at end of file diff --git a/ThirdParty/Ert/docs/course/config/refcase/seed.txt b/ThirdParty/Ert/docs/course/config/refcase/seed.txt deleted file mode 100644 index 0009f6e89a..0000000000 --- a/ThirdParty/Ert/docs/course/config/refcase/seed.txt +++ /dev/null @@ -1 +0,0 @@ -SEED:268776 \ No newline at end of file diff --git a/ThirdParty/Ert/docs/course/config/refcase/snake_oil_params.txt b/ThirdParty/Ert/docs/course/config/refcase/snake_oil_params.txt deleted file mode 100644 index 3868522924..0000000000 --- a/ThirdParty/Ert/docs/course/config/refcase/snake_oil_params.txt +++ /dev/null @@ -1,10 +0,0 @@ -OP1_PERSISTENCE:0.15 -OP1_OCTAVES:4 -OP1_DIVERGENCE_SCALE:0.5 -OP1_OFFSET:0.0 -OP2_PERSISTENCE:0.25 -OP2_OCTAVES:7.0 -OP2_DIVERGENCE_SCALE:1.0 -OP2_OFFSET:0.0 -BPR_555_PERSISTENCE:0.25 -BPR_138_PERSISTENCE:0.35 diff --git a/ThirdParty/Ert/docs/course/config/refcase/time_map.txt b/ThirdParty/Ert/docs/course/config/refcase/time_map.txt deleted file mode 100644 index d54b4293ae..0000000000 --- a/ThirdParty/Ert/docs/course/config/refcase/time_map.txt +++ /dev/null @@ -1,2000 +0,0 @@ -01/01/2010 -02/01/2010 -03/01/2010 -04/01/2010 -05/01/2010 -06/01/2010 -07/01/2010 -08/01/2010 -09/01/2010 -10/01/2010 -11/01/2010 -12/01/2010 -13/01/2010 -14/01/2010 -15/01/2010 -16/01/2010 -17/01/2010 -18/01/2010 -19/01/2010 -20/01/2010 -21/01/2010 -22/01/2010 -23/01/2010 -24/01/2010 -25/01/2010 -26/01/2010 -27/01/2010 -28/01/2010 -29/01/2010 -30/01/2010 -31/01/2010 -01/02/2010 -02/02/2010 -03/02/2010 -04/02/2010 -05/02/2010 -06/02/2010 -07/02/2010 -08/02/2010 -09/02/2010 -10/02/2010 -11/02/2010 -12/02/2010 -13/02/2010 -14/02/2010 -15/02/2010 -16/02/2010 -17/02/2010 -18/02/2010 -19/02/2010 -20/02/2010 -21/02/2010 -22/02/2010 -23/02/2010 -24/02/2010 -25/02/2010 -26/02/2010 -27/02/2010 -28/02/2010 -01/03/2010 -02/03/2010 -03/03/2010 -04/03/2010 -05/03/2010 -06/03/2010 -07/03/2010 -08/03/2010 -09/03/2010 -10/03/2010 -11/03/2010 -12/03/2010 -13/03/2010 -14/03/2010 -15/03/2010 -16/03/2010 -17/03/2010 -18/03/2010 -19/03/2010 -20/03/2010 -21/03/2010 -22/03/2010 -23/03/2010 -24/03/2010 -25/03/2010 -26/03/2010 -27/03/2010 -28/03/2010 -29/03/2010 -30/03/2010 -31/03/2010 -01/04/2010 -02/04/2010 -03/04/2010 -04/04/2010 -05/04/2010 -06/04/2010 -07/04/2010 -08/04/2010 -09/04/2010 -10/04/2010 -11/04/2010 -12/04/2010 -13/04/2010 -14/04/2010 -15/04/2010 -16/04/2010 -17/04/2010 -18/04/2010 -19/04/2010 -20/04/2010 -21/04/2010 -22/04/2010 -23/04/2010 -24/04/2010 -25/04/2010 -26/04/2010 -27/04/2010 -28/04/2010 -29/04/2010 -30/04/2010 -01/05/2010 -02/05/2010 -03/05/2010 -04/05/2010 -05/05/2010 -06/05/2010 -07/05/2010 -08/05/2010 -09/05/2010 -10/05/2010 -11/05/2010 -12/05/2010 -13/05/2010 -14/05/2010 -15/05/2010 -16/05/2010 -17/05/2010 -18/05/2010 -19/05/2010 -20/05/2010 -21/05/2010 -22/05/2010 -23/05/2010 -24/05/2010 -25/05/2010 -26/05/2010 -27/05/2010 -28/05/2010 -29/05/2010 -30/05/2010 -31/05/2010 -01/06/2010 -02/06/2010 -03/06/2010 -04/06/2010 -05/06/2010 -06/06/2010 -07/06/2010 -08/06/2010 -09/06/2010 -10/06/2010 -11/06/2010 -12/06/2010 -13/06/2010 -14/06/2010 -15/06/2010 -16/06/2010 -17/06/2010 -18/06/2010 -19/06/2010 -20/06/2010 -21/06/2010 -22/06/2010 -23/06/2010 -24/06/2010 -25/06/2010 -26/06/2010 -27/06/2010 -28/06/2010 -29/06/2010 -30/06/2010 -01/07/2010 -02/07/2010 -03/07/2010 -04/07/2010 -05/07/2010 -06/07/2010 -07/07/2010 -08/07/2010 -09/07/2010 -10/07/2010 -11/07/2010 -12/07/2010 -13/07/2010 -14/07/2010 -15/07/2010 -16/07/2010 -17/07/2010 -18/07/2010 -19/07/2010 -20/07/2010 -21/07/2010 -22/07/2010 -23/07/2010 -24/07/2010 -25/07/2010 -26/07/2010 -27/07/2010 -28/07/2010 -29/07/2010 -30/07/2010 -31/07/2010 -01/08/2010 -02/08/2010 -03/08/2010 -04/08/2010 -05/08/2010 -06/08/2010 -07/08/2010 -08/08/2010 -09/08/2010 -10/08/2010 -11/08/2010 -12/08/2010 -13/08/2010 -14/08/2010 -15/08/2010 -16/08/2010 -17/08/2010 -18/08/2010 -19/08/2010 -20/08/2010 -21/08/2010 -22/08/2010 -23/08/2010 -24/08/2010 -25/08/2010 -26/08/2010 -27/08/2010 -28/08/2010 -29/08/2010 -30/08/2010 -31/08/2010 -01/09/2010 -02/09/2010 -03/09/2010 -04/09/2010 -05/09/2010 -06/09/2010 -07/09/2010 -08/09/2010 -09/09/2010 -10/09/2010 -11/09/2010 -12/09/2010 -13/09/2010 -14/09/2010 -15/09/2010 -16/09/2010 -17/09/2010 -18/09/2010 -19/09/2010 -20/09/2010 -21/09/2010 -22/09/2010 -23/09/2010 -24/09/2010 -25/09/2010 -26/09/2010 -27/09/2010 -28/09/2010 -29/09/2010 -30/09/2010 -01/10/2010 -02/10/2010 -03/10/2010 -04/10/2010 -05/10/2010 -06/10/2010 -07/10/2010 -08/10/2010 -09/10/2010 -10/10/2010 -11/10/2010 -12/10/2010 -13/10/2010 -14/10/2010 -15/10/2010 -16/10/2010 -17/10/2010 -18/10/2010 -19/10/2010 -20/10/2010 -21/10/2010 -22/10/2010 -23/10/2010 -24/10/2010 -25/10/2010 -26/10/2010 -27/10/2010 -28/10/2010 -29/10/2010 -30/10/2010 -31/10/2010 -01/11/2010 -02/11/2010 -03/11/2010 -04/11/2010 -05/11/2010 -06/11/2010 -07/11/2010 -08/11/2010 -09/11/2010 -10/11/2010 -11/11/2010 -12/11/2010 -13/11/2010 -14/11/2010 -15/11/2010 -16/11/2010 -17/11/2010 -18/11/2010 -19/11/2010 -20/11/2010 -21/11/2010 -22/11/2010 -23/11/2010 -24/11/2010 -25/11/2010 -26/11/2010 -27/11/2010 -28/11/2010 -29/11/2010 -30/11/2010 -01/12/2010 -02/12/2010 -03/12/2010 -04/12/2010 -05/12/2010 -06/12/2010 -07/12/2010 -08/12/2010 -09/12/2010 -10/12/2010 -11/12/2010 -12/12/2010 -13/12/2010 -14/12/2010 -15/12/2010 -16/12/2010 -17/12/2010 -18/12/2010 -19/12/2010 -20/12/2010 -21/12/2010 -22/12/2010 -23/12/2010 -24/12/2010 -25/12/2010 -26/12/2010 -27/12/2010 -28/12/2010 -29/12/2010 -30/12/2010 -31/12/2010 -01/01/2011 -02/01/2011 -03/01/2011 -04/01/2011 -05/01/2011 -06/01/2011 -07/01/2011 -08/01/2011 -09/01/2011 -10/01/2011 -11/01/2011 -12/01/2011 -13/01/2011 -14/01/2011 -15/01/2011 -16/01/2011 -17/01/2011 -18/01/2011 -19/01/2011 -20/01/2011 -21/01/2011 -22/01/2011 -23/01/2011 -24/01/2011 -25/01/2011 -26/01/2011 -27/01/2011 -28/01/2011 -29/01/2011 -30/01/2011 -31/01/2011 -01/02/2011 -02/02/2011 -03/02/2011 -04/02/2011 -05/02/2011 -06/02/2011 -07/02/2011 -08/02/2011 -09/02/2011 -10/02/2011 -11/02/2011 -12/02/2011 -13/02/2011 -14/02/2011 -15/02/2011 -16/02/2011 -17/02/2011 -18/02/2011 -19/02/2011 -20/02/2011 -21/02/2011 -22/02/2011 -23/02/2011 -24/02/2011 -25/02/2011 -26/02/2011 -27/02/2011 -28/02/2011 -01/03/2011 -02/03/2011 -03/03/2011 -04/03/2011 -05/03/2011 -06/03/2011 -07/03/2011 -08/03/2011 -09/03/2011 -10/03/2011 -11/03/2011 -12/03/2011 -13/03/2011 -14/03/2011 -15/03/2011 -16/03/2011 -17/03/2011 -18/03/2011 -19/03/2011 -20/03/2011 -21/03/2011 -22/03/2011 -23/03/2011 -24/03/2011 -25/03/2011 -26/03/2011 -27/03/2011 -28/03/2011 -29/03/2011 -30/03/2011 -31/03/2011 -01/04/2011 -02/04/2011 -03/04/2011 -04/04/2011 -05/04/2011 -06/04/2011 -07/04/2011 -08/04/2011 -09/04/2011 -10/04/2011 -11/04/2011 -12/04/2011 -13/04/2011 -14/04/2011 -15/04/2011 -16/04/2011 -17/04/2011 -18/04/2011 -19/04/2011 -20/04/2011 -21/04/2011 -22/04/2011 -23/04/2011 -24/04/2011 -25/04/2011 -26/04/2011 -27/04/2011 -28/04/2011 -29/04/2011 -30/04/2011 -01/05/2011 -02/05/2011 -03/05/2011 -04/05/2011 -05/05/2011 -06/05/2011 -07/05/2011 -08/05/2011 -09/05/2011 -10/05/2011 -11/05/2011 -12/05/2011 -13/05/2011 -14/05/2011 -15/05/2011 -16/05/2011 -17/05/2011 -18/05/2011 -19/05/2011 -20/05/2011 -21/05/2011 -22/05/2011 -23/05/2011 -24/05/2011 -25/05/2011 -26/05/2011 -27/05/2011 -28/05/2011 -29/05/2011 -30/05/2011 -31/05/2011 -01/06/2011 -02/06/2011 -03/06/2011 -04/06/2011 -05/06/2011 -06/06/2011 -07/06/2011 -08/06/2011 -09/06/2011 -10/06/2011 -11/06/2011 -12/06/2011 -13/06/2011 -14/06/2011 -15/06/2011 -16/06/2011 -17/06/2011 -18/06/2011 -19/06/2011 -20/06/2011 -21/06/2011 -22/06/2011 -23/06/2011 -24/06/2011 -25/06/2011 -26/06/2011 -27/06/2011 -28/06/2011 -29/06/2011 -30/06/2011 -01/07/2011 -02/07/2011 -03/07/2011 -04/07/2011 -05/07/2011 -06/07/2011 -07/07/2011 -08/07/2011 -09/07/2011 -10/07/2011 -11/07/2011 -12/07/2011 -13/07/2011 -14/07/2011 -15/07/2011 -16/07/2011 -17/07/2011 -18/07/2011 -19/07/2011 -20/07/2011 -21/07/2011 -22/07/2011 -23/07/2011 -24/07/2011 -25/07/2011 -26/07/2011 -27/07/2011 -28/07/2011 -29/07/2011 -30/07/2011 -31/07/2011 -01/08/2011 -02/08/2011 -03/08/2011 -04/08/2011 -05/08/2011 -06/08/2011 -07/08/2011 -08/08/2011 -09/08/2011 -10/08/2011 -11/08/2011 -12/08/2011 -13/08/2011 -14/08/2011 -15/08/2011 -16/08/2011 -17/08/2011 -18/08/2011 -19/08/2011 -20/08/2011 -21/08/2011 -22/08/2011 -23/08/2011 -24/08/2011 -25/08/2011 -26/08/2011 -27/08/2011 -28/08/2011 -29/08/2011 -30/08/2011 -31/08/2011 -01/09/2011 -02/09/2011 -03/09/2011 -04/09/2011 -05/09/2011 -06/09/2011 -07/09/2011 -08/09/2011 -09/09/2011 -10/09/2011 -11/09/2011 -12/09/2011 -13/09/2011 -14/09/2011 -15/09/2011 -16/09/2011 -17/09/2011 -18/09/2011 -19/09/2011 -20/09/2011 -21/09/2011 -22/09/2011 -23/09/2011 -24/09/2011 -25/09/2011 -26/09/2011 -27/09/2011 -28/09/2011 -29/09/2011 -30/09/2011 -01/10/2011 -02/10/2011 -03/10/2011 -04/10/2011 -05/10/2011 -06/10/2011 -07/10/2011 -08/10/2011 -09/10/2011 -10/10/2011 -11/10/2011 -12/10/2011 -13/10/2011 -14/10/2011 -15/10/2011 -16/10/2011 -17/10/2011 -18/10/2011 -19/10/2011 -20/10/2011 -21/10/2011 -22/10/2011 -23/10/2011 -24/10/2011 -25/10/2011 -26/10/2011 -27/10/2011 -28/10/2011 -29/10/2011 -30/10/2011 -31/10/2011 -01/11/2011 -02/11/2011 -03/11/2011 -04/11/2011 -05/11/2011 -06/11/2011 -07/11/2011 -08/11/2011 -09/11/2011 -10/11/2011 -11/11/2011 -12/11/2011 -13/11/2011 -14/11/2011 -15/11/2011 -16/11/2011 -17/11/2011 -18/11/2011 -19/11/2011 -20/11/2011 -21/11/2011 -22/11/2011 -23/11/2011 -24/11/2011 -25/11/2011 -26/11/2011 -27/11/2011 -28/11/2011 -29/11/2011 -30/11/2011 -01/12/2011 -02/12/2011 -03/12/2011 -04/12/2011 -05/12/2011 -06/12/2011 -07/12/2011 -08/12/2011 -09/12/2011 -10/12/2011 -11/12/2011 -12/12/2011 -13/12/2011 -14/12/2011 -15/12/2011 -16/12/2011 -17/12/2011 -18/12/2011 -19/12/2011 -20/12/2011 -21/12/2011 -22/12/2011 -23/12/2011 -24/12/2011 -25/12/2011 -26/12/2011 -27/12/2011 -28/12/2011 -29/12/2011 -30/12/2011 -31/12/2011 -01/01/2012 -02/01/2012 -03/01/2012 -04/01/2012 -05/01/2012 -06/01/2012 -07/01/2012 -08/01/2012 -09/01/2012 -10/01/2012 -11/01/2012 -12/01/2012 -13/01/2012 -14/01/2012 -15/01/2012 -16/01/2012 -17/01/2012 -18/01/2012 -19/01/2012 -20/01/2012 -21/01/2012 -22/01/2012 -23/01/2012 -24/01/2012 -25/01/2012 -26/01/2012 -27/01/2012 -28/01/2012 -29/01/2012 -30/01/2012 -31/01/2012 -01/02/2012 -02/02/2012 -03/02/2012 -04/02/2012 -05/02/2012 -06/02/2012 -07/02/2012 -08/02/2012 -09/02/2012 -10/02/2012 -11/02/2012 -12/02/2012 -13/02/2012 -14/02/2012 -15/02/2012 -16/02/2012 -17/02/2012 -18/02/2012 -19/02/2012 -20/02/2012 -21/02/2012 -22/02/2012 -23/02/2012 -24/02/2012 -25/02/2012 -26/02/2012 -27/02/2012 -28/02/2012 -29/02/2012 -01/03/2012 -02/03/2012 -03/03/2012 -04/03/2012 -05/03/2012 -06/03/2012 -07/03/2012 -08/03/2012 -09/03/2012 -10/03/2012 -11/03/2012 -12/03/2012 -13/03/2012 -14/03/2012 -15/03/2012 -16/03/2012 -17/03/2012 -18/03/2012 -19/03/2012 -20/03/2012 -21/03/2012 -22/03/2012 -23/03/2012 -24/03/2012 -25/03/2012 -26/03/2012 -27/03/2012 -28/03/2012 -29/03/2012 -30/03/2012 -31/03/2012 -01/04/2012 -02/04/2012 -03/04/2012 -04/04/2012 -05/04/2012 -06/04/2012 -07/04/2012 -08/04/2012 -09/04/2012 -10/04/2012 -11/04/2012 -12/04/2012 -13/04/2012 -14/04/2012 -15/04/2012 -16/04/2012 -17/04/2012 -18/04/2012 -19/04/2012 -20/04/2012 -21/04/2012 -22/04/2012 -23/04/2012 -24/04/2012 -25/04/2012 -26/04/2012 -27/04/2012 -28/04/2012 -29/04/2012 -30/04/2012 -01/05/2012 -02/05/2012 -03/05/2012 -04/05/2012 -05/05/2012 -06/05/2012 -07/05/2012 -08/05/2012 -09/05/2012 -10/05/2012 -11/05/2012 -12/05/2012 -13/05/2012 -14/05/2012 -15/05/2012 -16/05/2012 -17/05/2012 -18/05/2012 -19/05/2012 -20/05/2012 -21/05/2012 -22/05/2012 -23/05/2012 -24/05/2012 -25/05/2012 -26/05/2012 -27/05/2012 -28/05/2012 -29/05/2012 -30/05/2012 -31/05/2012 -01/06/2012 -02/06/2012 -03/06/2012 -04/06/2012 -05/06/2012 -06/06/2012 -07/06/2012 -08/06/2012 -09/06/2012 -10/06/2012 -11/06/2012 -12/06/2012 -13/06/2012 -14/06/2012 -15/06/2012 -16/06/2012 -17/06/2012 -18/06/2012 -19/06/2012 -20/06/2012 -21/06/2012 -22/06/2012 -23/06/2012 -24/06/2012 -25/06/2012 -26/06/2012 -27/06/2012 -28/06/2012 -29/06/2012 -30/06/2012 -01/07/2012 -02/07/2012 -03/07/2012 -04/07/2012 -05/07/2012 -06/07/2012 -07/07/2012 -08/07/2012 -09/07/2012 -10/07/2012 -11/07/2012 -12/07/2012 -13/07/2012 -14/07/2012 -15/07/2012 -16/07/2012 -17/07/2012 -18/07/2012 -19/07/2012 -20/07/2012 -21/07/2012 -22/07/2012 -23/07/2012 -24/07/2012 -25/07/2012 -26/07/2012 -27/07/2012 -28/07/2012 -29/07/2012 -30/07/2012 -31/07/2012 -01/08/2012 -02/08/2012 -03/08/2012 -04/08/2012 -05/08/2012 -06/08/2012 -07/08/2012 -08/08/2012 -09/08/2012 -10/08/2012 -11/08/2012 -12/08/2012 -13/08/2012 -14/08/2012 -15/08/2012 -16/08/2012 -17/08/2012 -18/08/2012 -19/08/2012 -20/08/2012 -21/08/2012 -22/08/2012 -23/08/2012 -24/08/2012 -25/08/2012 -26/08/2012 -27/08/2012 -28/08/2012 -29/08/2012 -30/08/2012 -31/08/2012 -01/09/2012 -02/09/2012 -03/09/2012 -04/09/2012 -05/09/2012 -06/09/2012 -07/09/2012 -08/09/2012 -09/09/2012 -10/09/2012 -11/09/2012 -12/09/2012 -13/09/2012 -14/09/2012 -15/09/2012 -16/09/2012 -17/09/2012 -18/09/2012 -19/09/2012 -20/09/2012 -21/09/2012 -22/09/2012 -23/09/2012 -24/09/2012 -25/09/2012 -26/09/2012 -27/09/2012 -28/09/2012 -29/09/2012 -30/09/2012 -01/10/2012 -02/10/2012 -03/10/2012 -04/10/2012 -05/10/2012 -06/10/2012 -07/10/2012 -08/10/2012 -09/10/2012 -10/10/2012 -11/10/2012 -12/10/2012 -13/10/2012 -14/10/2012 -15/10/2012 -16/10/2012 -17/10/2012 -18/10/2012 -19/10/2012 -20/10/2012 -21/10/2012 -22/10/2012 -23/10/2012 -24/10/2012 -25/10/2012 -26/10/2012 -27/10/2012 -28/10/2012 -29/10/2012 -30/10/2012 -31/10/2012 -01/11/2012 -02/11/2012 -03/11/2012 -04/11/2012 -05/11/2012 -06/11/2012 -07/11/2012 -08/11/2012 -09/11/2012 -10/11/2012 -11/11/2012 -12/11/2012 -13/11/2012 -14/11/2012 -15/11/2012 -16/11/2012 -17/11/2012 -18/11/2012 -19/11/2012 -20/11/2012 -21/11/2012 -22/11/2012 -23/11/2012 -24/11/2012 -25/11/2012 -26/11/2012 -27/11/2012 -28/11/2012 -29/11/2012 -30/11/2012 -01/12/2012 -02/12/2012 -03/12/2012 -04/12/2012 -05/12/2012 -06/12/2012 -07/12/2012 -08/12/2012 -09/12/2012 -10/12/2012 -11/12/2012 -12/12/2012 -13/12/2012 -14/12/2012 -15/12/2012 -16/12/2012 -17/12/2012 -18/12/2012 -19/12/2012 -20/12/2012 -21/12/2012 -22/12/2012 -23/12/2012 -24/12/2012 -25/12/2012 -26/12/2012 -27/12/2012 -28/12/2012 -29/12/2012 -30/12/2012 -31/12/2012 -01/01/2013 -02/01/2013 -03/01/2013 -04/01/2013 -05/01/2013 -06/01/2013 -07/01/2013 -08/01/2013 -09/01/2013 -10/01/2013 -11/01/2013 -12/01/2013 -13/01/2013 -14/01/2013 -15/01/2013 -16/01/2013 -17/01/2013 -18/01/2013 -19/01/2013 -20/01/2013 -21/01/2013 -22/01/2013 -23/01/2013 -24/01/2013 -25/01/2013 -26/01/2013 -27/01/2013 -28/01/2013 -29/01/2013 -30/01/2013 -31/01/2013 -01/02/2013 -02/02/2013 -03/02/2013 -04/02/2013 -05/02/2013 -06/02/2013 -07/02/2013 -08/02/2013 -09/02/2013 -10/02/2013 -11/02/2013 -12/02/2013 -13/02/2013 -14/02/2013 -15/02/2013 -16/02/2013 -17/02/2013 -18/02/2013 -19/02/2013 -20/02/2013 -21/02/2013 -22/02/2013 -23/02/2013 -24/02/2013 -25/02/2013 -26/02/2013 -27/02/2013 -28/02/2013 -01/03/2013 -02/03/2013 -03/03/2013 -04/03/2013 -05/03/2013 -06/03/2013 -07/03/2013 -08/03/2013 -09/03/2013 -10/03/2013 -11/03/2013 -12/03/2013 -13/03/2013 -14/03/2013 -15/03/2013 -16/03/2013 -17/03/2013 -18/03/2013 -19/03/2013 -20/03/2013 -21/03/2013 -22/03/2013 -23/03/2013 -24/03/2013 -25/03/2013 -26/03/2013 -27/03/2013 -28/03/2013 -29/03/2013 -30/03/2013 -31/03/2013 -01/04/2013 -02/04/2013 -03/04/2013 -04/04/2013 -05/04/2013 -06/04/2013 -07/04/2013 -08/04/2013 -09/04/2013 -10/04/2013 -11/04/2013 -12/04/2013 -13/04/2013 -14/04/2013 -15/04/2013 -16/04/2013 -17/04/2013 -18/04/2013 -19/04/2013 -20/04/2013 -21/04/2013 -22/04/2013 -23/04/2013 -24/04/2013 -25/04/2013 -26/04/2013 -27/04/2013 -28/04/2013 -29/04/2013 -30/04/2013 -01/05/2013 -02/05/2013 -03/05/2013 -04/05/2013 -05/05/2013 -06/05/2013 -07/05/2013 -08/05/2013 -09/05/2013 -10/05/2013 -11/05/2013 -12/05/2013 -13/05/2013 -14/05/2013 -15/05/2013 -16/05/2013 -17/05/2013 -18/05/2013 -19/05/2013 -20/05/2013 -21/05/2013 -22/05/2013 -23/05/2013 -24/05/2013 -25/05/2013 -26/05/2013 -27/05/2013 -28/05/2013 -29/05/2013 -30/05/2013 -31/05/2013 -01/06/2013 -02/06/2013 -03/06/2013 -04/06/2013 -05/06/2013 -06/06/2013 -07/06/2013 -08/06/2013 -09/06/2013 -10/06/2013 -11/06/2013 -12/06/2013 -13/06/2013 -14/06/2013 -15/06/2013 -16/06/2013 -17/06/2013 -18/06/2013 -19/06/2013 -20/06/2013 -21/06/2013 -22/06/2013 -23/06/2013 -24/06/2013 -25/06/2013 -26/06/2013 -27/06/2013 -28/06/2013 -29/06/2013 -30/06/2013 -01/07/2013 -02/07/2013 -03/07/2013 -04/07/2013 -05/07/2013 -06/07/2013 -07/07/2013 -08/07/2013 -09/07/2013 -10/07/2013 -11/07/2013 -12/07/2013 -13/07/2013 -14/07/2013 -15/07/2013 -16/07/2013 -17/07/2013 -18/07/2013 -19/07/2013 -20/07/2013 -21/07/2013 -22/07/2013 -23/07/2013 -24/07/2013 -25/07/2013 -26/07/2013 -27/07/2013 -28/07/2013 -29/07/2013 -30/07/2013 -31/07/2013 -01/08/2013 -02/08/2013 -03/08/2013 -04/08/2013 -05/08/2013 -06/08/2013 -07/08/2013 -08/08/2013 -09/08/2013 -10/08/2013 -11/08/2013 -12/08/2013 -13/08/2013 -14/08/2013 -15/08/2013 -16/08/2013 -17/08/2013 -18/08/2013 -19/08/2013 -20/08/2013 -21/08/2013 -22/08/2013 -23/08/2013 -24/08/2013 -25/08/2013 -26/08/2013 -27/08/2013 -28/08/2013 -29/08/2013 -30/08/2013 -31/08/2013 -01/09/2013 -02/09/2013 -03/09/2013 -04/09/2013 -05/09/2013 -06/09/2013 -07/09/2013 -08/09/2013 -09/09/2013 -10/09/2013 -11/09/2013 -12/09/2013 -13/09/2013 -14/09/2013 -15/09/2013 -16/09/2013 -17/09/2013 -18/09/2013 -19/09/2013 -20/09/2013 -21/09/2013 -22/09/2013 -23/09/2013 -24/09/2013 -25/09/2013 -26/09/2013 -27/09/2013 -28/09/2013 -29/09/2013 -30/09/2013 -01/10/2013 -02/10/2013 -03/10/2013 -04/10/2013 -05/10/2013 -06/10/2013 -07/10/2013 -08/10/2013 -09/10/2013 -10/10/2013 -11/10/2013 -12/10/2013 -13/10/2013 -14/10/2013 -15/10/2013 -16/10/2013 -17/10/2013 -18/10/2013 -19/10/2013 -20/10/2013 -21/10/2013 -22/10/2013 -23/10/2013 -24/10/2013 -25/10/2013 -26/10/2013 -27/10/2013 -28/10/2013 -29/10/2013 -30/10/2013 -31/10/2013 -01/11/2013 -02/11/2013 -03/11/2013 -04/11/2013 -05/11/2013 -06/11/2013 -07/11/2013 -08/11/2013 -09/11/2013 -10/11/2013 -11/11/2013 -12/11/2013 -13/11/2013 -14/11/2013 -15/11/2013 -16/11/2013 -17/11/2013 -18/11/2013 -19/11/2013 -20/11/2013 -21/11/2013 -22/11/2013 -23/11/2013 -24/11/2013 -25/11/2013 -26/11/2013 -27/11/2013 -28/11/2013 -29/11/2013 -30/11/2013 -01/12/2013 -02/12/2013 -03/12/2013 -04/12/2013 -05/12/2013 -06/12/2013 -07/12/2013 -08/12/2013 -09/12/2013 -10/12/2013 -11/12/2013 -12/12/2013 -13/12/2013 -14/12/2013 -15/12/2013 -16/12/2013 -17/12/2013 -18/12/2013 -19/12/2013 -20/12/2013 -21/12/2013 -22/12/2013 -23/12/2013 -24/12/2013 -25/12/2013 -26/12/2013 -27/12/2013 -28/12/2013 -29/12/2013 -30/12/2013 -31/12/2013 -01/01/2014 -02/01/2014 -03/01/2014 -04/01/2014 -05/01/2014 -06/01/2014 -07/01/2014 -08/01/2014 -09/01/2014 -10/01/2014 -11/01/2014 -12/01/2014 -13/01/2014 -14/01/2014 -15/01/2014 -16/01/2014 -17/01/2014 -18/01/2014 -19/01/2014 -20/01/2014 -21/01/2014 -22/01/2014 -23/01/2014 -24/01/2014 -25/01/2014 -26/01/2014 -27/01/2014 -28/01/2014 -29/01/2014 -30/01/2014 -31/01/2014 -01/02/2014 -02/02/2014 -03/02/2014 -04/02/2014 -05/02/2014 -06/02/2014 -07/02/2014 -08/02/2014 -09/02/2014 -10/02/2014 -11/02/2014 -12/02/2014 -13/02/2014 -14/02/2014 -15/02/2014 -16/02/2014 -17/02/2014 -18/02/2014 -19/02/2014 -20/02/2014 -21/02/2014 -22/02/2014 -23/02/2014 -24/02/2014 -25/02/2014 -26/02/2014 -27/02/2014 -28/02/2014 -01/03/2014 -02/03/2014 -03/03/2014 -04/03/2014 -05/03/2014 -06/03/2014 -07/03/2014 -08/03/2014 -09/03/2014 -10/03/2014 -11/03/2014 -12/03/2014 -13/03/2014 -14/03/2014 -15/03/2014 -16/03/2014 -17/03/2014 -18/03/2014 -19/03/2014 -20/03/2014 -21/03/2014 -22/03/2014 -23/03/2014 -24/03/2014 -25/03/2014 -26/03/2014 -27/03/2014 -28/03/2014 -29/03/2014 -30/03/2014 -31/03/2014 -01/04/2014 -02/04/2014 -03/04/2014 -04/04/2014 -05/04/2014 -06/04/2014 -07/04/2014 -08/04/2014 -09/04/2014 -10/04/2014 -11/04/2014 -12/04/2014 -13/04/2014 -14/04/2014 -15/04/2014 -16/04/2014 -17/04/2014 -18/04/2014 -19/04/2014 -20/04/2014 -21/04/2014 -22/04/2014 -23/04/2014 -24/04/2014 -25/04/2014 -26/04/2014 -27/04/2014 -28/04/2014 -29/04/2014 -30/04/2014 -01/05/2014 -02/05/2014 -03/05/2014 -04/05/2014 -05/05/2014 -06/05/2014 -07/05/2014 -08/05/2014 -09/05/2014 -10/05/2014 -11/05/2014 -12/05/2014 -13/05/2014 -14/05/2014 -15/05/2014 -16/05/2014 -17/05/2014 -18/05/2014 -19/05/2014 -20/05/2014 -21/05/2014 -22/05/2014 -23/05/2014 -24/05/2014 -25/05/2014 -26/05/2014 -27/05/2014 -28/05/2014 -29/05/2014 -30/05/2014 -31/05/2014 -01/06/2014 -02/06/2014 -03/06/2014 -04/06/2014 -05/06/2014 -06/06/2014 -07/06/2014 -08/06/2014 -09/06/2014 -10/06/2014 -11/06/2014 -12/06/2014 -13/06/2014 -14/06/2014 -15/06/2014 -16/06/2014 -17/06/2014 -18/06/2014 -19/06/2014 -20/06/2014 -21/06/2014 -22/06/2014 -23/06/2014 -24/06/2014 -25/06/2014 -26/06/2014 -27/06/2014 -28/06/2014 -29/06/2014 -30/06/2014 -01/07/2014 -02/07/2014 -03/07/2014 -04/07/2014 -05/07/2014 -06/07/2014 -07/07/2014 -08/07/2014 -09/07/2014 -10/07/2014 -11/07/2014 -12/07/2014 -13/07/2014 -14/07/2014 -15/07/2014 -16/07/2014 -17/07/2014 -18/07/2014 -19/07/2014 -20/07/2014 -21/07/2014 -22/07/2014 -23/07/2014 -24/07/2014 -25/07/2014 -26/07/2014 -27/07/2014 -28/07/2014 -29/07/2014 -30/07/2014 -31/07/2014 -01/08/2014 -02/08/2014 -03/08/2014 -04/08/2014 -05/08/2014 -06/08/2014 -07/08/2014 -08/08/2014 -09/08/2014 -10/08/2014 -11/08/2014 -12/08/2014 -13/08/2014 -14/08/2014 -15/08/2014 -16/08/2014 -17/08/2014 -18/08/2014 -19/08/2014 -20/08/2014 -21/08/2014 -22/08/2014 -23/08/2014 -24/08/2014 -25/08/2014 -26/08/2014 -27/08/2014 -28/08/2014 -29/08/2014 -30/08/2014 -31/08/2014 -01/09/2014 -02/09/2014 -03/09/2014 -04/09/2014 -05/09/2014 -06/09/2014 -07/09/2014 -08/09/2014 -09/09/2014 -10/09/2014 -11/09/2014 -12/09/2014 -13/09/2014 -14/09/2014 -15/09/2014 -16/09/2014 -17/09/2014 -18/09/2014 -19/09/2014 -20/09/2014 -21/09/2014 -22/09/2014 -23/09/2014 -24/09/2014 -25/09/2014 -26/09/2014 -27/09/2014 -28/09/2014 -29/09/2014 -30/09/2014 -01/10/2014 -02/10/2014 -03/10/2014 -04/10/2014 -05/10/2014 -06/10/2014 -07/10/2014 -08/10/2014 -09/10/2014 -10/10/2014 -11/10/2014 -12/10/2014 -13/10/2014 -14/10/2014 -15/10/2014 -16/10/2014 -17/10/2014 -18/10/2014 -19/10/2014 -20/10/2014 -21/10/2014 -22/10/2014 -23/10/2014 -24/10/2014 -25/10/2014 -26/10/2014 -27/10/2014 -28/10/2014 -29/10/2014 -30/10/2014 -31/10/2014 -01/11/2014 -02/11/2014 -03/11/2014 -04/11/2014 -05/11/2014 -06/11/2014 -07/11/2014 -08/11/2014 -09/11/2014 -10/11/2014 -11/11/2014 -12/11/2014 -13/11/2014 -14/11/2014 -15/11/2014 -16/11/2014 -17/11/2014 -18/11/2014 -19/11/2014 -20/11/2014 -21/11/2014 -22/11/2014 -23/11/2014 -24/11/2014 -25/11/2014 -26/11/2014 -27/11/2014 -28/11/2014 -29/11/2014 -30/11/2014 -01/12/2014 -02/12/2014 -03/12/2014 -04/12/2014 -05/12/2014 -06/12/2014 -07/12/2014 -08/12/2014 -09/12/2014 -10/12/2014 -11/12/2014 -12/12/2014 -13/12/2014 -14/12/2014 -15/12/2014 -16/12/2014 -17/12/2014 -18/12/2014 -19/12/2014 -20/12/2014 -21/12/2014 -22/12/2014 -23/12/2014 -24/12/2014 -25/12/2014 -26/12/2014 -27/12/2014 -28/12/2014 -29/12/2014 -30/12/2014 -31/12/2014 -01/01/2015 -02/01/2015 -03/01/2015 -04/01/2015 -05/01/2015 -06/01/2015 -07/01/2015 -08/01/2015 -09/01/2015 -10/01/2015 -11/01/2015 -12/01/2015 -13/01/2015 -14/01/2015 -15/01/2015 -16/01/2015 -17/01/2015 -18/01/2015 -19/01/2015 -20/01/2015 -21/01/2015 -22/01/2015 -23/01/2015 -24/01/2015 -25/01/2015 -26/01/2015 -27/01/2015 -28/01/2015 -29/01/2015 -30/01/2015 -31/01/2015 -01/02/2015 -02/02/2015 -03/02/2015 -04/02/2015 -05/02/2015 -06/02/2015 -07/02/2015 -08/02/2015 -09/02/2015 -10/02/2015 -11/02/2015 -12/02/2015 -13/02/2015 -14/02/2015 -15/02/2015 -16/02/2015 -17/02/2015 -18/02/2015 -19/02/2015 -20/02/2015 -21/02/2015 -22/02/2015 -23/02/2015 -24/02/2015 -25/02/2015 -26/02/2015 -27/02/2015 -28/02/2015 -01/03/2015 -02/03/2015 -03/03/2015 -04/03/2015 -05/03/2015 -06/03/2015 -07/03/2015 -08/03/2015 -09/03/2015 -10/03/2015 -11/03/2015 -12/03/2015 -13/03/2015 -14/03/2015 -15/03/2015 -16/03/2015 -17/03/2015 -18/03/2015 -19/03/2015 -20/03/2015 -21/03/2015 -22/03/2015 -23/03/2015 -24/03/2015 -25/03/2015 -26/03/2015 -27/03/2015 -28/03/2015 -29/03/2015 -30/03/2015 -31/03/2015 -01/04/2015 -02/04/2015 -03/04/2015 -04/04/2015 -05/04/2015 -06/04/2015 -07/04/2015 -08/04/2015 -09/04/2015 -10/04/2015 -11/04/2015 -12/04/2015 -13/04/2015 -14/04/2015 -15/04/2015 -16/04/2015 -17/04/2015 -18/04/2015 -19/04/2015 -20/04/2015 -21/04/2015 -22/04/2015 -23/04/2015 -24/04/2015 -25/04/2015 -26/04/2015 -27/04/2015 -28/04/2015 -29/04/2015 -30/04/2015 -01/05/2015 -02/05/2015 -03/05/2015 -04/05/2015 -05/05/2015 -06/05/2015 -07/05/2015 -08/05/2015 -09/05/2015 -10/05/2015 -11/05/2015 -12/05/2015 -13/05/2015 -14/05/2015 -15/05/2015 -16/05/2015 -17/05/2015 -18/05/2015 -19/05/2015 -20/05/2015 -21/05/2015 -22/05/2015 -23/05/2015 -24/05/2015 -25/05/2015 -26/05/2015 -27/05/2015 -28/05/2015 -29/05/2015 -30/05/2015 -31/05/2015 -01/06/2015 -02/06/2015 -03/06/2015 -04/06/2015 -05/06/2015 -06/06/2015 -07/06/2015 -08/06/2015 -09/06/2015 -10/06/2015 -11/06/2015 -12/06/2015 -13/06/2015 -14/06/2015 -15/06/2015 -16/06/2015 -17/06/2015 -18/06/2015 -19/06/2015 -20/06/2015 -21/06/2015 -22/06/2015 -23/06/2015 diff --git a/ThirdParty/Ert/docs/course/config/snake_oil.ert b/ThirdParty/Ert/docs/course/config/snake_oil.ert deleted file mode 100644 index 72fef586d0..0000000000 --- a/ThirdParty/Ert/docs/course/config/snake_oil.ert +++ /dev/null @@ -1,40 +0,0 @@ -QUEUE_SYSTEM LOCAL - -JOBNAME SNAKE_OIL_%d -NUM_REALIZATIONS 25 - -DEFINE storage/ - -STORE_SEED SEED -LOAD_SEED SEED - -RUNPATH_FILE directory/test_runpath_list.txt -RUNPATH /runpath/realisation-%d/iter-%d -ENSPATH /ensemble -ECLBASE SNAKE_OIL_FIELD -SUMMARY * - -HISTORY_SOURCE REFCASE_HISTORY -REFCASE refcase/SNAKE_OIL_FIELD - -TIME_MAP refcase/time_map.txt -OBS_CONFIG observations/observations.txt - -INSTALL_JOB SNAKE_OIL_SIMULATOR jobs/SNAKE_OIL_SIMULATOR -INSTALL_JOB SNAKE_OIL_NPV jobs/SNAKE_OIL_NPV -INSTALL_JOB SNAKE_OIL_DIFF jobs/SNAKE_OIL_DIFF - -FORWARD_MODEL SNAKE_OIL_SIMULATOR -FORWARD_MODEL SNAKE_OIL_NPV -FORWARD_MODEL SNAKE_OIL_DIFF - -RUN_TEMPLATE templates/seed_template.txt seed.txt -GEN_KW SNAKE_OIL_PARAM templates/snake_oil_template.txt snake_oil_params.txt parameters/snake_oil_parameters.txt -CUSTOM_KW SNAKE_OIL_NPV snake_oil_npv.txt -GEN_DATA SNAKE_OIL_OPR_DIFF INPUT_FORMAT:ASCII RESULT_FILE:snake_oil_opr_diff_%d.txt REPORT_STEPS:199 -GEN_DATA SNAKE_OIL_WPR_DIFF INPUT_FORMAT:ASCII RESULT_FILE:snake_oil_wpr_diff_%d.txt REPORT_STEPS:199 -GEN_DATA SNAKE_OIL_GPR_DIFF INPUT_FORMAT:ASCII RESULT_FILE:snake_oil_gpr_diff_%d.txt REPORT_STEPS:199 - -LOG_LEVEL 3 -LOG_FILE log/log.txt -UPDATE_LOG_PATH log/update diff --git a/ThirdParty/Ert/docs/course/config/templates/seed_template.txt b/ThirdParty/Ert/docs/course/config/templates/seed_template.txt deleted file mode 100644 index a0bca49fbd..0000000000 --- a/ThirdParty/Ert/docs/course/config/templates/seed_template.txt +++ /dev/null @@ -1 +0,0 @@ -SEED: \ No newline at end of file diff --git a/ThirdParty/Ert/docs/course/config/templates/snake_oil_template.txt b/ThirdParty/Ert/docs/course/config/templates/snake_oil_template.txt deleted file mode 100644 index ad2c648a0b..0000000000 --- a/ThirdParty/Ert/docs/course/config/templates/snake_oil_template.txt +++ /dev/null @@ -1,10 +0,0 @@ -OP1_PERSISTENCE: -OP1_OCTAVES: -OP1_DIVERGENCE_SCALE: -OP1_OFFSET: -OP2_PERSISTENCE: -OP2_OCTAVES: -OP2_DIVERGENCE_SCALE: -OP2_OFFSET: -BPR_555_PERSISTENCE: -BPR_138_PERSISTENCE: diff --git a/ThirdParty/Ert/docs/course/ex1/ex1.txt b/ThirdParty/Ert/docs/course/ex1/ex1.txt deleted file mode 100644 index dadcc397eb..0000000000 --- a/ThirdParty/Ert/docs/course/ex1/ex1.txt +++ /dev/null @@ -1,7 +0,0 @@ -1. Create a small Python script which will load a ERT configuration - file and instantiate a EnkfMain object. - -2. Query the EnKFMain instance and print on standard out: - - a) How many realisations there are. - b) List all GEN_KW keywords, and their internal keys. diff --git a/ThirdParty/Ert/docs/course/ex1/sol1.py b/ThirdParty/Ert/docs/course/ex1/sol1.py deleted file mode 100644 index 5c30971e1b..0000000000 --- a/ThirdParty/Ert/docs/course/ex1/sol1.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -import sys -import time -from ert.enkf import EnKFMain -from ert.enkf.enums import ErtImplType - - -# This will instantiate the EnkFMain object and create a handle to -# "everything" ert related for this instance. -ert = EnKFMain( sys.argv[1] ) - - -# Ask the EnKFMain instance how many realisations it has. Observe that -# the answer to this question is just the value of the -# NUM_REALISATIONS setting in the configuration file. -print("This instance has %d realisations" % ert.getEnsembleSize()) - - -# Get the ensemble configuration object, and ask for all GEN_KW keys: -ens_config = ert.ensembleConfig( ) -for key in ens_config.getKeylistFromImplType(ErtImplType.GEN_KW): - config_node = ens_config[key] - - # "Downcast" to GEN_KW configuration. - gen_kw_config = config_node.getModelConfig( ) - print("%s : %s" % (key , gen_kw_config.getKeyWords( ))) - diff --git a/ThirdParty/Ert/docs/course/ex2/ex2.txt b/ThirdParty/Ert/docs/course/ex2/ex2.txt deleted file mode 100644 index 32daa87560..0000000000 --- a/ThirdParty/Ert/docs/course/ex2/ex2.txt +++ /dev/null @@ -1 +0,0 @@ -Implement the [] operator for the gen_data class in GenData.py diff --git a/ThirdParty/Ert/docs/course/ex2/sol2.txt b/ThirdParty/Ert/docs/course/ex2/sol2.txt deleted file mode 100644 index e6b4474389..0000000000 --- a/ThirdParty/Ert/docs/course/ex2/sol2.txt +++ /dev/null @@ -1,35 +0,0 @@ -The [] operator for python objects is implemeted with the -__getitem__() and __setitem__() methods. - -1. The __setitem__ and __getitem__ methods should clearly be based on - C functions which set and get an item based on an index. Going to - libenkf/src/gen_data.c we see that two such functions already exist: - - double gen_data_iget_double(const gen_data_type * gen_data, int index); - void gen_data_iset_double(gen_data_type * gen_data, int index, double value); - - -2. We must add bindings from Python to these C functions. Add the - following lines to at the top of the declaration of class GenData: - - _iset = EnkfPrototype("void gen_data_iset_double(gen_data, int , double)") - _iget = EnkfPrototype("double gen_data_iget_double(gen_data, int )") - - -3. Create (simple) Python methods: - - def __getitem__(self , index): - if index < len(self): - return self._iget( index ) - else: - raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , len(self))) - - - def __setitem__(self , index, value): - if index < len(self): - self._iset( index , value ) - else: - raise IndexError("Invalid index:%d - valid range: [0,%d)" % (index , len(self))) - - - diff --git a/ThirdParty/Ert/docs/course/ex3/ex3.txt b/ThirdParty/Ert/docs/course/ex3/ex3.txt deleted file mode 100644 index e5c6750107..0000000000 --- a/ThirdParty/Ert/docs/course/ex3/ex3.txt +++ /dev/null @@ -1,2 +0,0 @@ -Iterate through all the forward models which have been installed and -get the configuration file and executable. diff --git a/ThirdParty/Ert/docs/course/ex3/sol3.py b/ThirdParty/Ert/docs/course/ex3/sol3.py deleted file mode 100644 index 044a865719..0000000000 --- a/ThirdParty/Ert/docs/course/ex3/sol3.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python -import sys -import time -from ert.enkf import EnKFMain - - -# This will instantiate the EnkFMain object and create a handle to -# "everything" ert related for this instance. -ert = EnKFMain( sys.argv[1] ) -site_config = ert.siteConfig( ) - -jobs = site_config.get_installed_jobs( ) -for job in jobs: - print job.name() - print " config : %s" % job.get_config_file() - print " executable: %s" % job.get_executable( ) - print diff --git a/ThirdParty/Ert/docs/course/ex4/ex4.txt b/ThirdParty/Ert/docs/course/ex4/ex4.txt deleted file mode 100644 index 38b16f1939..0000000000 --- a/ThirdParty/Ert/docs/course/ex4/ex4.txt +++ /dev/null @@ -1,13 +0,0 @@ -Create a small script which: - -1. Loads the configuration file. - -2. Initializes the realisations and creates runpath folders. - -3. Submit simulations. - -4. Wait for simulations to complete. - -5. Fetch and print GEN_DATA results - use the GenData[] operator. - - diff --git a/ThirdParty/Ert/docs/course/ex4/sol4.py b/ThirdParty/Ert/docs/course/ex4/sol4.py deleted file mode 100644 index d62277c6c2..0000000000 --- a/ThirdParty/Ert/docs/course/ex4/sol4.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -import sys -import time -from ert.enkf import EnKFMain, RunArg, NodeId -from ert.enkf.data import EnkfNode -from ert.job_queue import JobQueueManager - -ert = EnKFMain( sys.argv[1] ) -fs_manager = ert.getEnkfFsManager( ) -fs = fs_manager.getCurrentFileSystem( ) - - -# Initialize the realisations. -for iens in range( ert.getEnsembleSize()): - realisation = ert.getRealisation( iens ) - realisation.initialize( fs ) - - -# Fetch out the job_queue from the SiteConfig object. In addition we -# create a JobQueueManager objects which wraps the queue. The purpose -# of this manager object is to let the queue run nonblocking in the -# background. -site_config = ert.siteConfig( ) -queue_manager = JobQueueManager( site_config.getJobQueue( ) ) -queue_manager.startQueue( ert.getEnsembleSize( ) , verbose = False ) - - -# Create list of RunArg instances which hold metadata for one running -# realisation, create the directory where the simulation should run -# and submit the simulation. -path_fmt = "/tmp/run%d" -arg_list = [ RunArg.createEnsembleExperimentRunArg(fs, iens, path_fmt % iens) for iens in range(ert.getEnsembleSize()) ] -for arg in arg_list: - ert.createRunPath( arg ) - ert.submitSimulation( arg ) - - -while True: - print("Waiting:%d Running:%d Complete:%d/%d" % (queue_manager.getNumWaiting( ), queue_manager.getNumRunning( ) , queue_manager.getNumSuccess() , queue_manager.getNumFailed( ))) - if not queue_manager.isRunning( ): - break - - time.sleep( 5 ) - -ens_config = ert.ensembleConfig( ) -data_config = ens_config["SNAKE_OIL_OPR_DIFF"] -param_config = ens_config["SNAKE_OIL_PARAM"] -for iens in range(ert.getEnsembleSize( )): - data_id = NodeId( realization_number = iens, - report_step = 199 ) - enkf_node1 = EnkfNode( data_config ) - enkf_node1.load( fs , data_id ) - gen_data = enkf_node1.asGenData( ) - data = gen_data.getData( ) - - - param_id = NodeId( realization_number = iens, - report_step = 0 ) - - enkf_node2 = EnkfNode( param_config ) - enkf_node2.load( fs , param_id ) - gen_kw = enkf_node2.asGenKw( ) - - print sum(data) - for v in gen_kw: - print v - - # Using the __getitem__() of GenData which was implemented - # previously. - for d in gen_data: - print d diff --git a/ThirdParty/Ert/docs/doxygen.cfg.in b/ThirdParty/Ert/docs/doxygen.cfg.in deleted file mode 100644 index 969caa1615..0000000000 --- a/ThirdParty/Ert/docs/doxygen.cfg.in +++ /dev/null @@ -1,42 +0,0 @@ -# This is a slightly modified standard doxygen config file - -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "Ert" -PROJECT_NUMBER = ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} -PROJECT_BRIEF = "ERT is a software initially developed by Statoil which main feature is to handle several ECLIPSE simulations in an Ensemble setting. --- http://ert.nr.no/ert" -PROJECT_LOGO = -OUTPUT_DIRECTORY = ${PROJECT_BINARY_DIR}/documentation/doxy -CREATE_SUBDIRS = NO -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -TAB_SIZE = 2 - -EXTRACT_ALL = YES -EXTRACT_PACKAGE = YES -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO - -CASE_SENSE_NAMES = YES - -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = NO -WARN_IF_DOC_ERROR = NO -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" - -INPUT = ${DOXYGEN_INPUT} - -RECURSIVE = YES -EXCLUDE_PATTERNS = */test/* */build/* */test-data/* */docs/* */python*/ - -HAVE_DOT = ${DOXYGEN_HAVE_DOT} -DOT_GRAPH_MAX_NODES = 1000 -GENERATE_HTML = YES -CLASS_DIAGRAMS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = NO -CALL_GRAPH = YES - -DOT_IMAGE_FORMAT = png -INTERACTIVE_SVG = NO diff --git a/ThirdParty/Ert/docs/eclipse_restart_spe1.txt b/ThirdParty/Ert/docs/eclipse_restart_spe1.txt deleted file mode 100644 index fd08813163..0000000000 --- a/ThirdParty/Ert/docs/eclipse_restart_spe1.txt +++ /dev/null @@ -1,109 +0,0 @@ -This files contains additional information about the structure of restart files generated in ECLIPSE. - -This applies to the case spe1 in the opm-data repository. - -INTEHEAD: -0: Value based on computer time in which the file was written -67: Timestep -68: Report step -219: Report step-1 -Values not described her or in ecl_kw_magic, are constant during simulation. - -LOGIHEAD -1: Set to true if RV values are calculated. -86: does not impact solution -Values not described her or in ecl_kw_magic, are constant during simulation. - -DOUBHEAD: -0: days -21: EQUIL, item 1 -157: Reservoir mean pressure -158: A double related to RS, but does not impact solution -159: possibly related to RV, 0 if RV not set -160: Start of simulation, 735979 days after year 0 -161: A whole number, value = 735979 + days -(735979 / 365.25 = 2015.00007. 735979 = Number of days since year 0) -Values not described her or in ecl_kw_magic, are constant during simulation. - -IWEL: -Changes during eclipse simulation. Reset to start values at restart stage does not impact solution. Related to the values: -index: 7 -index: 8 -index: 23 -index: 141 -index: 154 -index: 178 -All values except 7, 8, 23 , 141 154 and 178 are constant during simulation. -Known IWELS in addition to ecl_kw_magic: -0: PROD, X -1: PROD, Y -2: COMPDAT, 'PROD', item 4 -3: COMPDAT, 'PROD', item 5 -4: Number of completion connections -7, Uncertain -8: Uncertain -15: 1 = Oil production, 3 = Gas production -155: INJ, X -156: INJ, Y -157: COMPDAT, 'INJ', item 4 -158: COMPDAT, 'INJ', item 5 -159: Number of completion connections -168: Uncertain - -SWEL: -Mostly SWEL will contain the values: -0 -1 -+/-100000002004087734272, which are either missing entries in the .DATA file or settings. -Otherwise: -0: WCONPROD, item 4, noentry = 100000002004087734272 -2: WCONPROD, item 6, noentry = 100000002004087734272 -6: WCONPROD, item 9 -9: WELSPECS, 'PROD', item 5 -54: same as index: 2 -55: same as index: 6 -122: WCONINJ, item 6 -124: WCONINJ, item 5 -128: WCONINJ, item 7 -131: WELSPECS, 'INJ', item 5 -176: same as index: 124 -177: same as index: 128 -During simulation spe1, SWEL is constant. - -ICON: -1: I coordinate -2: J coordinate -3: K coordinate -4: Number of cells IF: I, J, K is are max. -During simulation spe1, ICON is constant. - - -These KS are unchanged during simulation (spe1): -LOGIHEAD -IGRP -SGRP -SWEL -ZWLS -ICON -SCON - - -KW that does not need to be present (can be removed): -XGRP -ZGRP -XWEL -IWLS -XCON -DLYTIM -HIDDEN -REGDIMS -FIPFAMNA -REGRPT - -note about STARTSOL: -ECLIPSE may cause if error or bugs anything unknwon or unecessary is added after STARTSOL -In spe1, there are some extra KWs after ENDSOL, and the TEMP and RV words, which should be removed. -If RV is calculated, Logihead indx: 1 should be set to true, if RV is not calculated, logihead,indx 1 should be set to false and RV should not be printed to solution. - - - diff --git a/ThirdParty/Ert/docs/eclipse_restart_specification.txt b/ThirdParty/Ert/docs/eclipse_restart_specification.txt deleted file mode 100644 index 6630d4225f..0000000000 --- a/ThirdParty/Ert/docs/eclipse_restart_specification.txt +++ /dev/null @@ -1,268 +0,0 @@ -Source: -kw_magic: K -Schlum : S -Decrypt : D - -INTEHEAD -INDEX SOURCE VALUE -0 S/D ISNUM = Time encoded number -1 D 201601 -2 K/S units type = 1 (METRIC), 2 (FIELD), 3 (LAB), 4 (PVT-M) -3 D CONSTANT, -2345 -4 D CONSTANT, -2345 -5 D CONSTANT, -2345 -6 D CONSTANT, -2345 -7 D CONSTANT, -2345 -8 K/S NX, cells in x dimension -9 K/S NY, cells in y dimension -10 K/S NZ, cells in z dimenstion -11 K/S NACTIV, number of active cells -12 - - -13 - - -14 K/S IPHS, intehead phase indicator -15 D CONSTANT, -2345 -16 K/S NWELLS=number of wells -17 K/S NCWMAX=maximum number of completions per wells -18 - - -19 K/S NWGMAX=maximum number of wells in any well group -20 K/S NGMAXZ=maximum number of groups in field -21 D CONSTANT, 0 -22 D CONSTANT, 0 -23 D CONSTANT, 0 -24 K/S NWELZ=number of data elements per well in IWEL array -25 K/S NSWELZ=number of data elements per well in SWEL array -26 K/S NXWELZ=number of data elements per well in XWEL array -27 K/S NZWELZ=number of data elements per well in ZWEL array -28 - - -29 - - -30 D CONSTANT, 1 -31 D CONSTANT, -2345 -32 K/S NICONZ=number of elements in ICON array -33 K/S NSCONZ=number of elements in SCON array -34 K/S NXCONZ=number of elements in XCON array -35 D CONSTANT, -2345 -36 K/S NIGRPZ=number of data elements per group in IGRP array -37 S NSGRPZ=number of data elements per group in SGRP array -38 S NXGRPZ=number of data elements per group in XGRP array -39 S NZGRPZ=number of data elements per group in ZGRP array -40 D CONSTANT, 0 -41 S NCAMAX=maximum number of analytic aquifer connections -42 S NIAAQZ=number of data elements per aquifer in IAAQ array -43 S NSAAQZ=number of data elements per aquifer in SAAQ array -44 S NXAAQZ=number of data elements per aquifer in XAAQ array -45 S NICAQZ=number of data elements per aquifer in ICAQ array -46 S NSCAQZ=number of data elements per aquifer in SCAQ array -47 S NXCAQZ=number of data elements per aquifer in XCAQ array -48 D CONSTANT, 0 -49 - - -50 D CONSTANT, 1 -51 - - -52 D CONSTANT, 0 -53 D CONSTANT, 0 -54 D CONSTANT, 0 -55 - - -56 D CONSTANT, 0 -57 D CONSTANT, 0 -58 D CONSTANT, 0 -59 D CONSTANT, 0 -60 D CONSTANT, 0 -61 D CONSTANT, 0 -62 D CONSTANT, 0 -63 D CONSTANT, 0 -64 K/S IDAY -65 K/S IMON -66 K/S IYEAR -67 D Timestep -68 D Reportstep -69 D CONSTANT, 0 -70 D CONSTANT, 1 -71 D CONSTANT, 0 -72 D CONSTANT, 0 -73 D CONSTANT, 0 -74 - - -75 D CONSTANT, 0 -76 - - -77 D CONSTANT, 10 -78 D CONSTANT 0 -79 - - -80 D CONSTANT, 12 -81 D CONSTANT, 1 -82 - - -83 D CONSTANT, 1 -84 D CONSTANT, -2345 -85 D CONSTANT, -2345 -86 - - -87 D CONSTANT, 8 -88 - - -89 - - -90 D CONSTANT, 2 -91 D CONSTANT, 3 -92 D CONSTANT, 1 -93 D CONSTANT, 2 -94 K/S IPROG, simulation program identifier -95 D CONSTANT, 0 -96 - - -97 D CONSTANT, 0 -98 D CONSTANT, -17 -99 - - -100 D 0 -101 D 1 -102 D 0 -103 D 1 -104 D 0 -105 D NX -106 D NY -107 D Number of cells -108 - - -109 D CONSTANT, 1 -110 D CONSTANT, 1 -111 D CONSTANT, 1 -112 D CONSTANT, 1 -113 - - -114 - - -115 - - -116 D CONSTANT, 25 -117 D CONSTANT, 1 -118 D CONSTANT, 0 -119 D CONSTANT, 0 -120 D CONSTANT, 0 -121 D CONSTANT, 0 -122 D CONSTANT, 0 -123 D CONSTANT, 1 -124 D CONSTANT, 1 -125 D CONSTANT, 1 -126 D CONSTANT, 0 -127 D CONSTANT, 0 -128 - - -129 D CONSTANT, 0 -130 D CONSTANT, 0 -131 D CONSTANT, 0 -132 D CONSTANT, 0 -133 D CONSTAND, 14 -134 D CONSTAND, 11 -135 D CONSTAND, 10 -136 D CONSTAND, 17 -137 D CONSTANT, 2 -138 D CONSTANT, 1 -139 D CONSTANT, 1 -140 D CONSTANT, 1 -141 D CONSTANT, 1 -142 - - -143 D CONSTANT, 1 -144 D CONSTANT, 1 -145 D CONSTANT, 1 -146 D CONSTANT, 1 -147 D CONSTANT, 1 -148 D CONSTANT, 1 -149 - - -150 D CONSTANT, 122 -151 D CONSTANT, 0 -152 D CONSTANT, 0 -153 D CONSTANT, 0 -154 D CONSTANT, 0 -155 D CONSTANT, 0 -156 D CONSTANT, 0 -157 D CONSTANT, 50 -158 D CONSTANT, 10 -159 D CONSTANT, 4 -160 D CONSTANT, 5 -161 D CONSTANT, 9 -162 D CONSTANT, 0 -163 - - -164 D CONSTANT; 8 -165 D CONSTANT; 8 -166 D CONSTANT; 12 -167 D CONSTANT; 1 -168 D CONSTANT; 25 -169 D CONSTANT; 1 -170 D CONSTANT, -1073741823 -171 D CONSTANT, -1073741823 -172 D CONSTANT, -1073741823 -173 D CONSTANT, -1073741823 -174 D CONSTANT, 0 -175 D CONSTANT, 1 -176 D CONSTANT, 1 -177 D CONSTANT, 1 -178 D CONSTANT, 22 -179 - - -180 D CONSTANT, 10 -181 D CONSTANT, 1 -182 D CONSTANT, 1 -183 D CONSTANT, 1 -184 D CONSTANT, 1 -185 - - -186 D CONSTANT, 116 -187 D CONSTANT, -1073741823 -188 D CONSTANT, -1073741823 -189 D CONSTANT, 0 -190 D CONSTANT, 0 -191 D CONSTANT, 130 -192 D CONSTANT, 58 -193 D CONSTANT, 180 -194 D CONSTANT, 10 -195 D CONSTANT, 0 -196 D CONSTANT, 25 -197 D CONSTANT, 155 -198 D CONSTANT, 0 -199 D CONSTANT, 0 -200 D CONSTANT, 1 -201 - - -202 D CONSTANT, 116 -203 D CONSTANT, 0 -204 D CONSTANT, 0 -205 D CONSTANT, 0 -206 D CONSTANT, 0 -207 D CONSTANT, 0 -208 D CONSTANT, 0 -209 D CONSTANT, 1 -210 D CONSTANT, 0 -211 - - -212 D CONSTANT, 0 -213 D CONSTANT, 0 -214 D CONSTANT, 1 -215 D CONSTANT, 0 -216 D CONSTANT, 0 -217 D CONSTANT, 1 -218 D CONSTANT, 0 -219 D Reportstep - 1 -220 D CONSTANT, 12 -221 D CONSTANT, 0 -222 D CONSTANT, 0 -223 D CONSTANT, 10 -224 D CONSTANT, 13 -225 D CONSTANT, 1 -226 D CONSTANT, 0 -227 D CONSTANT, 0 -228 D CONSTANT, 0 -229 D CONSTANT, 0 -230 D CONSTANT, 2 -231 D CONSTANT, 0 -232 D CONSTANT, 0 -233 D CONSTANT, 3600 -234 D CONSTANT, 1 -235 D CONSTANT, 0 -236 D CONSTANT, 1 -237 D CONSTANT, 10 -238 D CONSTANT, 1 -239 D CONSTANT, 10 -240 - - -241 D CONSTANT, 1 -242 - - - -287 D Number of cells - -302-410 D CONSTANT, -2345 - - - - - -DOUBHEAD - - - - - - - - diff --git a/ThirdParty/Ert/docs/nexus.plt b/ThirdParty/Ert/docs/nexus.plt deleted file mode 100644 index 88b482631b..0000000000 --- a/ThirdParty/Ert/docs/nexus.plt +++ /dev/null @@ -1,51 +0,0 @@ - - -bbbbPLOT__BIN_ : Header - verify file type -562*b : Header - skipped -264*b : Header - skipped -i : num_classes -iii : Day Month Year -i : nx -i : ny -i : nz -i : ncomp (number of phases???) -8b : ??? -num_classes *8b : The class names -8*b : Skipped -num_classes *i : The number of variables in each class (var_in_class[]) -8*b : Skipped - -for c in classes: - 4*b : TIME var name - for v in vars[c]: - 4*b : The variable names - 8*b : Skipped - -----> : This is the position of first timestep - -while classname != STOP: - 8*b : classname - 8*b : skipped - f : timestep (cast to int) - f : time - f : num_items (cast to int) - f : max_items (cast to int) - f : max_perfs (cast to int) - - if classame in ["WELLBORE","WELLYR"]: - 8*b : skipped - for item in num_items: - 8*b : skipped - 8*b : skipped - 8*b : ncon = atoi( ) - 48*b : skipped - for con in ncon: - 8*b : con_num (ignored) - 8*b : layer_name (ignored) - var_in_class*f : The real data - 16*b : skipped - else: - 8*b : skipped - 72*b : skipped - var_in_class*f : The real data - 8*b : skipped diff --git a/ThirdParty/Ert/install/install.py b/ThirdParty/Ert/install/install.py index 6358d54de7..1a60337933 100644 --- a/ThirdParty/Ert/install/install.py +++ b/ThirdParty/Ert/install/install.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index b0fb796a1c..079eb127de 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -54,12 +54,6 @@ if (ZLIB_FOUND) list(APPEND opt_srcs util/util_zlib.cpp) endif () -if (ERT_BUILD_CXX) - list(APPEND opt_srcs ecl/FortIO.cpp - ecl/Smspec.cpp - ecl/EclFilename.cpp -) -endif () configure_file(build_config.h.in include/ert/util/build_config.h) configure_file(ert_api_config.h.in include/ert/util/ert_api_config.h) @@ -145,6 +139,8 @@ add_library(ecl util/rng.cpp ecl/well_segment_collection.cpp ecl/well_branch_collection.cpp ecl/well_rseg_loader.cpp + ecl/FortIO.cpp + ecl/EclFilename.cpp geometry/geo_surface.cpp geometry/geo_util.cpp @@ -183,13 +179,6 @@ target_include_directories(ecl ${CMAKE_CURRENT_BINARY_DIR}/include ) - -if (NOT INSTALL_ERT) - # set git info to zero, to avoid recompile of libecl files at every commit - set(GIT_COMMIT 0) - set(GIT_COMMIT_SHORT 0) -endif() - target_compile_definitions(ecl PRIVATE -DGIT_COMMIT=${GIT_COMMIT} -DGIT_COMMIT_SHORT=${GIT_COMMIT_SHORT} @@ -211,7 +200,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) -if (INSTALL_ERT) + install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -219,25 +208,11 @@ install(TARGETS ecl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(DIRECTORY include/ DESTINATION include - PATTERN *.h -) -install(DIRECTORY include/ - DESTINATION include - PATTERN *.hpp EXCLUDE ) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include - PATTERN *.h ) -if (ERT_BUILD_CXX) - install(DIRECTORY include/ - DESTINATION include - PATTERN *.hpp -) -endif () -endif() - if (NOT BUILD_TESTS) return () endif () @@ -277,6 +252,7 @@ foreach (name ert_util_alloc_file_components ert_util_datetime ert_util_normal_path ert_util_mkdir_p + test_area ) add_executable(${name} util/tests/${name}.cpp) @@ -353,11 +329,14 @@ foreach (name ecl_alloc_cpgrid ecl_grid_copy ecl_grid_create ecl_grid_DEPTHZ + ecl_grid_fwrite 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 @@ -436,26 +415,24 @@ foreach (name geo_util_xlines geo_polygon geo_polygon_collection) add_test(NAME ${name} COMMAND ${name}) endforeach () -if (ERT_BUILD_CXX) - foreach (test ert_util_unique_ptr) - add_executable(${test} util/tests/${test}.cpp) - target_link_libraries(${test} ecl) - add_test(NAME ${test} COMMAND ${test}) - endforeach() +foreach (test ert_util_unique_ptr) + add_executable(${test} util/tests/${test}.cpp) + target_link_libraries(${test} ecl) + add_test(NAME ${test} COMMAND ${test}) +endforeach() - foreach (test eclxx_kw eclxx_fortio eclxx_smspec eclxx_filename eclxx_types) - add_executable(${test} ecl/tests/${test}.cpp) - target_link_libraries(${test} ecl) - add_test(NAME ${test} COMMAND ${test}) - endforeach () -endif () +foreach (test eclxx_kw eclxx_fortio eclxx_filename eclxx_types) + add_executable(${test} ecl/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_statoil_root + ecl_nnc_data_equinor_root ecl_sum_case_exists ecl_grid_lgr_name ecl_region @@ -467,19 +444,19 @@ foreach(name ecl_coarse_test ecl_grid_dims ecl_nnc_test ecl_lgr_test - ecl_layer_statoil + 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_statoil + ecl_file_equinor ecl_fmt ecl_rsthead ecl_smspec ecl_rft - ecl_grid_copy_statoil - ecl_fault_block_layer_statoil + ecl_grid_copy_equinor + ecl_fault_block_layer_equinor well_state_load well_state_load_missing_RSEG well_segment_load @@ -497,7 +474,7 @@ foreach(name ecl_coarse_test endforeach() -if (NOT STATOIL_TESTDATA_ROOT) +if (NOT EQUINOR_TESTDATA_ROOT) return () endif() @@ -531,7 +508,7 @@ add_test(NAME ecl_nnc_export7 COMMAND ecl_nnc_export ${_eclpath}/TYRIHANS/BASE20 add_test(NAME ecl_nnc_export_get_tran COMMAND ecl_nnc_export_get_tran ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3) -add_test(NAME ecl_nnc_data_statoil_root COMMAND ecl_nnc_data_statoil_root +add_test(NAME ecl_nnc_data_equinor_root COMMAND ecl_nnc_data_equinor_root ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3 ${_eclpath}/flow-nnc/Simple4/SIMPLE_SUMMARY4 ${_eclpath}/flow-nnc/Gullfaks/GF_ACT_NEW_TEMP) @@ -572,7 +549,7 @@ add_test(NAME ecl_grid_simple COMMAND ecl_grid_simple ${_eclpath}/Gurbat/ECLIPSE add_test(NAME ecl_grid_ecl2015_2 COMMAND ecl_grid_simple ${_eclpath}/Eclipse2015_NNC_BUG/FF15_2015B2_LGRM_RDI15_HIST_RDIREAL1_20142.EGRID) -add_test(NAME ecl_grid_export_statoil +add_test(NAME ecl_grid_export_equinor COMMAND ecl_grid_export ${_eclpath}/Gurbat/ECLIPSE.EGRID) add_test(NAME ecl_grid_volume1 COMMAND ecl_grid_volume ${_eclpath}/Gurbat/ECLIPSE) @@ -600,7 +577,7 @@ add_test(NAME ecl_nnc_test3 COMMAND ecl_nnc_test ${_eclpath}/Troll/MSW_LGR/2BRAN add_test(NAME ecl_nnc_test4 COMMAND ecl_nnc_test ${_eclpath}/DualPoro/DUAL_DIFF.EGRID ) add_test(NAME ecl_nnc_test5 COMMAND ecl_nnc_test ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR.EGRID) -add_test(NAME ecl_layer_statoil COMMAND ecl_layer_statoil +add_test(NAME ecl_layer_equinor COMMAND ecl_layer_equinor ${_eclpath}/Mariner/MARINER.EGRID ${_eclpath}/Mariner/faultblock.grdecl) @@ -622,8 +599,8 @@ add_test(NAME ecl_sum_report_step_compatible4 COMMAND ecl_sum_report_step_compat add_test(NAME ecl_sum_report_step_compatible5 COMMAND ecl_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 ${_eclpath}/Snorre2/SNORRE2 FALSE) -add_test(NAME ecl_file_statoil - COMMAND ecl_file_statoil ${_eclpath}/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST) +add_test(NAME ecl_file_equinor + COMMAND ecl_file_equinor ${_eclpath}/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST) add_test(NAME ecl_fmt COMMAND ecl_fmt ${_eclpath}/Gurbat/ECLIPSE.UNRST @@ -645,12 +622,12 @@ 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 ecl_grid_copy_statoil1 COMMAND ecl_grid_copy_statoil ${_eclpath}/Gurbat/ECLIPSE.EGRID) -add_test(NAME ecl_grid_copy_statoil2 COMMAND ecl_grid_copy_statoil ${_eclpath}/Mariner/MARINER.EGRID) -add_test(NAME ecl_grid_copy_statoil3 COMMAND ecl_grid_copy_statoil ${_eclpath}/LGCcase/LGC_TESTCASE2.EGRID) -add_test(NAME ecl_grid_copy_statoil4 COMMAND ecl_grid_copy_statoil ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID) +add_test(NAME ecl_grid_copy_equinor1 COMMAND ecl_grid_copy_equinor ${_eclpath}/Gurbat/ECLIPSE.EGRID) +add_test(NAME ecl_grid_copy_equinor2 COMMAND ecl_grid_copy_equinor ${_eclpath}/Mariner/MARINER.EGRID) +add_test(NAME ecl_grid_copy_equinor3 COMMAND ecl_grid_copy_equinor ${_eclpath}/LGCcase/LGC_TESTCASE2.EGRID) +add_test(NAME ecl_grid_copy_equinor4 COMMAND ecl_grid_copy_equinor ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID) -add_test(NAME ecl_fault_block_layer_statoil COMMAND ecl_fault_block_layer_statoil +add_test(NAME ecl_fault_block_layer_equinor COMMAND ecl_fault_block_layer_equinor ${_eclpath}/Mariner/MARINER.EGRID ${_eclpath}/Mariner/faultblock.grdecl) @@ -684,7 +661,9 @@ add_test(NAME well_segment_load add_test(NAME well_segment_branch_conn_load COMMAND well_segment_branch_conn_load ${_eclpath}/MSWcase/MSW_CASE.X0021) -add_test(NAME well_info COMMAND well_info ${_eclpath}/Gurbat/ECLIPSE.EGRID) +add_test(NAME well_info1 COMMAND well_info ${_eclpath}/Gurbat/ECLIPSE.EGRID) +add_test(NAME well_info2 COMMAND well_info ${_eclpath}/well_info_rio/BMS8_TMPL_1-BMS8_105DST_EMBED_T0_1.EGRID + ${_eclpath}/well_info_rio/BMS8_TMPL_1-BMS8_105DST_EMBED_T0_1.UNRST) add_test(NAME well_conn_CF COMMAND well_conn_CF ${_eclpath}/Gurbat/ECLIPSE.X0060) diff --git a/ThirdParty/Ert/lib/ecl/EclFilename.cpp b/ThirdParty/Ert/lib/ecl/EclFilename.cpp index 225ad52b46..f5db772659 100644 --- a/ThirdParty/Ert/lib/ecl/EclFilename.cpp +++ b/ThirdParty/Ert/lib/ecl/EclFilename.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/FortIO.cpp b/ThirdParty/Ert/lib/ecl/FortIO.cpp index c76985f173..edc5f1f92c 100644 --- a/ThirdParty/Ert/lib/ecl/FortIO.cpp +++ b/ThirdParty/Ert/lib/ecl/FortIO.cpp @@ -1,5 +1,5 @@ /* - Copyright 2015 Statoil ASA. + Copyright 2015 Equinor ASA. This file is part of the Open Porous Media project (OPM). diff --git a/ThirdParty/Ert/lib/ecl/Smspec.cpp b/ThirdParty/Ert/lib/ecl/Smspec.cpp deleted file mode 100644 index ba81341bef..0000000000 --- a/ThirdParty/Ert/lib/ecl/Smspec.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include - -namespace ERT { - - smspec_node::smspec_node( const smspec_node& rhs ) : - node( smspec_node_alloc_copy( rhs.node.get() ) ) - {} - - smspec_node::smspec_node( smspec_node&& rhs ) : - node( std::move( rhs.node ) ) - {} - - smspec_node& smspec_node::operator=( const smspec_node& rhs ) { - this->node.reset( smspec_node_alloc_copy( rhs.node.get() ) ); - return *this; - } - - smspec_node& smspec_node::operator=( smspec_node&& rhs ) { - this->node = std::move( rhs.node ); - return *this; - } - - int smspec_node::cmp( const smspec_node& node1, const smspec_node& node2) { - return smspec_node_cmp( node1.get() , node2.get() ); - } - - static const int dummy_dims[ 3 ] = { -1, -1, -1 }; - const auto default_join = ":"; - - static int global_index( const int dims[ 3 ], const int ijk[ 3 ] ) { - /* num is offset 1 global index */ - return 1 + ijk[ 0 ] + ( ijk[ 1 ] * dims[ 0 ] ) + ( ijk[ 2 ] * dims[ 1 ] * dims[ 0 ] ); - } - - smspec_node::smspec_node( - ecl_smspec_var_type var_type, - const std::string& name, - const std::string& kw - ) : smspec_node( var_type, name.c_str(), kw.c_str(), "", default_join, dummy_dims, 0 ) - {} - - smspec_node::smspec_node( const std::string& keyword ) : - smspec_node( ecl_smspec_identify_var_type( keyword.c_str() ), - "", - keyword.c_str(), - "", - default_join, - dummy_dims, - 0 ) - {} - - smspec_node::smspec_node( - const std::string& keyword, - const int dims[ 3 ], - const int ijk[ 3 ] ) : - smspec_node( - ECL_SMSPEC_BLOCK_VAR, "", keyword.c_str(), "", default_join, dims, global_index( dims, ijk ) - ) - {} - - smspec_node::smspec_node( - const std::string& keyword, - const std::string& wellname, - const int dims[ 3 ], - const int ijk[ 3 ] ) : - smspec_node( - ECL_SMSPEC_COMPLETION_VAR, wellname.c_str(), keyword.c_str(), "", default_join, dims, global_index( dims, ijk ) - ) - {} - - smspec_node::smspec_node( - const std::string& keyword, - const int dims[ 3 ], - int region ) : - smspec_node( - ECL_SMSPEC_REGION_VAR, "", keyword.c_str(), "", default_join, dims, region - ) - {} - - smspec_node::smspec_node( - ecl_smspec_var_type type, - const char* wgname, - const char* keyword, - const char* unit, - const char* join, - const int grid_dims[ 3 ], - int num, int index, float default_value ) : - node( smspec_node_alloc( type, wgname, keyword, unit, - join, grid_dims, num, index, default_value ) ) - {} - - int smspec_node::type() const { - return smspec_node_get_var_type( this->node.get() ); - } - - const char* smspec_node::wgname() const { - return smspec_node_get_wgname( this->node.get() ); - } - - const char* smspec_node::keyword() const { - return smspec_node_get_keyword( this->node.get() ); - } - - const char* smspec_node::key1() const { - return smspec_node_get_gen_key1( this->node.get() ); - } - - int smspec_node::num() const { - return smspec_node_get_num( this->node.get() ); - } - - smspec_node_type* smspec_node::get() { - return this->node.get(); - } - - const smspec_node_type* smspec_node::get() const { - return this->node.get(); - } -} diff --git a/ThirdParty/Ert/lib/ecl/ecl_box.cpp b/ThirdParty/Ert/lib/ecl/ecl_box.cpp index 292e7a78b5..de0c5b3e68 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_box.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_box.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_box.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp index 44fb620c58..09cd1a0d6b 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2012 statoil asa, norway. + Copyright (c) 2012 equinor asa, norway. The file 'ecl_coarse_cell.c' is part of ert - ensemble based reservoir tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_file.cpp b/ThirdParty/Ert/lib/ecl/ecl_file.cpp index 6384912bf6..d99e468623 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_file.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool. @@ -534,10 +534,13 @@ static void ecl_file_scan( ecl_file_type * ecl_file ) { if (read_status == ECL_KW_READ_OK) { ecl_file_kw_type * file_kw = ecl_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 ); - else + else { + ecl_file_kw_free( file_kw ); break; + } } } } diff --git a/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp b/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp index 5d5065c370..4bc20c32cc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_file_kw.c' is part of ERT - Ensemble based Reservoir Tool. @@ -91,7 +91,7 @@ static void inv_map_assert_sort( inv_map_type * map ) { size_t_vector_permute( map->file_kw_ptr , perm ); map->sorted = true; - free( perm ); + perm_vector_free( perm ); } } diff --git a/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp b/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp index 0a6e0a7622..f8fdd15999 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool. @@ -19,9 +19,7 @@ #include #include - -#include -#include +#include #include #include @@ -33,13 +31,13 @@ struct ecl_file_view_struct { - vector_type * kw_list; /* This is a vector of ecl_file_kw instances corresponding to the content of the file. */ - hash_type * kw_index; /* A hash table with integer vectors of indices - see comment below. */ + 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. */ bool owner; /* Is this map the owner of the ecl_file_kw instances; only true for the global_map. */ inv_map_type * inv_map; /* Shared reference owned by the ecl_file structure. */ - vector_type * child_list; + std::vector child_list; int * flags; }; @@ -75,9 +73,6 @@ const char * ecl_file_view_get_src_file( const ecl_file_view_type * file_view ) 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(); - ecl_file_view->kw_list = vector_alloc_new(); - ecl_file_view->kw_index = hash_alloc(); - ecl_file_view->child_list = vector_alloc_new(); ecl_file_view->owner = owner; ecl_file_view->fortio = fortio; ecl_file_view->inv_map = inv_map; @@ -87,9 +82,8 @@ ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , i } int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , const char * kw , int ith) { - const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); - int global_index = int_vector_iget( index_vector , ith); - return global_index; + const auto& index_vector = ecl_file_view->kw_index.at(kw); + return index_vector[ith]; } @@ -105,34 +99,28 @@ int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , c void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) { ecl_file_view->distinct_kw.clear(); - hash_clear( ecl_file_view->kw_index ); + ecl_file_view->kw_index.clear(); { - int i; - for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { - const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i); - const char * header = ecl_file_kw_get_header( file_kw ); - if ( !hash_has_key( ecl_file_view->kw_index , header )) { - int_vector_type * index_vector = int_vector_alloc( 0 , -1 ); - hash_insert_hash_owned_ref( ecl_file_view->kw_index , header , index_vector , int_vector_free__); + 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); - } - { - int_vector_type * index_vector = (int_vector_type*)hash_get( ecl_file_view->kw_index , header); - int_vector_append( index_vector , i); - } + auto& index_vector = ecl_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 hash_has_key( ecl_file_view->kw_index , kw ); + return (ecl_file_view->kw_index.find(kw) != ecl_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) { - ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , global_index); - return file_kw; + return ecl_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) { @@ -188,12 +176,12 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons int ecl_file_view_find_kw_value( const ecl_file_view_type * ecl_file_view , const char * kw , const void * value) { int global_index = -1; if ( ecl_file_view_has_kw( ecl_file_view , kw)) { - const int_vector_type * index_list = (const int_vector_type*)hash_get( ecl_file_view->kw_index , kw ); - int index = 0; - while (index < int_vector_size( index_list )) { - const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( index_list , index )); + const auto& index_list = ecl_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 )) { - global_index = int_vector_iget( index_list , index ); + global_index = index_list[index]; break; } index++; @@ -212,7 +200,7 @@ 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 ) { - return vector_get_size( ecl_file_view->kw_list ); + return ecl_file_view->kw_list.size(); } @@ -249,9 +237,9 @@ int ecl_file_view_iget_named_size( const ecl_file_view_type * ecl_file_view , co 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) { - int index = 0; - while (index < vector_get_size( ecl_file_view->kw_list )) { - ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); + 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)) { /* Found it; observe that the vector_iset() function will @@ -276,11 +264,8 @@ bool ecl_file_view_load_all( ecl_file_view_type * ecl_file_view ) { bool loadOK = false; if (fortio_assert_stream_open( ecl_file_view->fortio )) { - int index; - for (index = 0; index < vector_get_size( ecl_file_view->kw_list); index++) { - ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); - ecl_file_kw_get_kw( ikw , ecl_file_view->fortio , ecl_file_view->inv_map); - } + 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); loadOK = true; } @@ -296,16 +281,18 @@ 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) { - if (ecl_file_view->owner) - vector_append_owned_ref( ecl_file_view->kw_list , file_kw , ecl_file_kw_free__ ); - else - vector_append_ref( ecl_file_view->kw_list , file_kw); + ecl_file_view->kw_list.push_back( file_kw ); } void ecl_file_view_free( ecl_file_view_type * ecl_file_view ) { - vector_free( ecl_file_view->child_list ); - hash_free( ecl_file_view->kw_index ); - vector_free( ecl_file_view->kw_list ); + + for (auto& child_ptr : ecl_file_view->child_list) + ecl_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 ); + } delete ecl_file_view; } @@ -317,16 +304,15 @@ 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) { - if (hash_has_key(ecl_file_view->kw_index , kw)) { - const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); - return int_vector_size( index_vector ); + if (ecl_file_view_has_kw(ecl_file_view, kw)) { + const auto& index_vector = ecl_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) { - int index; - for (index = offset; index < vector_get_size( ecl_file_view->kw_list ); index++) { + 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 ); } @@ -336,18 +322,17 @@ void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_typ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int global_index) { - const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , 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 int_vector_type * index_vector = (const int_vector_type*)hash_get( ecl_file_view->kw_index , header ); - const int * index_data = int_vector_get_const_ptr( index_vector ); + const auto& index_vector = ecl_file_view->kw_index.at(header); int occurence = -1; { /* Manual reverse lookup. */ - int i; - for (i=0; i < int_vector_size( index_vector ); i++) - if (index_data[i] == global_index) + for (size_t i=0; i < index_vector.size(); i++) { + if (index_vector[i] == global_index) occurence = i; + } } if (occurence < 0) util_abort("%s: internal error ... \n" , __func__); @@ -356,9 +341,7 @@ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int } void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FILE * stream) { - int i; - for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { - const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i ); + 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 ) , @@ -375,21 +358,21 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e ecl_file_view_type * block_map = ecl_file_view_alloc( ecl_file_view->fortio , ecl_file_view->flags , ecl_file_view->inv_map , false); - int kw_index = 0; + size_t kw_index = 0; if (start_kw) kw_index = ecl_file_view_get_global_index( ecl_file_view , start_kw , occurence ); { - ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , kw_index ); + ecl_file_kw_type * file_kw = ecl_file_view->kw_list[kw_index]; while (true) { ecl_file_view_add_kw( block_map , file_kw ); kw_index++; - if (kw_index == vector_get_size( ecl_file_view->kw_list )) + if (kw_index == ecl_file_view->kw_list.size()) break; else { if (end_kw) { - file_kw = (ecl_file_kw_type*)vector_iget(ecl_file_view->kw_list , kw_index); + file_kw = ecl_file_view->kw_list[kw_index]; if (strcmp( end_kw , ecl_file_kw_get_header( file_kw )) == 0) break; } @@ -408,21 +391,21 @@ ecl_file_view_type * ecl_file_view_alloc_blockview(const ecl_file_view_type * ec } -ecl_file_view_type * ecl_file_view_add_blockview(const ecl_file_view_type * file_view , const char * header, int 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); if (child) - vector_append_owned_ref( file_view->child_list , child , ecl_file_view_free__ ); + file_view->child_list.push_back(child); return child; } -ecl_file_view_type * ecl_file_view_add_blockview2(const 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_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); if (child) - vector_append_owned_ref( ecl_file_view->child_list , child , ecl_file_view_free__ ); + ecl_file_view->child_list.push_back(child); return child; } @@ -593,10 +576,10 @@ double ecl_file_view_iget_restart_sim_days(const ecl_file_view_type * ecl_file_v int ecl_file_view_find_sim_time(const ecl_file_view_type * ecl_file_view , time_t sim_time) { int seqnum_index = -1; if ( ecl_file_view_has_kw( ecl_file_view , INTEHEAD_KW)) { - const int_vector_type * intehead_index_list = (const int_vector_type *)hash_get( ecl_file_view->kw_index , INTEHEAD_KW ); - int index = 0; - while (index < int_vector_size( intehead_index_list )) { - const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( intehead_index_list , index )); + const auto& intehead_index_list = ecl_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) { seqnum_index = index; break; @@ -832,6 +815,8 @@ void ecl_file_view_end_transaction( ecl_file_view_type * file_view, ecl_file_tra 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]); } + free(transaction->ref_count); + free(transaction); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav.cpp b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp index 42e96c240b..2503317369 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. @@ -20,9 +20,11 @@ #include #include +#include +#include +#include + #include -#include -#include #include #include @@ -69,12 +71,10 @@ struct ecl_grav_struct { const ecl_file_type * init_file; /* The init file - a shared reference owned by calling scope. */ ecl::ecl_grid_cache * grid_cache; /* An internal specialized structure to facilitate fast grid lookup. */ bool * aquifer_cell; /* Numerical aquifer cells should be ignored. */ - hash_type * surveys; /* A hash table containg ecl_grav_survey_type instances; one instance - for each interesting time. */ - hash_type * std_density; /* Hash table indexed with "SWAT" , "SGAS" and "SOIL"; each element - is a double_vector() instance which is indexed by PVTNUM - values. Used to lookup standard condition mass densities. Must - be suuplied by user __BEFORE__ adding a FIP based survey. */ + + std::unordered_map surveys; + std::unordered_map default_density; + std::unordered_map> std_density; }; @@ -90,10 +90,10 @@ struct ecl_grav_survey_struct { UTIL_TYPE_ID_DECLARATION; const ecl::ecl_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. */ - vector_type * phase_list; /* ecl_grav_phase_type objects - one for each phase present in the model. */ - hash_type * phase_map; /* The same objects as in the phase_list vector - accessible by the "SWAT", "SGAS" and "SOIL" keys. */ + 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 phase_map; /* The same objects as in the phase_list vector - accessible by the "SWAT", "SGAS" and "SOIL" keys. */ }; @@ -106,9 +106,9 @@ struct ecl_grav_phase_struct { UTIL_TYPE_ID_DECLARATION; const ecl::ecl_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; + 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; }; @@ -213,7 +213,7 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , const ecl::ecl_grid_cache * grid_cache = ecl_grav->grid_cache; const char * sat_kw_name = ecl_util_get_phase_name( phase ); { - ecl_grav_phase_type * grav_phase = (ecl_grav_phase_type*)util_malloc( sizeof * grav_phase ); + ecl_grav_phase_type * grav_phase = new ecl_grav_phase_type(); const int size = grid_cache->size(); UTIL_TYPE_ID_INIT( grav_phase , ECL_GRAV_PHASE_TYPE_ID ); @@ -225,7 +225,7 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , if (calc_type == GRAV_CALC_FIP) { ecl_kw_type * pvtnum_kw = ecl_file_iget_named_kw( init_file , PVTNUM_KW , 0 ); - double_vector_type * std_density = (double_vector_type*)hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase )); + 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) @@ -240,7 +240,7 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , 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 ); - grav_phase->fluid_mass[ iactive ] = fip * double_vector_safe_iget( std_density , pvtnum ); + grav_phase->fluid_mass[ iactive ] = fip * std_density[pvtnum]; } } } else { @@ -307,23 +307,18 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , static void ecl_grav_phase_free( ecl_grav_phase_type * grav_phase ) { free( grav_phase->work ); free( grav_phase->fluid_mass ); - free( grav_phase ); + delete grav_phase; } -static UTIL_SAFE_CAST_FUNCTION( ecl_grav_phase , ECL_GRAV_PHASE_TYPE_ID ) -static void ecl_grav_phase_free__( void * __grav_phase) { - ecl_grav_phase_type * grav_phase = ecl_grav_phase_safe_cast( __grav_phase ); - ecl_grav_phase_free( grav_phase ); -} /*****************************************************************/ static void ecl_grav_survey_add_phase( ecl_grav_survey_type * survey, ecl_phase_enum phase , ecl_grav_phase_type * grav_phase ) { - vector_append_owned_ref( survey->phase_list , grav_phase , ecl_grav_phase_free__ ); - hash_insert_ref( survey->phase_map , ecl_util_get_phase_name( phase ) , grav_phase ); + survey->phase_list.push_back(grav_phase); + survey->phase_map[std::string(ecl_util_get_phase_name(phase))] = grav_phase; } @@ -349,13 +344,11 @@ static void ecl_grav_survey_add_phases( ecl_grav_type * ecl_grav , ecl_grav_surv 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 = (ecl_grav_survey_type*)util_malloc( sizeof * survey ); + 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; survey->name = util_alloc_string_copy( name ); - survey->phase_list = vector_alloc_new(); - survey->phase_map = hash_alloc(); if (calc_type & GRAV_CALC_USE_PORV) survey->porv = (double*)util_calloc( ecl_grav->grid_cache->size() , sizeof * survey->porv ); @@ -365,8 +358,6 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * return survey; } -static UTIL_SAFE_CAST_FUNCTION( ecl_grav_survey , ECL_GRAV_SURVEY_ID ) - /** Check that the rporv values are in the right ballpark. For ECLIPSE @@ -530,15 +521,12 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_RFIP(ecl_grav_type * ecl_gra static void ecl_grav_survey_free( ecl_grav_survey_type * grav_survey ) { free( grav_survey->name ); free( grav_survey->porv ); - vector_free( grav_survey->phase_list ); - hash_free( grav_survey->phase_map ); - free( grav_survey ); + for (auto * phase : grav_survey->phase_list) + ecl_grav_phase_free( phase ); + + delete grav_survey; } -static void ecl_grav_survey_free__( void * __grav_survey ) { - ecl_grav_survey_type * grav_survey = ecl_grav_survey_safe_cast( __grav_survey ); - ecl_grav_survey_free( grav_survey ); -} @@ -546,13 +534,12 @@ 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) { - int phase_nr; double deltag = 0; - for (phase_nr = 0; phase_nr < vector_get_size( base_survey->phase_list ); phase_nr++) { - ecl_grav_phase_type * base_phase = (ecl_grav_phase_type*)vector_iget( base_survey->phase_list , phase_nr ); + 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]; if (base_phase->phase & phase_mask) { if (monitor_survey != NULL) { - const ecl_grav_phase_type * monitor_phase = (const ecl_grav_phase_type*)vector_iget_const( monitor_survey->phase_list , phase_nr ); + const ecl_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 ); } else deltag += ecl_grav_phase_eval( base_phase , NULL , region , utm_x , utm_y , depth ); @@ -570,20 +557,19 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey, */ ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file) { - ecl_grav_type * ecl_grav = (ecl_grav_type*)util_malloc( sizeof * ecl_grav ); + ecl_grav_type * ecl_grav = new ecl_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 ); - ecl_grav->surveys = hash_alloc(); - ecl_grav->std_density = hash_alloc(); return ecl_grav; } static void ecl_grav_add_survey__( ecl_grav_type * grav , const char * name , ecl_grav_survey_type * survey) { - hash_insert_hash_owned_ref( grav->surveys , name , survey , ecl_grav_survey_free__ ); + grav->surveys[name] = survey; } @@ -618,17 +604,15 @@ static ecl_grav_survey_type * ecl_grav_get_survey( const ecl_grav_type * grav , if (name == NULL) return NULL; // Calling scope must determine if this is OK? else { - if (hash_has_key( grav->surveys , name)) - return (ecl_grav_survey_type*)hash_get( grav->surveys , name ); + if (grav->surveys.count(name) > 0) + return grav->surveys.at(name); else { - hash_iter_type * survey_iter = hash_iter_alloc( grav->surveys ); fprintf(stderr,"Survey name:%s not registered. Available surveys are: \n\n " , name); - while (!hash_iter_is_complete( survey_iter )) { - const char * survey = hash_iter_get_next_key( survey_iter ); - fprintf(stderr,"%s ",survey); - } + + for (const auto& survey_pair : grav->surveys) + fprintf(stderr,"%s ",survey_pair.first.c_str()); + fprintf(stderr,"\n\n"); - hash_iter_free( survey_iter ); exit(1); } } @@ -660,8 +644,7 @@ double ecl_grav_eval( const ecl_grav_type * grav , const char * base, const char 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 ); - if (!hash_has_key( grav->std_density , phase_key )) - hash_insert_hash_owned_ref( grav->std_density , phase_key , double_vector_alloc( 0 , default_density ) , double_vector_free__ ); + grav->default_density[std::string(phase_key)] = default_density; } /** @@ -680,8 +663,10 @@ void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , dou void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density) { - double_vector_type * std_density = (double_vector_type*)hash_get( grav->std_density , ecl_util_get_phase_name( phase )); - double_vector_iset( std_density , pvtnum , density ); + std::vector& std_density = grav->std_density[ std::string(ecl_util_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)) ]); + std_density[pvtnum] = density; } @@ -689,7 +674,9 @@ void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int void ecl_grav_free( ecl_grav_type * ecl_grav ) { delete ecl_grav->grid_cache; free( ecl_grav->aquifer_cell ); - hash_free( ecl_grav->surveys ); - hash_free( ecl_grav->std_density ); - free( ecl_grav ); + + for (const auto& survey_pair : ecl_grav->surveys) + ecl_grav_survey_free( survey_pair.second ); + + delete ecl_grav; } diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp index 240fc64a87..1c758a4701 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grav.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp b/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp index 9f63c9583c..8b33bc0fc5 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grav_common.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid.cpp b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp index c01ece639a..2b59611a63 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2011 statoil asa, norway. + Copyright (c) 2011 equinor asa, norway. The file 'ecl_grid.c' is part of ert - ensemble based reservoir tool. @@ -21,12 +21,14 @@ #include #include #include + #include +#include +#include #include #include #include -#include #include #include @@ -726,7 +728,7 @@ struct ecl_grid_struct { 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. */ - hash_type * children; /* a table of lgr children for this grid. */ + std::unordered_map children; const ecl_grid_type * parent_grid; /* the parent grid for this (lgr) - NULL for the main grid. */ const ecl_grid_type * global_grid; /* the global grid - NULL for the main grid. */ @@ -739,7 +741,7 @@ struct ecl_grid_struct { */ vector_type * LGR_list; /* a vector of ecl_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.*/ - hash_type * 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 ecl_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 .. */ @@ -1534,7 +1536,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid, int nz, int lgr_nr, bool init_valid) { - ecl_grid_type * grid = (ecl_grid_type*)util_malloc(sizeof * grid ); + ecl_grid_type * grid = new ecl_grid_type(); UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID); grid->total_active = 0; grid->total_active_fracture = 0; @@ -1586,16 +1588,13 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid, if (ECL_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); - grid->LGR_hash = hash_alloc(); } else { grid->LGR_list = NULL; grid->lgr_index_map = NULL; - grid->LGR_hash = NULL; } grid->name = NULL; grid->parent_name = NULL; grid->parent_grid = NULL; - grid->children = hash_alloc(); grid->coarse_cells = vector_alloc_new(); grid->eclipse_version = 0; @@ -2104,13 +2103,15 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , bool apply_mapaxes 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__); + 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, vector_get_size(main_grid->LGR_list)-1); - hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_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) { - hash_insert_ref( host_grid->children , lgr_grid->name , lgr_grid); + host_grid->children[lgr_grid->name] = lgr_grid; lgr_grid->parent_grid = host_grid; } @@ -3027,12 +3028,12 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const */ const int * actnum_data = NULL; if (ext_actnum) - actnum_data = 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 (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 (grid_nr == 0) { @@ -4625,17 +4626,15 @@ void ecl_grid_free(ecl_grid_type * grid) { if (ECL_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */ vector_free( grid->LGR_list ); int_vector_free( grid->lgr_index_map); - hash_free( grid->LGR_hash ); } if (grid->coord_kw != NULL) ecl_kw_free( grid->coord_kw ); vector_free( grid->coarse_cells ); - hash_free( grid->children ); free( grid->parent_name ); free( grid->visited ); free( grid->name ); - free( grid ); + delete grid; } @@ -5284,7 +5283,7 @@ ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * _ __assert_main_grid( main_grid ); { char * lgr_name = util_alloc_strip_copy( __lgr_name ); - ecl_grid_type * lgr_grid = (ecl_grid_type*)hash_get(main_grid->LGR_hash , lgr_name); + ecl_grid_type * lgr_grid = main_grid->LGR_hash.at(lgr_name); free(lgr_name); return lgr_grid; } @@ -5303,7 +5302,7 @@ bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name) __assert_main_grid( main_grid ); { char * lgr_name = util_alloc_strip_copy( __lgr_name ); - bool has_lgr = hash_has_key( main_grid->LGR_hash , lgr_name ); + bool has_lgr = main_grid->LGR_hash.count(lgr_name ) > 0; free(lgr_name); return has_lgr; } @@ -5425,7 +5424,10 @@ const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) { stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) { __assert_main_grid( ecl_grid ); { - return hash_alloc_stringlist( ecl_grid->LGR_hash ); + stringlist_type * s = stringlist_alloc_new(); + for (const auto& lgr_pair : ecl_grid->LGR_hash) + stringlist_append_copy(s, lgr_pair.first.c_str()); + return s; } } @@ -5892,14 +5894,12 @@ static bool ecl_grid_test_lgr_consistency2( const ecl_grid_type * parent , const bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) { - hash_iter_type * lgr_iter = hash_iter_alloc( ecl_grid->children ); bool consistent = true; - while (!hash_iter_is_complete( lgr_iter )) { - const ecl_grid_type * lgr = (const ecl_grid_type*)hash_iter_get_next_value( lgr_iter ); + 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 ); } - hash_iter_free( lgr_iter ); return consistent; } @@ -6208,6 +6208,8 @@ static void ecl_grid_fwrite_GRID__( const ecl_grid_type * grid , int coords_size } } } + ecl_kw_free(coords_kw); + ecl_kw_free(corners_kw); } } @@ -6217,7 +6219,7 @@ void ecl_grid_fwrite_GRID2( const ecl_grid_type * grid , const char * filename, bool fmt_file = false; fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP ); - if (hash_get_size( grid->children ) > 0) + if (grid->children.size() > 0) coords_size = 7; if (grid->coarsening_active) @@ -6852,6 +6854,12 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio void ecl_grid_fwrite_EGRID2( ecl_grid_type * grid , const char * filename, ert_ecl_unit_enum output_unit) { bool fmt_file = false; + { + bool is_fmt; + + if (ecl_util_get_file_type( filename , &is_fmt, NULL ) != ECL_OTHER_FILE) + fmt_file = is_fmt; + } fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP ); ecl_grid_fwrite_EGRID__( grid , fortio, output_unit); diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp b/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp index 46dd0d9db5..7b2e394537 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grid_cache.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp b/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp index 8df249dcf1..f5fbeb2d69 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp b/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp index f8b1bc656f..dbca59ab56 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_init_file.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp b/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp index 9ad54c46be..893ff6f985 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_io_config.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw.cpp b/ThirdParty/Ert/lib/ecl/ecl_kw.cpp index b71c0c0ac6..abf24340ea 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_kw.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_kw.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp index 5d76c7f36d..3e60d55dc0 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp b/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp index 1e9f813927..434dfc4664 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp b/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp index 79cec6dabb..af05f4c3ac 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -26,11 +26,47 @@ #include -int ecl_nnc_export_get_size( const ecl_grid_type * grid ) { - return ecl_grid_get_num_nnc( grid ); + +/** + * 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)) + 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)); + const auto nnc2_num = ecl_kw_get_size(ecl_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)); + 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 +} + +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); + + 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}; + ++nnc_index; + } + *nnc_offset = nnc_index; + return ecl_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) { @@ -50,8 +86,8 @@ static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , cons int lgr_index2; for (lgr_index2=0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) { const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 ); - const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector ); - const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector ); + const std::vector& grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector ); + 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(global_grid , init_file , lgr_nr1 , lgr_nr2 ); @@ -63,8 +99,8 @@ static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , cons nnc.global_index1 = global_index1; for (index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) { - nnc.global_index2 = int_vector_iget( grid2_index_list , index2 ); - nnc.input_index = int_vector_iget( nnc_index_list, index2 ); + nnc.global_index2 = grid2_index_list[index2]; + nnc.input_index = nnc_index_list[index2]; if(tran_kw) { nnc.trans = ecl_kw_iget_as_double(tran_kw, nnc.input_index); valid_trans++; @@ -86,15 +122,21 @@ static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , cons int ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data) { int nnc_index = 0; int total_valid_trans = 0; - total_valid_trans = ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index ); - { - int lgr_index; - for (lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) { - ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index ); - total_valid_trans += ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index ); - } + if(ecl_nnc_intersect_format(grid, init_file)) { + // Intersect format + total_valid_trans = ecl_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 ); + { + for (int lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) { + ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index ); + total_valid_trans += ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index ); + } + } + nnc_index = ecl_grid_get_num_nnc( grid ); } - nnc_index = ecl_nnc_export_get_size( grid ); ecl_nnc_sort( nnc_data , nnc_index ); return total_valid_trans; } diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp index 36899a4824..a3f620e42c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2017 statoil asa, norway. + Copyright (c) 2017 equinor asa, norway. The file 'ecl_nnc_geometry.c' is part of ert - ensemble based reservoir tool. @@ -61,8 +61,8 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , for (int lgr_index2 = 0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) { const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 ); - const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector ); - const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector ); + const std::vector& grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector ); + const std::vector& nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector ); int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector ); for (int index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) { @@ -70,8 +70,8 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , pair.grid_nr1 = lgr_nr1; pair.global_index1 = global_index1; pair.grid_nr2 = lgr_nr2; - pair.global_index2 = int_vector_iget( grid2_index_list , index2 ); - pair.input_index = int_vector_iget( nnc_index_list, index2 ); + pair.global_index2 = grid2_index_list[index2]; + pair.input_index = nnc_index_list[index2]; nnc_geo->data->push_back(pair); } } diff --git a/ThirdParty/Ert/lib/ecl/ecl_region.cpp b/ThirdParty/Ert/lib/ecl/ecl_region.cpp index db63184266..ad92928efa 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_region.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_region.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_region.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp b/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp index b5c023689f..e70833514f 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rft_cell.c' is part of ERT - Ensemble based Reservoir Tool. @@ -366,3 +366,9 @@ int ecl_rft_cell_cmp__( const void * arg1 , const void * arg2) { const ecl_rft_cell_type * cell2 = ecl_rft_cell_safe_cast_const( arg2 ); return ecl_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); +} + diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp b/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp index 553cb1c56d..adbb0e81b3 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rft_file.c' is part of ERT - Ensemble based Reservoir Tool. @@ -25,10 +25,12 @@ #include #endif +#include +#include +#include +#include + #include -#include -#include -#include #include #include @@ -55,19 +57,19 @@ struct ecl_rft_file_struct { UTIL_TYPE_ID_DECLARATION; - char * filename; - vector_type * data; /* This vector just contains all the rft nodes in one long vector. */ - hash_type * well_index; /* This indexes well names into the data vector - very similar to the scheme used in ecl_file. */ + std::string filename; + 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 = (ecl_rft_file_type*)util_malloc(sizeof * rft_vector ); + ecl_rft_file_type * rft_vector = new ecl_rft_file_type(); + UTIL_TYPE_ID_INIT( rft_vector , ECL_RFT_FILE_ID ); - rft_vector->data = vector_alloc_new(); - rft_vector->filename = util_alloc_string_copy(filename); - rft_vector->well_index = hash_alloc(); + rft_vector->filename = std::string(filename); + return rft_vector; } @@ -82,8 +84,8 @@ UTIL_SAFE_CAST_FUNCTION( ecl_rft_file , ECL_RFT_FILE_ID ); UTIL_IS_INSTANCE_FUNCTION( ecl_rft_file , ECL_RFT_FILE_ID ); -static void ecl_rft_file_add_node(ecl_rft_file_type * rft_vector , const ecl_rft_node_type * rft_node) { - vector_append_owned_ref( rft_vector->data , rft_node , ecl_rft_node_free__); +static void ecl_rft_file_add_node(ecl_rft_file_type * rft_vector , ecl_rft_node_type * rft_node) { + rft_vector->data.push_back(rft_node); } @@ -100,15 +102,12 @@ ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) { if (rft_view) { ecl_rft_node_type * rft_node = ecl_rft_node_alloc( rft_view ); - if (rft_node != NULL) { + if (rft_node) { const char * well_name = ecl_rft_node_get_well_name( rft_node ); ecl_rft_file_add_node(rft_vector , rft_node); - if (!hash_has_key( rft_vector->well_index , well_name)) - hash_insert_hash_owned_ref( rft_vector->well_index , well_name , int_vector_alloc( 0 , 0 ) , int_vector_free__); - { - int_vector_type * index_list = (int_vector_type*)hash_get( rft_vector->well_index , well_name ); - int_vector_append(index_list , global_index); - } + + auto& index_vector = rft_vector->well_index[well_name]; + index_vector.push_back(global_index); global_index++; } } else @@ -194,10 +193,10 @@ bool ecl_rft_file_case_has_rft( const char * case_input ) { void ecl_rft_file_free(ecl_rft_file_type * rft_vector) { - vector_free(rft_vector->data); - hash_free( rft_vector->well_index ); - free(rft_vector->filename); - free(rft_vector); + for (auto node_ptr : rft_vector->data) + ecl_rft_node_free( node_ptr ); + + delete rft_vector; } @@ -223,12 +222,11 @@ void ecl_rft_file_free__(void * arg) { int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * well_pattern , time_t recording_time) { if ((well_pattern == NULL) && (recording_time < 0)) - return vector_get_size( rft_file->data ); + return rft_file->data.size(); else { int match_count = 0; - int i; - for ( i=0; i < vector_get_size( rft_file->data ); i++) { - const ecl_rft_node_type * rft = (const ecl_rft_node_type*)vector_iget_const( rft_file->data , i); + for (size_t i=0; i < rft_file->data.size(); i++) { + const ecl_rft_node_type * rft = rft_file->data[i]; if (well_pattern) { if (util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )) != 0) @@ -260,7 +258,7 @@ int ecl_rft_file_get_size( const ecl_rft_file_type * rft_file) { const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) { - return rft_file->filename; + return rft_file->filename.c_str(); } @@ -274,7 +272,7 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) { */ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index) { - return (ecl_rft_node_type*)vector_iget( rft_file->data , index ); + return rft_file->data[index]; } @@ -306,30 +304,32 @@ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index) { - const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); - return ecl_rft_file_iget_node( rft_file , int_vector_iget(index_vector , index)); + const auto& index_vector = rft_file->well_index.at(well); + return ecl_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) { + const auto& pair_iter = rft_file->well_index.find(well); + if (pair_iter == rft_file->well_index.end()) + return -1; + int global_index = -1; - if (hash_has_key( rft_file->well_index , well)) { - const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); - int well_index = 0; - while (true) { - if (well_index == int_vector_size( index_vector )) + size_t well_index = 0; + const auto& index_vector = pair_iter->second; + while (true) { + if (well_index == index_vector.size()) + 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) { + global_index = index_vector[well_index]; break; - - { - const ecl_rft_node_type * node = ecl_rft_file_iget_node( rft_file , int_vector_iget( index_vector , well_index )); - if (ecl_rft_node_get_date( node ) == recording_time) { - global_index = int_vector_iget( index_vector , well_index ); - break; - } } - - well_index++; } + + well_index++; } return global_index; } @@ -355,7 +355,7 @@ ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rf bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * well) { - return hash_has_key(rft_file->well_index , well); + return (rft_file->well_index.find(well) != rft_file->well_index.end()); } @@ -364,8 +364,11 @@ bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * we */ int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well) { - const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); - return int_vector_size( index_vector ); + const auto& pair_iter = rft_file->well_index.find(well); + if (pair_iter == rft_file->well_index.end()) + return 0; + else + return pair_iter->second.size(); } @@ -373,13 +376,18 @@ int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const Returns the number of distinct wells in RFT file. */ int ecl_rft_file_get_num_wells( const ecl_rft_file_type * rft_file ) { - return hash_get_size( rft_file->well_index ); + return rft_file->well_index.size(); } stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_file ) { - return hash_alloc_stringlist( rft_file->well_index ); + stringlist_type * well_list = stringlist_alloc_new(); + + for (const auto& pair : rft_file->well_index) + stringlist_append_copy(well_list, pair.first.c_str()); + + return well_list; } @@ -396,7 +404,8 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, if (storage_index == -1) { ecl_rft_file_add_node(rft_file, new_node); } else { - vector_iset_owned_ref(rft_file->data, storage_index, new_node,ecl_rft_node_free__); + ecl_rft_node_free(rft_file->data[storage_index]); + rft_file->data[storage_index] = new_node; } } }else{ @@ -410,7 +419,6 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, { bool fmt_file = false; fortio_type * fortio = fortio_open_writer( rft_file_name , fmt_file , ECL_ENDIAN_FLIP ); - int node_index; /** The sorting here works directly on the internal node storage @@ -421,9 +429,9 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, avoided for the rest of this function. */ - vector_sort(rft_file->data,(vector_cmp_ftype *) ecl_rft_node_cmp); - for(node_index=0; node_index < vector_get_size( rft_file->data ); node_index++) { - const ecl_rft_node_type *new_node = (const ecl_rft_node_type*)vector_iget_const(rft_file->data, node_index); + std::sort(rft_file->data.begin(), rft_file->data.end(), ecl_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); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp b/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp index 7290dccb73..48d4c58130 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rft_node.c' is part of ERT - Ensemble based Reservoir Tool. @@ -23,10 +23,11 @@ #include #include +#include +#include +#include + #include -#include -#include -#include #include #include @@ -57,16 +58,14 @@ #define ECL_RFT_NODE_ID 887195 struct ecl_rft_node_struct { UTIL_TYPE_ID_DECLARATION; - char * well_name; /* Name of the well. */ + 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.*/ double days; /* When was the RFT recorded - days after simulaton start. */ bool MSW; - bool sort_perm_in_sync ; - int_vector_type * sort_perm; - vector_type *cells; + std::vector cells; }; @@ -106,15 +105,13 @@ static ecl_rft_enum translate_from_sting_to_ecl_rft_enum(const char * 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 = (ecl_rft_node_type*)util_malloc(sizeof * rft_node ); + ecl_rft_node_type * rft_node = new ecl_rft_node_type(); + UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); - rft_node->well_name = util_alloc_string_copy(well_name); - rft_node->cells = vector_alloc_new(); + rft_node->well_name = std::string(well_name); rft_node->recording_date = recording_date; rft_node->days = days; rft_node->data_type = data_type; - rft_node->sort_perm = NULL; - rft_node->sort_perm_in_sync = false; return rft_node; } @@ -130,13 +127,10 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin } { - ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node ); - UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); + ecl_rft_node_type * rft_node = new ecl_rft_node_type(); - rft_node->cells = vector_alloc_new(); + UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); rft_node->data_type = data_type; - rft_node->sort_perm = NULL; - rft_node->sort_perm_in_sync = false; return rft_node; } @@ -148,8 +142,11 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_rft_node , ECL_RFT_NODE_ID ); void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell) { - vector_append_owned_ref( rft_node->cells , cell , ecl_rft_cell_free__ ); - rft_node->sort_perm_in_sync = false; + if (rft_node->MSW) { + auto pos_iter = std::upper_bound(rft_node->cells.begin(), rft_node->cells.end(), cell, ecl_rft_cell_lt); + rft_node->cells.insert(pos_iter, cell); + } else + rft_node->cells.push_back( cell ); } @@ -273,8 +270,11 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_view_type * rft_view) { if (rft_node != NULL) { ecl_kw_type * date_kw = ecl_file_view_iget_named_kw( rft_view , DATE_KW , 0); - rft_node->well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX)); - + { + char * tmp = util_alloc_strip_copy( (const char*) ecl_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 ); @@ -293,18 +293,15 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_view_type * rft_view) { const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * rft_node) { - return rft_node->well_name; + return rft_node->well_name.c_str(); } void ecl_rft_node_free(ecl_rft_node_type * rft_node) { + for (auto cell_ptr : rft_node->cells) + ecl_rft_cell_free( cell_ptr ); - free(rft_node->well_name); - vector_free( rft_node->cells ); - if (rft_node->sort_perm) - int_vector_free( rft_node->sort_perm ); - - free(rft_node); + delete rft_node; } void ecl_rft_node_free__(void * void_node) { @@ -316,7 +313,7 @@ void ecl_rft_node_free__(void * void_node) { -int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return vector_get_size( rft_node->cells ); } +int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return rft_node->cells.size(); } time_t ecl_rft_node_get_date(const ecl_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) { return rft_node->data_type; } @@ -325,32 +322,13 @@ ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return /* various functions to access properties at the cell level */ const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index) { - return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); + return rft_node->cells[index]; } -static void ecl_rft_node_create_sort_perm( ecl_rft_node_type * rft_node ) { - if (rft_node->sort_perm) - int_vector_free( rft_node->sort_perm ); - - rft_node->sort_perm = vector_alloc_sort_perm( rft_node->cells , ecl_rft_cell_cmp__ ); - rft_node->sort_perm_in_sync = true; -} - -void ecl_rft_node_inplace_sort_cells( ecl_rft_node_type * rft_node ) { - vector_sort( rft_node->cells , ecl_rft_cell_cmp__ ); - rft_node->sort_perm_in_sync = false; // The permutation is no longer sorted; however the vector itself is sorted .... -} const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft_node , int index) { - if (ecl_rft_node_is_RFT( rft_node )) - return ecl_rft_node_iget_cell( rft_node , index ); - else { - if (!rft_node->sort_perm_in_sync) - ecl_rft_node_create_sort_perm( rft_node ); - - return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index )); - } + return rft_node->cells[index]; } @@ -396,14 +374,14 @@ static void assert_type_and_index( const ecl_rft_node_type * rft_node , ecl_rft_ if (rft_node->data_type != target_type) util_abort("%s: wrong type \n",__func__); - if ((index < 0) || (index >= vector_get_size( rft_node->cells ))) + if ((index < 0) || (index >= static_cast(rft_node->cells.size()))) util_abort("%s: invalid index:%d \n",__func__ , index); } double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell(rft_node, index); return ecl_rft_cell_get_sgas( cell ); } } @@ -412,7 +390,7 @@ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = rft_node->cells[index]; return ecl_rft_cell_get_swat( cell ); } } @@ -424,7 +402,7 @@ double ecl_rft_node_get_days(const ecl_rft_node_type * rft_node ){ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = rft_node->cells[index]; return ecl_rft_cell_get_soil( cell ); } } @@ -435,7 +413,7 @@ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = rft_node->cells[index]; return ecl_rft_cell_get_orat( cell ); } } @@ -444,7 +422,7 @@ double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index); + const ecl_rft_cell_type * cell = rft_node->cells[index]; return ecl_rft_cell_get_wrat( cell ); } } @@ -453,7 +431,7 @@ 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) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index); + const ecl_rft_cell_type * cell = rft_node->cells[index]; return ecl_rft_cell_get_grat( cell ); } } @@ -591,10 +569,9 @@ void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * forti 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 i; - for(i =0;icells , i); + for(int i =0;icells[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); @@ -636,4 +613,6 @@ int ecl_rft_node_cmp( const ecl_rft_node_type * n1 , const ecl_rft_node_type * n } - +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); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp b/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp index 4c3e903f6e..484e11b237 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp @@ -1,6 +1,6 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_rst_file.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index 3c002cb9c5..d7bbb00e38 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rsthead.c' is part of ERT - Ensemble based Reservoir Tool. @@ -88,10 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - - if (doubhead_kw) - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); - + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -112,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ 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 = NULL; + 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, DOUBHEAD_KW)) - doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_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); diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index dbefb53bd9..ea0a095368 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_smspec.c' is part of ERT - Ensemble based Reservoir Tool. @@ -22,12 +22,18 @@ #include #include +#include +#include +#include +#include +#include +#include + #include #include -#include -#include #include #include +#include "detail/util/path.hpp" #include #include @@ -52,7 +58,7 @@ ------------------------------- 1. The function smspec_node_alloc() must be updated to return a valid - smspec_node_type instance when called with the new var_type. + ecl::smspec_node instance when called with the new var_type. 2. Update the function ecl_smpec_install_gen_key() to install smpec_index instances of this particular type. The format of the general key is @@ -95,7 +101,7 @@ #define ECL_SMSPEC_ID 806647 #define PARAMS_GLOBAL_DEFAULT -99 - +typedef std::map node_map; struct ecl_smspec_struct { UTIL_TYPE_ID_DECLARATION; @@ -104,31 +110,33 @@ struct ecl_smspec_struct { smspec_node instances. The actual smspec_node instances are owned by the smspec_nodes vector; */ - hash_type * well_var_index; /* Indexes for all well variables: {well1: {var1: index1 , var2: index2} , well2: {var1: index1 , var2: index2}} */ - hash_type * well_completion_var_index; /* Indexes for completion indexes .*/ - hash_type * group_var_index; /* Indexes for group variables.*/ - hash_type * field_var_index; - hash_type * region_var_index; /* The stored index is an offset. */ - hash_type * misc_var_index; /* Variables like 'TCPU' and 'NEWTON'. */ - hash_type * block_var_index; /* Block variables like BPR */ - hash_type * gen_var_index; /* This is "everything" - things can either be found as gen_var("WWCT:OP_X") or as well_var("WWCT" , "OP_X") */ + node_map field_var_index; + node_map misc_var_index; /* Variables like 'TCPU' and 'NEWTON'. */ + node_map gen_var_index /* This is "everything" - things can either be found as gen_var("WWCT:OP_X") or as well_var("WWCT" , "OP_X") */; + + std::map well_var_index; /* Indexes for all well variables: + {well1: {var1: index1 , var2: index2} , well2: {var1: index1 , var2: index2}} */ + std::map group_var_index; /* Indexes for group variables.*/ + std::map region_var_index; /* The stored index is an offset. */ + std::map block_var_index; /* Block variables like BPR */ + std::map> well_completion_var_index; /* Indexes for completion indexes .*/ - vector_type * smspec_nodes; + std::vector> smspec_nodes; bool write_mode; bool need_nums; - int_vector_type * index_map; - + std::vector index_map; + std::map inv_index_map; + int params_size; /*-----------------------------------------------------------------*/ int time_seconds; int grid_dims[3]; /* Grid dimensions - in DIMENS[1,2,3] */ int num_regions; int Nwells , param_offset; - int params_size; - const char * key_join_string; /* The string used to join keys when building gen_key keys - typically ":" - + std::string key_join_string; /* The string used to join keys when building gen_key keys - typically ":" - but arbitrary - NOT necessary to be able to invert the joining. */ - char * header_file; /* FULL path to the currenbtly loaded header_file. */ + std::string header_file; /* FULL path to the currenbtly loaded header_file. */ bool formatted; /* Has this summary instance been loaded from a formatted (i.e. FSMSPEC file) or unformatted (i.e. SMSPEC) file. */ time_t sim_start_time; /* When did the simulation start - worldtime. */ @@ -138,9 +146,9 @@ struct ecl_smspec_struct { int month_index; /* time information. */ int year_index; bool has_lgr; - float_vector_type * params_default; + std::vector params_default; - char * restart_case; + std::string restart_case; ert_ecl_unit_enum unit_system; int restart_step; }; @@ -201,33 +209,6 @@ Completion var: VAR_TYPE:WELL_NAME:NUM */ -/** - 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. - - 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. (What a fucking mess). - - The special_vars list is used in the functions - ecl_smspec_identify_special_var() and ecl_smspec_identify_var_type(). -*/ - -static const char* special_vars[] = {"NEWTON", - "NAIMFRAC", - "NLINEARS", - "NLINSMIN", - "NLINSMAX", - "ELAPSED", - "MAXDPR", - "MAXDSO", - "MAXDSG", - "MAXDSW", - "STEPTYPE", - "WNEWTON"}; - /* @@ -248,33 +229,69 @@ static const char* smspec_required_keywords[] = { DIMENS_KW }; +namespace { + +const ecl::smspec_node * ecl_smspec_get_var_node( const node_map& mp, const char * var) { + const auto it = mp.find(var); + if (it == mp.end()) + return nullptr; + + 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 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); + } + + const ecl::smspec_node * ecl_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); + } + +} //end namespace + +int ecl_smspec_num_nodes( const ecl_smspec_type * smspec) { + return smspec->smspec_nodes.size(); +} + +/* + When loading a summary case from file many of the nodes can be ignored, in + that case the size of PARAMS vector in the data files is larger than the + number of internalized nodes. Therefor we need to maintain the + params_size member. +*/ + +int ecl_smspec_get_params_size( const ecl_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; - ecl_smspec = (ecl_smspec_type*)util_malloc(sizeof *ecl_smspec ); + ecl_smspec_type * ecl_smspec = new ecl_smspec_type(); UTIL_TYPE_ID_INIT(ecl_smspec , ECL_SMSPEC_ID); - ecl_smspec->well_var_index = hash_alloc(); - ecl_smspec->well_completion_var_index = hash_alloc(); - ecl_smspec->group_var_index = hash_alloc(); - ecl_smspec->field_var_index = hash_alloc(); - ecl_smspec->region_var_index = hash_alloc(); - ecl_smspec->misc_var_index = hash_alloc(); - ecl_smspec->block_var_index = hash_alloc(); - ecl_smspec->gen_var_index = hash_alloc(); ecl_smspec->sim_start_time = -1; ecl_smspec->key_join_string = key_join_string; - ecl_smspec->header_file = NULL; - - ecl_smspec->smspec_nodes = vector_alloc_new(); + ecl_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; /* The unit system is given as an integer in the INTEHEAD keyword. The INTEHEAD @@ -283,10 +300,7 @@ ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join */ ecl_smspec->unit_system = ECL_METRIC_UNITS; - ecl_smspec->index_map = int_vector_alloc(0,0); - ecl_smspec->restart_case = NULL; ecl_smspec->restart_step = -1; - ecl_smspec->params_default = float_vector_alloc(0 , PARAMS_GLOBAL_DEFAULT); ecl_smspec->write_mode = write_mode; ecl_smspec->need_nums = false; @@ -296,19 +310,19 @@ ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join 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 * mapping = (int*)util_malloc( params_size * sizeof * mapping ); + 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 smspec_node_type * self_node = ecl_smspec_iget_node( self , i ); - int self_index = smspec_node_get_params_index( self_node ); - const char * key = smspec_node_get_gen_key1( self_node ); + const ecl::smspec_node& self_node = ecl_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 smspec_node_type * other_node = ecl_smspec_get_general_var_node( other , key); - int other_index = smspec_node_get_params_index(other_node); + const ecl::smspec_node& other_node = ecl_smspec_get_general_var_node( other , key); + int other_index = other_node.get_params_index(); mapping[ self_index ] = other_index; } } @@ -324,14 +338,25 @@ int * ecl_smspec_alloc_mapping( const ecl_smspec_type * self, const ecl_smspec_t */ -const smspec_node_type * ecl_smspec_iget_node( const ecl_smspec_type * smspec , int index ) { - return (const smspec_node_type*)vector_safe_iget_const( smspec->smspec_nodes , index ); +const ecl::smspec_node& ecl_smspec_iget_node_w_node_index( const ecl_smspec_type * smspec , int node_index ) { + const auto& node = smspec->smspec_nodes[node_index]; + return *node.get(); } -int ecl_smspec_num_nodes( const ecl_smspec_type * smspec) { - return vector_get_size( smspec->smspec_nodes ); + +/* + 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(). +*/ + +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 ecl::smspec_node& ecl_smspec_iget_node_w_params_index( const ecl_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); +} /** * Returns an ecl data type for which all names will fit. If the maximum name @@ -341,8 +366,8 @@ int ecl_smspec_num_nodes( const ecl_smspec_type * smspec) { static ecl_data_type get_wgnames_type(const ecl_smspec_type * smspec) { size_t max_len = 0; for(int i = 0; i < ecl_smspec_num_nodes(smspec); ++i) { - const smspec_node_type * node = ecl_smspec_iget_node(smspec, i); - const char * name = smspec_node_get_wgname( node ); + const ecl::smspec_node& node = ecl_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)); } @@ -367,11 +392,11 @@ static void ecl_smspec_fwrite_RESTART(const ecl_smspec_type * smspec, fortio_typ for (int i=0; i < SUMMARY_RESTART_SIZE; i++) ecl_kw_iset_string8( restart_kw , i , ""); - if (smspec->restart_case != NULL) { - int restart_case_len = strlen(smspec->restart_case); + if (smspec->restart_case.size() > 0) { + size_t restart_case_len = smspec->restart_case.size(); - int offset = 0; - for (int i = 0; i < SUMMARY_RESTART_SIZE ; i++) { + 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; @@ -433,7 +458,7 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT); for (int i=0; i < ecl_smspec_num_nodes( smspec ); i++) { - const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , i ); + const ecl::smspec_node& smspec_node = ecl_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 @@ -453,23 +478,23 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty ignored when/if this smspec file is read in at a later stage. */ - if (smspec_node_get_var_type( smspec_node ) == ECL_SMSPEC_INVALID_VAR) { + 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); } 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 )); + 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 )); { const char * wgname = DUMMY_WELL; - if (smspec_node_get_wgname( smspec_node )) - wgname = smspec_node_get_wgname( smspec_node ); + if (smspec_node_get_wgname( &smspec_node )) + wgname = smspec_node_get_wgname( &smspec_node ); ecl_kw_iset_string_ptr( wgnames_kw , i , wgname); } } if (nums_kw != NULL) - ecl_kw_iset_int( nums_kw , i , smspec_node_get_num( smspec_node )); + ecl_kw_iset_int( nums_kw , i , smspec_node.get_num()); } ecl_kw_fwrite( keywords_kw , fortio ); ecl_kw_fwrite( wgnames_kw , fortio ); @@ -512,7 +537,7 @@ static ecl_smspec_type * ecl_smspec_alloc_writer__( const char * key_join_string */ if (restart_case) { if (strlen(restart_case) <= (SUMMARY_RESTART_SIZE * ECL_STRING8_LENGTH)) { - ecl_smspec->restart_case = util_alloc_string_copy( restart_case ); + ecl_smspec->restart_case = restart_case; ecl_smspec->restart_step = restart_step; } } @@ -522,33 +547,16 @@ static ecl_smspec_type * ecl_smspec_alloc_writer__( const char * key_join_string ecl_smspec->sim_start_time = sim_start; { - smspec_node_type * time_node; - if (time_in_days) { - time_node = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , - NULL , - "TIME" , - "DAYS" , - key_join_string , - ecl_smspec->grid_dims , - 0 , - -1 , - 0 ); - ecl_smspec->time_seconds = 3600 * 24; - } else { - time_node = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , - NULL , - "TIME" , - "HOURS" , - key_join_string , - ecl_smspec->grid_dims , - 0 , - -1 , - 0 ); - ecl_smspec->time_seconds = 3600; - } + const ecl::smspec_node * time_node; - ecl_smspec_add_node( ecl_smspec , time_node ); - ecl_smspec->time_index = smspec_node_get_params_index( time_node ); + if (time_in_days) { + ecl_smspec->time_seconds = 3600 * 24; + time_node = ecl_smspec_add_node(ecl_smspec, "TIME", "DAYS", 0); + } else { + ecl_smspec->time_seconds = 3600; + time_node = ecl_smspec_add_node(ecl_smspec, "TIME", "HOURS", 0); + } + ecl_smspec->time_index = time_node->get_params_index(); } return ecl_smspec; } @@ -564,131 +572,8 @@ ecl_smspec_type * ecl_smspec_alloc_writer(const char * key_join_string, time_t s UTIL_SAFE_CAST_FUNCTION( ecl_smspec , ECL_SMSPEC_ID ) - -/** - 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 eavulates 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 - from the var name according to standard naming conventions. - - It is important that this function is called before the standard - method. -*/ - -static ecl_smspec_var_type ecl_smspec_identify_special_var( const char * var ) { - ecl_smspec_var_type var_type = ECL_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; - break; - } - } - - return var_type; -} - - -/* - See table 3.4 in the ECLIPSE file format reference manual. - - Observe that the combined ecl_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 - instance. -*/ - - ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) { - ecl_smspec_var_type var_type = ecl_smspec_identify_special_var( var ); - if (var_type == ECL_SMSPEC_INVALID_VAR) { - switch(var[0]) { - case('A'): - var_type = ECL_SMSPEC_AQUIFER_VAR; - break; - case('B'): - var_type = ECL_SMSPEC_BLOCK_VAR; - break; - case('C'): - var_type = ECL_SMSPEC_COMPLETION_VAR; - break; - case('F'): - var_type = ECL_SMSPEC_FIELD_VAR; - break; - case('G'): - var_type = ECL_SMSPEC_GROUP_VAR; - break; - case('L'): - switch(var[1]) { - case('B'): - var_type = ECL_SMSPEC_LOCAL_BLOCK_VAR; - break; - case('C'): - var_type = ECL_SMSPEC_LOCAL_COMPLETION_VAR; - break; - case('W'): - var_type = ECL_SMSPEC_LOCAL_WELL_VAR; - break; - default: - /* - The documentation explicitly mentions keywords starting with - LB, LC and LW as special types, but keywords starting with - L[^BCW] are also valid. These come in the misceallaneous - category; at least the LLINEAR keyword is an example of such - a keyword. - */ - var_type = ECL_SMSPEC_MISC_VAR; - } - break; - case('N'): - var_type = ECL_SMSPEC_NETWORK_VAR; - break; - case('R'): - { - /* - The distinction between region-to-region variables and plain - region variables is less than clear: The current - interpretation is that the cases: - - 1. Any variable matching: - - a) Starts with 'R' - b) Has 'F' as the third character - - 2. The variable "RNLF" - - Get variable type ECL_SMSPEC_REGION_2_REGION_VAR. The rest - get the type ECL_SMSPEC_REGION_VAR. - */ - - if (util_string_equal( var , "RNLF")) - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; - else if (var[2] == 'F') - var_type = ECL_SMSPEC_REGION_2_REGION_VAR; - else - var_type = ECL_SMSPEC_REGION_VAR; - - } - break; - case('S'): - var_type = ECL_SMSPEC_SEGMENT_VAR; - break; - case('W'): - var_type = ECL_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; - } - } - return var_type; + return ecl::smspec_node::identify_var_type(var); } @@ -789,23 +674,23 @@ static int ecl_smspec_get_global_grid_index(const ecl_smspec_type * smspec , int defined through the format strings used in this function. */ -static void ecl_smspec_install_gen_keys( ecl_smspec_type * smspec , smspec_node_type * smspec_node ) { +static void ecl_smspec_install_gen_keys( ecl_smspec_type * smspec , const ecl::smspec_node& smspec_node ) { /* Insert the default general mapping. */ { - const char * gen_key1 = smspec_node_get_gen_key1( smspec_node ); - if (gen_key1 != NULL) - hash_insert_ref(smspec->gen_var_index , gen_key1 , smspec_node); + const char * gen_key1 = smspec_node.get_gen_key1(); + if (gen_key1) + smspec->gen_var_index[gen_key1] = &smspec_node; } /* Insert the (optional) extra mapping for block related variables and region_2_region variables: */ { - const char * gen_key2 = smspec_node_get_gen_key2( smspec_node ); - if (gen_key2 != NULL) - hash_insert_ref(smspec->gen_var_index , gen_key2 , smspec_node); + const char * gen_key2 = smspec_node.get_gen_key2(); + if (gen_key2) + smspec->gen_var_index[gen_key2] = &smspec_node; } } -static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node) { +static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , const ecl::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 @@ -814,85 +699,35 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp ecl_smspec_get_well_var_index( smspec , well_name , var ); */ - const char * well = smspec_node_get_wgname( smspec_node ); + 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 ); + 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 ); switch(var_type) { case(ECL_SMSPEC_COMPLETION_VAR): - if (well) - { - /* Three level indexing: variable -> well -> string(cell_nr)*/ - if (!hash_has_key(ecl_smspec->well_completion_var_index , well)) - hash_insert_hash_owned_ref(ecl_smspec->well_completion_var_index , well , hash_alloc() , hash_free__); - { - hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well); - char cell_str[16]; - sprintf(cell_str , "%d" , num); - if (!hash_has_key(cell_hash , cell_str)) - hash_insert_hash_owned_ref(cell_hash , cell_str , hash_alloc() , hash_free__); - { - hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str); - hash_insert_ref(var_hash , keyword , smspec_node ); - } - } - } + ecl_smspec->well_completion_var_index[well][num][keyword] = &smspec_node; break; case(ECL_SMSPEC_FIELD_VAR): - /* - Field variable - */ - hash_insert_ref( ecl_smspec->field_var_index , keyword , smspec_node ); + ecl_smspec->field_var_index[keyword] = &smspec_node; break; case(ECL_SMSPEC_GROUP_VAR): - if (group) - { - if (!hash_has_key(ecl_smspec->group_var_index , group)) - hash_insert_hash_owned_ref(ecl_smspec->group_var_index , group, hash_alloc() , hash_free__); - { - hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->group_var_index , group); - hash_insert_ref(var_hash , keyword , smspec_node ); - } - } + ecl_smspec->group_var_index[group][keyword] = &smspec_node; break; case(ECL_SMSPEC_REGION_VAR): - if (!hash_has_key(ecl_smspec->region_var_index , keyword)) - hash_insert_hash_owned_ref( ecl_smspec->region_var_index , keyword , hash_alloc() , hash_free__); - { - hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->region_var_index , keyword); - char num_str[16]; - sprintf( num_str , "%d" , num); - hash_insert_ref(var_hash , num_str , smspec_node); - } + ecl_smspec->region_var_index[num][keyword] = &smspec_node; ecl_smspec->num_regions = util_int_max(ecl_smspec->num_regions , num); break; case (ECL_SMSPEC_WELL_VAR): - if (well) - { - if (!hash_has_key(ecl_smspec->well_var_index , well)) - hash_insert_hash_owned_ref(ecl_smspec->well_var_index , well , hash_alloc() , hash_free__); - { - hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->well_var_index , well); - hash_insert_ref(var_hash , keyword , smspec_node ); - } - } + ecl_smspec->well_var_index[well][keyword] = &smspec_node; break; case(ECL_SMSPEC_MISC_VAR): /* Misc variable - i.e. date or CPU time ... */ - hash_insert_ref(ecl_smspec->misc_var_index , keyword , smspec_node ); + ecl_smspec->misc_var_index[keyword] = &smspec_node; break; case(ECL_SMSPEC_BLOCK_VAR): - /* A block variable */ - if (!hash_has_key(ecl_smspec->block_var_index , keyword)) - hash_insert_hash_owned_ref(ecl_smspec->block_var_index , keyword , hash_alloc() , hash_free__); - { - hash_type * block_hash = (hash_type*)hash_get(ecl_smspec->block_var_index , keyword); - char block_nr[16]; - sprintf( block_nr , "%d" , num ); - hash_insert_ref(block_hash , block_nr , smspec_node); - } + ecl_smspec->block_var_index[num][keyword] = &smspec_node; break; /** The variables below are ONLY accesable through the gen_key @@ -913,9 +748,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp case(ECL_SMSPEC_AQUIFER_VAR): break; default: - smspec_node_fprintf(smspec_node, stderr); - util_abort("%: Internal error - should never be here ?? \n",__func__); - break; + throw std::invalid_argument("Internal error - should not be here \n"); } } @@ -1006,14 +839,14 @@ bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ) { bool ecl_smspec_equal(const ecl_smspec_type * self, const ecl_smspec_type * other) { - if (vector_get_size( self->smspec_nodes ) != vector_get_size( other->smspec_nodes)) + if (self->smspec_nodes.size() != other->smspec_nodes.size()) return false; - for (int i=0; i < vector_get_size( self->smspec_nodes ); i++) { - const smspec_node_type * node1 = (const smspec_node_type*)vector_iget_const(self->smspec_nodes, i); - const smspec_node_type * node2 = (const smspec_node_type*)vector_iget_const(other->smspec_nodes, i); + 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(); - if (!smspec_node_equal(node1, node2)) + if (node1->cmp(*node2) != 0) return false; } @@ -1035,7 +868,6 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi restart_base = util_alloc_strip_copy( tmp_base ); if (strlen(restart_base)) { /* We ignore the empty ones. */ - char * path; char * smspec_header; /* @@ -1050,6 +882,7 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi This code block will translate '/' -> '\' in the restart keyword which is read from the summary file. */ + #ifdef ERT_WINDOWS for (int i=0; i < strlen(restart_base); i++) { if (restart_base[i] == UTIL_POSIX_PATH_SEP_CHAR) @@ -1057,20 +890,22 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi } #endif - util_alloc_file_components( ecl_smspec->header_file , &path , NULL , NULL ); - smspec_header = ecl_util_alloc_exfilename( path , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0); - if (!util_same_file(smspec_header , ecl_smspec->header_file)) /* Restart from the current case is ignored. */ { - if (util_is_abs_path(restart_base)) - ecl_smspec->restart_case = util_alloc_string_copy( restart_base ); - else { - char * tmp_path = util_alloc_filename( path , restart_base , NULL ); - ecl_smspec->restart_case = util_alloc_abs_path(tmp_path); - free( tmp_path ); + 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); + if (smspec_header) { + if (!util_same_file(smspec_header , ecl_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; + 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; + free( abs_path ); + free( tmp_path ); + } } + free( smspec_header ); } - - free( path ); - free( smspec_header ); } free( restart_base ); } @@ -1078,62 +913,139 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi -void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node) { - ecl_smspec_install_gen_keys( ecl_smspec , smspec_node ); - ecl_smspec_install_special_keys( ecl_smspec , smspec_node ); - if (smspec_node_need_nums( smspec_node )) + + + + +static const ecl::smspec_node * ecl_smspec_insert_node(ecl_smspec_type * ecl_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())); + + ecl_smspec_install_gen_keys( ecl_smspec, *smspec_node.get() ); + ecl_smspec_install_special_keys( ecl_smspec, *smspec_node.get() ); + + if (smspec_node->need_nums()) ecl_smspec->need_nums = true; + + ecl_smspec->smspec_nodes.push_back(std::move(smspec_node)); + + if (params_index > ecl_smspec->params_size) + ecl_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(); + + const auto& node = ecl_smspec->smspec_nodes.back(); + return node.get(); } -static void ecl_smspec_set_params_size( ecl_smspec_type * ecl_smspec , int params_size) { - ecl_smspec->params_size = params_size; - float_vector_iset( ecl_smspec->params_default , ecl_smspec->params_size - 1 , PARAMS_GLOBAL_DEFAULT); +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()))); +} + +//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(params_index, + keyword, + wgname, + unit, + lgr, + lgr_i, lgr_j, lgr_k, + default_value, + ecl_smspec->key_join_string.c_str()))); } -void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node){ - int internal_index = vector_get_size( ecl_smspec->smspec_nodes ); - /* This IF test should only apply in write_mode. */ - if (smspec_node_get_params_index( smspec_node ) < 0) { - if (!ecl_smspec->write_mode) - util_abort("%s: internal error \n",__func__); - smspec_node_set_params_index( smspec_node , internal_index); - - if (internal_index >= ecl_smspec->params_size) - ecl_smspec_set_params_size( ecl_smspec , internal_index + 1); - } - vector_append_owned_ref( ecl_smspec->smspec_nodes , smspec_node , smspec_node_free__ ); - - { - int params_index = smspec_node_get_params_index( smspec_node ); - - /* This indexing must be used when writing. */ - int_vector_iset( ecl_smspec->index_map , internal_index , params_index); - - float_vector_iset( ecl_smspec->params_default , params_index , smspec_node_get_default(smspec_node) ); - } -} - - -void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ) { - ecl_smspec_insert_node( ecl_smspec , smspec_node ); - ecl_smspec_index_node( ecl_smspec , smspec_node ); -} - - - -void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ) { - smspec_node_init( smspec_node , ecl_smspec_identify_var_type( keyword ) , wgname , keyword , unit , ecl_smspec->key_join_string , ecl_smspec->grid_dims , num ); - ecl_smspec_index_node( ecl_smspec , smspec_node ); -} - - -const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ) { - return smspec->index_map; +const int * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ) { + return smspec->index_map.data(); } /** @@ -1178,6 +1090,7 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h int params_index; ecl_smspec->num_regions = 0; + ecl_smspec->params_size = ecl_kw_get_size(keywords); if (startdat == NULL) util_abort("%s: could not locate STARTDAT keyword in header - aborting \n",__func__); @@ -1214,7 +1127,6 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h 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); - ecl_smspec_set_params_size( ecl_smspec , ecl_kw_get_size(keywords)); ecl_util_get_file_type( header_file , &ecl_smspec->formatted , NULL ); @@ -1225,31 +1137,51 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h char * well = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(wells , params_index)); char * kw = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(keywords , params_index)); char * unit = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(units , params_index)); - char * lgr_name = NULL; - smspec_node_type * smspec_node; - ecl_smspec_var_type var_type = ecl_smspec_identify_var_type( kw ); + ecl_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) { + 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 ); - lgr_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgrs , params_index )); - smspec_node = smspec_node_alloc_lgr( var_type , well , kw , unit , lgr_name , ecl_smspec->key_join_string , lgr_i , lgr_j , lgr_k , params_index, default_value); - } else - smspec_node = smspec_node_alloc( var_type , well , kw , unit , ecl_smspec->key_join_string , ecl_smspec->grid_dims , num , params_index , default_value); + char * lgr_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgrs , params_index )); - if (smspec_node) - ecl_smspec_add_node( ecl_smspec , smspec_node ); + ecl_smspec_insert_node(ecl_smspec, std::unique_ptr( new ecl::smspec_node(params_index, + kw, + well, + unit, + lgr_name, + lgr_i, lgr_j, lgr_k, + default_value, + ecl_smspec->key_join_string.c_str()))); + free(lgr_name); + } else + ecl_smspec_insert_node(ecl_smspec, std::unique_ptr( new ecl::smspec_node(params_index, + kw, + well, + num, + unit, + ecl_smspec->grid_dims, + default_value, + ecl_smspec->key_join_string.c_str()))); free( kw ); free( well ); free( unit ); - free( lgr_name ); } } - ecl_smspec->header_file = util_alloc_realpath( header_file ); + char * header_str = util_alloc_realpath( header_file ); + ecl_smspec->header_file = header_str; + free(header_str); if (include_restart) ecl_smspec_load_restart( ecl_smspec , header ); @@ -1274,10 +1206,10 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k if (ecl_smspec_fread_header(ecl_smspec , header_file , include_restart)) { - if (hash_has_key( ecl_smspec->misc_var_index , "TIME")) { - const smspec_node_type * time_node = (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "TIME"); - const char * time_unit = smspec_node_get_unit( time_node ); - ecl_smspec->time_index = smspec_node_get_params_index( time_node ); + const ecl::smspec_node * time_node = ecl_smspec_get_var_node(ecl_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(); if (util_string_equal( time_unit , "DAYS")) ecl_smspec->time_seconds = 3600 * 24; @@ -1285,12 +1217,14 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k ecl_smspec->time_seconds = 3600; else util_abort("%s: time_unit:%s not recognized \n",__func__ , time_unit); + } - if (hash_has_key(ecl_smspec->misc_var_index , "DAY")) { - ecl_smspec->day_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "DAY") ); - ecl_smspec->month_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "MONTH") ); - ecl_smspec->year_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "YEAR") ); + const ecl::smspec_node * day_node = ecl_smspec_get_var_node(ecl_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"] ); } if ((ecl_smspec->time_index == -1) && ( ecl_smspec->day_index == -1)) { @@ -1313,13 +1247,13 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k int ecl_smspec_get_num_groups(const ecl_smspec_type * ecl_smspec) { - return hash_get_size(ecl_smspec->group_var_index); + return ecl_smspec->group_var_index.size(); } -char ** ecl_smspec_alloc_group_names(const ecl_smspec_type * ecl_smspec) { +/*char ** ecl_smspec_alloc_group_names(const ecl_smspec_type * ecl_smspec) { return hash_alloc_keylist(ecl_smspec->group_var_index); -} +}*/ int ecl_smspec_get_num_regions(const ecl_smspec_type * ecl_smspec) { return ecl_smspec->num_regions; @@ -1353,15 +1287,15 @@ int ecl_smspec_get_num_regions(const ecl_smspec_type * ecl_smspec) { /*****************************************************************/ -#define NODE_RETURN_INDEX(node) \ - if (node == NULL) \ +#define NODE_RETURN_INDEX(node_ptr) \ + if (!node_ptr) \ return -1; \ - else \ - return smspec_node_get_params_index( node ); + else \ + return smspec_node_get_params_index( node_ptr ); -#define NODE_RETURN_EXISTS(node) \ - if (node == NULL) \ +#define NODE_RETURN_EXISTS(node_ptr) \ + if (!node_ptr) \ return false; \ else \ return true; @@ -1371,26 +1305,24 @@ int ecl_smspec_get_num_regions(const ecl_smspec_type * ecl_smspec) { /******************************************************************/ /* Well variables */ -const smspec_node_type * ecl_smspec_get_well_var_node( const ecl_smspec_type * smspec , const char * well , const char * var) { - const smspec_node_type * node = NULL; - if (hash_has_key( smspec->well_var_index , well)) { - hash_type * var_hash = (hash_type*)hash_get(smspec->well_var_index , well); - if (hash_has_key(var_hash , var)) - node = (const smspec_node_type*)hash_get(var_hash , var); - } - return node; +const ecl::smspec_node& ecl_smspec_get_well_var_node( const ecl_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); + if (!node_ptr) + throw std::out_of_range("The well: " + std::string(well) + " variable: " + std::string(var) + " combination does not exist."); + + return *node_ptr; } int ecl_smspec_get_well_var_params_index(const ecl_smspec_type * ecl_smspec , const char * well , const char *var) { - const smspec_node_type * node = ecl_smspec_get_well_var_node( ecl_smspec , well , var ); - NODE_RETURN_INDEX(node); + const auto node_ptr = ecl_smspec_get_str_key_var_node(ecl_smspec->well_var_index, well, var); + NODE_RETURN_INDEX(node_ptr); } bool ecl_smspec_has_well_var(const ecl_smspec_type * ecl_smspec , const char * well , const char *var) { - const smspec_node_type * node = ecl_smspec_get_well_var_node(ecl_smspec , well ,var); - NODE_RETURN_EXISTS(node); + const auto node_ptr = ecl_smspec_get_str_key_var_node(ecl_smspec->well_var_index, well, var); + NODE_RETURN_EXISTS(node_ptr); } @@ -1398,52 +1330,50 @@ bool ecl_smspec_has_well_var(const ecl_smspec_type * ecl_smspec , const char * w /*****************************************************************/ /* Group variables */ -const smspec_node_type * ecl_smspec_get_group_var_node( const ecl_smspec_type * smspec , const char * group , const char * var) { - const smspec_node_type * node = NULL; - if (hash_has_key(smspec->group_var_index , group)) { - hash_type * var_hash = (hash_type*)hash_get(smspec->group_var_index , group); - if (hash_has_key(var_hash , var)) - node = (const smspec_node_type*)hash_get(var_hash , var); - } - return node; +const ecl::smspec_node& ecl_smspec_get_group_var_node( const ecl_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); + if (!node_ptr) + throw std::out_of_range("The group: " + std::string(group) + " variable: " + std::string(var) + " combination does not exist."); + + return *node_ptr; } int ecl_smspec_get_group_var_params_index(const ecl_smspec_type * ecl_smspec , const char * group , const char *var) { - const smspec_node_type * node = ecl_smspec_get_group_var_node( ecl_smspec , group , var ); - NODE_RETURN_INDEX(node); + const auto node_ptr = ecl_smspec_get_str_key_var_node(ecl_smspec->group_var_index, group, var); + NODE_RETURN_INDEX(node_ptr); } bool ecl_smspec_has_group_var(const ecl_smspec_type * ecl_smspec , const char * group , const char *var) { - const smspec_node_type * node = ecl_smspec_get_group_var_node(ecl_smspec , group ,var); - NODE_RETURN_EXISTS(node); + const auto node_ptr = ecl_smspec_get_str_key_var_node(ecl_smspec->group_var_index, group, var); + NODE_RETURN_EXISTS(node_ptr); } /*****************************************************************/ /* Field variables */ -const smspec_node_type * ecl_smspec_get_field_var_node(const ecl_smspec_type * ecl_smspec , const char *var) { - const smspec_node_type * node = NULL; - if (hash_has_key(ecl_smspec->field_var_index , var)) - node = (const smspec_node_type*)hash_get(ecl_smspec->field_var_index , var); +const ecl::smspec_node& ecl_smspec_get_field_var_node(const ecl_smspec_type * ecl_smspec , const char *var) { + const auto node_ptr = ecl_smspec_get_var_node( ecl_smspec->field_var_index, var); + if (!node_ptr) + throw std::out_of_range("The field variable: " + std::string(var) + " does not exist."); - return node; + return *node_ptr; } int ecl_smspec_get_field_var_params_index(const ecl_smspec_type * ecl_smspec , const char *var) { - const smspec_node_type * node = ecl_smspec_get_field_var_node( ecl_smspec , var ); - NODE_RETURN_INDEX(node); + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->field_var_index, var); + NODE_RETURN_INDEX(node_ptr); } bool ecl_smspec_has_field_var(const ecl_smspec_type * ecl_smspec , const char *var) { - const smspec_node_type * node = ecl_smspec_get_field_var_node( ecl_smspec , var ); - NODE_RETURN_EXISTS(node); + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->field_var_index, var); + NODE_RETURN_EXISTS(node_ptr); } /*****************************************************************/ @@ -1457,54 +1387,40 @@ bool ecl_smspec_has_field_var(const ecl_smspec_type * ecl_smspec , const char *v hash tables. */ -static const smspec_node_type * ecl_smspec_get_block_var_node_string(const ecl_smspec_type * ecl_smspec , const char * block_var , const char * block_str) { - const smspec_node_type * node = NULL; - if (hash_has_key(ecl_smspec->block_var_index , block_var)) { - hash_type * block_hash = (hash_type*)hash_get(ecl_smspec->block_var_index , block_var); - if (hash_has_key(block_hash , block_str)) - node = (const smspec_node_type*)hash_get(block_hash , block_str); - } +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); + if (!node_ptr) + throw std::out_of_range("No such block variable"); - return node; + return *node_ptr; } -const smspec_node_type * ecl_smspec_get_block_var_node(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr) { - const smspec_node_type * node; - char * block_str = util_alloc_sprintf("%d" , block_nr); - node = ecl_smspec_get_block_var_node_string(ecl_smspec , block_var , block_str); - free( block_str ); - return node; -} - - -const smspec_node_type * 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_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) ); } bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr) { - const smspec_node_type * node = ecl_smspec_get_block_var_node( ecl_smspec , block_var , block_nr ); - NODE_RETURN_EXISTS(node); + const auto node_ptr = ecl_smspec_get_int_key_var_node(ecl_smspec->block_var_index, block_nr, block_var); + NODE_RETURN_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) { - const smspec_node_type * node = ecl_smspec_get_block_var_node_ijk( ecl_smspec , block_var , i,j,k ); - NODE_RETURN_EXISTS(node); + return ecl_smspec_has_block_var(ecl_smspec, block_var, ecl_smspec_get_global_grid_index(ecl_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 smspec_node_type * node = ecl_smspec_get_block_var_node( ecl_smspec , block_var , block_nr ); - NODE_RETURN_INDEX(node); + const auto node_ptr = ecl_smspec_get_int_key_var_node(ecl_smspec->block_var_index, block_nr, block_var); + NODE_RETURN_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) { - const smspec_node_type * node = ecl_smspec_get_block_var_node_ijk( ecl_smspec , block_var , i,j,k ); - NODE_RETURN_INDEX(node); + return ecl_smspec_get_block_var_params_index(ecl_smspec, block_var, ecl_smspec_get_global_grid_index(ecl_smspec, i, j, k)); } @@ -1516,53 +1432,46 @@ int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type * ecl_smspec -const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * ecl_smspec , const char *region_var , int region_nr) { - const smspec_node_type * node = NULL; +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); + if (!node_ptr) + throw std::out_of_range("No such block variable"); - if (hash_has_key(ecl_smspec->region_var_index , region_var)) { - char * nr_str = util_alloc_sprintf( "%d" , region_nr ); - hash_type * nr_hash = (hash_type*)hash_get(ecl_smspec->region_var_index , region_var); - if (hash_has_key( nr_hash , nr_str)) - node = (const smspec_node_type*)hash_get( nr_hash , nr_str ); - free( nr_str ); - } - - return node; + return *node_ptr; } bool ecl_smspec_has_region_var(const ecl_smspec_type * ecl_smspec , const char *region_var, int region_nr) { - const smspec_node_type * node = ecl_smspec_get_region_var_node( ecl_smspec , region_var , region_nr ); - NODE_RETURN_EXISTS(node); + const auto node_ptr = ecl_smspec_get_int_key_var_node(ecl_smspec->region_var_index, region_nr, region_var); + NODE_RETURN_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 smspec_node_type * node = ecl_smspec_get_region_var_node( ecl_smspec , region_var , region_nr ); - NODE_RETURN_INDEX(node); + const auto node_ptr = ecl_smspec_get_int_key_var_node(ecl_smspec->region_var_index, region_nr, region_var); + NODE_RETURN_INDEX(node_ptr); } /*****************************************************************/ /* Misc variables */ -const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ecl_smspec , const char *var) { - const smspec_node_type * node = NULL; +const ecl::smspec_node& ecl_smspec_get_misc_var_node(const ecl_smspec_type * ecl_smspec , const char *var) { + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->misc_var_index, var); + if (!node_ptr) + throw std::out_of_range("No such misc variable"); - if (hash_has_key(ecl_smspec->misc_var_index , var)) - node = (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , var); - - return node; + return *node_ptr; } bool ecl_smspec_has_misc_var(const ecl_smspec_type * ecl_smspec , const char *var) { - const smspec_node_type * node = ecl_smspec_get_misc_var_node( ecl_smspec , var ); - NODE_RETURN_EXISTS(node); + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->misc_var_index , var ); + NODE_RETURN_EXISTS(node_ptr); } int ecl_smspec_get_misc_var_params_index(const ecl_smspec_type * ecl_smspec , const char *var) { - const smspec_node_type * node = ecl_smspec_get_misc_var_node( ecl_smspec , var ); - NODE_RETURN_INDEX(node); + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->misc_var_index , var ); + NODE_RETURN_INDEX(node_ptr); } @@ -1570,33 +1479,33 @@ int ecl_smspec_get_misc_var_params_index(const ecl_smspec_type * ecl_smspec , co /* Well completion - not fully implemented ?? */ -const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr) { - const smspec_node_type * node = NULL; +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()) + return nullptr; - char * cell_str = util_alloc_sprintf("%d" , cell_nr); - if (hash_has_key(ecl_smspec->well_completion_var_index , well)) { - hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well); + const auto& num_map = well_iter->second; + return ecl_smspec_get_int_key_var_node( num_map, cell_nr, var ); +} - if (hash_has_key(cell_hash , cell_str)) { - hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str); - if (hash_has_key(var_hash , var)) - node = (const smspec_node_type*)hash_get( var_hash , var); - } - } - free(cell_str); - return node; +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); + 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 smspec_node_type * node = ecl_smspec_get_well_completion_var_node( ecl_smspec , well , var , cell_nr ); - NODE_RETURN_EXISTS( node ); + const auto node_ptr = ecl_smspec_get_well_completion_var_node__( ecl_smspec , well , var , cell_nr ); + NODE_RETURN_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 cell_nr) { - const smspec_node_type * node = ecl_smspec_get_well_completion_var_node( ecl_smspec , well , var , cell_nr ); - NODE_RETURN_INDEX( node ); + const auto node_ptr = ecl_smspec_get_well_completion_var_node__( ecl_smspec , well , var , cell_nr ); + NODE_RETURN_INDEX( node_ptr ); } @@ -1610,31 +1519,31 @@ int ecl_smspec_get_well_completion_var_params_index(const ecl_smspec_type * ecl -const smspec_node_type * ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw ) { - if (hash_has_key( smspec->gen_var_index , lookup_kw )) { - const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( smspec->gen_var_index , lookup_kw ); - return smspec_node; - } else - return NULL; +const ecl::smspec_node& ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw ) { + const auto node_ptr = ecl_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) { - const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_smspec , lookup_kw ); - NODE_RETURN_INDEX( node ); + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->gen_var_index , lookup_kw ); + NODE_RETURN_INDEX( node_ptr ); } bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char * lookup_kw) { - const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_smspec , lookup_kw ); - NODE_RETURN_EXISTS( node ); + const auto node_ptr = ecl_smspec_get_var_node(ecl_smspec->gen_var_index , lookup_kw ); + NODE_RETURN_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 smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( ecl_smspec->gen_var_index , lookup_kw ); - return smspec_node_get_unit( smspec_node ); + const auto smspec_node = ecl_smspec_get_general_var_node(ecl_smspec, lookup_kw); + return smspec_node_get_unit( &smspec_node ); } @@ -1645,22 +1554,22 @@ const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec */ //const char * ecl_smspec_iget_unit( const ecl_smspec_type * smspec , int node_index ) { -// const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , node_index ); +// const ecl::smspec_node * smspec_node = ecl_smspec_iget_node( smspec , node_index ); // return smspec_node_get_unit( smspec_node ); //} // //int ecl_smspec_iget_num( const ecl_smspec_type * smspec , int node_index ) { -// const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , node_index ); +// const ecl::smspec_node * smspec_node = ecl_smspec_iget_node( smspec , node_index ); // return smspec_node_get_num( smspec_node ); //} // //const char * ecl_smspec_iget_wgname( const ecl_smspec_type * smspec , int node_index ) { -// const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , node_index ); +// const ecl::smspec_node * smspec_node = ecl_smspec_iget_node( smspec , node_index ); // return smspec_node_get_wgname( smspec_node ); //} // //const char * ecl_smspec_iget_keyword( const ecl_smspec_type * smspec , int index ) { -// const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , index ); +// const ecl::smspec_node * smspec_node = ecl_smspec_iget_node( smspec , index ); // return smspec_node_get_keyword( smspec_node ); //} @@ -1684,7 +1593,7 @@ bool ecl_smspec_get_formatted( const ecl_smspec_type * ecl_smspec) { } const char * ecl_smspec_get_header_file( const ecl_smspec_type * ecl_smspec ) { - return ecl_smspec->header_file; + return ecl_smspec->header_file.c_str(); } @@ -1701,31 +1610,18 @@ int ecl_smspec_get_first_step(const ecl_smspec_type * ecl_smspec) { const char * ecl_smspec_get_restart_case( const ecl_smspec_type * ecl_smspec) { - return ecl_smspec->restart_case; + if (ecl_smspec->restart_case.size() > 0) + return ecl_smspec->restart_case.c_str(); + else + return NULL; } - -const float_vector_type * ecl_smspec_get_params_default( const ecl_smspec_type * ecl_smspec ) { +const std::vector& ecl_smspec_get_params_default( const ecl_smspec_type * ecl_smspec ) { return ecl_smspec->params_default; } - - void ecl_smspec_free(ecl_smspec_type *ecl_smspec) { - hash_free(ecl_smspec->well_var_index); - hash_free(ecl_smspec->well_completion_var_index); - hash_free(ecl_smspec->group_var_index); - hash_free(ecl_smspec->field_var_index); - hash_free(ecl_smspec->region_var_index); - hash_free(ecl_smspec->misc_var_index); - hash_free(ecl_smspec->block_var_index); - hash_free(ecl_smspec->gen_var_index); - free( ecl_smspec->header_file ); - int_vector_free( ecl_smspec->index_map ); - float_vector_free( ecl_smspec->params_default ); - vector_free( ecl_smspec->smspec_nodes ); - free( ecl_smspec->restart_case ); - free( ecl_smspec ); + delete ecl_smspec; } @@ -1757,8 +1653,8 @@ int ecl_smspec_get_date_year_index( const ecl_smspec_type * smspec ) { bool ecl_smspec_general_is_total( const ecl_smspec_type * smspec , const char * gen_key) { - const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( smspec->gen_var_index , gen_key ); - return smspec_node_is_total( smspec_node ); + const ecl::smspec_node& smspec_node = ecl_smspec_get_general_var_node(smspec, gen_key); + return smspec_node_is_total( &smspec_node ); } @@ -1786,15 +1682,13 @@ bool ecl_smspec_general_is_total( const ecl_smspec_type * smspec , const char * void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys) { - hash_type * ex_keys = hash_alloc( ); - int i; - for (i=0; i < stringlist_get_size( keys ); i++) - hash_insert_int( ex_keys , stringlist_iget( keys , i ) , 1); + std::set ex_keys; + for (int i=0; i < stringlist_get_size( keys ); i++) + ex_keys.insert( stringlist_iget(keys, i)); { - hash_iter_type * iter = hash_iter_alloc( smspec->gen_var_index ); - while (!hash_iter_is_complete( iter )) { - const char * key = hash_iter_get_next_key( iter ); + for (const auto& pair : smspec->gen_var_index) { + const char * key = pair.first.c_str(); /* The TIME is typically special cased by output and will not @@ -1807,14 +1701,12 @@ void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec if ((pattern == NULL) || (util_fnmatch( pattern , key ) == 0)) { - if (!hash_has_key( ex_keys , key)) + if (ex_keys.find(key) == ex_keys.end()) stringlist_append_copy( keys , key ); } } - hash_iter_free( iter ); } - hash_free( ex_keys ); stringlist_sort( keys , (string_cmp_ftype *) util_strcmp_int ); } @@ -1833,7 +1725,7 @@ stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_ty const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec) { - return smspec->key_join_string; + return smspec->key_join_string.c_str(); } @@ -1850,24 +1742,25 @@ const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec) { i.e. standard shell wildcards. */ -stringlist_type * ecl_smspec_alloc_well_list( const ecl_smspec_type * smspec , const char * pattern) { - stringlist_type * well_list = stringlist_alloc_new( ); - { - hash_iter_type * iter = hash_iter_alloc( smspec->well_var_index ); +static stringlist_type * ecl_smspec_alloc_map_list( const std::map& mp , const char * pattern) { + stringlist_type * map_list = stringlist_alloc_new( ); + + for (const auto& pair : mp) { + const char * map_name = pair.first.c_str(); + + if (pattern == NULL) + stringlist_append_copy( map_list , map_name ); + else if (util_fnmatch( pattern , map_name) == 0) + stringlist_append_copy( map_list , map_name ); - while (!hash_iter_is_complete( iter )) { - const char * well_name = hash_iter_get_next_key( iter ); - if (pattern == NULL) - stringlist_append_copy( well_list , well_name ); - else if (util_fnmatch( pattern , well_name) == 0) - stringlist_append_copy( well_list , well_name ); - } - hash_iter_free(iter); } - stringlist_sort( well_list , (string_cmp_ftype *) util_strcmp_int ); - return well_list; + stringlist_sort( map_list , (string_cmp_ftype *) util_strcmp_int ); + 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 ); +} /** Returns a stringlist instance with all the (valid) group names. It @@ -1876,21 +1769,7 @@ stringlist_type * ecl_smspec_alloc_well_list( const ecl_smspec_type * smspec , c */ stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , const char * pattern) { - stringlist_type * group_list = stringlist_alloc_new( ); - { - hash_iter_type * iter = hash_iter_alloc( smspec->group_var_index ); - - while (!hash_iter_is_complete( iter )) { - const char * group_name = hash_iter_get_next_key( iter ); - if (pattern == NULL) - stringlist_append_copy( group_list , group_name ); - else if (util_fnmatch( pattern , group_name) == 0) - stringlist_append_copy( group_list , group_name ); - } - hash_iter_free(iter); - } - stringlist_sort( group_list , (string_cmp_ftype *) util_strcmp_int ); - return group_list; + return ecl_smspec_alloc_map_list( smspec->group_var_index, pattern ); } @@ -1902,18 +1781,15 @@ stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , */ stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec ) { - hash_iter_type * well_iter = hash_iter_alloc( smspec->well_var_index ); - hash_type * var_hash = (hash_type*)hash_iter_get_next_value( well_iter ); - hash_iter_free( well_iter ); - return hash_alloc_stringlist( var_hash ); + stringlist_type * stringlist = stringlist_alloc_new(); + for (const auto& pair : smspec->well_var_index) + stringlist_append_copy(stringlist, pair.first.c_str()); + + return stringlist; } -int ecl_smspec_get_params_size( const ecl_smspec_type * smspec ) { - return smspec->params_size; -} - const int * ecl_smspec_get_grid_dims( const ecl_smspec_type * smspec ) { @@ -1926,19 +1802,19 @@ const int * ecl_smspec_get_grid_dims( const ecl_smspec_type * smspec ) { /*****************************************************************/ char * ecl_smspec_alloc_well_key( const ecl_smspec_type * smspec , const char * keyword , const char * wgname) { - return smspec_alloc_well_key( smspec->key_join_string , keyword , wgname ); + return smspec_alloc_well_key( smspec->key_join_string.c_str() , keyword , wgname ); } -void ecl_smspec_sort( ecl_smspec_type * smspec ) { - vector_sort( smspec->smspec_nodes , smspec_node_cmp__); +/*void ecl_smspec_sort( ecl_smspec_type * smspec ) { + std::sort(smspec->smspec_nodes.begin(), smspec->smspec_nodes.end(), smspec_node_lt); - for (int i=0; i < vector_get_size( smspec->smspec_nodes ); i++) { - smspec_node_type * node = (smspec_node_type*)vector_iget( smspec->smspec_nodes , i ); - smspec_node_set_params_index( node , i ); + for (int i=0; i < static_cast(smspec->smspec_nodes.size()); i++) { + ecl::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) { return smspec->unit_system; diff --git a/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp b/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp index 1e06968afd..faec3f3fc3 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_subsidence.c' is part of ERT - Ensemble based Reservoir Tool. @@ -75,6 +75,7 @@ struct ecl_subsidence_survey_struct { char * name; /* Name of the survey - arbitrary string. */ double * porv; /* Reference pore volume */ double * pressure; /* Pressure in each grid cell at survey time */ + double * dynamic_porevolume; /* Porevolume in each grid cell at survey time */ }; @@ -92,6 +93,7 @@ static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_empty(const ecl_ survey->porv = (double*) util_calloc( sub->grid_cache->size() , sizeof * survey->porv ); survey->pressure = (double*) util_calloc( sub->grid_cache->size() , sizeof * survey->pressure ); + survey->dynamic_porevolume = NULL; return survey; } @@ -111,9 +113,18 @@ static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_PRESSURE(ecl_sub 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( restart_view , PRESSURE_KW , 0); /*Active indexing*/ + ecl_kw_type * rporv_kw = NULL; + if(ecl_file_view_has_kw(restart_view, RPORV_KW)) { + survey->dynamic_porevolume = (double*) util_calloc( ecl_subsidence->grid_cache->size() , sizeof * survey->dynamic_porevolume); + rporv_kw = ecl_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] ); survey->pressure[ active_index ] = ecl_kw_iget_float( pressure_kw , active_index ); + + if(rporv_kw) + survey->dynamic_porevolume[ active_index ] = ecl_kw_iget_float(rporv_kw, active_index); } return survey; } @@ -126,6 +137,7 @@ static void ecl_subsidence_survey_free( ecl_subsidence_survey_type * subsidence_ free( subsidence_survey->name ); free( subsidence_survey->porv ); free( subsidence_survey->pressure ); + free( subsidence_survey->dynamic_porevolume ); free( subsidence_survey ); } @@ -193,6 +205,47 @@ static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_t } +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 , + 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); + std::vector weight(grid_cache.size()); + + if(!base_survey->dynamic_porevolume) { + util_abort( + "%s: Keyword RPORV not defined in .UNRST file for %s. Please add RPORV keyword to output in RPTRST clause in .DATA file.\n", + __func__, base_survey->name); + } + + if(monitor_survey && !monitor_survey->dynamic_porevolume) { + util_abort( + "%s: Keyword RPORV not defined in .UNRST file for %s. Please add RPORV keyword to output in RPTRST clause in .DATA file.\n", + __func__, monitor_survey->name); + } + + for (size_t index = 0; index < weight.size(); ++index) { + if (monitor_survey) + weight[index] = (base_survey->dynamic_porevolume[index] - monitor_survey->dynamic_porevolume[index]) / (4*M_PI); + else + weight[index] = base_survey->dynamic_porevolume[index] / (4*M_PI); + } + + return ecl_grav_common_eval_geertsma( + grid_cache, + region, + base_survey->aquifer_cell, + weight.data(), + utm_x, + utm_y, + depth, + poisson_ratio, + seabed + ); +} + /*****************************************************************/ /** @@ -254,6 +307,14 @@ double ecl_subsidence_eval_geertsma( const ecl_subsidence_type * subsidence , co return ecl_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( 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; diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp index c5c27b58ee..a64e2e4bd8 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_sum.c' is part of ERT - Ensemble based Reservoir Tool. @@ -290,32 +290,16 @@ void ecl_sum_set_fmt_case( ecl_sum_type * ecl_sum , bool fmt_case ) { -smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value) { +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) throw std::invalid_argument("Can not interchange variable adding and timesteps.\n"); - - smspec_node_type * smspec_node = smspec_node_alloc( ecl_smspec_identify_var_type(keyword), - wgname, - keyword, - unit, - ecl_sum->key_join_string, - ecl_smspec_get_grid_dims(ecl_sum->smspec), - num, - -1, - default_value); - ecl_smspec_add_node(ecl_sum->smspec, smspec_node); - ecl_sum_data_reset_self_map( ecl_sum->data ); - return smspec_node; + return ecl_smspec_add_node( ecl_sum->smspec, keyword, wgname, num, unit, default_value); } -smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node) { - return ecl_sum_add_var(ecl_sum, - smspec_node_get_keyword(node), - smspec_node_get_wgname(node), - smspec_node_get_num(node), - smspec_node_get_unit(node), - smspec_node_get_default(node)); + +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); } @@ -335,7 +319,8 @@ smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_ */ ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_seconds) { - return ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_seconds ); + ecl_sum_tstep_type * new_tstep = ecl_sum_data_add_new_tstep( ecl_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) { @@ -516,12 +501,12 @@ bool ecl_sum_case_exists( const char * input_file ) { /*****************************************************************/ -double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const smspec_node_type * node) { - return ecl_sum_data_get_from_sim_time( ecl_sum->data , sim_time , node ); +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 ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const smspec_node_type * node) { - return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , 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 ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time) { @@ -559,13 +544,13 @@ double ecl_sum_get_well_var(const ecl_sum_type * ecl_sum , int time_index , con } 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 smspec_node_type * node = ecl_smspec_get_well_var_node( ecl_sum->smspec , well , var ); - return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node ); + 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 ecl_sum_get_well_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * well , const char * var) { - const smspec_node_type * node = ecl_smspec_get_well_var_node( ecl_sum->smspec , well , var ); - return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node ); + 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 ); } @@ -583,13 +568,13 @@ double ecl_sum_get_group_var(const ecl_sum_type * ecl_sum , int time_index , co 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 smspec_node_type * node = ecl_smspec_get_group_var_node( ecl_sum->smspec , group , var ); - return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node ); + 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 ecl_sum_get_group_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * group , const char * var) { - const smspec_node_type * node = ecl_smspec_get_group_var_node( ecl_sum->smspec , group , var ); - return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node ); + 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 ); } @@ -605,13 +590,13 @@ double ecl_sum_get_field_var(const ecl_sum_type * ecl_sum , int time_index , con } double ecl_sum_get_field_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) { - const smspec_node_type * node = ecl_smspec_get_field_var_node( ecl_sum->smspec , var ); - return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node ); + 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 ecl_sum_get_field_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var) { - const smspec_node_type * node = ecl_smspec_get_field_var_node( ecl_sum->smspec , var ); - return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node ); + 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 ); } @@ -641,13 +626,13 @@ double ecl_sum_get_block_var_ijk(const ecl_sum_type * ecl_sum , int time_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 smspec_node_type * 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 ); + 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 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 smspec_node_type * 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 ); + 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 ); } @@ -668,13 +653,13 @@ double ecl_sum_get_region_var(const ecl_sum_type * ecl_sum , int time_index , co } 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 smspec_node_type * 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 ); + 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 ecl_sum_get_region_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var , int region_nr) { - const smspec_node_type * 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 ); + 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 ); } @@ -715,14 +700,9 @@ double ecl_sum_get_well_completion_var(const ecl_sum_type * ecl_sum , int time_i /*****************************************************************/ /* General variables - this means WWCT:OP_1 - i.e. composite variables*/ -const smspec_node_type * ecl_sum_get_general_var_node(const ecl_sum_type * ecl_sum , const char * lookup_kw) { - const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , lookup_kw ); - if (node != NULL) - return node; - else { - util_abort("%s: summary case:%s does not contain key:%s\n",__func__ , ecl_sum_get_case( ecl_sum ) , lookup_kw ); - return NULL; - } +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 ); + return &node; } int ecl_sum_get_general_var_params_index(const ecl_sum_type * ecl_sum , const char * lookup_kw) { @@ -761,30 +741,38 @@ void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type * ecl_sum, time_t sim_tim double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , 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 ecl_sum_get_general_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , var ); - return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , node ); + 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 ); } const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const char * var) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , var ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_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) { - time_t start_time = ecl_sum_get_data_start(ecl_sum); +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) { + /* + 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 + */ - if ( time_t_vector_get_first(times) < start_time ) + time_t start_time = ecl_sum_get_data_start(ecl_sum); + time_t end_time = ecl_sum_get_end_time(ecl_sum); + time_t input_start = time_t_vector_get_first( times ); + time_t input_end = time_t_vector_get_last( times ); + + if ( !lower_extrapolation && input_start < start_time ) return NULL; - if ( time_t_vector_get_last(times) > ecl_sum_get_end_time(ecl_sum) ) + if ( !upper_extrapolation && input_end > end_time) return NULL; if ( !time_t_vector_is_sorted(times, false) ) return NULL; @@ -792,38 +780,57 @@ ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * const int * grid_dims = ecl_smspec_get_grid_dims(ecl_sum->smspec); bool time_in_days = false; - const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, 0); - if ( util_string_equal(smspec_node_get_unit(node), "DAYS" ) ) + const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, 0); + if ( util_string_equal(smspec_node_get_unit(&node), "DAYS" ) ) time_in_days = true; - ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_writer( ecl_case , ecl_sum->fmt_case , ecl_sum->unified , ecl_sum->key_join_string , start_time , time_in_days , grid_dims[0] , grid_dims[1] , grid_dims[2] ); - - + //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 , 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 smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, i); - if (util_string_equal(smspec_node_get_gen_key1(node), "TIME")) + const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i); + if (util_string_equal(smspec_node_get_gen_key1(&node), "TIME")) continue; - ecl_sum_add_smspec_node( ecl_sum_resampled, node ); + ecl_sum_add_smspec_node( ecl_sum_resampled, &node ); } /* The SMSPEC header structure has been completely initialized, it is time to start filling it up with data. + */ ecl_sum_vector_type * ecl_sum_vector = ecl_sum_vector_alloc(ecl_sum, true); double_vector_type * data = double_vector_alloc( ecl_sum_vector_get_size(ecl_sum_vector) , 0); - for (int report_step = 0; report_step < time_t_vector_size(times); report_step++) { - time_t t = time_t_vector_iget(times, report_step); - - /* Look up interpolated data in the original case. */ - ecl_sum_get_interp_vector( ecl_sum, t, ecl_sum_vector, data); + 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++) { + double value = 0; + const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i); + if (!node.is_rate()) + value = ecl_sum_iget_first_value(ecl_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++) { + double value = 0; + const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i); + if (!node.is_rate()) + value = ecl_sum_iget_last_value(ecl_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); + } /* 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 , t - start_time); + ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_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++) { 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. @@ -844,12 +851,12 @@ double ecl_sum_iget( const ecl_sum_type * ecl_sum , int time_index , int param_i /* Simple get functions which take a general var key as input */ bool ecl_sum_var_is_rate( const ecl_sum_type * ecl_sum , const char * gen_key) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_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 smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); return smspec_node_is_total( node ); } @@ -859,27 +866,27 @@ 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) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_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 smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_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 smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_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 smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_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 smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); return smspec_node_get_keyword( node ); } @@ -932,7 +939,7 @@ void ecl_sum_init_double_vector(const ecl_sum_type * ecl_sum, const char * gen_k } 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 smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); + 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); } @@ -1305,7 +1312,7 @@ stringlist_type * ecl_sum_alloc_well_var_list( const ecl_sum_type * ecl_sum ) { 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 smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); + const ecl::smspec_node& node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); double_vector_reset( value ); { int i; @@ -1316,7 +1323,7 @@ void ecl_sum_resample_from_sim_time( const ecl_sum_type * ecl_sum , const time_t 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 smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); + const ecl::smspec_node& node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); double_vector_reset( value ); { int i; @@ -1377,7 +1384,7 @@ int ecl_sum_get_report_step_from_days( const ecl_sum_type * sum , double sim_day /*****************************************************************/ -const ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum ) { +ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum ) { return ecl_sum->smspec; } @@ -1430,8 +1437,8 @@ bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_s 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 smspec_node_type * 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); + 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); } @@ -1467,11 +1474,11 @@ 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) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , 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 ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *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)); } @@ -1480,10 +1487,10 @@ 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, const char * gen_key) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , 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 ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *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)); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp index b1bc8dba62..e525a6f680 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_sum_data.c' is part of ERT - Ensemble based Reservoir Tool. @@ -458,16 +458,24 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da sequence has no holes. */ +static void fprintf_date_utc(time_t t , FILE * stream) { + int mday,year,month; + + util_set_datetime_values_utc(t , NULL , NULL , NULL , &mday , &month , &year); + 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); - fprintf(stderr , "Simulation start: "); util_fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr ); - fprintf(stderr , "Data start......: "); util_fprintf_date_utc( start_time , stderr ); - fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( end_time , stderr ); - fprintf(stderr , "Requested date .: "); util_fprintf_date_utc( sim_time , stderr ); + fprintf(stderr , "Simulation start: "); fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr ); + fprintf(stderr , "Data start......: "); fprintf_date_utc( start_time , stderr ); + fprintf(stderr , "Simulation end .: "); fprintf_date_utc( end_time , stderr ); + fprintf(stderr , "Requested date .: "); fprintf_date_utc( sim_time , stderr ); util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , start_time, end_time); } @@ -569,9 +577,9 @@ void ecl_sum_data_init_interp_from_sim_days( const ecl_sum_data_type * data , do } -double_vector_type * ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type * data, const smspec_node_type * node, double cmp_value, bool rates_clamp_lower) { +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) { double_vector_type * solution = double_vector_alloc(0, 0); - const int param_index = smspec_node_get_params_index(node); + const int param_index = smspec_node_get_params_index(&node); const int size = ecl_sum_data_get_length(data); if (size <= 1) @@ -593,7 +601,7 @@ double_vector_type * ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type double prev_time = ecl_sum_data_iget_sim_seconds(data, prev_index); double time = ecl_sum_data_iget_sim_seconds(data, index); - if (smspec_node_is_rate(node)) { + if (smspec_node_is_rate(&node)) { double_vector_append(solution, rates_clamp_lower ? prev_time + 1 : time); } else { double slope = (value - prev_value) / (time - prev_time); @@ -811,8 +819,8 @@ double ecl_sum_data_iget( const ecl_sum_data_type * data , int time_index , int if (params_map[params_index] >= 0) return file_data->iget( time_index - index_node.offset, params_map[params_index] ); else { - const smspec_node_type * smspec_node = ecl_smspec_iget_node(data->smspec, params_index); - return smspec_node_get_default(smspec_node); + const ecl::smspec_node& smspec_node = ecl_smspec_iget_node_w_params_index(data->smspec, params_index); + return smspec_node.get_default(); } } @@ -905,9 +913,9 @@ void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim } } -double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node) { - int params_index = smspec_node_get_params_index( smspec_node ); - if (smspec_node_is_rate( smspec_node )) { +double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const ecl::smspec_node& smspec_node) { + int params_index = smspec_node_get_params_index( &smspec_node ); + if (smspec_node_is_rate( &smspec_node )) { /* In general the mapping from sim_time to index is based on half open intervals, which are closed in the upper end: @@ -986,7 +994,7 @@ double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time) 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 smspec_node_type * 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) { time_t sim_time = ecl_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 ); @@ -1076,22 +1084,18 @@ static void ecl_sum_data_init_double_vector__(const ecl_sum_data_type * data, in const auto& params_map = index_node.params_map; int params_index = params_map[main_params_index]; - if (report_only) { - const smspec_node_type * smspec_node = ecl_smspec_iget_node(data->smspec, main_params_index); - double default_value = smspec_node_get_default(smspec_node); + const ecl::smspec_node& smspec_node = ecl_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, &output_data[offset], default_value); } else { if (params_index >= 0) data_file->get_data(params_index, index_node.length, &output_data[offset]); else { - const smspec_node_type * smspec_node = ecl_smspec_iget_node(data->smspec, main_params_index); - if (smspec_node) - { - for (int i=0; i < index_node.length; i++) - output_data[offset + i] = smspec_node_get_default(smspec_node); - } + const ecl::smspec_node& smspec_node = ecl_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(); } offset += index_node.length; } @@ -1118,6 +1122,9 @@ double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * d else output_data.resize( ecl_sum_data_get_length(data) ); + if (params_index >= ecl_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); double_vector_type * data_vector = double_vector_alloc(output_data.size(), 0); { @@ -1129,11 +1136,11 @@ double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * d void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data, - const smspec_node_type * smspec_node, + const ecl::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); + 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); double start_value = 0; diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp index b0367e2ec5..19c6fa28cd 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp @@ -471,7 +471,8 @@ void ecl_sum_file_data::fwrite_report( int report_step , fortio_type * fortio) c 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 ) , fortio ); + ecl_sum_tstep_fwrite( tstep , ecl_smspec_get_index_map(ecl_smspec) , ecl_smspec_num_nodes(ecl_smspec), fortio ); } } } @@ -553,7 +554,7 @@ bool ecl_sum_file_data::check_file( ecl_file_type * ecl_file ) { 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, const ecl_smspec_type * smspec) { +void ecl_sum_file_data::add_ecl_file(int report_step, const ecl_file_view_type * summary_view) { int num_ministep = ecl_file_view_get_num_named_kw( summary_view , PARAMS_KW); if (num_ministep > 0) { @@ -569,7 +570,7 @@ void ecl_sum_file_data::add_ecl_file(int report_step, const ecl_file_view_type * ministep_nr , params_kw , ecl_file_view_get_src_file( summary_view ), - smspec ); + this->ecl_smspec ); if (tstep) append_tstep( tstep ); @@ -600,7 +601,7 @@ bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load, { ecl_file_type * ecl_file = ecl_file_open( data_file , 0); if (ecl_file && check_file( ecl_file )) { - add_ecl_file( report_step , ecl_file_get_global_view( ecl_file ) , ecl_smspec); + this->add_ecl_file( report_step , ecl_file_get_global_view( ecl_file )); ecl_file_close( ecl_file ); } } @@ -632,7 +633,7 @@ bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load, */ ecl_file_view_type * summary_view = ecl_file_get_summary_view(ecl_file , block_index); if (summary_view) { - add_ecl_file(block_index + first_report_step , summary_view , ecl_smspec); + this->add_ecl_file(block_index + first_report_step , summary_view); block_index++; } else break; } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp index 3211baac34..ff3694f32f 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_sum_index.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp index 380b7e5732..6e565e7e16 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp @@ -1,5 +1,5 @@ - /* - Copyright (C) 2012 Statoil ASA, Norway. +/* + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_sum_tstep.c' is part of ERT - Ensemble based Reservoir Tool. @@ -19,6 +19,8 @@ #include #include +#include + #include #include @@ -59,12 +61,11 @@ Header direction: ecl_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25 struct ecl_sum_tstep_struct { UTIL_TYPE_ID_DECLARATION; - float * data; /* A memcpy copy of the PARAMS vector in ecl_kw instance - the raw data. */ + std::vector data; /* A memcpy copy of the PARAMS vector in ecl_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 data_size; /* Number of elements in data - only used for checking indices. */ int internal_index; /* Used for lookups of the next / previous ministep based on an existing ministep. */ const ecl_smspec_type * smspec; /* The smespec header information for this tstep - must be compatible. */ }; @@ -72,11 +73,13 @@ struct ecl_sum_tstep_struct { 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 = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src ); + ecl_sum_tstep_type * target = new ecl_sum_tstep_type(); + UTIL_TYPE_ID_INIT( target , ECL_SUM_TSTEP_ID); + target->report_step = src->report_step; + target->ministep = src->ministep; target->smspec = new_smspec; - target->data = (float*)util_malloc( params_size * sizeof * target->data ); - target->data_size = params_size; + target->data.resize(params_size); for (int i=0; i < params_size; i++) { if (params_map[i] >= 0) @@ -89,20 +92,23 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * } ecl_sum_tstep_type * ecl_sum_tstep_alloc_copy( const ecl_sum_tstep_type * src ) { - ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src ); - target->data = (float*)util_alloc_copy( src->data , src->data_size * sizeof * src->data ); + ecl_sum_tstep_type * target = new ecl_sum_tstep_type(); + UTIL_TYPE_ID_INIT( target , ECL_SUM_TSTEP_ID); + target->smspec = src->smspec; + target->report_step = src->report_step; + target->ministep = src->ministep; + target->data = src->data; 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 = (ecl_sum_tstep_type*)util_malloc( sizeof * tstep ); + ecl_sum_tstep_type * tstep = new ecl_sum_tstep_type(); UTIL_TYPE_ID_INIT( tstep , ECL_SUM_TSTEP_ID); tstep->smspec = smspec; tstep->report_step = report_step; tstep->ministep = ministep_nr; - tstep->data_size = ecl_smspec_get_params_size( smspec ); - tstep->data = (float*)util_calloc( tstep->data_size , sizeof * tstep->data ); + tstep->data.resize( ecl_smspec_get_params_size( smspec ) ); return tstep; } @@ -112,8 +118,7 @@ UTIL_SAFE_CAST_FUNCTION_CONST( ecl_sum_tstep , ECL_SUM_TSTEP_ID) void ecl_sum_tstep_free( ecl_sum_tstep_type * ministep ) { - free( ministep->data ); - free( ministep ); + delete ministep; } @@ -201,7 +206,7 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step , 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 ); + ecl_kw_get_memcpy_data( params_kw , ministep->data.data() ); ecl_sum_tstep_set_time_info( ministep , smspec ); return ministep; } else { @@ -211,7 +216,11 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step , ecl_smspec_load_restart() function and the restart case discarded. */ - fprintf(stderr , "** Warning size mismatch between timestep loaded from:%s and header:%s - timestep discarded.\n" , src_file , ecl_smspec_get_header_file( smspec )); + 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 )); return NULL; } } @@ -223,8 +232,7 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step , 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 ); - const float_vector_type * default_data = ecl_smspec_get_params_default( smspec ); - float_vector_memcpy_data( tstep->data , default_data ); + 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 ) ); @@ -235,10 +243,10 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , f double ecl_sum_tstep_iget(const ecl_sum_tstep_type * ministep , int index) { - if ((index >= 0) && (index < ministep->data_size)) + if ((index >= 0) && (index < (int)ministep->data.size())) return ministep->data[index]; else { - util_abort("%s: param index:%d invalid: Valid range: [0,%d) \n",__func__ , index , ministep->data_size); + util_abort("%s: param index:%d invalid: Valid range: [0,%d) \n",__func__ , index , ministep->data.size()); return -1; } } @@ -269,7 +277,7 @@ 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_vector_type * index_map , fortio_type * fortio) { +void ecl_sum_tstep_fwrite( const ecl_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 ); @@ -278,16 +286,15 @@ void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vecto } { - int compact_size = int_vector_size( index_map ); + int compact_size = index_map_size; ecl_kw_type * params_kw = ecl_kw_alloc( PARAMS_KW , compact_size , ECL_FLOAT ); - const int * index = int_vector_get_ptr( index_map ); float * data = (float*)ecl_kw_get_ptr( params_kw ); { int i; for (i=0; i < compact_size; i++) - data[i] = ministep->data[ index[i] ]; + data[i] = ministep->data[ index_map[i] ]; } ecl_kw_fwrite( params_kw , fortio ); ecl_kw_free( params_kw ); @@ -298,10 +305,10 @@ void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vecto /*****************************************************************/ void ecl_sum_tstep_iset( ecl_sum_tstep_type * tstep , int index , float value) { - if ((index < tstep->data_size) && (index >= 0)) + if ((index < static_cast(tstep->data.size())) && (index >= 0) ) tstep->data[index] = value; else - util_abort("%s: index:%d invalid. Valid range: [0,%d) \n",__func__ ,index , tstep->data_size); + util_abort("%s: index:%d invalid. Valid range: [0,%d) \n",__func__ ,index , tstep->data.size()); } void ecl_sum_tstep_iscale(ecl_sum_tstep_type * tstep, int index, float scalar) { @@ -312,24 +319,24 @@ 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 ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node , float value) { - int data_index = smspec_node_get_params_index( smspec_node ); +void ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const ecl::smspec_node& smspec_node , float value) { + int data_index = smspec_node_get_params_index( &smspec_node ); ecl_sum_tstep_iset( tstep , data_index , value); } -double ecl_sum_tstep_get_from_node( const ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node) { - int data_index = smspec_node_get_params_index( smspec_node ); +double ecl_sum_tstep_get_from_node( const ecl_sum_tstep_type * tstep , const ecl::smspec_node& smspec_node) { + int data_index = smspec_node_get_params_index( &smspec_node ); return ecl_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 smspec_node_type * smspec_node = ecl_smspec_get_general_var_node( tstep->smspec , gen_key ); + 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); } double ecl_sum_tstep_get_from_key(const ecl_sum_tstep_type * tstep , const char * gen_key) { - const smspec_node_type * smspec_node = ecl_smspec_get_general_var_node( tstep->smspec , 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 ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp index 8bcfebfe4a..ee7d9e1d64 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_sum_vector.c' is part of ERT - Ensemble based Reservoir Tool. @@ -16,6 +16,10 @@ for more details. */ #include + +#include +#include + #include #include #include @@ -23,68 +27,60 @@ #include #include #include -#include -#include #define ECL_SUM_VECTOR_TYPE_ID 8768778 struct ecl_sum_vector_struct { UTIL_TYPE_ID_DECLARATION; - int_vector_type * node_index_list; - bool_vector_type * is_rate_list; - stringlist_type * key_list; + std::vector node_index_list; + std::vector is_rate_list; + std::vector key_list; const ecl_sum_type * ecl_sum; }; void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){ - int_vector_free(ecl_sum_vector->node_index_list); - bool_vector_free(ecl_sum_vector->is_rate_list); - stringlist_free(ecl_sum_vector->key_list); - free(ecl_sum_vector); + delete ecl_sum_vector; } UTIL_IS_INSTANCE_FUNCTION( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID ) -static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const smspec_node_type * node, const char * key ) { +static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const ecl::smspec_node * node, const char * key ) { int params_index = smspec_node_get_params_index( node ); bool is_rate_key = smspec_node_is_rate( node); - int_vector_append(vector->node_index_list, params_index); - bool_vector_append(vector->is_rate_list, is_rate_key); - stringlist_append_copy( vector->key_list, key ); + vector->node_index_list.push_back(params_index); + vector->is_rate_list.push_back(is_rate_key); + 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 = (ecl_sum_vector_type*)util_malloc( sizeof * ecl_sum_vector ); + 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; - ecl_sum_vector->node_index_list = int_vector_alloc(0,0); - ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false); - ecl_sum_vector->key_list = stringlist_alloc_new( ); 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 smspec_node_type * node = ecl_smspec_iget_node( smspec , i ); - const char * key = smspec_node_get_gen_key1(node); + const ecl::smspec_node& node = ecl_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); + ecl_sum_vector_add_node( ecl_sum_vector, &node, key); } } return ecl_sum_vector; } static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type * vector, const char * key) { - int_vector_append(vector->node_index_list, -1); - bool_vector_append(vector->is_rate_list, false); - stringlist_append_copy(vector->key_list, key); + vector->node_index_list.push_back(-1); + vector->is_rate_list.push_back(false); + vector->key_list.push_back(key); } @@ -103,8 +99,8 @@ static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type * vector, const c 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); - for (int i=0; i < stringlist_get_size(src_vector->key_list); i++) { - const char * key = stringlist_iget(src_vector->key_list, i); + 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); else @@ -117,7 +113,7 @@ ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type 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 smspec_node_type * node = ecl_sum_get_general_var_node( 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); return true; } else @@ -131,29 +127,29 @@ void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char * int i; for(i = 0; i < num_keywords ;i++){ const char * key = stringlist_iget(keylist, i); - const smspec_node_type * node = ecl_sum_get_general_var_node( 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); } stringlist_free(keylist); } int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector){ - return int_vector_size(ecl_sum_vector->node_index_list); + return ecl_sum_vector->node_index_list.size(); } bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index){ - return bool_vector_iget(ecl_sum_vector->is_rate_list, index); + return ecl_sum_vector->is_rate_list[index]; } bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index) { - return (int_vector_iget(ecl_sum_vector->node_index_list, index) >= 0); + return (ecl_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 int_vector_iget(ecl_sum_vector->node_index_list, index); + return ecl_sum_vector->node_index_list[index]; } const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index){ - return stringlist_iget( ecl_sum_vector->key_list , index); + return ecl_sum_vector->key_list[index].c_str(); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_type.cpp b/ThirdParty/Ert/lib/ecl/ecl_type.cpp index da180467d9..6e0f6dca7c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_type.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_type.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_type.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp b/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp index bd9eb1edde..e30b038d89 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp @@ -53,7 +53,7 @@ int unsmry_loader::length() const { std::vector unsmry_loader::get_vector(int pos) const { if (pos >= size) - throw std::invalid_argument("unsmry_loader::get_vector: argument 'pos' mst be less than size of PARAMS."); + throw std::out_of_range("unsmry_loader::get_vector pos: " + std::to_string(pos) + " PARAMS_SIZE: " + std::to_string(size)); std::vector data(this->length()); int_vector_type * index_map = int_vector_alloc( 1 , pos); diff --git a/ThirdParty/Ert/lib/ecl/ecl_util.cpp b/ThirdParty/Ert/lib/ecl/ecl_util.cpp index fd479ca131..f0ddca45dd 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_util.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_util.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_util.c' is part of ERT - Ensemble based Reservoir Tool. @@ -1290,6 +1290,8 @@ static int ecl_util_get_num_slave_cpu__(basic_parser_type* parser, FILE* stream, const char * first_item = stringlist_iget(tokens, 0); if (first_item[0] == '/') { + stringlist_free(tokens); + free(buffer); break; } else{ diff --git a/ThirdParty/Ert/lib/ecl/fault_block.cpp b/ThirdParty/Ert/lib/ecl/fault_block.cpp index 8ea051204b..11a3452500 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block.cpp +++ b/ThirdParty/Ert/lib/ecl/fault_block.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'fault_block.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp b/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp index c802705d36..3565a02210 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp +++ b/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'fault_block_layer.c' is part of ERT - Ensemble based Reservoir Tool. @@ -67,6 +67,8 @@ fault_block_type * fault_block_layer_add_block( fault_block_layer_type * layer , fault_block_type * block = fault_block_alloc( layer , block_id ); int storage_index = vector_get_size( layer->blocks ); + if (block_id >= int_vector_size(layer->block_map)) + int_vector_resize(layer->block_map, block_id+1, -1); int_vector_iset( layer->block_map , block_id , storage_index ); vector_append_owned_ref( layer->blocks , block , fault_block_free__ ); diff --git a/ThirdParty/Ert/lib/ecl/fortio.c b/ThirdParty/Ert/lib/ecl/fortio.c index ec096364d0..e67c4072cc 100644 --- a/ThirdParty/Ert/lib/ecl/fortio.c +++ b/ThirdParty/Ert/lib/ecl/fortio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'fortio.c' is part of ERT - Ensemble based Reservoir Tool. @@ -30,8 +30,6 @@ #define FORTIO_ID 345116 -extern int errno; - /** The fortio struct is implemented to handle fortran io. The problem is that when a Fortran program writes unformatted data to file in a diff --git a/ThirdParty/Ert/lib/ecl/grid_dims.cpp b/ThirdParty/Ert/lib/ecl/grid_dims.cpp index 7a243f2878..ab5d327403 100644 --- a/ThirdParty/Ert/lib/ecl/grid_dims.cpp +++ b/ThirdParty/Ert/lib/ecl/grid_dims.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'grid_dims.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/layer.cpp b/ThirdParty/Ert/lib/ecl/layer.cpp index 07fe65f50e..3cbcbf5073 100644 --- a/ThirdParty/Ert/lib/ecl/layer.cpp +++ b/ThirdParty/Ert/lib/ecl/layer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'layer.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/nnc_info.cpp b/ThirdParty/Ert/lib/ecl/nnc_info.cpp index d520a985ae..2667303b70 100644 --- a/ThirdParty/Ert/lib/ecl/nnc_info.cpp +++ b/ThirdParty/Ert/lib/ecl/nnc_info.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'nnc_info.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,9 +18,14 @@ #include +#include +#include +#include + #include #include #include +#include #include #include @@ -127,6 +132,8 @@ nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info ) { static void nnc_info_add_vector( nnc_info_type * nnc_info , nnc_vector_type * nnc_vector) { vector_append_owned_ref( nnc_info->lgr_list , nnc_vector , nnc_vector_free__ ); + if (nnc_vector_get_lgr_nr( nnc_vector ) >= int_vector_size( nnc_info->lgr_index_map ) ) + int_vector_resize( nnc_info->lgr_index_map , nnc_vector_get_lgr_nr( nnc_vector)+1, -1); int_vector_iset( nnc_info->lgr_index_map , nnc_vector_get_lgr_nr( nnc_vector ) , vector_get_size( nnc_info->lgr_list ) - 1 ); } @@ -149,27 +156,28 @@ void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_numb } } +bool nnc_info_has_grid_index_list( const nnc_info_type * nnc_info, int lgr_nr ) { + return (nnc_info_get_vector( nnc_info , lgr_nr ) != NULL); +} -const int_vector_type * nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr) { +const std::vector& nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr) { nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr ); - if (nnc_vector) - return nnc_vector_get_grid_index_list( nnc_vector ); - else - return NULL; + if (!nnc_vector) + throw std::invalid_argument(std::string(__func__)); + return nnc_vector_get_grid_index_list( nnc_vector ); } -const int_vector_type * nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index) { +const std::vector& nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index) { nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index ); - if (nnc_vector) - return nnc_vector_get_grid_index_list( nnc_vector ); - else - return NULL; + if (!nnc_vector) + throw std::invalid_argument(std::string(__func__)); + return nnc_vector_get_grid_index_list( nnc_vector ); } -const int_vector_type * nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info) { +const std::vector& nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info) { return nnc_info_get_grid_index_list( nnc_info , nnc_info->lgr_nr ); } @@ -205,8 +213,8 @@ void nnc_info_fprintf(const nnc_info_type * nnc_info , FILE * stream) { if (lgr_index >= 0) { printf(" %02d -> %02d => ",lgr_nr , lgr_index); { - const int_vector_type * index_list = nnc_info_iget_grid_index_list( nnc_info , lgr_index ); - int_vector_fprintf( index_list , stream , " " , "%d"); + const std::vector& index_list = nnc_info_iget_grid_index_list( nnc_info , lgr_index ); + vector_util_fprintf( index_list , stream , " " , "%d"); printf("\n"); } } diff --git a/ThirdParty/Ert/lib/ecl/nnc_vector.cpp b/ThirdParty/Ert/lib/ecl/nnc_vector.cpp index b808faa6e4..be24ffba67 100644 --- a/ThirdParty/Ert/lib/ecl/nnc_vector.cpp +++ b/ThirdParty/Ert/lib/ecl/nnc_vector.cpp @@ -1,6 +1,6 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'nnc_vector.c' is part of ERT - Ensemble based Reservoir Tool. @@ -19,10 +19,11 @@ #include +#include + #include #include #include -#include #include @@ -33,9 +34,9 @@ struct nnc_vector_struct { UTIL_TYPE_ID_DECLARATION; - int lgr_nr; - int_vector_type * grid_index_list; - int_vector_type * nnc_index_list; + int lgr_nr; + std::vector grid_index_list; + std::vector nnc_index_list; }; @@ -45,21 +46,19 @@ static UTIL_SAFE_CAST_FUNCTION(nnc_vector , NNC_VECTOR_TYPE_ID) nnc_vector_type * nnc_vector_alloc(int lgr_nr) { - nnc_vector_type * nnc_vector = (nnc_vector_type*)util_malloc( sizeof * nnc_vector ); + nnc_vector_type * nnc_vector = new nnc_vector_type(); UTIL_TYPE_ID_INIT(nnc_vector , NNC_VECTOR_TYPE_ID); - nnc_vector->grid_index_list = int_vector_alloc(0,0); - nnc_vector->nnc_index_list = int_vector_alloc(0,0); nnc_vector->lgr_nr = lgr_nr; return nnc_vector; } nnc_vector_type * nnc_vector_alloc_copy(const nnc_vector_type * src_vector) { - nnc_vector_type * copy_vector = (nnc_vector_type*)util_malloc( sizeof * src_vector ); + nnc_vector_type * copy_vector = new nnc_vector_type(); UTIL_TYPE_ID_INIT(copy_vector , NNC_VECTOR_TYPE_ID); copy_vector->lgr_nr = src_vector->lgr_nr; - copy_vector->grid_index_list = int_vector_alloc_copy( src_vector->grid_index_list ); - copy_vector->nnc_index_list = int_vector_alloc_copy( src_vector->nnc_index_list ); + copy_vector->grid_index_list = src_vector->grid_index_list; + copy_vector->nnc_index_list = src_vector->nnc_index_list; return copy_vector; } @@ -75,10 +74,10 @@ bool nnc_vector_equal( const nnc_vector_type * nnc_vector1 , const nnc_vector_ty if (nnc_vector1->lgr_nr != nnc_vector2->lgr_nr) return false; - if (!int_vector_equal( nnc_vector1->grid_index_list , nnc_vector2->grid_index_list)) + if (nnc_vector1->grid_index_list != nnc_vector2->grid_index_list) return false; - if (!int_vector_equal( nnc_vector1->nnc_index_list , nnc_vector2->nnc_index_list)) + if (nnc_vector1->nnc_index_list != nnc_vector2->nnc_index_list) return false; return true; @@ -87,9 +86,7 @@ bool nnc_vector_equal( const nnc_vector_type * nnc_vector1 , const nnc_vector_ty void nnc_vector_free( nnc_vector_type * nnc_vector ) { - int_vector_free( nnc_vector->grid_index_list ); - int_vector_free( nnc_vector->nnc_index_list ); - free( nnc_vector ); + delete nnc_vector; } @@ -100,21 +97,21 @@ void nnc_vector_free__(void * arg) { void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number , int nnc_index) { - int_vector_append( nnc_vector->grid_index_list , global_cell_number ); - int_vector_append( nnc_vector->nnc_index_list , nnc_index); + nnc_vector->grid_index_list.push_back( global_cell_number ); + nnc_vector->nnc_index_list.push_back(nnc_index); } -const int_vector_type * nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector) { +const std::vector& nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector) { return nnc_vector->grid_index_list; } -const int_vector_type * nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector) { +const std::vector& nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector) { return nnc_vector->nnc_index_list; } int nnc_vector_get_size( const nnc_vector_type * nnc_vector ) { - return int_vector_size( nnc_vector->grid_index_list ); + return nnc_vector->grid_index_list.size(); } int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) { @@ -122,9 +119,9 @@ int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) { } int nnc_vector_iget_nnc_index( const nnc_vector_type * nnc_vector , int index ) { - return int_vector_iget( nnc_vector->nnc_index_list , index ); + return nnc_vector->nnc_index_list[index]; } int nnc_vector_iget_grid_index( const nnc_vector_type * nnc_vector , int index ) { - return int_vector_iget( nnc_vector->grid_index_list , index ); + return nnc_vector->grid_index_list[index]; } diff --git a/ThirdParty/Ert/lib/ecl/smspec_node.cpp b/ThirdParty/Ert/lib/ecl/smspec_node.cpp index 98bf35b597..ba4e9bfdae 100644 --- a/ThirdParty/Ert/lib/ecl/smspec_node.cpp +++ b/ThirdParty/Ert/lib/ecl/smspec_node.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'smspec_node.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,12 +18,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include @@ -41,6 +43,35 @@ #include "detail/util/string_util.hpp" +/** + 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. + + 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. (What a fucking mess). + + The special_vars list is used in the functions + ecl_smspec_identify_special_var() and ecl_smspec_identify_var_type(). +*/ + +static const char* special_vars[] = {"NEWTON", + "NAIMFRAC", + "NLINEARS", + "NLINSMIN", + "NLINSMAX", + "ELAPSED", + "MAXDPR", + "MAXDSO", + "MAXDSG", + "MAXDSW", + "STEPTYPE", + "WNEWTON"}; + + +static const int nums_unused = 0; /** This struct contains meta-information about one element in the smspec @@ -50,53 +81,166 @@ probably the most important field. */ -#define SMSPEC_TYPE_ID 61550451 +/** + 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 eavulates 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 + from the var name according to standard naming conventions. + It is important that this function is called before the standard + method. +*/ -struct smspec_node_struct { - UTIL_TYPE_ID_DECLARATION; - std::string wgname; - std::string keyword; /* The value of the KEYWORDS vector for this elements. */ - std::string unit; /* The value of the UNITS vector for this elements. */ - int num; /* The value of the NUMS vector for this elements - NB this will have the value SMSPEC_NUMS_INVALID if the smspec file does not have a NUMS vector. */ - std::string lgr_name; /* The lgr name of the current variable - will be NULL for non-lgr variables. */ - std::array lgr_ijk; +ecl_smspec_var_type ecl::smspec_node::identify_special_var( const char * var ) { + ecl_smspec_var_type var_type = ECL_SMSPEC_INVALID_VAR; - /*------------------------------------------- All members below this line are *derived* quantities. */ + 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; + break; + } + } - std::string 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 */ - std::array ijk; /* The ijk coordinates (NB: OFFSET 1) corresponding to the nums value - will be NULL if not relevant. */ - bool rate_variable; /* Is this a rate variable (i.e. WOPR) or a state variable (i.e. BPR). Relevant when doing time interpolation. */ - bool total_variable; /* Is this a total variable like WOPT? */ - bool historical; /* Does the name end with 'H'? */ - 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. */ -}; - - - -bool smspec_node_equal( const smspec_node_type * node1, const smspec_node_type * node2) { - return smspec_node_cmp( node1 , node2 ) == 0; + return var_type; } -static bool smspec_node_need_wgname(ecl_smspec_var_type var_type) { - if (var_type == ECL_SMSPEC_COMPLETION_VAR || - var_type == ECL_SMSPEC_GROUP_VAR || - var_type == ECL_SMSPEC_WELL_VAR || - var_type == ECL_SMSPEC_SEGMENT_VAR) - return true; - else - return false; +/* + See table 3.4 in the ECLIPSE file format reference manual. + + Observe that the combined ecl_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 + 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) { + switch(var[0]) { + case('A'): + var_type = ECL_SMSPEC_AQUIFER_VAR; + break; + case('B'): + var_type = ECL_SMSPEC_BLOCK_VAR; + break; + case('C'): + var_type = ECL_SMSPEC_COMPLETION_VAR; + break; + case('F'): + var_type = ECL_SMSPEC_FIELD_VAR; + break; + case('G'): + var_type = ECL_SMSPEC_GROUP_VAR; + break; + case('L'): + switch(var[1]) { + case('B'): + var_type = ECL_SMSPEC_LOCAL_BLOCK_VAR; + break; + case('C'): + var_type = ECL_SMSPEC_LOCAL_COMPLETION_VAR; + break; + case('W'): + var_type = ECL_SMSPEC_LOCAL_WELL_VAR; + break; + default: + /* + The documentation explicitly mentions keywords starting with + LB, LC and LW as special types, but keywords starting with + L[^BCW] are also valid. These come in the misceallaneous + category; at least the LLINEAR keyword is an example of such + a keyword. + */ + var_type = ECL_SMSPEC_MISC_VAR; + } + break; + case('N'): + var_type = ECL_SMSPEC_NETWORK_VAR; + break; + case('R'): + { + /* + The distinction between regular region variables and region-to-region + variables is less than clear. The manual prescribes a rule based on + the characters at position 3 and 4 or 4 and 5. + + R*FT* => Region to region + R**FT* => Region to region + R*FR* => Region to region + R**FR* => Region to region + + RORFR => exception - normal region var. + + + In addition older test cases seem to imply the following extra + rules/exceptions: + + RNLF: region to region variable + RxF : region to region variable + + The manual does not seem to offer any backup for these extra rules. + */ + + if (strlen(var) == 3 && var[2] == 'F') { + var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + break; + } + + if (util_string_equal( var , "RNLF")) { + var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + break; + } + + if (util_string_equal(var, "RORFR")) { + var_type = ECL_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; + break; + } + } + } + + if (strlen(var) >= 5) { + if (var[3] == 'F') { + if (var[4] == 'T' || var[4] == 'R') { + var_type = ECL_SMSPEC_REGION_2_REGION_VAR; + break; + } + } + } + + var_type = ECL_SMSPEC_REGION_VAR; + } + break; + case('S'): + var_type = ECL_SMSPEC_SEGMENT_VAR; + break; + case('W'): + var_type = ECL_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; + } + } + + return var_type; } -static bool smspec_node_type_supported(ecl_smspec_var_type var_type) { - if (var_type == ECL_SMSPEC_NETWORK_VAR) - return false; - return true; -} + /*****************************************************************/ @@ -123,9 +267,6 @@ static bool smspec_node_type_supported(ecl_smspec_var_type var_type) { #define ECL_SUM_KEYFMT_SEGMENT "%s%s%s%s%d" #define ECL_SUM_KEYFMT_LOCAL_WELL "%s%s%s%s%s" -UTIL_SAFE_CAST_FUNCTION( smspec_node , SMSPEC_TYPE_ID ) -static UTIL_SAFE_CAST_FUNCTION_CONST( smspec_node , SMSPEC_TYPE_ID ) - 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, @@ -188,7 +329,7 @@ std::string smspec_alloc_completion_ijk_key( const char * join_string , const st join_string , i , j , k ); else - return std::string(); + return NULL; } @@ -202,7 +343,7 @@ std::string smspec_alloc_completion_num_key( const char * join_string , const st join_string , num ); else - return std::string(); + return NULL; } /* @@ -265,7 +406,7 @@ std::string smspec_alloc_segment_key( const char * join_string , const std::stri join_string , num ); else - return std::string(); + return NULL; } @@ -278,7 +419,7 @@ std::string smspec_alloc_local_well_key( const char * join_string , const std::s join_string , wgname.c_str()); else - return std::string(); + return NULL; } std::string smspec_alloc_local_completion_key( const char * join_string, const std::string& keyword , const std::string& lgr_name , const std::string& wgname , int i , int j , int k) { @@ -292,32 +433,15 @@ std::string smspec_alloc_local_completion_key( const char * join_string, const s join_string , i,j,k); else - return std::string(); + return NULL; } /*****************************************************************/ -static void smspec_node_set_keyword( smspec_node_type * smspec_node , const std::string& keyword ) { - // ECLIPSE Standard: Max eight characters - everything beyond is silently dropped - // This function can __ONLY__ be called on time; run-time chaning of keyword is not - // allowed. - if (smspec_node->keyword.size() == 0) - smspec_node->keyword = keyword; - else - util_abort("%s: fatal error - attempt to change keyword runtime detected - aborting\n",__func__); -} - - -static void smspec_node_set_invalid_flags( smspec_node_type * smspec_node) { - smspec_node->rate_variable = false; - smspec_node->total_variable = false; - smspec_node->historical = false; -} - - bool smspec_node_identify_rate(const char * keyword) { - const char *rate_vars[] = {"OPR" , "GPR" , "WPR" , "LPR", "OIR", "GIR", "WIR", "LIR", "GOR" , "WCT"}; + const char *rate_vars[] = {"OPR" , "GPR" , "WPR" , "LPR", "OIR", "GIR", "WIR", "LIR", "GOR" , "WCT", + "OFR" , "GFR" , "WFR"}; int num_rate_vars = sizeof( rate_vars ) / sizeof( rate_vars[0] ); bool is_rate = false; int ivar; @@ -369,104 +493,76 @@ bool smspec_node_identify_total(const char * keyword, ecl_smspec_var_type var_ty } } } + else if (var_type == ECL_SMSPEC_SEGMENT_VAR) { + const char *total_vars[] = {"OFT", "GFT", "WFT"}; + const char *var_substring = &keyword[1]; + const size_t num_total_vars = sizeof(total_vars) / sizeof(total_vars[0]); + for (size_t ivar = 0; ivar < num_total_vars; ivar++) + if (strncmp(total_vars[ivar], var_substring, strlen(total_vars[ivar])) == 0) { + is_total = true; + break; + } + } return is_total; } -static void smspec_node_set_flags( smspec_node_type * smspec_node) { - /* - Check if this is a rate variabel - that info is used when - interpolating results to true_time between ministeps. - */ - smspec_node->rate_variable = smspec_node_identify_rate(smspec_node->keyword.c_str()); - if (smspec_node->keyword.back() == 'H') - smspec_node->historical = true; - smspec_node->total_variable = smspec_node_identify_total(smspec_node->keyword.c_str(), smspec_node->var_type); +namespace ecl { + + + +float smspec_node::get_default() const { + return this->default_value; } -/** - It is possible to change the default value of an smspec node - runtime, but observe that the new value will only be applied to the - new timesteps you add after the change. Already created timesteps - will not be updated if the default value is changed. + +void smspec_node::set_lgr_ijk( int lgr_i , int lgr_j , int lgr_k) { + lgr_ijk[0] = lgr_i; + lgr_ijk[1] = lgr_j; + lgr_ijk[2] = lgr_k; +} + + +/* + Observe that field vectors like 'FOPT' and 'FOPR' will have the string 'FIELD' + in the 'WGNAME' vector, that is not internalized here. */ -void smspec_node_set_default( smspec_node_type * smspec_node , float default_value) { - smspec_node->default_value = default_value; + +void smspec_node::set_wgname(const char * wgname) { + if (!wgname) + return; + + 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) + this->wgname = wgname; } - -float smspec_node_get_default( const smspec_node_type * smspec_node ) { - return smspec_node->default_value; -} - - -smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) { - smspec_node_type * node = new smspec_node_type(); - - UTIL_TYPE_ID_INIT( node , SMSPEC_TYPE_ID); - node->params_index = params_index; - smspec_node_set_default( node , default_value ); - - node->var_type = ECL_SMSPEC_INVALID_VAR; - smspec_node_set_invalid_flags( node ); - return node; // This is NOT usable -} - - -static void smspec_node_set_wgname( smspec_node_type * index , const char * wgname ) { - index->wgname = wgname; -} - - - -static void smspec_node_set_lgr_name( smspec_node_type * index , const std::string& lgr_name ) { - index->lgr_name = lgr_name; -} - - -static void smspec_node_set_lgr_ijk( smspec_node_type * index , int lgr_i , int lgr_j , int lgr_k) { - index->lgr_ijk[0] = lgr_i; - index->lgr_ijk[1] = lgr_j; - index->lgr_ijk[2] = lgr_k; -} - - -static void smspec_node_init_num( smspec_node_type * node , ecl_smspec_var_type var_type) { - switch( node->var_type ) { - case(ECL_SMSPEC_WELL_VAR): - node->num = SMSPEC_NUMS_WELL; - break; - case(ECL_SMSPEC_GROUP_VAR): - node->num = SMSPEC_NUMS_GROUP; - break; - case(ECL_SMSPEC_FIELD_VAR): - node->num = SMSPEC_NUMS_FIELD; - break; - default: - node->num = SMSPEC_NUMS_INVALID; - } -} -static void smspec_node_set_num( smspec_node_type * index , const int grid_dims[3] , int num) { - if (num == SMSPEC_NUMS_INVALID) +void smspec_node::set_num( const int * grid_dims , int num_) { + if (num_ == SMSPEC_NUMS_INVALID) util_abort("%s: explicitly trying to set nums == SMSPEC_NUMS_INVALID - seems like a bug?!\n",__func__); + this->num = num_; + if ((var_type == ECL_SMSPEC_COMPLETION_VAR) || (var_type == ECL_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]); + this->ijk[1] = global_index / grid_dims[0] ; global_index -= this->ijk[1] * grid_dims[0]; + this->ijk[0] = global_index; - index->num = num; - if ((index->var_type == ECL_SMSPEC_COMPLETION_VAR) || (index->var_type == ECL_SMSPEC_BLOCK_VAR)) { - int global_index = num - 1; - index->ijk[2] = global_index / ( grid_dims[0] * grid_dims[1] ); global_index -= index->ijk[2] * (grid_dims[0] * grid_dims[1]); - index->ijk[1] = global_index / grid_dims[0] ; global_index -= index->ijk[1] * grid_dims[0]; - index->ijk[0] = global_index; - - index->ijk[0] += 1; - index->ijk[1] += 1; - index->ijk[2] += 1; + this->ijk[0] += 1; + this->ijk[1] += 1; + this->ijk[2] += 1; } } -static void smspec_node_decode_R1R2( const smspec_node_type * smspec_node , int * r1 , int * r2) { - if (smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { - *r1 = smspec_node->num % 32768; - *r2 = ((smspec_node->num - (*r1)) / 32768)-10; +void smspec_node::decode_R1R2(int * r1 , int * r2) const { + if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { + *r1 = this->num % 32768; + *r2 = ((this->num - (*r1)) / 32768)-10; } else { *r1 = -1; *r2 = -1; @@ -485,78 +581,67 @@ static void smspec_node_decode_R1R2( const smspec_node_type * smspec_node , int */ -static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const char * key_join_string) { - switch( smspec_node->var_type) { +void smspec_node::set_gen_keys( const char* key_join_string_) { + switch( var_type) { case(ECL_SMSPEC_COMPLETION_VAR): // KEYWORD:WGNAME:NUM - smspec_node->gen_key1 = smspec_alloc_completion_ijk_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->ijk[0], smspec_node->ijk[1], smspec_node->ijk[2]); - smspec_node->gen_key2 = smspec_alloc_completion_num_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num); + gen_key1 = smspec_alloc_completion_ijk_key( key_join_string_ , keyword , wgname , ijk[0], ijk[1], ijk[2]); + gen_key2 = smspec_alloc_completion_num_key( key_join_string_ , keyword , wgname , num); break; case(ECL_SMSPEC_FIELD_VAR): // KEYWORD - smspec_node->gen_key1 = util_alloc_string_copy( smspec_node->keyword.c_str() ); + gen_key1 = keyword; break; case(ECL_SMSPEC_GROUP_VAR): // KEYWORD:WGNAME - smspec_node->gen_key1 = smspec_alloc_group_key( key_join_string , smspec_node->keyword , smspec_node->wgname); + gen_key1 = smspec_alloc_group_key( key_join_string_ , keyword , wgname); break; case(ECL_SMSPEC_WELL_VAR): // KEYWORD:WGNAME - smspec_node->gen_key1 = smspec_alloc_well_key( key_join_string , smspec_node->keyword , smspec_node->wgname); + gen_key1 = smspec_alloc_well_key( key_join_string_ , keyword , wgname); break; case(ECL_SMSPEC_REGION_VAR): // KEYWORD:NUM - smspec_node->gen_key1 = smspec_alloc_region_key( key_join_string , smspec_node->keyword , smspec_node->num); + gen_key1 = smspec_alloc_region_key( key_join_string_ , keyword , num); break; case (ECL_SMSPEC_SEGMENT_VAR): // KEYWORD:WGNAME:NUM - smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num); + gen_key1 = smspec_alloc_segment_key( key_join_string_ , keyword , wgname , num); break; case(ECL_SMSPEC_REGION_2_REGION_VAR): // KEYWORDS:RXF:NUM and RXF:R1-R2 { int r1,r2; - smspec_node_decode_R1R2( smspec_node , &r1 , &r2); - smspec_node->gen_key1 = smspec_alloc_region_2_region_r1r2_key( key_join_string , smspec_node->keyword , r1, r2); + decode_R1R2( &r1 , &r2); + gen_key1 = smspec_alloc_region_2_region_r1r2_key( key_join_string_ , keyword , r1, r2); } - smspec_node->gen_key2 = smspec_alloc_region_2_region_num_key( key_join_string , smspec_node->keyword , smspec_node->num); + gen_key2 = smspec_alloc_region_2_region_num_key( key_join_string_ , keyword , num); break; case(ECL_SMSPEC_MISC_VAR): // KEYWORD /* Misc variable - i.e. date or CPU time ... */ - smspec_node->gen_key1 = smspec_node->keyword; + gen_key1 = keyword; break; case(ECL_SMSPEC_BLOCK_VAR): // KEYWORD:NUM - smspec_node->gen_key1 = smspec_alloc_block_ijk_key( key_join_string , smspec_node->keyword , smspec_node->ijk[0], smspec_node->ijk[1], smspec_node->ijk[2]); - smspec_node->gen_key2 = smspec_alloc_block_num_key( key_join_string , smspec_node->keyword , smspec_node->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): /** KEYWORD:LGR:WGNAME */ - smspec_node->gen_key1 = smspec_alloc_local_well_key( key_join_string , smspec_node->keyword , smspec_node->lgr_name , smspec_node->wgname); + gen_key1 = smspec_alloc_local_well_key( key_join_string_ , keyword , lgr_name , wgname); break; case(ECL_SMSPEC_LOCAL_BLOCK_VAR): /* KEYWORD:LGR:i,j,k */ - smspec_node->gen_key1 = smspec_alloc_local_block_key( key_join_string , - smspec_node->keyword , - smspec_node->lgr_name , - smspec_node->lgr_ijk[0] , - smspec_node->lgr_ijk[1] , - smspec_node->lgr_ijk[2] ); + 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): /* KEYWORD:LGR:WELL:i,j,k */ - smspec_node->gen_key1 = smspec_alloc_local_completion_key( key_join_string , - smspec_node->keyword , - smspec_node->lgr_name , - smspec_node->wgname , - smspec_node->lgr_ijk[0], - smspec_node->lgr_ijk[1], - smspec_node->lgr_ijk[2]); + gen_key1 = 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): - smspec_node->gen_key1 = smspec_alloc_aquifer_key( key_join_string , smspec_node->keyword , smspec_node->num); + gen_key1 = smspec_alloc_aquifer_key( key_join_string_ , keyword , num); break; default: util_abort("%s: internal error - should not be here? \n" , __func__); @@ -564,123 +649,79 @@ static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const cha } +/* + Observe the following: -static void smspec_node_common_init( smspec_node_type * node , ecl_smspec_var_type var_type , const char * keyword , const std::string& unit ) { - if (node->var_type == ECL_SMSPEC_INVALID_VAR) { - smspec_node_set_unit( node , unit.c_str() ); - smspec_node_set_keyword( node , keyword); - node->var_type = var_type; - smspec_node_set_flags( node ); - smspec_node_init_num( node , var_type ); - } else - util_abort("%s: trying to re-init smspec node with keyword:%s - invalid \n",__func__ , keyword ); -} + 1. There are many legitimate value types here which we do not handle, then we + just return false. + 2. Observe that the LGR variables are not thoroughly checked; the only check + is that the well is not the dummy well. Experience has shown that there has + not been problems with SMSPEC files with invalid LGR and LGRIJK values; + that is therefor just assumed to be right. -static bool smspec_node_init__( smspec_node_type * smspec_node, - ecl_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) { +*/ - bool initOK = true; +ecl_smspec_var_type smspec_node::valid_type(const char * keyword, const char * wgname, int num) { + auto var_type = smspec_node::identify_var_type(keyword); - smspec_node_common_init( smspec_node , var_type , keyword , unit ); - switch (var_type) { - case(ECL_SMSPEC_COMPLETION_VAR): - /* Completion variable : WGNAME & NUM */ - smspec_node_set_num( smspec_node , grid_dims , num ); - smspec_node_set_wgname( smspec_node , wgname ); - if (num < 0) - initOK = false; - break; - case(ECL_SMSPEC_GROUP_VAR): - /* Group variable : WGNAME */ - smspec_node_set_wgname( smspec_node , wgname ); - break; - case(ECL_SMSPEC_WELL_VAR): - /* Well variable : WGNAME */ - smspec_node_set_wgname( smspec_node , wgname ); - break; - case(ECL_SMSPEC_SEGMENT_VAR): - smspec_node_set_wgname( smspec_node , wgname ); - smspec_node_set_num( smspec_node , grid_dims , num ); - if (num < 0) - initOK = false; - break; - case(ECL_SMSPEC_FIELD_VAR): - /* Field variable : */ - /* Fully initialized with the smspec_common_init() function */ - break; - case(ECL_SMSPEC_REGION_VAR): - /* Region variable : NUM */ - smspec_node_set_num( smspec_node , grid_dims , num ); - break; - case(ECL_SMSPEC_REGION_2_REGION_VAR): - /* Region 2 region variable : NUM */ - smspec_node_set_num( smspec_node , grid_dims , num ); - break; - case(ECL_SMSPEC_BLOCK_VAR): - /* A block variable : NUM*/ - smspec_node_set_num( smspec_node , grid_dims , num ); - break; - case(ECL_SMSPEC_MISC_VAR): - /* Misc variable : */ + if (var_type == ECL_SMSPEC_MISC_VAR) + return var_type; + + if (var_type == ECL_SMSPEC_FIELD_VAR) + return var_type; + + if (var_type == ECL_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 (IS_DUMMY_WELL(wgname)) + return ECL_SMSPEC_INVALID_VAR; /* - For some keywords the SMSPEC files generated by Eclipse have a - non zero NUMS value although; it seems that value is required - for the generatd summaryfiles to display nicely in - e.g. S3GRAF. + In most cases the dummy well ':+:+:+:+' is used in situations where a + well/group name does not make sense; however we have also encountered the + blank string as an invalid well name; when this is trimmed we get NULL (C) + or "" (C++). */ - if (util_string_equal( keyword ,SMSPEC_TIME_KEYWORD)) - smspec_node_set_num( smspec_node , grid_dims , SMSPEC_TIME_NUMS_VALUE ); + if (!wgname) + return ECL_SMSPEC_INVALID_VAR; - if (util_string_equal( keyword ,SMSPEC_YEARS_KEYWORD)) - smspec_node_set_num( smspec_node , grid_dims , SMSPEC_YEARS_NUMS_VALUE ); + if (strlen(wgname) == 0) + return ECL_SMSPEC_INVALID_VAR; - break; - case(ECL_SMSPEC_AQUIFER_VAR): - smspec_node_set_num( smspec_node , grid_dims , num ); - break; - default: - /* Lots of legitimate alternatives which are not internalized. */ - initOK = false; - break; + return var_type; } - if (initOK) - smspec_node_set_gen_keys( smspec_node , key_join_string ); + if (var_type == ECL_SMSPEC_COMPLETION_VAR || var_type == ECL_SMSPEC_SEGMENT_VAR) { + if (IS_DUMMY_WELL(wgname)) + return ECL_SMSPEC_INVALID_VAR; - return initOK; + if (num < 0) + return ECL_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 (num < 0) + return ECL_SMSPEC_INVALID_VAR; + + return var_type; + } + + return ECL_SMSPEC_INVALID_VAR; } -/* - This function should be removed from the public API. -*/ -void smspec_node_init( smspec_node_type * smspec_node, - ecl_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) { - smspec_node_init__(smspec_node, - var_type, - wgname, - keyword, - unit, - key_join_string, - grid_dims, - num); - -} /** This function will allocate a smspec_node instance, and initialize @@ -696,15 +737,83 @@ void smspec_node_init( smspec_node_type * smspec_node, ecl_smspec_fread_header() functions in addition. UGGGLY */ +smspec_node::smspec_node(int param_index, const char * keyword, int num, const char * unit, const int grid_dims[3], float default_value, const char * key_join_string) + : smspec_node(param_index, + keyword, + nullptr, + num, + unit, + grid_dims, + default_value, + key_join_string) +{ +} + +smspec_node::smspec_node(int param_index, const char * keyword, int num, const char * unit, float default_value, const char * key_join_string) + : smspec_node(param_index, + keyword, + nullptr, + num, + unit, + nullptr, + default_value, + key_join_string) +{ +} -smspec_node_type * smspec_node_alloc( ecl_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 , int param_index, float default_value) { + +smspec_node::smspec_node(int param_index, const char * keyword, const char * wgname, const char * unit, float default_value, const char * key_join_string) + : smspec_node(param_index, + keyword, + wgname, + nums_unused, + unit, + nullptr, + default_value, + key_join_string) +{ +} + +smspec_node::smspec_node(int param_index, const char * keyword, const char * wgname, int num, const char * unit, float default_value, const char * key_join_string) + : smspec_node(param_index, + keyword, + wgname, + num, + unit, + nullptr, + default_value, + key_join_string) +{} + + +smspec_node::smspec_node(int param_index, const char * keyword, const char * unit, float default_value) + : smspec_node(param_index, + keyword, + nullptr, + nums_unused, + unit, + nullptr, + default_value, + nullptr) +{ +} + +//copy constructor with a new id +smspec_node::smspec_node(const smspec_node& node, int param_index) +{ + *this = node; + this->params_index = param_index; +} + +smspec_node::smspec_node(int param_index, + const char * keyword, + const char * wgname , + int num, + const char * unit , + const int grid_dims[3] , + float default_value, + const char * key_join_string) { /* Well and group names in the wgname parameter is quite messy. The situation is as follows: @@ -734,132 +843,129 @@ smspec_node_type * smspec_node_alloc( ecl_smspec_var_type var_type , at all, e.g. like "FOPT" - the wgname input value is ignored completely. */ + this->var_type = this->valid_type(keyword, wgname, num); + if (this->var_type == ECL_SMSPEC_INVALID_VAR) + throw std::invalid_argument("Could not construct smspec_node from this input."); - if (smspec_node_need_wgname(var_type) && IS_DUMMY_WELL(wgname)) - return NULL; + this->params_index = param_index; + this->default_value = default_value; + this->keyword = keyword; + this->num = num; + this->unit = unit; + this->rate_variable = smspec_node_identify_rate(this->keyword.c_str()); + this->total_variable = smspec_node_identify_total(this->keyword.c_str(), this->var_type); + this->historical = (this->keyword.back() == 'H'); + this->set_wgname( wgname ); - if (!smspec_node_type_supported(var_type)) - return NULL; - - /* - TODO: The alloc_new and init functions should be joined in one function. - */ - smspec_node_type * smspec_node = smspec_node_alloc_new( param_index , default_value ); - bool initOK = smspec_node_init__( smspec_node , var_type , wgname , keyword , unit , key_join_string , grid_dims, num); - if (!initOK) { - smspec_node_free(smspec_node); - smspec_node = NULL; - } - - return smspec_node; -} - - - -static void smspec_node_init_lgr( smspec_node_type * smspec_node , - ecl_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 - ) { - bool initOK = true; - bool wgnameOK = true; - if ((wgname != NULL) && (IS_DUMMY_WELL(wgname))) - wgnameOK = false; - - smspec_node_common_init( smspec_node , var_type , keyword , unit ); - switch (var_type) { - case(ECL_SMSPEC_LOCAL_WELL_VAR): - smspec_node_set_wgname( smspec_node , wgname ); - smspec_node_set_lgr_name( smspec_node , lgr ); - initOK = wgnameOK; + switch (this->var_type) { + case(ECL_SMSPEC_COMPLETION_VAR): + /* Completion variable : WGNAME & NUM */ + set_num( grid_dims , num ); break; - case(ECL_SMSPEC_LOCAL_BLOCK_VAR): - smspec_node_set_lgr_name( smspec_node , lgr ); - smspec_node_set_lgr_ijk( smspec_node , lgr_i, lgr_j , lgr_k ); + case(ECL_SMSPEC_GROUP_VAR): + /* Group variable : WGNAME */ break; - case(ECL_SMSPEC_LOCAL_COMPLETION_VAR): - smspec_node_set_lgr_name( smspec_node , lgr ); - smspec_node_set_wgname( smspec_node , wgname ); - smspec_node_set_lgr_ijk( smspec_node , lgr_i, lgr_j , lgr_k ); - initOK = wgnameOK; + case(ECL_SMSPEC_WELL_VAR): + /* Well variable : WGNAME */ + break; + case(ECL_SMSPEC_SEGMENT_VAR): + set_num( grid_dims , num ); + break; + case(ECL_SMSPEC_FIELD_VAR): + /* Field variable : */ + /* Fully initialized with the smspec_common_init() function */ + break; + case(ECL_SMSPEC_REGION_VAR): + /* Region variable : NUM */ + set_num( grid_dims , num ); + break; + case(ECL_SMSPEC_REGION_2_REGION_VAR): + /* Region 2 region variable : NUM */ + set_num( grid_dims , num ); + break; + case(ECL_SMSPEC_BLOCK_VAR): + /* A block variable : NUM*/ + set_num( grid_dims , num ); + break; + case(ECL_SMSPEC_MISC_VAR): + /* Misc variable : */ + + /* + For some keywords the SMSPEC files generated by Eclipse have a + non zero NUMS value although; it seems that value is required + for the generatd summaryfiles to display nicely in + e.g. S3GRAF. + */ + + if (this->keyword == std::string(SMSPEC_TIME_KEYWORD)) + set_num( grid_dims , SMSPEC_TIME_NUMS_VALUE ); + + if (this->keyword == std::string(SMSPEC_YEARS_KEYWORD)) + set_num( grid_dims , SMSPEC_YEARS_NUMS_VALUE ); + + break; + case(ECL_SMSPEC_AQUIFER_VAR): + set_num( grid_dims , num ); break; default: - util_abort("%s: internal error: in LGR function with non-LGR keyword:%s \n",__func__ , keyword); + throw std::invalid_argument("Should not be here ... "); + break; + } + set_gen_keys( key_join_string ); +} + +smspec_node::smspec_node( int param_index_, + const char * keyword_ , + const char * wgname_ , + const char * unit_ , + const char * lgr_ , + int lgr_i, int lgr_j , int lgr_k, + 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) + throw std::invalid_argument("Could not construct smspec_node from this input."); + + this->params_index = param_index_; + this->default_value = default_value_; + this->keyword = keyword_; + this->wgname = wgname_; + this->unit = unit_; + this->rate_variable = smspec_node_identify_rate(this->keyword.c_str()); + this->total_variable = smspec_node_identify_total(this->keyword.c_str(), this->var_type); + this->historical = (this->keyword.back() == 'H'); + this->lgr_name = lgr_; + this->num = nums_unused; + + switch (this->var_type) { + case(ECL_SMSPEC_LOCAL_WELL_VAR): + break; + case(ECL_SMSPEC_LOCAL_BLOCK_VAR): + set_lgr_ijk( lgr_i, lgr_j , lgr_k ); + break; + case(ECL_SMSPEC_LOCAL_COMPLETION_VAR): + set_lgr_ijk( lgr_i, lgr_j , lgr_k ); + break; + default: + throw std::invalid_argument("Should not be here .... "); } - if (initOK) - smspec_node_set_gen_keys( smspec_node , key_join_string ); + set_gen_keys( key_join_string_ ); } -smspec_node_type * smspec_node_alloc_lgr( ecl_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) { - - smspec_node_type * smspec_node = smspec_node_alloc_new( param_index , default_value ); - smspec_node_init_lgr( smspec_node , var_type , wgname , keyword , unit , lgr , key_join_string , lgr_i, lgr_j , lgr_k); - return smspec_node; -} - -smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) { - - if( !node ) return NULL; - - { - smspec_node_type * copy = new smspec_node_type(); - UTIL_TYPE_ID_INIT( copy, SMSPEC_TYPE_ID ); - copy->gen_key1 = node->gen_key1; - copy->gen_key2 = node->gen_key2; - copy->var_type = node->var_type; - copy->wgname = node->wgname; - copy->keyword = node->keyword; - copy->unit = node->unit; - copy->num = node->num; - copy->ijk = node->ijk; - copy->lgr_name = node->lgr_name; - copy->lgr_ijk = node->lgr_ijk; - - copy->rate_variable = node->rate_variable; - copy->total_variable = node->total_variable; - copy->historical = node->historical; - copy->params_index = node->params_index; - copy->default_value = node->default_value; - return copy; - } -} - -void smspec_node_free( smspec_node_type * index ) { - delete index; -} - -void smspec_node_free__( void * arg ) { - smspec_node_type * node = smspec_node_safe_cast( arg ); - smspec_node_free( node ); -} - /*****************************************************************/ - - -int smspec_node_get_params_index( const smspec_node_type * smspec_node ) { - return smspec_node->params_index; +int smspec_node::get_params_index() const { + return this->params_index; } - -void smspec_node_set_params_index( smspec_node_type * smspec_node , int params_index) { - smspec_node->params_index = params_index; -} +// void smspec_node::set_params_index( int params_index_) { + // this->params_index = params_index_; +// } namespace { @@ -873,69 +979,60 @@ namespace { } -const char * smspec_node_get_gen_key1( const smspec_node_type * smspec_node) { - return get_cstring( smspec_node->gen_key1 ); + +const char * smspec_node::get_gen_key1() const { + return get_cstring( this->gen_key1 ); } -const char * smspec_node_get_gen_key2( const smspec_node_type * smspec_node) { - return get_cstring( smspec_node->gen_key2 ); +const char * smspec_node::get_gen_key2() const { + return get_cstring( this->gen_key2 ); } - -const char * smspec_node_get_wgname( const smspec_node_type * smspec_node) { - return get_cstring( smspec_node->wgname ); +const char * smspec_node::get_wgname() const { + return get_cstring( this->wgname ); } -const char * smspec_node_get_keyword( const smspec_node_type * smspec_node) { - return get_cstring( smspec_node->keyword ); +const char * smspec_node::get_keyword() const { + return get_cstring( this->keyword ); } - - -ecl_smspec_var_type smspec_node_get_var_type( const smspec_node_type * smspec_node) { - return smspec_node->var_type; +ecl_smspec_var_type smspec_node::get_var_type() const { + return this->var_type; } -int smspec_node_get_num( const smspec_node_type * smspec_node) { - return smspec_node->num; +int smspec_node::get_num() const { + return this->num; } -bool smspec_node_is_rate( const smspec_node_type * smspec_node ) { - return smspec_node->rate_variable; +bool smspec_node::is_rate() const { + return this->rate_variable; } - -bool smspec_node_is_total( const smspec_node_type * smspec_node ){ - return smspec_node->total_variable; +bool smspec_node::is_total() const { + return this->total_variable; } -bool smspec_node_is_historical( const smspec_node_type * smspec_node ){ - return smspec_node->historical; +bool smspec_node::is_historical() const { + return this->historical; } -const char * smspec_node_get_unit( const smspec_node_type * smspec_node) { - return smspec_node->unit.c_str(); -} - -void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit) { - // ECLIPSE Standard: Max eight characters - everything beyond is silently dropped - std::string tmp = unit; - smspec_node->unit = tmp.substr(0,8); +const char * smspec_node::get_unit() const { + return this->unit.c_str(); } // Will be garbage for smspec_nodes which do not have i,j,k -const int* smspec_node_get_ijk( const smspec_node_type * smspec_node ) { - return smspec_node->ijk.data(); +const std::array& smspec_node::get_ijk() const { + return this->ijk; } // Will be NULL for smspec_nodes which are not related to an LGR. -const char* smspec_node_get_lgr_name( const smspec_node_type * smspec_node ) { - return smspec_node->lgr_name.c_str(); +const char * smspec_node::get_lgr_name() const { + return get_cstring(this->lgr_name); } // Will be garbage for smspec_nodes which are not related to an LGR. -const int* smspec_node_get_lgr_ijk( const smspec_node_type * smspec_node ) { - return smspec_node->lgr_ijk.data(); +const std::array& smspec_node::get_lgr_ijk() const { + return this->lgr_ijk; } /* @@ -943,41 +1040,41 @@ const int* smspec_node_get_lgr_ijk( const smspec_node_type * smspec_node ) { of type ECL_SMSPEC_REGION_2_REGION_VAR. */ -int smspec_node_get_R1( const smspec_node_type * smspec_node ) { - if (smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { +int smspec_node::get_R1() const { + if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { int r1,r2; - smspec_node_decode_R1R2( smspec_node , &r1 , &r2); + decode_R1R2( &r1 , &r2); return r1; } else return -1; } -int smspec_node_get_R2( const smspec_node_type * smspec_node ) { - if (smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { +int smspec_node::get_R2() const { + if (var_type == ECL_SMSPEC_REGION_2_REGION_VAR) { int r1,r2; - smspec_node_decode_R1R2( smspec_node , &r1 , &r2); + decode_R1R2( &r1 , &r2); return r2; } else return -1; } -bool smspec_node_need_nums( const smspec_node_type * smspec_node ) { +bool smspec_node::need_nums() const { /* Check if this node needs the nums field; if at least one of the nodes need the NUMS field must be stored when writing a SMSPEC file. */ { - if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR || - smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR || - smspec_node->var_type == ECL_SMSPEC_REGION_VAR || - smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR || - smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR || - smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR) + 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) return true; else { - if (smspec_node->num == SMSPEC_NUMS_INVALID) + if (this->num == SMSPEC_NUMS_INVALID) return false; else return true; @@ -986,46 +1083,22 @@ bool smspec_node_need_nums( const smspec_node_type * smspec_node ) { } -void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream) { - fprintf(stream, "KEYWORD: %s \n",smspec_node->keyword.c_str()); - fprintf(stream, "WGNAME : %s \n",smspec_node->wgname.c_str()); - fprintf(stream, "UNIT : %s \n",smspec_node->unit.c_str()); - fprintf(stream, "TYPE : %d \n",smspec_node->var_type); - fprintf(stream, "NUM : %d \n\n",smspec_node->num); -} - - -static bool smspec_node_equal_MISC( const smspec_node_type * node1, const smspec_node_type * node2) { - return node1->keyword == node2->keyword; +void smspec_node::fprintf__( FILE * stream) const { + fprintf(stream, "KEYWORD: %s \n", this->keyword.c_str()); + fprintf(stream, "WGNAME : %s \n", this->wgname.c_str()); + fprintf(stream, "UNIT : %s \n", this->unit.c_str()); + fprintf(stream, "TYPE : %d \n", this->var_type); + fprintf(stream, "NUM : %d \n\n", this->num); } +namespace { /* MISC variables are generally sorted to the end of the list, but some special case variables come at the very beginning. */ -static int smspec_node_cmp_MISC( const smspec_node_type * node1, const smspec_node_type * node2) { - static const std::set early_vars = {"TIME", "DAYS", "DAY", "MONTH", "YEAR", "YEARS"}; - - if (smspec_node_equal_MISC( node1, node2) ) - return 0; - - bool node1_early = !( early_vars.find(node1->keyword) == early_vars.end() ); - bool node2_early = !( early_vars.find(node2->keyword) == early_vars.end() ); - - - if (node1_early && !node2_early) - return -1; - - if (!node1_early && node2_early) - return 1; - - return node1->keyword.compare(node2->keyword); -} - - -static int int_cmp(int v1, int v2) { +int int_cmp(int v1, int v2) { if (v1 < v2) return -1; @@ -1035,174 +1108,354 @@ static int int_cmp(int v1, int v2) { return 0; } -static int smspec_node_cmp_LGRIJK( const smspec_node_type * node1, const smspec_node_type * node2) { - int i_cmp = int_cmp( node1->lgr_ijk[0] , node2->lgr_ijk[0]); + +int cmp_MISC( const smspec_node& node1, const smspec_node& node2) { + static const std::set early_vars = {"TIME", "DAYS", "DAY", "MONTH", "YEAR", "YEARS"}; + + if (&node1 == &node2) + return 0; + + bool node1_early = !( early_vars.find(node1.get_keyword()) == early_vars.end() ); + bool node2_early = !( early_vars.find(node2.get_keyword()) == early_vars.end() ); + + + if (node1_early && !node2_early) + return -1; + + if (!node1_early && node2_early) + return 1; + + return strcmp(node1.get_keyword(), node2.get_keyword()); +} + + +int cmp_LGRIJK( const smspec_node& node1, const smspec_node& node2) { + const auto& ijk1 = node1.get_lgr_ijk(); + const auto& ijk2 = node2.get_lgr_ijk(); + + int i_cmp = int_cmp( ijk1[0] , ijk2[0]); if (i_cmp != 0) return i_cmp; - int j_cmp = int_cmp( node1->lgr_ijk[1] , node2->lgr_ijk[1]); + int j_cmp = int_cmp(ijk1[1] , ijk2[1]); if (j_cmp != 0) return j_cmp; - return int_cmp( node1->lgr_ijk[2] , node2->lgr_ijk[2]); + return int_cmp( ijk1[2] , ijk2[2]); } - -static int smspec_node_cmp_KEYWORD_LGR_LGRIJK( const smspec_node_type * node1, const smspec_node_type * node2) { - int keyword_cmp = node1->keyword.compare(node2->keyword); +int cmp_KEYWORD_LGR_LGRIJK( const smspec_node& node1, const smspec_node& node2) { + int keyword_cmp = strcmp(node1.get_keyword(), node2.get_keyword()); if (keyword_cmp != 0) return keyword_cmp; - int lgr_cmp = node1->lgr_name.compare( node2->lgr_name ); + int lgr_cmp = strcmp(node1.get_lgr_name(), node2.get_lgr_name()); if (lgr_cmp != 0) return lgr_cmp; - return smspec_node_cmp_LGRIJK( node1, node2); + return cmp_LGRIJK( node1, node2); } - -static int smspec_node_cmp_KEYWORD_WGNAME_NUM( const smspec_node_type * node1, const smspec_node_type * node2) { - int keyword_cmp = node1->keyword.compare(node2->keyword); +int cmp_KEYWORD_WGNAME_NUM(const smspec_node& node1, const smspec_node& node2) { + int keyword_cmp = strcmp(node1.get_keyword(), node2.get_keyword()); if (keyword_cmp != 0) return keyword_cmp; - int wgname_cmp = node1->wgname.compare(node2->wgname); + int wgname_cmp = strcmp(node1.get_wgname(), node2.get_wgname()); if (wgname_cmp != 0) return wgname_cmp; - return int_cmp( node1->num , node2->num); + return int_cmp( node1.get_num() , node2.get_num()); } -static int smspec_node_cmp_KEYWORD_WGNAME_LGR( const smspec_node_type * node1, const smspec_node_type * node2) { - int keyword_cmp = node1->keyword.compare(node2->keyword); +int cmp_KEYWORD_WGNAME_LGR( const smspec_node& node1, const smspec_node& node2) { + int keyword_cmp = strcmp(node1.get_keyword(), node2.get_keyword()); if (keyword_cmp != 0) return keyword_cmp; - int wgname_cmp = node1->wgname.compare(node2->wgname); + int wgname_cmp = strcmp(node1.get_wgname(), node2.get_wgname()); if (wgname_cmp != 0) return wgname_cmp; - return node1->lgr_name.compare(node2->lgr_name); + return strcmp(node1.get_lgr_name(), node2.get_lgr_name()); } - -static int smspec_node_cmp_KEYWORD_WGNAME_LGR_LGRIJK( const smspec_node_type * node1, const smspec_node_type * node2) { - int keyword_cmp = node1->keyword.compare(node2->keyword); +int cmp_KEYWORD_WGNAME_LGR_LGRIJK( const smspec_node& node1, const smspec_node& node2) { + int keyword_cmp = strcmp(node1.get_keyword(), node2.get_keyword()); if (keyword_cmp != 0) return keyword_cmp; - int wgname_cmp = node1->wgname.compare(node2->wgname); + int wgname_cmp = strcmp(node1.get_wgname(), node2.get_wgname()); if (wgname_cmp != 0) return wgname_cmp; - int lgr_cmp = node1->lgr_name.compare(node2->lgr_name); + int lgr_cmp = strcmp(node1.get_lgr_name(), node2.get_lgr_name()); if (lgr_cmp != 0) return lgr_cmp; - return smspec_node_cmp_LGRIJK( node1, node2); + return cmp_LGRIJK( node1, node2); } - - - -static int smspec_node_cmp_KEYWORD_WGNAME( const smspec_node_type * node1, const smspec_node_type * node2) { - int keyword_cmp = node1->keyword.compare(node2->keyword); +int cmp_KEYWORD_WGNAME( const smspec_node& node1, const smspec_node& node2) { + int keyword_cmp = strcmp(node1.get_keyword(), node2.get_keyword()); if (keyword_cmp != 0) return keyword_cmp; - if (IS_DUMMY_WELL( node1->wgname.c_str() )) { - if (IS_DUMMY_WELL( node2->wgname.c_str() )) + if (IS_DUMMY_WELL( node1.get_wgname() )) { + if (IS_DUMMY_WELL( node2.get_wgname() )) return 0; else return 1; } - if (IS_DUMMY_WELL( node2->wgname.c_str() )) + if (IS_DUMMY_WELL( node2.get_wgname() )) return -1; - return node1->wgname.compare(node2->wgname); + return strcmp(node1.get_wgname(), node2.get_wgname()); +} + +int cmp_KEYWORD( const smspec_node& node1, const smspec_node& node2) { + return strcmp(node1.get_keyword(), node2.get_keyword()); } -static int smspec_node_cmp_KEYWORD_NUM( const smspec_node_type * node1, const smspec_node_type * node2) { - int keyword_cmp = node1->keyword.compare(node2->keyword); + +int cmp_KEYWORD_NUM( const smspec_node& node1, const smspec_node& node2) { + int keyword_cmp = strcmp(node1.get_keyword(), node2.get_keyword()); if (keyword_cmp != 0) return keyword_cmp; - return int_cmp( node1->num , node2->num); + return int_cmp( node1.get_num() , node2.get_num()); } -static int smspec_node_cmp_KEYWORD( const smspec_node_type * node1, const smspec_node_type * node2) { - return node1->keyword.compare(node2->keyword); -} - -static int smspec_node_cmp_key1( const smspec_node_type * node1, const smspec_node_type * node2) { - if (node1->gen_key1.empty()) { - if (node2->gen_key1.empty()) +int cmp_key1( const smspec_node& node1, const smspec_node& node2) { + if (node1.get_gen_key1() == NULL) { + if (node2.get_gen_key1() == NULL) return 0; else return -1; - } else if (node2->gen_key1.empty()) { + } else if (node2.get_gen_key1() == NULL) return 1; - } - return util_strcmp_int( node1->gen_key1.c_str() , node2->gen_key1.c_str() ); + + return util_strcmp_int( node1.get_gen_key1() , node2.get_gen_key1() ); +} } - -int smspec_node_cmp( const smspec_node_type * node1, const smspec_node_type * 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)) - return smspec_node_cmp_MISC( node1 , node2 ); + if ((node1.var_type == ECL_SMSPEC_MISC_VAR) || (node2.var_type == ECL_SMSPEC_MISC_VAR)) + return cmp_MISC( node1 , node2 ); /* 2: Sort according to variable type */ - if (node1->var_type < node2->var_type) + if (node1.var_type < node2.var_type) return -1; - if (node1->var_type > node2->var_type) + if (node1.var_type > node2.var_type) return 1; /* 3: Internal sort of variables of the same type. */ - switch (node1->var_type) { + switch (node1.var_type) { case( ECL_SMSPEC_FIELD_VAR): - return smspec_node_cmp_KEYWORD( node1, node2); + return cmp_KEYWORD( node1, node2); case( ECL_SMSPEC_WELL_VAR): case( ECL_SMSPEC_GROUP_VAR): - return smspec_node_cmp_KEYWORD_WGNAME( node1, node2); + 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): - return smspec_node_cmp_KEYWORD_NUM( node1, node2); + return cmp_KEYWORD_NUM( node1, node2); case( ECL_SMSPEC_COMPLETION_VAR): case( ECL_SMSPEC_SEGMENT_VAR): - return smspec_node_cmp_KEYWORD_WGNAME_NUM( node1, node2); + return cmp_KEYWORD_WGNAME_NUM( node1, node2); case (ECL_SMSPEC_NETWORK_VAR): - return smspec_node_cmp_key1( node1, node2); + return cmp_key1( node1, node2); case( ECL_SMSPEC_LOCAL_BLOCK_VAR): - return smspec_node_cmp_KEYWORD_LGR_LGRIJK( node1, node2); + return cmp_KEYWORD_LGR_LGRIJK( node1, node2); case( ECL_SMSPEC_LOCAL_WELL_VAR): - return smspec_node_cmp_KEYWORD_WGNAME_LGR( node1, node2); + return cmp_KEYWORD_WGNAME_LGR( node1, node2); case( ECL_SMSPEC_LOCAL_COMPLETION_VAR): - return smspec_node_cmp_KEYWORD_WGNAME_LGR_LGRIJK( node1, node2); + return cmp_KEYWORD_WGNAME_LGR_LGRIJK( node1, node2); default: /* Should not really end up here. */ - return smspec_node_cmp_key1( node1, node2); + return cmp_key1( node1, node2); } } -int smspec_node_cmp__( const void * node1, const void * node2) { - return smspec_node_cmp( smspec_node_safe_cast_const( node1 ), - smspec_node_safe_cast_const( node2 )); +int smspec_node::cmp(const smspec_node& node2) const { + return smspec_node::cmp(*this, node2); +} + + +} // end namespace ecl + +/************************************** OLD API functions ***********************''''' */ + + +void smspec_node_free( void * 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(); +} + +int smspec_node_get_params_index( const void * 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 ); +// } + +const char * smspec_node_get_gen_key1( const void * smspec_node) { + 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(); +} + +const char * smspec_node_get_wgname( const void * smspec_node) { + return static_cast(smspec_node)->get_wgname(); +} + +const char * smspec_node_get_keyword( const void * smspec_node) { + 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(); +} + +int smspec_node_get_num( const void * smspec_node) { + return static_cast(smspec_node)->get_num(); +} + +bool smspec_node_is_rate( const void * smspec_node ) { + return static_cast(smspec_node)->is_rate(); +} + +bool smspec_node_is_total( const void * smspec_node ){ + return static_cast(smspec_node)->is_total(); +} + +bool smspec_node_is_historical( const void * smspec_node ){ + return static_cast(smspec_node)->is_historical(); +} + +const char * smspec_node_get_unit( const void * smspec_node) { + 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(); +} + +// 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(); +} + + +// 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)->get_lgr_ijk().data(); +} + +int smspec_node_get_R1( const void * smspec_node ) { + return static_cast(smspec_node)->get_R1(); +} + + +int smspec_node_get_R2( const void * smspec_node ) { + return static_cast(smspec_node)->get_R2(); +} + +bool smspec_node_need_nums( const void * smspec_node ) { + return static_cast(smspec_node)->need_nums(); +} + +void smspec_node_fprintf( const void * smspec_node , FILE * 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)); +} + +int smspec_node_cmp__( const void * node1, const void * node2) { + return smspec_node_cmp(node1, node2); +} + + +void * smspec_node_alloc( int param_index, + const char * keyword , + const char * wgname, + int num, + const char * unit , + const int grid_dims[3] , + float default_value, + const char * key_join_string) { + + ecl::smspec_node * node = NULL; + try { + node = new ecl::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 , + 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); +} + + + +bool smspec_node_equal( const void * node1, const void * node2) { + return ecl::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) ) > 0; +} + +bool smspec_node_lt( const void * node1, const void * node2) { + return ecl::smspec_node::cmp( static_cast(node1) , static_cast(node2) ) < 0; } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_cpgrid.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_cpgrid.cpp index f3c1ac4e44..2a06c3cc88 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_cpgrid.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_cpgrid.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_alloc_cpgrid.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_grid_dxv_dyv_dzv.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_grid_dxv_dyv_dzv.cpp index 9992680f74..7f7ff44104 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_grid_dxv_dyv_dzv.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_alloc_grid_dxv_dyv_dzv.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2013 Andreas Lauser - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_alloc_grid_dxv_dyv_dzv.c' is part of ERT - Ensemble based Reservoir Tool. @@ -55,6 +55,7 @@ void test_grid() { } } } + ecl_grid_free( ecl_grid ); } int main(int argc , char ** argv) { diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_coarse_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_coarse_test.cpp index d1882092cd..b2c36fbb22 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_coarse_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_coarse_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_coarse_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_dualp.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_dualp.cpp index a26d38b863..35b1860c1e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_dualp.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_dualp.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_dualp.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_collection_statoil.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_collection_equinor.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_collection_statoil.cpp rename to ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_collection_equinor.cpp index 73bd471390..a40dbaac1f 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_collection_statoil.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_collection_equinor.cpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. - The file 'ecl_fault_block_collection_statoil.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'ecl_fault_block_collection_equinor.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 diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer.cpp index d8de3438af..e1be64668e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_fault_block_layer.c' is part of ERT - Ensemble based Reservoir Tool. @@ -98,6 +98,7 @@ void test_trace_edge( const ecl_grid_type * grid) { test_assert_int_equal( 1 , int_vector_size( cell_list )); test_assert_int_equal( 0 , int_vector_iget( cell_list , 0)); + fault_block_layer_free(layer); int_vector_free( cell_list ); double_vector_free( x_list ); double_vector_free( y_list ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer_statoil.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer_equinor.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer_statoil.cpp rename to ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer_equinor.cpp index 6e2590397a..a7e0f1e18f 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer_statoil.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_fault_block_layer_equinor.cpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. - The file 'ecl_fault_block_layer_statoil.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'ecl_fault_block_layer_equinor.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 diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_file.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_file.cpp index c680e3d10e..951fe544f6 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_file.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_file.cpp @@ -1,6 +1,6 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool. @@ -31,7 +31,7 @@ #include void test_writable(size_t data_size) { - test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable"); + ecl::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); @@ -54,11 +54,10 @@ void test_writable(size_t data_size) { } ecl_kw_free(kw); - test_work_area_free( work_area ); } void test_truncated() { - test_work_area_type * work_area = test_work_area_alloc("ecl_file_truncated" ); + ecl::util::TestArea ta("truncate_file"); int num_kw; { ecl_grid_type * grid = ecl_grid_alloc_rectangular(20,20,20,1,1,1,NULL); @@ -69,6 +68,7 @@ void test_truncated() { 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 ); } @@ -83,7 +83,6 @@ void test_truncated() { test_assert_true( ecl_file_get_size( ecl_file) < num_kw ); ecl_file_close( ecl_file ); } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_file_statoil.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_file_equinor.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/tests/ecl_file_statoil.cpp rename to ThirdParty/Ert/lib/ecl/tests/ecl_file_equinor.cpp index 13de6fcf40..3d496444de 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_file_statoil.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_file_equinor.cpp @@ -1,8 +1,8 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. - The file 'ecl_file_statoil.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'ecl_file_equinor.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 @@ -108,10 +108,10 @@ void test_close_stream1(const char * src_file , const char * target_file ) { void test_writable(const char * src_file ) { - test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" ); + ecl::util::TestArea ta("file_writable"); char * fname = util_split_alloc_filename( src_file ); - test_work_area_copy_file( work_area , src_file ); + ta.copy_file(src_file); { test_flags( fname ); ecl_file_type * ecl_file = ecl_file_open( fname , ECL_FILE_WRITABLE); @@ -127,7 +127,6 @@ void test_writable(const char * src_file ) { swat = ecl_file_iget_named_kw( ecl_file , "SWAT" , 0 ); test_assert_true( util_double_approx_equal( ecl_kw_iget_float( swat , 0 ) , 1000 )); } - test_work_area_free( work_area ); } @@ -138,16 +137,15 @@ int main( int argc , char ** argv) { const char * target_file = argv[2]; { - test_work_area_type * work_area = test_work_area_alloc("ecl_file"); + ecl::util::TestArea ta("file_equinor"); - test_work_area_copy_file( work_area , src_file ); + ta.copy_file( src_file ); test_loadall(src_file , target_file ); test_close_stream1( src_file , target_file); test_close_stream2( src_file , target_file); test_writable( src_file ); - test_work_area_free( work_area ); } exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_file_view.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_file_view.cpp index 9dc7875d7c..7f329c310a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_file_view.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_file_view.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool. @@ -59,7 +59,7 @@ void test_create_file_kw() { test_assert_int_equal( ecl_file_kw_get_size( file_kw0 ) , 1000 ); test_assert_true( ecl_type_is_equal( ecl_file_kw_get_data_type( file_kw0 ) , ECL_FLOAT )); { - test_work_area_type * work_area = test_work_area_alloc("file_kw"); + ecl::util::TestArea ta("file_kw"); { FILE * ostream = util_fopen("file_kw" , "w"); ecl_file_kw_fwrite( file_kw0 , ostream ); @@ -101,7 +101,6 @@ void test_create_file_kw() { test_assert_NULL( ecl_file_kw_fread_alloc_multiple( istream , 10)); fclose( istream ); } - test_work_area_free( work_area ); } ecl_file_kw_free( file_kw0 ); ecl_file_kw_free( file_kw1 ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_fmt.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_fmt.cpp index 5b04922dce..ea07feae8f 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_fmt.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_fmt.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_fmt.c' is part of ERT - Ensemble based Reservoir Tool. @@ -25,14 +25,12 @@ #include -void test_content( test_work_area_type * work_area , const char * src_file , bool fmt_file ) { - test_work_area_install_file( work_area , src_file ); +void test_content( const ecl::util::TestArea& ta , const char * src_file , bool fmt_file ) { + ta.copy_file(src_file); { char * base_name; bool fmt; util_alloc_file_components( src_file , NULL , &base_name , NULL); - util_copy_file( src_file , base_name ); - test_assert_true( ecl_util_fmt_file( base_name , &fmt )); test_assert_bool_equal( fmt , fmt_file ); } @@ -41,6 +39,7 @@ void test_content( test_work_area_type * work_area , const char * src_file , boo + void test_small( ) { bool fmt; @@ -56,7 +55,7 @@ void test_small( ) { int main(int argc , char ** argv) { - test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt"); + ecl::util::TestArea ta("ecl_fmt"); { const char * binary_file = argv[1]; const char * text_file = argv[2]; @@ -78,10 +77,9 @@ int main(int argc , char ** argv) { test_assert_false(ecl_util_fmt_file( "TEST_DOES_NOT_EXIST" , &fmt_file )); - test_content( work_area , binary_file , false ); - test_content( work_area , text_file , true ); + test_content( ta , binary_file , false ); + test_content( ta , text_file , true ); test_small( ); } - test_work_area_free( work_area ); exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_fortio.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_fortio.cpp index e18fcd20ae..da7de8e695 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_fortio.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_fortio.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_fortio.c' is part of ERT - Ensemble based Reservoir Tool. @@ -111,7 +111,7 @@ void test_open_close_read( const char * filename ) { void test_fread_truncated_data() { - test_work_area_type * work_area = test_work_area_alloc("fortio_truncated" ); + ecl::util::TestArea work_area("fortio_truncated"); { const size_t buffer_size = 1000; char * buffer = (char *) util_malloc( buffer_size ); @@ -136,11 +136,10 @@ void test_fread_truncated_data() { } free( buffer ); } - test_work_area_free( work_area ); } void test_fread_truncated_head() { - test_work_area_type * work_area = test_work_area_alloc("fortio_truncated" ); + ecl::util::TestArea work_area("fortio_truncated"); { { FILE * stream = util_fopen("PRESSURE" , "w"); @@ -156,12 +155,11 @@ void test_fread_truncated_head() { fortio_fclose( fortio ); } } - test_work_area_free( work_area ); } void test_fread_truncated_tail() { - test_work_area_type * work_area = test_work_area_alloc("fortio_truncated2" ); + ecl::util::TestArea work_area("fortio_truncated3"); { const size_t buffer_size = 1000; char * buffer = (char *) util_malloc( buffer_size ); @@ -183,12 +181,11 @@ void test_fread_truncated_tail() { } free( buffer ); } - test_work_area_free( work_area ); } void test_fread_invalid_tail() { - test_work_area_type * work_area = test_work_area_alloc("fortio_invalid" ); + ecl::util::TestArea work_area("fortio_invalid"); int record_size = 10; char * buffer = (char *) util_malloc( record_size ); { @@ -215,13 +212,12 @@ void test_fread_invalid_tail() { } free( buffer ); - test_work_area_free( work_area ); } void test_at_eof() { - test_work_area_type * work_area = test_work_area_alloc("fortio_truncated2" ); + ecl::util::TestArea work_area("fortio_truncated3"); { fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true); char * buffer = (char *) util_malloc( 100 ); @@ -242,13 +238,11 @@ void test_at_eof() { fortio_fclose( fortio ); } - - test_work_area_free( work_area ); } void test_fseek() { - test_work_area_type * work_area = test_work_area_alloc("fortio_fseek" ); + ecl::util::TestArea work_area("fortio_fseek"); { fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true); char * buffer = (char *) util_malloc( 100 ); @@ -261,8 +255,6 @@ void test_fseek() { { fortio_type * fortio = fortio_open_reader("PRESSURE" , false , true); - - printf("Starting fssek test \n"); test_assert_true( fortio_fseek( fortio , 0 , SEEK_SET )); test_assert_true( fortio_fseek( fortio , 0 , SEEK_END )); test_assert_false( fortio_fseek( fortio , 100000 , SEEK_END)); @@ -270,14 +262,12 @@ void test_fseek() { fortio_fclose( fortio ); } - - test_work_area_free( work_area ); } void test_write_failure() { - test_work_area_type * work_area = test_work_area_alloc("fortio_fseek" ); + ecl::util::TestArea work_area("fortio_truncated"); { fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true); char * buffer = (char *) util_malloc( 100 ); @@ -292,7 +282,6 @@ void test_write_failure() { test_assert_false( util_file_exists( "PRESSURE")); } - test_work_area_free( work_area ); } @@ -317,10 +306,9 @@ int main( int argc , char ** argv) { test_write( "/tmp/path/does/not/exist" , false ); { - test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" ); + ecl::util::TestArea work_area("ecl_fortio_write"); util_make_path("path"); test_write( "path/file.x" , true ); - test_work_area_free( work_area ); } test_write_failure(); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_get_num_cpu_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_get_num_cpu_test.cpp index 3f715b2cd8..c608634367 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_get_num_cpu_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_get_num_cpu_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_get_num_cpu_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_DEPTHZ.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_DEPTHZ.cpp index 29b14612cb..056eebb750 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_DEPTHZ.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_DEPTHZ.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_DEPTHZ.c' is part of ERT - Ensemble based Reservoir Tool. @@ -44,15 +44,15 @@ void test_create() { int ny = 100; int nz = 10; - double * DXV = (double *) util_malloc( nx * sizeof * DXV ); - double * DYV = (double *) util_malloc( ny * sizeof * DYV ); + double * DXV = (double *) util_malloc( (nx + 1) * sizeof * DXV ); + double * DYV = (double *) util_malloc( (ny + 1) * sizeof * DYV ); double * DZV = (double *) util_malloc( nz * sizeof * DZV ); double * DEPTHZ = (double *) util_malloc( (nx + 1) * (ny + 1) * sizeof * DEPTHZ); - for (int i=0; i < nx; i++) + for (int i=0; i <= nx; i++) DXV[i] = 1.0 / nx; - for (int j=0; j < ny; j++) + for (int j=0; j <= ny; j++) DYV[j] = 1.0 / ny; for (int k=0; k < nz; k++) diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_add_nnc.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_add_nnc.cpp index d7d9221361..144d8dcc1e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_add_nnc.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_add_nnc.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ecl_grid_add_nnc.c' is part of ERT - Ensemble based Reservoir Tool. @@ -60,14 +60,13 @@ void simple_test() { verify_simple_nnc( grid0 ); { - test_work_area_type * test_area = test_work_area_alloc("ecl_grid_nnc"); + 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" ); verify_simple_nnc( grid1 ); ecl_grid_free( grid1 ); - test_work_area_free( test_area ); } ecl_grid_free( grid0 ); } @@ -90,14 +89,13 @@ void overwrite_test() { verify_simple_nnc( grid0 ); { - test_work_area_type * test_area = test_work_area_alloc("ecl_grid_nnc"); + 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" ); verify_simple_nnc( grid1 ); ecl_grid_free( grid1 ); - test_work_area_free( test_area ); } ecl_grid_free( grid0 ); } @@ -118,15 +116,16 @@ void list_test() { verify_simple_nnc( grid0 ); { - test_work_area_type * test_area = test_work_area_alloc("ecl_grid_nnc"); + 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" ); verify_simple_nnc( grid1 ); ecl_grid_free( grid1 ); - test_work_area_free( test_area ); } + int_vector_free(g1); + int_vector_free(g2); ecl_grid_free( grid0 ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_case.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_case.cpp index 6dcb7f05c2..ca2da22e3f 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_case.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_case.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_case.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains.cpp index c44ccbfc2f..bab105c304 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_cell_contains.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains_wellpath.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains_wellpath.cpp index c2eb6d8179..fc11a91c15 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains_wellpath.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_cell_contains_wellpath.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_grid_cell_contains_wellpath.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy.cpp index b5e69a4eae..37da21546a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_copy.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy_statoil.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy_equinor.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy_statoil.cpp rename to ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy_equinor.cpp index 23182906c3..eafff99257 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy_statoil.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_copy_equinor.cpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. - The file 'ecl_grid_copy_statoil.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'ecl_grid_copy_equinor.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 diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.cpp index 5b3c2fe044..d651d456e2 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_corner.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_create.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_create.cpp index d7d45f32e9..d67b09ebbc 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_create.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_create.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_create.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dims.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dims.cpp index 8658da7089..bff2114681 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dims.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dims.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dx_dy_dz.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dx_dy_dz.cpp index 542b70b824..35e13dbd8a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dx_dy_dz.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_dx_dy_dz.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_export.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_export.cpp index 913269ae36..80dce52d4c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_export.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_export.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_export.c' is part of ERT - Ensemble based Reservoir Tool. @@ -154,7 +154,7 @@ void export_mapaxes( const ecl_grid_type * grid , ecl_file_type * ecl_file ) { int main(int argc , char ** argv) { - test_work_area_type * work_area = test_work_area_alloc("grid_export"); + ecl::util::TestArea ta("grid_export"); { const char * test_grid = "TEST.EGRID"; const char * grid_file; @@ -181,5 +181,4 @@ int main(int argc , char ** argv) { ecl_grid_free( ecl_grid ); } } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp index 75c497189a..3378bda981 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp @@ -12,7 +12,7 @@ void test_1() { - test_work_area_type * work_area = test_work_area_alloc("ext_actnum_main_grid"); + ecl::util::TestArea ta("test1"); { const char * filename = "FILE.EGRID"; @@ -41,21 +41,18 @@ void test_1() { 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( 2, ecl_grid_get_nactive(grid) ); - test_assert_int_equal( 1, ecl_grid_get_nactive_fracture(grid) ); + 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, 3) ); test_assert_true( ecl_grid_cell_active1(grid, 4) ); test_assert_true( ecl_grid_cell_active1(grid, 5) ); ecl_grid_free( grid ); } - test_work_area_free( work_area ); - - } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_fwrite.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_fwrite.cpp index 861edc0c42..d359a41f71 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_fwrite.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_fwrite.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_kw_fwrite.c' is part of ERT - Ensemble based Reservoir Tool. @@ -37,12 +37,72 @@ void test_fwrite_EGRID(ecl_grid_type * grid ) { test_work_area_free( work_area ); } +namespace { + void test_fwrite_fmt_vs_unfmt( ) { + ecl::util::TestArea ta( "fmt_file" ); + ecl_grid_type * ecl_grid = ecl_grid_alloc_rectangular( 5 , 5 , 5 , 1 , 1 , 1 , nullptr); + + /* .FEGRID -> formatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.FEGRID" , ECL_METRIC_UNITS ); + test_assert_true( util_fmt_bit8( "CASE.FEGRID" ) ); + } + + /* .EGRID -> unformatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.EGRID" , ECL_METRIC_UNITS ); + test_assert_false( util_fmt_bit8( "CASE.EGRID" ) ); + } + + /* Unknown -> unformatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.UNKNOWN" , ECL_METRIC_UNITS ); + test_assert_false( util_fmt_bit8( "CASE.UNKNOWN" ) ); + } + + /* Abuse: .FUNRST -> formatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.FUNRST" , ECL_METRIC_UNITS ); + test_assert_true( util_fmt_bit8( "CASE.FUNRST" ) ); + } + + /* Abuse: .FSMSPEC -> formatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.FSMSPEC" , ECL_METRIC_UNITS ); + test_assert_true( util_fmt_bit8( "CASE.FSMSPEC" ) ); + } + + /* Abuse: .F0001 -> formatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.F0001" , ECL_METRIC_UNITS ); + test_assert_true( util_fmt_bit8( "CASE.F0001" ) ); + } + + /* Abuse: .X1234 -> unformatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.X1234" , ECL_METRIC_UNITS ); + test_assert_false( util_fmt_bit8( "CASE.X1234" ) ); + } + + /* Abuse: .UNSMRY -> unformatted */ + { + ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.UNSMRY" , ECL_METRIC_UNITS ); + test_assert_false( util_fmt_bit8( "CASE.UNSMRY" ) ); + } + + ecl_grid_free( ecl_grid ); + } +} int main( int argc , char **argv) { - const char * src_file = argv[1]; - ecl_grid_type * grid = ecl_grid_alloc( src_file ); + if (argc > 1) { + const char * src_file = argv[1]; + ecl_grid_type * grid = ecl_grid_alloc( src_file ); - test_fwrite_EGRID( grid ); + test_fwrite_EGRID( grid ); - ecl_grid_free( grid ); + ecl_grid_free( grid ); + } + + test_fwrite_fmt_vs_unfmt( ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_init_fwrite.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_init_fwrite.cpp index dc480232e0..8d6111f125 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_init_fwrite.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_init_fwrite.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. @@ -31,7 +31,7 @@ void test_write_depth(const ecl_grid_type * grid) { - test_work_area_type * test_area = test_work_area_alloc("write_depth"); + ecl::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); @@ -47,12 +47,11 @@ void test_write_depth(const ecl_grid_type * grid) { ecl_file_close(init_file); } - test_work_area_free( test_area ); } void test_write_dims(const ecl_grid_type * grid) { - test_work_area_type * test_area = test_work_area_alloc("write_dims"); + ecl::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 ); @@ -74,7 +73,6 @@ void test_write_dims(const ecl_grid_type * grid) { } ecl_file_close(init_file); } - test_work_area_free( test_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_layer_contains.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_layer_contains.cpp index 6af4f412be..5cb968d336 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_layer_contains.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_layer_contains.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_layer_contains' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_lgr_name.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_lgr_name.cpp index 59d314316f..0055b0a0a3 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_lgr_name.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_lgr_name.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_lgr_name.c' is part of ERT - Ensemble based Reservoir Tool. @@ -41,8 +41,6 @@ Name ..................: LG003014 Grid nr ...............: 110 - - Name ..................: /private/joaho/ERT/git/ert/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID */ diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_reset_actnum.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_reset_actnum.cpp index c0c39aab37..99d99d26ba 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_reset_actnum.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_reset_actnum.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_grid_reset_actnum.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_simple.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_simple.cpp index 8d9f9ed5a8..052766aaff 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_simple.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_simple.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_simple.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp index 2e75a1c59b..b191503ca9 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. The file 'ecl_grid_unit_system.c' is part of ERT - Ensemble based Reservoir Tool. @@ -52,12 +52,10 @@ void test_GRID(const char * filename, ert_ecl_unit_enum unit_system) { int main(int argc, char **argv) { - test_work_area_type * work_area = test_work_area_alloc("grid_export"); + ecl::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_work_area_free(work_area); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_volume.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_volume.cpp index eb6feb62d1..393bc3d14a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_volume.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_volume.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_volume.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_init_file.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_init_file.cpp index d4dbb4a293..4246bc32eb 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_init_file.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_init_file.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ecl_init_file.c' is part of ERT - Ensemble based Reservoir Tool. @@ -36,8 +36,8 @@ void test_write_header() { int ny = 10; int nz = 5; + ecl::util::TestArea ta("WRITE_header"); int_vector_type * actnum = int_vector_alloc( nx*ny*nz , 1 ); - test_work_area_type * test_area = test_work_area_alloc( "ecl_init_file" ); time_t start_time = util_make_date_utc(15 , 12 , 2010 ); ecl_grid_type * ecl_grid; @@ -84,7 +84,8 @@ void test_write_header() { ecl_init_file_fwrite_header( f , ecl_grid , NULL , ECL_METRIC_UNITS, 7 , start_time ); fortio_fclose( f ); } - test_work_area_free( test_area ); + ecl_grid_free( ecl_grid ); + int_vector_free( actnum ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_cmp_string.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_cmp_string.cpp index d7d925bc49..ecc411680e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_cmp_string.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_cmp_string.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_kw_cmp_string.c' is part of ERT - Ensemble based Reservoir Tool. @@ -39,6 +39,7 @@ void test_cmp_string() { test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "")); test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "")); + ecl_kw_free(ecl_kw); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_equal.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_equal.cpp index 912816025f..231e882468 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_equal.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_equal.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_kw_equal.c' is part of ERT - Ensemble based Reservoir Tool. @@ -55,12 +55,13 @@ int main(int argc , char ** argv) { test_assert_true( ecl_kw_content_equal( ecl_kw1 , ecl_ikw )); test_assert_false( ecl_kw_content_equal( ecl_kw1 , ecl_fkw )); + + ecl_kw_free(ecl_ikw); + ecl_kw_free(ecl_fkw); } test_assert_true( ecl_kw_data_equal( ecl_kw1 , data )); data[0] = 99; test_assert_false( ecl_kw_data_equal( ecl_kw1 , data )); - - - + ecl_kw_free(ecl_kw1); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_fread.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_fread.cpp index 2cf4a24be8..a4badb438b 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_fread.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_fread.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Statoil ASA, Norway. + Copyright (C) 2015 Equinor ASA, Norway. The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool. @@ -45,7 +45,7 @@ void test_truncated(const char * filename , offset_type truncate_size) { void test_fread_alloc() { - test_work_area_type * work_area = test_work_area_alloc("ecl_kw_fread" ); + ecl::util::TestArea ta("fread_alloc"); { ecl_kw_type * kw1 = ecl_kw_alloc( "INT" , 100 , ECL_INT ); int i; @@ -74,11 +74,10 @@ void test_fread_alloc() { } ecl_kw_free( kw1 ); } - test_work_area_free( work_area ); } void test_kw_io_charlength() { - test_work_area_type * work_area = test_work_area_alloc("ecl_kw_io_charlength"); + ecl::util::TestArea ta("io_charlength"); { const char * KW0 = "QWERTYUI"; const char * KW1 = "ABCDEFGHIJTTTTTTTTTTTTTTTTTTTTTTABCDEFGHIJKLMNOP"; @@ -115,13 +114,13 @@ void test_kw_io_charlength() { 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); + ecl_kw_free(ecl_kw_in); fclose(file); } ecl_kw_free( ecl_kw_out0 ); ecl_kw_free( ecl_kw_out1 ); } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_grdecl.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_grdecl.cpp index a1b49eb55b..97dd9c7947 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_grdecl.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_grdecl.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool. @@ -32,7 +32,7 @@ int main(int argc , char ** argv) { ecl_kw_iset_int(ecl_kw , i , i ); { - test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl"); + ecl::util::TestArea ta("kw_grdecl"); FILE * stream = util_fopen( "FILE.grdecl" , "w"); ecl_kw_fprintf_grdecl(ecl_kw , stream ); @@ -65,7 +65,6 @@ int main(int argc , char ** argv) { ecl_kw_free( ecl_kw2 ); } fclose( stream ); - test_work_area_free( work_area ); } ecl_kw_free( ecl_kw ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.cpp index 0f4a883526..16b382a188 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp index ab5d85c6d5..7a0d0ad0d0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_layer.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_layer_equinor.cpp similarity index 96% rename from ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp rename to ThirdParty/Ert/lib/ecl/tests/ecl_layer_equinor.cpp index 912248dfd4..a984cb84f8 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_layer_equinor.cpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. - The file 'ecl_layer_statoil.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'ecl_layer_equinor.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 diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.cpp index 6d2048cfdb..0a6163349a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_win64.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_name.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_name.cpp index ca798963d8..f45c5d6aec 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_name.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_name.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_lgr_name.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_test.cpp index a585de4fb2..c0807e951e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_lgr_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_lgr_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_data_statoil_root.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_data_equinor_root.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/tests/ecl_nnc_data_statoil_root.cpp rename to ThirdParty/Ert/lib/ecl/tests/ecl_nnc_data_equinor_root.cpp index 784864bf97..f804376366 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_data_statoil_root.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_data_equinor_root.cpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. - The file 'test_ecl_nnc_data_statoil.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'test_ecl_nnc_data_equinor.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 diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export.cpp index 556e2df7a0..ed97f621f9 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. @@ -74,8 +74,10 @@ int count_kw_data( const ecl_file_type * file , ecl_grid_type * grid , const cha void test_count(const char * name) { char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_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); int num_nnc = 0; @@ -83,7 +85,7 @@ 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 )); + test_assert_int_equal(num_nnc, ecl_nnc_export_get_size(grid, init_file)); free(grid_file_name); ecl_grid_free( grid ); @@ -97,7 +99,7 @@ void test_nnc_export_missing_TRANX(const char * name ) { 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 ) , sizeof * nnc_data1 ); + 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); int i; test_assert_int_equal( count , 0 ); @@ -113,8 +115,8 @@ void test_export(const char * name, bool have_tran_data) { 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 ) , sizeof * nnc_data1 ); - ecl_nnc_type * nnc_data2 = (ecl_nnc_type *) util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data2 ); + 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); { @@ -214,23 +216,23 @@ void test_export(const char * name, bool have_tran_data) { } } - test_assert_int_equal( nnc_offset , ecl_nnc_export_get_size( grid )); + test_assert_int_equal(nnc_offset, ecl_nnc_export_get_size(grid, init_file )); ecl_nnc_sort( nnc_data1 , nnc_offset ); } { int export_size = ecl_nnc_export( grid , init_file , nnc_data2 ); - test_assert_int_equal( export_size , ecl_nnc_export_get_size( grid )); + test_assert_int_equal(export_size , ecl_nnc_export_get_size(grid, init_file)); } { int i; - int size = ecl_nnc_export_get_size( grid ); + int size = ecl_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])); } - for (int i =0; i < ecl_nnc_export_get_size( grid ); 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] )); { @@ -238,7 +240,7 @@ void test_export(const char * name, bool have_tran_data) { 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 ), ecl_nnc_geometry_size( nnc_geo )); + 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]; diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_get_tran.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_get_tran.cpp index fb40436af0..61addc079a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_get_tran.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_get_tran.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_intersect.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_intersect.cpp new file mode 100644 index 0000000000..7a8113823d --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_export_intersect.cpp @@ -0,0 +1,117 @@ +/* + Copyright (C) 2018 Equinor ASA, Norway. + + The file 'ecl_nnc_export_intersect.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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more detals. +*/ +// #include +// #include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + + + +namespace { + +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) + ); + for(auto i = 0; i < GRID_NNC_NUM; ++i) + ecl_grid_add_self_nnc(out.get(), 2 * i + 1, 2 * i, i); + return out; +} + + +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); + 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); + } + + // 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); + fortio_fclose(fortio); + + // reopen the file as an ecl file + auto out = ERT::ert_unique_ptr( + ecl_file_open(init_filename, 0) + ); + + ecl_kw_free(nnc1_kw); + ecl_kw_free(nnc2_kw); + ecl_kw_free(tran_kw); + free(init_filename); + return out; +} +} /* unnamed namespace */ + + + +int main(int argc, char ** argv) { + util_install_signals(); + + 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()), INIT_NNC_NUM); + + auto nnc_data = std::vector( + ecl_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()); + test_assert_int_equal(total_valid_trans, INIT_NNC_NUM); + test_assert_int_equal(int(nnc_data.size()), INIT_NNC_NUM); + + for(auto i = 0; i < int(nnc_data.size()); ++i) { + auto const& nnc = nnc_data[i]; + test_assert_int_equal(nnc.grid_nr1, 0); + test_assert_int_equal(nnc.grid_nr2, 0); + test_assert_int_equal(nnc.global_index1, 2 * i); // as set in make_intersect_init_file() + test_assert_int_equal(nnc.global_index2, 2 * i + 1); // as set in make_intersect_init_file() + test_assert_double_equal(nnc.trans, 2.5 * i); // as set in make_intersect_init_file() + test_assert_int_equal(nnc.input_index, i); + } + + return 0; +} diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_geometry.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_geometry.cpp index d457ee7b6b..25fb4e6633 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_geometry.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_geometry.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_nnc_geometry.c' is part of ERT - Ensemble based Reservoir Tool. @@ -36,7 +36,7 @@ void test_create_empty() { } void test_create_simple() { - test_work_area_type * work_area = test_work_area_alloc("nnc-INIT"); + ecl::util::TestArea ta("nnc_geometry"); { int nx = 10; int ny = 10; @@ -64,10 +64,10 @@ void test_create_simple() { fortio_fclose( f ); ecl_kw_free( trann_nnc ); } + ecl_nnc_geometry_free(nnc_geo); } ecl_grid_free( grid0 ); } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list.cpp index dd4f2e616a..c464e6ee07 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_index_list.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list_grid.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list_grid.cpp index cfec278eaa..35181b9549 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list_grid.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_index_list_grid.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_index_list_grid.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_info_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_info_test.cpp index dba5876244..8ddd77ddfd 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_info_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_info_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_info_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,6 +18,8 @@ #include #include +#include + #include #include #include @@ -53,6 +55,8 @@ void test_equal( ) { nnc_info_add_nnc( nnc_info1 , lgr_nr + 2 , 11 , 11 ); nnc_info_add_nnc( nnc_info2 , lgr_nr + 1 , 10 , 10 ); test_assert_true( nnc_info_equal( nnc_info1 , nnc_info2 )); + nnc_info_free( nnc_info1 ); + nnc_info_free( nnc_info2 ); } @@ -91,23 +95,22 @@ void basic_test() { nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1); - const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1); - test_assert_int_equal(int_vector_size(nnc_cells), 2); - test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector )); + const std::vector& nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1); + test_assert_int_equal(nnc_cells.size(), 2); + test_assert_ptr_equal( nnc_cells.data() , nnc_vector_get_grid_index_list( nnc_vector ).data()); nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2); - const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2); - test_assert_NULL(nnc_cells_null); + test_assert_true( !nnc_info_has_grid_index_list(nnc_info, 2) ); test_assert_NULL(nnc_vector_null); nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info ); const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr ); test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self ); - const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr); - const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info); - test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self ); + const std::vector& nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr); + const std::vector& nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info); + test_assert_ptr_equal( nnc_cells_77.data() , nnc_cells_self.data() ); test_assert_int_equal( 2 , nnc_info_get_size( nnc_info )); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_pair.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_pair.cpp index 2827077c4e..4f807b6e50 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_pair.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_pair.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_nnc_pair.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_test.cpp index 5a7d72d958..e84d672cbe 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,9 +18,12 @@ #include #include +#include + #include #include #include +#include #include #include @@ -55,9 +58,9 @@ void test_scan( const char * grid_filename) { if (g2 < ecl_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 ); - const int_vector_type * index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr); + const std::vector& index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr); test_assert_not_NULL( nnc_info ); - test_assert_int_not_equal( -1 , int_vector_index( index_list , g2 )); + test_assert_int_not_equal( -1 , vector_util_index( index_list , g2 )); } } } @@ -79,9 +82,9 @@ void test_scan( const char * grid_filename) { const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( ecl_grid , g ); test_assert_not_NULL( nnc_info ); { - const int_vector_type * index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr ); - test_assert_not_NULL( index_list ); - test_assert_int_not_equal( -1 , int_vector_index( index_list , l )); + const std::vector& index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr ); + test_assert_true(nnc_info_has_grid_index_list( nnc_info , lgr_nr ) ); + test_assert_int_not_equal( -1 , vector_util_index( index_list , l )); } } } @@ -102,9 +105,9 @@ void test_scan( const char * grid_filename) { const int g2 = ecl_kw_iget_int( nnc2_kw , i ) - 1; const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( lgr1 , g1 ); - const int_vector_type * index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr2); + const std::vector& index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr2); test_assert_not_NULL( nnc_info ); - test_assert_int_not_equal( -1 , int_vector_index( index_list , g2 )); + test_assert_int_not_equal( -1 , vector_util_index( index_list , g2 )); } } } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_vector.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_vector.cpp index e568531756..7c12598534 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_vector.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_nnc_vector.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_vector.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -41,17 +43,17 @@ void test_basic() { test_assert_int_equal( 6 , nnc_vector_get_size( vector )); { - const int_vector_type * grid_index_list = nnc_vector_get_grid_index_list( vector ); - const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( vector ); + const std::vector& grid_index_list = nnc_vector_get_grid_index_list( vector ); + const std::vector& nnc_index_list = nnc_vector_get_nnc_index_list( vector ); - test_assert_int_equal( 6 , int_vector_size( nnc_index_list )); - test_assert_int_equal( 1 , int_vector_iget( nnc_index_list , 0 )); - test_assert_int_equal( 6 , int_vector_iget( nnc_index_list , 5 )); + test_assert_int_equal( 6 , nnc_index_list.size() ); + test_assert_int_equal( 1 , nnc_index_list[0] ); + test_assert_int_equal( 6 , nnc_index_list[5] ); - test_assert_int_equal( 6 , int_vector_size( grid_index_list )); - test_assert_int_equal( 100 , int_vector_iget( grid_index_list , 0 )); - test_assert_int_equal( 200 , int_vector_iget( grid_index_list , 1 )); - test_assert_int_equal( 300 , int_vector_iget( grid_index_list , 2 )); + test_assert_int_equal( 6 , grid_index_list.size() ); + test_assert_int_equal( 100 , grid_index_list[0] ); + test_assert_int_equal( 200 , grid_index_list[1] ); + test_assert_int_equal( 300 , grid_index_list[2] ); } nnc_vector_free( vector ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_region.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_region.cpp index 2ddf344fa3..98d0961b8a 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_region.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_region.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_region.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_region2region.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_region2region.cpp index 3402bf92fa..a5dcc685f0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_region2region.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_region2region.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_region2region.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_restart_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_restart_test.cpp index f36d0297ea..3fbe747b50 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_restart_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_restart_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_restart_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_rft.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_rft.cpp index fd7c698ae9..f7a9a18811 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_rft.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_rft.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_rft.c' is part of ERT - Ensemble based Reservoir Tool. @@ -40,10 +40,9 @@ void test_rft_read_write(const char * rft_file){ 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)); nodes[2]=new_node; - test_work_area_type * work_area = test_work_area_alloc("RFT_RW"); + ecl::util::TestArea ta("rft"); ecl_rft_file_update("eclipse.rft", nodes,3, ECL_METRIC_UNITS); - test_work_area_free(work_area); free(nodes); } @@ -81,8 +80,6 @@ void test_rft( const char * rft_file ) { test_assert_ptr_equal( cell1 , cell2 ); } } - ecl_rft_node_inplace_sort_cells( rft_node ); - ecl_rft_file_free( rft ); } @@ -94,7 +91,6 @@ void test_plt_msw( const char * plt_file ) { 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 )); - ecl_rft_node_inplace_sort_cells( plt_node ); { int i; for (i=1; i < ecl_rft_node_get_size( plt_node ); i++) { @@ -143,7 +139,6 @@ void test_plt( const char * plt_file ) { test_assert_ptr_equal( cell1 , cell2 ); } - ecl_rft_node_inplace_sort_cells( plt_node ); } ecl_rft_file_free( plt ); @@ -159,7 +154,7 @@ void test_simple_load_rft(const char * filename) { int main( int argc , char ** argv) { const char * rft_file = argv[1]; const char * mode_string = argv[2]; - + util_install_signals(); if (strcmp( mode_string , "RFT") == 0) test_rft( rft_file ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_rft_cell.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_rft_cell.cpp index 03e0be4bcc..cd9e82cbc0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_rft_cell.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_rft_cell.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_rft_cell.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_rst_file.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_rst_file.cpp index 50d1bb6703..b708490790 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_rst_file.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_rst_file.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ecl_rst_file.c' is part of ERT - Ensemble based Reservoir Tool. @@ -65,7 +65,7 @@ void test_file( const char * src_file , const char * target_file , int report_st void test_Xfile() { - test_work_area_type * work_area = test_work_area_alloc("rst-file"); + ecl::util::TestArea ta("xfile"); { fortio_type * f = fortio_open_writer( "TEST.X0010" , false , ECL_ENDIAN_FLIP); @@ -80,13 +80,12 @@ void test_Xfile() { fortio_fclose( f ); } test_file( "TEST.X0010" , "FILE.X0010" , 10 , 0 ); - test_work_area_free( work_area ); } void test_UNRST0() { - test_work_area_type * work_area = test_work_area_alloc("rst-file"); + ecl::util::TestArea ta("rst-file"); offset_type pos10; offset_type pos20; offset_type pos_end; @@ -118,12 +117,11 @@ void test_UNRST0() { test_file( "TEST.UNRST" , "FILE.UNRST" , 15 , pos20 ); test_file( "TEST.UNRST" , "FILE.UNRST" , 20 , pos20 ); test_file( "TEST.UNRST" , "FILE.UNRST" , 25 , pos_end ); - test_work_area_free( work_area ); } void test_UNRST1() { - test_work_area_type * work_area = test_work_area_alloc("rst-file"); + ecl::util::TestArea ta("rst-file"); offset_type pos5; offset_type pos10; offset_type pos20; @@ -158,7 +156,6 @@ void test_UNRST1() { test_file( "TEST.UNRST" , "FILE.UNRST" , 15 , pos20 ); test_file( "TEST.UNRST" , "FILE.UNRST" , 20 , pos20 ); test_file( "TEST.UNRST" , "FILE.UNRST" , 25 , pos_end ); - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_rsthead.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_rsthead.cpp index c690d71535..ab551c685c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_rsthead.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_rsthead.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_rst_header.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.cpp index 6ee378897e..963ce03f41 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. @@ -23,28 +23,13 @@ #include #include -void test_sort( ecl_smspec_type * smspec ) -{ - int num_nodes = ecl_smspec_num_nodes( smspec ); - ecl_smspec_sort( smspec ); - test_assert_int_equal( num_nodes, ecl_smspec_num_nodes( smspec )); - - for (int i=1; i < ecl_smspec_num_nodes( smspec ); i++) { - const smspec_node_type * node1 = ecl_smspec_iget_node( smspec, i - 1 ); - const smspec_node_type * node2 = ecl_smspec_iget_node( smspec, i ); - test_assert_true( smspec_node_cmp( node1 , node2 ) <= 0 ); - - test_assert_int_equal( smspec_node_get_params_index( node1 ) , i - 1 ); - } -} - 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 smspec_node_type * node = ecl_smspec_iget_node(smspec1, i); - ecl_sum_add_smspec_node(ecl_sum2, node); + const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(smspec1, i); + ecl_sum_add_smspec_node(ecl_sum2, &node); } test_assert_true( ecl_smspec_equal(smspec1, smspec2)); ecl_sum_free(ecl_sum2); @@ -63,8 +48,6 @@ int main(int argc, char ** argv) { test_assert_false( ecl_smspec_equal( smspec1 , smspec2 )); test_assert_false( ecl_smspec_equal( smspec2 , smspec1 )); - test_sort( smspec1 ); - test_sort( smspec2 ); ecl_smspec_free( smspec1 ); ecl_smspec_free( smspec2 ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec_node.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec_node.cpp index 7806fc8dec..bc0efbe740 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec_node.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec_node.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. @@ -25,94 +25,158 @@ #include +static void test_identify_rate_variable() { + const char* rate_vars[] = { + "WOPR" , "GGPR" , "FWPR" , "WLPR" , "WOIR" , "FGIR" , "GWIR" , + "WLIR" , "GGOR" , "FWCT" , "SOFR" , "SGFR" , "SWFR" , + }; + + const auto n_var = sizeof(rate_vars) / sizeof(rate_vars[0]); + + for (auto var = rate_vars, end = rate_vars + n_var; var != end; ++var) + test_assert_true(smspec_node_identify_rate(*var)); + + test_assert_false(smspec_node_identify_rate("SPR")); + test_assert_false(smspec_node_identify_rate("SOFT")); + test_assert_false(smspec_node_identify_rate("SGFT")); + test_assert_false(smspec_node_identify_rate("SWFT")); +} + +static void test_identify_total_variable() { + test_assert_true(smspec_node_identify_total("WOPT", ECL_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GGPT", ECL_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FWPT", ECL_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("RGIT", ECL_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("CWIT", ECL_SMSPEC_COMPLETION_VAR)); + + test_assert_true(smspec_node_identify_total("WOPTF", ECL_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GOPTS", ECL_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FOIT", ECL_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("ROVPT", ECL_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("COVIT", ECL_SMSPEC_COMPLETION_VAR)); + + test_assert_true(smspec_node_identify_total("WMWT", 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("RGMT", ECL_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("CGPTF", ECL_SMSPEC_COMPLETION_VAR)); + + test_assert_true(smspec_node_identify_total("WSGT", ECL_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GGST", ECL_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FFGT", ECL_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("RGCT", ECL_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("CGIMT", ECL_SMSPEC_COMPLETION_VAR)); + + test_assert_true(smspec_node_identify_total("WWGPT", ECL_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GWGIT", ECL_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FEGT", ECL_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("REXGT", ECL_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("CGVPT", ECL_SMSPEC_COMPLETION_VAR)); + + test_assert_true(smspec_node_identify_total("WGVIT", ECL_SMSPEC_WELL_VAR)); + test_assert_true(smspec_node_identify_total("GLPT", ECL_SMSPEC_GROUP_VAR)); + test_assert_true(smspec_node_identify_total("FVPT", ECL_SMSPEC_FIELD_VAR)); + test_assert_true(smspec_node_identify_total("RVIT", ECL_SMSPEC_REGION_VAR)); + test_assert_true(smspec_node_identify_total("CNPT", ECL_SMSPEC_COMPLETION_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)); + + 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_false(smspec_node_identify_total("SOPT", ECL_SMSPEC_SEGMENT_VAR)); + test_assert_false(smspec_node_identify_total("HEI!", ECL_SMSPEC_SEGMENT_VAR)); + test_assert_false(smspec_node_identify_total("xXx", ECL_SMSPEC_SEGMENT_VAR)); + test_assert_false(smspec_node_identify_total("SPR", ECL_SMSPEC_SEGMENT_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, ":"); + + int default_nums = 0; + /* + The integer constant default nums corresponds to the symbol nums_unused + in smspec_node.cpp. It is duplicated here to avoid exporting it - it should + not really be a publically available symbol. + */ + + test_assert_int_equal( field_node.get_num(), default_nums); + test_assert_int_equal( group_node.get_num(), default_nums); + test_assert_int_equal( well_node.get_num(), default_nums); +} + + void test_cmp_types() { const int dims[3] = {10,10,10}; - smspec_node_type * field_node = smspec_node_alloc( ECL_SMSPEC_FIELD_VAR , NULL , "FOPT" , "UNIT" , ":" , dims , 0 , 0 , 0 ); - smspec_node_type * region_node = smspec_node_alloc( ECL_SMSPEC_REGION_VAR , NULL , "RPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * group_node = smspec_node_alloc( ECL_SMSPEC_GROUP_VAR , "G1" , "GOPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * well_node = smspec_node_alloc( ECL_SMSPEC_WELL_VAR , "W1" , "WOPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * block_node = smspec_node_alloc( ECL_SMSPEC_BLOCK_VAR , NULL , "BPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * aquifer_node = smspec_node_alloc( ECL_SMSPEC_AQUIFER_VAR , NULL , "AAQP" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * segment_node = smspec_node_alloc( ECL_SMSPEC_SEGMENT_VAR , "W1" , "SGOR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * misc_node1 = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , NULL , "TIME" , "UNIT" , ":", dims, 10 , 0, 0); - smspec_node_type * misc_node2 = smspec_node_alloc( ECL_SMSPEC_MISC_VAR , NULL , "TCPU" , "UNIT" , ":", dims, 10 , 0, 0); + 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); - test_assert_int_equal( smspec_node_cmp( field_node , field_node ), 0); - test_assert_int_equal( smspec_node_cmp( region_node , region_node ), 0); - test_assert_int_equal( smspec_node_cmp( well_node , well_node ), 0); - test_assert_int_equal( smspec_node_cmp( group_node , group_node ), 0); - test_assert_int_equal( smspec_node_cmp( block_node , block_node ), 0); + test_assert_int_equal( field_node.cmp(field_node), 0); + test_assert_int_equal( region_node.cmp(region_node), 0); + test_assert_int_equal( well_node.cmp(well_node), 0); + test_assert_int_equal( group_node.cmp(group_node), 0); + test_assert_int_equal( block_node.cmp(block_node), 0); - test_assert_true( smspec_node_cmp( misc_node1 , field_node ) < 0 ); - test_assert_true( smspec_node_cmp( field_node , region_node ) < 0 ); - test_assert_true( smspec_node_cmp( region_node , group_node ) < 0 ); - test_assert_true( smspec_node_cmp( group_node , well_node ) < 0 ); - test_assert_true( smspec_node_cmp( well_node , segment_node ) < 0 ); - test_assert_true( smspec_node_cmp( segment_node , block_node ) < 0 ); - test_assert_true( smspec_node_cmp( block_node , aquifer_node) < 0 ); - test_assert_true( smspec_node_cmp( aquifer_node , misc_node2 ) < 0 ); + test_assert_true( misc_node1.cmp(field_node) < 0 ); + test_assert_true( field_node.cmp(region_node) < 0 ); + test_assert_true( region_node.cmp(group_node) < 0 ); + test_assert_true( group_node.cmp(well_node) < 0 ); + test_assert_true( well_node.cmp(segment_node) < 0 ); + test_assert_true( segment_node.cmp(block_node) < 0 ); + test_assert_true( block_node.cmp(aquifer_node)< 0 ); + test_assert_true( aquifer_node.cmp(misc_node2) < 0 ); - test_assert_true( smspec_node_cmp( field_node, misc_node1) > 0 ); - test_assert_true( smspec_node_cmp( misc_node2, aquifer_node) > 0 ); - test_assert_true( smspec_node_cmp( misc_node1, misc_node2) < 0 ); - test_assert_true( smspec_node_cmp( misc_node2, misc_node1) > 0 ); - - smspec_node_free( segment_node ); - smspec_node_free( aquifer_node ); - smspec_node_free( block_node ); - smspec_node_free( group_node ); - smspec_node_free( well_node ); - smspec_node_free( region_node ); - smspec_node_free( field_node ); - smspec_node_free( misc_node1 ); - smspec_node_free( misc_node2 ); + test_assert_true( field_node.cmp(misc_node1) > 0 ); + test_assert_true( misc_node2.cmp(aquifer_node) > 0 ); + test_assert_true( misc_node1.cmp(misc_node2) < 0 ); + test_assert_true( misc_node2.cmp(misc_node1) > 0 ); } void test_cmp_well() { - const int dims[3] = {10,10,10}; - smspec_node_type * well_node1_1 = smspec_node_alloc( ECL_SMSPEC_WELL_VAR , "W1" , "WOPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * well_node1_2 = smspec_node_alloc( ECL_SMSPEC_WELL_VAR , "W2" , "WOPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * well_node2_1 = smspec_node_alloc( ECL_SMSPEC_WELL_VAR , "W1" , "WWCT" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * well_node2_2 = smspec_node_alloc( ECL_SMSPEC_WELL_VAR , "W2" , "WWWT" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * well_node_dummy = smspec_node_alloc( ECL_SMSPEC_WELL_VAR , DUMMY_WELL , "WOPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); + 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 ,":"); - test_assert_NULL( well_node_dummy); - test_assert_int_equal( smspec_node_cmp( well_node1_1 , well_node1_1 ), 0); - test_assert_int_equal( smspec_node_cmp( well_node2_2 , well_node2_2 ), 0); + test_assert_int_equal( well_node1_1.cmp(well_node1_1), 0); + test_assert_int_equal( well_node2_2.cmp(well_node2_2), 0); - test_assert_true( smspec_node_cmp( well_node1_1, well_node1_2) < 0 ); - test_assert_true( smspec_node_cmp( well_node1_1, well_node2_1) < 0 ); - test_assert_true( smspec_node_cmp( well_node1_1, well_node2_2) < 0 ); + test_assert_true( well_node1_1.cmp(well_node1_2)< 0 ); + test_assert_true( well_node1_1.cmp(well_node2_1)< 0 ); + test_assert_true( well_node1_1.cmp(well_node2_2)< 0 ); - test_assert_true( smspec_node_cmp( well_node1_2, well_node1_1) > 0 ); - test_assert_true( smspec_node_cmp( well_node1_2, well_node2_1) < 0 ); - - smspec_node_free( well_node1_1 ); - smspec_node_free( well_node2_1 ); - smspec_node_free( well_node1_2 ); - smspec_node_free( well_node2_2 ); + test_assert_true( well_node1_2.cmp(well_node1_1)> 0 ); + test_assert_true( well_node1_2.cmp(well_node2_1)< 0 ); } void test_cmp_region() { const int dims[3] = {10,10,10}; - smspec_node_type * region_node1_1 = smspec_node_alloc( ECL_SMSPEC_REGION_VAR , NULL , "ROIP" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * region_node1_2 = smspec_node_alloc( ECL_SMSPEC_REGION_VAR , NULL , "ROIP" , "UNIT" , ":" , dims , 11 , 0 , 0 ); - smspec_node_type * region_node2_1 = smspec_node_alloc( ECL_SMSPEC_REGION_VAR , NULL , "RPR" , "UNIT" , ":" , dims , 10 , 0 , 0 ); - smspec_node_type * region_node2_2 = smspec_node_alloc( ECL_SMSPEC_REGION_VAR , NULL , "RPR" , "UNIT" , ":" , dims , 12 , 0 , 0 ); + 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 , ":" ); - test_assert_true( smspec_node_cmp( region_node1_1, region_node1_2) < 0 ); - test_assert_true( smspec_node_cmp( region_node1_1, region_node2_1) < 0 ); - test_assert_true( smspec_node_cmp( region_node1_1, region_node2_2) < 0 ); + test_assert_true( region_node1_1.cmp(region_node1_2)< 0 ); + test_assert_true( region_node1_1.cmp(region_node2_1)< 0 ); + test_assert_true( region_node1_1.cmp(region_node2_2)< 0 ); - test_assert_true( smspec_node_cmp( region_node1_2, region_node1_1) > 0 ); - test_assert_true( smspec_node_cmp( region_node1_2, region_node2_1) < 0 ); - - smspec_node_free( region_node1_1 ); - smspec_node_free( region_node2_1 ); - smspec_node_free( region_node1_2 ); - smspec_node_free( region_node2_2 ); + test_assert_true( region_node1_2.cmp(region_node1_1)> 0 ); + test_assert_true( region_node1_2.cmp(region_node2_1)< 0 ); } @@ -121,4 +185,7 @@ int main(int argc, char ** argv) { test_cmp_types(); test_cmp_well(); test_cmp_region( ); + test_identify_rate_variable(); + test_identify_total_variable(); + test_nums_default(); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.cpp index 3eb32c2f5a..ae98f6acb4 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.cpp @@ -3,6 +3,7 @@ #include #include +#include ecl_sum_type * test_alloc_ecl_sum() { time_t start_time = util_make_date_utc( 1,1,2010 ); @@ -12,16 +13,16 @@ ecl_sum_type * test_alloc_ecl_sum() { int num_dates = 4; double ministep_length = 86400; // seconds in a day - smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); - smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); + 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 ); 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 ); + 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 ); } sim_seconds += ministep_length * 3; @@ -37,19 +38,19 @@ void test_correct_time_vector() { 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); + 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) , util_make_date_utc( 6,1,2010 )); const ecl_smspec_type * smspec_resampled = ecl_sum_get_smspec(ecl_sum_resampled); - const smspec_node_type * node1 = ecl_smspec_iget_node(smspec_resampled, 1); - const smspec_node_type * node2 = ecl_smspec_iget_node(smspec_resampled, 2); - const smspec_node_type * node3 = ecl_smspec_iget_node(smspec_resampled, 3); - test_assert_string_equal( "BPR" , smspec_node_get_keyword(node2) ); - test_assert_string_equal( "BARS" , smspec_node_get_unit(node2) ); + 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); + 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) ); - test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_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) ); + test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_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) ); + test_assert_double_equal(10.0000, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 4,1,2010 ), &node3) ); ecl_sum_free(ecl_sum_resampled); @@ -57,23 +58,38 @@ void test_correct_time_vector() { ecl_sum_free(ecl_sum); } -void test_time_before() { - ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); - time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); - time_t_vector_append(t, util_make_date_utc( 1,1,2009 )); - test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) ); - time_t_vector_free(t); - ecl_sum_free(ecl_sum); -} -void test_time_after() { - ecl_sum_type * ecl_sum = test_alloc_ecl_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( 11,1,2010 )); - test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) ); - time_t_vector_free(t); - ecl_sum_free(ecl_sum); +void test_resample_extrapolate_rate() { + + ecl_sum_type * ecl_sum = test_alloc_ecl_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); + + + 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); + + + //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)); + test_assert_double_equal(10.000, ecl_sum_get_from_sim_time( ecl_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)); + + //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) ); + test_assert_double_equal(2.000, ecl_sum_get_from_sim_time( ecl_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) ); + + + ecl_sum_free(ecl_sum_resampled); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); } void test_not_sorted() { @@ -82,7 +98,7 @@ void test_not_sorted() { 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) ); + test_assert_NULL( ecl_sum_alloc_resample( ecl_sum, "kk", t, false, false) ); time_t_vector_free(t); ecl_sum_free(ecl_sum); } @@ -90,8 +106,7 @@ void test_not_sorted() { int main() { test_correct_time_vector(); - test_time_before(); - test_time_after(); + test_resample_extrapolate_rate(); test_not_sorted(); return 0; } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_case_exists.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_case_exists.cpp index ed43da456d..a9f852388d 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_case_exists.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_case_exists.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_sum_case_exists.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp index 9a4e569894..3de2dd13a7 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp @@ -5,16 +5,21 @@ #include #include +#include +#include +#include +#include #include +#include /* CASE1 --------- -1 : BPR:1 100 200 300 400 -2 : BPR:2 110 210 310 410 -3 : BRP:3 120 220 320 430 +1 : BPR:1 100 200 300 400 500 600 700 800 900 .... +2 : BPR:2 110 210 310 410 510 610 710 810 910 .... +3 : BRP:3 120 220 320 420 520 620 720 820 920 .... @@ -51,13 +56,14 @@ Total CASE3: #define ieq(d,i,v) test_assert_double_equal(double_vector_iget(d,(i)), v) -void verify_CASE1() { +void verify_CASE1(int length) { ecl_sum_type * sum = ecl_sum_fread_alloc_case("CASE1", ":"); + int params_size = 4; // TIME, BPR:1, BPR:2, BPR:3 - for (int i=1; i < 4; i++) { + for (int i=1; i < params_size; i++) { double_vector_type * d = ecl_sum_alloc_data_vector(sum, i, false); - //test_assert_int_equal(4, double_vector_size(d)); - for (int j=0; j < 4; j++) { + 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), (i - 1)*10 + (j + 1)*100); } double_vector_free(d); @@ -72,37 +78,38 @@ void write_CASE1(bool unified) { ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( "CASE1" , false , unified, ":" , start_time , true , 10 , 10 , 10 ); double sim_seconds = 0; - int num_dates = 4; + int num_dates = 100; double ministep_length = 86400; // seconds in a day - smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 1 , "BARS" , 0.0 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 2 , "BARS" , 0.0 ); - smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 3 , "BARS" , 0.0 ); + 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 ); 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 ); + 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 ); } sim_seconds += ministep_length * 3; } ecl_sum_fwrite( ecl_sum ); ecl_sum_free(ecl_sum); - verify_CASE1(); + verify_CASE1(num_dates); } -void verify_CASE2() { +void verify_CASE2(int length) { ecl_sum_type * sum = ecl_sum_fread_alloc_case2__("CASE2", ":", false, true, 0); + const int params_size = 2; // TIME, BPR:2, BPR:1 - for (int i=0; i < 2; i++) { + for (int i=0; i < params_size; i++) { double_vector_type * d = ecl_sum_alloc_data_vector(sum, i+1, false); - //test_assert_int_equal(4, double_vector_size(d)); - for (int j=1; j < 4; j++) + 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), (1 - i)*100 + j*1000); double_vector_free(d); } @@ -111,9 +118,9 @@ void verify_CASE2() { sum = ecl_sum_fread_alloc_case("CASE2", ":"); - for (int i=0; i < 2; i++) { + for (int i=0; i < params_size; i++) { double_vector_type * d = ecl_sum_alloc_data_vector(sum, i+1, false); - //test_assert_int_equal(double_vector_size(d), 7); + test_assert_int_equal(double_vector_size(d), 7); ieq(d,0,(1 - i)*10 + 100); ieq(d,1,(1 - i)*10 + 200); ieq(d,2,(1 - i)*10 + 300); @@ -137,30 +144,31 @@ void write_CASE2(bool unified) { double sim_seconds = ministep_length * 2.5 * 3; ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer( "CASE2" , "CASE1", false , true , ":" , start_time , true , 10 , 10 , 10 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 2 , "BARS" , 0.0 ); - smspec_node_type * 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 * node1 = ecl_sum_add_var( ecl_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); + ecl_sum_tstep_set_from_node( tstep , *node1 , report_step*1000); + ecl_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); - verify_CASE2(); + verify_CASE2(num_dates); } } -void verify_CASE3() { +void verify_CASE3(int length) { + const int params_size = 3; ecl_sum_type * sum = ecl_sum_fread_alloc_case2__("CASE3", ":", false, true, 0); - for (int i=0; i < 3; i++) { + for (int i=0; i < params_size; i++) { double_vector_type * d = ecl_sum_alloc_data_vector(sum, i+1, false); - //test_assert_int_equal(4, double_vector_size(d)); - for (int j=0; j < 4; j++) { + 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), (2 - i)*1000 + (j + 1)*10000); } double_vector_free(d); @@ -168,15 +176,15 @@ void verify_CASE3() { ecl_sum_free(sum); sum = ecl_sum_fread_alloc_case("CASE3", ":"); - for (int i=0; i < 3; i++) { + for (int i=0; i < params_size; i++) { double_vector_type * d = ecl_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 smspec_node_type * node = ecl_smspec_iget_node(ecl_sum_get_smspec(sum), i); - double default_value = smspec_node_get_default(node); + const ecl::smspec_node& node = ecl_smspec_iget_node_w_params_index(ecl_sum_get_smspec(sum), i); + double default_value = node.get_default(); ieq(d,3,default_value); ieq(d,4,default_value); } else { @@ -190,12 +198,16 @@ void verify_CASE3() { double_vector_free(d); } + ecl_sum_vector_type * vector = ecl_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); + ecl_sum_free(sum); } void write_CASE3(bool unified) { - test_work_area_type * work_area = test_work_area_alloc("SMSPEC"); write_CASE2(unified); { time_t start_time = util_make_date_utc( 1,1,2010 ); @@ -204,29 +216,103 @@ void write_CASE3(bool unified) { double sim_seconds = ministep_length * 4.0 * 3; ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer( "CASE3" , "CASE2", false , true , ":" , start_time , true , 10 , 10 , 10 ); - smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 3 , "BARS" , 0.0 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 2 , "BARS" , 0.0 ); - smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 1 , "BARS" , 0.0 ); + 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 ); 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); + 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); } sim_seconds += ministep_length * 3; } ecl_sum_fwrite( ecl_sum ); ecl_sum_free(ecl_sum); - verify_CASE3(); + verify_CASE3(num_dates); } - test_work_area_free(work_area); } +void verify_CASE4() { + ecl_sum_type * sum = ecl_sum_fread_alloc_case("CASE4", ":"); + + double_vector_type * d; + d = ecl_sum_alloc_data_vector(sum, 0, false); double_vector_free(d); + d = ecl_sum_alloc_data_vector(sum, 1, false); double_vector_free(d); + d = ecl_sum_alloc_data_vector(sum, 2, false); double_vector_free(d); + d = ecl_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); + double frame[27]; //3 vectors X 9 data points pr. vector + ecl_sum_init_double_frame(sum, vector, frame); + test_assert_double_equal(frame[26], 40000); + ecl_sum_vector_free(vector); + + ecl_sum_free(sum); +} + + +void write_CASE4(bool unified) { + ecl::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); + 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, ":+:+:+:+"); + + 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"); + + int num_params = ecl_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); + 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); + 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); + fortio_fclose( f ); + + ecl_file_close(smspec_file); + ecl_file_close(sum_file); + verify_CASE4(); + } +} int main() { - write_CASE3(true); - write_CASE3(false); + write_CASE4(true); + write_CASE4(false); return 0; } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_compatible.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_compatible.cpp index 4cd4b1ece4..673755d55b 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_compatible.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_compatible.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_equal.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_equal.cpp index d9b30efa0e..93f8b3f572 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_equal.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_report_step_equal.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_restart.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_restart.cpp new file mode 100644 index 0000000000..aa247fcd29 --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_restart.cpp @@ -0,0 +1,167 @@ +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +/* + +CASE1 +--------- +1 : BPR:1 100 200 300 400 500 600 700 800 900 .... +2 : BPR:2 110 210 310 410 510 610 710 810 910 .... +3 : BRP:3 120 220 320 420 520 620 720 820 920 .... + + + +CASE2 +--------- +1 : BRP:2 1100 2100 3100 4100 +2 : BPR:1 1000 2000 3000 4000 + + + +Total CASE2: +------------ +1 : BPR:2 110 210 310 1100 2100 3100 4100 +2 : BRP:1 100 200 300 1000 2000 3000 4000 + + + +CASE3 +----- +1 : BPR:3 12000 22000 32000 42000 +2 : BRP:2 11000 21000 31000 41000 +3 : BPR:1 10000 20000 30000 40000 + + +Total CASE3: +------------ +1 : BPR:3 120 220 320 0 0 12000 22000 32000 42000 +2 : BPR:2 110 210 310 1100 2100 11000 21000 31000 41000 +3 : BPR:1 100 200 300 1000 2000 10000 20000 30000 40000 + +*/ + + +#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", ":"); + 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); + 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), (i - 1)*10 + (j + 1)*100); + } + double_vector_free(d); + } + ecl_sum_free(sum); +} + + +void verify_CASE2(int length) { + ecl_sum_type * sum = ecl_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); + 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), (1 - i)*100 + j*1000); + double_vector_free(d); + } + + ecl_sum_free(sum); + + sum = ecl_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); + test_assert_int_equal(double_vector_size(d), 4); + ieq(d,0,(1 - i)*100 + 1000); + ieq(d,1,(1 - i)*100 + 2000); + ieq(d,2,(1 - i)*100 + 3000); + ieq(d,3,(1 - i)*100 + 4000); + double_vector_free(d); + } + + ecl_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 ); + 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 ); + + 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 ); + } + sim_seconds += ministep_length * 3; + } + ecl_sum_fwrite( ecl_sum ); + ecl_sum_free(ecl_sum); + + verify_CASE1(num_dates); +} + + + + +void write_CASE2() { + bool unified = false; + write_CASE1(unified); + { + time_t start_time = util_make_date_utc( 1,1,2010 ); + 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( "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 ); + + 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); + } + sim_seconds += ministep_length * 3; + } + ecl_sum_fwrite( ecl_sum ); + ecl_sum_free(ecl_sum); + + util_unlink("CASE1.SMSPEC"); + + verify_CASE2(num_dates); + } +} + +int main() { + write_CASE2(); + return 0; +} diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.cpp index 9b049bdb79..58d6f693be 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.cpp index 2fb3abb4c9..9db9f9f4d6 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ecl_sum_writer.c' is part of ERT - Ensemble based Reservoir Tool. @@ -32,10 +32,13 @@ 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 ); double sim_seconds = 0; + ecl_smspec_type * smspec = ecl_sum_get_smspec( ecl_sum ); - smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); - smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); + 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); for (int report_step = 0; report_step < num_dates; report_step++) { for (int step = 0; step < num_ministep; step++) { @@ -43,13 +46,13 @@ double write_summary( const char * name , time_t start_time , int nx , int ny , { 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 ); + 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 ); - test_assert_double_equal( ecl_sum_tstep_get_from_node( tstep , node1 ), sim_seconds ); - test_assert_double_equal( ecl_sum_tstep_get_from_node( tstep , node2 ), sim_seconds*10 ); - test_assert_double_equal( ecl_sum_tstep_get_from_node( tstep , node3 ), sim_seconds*100 ); + test_assert_double_equal( ecl_sum_tstep_get_from_node( tstep , *node1 ), sim_seconds ); + test_assert_double_equal( ecl_sum_tstep_get_from_node( tstep , *node2 ), sim_seconds*10 ); + test_assert_double_equal( ecl_sum_tstep_get_from_node( tstep , *node3 ), sim_seconds*100 ); } sim_seconds += ministep_length; } @@ -61,20 +64,20 @@ double write_summary( const char * name , time_t start_time , int nx , int ny , int write_restart_summary(const char * name, const char * restart_name , int start_report_step, double sim_seconds, 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( name , restart_name, false , true , ":" , start_time , true , nx , ny , nz ); + ecl_smspec_type * smspec = ecl_sum_get_smspec( ecl_sum ); - - smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); - smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); + 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 ); 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 ); + 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 ); } sim_seconds += ministep_length; @@ -97,17 +100,24 @@ void test_write_read( ) { int num_ministep = 10; double ministep_length = 86400; // Seconds - numerical value chosen to avoid rounding problems when converting between seconds and days. { - test_work_area_type * work_area = test_work_area_alloc("sum/write"); ecl_sum_type * ecl_sum; - write_summary( name , start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); + auto seconds = 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 )); + printf("days: %g \n", seconds / 86400.0 ); + /* 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)); util_inplace_forward_seconds_utc(&end_time, (num_dates * num_ministep - 1) * ministep_length ); + { + time_t et = ecl_sum_get_end_time(ecl_sum); + printf("days: %g \n", 1.0 * (et - start_time) / 86400); + printf("days: %g \n", 1.0 * (end_time - start_time) / 86400); + printf("%ld %ld diff:%ld fraction:%g \n", end_time, et, end_time - et , 1.0 * et / end_time); + } test_assert_time_t_equal( end_time , ecl_sum_get_end_time(ecl_sum)); /* Keys */ @@ -126,14 +136,13 @@ void test_write_read( ) { } ecl_sum_free( ecl_sum ); - test_work_area_free( work_area ); + //test_work_area_free( work_area ); } } void test_ecl_sum_alloc_restart_writer() { - - test_work_area_type * work_area = test_work_area_alloc("sum_write_restart"); + ecl::util::TestArea ta("sum_write_restart"); { const char * name1 = "CASE1"; const char * name2 = "CASE2"; @@ -170,7 +179,6 @@ void test_ecl_sum_alloc_restart_writer() { ecl_file_close(restart_file); } - test_work_area_free( work_area ); } @@ -182,7 +190,7 @@ void test_long_restart_names() { strcat(restart_case, s); } const char * name = "THE_CASE"; - test_work_area_type * work_area = test_work_area_alloc("sum_write_restart_long_name"); + ecl::util::TestArea ta("suM_write_restart_long_name"); { int restart_step = 77; time_t start_time = util_make_date_utc( 1,1,2010 ); @@ -210,12 +218,10 @@ void test_long_restart_names() { ecl_smspec_free( smspec); } } - - test_work_area_free( work_area ); - } int main( int argc , char ** argv) { + util_install_signals(); test_write_read(); test_ecl_sum_alloc_restart_writer(); test_long_restart_names(); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp index 55606a6ffa..e142b78cab 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp @@ -17,16 +17,16 @@ ecl_sum_type * write_ecl_sum() { int num_dates = 4; double ministep_length = 86400; // seconds in a day - smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); - smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); - smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); + 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 ); 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 ); + 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 ); } sim_seconds += ministep_length * 3; @@ -36,7 +36,7 @@ ecl_sum_type * write_ecl_sum() { } void test_load() { - test_work_area_type * work_area = test_work_area_alloc("unsmry_loader"); + ecl::util::TestArea ta("ecl_sum_loader"); ecl_sum_type * ecl_sum = write_ecl_sum(); test_assert_true( util_file_exists("CASE.SMSPEC") ); test_assert_true( util_file_exists("CASE.UNSMRY") ); @@ -52,7 +52,6 @@ void test_load() { delete loader; ecl_sum_free(ecl_sum); - test_work_area_free(work_area); } int main() { diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.cpp index 65bc7d58fd..afc25cb970 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. The file 'ecl_util_filenames.c' is part of ERT - Ensemble based Reservoir Tool. @@ -33,14 +33,21 @@ void test_filename_report_nr() { } void test_filename_case() { - test_assert_NULL( ecl_util_alloc_filename(NULL, "mixedBase", ECL_EGRID_FILE, false, -1)); - test_assert_string_equal( ecl_util_alloc_filename(NULL, "UPPER", ECL_EGRID_FILE, false, -1), "UPPER.EGRID"); - test_assert_string_equal( ecl_util_alloc_filename(NULL , "lower", ECL_EGRID_FILE, false, -1), "lower.egrid"); + 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); + + test_assert_NULL( f1 ); + test_assert_string_equal( f2 , "UPPER.EGRID"); + test_assert_string_equal( f3 , "lower.egrid"); + + free(f2); + free(f3); } void test_file_list() { - test_work_area_type * work_area = test_work_area_alloc("RESTART_FILES"); + ecl::util::TestArea ta("file_list"); stringlist_type * s = stringlist_alloc_new(); for (int i = 0; i < 10; i += 2) { @@ -109,7 +116,6 @@ void test_file_list() { test_assert_int_equal(stringlist_get_size(s), 10); stringlist_free(s); - test_work_area_free(work_area); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_no_shift.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_no_shift.cpp index b4d6cc1eaa..6af65736e0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_no_shift.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_no_shift.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_util_make_date_no_shift.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_shift.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_shift.cpp index 73fa007994..159a874b0f 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_shift.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_make_date_shift.cpp @@ -1,4 +1,4 @@ - /* Copyright (C) 2013 Statoil ASA, Norway. + /* Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_util_make_date_shift.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_month_range.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_util_month_range.cpp index afd3d7af11..f708805d15 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_util_month_range.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_month_range.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_util_month_range.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.cpp index 470acebe53..f1821756cb 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. The file 'ecl_util_path_access.c' is part of ERT - Ensemble based Reservoir Tool. @@ -27,7 +27,7 @@ void test_relative_access() { - test_work_area_type * work_area = test_work_area_alloc("access"); + ecl::util::TestArea ta("ecl_access"); test_assert_false( ecl_util_path_access("No/directory/does/not/exist")); util_make_path("path"); @@ -44,7 +44,6 @@ void test_relative_access() { test_assert_false( ecl_util_path_access("path/file")); test_assert_true( ecl_util_path_access("ECLIPSE_CASE")); - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_valid_basename.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_valid_basename.cpp index b275c4300f..f69e5d47d7 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_valid_basename.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_valid_basename.cpp @@ -5,7 +5,7 @@ * Author: joaho */ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_lgr_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_filename.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_filename.cpp index 1dd75bd20e..cb9b2e05c8 100644 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_filename.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/eclxx_filename.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_fortio.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_fortio.cpp index bbfab425cb..238572e725 100644 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_fortio.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/eclxx_fortio.cpp @@ -1,5 +1,5 @@ /* - Copyright 2015 Statoil ASA. + Copyright 2015 Equinor ASA. This file is part of the Open Porous Media project (OPM). @@ -28,7 +28,7 @@ void test_open() { - test_work_area_type * work_area = test_work_area_alloc("FORTIO"); + ecl::util::TestArea ta("fortioxx"); ERT::FortIO fortio; fortio.open( "new_file" , std::fstream::out ); @@ -67,12 +67,11 @@ void test_open() { } test_assert_false( fortio.ftruncate( 0 )); fortio.close(); - test_work_area_free(work_area); } void test_fortio() { - test_work_area_type * work_area = test_work_area_alloc("FORTIO"); + ecl::util::TestArea ta("FORTIO"); ERT::FortIO fortio("new_file" , std::fstream::out ); { std::vector data; @@ -97,12 +96,11 @@ void test_fortio() { fortio.close(); test_assert_throw( ERT::FortIO fortio("file/does/not/exists" , std::fstream::in) , std::invalid_argument ); - test_work_area_free(work_area); } void test_fortio_kw() { - test_work_area_type * work_area = test_work_area_alloc("FORTIO"); + ecl::util::TestArea ta("fortio_kw"); std::vector< int > vec( 1000 ); for (size_t i =0 ; i < vec.size(); i++) @@ -123,12 +121,7 @@ void test_fortio_kw() { for (size_t i =0 ; i < kw.size(); i++) test_assert_int_equal( kw.at( i ), kw2.at( i ) ); - - fortio = ERT::FortIO("new_file" , std::fstream::in ); - test_assert_throw( ERT::EclKW::load(fortio) , std::invalid_argument ); - fortio.close(); } - test_work_area_free(work_area); } diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp index f348304c33..a3c561681c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp @@ -1,5 +1,5 @@ /* - Copyright 2015 Statoil ASA. + Copyright 2015 Equinor ASA. This file is part of the Open Porous Media project (OPM). @@ -170,7 +170,7 @@ void test_read_write() { std::vector s_data = {"S1", "S2", "S3"}; { - test_work_area_type * work_area = test_work_area_alloc("READ_WRITE"); + ecl::util::TestArea ta("kw-read-write"); { ERT::FortIO f("test_file", std::ios_base::out); ERT::write_kw(f, "DOUBLE", d_data); @@ -208,7 +208,6 @@ void test_read_write() { } ecl_file_close(f); - test_work_area_free(work_area); } } } diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_smspec.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_smspec.cpp deleted file mode 100644 index ca134cf6f9..0000000000 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_smspec.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright 2015 Statoil ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include -#include - -#include - -void test_smspec_copy() { - std::string kw( "FOPT" ); - ERT::smspec_node field( kw ); - - ERT::smspec_node copy( field ); -} - -void test_smspec_get() { - std::string kw( "FOPT" ); - ERT::smspec_node field( kw ); - - test_assert_true( field.get() != nullptr ); -} - -void test_smspec_move() { - std::string kw( "FOPT" ); - ERT::smspec_node field( kw ); - ERT::smspec_node move_ctor( std::move( field ) ); - auto move_assignment = std::move( move_ctor ); -} - -void test_smspec_wg() { - std::string wkw( "WWCT" ); - std::string gkw( "GWCT" ); - std::string wg( "OP1" ); - std::string gr( "WG1" ); - - ERT::smspec_node well( ECL_SMSPEC_WELL_VAR, wg, wkw ); - ERT::smspec_node group( ECL_SMSPEC_GROUP_VAR, gr, gkw ); - - test_assert_string_equal(well.key1() , "WWCT:OP1"); - test_assert_string_equal(well.keyword() , "WWCT"); - test_assert_true(well.wgname() == wg); - test_assert_true(well.type() == ECL_SMSPEC_WELL_VAR ); - - test_assert_string_equal(group.key1(), "GWCT:WG1"); - test_assert_string_equal(group.keyword() , "GWCT"); - test_assert_true(group.wgname() == gr); - test_assert_true(group.type() == ECL_SMSPEC_GROUP_VAR ); -} - -void test_smspec_field() { - std::string kw( "FOPT" ); - ERT::smspec_node field( kw ); - - test_assert_string_equal( field.key1() , "FOPT" ); - test_assert_true( field.keyword() == kw ); - test_assert_true( field.type() == ECL_SMSPEC_FIELD_VAR ); -} - -void test_smspec_block() { - std::string kw( "BPR" ); - int dims[ 3 ] = { 10, 10, 10 }; - int ijk[ 3 ] = { 5, 5, 5 }; - - ERT::smspec_node block( kw, dims, ijk ); - - // Observe that ERT::smspec_node( ) constructor is considered part - // of the developer API, with offset zero indices, whereas the - // key1() string is meant for user consumption and has offset 1 - - // what a mess! - test_assert_string_equal( block.key1(), "BPR:6,6,6" ); - test_assert_true( block.keyword() == kw ); - test_assert_true( block.type() == ECL_SMSPEC_BLOCK_VAR ); - test_assert_true( block.num() == 556 ); -} - -void test_smspec_misc() { - ERT::smspec_node tcpu( "TCPU" ); - test_assert_true( tcpu.type() == ECL_SMSPEC_MISC_VAR ); -} - - -void test_smspec_region() { - std::string kw( "ROIP" ); - int dims[ 3 ] = { 10, 10, 10 }; - ERT::smspec_node region( kw, dims, 0 ); - - test_assert_true( region.keyword() == kw ); - test_assert_true( region.type() == ECL_SMSPEC_REGION_VAR ); - test_assert_true( region.num() == 0 ); -} - -void test_smspec_completion() { - std::string kw( "CWIT" ); - std::string wg( "WELL1" ); - int dims[ 3 ] = { 10, 10, 10 }; - int ijk[ 3 ] = { 1, 1, 1 }; - ERT::smspec_node completion( kw, wg, dims, ijk ); - - test_assert_true( completion.keyword() == kw ); - test_assert_true( completion.type() == ECL_SMSPEC_COMPLETION_VAR ); - test_assert_true( completion.num() == 112 ); -} - -int main (int argc, char **argv) { - test_smspec_copy(); - test_smspec_move(); - test_smspec_get(); - test_smspec_wg(); - test_smspec_field(); - test_smspec_block(); - test_smspec_region(); - test_smspec_completion(); - test_smspec_misc(); -} diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_types.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_types.cpp index 7b04d9414d..c1098b2e0e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_types.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/eclxx_types.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/rft_test.cpp b/ThirdParty/Ert/lib/ecl/tests/rft_test.cpp index 4bd4b85f5f..fae3c59b93 100644 --- a/ThirdParty/Ert/lib/ecl/tests/rft_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/rft_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'rft_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/test_ecl_file_index.cpp b/ThirdParty/Ert/lib/ecl/tests/test_ecl_file_index.cpp index 59f59bb79e..5a4fc201ea 100644 --- a/ThirdParty/Ert/lib/ecl/tests/test_ecl_file_index.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/test_ecl_file_index.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'test_ecl_file_index.c' is part of ERT - Ensemble based Reservoir Tool. @@ -34,7 +34,7 @@ void test_load_nonexisting_file() { void test_create_and_load_index_file() { - test_work_area_type * work_area = test_work_area_alloc("ecl_file_index_testing"); + ecl::util::TestArea ta("Load_index"); { const char * file_name = "initial_data_file"; const char * index_file_name = "index_file"; @@ -98,7 +98,6 @@ void test_create_and_load_index_file() { ecl_kw_free(kw2); ecl_file_close( ecl_file_index ); } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/test_ecl_nnc_data.cpp b/ThirdParty/Ert/lib/ecl/tests/test_ecl_nnc_data.cpp index a68185e61f..cc5f3cf460 100644 --- a/ThirdParty/Ert/lib/ecl/tests/test_ecl_nnc_data.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/test_ecl_nnc_data.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'test_ecl_nnc_data.c' is part of ERT - Ensemble based Reservoir Tool. @@ -34,7 +34,7 @@ void test_alloc_global_only(bool data_in_file) { - test_work_area_type * work_area = test_work_area_alloc("nnc-INIT"); + ecl::util::TestArea ta("nnc-INIT"); { int nx = 10; int ny = 10; @@ -90,7 +90,6 @@ void test_alloc_global_only(bool data_in_file) { } ecl_grid_free( grid0 ); } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/test_transactions.cpp b/ThirdParty/Ert/lib/ecl/tests/test_transactions.cpp index 1d6f9933ad..057f3f4fbc 100644 --- a/ThirdParty/Ert/lib/ecl/tests/test_transactions.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/test_transactions.cpp @@ -1,6 +1,6 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'test_transactions.c' is part of ERT - Ensemble based Reservoir Tool. @@ -38,7 +38,7 @@ void test_transaction() { - test_work_area_type * work_area = test_work_area_alloc("ecl_file_index_testing"); + ecl::util::TestArea ta("index_testing"); { const char * file_name = "data_file"; fortio_type * fortio = fortio_open_writer(file_name, false, ECL_ENDIAN_FLIP); @@ -99,9 +99,10 @@ void test_transaction() { 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); } - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.cpp b/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.cpp index df88ed73af..55cd4c8563 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_branch_collection.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_conn.cpp b/ThirdParty/Ert/lib/ecl/tests/well_conn.cpp index c81907c0bc..95ed85fdcd 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_conn.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_conn.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_conn_CF.cpp b/ThirdParty/Ert/lib/ecl/tests/well_conn_CF.cpp index 27de6631d5..dc89d6a935 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_conn_CF.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_conn_CF.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_conn_collection.cpp b/ThirdParty/Ert/lib/ecl/tests/well_conn_collection.cpp index d988c1b1e6..b843a6cb3b 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_conn_collection.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_conn_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn_collection.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_conn_load.cpp b/ThirdParty/Ert/lib/ecl/tests/well_conn_load.cpp index 02fd157415..197d11f37d 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_conn_load.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_conn_load.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_dualp.cpp b/ThirdParty/Ert/lib/ecl/tests/well_dualp.cpp index 30315df48e..abcc652a50 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_dualp.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_dualp.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_dualp.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_info.cpp b/ThirdParty/Ert/lib/ecl/tests/well_info.cpp index 2daf549175..e2f4fe3df0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_info.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_info.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool. @@ -30,6 +30,7 @@ int main(int argc , char ** argv) { + util_install_signals(); const char * grid_file = argv[1]; ecl_grid_type * grid = ecl_grid_alloc( grid_file ); @@ -37,6 +38,9 @@ int main(int argc , char ** argv) { { well_info_type * well_info = well_info_alloc( grid ); test_assert_not_NULL( well_info ); + if (argc >= 3) + well_info_load_rstfile(well_info, argv[2], true); + well_info_free( well_info ); } ecl_grid_free( grid ); diff --git a/ThirdParty/Ert/lib/ecl/tests/well_lgr_load.cpp b/ThirdParty/Ert/lib/ecl/tests/well_lgr_load.cpp index 4e060c1772..86bfd96336 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_lgr_load.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_lgr_load.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_lgr_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment.cpp b/ThirdParty/Ert/lib/ecl/tests/well_segment.cpp index fd3062716a..512bf4be10 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_branch_conn_load.cpp b/ThirdParty/Ert/lib/ecl/tests/well_segment_branch_conn_load.cpp index 55761b2448..68b399ab4b 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_branch_conn_load.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_branch_conn_load.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_conn_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_collection.cpp b/ThirdParty/Ert/lib/ecl/tests/well_segment_collection.cpp index 8c28653adc..aafcded940 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_collection.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_collection.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.cpp b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.cpp index 9b53f16eaa..bd4d31b915 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_conn.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn_load.cpp b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn_load.cpp index 92b213fbfd..9de125c64c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn_load.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn_load.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_conn_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_load.cpp b/ThirdParty/Ert/lib/ecl/tests/well_segment_load.cpp index 6ca651d811..dc59ea1d4f 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_load.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_load.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_state.cpp b/ThirdParty/Ert/lib/ecl/tests/well_state.cpp index 436aad1cd0..7c12b932dc 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_state.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_state.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_state.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_state_load.cpp b/ThirdParty/Ert/lib/ecl/tests/well_state_load.cpp index e78acdfcd5..52bbf88a46 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_state_load.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_state_load.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_state_load.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_state_load_missing_RSEG.cpp b/ThirdParty/Ert/lib/ecl/tests/well_state_load_missing_RSEG.cpp index d20955352b..a80f7aeda7 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_state_load_missing_RSEG.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_state_load_missing_RSEG.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_state_load_missing_RSEG.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/ecl/tests/well_ts.cpp b/ThirdParty/Ert/lib/ecl/tests/well_ts.cpp index 7a4dba9dc9..9fe458d8cb 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_ts.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/well_ts.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. @@ -70,7 +70,8 @@ int main(int argc , char ** argv) { well_info_load_rstfile( well_info , stringlist_iget(file_list , i), true); well_info_free( well_info ); } - + ecl_grid_free( grid ); + free( grid_file ); exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp b/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp index 005419decf..46f5ef3e25 100644 --- a/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp +++ b/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_branch_collection.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,10 +18,10 @@ #include +#include + #include #include -#include -#include #include #include @@ -33,8 +33,8 @@ struct well_branch_collection_struct { UTIL_TYPE_ID_DECLARATION; - vector_type * __start_segments; - int_vector_type * index_map; + std::vector __start_segments; + std::vector index_map; }; @@ -43,19 +43,24 @@ static UTIL_SAFE_CAST_FUNCTION( well_branch_collection , WELL_BRANCH_COLLECTION_ well_branch_collection_type * well_branch_collection_alloc() { - well_branch_collection_type * branch_collection = (well_branch_collection_type*)util_malloc( sizeof * branch_collection ); + well_branch_collection_type * branch_collection = new well_branch_collection_type(); UTIL_TYPE_ID_INIT( branch_collection , WELL_BRANCH_COLLECTION_TYPE_ID ); - branch_collection->__start_segments = vector_alloc_new(); - branch_collection->index_map = int_vector_alloc(0 , -1 ); return branch_collection; } +namespace { +int well_branch_collection_safe_iget_index( const well_branch_collection_type * branches, int index ) { + if (index >= (int)branches->index_map.size()) + return -1; + else + return branches->index_map[index]; +} + +} void well_branch_collection_free( well_branch_collection_type * branches ) { - vector_free( branches->__start_segments ); - int_vector_free( branches->index_map ); - free( branches ); + delete branches; } @@ -67,12 +72,12 @@ void well_branch_collection_free__( void * arg ) { int well_branch_collection_get_size( const well_branch_collection_type * branches ) { - return vector_get_size( branches->__start_segments ); + return branches->__start_segments.size(); } bool well_branch_collection_has_branch( const well_branch_collection_type * branches , int branch_id) { - if (int_vector_safe_iget( branches->index_map , branch_id) >= 0) + if (well_branch_collection_safe_iget_index( branches , branch_id) >= 0) return true; else return false; @@ -81,8 +86,8 @@ bool well_branch_collection_has_branch( const well_branch_collection_type * bran const well_segment_type * well_branch_collection_iget_start_segment( const well_branch_collection_type * branches , int index ) { - if (index < vector_get_size( branches->__start_segments)) - return (const well_segment_type*)vector_iget_const( branches->__start_segments , index); + if (index < static_cast(branches->__start_segments.size())) + return branches->__start_segments[index]; else return NULL; } @@ -90,7 +95,7 @@ const well_segment_type * well_branch_collection_iget_start_segment( const well_ const well_segment_type * well_branch_collection_get_start_segment( const well_branch_collection_type * branches , int branch_id) { - int internal_index = int_vector_safe_iget( branches->index_map , branch_id); + int internal_index = well_branch_collection_safe_iget_index( branches , branch_id); if (internal_index >= 0) return well_branch_collection_iget_start_segment( branches , internal_index ); else @@ -98,16 +103,18 @@ const well_segment_type * well_branch_collection_get_start_segment( const well_b } -bool well_branch_collection_add_start_segment( well_branch_collection_type * branches , const well_segment_type * start_segment) { +bool well_branch_collection_add_start_segment( well_branch_collection_type * branches , well_segment_type * start_segment) { if ((well_segment_get_link_count( start_segment ) == 0) && (well_segment_get_outlet(start_segment))) { int branch_id = well_segment_get_branch_id( start_segment ); - int current_index = int_vector_safe_iget( branches->index_map , branch_id); + int current_index = well_branch_collection_safe_iget_index( branches , branch_id); if (current_index >= 0) - vector_iset_ref( branches->__start_segments , current_index , start_segment); + branches->__start_segments[current_index] = start_segment; else { - int new_index = vector_get_size( branches->__start_segments ); - vector_append_ref( branches->__start_segments , start_segment); - int_vector_iset( branches->index_map , branch_id , new_index); + int new_index = branches->__start_segments.size(); + branches->__start_segments.push_back(start_segment); + if (branch_id >= (int)branches->index_map.size()) + branches->index_map.resize(branch_id+1, -1); + branches->index_map[branch_id] = new_index; } return true; diff --git a/ThirdParty/Ert/lib/ecl/well_conn.cpp b/ThirdParty/Ert/lib/ecl/well_conn.cpp index eaa8a90ac4..e3f2f2a890 100644 --- a/ThirdParty/Ert/lib/ecl/well_conn.cpp +++ b/ThirdParty/Ert/lib/ecl/well_conn.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool. @@ -92,7 +92,7 @@ UTIL_SAFE_CAST_FUNCTION( well_conn , WELL_CONN_TYPE_ID) static well_conn_type * well_conn_alloc__( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open, int segment_id, bool matrix_connection) { if (well_conn_assert_direction( dir , matrix_connection)) { - well_conn_type * conn = (well_conn_type*)util_malloc( sizeof * conn ); + well_conn_type * conn = new well_conn_type(); UTIL_TYPE_ID_INIT( conn , WELL_CONN_TYPE_ID ); conn->i = i; conn->j = j; @@ -245,7 +245,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , void well_conn_free( well_conn_type * conn) { - free( conn ); + delete conn; } diff --git a/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp b/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp index 788d25440a..1616e796dc 100644 --- a/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp +++ b/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn_collection.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,9 +18,10 @@ #include +#include + #include #include -#include #include #include @@ -34,7 +35,8 @@ struct well_conn_collection_struct { UTIL_TYPE_ID_DECLARATION; - vector_type * connection_list; + std::vector connection_list; + std::vector connection_list_owned; }; @@ -43,9 +45,8 @@ static UTIL_SAFE_CAST_FUNCTION( well_conn_collection , WELL_CONN_COLLECTION_TYPE well_conn_collection_type * well_conn_collection_alloc() { - well_conn_collection_type * wellcc = (well_conn_collection_type*)util_malloc( sizeof * wellcc ); + well_conn_collection_type * wellcc = new well_conn_collection_type(); UTIL_TYPE_ID_INIT( wellcc , WELL_CONN_COLLECTION_TYPE_ID ); - wellcc->connection_list = vector_alloc_new(); return wellcc; } @@ -55,7 +56,8 @@ well_conn_collection_type * well_conn_collection_alloc() { */ void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_type * conn) { - vector_append_owned_ref( wellcc->connection_list , conn , well_conn_free__); + wellcc->connection_list.push_back(conn); + wellcc->connection_list_owned.push_back(true); } /* @@ -63,13 +65,16 @@ void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_ty */ void well_conn_collection_add_ref( well_conn_collection_type * wellcc , well_conn_type * conn) { - vector_append_ref( wellcc->connection_list , conn ); + wellcc->connection_list.push_back(conn); + wellcc->connection_list_owned.push_back(false); } void well_conn_collection_free( well_conn_collection_type * wellcc ) { - vector_free( wellcc->connection_list ); - free( wellcc ); + for (size_t i = 0; i < wellcc->connection_list.size(); i++) + if (wellcc->connection_list_owned[i]) + well_conn_free(wellcc->connection_list[i]); + delete wellcc; } void well_conn_collection_free__( void * arg ) { @@ -79,14 +84,14 @@ void well_conn_collection_free__( void * arg ) { int well_conn_collection_get_size( const well_conn_collection_type * wellcc ) { - return vector_get_size( wellcc->connection_list ); + return wellcc->connection_list.size(); } const well_conn_type * well_conn_collection_iget_const(const well_conn_collection_type * wellcc , int index) { int size = well_conn_collection_get_size( wellcc ); if (index < size) - return (const well_conn_type*)vector_iget_const( wellcc->connection_list , index ); + return wellcc->connection_list[index]; else return NULL; } @@ -95,7 +100,7 @@ const well_conn_type * well_conn_collection_iget_const(const well_conn_collectio well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index) { int size = well_conn_collection_get_size( wellcc ); if (index < size) - return (well_conn_type*)vector_iget( wellcc->connection_list , index ); + return wellcc->connection_list[index]; else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_info.cpp b/ThirdParty/Ert/lib/ecl/well_info.cpp index b838955ff9..94f6692dd7 100644 --- a/ThirdParty/Ert/lib/ecl/well_info.cpp +++ b/ThirdParty/Ert/lib/ecl/well_info.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_info.c' is part of ERT - Ensemble based Reservoir Tool. @@ -21,10 +21,10 @@ #include #include +#include +#include #include -#include -#include #include #include @@ -182,7 +182,7 @@ struct well_info_struct { - hash_type * wells; /* Hash table of well_ts_type instances; indexed by well name. */ + 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; }; @@ -195,23 +195,25 @@ struct well_info_struct { well_info_type * well_info_alloc( const ecl_grid_type * grid) { well_info_type * well_info = new well_info_type(); - well_info->wells = hash_alloc(); well_info->grid = grid; return well_info; } bool well_info_has_well( well_info_type * well_info , const char * well_name ) { - return hash_has_key( well_info->wells , well_name ); + const auto it = well_info->wells.find(well_name); + if (it == well_info->wells.end()) + return false; + return true; } well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name) { - return (well_ts_type*)hash_get( well_info->wells , well_name ); + return well_info->wells.at( well_name ); } static void well_info_add_new_ts( well_info_type * well_info , const char * well_name) { well_ts_type * well_ts = well_ts_alloc( well_name ) ; - hash_insert_hash_owned_ref( well_info->wells , well_name , well_ts , well_ts_free__); + well_info->wells[well_name] = well_ts; well_info->well_names.push_back( well_name ); } @@ -353,7 +355,9 @@ void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * ec } void well_info_free( well_info_type * well_info ) { - hash_free( well_info->wells ); + for (const auto& pair : well_info->wells) + well_ts_free(pair.second); + delete well_info; } diff --git a/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp b/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp index c0bc317cc2..43c757ec2d 100644 --- a/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp +++ b/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_info.c' is part of ERT - Ensemble based Reservoir Tool. @@ -79,6 +79,7 @@ double * well_rseg_loader_load_values(const well_rseg_loader_type * loader, int int_vector_type * index_map = loader->absolute_index_map; int index = 0; + int_vector_resize( index_map, int_vector_size(loader->relative_index_map), 0 ); for(index = 0; index < int_vector_size(loader->relative_index_map); index++) { int relative_index = int_vector_iget(loader->relative_index_map, index); int_vector_iset(index_map, index, relative_index + rseg_offset); diff --git a/ThirdParty/Ert/lib/ecl/well_segment.cpp b/ThirdParty/Ert/lib/ecl/well_segment.cpp index 8d3717847e..cfb041c7e8 100644 --- a/ThirdParty/Ert/lib/ecl/well_segment.cpp +++ b/ThirdParty/Ert/lib/ecl/well_segment.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,8 +18,10 @@ #include +#include +#include + #include -#include #include #include @@ -39,7 +41,8 @@ struct well_segment_struct { int branch_id; int outlet_segment_id; // This is in the global index space given by the ISEG keyword. well_segment_type * outlet_segment; - hash_type * connections; // hash_type; + std::map connections; // hash_type; double depth; // The depth of the segment node; furthest away from the wellhead. double length; @@ -53,7 +56,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_segment , WELL_SEGMENT_TYPE_ID ) well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , int branch_id , const double * rseg_data) { - well_segment_type * segment = (well_segment_type*)util_malloc( sizeof * segment ); + well_segment_type * segment = new well_segment_type(); UTIL_TYPE_ID_INIT( segment , WELL_SEGMENT_TYPE_ID ); segment->link_count = 0; @@ -61,7 +64,6 @@ well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , segment->outlet_segment_id = outlet_segment_id; segment->branch_id = branch_id; segment->outlet_segment = NULL; - segment->connections = hash_alloc(); segment->depth = 0.0; segment->length = 0.0; @@ -116,8 +118,10 @@ well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , co void well_segment_free(well_segment_type * segment ) { - hash_free( segment->connections ); - free( segment ); + for (auto& pair : segment->connections) + well_conn_collection_free(pair.second); + + delete segment; } void well_segment_free__(void * arg) { @@ -196,7 +200,10 @@ void well_segment_link_strict( well_segment_type * segment , well_segment_type * bool well_segment_has_grid_connections( const well_segment_type * segment , const char * grid_name) { - return hash_has_key( segment->connections , grid_name ); + const auto it = segment->connections.find(grid_name); + if (it == segment->connections.end()) + return false; + return true; } @@ -208,13 +215,11 @@ bool well_segment_has_global_grid_connections( const well_segment_type * segment bool well_segment_add_connection( well_segment_type * segment , const char * grid_name , well_conn_type * conn) { int conn_segment_id = well_conn_get_segment_id( conn ); if (conn_segment_id == segment->segment_id) { - if (!well_segment_has_grid_connections( segment , grid_name )) - hash_insert_hash_owned_ref( segment->connections , grid_name , well_conn_collection_alloc() , well_conn_collection_free__ ); - { - well_conn_collection_type * connections = (well_conn_collection_type*)hash_get( segment->connections , grid_name ); - well_conn_collection_add_ref( connections , conn ); - } + if (!well_segment_has_grid_connections(segment, grid_name)) + segment->connections[grid_name] = well_conn_collection_alloc(); + + well_conn_collection_add_ref( segment->connections[grid_name] , conn ); return true; } else return false; @@ -223,7 +228,7 @@ bool well_segment_add_connection( well_segment_type * segment , const char * gri const well_conn_collection_type * well_segment_get_connections(const well_segment_type * segment , const char * grid_name ) { if (well_segment_has_grid_connections( segment , grid_name)) - return (const well_conn_collection_type*)hash_get( segment->connections , grid_name); + return segment->connections.at(grid_name); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp b/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp index 841ee7d394..da9d1b3de8 100644 --- a/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp +++ b/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_collection.c' is part of ERT - Ensemble based Reservoir Tool. @@ -18,6 +18,8 @@ #include +#include + #include #include @@ -33,56 +35,61 @@ struct well_segment_collection_struct { - int_vector_type * segment_index_map; - vector_type * __segment_storage; + std::vector segment_index_map; + std::vector __segment_storage; }; well_segment_collection_type * well_segment_collection_alloc(void) { - well_segment_collection_type * segment_collection = (well_segment_collection_type*)util_malloc( sizeof * segment_collection ); - - segment_collection->__segment_storage = vector_alloc_new(); - segment_collection->segment_index_map = int_vector_alloc( 0 , -1 ); + well_segment_collection_type * segment_collection = new well_segment_collection_type(); return segment_collection; } void well_segment_collection_free(well_segment_collection_type * segment_collection ) { - vector_free( segment_collection->__segment_storage ); - int_vector_free( segment_collection->segment_index_map ); - free( segment_collection ); + for (int i = 0; i < static_cast(segment_collection->__segment_storage.size()); i++) + well_segment_free( segment_collection->__segment_storage[i] ); + delete segment_collection; } int well_segment_collection_get_size( const well_segment_collection_type * segment_collection ) { - return vector_get_size( segment_collection->__segment_storage ); + return segment_collection->__segment_storage.size(); } void well_segment_collection_add( well_segment_collection_type * segment_collection , well_segment_type * segment) { int segment_id = well_segment_get_id( segment ); - int current_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id ); - if (current_index >= 0) - vector_iset_owned_ref( segment_collection->__segment_storage , current_index , segment , well_segment_free__); + int current_index = -1; + if (segment_id < static_cast(segment_collection->segment_index_map.size())) + current_index = segment_collection->segment_index_map[segment_id]; + if (current_index >= 0) { + well_segment_free( segment_collection->__segment_storage[current_index] ); + segment_collection->__segment_storage[current_index] = segment; + } else { - int new_index = vector_get_size(segment_collection->__segment_storage); - vector_append_owned_ref( segment_collection->__segment_storage , segment , well_segment_free__); - int_vector_iset( segment_collection->segment_index_map , segment_id , new_index); + int new_index = segment_collection->__segment_storage.size(); + segment_collection->__segment_storage.push_back( segment ); + if ( segment_id >= static_cast(segment_collection->segment_index_map.size()) ) + segment_collection->segment_index_map.resize(segment_id+1, -1); + segment_collection->segment_index_map[segment_id] = new_index; } } well_segment_type * well_segment_collection_iget( const well_segment_collection_type * segment_collection , int index) { - return (well_segment_type*)vector_iget( segment_collection->__segment_storage , index ); + return segment_collection->__segment_storage[ index ]; } well_segment_type * well_segment_collection_get( const well_segment_collection_type * segment_collection , int segment_id) { - int internal_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id ); + int internal_index = -1; + if (segment_id < static_cast(segment_collection->segment_index_map.size())) + internal_index = segment_collection->segment_index_map[segment_id]; if (internal_index >= 0) return well_segment_collection_iget( segment_collection , internal_index ); else @@ -91,7 +98,9 @@ well_segment_type * well_segment_collection_get( const well_segment_collection_t bool well_segment_collection_has_segment( const well_segment_collection_type * segment_collection , int segment_id) { - int internal_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id ); + int internal_index = -1; + if (segment_id < static_cast(segment_collection->segment_index_map.size())) + internal_index = segment_collection->segment_index_map[segment_id]; if (internal_index >= 0) return true; else @@ -133,8 +142,8 @@ int well_segment_collection_load_from_kw( well_segment_collection_type * segment void well_segment_collection_link(const well_segment_collection_type * segment_collection) { - int index; - for (index = 0; index < vector_get_size( segment_collection->__segment_storage); index++) { + size_t index; + for (index = 0; index < segment_collection->__segment_storage.size(); index++) { well_segment_type * segment = well_segment_collection_iget( segment_collection , index ); int outlet_segment_id = well_segment_get_outlet_id( segment ); if (!well_segment_nearest_wellhead(segment)) { @@ -166,7 +175,7 @@ void well_segment_collection_add_branches( const well_segment_collection_type * well_branch_collection_type * branches ) { int iseg; for (iseg =0; iseg < well_segment_collection_get_size( segment_collection ); iseg++) { - const well_segment_type * segment = well_segment_collection_iget( segment_collection , iseg ); + well_segment_type * segment = well_segment_collection_iget( segment_collection , iseg ); if (well_segment_get_link_count( segment ) == 0) well_branch_collection_add_start_segment( branches , segment ); } diff --git a/ThirdParty/Ert/lib/ecl/well_state.cpp b/ThirdParty/Ert/lib/ecl/well_state.cpp index d0dc6c0273..67fedbe68e 100644 --- a/ThirdParty/Ert/lib/ecl/well_state.cpp +++ b/ThirdParty/Ert/lib/ecl/well_state.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_state.c' is part of ERT - Ensemble based Reservoir Tool. @@ -31,6 +31,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -105,7 +109,7 @@ links are as follows: Segment1: C2 Segment2: C3 Segment3: C4, C5 - Segment4: C6 + Segment4: C6state_free( Segment5: C7 Each segment has an outlet segment, which will link the segments @@ -164,7 +168,7 @@ coupledte implementation these objects are modelled as such: struct well_state_struct { UTIL_TYPE_ID_DECLARATION; - char * name; + std::string name; time_t valid_from_time; int valid_from_report; int global_well_nr; @@ -176,15 +180,15 @@ struct well_state_struct { double water_rate; double volume_rate; ert_ecl_unit_enum unit_system; - - hash_type * connections; // hash + + std::map connections; // hash well_segment_collection_type * segments; well_branch_collection_type * branches; /*****************************************************************/ - - vector_type * index_wellhead; // An well_conn_type instance representing the wellhead - indexed by grid_nr. - hash_type * name_wellhead; // An well_conn_type instance representing the wellhead - indexed by lgr_name. + + std::vector index_wellhead; // An well_conn_type instance representing the wellhead - indexed by grid_nr. + std::map name_wellhead; // An well_conn_type instance representing the wellhead - indexed by lgr_name. }; @@ -193,18 +197,15 @@ UTIL_IS_INSTANCE_FUNCTION( well_state , WELL_STATE_TYPE_ID) 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 = (well_state_type*)util_malloc( sizeof * well_state ); + well_state_type * well_state = new well_state_type(); UTIL_TYPE_ID_INIT( well_state , WELL_STATE_TYPE_ID ); - well_state->index_wellhead = vector_alloc_new(); - well_state->name_wellhead = hash_alloc(); - well_state->name = util_alloc_string_copy( well_name ); + well_state->name = well_name; well_state->valid_from_time = valid_from; well_state->valid_from_report = report_nr; well_state->open = open; well_state->type = type; well_state->global_well_nr = global_well_nr; - well_state->connections = hash_alloc(); well_state->segments = well_segment_collection_alloc(); well_state->branches = well_branch_collection_alloc(); well_state->is_MSW_well = false; @@ -291,8 +292,10 @@ void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_t well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , well_nr ); if (wellhead != NULL) { - vector_safe_iset_owned_ref( well_state->index_wellhead , grid_nr , wellhead , well_conn_free__ ); - hash_insert_ref( well_state->name_wellhead , grid_name , wellhead ); + if (grid_nr >= static_cast(well_state->index_wellhead.size())) + well_state->index_wellhead.resize(grid_nr+1, NULL); + well_state->index_wellhead[grid_nr] = wellhead; + well_state->name_wellhead[grid_name] = wellhead; } } @@ -342,7 +345,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons { char * lgr_well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); - if ( strcmp( well_state->name , lgr_well_name) == 0) + if ( well_state->name == lgr_well_name) found = true; else well_nr++; @@ -406,27 +409,29 @@ static void well_state_add_connections__( well_state_type * well_state , int well_nr ) { ecl_rsthead_type * header = ecl_rsthead_alloc( rst_view , -1); - const ecl_kw_type * icon_kw = ecl_file_view_iget_named_kw( rst_view , ICON_KW , 0); const ecl_kw_type * iwel_kw = ecl_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 (!well_state_has_grid_connections( well_state , grid_name )) - hash_insert_hash_owned_ref( well_state->connections , grid_name, well_conn_collection_alloc( ) , well_conn_collection_free__ ); + 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 (!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); + { + 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); - 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); + 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); + } + + well_conn_collection_type * wellcc = well_state->connections[grid_name]; + well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw, xcon_kw , well_nr , header ); } - - well_conn_collection_type * wellcc = (well_conn_collection_type*)hash_get( well_state->connections , grid_name ); - well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw, xcon_kw , well_nr , header ); } ecl_rsthead_free( header ); } @@ -447,10 +452,19 @@ static void well_state_add_LGR_connections(well_state_type * well_state, int num_lgr = ecl_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); - const char * grid_name = ecl_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 , lgr_index + 1, well_nr ); + /* + 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 + unchecked, and there might be bugs lurking based on the incorrect + assumption that if the grid has LGR information then the corresponding LGR + information can also be found in the restart file. + */ + if (lgr_view) { + const char * grid_name = ecl_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 , lgr_index + 1, well_nr ); + } } } @@ -515,13 +529,12 @@ bool well_state_add_MSW2( well_state_type * well_state , if (segment_count > 0) { - hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections ); - while (!hash_iter_is_complete( grid_iter )) { - const char * grid_name = hash_iter_get_next_key( grid_iter ); - const well_conn_collection_type * connections = (const well_conn_collection_type*)hash_get( well_state->connections , grid_name ); - well_segment_collection_add_connections( well_state->segments , grid_name , connections ); + + auto it = well_state->connections.begin(); + while (it != well_state->connections.end()) { + well_segment_collection_add_connections( well_state->segments , it->first.c_str() , it->second ); + it++; } - hash_iter_free( grid_iter ); well_segment_collection_link( well_state->segments ); well_segment_collection_add_branches( well_state->segments , well_state->branches ); @@ -607,14 +620,19 @@ well_state_type * well_state_alloc_from_file2( ecl_file_view_type * file_view , void well_state_free( well_state_type * well ) { - hash_free( well->name_wellhead ); - vector_free( well->index_wellhead ); - hash_free( well->connections ); + + for (size_t i = 0; i < well->index_wellhead.size(); i++) { + if (well->index_wellhead[i]) + well_conn_free(well->index_wellhead[i]); + } + + for (auto& pair : well->connections) + well_conn_collection_free(pair.second); + well_segment_collection_free( well->segments ); well_branch_collection_free( well->branches ); - free( well->name ); - free( well ); + delete well; } /*****************************************************************/ @@ -631,22 +649,30 @@ time_t well_state_get_sim_time( const well_state_type * well_state ) { Will return NULL if no wellhead in this grid. */ const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr) { - return (const well_conn_type*)vector_safe_iget_const( well_state->index_wellhead , grid_nr ); + if (grid_nr < static_cast(well_state->index_wellhead.size())) + return well_state->index_wellhead[grid_nr]; + else + return NULL; +} + + +bool well_state_has_named_well_conn( const well_state_type * well_state , const char * grid_name ) { + const auto it = well_state->name_wellhead.find( grid_name ); + if (it == well_state->name_wellhead.end()) + return false; + return true; } const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name) { - if (hash_has_key( well_state->name_wellhead , grid_name)) - return (const well_conn_type*)hash_get( well_state->name_wellhead , grid_name ); - else - return NULL; + const auto it = well_state->name_wellhead.find( grid_name ); + if (it != well_state->name_wellhead.end()) + return it->second; + return NULL; } const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state ) { - if (hash_has_key( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID)) - return (const well_conn_type*)hash_get( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID ); - else - return NULL; + return well_state_get_wellhead( well_state, ECL_GRID_GLOBAL_GRID ); } @@ -664,15 +690,15 @@ int well_state_get_well_nr( const well_state_type * well_state ) { const char * well_state_get_name( const well_state_type * well_state ) { - return well_state->name; + return well_state->name.c_str(); } /*****************************************************************/ const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name) { - if (hash_has_key( well_state->connections , grid_name)) - return (const well_conn_collection_type*)hash_get( well_state->connections , grid_name); + if (well_state_has_grid_connections(well_state, grid_name) ) + return well_state->connections.at(grid_name); else return NULL; } @@ -684,10 +710,11 @@ const well_conn_collection_type * well_state_get_global_connections( const well_ bool well_state_has_grid_connections( const well_state_type * well_state , const char * grid_name) { - if (hash_has_key( well_state->connections , grid_name)) - return true; - else + + const auto it = well_state->connections.find(grid_name); + if (it == well_state->connections.end()) return false; + return true; } diff --git a/ThirdParty/Ert/lib/ecl/well_ts.cpp b/ThirdParty/Ert/lib/ecl/well_ts.cpp index 6aa42d4c16..cfae4974c1 100644 --- a/ThirdParty/Ert/lib/ecl/well_ts.cpp +++ b/ThirdParty/Ert/lib/ecl/well_ts.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. @@ -62,6 +62,10 @@ #include #include +#include +#include +#include + #include #include @@ -84,14 +88,14 @@ typedef struct { struct well_ts_struct { UTIL_TYPE_ID_DECLARATION; - char * well_name; - vector_type * ts; + std::string well_name; + std::vector ts; }; /******************************************************************/ static well_node_type * well_node_alloc( well_state_type * well_state) { - well_node_type * node = (well_node_type*)util_malloc( sizeof * node ); + well_node_type * node = new well_node_type(); UTIL_TYPE_ID_INIT( node , WELL_NODE_TYPE_ID ); node->report_nr = well_state_get_report_nr( well_state ); node->sim_time = well_state_get_sim_time( well_state ); @@ -100,41 +104,23 @@ static well_node_type * well_node_alloc( well_state_type * well_state) { } -static UTIL_SAFE_CAST_FUNCTION( well_node , WELL_NODE_TYPE_ID ) -static UTIL_SAFE_CAST_FUNCTION_CONST( well_node , WELL_NODE_TYPE_ID ) - - static void well_node_free( well_node_type * well_node ) { well_state_free( well_node->well_state ); - free( well_node ); + delete well_node; } -static void well_node_free__( void * arg ) { - well_node_type * node = well_node_safe_cast( arg ); - well_node_free( node ); -} - -static int well_node_time_cmp( const void * arg1 , const void * arg2) { - const well_node_type * node1 = well_node_safe_cast_const( arg1 ); - const well_node_type * node2 = well_node_safe_cast_const( arg2 ); - - if (node1->sim_time < node2->sim_time) - return -1; - else if (node1->sim_time == node2->sim_time) - return 0; - else - return 1; +static bool well_node_time_lt( const well_node_type * node1 , const well_node_type * node2) { + return (node1->sim_time < node2->sim_time); } /*****************************************************************/ static well_ts_type * well_ts_alloc_empty( ) { - well_ts_type * well_ts = (well_ts_type*)util_malloc( sizeof * well_ts ); + well_ts_type * well_ts = new well_ts_type(); UTIL_TYPE_ID_INIT( well_ts , WELL_TS_TYPE_ID ); - well_ts->ts = vector_alloc_new(); return well_ts; } @@ -143,22 +129,22 @@ static UTIL_SAFE_CAST_FUNCTION( well_ts , WELL_TS_TYPE_ID ) well_ts_type * well_ts_alloc( const char * well_name ) { well_ts_type * well_ts = well_ts_alloc_empty(); - well_ts->well_name = util_alloc_string_copy( well_name ); + well_ts->well_name = well_name; return well_ts; } -char * well_ts_get_name( const well_ts_type * well_ts) { - return well_ts->well_name; +const char * well_ts_get_name( const well_ts_type * well_ts) { + return well_ts->well_name.c_str(); } static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , time_t sim_time , bool use_report) { - const int size = vector_get_size( well_ts->ts ); + const int size = well_ts->ts.size(); if (size == 0) return 0; else { - const well_node_type * first_node = (const well_node_type*)vector_iget_const( well_ts->ts , 0 ); - const well_node_type * last_node = (const well_node_type*)vector_get_last_const( well_ts->ts ); + const well_node_type * first_node = well_ts->ts[0]; + const well_node_type * last_node = well_ts->ts.back(); if (use_report) { if (report_step < first_node->report_nr) @@ -181,7 +167,7 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , while (true) { int center_index = (lower_index + upper_index) / 2; - const well_node_type * center_node = (const well_node_type*)vector_iget_const( well_ts->ts , center_index ); + const well_node_type * center_node = well_ts->ts[center_index]; double cmp; if (use_report) cmp = center_node->report_nr - report_step; @@ -221,11 +207,11 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t // Inline check that the index is correct { bool OK = true; - const well_node_type * node = (const well_node_type*)vector_iget_const( well_ts->ts , index ); + const well_node_type * node = well_ts->ts[index]; well_node_type * next_node = NULL; - if (index < (vector_get_size( well_ts->ts ) - 1)) - next_node = (well_node_type*)vector_iget( well_ts->ts , index + 1); + if (index < (static_cast(well_ts->ts.size()) - 1) ) + next_node = well_ts->ts[index + 1]; if (use_report) { if (index < 0) { @@ -265,24 +251,24 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) { well_node_type * new_node = well_node_alloc( well_state ); - vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ ); + well_ts->ts.push_back( new_node ); - if (vector_get_size( well_ts->ts ) > 1) { - const well_node_type * last_node = (const well_node_type*)vector_get_last_const(well_ts->ts ); + if (well_ts->ts.size() > 1) { + const well_node_type * last_node = well_ts->ts.back(); if (new_node->sim_time < last_node->sim_time) // The new node is chronologically before the previous node; // i.e. we must sort the nodes in time. This should probably happen - // quite seldom: - vector_sort( well_ts->ts , well_node_time_cmp ); + // quite seldom: + std::sort( well_ts->ts.begin(), well_ts->ts.end(), well_node_time_lt ); } } void well_ts_free( well_ts_type * well_ts ){ - free( well_ts->well_name ); - vector_free( well_ts->ts ); - free( well_ts ); + for (size_t i = 0; i < well_ts->ts.size(); i++) + well_node_free( well_ts->ts[i] ); + delete well_ts; } @@ -294,7 +280,7 @@ void well_ts_free__( void * arg ) { int well_ts_get_size( const well_ts_type * well_ts) { - return vector_get_size( well_ts->ts ); + return well_ts->ts.size(); } @@ -304,12 +290,12 @@ well_state_type * well_ts_get_first_state( const well_ts_type * well_ts) { well_state_type * well_ts_get_last_state( const well_ts_type * well_ts) { - return well_ts_iget_state( well_ts , vector_get_size( well_ts->ts ) - 1); + return well_ts_iget_state( well_ts , well_ts->ts.size() - 1); } well_state_type * well_ts_iget_state( const well_ts_type * well_ts , int index) { - well_node_type * node = (well_node_type*)vector_iget( well_ts->ts , index ); + well_node_type * node = well_ts->ts[index]; return node->well_state; } diff --git a/ThirdParty/Ert/lib/geometry/geo_pointset.cpp b/ThirdParty/Ert/lib/geometry/geo_pointset.cpp index 0aa2777753..513c89cbf0 100644 --- a/ThirdParty/Ert/lib/geometry/geo_pointset.cpp +++ b/ThirdParty/Ert/lib/geometry/geo_pointset.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_pointset.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/geo_polygon.cpp b/ThirdParty/Ert/lib/geometry/geo_polygon.cpp index e375bb07e5..67571ca5f5 100644 --- a/ThirdParty/Ert/lib/geometry/geo_polygon.cpp +++ b/ThirdParty/Ert/lib/geometry/geo_polygon.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_polygon.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp b/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp index 043bffcb83..d3bcd4170f 100644 --- a/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp +++ b/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'geo_polygon_collection.c' is part of ERT - Ensemble based Reservoir Tool. @@ -20,10 +20,12 @@ #include #include +#include +#include + #include #include #include -#include #include #include @@ -35,17 +37,16 @@ struct geo_polygon_collection_struct { UTIL_TYPE_ID_DECLARATION; vector_type * polygon_list; - hash_type * polygon_map; + std::map polygon_map; }; UTIL_IS_INSTANCE_FUNCTION( geo_polygon_collection , GEO_POLYGON_COLLECTION_TYPE_ID) geo_polygon_collection_type * geo_polygon_collection_alloc( ) { - geo_polygon_collection_type * polygons = (geo_polygon_collection_type*)util_malloc( sizeof * polygons ); + geo_polygon_collection_type * polygons = new geo_polygon_collection_type(); UTIL_TYPE_ID_INIT( polygons , GEO_POLYGON_COLLECTION_TYPE_ID ); polygons->polygon_list = vector_alloc_new(); - polygons->polygon_map = hash_alloc(); return polygons; } @@ -82,7 +83,7 @@ bool geo_polygon_collection_add_polygon( geo_polygon_collection_type * polygons vector_append_ref( polygons->polygon_list , polygon ); if (name) - hash_insert_ref( polygons->polygon_map , name , polygon ); + polygons->polygon_map[name] = polygon; return true; } @@ -91,7 +92,7 @@ bool geo_polygon_collection_add_polygon( geo_polygon_collection_type * polygons bool geo_polygon_collection_has_polygon( const geo_polygon_collection_type * polygons , const char * name) { if (name) - return hash_has_key( polygons->polygon_map , name ); + return (polygons->polygon_map.count(name) > 0); else return false; } @@ -99,8 +100,7 @@ bool geo_polygon_collection_has_polygon( const geo_polygon_collection_type * pol void geo_polygon_collection_free( geo_polygon_collection_type * polygons ) { vector_free( polygons->polygon_list ); - hash_free( polygons->polygon_map ); - free( polygons ); + delete polygons; } @@ -111,5 +111,5 @@ geo_polygon_type * geo_polygon_collection_iget_polygon(const geo_polygon_collect geo_polygon_type * geo_polygon_collection_get_polygon(const geo_polygon_collection_type * polygons , const char * polygon_name) { - return (geo_polygon_type*)hash_get( polygons->polygon_map , polygon_name ); + return polygons->polygon_map.at( polygon_name ); } diff --git a/ThirdParty/Ert/lib/geometry/geo_region.cpp b/ThirdParty/Ert/lib/geometry/geo_region.cpp index 5ce2a6f382..c8e4985abb 100644 --- a/ThirdParty/Ert/lib/geometry/geo_region.cpp +++ b/ThirdParty/Ert/lib/geometry/geo_region.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_region.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/geo_surface.cpp b/ThirdParty/Ert/lib/geometry/geo_surface.cpp index 773da26113..00e76938e1 100644 --- a/ThirdParty/Ert/lib/geometry/geo_surface.cpp +++ b/ThirdParty/Ert/lib/geometry/geo_surface.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_surface.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/geo_util.cpp b/ThirdParty/Ert/lib/geometry/geo_util.cpp index e8d0b1cbb1..5f80362a66 100644 --- a/ThirdParty/Ert/lib/geometry/geo_util.cpp +++ b/ThirdParty/Ert/lib/geometry/geo_util.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_util.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/tests/geo_polygon.cpp b/ThirdParty/Ert/lib/geometry/tests/geo_polygon.cpp index f3f46e6f60..fe97113cd2 100644 --- a/ThirdParty/Ert/lib/geometry/tests/geo_polygon.cpp +++ b/ThirdParty/Ert/lib/geometry/tests/geo_polygon.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'geo_surface.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/tests/geo_polygon_collection.cpp b/ThirdParty/Ert/lib/geometry/tests/geo_polygon_collection.cpp index 7023a82446..8627ccde6a 100644 --- a/ThirdParty/Ert/lib/geometry/tests/geo_polygon_collection.cpp +++ b/ThirdParty/Ert/lib/geometry/tests/geo_polygon_collection.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'geo_polygon_collection.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/tests/geo_surface.cpp b/ThirdParty/Ert/lib/geometry/tests/geo_surface.cpp index c9fd440b54..b506064d79 100644 --- a/ThirdParty/Ert/lib/geometry/tests/geo_surface.cpp +++ b/ThirdParty/Ert/lib/geometry/tests/geo_surface.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'geo_surface.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/geometry/tests/geo_util_xlines.cpp b/ThirdParty/Ert/lib/geometry/tests/geo_util_xlines.cpp index 6c926632c0..06f7ee72d1 100644 --- a/ThirdParty/Ert/lib/geometry/tests/geo_util_xlines.cpp +++ b/ThirdParty/Ert/lib/geometry/tests/geo_util_xlines.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'geo_util_xlines.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/EclFilename.hpp b/ThirdParty/Ert/lib/include/ert/ecl/EclFilename.hpp index 858fccfb59..b5e9900582 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/EclFilename.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/EclFilename.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp index 9a07836bf8..71a7c70264 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp @@ -1,5 +1,5 @@ /* - Copyright 2015 Statoil ASA. + Copyright 2015 Equinor ASA. This file is part of the Open Porous Media project (OPM). diff --git a/ThirdParty/Ert/lib/include/ert/ecl/FortIO.hpp b/ThirdParty/Ert/lib/include/ert/ecl/FortIO.hpp index 2f7d69fa09..e4312eb61b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/FortIO.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/FortIO.hpp @@ -1,5 +1,5 @@ /* - Copyright 2015 Statoil ASA. + Copyright 2015 Equinor ASA. This file is part of the Open Porous Media project (OPM). diff --git a/ThirdParty/Ert/lib/include/ert/ecl/Smspec.hpp b/ThirdParty/Ert/lib/include/ert/ecl/Smspec.hpp deleted file mode 100644 index b16c4ced38..0000000000 --- a/ThirdParty/Ert/lib/include/ert/ecl/Smspec.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef OPM_ERT_SMSPEC_HPP -#define OPM_ERT_SMSPEC_HPP - -#include -#include - -#include -#include - -namespace ERT { - - class smspec_node { - public: - smspec_node( const smspec_node& ); - smspec_node( smspec_node&& ); - - smspec_node& operator=( const smspec_node& ); - smspec_node& operator=( smspec_node&& ); - - static int cmp( const smspec_node& node1, const smspec_node& node2); - smspec_node( - ecl_smspec_var_type, - const std::string& wgname, - const std::string& keyword - ); - - smspec_node( const std::string& keyword ); - - smspec_node( const std::string& keyword, - const int dims[ 3 ], - const int ijk[ 3 ] ); - - smspec_node( const std::string& keyword, - const std::string& wellname, - const int dims[ 3 ], - const int ijk[ 3 ] ); - - smspec_node( const std::string& keyword, - const int dims[ 3 ], - int region ); - - int type() const; - const char* keyword() const; - const char* wgname() const; - const char* key1() const; - int num() const; - smspec_node_type* get(); - const smspec_node_type* get() const; - - private: - smspec_node( - ecl_smspec_var_type, - const char*, const char*, const char*, const char*, - const int[3], int, int = 0, float = 0 ); - - ert_unique_ptr< smspec_node_type, smspec_node_free > node; - }; - -} - -#endif //OPM_ERT_SMSPEC_HPP diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp index e88098554a..a08d496b28 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_box.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp index 6b04ac1523..2bcea05cf2 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp index 9876aaf0ef..409a023512 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_endian_flip.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp index 8ddae75c74..eaafb00654 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_file.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp index f066fd1b5d..18abcaea6c 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_file_kw.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp index 20ab40af07..7cceec3319 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. @@ -81,8 +81,8 @@ typedef struct ecl_file_transaction_struct ecl_file_transaction_type; 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(const ecl_file_view_type * ecl_file_view , const char * header, int occurence); - ecl_file_view_type * ecl_file_view_add_blockview2(const 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_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); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp index 41e09f34cd..b39de29fb2 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp index 62a1b84ed1..3b42b0ed94 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grav.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp index 925508cf17..3097395f4e 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grav_common.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp index 4efac56885..9fdd7fc75c 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grid.h' is part of ERT - Ensemble based Reservoir Tool. @@ -18,9 +18,7 @@ #ifndef ERT_ECL_GRID_H #define ERT_ECL_GRID_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -32,6 +30,10 @@ extern "C" { #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)) diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp index f67179badd..358c06d9cb 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_grid_dims.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp index 8870ffe54a..a515a15eeb 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_init_file.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp index d198d47ca6..104d5c74a6 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_io_config.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp index 607c638af3..6e13c1be4c 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_kw.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp index 2113c18cd9..1e777d3d86 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_kw_grdecl.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp index 8ed4c594e7..b3697d54d6 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_nnc_geometry.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp index 68ca00d61a..1e2b2d9106 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ecl_nnc_export.h' is part of ERT - Ensemble based Reservoir Tool. @@ -45,7 +45,8 @@ typedef struct { } ecl_nnc_type; - int ecl_nnc_export_get_size( const ecl_grid_type * grid ); +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 ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp index 66c5742ede..dbca5d9d5e 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_nnc_geometry.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp index 321b1f68d5..bf9acfa99f 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_region.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp index 96ba37abd6..07460401e2 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rft_cell.h' is part of ERT - Ensemble based Reservoir Tool. @@ -76,7 +76,7 @@ UTIL_IS_INSTANCE_HEADER( ecl_rft_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); #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp index 02f23cb048..eb58c5e4d2 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rft_file.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp index ab6dcd46c6..6ad7896f97 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_rft_node.h' is part of ERT - Ensemble based Reservoir Tool. @@ -62,7 +62,8 @@ 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); +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); 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); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp index f4d6e5d4a8..7a36ef0ad1 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_rst_file.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp index 8c91a65e16..566f60517c 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_RSTHEAD.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp index 5bfef485f8..5a5bea9578 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_smspec.h' is part of ERT - Ensemble based Reservoir Tool. @@ -29,12 +29,29 @@ #include #include +typedef struct ecl_smspec_struct ecl_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 , 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); +#endif + #ifdef __cplusplus extern "C" { #endif -typedef struct ecl_smspec_struct ecl_smspec_type; - /** These are the different variable types, see table 3.4 in the @@ -47,10 +64,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; */ int * ecl_smspec_alloc_mapping( const ecl_smspec_type * self, const ecl_smspec_type * other); - const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec ); - void ecl_smspec_index_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node); - void ecl_smspec_insert_node(ecl_smspec_type * ecl_smspec, smspec_node_type * smspec_node); - void ecl_smspec_add_node( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node ); + 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 ); @@ -71,39 +85,30 @@ typedef struct ecl_smspec_struct ecl_smspec_type; int ecl_smspec_get_date_year_index( const ecl_smspec_type * smspec ); - const smspec_node_type * ecl_smspec_get_well_var_node( const ecl_smspec_type * smspec , const char * well , const char * var); 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); - const smspec_node_type * ecl_smspec_get_group_var_node( const ecl_smspec_type * smspec , const char * group , 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); - const smspec_node_type * ecl_smspec_get_field_var_node( const ecl_smspec_type * smspec , 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); - const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * ecl_smspec , const char *region_var , int region_nr); 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); - const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ecl_smspec , const char *var); 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 , const char *var); - const smspec_node_type * ecl_smspec_get_block_var_node(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr); 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); - const smspec_node_type * ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k); 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); - const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr); int ecl_smspec_get_well_completion_var_params_index(const ecl_smspec_type * ecl_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); - const smspec_node_type * ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw ); 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); @@ -120,7 +125,6 @@ typedef struct ecl_smspec_struct ecl_smspec_type; - void ecl_smspec_init_var( ecl_smspec_type * ecl_smspec , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num, const char * unit ); void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys); stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern); @@ -138,21 +142,48 @@ typedef struct ecl_smspec_struct ecl_smspec_type; 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 float_vector_type * ecl_smspec_get_params_default( const ecl_smspec_type * ecl_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); - const smspec_node_type * ecl_smspec_iget_node( const ecl_smspec_type * smspec , int index ); - 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 ); + // void ecl_smspec_sort( ecl_smspec_type * smspec ); ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_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); + + + + #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp index 84f8977fbb..c41d9091d4 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_subsidence.h' is part of ERT - Ensemble based Reservoir Tool. @@ -47,6 +47,12 @@ extern "C" { 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); + + + #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp index a66529fb45..201384b878 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_sum.h' is part of ERT - Ensemble based Reservoir Tool. @@ -58,8 +58,8 @@ 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 smspec_node_type * node); - double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const smspec_node_type * node); + 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 ); @@ -93,7 +93,7 @@ typedef struct ecl_sum_struct ecl_sum_type; 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); + 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 ); /* Accessor functions : */ @@ -130,7 +130,7 @@ typedef struct ecl_sum_struct ecl_sum_type; 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 smspec_node_type * ecl_sum_get_general_var_node(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); @@ -190,7 +190,7 @@ typedef struct ecl_sum_struct ecl_sum_type; stringlist_type * ecl_sum_alloc_well_var_list( const ecl_sum_type * ecl_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); - const ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum ); + 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); @@ -230,8 +230,8 @@ typedef struct ecl_sum_struct ecl_sum_type; 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 ); - smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node); - smspec_node_type * ecl_sum_add_var(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 , @@ -256,10 +256,10 @@ typedef struct ecl_sum_struct ecl_sum_type; 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 smspec_node_type *node); + 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, const char * gen_key); - double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node); + 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); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp index 0c6fdbc0b1..22ab10a768 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_sum_data.h' is part of ERT - Ensemble based Reservoir Tool. @@ -75,8 +75,8 @@ typedef struct ecl_sum_data_struct 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 ); - double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node); - double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node); + 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); 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); @@ -92,14 +92,14 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_init_datetime64_vector(const ecl_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); - double_vector_type * ecl_sum_data_alloc_seconds_solution( const ecl_sum_data_type * data , const smspec_node_type * node , double value, bool rates_clamp_lower); + 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); void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data, - const smspec_node_type * smspec_node, + const ecl::smspec_node& smspec_node, const time_t_vector_type * time_points, double * output_data); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp index d68088f976..bb4a216441 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_sum_index.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp index 4fc332ea00..ac113a5559 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ecl_sum_tstep.h' is part of ERT - Ensemble based Reservoir Tool. @@ -19,15 +19,15 @@ #ifndef ERT_ECL_SUM_TSTEP_H #define ERT_ECL_SUM_TSTEP_H -#ifdef __cplusplus -extern "C" { -#endif - #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); @@ -42,6 +42,9 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type; 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); @@ -50,7 +53,7 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type; 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_vector_type * index_map , fortio_type * fortio); + 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); /// scales with value; equivalent to iset( iget() * scalar) @@ -59,8 +62,6 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type; /// 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 ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node , float value); - double ecl_sum_tstep_get_from_node( const ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node); 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); @@ -75,5 +76,7 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type; #ifdef __cplusplus } + + #endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp index c9e4ed9c42..b04dee0c8e 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ecl_sum_vector.h' is part of ERT - Ensemble based Reservoir Tool. @@ -19,14 +19,14 @@ #ifndef ERT_ECL_SUM_VECTOR_H #define ERT_ECL_SUM_VECTOR_H -#ifdef __cplusplus -extern "C" { -#endif - #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct ecl_sum_vector_struct ecl_sum_vector_type; void ecl_sum_vector_free( ecl_sum_vector_type * keylist ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp index a218330974..305498057e 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_type.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp index ecee98a662..c752ff4438 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ecl_units.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp index 0cf1ada4b7..590068d135 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_util.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp b/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp index 5d9ebbc27a..ec0b8ad41a 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'fault_block.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp index 745fa509d9..2d84d396dd 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'fault_block_layer.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fortio.h b/ThirdParty/Ert/lib/include/ert/ecl/fortio.h index 93a56eb827..c2228d784c 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/fortio.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/fortio.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'fortio.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp b/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp index b7955cf404..510f86d89d 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'grid_dims.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp index 450ee240d3..27c0f268f4 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'layer.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp index 91858cefbf..a6b6efc0a5 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'nnc_info.h' is part of ERT - Ensemble based Reservoir Tool. @@ -19,16 +19,24 @@ #ifndef ERT_NNC_INFO_H #define ERT_NNC_INFO_H -#ifdef __cplusplus -extern "C" { -#endif #include #include #include - typedef struct nnc_info_struct nnc_info_type; +typedef struct nnc_info_struct nnc_info_type; + +#ifdef __cplusplus +#include + const std::vector& nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr); + const std::vector& nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index); + const std::vector& nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info); +#endif + +#ifdef __cplusplus +extern "C" { +#endif UTIL_IS_INSTANCE_HEADER(nnc_info); @@ -36,13 +44,10 @@ extern "C" { void nnc_info_free( nnc_info_type * nnc_info ); void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number, int nnc_index); - const int_vector_type * nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index); nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index); - const int_vector_type * nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr); nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_nr); - const int_vector_type * nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info); nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info ); int nnc_info_get_lgr_nr(const nnc_info_type * nnc_info ); @@ -52,6 +57,7 @@ extern "C" { bool nnc_info_equal( const nnc_info_type * nnc_info1 , const nnc_info_type * nnc_info2 ); nnc_info_type * nnc_info_alloc_copy( const nnc_info_type * src_info ); + bool nnc_info_has_grid_index_list( const nnc_info_type * nnc_info, int lgr_nr ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp b/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp index 3c5f6c304c..741bbaa5aa 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'nnc_vector.h' is part of ERT - Ensemble based Reservoir Tool. @@ -19,14 +19,21 @@ #ifndef ERT_NNC_VECTOR_H #define ERT_NNC_VECTOR_H -#ifdef __cplusplus -extern "C" { -#endif #include #include - typedef struct nnc_vector_struct nnc_vector_type; +typedef struct nnc_vector_struct nnc_vector_type; + +#ifdef __cplusplus +#include + const std::vector& nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector); + const std::vector& nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector); +#endif + +#ifdef __cplusplus +extern "C" { +#endif UTIL_IS_INSTANCE_HEADER(nnc_vector); @@ -36,8 +43,6 @@ extern "C" { nnc_vector_type * nnc_vector_alloc_copy(const nnc_vector_type * src_vector); void nnc_vector_free( nnc_vector_type * nnc_vector ); void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number, int nnc_index); - const int_vector_type * nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector); - const int_vector_type * nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector); int nnc_vector_get_lgr_nr(const nnc_vector_type * nnc_vector ); void nnc_vector_free__(void * arg); int nnc_vector_get_size( const nnc_vector_type * nnc_vector ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.h b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.h index e0e4b77ccd..b058fc8898 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.h @@ -4,6 +4,133 @@ to switch to include the new hpp header directly in your code. */ -#include +#include +#include + +#ifndef ERT_SMSPEC_NODE_H +#define ERT_SMSPEC_NODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define DUMMY_WELL ":+:+:+:+" +#define IS_DUMMY_WELL(well) (strcmp((well) , DUMMY_WELL) == 0) +#define SMSPEC_PARAMS_INDEX_INVALID -77 + + +#define SMSPEC_TIME_KEYWORD "TIME" +#define SMSPEC_TIME_NUMS_VALUE -32676 + +#define SMSPEC_YEARS_KEYWORD "YEARS" +#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; + +#define SMSPEC_NUMS_INVALID -991199 +#define SMSPEC_NUMS_WELL 1 +#define SMSPEC_NUMS_GROUP 2 +#define SMSPEC_NUMS_FIELD 0 + +#define SMSPEC_TYPE_ID 61550451 + + char * smspec_alloc_block_ijk_key( const char * join_string , const char * keyword , int i , int j , int k); + char * smspec_alloc_completion_ijk_key( const char * join_string , const char * keyword, const char * wgname , int i , int j , int k); + char * smspec_alloc_completion_num_key( const char * join_string , const char * keyword, const char * wgname , int num); + char * smspec_alloc_group_key( const char * join_string , const char * keyword , const char * wgname); + char * smspec_alloc_well_key( const char * join_string , const char * keyword , const char * wgname); + char * smspec_alloc_region_key( const char * join_string , const char * keyword , int num); + char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2); + char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num); + char * smspec_alloc_segment_key( const char * join_string , const char * keyword , const char * wgname , int num); + char * smspec_alloc_block_num_key( const char * join_string , const char * keyword , int num); + char * smspec_alloc_local_well_key( const char * join_string , const char * keyword , const char * lgr_name , const char * wgname); + char * smspec_alloc_local_block_key( const char * join_string , const char * keyword , const char * lgr_name , int i , int j , int k); + char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); + + bool smspec_node_identify_total(const char * keyword, ecl_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 , + const char * wgname , + const char * keyword , + const char * unit , + const char * key_join_string , + const int grid_dims[3] , + int num); + + void * smspec_node_alloc( int param_index, + const char * keyword , + const char * wgname, + int num, + const char * unit , + 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 , + 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); + + void * smspec_node_alloc_copy( const void* ); + + void smspec_node_free( void * index ); + void smspec_node_free__(void * arg); + 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); + 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); + const char * smspec_node_get_unit( const void * smspec_node); + bool smspec_node_is_rate( const void * smspec_node ); + bool smspec_node_is_total( const void * smspec_node ); + bool smspec_node_is_historical( const void * smspec_node ); + bool smspec_node_need_nums( const void * smspec_node ); + void smspec_node_fprintf( const void * smspec_node , FILE * stream); + + float smspec_node_get_default( const void * smspec_node); + + const int* smspec_node_get_ijk( const void * smpsec_node ); + const char* smspec_node_get_lgr_name( const void * smpsec_node ); + const int* smspec_node_get_lgr_ijk( const void * smpsec_node ); + + int smspec_node_get_R1( const void * smpsec_node ); + int smspec_node_get_R2( const void * smpsec_node ); + + bool smspec_node_lt( const void * node1, const void * node2); + bool smspec_node_gt( const void * node1, const void * node2); + int smspec_node_cmp( const void * node1, const void * node2); + int smspec_node_cmp__( const void * node1, const void * node2); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp index a8dfc0dba2..50dd00e451 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'smspec_node.h' is part of ERT - Ensemble based Reservoir Tool. @@ -17,132 +17,110 @@ */ -#ifndef ERT_SMSPEC_NODE_H -#define ERT_SMSPEC_NODE_H +#ifndef ERT_SMSPEC_NODE_HPP +#define ERT_SMSPEC_NODE_HPP #include #include -#ifdef __cplusplus -extern "C" { -#endif +#include +#include -#define DUMMY_WELL ":+:+:+:+" -#define IS_DUMMY_WELL(well) (strcmp((well) , DUMMY_WELL) == 0) -#define SMSPEC_PARAMS_INDEX_INVALID -77 +#include + +#include -#define SMSPEC_TIME_KEYWORD "TIME" -#define SMSPEC_TIME_NUMS_VALUE -32676 +namespace ecl { -#define SMSPEC_YEARS_KEYWORD "YEARS" -#define SMSPEC_YEARS_NUMS_VALUE -32676 + class smspec_node { + private: + std::string wgname; + std::string keyword; /* The value of the KEYWORDS vector for this elements. */ + std::string unit; /* The value of the UNITS vector for this elements. */ + int num; /* The value of the NUMS vector for this elements - NB this will have the value SMSPEC_NUMS_INVALID if the smspec file does not have a NUMS vector. */ + std::string lgr_name; /* The lgr name of the current variable - will be NULL for non-lgr variables. */ + std::array lgr_ijk; -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; + /*------------------------------------------- All members below this line are *derived* quantities. */ + std::string 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 */ + std::array ijk; /* The ijk coordinates (NB: OFFSET 1) corresponding to the nums value - will be NULL if not relevant. */ + bool rate_variable; /* Is this a rate variable (i.e. WOPR) or a state variable (i.e. BPR). Relevant when doing time interpolation. */ + bool total_variable; /* Is this a total variable like WOPT? */ + bool historical; /* Does the name end with 'H'? */ + 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. */ -#define SMSPEC_NUMS_INVALID -991199 -#define SMSPEC_NUMS_WELL 1 -#define SMSPEC_NUMS_GROUP 2 -#define SMSPEC_NUMS_FIELD 0 + static ecl_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_); + void decode_R1R2( int * r1 , int * r2) const; + void set_lgr_ijk( int lgr_i , int lgr_j , int lgr_k); - typedef struct smspec_node_struct smspec_node_type; + public: - char * smspec_alloc_block_ijk_key( const char * join_string , const char * keyword , int i , int j , int k); - char * smspec_alloc_completion_ijk_key( const char * join_string , const char * keyword, const char * wgname , int i , int j , int k); - char * smspec_alloc_completion_num_key( const char * join_string , const char * keyword, const char * wgname , int num); - char * smspec_alloc_group_key( const char * join_string , const char * keyword , const char * wgname); - char * smspec_alloc_well_key( const char * join_string , const char * keyword , const char * wgname); - char * smspec_alloc_region_key( const char * join_string , const char * keyword , int num); - char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2); - char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num); - char * smspec_alloc_segment_key( const char * join_string , const char * keyword , const char * wgname , int num); - char * smspec_alloc_block_num_key( const char * join_string , const char * keyword , int num); - char * smspec_alloc_local_well_key( const char * join_string , const char * keyword , const char * lgr_name , const char * wgname); - char * smspec_alloc_local_block_key( const char * join_string , const char * keyword , const char * lgr_name , int i , int j , int k); - char * smspec_alloc_local_completion_key( const char * join_string, const char * keyword , const char * lgr_name , const char * wgname , int i , int j , int k); + static ecl_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); - bool smspec_node_equal( const smspec_node_type * node1, const smspec_node_type * node2); + smspec_node(int param_index, + const char * keyword , + const char * wgname, + int num, + const char * unit , + const int grid_dims[3] , + float default_value, + const char * key_join_string); - void smspec_node_init( smspec_node_type * smspec_node, - ecl_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); + smspec_node(int param_index, + const char * keyword , + const char * wgname , + const char * unit , + const char * lgr , + int lgr_i, int lgr_j , int lgr_k, + float default_value, + const char * key_join_string); - smspec_node_type * smspec_node_alloc( ecl_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 , int param_index, float default_value); + smspec_node(int param_index, const char * keyword, const char * unit, float default_value); + smspec_node(int param_index, const char * keyword, int num, const char * unit, const int grid_dims[3], float default_value, const char * key_join_string); + smspec_node(int param_index, const char * keyword, int num, const char * unit, float default_value, const char * key_join_string); + smspec_node(int param_index, const char * keyword, const char * wgname, const char * unit, float default_value, const char * key_join_string); + smspec_node(int param_index, const char * keyword, const char * wgname, int num, const char * unit, float default_value, const char * key_join_string); + smspec_node(const smspec_node& node, int param_index); - smspec_node_type * smspec_node_alloc_lgr( ecl_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); + static ecl_smspec_var_type identify_var_type(const char * var); - smspec_node_type * smspec_node_alloc_new(int params_index, float default_value); - smspec_node_type * smspec_node_alloc_copy( const smspec_node_type* ); + static int cmp( const smspec_node * node1, const smspec_node * node2) { + return node1->cmp(*node2); + } - void smspec_node_free( smspec_node_type * index ); - void smspec_node_free__(void * arg); - void smspec_node_set_params_index( smspec_node_type * smspec_node , int params_index); - int smspec_node_get_params_index( const smspec_node_type * smspec_node ); - const char * smspec_node_get_gen_key1( const smspec_node_type * smspec_node); - const char * smspec_node_get_gen_key2( const smspec_node_type * smspec_node); - ecl_smspec_var_type smspec_node_get_var_type( const smspec_node_type * smspec_node); - int smspec_node_get_num( const smspec_node_type * smspec_node); - const char * smspec_node_get_wgname( const smspec_node_type * smspec_node); - const char * smspec_node_get_keyword( const smspec_node_type * smspec_node); - const char * smspec_node_get_unit( const smspec_node_type * smspec_node); - void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit ); - bool smspec_node_is_rate( const smspec_node_type * smspec_node ); - bool smspec_node_is_total( const smspec_node_type * smspec_node ); - bool smspec_node_is_historical( const smspec_node_type * smspec_node ); - bool smspec_node_need_nums( const smspec_node_type * smspec_node ); - void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); + int get_R1() const; + int get_R2() const; + const char * get_gen_key1() const; + const char * get_gen_key2() const; + ecl_smspec_var_type get_var_type() const; + int get_num() const; + const char * get_wgname() const; + const char * get_keyword() const; + const char * get_unit() const; + bool is_rate() const; + bool is_total() const; + bool is_historical() const; + bool need_nums() const; + void fprintf__( FILE * stream) const; + int get_params_index() const; + float get_default() const; + const std::array& get_ijk() const; + const char * get_lgr_name() const; + const std::array& get_lgr_ijk() const; - void smspec_node_set_default( smspec_node_type * smspec_node , float default_value); - float smspec_node_get_default( const smspec_node_type * smspec_node); + }; - const int* smspec_node_get_ijk( const smspec_node_type * smpsec_node ); - const char* smspec_node_get_lgr_name( const smspec_node_type * smpsec_node ); - const int* smspec_node_get_lgr_ijk( const smspec_node_type * smpsec_node ); - - int smspec_node_get_R1( const smspec_node_type * smpsec_node ); - int smspec_node_get_R2( const smspec_node_type * smpsec_node ); - - int smspec_node_cmp( const smspec_node_type * node1, const smspec_node_type * node2); - int smspec_node_cmp__( const void * node1, const void * node2); - bool smspec_node_identify_total(const char * keyword, ecl_smspec_var_type var_type); - bool smspec_node_identify_rate(const char * keyword); - -#ifdef __cplusplus } -#endif + #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp index d7aca7a963..c8c942ce96 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_branch_collection.h' is part of ERT - Ensemble based Reservoir Tool. @@ -40,7 +40,7 @@ extern "C" { int well_branch_collection_get_size( const well_branch_collection_type * branches ); const well_segment_type * well_branch_collection_iget_start_segment( const well_branch_collection_type * branches , int index ); const well_segment_type * well_branch_collection_get_start_segment( const well_branch_collection_type * branches , int branch_id); - bool well_branch_collection_add_start_segment( well_branch_collection_type * branches , const well_segment_type * start_segment); + bool well_branch_collection_add_start_segment( well_branch_collection_type * branches , well_segment_type * start_segment); UTIL_IS_INSTANCE_HEADER( well_branch_collection ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp index 610779ab5d..eabcbc421b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_conn.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp index 3cc9a178c8..e08fe23674 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_conn_collection.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp index 41a2ade9f2..833e5c9b00 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_const.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp index b7bad41564..b3474c0db5 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_info.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp index 1270fba0d8..2060487ded 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_info.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp index 084cfea8da..cee97fe73d 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp index fc4dd95d45..270d1171bb 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'well_segment_collection.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp index c41e215685..b6151b9aae 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_state.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp index 5044b685b0..572462790b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'well_ts.h' is part of ERT - Ensemble based Reservoir Tool. @@ -37,7 +37,7 @@ extern "C" { well_state_type * well_ts_get_state_from_report( const well_ts_type * well_ts , int report_nr); well_state_type * well_ts_iget_state( const well_ts_type * well_ts , int index); int well_ts_get_size( const well_ts_type * well_ts); - char * well_ts_get_name( const well_ts_type * well_ts); + const char * well_ts_get_name( const well_ts_type * well_ts); well_state_type * well_ts_get_first_state( const well_ts_type * well_ts); well_state_type * well_ts_get_last_state( const well_ts_type * well_ts); diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp index 7e549e6852..d591c513f0 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_pointset.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp index b7287644b8..675942701a 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_polygon.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp index 1ee312ee10..36777e1a8a 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'geo_polygon_collection.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp index e719112d2c..882c1553e4 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_region.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp index 8a827b5b88..b5c77dc136 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_surface.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp index a988963dbc..b02d56df83 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'geo_util.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/atomic.h b/ThirdParty/Ert/lib/include/ert/util/atomic.h index 08aae0110e..16cf9a1f2d 100644 --- a/ThirdParty/Ert/lib/include/ert/util/atomic.h +++ b/ThirdParty/Ert/lib/include/ert/util/atomic.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'atomic.h' is part of ERT - Ensemble based Reservoir Tool. @@ -30,124 +30,124 @@ /** - * Atomic type. - */ +�* Atomic type. +�*/ typedef struct { volatile int counter; } atomic_t; -#define ATOMIC_INIT(i)  { (i) } +#define ATOMIC_INIT(i) �{ (i) } /** - * Read atomic variable - * @param v pointer of type atomic_t - * - * Atomically reads the value of @v. - */ +�* Read atomic variable +�* @param v pointer of type atomic_t +�* +�* Atomically reads the value of @v. +�*/ #define atomic_read(v) ((v)->counter) /** - * Set atomic variable - * @param v pointer of type atomic_t - * @param i required value - */ +�* Set atomic variable +�* @param v pointer of type atomic_t +�* @param i required value +�*/ #define atomic_set(v,i) (((v)->counter) = (i)) /** - * Add to the atomic variable - * @param i integer value to add - * @param v pointer of type atomic_t - */ +�* Add to the atomic variable +�* @param i integer value to add +�* @param v pointer of type atomic_t +�*/ static inline void atomic_add( int i, atomic_t *v ) { (void)__sync_add_and_fetch(&v->counter, i); } /** - * Subtract the atomic variable - * @param i integer value to subtract - * @param v pointer of type atomic_t - * - * Atomically subtracts @i from @v. - */ +�* Subtract the atomic variable +�* @param i integer value to subtract +�* @param v pointer of type atomic_t +�* +�* Atomically subtracts @i from @v. +�*/ static inline void atomic_sub( int i, atomic_t *v ) { (void)__sync_sub_and_fetch(&v->counter, i); } /** - * Subtract value from variable and test result - * @param i integer value to subtract - * @param v pointer of type atomic_t - * - * Atomically subtracts @i from @v and returns - * true if the result is zero, or false for all - * other cases. - */ +�* Subtract value from variable and test result +�* @param i integer value to subtract +�* @param v pointer of type atomic_t +�* +�* Atomically subtracts @i from @v and returns +�* true if the result is zero, or false for all +�* other cases. +�*/ static inline int atomic_sub_and_test( int i, atomic_t *v ) { return !(__sync_sub_and_fetch(&v->counter, i)); } /** - * Increment atomic variable - * @param v pointer of type atomic_t - * - * Atomically increments @v by 1. - */ +�* Increment atomic variable +�* @param v pointer of type atomic_t +�* +�* Atomically increments @v by 1. +�*/ static inline void atomic_inc( atomic_t *v ) { (void)__sync_fetch_and_add(&v->counter, 1); } /** - * @brief decrement atomic variable - * @param v: pointer of type atomic_t - * - * Atomically decrements @v by 1.  Note that the guaranteed - * useful range of an atomic_t is only 24 bits. - */ +�* @brief decrement atomic variable +�* @param v: pointer of type atomic_t +�* +�* Atomically decrements @v by 1. �Note that the guaranteed +�* useful range of an atomic_t is only 24 bits. +�*/ static inline void atomic_dec( atomic_t *v ) { (void)__sync_fetch_and_sub(&v->counter, 1); } /** - * @brief Decrement and test - * @param v pointer of type atomic_t - * - * Atomically decrements @v by 1 and - * returns true if the result is 0, or false for all other - * cases. - */ +�* @brief Decrement and test +�* @param v pointer of type atomic_t +�* +�* Atomically decrements @v by 1 and +�* returns true if the result is 0, or false for all other +�* cases. +�*/ static inline int atomic_dec_and_test( atomic_t *v ) { return !(__sync_sub_and_fetch(&v->counter, 1)); } /** - * @brief Increment and test - * @param v pointer of type atomic_t - * - * Atomically increments @v by 1 - * and returns true if the result is zero, or false for all - * other cases. - */ +�* @brief Increment and test +�* @param v pointer of type atomic_t +�* +�* Atomically increments @v by 1 +�* and returns true if the result is zero, or false for all +�* other cases. +�*/ static inline int atomic_inc_and_test( atomic_t *v ) { return !(__sync_add_and_fetch(&v->counter, 1)); } /** - * @brief add and test if negative - * @param v pointer of type atomic_t - * @param i integer value to add - * - * Atomically adds @i to @v and returns true - * if the result is negative, or false when - * result is greater than or equal to zero. - */ +�* @brief add and test if negative +�* @param v pointer of type atomic_t +�* @param i integer value to add +�* +�* Atomically adds @i to @v and returns true +�* if the result is negative, or false when +�* result is greater than or equal to zero. +�*/ static inline int atomic_add_negative( int i, atomic_t *v ) { return (__sync_add_and_fetch(&v->counter, i) < 0); @@ -168,14 +168,14 @@ static inline int atomic_add_negative( int i, atomic_t *v ) // ////As a second example, consider a compare and swap operation, frequently used in lock-free algorithms. Once again, it's trivially: ///** -// * @brief compare and swap -// * @param v pointer of type atomic_t -// * -// * If the current value of @b v is @b oldval, -// * then write @b newval into @b v. Returns #TRUE if -// * the comparison is successful and @b newval was -// * written. -// */ +//�* @brief compare and swap +//�* @param v pointer of type atomic_t +//�* +//�* If the current value of @b v is @b oldval, +//�* then write @b newval into @b v. Returns #TRUE if +//�* the comparison is successful and @b newval was +//�* written. +//�*/ //static inline int atomic_cas( atomic_t *v, int oldval, int newval ) //{ // return __sync_bool_compare_and_swap(&v->counter, oldval, newval); diff --git a/ThirdParty/Ert/lib/include/ert/util/buffer.hpp b/ThirdParty/Ert/lib/include/ert/util/buffer.hpp index 167028a46b..0784c33c4b 100644 --- a/ThirdParty/Ert/lib/include/ert/util/buffer.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/buffer.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'buffer.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp b/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp index 83c39ae8b2..c431152a91 100644 --- a/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ecl_version.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/hash.hpp b/ThirdParty/Ert/lib/include/ert/util/hash.hpp index deae544285..4fdc1426ab 100644 --- a/ThirdParty/Ert/lib/include/ert/util/hash.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/hash.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'hash.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp b/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp index 8579068ebb..bc0a7194b8 100644 --- a/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'hash_node.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp b/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp index 2af6319e41..4a830e1374 100644 --- a/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'hash_sll.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp b/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp index 9658cd411b..781842d127 100644 --- a/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'lookup_table.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/mzran.hpp b/ThirdParty/Ert/lib/include/ert/util/mzran.hpp index 06315a06ce..fbabf0d3c1 100644 --- a/ThirdParty/Ert/lib/include/ert/util/mzran.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/mzran.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'mzran.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp b/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp index 344a3aa0f3..57c91d6698 100644 --- a/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'node_ctype.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/node_data.hpp b/ThirdParty/Ert/lib/include/ert/util/node_data.hpp index 4e572f1836..a4aa3d0ad4 100644 --- a/ThirdParty/Ert/lib/include/ert/util/node_data.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/node_data.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'node_data.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/parser.hpp b/ThirdParty/Ert/lib/include/ert/util/parser.hpp index d00e311f0f..250cea4fc9 100644 --- a/ThirdParty/Ert/lib/include/ert/util/parser.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/parser.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'parser.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp b/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp index 7da9f9fc27..237852e3ac 100644 --- a/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'path_stack.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp b/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp index 60662c2e9b..539c2d4e50 100644 --- a/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'perm_vector.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/rng.hpp b/ThirdParty/Ert/lib/include/ert/util/rng.hpp index 2964296877..2576ae7143 100644 --- a/ThirdParty/Ert/lib/include/ert/util/rng.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/rng.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'rng.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp b/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp index 10507fa5d9..9a6c894e76 100644 --- a/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ssize_t.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/statistics.hpp b/ThirdParty/Ert/lib/include/ert/util/statistics.hpp index 5a14bb390a..27da8dda20 100644 --- a/ThirdParty/Ert/lib/include/ert/util/statistics.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/statistics.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'statistics.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/string_util.hpp b/ThirdParty/Ert/lib/include/ert/util/string_util.hpp index dc43464a76..e6f5d212a2 100644 --- a/ThirdParty/Ert/lib/include/ert/util/string_util.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/string_util.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'string_util.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp b/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp index 8e8176739d..0596c178ef 100644 --- a/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'stringlist.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/test_util.hpp b/ThirdParty/Ert/lib/include/ert/util/test_util.hpp index 0e3087681d..939fc516fd 100644 --- a/ThirdParty/Ert/lib/include/ert/util/test_util.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/test_util.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'test_util.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp b/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp index e988012536..8faff93d22 100644 --- a/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'test_work_area.h' is part of ERT - Ensemble based Reservoir Tool. @@ -20,36 +20,58 @@ #ifndef ERT_TEST_WORK_AREA_H #define ERT_TEST_WORK_AREA_H +#include + +namespace ecl { +namespace util { + +class TestArea { +public: + TestArea(const std::string& test_name, bool store_area = false); + ~TestArea(); + const std::string& test_cwd() const; + const std::string& original_cwd() const; + + void copy_directory(const std::string input_directory) const; + void copy_directory_content(const std::string input_directory) const; + bool copy_parent(const std::string input_path) const; + bool copy_parent_content(const std::string original_path) const; + + void copy_file(const std::string& input_src_file) const; + std::string original_path(const std::string& input_path) const; + +private: + bool store; + std::string cwd; + std::string org_cwd; +}; + + +} +} + +typedef ecl::util::TestArea test_work_area_type; + #ifdef __cplusplus extern "C" { #endif #include -#include - - typedef struct test_work_area_struct test_work_area_type; - char * test_work_area_alloc_input_path( const test_work_area_type * work_area , const char * input_path ); test_work_area_type * test_work_area_alloc(const char * test_name ); + test_work_area_type * test_work_area_alloc__(const char * test_name, bool store_area ); test_work_area_type * test_work_area_alloc_relative(const char * prefix , const char * test_path); - void test_work_area_set_store( test_work_area_type * work_area , bool store); void test_work_area_free(test_work_area_type * work_area); const char * test_work_area_get_cwd( const test_work_area_type * work_area ); const char * test_work_area_get_original_cwd( const test_work_area_type * work_area ); - void test_work_area_install_file( test_work_area_type * work_area , const char * input_src_file ); - void test_work_area_copy_directory( test_work_area_type * work_area , const char * input_directory); - void test_work_area_copy_directory_content( test_work_area_type * work_area , const char * input_directory); - void test_work_area_copy_file( test_work_area_type * work_area , const char * input_file); - bool test_work_area_copy_parent_directory( test_work_area_type * work_area , const char * input_path); - bool test_work_area_copy_parent_content( test_work_area_type * work_area , const char * input_path); - void test_work_area_sync( test_work_area_type * work_area); - - test_work_area_type * temp_area_alloc_relative(const char * prefix , const char * test_path); - test_work_area_type * temp_area_alloc(const char * test_path); - - UTIL_IS_INSTANCE_HEADER( test_work_area ); + void test_work_area_install_file( const test_work_area_type * work_area , const char * input_src_file ); + void test_work_area_copy_directory( const test_work_area_type * work_area , const char * input_directory); + void test_work_area_copy_directory_content( const test_work_area_type * work_area , const char * input_directory); + void test_work_area_copy_file( const test_work_area_type * work_area , const char * input_file); + bool test_work_area_copy_parent_directory( const test_work_area_type * work_area , const char * input_path); + bool test_work_area_copy_parent_content( const test_work_area_type * work_area , const char * input_path); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/util/thread_pool1.h b/ThirdParty/Ert/lib/include/ert/util/thread_pool1.h index be605c0ba3..b5b6111692 100644 --- a/ThirdParty/Ert/lib/include/ert/util/thread_pool1.h +++ b/ThirdParty/Ert/lib/include/ert/util/thread_pool1.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'thread_pool1.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp b/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp index 939a2748e4..c35438a68a 100644 --- a/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. This is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/timer.hpp b/ThirdParty/Ert/lib/include/ert/util/timer.hpp index 8830222065..619c5b6164 100644 --- a/ThirdParty/Ert/lib/include/ert/util/timer.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/timer.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'timer.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp b/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp index f607faf163..69b7bf638b 100644 --- a/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'type_vector_functions.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/util.h b/ThirdParty/Ert/lib/include/ert/util/util.h index 5d44346560..fff69fc5ac 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util.h +++ b/ThirdParty/Ert/lib/include/ert/util/util.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'util.h' is part of ERT - Ensemble based Reservoir Tool. @@ -96,16 +96,9 @@ typedef bool (walk_dir_callback_ftype) (const char * , /* The current director void *); /* Arbitrary argument */ - -typedef enum {left_pad = 0, - right_pad = 1, - center_pad = 2} string_alignement_type; - - //#define UTIL_CXX_MALLOC(var , num_elm) (typeof (var)) util_malloc( (num_elm) * sizeof var) char * util_get_timezone(void); time_t util_make_datetime_utc(int , int , int , int , int , int ); bool util_make_datetime_utc_validated(int sec, int min, int hour , int mday , int month , int year, time_t * t); - void util_fprintf_date_utc(time_t , FILE * ); time_t util_make_date_utc(int , int , int); time_t util_make_pure_date_utc(time_t t); void util_inplace_forward_seconds_utc(time_t * t , double seconds); @@ -128,9 +121,6 @@ typedef enum {left_pad = 0, char * util_alloc_sprintf_va(const char * fmt , va_list ap); char * util_alloc_sprintf(const char * , ...); char * util_realloc_sprintf(char * , const char * , ...); - void util_fprintf_int(int , int , FILE * ); - void util_fprintf_string(const char * , int , string_alignement_type , FILE * ); - void util_fprintf_double(double , int , int , char , FILE *); bool util_fscanf_date_utc(FILE * , time_t *); bool util_sscanf_date_utc(const char * , time_t *); bool util_sscanf_isodate(const char * , time_t *); @@ -237,7 +227,6 @@ typedef enum {left_pad = 0, char * util_alloc_filename(const char * , const char * , const char * ); char * util_realloc_filename(char * , const char * , const char * , const char * ); char * util_alloc_strip_copy(const char *); - void util_set_strip_copy(char * , const char *); char * util_alloc_string_sum(const char ** , int); char * util_strcat_realloc(char *, const char * ); char * util_alloc_string_copy(const char *); diff --git a/ThirdParty/Ert/lib/include/ert/util/util.hpp b/ThirdParty/Ert/lib/include/ert/util/util.hpp index 8d293d4382..e7ca212096 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/util.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. This is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/util_endian.h b/ThirdParty/Ert/lib/include/ert/util/util_endian.h index 96f2399f4a..4a4e145fa9 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util_endian.h +++ b/ThirdParty/Ert/lib/include/ert/util/util_endian.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'util_endian.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/util_unlink.h b/ThirdParty/Ert/lib/include/ert/util/util_unlink.h index 3fc1e232c5..4d0766de6e 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util_unlink.h +++ b/ThirdParty/Ert/lib/include/ert/util/util_unlink.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'util_unlink.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/vector.hpp b/ThirdParty/Ert/lib/include/ert/util/vector.hpp index ff4f526bc2..ffcf764572 100644 --- a/ThirdParty/Ert/lib/include/ert/util/vector.hpp +++ b/ThirdParty/Ert/lib/include/ert/util/vector.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'vector.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/include/ert/util/vector_util.hpp b/ThirdParty/Ert/lib/include/ert/util/vector_util.hpp new file mode 100644 index 0000000000..6ddc913466 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/vector_util.hpp @@ -0,0 +1,52 @@ +/* + Copyright (C) 2018 Equinor ASA, Norway. + + The file 'vector_util.h' 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#include + +#include +#include + +template +int vector_util_index(const std::vector& vec, T value) { + + int index; + auto iter = find(vec.begin(), vec.end(), value); + if (iter == vec.end()) + index = -1; + else + index = iter - vec.begin(); + return index; +} + + +template +void vector_util_fprintf(const std::vector& vec , FILE * stream , const char * name , const char * fmt) { + size_t i; + if (name != NULL) + fprintf(stream , "%s = [" , name); + else + fprintf(stream , "["); + + for (i = 0; i < vec.size(); i++) { + fprintf(stream , fmt , vec[i]); + if (i < (vec.size() - 1)) + fprintf(stream , ", "); + } + + fprintf(stream , "]\n"); +} diff --git a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_grid_cache.hpp b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_grid_cache.hpp index cb96cee2e7..60543c500e 100644 --- a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_grid_cache.hpp +++ b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_grid_cache.hpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'ecl_grid_cache.h' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp index 3435cc6017..e323a307f6 100644 --- a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp +++ b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp @@ -141,7 +141,7 @@ private: 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, const ecl_smspec_type * smspec); + void add_ecl_file(int report_step, const ecl_file_view_type * summary_view); }; diff --git a/ThirdParty/Ert/lib/util/buffer.cpp b/ThirdParty/Ert/lib/util/buffer.cpp index 909b220f91..64eaf25dec 100644 --- a/ThirdParty/Ert/lib/util/buffer.cpp +++ b/ThirdParty/Ert/lib/util/buffer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'buffer.c' is part of ERT - Ensemble based Reservoir Tool. @@ -563,12 +563,36 @@ void buffer_replace_string( buffer_type * buffer , size_t offset , size_t old_si touching internal state. */ +namespace { + + /* + This homemade strstr() implementation is used here because we can not + guarantee that the buffer->data is '\0' terminated and then normal strstr() + gives undefined behaviour - problem found with address sanitizer. + */ + + const char * memcmp_strstr(const char * buffer, size_t buffer_size, const char * expr) { + size_t N = strlen(expr); + const char * pos = buffer; + while (true) { + if (buffer_size < N) + return NULL; + + if (memcmp(pos, expr, N) == 0) + return pos; + + pos++; + buffer_size--; + } + } +} + bool buffer_strstr( buffer_type * buffer , const char * expr ) { bool match = false; if (strlen(expr) > 0) { - char * match_ptr = strstr( &buffer->data[buffer->pos] , expr ); + const char * match_ptr = memcmp_strstr( &buffer->data[buffer->pos], buffer->content_size - buffer->pos, expr ); if (match_ptr) { buffer->pos += match_ptr - &buffer->data[buffer->pos]; match = true; diff --git a/ThirdParty/Ert/lib/util/cxx_string_util.cpp b/ThirdParty/Ert/lib/util/cxx_string_util.cpp index 5927039620..b49197b540 100644 --- a/ThirdParty/Ert/lib/util/cxx_string_util.cpp +++ b/ThirdParty/Ert/lib/util/cxx_string_util.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Equinor Statoil ASA, Norway. + Copyright (C) 2018 Equinor Equinor ASA, Norway. The file 'cxx_string_util.cpp' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/hash.cpp b/ThirdParty/Ert/lib/util/hash.cpp index a085abe6b9..214664a444 100644 --- a/ThirdParty/Ert/lib/util/hash.cpp +++ b/ThirdParty/Ert/lib/util/hash.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'hash.c' is part of ERT - Ensemble based Reservoir Tool. @@ -82,11 +82,6 @@ static void * __hash_get_node(const hash_type *__hash , const char *key, bool ab hash_type * hash = (hash_type *) __hash; /* The net effect is no change - but .... ?? */ hash_node_type * node = NULL; { - if (key == NULL) - { - return NULL; - } - const uint32_t global_index = hash->hashf(key , strlen(key)); const uint32_t table_index = (global_index % hash->size); diff --git a/ThirdParty/Ert/lib/util/hash_node.cpp b/ThirdParty/Ert/lib/util/hash_node.cpp index 1a983e0ba7..66e099879e 100644 --- a/ThirdParty/Ert/lib/util/hash_node.cpp +++ b/ThirdParty/Ert/lib/util/hash_node.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'hash_node.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/hash_sll.cpp b/ThirdParty/Ert/lib/util/hash_sll.cpp index 6f3ec0f623..080462cfaf 100644 --- a/ThirdParty/Ert/lib/util/hash_sll.cpp +++ b/ThirdParty/Ert/lib/util/hash_sll.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'hash_sll.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/lookup_table.cpp b/ThirdParty/Ert/lib/util/lookup_table.cpp index 616a54eac6..2f453a8d19 100644 --- a/ThirdParty/Ert/lib/util/lookup_table.cpp +++ b/ThirdParty/Ert/lib/util/lookup_table.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'lookup_table.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/mzran.cpp b/ThirdParty/Ert/lib/util/mzran.cpp index fd1bc353b5..a042988ff9 100644 --- a/ThirdParty/Ert/lib/util/mzran.cpp +++ b/ThirdParty/Ert/lib/util/mzran.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'mzran.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/node_ctype.cpp b/ThirdParty/Ert/lib/util/node_ctype.cpp index b50ce095fd..8db8504f1f 100644 --- a/ThirdParty/Ert/lib/util/node_ctype.cpp +++ b/ThirdParty/Ert/lib/util/node_ctype.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'node_ctype.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/node_data.cpp b/ThirdParty/Ert/lib/util/node_data.cpp index ae7d2a3653..728cbf8566 100644 --- a/ThirdParty/Ert/lib/util/node_data.cpp +++ b/ThirdParty/Ert/lib/util/node_data.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'node_data.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/parser.cpp b/ThirdParty/Ert/lib/util/parser.cpp index 48b963575e..8b187214d1 100644 --- a/ThirdParty/Ert/lib/util/parser.cpp +++ b/ThirdParty/Ert/lib/util/parser.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'parser.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/path.cpp b/ThirdParty/Ert/lib/util/path.cpp index 30d206e9e3..d0cb5418a8 100644 --- a/ThirdParty/Ert/lib/util/path.cpp +++ b/ThirdParty/Ert/lib/util/path.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. @@ -15,6 +15,7 @@ See the GNU General Public License at for more details. */ +#include #include @@ -55,10 +56,16 @@ namespace ecl { { const char * c_str = fname.c_str(); + const char * return_raw; if (end_pos == std::string::npos || end_pos < offset) - return util_alloc_string_copy( &c_str[offset] ); + return_raw = util_alloc_string_copy( &c_str[offset] ); + else + return_raw = util_alloc_substring_copy(c_str, offset, end_pos - offset); + std::string return_value = return_raw; + free( (void*)return_raw ); + return return_value; + - return util_alloc_substring_copy(c_str, offset, end_pos - offset); } } @@ -71,7 +78,11 @@ namespace ecl { if (last_slash == std::string::npos || end_pos > last_slash) { const char * c_str = fname.c_str(); - return util_alloc_substring_copy( c_str, end_pos + 1, fname.size() - end_pos - 1); + + const char * return_raw = util_alloc_substring_copy( c_str, end_pos + 1, fname.size() - end_pos - 1); + std::string return_value = return_raw; + free( (void*)return_raw ); + return return_value; } return ""; diff --git a/ThirdParty/Ert/lib/util/path_stack.cpp b/ThirdParty/Ert/lib/util/path_stack.cpp index 9ae4ff9433..fd6f03565f 100644 --- a/ThirdParty/Ert/lib/util/path_stack.cpp +++ b/ThirdParty/Ert/lib/util/path_stack.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/perm_vector.cpp b/ThirdParty/Ert/lib/util/perm_vector.cpp index 459eced207..03e52ed6fc 100644 --- a/ThirdParty/Ert/lib/util/perm_vector.cpp +++ b/ThirdParty/Ert/lib/util/perm_vector.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'perm_vector.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/rng.cpp b/ThirdParty/Ert/lib/util/rng.cpp index f0daadcb2f..b5822d76ab 100644 --- a/ThirdParty/Ert/lib/util/rng.cpp +++ b/ThirdParty/Ert/lib/util/rng.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'rng.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/statistics.cpp b/ThirdParty/Ert/lib/util/statistics.cpp index 9aa170b849..7dfec8be3b 100644 --- a/ThirdParty/Ert/lib/util/statistics.cpp +++ b/ThirdParty/Ert/lib/util/statistics.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'statistics.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/string_util.cpp b/ThirdParty/Ert/lib/util/string_util.cpp index 37f258fea7..41f2b3f353 100644 --- a/ThirdParty/Ert/lib/util/string_util.cpp +++ b/ThirdParty/Ert/lib/util/string_util.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'string_util.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/stringlist.cpp b/ThirdParty/Ert/lib/util/stringlist.cpp index 237deabc03..879d1fa5d9 100644 --- a/ThirdParty/Ert/lib/util/stringlist.cpp +++ b/ThirdParty/Ert/lib/util/stringlist.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'stringlist.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/test_util.cpp b/ThirdParty/Ert/lib/util/test_util.cpp index 0e4349f7e0..e52612b558 100644 --- a/ThirdParty/Ert/lib/util/test_util.cpp +++ b/ThirdParty/Ert/lib/util/test_util.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'test_util.c' is part of ERT - Ensemble based Reservoir Tool. @@ -37,6 +37,7 @@ void test_error_exit( const char * fmt , ...) { s = util_alloc_sprintf_va(fmt , ap); va_end(ap); fprintf(stderr, "%s", s); + free(s); exit(1); } diff --git a/ThirdParty/Ert/lib/util/test_work_area.cpp b/ThirdParty/Ert/lib/util/test_work_area.cpp index 32a6267b4c..df7643ef2f 100644 --- a/ThirdParty/Ert/lib/util/test_work_area.cpp +++ b/ThirdParty/Ert/lib/util/test_work_area.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'test_work_area.c' is part of ERT - Ensemble based Reservoir Tool. @@ -25,19 +25,16 @@ #include #endif +#include + #include #include #include #include #include -#include -#include -#ifdef ERT_HAVE_OPENDIR -#include -#include -#endif +#include "detail/util/path.hpp" /* This file implements a small work area implementation to be used for @@ -96,82 +93,65 @@ #define TEST_WORK_AREA_TYPE_ID 1107355 -struct test_work_area_struct { - UTIL_TYPE_ID_DECLARATION; - bool store; - char * cwd; - char * original_cwd; - bool change_dir; +static char * test_work_area_alloc_prefix( ) { +#ifdef HAVE_WINDOWS_GET_TEMP_PATH - /* - There have been issues where a test like this: + char tmp_path[MAX_PATH]; + GetTempPath( MAX_PATH , tmp_path ); + return util_alloc_string_copy( tmp_path ); - 1. Create new file in test area. - 2. Open file for reading. - - Fail randomly at step 2 with "File not found", although the file - is clearly there when checking afterwards. Inspired by this - article: https:/lwn.net/Articles/457667/ we try to call fsync() on - the directory file descriptor. - */ -#ifdef ERT_HAVE_OPENDIR - DIR * dir_stream; -#endif - int dir_fd; -}; - - - - -static test_work_area_type * test_work_area_alloc__(const char * prefix , const char * test_path, bool change_dir) { - test_work_area_type * work_area = NULL; - - if (util_is_directory( prefix )) { - char * test_cwd = util_alloc_sprintf(FULL_PATH_FMT , prefix , test_path ); - util_make_path( test_cwd ); - if (true) { - work_area = (test_work_area_type*)util_malloc( sizeof * work_area ); - - UTIL_TYPE_ID_INIT( work_area , TEST_WORK_AREA_TYPE_ID ); - work_area->original_cwd = util_alloc_cwd(); - work_area->cwd = test_cwd; - work_area->change_dir = change_dir; - if (change_dir ) - if(util_chdir( work_area->cwd ) != 0) - util_abort("%s: Failed to move into temporary directory: %s", __func__, test_cwd); - - test_work_area_set_store( work_area , DEFAULT_STORE); - -#ifdef ERT_HAVE_OPENDIR - work_area->dir_stream = opendir( work_area->cwd ); - if (work_area->dir_stream) - work_area->dir_fd = dirfd( work_area->dir_stream ); - else - work_area->dir_fd = -1; #else - work_area->dir_fd = -1 + + const char * prefix_path = getenv("TMPDIR"); + +#ifdef P_tmpdir + if (!prefix_path) + prefix_path = P_tmpdir; #endif - } else - free( test_cwd ); + + if (!prefix_path) + prefix_path = _PATH_TMP; + + return util_alloc_realpath(prefix_path); + +#endif +} + + + +namespace ecl { +namespace util { + +static bool test_work_area_copy_parent__( const TestArea * work_area , const std::string& input_path, bool copy_content) { + char * full_path; + + if (util_is_abs_path( input_path.c_str() )) + full_path = util_alloc_string_copy( input_path.c_str() ); + else + full_path = util_alloc_filename( work_area->original_cwd().c_str( ) , input_path.c_str() , NULL); + + if (util_entry_exists( full_path)) { + char * parent_path = util_alloc_parent_path( full_path ); + + if (copy_content) + work_area->copy_directory_content(std::string(parent_path)); + else + work_area->copy_directory(std::string(parent_path)); + + free( full_path ); + free( parent_path ); + return true; + } else { + free( full_path ); + return false; } - return work_area; } -test_work_area_type * test_work_area_alloc_relative(const char * prefix , const char * test_path) { - return test_work_area_alloc__(prefix , test_path , true ); -} - - -test_work_area_type * temp_area_alloc_relative(const char * prefix , const char * test_path) { - return test_work_area_alloc__(prefix , test_path , false ); -} - - -UTIL_IS_INSTANCE_FUNCTION( test_work_area , TEST_WORK_AREA_TYPE_ID) - -static test_work_area_type * test_work_area_alloc_with_prefix(const char * prefix , const char * test_name, bool change_dir) { - if (test_name) { +TestArea::TestArea(const std::string& test_name, bool store_area) : + store(store_area) +{ + char * prefix = test_work_area_alloc_prefix(); unsigned int random_int; util_fread_dev_urandom( sizeof random_int, (char *) &random_int); random_int = random_int % 100000000; @@ -183,216 +163,177 @@ static test_work_area_type * test_work_area_alloc_with_prefix(const char * prefi #else char * user_name = util_alloc_sprintf("ert-test-%08u" , random_int); #endif - char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name , random_int); - test_work_area_type * work_area = test_work_area_alloc__( prefix , test_path, change_dir); + + char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name.c_str() , random_int); + char * test_cwd = util_alloc_sprintf(FULL_PATH_FMT , prefix , test_path ); + util_make_path( test_cwd ); + + { + char * cwd_tmp = util_alloc_cwd(); + this->org_cwd = cwd_tmp; + free(cwd_tmp); + } + this->cwd = test_cwd; + if (util_chdir( this->cwd.c_str() ) != 0) + util_abort("%s: Failed to move into temporary directory: %s", __func__, this->cwd.c_str()); + free( test_path ); free( user_name ); - return work_area; - } else + free( test_cwd ); + free( prefix ); +} + +TestArea::~TestArea() { + if (!this->store) + util_clear_directory( this->cwd.c_str() , true , true ); + + util_chdir( this->org_cwd.c_str() ); +} + +const std::string& TestArea::test_cwd() const { + return this->cwd; +} + +const std::string& TestArea::original_cwd() const { + return this->org_cwd; +} + +std::string TestArea::original_path(const std::string& input_path) const { + if (util_is_abs_path( input_path.c_str() )) + return std::string(input_path); + else { + char * fname = util_alloc_filename( this->original_cwd().c_str(), input_path.c_str() , NULL); + + std::string return_string = std::string(fname); + free(fname); + + return return_string; + } +} + + +void TestArea::copy_file(const std::string& input_src_file) const { + std::string src_file = this->original_path(input_src_file); + + if (util_file_exists( src_file.c_str() )) { + char * target_name = util_split_alloc_filename( input_src_file.c_str() ); + char * target_file = util_alloc_filename( this->test_cwd().c_str() , target_name , NULL ); + util_copy_file( src_file.c_str(), target_file ); + free( target_file ); + free( target_name ); + } +} + +void TestArea::copy_directory(const std::string input_directory) const { + std::string src_directory = this->original_path(input_directory); + util_copy_directory(src_directory.c_str() , this->test_cwd().c_str() ); +} + +void TestArea::copy_directory_content(const std::string input_directory) const { + std::string src_directory = this->original_path(input_directory); + util_copy_directory_content(src_directory.c_str() , this->test_cwd().c_str() ); +} + +bool TestArea::copy_parent(const std::string input_path) const { + return test_work_area_copy_parent__(this, input_path, false); +} + +bool TestArea::copy_parent_content(const std::string input_path) const { + return test_work_area_copy_parent__(this, input_path, true); +} + +} +} + +/*****************************************************************/ +/* C API */ + +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); + else return NULL; } -static char * test_work_area_alloc_prefix( ) { -#ifdef HAVE_WINDOWS_GET_TEMP_PATH - - char tmp_path[MAX_PATH]; - GetTempPath( MAX_PATH , tmp_path ); - return util_alloc_string_copy( tmp_path ); - -#else - - const char * prefix_path = getenv("TMPDIR"); - - #ifdef P_tmpdir - if (!prefix_path) - prefix_path = P_tmpdir; - #endif - - if (!prefix_path) - prefix_path = _PATH_TMP; - - return util_alloc_realpath(prefix_path); - -#endif -} - - test_work_area_type * test_work_area_alloc(const char * test_name) { - test_work_area_type * work_area; - { - char * tmp_prefix = test_work_area_alloc_prefix( ); - work_area = test_work_area_alloc_with_prefix( tmp_prefix , test_name , true); - free( tmp_prefix ); - } - return work_area; + return test_work_area_alloc__(test_name, false); } -test_work_area_type * temp_area_alloc(const char * path) { - test_work_area_type * work_area; - { - char * tmp_prefix = test_work_area_alloc_prefix( ); - work_area = test_work_area_alloc_with_prefix( tmp_prefix , path , false ); - free( tmp_prefix ); - } - return work_area; -} - - - -void test_work_area_set_store( test_work_area_type * work_area , bool store) { - work_area->store = store; -} - - -void test_work_area_sync( test_work_area_type * work_area) { -#ifdef ERT_HAVE_OPENDIR - if (work_area->dir_fd >= 0) - fsync( work_area->dir_fd ); -#endif -} void test_work_area_free(test_work_area_type * work_area) { - if (!work_area->store) - util_clear_directory( work_area->cwd , true , true ); - - if (work_area->change_dir) - util_chdir( work_area->original_cwd ); - -#ifdef ERT_HAVE_OPENDIR - if (work_area->dir_stream) - closedir( work_area->dir_stream ); -#endif - - free( work_area->original_cwd ); - free( work_area->cwd ); - free( work_area ); + delete work_area; } const char * test_work_area_get_cwd( const test_work_area_type * work_area ) { - return work_area->cwd; + return work_area->test_cwd().c_str(); } const char * test_work_area_get_original_cwd( const test_work_area_type * work_area ) { - return work_area->original_cwd; + return work_area->original_cwd().c_str(); } + char * test_work_area_alloc_input_path( const test_work_area_type * work_area , const char * input_path ) { - if (util_is_abs_path( input_path )) - return util_alloc_string_copy( input_path ); - else { - if (work_area->change_dir) - return util_alloc_filename( work_area->original_cwd , input_path , NULL); - else - return util_alloc_string_copy( input_path ); - } + std::string relocated_input_path = work_area->original_path(std::string(input_path)); + return util_alloc_string_copy(relocated_input_path.c_str()); } + + /** The point of this function is that the test code should be able to access the file @input_file independent of the fact that it has changed path. If @input_file is an absolute path the function will - do nothing, if @input_file is a realtive path the function will + do nothing, if @input_file is a relative path the function will copy @input_file from the location relative to the original cwd to the corresponding location relative to the test cwd. */ - -void test_work_area_install_file( test_work_area_type * work_area , const char * input_src_file ) { - if (util_is_abs_path( input_src_file )) +void test_work_area_install_file( const test_work_area_type * work_area , const char * input_src_file ) { + if (util_is_abs_path( input_src_file)) return; else { - char * src_file = test_work_area_alloc_input_path( work_area , input_src_file ); - char * src_path = NULL; + std::string src_file = work_area->original_path(input_src_file); + std::string src_path = ecl::util::path::dirname(input_src_file); - util_alloc_file_components( input_src_file , &src_path , NULL , NULL); - if (!util_entry_exists( src_path )) - util_make_path( src_path ); + if (!util_entry_exists( src_path.c_str() )) + util_make_path( src_path.c_str() ); - if (util_file_exists( src_file )) { - char * target_file = util_alloc_filename( work_area->cwd , input_src_file , NULL ); - util_copy_file( src_file , target_file ); + if (util_file_exists( src_file.c_str() )) { + char * target_file = util_alloc_filename( work_area->test_cwd().c_str(), input_src_file, NULL ); + util_copy_file( src_file.c_str() , target_file ); free( target_file ); } - free( src_file ); - free( src_path ); } } -void test_work_area_copy_directory( test_work_area_type * work_area , const char * input_directory) { - char * src_directory = test_work_area_alloc_input_path( work_area , input_directory ); - util_copy_directory(src_directory , work_area->cwd ); - free( src_directory ); - test_work_area_sync( work_area ); +void test_work_area_copy_file( const test_work_area_type * work_area , const char * input_file) { + if (input_file) + work_area->copy_file(std::string(input_file)); } -void test_work_area_copy_directory_content( test_work_area_type * work_area , const char * input_directory) { - char * src_directory = test_work_area_alloc_input_path( work_area , input_directory ); - util_copy_directory_content(src_directory , work_area->cwd ); - free( src_directory ); - test_work_area_sync( work_area ); +void test_work_area_copy_directory( const test_work_area_type * work_area , const char * input_directory) { + work_area->copy_directory(std::string(input_directory)); } - -void test_work_area_copy_file( test_work_area_type * work_area , const char * input_file) { - if (input_file) { - char * src_file = test_work_area_alloc_input_path( work_area , input_file ); - - if (util_file_exists( src_file )) { - char * target_name = util_split_alloc_filename( input_file ); - char * target_file = util_alloc_filename( work_area->cwd , target_name , NULL ); - util_copy_file( src_file , target_file ); - free( target_file ); - free( target_name ); - } - free( src_file ); - test_work_area_sync( work_area ); - } +void test_work_area_copy_directory_content( const test_work_area_type * work_area , const char * input_directory) { + work_area->copy_directory_content(std::string(input_directory)); } - -static bool test_work_area_copy_parent__( test_work_area_type * work_area , const char * input_path, bool copy_content) { - char * full_path; - - if (util_is_abs_path( input_path )) - full_path = util_alloc_string_copy( input_path ); - else - full_path = util_alloc_filename( work_area->original_cwd , input_path , NULL); - - if (util_entry_exists( full_path)) { - char * parent_path = NULL; - - parent_path = util_alloc_parent_path( full_path ); - - if (copy_content) - test_work_area_copy_directory_content( work_area , parent_path ); - else - test_work_area_copy_directory( work_area , parent_path ); - - free( full_path ); - free( parent_path ); - test_work_area_sync( work_area ); - return true; - } else { - free( full_path ); - return false; - } +bool test_work_area_copy_parent_directory( const test_work_area_type * work_area , const char * input_path) { + return work_area->copy_parent(std::string(input_path)); } -bool test_work_area_copy_parent_directory( test_work_area_type * work_area , const char * input_path) { - return test_work_area_copy_parent__( work_area , input_path , false ); -} - - -bool test_work_area_copy_parent_content( test_work_area_type * work_area , const char * input_path) { - return test_work_area_copy_parent__( work_area , input_path , true ); +bool test_work_area_copy_parent_content( const test_work_area_type * work_area , const char * input_path) { + return work_area->copy_parent_content(std::string(input_path)); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_addr2line.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_addr2line.cpp index 06d76bfc28..07cb596216 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_addr2line.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_addr2line.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_addr2line.c' is part of ERT - Ensemble based Reservoir Tool. @@ -28,7 +28,6 @@ void test_lookup(bool valid_address, bool change_cwd) { const char * file = __FILE__; - const char * func = __func__; int line; const int max_bt = 50; void *bt_addr[max_bt]; @@ -45,7 +44,6 @@ void test_lookup(bool valid_address, bool change_cwd) { util_chdir("/tmp"); if (valid_address) { test_assert_false( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr)); - test_assert_string_equal( func_name , func ); test_assert_string_equal( file_name , NULL ); test_assert_int_equal( 0 , line_nr); } else { @@ -59,7 +57,6 @@ void test_lookup(bool valid_address, bool change_cwd) { } else { if (valid_address) { test_assert_true( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr)); - test_assert_string_equal( func_name , func ); test_assert_string_equal( file_name , file ); test_assert_int_equal( line , line_nr ); } else { @@ -90,6 +87,7 @@ int main( int argc , char ** argv) { util_chdir(path); dot_name = util_alloc_sprintf("./%s" , name); util_spawn_blocking(dot_name, 0, NULL, NULL, NULL); + free(dot_name); exit(0); } else { printf("Testing internal lookup ....\n"); diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_alloc_file_components.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_alloc_file_components.cpp index cfdf63fda2..c8a80b4d30 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_alloc_file_components.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_alloc_file_components.cpp @@ -8,36 +8,33 @@ #include -bool checkPath(const char * path, const char * directory, const char * base_name, const char * extension) { +void checkPath(const char * path, const char * directory, const char * base_name, const char * extension) { char * dir; char * base; char * ext; util_alloc_file_components(path, &dir, &base, &ext); - bool success = true; - - success = success && (util_string_equal(dir, directory) || dir == directory); - success = success && (util_string_equal(base, base_name) || base == base_name); - success = success && (util_string_equal(ext, extension) || ext == extension); + test_assert_string_equal(dir, directory); + test_assert_string_equal(base, base_name); + test_assert_string_equal(ext, extension); free(dir); free(base); free(ext); - return success; } int main(int argc , char ** argv) { - test_assert_true(checkPath("/dir/filename.ext", "/dir", "filename", "ext")); - test_assert_true(checkPath("/dir/subdir/filename.ext", "/dir/subdir", "filename", "ext")); - test_assert_true(checkPath("/dir/subdir/filename.name.ext", "/dir/subdir", "filename.name", "ext")); - test_assert_true(checkPath("/dir/subdir/filename", "/dir/subdir", "filename", NULL)); - test_assert_true(checkPath("filename.ext", NULL, "filename", "ext")); - test_assert_true(checkPath("filename", NULL, "filename", NULL)); - test_assert_true(checkPath(".filename", NULL, ".filename", NULL)); - test_assert_true(checkPath(".filename.ext", NULL, ".filename", "ext")); - - exit(0); + checkPath("/dir/filename.ext", "/dir", "filename", "ext"); + checkPath("/dir/subdir/filename.ext", "/dir/subdir", "filename", "ext"); + checkPath("/dir/subdir/filename.name.ext", "/dir/subdir", "filename.name", "ext"); + checkPath("/dir/subdir/filename", "/dir/subdir", "filename", NULL); + checkPath("filename.ext", NULL, "filename", "ext"); + checkPath("filename", NULL, "filename", NULL); + checkPath(".filename", NULL, ".filename", NULL); + checkPath(".filename.ext", NULL, ".filename", "ext"); + checkPath("./SPECASE1", ".", "SPECASE1", NULL); + checkPath("/absolute/path/to/CASE", "/absolute/path/to", "CASE", NULL); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_approx_equal.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_approx_equal.cpp index d9b9f45acf..19f2212795 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_approx_equal.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_approx_equal.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_approx_equal.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_before_after.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_before_after.cpp index d5982d27bd..a3e9753f53 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_before_after.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_before_after.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_before_after.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_binary_split.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_binary_split.cpp index 4c3ee41585..4a1e49ad2c 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_binary_split.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_binary_split.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_binary_split.c' is part of ERT - Ensemble based Reservoir Tool. @@ -25,18 +25,22 @@ void test_split(const char * test_string , bool split_on_first , const char * tr char * part1; char * part2; - util_binary_split_string( test_string , ":" , split_on_first , &part1 , &part2 ); test_assert_string_equal( true1 , part1 ); test_assert_string_equal( true2 , part2 ); + free(part1); + free(part2); util_binary_split_string( test_string , ":;" , split_on_first , &part1 , &part2 ); test_assert_string_equal( true1 , part1 ); test_assert_string_equal( true2 , part2 ); + free(part1); + free(part2); util_binary_split_string( test_string , ";" , split_on_first , &part1 , &part2 ); test_assert_string_equal( test_string , part1 ); test_assert_string_equal( NULL , part2 ); + free(part1); } int main(int argc , char ** argv) { diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_buffer.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_buffer.cpp index a42768df2f..b510933274 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_buffer.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_buffer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Statoil ASA, Norway. + Copyright (C) 2015 Equinor ASA, Norway. The file 'ert_util_buffer.c' is part of ERT - Ensemble based Reservoir Tool. @@ -68,6 +68,7 @@ void test_buffer_strstr() { test_assert_true( buffer_strstr( buffer , "ABC" )); test_assert_true( buffer_strstr( buffer , "BC" )); test_assert_false( buffer_strstr( buffer , "ABC" )); + buffer_free(buffer); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_chdir.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_chdir.cpp index bd84459deb..f465ac7031 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_chdir.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_chdir.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ert_util_chdir.c' is part of ERT - Ensemble based Reservoir Tool. @@ -24,8 +24,8 @@ void test_chdir() { - test_work_area_type * work_area = test_work_area_alloc("test-area"); - const char * cwd = test_work_area_get_cwd( work_area ); + ecl::util::TestArea ta("chdir"); + const char * cwd = ta.test_cwd().c_str(); test_assert_false( util_chdir_file( "/file/does/not/exist")); test_assert_false( util_chdir_file( cwd )); @@ -34,8 +34,13 @@ void test_chdir() { fclose( stream ); } test_assert_true( util_chdir_file( "path/FILE" )); - test_assert_string_equal( util_alloc_cwd() , util_alloc_filename( cwd, "path", NULL)); - test_work_area_free( work_area ); + { + char * new_cwd = util_alloc_cwd(); + char * fname = util_alloc_filename(cwd, "path", NULL); + test_assert_string_equal( new_cwd, fname ); + free(new_cwd); + free(fname); + } } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_clamp.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_clamp.cpp index e56640ada0..65932ab25c 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_clamp.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_clamp.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_clamp.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_copy_file.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_copy_file.cpp index 6ccb4f99ed..1fd0012cff 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_copy_file.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_copy_file.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'enkf_util_copy_file.c' is part of ERT - Ensemble based Reservoir Tool. @@ -36,7 +36,7 @@ void test_copy_file( const char * executable ) { mode0 = stat_buf.st_mode; { - test_work_area_type * test_area = test_work_area_alloc( "executable-copy" ); + ecl::util::TestArea ta("copy_file"); util_copy_file( executable , "test.x"); test_assert_true( util_file_exists( "test.x" )); @@ -44,7 +44,6 @@ void test_copy_file( const char * executable ) { mode1 = stat_buf.st_mode; test_assert_true( mode0 == mode1 ); - test_work_area_free( test_area ); } } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_cwd_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_cwd_test.cpp index 0b59b4fa69..e04523deb8 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_cwd_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_cwd_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_cwd_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -24,10 +24,11 @@ int main(int argc , char ** argv) { char * cwd = argv[1]; - printf("cwd :%s\n",util_alloc_cwd()); + char * cwd_alloc = util_alloc_cwd(); + printf("cwd :%s\n",cwd_alloc); printf("argv[1]:%s\n",argv[1]); - if (!util_is_cwd(cwd)) + if (!util_is_cwd(cwd_alloc)) test_error_exit("Hmmm did not recognize:%s as cwd\n",cwd); if (util_is_cwd("/some/path")) diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp index 2564784ee0..3673653497 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. This file is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_file_readable.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_file_readable.cpp index 25e29b5a42..13bf0f5c1f 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_file_readable.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_file_readable.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_file_readable.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_filename.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_filename.cpp index d42150605e..a88c8f5027 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_filename.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_filename.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_hash_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_hash_test.cpp index d157750e23..c75b8ee219 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_hash_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_hash_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_hash_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_mkdir_p.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_mkdir_p.cpp index 30a2ea8d39..a87a6b86f1 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_mkdir_p.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_mkdir_p.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. The file 'ert_util_mkdir_p.c' is part of ERT - Ensemble based Reservoir Tool. @@ -24,7 +24,7 @@ int main(int argc , char ** argv) { - test_work_area_type * work_area = test_work_area_alloc("Test_area"); + ecl::util::TestArea ta("mkdir"); // Regular use test_assert_true( util_mkdir_p("some/path/with/many/levels")); @@ -45,6 +45,5 @@ int main(int argc , char ** argv) { chmod("read_only", 0555); test_assert_false(util_mkdir_p("read_only/no/not/this")); - test_work_area_free(work_area); exit(0); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.cpp index ff1f117020..8b46860ba6 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'ert_util_normal_path.c' is part of ERT - Ensemble based Reservoir Tool. @@ -32,7 +32,7 @@ void test_path(const char * input_path, const char * expected_path) { void test_relative() { - test_work_area_type * work_area = test_work_area_alloc("Work"); + ecl::util::TestArea ta("relative_path"); util_make_path("level0/level1/level2"); test_path( "level0/level1/../", "level0"); @@ -48,11 +48,10 @@ void test_relative() { util_chdir("level0/level1"); test_path("../../level0/level1/level2/../file.txt" , "file.txt"); test_path("../../level0/level1/level2/../" , ""); - test_work_area_free( work_area ); } void test_beyond_root() { - test_work_area_type * work_area = test_work_area_alloc("Work"); + ecl::util::TestArea("beyond_root"); char * cwd = util_alloc_cwd( ); char * backref_cwd1 = util_alloc_sprintf("../../../../../../../../../../../%s" , cwd ); char * backref_cwd2 = util_alloc_sprintf("/../../../../../../../../../../../%s" , cwd ); @@ -61,7 +60,6 @@ void test_beyond_root() { free( backref_cwd1 ); free( backref_cwd2 ); free( cwd ); - test_work_area_free( work_area ); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_parent_path.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_parent_path.cpp index b5af351b93..7e3d5bdeef 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_parent_path.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_parent_path.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_parent_path.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_path_stack_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_path_stack_test.cpp index ddc26dbaf0..89e0cd018a 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_path_stack_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_path_stack_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_path_stack_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_ping.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_ping.cpp index 58f8e69ba3..a9291d3630 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_ping.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_ping.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_ping.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_realpath.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_realpath.cpp index 7f8c6e814e..2862e07060 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_realpath.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_realpath.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_realpath.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.cpp index e19b336e99..2de2b0ea13 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_relpath_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_rng.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_rng.cpp index ed12cffa83..c309769072 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_rng.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_rng.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_rng.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_spawn.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_spawn.cpp index 19d402f031..127c7847dd 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_spawn.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_spawn.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. The file 'ert_util_spawn.c' is part of ERT - Ensemble based Reservoir Tool. @@ -59,7 +59,7 @@ bool check_script(const char* script) { } void test_spawn_no_redirect() { - test_work_area_type * test_area = test_work_area_alloc("spawn1"); + ecl::util::TestArea ta("spawn1"); { int status; make_script("script" , stdout_msg , stderr_msg); @@ -77,7 +77,6 @@ void test_spawn_no_redirect() { test_assert_int_equal( status , 0 ); } } - test_work_area_free( test_area ); } @@ -136,7 +135,7 @@ void * test_spawn_redirect__( const char * path ) { void test_spawn_redirect() { - test_work_area_type * test_area = test_work_area_alloc("spawn1"); + ecl::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 + S_IWGRP + S_IXGRP + S_IROTH + S_IXOTH); /* u:rwx g:rwx o:rx */ @@ -144,14 +143,13 @@ void test_spawn_redirect() { test_spawn_redirect__( NULL ); } - test_work_area_free( test_area ); } void test_spawn_redirect_threaded() { const int num = 128; // Generate the scripts on disk first - test_work_area_type * test_area = test_work_area_alloc("spawn1_threaded"); + ecl::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++) { @@ -180,7 +178,6 @@ void test_spawn_redirect_threaded() { stringlist_free(script_fullpaths); free(path_codes); - test_work_area_free( test_area ); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_split_path.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_split_path.cpp index 4fce2b4e81..c759c624f7 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_split_path.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_split_path.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Statoil ASA, Norway. + Copyright (C) 2018 Equinor ASA, Norway. The file 'ert_util_split_path.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_sscan_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_sscan_test.cpp index 60f4d180e1..f2d885b816 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_sscan_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_sscan_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. + Copyright (C) 2014 Equinor ASA, Norway. The file 'ert_util_sscan_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_statistics.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_statistics.cpp index ea859328f1..2ecfe9aef9 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_statistics.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_statistics.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_statistics.c' is part of ERT - Ensemble based Reservoir Tool. @@ -32,6 +32,8 @@ void test_mean_std() { test_assert_double_equal( statistics_mean( d ) , 0.50 ); test_assert_double_equal( statistics_std( d ) , 0.50 ); + + double_vector_free( d ); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_strcat_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_strcat_test.cpp index a7042a38eb..27742cc4ff 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_strcat_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_strcat_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_strcat_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -28,8 +28,11 @@ void test_strcat(char * s1 , const char *s2 , const char * expected) { char * cat = util_strcat_realloc(s1 , s2 ); if (test_check_string_equal( cat , expected )) free( cat ); - else - test_error_exit("util_strcat_realloc(%s,%s) Got:%s expected:%s \n",s1,s2,cat , expected); + else { + fprintf(stderr, "util_strcat_realloc(%s,%s) Got:%s expected:%s \n",s1,s2,cat , expected); + free(cat); + exit(1); + } } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_string_util.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_string_util.cpp index 65389d7176..872578336c 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_string_util.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_string_util.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_string_util.c' is part of ERT - Ensemble based Reservoir Tool. @@ -60,6 +60,7 @@ void test_active_list() { test_assert_true( string_util_update_active_list("4-6" , active_list) ); test_int_vector( active_list , 13 , 0,1,3,4,5,6,7,8,9,10,14,15,16); + int_vector_free(active_list); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.cpp index 1ad4c890a7..f01c422819 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_stringlist_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -36,15 +36,25 @@ void test_char() { { char ** copy = stringlist_alloc_char_copy( s ); int i; + bool equal = true; for (i=0; i < stringlist_get_size( s ); i++) { if (strcmp( stringlist_iget( s , i ) , copy[i]) != 0) - exit(1); - + equal = false; + free(copy[i]); } + free(copy); + if (!equal) + test_assert_false("Bug in test_char() function\n"); } + stringlist_free(s); } +void test_alloc_join(const stringlist_type * s, const char * sep, const char * expected) { + char * j = stringlist_alloc_joined_string(s, sep); + test_assert_string_equal(j, expected); + free(j); +} void test_join() { const char * elt0 = "AAA"; @@ -55,13 +65,8 @@ void test_join() { const char * elt5 = "FFF"; stringlist_type * s = stringlist_alloc_new(); + test_alloc_join(s, "!!!", ""); - { - // empty join - const char* empty_join = stringlist_alloc_joined_string(s, "!!!"); - test_assert_not_NULL(empty_join); - test_assert_string_equal("", empty_join); - } stringlist_append_copy( s , elt0 ); stringlist_append_copy( s , elt1 ); @@ -71,28 +76,37 @@ void test_join() { const char * sep1 = "!!!"; const char * sep2 = " abc "; - const char * j0 = stringlist_alloc_joined_string( s, sep0); - const char * j1 = stringlist_alloc_joined_string( s, sep1); - const char * j2 = stringlist_alloc_joined_string( s, sep2); + test_alloc_join(s, sep0, "AAABBBCCC"); + test_alloc_join(s, sep1, "AAA!!!BBB!!!CCC"); + test_alloc_join(s, sep2, "AAA abc BBB abc CCC"); - test_assert_string_equal( j0, "AAABBBCCC"); - test_assert_string_equal( j1, "AAA!!!BBB!!!CCC"); - test_assert_string_equal( j2, "AAA abc BBB abc CCC"); + { + stringlist_type * s1 = stringlist_alloc_new(); - stringlist_type * s1 = stringlist_alloc_new(); - stringlist_append_copy( s1 , elt0 ); - test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep0)); - test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep1)); - test_assert_string_equal( "AAA", stringlist_alloc_joined_string( s1, sep2)); + stringlist_append_copy( s1 , elt0 ); + test_alloc_join(s1, sep0, "AAA"); + test_alloc_join(s1, sep1, "AAA"); + test_alloc_join(s1, sep2, "AAA"); - stringlist_type * sub = stringlist_alloc_new(); - stringlist_append_copy( sub , elt0 ); - stringlist_append_copy( sub , elt1 ); - stringlist_append_copy( sub , elt2 ); - stringlist_append_copy( sub , elt3 ); - stringlist_append_copy( sub , elt4 ); - stringlist_append_copy( sub , elt5 ); - test_assert_string_equal( "CCC:DDD:EEE", stringlist_alloc_joined_substring( sub, 2, 5, ":")); + stringlist_free(s1); + } + { + stringlist_type * sub = stringlist_alloc_new(); + stringlist_append_copy( sub , elt0 ); + stringlist_append_copy( sub , elt1 ); + stringlist_append_copy( sub , elt2 ); + stringlist_append_copy( sub , elt3 ); + stringlist_append_copy( sub , elt4 ); + stringlist_append_copy( sub , elt5 ); + { + char * j = stringlist_alloc_joined_substring( sub, 2, 5, ":"); + test_assert_string_equal( "CCC:DDD:EEE", j); + free(j); + } + + stringlist_free(sub); + } + stringlist_free(s); } @@ -112,6 +126,8 @@ void test_reverse() { test_assert_string_equal( s2 , stringlist_iget(s , 0 )); test_assert_string_equal( s1 , stringlist_iget(s , 1 )); test_assert_string_equal( s0 , stringlist_iget(s , 2 )); + + stringlist_free(s); } @@ -136,6 +152,7 @@ void test_iget_as_int() { value = stringlist_iget_as_int( s , 2 , NULL); test_assert_int_equal( value , -1); } + stringlist_free(s); } @@ -161,6 +178,7 @@ void test_iget_as_double() { test_assert_double_equal( value , -1); test_assert_false( valid ); } + stringlist_free(s); } @@ -235,12 +253,14 @@ void test_iget_as_bool() { test_assert_false( value ); test_assert_false( valid ); } + stringlist_free(s); } void test_empty() { stringlist_type * s = stringlist_alloc_new(); stringlist_fprintf( s , "\n" , stdout ); + stringlist_free(s); } void test_front_back() { @@ -347,7 +367,7 @@ bool not_FILE_predicate(const char * name, const void * arg) { void test_predicate_matching() { - test_work_area_type * work_area = test_work_area_alloc("predicate_test"); + ecl::util::TestArea ta("stringlist"); stringlist_type * s = stringlist_alloc_new(); stringlist_append_copy(s, "s"); stringlist_select_files(s, "does/not/exist", NULL, NULL); @@ -358,7 +378,7 @@ void test_predicate_matching() { FILE * f = util_fopen("FILE.txt", "w"); fclose(f); } - stringlist_select_files(s , test_work_area_get_cwd(work_area), NULL, NULL); + stringlist_select_files(s , ta.test_cwd().c_str(), NULL, NULL); test_assert_int_equal(1, stringlist_get_size(s)); { char * exp = util_alloc_abs_path("FILE.txt"); @@ -370,7 +390,7 @@ void test_predicate_matching() { test_assert_int_equal(1, stringlist_get_size(s)); test_assert_string_equal( "FILE.txt", stringlist_iget(s, 0)); - stringlist_select_files(s , test_work_area_get_cwd(work_area), FILE_predicate, NULL); + stringlist_select_files(s , ta.test_cwd().c_str(), FILE_predicate, NULL); test_assert_int_equal(1, stringlist_get_size(s)); { char * exp = util_alloc_abs_path("FILE.txt"); @@ -378,11 +398,10 @@ void test_predicate_matching() { free(exp); } - stringlist_select_files(s , test_work_area_get_cwd(work_area), not_FILE_predicate, NULL); + stringlist_select_files(s , ta.test_cwd().c_str(), not_FILE_predicate, NULL); test_assert_int_equal(0, stringlist_get_size(s)); stringlist_free(s); - test_work_area_free(work_area); } @@ -399,6 +418,7 @@ void test_unique() { stringlist_append_copy( s, "S2"); test_assert_false( stringlist_unique( s )); + stringlist_free(s); } int main( int argc , char ** argv) { diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_strstr_int_format.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_strstr_int_format.cpp index 567323c8eb..04b6e84ad0 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_strstr_int_format.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_strstr_int_format.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_str_str_int_format.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_functions.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_functions.cpp index 802e8e69cf..7376df2d50 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_functions.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_functions.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_type_vector_functions.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.cpp index 1a447db084..5ef217d461 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_type_vector_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -94,10 +94,12 @@ void test_contains() { int_vector_type * int_vector = int_vector_alloc( 0 , 100); test_assert_false( int_vector_contains( int_vector , 100 )); + int_vector_resize( int_vector, 1, 100 ); int_vector_iset( int_vector , 0 , 77 ); test_assert_false( int_vector_contains( int_vector , 100 )); test_assert_true( int_vector_contains( int_vector , 77 )); + int_vector_resize( int_vector, 11, 100 ); int_vector_iset( int_vector , 10 , 33 ); test_assert_true( int_vector_contains( int_vector , 100 )); test_assert_true( int_vector_contains( int_vector , 77 )); @@ -120,12 +122,15 @@ void test_contains_sorted() { test_assert_false( int_vector_contains( int_vector , 100 )); test_assert_true( int_vector_contains( int_vector , 89 )); test_assert_true( int_vector_contains( int_vector , 109 )); + + int_vector_free(int_vector); } void test_div() { int_vector_type * int_vector = int_vector_alloc( 0 , 100); + int_vector_resize( int_vector, 11, 100 ); int_vector_iset( int_vector , 10 , 100 ); int_vector_div( int_vector , 10 ); { @@ -133,6 +138,7 @@ void test_div() { for (i=0; i < int_vector_size( int_vector ); i++) test_assert_int_equal( 10 , int_vector_iget( int_vector , i )); } + int_vector_free(int_vector); } void test_memcpy_from_data() { @@ -239,6 +245,8 @@ void test_idel_insert() { void test_iset_block() { int_vector_type * vec = int_vector_alloc(0,0); + int_vector_resize( vec, 10, 0 ); + int_vector_resize( vec, 20, 77 ); int_vector_iset_block( vec , 10 , 10 , 77 ); test_assert_int_equal( int_vector_size( vec ) , 20 ); { @@ -263,8 +271,8 @@ void test_resize() { int i; int def = 77; int_vector_type * vec = int_vector_alloc(0,def); - int_vector_resize( vec , 10 ); - test_assert_int_equal( int_vector_size( vec ) , 10 ); + int_vector_resize( vec , 10 , def); + test_assert_int_equal( int_vector_size( vec ) , 10 ); for (i=0; i < 10; i++) test_assert_int_equal( int_vector_iget( vec , i ) , def ); @@ -272,12 +280,12 @@ void test_resize() { for (i=5; i < 10; i++) test_assert_int_equal( int_vector_iget( vec , i ) , 5 ); - int_vector_resize( vec , 5 ); + int_vector_resize( vec , 5 , def); test_assert_int_equal( int_vector_size( vec ) , 5 ); for (i=0; i < 5; i++) test_assert_int_equal( int_vector_iget( vec , i ) , def ); - int_vector_resize( vec , 10 ); + int_vector_resize( vec , 10, def ); test_assert_int_equal( int_vector_size( vec ) , 10 ); for (i=0; i < 10; i++) test_assert_int_equal( int_vector_iget( vec , i ) , def ); @@ -345,9 +353,9 @@ void test_empty() { void test_equal_index() { - int_vector_type * v1 = int_vector_alloc(0,0); - int_vector_type * v2 = int_vector_alloc(0,0); - int_vector_type * v3 = int_vector_alloc(0,0); + int_vector_type * v1 = int_vector_alloc(5,0); + int_vector_type * v2 = int_vector_alloc(5,0); + int_vector_type * v3 = int_vector_alloc(5,0); for (int i=0; i < 5; i++) { int_vector_iset(v1,i,i); @@ -373,10 +381,18 @@ void test_equal_index() { int_vector_free(v3); } +void test_misc() { + int_vector_type * v = int_vector_alloc(5, 123); + test_assert_int_equal( int_vector_iget(v, 2), 123 ); + int_vector_resize(v, 20, 0); + test_assert_int_equal( int_vector_iget(v, 4), 123); + test_assert_int_equal( int_vector_iget(v, 9), 0 ); + test_assert_int_equal( int_vector_iget(v, 19), 0); + int_vector_free(v); +} -int main(int argc , char ** argv) { - +void misc_int_vector_test() { int_vector_type * int_vector = int_vector_alloc( 0 , 99); test_abort(); @@ -385,8 +401,10 @@ int main(int argc , char ** argv) { test_assert_true( int_vector_is_instance( int_vector )); test_assert_false( double_vector_is_instance( int_vector )); + int_vector_resize( int_vector, 3, 99 ); int_vector_iset( int_vector , 2 , 0); int_vector_insert( int_vector , 2 , 77 ); + int_vector_resize( int_vector, 6, 99 ); int_vector_iset( int_vector , 5 , -10); assert_equal( int_vector_iget(int_vector , 0 ) == 99 ); @@ -428,6 +446,12 @@ int main(int argc , char ** argv) { test_assert_int_equal( int_vector_iget( int_vector , 3 ) , -245); test_assert_int_equal( int_vector_get_last( int_vector ) , -935); + int_vector_free(int_vector); +} + +int main(int argc , char ** argv) { + test_misc(); + misc_int_vector_test(); { int_vector_type * v1 = int_vector_alloc(0,0); int_vector_type * v2 = int_vector_alloc(0,0); diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_unique_ptr.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_unique_ptr.cpp index a2873abd6c..4d755633e7 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_unique_ptr.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_unique_ptr.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Statoil ASA, Norway. + Copyright (C) 2016 Equinor ASA, Norway. This is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_vector_test.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_vector_test.cpp index ade1cb5f99..8a44cd2168 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_vector_test.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_vector_test.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_vector_test.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_work_area.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_work_area.cpp index 29e344729a..2c462290a6 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_work_area.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_work_area.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -48,10 +49,9 @@ void test_get_original_cwd() { void create_test_area(const char * test_name , bool store) { char * pre_cwd = util_alloc_cwd(); - test_work_area_type * work_area = test_work_area_alloc( test_name ); + test_work_area_type * work_area = test_work_area_alloc__( test_name, store ); char * work_path = util_alloc_string_copy( test_work_area_get_cwd( work_area )); - test_work_area_set_store( work_area , store ); test_assert_true( util_is_directory( work_path )); test_work_area_free( work_area ); test_assert_bool_equal( store , util_entry_exists( work_path )); @@ -158,31 +158,14 @@ void test_copy_parent_content( const char * path ) { } -void test_with_prefix() { - test_work_area_type * work_area = test_work_area_alloc( "with-prefix" ); - - util_make_path( "PREFIX" ); - { - test_work_area_type * sub_area = test_work_area_alloc_relative("PREFIX" , "sub-work" ); - test_assert_true( test_work_area_is_instance( sub_area )); - test_work_area_free( sub_area ); - test_assert_true( util_entry_exists("PREFIX/sub-work")); - } - { - test_work_area_type * sub_area = test_work_area_alloc_relative("DoesNotExist" , "sub-work" ); - test_assert_NULL( sub_area ); - } - test_work_area_free( work_area ); -} - void test_update_store() { { - test_work_area_type * work_area = test_work_area_alloc( "update-store1" ); + test_work_area_type * work_area = test_work_area_alloc__( "update-store1" , true); char * work_cwd = util_alloc_string_copy( test_work_area_get_cwd( work_area )); - test_work_area_set_store( work_area , true ); test_work_area_free( work_area ); test_assert_true( util_entry_exists( work_cwd )); + free(work_cwd); } { @@ -190,22 +173,23 @@ void test_update_store() { char * work_cwd = util_alloc_string_copy( test_work_area_get_cwd( work_area )); test_work_area_free( work_area ); test_assert_false( util_entry_exists( work_cwd )); + free(work_cwd); } { - test_work_area_type * work_area = test_work_area_alloc( "update-store3" ); + test_work_area_type * work_area = test_work_area_alloc__( "update-store3" , false); char * work_cwd = util_alloc_string_copy( test_work_area_get_cwd( work_area )); - test_work_area_set_store( work_area , false ); test_work_area_free( work_area ); test_assert_false( util_entry_exists( work_cwd )); + free(work_cwd); } { - test_work_area_type * work_area = test_work_area_alloc( "update-store4" ); + test_work_area_type * work_area = test_work_area_alloc__( "update-store4" , true); char * work_cwd = util_alloc_string_copy( test_work_area_get_cwd( work_area )); - test_work_area_set_store( work_area , true); test_work_area_free( work_area ); test_assert_true( util_entry_exists( work_cwd )); + free(work_cwd); } } @@ -215,10 +199,12 @@ int main(int argc , char ** argv) { const char * abs_path_file = argv[2]; const char * rel_directory = argv[3]; - create_test_area("STORE-TEST" , true ); - create_test_area("DEL-TEST" , false); + create_test_area("STORE-TEST", true ); + create_test_area("DEL-TEST", false); + test_install_file_exists( rel_path_file ); test_install_file_exists( abs_path_file ); + test_copy_directory( rel_directory ); test_input(); test_get_cwd(); @@ -233,8 +219,6 @@ int main(int argc , char ** argv) { test_copy_parent_content( rel_path_file ); test_copy_parent_content( abs_path_file ); - test_with_prefix(); test_update_store(); - exit(0); } diff --git a/ThirdParty/Ert/lib/util/tests/test_area.cpp b/ThirdParty/Ert/lib/util/tests/test_area.cpp new file mode 100644 index 0000000000..9f580ae18f --- /dev/null +++ b/ThirdParty/Ert/lib/util/tests/test_area.cpp @@ -0,0 +1,34 @@ +/* + Copyright (C) 2019 Equinor ASA, Norway. + + The file 'test_area.cpp' 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ +#include + +#include +#include + +void test_create() { + ecl::util::TestArea ta("Name"); + + test_assert_true( ta.test_cwd() != ta.original_cwd() ); + +} + + + +int main(int argc, char **argv) { + test_create(); +} diff --git a/ThirdParty/Ert/lib/util/tests/test_thread_pool.cpp b/ThirdParty/Ert/lib/util/tests/test_thread_pool.cpp index 1700de5a3b..f2679ae6d8 100644 --- a/ThirdParty/Ert/lib/util/tests/test_thread_pool.cpp +++ b/ThirdParty/Ert/lib/util/tests/test_thread_pool.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Statoil ASA, Norway. + Copyright (C) 2015 Equinor ASA, Norway. The file 'test_thread_pool.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/timer.cpp b/ThirdParty/Ert/lib/util/timer.cpp index c333a20663..7c87a9c8c3 100644 --- a/ThirdParty/Ert/lib/util/timer.cpp +++ b/ThirdParty/Ert/lib/util/timer.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'timer.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/type_vector_functions.cpp b/ThirdParty/Ert/lib/util/type_vector_functions.cpp index 2dec9f3f1e..9daf66111e 100644 --- a/ThirdParty/Ert/lib/util/type_vector_functions.cpp +++ b/ThirdParty/Ert/lib/util/type_vector_functions.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'ert_util_vector_function.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 9ae01521b7..84048565e2 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'util.c' is part of ERT - Ensemble based Reservoir Tool. @@ -996,7 +996,9 @@ char * util_alloc_normal_path( const char * input_path ) { return util_alloc_realpath__( input_path ); char * realpath = util_alloc_realpath__(input_path); - return util_alloc_rel_path( NULL , realpath ); + char * rel_path = util_alloc_rel_path( NULL , realpath ); + free( realpath ); + return rel_path; } @@ -2153,8 +2155,6 @@ int util_fmove( FILE * stream , long offset , long shift) { #ifdef HAVE_WINDOWS__ACCESS bool util_access(const char * entry, int mode) { - if (!entry) return false; - return (_access(entry, mode) == 0); } @@ -2162,8 +2162,6 @@ bool util_access(const char * entry, int mode) { #ifdef HAVE_POSIX_ACCESS bool util_access(const char * entry, mode_t mode) { - if (!entry) return false; - return (access(entry, mode) == 0); } #endif @@ -2890,13 +2888,6 @@ bool util_fscanf_date_utc(FILE *stream , time_t *t) { */ -void util_fprintf_date_utc(time_t t , FILE * stream) { - int mday,year,month; - - util_set_datetime_values_utc(t , NULL , NULL , NULL , &mday , &month , &year); - fprintf(stream , "%02d/%02d/%4d", mday,month,year); -} - char * util_alloc_date_string_utc( time_t t ) { int mday,year,month; @@ -3070,22 +3061,6 @@ time_t util_make_pure_date_utc(time_t t) { /*****************************************************************/ -void util_set_strip_copy(char * copy , const char *src) { - const char null_char = '\0'; - const char space_char = ' '; - int src_index = 0; - int target_index = 0; - while (src[src_index] == space_char) - src_index++; - - while (src[src_index] != null_char && src[src_index] != space_char) { - copy[target_index] = src[src_index]; - src_index++; - target_index++; - } - copy[target_index] = null_char; -} - /** The function will allocate a new copy of src where leading and @@ -4334,53 +4309,6 @@ void * util_realloc_copy(void * org_ptr , const void * src , size_t byte_size ) /*****************************************************************/ -/** - These small functions write formatted values onto a stream. The - main point about these functions is to avoid creating small one-off - format strings. The character base_fmt should be 'f' or 'g' -*/ - -void util_fprintf_double(double value , int width , int decimals , char base_fmt , FILE * stream) { - char * fmt = util_alloc_sprintf("%c%d.%d%c" , '%' , width , decimals , base_fmt); - fprintf(stream , fmt , value); - free(fmt); -} - - -void util_fprintf_int(int value , int width , FILE * stream) { - char fmt[32]; - sprintf(fmt , "%%%dd" , width); - fprintf(stream , fmt , value); -} - - - -void util_fprintf_string(const char * s , int width_ , string_alignement_type alignement , FILE * stream) { - char fmt[32]; - size_t i; - size_t width = width_; - if (alignement == left_pad) { - i = 0; - if (width > strlen(s)) { - for (i=0; i < (width - strlen(s)); i++) - fputc(' ' , stream); - } - fprintf(stream , "%s", s); - } else if (alignement == right_pad) { - sprintf(fmt , "%%-%lus" , width); - fprintf(stream , fmt , s); - } else { - int total_pad = width - strlen(s); - int front_pad = total_pad / 2; - int back_pad = total_pad - front_pad; - int i; - util_fprintf_string(s , front_pad + strlen(s) , left_pad , stream); - for (i=0; i < back_pad; i++) - fputc(' ' , stream); - } -} - - diff --git a/ThirdParty/Ert/lib/util/util_endian.cpp b/ThirdParty/Ert/lib/util/util_endian.cpp index 0613f0e639..a8a03f7af8 100644 --- a/ThirdParty/Ert/lib/util/util_endian.cpp +++ b/ThirdParty/Ert/lib/util/util_endian.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. + Copyright (C) 2012 Equinor ASA, Norway. The file 'util_endian.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/util_lfs.c b/ThirdParty/Ert/lib/util/util_lfs.c index d6d9c1f735..422e87fd63 100644 --- a/ThirdParty/Ert/lib/util/util_lfs.c +++ b/ThirdParty/Ert/lib/util/util_lfs.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. + Copyright (C) 2013 Equinor ASA, Norway. The file 'util_lfs.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/util_unlink.cpp b/ThirdParty/Ert/lib/util/util_unlink.cpp index be7d633665..74200f572d 100644 --- a/ThirdParty/Ert/lib/util/util_unlink.cpp +++ b/ThirdParty/Ert/lib/util/util_unlink.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Statoil ASA, Norway. + Copyright (C) 2017 Equinor ASA, Norway. The file 'util_unlink.c' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/lib/util/vector.cpp b/ThirdParty/Ert/lib/util/vector.cpp index 27da7ff790..9c8fdd6d76 100644 --- a/ThirdParty/Ert/lib/util/vector.cpp +++ b/ThirdParty/Ert/lib/util/vector.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'vector.c' is part of ERT - Ensemble based Reservoir Tool. @@ -589,6 +589,7 @@ int_vector_type * vector_alloc_sort_perm(const vector_type * vector , vector_cmp vector_sort_node_type * sort_data = vector_alloc_sort_data( vector , cmp ); int_vector_type * sort_perm = int_vector_alloc(0,0); int i; + int_vector_resize( sort_perm, vector->size, 0 ); for (i = 0; i < vector->size; i++) int_vector_iset( sort_perm , i , sort_data[i].index); diff --git a/ThirdParty/Ert/lib/util/vector_template.cpp b/ThirdParty/Ert/lib/util/vector_template.cpp index de5ee77a28..d9811f01ce 100644 --- a/ThirdParty/Ert/lib/util/vector_template.cpp +++ b/ThirdParty/Ert/lib/util/vector_template.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'vector_template.c' is part of ERT - Ensemble based Reservoir Tool. @@ -47,29 +47,29 @@ ------------------------------------ - ·-----·-----· + �-----�-----� 1. | 77 | 77 | size = 0, alloc_size = 2 - ·-----·-----· + �-----�-----� - ·-----·-----· + �-----�-----� 2. | 1 | 77 | size = 1, alloc_size = 2 - ·-----·-----· + �-----�-----� - ·-----·-----· + �-----�-----� 3. | 1 | 0 | size = 2, alloc_size = 2 - ·-----·-----· + �-----�-----� - ·-----·-----·-----·-----· + �-----�-----�-----�-----� 4. | 1 | 0 | 12 | 77 | size = 3, alloc_size = 4 - ·-----·-----·-----·-----· + �-----�-----�-----�-----� - ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· + �-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----� 5. | 1 | 0 | 12 | 77 | 77 | 77 | 78 | 77 | 77 | 77 | 77 | 77 | 77 | 77 | 77 | 77 | size = 7, alloc_size = 12, default = 77 - ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· + �-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----� - ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· + �-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----� 6. | 1 | 0 | 12 | 77 | 77 | 77 | 78 | 99 | 99 | 99 | 99 | 99 | 99 | 99 | 99 | 99 | size = 7, alloc_size = 12, default = 99 - ·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----·-----· + �-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----�-----� 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 @@ -137,14 +137,14 @@ UTIL_SAFE_CAST_FUNCTION(@TYPE@_vector , TYPE_VECTOR_ID); UTIL_IS_INSTANCE_FUNCTION(@TYPE@_vector , TYPE_VECTOR_ID); -static void @TYPE@_vector_realloc_data__(@TYPE@_vector_type * vector , int new_alloc_size) { +static void @TYPE@_vector_realloc_data__(@TYPE@_vector_type * vector , int new_alloc_size, @TYPE@ default_value) { if (new_alloc_size != vector->alloc_size) { if (vector->data_owner) { if (new_alloc_size > 0) { int i; vector->data = (@TYPE@*)util_realloc(vector->data , new_alloc_size * sizeof * vector->data ); for (i=vector->alloc_size; i < new_alloc_size; i++) - vector->data[i] = vector->default_value; + vector->data[i] = default_value; } else { if (vector->alloc_size > 0) { free(vector->data); @@ -163,7 +163,7 @@ static void @TYPE@_vector_memmove(@TYPE@_vector_type * vector , int offset , int util_abort("%s: offset:%d left_shift:%d - invalid \n",__func__ , offset , -shift); if ((shift + vector->size > vector->alloc_size)) - @TYPE@_vector_realloc_data__( vector , util_int_min( 2*vector->alloc_size , shift + vector->size )); + @TYPE@_vector_realloc_data__( vector , util_int_min( 2*vector->alloc_size , shift + vector->size ), vector->default_value); { size_t move_size = (vector->size - offset) * sizeof(@TYPE@); @@ -230,7 +230,7 @@ static @TYPE@_vector_type * @TYPE@_vector_alloc__(int init_size , @TYPE@ default @TYPE@_vector_set_read_only( vector , false ); if (init_size > 0) - @TYPE@_vector_iset( vector , init_size - 1 , default_value ); /* Filling up the init size elements with the default value */ + @TYPE@_vector_resize( vector , init_size , default_value ); /* Filling up the init size elements with the default value */ return vector; } @@ -253,11 +253,18 @@ static @TYPE@_vector_type * @TYPE@_vector_alloc__(int init_size , @TYPE@ default new_size > current_size: The vector will grow by adding default elements at the end. */ -void @TYPE@_vector_resize( @TYPE@_vector_type * vector , int new_size ) { - if (new_size <= vector->size) - vector->size = new_size; - else - @TYPE@_vector_iset( vector , new_size - 1 , vector->default_value); +void @TYPE@_vector_resize( @TYPE@_vector_type * vector , int new_size, @TYPE@ default_value ) { + if (new_size > vector->size) { + if (new_size > vector->alloc_size) { + for (int i = vector->size; i < vector->alloc_size; i++) + vector->data[i] = default_value; + @TYPE@_vector_realloc_data__( vector, 2 * new_size, default_value); + } + else + for (int i = vector->size; i < new_size; i++) + vector->data[i] = default_value; + } + vector->size = new_size; } @@ -341,7 +348,8 @@ void @TYPE@_vector_memcpy_data_block( @TYPE@_vector_type * target , const @TYPE@ void @TYPE@_vector_memcpy_from_data( @TYPE@_vector_type * target , const @TYPE@ * src , int src_size ) { @TYPE@_vector_reset( target ); - @TYPE@_vector_iset( target , src_size - 1 , 0 ); + //@TYPE@_vector_iset( target , src_size - 1 , 0 ); + @TYPE@_vector_resize( target, src_size, 0); memcpy( target->data , src , src_size * sizeof * target->data ); } @@ -397,7 +405,7 @@ void @TYPE@_vector_memcpy( @TYPE@_vector_type * target, const @TYPE@_vector_type @TYPE@_vector_type * @TYPE@_vector_alloc_copy( const @TYPE@_vector_type * src) { @TYPE@_vector_type * copy = @TYPE@_vector_alloc( src->size , src->default_value ); - @TYPE@_vector_realloc_data__( copy , src->alloc_size ); + @TYPE@_vector_realloc_data__( copy , src->alloc_size, src->default_value ); copy->size = src->size; memcpy(copy->data , src->data , src->alloc_size * sizeof * src->data ); return copy; @@ -616,7 +624,7 @@ void @TYPE@_vector_iset(@TYPE@_vector_type * vector , int index , @TYPE@ value) util_abort("%s: Sorry - can NOT set negative indices. called with index:%d \n",__func__ , index); { if (vector->alloc_size <= index) - @TYPE@_vector_realloc_data__(vector , 2 * (index + 1)); /* Must have ( + 1) here to ensure we are not doing 2*0 */ + @TYPE@_vector_realloc_data__(vector , 2 * (index + 1), vector->default_value); /* Must have ( + 1) here to ensure we are not doing 2*0 */ vector->data[index] = value; if (index >= vector->size) { int i; @@ -729,7 +737,10 @@ void @TYPE@_vector_insert( @TYPE@_vector_type * vector , int index , @TYPE@ valu void @TYPE@_vector_append(@TYPE@_vector_type * vector , @TYPE@ value) { - @TYPE@_vector_iset(vector , vector->size , value); + //@TYPE@_vector_iset(vector , vector->size , value); + int size = vector->size; + @TYPE@_vector_resize(vector, size+1, 0); + vector->data[size] = value; } @@ -746,7 +757,7 @@ void @TYPE@_vector_free_container(@TYPE@_vector_type * vector) { void @TYPE@_vector_free_data(@TYPE@_vector_type * vector) { @TYPE@_vector_reset(vector); - @TYPE@_vector_realloc_data__(vector , 0); + @TYPE@_vector_realloc_data__(vector , 0, vector->default_value); } @@ -848,7 +859,7 @@ void @TYPE@_vector_set_many(@TYPE@_vector_type * vector , int index , const @TYP { int min_size = index + length; if (min_size > vector->alloc_size) - @TYPE@_vector_realloc_data__(vector , 2 * min_size); + @TYPE@_vector_realloc_data__(vector , 2 * min_size, vector->default_value); memcpy( &vector->data[index] , data , length * sizeof * data); if (min_size > vector->size) vector->size = min_size; @@ -931,7 +942,7 @@ void @TYPE@_vector_append_vector(@TYPE@_vector_type * vector , const @TYPE@_vect */ void @TYPE@_vector_shrink(@TYPE@_vector_type * vector) { - @TYPE@_vector_realloc_data__(vector , vector->size); + @TYPE@_vector_realloc_data__(vector , vector->size, vector->default_value); } @@ -1420,7 +1431,7 @@ void @TYPE@_vector_fprintf(const @TYPE@_vector_type * vector , FILE * stream , c vector_resize based on the input size. */ void @TYPE@_vector_fread_data( @TYPE@_vector_type * vector , int size, FILE * stream) { - @TYPE@_vector_realloc_data__( vector , size ); + @TYPE@_vector_realloc_data__( vector , size, vector->default_value ); util_fread( vector->data , sizeof * vector->data , size , stream , __func__); vector->size = size; } diff --git a/ThirdParty/Ert/lib/vector_template.h.in b/ThirdParty/Ert/lib/vector_template.h.in index c11dc38d34..8850800e2e 100644 --- a/ThirdParty/Ert/lib/vector_template.h.in +++ b/ThirdParty/Ert/lib/vector_template.h.in @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'vector_template.h' is part of ERT - Ensemble based Reservoir Tool. @@ -61,7 +61,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); int @TYPE@_vector_get_min_index(const @TYPE@_vector_type * vector, bool reverse); int @TYPE@_vector_get_max_index(const @TYPE@_vector_type * vector, bool reverse); @TYPE@ @TYPE@_vector_iadd( @TYPE@_vector_type * vector , int index , @TYPE@ delta); - void @TYPE@_vector_resize( @TYPE@_vector_type * vector , int new_size ); + void @TYPE@_vector_resize( @TYPE@_vector_type * vector , int new_size , @TYPE@ default_value ); void @TYPE@_vector_iset(@TYPE@_vector_type * , int , @TYPE@); void @TYPE@_vector_iset_block(@TYPE@_vector_type * vector , int index , int block_size , @TYPE@ value); void @TYPE@_vector_idel_block( @TYPE@_vector_type * vector , int index , int block_size); diff --git a/ThirdParty/Ert/lib/vector_template.hpp.in b/ThirdParty/Ert/lib/vector_template.hpp.in index f4574fdda5..cc98127f36 100644 --- a/ThirdParty/Ert/lib/vector_template.hpp.in +++ b/ThirdParty/Ert/lib/vector_template.hpp.in @@ -1,5 +1,5 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2011 Equinor ASA, Norway. The file 'vector_template.hpp' is part of ERT - Ensemble based Reservoir Tool. diff --git a/ThirdParty/Ert/python/CMakeLists.txt b/ThirdParty/Ert/python/CMakeLists.txt index 6463a7704c..8f9cf51d9f 100644 --- a/ThirdParty/Ert/python/CMakeLists.txt +++ b/ThirdParty/Ert/python/CMakeLists.txt @@ -35,3 +35,6 @@ if (BUILD_TESTS) add_subdirectory( tests ) endif() +if(RST_DOC) + add_subdirectory( docs ) +endif() diff --git a/ThirdParty/Ert/python/docs/CMakeLists.txt b/ThirdParty/Ert/python/docs/CMakeLists.txt new file mode 100644 index 0000000000..58516cf894 --- /dev/null +++ b/ThirdParty/Ert/python/docs/CMakeLists.txt @@ -0,0 +1,60 @@ +find_package(Sphinx REQUIRED) + +set(DOC_INSTALL_PREFIX "share/libecl/docs") +set(doc_build "${PROJECT_BINARY_DIR}/doc_build") +file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/code" DESTINATION ${doc_build}) + +configure_file(index.rst.in "${doc_build}/index.rst") +configure_file(conf.py.in "${doc_build}/conf.py") + +add_custom_target(api-doc ALL + 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) + +add_custom_target(html-doc ALL + COMMAND sphinx-build -b html -d ${doc_build}/doctrees ${doc_build} ${doc_build}/html + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} + DEPENDS api-doc) + +INSTALL( DIRECTORY ${doc_build}/html DESTINATION ${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_PREFIX}) + + +# This command will configure sphinx to create a LaTeX version of the manual in +# ${doc_build}/latex - this can then subsequently be compiled with pdflatex to +# generate a pdf document. +# +# The LaTeX code generated by sphinx uses some packages which are not +# installed on RHEL 6/7, those sty files are therefor bundled with this +# project and copied manually to the LaTeX directory. +# +# Observe that at least on stock ubuntu 16.04 cmake will complain with a message: +# +# -- Could NOT find LATEX (missing: pdflatex) +# +# even in situatons where pdflatex is found and works ok; in this case the +# PDFLATEX_COMPILER variable is set and the pdf generation seems to work as +# expected. +find_package(LATEX COMPONENTS pdflatex) +if (PDFLATEX_COMPILER) + set(latex_workdir "${doc_build}/latex") + + add_custom_target(latex-doc ALL + COMMAND sphinx-build -b latex -d ${doc_build}/doctrees ${doc_build} ${latex_workdir} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} + DEPENDS api-doc) + + file(GLOB sty_files "latex/*.sty") + file(COPY ${sty_files} DESTINATION ${latex_workdir}) + + # The pdflatex command is issued twice to let latex resolve references + # correctly. + add_custom_target(pdf-doc ALL + COMMAND ${PDFLATEX_COMPILER} "libecl.tex" + COMMAND ${PDFLATEX_COMPILER} "libecl.tex" + DEPENDS latex-doc + WORKING_DIRECTORY ${latex_workdir}) + + install(FILES ${latex_workdir}/libecl.pdf DESTINATION ${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_PREFIX}/pdf) +endif() + diff --git a/ThirdParty/Ert/docs/code/index.rst b/ThirdParty/Ert/python/docs/code/index.rst similarity index 90% rename from ThirdParty/Ert/docs/code/index.rst rename to ThirdParty/Ert/python/docs/code/index.rst index 8ebb5c1196..35405bde17 100644 --- a/ThirdParty/Ert/docs/code/index.rst +++ b/ThirdParty/Ert/python/docs/code/index.rst @@ -7,5 +7,4 @@ Contents: :maxdepth: 1 python/index - C/index diff --git a/ThirdParty/Ert/docs/code/python/eclipse/index.rst b/ThirdParty/Ert/python/docs/code/python/eclipse/index.rst similarity index 100% rename from ThirdParty/Ert/docs/code/python/eclipse/index.rst rename to ThirdParty/Ert/python/docs/code/python/eclipse/index.rst diff --git a/ThirdParty/Ert/docs/code/python/examples/eclipse/index.rst b/ThirdParty/Ert/python/docs/code/python/examples/eclipse/index.rst similarity index 100% rename from ThirdParty/Ert/docs/code/python/examples/eclipse/index.rst rename to ThirdParty/Ert/python/docs/code/python/examples/eclipse/index.rst diff --git a/ThirdParty/Ert/docs/code/python/examples/geo/index.rst b/ThirdParty/Ert/python/docs/code/python/examples/geo/index.rst similarity index 100% rename from ThirdParty/Ert/docs/code/python/examples/geo/index.rst rename to ThirdParty/Ert/python/docs/code/python/examples/geo/index.rst diff --git a/ThirdParty/Ert/docs/code/python/examples/index.rst b/ThirdParty/Ert/python/docs/code/python/examples/index.rst similarity index 81% rename from ThirdParty/Ert/docs/code/python/examples/index.rst rename to ThirdParty/Ert/python/docs/code/python/examples/index.rst index d5f7978c2f..90b577182b 100644 --- a/ThirdParty/Ert/docs/code/python/examples/index.rst +++ b/ThirdParty/Ert/python/docs/code/python/examples/index.rst @@ -7,4 +7,3 @@ Examples Eclipse results Geometric objects - Full ert cases diff --git a/ThirdParty/Ert/docs/code/python/index.rst b/ThirdParty/Ert/python/docs/code/python/index.rst similarity index 54% rename from ThirdParty/Ert/docs/code/python/index.rst rename to ThirdParty/Ert/python/docs/code/python/index.rst index 80e9b8d0f0..ec5233c5e3 100644 --- a/ThirdParty/Ert/docs/code/python/index.rst +++ b/ThirdParty/Ert/python/docs/code/python/index.rst @@ -9,5 +9,3 @@ Python documentation introduction/index Overview of ert Python examples/index - ert package - autogenerated API documentation <../../API/python/ert> - ert_gui package - autogenerated API documentation <../../API/python/ert_gui> diff --git a/ThirdParty/Ert/docs/code/python/introduction/index.rst b/ThirdParty/Ert/python/docs/code/python/introduction/index.rst similarity index 100% rename from ThirdParty/Ert/docs/code/python/introduction/index.rst rename to ThirdParty/Ert/python/docs/code/python/introduction/index.rst diff --git a/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst b/ThirdParty/Ert/python/docs/code/python/packages/eclipse/index.rst similarity index 100% rename from ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst rename to ThirdParty/Ert/python/docs/code/python/packages/eclipse/index.rst diff --git a/ThirdParty/Ert/docs/code/python/packages/index.rst b/ThirdParty/Ert/python/docs/code/python/packages/index.rst similarity index 86% rename from ThirdParty/Ert/docs/code/python/packages/index.rst rename to ThirdParty/Ert/python/docs/code/python/packages/index.rst index f7522ecb6c..04ebdc6959 100644 --- a/ThirdParty/Ert/docs/code/python/packages/index.rst +++ b/ThirdParty/Ert/python/docs/code/python/packages/index.rst @@ -4,10 +4,7 @@ The ert packages .. toctree:: :maxdepth: 1 - util/index.rst eclipse/index.rst - well/index.rst - geometry/index.rst Currently only the package targeted at working with Eclipse files, diff --git a/ThirdParty/Ert/docs/conf.py.in b/ThirdParty/Ert/python/docs/conf.py.in similarity index 93% rename from ThirdParty/Ert/docs/conf.py.in rename to ThirdParty/Ert/python/docs/conf.py.in index 2bde72df1c..7d57a51d49 100644 --- a/ThirdParty/Ert/docs/conf.py.in +++ b/ThirdParty/Ert/python/docs/conf.py.in @@ -19,7 +19,7 @@ import os # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('${PYTHON_INSTALL_PREFIX}')) +sys.path.insert(0, os.path.join('${PROJECT_BINARY_DIR}','${PYTHON_INSTALL_PREFIX}')) # -- General configuration ------------------------------------------------ @@ -47,17 +47,17 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'ert' -copyright = u'2014, Statoil ASA' +project = u'libecl' +copyright = u'2014, Equinor ASA' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR}' +version = '${LIBECL_VERSION_MAJOR}.${LIBECL_VERSION_MINOR}' # The full version, including alpha/beta/rc tags. -release = '${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR}.${ERT_VERSION_MICRO}' +release = '${LIBECL_VERSION_MAJOR}.${LIBECL_VERSION_MINOR}.${LIBECL_VERSION_MICRO}' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -180,7 +180,7 @@ html_static_path = ['_static'] #html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'ertdoc' +htmlhelp_basename = 'libecldoc' # -- Options for LaTeX output --------------------------------------------- @@ -200,8 +200,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'ert.tex', u'ert Documentation', - u'Statoil ASA', 'manual'), + ('index', 'libecl.tex', u'libecl documentation', + u'Equinor ASA', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -230,8 +230,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'ert', u'ert Documentation', - [u'Statoil ASA'], 1) + ('index', 'libecl', u'libecl documentation', + [u'Equinor ASA'], 1) ] # If true, show URL addresses after external links. @@ -244,8 +244,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'ert', u'ert Documentation', - u'Statoil ASA', 'ert', 'One line description of project.', + ('index', 'libecl', u'libecl ocumentation', + u'Equinor ASA', 'ert', 'One line description of project.', 'Miscellaneous'), ] @@ -266,9 +266,9 @@ texinfo_documents = [ # Bibliographic Dublin Core info. epub_title = u'ert' -epub_author = u'Statoil ASA' -epub_publisher = u'Statoil ASA' -epub_copyright = u'2014, Statoil ASA' +epub_author = u'Equinor ASA' +epub_publisher = u'Equinor ASA' +epub_copyright = u'2014, Equinor ASA' # The basename for the epub file. It defaults to the project name. #epub_basename = u'ert' diff --git a/ThirdParty/Ert/docs/examples/avg_pressure.py b/ThirdParty/Ert/python/docs/examples/avg_pressure.py similarity index 96% rename from ThirdParty/Ert/docs/examples/avg_pressure.py rename to ThirdParty/Ert/python/docs/examples/avg_pressure.py index 45dd786802..aa502b8c77 100644 --- a/ThirdParty/Ert/docs/examples/avg_pressure.py +++ b/ThirdParty/Ert/python/docs/examples/avg_pressure.py @@ -3,7 +3,8 @@ import sys import matplotlib.pyplot as plt # Import the required symbols from the ecl.ecl package. -from ecl.ecl import EclFile, EclGrid, EclRegion, EclRestartFile +from ecl.eclfile import EclFile, EclRestartFile +from ecl.grid import EclGrid, EclRegion # Calculate the average pressure for all the cells in the region using diff --git a/ThirdParty/Ert/docs/examples/cmp_nnc.py b/ThirdParty/Ert/python/docs/examples/cmp_nnc.py similarity index 69% rename from ThirdParty/Ert/docs/examples/cmp_nnc.py rename to ThirdParty/Ert/python/docs/examples/cmp_nnc.py index 1e1ff2f52c..248d3000f2 100644 --- a/ThirdParty/Ert/docs/examples/cmp_nnc.py +++ b/ThirdParty/Ert/python/docs/examples/cmp_nnc.py @@ -1,7 +1,8 @@ #!/usr/bin/env python import sys from operator import itemgetter -from ecl.ecl import EclFile, EclGrid +from ecl.eclfile import EclFile +from ecl.grid import EclGrid @@ -22,10 +23,15 @@ if __name__ == "__main__": nnc_list = sorted(nnc_list, key = itemgetter(0)) for (g1,g2,T) in nnc_list: + # grid_ijk assumes 0-based indexing, g1/g2 are 1-based (FORTRAN) + # Convert them to zero based ones. + g1 = g1 - 1 + g2 = g2 - 1 i1,j1,k1 = grid.get_ijk( global_index = g1 ) i2,j2,k2 = grid.get_ijk( global_index = g2 ) - print "(%02d,%02d,%02d) -> (%02d,%02d,%02d) T:%g" % (i1,j1,k2,i2,j2,k2,T) + # print 1-based indices just like in eclipse PRT files + print "(%02d,%02d,%02d) -> (%02d,%02d,%02d) T:%g" % (i1+1,j1+1,k1+1,i2+1,j2+1,k2+1,T) diff --git a/ThirdParty/Ert/docs/examples/grid_info.py b/ThirdParty/Ert/python/docs/examples/grid_info.py similarity index 94% rename from ThirdParty/Ert/docs/examples/grid_info.py rename to ThirdParty/Ert/python/docs/examples/grid_info.py index 3a226a929f..20ffdb0cab 100644 --- a/ThirdParty/Ert/docs/examples/grid_info.py +++ b/ThirdParty/Ert/python/docs/examples/grid_info.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import sys -from ecl.ecl import EclGrid, EclRegion +from ecl.grid import EclGrid, EclRegion def volume_min_max(grid): diff --git a/ThirdParty/Ert/docs/index.rst.in b/ThirdParty/Ert/python/docs/index.rst.in similarity index 87% rename from ThirdParty/Ert/docs/index.rst.in rename to ThirdParty/Ert/python/docs/index.rst.in index f75b6f9116..9d688b5183 100644 --- a/ThirdParty/Ert/docs/index.rst.in +++ b/ThirdParty/Ert/python/docs/index.rst.in @@ -7,10 +7,8 @@ Contents: :maxdepth: 1 :numbered: - user/index code/index - ${ERT_DOC_LINK} - + api/ecl Indices and tables ================== diff --git a/ThirdParty/Ert/python/docs/latex/capt-of.sty b/ThirdParty/Ert/python/docs/latex/capt-of.sty new file mode 100644 index 0000000000..b40978ad2c --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/capt-of.sty @@ -0,0 +1,33 @@ +%% +%% This is file `capt-of.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% capt-of.dtx (with options: `package') +%% ---------------------------------------------------------------------- +%% The capt-off package -- float-style captions outside of floats +%% Copyright (c) 2010 Robin Fairbairns +%% +%% This work may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License, either version 1.3c of this license or (at +%% your option) any later version. The latest version of this license is in: +%% http://www.latex-project.org/lppl.txt, and version 1.3c or later is part +%% of all distributions of LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `author-maintained'. +%% +%% This work consists of the files capt-of.dtx, capt-of.ins, and README +%% and the derived files footmisc.sty (not distributed from the archive) +%% and footmisc.pdf. +%% ----------------------------------------------------------------------- +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{capt-of}% + [2009/12/29 v0.2 + standard captions outside of floats% + ]% $Id: footmisc.dtx,v 4.20 2005/03/17 13:41:58 rf Exp rf10 $ +\newcommand\captionof[1]{\def\@captype{#1}\caption} +\endinput +%% +%% End of file `capt-of.sty'. diff --git a/ThirdParty/Ert/python/docs/latex/fncychap.sty b/ThirdParty/Ert/python/docs/latex/fncychap.sty new file mode 100644 index 0000000000..f0a9c97e22 --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/fncychap.sty @@ -0,0 +1,701 @@ +%% Copyright 2007 Ulf Lindgren +% +% This work may be distributed and/or modified under the conditions of the LaTeX +% Project Public License, either version 1.3 of this license or (at your option) +% any later version. The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX version +% 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Ulf Lindgren. +% +% This work consists of all files listed in manifest.txt. +% +%% This statement added 2010/12/10 by Clea F. Rees following correspondence +%% between Ulf Lindgren and Karl Berry concerning licensing. + +%%% Copyright Ulf A. Lindgren +%%% +%%% Note Premission is granted to modify this file under +%%% the condition that it is saved using another +%%% file and package name. +%%% +%%% Revision 1.1 (1997) +%%% +%%% Jan. 8th Modified package name base date option +%%% Jan. 22th Modified FmN and FmTi for error in book.cls +%%% \MakeUppercase{#}->{\MakeUppercase#} +%%% Apr. 6th Modified Lenny option to prevent undesired +%%% skip of line. +%%% Nov. 8th Fixed \@chapapp for AMS +%%% +%%% Revision 1.2 (1998) +%%% +%%% Feb. 11th Fixed appendix problem related to Bjarne +%%% Aug. 11th Fixed problem related to 11pt and 12pt +%%% suggested by Tomas Lundberg. THANKS! +%%% +%%% Revision 1.3 (2004) +%%% Sep. 20th problem with frontmatter, mainmatter and +%%% backmatter, pointed out by Lapo Mori +%%% +%%% Revision 1.31 (2004) +%%% Sep. 21th problem with the Rejne definition streched text +%%% caused ugly gaps in the vrule aligned with the title +%%% text. Kindly pointed out to me by Hendri Adriaens +%%% +%%% Revision 1.32 (2005) +%%% Jun. 23th compatibility problem with the KOMA class 'scrbook.cls' +%%% a remedy is a redefinition of '\@schapter' in +%%% line with that used in KOMA. The problem was pointed +%%% out to me by Mikkel Holm Olsen +%%% +%%% Revision 1.33 (2005) +%%% Aug. 9th misspelled ``TWELV'' corrected, the error was pointed +%%% out to me by George Pearson +%%% +%%% Revision 1.34 (2007) +%%% Added an alternative to Lenny provided by Peter +%%% Osborne (2005-11-28) +%%% Corrected front, main and back matter, based on input +%%% from Bas van Gils (2006-04-24) +%%% Jul. 30th Added Bjornstrup option provided by Jean-Marc +%%% Francois (2007-01-05). +%%% Reverted to \MakeUppercase{#} see rev 1.1, solved +%%% problem with MakeUppercase and MakeLowercase pointed +%%% out by Marco Feuerstein (2007-06-06) + + +%%% Last modified Jul. 2007 + +\NeedsTeXFormat{LaTeX2e}[1995/12/01] +\ProvidesPackage{fncychap} + [2007/07/30 v1.34 + LaTeX package (Revised chapters)] + +%%%% For conditional inclusion of color +\newif\ifusecolor +\usecolorfalse + + + +%%%% DEFINITION OF Chapapp variables +\newcommand{\CNV}{\huge\bfseries} +\newcommand{\ChNameVar}[1]{\renewcommand{\CNV}{#1}} + + +%%%% DEFINITION OF TheChapter variables +\newcommand{\CNoV}{\huge\bfseries} +\newcommand{\ChNumVar}[1]{\renewcommand{\CNoV}{#1}} + +\newif\ifUCN +\UCNfalse +\newif\ifLCN +\LCNfalse +\def\ChNameLowerCase{\LCNtrue\UCNfalse} +\def\ChNameUpperCase{\UCNtrue\LCNfalse} +\def\ChNameAsIs{\UCNfalse\LCNfalse} + +%%%%% Fix for AMSBook 971008 + +\@ifundefined{@chapapp}{\let\@chapapp\chaptername}{} + + +%%%%% Fix for Bjarne and appendix 980211 + +\newif\ifinapp +\inappfalse +\renewcommand\appendix{\par + \setcounter{chapter}{0}% + \setcounter{section}{0}% + \inapptrue% + \renewcommand\@chapapp{\appendixname}% + \renewcommand\thechapter{\@Alph\c@chapter}} + +%%%%% Fix for frontmatter, mainmatter, and backmatter 040920 + +\@ifundefined{@mainmatter}{\newif\if@mainmatter \@mainmattertrue}{} + +%%%%% + + + +\newcommand{\FmN}[1]{% +\ifUCN + {\MakeUppercase{#1}}\LCNfalse +\else + \ifLCN + {\MakeLowercase{#1}}\UCNfalse + \else #1 + \fi +\fi} + + +%%%% DEFINITION OF Title variables +\newcommand{\CTV}{\Huge\bfseries} +\newcommand{\ChTitleVar}[1]{\renewcommand{\CTV}{#1}} + +%%%% DEFINITION OF the basic rule width +\newlength{\RW} +\setlength{\RW}{1pt} +\newcommand{\ChRuleWidth}[1]{\setlength{\RW}{#1}} + +\newif\ifUCT +\UCTfalse +\newif\ifLCT +\LCTfalse +\def\ChTitleLowerCase{\LCTtrue\UCTfalse} +\def\ChTitleUpperCase{\UCTtrue\LCTfalse} +\def\ChTitleAsIs{\UCTfalse\LCTfalse} +\newcommand{\FmTi}[1]{% +\ifUCT + {\MakeUppercase{#1}}\LCTfalse +\else + \ifLCT + {\MakeLowercase{#1}}\UCTfalse + \else {#1} + \fi +\fi} + + + +\newlength{\mylen} +\newlength{\myhi} +\newlength{\px} +\newlength{\py} +\newlength{\pyy} +\newlength{\pxx} + + +\def\mghrulefill#1{\leavevmode\leaders\hrule\@height #1\hfill\kern\z@} + +\newcommand{\DOCH}{% + \CNV\FmN{\@chapapp}\space \CNoV\thechapter + \par\nobreak + \vskip 20\p@ + } +\newcommand{\DOTI}[1]{% + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@ + } +\newcommand{\DOTIS}[1]{% + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@ + } + +%%%%%% SONNY DEF + +\DeclareOption{Sonny}{% + \ChNameVar{\Large\sf} + \ChNumVar{\Huge} + \ChTitleVar{\Large\sf} + \ChRuleWidth{0.5pt} + \ChNameUpperCase + \renewcommand{\DOCH}{% + \raggedleft + \CNV\FmN{\@chapapp}\space \CNoV\thechapter + \par\nobreak + \vskip 40\p@} + \renewcommand{\DOTI}[1]{% + \CTV\raggedleft\mghrulefill{\RW}\par\nobreak + \vskip 5\p@ + \CTV\FmTi{#1}\par\nobreak + \mghrulefill{\RW}\par\nobreak + \vskip 40\p@} + \renewcommand{\DOTIS}[1]{% + \CTV\raggedleft\mghrulefill{\RW}\par\nobreak + \vskip 5\p@ + \CTV\FmTi{#1}\par\nobreak + \mghrulefill{\RW}\par\nobreak + \vskip 40\p@} +} + +%%%%%% LENNY DEF + +\DeclareOption{Lenny}{% + + \ChNameVar{\fontsize{14}{16}\usefont{OT1}{phv}{m}{n}\selectfont} + \ChNumVar{\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont} + \ChTitleVar{\Huge\bfseries\rm} + \ChRuleWidth{1pt} + \renewcommand{\DOCH}{% + \settowidth{\px}{\CNV\FmN{\@chapapp}} + \addtolength{\px}{2pt} + \settoheight{\py}{\CNV\FmN{\@chapapp}} + \addtolength{\py}{1pt} + + \settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter} + \addtolength{\mylen}{1pt} + \settowidth{\pxx}{\CNoV\thechapter} + \addtolength{\pxx}{-1pt} + + \settoheight{\pyy}{\CNoV\thechapter} + \addtolength{\pyy}{-2pt} + \setlength{\myhi}{\pyy} + \addtolength{\myhi}{-1\py} + \par + \parbox[b]{\textwidth}{% + \rule[\py]{\RW}{\myhi}% + \hskip -\RW% + \rule[\pyy]{\px}{\RW}% + \hskip -\px% + \raggedright% + \CNV\FmN{\@chapapp}\space\CNoV\thechapter% + \hskip1pt% + \mghrulefill{\RW}% + \rule{\RW}{\pyy}\par\nobreak% + \vskip -\baselineskip% + \vskip -\pyy% + \hskip \mylen% + \mghrulefill{\RW}\par\nobreak% + \vskip \pyy}% + \vskip 20\p@} + + + \renewcommand{\DOTI}[1]{% + \raggedright + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@} + + \renewcommand{\DOTIS}[1]{% + \raggedright + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@} + } + +%%%%%% Peter Osbornes' version of LENNY DEF + +\DeclareOption{PetersLenny}{% + +% five new lengths +\newlength{\bl} % bottom left : orig \space +\setlength{\bl}{6pt} +\newcommand{\BL}[1]{\setlength{\bl}{#1}} +\newlength{\br} % bottom right : orig 1pt +\setlength{\br}{1pt} +\newcommand{\BR}[1]{\setlength{\br}{#1}} +\newlength{\tl} % top left : orig 2pt +\setlength{\tl}{2pt} +\newcommand{\TL}[1]{\setlength{\tl}{#1}} +\newlength{\trr} % top right :orig 1pt +\setlength{\trr}{1pt} +\newcommand{\TR}[1]{\setlength{\trr}{#1}} +\newlength{\blrule} % top right :orig 1pt +\setlength{\trr}{0pt} +\newcommand{\BLrule}[1]{\setlength{\blrule}{#1}} + + + \ChNameVar{\fontsize{14}{16}\usefont{OT1}{phv}{m}{n}\selectfont} + \ChNumVar{\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont} + \ChTitleVar{\Huge\bfseries\rm} + \ChRuleWidth{1pt} +\renewcommand{\DOCH}{% + + +%%%%%%% tweaks for 1--9 and A--Z +\ifcase\c@chapter\relax% +\or\BL{-3pt}\TL{-4pt}\BR{0pt}\TR{-6pt}%1 +\or\BL{0pt}\TL{-4pt}\BR{2pt}\TR{-4pt}%2 +\or\BL{0pt}\TL{-4pt}\BR{2pt}\TR{-4pt}%3 +\or\BL{0pt}\TL{5pt}\BR{2pt}\TR{-4pt}%4 +\or\BL{0pt}\TL{3pt}\BR{2pt}\TR{-4pt}%5 +\or\BL{-1pt}\TL{0pt}\BR{2pt}\TR{-2pt}%6 +\or\BL{0pt}\TL{-3pt}\BR{2pt}\TR{-2pt}%7 +\or\BL{0pt}\TL{-3pt}\BR{2pt}\TR{-2pt}%8 +\or\BL{0pt}\TL{-3pt}\BR{-4pt}\TR{-2pt}%9 +\or\BL{-3pt}\TL{-3pt}\BR{2pt}\TR{-7pt}%10 +\or\BL{-6pt}\TL{-6pt}\BR{0pt}\TR{-9pt}%11 +\or\BL{-6pt}\TL{-6pt}\BR{2pt}\TR{-7pt}%12 +\or\BL{-5pt}\TL{-5pt}\BR{0pt}\TR{-9pt}%13 +\or\BL{-6pt}\TL{-6pt}\BR{0pt}\TR{-9pt}%14 +\or\BL{-3pt}\TL{-3pt}\BR{3pt}\TR{-6pt}%15 +\or\BL{-3pt}\TL{-3pt}\BR{3pt}\TR{-6pt}%16 +\or\BL{-5pt}\TL{-3pt}\BR{-8pt}\TR{-6pt}%17 +\or\BL{-5pt}\TL{-5pt}\BR{0pt}\TR{-9pt}%18 +\or\BL{-3pt}\TL{-3pt}\BR{-6pt}\TR{-9pt}%19 +\or\BL{0pt}\TL{0pt}\BR{0pt}\TR{-5pt}%20 +\fi + +\ifinapp\ifcase\c@chapter\relax% +\or\BL{0pt}\TL{14pt}\BR{5pt}\TR{-19pt}%A +\or\BL{0pt}\TL{-5pt}\BR{-3pt}\TR{-8pt}%B +\or\BL{-3pt}\TL{-2pt}\BR{1pt}\TR{-6pt}\BLrule{0pt}%C +\or\BL{0pt}\TL{-5pt}\BR{-3pt}\TR{-8pt}\BLrule{0pt}%D +\or\BL{0pt}\TL{-5pt}\BR{2pt}\TR{-3pt}%E +\or\BL{0pt}\TL{-5pt}\BR{-10pt}\TR{-1pt}%F +\or\BL{-3pt}\TL{0pt}\BR{0pt}\TR{-7pt}%G +\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%H +\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%I +\or\BL{2pt}\TL{0pt}\BR{-3pt}\TR{1pt}%J +\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%K +\or\BL{0pt}\TL{-5pt}\BR{2pt}\TR{-19pt}%L +\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%M +\or\BL{0pt}\TL{-5pt}\BR{-2pt}\TR{-1pt}%N +\or\BL{-3pt}\TL{-2pt}\BR{-3pt}\TR{-11pt}%O +\or\BL{0pt}\TL{-5pt}\BR{-9pt}\TR{-3pt}%P +\or\BL{-3pt}\TL{-2pt}\BR{-3pt}\TR{-11pt}%Q +\or\BL{0pt}\TL{-5pt}\BR{4pt}\TR{-8pt}%R +\or\BL{-2pt}\TL{-2pt}\BR{-2pt}\TR{-7pt}%S +\or\BL{-3pt}\TL{0pt}\BR{-5pt}\TR{4pt}\BLrule{8pt}%T +\or\BL{-7pt}\TL{-11pt}\BR{-5pt}\TR{-7pt}\BLrule{0pt}%U +\or\BL{-14pt}\TL{-5pt}\BR{-14pt}\TR{-1pt}\BLrule{14pt}%V +\or\BL{-10pt}\TL{-9pt}\BR{-13pt}\TR{-3pt}\BLrule{7pt}%W +\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}\BLrule{0pt}%X +\or\BL{-6pt}\TL{-4pt}\BR{-7pt}\TR{1pt}\BLrule{7pt}%Y +\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}\BLrule{0pt}%Z +\fi\fi +%%%%%%% + \settowidth{\px}{\CNV\FmN{\@chapapp}} + \addtolength{\px}{\tl} %MOD change 2pt to \tl + \settoheight{\py}{\CNV\FmN{\@chapapp}} + \addtolength{\py}{1pt} + + \settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter} + \addtolength{\mylen}{\trr}% MOD change 1pt to \tr + \settowidth{\pxx}{\CNoV\thechapter} + \addtolength{\pxx}{-1pt} + + \settoheight{\pyy}{\CNoV\thechapter} + \addtolength{\pyy}{-2pt} + \setlength{\myhi}{\pyy} + \addtolength{\myhi}{-1\py} + \par + \parbox[b]{\textwidth}{% + \rule[\py]{\RW}{\myhi}% + \hskip -\RW% + \rule[\pyy]{\px}{\RW}% + \hskip -\px% + \raggedright% + \CNV\FmN{\@chapapp}\rule{\blrule}{\RW}\hskip\bl\CNoV\thechapter%MOD +% \CNV\FmN{\@chapapp}\space\CNoV\thechapter %ORIGINAL + \hskip\br% %MOD 1pt to \br + \mghrulefill{\RW}% + \rule{\RW}{\pyy}\par\nobreak% + \vskip -\baselineskip% + \vskip -\pyy% + \hskip \mylen% + \mghrulefill{\RW}\par\nobreak% + \vskip \pyy}% + \vskip 20\p@} + + + \renewcommand{\DOTI}[1]{% + \raggedright + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@} + + \renewcommand{\DOTIS}[1]{% + \raggedright + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@} + } + + +% + + +%%%%%% BJORNSTRUP DEF + +\DeclareOption{Bjornstrup}{% + \usecolortrue + % pzc (Zapf Chancelery) is nice. ppl (Palatino) is cool too. + \ChNumVar{\fontsize{76}{80}\usefont{OT1}{pzc}{m}{n}\selectfont} + \ChTitleVar{\raggedleft\Large\sffamily\bfseries} + + \setlength{\myhi}{10pt} % Space between grey box border and text + \setlength{\mylen}{\textwidth} + \addtolength{\mylen}{-2\myhi} + \renewcommand{\DOCH}{% + \settowidth{\py}{\CNoV\thechapter} + \addtolength{\py}{-10pt} % Amount of space by which the +% % number is shifted right + \fboxsep=0pt% + \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}% + \kern-\py\raise20pt% + \hbox{\color[gray]{.5}\CNoV\thechapter}\\% + } + + \renewcommand{\DOTI}[1]{% + \nointerlineskip\raggedright% + \fboxsep=\myhi% + \vskip-1ex% + \colorbox[gray]{.85}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak% + \vskip 40\p@% + } + + \renewcommand{\DOTIS}[1]{% + \fboxsep=0pt + \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\% + \nointerlineskip\raggedright% + \fboxsep=\myhi% + \colorbox[gray]{.85}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak% + \vskip 40\p@% + } +} + + +%%%%%%% GLENN DEF + + +\DeclareOption{Glenn}{% + \ChNameVar{\bfseries\Large\sf} + \ChNumVar{\Huge} + \ChTitleVar{\bfseries\Large\rm} + \ChRuleWidth{1pt} + \ChNameUpperCase + \ChTitleUpperCase + \renewcommand{\DOCH}{% + \settoheight{\myhi}{\CTV\FmTi{Test}} + \setlength{\py}{\baselineskip} + \addtolength{\py}{\RW} + \addtolength{\py}{\myhi} + \setlength{\pyy}{\py} + \addtolength{\pyy}{-1\RW} + + \raggedright + \CNV\FmN{\@chapapp}\space\CNoV\thechapter + \hskip 3pt\mghrulefill{\RW}\rule[-1\pyy]{2\RW}{\py}\par\nobreak} + + \renewcommand{\DOTI}[1]{% + \addtolength{\pyy}{-4pt} + \settoheight{\myhi}{\CTV\FmTi{#1}} + \addtolength{\myhi}{\py} + \addtolength{\myhi}{-1\RW} + \vskip -1\pyy + \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 2pt + \raggedleft\CTV\FmTi{#1}\par\nobreak + \vskip 80\p@} + +\newlength{\backskip} + \renewcommand{\DOTIS}[1]{% +% \setlength{\py}{10pt} +% \setlength{\pyy}{\py} +% \addtolength{\pyy}{\RW} +% \setlength{\myhi}{\baselineskip} +% \addtolength{\myhi}{\pyy} +% \mghrulefill{\RW}\rule[-1\py]{2\RW}{\pyy}\par\nobreak +% \addtolength{}{} +%\vskip -1\baselineskip +% \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 2pt +% \raggedleft\CTV\FmTi{#1}\par\nobreak +% \vskip 60\p@} +%% Fix suggested by Tomas Lundberg + \setlength{\py}{25pt} % eller vad man vill + \setlength{\pyy}{\py} + \setlength{\backskip}{\py} + \addtolength{\backskip}{2pt} + \addtolength{\pyy}{\RW} + \setlength{\myhi}{\baselineskip} + \addtolength{\myhi}{\pyy} + \mghrulefill{\RW}\rule[-1\py]{2\RW}{\pyy}\par\nobreak + \vskip -1\backskip + \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 3pt % + \raggedleft\CTV\FmTi{#1}\par\nobreak + \vskip 40\p@} + } + +%%%%%%% CONNY DEF + +\DeclareOption{Conny}{% + \ChNameUpperCase + \ChTitleUpperCase + \ChNameVar{\centering\Huge\rm\bfseries} + \ChNumVar{\Huge} + \ChTitleVar{\centering\Huge\rm} + \ChRuleWidth{2pt} + + \renewcommand{\DOCH}{% + \mghrulefill{3\RW}\par\nobreak + \vskip -0.5\baselineskip + \mghrulefill{\RW}\par\nobreak + \CNV\FmN{\@chapapp}\space \CNoV\thechapter + \par\nobreak + \vskip -0.5\baselineskip + } + \renewcommand{\DOTI}[1]{% + \mghrulefill{\RW}\par\nobreak + \CTV\FmTi{#1}\par\nobreak + \vskip 60\p@ + } + \renewcommand{\DOTIS}[1]{% + \mghrulefill{\RW}\par\nobreak + \CTV\FmTi{#1}\par\nobreak + \vskip 60\p@ + } + } + +%%%%%%% REJNE DEF + +\DeclareOption{Rejne}{% + + \ChNameUpperCase + \ChTitleUpperCase + \ChNameVar{\centering\Large\rm} + \ChNumVar{\Huge} + \ChTitleVar{\centering\Huge\rm} + \ChRuleWidth{1pt} + \renewcommand{\DOCH}{% + \settoheight{\py}{\CNoV\thechapter} + \parskip=0pt plus 1pt % Set parskip to default, just in case v1.31 + \addtolength{\py}{-1pt} + \CNV\FmN{\@chapapp}\par\nobreak + \vskip 20\p@ + \setlength{\myhi}{2\baselineskip} + \setlength{\px}{\myhi} + \addtolength{\px}{-1\RW} + \rule[-1\px]{\RW}{\myhi}\mghrulefill{\RW}\hskip + 10pt\raisebox{-0.5\py}{\CNoV\thechapter}\hskip 10pt\mghrulefill{\RW}\rule[-1\px]{\RW}{\myhi}\par\nobreak + \vskip -3\p@% Added -2pt vskip to correct for streched text v1.31 + } + \renewcommand{\DOTI}[1]{% + \setlength{\mylen}{\textwidth} + \parskip=0pt plus 1pt % Set parskip to default, just in case v1.31 + \addtolength{\mylen}{-2\RW} + {\vrule width\RW}\parbox{\mylen}{\CTV\FmTi{#1}}{\vrule width\RW}\par\nobreak% + \vskip -3pt\rule{\RW}{2\baselineskip}\mghrulefill{\RW}\rule{\RW}{2\baselineskip}% + \vskip 60\p@% Added -2pt in vskip to correct for streched text v1.31 + } + \renewcommand{\DOTIS}[1]{% + \setlength{\py}{\fboxrule} + \setlength{\fboxrule}{\RW} + \setlength{\mylen}{\textwidth} + \addtolength{\mylen}{-2\RW} + \fbox{\parbox{\mylen}{\vskip 2\baselineskip\CTV\FmTi{#1}\par\nobreak\vskip \baselineskip}} + \setlength{\fboxrule}{\py} + \vskip 60\p@ + } + } + + +%%%%%%% BJARNE DEF + +\DeclareOption{Bjarne}{% + \ChNameUpperCase + \ChTitleUpperCase + \ChNameVar{\raggedleft\normalsize\rm} + \ChNumVar{\raggedleft \bfseries\Large} + \ChTitleVar{\raggedleft \Large\rm} + \ChRuleWidth{1pt} + + +%% Note thechapter -> c@chapter fix appendix bug +%% Fixed misspelled 12 + + \newcounter{AlphaCnt} + \newcounter{AlphaDecCnt} + \newcommand{\AlphaNo}{% + \ifcase\number\theAlphaCnt + \ifnum\c@chapter=0 + ZERO\else{}\fi + \or ONE\or TWO\or THREE\or FOUR\or FIVE + \or SIX\or SEVEN\or EIGHT\or NINE\or TEN + \or ELEVEN\or TWELVE\or THIRTEEN\or FOURTEEN\or FIFTEEN + \or SIXTEEN\or SEVENTEEN\or EIGHTEEN\or NINETEEN\fi +} + + \newcommand{\AlphaDecNo}{% + \setcounter{AlphaDecCnt}{0} + \@whilenum\number\theAlphaCnt>0\do + {\addtocounter{AlphaCnt}{-10} + \addtocounter{AlphaDecCnt}{1}} + \ifnum\number\theAlphaCnt=0 + \else + \addtocounter{AlphaDecCnt}{-1} + \addtocounter{AlphaCnt}{10} + \fi + + + \ifcase\number\theAlphaDecCnt\or TEN\or TWENTY\or THIRTY\or + FORTY\or FIFTY\or SIXTY\or SEVENTY\or EIGHTY\or NINETY\fi + } + \newcommand{\TheAlphaChapter}{% + + \ifinapp + \thechapter + \else + \setcounter{AlphaCnt}{\c@chapter} + \ifnum\c@chapter<20 + \AlphaNo + \else + \AlphaDecNo\AlphaNo + \fi + \fi + } + \renewcommand{\DOCH}{% + \mghrulefill{\RW}\par\nobreak + \CNV\FmN{\@chapapp}\par\nobreak + \CNoV\TheAlphaChapter\par\nobreak + \vskip -1\baselineskip\vskip 5pt\mghrulefill{\RW}\par\nobreak + \vskip 20\p@ + } + \renewcommand{\DOTI}[1]{% + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@ + } + \renewcommand{\DOTIS}[1]{% + \CTV\FmTi{#1}\par\nobreak + \vskip 40\p@ + } +} + +\DeclareOption*{% + \PackageWarning{fancychapter}{unknown style option} + } + +\ProcessOptions* \relax + +\ifusecolor + \RequirePackage{color} +\fi +\def\@makechapterhead#1{% + \vspace*{50\p@}% + {\parindent \z@ \raggedright \normalfont + \ifnum \c@secnumdepth >\m@ne + \if@mainmatter%%%%% Fix for frontmatter, mainmatter, and backmatter 040920 + \DOCH + \fi + \fi + \interlinepenalty\@M + \if@mainmatter%%%%% Fix for frontmatter, mainmatter, and backmatter 060424 + \DOTI{#1}% + \else% + \DOTIS{#1}% + \fi + }} + + +%%% Begin: To avoid problem with scrbook.cls (fncychap version 1.32) + +%%OUT: +%\def\@schapter#1{\if@twocolumn +% \@topnewpage[\@makeschapterhead{#1}]% +% \else +% \@makeschapterhead{#1}% +% \@afterheading +% \fi} + +%%IN: +\def\@schapter#1{% +\if@twocolumn% + \@makeschapterhead{#1}% +\else% + \@makeschapterhead{#1}% + \@afterheading% +\fi} + +%%% End: To avoid problem with scrbook.cls (fncychap version 1.32) + +\def\@makeschapterhead#1{% + \vspace*{50\p@}% + {\parindent \z@ \raggedright + \normalfont + \interlinepenalty\@M + \DOTIS{#1} + \vskip 40\p@ + }} + +\endinput + + diff --git a/ThirdParty/Ert/python/docs/latex/framed.sty b/ThirdParty/Ert/python/docs/latex/framed.sty new file mode 100644 index 0000000000..b044e96593 --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/framed.sty @@ -0,0 +1,548 @@ +% framed.sty v 0.96 2011/10/22 +% Copyright (C) 1992-2011 by Donald Arseneau (asnd@triumf.ca) +% These macros may be freely transmitted, reproduced, or modified +% for any purpose provided that this notice is left intact. +% +%====================== Begin Instructions ======================= +% +% framed.sty +% ~~~~~~~~~~ +% Create framed, shaded, or differently highlighted regions that can +% break across pages. The environments defined are +% framed - ordinary frame box (\fbox) with edge at margin +% oframed - framed with open top/bottom at page breaks +% shaded - shaded background (\colorbox) bleeding into margin +% shaded* - shaded background (\colorbox) with edge at margin +% snugshade - shaded with tight fit around text (esp. in lists) +% snugshade* - like snugshade with shading edge at margin +% leftbar - thick vertical line in left margin +% +% to be used like +% \begin{framed} +% copious text +% \end{framed} +% +% But the more general purpose of this package is to facilitate the +% definition of new environments that take multi-line material, +% wrap it with some non-breakable formatting (some kind of box or +% decoration) and allow page breaks in the material. Such environments +% are defined to declare (or use) \FrameCommand for applying the boxy +% decoration, and \MakeFramed{settings} ... \endMakeFramed wrapped +% around the main text argument (environment body). +% +% The "framed" environment uses "\fbox", by default, as its "\FrameCommand" +% with the additional settings "\fboxrule=\FrameRule" and "\fboxsep=\FrameSep". +% You can change these lengths (using "\setlength") and you can change +% the definition of "\FrameCommand" to use much fancier boxes. +% +% In fact, the "shaded" environment just redefines \FrameCommand to be +% "\colorbox{shadecolor}" (and you have to define the color `"shadecolor"': +% "\definecolor{shadecolor}..."). +% +% Although the intention is for other packages to define the varieties +% of decoration, a command "\OpenFbox" is defined for frames with open +% tops or bottoms, and used for the "oframed" environment. This facility +% is based on a more complex and capable command "\CustomFBox" which can +% be used for a wider range of frame styles. One such style of a title-bar +% frame with continuation marks is provided as an example. It is used by +% the "titled-frame" environment. To make use of "titled-frame" in your +% document, or the "\TitleBarFrame" command in your own environment +% definitions, you must define the colors TFFrameColor (for the frame) +% and a contrasting TFTitleColor (for the title text). +% +% A page break is allowed, and even encouraged, before the framed +% environment. If you want to attach some text (a box title) to the +% frame, then the text should be inserted by \FrameCommand so it cannot +% be separated from the body. +% +% The contents of the framed regions are restricted: +% Floats, footnotes, marginpars and head-line entries will be lost. +% (Some of these may be handled in a later version.) +% This package will not work with the page breaking of multicol.sty, +% or other systems that perform column-balancing. +% +% The MakeFramed environment does the work. Its `settings' argument +% should contain any adjustments to the text width (via a setting of +% "\hsize"). Here, the parameter "\width" gives the measured extra width +% added by the frame, so a common setting is "\advance\hsize-\width" +% which reduces the width of the text just enough that the outer edge +% of the frame aligns with the margins. The `settings' should also +% include a `restore' command -- "\@parboxrestore" or "\FrameRestore" +% or something similar; for instance, the snugshade environment uses +% settings to eliminate list indents and vertical space, but uses +% "\hspace" in "\FrameCommand" to reproduce the list margin ouside the +% shading. +% +% There are actually four variants of "\FrameCommand" to allow different +% formatting for each part of an environment broken over pages. Unbroken +% text is adorned by "\FrameCommand", whereas split text first uses +% "\FirstFrameCommand", possibly followed by "\MidFrameCommand", and +% finishing with "\LastFrameCommand". The default definitions for +% these three just invokes "\FrameCommand", so that all portions are +% framed the same way. See the oframe environment for use of distinct +% First/Mid/Last frames. +% +% Expert commands: +% \MakeFramed, \endMakeFramed: the "MakeFramed" environment +% \FrameCommand: command to draw the frame around its argument +% \FirstFrameCommand: the frame for the first part of a split environment +% \LastFrameCommand: for the last portion +% \MidFrameCommand: for any intermediate segments +% \FrameRestore: restore some text settings, but fewer than \@parboxrestore +% \FrameRule: length register; \fboxrule for default "framed". +% \FrameSep: length register; \fboxsep for default "framed". +% \FrameHeightAdjust: macro; height of frame above baseline at top of page +% \OuterFrameSep: vertical space before and after the framed env. Defaults to "\topsep" +% +% This is still a `pre-production' version because I can think of many +% features/improvements that should be made. Also, a detailed manual needs +% to be written. Nevertheless, starting with version 0.5 it should be bug-free. +% +% ToDo: +% Test more varieties of list +% Improve and correct documentation +% Propagation of \marks +% Handle footnotes (how??) floats (?) and marginpars. +% Stretchability modification. +% Make inner contents height/depth influence placement. +%======================== End Instructions ======================== + +\ProvidesPackage{framed}[2011/10/22 v 0.96: + framed or shaded text with page breaks] + +\newenvironment{framed}% using default \FrameCommand + {\MakeFramed {\advance\hsize-\width \FrameRestore}}% + {\endMakeFramed} + +\newenvironment{shaded}{% + \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}% + \MakeFramed {\FrameRestore}}% + {\endMakeFramed} + +\newenvironment{shaded*}{% + \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}% + \MakeFramed {\advance\hsize-\width \FrameRestore}}% + {\endMakeFramed} + +\newenvironment{leftbar}{% + \def\FrameCommand{\vrule width 3pt \hspace{10pt}}% + \MakeFramed {\advance\hsize-\width \FrameRestore}}% + {\endMakeFramed} + +% snugshde: Shaded environment that +% -- uses the default \fboxsep instead of \FrameSep +% -- leaves the text indent unchanged (shading bleeds out) +% -- eliminates possible internal \topsep glue (\@setminipage) +% -- shrinks inside the margins for lists +% An \item label will tend to hang outside the shading, thanks to +% the small \fboxsep. + +\newenvironment{snugshade}{% + \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep + \colorbox{shadecolor}{##1}\hskip-\fboxsep + % There is no \@totalrightmargin, so: + \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% + \MakeFramed {\advance\hsize-\width + \@totalleftmargin\z@ \linewidth\hsize + \@setminipage}% + }{\par\unskip\@minipagefalse\endMakeFramed} + +\newenvironment{snugshade*}{% + \def\FrameCommand##1{\hskip\@totalleftmargin + \colorbox{shadecolor}{##1}% + % There is no \@totalrightmargin, so: + \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}% + \MakeFramed {\advance\hsize-\width + \@totalleftmargin\z@ \linewidth\hsize + \advance\labelsep\fboxsep + \@setminipage}% + }{\par\unskip\@minipagefalse\endMakeFramed} + +\newenvironment{oframed}{% open (top or bottom) framed + \def\FrameCommand{\OpenFBox\FrameRule\FrameRule}% + \def\FirstFrameCommand{\OpenFBox\FrameRule\z@}% + \def\MidFrameCommand{\OpenFBox\z@\z@}% + \def\LastFrameCommand{\OpenFBox\z@\FrameRule}% + \MakeFramed {\advance\hsize-\width \FrameRestore}% + }{\endMakeFramed} + +% A simplified entry to \CustomFBox with two customized parameters: +% the thicknesses of the top and bottom rules. Perhaps we want to +% use less \fboxsep on the open edges? + +\def\OpenFBox#1#2{\fboxsep\FrameSep + \CustomFBox{}{}{#1}{#2}\FrameRule\FrameRule} + +% \CustomFBox is like an amalgamation of \fbox and \@frameb@x, +% so it can be used by an alternate to \fbox or \fcolorbox, but +% it has more parameters for various customizations. +% Parameter #1 is inserted (in vmode) right after the top rule +% (useful for a title or assignments), and #2 is similar, but +% inserted right above the bottom rule. +% The thicknesses of the top, bottom, left, and right rules are +% given as parameters #3,#4,#5,#6 respectively. They should be +% \fboxrule or \z@ (or some other thickness). +% The text argument is #7. +% An instance of this can be used for the frame of \fcolorbox by +% locally defining \fbox before \fcolorbox; e.g., +% \def\fbox{\CustomFBox{}{}\z@\z@\fboxrule\fboxrule}\fcolorbox +% +% Do we need to use different \fboxsep on different sides too? +% +\long\def\CustomFBox#1#2#3#4#5#6#7{% + \leavevmode\begingroup + \setbox\@tempboxa\hbox{% + \color@begingroup + \kern\fboxsep{#7}\kern\fboxsep + \color@endgroup}% + \hbox{% + % Here we calculate and shift for the depth. Done in + % a group because one of the arguments might be \@tempdima + % (we could use \dimexpr instead without grouping). + \begingroup + \@tempdima#4\relax + \advance\@tempdima\fboxsep + \advance\@tempdima\dp\@tempboxa + \expandafter\endgroup\expandafter + \lower\the\@tempdima\hbox{% + \vbox{% + \hrule\@height#3\relax + #1% + \hbox{% + \vrule\@width#5\relax + \vbox{% + \vskip\fboxsep % maybe these should be parameters too + \copy\@tempboxa + \vskip\fboxsep}% + \vrule\@width#6\relax}% + #2% + \hrule\@height#4\relax}% + }% + }% + \endgroup +} + + +% A particular type of titled frame with continuation marks. +% Parameter #1 is the title, repeated on each page. +\newenvironment{titled-frame}[1]{% + \def\FrameCommand{\fboxsep8pt\fboxrule2pt + \TitleBarFrame{\textbf{#1}}}% + \def\FirstFrameCommand{\fboxsep8pt\fboxrule2pt + \TitleBarFrame[$\blacktriangleright$]{\textbf{#1}}}% + \def\MidFrameCommand{\fboxsep8pt\fboxrule2pt + \TitleBarFrame[$\blacktriangleright$]{\textbf{#1\ (cont)}}}% + \def\LastFrameCommand{\fboxsep8pt\fboxrule2pt + \TitleBarFrame{\textbf{#1\ (cont)}}}% + \MakeFramed{\advance\hsize-20pt \FrameRestore}}% +% note: 8 + 2 + 8 + 2 = 20. Don't use \width because the frame title +% could interfere with the width measurement. + {\endMakeFramed} + +% \TitleBarFrame[marker]{title}{contents} +% Frame with a label at top, optional continuation marker at bottom right. +% Frame color is TFFrameColor and title color is a contrasting TFTitleColor; +% both need to be defined before use. The frame itself use \fboxrule and +% \fboxsep. If the title is omitted entirely, the title bar is omitted +% (use a blank space to force a blank title bar). +% +\newcommand\TitleBarFrame[3][]{\begingroup + \ifx\delimiter#1\delimiter + \let\TF@conlab\@empty + \else + \def\TF@conlab{% continuation label + \nointerlineskip + \smash{\rlap{\kern\wd\@tempboxa\kern\fboxrule\kern\fboxsep #1}}}% + \fi + \let\TF@savecolor\current@color + \textcolor{TFFrameColor}{% + \CustomFBox + {\TF@Title{#2}}{\TF@conlab}% + \fboxrule\fboxrule\fboxrule\fboxrule + {\let\current@color\TF@savecolor\set@color #3}% + }\endgroup +} + +% The title bar for \TitleBarFrame +\newcommand\TF@Title[1]{% + \ifx\delimiter#1\delimiter\else + \kern-0.04pt\relax + \begingroup + \setbox\@tempboxa\vbox{% + \kern0.8ex + \hbox{\kern\fboxsep\textcolor{TFTitleColor}{#1}\vphantom{Tj)}}% + \kern0.8ex}% + \hrule\@height\ht\@tempboxa + \kern-\ht\@tempboxa + \box\@tempboxa + \endgroup + \nointerlineskip + \kern-0.04pt\relax + \fi +} + +\chardef\FrameRestore=\catcode`\| % for debug +\catcode`\|=\catcode`\% % (debug: insert space after backslash) + +\newlength\OuterFrameSep \OuterFrameSep=\maxdimen \relax + +\def\MakeFramed#1{\par + % apply default \OuterFrameSep = \topsep + \ifdim\OuterFrameSep=\maxdimen \OuterFrameSep\topsep \fi + % measure added width and height; call result \width and \height + \fb@sizeofframe\FrameCommand + \let\width\fb@frw \let\height\fb@frh + % insert pre-penalties and skips + \begingroup + \skip@\lastskip + \if@nobreak\else + \penalty9999 % updates \page parameters + \ifdim\pagefilstretch=\z@ \ifdim\pagefillstretch=\z@ + % not infinitely stretchable, so encourage a page break here + \edef\@tempa{\the\skip@}% + \ifx\@tempa\zero@glue \penalty-30 + \else \vskip-\skip@ \penalty-30 \vskip\skip@ + \fi\fi\fi + \penalty\z@ + % Give a stretchy breakpoint that will always be taken in preference + % to the \penalty 9999 used to update page parameters. The cube root + % of 10000/100 indicates a multiplier of 0.21545, but the maximum + % calculated badness is really 8192, not 10000, so the multiplier + % is 0.2301. + \advance\skip@ \z@ plus-.5\baselineskip + \advance\skip@ \z@ plus-.231\height + \advance\skip@ \z@ plus-.231\skip@ + \advance\skip@ \z@ plus-.231\OuterFrameSep + \vskip-\skip@ \penalty 1800 \vskip\skip@ + \fi + \addvspace{\OuterFrameSep}% + \endgroup + % clear out pending page break + \penalty\@M \vskip 2\baselineskip \vskip\height + \penalty9999 \vskip -2\baselineskip \vskip-\height + \penalty9999 % updates \pagetotal +|\message{After clearout, \pagetotal=\the\pagetotal, \pagegoal=\the\pagegoal. }% + \fb@adjheight + \setbox\@tempboxa\vbox\bgroup + #1% Modifications to \hsize (can use \width and \height) + \textwidth\hsize \columnwidth\hsize +} + +\def\endMakeFramed{\par + \kern\z@ + \hrule\@width\hsize\@height\z@ % possibly bad + \penalty-100 % (\hrule moves depth into height) + \egroup +%%% {\showoutput\showbox\@tempboxa}% + \begingroup + \fb@put@frame\FrameCommand\FirstFrameCommand + \endgroup + \@minipagefalse % In case it was set and not cleared +} + +% \fb@put@frame takes the contents of \@tempboxa and puts all, or a piece, +% of it on the page with a frame (\FrameCommand, \FirstFrameCommand, +% \MidFrameCommand, or \LastFrameCommand). It recurses until all of +% \@tempboxa has been used up. (\@tempboxa must have zero depth.) +% #1 = attempted framing command, if no split +% #2 = framing command if split +% First iteration: Try to fit with \FrameCommand. If it does not fit, +% split for \FirstFrameCommand. +% Later iteration: Try to fit with \LastFrameCommand. If it does not +% fit, split for \MidFrameCommand. +\def\fb@put@frame#1#2{\relax + \ifdim\pagegoal=\maxdimen \pagegoal\vsize \fi +| \message{=============== Entering putframe ====================^^J +| \pagegoal=\the\pagegoal, \pagetotal=\the\pagetotal. }% + \ifinner + \fb@putboxa#1% + \fb@afterframe + \else + \dimen@\pagegoal \advance\dimen@-\pagetotal % natural space left on page + \ifdim\dimen@<2\baselineskip % Too little room on page +| \message{Page has only \the\dimen@\space room left; eject. }% + \eject \fb@adjheight \fb@put@frame#1#2% + \else % there's appreciable room left on the page + \fb@sizeofframe#1% +| \message{\string\pagetotal=\the\pagetotal, +| \string\pagegoal=\the\pagegoal, +| \string\pagestretch=\the\pagestretch, +| \string\pageshrink=\the\pageshrink, +| \string\fb@frh=\the\fb@frh. \space} +| \message{^^JBox of size \the\ht\@tempboxa\space}% + \begingroup % temporarily set \dimen@ to be... + \advance\dimen@.8\pageshrink % maximum space available on page + \advance\dimen@-\fb@frh\relax % max space available for frame's contents +%%% LOOKS SUBTRACTED AND ADDED, SO DOUBLE ACCOUNTING! + \expandafter\endgroup + % expand \ifdim, then restore \dimen@ to real room left on page + \ifdim\dimen@>\ht\@tempboxa % whole box does fit +| \message{fits in \the\dimen@. }% + % ToDo: Change this to use vsplit anyway to capture the marks + % MERGE THIS WITH THE else CLAUSE!!! + \fb@putboxa#1% + \fb@afterframe + \else % box must be split +| \message{must be split to fit in \the\dimen@. }% + % update frame measurement to use \FirstFrameCommand or \MidFrameCommand + \fb@sizeofframe#2% + \setbox\@tempboxa\vbox{% simulate frame and flexiblity of the page: + \vskip \fb@frh \@plus\pagestretch \@minus.8\pageshrink + \kern137sp\kern-137sp\penalty-30 + \unvbox\@tempboxa}% + \edef\fb@resto@set{\boxmaxdepth\the\boxmaxdepth + \splittopskip\the\splittopskip}% + \boxmaxdepth\z@ \splittopskip\z@ +| \message{^^JPadded box of size \the\ht\@tempboxa\space split to \the\dimen@}% + % Split box here + \setbox\tw@\vsplit\@tempboxa to\dimen@ +| \toks99\expandafter{\splitfirstmark}% +| \toks98\expandafter{\splitbotmark}% +| \message{Marks are: \the\toks99, \the\toks98. }% + \setbox\tw@\vbox{\unvbox\tw@}% natural-sized +| \message{Natural height of split box is \the\ht\tw@, leaving +| \the\ht\@tempboxa\space remainder. }% + % If the split-to size > (\vsize-\topskip), then set box to full size. + \begingroup + \advance\dimen@\topskip + \expandafter\endgroup + \ifdim\dimen@>\pagegoal +| \message{Frame is big -- Use up the full column. }% + \dimen@ii\pagegoal + \advance\dimen@ii -\topskip + \advance\dimen@ii \FrameHeightAdjust\relax + \else % suspect this is implemented incorrectly: + % If the split-to size > feasible room_on_page, rebox it smaller. + \advance\dimen@.8\pageshrink + \ifdim\ht\tw@>\dimen@ +| \message{Box too tall; rebox it to \the\dimen@. }% + \dimen@ii\dimen@ + \else % use natural size + \dimen@ii\ht\tw@ + \fi + \fi + % Re-box contents to desired size \dimen@ii + \advance\dimen@ii -\fb@frh + \setbox\tw@\vbox to\dimen@ii \bgroup + % remove simulated frame and page flexibility: + \vskip -\fb@frh \@plus-\pagestretch \@minus-.8\pageshrink + \unvbox\tw@ \unpenalty\unpenalty + \ifdim\lastkern=-137sp % whole box went to next page +| \message{box split at beginning! }% + % need work here??? + \egroup \fb@resto@set \eject % (\vskip for frame size was discarded) + \fb@adjheight + \fb@put@frame#1#2% INSERTED ??? + \else % Got material split off at the head + \egroup \fb@resto@set + \ifvoid\@tempboxa % it all fit after all +| \message{box split at end! }% + \setbox\@tempboxa\box\tw@ + \fb@putboxa#1% + \fb@afterframe + \else % it really did split +| \message{box split as expected. Its reboxed height is \the\ht\tw@. }% + \ifdim\wd\tw@>\z@ + \wd\tw@\wd\@tempboxa + \centerline{#2{\box\tw@}}% ??? \centerline bad idea + \else +| \message{Zero width means likely blank. Don't frame it (guess)}% + \box\tw@ + \fi + \hrule \@height\z@ \@width\hsize + \eject + \fb@adjheight + \fb@put@frame\LastFrameCommand\MidFrameCommand + \fi\fi\fi\fi\fi +} + +\def\fb@putboxa#1{% + \ifvoid\@tempboxa + \PackageWarning{framed}{Boxa is void -- discard it. }% + \else +| \message{Frame and place boxa. }% +| %{\showoutput\showbox\@tempboxa}% + \centerline{#1{\box\@tempboxa}}% + \fi +} + +\def\fb@afterframe{% + \nointerlineskip \null %{\showoutput \showlists} + \penalty-30 \vskip\OuterFrameSep \relax +} + +% measure width and height added by frame (#1 = frame command) +% call results \fb@frw and \fb@frh +% todo: a mechanism to handle wide frame titles +\newdimen\fb@frw +\newdimen\fb@frh +\def\fb@sizeofframe#1{\begingroup + \setbox\z@\vbox{\vskip-5in \hbox{\hskip-5in + #1{\hbox{\vrule \@height 4.7in \@depth.3in \@width 5in}}}% + \vskip\z@skip}% +| \message{Measuring frame addition for \string#1 in \@currenvir\space +| gives ht \the\ht\z@\space and wd \the\wd\z@. }% +| %{\showoutput\showbox\z@}% + \global\fb@frw\wd\z@ \global\fb@frh\ht\z@ + \endgroup +} + +\def\fb@adjheight{% + \vbox to\FrameHeightAdjust{}% get proper baseline skip from above. + \penalty\@M \nointerlineskip + \vskip-\FrameHeightAdjust + \penalty\@M} % useful for tops of pages + +\edef\zero@glue{\the\z@skip} + +\catcode`\|=\FrameRestore + +% Provide configuration commands: +\providecommand\FrameCommand{% + \setlength\fboxrule{\FrameRule}\setlength\fboxsep{\FrameSep}% + \fbox} +\@ifundefined{FrameRule}{\newdimen\FrameRule \FrameRule=\fboxrule}{} +\@ifundefined{FrameSep} {\newdimen\FrameSep \FrameSep =3\fboxsep}{} +\providecommand\FirstFrameCommand{\FrameCommand} +\providecommand\MidFrameCommand{\FrameCommand} +\providecommand\LastFrameCommand{\FrameCommand} + +% Height of frame above first baseline when frame starts a page: +\providecommand\FrameHeightAdjust{6pt} + +% \FrameRestore has parts of \@parboxrestore, performing a similar but +% less complete restoration of the default layout. See how it is used in +% the "settings" argument of \MakeFrame. Though not a parameter, \hsize +% should be set to the desired total line width available inside the +% frame before invoking \FrameRestore. +\def\FrameRestore{% + \let\if@nobreak\iffalse + \let\if@noskipsec\iffalse + \let\-\@dischyph + \let\'\@acci\let\`\@accii\let\=\@acciii + % \message{FrameRestore: + % \@totalleftmargin=\the \@totalleftmargin, + % \rightmargin=\the\rightmargin, + % \@listdepth=\the\@listdepth. }% + % Test if we are in a list (or list-like paragraph) + \ifnum \ifdim\@totalleftmargin>\z@ 1\fi + \ifdim\rightmargin>\z@ 1\fi + \ifnum\@listdepth>\z@ 1\fi 0>\z@ + % \message{In a list: \linewidth=\the\linewidth, \@totalleftmargin=\the\@totalleftmargin, + % \parshape=\the\parshape, \columnwidth=\the\columnwidth, \hsize=\the\hsize, + % \labelwidth=\the\labelwidth. }% + \@setminipage % snug fit around the item. I would like this to be non-global. + % Now try to propageate changes of width from \hsize to list parameters. + % This is deficient, but a more advanced way to indicate modification to text + % dimensions is not (yet) provided; in particular, no separate left/right + % adjustment. + \advance\linewidth-\columnwidth \advance\linewidth\hsize + \parshape\@ne \@totalleftmargin \linewidth + \else % Not in list + \linewidth=\hsize + %\message{No list, set \string\linewidth=\the\hsize. }% + \fi + \sloppy +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/ThirdParty/Ert/python/docs/latex/needspace.sty b/ThirdParty/Ert/python/docs/latex/needspace.sty new file mode 100644 index 0000000000..113d87216f --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/needspace.sty @@ -0,0 +1,35 @@ + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{needspace}[2010/09/12 v1.3d reserve vertical space] + +\newcommand{\needspace}[1]{% + \begingroup + \setlength{\dimen@}{#1}% + \vskip\z@\@plus\dimen@ + \penalty -100\vskip\z@\@plus -\dimen@ + \vskip\dimen@ + \penalty 9999% + \vskip -\dimen@ + \vskip\z@skip % hide the previous |\vskip| from |\addvspace| + \endgroup +} + +\newcommand{\Needspace}{\@ifstar{\@sneedsp@}{\@needsp@}} + +\newcommand{\@sneedsp@}[1]{\par \penalty-100\begingroup + \setlength{\dimen@}{#1}% + \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal + \ifdim \dimen@>\dimen@ii + \break + \fi\endgroup} + +\newcommand{\@needsp@}[1]{\par \penalty-100\begingroup + \setlength{\dimen@}{#1}% + \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal + \ifdim \dimen@>\dimen@ii + \ifdim \dimen@ii>\z@ + \vfil + \fi + \break + \fi\endgroup} + diff --git a/ThirdParty/Ert/python/docs/latex/tabulary.sty b/ThirdParty/Ert/python/docs/latex/tabulary.sty new file mode 100644 index 0000000000..5660cdfbbe --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/tabulary.sty @@ -0,0 +1,451 @@ +%% +%% This is file `tabulary.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% tabulary.dtx (with options: `package') +%% DRAFT VERSION +%% +%% File `tabulary.dtx'. +%% Copyright (C) 1995 1996 2003 2008 David Carlisle +%% This file may be distributed under the terms of the LPPL. +%% See 00readme.txt for details. +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tabulary} + [2014/06/11 v0.10 tabulary package (DPC)] +\RequirePackage{array} +\catcode`\Z=14 +\DeclareOption{debugshow}{\catcode`\Z=9\relax} +\ProcessOptions +\def\arraybackslash{\let\\=\@arraycr} +\def\@finalstrut#1{% + \unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1} +\newcount\TY@count +\def\tabulary{% + \let\TY@final\tabular + \let\endTY@final\endtabular + \TY@tabular} +\def\TY@tabular#1{% + \edef\TY@{\@currenvir}% + {\ifnum0=`}\fi + \@ovxx\TY@linewidth + \@ovyy\TY@tablewidth + \count@\z@ + \@tempswatrue + \@whilesw\if@tempswa\fi{% + \advance\count@\@ne + \expandafter\ifx\csname TY@F\the\count@\endcsname\relax + \@tempswafalse + \else + \expandafter\let\csname TY@SF\the\count@\expandafter\endcsname + \csname TY@F\the\count@\endcsname + \global\expandafter\let\csname TY@F\the\count@\endcsname\relax + \expandafter\let\csname TY@S\the\count@\expandafter\endcsname + \csname TY@\the\count@\endcsname + \fi}% + \global\TY@count\@ne + \TY@width\xdef{0pt}% + \global\TY@tablewidth\z@ + \global\TY@linewidth#1\relax +Z\message{^^J^^JTable^^J% +Z Target Width: \the\TY@linewidth^^J% +Z \string\tabcolsep: \the\tabcolsep\space +Z \string\arrayrulewidth: \the\arrayrulewidth\space +Z \string\doublerulesep: \the\doublerulesep^^J% +Z \string\tymin: \the\tymin\space +Z \string\tymax: \the\tymax^^J}% + \let\@classz\TY@classz + \let\verb\TX@verb + \toks@{}\TY@get@body} +\let\TY@@mkpream\@mkpream +\def\TY@mkpream{% + \def\@addamp{% + \if@firstamp \@firstampfalse \else + \global\advance\TY@count\@ne + \edef\@preamble{\@preamble &}\fi + \TY@width\xdef{0pt}}% + \def\@acol{% + \TY@subwidth\col@sep + \@addtopreamble{\hskip\col@sep}}% + \let\@arrayrule\TY@arrayrule + \let\@classvi\TY@classvi + \def\@classv{\save@decl + \expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@ + \sbox\z@{\d@llarbegin\@nextchar\d@llarend}% + \TY@subwidth{\wd\z@}% + \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% + \prepnext@tok}% + \global\let\@mkpream\TY@@mkpream + \TY@@mkpream} +\def\TY@arrayrule{% + \TY@subwidth\arrayrulewidth + \@addtopreamble \vline} +\def\TY@classvi{\ifcase \@lastchclass + \@acol \or + \TY@subwidth\doublerulesep + \@addtopreamble{\hskip \doublerulesep}\or + \@acol \or + \@classvii + \fi} +\def\TY@tab{% + \setbox\z@\hbox\bgroup + \let\[$\let\]$% + \let\equation$\let\endequation$% + \col@sep\tabcolsep + \let\d@llarbegin\begingroup\let\d@llarend\endgroup + \let\@mkpream\TY@mkpream + \def\multicolumn##1##2##3{\multispan##1\relax}% + \CT@start\TY@tabarray} +\def\TY@tabarray{\@ifnextchar[{\TY@array}{\@array[t]}} +\def\TY@array[#1]{\@array[t]} +\def\TY@width#1{% + \expandafter#1\csname TY@\the\TY@count\endcsname} +\def\TY@subwidth#1{% + \TY@width\dimen@ + \advance\dimen@-#1\relax + \TY@width\xdef{\the\dimen@}% + \global\advance\TY@linewidth-#1\relax} +\def\endtabulary{% + \gdef\@halignto{}% + \expandafter\TY@tab\the\toks@ + \crcr\omit + {\xdef\TY@save@row{}% + \loop + \advance\TY@count\m@ne + \ifnum\TY@count>\z@ + \xdef\TY@save@row{\TY@save@row&\omit}% + \repeat}\TY@save@row + \endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1 + \unskip\global\setbox1=\lastbox}\egroup + \dimen@\TY@linewidth + \divide\dimen@\TY@count + \ifdim\dimen@<\tymin + \TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}% + \tymin\dimen@ + \fi + \setbox\tw@=\hbox{\unhbox\@ne + \loop +\@tempdima=\lastskip +\ifdim\@tempdima>\z@ +Z \message{ecs=\the\@tempdima^^J}% + \global\advance\TY@linewidth-\@tempdima +\fi + \unskip + \setbox\tw@=\lastbox + \ifhbox\tw@ +Z \message{Col \the\TY@count: Initial=\the\wd\tw@\space}% + \ifdim\wd\tw@>\tymax + \wd\tw@\tymax +Z \message{> max\space}% +Z \else +Z \message{ \@spaces\space}% + \fi + \TY@width\dimen@ +Z \message{\the\dimen@\space}% + \advance\dimen@\wd\tw@ +Z \message{Final=\the\dimen@\space}% + \TY@width\xdef{\the\dimen@}% + \ifdim\dimen@<\tymin +Z \message{< tymin}% + \global\advance\TY@linewidth-\dimen@ + \expandafter\xdef\csname TY@F\the\TY@count\endcsname + {\the\dimen@}% + \else + \expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@ +Z \message{***}% + \global\advance\TY@linewidth-\dimen@ + \expandafter\xdef\csname TY@F\the\TY@count\endcsname + {\the\dimen@}% + \else +Z \message{> tymin}% + \global\advance\TY@tablewidth\dimen@ + \global\expandafter\let\csname TY@F\the\TY@count\endcsname + \maxdimen + \fi\fi + \advance\TY@count\m@ne + \repeat}% + \TY@checkmin + \TY@checkmin + \TY@checkmin + \TY@checkmin + \TY@count\z@ + \let\TY@box\TY@box@v + {\expandafter\TY@final\the\toks@\endTY@final}% + \count@\z@ + \@tempswatrue + \@whilesw\if@tempswa\fi{% + \advance\count@\@ne + \expandafter\ifx\csname TY@SF\the\count@\endcsname\relax + \@tempswafalse + \else + \global\expandafter\let\csname TY@F\the\count@\expandafter\endcsname + \csname TY@SF\the\count@\endcsname + \global\expandafter\let\csname TY@\the\count@\expandafter\endcsname + \csname TY@S\the\count@\endcsname + \fi}% + \TY@linewidth\@ovxx + \TY@tablewidth\@ovyy + \ifnum0=`{\fi}} +\def\TY@checkmin{% + \let\TY@checkmin\relax +\ifdim\TY@tablewidth>\z@ + \Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth + \ifdim\TY@tablewidth <\TY@linewidth + \def\TY@ratio{1}% + \fi +\else + \TY@warn{No suitable columns!}% + \def\TY@ratio{1}% +\fi +\count@\z@ +Z \message{^^JLine Width: \the\TY@linewidth, +Z Natural Width: \the\TY@tablewidth, +Z Ratio: \TY@ratio^^J}% +\@tempdima\z@ +\loop +\ifnum\count@<\TY@count +\advance\count@\@ne + \ifdim\csname TY@F\the\count@\endcsname>\tymin + \dimen@\csname TY@\the\count@\endcsname + \dimen@\TY@ratio\dimen@ + \ifdim\dimen@<\tymin +Z \message{Column \the\count@\space ->}% + \global\expandafter\let\csname TY@F\the\count@\endcsname\tymin + \global\advance\TY@linewidth-\tymin + \global\advance\TY@tablewidth-\csname TY@\the\count@\endcsname + \let\TY@checkmin\TY@@checkmin + \else + \expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}% + \advance\@tempdima\csname TY@F\the\count@\endcsname + \fi + \fi +Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }% +\repeat +Z \message{^^JTotal:\the\@tempdima^^J}% +} +\let\TY@@checkmin\TY@checkmin +\newdimen\TY@linewidth +\def\tyformat{\everypar{{\nobreak\hskip\z@skip}}} +\newdimen\tymin +\tymin=10pt +\newdimen\tymax +\tymax=2\textwidth +\def\@testpach{\@chclass + \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else + \ifnum \@lastchclass=7 5 \else + \ifnum \@lastchclass=8 \tw@ \else + \ifnum \@lastchclass=9 \thr@@ + \else \z@ + \ifnum \@lastchclass = 10 \else + \edef\@nextchar{\expandafter\string\@nextchar}% + \@chnum + \if \@nextchar c\z@ \else + \if \@nextchar l\@ne \else + \if \@nextchar r\tw@ \else + \if \@nextchar C7 \else + \if \@nextchar L8 \else + \if \@nextchar R9 \else + \if \@nextchar J10 \else + \z@ \@chclass + \if\@nextchar |\@ne \else + \if \@nextchar !6 \else + \if \@nextchar @7 \else + \if \@nextchar <8 \else + \if \@nextchar >9 \else + 10 + \@chnum + \if \@nextchar m\thr@@\else + \if \@nextchar p4 \else + \if \@nextchar b5 \else + \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi\fi \fi \fi\fi \fi + \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} +\def\TY@classz{% + \@classx + \@tempcnta\count@ + \ifx\TY@box\TY@box@v + \global\advance\TY@count\@ne + \fi + \let\centering c% + \let\raggedright\noindent + \let\raggedleft\indent + \let\arraybackslash\relax + \prepnext@tok + \ifnum\@chnum<4 + \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ + \fi + \ifnum\@chnum=6 + \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ + \fi + \@addtopreamble{% + \ifcase\@chnum + \hfil \d@llarbegin\insert@column\d@llarend \hfil \or + \kern\z@ + \d@llarbegin \insert@column \d@llarend \hfil \or + \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or + $\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or + \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or + \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or + \d@llarbegin \insert@column \d@llarend \or% dubious "s" case + \TY@box\centering\or + \TY@box\raggedright\or + \TY@box\raggedleft\or + \TY@box\relax + \fi}\prepnext@tok} +\def\TY@box#1{% + \ifx\centering#1% + \hfil \d@llarbegin\insert@column\d@llarend \hfil \else + \ifx\raggedright#1% + \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + \d@llarbegin \insert@column \d@llarend \hfil \else + \ifx\raggedleft#1% + \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else + \ifx\relax#1% + \d@llarbegin \insert@column \d@llarend + \fi \fi \fi \fi} +\def\TY@box@v#1{% + \vtop \@startpbox{\csname TY@F\the\TY@count\endcsname}% + #1\arraybackslash\tyformat + \insert@column\@endpbox} +\newdimen\TY@tablewidth +\def\Gscale@div#1#2#3{% + \setlength\dimen@{#3}% + \ifdim\dimen@=\z@ + \PackageError{graphics}{Division by 0}\@eha + \dimen@#2% + \fi + \edef\@tempd{\the\dimen@}% + \setlength\dimen@{#2}% + \count@65536\relax + \ifdim\dimen@<\z@ + \dimen@-\dimen@ + \count@-\count@ + \fi + \loop + \ifdim\dimen@<8192\p@ + \dimen@\tw@\dimen@ + \divide\count@\tw@ + \repeat + \dimen@ii=\@tempd\relax + \divide\dimen@ii\count@ + \divide\dimen@\dimen@ii + \edef#1{\strip@pt\dimen@}} +\long\def\TY@get@body#1\end + {\toks@\expandafter{\the\toks@#1}\TY@find@end} +\def\TY@find@end#1{% + \def\@tempa{#1}% + \ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa + \else\toks@\expandafter + {\the\toks@\end{#1}}\expandafter\TY@get@body\fi} +\def\TY@warn{% + \PackageWarning{tabulary}} +\catcode`\Z=11 +\AtBeginDocument{ +\@ifpackageloaded{colortbl}{% +\expandafter\def\expandafter\@mkpream\expandafter#\expandafter1% + \expandafter{% + \expandafter\let\expandafter\CT@setup\expandafter\relax + \expandafter\let\expandafter\CT@color\expandafter\relax + \expandafter\let\expandafter\CT@do@color\expandafter\relax + \expandafter\let\expandafter\color\expandafter\relax + \expandafter\let\expandafter\CT@column@color\expandafter\relax + \expandafter\let\expandafter\CT@row@color\expandafter\relax + \expandafter\let\expandafter\CT@cell@color\expandafter\relax + \@mkpream{#1}} +\let\TY@@mkpream\@mkpream +\def\TY@classz{% + \@classx + \@tempcnta\count@ + \ifx\TY@box\TY@box@v + \global\advance\TY@count\@ne + \fi + \let\centering c% + \let\raggedright\noindent + \let\raggedleft\indent + \let\arraybackslash\relax + \prepnext@tok +\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil + \ifnum\@chnum<4 + \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ + \fi + \ifnum\@chnum=6 + \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ + \fi + \@addtopreamble{% + \setbox\z@\hbox\bgroup\bgroup + \ifcase\@chnum + \hskip\stretch{.5}\kern\z@ + \d@llarbegin\insert@column\d@llarend\hskip\stretch{.5}\or + \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<< + \d@llarbegin \insert@column \d@llarend \hfill \or + \hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or + $\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or + \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or + \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or + \d@llarbegin \insert@column \d@llarend \or% dubious s case + \TY@box\centering\or + \TY@box\raggedright\or + \TY@box\raggedleft\or + \TY@box\relax + \fi + \egroup\egroup +\begingroup + \CT@setup + \CT@column@color + \CT@row@color + \CT@cell@color + \CT@do@color +\endgroup + \@tempdima\ht\z@ + \advance\@tempdima\minrowclearance + \vrule\@height\@tempdima\@width\z@ +\unhbox\z@ +}\prepnext@tok}% + \def\TY@arrayrule{% + \TY@subwidth\arrayrulewidth + \@addtopreamble{{\CT@arc@\vline}}}% + \def\TY@classvi{\ifcase \@lastchclass + \@acol \or + \TY@subwidth\doublerulesep + \ifx\CT@drsc@\relax + \@addtopreamble{\hskip\doublerulesep}% + \else + \@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}% + \fi\or + \@acol \or + \@classvii + \fi}% +}{% +\let\CT@start\relax +} +} +{\uccode`\*=`\ % +\uppercase{\gdef\TX@verb{% + \leavevmode\null\TX@vwarn + {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces + \@ifstar{\let~*\TX@vb}{\TX@vb}}}} +\def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}% + \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!} +\def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= } +\begingroup +\catcode`\*=\catcode`\# +\catcode`\#=12 +\gdef\TX@vfirst{% + \if\@tempa#% + \def\@tempb{\TX@v@#}% + \else + \let\@tempb\TX@v@ + \if\@tempa\space~\else\@tempa\fi + \fi + \@tempb} +\gdef\TX@v@*1 *2{% + \TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2} +\gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2} +\endgroup +\def\TX@vwarn{% + \@warning{\noexpand\verb may be unreliable inside tabularx/y}% + \global\let\TX@vwarn\@empty} +\endinput +%% +%% End of file `tabulary.sty'. diff --git a/ThirdParty/Ert/python/docs/latex/titlesec.sty b/ThirdParty/Ert/python/docs/latex/titlesec.sty new file mode 100644 index 0000000000..ab4d0177cc --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/titlesec.sty @@ -0,0 +1,1349 @@ +% +--------------------------------------------------+ +% | Typeset titlesec.tex to get the documentation. | +% +--------------------------------------------------+ +% +% Copyright (c) 1998-2016 by Javier Bezos. +% All Rights Reserved. +% +% This file is part of the titlesec distribution release 2.10.1 +% ----------------------------------------------------------- +% +% It may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2003/12/01 or later. +% +% This work has the LPPL maintenance status "maintained". +% +% The Current Maintainer of this work is Javier Bezos. +% +% Notes +% ~~~~~ +% +% The following tags are used: +% ttl@ : the generic tag used through the style +% ttlh@ : a shape definition +% ttlf@ : a macro containing the title format +% ttls@ : id. the title space +% ttlp@ : page key related macros +% ttll@ : level number +% +% The ttlf@ and ttls@ contains data in the form {..}{..}. +% Perhaps in future releases they should be converted +% to a prop-like list, similar to that proposed by the +% latex team. +% +% Admittedly, the current implementation seems too +% complicated, but that's necessary in order to provide +% certain compatibility with the sections as defined by the +% used class. Other packages opt for providing the sections +% as defined by standard classes ignoring the class; for +% instance sectsty which does a simple task in a simple and +% nice way. However, that was not my goal. +% +% Release +% ~~~~~~~ + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{titlesec}[2016/03/15 v2.10.1 Sectioning titles] + +% Initialization +% ~~~~~~~~~~~~~~ + +\newif\ifttl@ps +\ttl@psfalse + +% The \ttl@label switch is used when printing the label in titles. +% A numberless variant makes it to true. +% There is a \ttl@toclabel as well, which is true iff the +% title is numbered; used in toc entries (except default part +% and chapter) and marks (only in titlesec pagestyles). + +\newif\ifttl@label +\newif\ifttl@toclabel + +\newbox\ttl@box + +% A provision for the report style: + +\@ifundefined{if@mainmatter} + {\let\if@mainmatter\iftrue}{} + +\@ifundefined{if@openright} + {\let\if@openright\iftrue}{} + +% and the ams styles as well + +\@ifundefined{@chapapp} + {\let\@chapapp\chaptername}{} + +\def\ttl@trylist{\ttl@try{}} + +\def\ttl@getkeys#1#2{% + \if\expandafter @\@gobble#1@\@empty + \edef\ttl@b{\expandafter\@gobble\string#1}% + \let\ttl@a\ttl@b + \else + \makeatletter + \edef\ttl@d{% + \noexpand\input{ttlkeys.def}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \ttl@getkeys{#1}{#2}% + \fi} + +% A more meaningful error for \@notdefinable + +\expandafter\AtEndOfPackage\expandafter{\expandafter + \gdef\expandafter\@notdefinable\expandafter{\@notdefinable}} + +\def\@notdefinable{% + \PackageError{titlesec}% + {Incompatible package}% + {Titlesec cannot continue defining its own macros + because\MessageBreak + \@backslashchar\reserved@a\space is already used by other package, + the class\MessageBreak + or the document.}} + +% +-----------------+ +% | C L A S S E S | +% +-----------------+ + +\def\ttl@useclass#1#2{% + \@ifstar + {\ttl@labelfalse#1{#2}[]}% + {\ttl@labeltrue\@dblarg{#1{#2}}}} + +\def\ttl@straightclass{\ttl@useclass\ttl@straight@i} +\def\ttl@partclass{\ttl@useclass\ttl@part@i} +\def\ttl@topclass{\ttl@useclass\ttl@top@i} +\def\ttl@pageclass{\ttl@useclass\ttl@page@i} + +% Here \scantokens is used to make sure the unescaped name +% has `letters' and no `others'. Mainly for hyperref, so there +% should be no problems. + +\newcommand\titleclass[1]{% + \edef\ttl@a{\expandafter\@gobble\string#1}% + \ifx\scantokens\@undefined\else + \scantokens\expandafter{\expandafter + \def\expandafter\ttl@a\expandafter{\ttl@a}}% + \fi + \@ifnextchar[{\@tempswatrue\ttl@class@i{#1}}% + {\@tempswafalse\ttl@class@ii{#1}}} + +\def\ttl@class@i#1[#2]{% + \@namedef{ttll@\ttl@a}{#2}% + \expandafter\providecommand\csname\ttl@a title\endcsname{}%%%% + \@ifundefined{ttl@toplevel}{}% + {\expandafter\let\csname ttlss@\ttl@a\expandafter\endcsname + \csname ttlss@\ttl@toplevel\endcsname}% + \edef\ttl@toplevel{\ttl@a}% + \ttl@class@ii{#1}} + +\def\ttl@class@ii#1#2{% + \@ifundefined{ttl@#2class}% + {\PackageError{titlesec}{Unknown sectioning class}% + {Valid names are top, page and straight}}% + {\expandafter\let\csname ttl@compat\ttl@a\endcsname\relax + \@ifundefined{\ttl@a mark}% + {\@namedef{\ttl@a mark}{\@gobble}}% + {}% + \edef#1{% + \expandafter\noexpand\csname ttl@#2class\endcsname{\ttl@a}}}% + \if@tempswa + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {\@ifnextchar[% + {\ttl@class@iii}% + {\@ifundefined{ttll@\ttl@a}% + {\PackageError{titlesec}{Unknown sectioning level}% + {\string\titleclass\space with no optional arguments\MessageBreak + only changes the class of an *existing* level}}}}} + +\def\ttl@class@iii[#1]{% + \edef\ttl@b{\expandafter\@gobble\string#1}% + \expandafter\let\csname ttlss@\ttl@a\expandafter\endcsname + \csname ttlss@\ttl@b\endcsname + \expandafter\edef\csname ttlss@\ttl@b\endcsname{\ttl@a}% + \let\ttl@a\ttl@toplevel + \count@\csname ttll@\ttl@toplevel\endcsname + \ttl@class@iv} + +\def\ttl@class@iv{% + \@ifundefined{ttlss@\ttl@a}{}% + {\advance\count@\@ne + \edef\ttl@a{\csname ttlss@\ttl@a\endcsname}% + \expandafter\edef\csname ttll@\ttl@a\endcsname{\the\count@}% + \ttl@class@iv}} + +% Typesetting Classes: General tools +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% The following command handles the *n spacing +% Some tricks are necessary to multiply a +% skip by a non integer number + +\newskip\beforetitleunit +\beforetitleunit=1ex\@plus.3ex\@minus.06ex +\newskip\aftertitleunit +\aftertitleunit=1ex\@plus.1ex + +\newdimen\ttl@plus +\newdimen\ttl@minus + +\def\ttl@assign#1{% + \@ifstar + {\ttl@assign@i{#1}}% + {\ttl@assign@d{#1}}} + +\def\ttl@assign@i#1#2\relax#3{% + \ttl@plus\z@ + \ttl@minus\z@ + \afterassignment\ttl@assign@ii + \dimen@\the#3, % <- space + #1 = #2\dimen@ + plus #2\ttl@plus + minus #2\ttl@minus} + +\def\ttl@assign@ii#1 {% <- space + \if#1,\else\afterassignment\ttl@assign@ii\fi + \csname ttl@\string#1\endcsname} + +\def\ttl@assign@d#1#2\relax#3{\setlength#1{#2}} + +% To be used with \v/vspace to make them calc-savvy + +\def\ttl@calc#1#2{% + {\setlength\@tempskipa{#2}% + #1\@tempskipa}} + +\def\ttl@calcneg#1#2{% + {\setlength\@tempskipa{#2}% + #1{-\@tempskipa}}} + +% Gets from ttls@ and passes the spacing parameters: + +\def\ttl@startargs#1#2{% Get the first arguments, with the spacing + \@ifundefined{ttlp@#2}% + {\let\ttl@key@page\@empty}% + {\ttlp@fetch{#2}}% + \begingroup + \def\ttl@b{ttls@#2}% + \edef\ttl@key@numberless{\ifttl@label//\else/*\fi}% + \def\ttl@a##1{\csname ttl@key@##1\endcsname}% Used as elt in try + \ttl@trylist + \xdef\ttl@b{\ttl@c}% + \endgroup + \ifx\ttl@b\@empty + \PackageError{titlesec}{Format/spacing not found}% + {I was unable to find the format corresponding to #2.\MessageBreak + Maybe you haven't set it with \string\titleformat\space and + \string\titlespacing} + \fi + \expandafter#1\ttl@b{#2}} + +% Used in ttl@select + +\def\ttl@savefn#1[#2]#3{% + \ifcase#1% + \footnotemark[#2]% + \gdef\ttl@fn{\footnotetext[#2]{#3}}% + \else + \footnotemark + \gdef\ttl@fn{\footnotetext{#3}}% + \fi} + +\def\ttl@nest@error{% + \PackageError{titlesec}{Nested titles}{Titles must not be nested}} + +\def\ttl@hmode@error{% + \PackageError{titlesec}{Entered in horizontal mode} + {The argument cannot contain horizontal material\MessageBreak + such as text, \string\noindent, \string\makebox, etc.}} + +% \ttl@select not only selects the right version to be +% used. It also take steps to ensure that a mark +% is not lost inside a box by saving it into \ttl@mk, +% which in turn is used by the sect and chap commands. + +\newif\ifttl@explicit + +\def\ttl@gmk#1{\gdef\ttl@mk{#1}} + +\def\ttl@select#1#2#3#4{% + \ttl@Hy@saveanchor + \global\let\ttl@mk\@empty % global because of rigidchapters + \global\let\ttl@fn\@empty + \begingroup + \if@inlabel\else % Keep item's \everypar + \everypar{\setbox\z@\lastbox\strut}% + \fi + \let\ttl@straight@i\ttl@nest@error + \let\ttl@top@i \ttl@nest@error + \let\ttl@part@i \ttl@nest@error + \let\ttl@page@i \ttl@nest@error + \let\ttl@newpage\newpage + \def\newpage{\ttl@savewrite\ttl@newpage}% + \def\markboth##1##2{\protect\ttl@gmk{\protect\markboth{##1}{##2}}}% + \def\markright##1{\protect\ttl@gmk{\protect\markright{##1}}}% + \def\@mkboth##1##2{\protect\ttl@gmk{\protect\@mkboth{##1}{##2}}}% + \def\footnote{\@ifnextchar[% + {\ttl@savefn\z@}{\ttl@savefn\@ne[]}}% + \edef\ttl@key@numberless{\ifttl@label//\else/*\fi}% + \def\ttl@b{ttlf@#1}% + \def\ttl@a##1{\csname ttl@key@##1\endcsname}% Used as elt in try + \ttl@trylist + \ifttl@explicit + \def\ttl@passexplicit{\ttl@case{#4}}% + \ttl@c{#4}{#2}{#3}{}% ttl@c is returned by ttl@try with ttlf@... + \else + \let\ttl@passexplicit\ttl@case + \ttl@c{#2}{#3}{#4}% ttl@c is returned by ttl@try with ttlf@... + \fi + \endgroup} + +\let\ttl@savewrite\@empty + +\def\ttl@finmarks{% + \ttl@savewrite + \ttl@mk % Contains a possible mark, returned by \ttl@select + \ttl@fn} % And a footnote + +\def\ttl@try#1{% + \edef\ttl@c{#1}% #1 is a list in the form \ttl@a{key}\ttl@a{key} + \@ifundefined{\ttl@b\ttl@c}{}{% + \edef\ttl@c{\expandafter\noexpand\csname\ttl@b\ttl@c\endcsname}% + \def\ttl@a##1{\csname ttl@extra@##1\endcsname}% + #1% + \let\ttl@try\@gobble}} % locally modified to `break' testings + +% \ttl@write writes marks and toc. tocdepth is taken care of when +% the toc is typesetted and not here. Used always through +% ttl@savewrite, which is reset to \@empty to avoid duplicated +% calls. + +\def\ttl@write#1#2{% + \ttl@blinemarks + \csname#1mark\endcsname{#2}% + \def\ttl@a{\protect\numberline{\@nameuse{the#1}}}% + \@nameuse{ttl@toc#1}% eg, \ttl@tocpart modifies \ttl@a + \ttl@addcontentsline{#1}{#2}% Depends on toctitles, uses \ttl@a + \ttl@elinemarks + \global\ttl@toclabelfalse + \global\let\ttl@savewrite\@empty} + +\newif\ifttl@premark % to be used in ttlps.def +\ttl@premarkfalse + +\def\ttl@premark#1#2{% + \protected@xdef\ttl@prevmarks{\ttl@marks}% + \ttl@blinemarks + \csname#1mark\endcsname{#2}% + \ttl@elinemarks + \gdef\ttl@prevmarks{\ttl@marks}} + +% Must be preceded by a default \ttl@savewrite, which is used +% in starred variants--\@empty in top and straight classes. +% In straight class, it is preceded by the setting of +% prev marks to provide a "fixed" top mark. Otherwise, +% the default prev mark (= curr mark) is used (restored +% after ttl@labelling in straight). This is the command +% to be hacked if you want to change the behaviour of +% starred variants. + +\def\ttl@labelling#1#2{% + \let\ttl@Hy@saveanchor\@empty + \ifttl@label % 1st - if star + \def\ttl@savewrite{\ttl@write{#1}{#2}}% + \@nameuse{ttl@#1label}% eg, sets if mainmatter in chapter. + \ifttl@label % 2nd - eg, if not main matter + \ifnum\@nameuse{ttll@#1}>\c@secnumdepth\relax + \ttl@labelfalse % 3rd - if too deep + \else + \ttl@Hy@refstepcounter{#1}% + \@nameuse{ttl@#1out}% + \fi + \fi + \fi + \let\ifttl@toclabel\ifttl@label + \ifx\ttl@savewrite\@empty\else % If marks + \ifttl@ps + \ifttl@premark + \global\ttl@premarkfalse + \else % if no \pretitlemark + \ttl@premark{#1}{#2}% + \fi + \fi + \ifttl@label\else\ttl@Hy@steplink{#1}\fi + \fi} + +% Executed by ttl@labelling if the name of section is chapter: + +\def\ttl@chapterlabel{\if@mainmatter\else\ttl@labelfalse\fi} + +% Executed by ttl@labelling if chapter has a number. Note +% you can define messages for other sectioning levels (eg, +% \ttl@sectionout). + +\def\ttl@chapterout{\typeout{\chaptertitlename\space\thechapter.}} + +% Straight class +% ~~~~~~~~~~~~~ +% Default for nobottomtitles. Changed by nobottomtitles* + +\def\ttl@addstretch{\advance\@tempskipa-\pagestretch} + +% 1:name 2:level 3:indent 4:before 5:after 6:afind [7]:cap 8:title +% The second argument of ttl@sect is the level, which +% is empty if the star version is used. In this case +% neither the toc nor the marks are written. + +\def\ttl@straight@i#1[#2]#3{% + \def\@currentlabelname{#2}% for nameref + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \let\ttl@savewrite\@empty + \def\ttl@savetitle{#3}% + \gdef\thetitle{\csname the#1\endcsname}% + \if@noskipsec \leavevmode \fi + \par + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@straight@ii{#1}{#3}} + +% 1:left 2:right 3:before 4:after 5:afterindent 6:name 7:title + +\def\ttl@straight@ii#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \@ifundefined{ttl@ps@#6}{}% + {\PackageWarning{titlesec}{Page style in straight class ignored}}% + \if@nobreak + \ttl@titlespace{\@tempskipa}% + \else + \@ifundefined{#6break}% + {\addpenalty{\@secpenalty}}% + {\csname#6break\endcsname}% + \addvspace{\@tempskipa}% + \ifdim\bottomtitlespace<\z@ + \else + \begingroup + \@tempskipb\pagegoal + \@tempskipa\pagegoal + \ttl@addstretch % \relax if nobottomtitle* + \advance\@tempskipa-\bottomtitlespace\relax % not a register + \pagegoal\@tempskipa + \def\@textbottom{\vskip\z@\@plus.0001fil}% + \penalty9999 + \pagegoal\@tempskipb + \endgroup + \fi + \fi + \@afterindenttrue + \ifcase#5 \@afterindentfalse\fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@select{#6}{#1}{#2}{#7}% + \ttl@finmarks + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}% + \if@noskipsec + \global\@nobreakfalse + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + \clubpenalty\@M + \hskip-\parindent + \begingroup + \@svsechd\unskip{\hspace{\@tempskipb}}% + \endgroup + \else + \clubpenalty\@clubpenalty\everypar{}% + \fi}% + \else + \par\nobreak + \vspace{\@tempskipb}% + \@afterheading + \fi + \ignorespaces} + +% Part class +% ~~~~~~~~~~ + +\providecommand\partmark[1]{\markboth{}{}} + +\def\ttl@part@i#1[#2]#3{% + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \ifx\ttl@notocparts\@undefined + \def\ttl@savewrite{\ttl@write{#1}{#3}}% Not #2! + \else + \let\ttl@savewrite\@empty + \fi + \def\ttl@savetitle{#3}% + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@part@ii{#1}{#3}} + +\def\ttl@part@ii#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \vspace*{\@tempskipa}% + \@ifundefined{ttl@ps@#6}{}% + {\PackageWarning{titlesec}{Page style in part class ignored}}% + \global\@afterindenttrue + \ifcase#5 \global\@afterindentfalse \fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@select{#6}{#1}{#2}{#7}% + \ttl@finmarks + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}% + \par\nobreak + \vspace{\@tempskipb}% + \@afterheading} + +% Page class +% ~~~~~~~~~~ + +\def\ttl@page@i#1[#2]#3{% + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \ifx\ttl@notocparts\@undefined + \def\ttl@savewrite{\ttl@write{#1}{#3}}% Not #2! + \else + \let\ttl@savewrite\@empty + \fi + \def\ttl@savetitle{#3}% + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@page@ii{#1}{#3}} + +\def\ttl@page@ii#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \if@openright + \cleardoublepage + \else + \clearpage + \fi + \@ifundefined{ttl@ps@#6}% + {\thispagestyle{plain}}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \vspace*{\@tempskipa}% + \@afterindenttrue + \ifcase#5 \@afterindentfalse\fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@select{#6}{#1}{#2}{#7}% + \ttl@finmarks + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}% + \vspace{\@tempskipb}% + \newpage + \if@twoside + \if@openright + \null + \@ifundefined{ttl@ps@#6}% + {\thispagestyle{empty}}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi + \ignorespaces} + +% Top class and some makechapterhead stuff +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% +% \ttl@mkchap is the new make(s)chapterhead. + +\def\ttl@mkchap#1#2#3#4#5#6#7{% + \gdef\ttl@savemark{\csname#6mark\endcsname{#7}}% + \let\ttl@savewrite\@empty + \let\ttl@Hy@saveanchor\@empty + \@ifundefined{ttl@ps@#6}{}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \let\ifttl@toclabel\ifttl@label + \ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}} + +% But \ttl@mkchap@i is used by both makechapterhead and +% the top class. + +\def\ttl@mkchap@i#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \vspace*{\@tempskipa}% + \global\@afterindenttrue + \ifcase#5 \global\@afterindentfalse\fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@topmode{\@tempskipb}{% + \ttl@select{#6}{#1}{#2}{#7}}% + \ttl@finmarks % Outside the box! + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}} + +\def\ttl@top@i#1[#2]#3{% + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \let\ttl@savewrite\@empty + \def\ttl@savetitle{#3}% + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@top@ii{#1}{#3}} + +\def\ttl@top@ii#1#2#3#4#5#6#7{% + \@ifundefined{#6break}% + {\if@openright + \cleardoublepage + \else + \clearpage + \fi}% + {\csname#6break\endcsname}% + \@ifundefined{ttl@ps@#6}% + {\thispagestyle{plain}}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \global\@topnum\z@ + \@ifundefined{#6tolists}% + {\addtocontents{lof}{\protect\ttl@tocsep}% + \addtocontents{lot}{\protect\ttl@tocsep}} + {\@nameuse{#6tolists}}% + \if@twocolumn + \@topnewpage[\ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}]% + \else + \ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}% + \@afterheading + \fi + \ignorespaces} + + +% \def\ttl@noskipsectrue{% +% \if@noskipsec +% \PackageError{titlesec}{Invalid shape for top class}% +% {The selected shape only makes sense when merged into\MessageBreak +% a paragraph. That is impossible in the top class}% +% \else + +\newcommand\chaptertitlename{\@chapapp} +\def\ttl@tocsep{\addvspace{10\p@}} + +% +-----------------+ +% | S H A P E S | +% +-----------------+ +% +% % Reformatting Titles: Interface +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +% The surrounding space is stored in a macro +% named \ttls@
whose content is +% {left}{right}{before}{after}{afterindent}. +% But if there is the page key, the name is +% \ttls@
/ + +\newcommand\titlespacing{% + \@ifstar{\ttl@spacing@i{\z@}}{\ttl@spacing@i{\@ne}}} + +\def\ttl@spacing@i#1#2#3#4#5{% + \ttl@getkeys{#2}{titlesec}% + \@ifnextchar[{% + \ttl@spacing@ii{#1}{#3}{#4}{#5}% + }{% + \ttl@spacing@ii{#1}{#3}{#4}{#5}[\z@]}} + +\def\ttl@spacing@ii#1#2#3#4[#5]{% + \expandafter\def\csname ttls@\ttl@a\endcsname + {{#2}{#5}{#3}{#4}{#1}}} + +% The section name is built in \ttl@a. +% The format is stored in a macro named \ttlf@
, +% or \ttlf@
/ if there is the page spec, +% or \ttlf@.../* if numberless is true +% whose content is +% \ttl@{format}{label}{sep}{before}{after} + +\newtoks\ttl@toksa + +\newcommand\titleformat{% + \@ifstar{\ttl@format@s}% + {\ttl@format@i}} + +\def\ttl@format@s#1#2{% + \edef\ttl@a{\expandafter\@gobble\string#1}% + \@ifundefined{ttlf@\ttl@a}% + {\PackageError{titlesec}{Not allowed in `easy' settings} + {The sectiong command you are trying to redefine\MessageBreak + is not handled by the starred variant (eg, \string\part)}}{} + \expandafter\expandafter\expandafter + \ttl@format@si\csname ttlf@\ttl@a \endcsname + {#2}} + +\def\ttl@format@si#1#2#3#4#5#6#7{% + \@namedef{ttlf@\ttl@a}{#1{#7}{#3}{#4}{#5}{#6}}} + +\def\ttl@format@i#1{% + \@ifnextchar[{\ttl@format@ii{#1}}{\ttl@format@ii{#1}[hang]}} + +\def\ttl@format@ii#1[#2]#3#4#5#6{% + \ttl@getkeys{#1}{titlesec}% + \ttl@toksa{{#3}{#4}{#5}{#6}}% Save arguments + \@ifnextchar[{% + \ttl@format@iii{#2}% + }{% + \ttl@format@iii{#2}[]}} + +% First, we get the shape -- if not defined it loads +% the corresponding file. + +\def\ttl@format@iii#1[#2]{% + \@ifundefined{ttlh@#1}{% + \begingroup + \makeatletter + \InputIfFileExists{#1.tss}{}{% + \PackageError{titlesec}{Unknown shape}% + {Shapes are defined in files with extension tss\MessageBreak + Either you have misspelled the shape\MessageBreak + or there is no a #1.tss file}}% + \endgroup}{}% + \@temptokena{#2}% + \ifttl@explicit + \edef\ttl@b{% + \def\expandafter\noexpand\csname ttlf@\ttl@a\endcsname####1% + {\expandafter\noexpand\csname ttlh@#1\endcsname + \the\ttl@toksa{\the\@temptokena}}}% + \else + \edef\ttl@b{% + \def\expandafter\noexpand\csname ttlf@\ttl@a\endcsname + {\expandafter\noexpand\csname ttlh@#1\endcsname + \the\ttl@toksa{\the\@temptokena}}}% + \fi + \ttl@b + \csname ttl@compat\ttl@a\endcsname} + +% Styles +% ~~~~~~ + +% 1:global 2:label 3:sep 4:style 5:after 6:left 7:right 8:title +% \ttl@ and \ttlh@ take the following eight +% arguments: +% {format}{label}{sep}{before}{after}{left}{right}{title} +% where before and after refer to the format. +% With the option explicit, #4 contains the title and #8 is +% empty. + +\def\ttlh@display#1#2#3#4#5#6#7#8{% + \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@beginlongest + #1\ifhmode\ttl@hmode@error\fi + \ttl@glcmds + \parindent\z@ + \ifttl@label + {#2\strut\@@par}\nobreak\ttl@calc\vspace{#3}% + \fi + #4{#8}% + \kern\z@\strut\@@par + \nobreak\ttl@midlongest#5\@@par + \ttl@endlongest} + +\def\ttlh@hang#1#2#3#4#5#6#7#8{% + \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@beginlongest + #1{\ifhmode\ttl@hmode@error\fi + \ttl@glcmds + \parindent\z@ + \begingroup + \ifttl@label + \sbox\z@{#2\strut\ttl@calc\hspace{#3}}% + \hangindent\wd\z@ + \noindent\box\z@ + \fi + #4{#8}% + \kern\z@\strut\@@par + \endgroup + \nobreak\ttl@midlongest#5\@@par}% + \ttl@endlongest} + +\def\ttlh@runin#1#2#3#4#5#6#7#8{% + \global\@noskipsectrue + \gdef\ttl@makeline##1{##1}% + \ttl@changecentercr + #1{\ifhmode\ttl@hmode@error\fi + \global\sbox\ttl@box{% + \ttl@calc\hspace{#6}% + \ifttl@label{\strut#2}\ttl@calc\hspace{#3}\fi + #4{#8}#5\unskip}}% + \gdef\@svsechd{\unhbox\ttl@box}} + +% +-----------------+ +% | T O O L S | +% +-----------------+ +% +% calcwidth +% ~~~~~~~~~ +% Implemented after code from soul (but much modified...) + +\newdimen\titlewidth +\newdimen\titlewidthlast +\newdimen\titlewidthfirst + +\let\ttl@glcmds\relax +\let\ttl@beginlongest\@empty +\let\ttl@midlongest\@empty +\let\ttl@endlongest\@empty +\let\iftitlemeasuring\@secondoftwo + +\def\ttl@xbeginlongest#1\ttl@endlongest{% + \titlewidth\z@ + \titlewidthlast\z@ + \let\iftitlemeasuring\@firstoftwo + \setbox\ttl@box\vbox{% + \def\ttl@glcmds{% + \def\\{\@ifstar{\@ifnextchar[{\ttl@bs}{\newline}}% + {\@ifnextchar[{\ttl@bs}{\newline}}}% + \def\ttl@bs[####1]{\newline}% + \let\@centercr\\% + \def\ttl@midlongest####1\@@par{}% Very dirty... + \advance\rightskip 1\leftskip plus 1fil + \leftskip=\z@}% + #1}% + \let\iftitlemeasuring\@secondoftwo + \ttl@boxprocess + #1} + +\def\ttl@boxprocess{% + \setbox\ttl@box=\vbox{% + \unvcopy\ttl@box + \unskip\unpenalty + \global\setbox\@ne=\lastbox}% + \ifvoid\@ne + \else + \setbox\tw@=\hbox{\hskip-\leftskip\unhbox\@ne\hskip-\rightskip}% + \titlewidthfirst\wd\tw@ + \ifdim\titlewidth<\titlewidthfirst + \titlewidth\titlewidthfirst + \fi + \ifdim\titlewidthlast=\z@ + \titlewidthlast\titlewidthfirst + \fi + \expandafter\ttl@boxprocess + \fi} + +% Rules +% ~~~~~ + +\providecommand\titleline{% + \@ifstar{\ttl@line@i{\hb@xt@\titlewidth}}% + {\ttl@line@i{}}} + +\def\ttl@line@i#1{% + \@ifnextchar[{\ttl@line{#1}}{\ttl@line{#1}[s]}} + +\def\ttl@line#1[#2]#3{% + \vskip\topskip + \hrule \@height \z@ + \nobreak + \vskip-\topskip + \begingroup + \parindent\z@ + \everypar{}% + \leftskip\z@ + \rightskip\z@ % #1 is either \hb@xt@\titlewidth or empty: + \@makebox[\hsize][#2]{\ttl@makeline{#1{#3}}}% + \par + \endgroup + \hrule height \z@ + \nobreak} + +\providecommand\titlerule{\@ifstar{\ttl@row}{\ttl@rule}} + +\let\ttl@leaders\xleaders % For titletoc compatibility + +\def\ttl@row{\@ifnextchar[{\ttl@row@i}{\ttl@row@i[\wd\z@]}} +\def\ttl@row@i[#1]#2{% + \ifvmode\expandafter\titleline\fi + {\sbox\z@{#2}% + \ttl@calcneg\hspace{#1}% + \hskip\wd\z@ + \ttl@leaders\hb@xt@#1{\hss\box\z@}% + \hfill\kern\z@}} + +\def\ttl@rule{\@ifnextchar[{\ttl@rule@i}{\ttl@rule@i[.4\p@]}} +\def\ttl@rule@i[#1]{% + \ifvmode\expandafter\titleline\fi + {\leaders\hrule height #1\hfill\kern\z@}} + +% Par shapes and space +% ~~~~~~~~~~~~~~~~~~~~ + +\providecommand\filright{% + \gdef\ttl@filleft##1{\hskip##1}% + \gdef\ttl@filright##1{\hfill}% + \let\\\@centercr + \advance\rightskip\z@ \@plus 1fil\relax} +\providecommand\filleft{% + \gdef\ttl@filleft##1{\hfill}% + \gdef\ttl@filright##1{\hskip##1}% + \let\\\@centercr + \advance\leftskip\z@ \@plus 1fil + \parfillskip\z@} +\providecommand\filcenter{\filleft\filright + \gdef\ttl@filleft##1{\hfill}} +\providecommand\fillast{% + \gdef\ttl@filleft##1{\hfill}% + \gdef\ttl@filright##1{\hfill}% + \let\\\@centercr + \filleft\advance\rightskip\z@ \@plus -1fil + \parfillskip\z@ \@plus 2fil\relax} +\newcommand\filinner{% + \if@twoside + \ifodd\count\z@\filleft\else\filright\fi + \else + \filleft + \fi} +\newcommand\filouter{% + \if@twoside + \ifodd\count\z@\filright\else\filleft\fi + \else + \filright + \fi} + +\newcommand\wordsep{\fontdimen\tw@\font \@plus + \fontdimen\thr@@\font \@minus \fontdimen4\font} + +% +-----------------+ +% | O P T I O N S | +% +-----------------+ + + +\DeclareOption{pagestyles}{\let\sectiontitle\@empty} +\DeclareOption{extramarks}{\let\ttl@fetchmark\@empty} +\DeclareOption{floatps}{% + \ifx\sectiontitle\@empty + \let\ttl@replace\space + \else + \PackageWarning{titlesec}{Ignoring `floatps' without + `pagestyles'. This option is now deprecated.}% + \fi} +\DeclareOption{psfloats}{% + \ifx\sectiontitle\@empty + \let\ttl@replace\@empty + \else + \PackageWarning{titlesec}{Ignoring `psfloats' without + `pagestyles'}% + \fi} + +\DeclareOption{loadonly}{\let\ttl@extract\@empty} + +\DeclareOption{outermarks}{% + \def\ttl@titlemarks{\outertitlemarks}} +\DeclareOption{topmarks}{ + \def\ttl@titlemarks{\toptitlemarks}} +\DeclareOption{botmarks}{% + \def\ttl@titlemarks{\bottitlemarks}} +\DeclareOption{innermarks}{% + \def\ttl@titlemarks{\innertitlemarks}} + +\DeclareOption{footmarks}{} % Backward compat + +\DeclareOption{explicit}{\ttl@explicittrue} + +\DeclareOption{clearempty}{% + \def\cleardoublepage{% + \clearpage{\ps@empty\if@twoside\ifodd\c@page\else + \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}}} + +\DeclareOption{rigidchapters}{% + \def\ttl@topmode#1#2{\vbox to #1{#2\vfil}}% + \def\ttl@chapafter{.26\textheight}} +\DeclareOption{rubberchapters}{% + \def\ttl@topmode#1#2{{#2}\ttl@calc\vspace{#1}}% + \def\ttl@chapafter{40\p@}} + +\DeclareOption{bottomtitles}{% + \def\bottomtitlespace{-1\p@}} +\DeclareOption{nobottomtitles}{% + \def\bottomtitlespace{.2\textheight}} +\DeclareOption{nobottomtitles*}{% + \let\ttl@addstretch\relax + \def\bottomtitlespace{.2\textheight}} + +\DeclareOption{calcwidth}{% + \let\ttl@beginlongest\ttl@xbeginlongest} + +\DeclareOption{aftersep}{% + \let\ttl@titlespace\@gobble} +\DeclareOption{largestsep}{% + \let\ttl@titlespace\addvspace} + +\DeclareOption{oldparttoc}{% + \def\ttl@tocpart{\def\ttl@a{\thepart\hspace{1em}}}} +\DeclareOption{newparttoc}{% + \let\ttl@tocpart\relax} +\DeclareOption{notocpart*}{% + \let\ttl@notocparts\@empty} + +\DeclareOption{rm}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\rmfamily}} +\DeclareOption{sf}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\sffamily}} +\DeclareOption{tt}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\ttfamily}} +\DeclareOption{md}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\mdseries}} +\DeclareOption{bf}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\bfseries}} +\DeclareOption{up}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\upshape}} +\DeclareOption{it}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\itshape}} +\DeclareOption{sl}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\slshape}} +\DeclareOption{sc}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\scshape}} + +\DeclareOption{big}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\Huge\or\Large\or\large + \or\normalsize\or\or\or\huge\fi}} +\DeclareOption{medium}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\huge\or\Large\or\large + \or\normalsize\or\or\or\LARGE\fi}} +\DeclareOption{small}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\LARGE\or\large + \or\normalsize\or\normalsize\or\or\or\Large\fi}} +\DeclareOption{tiny}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\large\or\normalsize\or + \normalsize\or\normalsize\or\or\or\normalsize\fi}} + +\DeclareOption{raggedleft}{% + \gdef\ttl@fil{\filleft}} +\DeclareOption{center}{% + \gdef\ttl@fil{\filcenter}} +\DeclareOption{raggedright}{% + \gdef\ttl@fil{\filright}} + +\DeclareOption{uppercase}{% + \gdef\ttl@case{\MakeUppercase}} + +\DeclareOption{compact}{% + \gdef\ttl@space{1}% + \gdef\ttl@chapafter{30\p@}} + +% Deprecated. To be remmoved in a major upgrade (3.0) +\DeclareOption{indentfirst}{% + \gdef\@afterindentfalse{\let\if@afterindent\iftrue}% + \@afterindenttrue + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\@ne}}{\ttl@spacing@i{\@ne}}}} +\DeclareOption{nonindentfirst}{% + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\z@}}{\ttl@spacing@i{\z@}}}} + +% New names +\DeclareOption{indentafter}{% + \gdef\@afterindentfalse{\let\if@afterindent\iftrue}% + \@afterindenttrue + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\@ne}}{\ttl@spacing@i{\@ne}}}} +\DeclareOption{noindentafter}{% + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\z@}}{\ttl@spacing@i{\z@}}}} + +% newlinetospace +\let\ttl@blinemarks\relax +\let\ttl@elinemarks\relax + +\DeclareRobustCommand\ttl@linetosp{% + \@ifstar{\ttl@linetosp@i}{\ttl@linetosp@i}}% + +\def\ttl@linetosp@i{% + \ifdim\lastskip>\z@\else\space\fi + \ignorespaces} + +\DeclareOption{newlinetospace}{% + \def\ttl@blinemarks{% + \let\ttl@e\\% + \def\\{\ttl@linetosp}}% + \def\ttl@elinemarks{\let\\\ttl@e}}% + +% toctitles +\def\ttl@addcontentsline#1#2{% + \addcontentsline{toc}{#1}{\ifttl@toclabel\ttl@a\fi#2}% + \nobreak} + +\DeclareOption{toctitles}{% + \def\ttl@addcontentsline#1#2{% + \addcontentsline{toc}{#1}{\ifttl@toclabel\ttl@a\fi\ttl@savetitle}% + \nobreak}} + +% pageatnewline + +\def\ttl@changecentercr{% + \let\ttl@centercr\@centercr + \def\@centercr{\@ifstar{\ttl@centercr*}{\ttl@centercr*}}} + +\DeclareOption{pageatnewline}{\let\ttl@changecentercr\relax} + +\def\ttl@fonts{} + +\ExecuteOptions{rubberchapters,bottomtitles,aftersep,oldparttoc,% + innermarks} + +\ProcessOptions + +% +-----------------+ +% | H Y P E R R E F | +% +-----------------+ +% +% These two commands are provided by hyperref. But if they +% are not defined at \begin{document} hyperref has not been +% loaded or it is an old version. + +\AtBeginDocument{% + \ifx\ttl@Hy@steplink\@undefined + \let\ttl@Hy@steplink\@gobble + \let\ttl@Hy@refstepcounter\refstepcounter + \fi} + +% +-----------------+ +% | PAGE STYLES | +% +-----------------+ +% +% This is generic: + +\newcommand\assignpagestyle[2]{% + \@namedef{ttl@ps@\expandafter\@gobble\string#1}{#2}} + +% Old pagestyles +% ~~~~~~~~~~~~~~ + +\providecommand\newpagestyle{% + \let\ttl@compatps\@empty % marks the ``old interface'' + \makeatletter + \edef\ttl@d{% + \noexpand\input{ttlps.def}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \newpagestyle} + +\providecommand\renewpagestyle{% + \let\ttl@compatps\@empty % marks the ``old interface'' + \makeatletter + \edef\ttl@d{% + \noexpand\input{ttlps.def}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \renewpagestyle} + +\providecommand\widenhead{% + \let\ttl@compatps\@empty % marks the ``old interface'' + \makeatletter + \edef\ttl@d{% + \noexpand\input{ttlps.def}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \widenhead} + +% New pagestyles +% ~~~~~~~~~~~~~~ + +\@ifundefined{sectiontitle}{}{\input{ttlps.def}} + +% +-----------------+ +% | C O M P A T | +% +-----------------+ +% Easy setup, i.e., that of package options, is +% taken care of, if necessary. + +\renewcommand\secdef[2]{% + \@ifstar + {\ttl@labelfalse + #2} + {\ttl@labeltrue + \ifx#1\@chapter + \if@mainmatter\else\ttl@labelfalse\fi + \ifnum\ttll@chapter>\c@secnumdepth\ttl@labelfalse\fi + \else\ifx#1\@part + \ifnum\ttll@part>\c@secnumdepth\ttl@labelfalse\fi + \fi\fi + \let\ifttl@toclabel\ifttl@label + \@dblarg{#1}}} + +\@ifundefined{ttl@extract}{}{\endinput} + +\newcommand\titlelabel[1]{% + \def\@seccntformat##1{#1}} + +\expandafter\ifx\csname chapter\endcsname\relax + + \def\ttl@compatpart{\titleclass{\part}{part}\relax} + +\else + + \def\ttl@compatchapter{% + \def\@makechapterhead{% + \ttl@labeltrue + \if@mainmatter\else\ttl@labelfalse\fi + \ifnum\ttll@chapter>\c@secnumdepth\ttl@labelfalse\fi + \ttl@startargs\ttl@mkchap{chapter}}% + \def\@makeschapterhead{% + \ttl@labelfalse + \if@mainmatter\else\ttl@labelfalse\fi + \ifnum\ttll@chapter>\c@secnumdepth\ttl@labelfalse\fi + \ttl@startargs\ttl@mkchap{chapter}}} + + \def\ttl@compatpart{\titleclass{\part}{page}\relax} + +\fi + +\def\ttl@@extract#1\@startsection#2#3#4#5#6#7#8{% + \@tempskipa=#5 + \@tempskipb=#6 + \ifdim\@tempskipa<\z@ + \toks@{\titlespacing*#8{#4}}% + \@tempskipa-\@tempskipa + \else + \toks@{\titlespacing#8{#4}}% + \fi + \@ifundefined{ttl@space}{}{% + \ttl@assign\@tempskipa*\ttl@space\relax\beforetitleunit}% + \ifdim\@tempskipb<\z@ + \if@tempswa + \titleformat#8[runin]% + {\ttl@fonts\ttl@sizes{#3}}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \else + \titleformat#8[runin]% + {#7}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \fi + \@tempskipb-\@tempskipb + \else + \if@tempswa + \titleformat#8% + {\ttl@fil\ttl@fonts\ttl@sizes{#3}}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \else + \titleformat#8% + {#7}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \fi + \@ifundefined{ttl@space}{}{% + \ttl@assign\@tempskipb*\ttl@space\relax\aftertitleunit}% + \fi + \edef\ttl@a{\the\toks@{\the\@tempskipa}{\the\@tempskipb}} + \ttl@a} + +\def\ttl@extract#1{% + \expandafter\in@\expandafter\@startsection\expandafter{#1}% + \ifin@ + \expandafter\ttl@@extract#1#1% + \else + \PackageWarningNoLine{titlesec}% + {Non standard sectioning command detected\MessageBreak + Using default spacing and no format} + \titlespacing*#1{\z@}{*3}{*2}% + \fi} + +\@tempswafalse + +\ifx\ttl@fonts\@empty + \def\ttl@fonts{\bfseries} +\else + \@tempswatrue +\fi + +\expandafter\ifx\csname ttl@sizes\endcsname\relax + \gdef\ttl@sizes#1{\ifcase#1\relax\Huge\or\Large\or\large + \or\normalsize\or\or\or\huge\fi} +\else + \@tempswatrue +\fi + +\expandafter\ifx\csname ttl@fil\endcsname\relax + \let\ttl@fil\@empty +\else + \@tempswatrue +\fi + +\expandafter\ifx\csname ttl@case\endcsname\relax + \let\ttl@case\@firstofone +\else + \@tempswatrue +\fi + +\if@tempswa + + \expandafter\ifx\csname chapter\endcsname\relax\else + \titleformat\chapter[display]% + {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6} + {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit} + \fi + +\fi + +\ttl@extract\section +\ttl@extract\subsection +\ttl@extract\subsubsection +\ttl@extract\paragraph +\ttl@extract\subparagraph + +\let\ttl@extract\@undefined +\let\ttl@@extract\@undefined + +\def\ttl@toplevel{part} + +\expandafter\ifx\csname chapter\endcsname\relax + + \@namedef{ttll@part}{0} + \titleclass{\section}{straight}[\part] + + \titlespacing*{\part} + {\z@} + {4ex} + {3ex} + +\else + + \let\ttl@save@mkchap\@makechapterhead + \let\ttl@save@mkschap\@makeschapterhead + + \def\@makechapterhead#1{% + \gdef\ttl@savemark{\chaptermark{#1}}% + \ttl@save@mkchap{#1}% + \@ifundefined{ttl@ps@chapter}{}% + {\thispagestyle{\@nameuse{ttl@ps@chapter}}}} + + \def\@makeschapterhead#1{% + \gdef\ttl@savemark{\chaptermark{#1}}% + \ttl@save@mkschap{#1}% + \@ifundefined{ttl@ps@chapter}{}% + {\thispagestyle{\@nameuse{ttl@ps@chapter}}}} + + \@namedef{ttll@part}{-1} + \@namedef{ttlss@part}{chapter} + \@namedef{ttll@chapter}{0} + \titleclass{\section}{straight}[\chapter] + +% The following is unoperant, unless when \chapter / \part +% format is redefined + + \titlespacing*{\part} + {\z@} + {\z@\@plus1fil} + {\z@\@plus1fil} + + \titlespacing*\chapter + {\z@}% + {50\p@}% + {\ttl@chapafter}% + +\fi + +\titleclass{\subsection} {straight}[\section] +\titleclass{\subsubsection}{straight}[\subsection] +\titleclass{\paragraph} {straight}[\subsubsection] +\titleclass{\subparagraph} {straight}[\paragraph] + +\endinput diff --git a/ThirdParty/Ert/python/docs/latex/upquote.sty b/ThirdParty/Ert/python/docs/latex/upquote.sty new file mode 100644 index 0000000000..6b9d754f2a --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/upquote.sty @@ -0,0 +1,40 @@ +%% +%% This is file `upquote.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% upquote.dtx (with options: `package') +%% +%% Copyright (C) 2000 by Michael A. Covington +%% Copyright (C) 2003 by Frank Mittelbach +%% Copyright (C) 2012 by Markus Kuhn (current maintainer) +%% +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{upquote} + [2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbatim] +\newcommand\upquote@cmtt{cmtt} +\newcommand\upquote@OTone{OT1} +\ifx\encodingdefault\upquote@OTone + \ifx\ttdefault\upquote@cmtt\else\RequirePackage{textcomp}\fi +\else + \RequirePackage{textcomp} +\fi +\begingroup +\catcode`'=\active +\catcode``=\active +\g@addto@macro\@noligs + {\let'\textquotesingle + \let`\textasciigrave + \ifx\encodingdefault\upquote@OTone + \ifx\ttdefault\upquote@cmtt + \def'{\char13 }% + \def`{\char18 }% + \fi\fi} +\endgroup +\endinput +%% +%% End of file `upquote.sty'. diff --git a/ThirdParty/Ert/python/docs/latex/wrapfig.sty b/ThirdParty/Ert/python/docs/latex/wrapfig.sty new file mode 100644 index 0000000000..ea85e1b0d4 --- /dev/null +++ b/ThirdParty/Ert/python/docs/latex/wrapfig.sty @@ -0,0 +1,598 @@ +% W R A P F I G . S T Y ver 3.6 (Jan 31, 2003) +% +% Copyright (C) 1991-2003 by Donald Arseneau +% This software is released under the terms of the LaTeX Project +% public license. +% +% Environments "wrapfigure" and "wraptable" place a figure or table +% at the side of the page and wrap text around it. +% +% \begin{wrapfigure}[12]{r}[34pt]{5cm}
\end{wrapfigure} +% -- - ---- --- +% [number of narrow lines] {placement} [overhang] {width of figure} +% +% Placement is one of r, l, i, o, R, L, I, O, for right, left, +% inside, outside, (here / FLOAT). +% The figure sticks into the margin by `overhang', if given, or by the +% length \wrapoverhang, which is normally zero. +% The number of wrapped text lines is normally calculated from the height +% of the figure, but may be specified manually ("12" above). +% +% Environments similar to "wrapfigure" and "wraptable" may be easily added, +% or invoked by "\begin{wrapfloat}{float_name}" +% +% More detailed instructions are given below, following the definitions. +% Please direct any problem reports to asnd@triumf.ca + +%%%%% ----- Begin definitions ----- %%%%% + +\@ifundefined{c@WF@wrappedlines}{}{\endinput} + +\newdimen\wrapoverhang \wrapoverhang\z@ +\newdimen\WF@size +\newcount\c@WF@wrappedlines % used globally +\newbox\WF@box +\newtoks\WF@everypar +\newif\ifWF@float +\let\@@parshape\parshape +\let\WF@@everypar\everypar + +\def\wrapfloat#1{\def\@captype{#1}\@ifnextchar[\WF@wr{\WF@wr[]}} + +\def\wrapfigure{\wrapfloat{figure}} +\def\wraptable{\wrapfloat{table}} + +\def\WF@wr[#1]#2{% first two args: #1=num lines, #2=placement + \xdef\WF@wfname{wrap\@captype\space}% + \ifvoid\WF@box\else \WFclear \WF@collision \fi + \xdef\WF@place{\string`\@car#2r\@nil}% + \ifnum\lccode\WF@place=\WF@place \global\WF@floatfalse + \else \global\WF@floattrue \fi + \ifx\parshape\WF@fudgeparshape \ifWF@float\else\WF@collision\fi \else + \ifx\par\@@par \ifnum\@@parshape>\z@\WF@conflict\fi \else \WF@conflict\fi + \fi \gdef\WF@wli{#1}% + \@ifnextchar[\WF@rapt{\WF@rapt[\wrapoverhang]}} + +\def\WF@rapt[#1]#2{% final two args: #1 = overhang, #2 = width, + \gdef\WF@ovh{#1}% hold overhang for later, when \width is known + \global\setbox\WF@box\vtop\bgroup \setlength\hsize{#2}% + \ifdim\hsize>\z@ \@parboxrestore \else + \setbox\z@\hbox\bgroup \let\wf@@caption\caption \let\caption\wf@caption + \ignorespaces \fi} + +\def\wf@caption{\relax + \ifdim\hsize>\z@ \let\caption\wf@@caption \else + \unskip \egroup \hsize\wd\z@ \@parboxrestore \box\z@ \fi \caption} + +\def\endwrapfloat{% + \ifdim\hsize>\z@ \par\hrule\@width\hsize\@height\z@ % force width + \else \unskip \egroup \box\z@ \fi % or end hbox + \egroup % end the \vtop; width is known so now is "later" + \WF@floatstyhook % support float.sty + \def\width{\wd\WF@box}\setlength\wrapoverhang{\WF@ovh}% + \xdef\WF@ovh{\the\wrapoverhang}% save until wrapping + \ifdim\ht\WF@box>\topskip \ht\WF@box\z@ \fi % too much height, set flag. + \ifdim\ht\WF@box<.5\p@ % too tall (starts with \vbox) or too short + \global\setbox\WF@box\vtop{\vskip-1.4ex\unvbox\WF@box}\fi + \global\WF@size\dp\WF@box % box is guaranteed to have little height. + \global\advance\WF@size1.5\baselineskip \global\advance\WF@size\tw@\intextsep + \aftergroup\WF@startfloating % even when not really floating! + \ifWF@float\else \ifhmode + {\unskip \parfillskip\z@skip \par \vskip-\parskip}\aftergroup\noindent + \fi\fi \global\@ignoretrue} + +\let\endwrapfigure\endwrapfloat +\let\endwraptable\endwrapfloat + +% Subvert \everypar to float fig and do wrapping. Also for non-float. +\def\WF@startfloating{% + \WF@everypar\expandafter{\the\everypar}\let\everypar\WF@everypar + \WF@@everypar{\ifvoid\WF@box\else\WF@floathand\fi \the\everypar + \WF@wraphand +}} + +\def\WF@floathand{% +\ifx\parshape\WF@fudgeparshape \WF@fltmes\else + \ifx\par\@@par\ifnum\@@parshape=\z@\ifdim\hangindent=\z@ + \setbox\z@\lastbox \begingroup + \@@par \WF@@everypar{}\WF@putfigmaybe + \endgroup % start wrapping + \ifvoid\z@\else\box\z@\fi % replace indentation + \else\WF@fltmes\fi\else\WF@fltmes\fi\else\WF@fltmes\fi\fi} + +% Put fig here if it fits or if it can't float +\def\WF@putfigmaybe{% +\ifinner + \vskip-\parskip \global\WF@floatfalse + \let\pagetotal\maxdimen % kludge flag for "not top of page" +\else % outer page + \@tempdima\pagedepth % save page depth + {\advance\parskip\@tempdima\vskip-\parskip}% back up to baseline + \penalty\interlinepenalty % update pg. parameters + \@tempdimb\pagegoal \advance\@tempdimb-\pagetotal % room left on page + \ifdim\@tempdimb<\z@ % \WF@info{Page overfull already;}% + \global\WF@floatfalse + \ifdim-\@tempdimb>\pageshrink \else \pagebreak \fi + \else + \ifdim\WF@size>\@tempdimb +% \WF@info{Size \the\WF@size\space does not fit in \the\@tempdimb}% + \ifWF@float \dimen@.5\baselineskip \else \dimen@ 2\baselineskip\fi + \ifdim\pagestretch>\dimen@ \dimen@\pagestretch \fi + \ifdim\pagefilstretch>\z@ \dimen@\@tempdimb \fi + \ifdim\pagefillstretch>\z@ \dimen@\@tempdimb \fi + \advance\dimen@.5\baselineskip + \ifdim\dimen@>\@tempdimb % \WF@info{Page nearly full; can stretch}% + \global\WF@floatfalse \pagebreak + \fi + \else % \WF@info{Fits in \the\@tempdimb;}% + \global\WF@floatfalse + \fi\fi + \vskip\@tempdima\relax % (return erased page depth) +\fi +\noindent +\ifWF@float + \WF@fltmes +\else % putting here; + \WF@info{Put \WF@wfname here:}% + {\ifodd\if@twoside\c@page\else\@ne\fi % assign l/r to i/o placement + \lccode`i`l\lccode`o`r\else \lccode`i`r\lccode`o`l\fi + \xdef\WF@place{\the\lccode\lccode\WF@place}}% twice to get only l or r + \hbox to\z@{% llap or rlap depending on {l} or {r}; calc effective width + \@tempdima\wd\WF@box \@tempdimb\WF@ovh + \advance\@tempdima-\@tempdimb \advance\@tempdima\columnsep + \@tempdimb\hsize \advance\@tempdimb-\@tempdima + \xdef\WF@adjlw{\the\@tempdima}% + \ifnum `l=\WF@place % fig on left + \hss % figure overlaps space to the left + \def\@tempa{\kern\columnsep}% position to left of the gap + \else % fig on right + \@tempdima\z@ % no left indentation + \kern\@tempdimb \kern\columnsep + \def\@tempa{\hss}% figure overlaps space to the right + \fi + \ifdim\@tempdimb<\hsize + \xdef\WF@wrapil{\the\@tempdima \the\@tempdimb}% indentation and length + \xdef\WF@adjtlm{\the\@tempdima}% + \else + \xdef\WF@wrapil{\z@ \the\hsize}% + \xdef\WF@adjlw{\z@}\xdef\WF@adjtlm{\z@}% + \fi + \ifdim\pagetotal=\z@ % \WF@info{Put \WF@wfname at top of p.\thepage}% + \global\advance\WF@size-\intextsep + \else % \WF@info{Putting \WF@wfname in middle of page}% + \setbox\WF@box\hbox{\lower\intextsep\box\WF@box}% + \fi \dp\WF@box\z@ \box\WF@box \@tempa + }% end \hbox to 0pt + \aftergroup\WF@startwrapping % after the \endgroup which immediately follows +\fi} + +\def\WF@startwrapping{% + \ifx\WF@wli\@empty + {\advance\WF@size1.1\baselineskip + \divide\WF@size\baselineskip \global\c@WF@wrappedlines\WF@size}% + \else + \setcounter{WF@wrappedlines}{\WF@wli}\global\advance\c@WF@wrappedlines\@ne + \fi + \ifnum\c@WF@wrappedlines>\@ne + \let\parshape\WF@fudgeparshape \let\WF@pspars\@empty \let\WF@@par\par + \def\@setpar##1{\def\WF@@par{##1}}\def\par{\@par}\let\@par\WF@mypar + \xdef\WF@restoretol{\tolerance\the\tolerance}\tolerance9999 + \advance\linewidth-\WF@adjlw \advance\@totalleftmargin\WF@adjtlm + \fi} + +\def\WF@wraphand{% +\ifnum\c@WF@wrappedlines<\tw@ \WF@finale +\else \begingroup % Create \parshape command: + \@tempcnta\@ne \let\WF@wrapil\relax \gdef\WF@ps{}% + \@whilenum \@tempcnta<\c@WF@wrappedlines\do{% repeated indentation, length + \xdef\WF@ps{\WF@ps\WF@wrapil}\advance\@tempcnta\@ne + }\endgroup + \ifx\WF@pspars\@empty + \@@parshape\c@WF@wrappedlines \WF@ps \WF@noil + \else % use external `parshape' values to modify my parshape + \WF@modps +\fi\fi} + +\def\WF@mypar{\relax + \WF@@par % what the rest of LaTeX expects \par to be (usually \@@par) + \ifnum\@@parshape=\z@ \let\WF@pspars\@empty \fi % reset `parshape' + \global\advance\c@WF@wrappedlines-\prevgraf \prevgraf\z@ + \ifnum\c@WF@wrappedlines<\tw@ \WF@finale \fi} + +\def\WF@modps{\begingroup + \afterassignment\@tempdimb \@tempdima\WF@pspars % a=ind, b=wid + \advance\@tempdima-\WF@adjtlm \advance\@tempdimb\WF@adjlw +% \afterassignment\dimen@\advance\@tempdima\WF@wrapil +% \advance\@tempdimb\dimen@ \advance\@tempdimb-\hsize + \let\WF@wrapil\WF@pspars%{\the\@tempdima \the\@tempdimb}% + \edef\@tempb{\@@parshape\c@WF@wrappedlines \WF@ps \the\@tempdima \the\@tempdimb}% + \expandafter\endgroup\@tempb} + +\let\@@setpar\@setpar +\def\WF@noil{\z@ \hsize} +\let\WF@pspars\@empty + +\def\WF@fudgeparshape{\relax \ifnum\c@WF@wrappedlines<\tw@ \WF@finale + \else \afterassignment\WF@fudgeparshapee \fam \fi} +\def\WF@fudgeparshapee{\ifnum\fam=\@ne \expandafter \WF@parshapeee \else + \WF@conflict \@@parshape\fam \fi} +\def\WF@parshapeee#1#2{\begingroup\delimitershortfall#1% + \nulldelimiterspace#2%\advance\nulldelimiterspace\WF@adjlw + \edef\@tempa{\def\noexpand\WF@pspars{% + \the\delimitershortfall \the\nulldelimiterspace}}% + \expandafter\endgroup\@tempa \WF@wraphand} + +\def\WF@finale{\ifx\parshape\WF@fudgeparshape + \WF@restoretol \let\@setpar\@@setpar \let\par\WF@@par + \advance\linewidth\WF@adjlw \advance\@totalleftmargin-\WF@adjtlm + \WF@info{Finish wrapping text}% + \ifx\par\@@par \def\@par{\let\par\@@par\par}\else \let\@par\WF@@par \fi + \let\parshape\@@parshape + \parshape\ifx\WF@pspars\@empty \z@ \else \@ne \WF@pspars\fi \fi + \ifvoid\WF@box \ifx\everypar\WF@everypar + \let\everypar\WF@@everypar \everypar\expandafter{\the\WF@everypar}% + \fi\fi} + +\newcommand{\WFclear}{\par + \ifvoid\WF@box\else \vskip\bigskipamount \box\WF@box + \let\everypar\WF@@everypar \everypar\expandafter{\the\WF@everypar}% + \fi \global\c@WF@wrappedlines\z@ \WF@finale} + +\begingroup + \toks0={\let\everypar\WF@@everypar \everypar\expandafter{\the\WF@everypar}% + \let\parshape\@@parshape \let\@setpar\@@setpar } + \toks1=\expandafter{\@arrayparboxrestore} + \toks2=\expandafter{\clearpage} + \edef\@tempa{\def\noexpand\@arrayparboxrestore{\the\toks0 \the\toks1}% + \def\noexpand\clearpage{\noexpand\protect\noexpand\WFclear \the\toks2}} + \expandafter +\endgroup\@tempa + +\@ifundefined{@capwidth}{\let\@capwidth\hsize}{}% Pamper RevTeX's Stupidity + +\def\WF@conflict{\WF@warning + {\WF@wfname used inside a conflicting environment}} +\def\WF@collision{\WF@warning{Collision between wrapping environments}} +\def\WF@fltmes{\ifWF@float \WF@info{\WF@wfname floats}% + \else \WF@warning{Stationary \WF@wfname forced to float}\fi} + +\let\WF@warning\@warning +\let\WF@info\@gobble + +% Support float.sty: float styles and \newfloat. Make \newfloat{foo} +% define the `wrapfoo' environment. Support \newfloat from memoir.cls +% and \newfloatlist from ccaption.sty. +% +\let\WF@floatstyhook\relax + +\@ifundefined{newfloat}{}{% There is a \newfloat command +% + \@ifundefined{restylefloat}{ + % \newfloat comes from somewhere besides float.sty + \@ifclassloaded{memoir}{ + \toks@=\expandafter\expandafter\expandafter + {\csname\string\newfloat\endcsname [{#1}]{#2}{#3}{#4}% + \newenvironment{wrap#2}{\wrapfloat{#2}}{\endwrapfloat}% + } + \edef\@tempa{\def\expandafter\noexpand\csname\string\newfloat\endcsname + [##1]##2##3##4{\the\toks@}} + \@tempa + }% end memoir support + {}% Other origins of \newfloat here?? + }{ + % float.sty handler. Ooops: Two versions for different versions + % Changing \float@restyle (or \restylefloat) changes \newfloat too. + \@ifundefined{float@restyle}{% older float.sty + \toks@=\expandafter{\restylefloat{#1}% (env may or may not be defined) + \@namedef{wrap#1}{\def\@captype{#1}\@nameuse{fst@#1}% + \def\WF@floatstyhook{\let\@currbox\WF@box \columnwidth\wd\WF@box + \global\setbox\WF@box\float@makebox}% + \@ifnextchar[\WF@wr{\WF@wr[]}}% + \expandafter\let\csname endwrap#1\endcsname \endwrapfigure + }\edef\@tempa{\def\noexpand\restylefloat##1{\the\toks@}} + }{% newer float.sty: use \float@restyle, and \float@makebox takes width arg + \toks@=\expandafter{\float@restyle{#1}% (env may or may not be defined) + \@namedef{wrap#1}{\def\@captype{#1}\@nameuse{fst@#1}% + \def\WF@floatstyhook{\let\@currbox\WF@box + \global\setbox\WF@box\float@makebox{\wd\WF@box}}% + \@ifnextchar[\WF@wr{\WF@wr[]}}% + \expandafter\let\csname endwrap#1\endcsname \endwrapfigure + }\edef\@tempa{\def\noexpand\float@restyle##1{\the\toks@}} + } + \@tempa % perform redefinitions + % + }% End float.sty handler +}% End redefinitions of \newfloat + +% Support ccaption.sty +\@ifundefined{\string\newfloatlist}{}{ + \toks@=\expandafter\expandafter\expandafter + {\csname\string\newfloatlist\endcsname [{#1}]{#2}{#3}{#4}{#5}% + \@namedef{wrap#2}{\wrapfloat{#2}}% + \expandafter\let\csname endwrap#2\endcsname \endwrapfloat + } + \edef\@tempa{\def\expandafter\noexpand\csname\string\newfloatlist\endcsname + [##1]##2##3##4##5{\the\toks@}} + \@tempa +} + +% Process package options. + +\@ifundefined{DeclareOption}{\endinput}{} + +\def\WF@warning{\PackageWarning{wrapfig}} +\ProvidesPackage{wrapfig}[2003/01/31 \space v 3.6] +\DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig}}} +\ProcessOptions +\AtEndDocument{\WFclear} + +\endinput + +%%%%% ----- End definitions ----- %%%%% + +%%%%% ----- Begin Instructions ----- %%%%% + + +W R A P F I G . S T Y \ \ ver 3.6 \ \ (Jan 31, 2003) + +Copyright (C) 1991-2003 by Donald Arseneau (asnd@triumf.ca) + +Wrapfig.sty provides the environments "wrapfigure" and "wraptable" for +typesetting a narrow float at the edge of the text, and making the text +wrap around it. The "wrapfigure" and "wraptable" environments interact +properly with the "\caption" command to produce proper numbering, but +they are not regular floats like "figure" and "table", so (beware!) they +may be printed out of sequence with the regular floats. There are four +parameters for "\begin{wrapfigure}", two optional and two required, plus +the text of the figure, with a caption perhaps: + + \begin{wrapfigure}[12]{r}[34pt]{5cm}
\end{wrapfigure} + == = ==== === + [number of narrow lines] {placement} [overhang] {width} + +Some idiosyncrasies: + + - You must not specify a wrapfigure in any type of list environment or + or immediately before or immediately after one. It is OK to follow + a list if there is a blank line ("\par") in between. + + - If you put a wrapfigure in a parbox or a minipage, or any other type + of grouping, the text wrapping should end before the group does. + + - It does work in two-column format, but are your figures that small? + + - It may be out of sequence with regular floats. + + - The hlines that may be printed above and below floats are ignored; + you must insert them manually if desired. + + - "\linewidth" is now adjusted within the wrapped text, but since it + can only be set for whole paragraphs at a time, it will persist with + the wrong value after the wrapping, until the paragraph is finished. + +New wrapping environments may be added when new float types are defined +(using memoir.cls, float.sty, or ccaption.sty). Any wrapping environment, +"wrapfigure", "wraptable", or something else may be invoked using the +"wrapfloat" environment, as in "\begin{wrapfloat}{figure}{O}{5cm}". + +To use float.sty properly, load package "float" before "wrapfig", +and declare any new float types after loading both. Likewise for +ccaption.sty and "\newfloatlist" and memoir.cls and its "\newfloat". + +\section{Placement and Floating} + +Parameter "#2" (required) is the figure placement code, but the valid +codes are different from regular figures. They come in pairs: an +uppercase version which allows the figure to float, and a lowercase +version that puts the figure ``exactly here''. + + r R - the right side of the text + l L - the left side of the text + i I - the inside edge--near the binding (if "[twoside]" document) + o O - the outside edge--far from the binding + +You should specify one code only, not a list. The figure or table must +be on one side or the other; it cannot be in the middle with text on +both sides. The "i" and "o" options refer to the inside and outside of +the whole page, not individual columns. + +The ability to float is somewhat restricted, and you will get best results +by giving exact manual placement, but floating is more convenient while +revising the document. Any changes to the formatting can ruin your manual +positioning so you should adjust the placement just before printing a +final copy. Here are some tips for good placement: + + - The environment should be placed so as to not run over a page break. + + - The environment must not be placed in special places like lists. + + - For esthetic reasons, only plain text should wrap around the figure. + Section titles and big equations look bad; lists are bad if the figure + is on the left. (All these function properly, they just don't look + very good.) Small equations look fine. + + - It is convenient to begin the environment between paragraphs, but if + you want placement in the middle of a paragraph, you must put the + environment between two words where there is a natural line break. + +When floating, \LaTeX\ tries to apply these rules. More specifically, +a floated wrapping environment will only begin... + + - at the beginning of a paragraph, + + - when there is enough room on the page, or it is possible to go on + the next page, + + - if the `paragraph' is not in a section title or a list, + + - if the paragraph is not wrapping around another figure, + + - in the main text (not in a minipage etc.) + +It is possible that a non-floating wrapfigure will be forced to float +when an earlier one is still being processed. A warning will be written +in that case. You can have more information about the floating process +written to the log file by specifying "\usepackage[verbose]{wrapfig}". + +If there is a lot of flexibility on a page, a floating wrapfigure may +be placed badly; you must turn to manual placement. A rare problem is +that floats and footnotes specified within the wrapping text can also +cause poor placement and bad formatting. + + +\section {Sizing and optional overhang} + +Parameter "#4" (the second required parameter) is the width of the figure +or table. Given the way that \LaTeX\ puts just about everything into boxes +with the current line-width, the width parameter will take precedence over +whatever natural width the figure has. In particular, the caption is always +typeset with the specified width. If the figure is wider than the space +allotted, you will get an ``overfull box'' warning. + +However, if you specify a width of *zero* ("0pt"), the actual width of +the figure will determine the wrapping width. A following "\caption" +should have the same width as the figure, but it might fail badly; it +is safer to specify a width when you use a caption. + +\LaTeX\ will wrap surrounding text around the figure, leaving a gap of +"\intextsep" at the top and bottom, and "\columsep" at the side, by +producing a series of shortened text lines beside the figure. The +indentation (shortening) of the text is the figure width plus "\columnsep" +minus overhang (if any; see below). + +\LaTeX\ calculates the number of short lines needed based on the height +of the figure and the length "\intextsep". You can override this guess +by giving the first optional argument (parameter "#1") specifying the +number of shortened lines (counting each displayed equation as 3 lines). +This is particularly useful when the surrounding text contains extra +vertical spacing that is not accounted for automatically. + +The second optional parameter ("#3") tells how much the figure should +hang out into the margin. The default overhang is given by the length +"\wrapoverhang", which is "0pt" normally but can be changed using +"\setlength". For example, to have all wrapfigures use the space +reserved for marginal notes, + + \setlength{\wrapoverhang}{\marginparwidth} + \addtolength{\wrapoverhang}{\marginparsep} + +When you do specify the overhang explicitly for a particular figure, you +can use a special unit called "\width" meaning the width of the figure. +For example, "[0.5\width]" makes the center of the figure sit on the +edge of the text, and "[\width]" puts the figure entirely in the margin +(and the adjacent text is indented by just "\columnsep"). This "\width" +is the actual width of the wrapfigure, which may be greater than the +declared width. + + +\section{Some Random Implementation Notes} + +Unfortunately, \LaTeX's system of setting "\everypar" and "\par" is +unable to coexist peacefully with a wrapping environment, so I was +forced to subvert the "\@setpar" mechanism and "\everypar". ("\everypar" +is already subverted once by NFSS.) + +When checking the room left on the page, remember that if there is less +than "\baselineskip" the new paragraph will begin on the next page, even +if there is no page stretch. If non-floating, I force a bad page break +rather than have the figure hang into the bottom margin. + +Here are notes on various variables and some macros; what info they +store and how they are used. + + \WF@wli - number-of-wrapped-lines parameter, saved for start of wrapping. + Set globally by "\WF@wr" (set empty if no optional parameter given). + The floating mechanism ignores this and uses the real size. + + \WF@ovh - margin overhang set globally by "\WF@rapt", saved until placing + figure (but not reset). Actually, the setting is very tricky so that + the expected values are used when a figure floats. First, the expression + is saved without evaluation by "\WF@rapt" ("\begin{wrapfigure}") because + "\width" is still unknown. Soon after that, "\endwrapfigure" executes + "\WF@ovh" to evaluate the overhang and save the result (so that changes + to "\wrapoverhang" while this figure is floating won't affect this + figure). Finally, it is used by "\WF@putfigmaybe" when printing the fig. + + \WF@place - a macro that is used as a number, giving the placement code. + It might start out as "`I" and later be converted to "114" (r). + + \WF@box - tested for void at "\begin{wrapfigure}", to avoid collisions, + by "\everypar" to do floating, and by "\WF@finale" before resetting + "\everypar". Voided globally when used by "\WF@putfigmaybe" (or by + "\WF@wr" if an old figure must be dumped prematurely). + + \par - test if it is "\@@par" by "\begin{wrapfigure}" and "\WF@floathand" + to float past special environments. It is set to "\@par" ("\WF@mypar") + by "\WF@startwrapping", and restored by an end-group (bad!) or by + "\WF@finale" (good). It is protected from change by redefining + "\@setpar". + + \parshape - let to "\WF@fudgeparshape" by "\WF@startwrapping", so lists + will continue wrapping; "\@@parshape" preserves the real "\parshape" + command, and it is restored by "\WF@finale" or "\@parboxrestore". + "\WF@floathand" and "\WF@wr" test if old wrapping is still in progress + with "\ifx\parshape\WF@fudgeparshape". The value of "\@@parshape" is + also tested to float past lists and other wrapping environments. + + \hangindent - tested to float past section titles etc. + + \c@WF@wrappedlines - the number of shortened lines + 1; set globally by + "\WF@startwrapping" and decremented by "\par" ("\WF@mypar"). It is > 1 + only when wrapping is incomplete. "\WF@wraphand", "\WF@fudgeparshape", + and "\WF@mypar" test the number for calling "\WF@finale". It may get + stuck at some high value if "\par" is restored by an end-group, (and + wrapping is terminated prematurely) so it is unwise to use this as a + test for wrapping-complete. + + \pagetotal - one of many parameters used to compute floating. When + putting a wrapfigure in a parbox, I assign "\let\pagetotal\maxdimen" + (locally!) to signal not-top-of-page and no floating. + + \WF@pspars - the "\parshape" parameters as LaTeX sets them for lists + ("\WF@fudgeparshape"); when wrapping I test it and use it to modify my + own real params for the paragraph. They are also used when "\parshape" + is restored after wrapping. + + \WF@finale - is performed by "\par" when wrapping should end. However, + that might happen inside a group (a list especially), so the subverted + versions of "\par", "\parshape" etc. will be reinstated when the group + ends. Thus, they must themselves test "\c@WF@wrappedlines" < 2 to see + when wrapping is over, and if so, they should just do "\WF@finale" again. + +These are the tests to see if a floating wrapfigure will fit at a particular +spot. These tests are performed at the beginning of every paragraph after +the figure, except in lists etc. ("\pagegoal" - "\pagetotal" is the room +left on the page.) + + > + room_left := \pagegoal - \pagetotal + if room_left < 0 then page overfull already: put figure (on next page) + else + if figure_size > room_left then does not fit + if max(min_stretch, \pagestretch) + extra > room_left + then page can stretch until full: put figure (at top of next page) + fi + else figure fits: put figure + fi fi + < + +Even if a wrapfigure is not floating, it will go through the same logic +to generate a "\pagebreak", and maybe an underfull page, when the current +page can stretch until full. The "min_stretch" depends on whether it is +floating or not: ".5\baselineskip" (floating) "2\baselineskip" (not). The +"extra" is ".5\baselineskip" in either case. These values can be adjusted. + +There are some other `magic numbers' for floating that aren't really so +special, but you must change them together if you change them at all. +To make floating wrapfigures float less and fit on pages more frequently, +but not change the number of wrapped lines, decrease the "1.5" in +"\global\advance\WF@size1.5\baselineskip" and increase the "1.1" in +"\advance\WF@size1.1\baselineskip" by the same amount (and vice versa). +To make more (or fewer) wrapped lines for the same size figure, without +changing the floating, change "1.1" in "\advance\WF@size1.1\baselineskip" +unilaterally. + +%%%%% ----- End Instructions ----- %%%%% + +Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789 +:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ diff --git a/ThirdParty/Ert/python/ecl/__init__.py b/ThirdParty/Ert/python/ecl/__init__.py index 50cb5823bd..f60dd2b8c6 100644 --- a/ThirdParty/Ert/python/ecl/__init__.py +++ b/ThirdParty/Ert/python/ecl/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/ecl_type.py b/ThirdParty/Ert/python/ecl/ecl_type.py index 330d636a9a..69537a9a6b 100644 --- a/ThirdParty/Ert/python/ecl/ecl_type.py +++ b/ThirdParty/Ert/python/ecl/ecl_type.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # The file 'ecl_type.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/ecl_util.py b/ThirdParty/Ert/python/ecl/ecl_util.py index 3835d3e5ae..e6edce0351 100644 --- a/ThirdParty/Ert/python/ecl/ecl_util.py +++ b/ThirdParty/Ert/python/ecl/ecl_util.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_util.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/__init__.py b/ThirdParty/Ert/python/ecl/eclfile/__init__.py index c98633910f..a183ea32b6 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/__init__.py +++ b/ThirdParty/Ert/python/ecl/eclfile/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py index 0d462a7636..90156ac322 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py index f19d01f171..6db3647849 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'ecl_3dkw.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py index 75ac344456..ca96e6cdc3 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_file.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py index ccb29032fa..1c6f02345d 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py index 51ae032143..e15df9dab3 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py index d5cd61dcad..6a47ddecc5 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_kw.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py index bdd2e33e8f..d09f179d65 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'ecl_restart_file.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/eclfile/fortio.py b/ThirdParty/Ert/python/ecl/eclfile/fortio.py index e454a9b8b0..d32e501990 100644 --- a/ThirdParty/Ert/python/ecl/eclfile/fortio.py +++ b/ThirdParty/Ert/python/ecl/eclfile/fortio.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'fortio.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/gravimetry/__init__.py b/ThirdParty/Ert/python/ecl/gravimetry/__init__.py index f218261dda..16881ceaba 100644 --- a/ThirdParty/Ert/python/ecl/gravimetry/__init__.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py index f8d75a3822..41171d94fe 100644 --- a/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_grav.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py index c00a1e714b..58dd878724 100644 --- a/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py index 890e4e5ccc..a9073c4d80 100644 --- a/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_subsidence.py' is part of ERT - Ensemble based # Reservoir Tool. @@ -49,6 +49,7 @@ class EclSubsidence(BaseCClass): _add_survey_PRESSURE = EclPrototype("void* ecl_subsidence_add_survey_PRESSURE( ecl_subsidence , char* , ecl_file_view )") _eval = EclPrototype("double ecl_subsidence_eval( ecl_subsidence , char* , char* , ecl_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_rporv = EclPrototype("double ecl_subsidence_eval_geertsma_rporv( ecl_subsidence , char* , char* , ecl_region , double , double , double, double, double, double)") _has_survey = EclPrototype("bool ecl_subsidence_has_survey( ecl_subsidence , char*)") def __init__( self, grid, init_file ): @@ -103,6 +104,17 @@ class EclSubsidence(BaseCClass): return self._eval_geertsma(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], youngs_modulus, poisson_ratio, seabed) + def eval_geertsma_rporv(self, base_survey, monitor_survey, pos, youngs_modulus, poisson_ratio, seabed, region=None): + if not base_survey in self: + raise KeyError("No such survey: %s" % base_survey) + + if monitor_survey is not None: + if not monitor_survey in self: + raise KeyError("No such survey: %s" % monitor_survey) + + return self._eval_geertsma_rporv(base_survey, monitor_survey, region, pos[0], pos[1], pos[2], youngs_modulus, poisson_ratio, seabed) + + def eval(self, base_survey, monitor_survey, pos, compressibility, poisson_ratio, region=None): """ Calculates the subsidence change between two surveys. diff --git a/ThirdParty/Ert/python/ecl/grid/__init__.py b/ThirdParty/Ert/python/ecl/grid/__init__.py index 69d110e0bf..b262c5b381 100644 --- a/ThirdParty/Ert/python/ecl/grid/__init__.py +++ b/ThirdParty/Ert/python/ecl/grid/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/cell.py b/ThirdParty/Ert/python/ecl/grid/cell.py index 5824d6fc47..ee6949624e 100644 --- a/ThirdParty/Ert/python/ecl/grid/cell.py +++ b/ThirdParty/Ert/python/ecl/grid/cell.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/ecl_grid.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py index 9afc3acd30..e8b662b006 100644 --- a/ThirdParty/Ert/python/ecl/grid/ecl_grid.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_grid.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py index 7bdf798bd3..66d4eec2a3 100644 --- a/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # The file 'ecl_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/ecl_region.py b/ThirdParty/Ert/python/ecl/grid/ecl_region.py index 295f0e59f9..db1a0bc092 100644 --- a/ThirdParty/Ert/python/ecl/grid/ecl_region.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_region.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_region.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault.py b/ThirdParty/Ert/python/ecl/grid/faults/fault.py index ac5ef42acb..986b6288ba 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'fault.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py index e5313170a7..0757b9e4eb 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'fault_block.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py index 16166c3ea6..bc4ad438c6 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'fault_block_collection.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py index cc84d65981..e51e889c19 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'fault_block_layer.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py index 704c5fad87..755ff90d58 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'fault_collection.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py index 10ef3da0e8..cbd9b7a67b 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'fault_line.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py index 7949a44d0e..b7af6ea97f 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014. Statoil ASA, Norway. +# Copyright (C) 2014. Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/grid/faults/layer.py b/ThirdParty/Ert/python/ecl/grid/faults/layer.py index 855f8f6be0..dc8df60a29 100644 --- a/ThirdParty/Ert/python/ecl/grid/faults/layer.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/layer.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'layer.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/rft/__init__.py b/ThirdParty/Ert/python/ecl/rft/__init__.py index d4efcd32c0..ac830d914b 100644 --- a/ThirdParty/Ert/python/ecl/rft/__init__.py +++ b/ThirdParty/Ert/python/ecl/rft/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/rft/ecl_rft.py b/ThirdParty/Ert/python/ecl/rft/ecl_rft.py index 38411dfd4b..493fa47727 100644 --- a/ThirdParty/Ert/python/ecl/rft/ecl_rft.py +++ b/ThirdParty/Ert/python/ecl/rft/ecl_rft.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_rft.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -53,8 +53,6 @@ class EclRFT(BaseCClass): _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_cell_sorted = EclPrototype("void* ecl_rft_node_iget_cell_sorted( ecl_rft )") - _sort_cells = EclPrototype("void* ecl_rft_node_inplace_sort_cells( 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*)") @@ -165,6 +163,9 @@ class EclRFT(BaseCClass): The return value from the __getitem__() method is either an EclRFTCell instance or a EclPLTCell instance, depending on the type of this particular RFT object. + + For MSW wells the cells will come in sorted order along the wellpath, + for other well types the cells will come sorted in input order. """ self.assert_cell_index( index ) cell_ptr = self._iget_cell( index ) @@ -175,46 +176,6 @@ class EclRFT(BaseCClass): return self[index] - def iget_sorted( self , index ): - """ - Will return the cell nr @index in the list of sorted cells. - - See method sort() for further documentation. - """ - self.assert_cell_index( index ) - cell_ptr = self._iget_cell_sorted( index ) - return self.__cell_ref( cell_ptr ) - - - def sort(self): - """ - Will sort cells in RFT; currently only applies to MSW wells. - - By default the cells in the RFT come in the order they are - specified in the ECLIPSE input file; that is not necessarily - in a suitable order. In the case of MSW wells it is possible - to sort the connections after distance along the wellpath. To - access the cells in sort order you have two options: - - 1. Sort the cells using the sort() method, and then - subsequently access them sequentially: - - rft.sort() - for cell in rft: - print cell - - 2. Let the rft object stay unsorted, but access the cells - using the iget_sorted() method: - - for i in range(len(rft)): - cell = rft.iget_sorted( i ) - - Currently only MSW/PLTs are sorted, based on the CONLENST - keyword; for other wells the sort() method does nothing. - """ - self._sort_cells( ) - - # ijk are zero offset def ijkget( self , ijk ): """ diff --git a/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py b/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py index 13a80cc4b6..ae01fb1ff6 100644 --- a/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py +++ b/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_rft_cell.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/rft/well_trajectory.py b/ThirdParty/Ert/python/ecl/rft/well_trajectory.py index abe0cadcd5..7df3a76c80 100644 --- a/ThirdParty/Ert/python/ecl/rft/well_trajectory.py +++ b/ThirdParty/Ert/python/ecl/rft/well_trajectory.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'well_trajectory.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/__init__.py b/ThirdParty/Ert/python/ecl/summary/__init__.py index 946fcf6e8d..064164accf 100644 --- a/ThirdParty/Ert/python/ecl/summary/__init__.py +++ b/ThirdParty/Ert/python/ecl/summary/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py b/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py index ce705d20e7..dfbcf626a2 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_npv.py b/ThirdParty/Ert/python/ecl/summary/ecl_npv.py index 67363f2669..3f1fbe42ad 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_npv.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_npv.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2013 Equinor ASA, Norway. # # The file 'ecl_npv.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -136,7 +136,7 @@ class NPVPriceVector(object): class EclNPV(object): - sumKeyRE = re.compile("[[]([\w:,]+)[]]") + sumKeyRE = re.compile("[\[]([\w:,]+)[\]]") def __init__(self, baseCase): diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py b/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py index 893eb66162..676515bd1d 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 Statoil ASA, Norway. +# Copyright (C) 2016 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py index 029334836a..f721ee9dee 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -26,6 +26,8 @@ import numpy import datetime import os.path import ctypes +import pandas +import re # Observe that there is some convention conflict with the C code # regarding order of arguments: The C code generally takes the time @@ -90,7 +92,7 @@ class EclSum(BaseCClass): _fread_alloc = EclPrototype("void* ecl_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)", bind = False) _create_writer = EclPrototype("ecl_sum_obj ecl_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)") + _resample = EclPrototype("ecl_sum_obj ecl_sum_alloc_resample( ecl_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)") @@ -303,9 +305,8 @@ class EclSum(BaseCClass): raise TypeError('Parameter sim_days should be float, was %r' % sim_days) sim_seconds = sim_days * 24 * 60 * 60 - - return self._add_tstep(report_step, sim_seconds).setParent(parent=self) - + tstep = self._add_tstep(report_step, sim_seconds).setParent(parent=self) + return tstep @@ -500,7 +501,6 @@ class EclSum(BaseCClass): .... """ from ecl.summary import EclSumKeyWordVector - import pandas if column_keys is None: keywords = EclSumKeyWordVector(self, add_keywords = True) else: @@ -524,6 +524,61 @@ class EclSum(BaseCClass): frame = pandas.DataFrame(index = time_index, columns=list(keywords), data=data) return frame + @staticmethod + def _compile_headers_list(headers, dims): + var_list = [] + for key in headers: + lst = re.split(':', key) + kw = lst[0] + wgname = None + num = 0; + unit = "UNIT" + if len(lst) > 1: + nums = [] + if lst[1][0].isdigit(): + nums = re.split(',', lst[1]) + else: + wgname = lst[1] + if len(lst) == 3: + nums = re.split(",", lst[2]) + if len(nums) == 3: + i = int(nums[0])-1 + j = int(nums[1])-1 + k = int(nums[2])-1 + if dims is None: + raise ValueError("For key %s When using indexing i,j,k you must supply a valid value for the dims argument" % key) + num = i + j * dims[0] + k * dims[0]*dims[1] + 1 + elif len(nums) == 1: + num = int(nums[0]) + + var_list.append( [kw, wgname, num, unit] ) + return var_list + + @classmethod + def from_pandas(cls, case, frame, dims = None, headers = None): + start_time = frame.index[0] + var_list = [] + if headers is None: + header_list = EclSum._compile_headers_list( frame.columns.values, dims ) + else: + header_list = EclSum._compile_headers_list( headers, dims ) + if dims is None: + dims = [1,1,1]; + ecl_sum = EclSum.writer(case, + start_time.to_pydatetime(), + 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() ) + + for i, time in enumerate(frame.index): + days = (time - start_time).days + t_step = ecl_sum.addTStep( i+1 , days ) + + for var in var_list: + t_step[var] = frame.iloc[i][var] + + return ecl_sum + def get_key_index(self, key): """ @@ -1481,8 +1536,12 @@ are advised to fetch vector as a numpy vector and then scale that yourself: - def resample(self, new_case_name, time_points): - return self._resample(new_case_name, time_points) + def resample(self, new_case_name, time_points, lower_extrapolation=False, upper_extrapolation=False): + new_case = self._resample(new_case_name, time_points, lower_extrapolation, upper_extrapolation) + if new_case is None: + raise ValueError("Failed to create new resampled case:{}".format(new_case_name)) + + return new_case import ecl.summary.ecl_sum_keyword_vector diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py index a3fc4c12a6..466106bfcc 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ecl_sum_keyword_vector.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py index 0b165e6e0a..1fa471619b 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py index 039105f497..3d19a9eff3 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 Statoil ASA, Norway. +# Copyright (C) 2016 Equinor ASA, Norway. # # The file 'ecl_sum_var_type.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py index 8c7a614eef..3feff8d326 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # @@ -46,7 +46,7 @@ class EclSumVector(object): self.__dates = parent.get_dates(report_only) self.__days = parent.get_days(report_only) - self.__mpl_dates = parent.get_mpl_dates(report_only) + self.__numpy_dates = parent.numpy_dates self.__report_step = parent.get_report_step(report_only) self.__values = None @@ -99,8 +99,21 @@ class EclSumVector(object): def mpl_dates(self): """ All the dates as numpy vector of dates in matplotlib format. + This property will be replaced by numpy_dates, but is kept for + backwards-compatibility for the time-being. Usage will trigger + a depreciation warning. """ - return self.__mpl_dates + warnings.warn("The mpl_dates property has been deprecated - use numpy_dates instead", + DeprecationWarning) + + return self.parent.get_mpl_dates(self.report_only) + + @property + def numpy_dates(self): + """ + All the dates as numpy vector of dates in numpy format. + """ + return self.__numpy_dates @property def report_step(self): @@ -119,7 +132,7 @@ class EclSumVector(object): return EclSumNode(self.__report_step[index], self.__days[index], self.__dates[index], - self.__mpl_dates[index], + self.mpl_dates[index], self.__values[index]) diff --git a/ThirdParty/Ert/python/ecl/util/geometry/__init__.py b/ThirdParty/Ert/python/ecl/util/geometry/__init__.py index e4bc012dc9..d970567ebe 100644 --- a/ThirdParty/Ert/python/ecl/util/geometry/__init__.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py index 227413182b..550bd68bcb 100644 --- a/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py index 335f3092b6..814900cca1 100644 --- a/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'cpolyline_collection.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py b/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py index 6286de3eef..501af9e451 100644 --- a/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py b/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py index 9d4e290147..fab03e64c9 100644 --- a/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/geometry/surface.py b/ThirdParty/Ert/python/ecl/util/geometry/surface.py index ba610cb9bc..8152b1cc08 100644 --- a/ThirdParty/Ert/python/ecl/util/geometry/surface.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/surface.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 Statoil ASA, Norway. +# Copyright (C) 2016 Equinor ASA, Norway. # # The file 'surface' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt index 4d87b9efca..50c2a9bd09 100644 --- a/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt @@ -6,7 +6,6 @@ set(PYTHON_SOURCES test_run.py source_enumerator.py test_area.py - temp_area.py path_context.py lint_test_case.py import_test_case.py diff --git a/ThirdParty/Ert/python/ecl/util/test/__init__.py b/ThirdParty/Ert/python/ecl/util/test/__init__.py index 1cc89f8d32..ab79dd25d9 100644 --- a/ThirdParty/Ert/python/ecl/util/test/__init__.py +++ b/ThirdParty/Ert/python/ecl/util/test/__init__.py @@ -3,7 +3,6 @@ from .test_run import path_exists from .extended_testcase import ExtendedTestCase from .source_enumerator import SourceEnumerator from .test_area import TestArea , TestAreaContext -from .temp_area import TempArea , TempAreaContext from .ert_test_runner import ErtTestRunner from .path_context import PathContext from .lint_test_case import LintTestCase diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py index 9fc8b7a8b1..3096791654 100644 --- a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py @@ -39,8 +39,10 @@ def createEclSum( case, days = time_offset + report_step * report_step_length + mini_step * mini_step_length t_step = ecl_sum.addTStep( report_step + 1 , sim_days = days ) + for var in var_list: key = var.getKey1( ) + if key in func_table: func = func_table[key] t_step[key] = func( days ) diff --git a/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py b/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py index dd89c5a720..931578ac79 100644 --- a/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py +++ b/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2013 Equinor ASA, Norway. # # The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/test/import_test_case.py b/ThirdParty/Ert/python/ecl/util/test/import_test_case.py index 13b940d49b..089107f2b7 100644 --- a/ThirdParty/Ert/python/ecl/util/test/import_test_case.py +++ b/ThirdParty/Ert/python/ecl/util/test/import_test_case.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py b/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py index ff3bd729d6..3b27225384 100644 --- a/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py +++ b/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/test/temp_area.py b/ThirdParty/Ert/python/ecl/util/test/temp_area.py deleted file mode 100644 index 4b7d2aa697..0000000000 --- a/ThirdParty/Ert/python/ecl/util/test/temp_area.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# The file 'temp_area.py' 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ERT is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. -# -# See the GNU General Public License at -# for more details. - -import os -import os.path -from ecl import EclPrototype -from . import TestArea - -class TempArea(TestArea): - """TempArea class is essentially similar to the TestArea class, with - the only difference that the cwd is *not* changed into the newly - created area. - """ - - _temp_area_alloc = EclPrototype("void* temp_area_alloc( char* )" , bind = False) - _temp_area_alloc_relative = EclPrototype("void* temp_area_alloc_relative( char* , char* )" , bind = False) - - def __init__(self, name, prefix = None , store_area=False): - if prefix: - if os.path.exists( prefix ): - c_ptr = self._temp_area_alloc_relative(prefix , name) - else: - raise IOError("The prefix path:%s must exist" % prefix) - else: - c_ptr = self._temp_area_alloc(name) - super(TempArea, self).__init__(name , c_ptr = c_ptr , store_area = store_area) - - - def __str__(self): - return self.getPath() - - - def get_cwd(self): - """ - Since the TempArea class does *not* change the cwd this method - just returns the ordinary os.getcwd(). - """ - return os.getcwd() - - - def getPath(self): - """ - Will return the full path to the temporary working area. - """ - return self._get_cwd( ) - - - -class TempAreaContext(object): - def __init__(self, name, prefix = None , store_area=False): - self.name = name - self.store_area = store_area - self.prefix = prefix - - def __enter__(self): - """ - @rtype: TempArea - """ - self.temp_area = TempArea(self.name, prefix = self.prefix , store_area = self.store_area ) - return self.temp_area - - - def __exit__(self, exc_type, exc_val, exc_tb): - del self.temp_area - return False - - - diff --git a/ThirdParty/Ert/python/ecl/util/test/test_area.py b/ThirdParty/Ert/python/ecl/util/test/test_area.py index 22089bd86c..929bae6ff2 100644 --- a/ThirdParty/Ert/python/ecl/util/test/test_area.py +++ b/ThirdParty/Ert/python/ecl/util/test/test_area.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2013 Equinor ASA, Norway. # # The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -20,8 +20,7 @@ from ecl import EclPrototype class TestArea(BaseCClass): - _test_area_alloc = EclPrototype("void* test_work_area_alloc( char* )" , bind = False) - _test_area_alloc_relative = EclPrototype("void* test_work_area_alloc_relative( char* , char* )" , bind = False) + _test_area_alloc = EclPrototype("void* test_work_area_alloc__( char*, bool )" , bind = False) _free = EclPrototype("void test_work_area_free( test_area )") _install_file = EclPrototype("void test_work_area_install_file( test_area , char* )") _copy_directory = EclPrototype("void test_work_area_copy_directory( test_area , char* )") @@ -31,22 +30,13 @@ class TestArea(BaseCClass): _copy_parent_content = EclPrototype("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("char* test_work_area_get_original_cwd( test_area )") - _set_store = EclPrototype("void test_work_area_set_store( test_area , bool)") - _sync = EclPrototype("void test_work_area_sync( test_area )") - def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): + def __init__(self, test_name, store_area=False , c_ptr = None): if c_ptr is None: - if prefix: - if os.path.exists( prefix ): - c_ptr = self._test_area_alloc_relative(prefix , test_name) - else: - raise IOError("The prefix path:%s must exist" % prefix) - else: - c_ptr = self._test_area_alloc(test_name) + c_ptr = self._test_area_alloc(test_name, store_area) super(TestArea, self).__init__(c_ptr) - self.set_store( store_area ) def get_original_cwd(self): @@ -111,10 +101,6 @@ class TestArea(BaseCClass): self._free() - def set_store(self, store): - self._set_store(store) - - def getFullPath(self , path): if not os.path.exists( path ): raise IOError("Path not found:%s" % path) @@ -125,22 +111,17 @@ class TestArea(BaseCClass): return os.path.join( self.get_cwd() , path ) - def sync(self): - return self._sync( ) - - class TestAreaContext(object): - def __init__(self, test_name, prefix = None , store_area=False): + def __init__(self, test_name, store_area=False): self.test_name = test_name self.store_area = store_area - self.prefix = prefix def __enter__(self): """ @rtype: TestArea """ - self.test_area = TestArea(self.test_name, prefix = self.prefix , store_area = self.store_area ) + self.test_area = TestArea(self.test_name, store_area = self.store_area ) return self.test_area diff --git a/ThirdParty/Ert/python/ecl/util/test/test_run.py b/ThirdParty/Ert/python/ecl/util/test/test_run.py index 496353ba4d..b32a8f45c5 100644 --- a/ThirdParty/Ert/python/ecl/util/test/test_run.py +++ b/ThirdParty/Ert/python/ecl/util/test/test_run.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2013 Equinor ASA, Norway. # # The file 'test_run.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/__init__.py b/ThirdParty/Ert/python/ecl/util/util/__init__.py index aa5edf30b6..3960e7bfd2 100644 --- a/ThirdParty/Ert/python/ecl/util/util/__init__.py +++ b/ThirdParty/Ert/python/ecl/util/util/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -71,7 +71,7 @@ from .cwd_context import CWDContext ### the process of changing camelCase function names to snake_case function ### names. ### -### See https://github.com/Statoil/libecl/issues/142 for a discussion and for +### See https://github.com/Equinor/libecl/issues/142 for a discussion and for ### usage. ### diff --git a/ThirdParty/Ert/python/ecl/util/util/arg_pack.py b/ThirdParty/Ert/python/ecl/util/util/arg_pack.py index 4b53e03b18..018cffcb48 100644 --- a/ThirdParty/Ert/python/ecl/util/util/arg_pack.py +++ b/ThirdParty/Ert/python/ecl/util/util/arg_pack.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'arg_pack.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/bool_vector.py b/ThirdParty/Ert/python/ecl/util/util/bool_vector.py index d688562682..cb68a2d013 100644 --- a/ThirdParty/Ert/python/ecl/util/util/bool_vector.py +++ b/ThirdParty/Ert/python/ecl/util/util/bool_vector.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py b/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py index 39d8c3be91..30c923e8f3 100644 --- a/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py +++ b/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'cthread_pool.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/ctime.py b/ThirdParty/Ert/python/ecl/util/util/ctime.py index 0c92ecd893..173f7c64ad 100644 --- a/ThirdParty/Ert/python/ecl/util/util/ctime.py +++ b/ThirdParty/Ert/python/ecl/util/util/ctime.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'ctime.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/double_vector.py b/ThirdParty/Ert/python/ecl/util/util/double_vector.py index 9ba7100958..c9fa16d66f 100644 --- a/ThirdParty/Ert/python/ecl/util/util/double_vector.py +++ b/ThirdParty/Ert/python/ecl/util/util/double_vector.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'double_vector.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/hash.py b/ThirdParty/Ert/python/ecl/util/util/hash.py index 3edc600763..62def2f3c3 100644 --- a/ThirdParty/Ert/python/ecl/util/util/hash.py +++ b/ThirdParty/Ert/python/ecl/util/util/hash.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'hash.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/int_vector.py b/ThirdParty/Ert/python/ecl/util/util/int_vector.py index f280603df8..34c6cd8415 100644 --- a/ThirdParty/Ert/python/ecl/util/util/int_vector.py +++ b/ThirdParty/Ert/python/ecl/util/util/int_vector.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'int_vector.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/lookup_table.py b/ThirdParty/Ert/python/ecl/util/util/lookup_table.py index 4d01ba8732..3ebf71c5f5 100644 --- a/ThirdParty/Ert/python/ecl/util/util/lookup_table.py +++ b/ThirdParty/Ert/python/ecl/util/util/lookup_table.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'lookup_table.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/matrix.py b/ThirdParty/Ert/python/ecl/util/util/matrix.py deleted file mode 100644 index 160763987c..0000000000 --- a/ThirdParty/Ert/python/ecl/util/util/matrix.py +++ /dev/null @@ -1,230 +0,0 @@ - -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'matrix.py' 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ERT is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. -# -# See the GNU General Public License at -# for more details. - - -# The Matrix class implemented here wraps the C matrix implementation -# in matrix.c from the libutil library. The C matrix implementation -# has the very limited ambition of just barely satisfying the matrix -# needs of the EnKF algorithm, i.e. for general linear algebra -# applications you will probably be better served by a more complete -# matrix library. This applies even more so to this Python -# implementation; it is only here facilitate use of C libraries which -# expect a matrix instance as input (i.e. the LARS estimator). For -# general linear algebra in Python the numpy library is a natural -# choice. - - -from cwrap import BaseCClass,CFILE -from ecl import EclPrototype - - -class Matrix(BaseCClass): - _matrix_alloc = EclPrototype("void* matrix_alloc(int, int )" , bind = False) - _matrix_alloc_identity = EclPrototype("matrix_obj matrix_alloc_identity( int )" , bind = False) - _alloc_transpose = EclPrototype("matrix_obj matrix_alloc_transpose(matrix)") - _inplace_transpose = EclPrototype("void matrix_inplace_transpose(matrix)") - _copy = EclPrototype("matrix_obj matrix_alloc_copy(matrix)" ) - _sub_copy = EclPrototype("matrix_obj matrix_alloc_sub_copy(matrix, int , int , int , int)" ) - _free = EclPrototype("void matrix_free(matrix)") - _iget = EclPrototype("double matrix_iget( matrix , int , int )") - _iset = EclPrototype("void matrix_iset( matrix , int , int , double)") - _set_all = EclPrototype("void matrix_scalar_set( matrix , double)") - _scale_column = EclPrototype("void matrix_scale_column(matrix , int , double)") - _scale_row = EclPrototype("void matrix_scale_row(matrix , int , double)") - _copy_column = EclPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False) - _rows = EclPrototype("int matrix_get_rows(matrix)") - _columns = EclPrototype("int matrix_get_columns(matrix)") - _equal = EclPrototype("bool matrix_equal(matrix, matrix)") - _pretty_print = EclPrototype("void matrix_pretty_print(matrix, char*, char*)") - _fprint = EclPrototype("void matrix_fprintf(matrix, char*, FILE)") - _random_init = EclPrototype("void matrix_random_init(matrix, rng)") - _dump_csv = EclPrototype("void matrix_dump_csv(matrix, char*)") - - # Requires BLAS. If the library does not have the - # matrix_alloc_matmul() function the prototype will have _func = - # None, and NotImplementedError( ) will be raised int the - # __call__() method if we try to use this function. - try: - _alloc_matmul = EclPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False) - except AttributeError: - _alloc_matmul = None - - # Requires BLAS! - @classmethod - def matmul(cls, m1,m2): - """ - Will return a new matrix which is matrix product of m1 and m2. - """ - if m1.columns( ) == m2.rows( ): - return cls._alloc_matmul( m1, m2) - else: - raise ValueError("Matrix size mismatch") - - - def __init__(self, rows, columns, value=0): - c_ptr = self._matrix_alloc(rows, columns) - super(Matrix, self).__init__(c_ptr) - self.setAll(value) - - def copy(self): - return self._copy( ) - - @classmethod - def identity(cls, dim): - """Returns a dim x dim identity matrix.""" - if dim < 1: - raise ValueError('Identity matrix must have positive size, %d not allowed.' % dim) - return cls._matrix_alloc_identity(dim) - - def subCopy(self, row_offset, column_offset, rows, columns): - if row_offset < 0 or row_offset >= self.rows(): - raise ValueError("Invalid row offset") - - if column_offset < 0 or column_offset >= self.columns(): - raise ValueError("Invalid column offset") - - if row_offset + rows > self.rows(): - raise ValueError("Invalid rows") - - if column_offset + columns > self.columns(): - raise ValueError("Invalid columns") - - return self._sub_copy( row_offset , column_offset , rows , columns) - - - def __str__(self): - s = "" - for i in range(self.rows()): - s += "[" - for j in range(self.columns()): - d = self._iget(i, j) - s += "%6.3g " % d - s += "]\n" - return s - - def __getitem__(self, index_tuple): - if not 0 <= index_tuple[0] < self.rows(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) - - if not 0 <= index_tuple[1] < self.columns(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[1], self.columns())) - - return self._iget(index_tuple[0], index_tuple[1]) - - def __setitem__(self, index_tuple, value): - if not 0 <= index_tuple[0] < self.rows(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[0], self.rows())) - - if not 0 <= index_tuple[1] < self.columns(): - raise IndexError("Expected 0 <= %d < %d" % (index_tuple[1], self.columns())) - - return self._iset(index_tuple[0], index_tuple[1], value) - - def dims(self): - return self._rows(), self._columns() - - def rows(self): - """ @rtype: int """ - return self._rows() - - def transpose(self , inplace = False): - """ - Will transpose the matrix. By default a transposed copy is returned. - """ - if inplace: - self._inplace_transpose( ) - return self - else: - return self._alloc_transpose( ) - - - def columns(self): - """ @rtype: int """ - return self._columns() - - def __eq__(self, other): - assert isinstance(other, Matrix) - return self._equal(other) - - def scaleColumn(self, column, factor): - if not 0 <= column < self.columns(): - raise IndexError("Expected column: [0,%d) got:%d" % (self.columns(), column)) - self._scale_column(column, factor) - - def scaleRow(self, row, factor): - if not 0 <= row < self.rows(): - raise IndexError("Expected row: [0,%d) got:%d" % (self.rows(), row)) - self._scale_row(row, factor) - - def setAll(self, value): - self._set_all(value) - - def copyColumn(self, target_column, src_column): - columns = self.columns() - if not 0 <= src_column < columns: - raise ValueError("src column:%d invalid" % src_column) - - if not 0 <= target_column < columns: - raise ValueError("target column:%d invalid" % target_column) - - if src_column != target_column: - # The underlying C function accepts column copy between matrices. - Matrix._copy_column(self, self, target_column, src_column) - - - def dumpCSV(self , filename): - self._dump_csv( filename ) - - - def prettyPrint(self, name, fmt="%6.3g"): - self._pretty_print(name, fmt) - - def fprint(self , fileH , fmt = "%g "): - """Will print ASCII representation of matrix. - - The fileH argument should point to an open Python - filehandle. If you supply a fmt string it is important that it - contains a separator, otherwise you might risk that elements - overlap in the output. For the matrix: - - [0 1 2] - m = [3 4 5] - [6 7 8] - - The code: - - with open("matrix.txt" , "w") as f: - m.fprintf( f ) - - The file 'matrix.txt' will look like: - - 0 1 2 - 3 4 5 - 6 7 8 - - """ - self._fprint( fmt , CFILE( fileH)) - - - def randomInit(self, rng): - self._random_init(rng) - - def free(self): - self._free() - - - diff --git a/ThirdParty/Ert/python/ecl/util/util/rng.py b/ThirdParty/Ert/python/ecl/util/util/rng.py index e03af1c3f2..ff46f30b0b 100644 --- a/ThirdParty/Ert/python/ecl/util/util/rng.py +++ b/ThirdParty/Ert/python/ecl/util/util/rng.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'rng.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/stringlist.py b/ThirdParty/Ert/python/ecl/util/util/stringlist.py index 19d4de759e..3c98a202de 100644 --- a/ThirdParty/Ert/python/ecl/util/util/stringlist.py +++ b/ThirdParty/Ert/python/ecl/util/util/stringlist.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'stringlist.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/time_vector.py b/ThirdParty/Ert/python/ecl/util/util/time_vector.py index cffcb411f8..d8e0425189 100644 --- a/ThirdParty/Ert/python/ecl/util/util/time_vector.py +++ b/ThirdParty/Ert/python/ecl/util/util/time_vector.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/util_func.py b/ThirdParty/Ert/python/ecl/util/util/util_func.py index cb7cf236d6..40acc3385b 100644 --- a/ThirdParty/Ert/python/ecl/util/util/util_func.py +++ b/ThirdParty/Ert/python/ecl/util/util/util_func.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'util_func.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/util/util/vector_template.py b/ThirdParty/Ert/python/ecl/util/util/vector_template.py index ca4d1a506a..5693a64322 100644 --- a/ThirdParty/Ert/python/ecl/util/util/vector_template.py +++ b/ThirdParty/Ert/python/ecl/util/util/vector_template.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ecl/well/well_info.py b/ThirdParty/Ert/python/ecl/well/well_info.py index 938341ace0..e8e3dcc6b5 100644 --- a/ThirdParty/Ert/python/ecl/well/well_info.py +++ b/ThirdParty/Ert/python/ecl/well/well_info.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/ert/test/__init__.py b/ThirdParty/Ert/python/ert/test/__init__.py index bacdd1adf8..743e58fc12 100644 --- a/ThirdParty/Ert/python/ert/test/__init__.py +++ b/ThirdParty/Ert/python/ert/test/__init__.py @@ -3,7 +3,6 @@ from ecl.util.test import path_exists from ecl.util.test import ExtendedTestCase from ecl.util.test import SourceEnumerator from ecl.util.test import TestArea , TestAreaContext -from ecl.util.test import TempArea , TempAreaContext from ecl.util.test import ErtTestRunner from ecl.util.test import PathContext from ecl.util.test import LintTestCase diff --git a/ThirdParty/Ert/python/tests/__init__.py b/ThirdParty/Ert/python/tests/__init__.py index 918cbb6acc..4fb12b1cca 100644 --- a/ThirdParty/Ert/python/tests/__init__.py +++ b/ThirdParty/Ert/python/tests/__init__.py @@ -23,12 +23,12 @@ def source_root(): # Decorator which is used to mark either an entire test class or individual -# test methods as requiring Statoil testdata. If Statoil testdata has not been +# test methods as requiring Equinor testdata. If Equinor testdata has not been # configured as part of the build process these tests will be skipped. # -# Ideally the statoil_test() implementation should just be a suitable wrapper of: +# Ideally the equinor_test() implementation should just be a suitable wrapper of: # -# skipUnless(EclTest.STATOIL_DATA, "Missing Statoil testdata") +# skipUnless(EclTest.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 @@ -42,32 +42,32 @@ def source_root(): # class, that is not required when decorating method: # # -# @statoil_test() -# class StatoilTest(EclTest): +# @equinor_test() +# class EquinorTest(EclTest): # # This test class will be skipped entirely if we do not have access to -# # Statoil testdata. +# # Equinor testdata. # # # class XTest(EclTest): # -# @statoil_test +# @equinor_test # def test_method(self): -def statoil_test(): +def equinor_test(): """ - Will mark a test method or an entire test class as dependent on Statoil testdata. + Will mark a test method or an entire test class as dependent on Equinor testdata. """ def decorator(test_item): if not isinstance(test_item, type): - if not EclTest.STATOIL_DATA: + if not EclTest.EQUINOR_DATA: @functools.wraps(test_item) def skip_wrapper(*args, **kwargs): - raise SkipTest("Missing Statoil testdata") + raise SkipTest("Missing Equinor testdata") test_item = skip_wrapper - if not EclTest.STATOIL_DATA: + if not EclTest.EQUINOR_DATA: test_item.__unittest_skip__ = True - test_item.__unittest_skip_why__ = "Missing Statoil testdata" + test_item.__unittest_skip_why__ = "Missing Equinor testdata" return test_item return decorator @@ -77,6 +77,6 @@ def statoil_test(): class EclTest(ExtendedTestCase): SOURCE_ROOT = source_root() TESTDATA_ROOT = os.path.join(SOURCE_ROOT, "test-data") - STATOIL_DATA = os.path.islink(os.path.join(TESTDATA_ROOT, "Statoil")) + EQUINOR_DATA = os.path.islink(os.path.join(TESTDATA_ROOT, "Equinor")) diff --git a/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py index c265382c00..d4e0db52b9 100644 --- a/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py +++ b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # @@ -60,6 +60,7 @@ class SummaryResampleTest(EclTest): with TestAreaContext(""): self.case.fwrite() + # Too few arguments with self.assertRaises(CallError): subprocess.check_call([self.script]) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt index 5196dd1016..eec263e163 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt +++ b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt @@ -4,7 +4,7 @@ set(TEST_SOURCES test_ecl_ecl.py test_removed.py test_ecl_3dkw.py - test_ecl_file_statoil.py + test_ecl_file_equinor.py test_ecl_file.py test_ecl_init_file.py test_ecl_restart_file.py @@ -12,33 +12,33 @@ set(TEST_SOURCES test_ecl_sum.py test_ecl_sum_vector.py test_fault_blocks.py - test_fault_blocks_statoil.py + test_fault_blocks_equinor.py test_faults.py test_fortio.py - test_grdecl_statoil.py + test_grdecl_equinor.py test_grdecl.py test_grid.py test_grid_pandas.py test_cell.py - test_grid_statoil.py - test_grid_statoil_coarse.py - test_grid_statoil_dual.py - test_grid_statoil_large_case.py + test_grid_equinor.py + test_grid_equinor_coarse.py + test_grid_equinor_dual.py + test_grid_equinor_large_case.py test_grid_generator.py test_indexed_read.py - test_ecl_kw_statoil.py + test_ecl_kw_equinor.py test_ecl_kw.py test_kw_function.py test_layer.py test_npv.py test_region.py - test_region_statoil.py + test_region_equinor.py test_restart.py test_rft.py - test_rft_statoil.py + test_rft_equinor.py test_rft_cell.py - test_statoil_faults.py - test_sum_statoil.py + test_equinor_faults.py + test_sum_equinor.py test_ecl_util.py test_ecl_cmp.py test_sum.py @@ -83,24 +83,24 @@ if (INSTALL_ERT_LEGACY) endif() -addPythonTest(tests.ecl_tests.test_ecl_file_statoil.EclFileStatoilTest) -addPythonTest(tests.ecl_tests.test_grdecl_statoil.GRDECLStatoilTest) +addPythonTest(tests.ecl_tests.test_ecl_file_equinor.EclFileEquinorTest) +addPythonTest(tests.ecl_tests.test_grdecl_equinor.GRDECLEquinorTest) addPythonTest(tests.ecl_tests.test_grdecl.GRDECLTest) -addPythonTest(tests.ecl_tests.test_grid_statoil.GridTest) -addPythonTest(tests.ecl_tests.test_grid_statoil_coarse.GridCoarceTest) -addPythonTest(tests.ecl_tests.test_grid_statoil_dual.GridDualTest) -addPythonTest(tests.ecl_tests.test_grid_statoil_large_case.GridLargeCaseTest) -addPythonTest(tests.ecl_tests.test_ecl_kw_statoil.KWTest) +addPythonTest(tests.ecl_tests.test_grid_equinor.GridTest) +addPythonTest(tests.ecl_tests.test_grid_equinor_coarse.GridCoarceTest) +addPythonTest(tests.ecl_tests.test_grid_equinor_dual.GridDualTest) +addPythonTest(tests.ecl_tests.test_grid_equinor_large_case.GridLargeCaseTest) +addPythonTest(tests.ecl_tests.test_ecl_kw_equinor.KWTest) addPythonTest(tests.ecl_tests.test_ecl_init_file.InitFileTest) addPythonTest(tests.ecl_tests.test_ecl_restart_file.RestartFileTest) addPythonTest(tests.ecl_tests.test_restart.RestartTest ) -addPythonTest(tests.ecl_tests.test_region_statoil.RegionTest) -addPythonTest(tests.ecl_tests.test_rft_statoil.RFTTest) -addPythonTest(tests.ecl_tests.test_sum_statoil.SumTest) +addPythonTest(tests.ecl_tests.test_region_equinor.RegionTest) +addPythonTest(tests.ecl_tests.test_rft_equinor.RFTTest) +addPythonTest(tests.ecl_tests.test_sum_equinor.SumTest) addPythonTest(tests.ecl_tests.test_ecl_sum_vector.EclSumVectorTest) addPythonTest(tests.ecl_tests.test_ecl_sum.EclSumTest) -addPythonTest(tests.ecl_tests.test_statoil_faults.StatoilFaultTest) -addPythonTest(tests.ecl_tests.test_fault_blocks_statoil.FaultBlockTest) +addPythonTest(tests.ecl_tests.test_equinor_faults.EquinorFaultTest) +addPythonTest(tests.ecl_tests.test_fault_blocks_equinor.FaultBlockTest) addPythonTest(tests.ecl_tests.test_npv.NPVTest) addPythonTest(tests.ecl_tests.test_indexed_read.EclIndexedReadTest) addPythonTest(tests.ecl_tests.test_ecl_cmp.EclCmpTest) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py b/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py index 5b8f41e52b..55120ce5c2 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py b/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py index 49e4f997f1..ef930ed46b 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # The file 'test_debug.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py b/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py index 869b6a4168..1096fc5272 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'test_deprecation.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -43,7 +43,6 @@ class Deprecation_2_0_Test(EclTest): with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: kw.fwrite( f ) - t.sync() f = EclFile( "TEST" ) class Deprecation_1_9_Test(EclTest): diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py index e6a8fed20a..8c4f146743 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py index 39adb1fcb9..3d90837248 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'test_ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -17,13 +17,13 @@ from ecl.util.test import TestAreaContext from ecl.util.test.ecl_mock import createEclSum from ecl.summary import EclCmp -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class EclCmpTest(EclTest): def setUp(self): - self.root1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") - self.root2 = self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4") + self.root1 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE") + self.root2 = self.createTestPath("Equinor/ECLIPSE/Oseberg/F8MLT/F8MLT-F4") def test_not_existing(self): diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py index c04ef9ef9a..8038ad5711 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_equinor.py similarity index 97% rename from ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_equinor.py index 8cffcbc259..1c9e8bf4da 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_equinor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -22,14 +22,14 @@ from ecl import EclFileFlagEnum, EclFileEnum from ecl.eclfile import EclFile, FortIO, EclKW , openFortIO , openEclFile from ecl.util.test import TestAreaContext -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() -class EclFileStatoilTest(EclTest): +@equinor_test() +class EclFileEquinorTest(EclTest): def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.test_fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") + self.test_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") + self.test_fmt_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.FUNRST") def assertFileType(self , filename , expected): file_type , step , fmt_file = EclFile.getFileType(filename) @@ -159,7 +159,7 @@ class EclFileStatoilTest(EclTest): def test_ix_case(self): - f = EclFile( self.createTestPath( "Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well.SMSPEC")) + f = EclFile( self.createTestPath( "Equinor/ECLIPSE/ix/summary/Create_Region_Around_Well.SMSPEC")) # Keywords self.assertTrue( "KEYWORDS" in f ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py index 9be2c65c72..c17a2fa6ea 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -15,18 +15,18 @@ # for more details. -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl import EclFileFlagEnum from ecl.eclfile import Ecl3DKW, EclKW, EclInitFile, EclFile, FortIO from ecl.grid import EclGrid -@statoil_test() +@equinor_test() class InitFileTest(EclTest): def setUp(self): - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.init_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT") + 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): diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py index 7528b85b66..f2c084a5d4 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_equinor.py similarity index 91% rename from ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_equinor.py index 13b2d5d292..8593a64dcb 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_equinor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -20,7 +20,7 @@ from ecl import EclDataType, EclFileFlagEnum from ecl.eclfile import EclKW, EclFile, FortIO from ecl.util.test import TestAreaContext -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test def copy_long(): src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) @@ -32,10 +32,10 @@ def copy_offset(): copy = src.sub_copy(200, 100) -@statoil_test() +@equinor_test() class KWTest(EclTest): def test_fortio_size( self ): - unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + unrst_file_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") unrst_file = EclFile(unrst_file_path) size = 0 for kw in unrst_file: @@ -48,7 +48,7 @@ class KWTest(EclTest): def test_sub_copy(self): - unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + unrst_file_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") unrst_file = EclFile(unrst_file_path) swat = unrst_file["SWAT"][0] @@ -89,7 +89,7 @@ class KWTest(EclTest): self.assertFalse(kw1.equal(kw2)) self.assertFalse(kw1.equal_numeric(kw2)) - unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") + unrst_file_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") unrst_file = EclFile(unrst_file_path) kw1 = unrst_file["PRESSURE"][0] kw2 = kw1.deep_copy() diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py index 690ac7ba52..cb3f437ee2 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -15,19 +15,19 @@ # for more details. import datetime -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl import EclFileFlagEnum from ecl.eclfile import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO from ecl.grid import EclGrid -@statoil_test() +@equinor_test() class RestartFileTest(EclTest): def setUp(self): - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") - self.xrst_file10 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0010") - self.xrst_file20 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0020") + 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") + self.xrst_file10 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0010") + self.xrst_file20 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0020") def test_load(self): diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py index 80c69003b7..40c36bccda 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_ecl_sum.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -24,14 +24,14 @@ 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, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class EclSumTest(EclTest): def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + self.test_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") self.ecl_sum = EclSum(self.test_file) @@ -71,7 +71,7 @@ class EclSumTest(EclTest): def test_truncated_smspec(self): with TestAreaContext("EclSum/truncated_smspec") as ta: ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) file_size = os.path.getsize("ECLIPSE.SMSPEC") with open("ECLIPSE.SMSPEC","r+") as f: @@ -84,7 +84,7 @@ class EclSumTest(EclTest): def test_truncated_data(self): with TestAreaContext("EclSum/truncated_data") as ta: ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) file_size = os.path.getsize("ECLIPSE.UNSMRY") @@ -98,7 +98,7 @@ class EclSumTest(EclTest): def test_missing_smspec_keyword(self): with TestAreaContext("EclSum/truncated_data") as ta: ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) with openEclFile("ECLIPSE.SMSPEC") as f: kw_list = [] @@ -118,7 +118,7 @@ class EclSumTest(EclTest): def test_missing_unsmry_keyword(self): with TestAreaContext("EclSum/truncated_data") as ta: ta.copy_file(self.test_file) - ta.copy_file(self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) + ta.copy_file(self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNSMRY")) with openEclFile("ECLIPSE.UNSMRY") as f: kw_list = [] @@ -140,7 +140,7 @@ class EclSumTest(EclTest): def test_labscale(self): - case = self.createTestPath("Statoil/ECLIPSE/LabScale/HDMODEL") + case = self.createTestPath("Equinor/ECLIPSE/LabScale/HDMODEL") sum = EclSum(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)) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py index 90e799eb1b..8a72dd0452 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2013 Equinor ASA, Norway. # # The file 'test_ecl_sum_vector.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -23,14 +23,14 @@ except ImportError: import warnings from ecl.summary import EclSumVector, EclSum -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class EclSumVectorTest(EclTest): def setUp(self): - self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + self.test_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") self.ecl_sum = EclSum(self.test_file) def test_reportOnly_warns(self): @@ -38,7 +38,7 @@ class EclSumVectorTest(EclTest): warnings.simplefilter("always") vector = EclSumVector(self.ecl_sum, "FOPT", True) - self.assertEqual(len(w), 2) + self.assertEqual(len(w), 1) assert issubclass(w[-1].category, DeprecationWarning) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py index fc5c03d7dc..522afd7c8f 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py b/ThirdParty/Ert/python/tests/ecl_tests/test_equinor_faults.py similarity index 94% rename from ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_equinor_faults.py index 03c5b3210a..cdde627cb3 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_equinor_faults.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -26,13 +26,13 @@ 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, statoil_test +from tests import EclTest, equinor_test -@statoil_test() -class StatoilFaultTest(EclTest): +@equinor_test() +class EquinorFaultTest(EclTest): def loadGrid(self): - grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl") + 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) zcorn = EclKW.read_grdecl(fileH, "ZCORN") @@ -46,7 +46,7 @@ class StatoilFaultTest(EclTest): def test_load(self): grid = self.loadGrid() - faults_file = self.createTestPath("Statoil/ECLIPSE/Faults/faults.grdecl") + faults_file = self.createTestPath("Equinor/ECLIPSE/Faults/faults.grdecl") faults = FaultCollection( grid , faults_file ) for fault in faults: for layer in fault: diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py index 8e6ca732c4..7be4554098 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_equinor.py similarity index 85% rename from ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_equinor.py index 4b72f27be6..1c5e760579 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_equinor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -22,17 +22,17 @@ except ImportError: from ecl import EclDataType from ecl.eclfile import EclKW from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl.grid.faults import FaultBlock, FaultBlockLayer from cwrap import open as copen -@statoil_test() +@equinor_test() class FaultBlockTest(EclTest): def setUp(self): - self.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID")) - fileH = copen( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) + self.grid = EclGrid( 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 ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py b/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py index 5a65e9a0b1..240204d367 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py index d01c981463..3e484cac27 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # The file 'test_ecl_cell_containment.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py index 54a4b9fabe..842ac049b7 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # @@ -77,8 +77,7 @@ class FortIOTest(EclTest): kw1.fwrite(f) pos1 = f.getPosition( ) kw2.fwrite(f) - - t.sync( ) + # Truncate file in read mode; should fail hard. with openFortIO("file") as f: with self.assertRaises(IOError): @@ -121,8 +120,6 @@ class FortIOTest(EclTest): kw1.fwrite( f ) self.assertEqual( f.filename() , "file") - t.sync( ) - with openFortIO("file") as f: kw2 = EclKW.fread( f ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py b/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py index f991e88704..12a36297d8 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py @@ -22,7 +22,7 @@ def create_init(grid, case): porv.fwrite(f) -def create_restart(grid, case, p1, p2=None): +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[0] = 10 @@ -39,6 +39,13 @@ def create_restart(grid, case, p1, p2=None): header.fwrite(f) p.fwrite(f) + if rporv1: + rp = EclKW("RPORV", grid.getNumActive(), EclDataType.ECL_FLOAT) + for idx, val in enumerate(rporv1): + rp[idx] = val + + rp.fwrite(f) + if p2: seq_hdr[0] = 20 header[66] = 2010 @@ -49,6 +56,13 @@ def create_restart(grid, case, p1, p2=None): header.fwrite(f) p.fwrite(f) + if rporv2: + rp = EclKW("RPORV", grid.getNumActive(), EclDataType.ECL_FLOAT) + for idx, val in enumerate(rporv2): + rp[idx] = val + + rp.fwrite(f) + class GeertsmaTest(EclTest): @@ -145,4 +159,62 @@ class GeertsmaTest(EclTest): dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) np.testing.assert_almost_equal(dz, 5.819790154474284e-08) + @staticmethod + def test_geertsma_kernel_seabed(): + grid = EclGrid.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") + + restart_view1 = restart_file.restartView(sim_time=datetime.date(2000, 1, 1)) + + subsidence = EclSubsidence(grid, init) + subsidence.add_survey_PRESSURE("S1", restart_view1) + + youngs_modulus = 5E8 + poisson_ratio = 0.3 + seabed = 300 + above = 100 + topres = 2000 + receiver = (1000, 1000, topres - seabed - above) + + dz = subsidence.evalGeertsma("S1", None, receiver, youngs_modulus, poisson_ratio, 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)) + + with TestAreaContext("Subsidence"): + p1 = [1, 10] + p2 = [10, 20] + create_restart(grid, "TEST", + p1, p2, + rporv1=[10**5, 10**5], rporv2=[9*10**4, 9*10**4] + ) + create_init(grid, "TEST") + + init = EclFile("TEST.INIT") + restart_file = EclFile("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.add_survey_PRESSURE("S1", restart_view1) + subsidence.add_survey_PRESSURE("S2", restart_view2) + + youngs_modulus = 5E8 + poisson_ratio = 0.3 + seabed = 0 + receiver = (1000, 1000, 0) + + dz1 = subsidence.eval_geertsma_rporv("S1", None, receiver, youngs_modulus, poisson_ratio, seabed) + dz2 = subsidence.eval_geertsma_rporv("S2", None, receiver, youngs_modulus, poisson_ratio, seabed) + dz = subsidence.eval_geertsma_rporv("S1", "S2", receiver, youngs_modulus, poisson_ratio, seabed) + + np.testing.assert_almost_equal(dz, dz1-dz2) + self.assertTrue(dz > 0) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py index 58337e00ef..0473dbdc51 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # The file 'test_grdecl.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_equinor.py similarity index 93% rename from ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_equinor.py index a627d84cd9..35273b2220 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_equinor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -18,15 +18,15 @@ import os from ecl.eclfile import EclKW, Ecl3DKW from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from cwrap import open as copen -@statoil_test() -class GRDECLStatoilTest(EclTest): +@equinor_test() +class GRDECLEquinorTest(EclTest): def setUp(self): - self.src_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_permx.GRDECL") + self.src_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/include/example_permx.GRDECL") self.file_list = [] def addFile(self, filename): @@ -42,7 +42,7 @@ class GRDECLStatoilTest(EclTest): kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") self.assertTrue(kw) - grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) + grid = EclGrid( self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE" )) kw = Ecl3DKW.read_grdecl(grid , copen(self.src_file, "r"), "PERMX") self.assertTrue( isinstance( kw , Ecl3DKW )) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py index b3df4dee7c..2095fa2378 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -122,8 +122,8 @@ def average(points): return [elem/float(len(points)) for elem in p] # This test class should only have test cases which do not require -# external test data. Tests involving Statoil test data are in the -# test_grid_statoil module. +# external test data. Tests involving Equinor test data are in the +# test_grid_equinor module. class GridTest(EclTest): def test_oom_grid(self): diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor.py similarity index 94% rename from ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor.py index a925b6ac0b..74a9c3a2bc 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -30,21 +30,21 @@ 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, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class GridTest(EclTest): def egrid_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + return self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") def grid_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID") + return self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.GRID") def grdecl_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_grid_sim.GRDECL") + return self.createTestPath("Equinor/ECLIPSE/Gurbat/include/example_grid_sim.GRDECL") def test_loadFromFile(self): g1 = EclGrid.loadFromFile( self.egrid_file() ) @@ -277,7 +277,7 @@ class GridTest(EclTest): @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of numActive large memory skipped!") def test_num_active_large_memory(self): - case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") + case = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE") vecList = [] for i in range(12500): vec = DoubleVector() @@ -291,7 +291,7 @@ class GridTest(EclTest): def test_no_mapaxes_check_for_nan(self): - grid_paths = ["Statoil/ECLIPSE/NoMapaxes/ECLIPSE.EGRID", "Statoil/ECLIPSE/NoMapaxes/ECLIPSE.GRID"] + grid_paths = ["Equinor/ECLIPSE/NoMapaxes/ECLIPSE.EGRID", "Equinor/ECLIPSE/NoMapaxes/ECLIPSE.GRID"] for grid_path in grid_paths: test_grid_path = self.createTestPath(grid_path) @@ -309,7 +309,7 @@ class GridTest(EclTest): def test_valid_geometry(self): - grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/GRID_INVALID_CELL/PRED_RESEST_0_R_13_0.GRID")) + grid = EclGrid( self.createTestPath("Equinor/ECLIPSE/GRID_INVALID_CELL/PRED_RESEST_0_R_13_0.GRID")) self.assertTrue( grid.validCellGeometry( ijk = (27,0,0)) ) self.assertFalse( grid.validCellGeometry( ijk = (0,0,0)) ) @@ -328,7 +328,7 @@ class GridTest(EclTest): def test_lgr_get(self): - grid = EclGrid(self.createTestPath("Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID")) + grid = EclGrid(self.createTestPath("Equinor/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID")) for (nr,name) in [ ( 104 , "LG003017"), (2 , "LG006024"), ( 4 , "LG005025"), diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_coarse.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_coarse.py similarity index 84% rename from ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_coarse.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_coarse.py index 11f94ebc90..29029f0ad9 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_coarse.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_coarse.py @@ -1,6 +1,6 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # -# The file 'test_grid_statoil_coarse.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_grid_equinor_coarse.py' 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 @@ -18,17 +18,17 @@ import math from ecl.util.test import TestAreaContext from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class GridCoarceTest(EclTest): def test_coarse(self): #work_area = TestArea("python/grid-test/testCoarse") with TestAreaContext("python/grid-test/testCoarse"): testGRID = True - g1 = EclGrid(self.createTestPath("Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2.EGRID")) + g1 = EclGrid(self.createTestPath("Equinor/ECLIPSE/LGCcase/LGC_TESTCASE2.EGRID")) g1.save_EGRID("LGC.EGRID") g2 = EclGrid("LGC.EGRID") diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_dual.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_dual.py similarity index 84% rename from ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_dual.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_dual.py index eeb907c075..d962448953 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_dual.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_dual.py @@ -1,6 +1,6 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # -# The file 'test_grid_statoil_dual.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_grid_equinor_dual.py' 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 @@ -18,16 +18,16 @@ import math from ecl.util.test import TestAreaContext from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class GridDualTest(EclTest): def egrid_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + return self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") def grid_file(self): - return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID") + return self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.GRID") def test_dual(self): with TestAreaContext("python/grid-test/testDual"): @@ -39,11 +39,11 @@ class GridDualTest(EclTest): self.assertFalse(grid.dualGrid()) self.assertTrue(grid.getNumActiveFracture() == 0) - dgrid = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUALPOR_MSW.EGRID")) + dgrid = EclGrid(self.createTestPath("Equinor/ECLIPSE/DualPoro/DUALPOR_MSW.EGRID")) self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) self.assertTrue(dgrid.getNumActive() == 46118) - dgrid2 = EclGrid(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUALPOR_MSW.GRID")) + dgrid2 = EclGrid(self.createTestPath("Equinor/ECLIPSE/DualPoro/DUALPOR_MSW.GRID")) self.assertTrue(dgrid.getNumActive() == dgrid.getNumActiveFracture()) self.assertTrue(dgrid.getNumActive() == 46118) self.assertTrue(dgrid.equal(dgrid2)) @@ -52,7 +52,7 @@ class GridDualTest(EclTest): # 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(self.createTestPath("Statoil/ECLIPSE/DualPoro/DUAL_DIFF.EGRID")) + dgrid = EclGrid(self.createTestPath("Equinor/ECLIPSE/DualPoro/DUAL_DIFF.EGRID")) self.assertTrue(dgrid.getNumActive() == 106) self.assertTrue(dgrid.getNumActiveFracture() == 105) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_large_case.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_large_case.py similarity index 78% rename from ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_large_case.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_large_case.py index 09b4b366df..3545e1b529 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil_large_case.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_equinor_large_case.py @@ -1,6 +1,6 @@ -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # -# The file 'test_grid_statoil_large_case.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_grid_equinor_large_case.py' 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 @@ -18,12 +18,12 @@ import math from ecl.util.test import TestAreaContext from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class GridLargeCaseTest(EclTest): def test_large_case(self): - grdecl_file = self.createTestPath("Statoil/ECLIPSE/1.6.0_issueGrdecl/test_aug2016_gridOnly.grdecl") + grdecl_file = self.createTestPath("Equinor/ECLIPSE/1.6.0_issueGrdecl/test_aug2016_gridOnly.grdecl") grid = EclGrid.loadFromGrdecl( grdecl_file ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py index 9289003bc5..cf55ffcf43 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # The file 'test_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_pandas.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_pandas.py index f02bdb8f17..f73e1b6b5f 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_pandas.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_pandas.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2018 Statoil ASA, Norway. +# Copyright (C) 2018 Equinor ASA, Norway. # # The file 'test_grid.pandas' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py b/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py index 21f8452be8..5b42387c04 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'test_kw_function.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py b/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py index 0c8aabf6f7..9b4b6a55a3 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. +# Copyright (C) 2014 Equinor ASA, Norway. # # The file 'test_layer.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py b/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py index 43bd77493f..1b64680e43 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -29,11 +29,11 @@ from ecl.summary import EclNPV , NPVPriceVector from ecl.util.util import StringList, TimeVector, DoubleVector , CTime from ecl.util.test import TestAreaContext -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test base = "ECLIPSE" -path = "Statoil/ECLIPSE/Gurbat" +path = "Equinor/ECLIPSE/Gurbat" case = "%s/%s" % (path, base) def callable(x): @@ -45,7 +45,7 @@ def linear1(x): def linear2(x): return 2*x -@statoil_test() +@equinor_test() class NPVTest(EclTest): def setUp(self): self.case = self.createTestPath(case) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_region.py b/ThirdParty/Ert/python/tests/ecl_tests/test_region.py index 6c38697115..d077ae9dca 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_region.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_region.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_region_equinor.py similarity index 96% rename from ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_region_equinor.py index 16fc04090a..2ede1f71e6 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_region_equinor.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2012 Statoil ASA, Norway. +# Copyright (C) 2012 Equinor ASA, Norway. # # The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -17,13 +17,13 @@ from ecl.eclfile import EclFile from ecl.grid import EclGrid, EclRegion from ecl.grid.faults import Layer -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class RegionTest(EclTest): def setUp(self): - case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") + 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) @@ -166,7 +166,7 @@ class RegionTest(EclTest): def test_heidrun(self): - root = self.createTestPath("Statoil/ECLIPSE/Heidrun") + root = self.createTestPath("Equinor/ECLIPSE/Heidrun") grid = EclGrid( "%s/FF12_2013B2_AMAP_AOP-J15_NO62_MOVEX.EGRID" % root) polygon = [] diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py b/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py index db480ffe82..9cc5eea2ae 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py @@ -16,8 +16,6 @@ class Removed_2_1_Test(EclTest): with openFortIO("TEST" , mode = FortIO.WRITE_MODE) as f: kw.fwrite( f ) - t.sync() - f = EclFile( "TEST" ) with self.assertRaises(NotImplementedError): f.select_block( "KW" , 100 ) @@ -33,4 +31,4 @@ class Removed_2_1_Test(EclTest): with self.assertRaises(NotImplementedError): EclFile.restart_block( "TEST" ) - + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py b/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py index 32fa276aec..c28164a1b1 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -18,18 +18,18 @@ from _ctypes import ArgumentError import os import datetime from ecl.eclfile import EclFile -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class RestartTest(EclTest): def setUp(self): - self.xfile0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") - self.u_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + self.xfile0 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0000") + self.u_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") + self.fmt_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.FUNRST") + self.grid_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") self.file_list = [] def addFile( self, filename ): diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py b/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py index c1683f6d41..b92e3cabfe 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -15,17 +15,17 @@ # for more details. import datetime -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl import EclFileFlagEnum from ecl.eclfile import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO from ecl.grid import EclGrid -@statoil_test() +@equinor_test() class RestartHeadTest(EclTest): def setUp(self): - self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") + 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 ) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py index b903f3d78f..f4bf29b003 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py @@ -1,19 +1,19 @@ #!/usr/bin/env python -# Copyright (C) 2016 Statoil ASA, Norway. -# +# Copyright (C) 2016 Equinor ASA, Norway. +# # The file 'test_rft.py' 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ERT is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. -# -# See the GNU General Public License at -# for more details. +# +# ERT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ERT is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU General Public License at +# for more details. import datetime @@ -32,5 +32,5 @@ class RFTTest(EclTest): def test_repr(self): rft = EclRFT( "WELL" , "RFT" , datetime.date(2015 , 10 , 1 ) , 100 ) - pfx = 'EclRFT(completed_cells = 0, date = 2015-10-01, RFT, MSW)' + pfx = 'EclRFT(completed_cells = 0, date = 2015-10-01, RFT)' self.assertEqual(pfx, repr(rft)[:len(pfx)]) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py index 67fb0c0062..ba0cc007bc 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013 Statoil ASA, Norway. +# Copyright (C) 2013 Equinor ASA, Norway. # # The file 'test_rft_cell.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -27,8 +27,8 @@ from tests import EclTest class RFTCellTest(EclTest): def setUp(self): - self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") - self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") + self.RFT_file = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.RFT") + self.PLT_file = self.createTestPath("Equinor/ECLIPSE/RFT/TEST1_1A.RFT") def test_RFT_cell(self): i = 10 diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_equinor.py similarity index 81% rename from ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_rft_equinor.py index e097551a44..051ee0582a 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_equinor.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # -# The file 'test_rft_statoil.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_rft_equinor.py' 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 @@ -18,14 +18,14 @@ from __future__ import print_function import datetime from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, WellTrajectory -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test -@statoil_test() +@equinor_test() class RFTTest(EclTest): def setUp(self): - self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") - self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") + 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): @@ -53,10 +53,6 @@ class RFTTest(EclTest): for cell in rft: self.assertIsInstance(cell, EclRFTCell) - cell0 = rft.iget_sorted(0) - self.assertIsInstance(cell, EclRFTCell) - rft.sort() - for h in rftFile.getHeaders(): print(h) self.assertIsInstance(h[1], datetime.date) @@ -81,7 +77,7 @@ class RFTTest(EclTest): def test_basics(self): - wt = WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt")) + wt = WellTrajectory(self.createTestPath("Equinor/ert-equinor/spotfire/gendata_rft_zone/E-3H.txt")) self.assertEqual(len(wt), 38) self.assertTrue(isinstance(str(wt), str)) self.assertTrue(isinstance(repr(wt), str)) @@ -92,12 +88,12 @@ class RFTTest(EclTest): WellTrajectory("/does/no/exist") with self.assertRaises(UserWarning): - WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/invalid_float.txt")) + WellTrajectory(self.createTestPath("Equinor/ert-equinor/spotfire/gendata_rft_zone/invalid_float.txt")) with self.assertRaises(UserWarning): - WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/missing_item.txt")) + WellTrajectory(self.createTestPath("Equinor/ert-equinor/spotfire/gendata_rft_zone/missing_item.txt")) - wt = WellTrajectory(self.createTestPath("Statoil/ert-statoil/spotfire/gendata_rft_zone/E-3H.txt")) + wt = WellTrajectory(self.createTestPath("Equinor/ert-equinor/spotfire/gendata_rft_zone/E-3H.txt")) self.assertEqual(len(wt), 38) with self.assertRaises(IndexError): @@ -115,7 +111,7 @@ class RFTTest(EclTest): def test_PLT(self): - rft_file = EclRFTFile(self.createTestPath("Statoil/ECLIPSE/Heidrun/RFT/2C3_MR61.RFT")) + rft_file = EclRFTFile(self.createTestPath("Equinor/ECLIPSE/Heidrun/RFT/2C3_MR61.RFT")) rft0 = rft_file[0] rft1 = rft_file[1] diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py index b29c8e0da9..5c33c87d04 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -22,8 +22,19 @@ import csv import shutil import cwrap import stat +import pandas + +def assert_frame_equal(a,b): + if not a.equals(b): + raise AssertionError("Expected dataframes to be equal") + +try: + from pandas.testing import assert_frame_equal +except ImportError: + pass + from contextlib import contextmanager -from unittest import skipIf, skipUnless, skipIf +from unittest import skipIf, skipUnless from ecl import EclUnitTypeEnum from ecl import EclDataType @@ -78,6 +89,21 @@ def create_case(case = "CSV", restart_case = None, restart_step = -1, data_start restart_case = restart_case, restart_step = restart_step) +def create_case2(case = "CSV", restart_case = None, restart_step = -1, data_start = None): + length = 100 + return createEclSum(case , [("WOPT", "OPX" , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY"), ("BPR" , None , 10, "SM3"), ("RPR", None, 3, "BARS"), ("COPR", "OPX", 421, "BARS")], + sim_length_days = length, + num_report_step = 10, + num_mini_step = 10, + data_start = data_start, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FGPT" : fgpt }, + restart_case = restart_case, + restart_step = restart_step) + + + class SumTest(EclTest): @@ -101,19 +127,26 @@ class SumTest(EclTest): def test_identify_var_type(self): - self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.hpp") + self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/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( EclSum.varType("RXFT"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR) + self.assertEqual( EclSum.varType("RxxFT"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR) + self.assertEqual( EclSum.varType("RXFR"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR) + self.assertEqual( EclSum.varType("RxxFR"), EclSumVarType.ECL_SMSPEC_REGION_2_REGION_VAR) + self.assertEqual( EclSum.varType("RORFR"), EclSumVarType.ECL_SMSPEC_REGION_VAR) + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY"), ("AARQ" , None , 10, "???"), - ("RGPT" , None ,1, "SM3")]) + ("RGPT" , None ,1, "SM3")]) node1 = case.smspec_node( "FOPT" ) self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR ) + self.assertIsNone(node1.wgname) node2 = case.smspec_node( "AARQ:10" ) self.assertEqual( node2.varType( ) , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) @@ -549,6 +582,24 @@ class SumTest(EclTest): self.assertEqual(len(case), rows) + def test_csv_load(self): + case = create_case2() + frame = case.pandas_frame() + ecl_sum = EclSum.from_pandas("PANDAS", frame, dims=[20,10,5]) + + for key in frame.columns: + self.assertTrue(key in ecl_sum) + + df = ecl_sum.pandas_frame() + assert_frame_equal(frame, df) + + ecl_sum_less = EclSum.from_pandas("PANDAS", frame, dims=[20,10,5], headers=['BPR:10', 'RPR:3,1,1', 'COPR:OPX:1,2,3']) + del frame['WOPT:OPX'] + del frame['FOPR'] + df_less = ecl_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")) @@ -568,8 +619,6 @@ class SumTest(EclTest): for time_index,value in enumerate(fopr): self.assertEqual(fopr[time_index], value) - - 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 ) @@ -578,10 +627,55 @@ class SumTest(EclTest): case.fwrite( ) - def test_directory_conflict(self): with TestAreaContext("dir_conflict"): case = create_case("UNITS") case.fwrite() os.mkdir("UNITS") case2 = EclSum("./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 + + time_points = TimeVector() + + path = os.path.join(self.TESTDATA_ROOT, "local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3") + ecl_sum = EclSum( 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) + delta = end_time - start_time + + N = 25 + time_points.initRange( CTime(start_time), + CTime(end_time), + CTime(int(delta.total_seconds()/(N - 1)))) + time_points.append(CTime(end_time)) + resampled = ecl_sum.resample( "OUTPUT_CASE", time_points, lower_extrapolation=True, upper_extrapolation=True ) + + for key in ecl_sum.keys(): + self.assertIn( key, resampled ) + + self.assertEqual(ecl_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(): + self.assertFloatEqual(resampled.iget( key_not_rate, time_index), ecl_sum._get_first_value(key_not_rate)) + elif t > ecl_sum.get_end_time(): + self.assertFloatEqual(resampled.iget( key_not_rate, time_index), ecl_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)) + + key_rate = "FOPR" + for time_index,t in enumerate(time_points): + if t < ecl_sum.get_data_start_time(): + self.assertFloatEqual(resampled.iget( key_rate, time_index), 0) + elif t > ecl_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)) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum_equinor.py similarity index 93% rename from ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_sum_equinor.py index 477d5135e3..aa1e6454d8 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum_equinor.py @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. # @@ -26,11 +26,11 @@ from ecl import EclUnitTypeEnum from ecl.util.util import StringList, TimeVector, DoubleVector, CTime from ecl.util.test import TestAreaContext -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test import csv base = "ECLIPSE" -path = "Statoil/ECLIPSE/Gurbat" +path = "Equinor/ECLIPSE/Gurbat" case = "%s/%s" % (path, base) @@ -42,7 +42,7 @@ def sum_get(*args): vec = sum[key] -@statoil_test() +@equinor_test() class SumTest(EclTest): def setUp(self): self.case = self.createTestPath(case) @@ -110,7 +110,7 @@ class SumTest(EclTest): def test_LLINEAR(self): - sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/LGRISSUE/EM-LTAA-ISEG_CARFIN_NWPROPS")) + sum = EclSum( self.createTestPath("Equinor/ECLIPSE/Heidrun/LGRISSUE/EM-LTAA-ISEG_CARFIN_NWPROPS")) self.assertTrue( sum.has_key("LLINEARS") ) @@ -163,7 +163,7 @@ class SumTest(EclTest): def test_dates2( self ): - sum = EclSum(self.createTestPath("Statoil/ECLIPSE/FF12/FF12_2013B3_AMAP2")) + sum = EclSum(self.createTestPath("Equinor/ECLIPSE/FF12/FF12_2013B3_AMAP2")) self.assertEqual(sum.end_date , datetime.date(2045, 1, 1)) @@ -216,9 +216,9 @@ class SumTest(EclTest): def test_restart(self): - hist = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/history/T07-4A-W2011-18-P1")) - base = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/prediction/BASECASE")) - pred = EclSum(self.createTestPath("Statoil/ECLIPSE/sum-restart/prediction/BASECASE"), include_restart=False) + hist = EclSum(self.createTestPath("Equinor/ECLIPSE/sum-restart/history/T07-4A-W2011-18-P1")) + base = EclSum(self.createTestPath("Equinor/ECLIPSE/sum-restart/prediction/BASECASE")) + pred = EclSum(self.createTestPath("Equinor/ECLIPSE/sum-restart/prediction/BASECASE"), include_restart=False) self.assertIsNotNone(hist) self.assertIsNotNone(base) @@ -311,7 +311,7 @@ class SumTest(EclTest): def test_segment(self): - sum = EclSum(self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4")) + sum = EclSum(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: @@ -365,7 +365,7 @@ class SumTest(EclTest): # Loading this dataset is a test of loading a case where one report step is missing. def test_Heidrun(self): - sum = EclSum( self.createTestPath("Statoil/ECLIPSE/Heidrun/Summary/FF12_2013B3_CLEAN_RS")) + sum = EclSum( self.createTestPath("Equinor/ECLIPSE/Heidrun/Summary/FF12_2013B3_CLEAN_RS")) self.assertEqual( 452 , len(sum)) self.assertFloatEqual( 1.8533144e+8 , sum.last_value("FOPT")) @@ -422,13 +422,13 @@ class SumTest(EclTest): def test_aquifer(self): - case = EclSum( self.createTestPath( "Statoil/ECLIPSE/Aquifer/06_PRESSURE_R009-0")) + case = EclSum( self.createTestPath( "Equinor/ECLIPSE/Aquifer/06_PRESSURE_R009-0")) self.assertTrue( "AAQR:2" in case ) def test_restart_mapping(self): - history = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") ) - total = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/Prediction/NOR-2013A_R007_PRED-0") , include_restart = True) + history = EclSum( self.createTestPath( "Equinor/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0") ) + total = EclSum( self.createTestPath( "Equinor/ECLIPSE/SummaryRestart/Prediction/NOR-2013A_R007_PRED-0") , include_restart = True) history_dates = history.get_dates( ) total_dates = total.get_dates( ) @@ -449,7 +449,7 @@ class SumTest(EclTest): def test_write(self): with TestAreaContext("my_space") as area: - intersect_summary = EclSum( self.createTestPath( "Statoil/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0"), lazy_load=False ) + intersect_summary = EclSum( self.createTestPath( "Equinor/ECLIPSE/SummaryRestart/iter-1/NOR-2013A_R007-0"), lazy_load=False ) self.assertIsNotNone(intersect_summary) write_location = os.path.join(os.getcwd(), "CASE") @@ -459,7 +459,7 @@ class SumTest(EclTest): self.assertEqual(intersect_summary.keys(), reloaded_summary.keys()) def test_ix_case(self): - intersect_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL")) + intersect_summary = EclSum(self.createTestPath("Equinor/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL")) self.assertIsNotNone(intersect_summary) self.assertTrue( @@ -467,7 +467,7 @@ class SumTest(EclTest): [intersect_summary.smspec_node(key).wgname for key in intersect_summary.keys()] ) - eclipse_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/ECL100/E100_CREATE_REGION_AROUND_WELL")) + eclipse_summary = EclSum(self.createTestPath("Equinor/ECLIPSE/ix/summary/ECL100/E100_CREATE_REGION_AROUND_WELL")) self.assertIsNotNone(eclipse_summary) hwell_padder = lambda key : key if key.split(":")[-1] != "HWELL_PR" else key + "OD" @@ -478,8 +478,8 @@ class SumTest(EclTest): def test_ix_write(self): for data_set in [ - "Statoil/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL", - "Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC" + "Equinor/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL", + "Equinor/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC" ]: with TestAreaContext("my_space" + data_set.split("/")[-1]) as area: @@ -496,7 +496,7 @@ class SumTest(EclTest): ) def test_ix_caseII(self): - troll_summary = EclSum( self.createTestPath("Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC")) + troll_summary = EclSum( self.createTestPath("Equinor/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC")) self.assertIsNotNone(troll_summary) self.assertTrue("WMCTL:Q21BH1" in list(troll_summary.keys())) @@ -525,7 +525,6 @@ class SumTest(EclTest): for time_index,t in enumerate(time_points): self.assertFloatEqual(resampled.iget( key, time_index), self.ecl_sum.get_interp_direct( key, t)) - def test_summary_units(self): self.assertEqual(self.ecl_sum.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) @@ -534,4 +533,4 @@ class SumTest(EclTest): # which was shut down brutally. This test verifies that we # can create a valid ecl_sum instance from what we find. def test_broken_case(self): - ecl_sum = EclSum( self.createTestPath("Statoil/ECLIPSE/SummaryFail3/COMBINED-AUTUMN2018_CARBSENS-0")) + ecl_sum = EclSum( self.createTestPath("Equinor/ECLIPSE/SummaryFail3/COMBINED-AUTUMN2018_CARBSENS-0")) diff --git a/ThirdParty/Ert/python/tests/global_tests/test_import.py b/ThirdParty/Ert/python/tests/global_tests/test_import.py index 6681589a8d..ef3c3b5eb5 100644 --- a/ThirdParty/Ert/python/tests/global_tests/test_import.py +++ b/ThirdParty/Ert/python/tests/global_tests/test_import.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/global_tests/test_pylint.py b/ThirdParty/Ert/python/tests/global_tests/test_pylint.py index 1dac7dafaf..ce93f60934 100644 --- a/ThirdParty/Ert/python/tests/global_tests/test_pylint.py +++ b/ThirdParty/Ert/python/tests/global_tests/test_pylint.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 Statoil ASA, Norway. +# Copyright (C) 2017 Equinor ASA, Norway. # # This file is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_test.py b/ThirdParty/Ert/python/tests/legacy_tests/test_test.py index 1b75b2941f..ba588d6333 100644 --- a/ThirdParty/Ert/python/tests/legacy_tests/test_test.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_test.py @@ -2,7 +2,6 @@ from ert.test import TestRun from ert.test import path_exists from ert.test import SourceEnumerator from ert.test import TestArea , TestAreaContext -from ert.test import TempArea , TempAreaContext from ert.test import ErtTestRunner from ert.test import PathContext from ert.test import LintTestCase diff --git a/ThirdParty/Ert/python/tests/util_tests/test_rng.py b/ThirdParty/Ert/python/tests/util_tests/test_rng.py index 2a4f786705..70148013c5 100644 --- a/ThirdParty/Ert/python/tests/util_tests/test_rng.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_rng.py @@ -37,7 +37,6 @@ class RngTest(EclTest): with TestAreaContext("rng_state") as t: rng.saveState( "rng.txt" ) - t.sync() val1 = rng.getInt() val2 = rng.getInt() rng.loadState( "rng.txt" ) diff --git a/ThirdParty/Ert/python/tests/util_tests/test_vectors.py b/ThirdParty/Ert/python/tests/util_tests/test_vectors.py index 47d306aacd..e16cfcea75 100644 --- a/ThirdParty/Ert/python/tests/util_tests/test_vectors.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_vectors.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2011 Equinor ASA, Norway. # # The file 'test_vectors.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/util_tests/test_version.py b/ThirdParty/Ert/python/tests/util_tests/test_version.py index c0864b4a20..0a82658b86 100644 --- a/ThirdParty/Ert/python/tests/util_tests/test_version.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_version.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Statoil ASA, Norway. +# Copyright (C) 2015 Equinor ASA, Norway. # # The file 'test_version.py' is part of ERT - Ensemble based Reservoir Tool. # diff --git a/ThirdParty/Ert/python/tests/util_tests/test_work_area.py b/ThirdParty/Ert/python/tests/util_tests/test_work_area.py index 0d7a69bae5..1a89ac7621 100644 --- a/ThirdParty/Ert/python/tests/util_tests/test_work_area.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_work_area.py @@ -1,21 +1,21 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# +# Copyright (C) 2014 Equinor ASA, Norway. +# # The file 'test_work_area.py' 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ERT is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. -# -# See the GNU General Public License at +# +# ERT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ERT is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU General Public License at # for more details. -import os.path +import os.path import os try: @@ -23,7 +23,7 @@ try: except ImportError: from unittest import skipIf -from ecl.util.test import TestAreaContext, TempAreaContext +from ecl.util.test import TestAreaContext from tests import EclTest @@ -33,39 +33,20 @@ class WorkAreaTest(EclTest): with TestAreaContext("TestArea") as test_area: with open("test_file" , "w") as fileH: fileH.write("Something") - + self.assertTrue( os.path.isfile( "test_file") ) - + with self.assertRaises(IOError): full_path = test_area.getFullPath( "does/not/exists" ) with self.assertRaises(IOError): full_path = test_area.getFullPath( "/already/absolute" ) - + full_path = test_area.getFullPath( "test_file" ) self.assertTrue( os.path.isfile( full_path )) self.assertTrue( os.path.isabs( full_path )) - - def test_temp_area(self): - with TestAreaContext("TestArea") as test_area: - cwd = os.getcwd() - with open("file.txt" , "w") as f: - f.write("File") - - with TempAreaContext("TempArea") as temp_area: - self.assertEqual( cwd, os.getcwd()) - self.assertEqual( cwd, temp_area.get_cwd()) - temp_area.copy_file( "file.txt" ) - self.assertTrue( os.path.isfile( os.path.join( temp_area.getPath( ) , "file.txt"))) - - os.mkdir("tmp") - os.chdir("tmp") - - self.assertEqual( os.getcwd() , os.path.join( cwd , "tmp")) - - def test_IOError(self): with TestAreaContext("TestArea") as test_area: with self.assertRaises(IOError): @@ -86,40 +67,33 @@ class WorkAreaTest(EclTest): with self.assertRaises(IOError): test_area.copy_directory( "path1/file.txt" ) - - def test_sync(self): - with TestAreaContext("test_sync") as t: - with open("file.txt" , "w") as f: - f.write("content") - t.sync() - self.assertTrue( os.path.isfile( "file.txt")) - + def test_multiple_areas(self): original_dir = os.getcwd() context_dirs = [] for i in range(3): loop_dir = os.getcwd() - self.assertEqual(loop_dir, original_dir, + self.assertEqual(loop_dir, original_dir, 'Wrong folder before creating TestAreaContext. Loop: {} -- CWD: {} ' .format(i, loop_dir)) - + with TestAreaContext("test_multiple_areas") as t: t_dir = t.get_cwd() - - self.assertNotIn(t_dir, context_dirs, + + self.assertNotIn(t_dir, context_dirs, 'Multiple TestAreaContext objects in the same folder. Loop {} -- CWD: {}' .format(i, loop_dir)) context_dirs.append(t_dir) - + # It is possible to make the following assert fail, but whoever run the tests should # try really really hard to make that happen - self.assertNotEqual(t_dir, original_dir, + self.assertNotEqual(t_dir, original_dir, 'TestAreaContext in the current working directory. Loop: {} -- CWD: {}' - .format(i, loop_dir)) - + .format(i, loop_dir)) + loop_dir = os.getcwd() - self.assertEqual(loop_dir, original_dir, + self.assertEqual(loop_dir, original_dir, 'Wrong folder after creating TestAreaContext. Loop: {} -- CWD: {} ' .format(i, loop_dir)) - + diff --git a/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt index 00d362918c..f943b5d5f4 100644 --- a/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt +++ b/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt @@ -3,6 +3,7 @@ set(TEST_SOURCES test_ecl_well.py test_ecl_well2.py test_ecl_well3.py + test_well_missing_ICON.py ) add_python_package("python.tests.well_tests" ${PYTHON_INSTALL_PREFIX}/tests/well_tests "${TEST_SOURCES}" False) @@ -10,3 +11,4 @@ add_python_package("python.tests.well_tests" ${PYTHON_INSTALL_PREFIX}/tests/wel addPythonTest(tests.well_tests.test_ecl_well.EclWellTest) addPythonTest(tests.well_tests.test_ecl_well2.EclWellTest2) addPythonTest(tests.well_tests.test_ecl_well3.EclWellTest3) +addPythonTest(tests.well_tests.test_well_missing_ICON.EclWellICONTest) diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py index cb3b5c3038..391fe05c52 100644 --- a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py @@ -2,11 +2,11 @@ import datetime from ecl import EclFileFlagEnum from ecl.eclfile import EclFile from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl.util.util.ctime import CTime from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment -@statoil_test() +@equinor_test() class EclWellTest(EclTest): ALL_WELLS = ['E5H', 'G1H', 'M41', 'J41', 'D10H', 'P41', 'L41', 'M42', 'S41', 'S13H', 'Q12HT2', 'O41', 'L11H', 'Q21H', 'E6CH', 'D4Y1H', 'D4Y2H', 'I13Y1H', 'Q21AY1H', 'F5AH', 'O14Y4HT2', 'K24Y1H', 'K24Y3H', 'S21H', 'N11H', @@ -39,8 +39,8 @@ class EclWellTest(EclTest): def getWellInfoWithNoWellSegments(self): """ @rtype: WellInfo """ if EclWellTest.__well_info_with_no_well_segments is None: - grid_path = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") - rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") + grid_path = self.createTestPath("Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") + rst_path_1 = self.createTestPath("Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") grid = EclGrid(grid_path) @@ -54,8 +54,8 @@ class EclWellTest(EclTest): def getWellInfo(self): """ @rtype: WellInfo """ if EclWellTest.__well_info is None: - grid_path = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") - rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") + grid_path = self.createTestPath("Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.EGRID") + rst_path_1 = self.createTestPath("Equinor/ECLIPSE/Troll/MSW/T07-4A-W2012-16-F3.X0135") grid = EclGrid(grid_path) @@ -68,7 +68,7 @@ class EclWellTest(EclTest): def test_no_such_well(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") + 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) @@ -78,11 +78,11 @@ class EclWellTest(EclTest): _ = WellInfo(grid, [rst_path1, rst_path2]) def test_construction(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - rst_path_1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0011") - rst_path_2 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0022") - rst_path_3 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0035") - rst_path_4 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0061") + grid_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") + rst_path_1 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0011") + rst_path_2 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0022") + rst_path_3 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0035") + rst_path_4 = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.X0061") grid = EclGrid(grid_path) @@ -449,7 +449,7 @@ class EclWellTest(EclTest): def test_load_broken_direction(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.EGRID") - rst_path = self.createTestPath("Statoil/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.UNRST") + grid_path = self.createTestPath("Equinor/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.EGRID") + rst_path = self.createTestPath("Equinor/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.UNRST") grid = EclGrid(grid_path) well_info = WellInfo(grid, rst_path) diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py index 554e18bda2..2535228939 100644 --- a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py @@ -4,19 +4,19 @@ import os.path from ecl import EclFileFlagEnum from ecl.eclfile import EclFile from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl.util.util.ctime import CTime from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment -@statoil_test() +@equinor_test() class EclWellTest2(EclTest): grid = None def getGrid(self): if EclWellTest2.grid is None: - EclWellTest2.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID")) + EclWellTest2.grid = EclGrid( self.createTestPath("Equinor/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID")) return EclWellTest2.grid @@ -25,7 +25,7 @@ class EclWellTest2(EclTest): segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529, 128.534 , 165.33 , 59.97 , 936.719 ] - well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Statoil/ECLIPSE/Troll/Ref2014" , rst_file ))) + well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Equinor/ECLIPSE/Troll/Ref2014" , rst_file ))) well_time_line = well_info["F4BYH"] for well_state in well_time_line: self.assertTrue( well_state.isMultiSegmentWell() ) diff --git a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py index 9252f111d6..027cfc47cf 100644 --- a/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py @@ -4,18 +4,18 @@ import os.path from ecl.eclfile import EclFile from ecl.grid import EclGrid from ecl.summary import EclSum -from tests import EclTest, statoil_test +from tests import EclTest, equinor_test from ecl.util.util.ctime import CTime from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment -@statoil_test() +@equinor_test() class EclWellTest3(EclTest): grid = None def test_rates(self): - grid_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") - rst_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") - sum_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") + grid_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.EGRID") + rst_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.UNRST") + sum_path = self.createTestPath("Equinor/ECLIPSE/Gurbat/ECLIPSE.SMSPEC") grid = EclGrid(grid_path) well_info = WellInfo(grid, rst_path) diff --git a/ThirdParty/Ert/python/tests/well_tests/test_well_missing_ICON.py b/ThirdParty/Ert/python/tests/well_tests/test_well_missing_ICON.py new file mode 100644 index 0000000000..28cb69d1af --- /dev/null +++ b/ThirdParty/Ert/python/tests/well_tests/test_well_missing_ICON.py @@ -0,0 +1,28 @@ +import datetime +from tests import EclTest +from ecl.grid import EclGridGenerator +from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment + + + + +class EclWellICONTest(EclTest): + + def setUp(self): + self.grid = EclGridGenerator.create_rectangular((46,112,22), (1,1,1)) + self.rst_file_ICON0 = self.createTestPath("local/ECLIPSE/well/missing-ICON/ICON0.X0027") + self.rst_file_ICON1 = self.createTestPath("local/ECLIPSE/well/missing-ICON/ICON1.X0027") + + + def check_connections(self, well_info, expected): + well = well_info["B-2H"] + well_state = well[0] + self.assertEqual( well_state.hasGlobalConnections(), expected) + + + def test_missing_icon(self): + well_info_ICON0 = WellInfo(self.grid, self.rst_file_ICON0) + well_info_ICON1 = WellInfo(self.grid, self.rst_file_ICON1) + + self.check_connections(well_info_ICON0, False) + self.check_connections(well_info_ICON1, True) diff --git a/ThirdParty/Ert/python/txt-doc/README.txt b/ThirdParty/Ert/python/txt-doc/README.txt new file mode 100644 index 0000000000..7a7a6b294a --- /dev/null +++ b/ThirdParty/Ert/python/txt-doc/README.txt @@ -0,0 +1,4 @@ +The files 'devel.txt', 'import.txt', 'tips.txt' and 'install.txt' in the 'txt-doc/' +directory are old text files with documentation. The content of these files is - +to a varyiing degree - relevant and valuable, but it should be integrated into +the rst files, and then deleted. diff --git a/ThirdParty/Ert/python/doc/devel.txt b/ThirdParty/Ert/python/txt-doc/devel.txt similarity index 99% rename from ThirdParty/Ert/python/doc/devel.txt rename to ThirdParty/Ert/python/txt-doc/devel.txt index 7bae061d39..0b72477791 100644 --- a/ThirdParty/Ert/python/doc/devel.txt +++ b/ThirdParty/Ert/python/txt-doc/devel.txt @@ -13,7 +13,7 @@ Developer documentation 4.2 Prototyping 4.3 Python classes 5 Garbage collection and 'data_owner' - 6 Installation in Statoil + 6 Installation in Equinor @@ -210,12 +210,12 @@ The following excerpt from ecl_kw.y illustrates this: # Load the shared library import libecl <--- Step 1 - Class EclKW: <-------------· + Class EclKW: <-------------� # Pure Python code to implement the EclKW class, | # based on the functions prototyped below. | Step 3 - .... <-------------· + .... <-------------� - # Create a wrapper instance which wraps the libecl library. <--------· + # Create a wrapper instance which wraps the libecl library. <--------� cwrapper = CWrapper( libecl.lib ) | | # Register the type mapping "ecl_kw" <-> EclKW | Step 2 @@ -224,7 +224,7 @@ The following excerpt from ecl_kw.y illustrates this: # 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 )") | - .... <--------· + .... <--------� ------------------------------------------------------------ These three steps are described in more detail in 4.1 - 4.3 below. @@ -423,7 +423,7 @@ takeover' or 'orphaning' of objects). -6 Installation in Statoil +6 Installation in Equinor -In Statoil the ert Python libraries are installed in the /project/res +In Equinor the ert Python libraries are installed in the /project/res hierarchy. diff --git a/ThirdParty/Ert/python/doc/import.txt b/ThirdParty/Ert/python/txt-doc/import.txt similarity index 100% rename from ThirdParty/Ert/python/doc/import.txt rename to ThirdParty/Ert/python/txt-doc/import.txt diff --git a/ThirdParty/Ert/python/doc/install.txt b/ThirdParty/Ert/python/txt-doc/install.txt similarity index 100% rename from ThirdParty/Ert/python/doc/install.txt rename to ThirdParty/Ert/python/txt-doc/install.txt diff --git a/ThirdParty/Ert/docs/tips.txt b/ThirdParty/Ert/python/txt-doc/tips.txt similarity index 99% rename from ThirdParty/Ert/docs/tips.txt rename to ThirdParty/Ert/python/txt-doc/tips.txt index d6bf3c18dc..40e8b9c349 100644 --- a/ThirdParty/Ert/docs/tips.txt +++ b/ThirdParty/Ert/python/txt-doc/tips.txt @@ -4,7 +4,7 @@ Table of contents: 2. About gen_data / gen_param and gen_obs. 3. Some tips for implementing a obs_script 4. About the ERT filesystem - 5. Installing ERT software in Statoil + 5. Installing ERT software in Equinor ********************************************************************** @@ -440,7 +440,7 @@ program, the block_fs system then has an api for reading and writing The block_fs_driver/block_fs combination is quite complex, but it has not had any hickups for about 1.5 years of extensive use in -Statoil. Observe that if you pull the plug on ERT you might loose some +Equinor. Observe that if you pull the plug on ERT you might loose some of the data which has been stored with the block_fs driver, but partly written and malformed data will be detected and discarded at the next boot. You are therefore guaranteed (add as many quotes you like to the @@ -524,10 +524,10 @@ enkf_fs. Not very important functions, but convenient enough. ********************************************************************** -5. Installing ERT software in Statoil +5. Installing ERT software in Equinor ------------------------------------- -Installation of research software in Statoil is according to the +Installation of research software in Equinor is according to the general guideline: 1. Log in to a computer in Trondheim with the correct version of diff --git a/ThirdParty/Ert/redhat/ecl.spec b/ThirdParty/Ert/redhat/ecl.spec index cca9c92159..7c85366a8e 100644 --- a/ThirdParty/Ert/redhat/ecl.spec +++ b/ThirdParty/Ert/redhat/ecl.spec @@ -2,7 +2,7 @@ # spec file for package ecl # -%define tag final +%define tag rc1 Name: ecl Version: 2018.10 @@ -11,7 +11,7 @@ Summary: ECL library License: GPL-3+ Group: Development/Libraries/C and C++ Url: http://ert.nr.no -Source0: https://github.com/Statoil/libecl/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz +Source0: https://github.com/Equinor/libecl/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz BuildRequires: lapack-devel zlib-devel iputils BuildRequires: devtoolset-6-toolchain %{?!el6:BuildRequires: python-devel numpy python-pandas python-cwrap} diff --git a/ThirdParty/Ert/requirements.txt b/ThirdParty/Ert/requirements.txt index 4d44c49dca..303f7ff42b 100644 --- a/ThirdParty/Ert/requirements.txt +++ b/ThirdParty/Ert/requirements.txt @@ -1,3 +1,7 @@ cwrap numpy pandas +sphinx +future +six +functools32;python_version=='2.7' diff --git a/ThirdParty/Ert/script/download-pr b/ThirdParty/Ert/script/download-pr index 7e6f01ad12..fb82bb3940 100644 --- a/ThirdParty/Ert/script/download-pr +++ b/ThirdParty/Ert/script/download-pr @@ -4,7 +4,7 @@ import json import os import sys -url_fmt = "https://api.github.com/repos/Statoil/libecl/pulls/%d" +url_fmt = "https://api.github.com/repos/Equinor/libecl/pulls/%d" def getPRList( api_token, pr1, pr2): pr = pr1 @@ -38,7 +38,7 @@ def printPRList( pr_list , fileH): title = pr["title"] body = pr["body"] nr = pr["number"] - url = "https://github.com/Statoil/libecl/pull/{}/".format(nr) + url = "https://github.com/Equinor/libecl/pull/{}/".format(nr) try: title = str(title) diff --git a/ThirdParty/Ert/setup.py b/ThirdParty/Ert/setup.py index 5dacb9973b..ac71393d32 100644 --- a/ThirdParty/Ert/setup.py +++ b/ThirdParty/Ert/setup.py @@ -31,13 +31,13 @@ class CMakeBuild(build_ext): subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) setup( - name='statoil_libecl', + name='equinor_libecl', version='0.1.1', author_email='chandan.nath@gmail.com', description='libecl', long_description=open("README.md", "r").read(), long_description_content_type="text/markdown", - url="https://github.com/statoil/libecl", + url="https://github.com/equinor/libecl", license="GNU General Public License, Version 3, 29 June 2007", packages=find_packages(where='python', exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), package_dir={'': 'python'}, diff --git a/ThirdParty/Ert/test-data/README.txt b/ThirdParty/Ert/test-data/README.txt index 2e7e908124..182de174d3 100644 --- a/ThirdParty/Ert/test-data/README.txt +++ b/ThirdParty/Ert/test-data/README.txt @@ -2,11 +2,11 @@ This directory is meant as a holding place for test data for the ERT project. The local/ directory should contain test-data which is checked in an distributed as part of the solution. -In addition many of the tests expect to find a Statoil/ subdirectory -in the current directory. This directory should link to Statoil +In addition many of the tests expect to find a Equinor/ subdirectory +in the current directory. This directory should link to Equinor internal test data. This data is currently located on the enkf disk in -Bergen; before you can start using the Statoil specific test data you +Bergen; before you can start using the Equinor specific test data you must add the following symlink: - ln -s /ErtTestData Statoil + ln -s /ErtTestData Equinor diff --git a/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SHORT.SMSPEC b/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SHORT.SMSPEC new file mode 100644 index 0000000000..ffeee8809c Binary files /dev/null and b/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SHORT.SMSPEC differ diff --git a/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SHORT.UNSMRY b/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SHORT.UNSMRY new file mode 100644 index 0000000000..5b02db1f62 Binary files /dev/null and b/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SHORT.UNSMRY differ diff --git a/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA b/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA index ccfa835647..d1447bee5a 100644 --- a/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA +++ b/ThirdParty/Ert/test-data/local/ECLIPSE/cp_simple3/SIMPLE_SUMMARY3.DATA @@ -3,7 +3,7 @@ -- individual contents of the database are licensed under the Database Contents -- License: http://opendatacommons.org/licenses/dbcl/1.0/ --- Copyright (C) 2016 Statoil +-- Copyright (C) 2016 Equinor -- NOTE: This deck is currently not supported by the OPM -- simulator flow due to lack of support for LGR. diff --git a/ThirdParty/Ert/test-data/local/ECLIPSE/well/missing-ICON/ICON0.X0027 b/ThirdParty/Ert/test-data/local/ECLIPSE/well/missing-ICON/ICON0.X0027 new file mode 100644 index 0000000000..37ad813f10 Binary files /dev/null and b/ThirdParty/Ert/test-data/local/ECLIPSE/well/missing-ICON/ICON0.X0027 differ diff --git a/ThirdParty/Ert/test-data/local/ECLIPSE/well/missing-ICON/ICON1.X0027 b/ThirdParty/Ert/test-data/local/ECLIPSE/well/missing-ICON/ICON1.X0027 new file mode 100644 index 0000000000..7ed2efdc20 Binary files /dev/null and b/ThirdParty/Ert/test-data/local/ECLIPSE/well/missing-ICON/ICON1.X0027 differ diff --git a/ThirdParty/Ert/test-data/local/util/latex/report_OK.tex b/ThirdParty/Ert/test-data/local/util/latex/report_OK.tex index 21c215939b..7c17203c07 100644 --- a/ThirdParty/Ert/test-data/local/util/latex/report_OK.tex +++ b/ThirdParty/Ert/test-data/local/util/latex/report_OK.tex @@ -1,7 +1,7 @@ \documentclass[screen,8pt]{beamer} \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} -\usetheme{statoil} +\usetheme{equinor} \usepackage{amsmath,amssymb,amsfonts} \usepackage{graphicx} \usepackage[tight]{subfigure} diff --git a/ThirdParty/Ert/test-data/local/util/latex/report_error.tex b/ThirdParty/Ert/test-data/local/util/latex/report_error.tex index 1a51a6bc7f..d09d5c3835 100644 --- a/ThirdParty/Ert/test-data/local/util/latex/report_error.tex +++ b/ThirdParty/Ert/test-data/local/util/latex/report_error.tex @@ -1,7 +1,7 @@ \documentclass[screen,8pt]{beamer} \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} -\usetheme{statoil} +\usetheme{equinor} \usepackage{amsmath,amssymb,amsfonts} \usepackage{graphicx} \usepackage[tight]{subfigure}