Merge branch 'update-libecl-2.4' into dev

This commit is contained in:
Magne Sjaastad 2019-05-09 10:13:22 +02:00
commit 9af0216359
596 changed files with 9038 additions and 7936 deletions

View File

@ -17,10 +17,8 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RifReaderEclipseSummary.h" #include "RifReaderEclipseSummary.h"
#include "RiaFilePathTools.h" #include "RiaFilePathTools.h"
#include "RiaStringEncodingTools.h" #include "RiaStringEncodingTools.h"
#include "RifEclipseSummaryTools.h" #include "RifEclipseSummaryTools.h"
#include "RifReaderEclipseOutput.h" #include "RifReaderEclipseOutput.h"
@ -36,11 +34,8 @@
#include "ert/ecl/ecl_kw.h" #include "ert/ecl/ecl_kw.h"
#include "ert/ecl/ecl_kw_magic.h" #include "ert/ecl/ecl_kw_magic.h"
#include "ert/ecl/ecl_sum.h" #include "ert/ecl/ecl_sum.h"
#include "ert/ecl/smspec_node.h" #include "ert/ecl/smspec_node.hpp"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<time_t> getTimeSteps(ecl_sum_type* ecl_sum) std::vector<time_t> getTimeSteps(ecl_sum_type* ecl_sum)
{ {
std::vector<time_t> timeSteps; std::vector<time_t> timeSteps;
@ -246,7 +241,7 @@ std::string stringFromPointer(const char* pointerToChar)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::string wellNameFromNode(const smspec_node_type* ertSumVarNode) std::string wellNameFromNode(const ecl::smspec_node* ertSumVarNode)
{ {
return stringFromPointer(smspec_node_get_wgname(ertSumVarNode)); return stringFromPointer(smspec_node_get_wgname(ertSumVarNode));
} }
@ -254,7 +249,7 @@ std::string wellNameFromNode(const smspec_node_type* ertSumVarNode)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::string lgrNameFromNode(const smspec_node_type* ertSumVarNode) std::string lgrNameFromNode(const ecl::smspec_node* ertSumVarNode)
{ {
return stringFromPointer(smspec_node_get_lgr_name(ertSumVarNode)); return stringFromPointer(smspec_node_get_lgr_name(ertSumVarNode));
} }
@ -262,9 +257,9 @@ std::string lgrNameFromNode(const smspec_node_type* ertSumVarNode)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type* ertSumVarNode) RifEclipseSummaryAddress addressFromErtSmSpecNode(const ecl::smspec_node& ertSumVarNode)
{ {
if (smspec_node_get_var_type(ertSumVarNode) == ECL_SMSPEC_INVALID_VAR) if (ertSumVarNode.get_var_type() == ECL_SMSPEC_INVALID_VAR)
{ {
return RifEclipseSummaryAddress(); return RifEclipseSummaryAddress();
} }
@ -283,108 +278,97 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type* ertSum
int aquiferNumber(-1); int aquiferNumber(-1);
bool isErrorResult(false); bool isErrorResult(false);
quantityName = smspec_node_get_keyword(ertSumVarNode); quantityName = stringFromPointer(ertSumVarNode.get_keyword());
switch (smspec_node_get_var_type(ertSumVarNode)) switch (ertSumVarNode.get_var_type())
{
case ECL_SMSPEC_AQUIFER_VAR:
{ {
case ECL_SMSPEC_AQUIFER_VAR: {
sumCategory = RifEclipseSummaryAddress::SUMMARY_AQUIFER; sumCategory = RifEclipseSummaryAddress::SUMMARY_AQUIFER;
aquiferNumber = smspec_node_get_num(ertSumVarNode); aquiferNumber = ertSumVarNode.get_num();
} }
break; break;
case ECL_SMSPEC_WELL_VAR: case ECL_SMSPEC_WELL_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL; sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL;
wellName = wellNameFromNode(ertSumVarNode); wellName = stringFromPointer(ertSumVarNode.get_wgname());
} }
break; break;
case ECL_SMSPEC_REGION_VAR: case ECL_SMSPEC_REGION_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_REGION; sumCategory = RifEclipseSummaryAddress::SUMMARY_REGION;
regionNumber = smspec_node_get_num(ertSumVarNode); regionNumber = ertSumVarNode.get_num();
} }
break; break;
case ECL_SMSPEC_FIELD_VAR: case ECL_SMSPEC_FIELD_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_FIELD; sumCategory = RifEclipseSummaryAddress::SUMMARY_FIELD;
} }
break; break;
case ECL_SMSPEC_GROUP_VAR: case ECL_SMSPEC_GROUP_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP; sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP;
wellGroupName = wellNameFromNode(ertSumVarNode); wellGroupName = stringFromPointer(ertSumVarNode.get_wgname());
} }
break; break;
case ECL_SMSPEC_BLOCK_VAR: case ECL_SMSPEC_BLOCK_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_BLOCK; sumCategory = RifEclipseSummaryAddress::SUMMARY_BLOCK;
const int* ijk = smspec_node_get_ijk(ertSumVarNode); auto ijk = ertSumVarNode.get_ijk();
cellI = ijk[0]; cellI = ijk[0];
cellJ = ijk[1]; cellJ = ijk[1];
cellK = ijk[2]; cellK = ijk[2];
} }
break; break;
case ECL_SMSPEC_COMPLETION_VAR: case ECL_SMSPEC_COMPLETION_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION; sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION;
wellName = wellNameFromNode(ertSumVarNode); wellName = stringFromPointer(ertSumVarNode.get_wgname());
const int* ijk = smspec_node_get_ijk(ertSumVarNode);
auto ijk = ertSumVarNode.get_ijk();
cellI = ijk[0]; cellI = ijk[0];
cellJ = ijk[1]; cellJ = ijk[1];
cellK = ijk[2]; cellK = ijk[2];
} }
break; break;
case ECL_SMSPEC_LOCAL_BLOCK_VAR: case ECL_SMSPEC_LOCAL_BLOCK_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR; sumCategory = RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR;
lgrName = lgrNameFromNode(ertSumVarNode); lgrName = stringFromPointer(ertSumVarNode.get_lgr_name());
const int* ijk = smspec_node_get_lgr_ijk(ertSumVarNode);
auto ijk = ertSumVarNode.get_lgr_ijk();
cellI = ijk[0]; cellI = ijk[0];
cellJ = ijk[1]; cellJ = ijk[1];
cellK = ijk[2]; cellK = ijk[2];
} }
break; break;
case ECL_SMSPEC_LOCAL_COMPLETION_VAR: case ECL_SMSPEC_LOCAL_COMPLETION_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR; sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR;
wellName = wellNameFromNode(ertSumVarNode); wellName = stringFromPointer(ertSumVarNode.get_wgname());
lgrName = lgrNameFromNode(ertSumVarNode); lgrName = stringFromPointer(ertSumVarNode.get_lgr_name());
const int* ijk = smspec_node_get_lgr_ijk(ertSumVarNode);
auto ijk = ertSumVarNode.get_lgr_ijk();
cellI = ijk[0]; cellI = ijk[0];
cellJ = ijk[1]; cellJ = ijk[1];
cellK = ijk[2]; cellK = ijk[2];
} }
break; break;
case ECL_SMSPEC_LOCAL_WELL_VAR: case ECL_SMSPEC_LOCAL_WELL_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_LGR; sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_LGR;
wellName = wellNameFromNode(ertSumVarNode); wellName = stringFromPointer(ertSumVarNode.get_wgname());
lgrName = lgrNameFromNode(ertSumVarNode); lgrName = stringFromPointer(ertSumVarNode.get_lgr_name());
} }
break; break;
case ECL_SMSPEC_NETWORK_VAR: case ECL_SMSPEC_NETWORK_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_NETWORK; sumCategory = RifEclipseSummaryAddress::SUMMARY_NETWORK;
} }
break; break;
case ECL_SMSPEC_REGION_2_REGION_VAR: case ECL_SMSPEC_REGION_2_REGION_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION; sumCategory = RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION;
regionNumber = smspec_node_get_R1(ertSumVarNode); regionNumber = ertSumVarNode.get_R1();
regionNumber2 = smspec_node_get_R2(ertSumVarNode); regionNumber2 = ertSumVarNode.get_R2();
} }
break; break;
case ECL_SMSPEC_SEGMENT_VAR: case ECL_SMSPEC_SEGMENT_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT; sumCategory = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT;
wellName = wellNameFromNode(ertSumVarNode); wellName = stringFromPointer(ertSumVarNode.get_wgname());
wellSegmentNumber = smspec_node_get_num(ertSumVarNode); wellSegmentNumber = ertSumVarNode.get_num();
} }
break; break;
case ECL_SMSPEC_MISC_VAR: case ECL_SMSPEC_MISC_VAR: {
{
sumCategory = RifEclipseSummaryAddress::SUMMARY_MISC; sumCategory = RifEclipseSummaryAddress::SUMMARY_MISC;
} }
break; break;
@ -429,8 +413,8 @@ bool RifReaderEclipseSummary::values(const RifEclipseSummaryAddress& resultAddre
} }
else if (m_ecl_SmSpec) else if (m_ecl_SmSpec)
{ {
const smspec_node_type* ertSumVarNode = ecl_smspec_iget_node(m_ecl_SmSpec, variableIndex); const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index(m_ecl_SmSpec, variableIndex);
int paramsIndex = smspec_node_get_params_index(ertSumVarNode); int paramsIndex = ertSumVarNode.get_params_index();
double_vector_type* dataValues = ecl_sum_alloc_data_vector(m_ecl_sum, paramsIndex, false); double_vector_type* dataValues = ecl_sum_alloc_data_vector(m_ecl_sum, paramsIndex, false);
@ -497,7 +481,7 @@ void RifReaderEclipseSummary::buildMetaData()
int varCount = ecl_smspec_num_nodes(m_ecl_SmSpec); int varCount = ecl_smspec_num_nodes(m_ecl_SmSpec);
for (int i = 0; i < varCount; i++) for (int i = 0; i < varCount; i++)
{ {
const smspec_node_type* ertSumVarNode = ecl_smspec_iget_node(m_ecl_SmSpec, i); const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index(m_ecl_SmSpec, i);
RifEclipseSummaryAddress addr = addressFromErtSmSpecNode(ertSumVarNode); RifEclipseSummaryAddress addr = addressFromErtSmSpecNode(ertSumVarNode);
m_allResultAddresses.insert(addr); m_allResultAddresses.insert(addr);
m_resultAddressToErtNodeIdx[addr] = i; m_resultAddressToErtNodeIdx[addr] = i;
@ -543,8 +527,8 @@ std::string RifReaderEclipseSummary::unitName(const RifEclipseSummaryAddress& re
if (variableIndex < 0) return ""; if (variableIndex < 0) return "";
const smspec_node_type* ertSumVarNode = ecl_smspec_iget_node(m_ecl_SmSpec, variableIndex); const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index(m_ecl_SmSpec, variableIndex);
return smspec_node_get_unit(ertSumVarNode); return ertSumVarNode.get_unit();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -590,6 +574,7 @@ std::set<RifReaderEclipseSummary::ValuesCache*> RifReaderEclipseSummary::ValuesC
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RifReaderEclipseSummary::ValuesCache::ValuesCache() RifReaderEclipseSummary::ValuesCache::ValuesCache()
{ {
// Register instance
m_instances.insert(this); m_instances.insert(this);
} }
@ -598,6 +583,7 @@ RifReaderEclipseSummary::ValuesCache::ValuesCache()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RifReaderEclipseSummary::ValuesCache::~ValuesCache() RifReaderEclipseSummary::ValuesCache::~ValuesCache()
{ {
// Deregister instance
m_instances.erase(this); m_instances.erase(this);
} }
@ -645,7 +631,7 @@ void RifReaderEclipseSummary::ValuesCache::purge()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RifReaderEclipseSummary::ValuesCache::purgeData() void RifReaderEclipseSummary::ValuesCache::purgeData()
{ {
for (const auto& purgeAddr : m_purgeList) for (const auto purgeAddr : m_purgeList)
{ {
m_cachedValues.erase(purgeAddr); m_cachedValues.erase(purgeAddr);
} }

View File

@ -110,7 +110,7 @@ namespace RigFlowDiagInterfaceTools {
{ {
auto satfunc = Opm::ECLSaturationFunc(G, init); auto satfunc = Opm::ECLSaturationFunc(G, init);
Opm::ECLFluxCalc calc(G, init, 9.80665); Opm::ECLFluxCalc calc(G, init, 9.80665, false);
auto getFlux = [&calc, &rstrt] auto getFlux = [&calc, &rstrt]
(const Opm::ECLPhaseIndex p) (const Opm::ECLPhaseIndex p)

View File

@ -18,13 +18,13 @@ set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")
# https://github.com/Statoil/libecl # https://github.com/Statoil/libecl
# Note: # Note:
# Apply patches fix-synthetic-odb-cases.patch and install-ert.patch after update # Apply patches fix-synthetic-odb-cases.patch and install-ert.patch after update
set(ECL_GITHUB_SHA "7f93730c08a4d981a4b738b42146d099977572ce") set(ECL_GITHUB_SHA "0e1e780fd6f18ce93119061e36a4fca9711bc020")
# https://github.com/OPM/opm-flowdiagnostics # https://github.com/OPM/opm-flowdiagnostics
set(OPM_FLOWDIAGNOSTICS_SHA "f8af0914f8b1ddcda41f040f539c945a6057f5e4") set(OPM_FLOWDIAGNOSTICS_SHA "8bb60d6111063f2b7557502ecaa329a2d5c13b41")
# https://github.com/OPM/opm-flowdiagnostics-applications # https://github.com/OPM/opm-flowdiagnostics-applications
set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "24ff768dc509b6c6bbd0121ef46a5932fae92961") set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "f57942a8cdf57422fabf3a4423d02a3e46e0be4e")
# https://github.com/OPM/opm-parser/blob/master/opm/parser/eclipse/Units/Units.hpp # https://github.com/OPM/opm-parser/blob/master/opm/parser/eclipse/Units/Units.hpp
# This file was moved from opm-core to opm-parser october 2016 # This file was moved from opm-core to opm-parser october 2016

2
ThirdParty/Ert/.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,2 @@
# These owners will be the default owners for everything in the repo.
* @markusdregi @lars-petter-hauge @andreabrambilla @pgdr @jokva @xjules

View File

@ -1,10 +1,5 @@
**Task** **Issue**
_Short description of the task_ Resolves #<Issue id>
**Approach** **Approach**
_Short description of the approach_ _Short description of the approach_
**Pre un-WIP checklist**
- [ ] Statoil tests pass locally

View File

@ -11,8 +11,9 @@ python/lib64
/libenkf/src/.faultlist /libenkf/src/.faultlist
/develbranch/libenkf/src/.faultlist /develbranch/libenkf/src/.faultlist
/build /build
/temp-build
/libert_util/tests/data/latex_OK.pdf /libert_util/tests/data/latex_OK.pdf
/test-data/Statoil /test-data/Equinor
/python/python/ert/ecl/ecl_local.py /python/python/ert/ecl/ecl_local.py
/GPATH /GPATH
/GRTAGS /GRTAGS

3
ThirdParty/Ert/.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "multibuild"]
path = multibuild
url = https://github.com/matthew-brett/multibuild.git

View File

@ -1,82 +1,70 @@
language: c language: python
python:
compiler: - 2.7
- gcc - 3.6
- clang
os: os:
- linux - linux
- osx
osx_image: xcode7.3 sudo: required
sudo: false services: docker
dist: trusty
env: env:
global: global:
- ERT_SHOW_BACKTRACE=1 - ERT_SHOW_BACKTRACE=1
- LD_LIBRARY_PATH="$(pwd)/install/lib64" - MB_PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
matrix: matrix:
- PYTHON_VERSION=2.7 TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow - 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 - 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 - TEST_SUITE="-L SLOW_2" # Run all tests labeled as SLOW in group 2
- PYTHON_VERSION=3.6 # Run all tests
matrix: matrix:
fast_finish: true fast_finish: true
exclude: include:
- os: osx - os: osx
compiler: gcc language: generic
- os: linux python: 2.7
compiler: clang env:
- MB_PYTHON_VERSION=2.7
- TEST_SUITE=""
- os: osx
language: generic
python: 3.6
env:
- MB_PYTHON_VERSION=3.6
- TEST_SUITE=""
addons: addons:
apt: apt:
sources:
- ubuntu-toolchain-r-test
packages: packages:
- liblapack-dev - 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: 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 - 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: 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

View File

@ -11,7 +11,7 @@ endif()
#----------------------------------------------------------------- #-----------------------------------------------------------------
set( ECL_VERSION_MAJOR 2 ) # Remember to update release notes whenever 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"! 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 # 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( BUILD_SHARED_LIBS "Build shared libraries" ON )
option( ERT_USE_OPENMP "Use OpenMP" OFF ) option( ERT_USE_OPENMP "Use OpenMP" OFF )
option( RST_DOC "Build RST documentation" 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( USE_RPATH "Don't strip RPATH from libraries and binaries" OFF)
option( INSTALL_ERT_LEGACY "Add ert legacy wrappers" OFF) option( INSTALL_ERT_LEGACY "Add ert legacy wrappers" OFF)
set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata") set(EQUINOR_TESTDATA_ROOT "" CACHE PATH "Root to Equinor internal testdata")
if (EXISTS ${STATOIL_TESTDATA_ROOT}) if (EXISTS ${EQUINOR_TESTDATA_ROOT})
set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Statoil" ) set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Equinor" )
if (EXISTS ${LINK}) if (EXISTS ${LINK})
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${LINK}") EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${LINK}")
endif() endif()
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${STATOIL_TESTDATA_ROOT}" "${LINK}") EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${EQUINOR_TESTDATA_ROOT}" "${LINK}")
message(STATUS "Linking testdata: ${LINK} -> ${STATOIL_TESTDATA_ROOT}") message(STATUS "Linking testdata: ${LINK} -> ${EQUINOR_TESTDATA_ROOT}")
set(_statoil_test_data ${CMAKE_SOURCE_DIR}/test-data/Statoil) set(_equinor_test_data ${CMAKE_SOURCE_DIR}/test-data/Equinor)
set(_eclpath ${_statoil_test_data}/ECLIPSE) set(_eclpath ${_equinor_test_data}/ECLIPSE)
set(_geopath ${_statoil_test_data}/Geometry) set(_geopath ${_equinor_test_data}/Geometry)
endif() endif()
@ -116,7 +115,7 @@ endif()
# Treat warnings as errors if not on Windows # Treat warnings as errors if not on Windows
if (NOT ERT_WINDOWS) if (NOT ERT_WINDOWS)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wno-unknown-pragmas ") 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() endif()
if (MSVC) if (MSVC)
@ -339,11 +338,6 @@ if (ENABLE_PYTHON)
# fails in the python/CMakeLists.txt file the ENABLE_PYTHON # fails in the python/CMakeLists.txt file the ENABLE_PYTHON
# will be set to OFF. # will be set to OFF.
add_subdirectory( python ) add_subdirectory( python )
if(RST_DOC)
add_subdirectory( docs )
endif()
endif() endif()
if (ENABLE_PYTHON) if (ENABLE_PYTHON)

View File

@ -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 *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 available on *Windows*. The main functionality is written in C/C++, and
should typically be linked in in other compiled programs. *libecl* was should typically be linked in in other compiled programs. *libecl* was
initially developed as part of the [Ensemble Reservoir 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 *libecl* are the reservoir simulator flow and Resinsight from the [OPM
project](http://github.com/OPM/). project](http://github.com/OPM/).
@ -30,7 +30,7 @@ configured with `-DCMAKE_INSTALL_PREFIX=/path/to/install`.
*libecl* uses CMake as build system: *libecl* uses CMake as build system:
```bash ```bash
git clone https://github.com/Statoil/libecl git clone https://github.com/Equinor/libecl
cd libecl cd libecl
mkdir build mkdir build
cd 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 files to correctly set up the interaction between the Python classes and the
shared libraries built from the C code: shared libraries built from the C code:
```bash ```bash
git clone https://github.com/Statoil/libecl git clone https://github.com/Equinor/libecl
cd libecl cd libecl
sudo pip install -r requirements.txt sudo pip install -r requirements.txt
mkdir build 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. [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.

27
ThirdParty/Ert/WINDOWS.md vendored Normal file
View File

@ -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.

View File

@ -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.

View File

@ -1,10 +1,10 @@
project(libecl-applications) project(libecl-applications)
if (BUILD_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(make_grid ecl/make_grid.c)
add_executable(grdecl_grid ecl/grdecl_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(sum_write ecl)
target_link_libraries(make_grid ecl) target_link_libraries(make_grid ecl)
target_link_libraries(grdecl_grid ecl) target_link_libraries(grdecl_grid ecl)
@ -13,16 +13,16 @@ if (BUILD_APPLICATIONS)
list(APPEND apps make_grid grdecl_grid summary) list(APPEND apps make_grid grdecl_grid summary)
foreach (app ecl_pack foreach (app ecl_pack.c
ecl_unpack ecl_unpack.c
kw_extract kw_extract.cpp
grid_info grid_info.c
grid_dump grid_dump.c
grid_dump_ascii grid_dump_ascii.c
select_test select_test.c
load_test load_test.c
) )
add_executable(${app} ecl/${app}.c) add_executable(${app} ecl/${app})
target_link_libraries(${app} ecl) target_link_libraries(${app} ecl)
list(APPEND apps ${app}) list(APPEND apps ${app})
if (ERT_LINUX) if (ERT_LINUX)
@ -71,7 +71,7 @@ if (BUILD_APPLICATIONS)
endif() endif()
if (BUILD_ECL_SUMMARY) 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) target_link_libraries(ecl_summary ecl)
list(APPEND apps ecl_summary) list(APPEND apps ecl_summary)

View File

@ -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. The file 'convert.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. 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("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("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("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); exit(0);
} }

View File

@ -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. The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'grdecl_grid.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'grdecl_test.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'grid_info.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'grid_dump_ascii.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'grid_info.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'grid_layer.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'key_list.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'kw_extract.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'kw_list.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'load_test.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'make_grid.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'run_gravity.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'select_test.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'sum_write' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify 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 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 which is essentially a struct holding header information about
this varible. There are several options on how to handle the this varible. There are several options on how to handle the
return value from the ecl_sum_add_var() function; which affect how return value from the 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); const ecl::smspec_node * 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 * 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 We can use the smspec_node value from the
ecl_sum_add_var() function directly: ecl_sum_add_var() function directly:
*/ */
ecl_sum_tstep_set_from_node( tstep , wwct_wellx , sim_days ); 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, *wopr_wellx, sim_days * 100);
} }
} }
} }

View File

@ -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. The file 'summary2csv2.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify ERT is free software: you can redistribute it and/or modify

View File

@ -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. The file 'view_restart.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'view_rft.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'view_summary.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify ERT is free software: you can redistribute it and/or modify
@ -111,9 +111,6 @@ void print_help_and_exit() {
printf("* If the extension corresponds to a unified file, summary.x will\n"); printf("* If the extension corresponds to a unified file, summary.x will\n");
printf(" only look for unified files.\n"); printf(" only look for unified files.\n");
printf("\n"); printf("\n");
printf("\n");
printf("Contact Joakim Hove / joaho@statoil.com / 92 68 57 04 for bugs\n");
printf("and feature requests.\n");
exit(1); exit(1);
} }

View File

@ -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. The file 'vprofile.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -99,9 +99,6 @@ will only look for unformatted files.
.IP .IP
only look for unified files. only look for unified files.
.PP .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 The ecl_summary program is used to quickly extract summary vectors
from ECLIPSE summary files. The program is invoked as: from ECLIPSE summary files. The program is invoked as:
.PP .PP
@ -183,6 +180,6 @@ will only look for unformatted files.
.IP .IP
only look for unified files. only look for unified files.
.PP .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. and feature requests.

View File

@ -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. The file 'well_CF_dump.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'segment_info.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'well_CF_dump.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -19,7 +19,6 @@ build_script:
- cmake %W64% -DBUILD_SHARED_LIBS=ON - cmake %W64% -DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
-DENABLE_PYTHON=ON -DENABLE_PYTHON=ON
-DERT_BUILD_CXX=OFF
-DBUILD_APPLICATIONS=ON -DBUILD_APPLICATIONS=ON
- cmake --build . --config %configuration% --target install - cmake --build . --config %configuration% --target install

View File

@ -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("output_case", metavar="output_case", type=str)
parser.add_argument("--num-timestep", type=int, default=50) parser.add_argument("--num-timestep", type=int, default=50)
parser.add_argument("--refcase", metavar="refcase", type=str) parser.add_argument("--refcase", metavar="refcase", type=str)
parser.add_argument("--extrapolation", action="store_true")
args = parser.parse_args() args = parser.parse_args()
input_case = EclSum(args.input_case) input_case = EclSum(args.input_case)
@ -23,5 +24,8 @@ else:
end_time = input_case.get_end_time() end_time = input_case.get_end_time()
time_points = TimeVector.create_linear(CTime(start_time), CTime(end_time), args.num_timestep) 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( ) output_case.fwrite( )

0
ThirdParty/Ert/config.sh vendored Normal file
View File

View File

@ -7,7 +7,3 @@ working with ECLIPSE output files. The package contains functionality
for reading, and partly writing, ECLIPSE INIT/GRID/EGRID/RFT and for reading, and partly writing, ECLIPSE INIT/GRID/EGRID/RFT and
summary and restart files. There is also some functionality for summary and restart files. There is also some functionality for
working with .grdecl formatted ECLIPSE input files. working with .grdecl formatted ECLIPSE input files.
-- Joakim Hove <joaho@statoil.com> Wed, 23 Jan 2013 13:41:00 +0100
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Wed, 16 Jan 2013 11:21:17 +0100

View File

@ -1,4 +1,4 @@
ecl (2018.10-rfinal-1~xenial) xenial; urgency=low ecl (2018.10-rc1-1~xenial) xenial; urgency=low
* New release * New release

View File

@ -3,7 +3,7 @@ Upstream-Name: libert.ecl
Source: https://github.com/Ensembles/ert Source: https://github.com/Ensembles/ert
Files: * Files: *
Copyright: 2013 Statoil Copyright: 2013 Equinor
License: GPL-3+ License: GPL-3+
This package is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by

View File

@ -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} )

View File

@ -1,4 +0,0 @@
Low level C libraries
=====================
How to use the C libraries

View File

@ -1,9 +0,0 @@
The ert Python API
==================
.. toctree::
:maxdepth: 2
../../API/python/ert
../../API/python/ert_gui

View File

@ -1,3 +0,0 @@
Working with full ert cases
===========================

View File

@ -1,2 +0,0 @@
The ert.geo package
===================

View File

@ -1,2 +0,0 @@
The ert.util package
===================

View File

@ -1,2 +0,0 @@
The ert.well package
====================

View File

@ -1,34 +0,0 @@
QUEUE_SYSTEM LOCAL
JOBNAME SNAKE_OIL_%d
NUM_REALIZATIONS 25
DEFINE <STORAGE> storage/<CONFIG_FILE_BASE>
RUNPATH_FILE directory/test_runpath_list.txt
RUNPATH <STORAGE>/runpath/realisation-%d/iter-%d
ENSPATH <STORAGE>/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

View File

@ -1,4 +0,0 @@
STDOUT snake_oil_diff.stdout
STDERR snake_oil_diff.stderr
EXECUTABLE snake_oil_diff.py

View File

@ -1,4 +0,0 @@
STDOUT snake_oil_npv.stdout
STDERR snake_oil_npv.stderr
EXECUTABLE snake_oil_npv.py

View File

@ -1,4 +0,0 @@
STDOUT snake_oil.stdout
STDERR snake_oil.stderr
EXECUTABLE snake_oil_simulator.py

View File

@ -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"])

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -1 +0,0 @@
To create a refcase run the snake_oil_simulator.py job with the this as working directory.

View File

@ -1 +0,0 @@
SEED:268776

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +0,0 @@
QUEUE_SYSTEM LOCAL
JOBNAME SNAKE_OIL_%d
NUM_REALIZATIONS 25
DEFINE <STORAGE> storage/<CONFIG_FILE_BASE>
STORE_SEED SEED
LOAD_SEED SEED
RUNPATH_FILE directory/test_runpath_list.txt
RUNPATH <STORAGE>/runpath/realisation-%d/iter-%d
ENSPATH <STORAGE>/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

View File

@ -1 +0,0 @@
SEED:<IENS>

View File

@ -1,10 +0,0 @@
OP1_PERSISTENCE:<OP1_PERSISTENCE>
OP1_OCTAVES:<OP1_OCTAVES>
OP1_DIVERGENCE_SCALE:<OP1_DIVERGENCE_SCALE>
OP1_OFFSET:<OP1_OFFSET>
OP2_PERSISTENCE:<OP2_PERSISTENCE>
OP2_OCTAVES:<OP2_OCTAVES>
OP2_DIVERGENCE_SCALE:<OP2_DIVERGENCE_SCALE>
OP2_OFFSET:<OP2_OFFSET>
BPR_555_PERSISTENCE:<BPR_555_PERSISTENCE>
BPR_138_PERSISTENCE:<BPR_138_PERSISTENCE>

View File

@ -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.

View File

@ -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( )))

View File

@ -1 +0,0 @@
Implement the [] operator for the gen_data class in GenData.py

View File

@ -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)))

View File

@ -1,2 +0,0 @@
Iterate through all the forward models which have been installed and
get the configuration file and executable.

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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. # The file 'ecl.py' is part of ERT - Ensemble based Reservoir Tool.
# #

View File

@ -54,12 +54,6 @@ if (ZLIB_FOUND)
list(APPEND opt_srcs util/util_zlib.cpp) list(APPEND opt_srcs util/util_zlib.cpp)
endif () 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(build_config.h.in include/ert/util/build_config.h)
configure_file(ert_api_config.h.in include/ert/util/ert_api_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_segment_collection.cpp
ecl/well_branch_collection.cpp ecl/well_branch_collection.cpp
ecl/well_rseg_loader.cpp ecl/well_rseg_loader.cpp
ecl/FortIO.cpp
ecl/EclFilename.cpp
geometry/geo_surface.cpp geometry/geo_surface.cpp
geometry/geo_util.cpp geometry/geo_util.cpp
@ -219,23 +215,10 @@ install(TARGETS ecl
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY include/ install(DIRECTORY include/
DESTINATION include DESTINATION include
PATTERN *.h
)
install(DIRECTORY include/
DESTINATION include
PATTERN *.hpp EXCLUDE
) )
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION include DESTINATION include
PATTERN *.h
) )
if (ERT_BUILD_CXX)
install(DIRECTORY include/
DESTINATION include
PATTERN *.hpp
)
endif ()
endif() endif()
if (NOT BUILD_TESTS) if (NOT BUILD_TESTS)
@ -277,6 +260,7 @@ foreach (name ert_util_alloc_file_components
ert_util_datetime ert_util_datetime
ert_util_normal_path ert_util_normal_path
ert_util_mkdir_p ert_util_mkdir_p
test_area
) )
add_executable(${name} util/tests/${name}.cpp) add_executable(${name} util/tests/${name}.cpp)
@ -353,11 +337,14 @@ foreach (name ecl_alloc_cpgrid
ecl_grid_copy ecl_grid_copy
ecl_grid_create ecl_grid_create
ecl_grid_DEPTHZ ecl_grid_DEPTHZ
ecl_grid_fwrite
ecl_grid_unit_system ecl_grid_unit_system
ecl_grid_export ecl_grid_export
ecl_grid_init_fwrite ecl_grid_init_fwrite
ecl_grid_reset_actnum ecl_grid_reset_actnum
ecl_grid_ext_actnum ecl_grid_ext_actnum
ecl_nnc_export_intersect
ecl_sum_restart
ecl_sum_data_intermediate_test ecl_sum_data_intermediate_test
ecl_grid_cell_contains ecl_grid_cell_contains
ecl_unsmry_loader_test ecl_unsmry_loader_test
@ -436,26 +423,24 @@ foreach (name geo_util_xlines geo_polygon geo_polygon_collection)
add_test(NAME ${name} COMMAND ${name}) add_test(NAME ${name} COMMAND ${name})
endforeach () endforeach ()
if (ERT_BUILD_CXX) foreach (test ert_util_unique_ptr)
foreach (test ert_util_unique_ptr)
add_executable(${test} util/tests/${test}.cpp) add_executable(${test} util/tests/${test}.cpp)
target_link_libraries(${test} ecl) target_link_libraries(${test} ecl)
add_test(NAME ${test} COMMAND ${test}) add_test(NAME ${test} COMMAND ${test})
endforeach() endforeach()
foreach (test eclxx_kw eclxx_fortio eclxx_smspec eclxx_filename eclxx_types) foreach (test eclxx_kw eclxx_fortio eclxx_filename eclxx_types)
add_executable(${test} ecl/tests/${test}.cpp) add_executable(${test} ecl/tests/${test}.cpp)
target_link_libraries(${test} ecl) target_link_libraries(${test} ecl)
add_test(NAME ${test} COMMAND ${test}) add_test(NAME ${test} COMMAND ${test})
endforeach () endforeach ()
endif ()
foreach(name ecl_coarse_test foreach(name ecl_coarse_test
ecl_grid_layer_contains ecl_grid_layer_contains
ecl_restart_test ecl_restart_test
ecl_nnc_export ecl_nnc_export
ecl_nnc_export_get_tran ecl_nnc_export_get_tran
ecl_nnc_data_statoil_root ecl_nnc_data_equinor_root
ecl_sum_case_exists ecl_sum_case_exists
ecl_grid_lgr_name ecl_grid_lgr_name
ecl_region ecl_region
@ -467,19 +452,19 @@ foreach(name ecl_coarse_test
ecl_grid_dims ecl_grid_dims
ecl_nnc_test ecl_nnc_test
ecl_lgr_test ecl_lgr_test
ecl_layer_statoil ecl_layer_equinor
ecl_dualp ecl_dualp
ecl_grid_dx_dy_dz ecl_grid_dx_dy_dz
ecl_sum_test ecl_sum_test
ecl_sum_report_step_equal ecl_sum_report_step_equal
ecl_sum_report_step_compatible ecl_sum_report_step_compatible
ecl_file_statoil ecl_file_equinor
ecl_fmt ecl_fmt
ecl_rsthead ecl_rsthead
ecl_smspec ecl_smspec
ecl_rft ecl_rft
ecl_grid_copy_statoil ecl_grid_copy_equinor
ecl_fault_block_layer_statoil ecl_fault_block_layer_equinor
well_state_load well_state_load
well_state_load_missing_RSEG well_state_load_missing_RSEG
well_segment_load well_segment_load
@ -497,7 +482,7 @@ foreach(name ecl_coarse_test
endforeach() endforeach()
if (NOT STATOIL_TESTDATA_ROOT) if (NOT EQUINOR_TESTDATA_ROOT)
return () return ()
endif() endif()
@ -531,7 +516,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 add_test(NAME ecl_nnc_export_get_tran COMMAND ecl_nnc_export_get_tran
${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3) ${_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}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3
${_eclpath}/flow-nnc/Simple4/SIMPLE_SUMMARY4 ${_eclpath}/flow-nnc/Simple4/SIMPLE_SUMMARY4
${_eclpath}/flow-nnc/Gullfaks/GF_ACT_NEW_TEMP) ${_eclpath}/flow-nnc/Gullfaks/GF_ACT_NEW_TEMP)
@ -572,7 +557,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 add_test(NAME ecl_grid_ecl2015_2 COMMAND ecl_grid_simple
${_eclpath}/Eclipse2015_NNC_BUG/FF15_2015B2_LGRM_RDI15_HIST_RDIREAL1_20142.EGRID) ${_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) COMMAND ecl_grid_export ${_eclpath}/Gurbat/ECLIPSE.EGRID)
add_test(NAME ecl_grid_volume1 COMMAND ecl_grid_volume ${_eclpath}/Gurbat/ECLIPSE) add_test(NAME ecl_grid_volume1 COMMAND ecl_grid_volume ${_eclpath}/Gurbat/ECLIPSE)
@ -600,7 +585,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_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_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/MARINER.EGRID
${_eclpath}/Mariner/faultblock.grdecl) ${_eclpath}/Mariner/faultblock.grdecl)
@ -622,8 +607,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_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_sum_report_step_compatible6 COMMAND ecl_sum_report_step_equal ${_eclpath}/Snorre/SNORRE ${_eclpath}/Snorre2/SNORRE2 FALSE)
add_test(NAME ecl_file_statoil add_test(NAME ecl_file_equinor
COMMAND ecl_file_statoil ${_eclpath}/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST) COMMAND ecl_file_equinor ${_eclpath}/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST)
add_test(NAME ecl_fmt COMMAND ecl_fmt add_test(NAME ecl_fmt COMMAND ecl_fmt
${_eclpath}/Gurbat/ECLIPSE.UNRST ${_eclpath}/Gurbat/ECLIPSE.UNRST
@ -645,12 +630,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_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_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_equinor1 COMMAND ecl_grid_copy_equinor ${_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_equinor2 COMMAND ecl_grid_copy_equinor ${_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_equinor3 COMMAND ecl_grid_copy_equinor ${_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_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/MARINER.EGRID
${_eclpath}/Mariner/faultblock.grdecl) ${_eclpath}/Mariner/faultblock.grdecl)
@ -684,7 +669,9 @@ add_test(NAME well_segment_load
add_test(NAME well_segment_branch_conn_load add_test(NAME well_segment_branch_conn_load
COMMAND well_segment_branch_conn_load ${_eclpath}/MSWcase/MSW_CASE.X0021) 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) add_test(NAME well_conn_CF COMMAND well_conn_CF ${_eclpath}/Gurbat/ECLIPSE.X0060)

View File

@ -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. This file is part of ERT - Ensemble based Reservoir Tool.

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2015 Statoil ASA. Copyright 2015 Equinor ASA.
This file is part of the Open Porous Media project (OPM). This file is part of the Open Porous Media project (OPM).

View File

@ -1,120 +0,0 @@
#include <ert/ecl/ecl_smspec.hpp>
#include <ert/ecl/Smspec.hpp>
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();
}
}

View File

@ -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. The file 'ecl_box.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'ecl_coarse_cell.c' is part of ert - ensemble based reservoir tool.

View File

@ -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. The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool.
@ -534,13 +534,16 @@ static void ecl_file_scan( ecl_file_type * ecl_file ) {
if (read_status == ECL_KW_READ_OK) { if (read_status == ECL_KW_READ_OK) {
ecl_file_kw_type * file_kw = ecl_file_kw_alloc( work_kw , current_offset); 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 )) if (ecl_file_kw_fskip_data( file_kw , ecl_file->fortio ))
ecl_file_view_add_kw( ecl_file->global_view , file_kw ); ecl_file_view_add_kw( ecl_file->global_view , file_kw );
else else {
ecl_file_kw_free( file_kw );
break; break;
} }
} }
} }
}
ecl_kw_free( work_kw ); ecl_kw_free( work_kw );
} }

View File

@ -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. 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 ); size_t_vector_permute( map->file_kw_ptr , perm );
map->sorted = true; map->sorted = true;
free( perm ); perm_vector_free( perm );
} }
} }

View File

@ -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. The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool.
@ -19,9 +19,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <map>
#include <ert/util/vector.hpp>
#include <ert/util/hash.hpp>
#include <ert/ecl/fortio.h> #include <ert/ecl/fortio.h>
#include <ert/ecl/ecl_kw.hpp> #include <ert/ecl/ecl_kw.hpp>
@ -33,13 +31,13 @@
struct ecl_file_view_struct { 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. */ std::vector<ecl_file_kw_type *> kw_list;
hash_type * kw_index; /* A hash table with integer vectors of indices - see comment below. */ std::map<std::string,std::vector<int>> kw_index;
std::vector<std::string> distinct_kw; /* A list of the keywords occuring in the file - each string occurs ONLY ONCE. */ std::vector<std::string> distinct_kw; /* A list of the keywords occuring in the file - each string occurs ONLY ONCE. */
fortio_type * fortio; /* The same fortio instance pointer as in the ecl_file styructure. */ fortio_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. */ 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. */ inv_map_type * inv_map; /* Shared reference owned by the ecl_file structure. */
vector_type * child_list; std::vector<ecl_file_view_type *> child_list;
int * flags; 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_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_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->owner = owner;
ecl_file_view->fortio = fortio; ecl_file_view->fortio = fortio;
ecl_file_view->inv_map = inv_map; 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) { 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); const auto& index_vector = ecl_file_view->kw_index.at(kw);
int global_index = int_vector_iget( index_vector , ith); return index_vector[ith];
return global_index;
} }
@ -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 ) { void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) {
ecl_file_view->distinct_kw.clear(); ecl_file_view->distinct_kw.clear();
hash_clear( ecl_file_view->kw_index ); ecl_file_view->kw_index.clear();
{ {
int i; int global_index = 0;
for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { for (const auto& file_kw : ecl_file_view->kw_list) {
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i); const std::string& header = ecl_file_kw_get_header( file_kw );
const char * header = ecl_file_kw_get_header( file_kw ); if (ecl_file_view->kw_index.find(header) == ecl_file_view->kw_index.end())
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__);
ecl_file_view->distinct_kw.push_back(header); ecl_file_view->distinct_kw.push_back(header);
}
{ auto& index_vector = ecl_file_view->kw_index[header];
int_vector_type * index_vector = (int_vector_type*)hash_get( ecl_file_view->kw_index , header); index_vector.push_back(global_index);
int_vector_append( index_vector , i); global_index++;
}
} }
} }
} }
bool ecl_file_view_has_kw( const ecl_file_view_type * ecl_file_view, const char * kw) { 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 * 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 ecl_file_view->kw_list[global_index];
return file_kw;
} }
ecl_file_kw_type * ecl_file_view_iget_named_file_kw( const ecl_file_view_type * ecl_file_view , const char * kw, int ith) { ecl_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 ecl_file_view_find_kw_value( const ecl_file_view_type * ecl_file_view , const char * kw , const void * value) {
int global_index = -1; int global_index = -1;
if ( ecl_file_view_has_kw( ecl_file_view , kw)) { 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 ); const auto& index_list = ecl_file_view->kw_index.at(kw);
int index = 0; size_t index = 0;
while (index < int_vector_size( index_list )) { while (index < index_list.size()) {
const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( index_list , index )); 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 )) { if (ecl_kw_data_equal( ecl_kw , value )) {
global_index = int_vector_iget( index_list , index ); global_index = index_list[index];
break; break;
} }
index++; 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 ) { 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) { 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; size_t index = 0;
while (index < vector_get_size( ecl_file_view->kw_list )) { while (index < ecl_file_view->kw_list.size() ) {
ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); auto * ikw = ecl_file_view->kw_list[index];
if (ecl_file_kw_ptr_eq( ikw , old_kw)) { if (ecl_file_kw_ptr_eq( ikw , old_kw)) {
/* /*
Found it; observe that the vector_iset() function will 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; bool loadOK = false;
if (fortio_assert_stream_open( ecl_file_view->fortio )) { if (fortio_assert_stream_open( ecl_file_view->fortio )) {
int index; for (ecl_file_kw_type * file_kw : ecl_file_view->kw_list)
for (index = 0; index < vector_get_size( ecl_file_view->kw_list); index++) { ecl_file_kw_get_kw( file_kw, ecl_file_view->fortio , ecl_file_view->inv_map);
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);
}
loadOK = true; 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) { void ecl_file_view_add_kw( ecl_file_view_type * ecl_file_view , ecl_file_kw_type * file_kw) {
if (ecl_file_view->owner) ecl_file_view->kw_list.push_back( file_kw );
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);
} }
void ecl_file_view_free( ecl_file_view_type * ecl_file_view ) { 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 ); for (auto& child_ptr : ecl_file_view->child_list)
vector_free( ecl_file_view->kw_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; 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) { 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)) { if (ecl_file_view_has_kw(ecl_file_view, kw)) {
const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); const auto& index_vector = ecl_file_view->kw_index.at(kw);
return int_vector_size( index_vector ); return index_vector.size();
} else } else
return 0; return 0;
} }
void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_type * target , int offset) { void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_type * target , int offset) {
int index; for (size_t index = offset; index < ecl_file_view->kw_list.size(); index++) {
for (index = offset; index < vector_get_size( ecl_file_view->kw_list ); index++) {
ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , index ); ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , index );
ecl_kw_fwrite( ecl_kw , target ); ecl_kw_fwrite( ecl_kw , target );
} }
@ -336,19 +322,18 @@ 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) { 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 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 auto& index_vector = ecl_file_view->kw_index.at(header);
const int * index_data = int_vector_get_const_ptr( index_vector );
int occurence = -1; int occurence = -1;
{ {
/* Manual reverse lookup. */ /* Manual reverse lookup. */
int i; for (size_t i=0; i < index_vector.size(); i++) {
for (i=0; i < int_vector_size( index_vector ); i++) if (index_vector[i] == global_index)
if (index_data[i] == global_index)
occurence = i; occurence = i;
} }
}
if (occurence < 0) if (occurence < 0)
util_abort("%s: internal error ... \n" , __func__); 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) { void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FILE * stream) {
int i; for (auto& file_kw : ecl_file_view->kw_list) {
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 );
char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw)); char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw));
fprintf(stream , "%-8s %7d:%s\n", fprintf(stream , "%-8s %7d:%s\n",
ecl_file_kw_get_header( file_kw ) , 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); 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) if (start_kw)
kw_index = ecl_file_view_get_global_index( ecl_file_view , start_kw , occurence ); 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) { while (true) {
ecl_file_view_add_kw( block_map , file_kw ); ecl_file_view_add_kw( block_map , file_kw );
kw_index++; kw_index++;
if (kw_index == vector_get_size( ecl_file_view->kw_list )) if (kw_index == ecl_file_view->kw_list.size())
break; break;
else { else {
if (end_kw) { 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) if (strcmp( end_kw , ecl_file_kw_get_header( file_kw )) == 0)
break; 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); ecl_file_view_type * child = ecl_file_view_alloc_blockview2(file_view, header, header, occurence);
if (child) if (child)
vector_append_owned_ref( file_view->child_list , child , ecl_file_view_free__ ); file_view->child_list.push_back(child);
return 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); ecl_file_view_type * child = ecl_file_view_alloc_blockview2(ecl_file_view, start_kw , end_kw , occurence);
if (child) 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; 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 ecl_file_view_find_sim_time(const ecl_file_view_type * ecl_file_view , time_t sim_time) {
int seqnum_index = -1; int seqnum_index = -1;
if ( ecl_file_view_has_kw( ecl_file_view , INTEHEAD_KW)) { 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 ); const auto& intehead_index_list = ecl_file_view->kw_index.at(INTEHEAD_KW);
int index = 0; size_t index = 0;
while (index < int_vector_size( intehead_index_list )) { while (index < intehead_index_list.size()) {
const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( intehead_index_list , index )); 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) { if (ecl_rsthead_date( intehead_kw ) == sim_time) {
seqnum_index = index; seqnum_index = index;
break; 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_type * file_kw = ecl_file_view_iget_file_kw(file_view, i);
ecl_file_kw_end_transaction(file_kw, ref_count[i]); ecl_file_kw_end_transaction(file_kw, ref_count[i]);
} }
free(transaction->ref_count);
free(transaction);
} }

View File

@ -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. This file is part of ERT - Ensemble based Reservoir Tool.
@ -20,9 +20,11 @@
#include <math.h> #include <math.h>
#include <stdbool.h> #include <stdbool.h>
#include <unordered_map>
#include <vector>
#include <string>
#include <ert/util/util.h> #include <ert/util/util.h>
#include <ert/util/hash.hpp>
#include <ert/util/vector.hpp>
#include <ert/ecl/ecl_kw.hpp> #include <ert/ecl/ecl_kw.hpp>
#include <ert/ecl/ecl_util.hpp> #include <ert/ecl/ecl_util.hpp>
@ -69,12 +71,10 @@ struct ecl_grav_struct {
const ecl_file_type * init_file; /* The init file - a shared reference owned by calling scope. */ 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. */ ecl::ecl_grid_cache * grid_cache; /* An internal specialized structure to facilitate fast grid lookup. */
bool * aquifer_cell; /* Numerical aquifer cells should be ignored. */ 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. */ std::unordered_map<std::string, ecl_grav_survey_type *> surveys;
hash_type * std_density; /* Hash table indexed with "SWAT" , "SGAS" and "SOIL"; each element std::unordered_map<std::string, double> default_density;
is a double_vector() instance which is indexed by PVTNUM std::unordered_map<std::string, std::vector<double>> std_density;
values. Used to lookup standard condition mass densities. Must
be suuplied by user __BEFORE__ adding a FIP based survey. */
}; };
@ -92,8 +92,8 @@ struct ecl_grav_survey_struct {
const bool * aquifer_cell; const bool * aquifer_cell;
char * name; /* Name of the survey - arbitrary string. */ 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. */ 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. */ std::vector<ecl_grav_phase_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. */ std::unordered_map<std::string, ecl_grav_phase_type*> phase_map; /* The same objects as in the phase_list vector - accessible by the "SWAT", "SGAS" and "SOIL" keys. */
}; };
@ -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 ecl::ecl_grid_cache * grid_cache = ecl_grav->grid_cache;
const char * sat_kw_name = ecl_util_get_phase_name( phase ); 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(); const int size = grid_cache->size();
UTIL_TYPE_ID_INIT( grav_phase , ECL_GRAV_PHASE_TYPE_ID ); 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) { if (calc_type == GRAV_CALC_FIP) {
ecl_kw_type * pvtnum_kw = ecl_file_iget_named_kw( init_file , PVTNUM_KW , 0 ); 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<double> std_density = ecl_grav->std_density[std::string(ecl_util_get_phase_name(phase))];
ecl_kw_type * fip_kw; ecl_kw_type * fip_kw;
if ( phase == ECL_OIL_PHASE) 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++) { for (iactive=0; iactive < size; iactive++) {
double fip = ecl_kw_iget_as_double( fip_kw , iactive ); double fip = ecl_kw_iget_as_double( fip_kw , iactive );
int pvtnum = ecl_kw_iget_int( pvtnum_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 { } 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 ) { static void ecl_grav_phase_free( ecl_grav_phase_type * grav_phase ) {
free( grav_phase->work ); free( grav_phase->work );
free( grav_phase->fluid_mass ); 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 ) { 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__ ); survey->phase_list.push_back(grav_phase);
hash_insert_ref( survey->phase_map , ecl_util_get_phase_name( phase ) , 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 , static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * ecl_grav ,
const char * name , const char * name ,
grav_calc_type calc_type) { 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 ); UTIL_TYPE_ID_INIT( survey , ECL_GRAV_SURVEY_ID );
survey->grid_cache = ecl_grav->grid_cache; survey->grid_cache = ecl_grav->grid_cache;
survey->aquifer_cell = ecl_grav->aquifer_cell; survey->aquifer_cell = ecl_grav->aquifer_cell;
survey->name = util_alloc_string_copy( name ); 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) if (calc_type & GRAV_CALC_USE_PORV)
survey->porv = (double*)util_calloc( ecl_grav->grid_cache->size() , sizeof * survey->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; 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 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 ) { static void ecl_grav_survey_free( ecl_grav_survey_type * grav_survey ) {
free( grav_survey->name ); free( grav_survey->name );
free( grav_survey->porv ); free( grav_survey->porv );
vector_free( grav_survey->phase_list ); for (auto * phase : grav_survey->phase_list)
hash_free( grav_survey->phase_map ); ecl_grav_phase_free( phase );
free( grav_survey );
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 , const ecl_grav_survey_type * monitor_survey ,
ecl_region_type * region , ecl_region_type * region ,
double utm_x , double utm_y , double depth, int phase_mask) { double utm_x , double utm_y , double depth, int phase_mask) {
int phase_nr;
double deltag = 0; double deltag = 0;
for (phase_nr = 0; phase_nr < vector_get_size( 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 = (ecl_grav_phase_type*)vector_iget( base_survey->phase_list , phase_nr ); ecl_grav_phase_type * base_phase = base_survey->phase_list[phase_nr];
if (base_phase->phase & phase_mask) { if (base_phase->phase & phase_mask) {
if (monitor_survey != NULL) { 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 ); deltag += ecl_grav_phase_eval( base_phase , monitor_phase , region , utm_x , utm_y , depth );
} else } else
deltag += ecl_grav_phase_eval( base_phase , NULL , region , utm_x , utm_y , depth ); 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_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->init_file = init_file;
ecl_grav->grid_cache = new ecl::ecl_grid_cache(ecl_grid); 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->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; return ecl_grav;
} }
static void ecl_grav_add_survey__( ecl_grav_type * grav , const char * name , ecl_grav_survey_type * survey) { 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) if (name == NULL)
return NULL; // Calling scope must determine if this is OK? return NULL; // Calling scope must determine if this is OK?
else { else {
if (hash_has_key( grav->surveys , name)) if (grav->surveys.count(name) > 0)
return (ecl_grav_survey_type*)hash_get( grav->surveys , name ); return grav->surveys.at(name);
else { else {
hash_iter_type * survey_iter = hash_iter_alloc( grav->surveys );
fprintf(stderr,"Survey name:%s not registered. Available surveys are: \n\n " , name); 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 ); for (const auto& survey_pair : grav->surveys)
fprintf(stderr,"%s ",survey); fprintf(stderr,"%s ",survey_pair.first.c_str());
}
fprintf(stderr,"\n\n"); fprintf(stderr,"\n\n");
hash_iter_free( survey_iter );
exit(1); 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) { 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 ); const char * phase_key = ecl_util_get_phase_name( phase );
if (!hash_has_key( grav->std_density , phase_key )) grav->default_density[std::string(phase_key)] = default_density;
hash_insert_hash_owned_ref( grav->std_density , phase_key , double_vector_alloc( 0 , default_density ) , double_vector_free__ );
} }
/** /**
@ -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) { 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 )); std::vector<double>& std_density = grav->std_density[ std::string(ecl_util_get_phase_name(phase)) ];
double_vector_iset( std_density , pvtnum , density ); if (std_density.size() <= static_cast<std::size_t>(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 ) { void ecl_grav_free( ecl_grav_type * ecl_grav ) {
delete ecl_grav->grid_cache; delete ecl_grav->grid_cache;
free( ecl_grav->aquifer_cell ); free( ecl_grav->aquifer_cell );
hash_free( ecl_grav->surveys );
hash_free( ecl_grav->std_density ); for (const auto& survey_pair : ecl_grav->surveys)
free( ecl_grav ); ecl_grav_survey_free( survey_pair.second );
delete ecl_grav;
} }

View File

@ -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. The file 'ecl_grav.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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 The file 'ecl_grav_common.c' is part of ERT - Ensemble based
Reservoir Tool. Reservoir Tool.

View File

@ -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. The file 'ecl_grid.c' is part of ert - ensemble based reservoir tool.
@ -21,12 +21,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include <math.h> #include <math.h>
#include <vector> #include <vector>
#include <unordered_map>
#include <string>
#include <ert/util/util.h> #include <ert/util/util.h>
#include <ert/util/double_vector.hpp> #include <ert/util/double_vector.hpp>
#include <ert/util/int_vector.hpp> #include <ert/util/int_vector.hpp>
#include <ert/util/hash.hpp>
#include <ert/util/vector.hpp> #include <ert/util/vector.hpp>
#include <ert/util/stringlist.hpp> #include <ert/util/stringlist.hpp>
@ -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 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. */ 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<std::string, ecl_grid_type*> children;
const ecl_grid_type * parent_grid; /* the parent grid for this (lgr) - NULL for the main grid. */ 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. */ 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*/ 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.*/ 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<std::string, ecl_grid_type*> 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 */ 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 .. */ /* not used yet .. */
@ -1534,7 +1536,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid,
int nz, int nz,
int lgr_nr, int lgr_nr,
bool init_valid) { 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); UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID);
grid->total_active = 0; grid->total_active = 0;
grid->total_active_fracture = 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 */ if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */
grid->LGR_list = vector_alloc_new(); grid->LGR_list = vector_alloc_new();
grid->lgr_index_map = int_vector_alloc(0,0); grid->lgr_index_map = int_vector_alloc(0,0);
grid->LGR_hash = hash_alloc();
} else { } else {
grid->LGR_list = NULL; grid->LGR_list = NULL;
grid->lgr_index_map = NULL; grid->lgr_index_map = NULL;
grid->LGR_hash = NULL;
} }
grid->name = NULL; grid->name = NULL;
grid->parent_name = NULL; grid->parent_name = NULL;
grid->parent_grid = NULL; grid->parent_grid = NULL;
grid->children = hash_alloc();
grid->coarse_cells = vector_alloc_new(); grid->coarse_cells = vector_alloc_new();
grid->eclipse_version = 0; 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) { 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__); 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); 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) { 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; lgr_grid->parent_grid = host_grid;
} }
@ -3029,8 +3030,8 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const
if (ext_actnum) if (ext_actnum)
actnum_data = ext_actnum; actnum_data = ext_actnum;
else { else {
if (ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW) > grid_nr) { 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_kw = ecl_file_iget_named_kw( ecl_file , ACTNUM_KW , grid_nr);
actnum_data = ecl_kw_get_int_ptr(actnum_kw); actnum_data = ecl_kw_get_int_ptr(actnum_kw);
} }
} }
@ -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. */ if (ECL_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */
vector_free( grid->LGR_list ); vector_free( grid->LGR_list );
int_vector_free( grid->lgr_index_map); int_vector_free( grid->lgr_index_map);
hash_free( grid->LGR_hash );
} }
if (grid->coord_kw != NULL) if (grid->coord_kw != NULL)
ecl_kw_free( grid->coord_kw ); ecl_kw_free( grid->coord_kw );
vector_free( grid->coarse_cells ); vector_free( grid->coarse_cells );
hash_free( grid->children );
free( grid->parent_name ); free( grid->parent_name );
free( grid->visited ); free( grid->visited );
free( grid->name ); 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 ); __assert_main_grid( main_grid );
{ {
char * lgr_name = util_alloc_strip_copy( __lgr_name ); 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); free(lgr_name);
return lgr_grid; 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 ); __assert_main_grid( main_grid );
{ {
char * lgr_name = util_alloc_strip_copy( __lgr_name ); 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); free(lgr_name);
return has_lgr; 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) { stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) {
__assert_main_grid( 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 ) { 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; bool consistent = true;
while (!hash_iter_is_complete( lgr_iter )) { for (const auto& lgr_pair : ecl_grid->children) {
const ecl_grid_type * lgr = (const ecl_grid_type*)hash_iter_get_next_value( lgr_iter ); const ecl_grid_type * lgr = lgr_pair.second;
consistent &= ecl_grid_test_lgr_consistency2( ecl_grid , lgr ); consistent &= ecl_grid_test_lgr_consistency2( ecl_grid , lgr );
consistent &= ecl_grid_test_lgr_consistency( lgr ); consistent &= ecl_grid_test_lgr_consistency( lgr );
} }
hash_iter_free( lgr_iter );
return consistent; 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; bool fmt_file = false;
fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP ); 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; coords_size = 7;
if (grid->coarsening_active) 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) { void ecl_grid_fwrite_EGRID2( ecl_grid_type * grid , const char * filename, ert_ecl_unit_enum output_unit) {
bool fmt_file = false; 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 ); fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP );
ecl_grid_fwrite_EGRID__( grid , fortio, output_unit); ecl_grid_fwrite_EGRID__( grid , fortio, output_unit);

View File

@ -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 The file 'ecl_grid_cache.c' is part of ERT - Ensemble based
Reservoir Tool. Reservoir Tool.

View File

@ -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. The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'ecl_init_file.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@ -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. The file 'ecl_io_config.c' is part of ERT - Ensemble based Reservoir Tool.

Some files were not shown because too many files have changed in this diff Show More