mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#804 Updated ERT based on 6287acdb0d039ce13eb9956b67035280a3de9539
This commit is contained in:
parent
7269e6e165
commit
3b4f1620a5
18
ThirdParty/Ert/.gitignore
vendored
18
ThirdParty/Ert/.gitignore
vendored
@ -7,17 +7,17 @@
|
||||
*.user
|
||||
*.user.*
|
||||
.idea
|
||||
devel/python/lib64
|
||||
/devel/libenkf/src/.faultlist
|
||||
python/lib64
|
||||
/libenkf/src/.faultlist
|
||||
/develbranch/libenkf/src/.faultlist
|
||||
/build
|
||||
/devel/libert_util/tests/data/latex_OK.pdf
|
||||
/devel/test-data/Statoil
|
||||
/devel/python/python/ert/ecl/ecl_local.py
|
||||
/devel/GPATH
|
||||
/devel/GRTAGS
|
||||
/devel/GTAGS
|
||||
/devel/gtags.sh
|
||||
/libert_util/tests/data/latex_OK.pdf
|
||||
/test-data/Statoil
|
||||
/python/python/ert/ecl/ecl_local.py
|
||||
/GPATH
|
||||
/GRTAGS
|
||||
/GTAGS
|
||||
/gtags.sh
|
||||
/cmake.sh
|
||||
scratch.sparsebundle
|
||||
*.iml
|
||||
|
10
ThirdParty/Ert/.travis.yml
vendored
10
ThirdParty/Ert/.travis.yml
vendored
@ -49,7 +49,7 @@ install:
|
||||
- conda update -q conda
|
||||
# Useful for debugging any issues with conda
|
||||
- conda info -a
|
||||
- conda install pyqt scipy=0.16.1 numpy pandas matplotlib
|
||||
- conda install pyqt=4 scipy=0.16.1 numpy pandas matplotlib
|
||||
|
||||
env:
|
||||
global:
|
||||
@ -58,10 +58,6 @@ env:
|
||||
before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- echo "WORKFLOW_JOB_DIRECTORY ../devel/share/workflows/jobs/internal/config" > DEFAULT_SITE_CONFIG_FILE
|
||||
- echo "WORKFLOW_JOB_DIRECTORY ../devel/share/workflows/jobs/internal-gui/config" >> DEFAULT_SITE_CONFIG_FILE
|
||||
- echo "JOB_SCRIPT ../devel/share/bin/job_dispatch.py" >> DEFAULT_SITE_CONFIG_FILE
|
||||
- echo "MAX_RUNNING_LOCAL 1" >> DEFAULT_SITE_CONFIG_FILE
|
||||
- cmake -DPYTHON_INSTALL_PREFIX=python -DBUILD_ERT=ON -DERT_BUILD_GUI=ON -DBUILD_TESTS=ON -DBUILD_APPLICATIONS=ON -DUSE_RUNPATH=ON -DBUILD_PYTHON=ON -DERT_USE_OPENMP=ON -DERT_DOC=OFF -DSITE_CONFIG_FILE=DEFAULT_SITE_CONFIG_FILE -DERT_BUILD_CXX=ON ../devel
|
||||
- cmake -DPYTHON_INSTALL_PREFIX=python -DBUILD_ERT=ON -DERT_BUILD_GUI=ON -DBUILD_TESTS=ON -DBUILD_APPLICATIONS=ON -DUSE_RUNPATH=ON -DBUILD_PYTHON=ON -DERT_USE_OPENMP=ON -DERT_DOC=OFF -DERT_BUILD_CXX=ON ..
|
||||
|
||||
script: make && ctest --output-on-failure -LE StatoilData
|
||||
script: make && ctest --output-on-failure
|
||||
|
@ -7,27 +7,43 @@ endif()
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
set( ERT_VERSION_MAJOR 2 )
|
||||
set( ERT_VERSION_MINOR 0 )
|
||||
set( ERT_VERSION_MICRO git )
|
||||
set( ERT_VERSION_MAJOR 2 ) # Remember to update release notes whenever
|
||||
set( ERT_VERSION_MINOR 1 ) # you change the ERT_VERSION_MINOR or MAJOR
|
||||
set( ERT_VERSION_MICRO git ) # with "new in Ert Version X.X.X"!
|
||||
|
||||
# If the micro version is not integer, that should be interpreted as a
|
||||
# development version leading towards version MAJOR.MINOR.0
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
option( BUILD_ERT "Build the full ERT application - Linux only" OFF)
|
||||
option( BUILD_TESTS "Should the tests be built" OFF)
|
||||
option( BUILD_APPLICATIONS "Should we build small utility applications" OFF)
|
||||
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" ON )
|
||||
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
||||
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON )
|
||||
option( ERT_BUILD_GUI "Should the PyQt based GUI be compiled and installed" OFF)
|
||||
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" OFF)
|
||||
option( ERT_DOC "Build ERT documantation" OFF)
|
||||
option( ERT_BUILD_CXX "Build some CXX wrappers" ON)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata")
|
||||
if (EXISTS ${STATOIL_TESTDATA_ROOT})
|
||||
set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Statoil" )
|
||||
if (EXISTS ${LINK})
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${LINK}")
|
||||
endif()
|
||||
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${STATOIL_TESTDATA_ROOT}" "${LINK}")
|
||||
message(STATUS "Linking testdata: ${LINK} -> ${STATOIL_TESTDATA_ROOT}")
|
||||
endif()
|
||||
|
||||
|
||||
option( BUILD_ERT "Build the full ERT application - Linux only" OFF)
|
||||
option( BUILD_TESTS "Should the tests be built" OFF)
|
||||
option( BUILD_APPLICATIONS "Should we build small utility applications" OFF)
|
||||
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" ON)
|
||||
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
||||
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON)
|
||||
option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF )
|
||||
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" OFF)
|
||||
option( ERT_DOC "Build ERT documantation" OFF)
|
||||
option( ERT_BUILD_CXX "Build some CXX wrappers" ON)
|
||||
|
||||
include( CheckFunctionExists )
|
||||
include( CheckTypeSize )
|
||||
@ -59,13 +75,13 @@ endif()
|
||||
# Treat warnings as errors if not on Windows
|
||||
if (NOT ERT_WINDOWS)
|
||||
set( CMAKE_C_FLAGS "-std=gnu99 -Wall -Wno-unknown-pragmas ")
|
||||
set( CMAKE_CXX_FLAGS "-Wall " )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall " )
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
|
||||
else()
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
|
||||
endif()
|
||||
|
||||
|
||||
@ -89,8 +105,8 @@ set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} )
|
||||
set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} )
|
||||
|
||||
if (NOT ERT_WINDOWS)
|
||||
set( CMAKE_C_FLAGS "-std=gnu99" )
|
||||
set( CMAKE_CXX_FLAGS "-std=c++0x")
|
||||
set( CMAKE_C_FLAGS_main "${CMAKE_C_FLAGS} -std=gnu99" )
|
||||
set( CMAKE_CXX_FLAGS_main "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif()
|
||||
|
||||
set( ERT_EXTERNAL_UTIL_LIBS "" )
|
||||
@ -168,6 +184,7 @@ if (BUILD_ERT)
|
||||
if (BUILD_TESTS)
|
||||
option( ERT_LSF_SUBMIT_TEST "Build and run tests of LSF submit" OFF)
|
||||
endif()
|
||||
add_subdirectory( bin )
|
||||
|
||||
include(cmake/ert_module_name.cmake)
|
||||
|
61
ThirdParty/Ert/README
vendored
61
ThirdParty/Ert/README
vendored
@ -1,3 +1,39 @@
|
||||
Coming from OPM??
|
||||
-----------------
|
||||
|
||||
ERT is a package for handling an ensemble of reservoir models, an
|
||||
important part of that is beeing able to read and write the files from
|
||||
standard reservoir applications; ert has quite extensive support for
|
||||
reading and writing the result files from the ECLIPSE reservoir
|
||||
simulator. The capabilities to read and write ECLIPSE result files is
|
||||
used by the OPM simulator codes.
|
||||
|
||||
The ERT build system has many configuration options, but when
|
||||
compiling for OPM you should be able to use the all defaults route:
|
||||
|
||||
git clone https://github.com/Ensembles/ert.git
|
||||
cd ert
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
|
||||
The OPM build system can find an ERT distribution in the sibling
|
||||
location, i.e. if you have cloned ert beside the opm modules like:
|
||||
|
||||
ert/
|
||||
opm-common/
|
||||
opm-parser/
|
||||
opm-material/
|
||||
....
|
||||
|
||||
The opm build system will find the ert distribution in-place,
|
||||
otherwise you should install ert with 'make install' and the normal
|
||||
cmake machinery of the opm build system should find it.
|
||||
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
_________________________________
|
||||
/ \
|
||||
| ______ ______ _______ |
|
||||
@ -77,14 +113,15 @@ with MinGW.
|
||||
3. Building ERT
|
||||
|
||||
CMake is the build system for ERT. The top level CMakeLists.txt file
|
||||
is located in the devel/ directory, and this CMakeLists.txt file
|
||||
includes individual CMakeLists.txt files for the different libraries.
|
||||
is located in the top level directory of the repository, and this
|
||||
CMakeLists.txt file includes individual CMakeLists.txt files for the
|
||||
different libraries.
|
||||
|
||||
Building with CMake is performed like this:
|
||||
|
||||
1. Create a build directory, this can in principle be anywhere in
|
||||
the filesystem. At the same level as the devel/ directory is a
|
||||
practical choice.
|
||||
the filesystem. One level above the toplevel source directory is
|
||||
a practical choice.
|
||||
|
||||
2. Go to the build directory and invoke the command:
|
||||
|
||||
@ -205,8 +242,8 @@ orientation'. Most of the code is uses the following conventions:
|
||||
Some of the code, in particular the ECLIPSE related functionality, has
|
||||
been wrapped for usage in Python. Using these wrappers, it is quite
|
||||
easy work with ECLIPSE files. The python wrappers are quite well
|
||||
documented both in the directory devel/python/docs and in the Python
|
||||
classes themselves.
|
||||
documented both in the directory python/docs and in the Python classes
|
||||
themselves.
|
||||
|
||||
|
||||
5. Tests
|
||||
@ -242,10 +279,10 @@ way, and the last line adds it as a test.
|
||||
|
||||
5.2 Testing of Python Code
|
||||
|
||||
In devel/python/test there are several files with Python tests, these
|
||||
files are executable files and they are invoked directly from the
|
||||
command line. A limited number of the tests have been integrated in the
|
||||
ctest system.
|
||||
In python/test there are several files with Python tests, these files
|
||||
are executable files and they are invoked directly from the command
|
||||
line. A limited number of the tests have been integrated in the ctest
|
||||
system.
|
||||
|
||||
5.3 Test names
|
||||
|
||||
@ -275,8 +312,8 @@ labels currently available in the ERT test setup are:
|
||||
|
||||
StatoilData: This implies that the test makes use of Statoil
|
||||
internal data. If you are work for the Bergen office of Statoil,
|
||||
you can read the the file devel/test-data/README for
|
||||
instructions on how to make this data available.
|
||||
you can read the the file test-data/README for instructions on
|
||||
how to make this data available.
|
||||
|
||||
If you are not for Statoil in Bergen, you must pass the option:
|
||||
"-EL StatoilData" to ctest to skip all the tests which require
|
||||
|
4
ThirdParty/Ert/appveyor.yml
vendored
4
ThirdParty/Ert/appveyor.yml
vendored
@ -2,8 +2,6 @@
|
||||
clone_depth: 1
|
||||
build_script:
|
||||
- cmd: >-
|
||||
cd devel
|
||||
|
||||
mkdir build
|
||||
|
||||
cd build
|
||||
@ -11,4 +9,4 @@ build_script:
|
||||
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DERT_BUILD_CXX=OFF -DBUILD_PYTHON=OFF -DBUILD_APPLICATIONS=ON
|
||||
|
||||
|
||||
msbuild /m /p:Configuration=Release /p:Platform="x64" ERT.sln
|
||||
msbuild /m /p:Configuration=Release /p:Platform="x64" ERT.sln
|
||||
|
@ -20,6 +20,7 @@ endif(UNIX)
|
||||
|
||||
|
||||
check_function_exists( localtime_r HAVE_LOCALTIME_R )
|
||||
check_function_exists( gmtime_r HAVE_GMTIME_R )
|
||||
check_function_exists( realpath HAVE_REALPATH )
|
||||
check_function_exists( usleep HAVE__USLEEP )
|
||||
check_function_exists( fnmatch HAVE_FNMATCH )
|
||||
@ -35,7 +36,7 @@ check_function_exists( pthread_timedjoin_np HAVE_TIMEDJOIN)
|
||||
check_function_exists( pthread_yield_np HAVE_YIELD_NP)
|
||||
check_function_exists( pthread_yield HAVE_YIELD)
|
||||
check_function_exists( fseeko HAVE_FSEEKO )
|
||||
|
||||
check_function_exists( timegm HAVE_TIMEGM )
|
||||
|
||||
check_function_exists( _mkdir HAVE_WINDOWS_MKDIR)
|
||||
if (NOT HAVE_WINDOWS_MKDIR)
|
@ -2,7 +2,7 @@ Source: ert.ecl
|
||||
Priority: extra
|
||||
Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no>
|
||||
Build-Depends: debhelper (>= 8.0.0), cmake, liblapack-dev, libquadmath0,
|
||||
iputils-ping, zlib1g-dev, git, python-dev
|
||||
iputils-ping, zlib1g-dev, git, python-dev, python-numpy
|
||||
Standards-Version: 3.9.2
|
||||
Section: libs
|
||||
Homepage: http://ert.nr.no
|
||||
@ -28,7 +28,14 @@ Description: The Ensemble based Reservoir Tool
|
||||
Package: python-ert.ecl
|
||||
Section: python
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, libert.ecl1
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, libert.ecl1, python-cwrap
|
||||
Description: The Ensemble based Reservoir Tool - Python bindings
|
||||
ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble
|
||||
of reservoir models.
|
||||
|
||||
Package: python-cwrap
|
||||
Section: python
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: Package to simplify ctypes based wrapping of C code.
|
||||
Package to simplify ctypes based wrapping of C code.
|
1
ThirdParty/Ert/debian/python-cwrap.install
vendored
Normal file
1
ThirdParty/Ert/debian/python-cwrap.install
vendored
Normal file
@ -0,0 +1 @@
|
||||
usr/lib/python2.7/*/cwrap/*
|
1
ThirdParty/Ert/debian/python-ert.ecl.install
vendored
Normal file
1
ThirdParty/Ert/debian/python-ert.ecl.install
vendored
Normal file
@ -0,0 +1 @@
|
||||
usr/lib/python2.7/*/ert/*
|
@ -1 +0,0 @@
|
||||
usr/lib/python2.7/*
|
@ -1,945 +0,0 @@
|
||||
|
||||
Keywords for the local configuration file
|
||||
=========================================
|
||||
|
||||
|
||||
|
||||
General overview
|
||||
----------------
|
||||
|
||||
To create a configuration for localization you must "program" your own
|
||||
configuration file, this file is then loaded from the ert/enkf proper
|
||||
application. The 'commands' available in the local_config programming
|
||||
language are listed below.
|
||||
|
||||
An alterative way to 'program' the local config commands is by writing a Python script, and invoking it from a workflow.
|
||||
Not all the commands available from the local config programming are supported for Python scripting.
|
||||
|
||||
|
||||
**Local config python script example:**
|
||||
|
||||
::
|
||||
|
||||
from ert.enkf import ErtScript
|
||||
from ert.enkf import LocalConfig, LocalObsdata, LocalObsdataNode, LocalMinistep, LocalUpdateStep, LocalDataset, ActiveList
|
||||
from ert.ecl import EclGrid, EclRegion, Ecl3DKW, EclFile, EclInitFile, EclKW, EclTypeEnum
|
||||
|
||||
class LocalConfigJob(ErtScript):
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
# This example can be used with the REEK data set from the ERT tutorial
|
||||
|
||||
# Get the ert object
|
||||
ert = self.ert()
|
||||
|
||||
# Get local config object
|
||||
local_config = ert.getLocalConfig()
|
||||
|
||||
# Reset internal local config structure. From now you need to specify what to localize
|
||||
local_config.clear()
|
||||
|
||||
# There is only one update step
|
||||
updatestep = local_config.getUpdatestep()
|
||||
|
||||
# A ministep
|
||||
ministep = local_config.createMinistep("MINISTEP" )
|
||||
|
||||
# Add some dataset you want to localize here.
|
||||
dataset_multflt = local_config.createDataset("DATASET_MULTFLT")
|
||||
|
||||
# Add some field and localize inside a box
|
||||
data_poro = local_config.createDataset("DATA_PORO")
|
||||
ecl_grid = local_config.getGrid()
|
||||
ecl_region = EclRegion(ecl_grid, False)
|
||||
ecl_region.select_box((0,0,0),(3,3,3))
|
||||
data_poro.addField("PORO", ecl_region)
|
||||
|
||||
|
||||
# Add some index from MULTFLT to the dataset
|
||||
dataset_multflt.addNode("MULTFLT")
|
||||
active_list = dataset_multflt.getActiveList("MULTFLT")
|
||||
active_list.addActiveIndex(0)
|
||||
|
||||
# Add existing observations from WOPR:OP_1. Alternatively, use getObservations and filter the observations you want to use for this ministep.
|
||||
obsdata_wopr = local_config.createObsdata("WOPR:OP_1_10")
|
||||
for i in range(1,10):
|
||||
obsdata_wopr.addNode("OBS"+str(i))
|
||||
|
||||
# Attach the created dataset and obsset to the ministep
|
||||
ministep.attachDataset(dataset_multflt)
|
||||
ministep.attachObsset(obsdata_wopr)
|
||||
|
||||
# Then attach the ministep to the update step
|
||||
updatestep.attachMinistep(ministep)
|
||||
|
||||
# Write a .csv file for debugging. The generated file can be imported into Excel for a better tabulation of the setup
|
||||
local_config.writeSummaryFile("tmp/summary_local_config.csv")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
List of keywords
|
||||
----------------
|
||||
=========================================================================================== =========================================================== ==============================================================================================================================================
|
||||
Keyword name ERT script function Purpose
|
||||
=========================================================================================== =========================================================== ==============================================================================================================================================
|
||||
:ref:`CREATE_UPDATESTEP <create_updatestep>` getUpdatestep Creates/gets default updatestep
|
||||
:ref:`CREATE_MINISTEP <create_ministep>` createMinistep Creates ministep
|
||||
:ref:`CREATE_DATASET <create_dataset>` createDataset Creates dataset
|
||||
:ref:`COPY_DATASET <copy_dataset>` copyDataset Deep copy of dataset
|
||||
:ref:`CREATE_OBSSET <create_obsset>` createObsdata Creates observation set
|
||||
:ref:`COPY_OBSSET <copy_obsset>` copyObsdata Deep copy of observation set
|
||||
:ref:`ATTACH_MINISTEP <attach_ministep>` attachMinistep Attaches ministep to update step
|
||||
:ref:`ATTACH_DATASET <attach_dataset>` attachDataset Attaches dataset to mini step
|
||||
:ref:`ATTACH_OBSSET <attach_obsset>` attachObsset Attaches observation set to mini step
|
||||
:ref:`ADD_DATA <add_data>` addNode Adds data node to dataset
|
||||
:ref:`DEL_DATA <del_data>` del Deletes observation node from dataset
|
||||
:ref:`ADD_OBS <add_obs>` addNode, addNodeAndRange Adds observation node to observation set for all times or in a given time range
|
||||
:ref:`DEL_OBS <del_obs>` del Deletes observation node from observation set
|
||||
:ref:`DATASET_DEL_ALL_DATA <dataset_del_all_data>` clear Delete all the data keys from a dataset
|
||||
:ref:`ACTIVE_LIST_ADD_DATA_INDEX <active_list_add_data_index>` addActiveIndex Adds data index to the list of active indices
|
||||
:ref:`ACTIVE_LIST_ADD_OBS_INDEX <active_list_add_obs_index>` addActiveIndex Adds observation index to the list of active indices
|
||||
:ref:`ACTIVE_LIST_ADD_MANY_DATA_INDEX <active_list_add_many_data_index>` addActiveIndex Adds several data indices to the list of active indices
|
||||
:ref:`ACTIVE_LIST_ADD_MANY_OBS_INDEX <active_list_add_many_obs_index>` addActiveIndex Adds several observation indinces to the list of active indices
|
||||
:ref:`ADD_FIELD <add_field>` addField Adds field node to dataset
|
||||
:ref:`LOAD_FILE <load_file>` EclGrid, EclInitFile, Loads eclipse file in restart format
|
||||
:ref:`CREATE_ECLREGION <create_eclregion>` EclRegion Creates a new region for use when defining active regions for fields
|
||||
:ref:`ECLREGION_SELECT_ALL <eclregion_select_all>` select_active Selects or deselects cells in a region
|
||||
:ref:`ECLREGION_SELECT_VALUE_EQUAL <eclregion_select_value_equal>` select_equal Selects or deselects cells in a region equal to given value
|
||||
:ref:`ECLREGION_SELECT_VALUE_LESS <eclregion_select_value_less>` select_less Selects or deselects cells in a region equal less than a given value
|
||||
:ref:`ECLREGION_SELECT_VALUE_MORE <eclregion_select_value_more>` select_more Selects or deselects cells in a region equal greater than a given value
|
||||
:ref:`ECLREGION_SELECT_BOX <eclregion_select_box>` select_box Selects or deselects cells in a box
|
||||
:ref:`ECLREGION_SELECT_SLICE <eclregion_select_slice>` select_islice, select_jslice, select_kslice Selects or deselects cells in a slice
|
||||
:ref:`ECLREGION_SELECT_PLANE <eclregion_select_plane>` select_below_plane Selects or deselects cells in a half space defined by a plane
|
||||
:ref:`ECLREGION_SELECT_IN_POLYGON <eclregion_select_in_polygon>` select_inside_polygon Selects or deselects cells in region inside polygon
|
||||
:ref:`CREATE_POLYGON <create_polygon>` :ref:`Example <create_polygon>` Creates a geo-polygon based on coordinate list
|
||||
:ref:`LOAD_POLYGON <load_polygon>` :ref:`Example <load_polygon>` Loads polygon in Irap RMS format from file
|
||||
:ref:`LOAD_SURFACE <load_surface>` Loads surface in Irap RMS format from file
|
||||
:ref:`CREATE_SURFACE_REGION <create_surface_region>` Creates region to select or deselect parts of a surface
|
||||
:ref:`SURFACE_REGION_SELECT_IN_POLYGON <surface_region_select_in_polygon>` Creates region to select or deselect parts of a surface
|
||||
:ref:`SURFACE_REGION_SELECT_LINE <surface_region_select_line>` Selects or deselects parts of a surface in half space define by a line
|
||||
:ref:`ADD_DATA_SURFACE <add_data_surface>` Adds surface node to dataset with elements in a surface region
|
||||
| getObservations Get the observations currently imported. Use to filter the observations to localize.
|
||||
| getGrid Get the underlying grid. Use to define active cells in a field.
|
||||
=========================================================================================== =========================================================== ==============================================================================================================================================
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _create_updatestep:
|
||||
.. topic:: CREATE_UPDATESTEP
|
||||
|
||||
| This function will create a updatestep with the name 'NAME_OF_UPDATESTEP'.
|
||||
| Observe that you must add (at least) one ministep to the updatestep, otherwise it will not be able to do anything.
|
||||
| Currently supports only one update step. It is kept here due to historical reasons when it was possible to have several update steps.
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Updatestep
|
||||
CREATE_UPDATESTEP DEFAULT
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
updatestep = local_config.getUpdatestep()
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
|
||||
.. _create_ministep:
|
||||
.. topic:: CREATE_MINISTEP
|
||||
|
||||
| This function will create a new ministep with the name 'NAME_OF_MINISTEP'. A given OBSSET can be attached to a given ministep.The ministep is then ready for adding data. Before the ministep can be used you must attach it to an updatestep with the ATTACH_MINISTEP command
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Ministep in updatestep
|
||||
CREATE_MINISTEP MINISTEP
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
ministep = local_config.createMinistep("MINISTEP")
|
||||
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _create_dataset:
|
||||
.. topic:: CREATE_DATASET
|
||||
|
||||
| This function will create a new dataset, i.e. a collection of enkf_nodes which should be updated together. Before you can actually use a dataset you must attach it to a ministep with the ATTACH_DATASET command.
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Create a DATASET_MULTFLT dataset
|
||||
CREATE_DATASET DATASET_MULTFLT
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
dataset_multflt = local_config.createDataset("DATASET_MULTFLT")
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _copy_dataset:
|
||||
.. topic:: COPY_DATASET
|
||||
|
||||
| Will create a new local_obsset instance which is a copy of the 'SRC_OBSSET'; this is a deep copy where also the lowest level active_list instances are copied, and can then subsequently be updated independently of each other.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Deep copy DATASET_MULTFLT dataset
|
||||
COPY_DATASET DATASET_MULTFLT COPY_DATASET_MULTFLT
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _create_obsset:
|
||||
.. topic:: CREATE_OBSSET
|
||||
|
||||
| This function will create an observation set, i.e. a collection of observation keys which will be used as the observations in one ministep. Before the obsset can be used it must be attached to a ministep with the ATTACH_OBSSET command.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Create a OBS_WELL obsset
|
||||
CREATE_OBSSET OBS_WELL
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
obsset_obs_well = local_config.createObsdata("OBS_WELL")
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _copy_obsset:
|
||||
.. topic:: COPY_OBSSET
|
||||
|
||||
| Will create a new local_obsset instance which is a copy of the 'SRC_OBSSET'; this is a deep copy where also the lowest level active_list instances are copied, and can then subsequently be updated independently of each other.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Deep copy OBS_WELL observation set
|
||||
COPY_OBSSET OBS_WELL COPY_OBS_WELL
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _attach_ministep:
|
||||
.. topic:: ATTACH_MINISTEP
|
||||
|
||||
| This function will attach the ministep 'NAME_OF_MINISTEP' to the updatestep 'NAME_OF_UPDATESTEP'; one ministep can be attached to many updatesteps.
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Attach MINISTEP to UPDATESTEP
|
||||
ATTACH_MINISTEP UPDATESTEP MINISTEP
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
update_step.attachMinistep(ministep)
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _attach_dataset:
|
||||
.. topic:: ATTACH_DATASET
|
||||
|
||||
| Will attach the dataset 'NAME_OF_DATASET' to the ministep given by 'NAME_OF_MINISTEP'.
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Attach DATASET_MULTFLT to MINISTEP
|
||||
ATTACH_MINISTEP MINISTEP DATASET_MULTFLT
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
ministep.attachDataset(dataset_multflt)
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _attach_obsset:
|
||||
.. topic:: ATTACH_OBSSET
|
||||
|
||||
| Will attach the obsset 'NAME_OF_OBSSET' to the ministep given by 'NAME_OF_MINISTEP'.
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Attach OBS_WELL to MINISTEP
|
||||
ATTACH_MINISTEP MINISTEP OBS_WELL
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
ministep.attachObsset(obsset_obs_well)
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _add_data:
|
||||
.. topic:: ADD_DATA
|
||||
|
||||
| This function will install 'KEY' as one enkf node which should be updated in this dataset. If you do not manipulate the KEY further with the ACTIVE_LIST_ADD_DATA_INDEX function the KEY will be added as 'ALL_ACTIVE', i.e. all elements will be updated.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add data node to data set
|
||||
ADD_DATA DATASET_MULTFLT MULTFLT
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
dataset_multflt.addNode("MULTFLT")
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _del_data:
|
||||
.. topic:: DEL_DATA
|
||||
|
||||
| This function will delete the data 'KEY' from the dataset 'NAME_OF_DATASET'.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Delete data node from data set
|
||||
DEL_DATA DATASET_MULTFLT MULTFLT
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
del dataset_multflt["MULTFLT"]
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _add_obs:
|
||||
.. topic:: ADD_OBS
|
||||
|
||||
| This function will install the observation 'OBS_KEY' as an observation for this obsset - similarly to the ADD_DATA function.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add data node to observation set
|
||||
ADD_OBS OBS_WELL WOPR:OBS_WELL
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- The obsset has a time range
|
||||
obsset_obs_well.addNodeAndRange("WOPR:OBS_WELL", 0, 1)
|
||||
|
||||
-- All times are active
|
||||
obsset_obs_well.addNode("WOPR:OBS_WELL")
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _del_obs:
|
||||
.. topic:: DEL_OBS
|
||||
|
||||
| This function will delete the obs 'OBS_KEY' from the obsset 'NAME_OF_OBSSET'.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Delete data node from observation set
|
||||
DEL_OBS OBS_WELL WOPR:OBS_WELL
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
del obsset_obs_well["WOPR:OBS_WELL"]
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _dataset_del_all_data:
|
||||
.. topic:: DATASET_DEL_ALL_DATA
|
||||
|
||||
| This function will delete all the data keys from the dataset 'NAME_OF_DATASET'.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Delete all data nodes from DATASET_MULTFLT
|
||||
DATASET_DEL_ALL_DATA DATASET_MULTFLT
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
dataset_multflt.clear()
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _active_list_add_data_index:
|
||||
.. topic:: ACTIVE_LIST_ADD_DATA_INDEX
|
||||
|
||||
| This function will say that the data with name 'DATA_KEY' in dataset with name 'DATASTEP_NAME' should have the index 'INDEX' active.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add index 0 from data MULTFLT to dataset DATASET_MULTFLT
|
||||
ACTIVE_LIST_ADD_DATA_INDEX DATASET_MULTFLT MULTFLT 0
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
active_list = dataset_multflt.getActiveList("MULTFLT")
|
||||
active_list.addActiveIndex(0);
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _active_list_add_obs_index:
|
||||
.. topic:: ACTIVE_LIST_ADD_OBS_INDEX
|
||||
|
||||
| This function will say that the observation with name 'OBS_KEY' in obsset with name 'OBSSET_NAME' should have the index 'INDEX' active.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add index 0 from data WOPR:OBS_WELL to obsset OBS_WELL
|
||||
ACTIVE_LIST_ADD_OBS_INDEX OBS_WELL WOPR:OBS_WELL 0
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
active_list = obsset_obs_well.getActiveList("WOPR:OBS_WELL")
|
||||
active_list.addActiveIndex(0);
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _active_list_add_many_data_index:
|
||||
.. topic:: ACTIVE_LIST_ADD_MANY_DATA_INDEX
|
||||
|
||||
| This function is similar to ACTIVE_LIST_ADD_DATA_INDEX, but it will add many indices.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add indices 0, 1 and 2 from data MULTFLT to dataset DATASET_MULTFLT
|
||||
ACTIVE_LIST_ADD_MANY_DATA_INDEX DATASET_MULTFLT MULTFLT 0 1 2
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _active_list_add_many_obs_index:
|
||||
.. topic:: ACTIVE_LIST_ADD_MANY_OBS_INDEX
|
||||
|
||||
| This function is similar to ACTIVE_LIST_ADD_OBS_INDEX, but it will add many indices.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add index 0, 1 and 2 from data WOPR:OBS_WELL to obsset OBS_WELL
|
||||
ACTIVE_LIST_ADD_MANY_OBS_INDEX OBS_WELL WOPR:OBS_WELL 0 1 2
|
||||
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _add_field:
|
||||
.. topic:: ADD_FIELD
|
||||
|
||||
| This function will install the node with name 'FIELD_NAME' in the dataset 'DATASET_NAME'. It will in addition select all the (currently) active cells in the region 'ECLREGION_NAME' as active for this field/ministep combination. The ADD_FIELD command is actually a shortcut of: ADD_DATA DATASET FIELD_NAME; followed by: ACTIVE_LIST_ADD_MANY_DATA_INDEX <All the indices from the region>
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add data node PORO to data set DATA_PORO activating indices in ECLREG_PORO
|
||||
ADD_FIELD DATA_PORO PORO ECLREG_PORO
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
# Load Eclipse grid
|
||||
ecl_grid = EclGrid("path/to/LOCAL.GRDECL")
|
||||
|
||||
with open("path/to/LOCAL.GRDECL","r") as fileH:
|
||||
local_kw = Ecl3DKW.read_grdecl(ecl_grid, fileH, "LOCAL")
|
||||
|
||||
# Define Eclipse region
|
||||
eclreg_poro = EclRegion(ecl_grid, False)
|
||||
eclreg_poro.select_more(local_kw, 1)
|
||||
|
||||
# Create dataset and add field to dataset
|
||||
data_poro = local_config.createDataset("DATA_PORO")
|
||||
data_poro.addField("PORO", eclreg_poro)
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _load_file:
|
||||
.. topic:: LOAD_FILE
|
||||
|
||||
| This function will load an ECLIPSE file in restart format (i.e. restart file or INIT file), the keywords in this file can then subsequently be used in ECLREGION_SELECT_VALUE_XXX commands below. The 'KEY' argument is a string which will be used later when we refer to the content of this file
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Load Eclipse init file
|
||||
LOAD_FILE REFINIT path/to/FULLMODEL.INIT
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
# Load Eclipse grid and init file
|
||||
ecl_grid = EclGrid("path/to/FULLMODEL.GRDECL")
|
||||
refinit_file = EclInitFile(grid , "path/to/somefile.init")
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _create_eclregion:
|
||||
.. topic:: CREATE_ECLREGION
|
||||
|
||||
| This function will create a new region 'ECLREGION_NAME', which can subsequently be used when defining active regions for fields. The second argument, SELECT_ALL, is a boolean value. If this value is set to true the region will start with all cells selected, if set to false the region will start with no cells selected.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- New Eclipse region with all cells inactive
|
||||
CREATE_ECLREGION ECL_REGION FALSE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
# Define Eclipse region
|
||||
eclreg_poro = EclRegion(ecl_grid, False)
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_all:
|
||||
.. topic:: ECLREGION_SELECT_ALL
|
||||
|
||||
| Will select all the cells in the region (or deselect if SELECT == FALSE).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select cells in region
|
||||
ECLREGION_SELECT_ALL ECL_REGION TRUE
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
eclreg_poro.select_active()
|
||||
|
||||
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_value_equal:
|
||||
.. topic:: ECLREGION_SELECT_VALUE_EQUAL
|
||||
|
||||
| This function will compare an ecl_kw instance loaded from file with a user supplied value, and select (or deselect) all cells which match this value. It is assumed that the ECLIPSE keyword is an INTEGER keyword, for float comparisons use the ECLREGION_SELECT_VALUE_LESS and ECLREGION_SELECT_VALUE_MORE functions.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select cells in region ECL_REGION equal to 0
|
||||
ECLREGION_SELECT_VALUE_EQUAL ECL_REGION ECL_REGION:LOCAL 0 TRUE
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
# Load Eclipse grid
|
||||
ecl_grid = EclGrid("path/to/LOCAL.GRDECL")
|
||||
|
||||
with open("path/to/LOCAL.GRDECL","r") as fileH:
|
||||
local_kw = Ecl3DKW.read_grdecl(ecl_grid, fileH, "LOCAL", ecl_type= EclTypeEnum.ECL_INT_TYPE)
|
||||
|
||||
# Define Eclipse region
|
||||
eclreg_poro = EclRegion(ecl_grid, False)
|
||||
eclreg_poro.select_equal(local_kw, 1)
|
||||
print 'GRID LOADED%s' % ecl_grid
|
||||
print ecl_grid.getDims()
|
||||
print local_kw.header
|
||||
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_value_less:
|
||||
.. topic:: ECLREGION_SELECT_VALUE_LESS
|
||||
|
||||
| This function will compare an ecl_kw instance loaded from disc with a numerical value, and select all cells which have numerical below the limiting value. The ecl_kw value should be a floating point value like e.g. PRESSURE or PORO. The arguments are just as for ECLREGION_SELECT_VALUE_EQUAL.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select cells in region ECL_REGION less than 1
|
||||
ECLREGION_SELECT_VALUE_LESS ECL_REGION ECL_REGION:LOCAL 1 TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
eclreg_poro.select_less(local_kw, 1)
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_value_more:
|
||||
.. topic:: ECLREGION_SELECT_VALUE_MORE
|
||||
|
||||
| This function will compare an ecl_kw instance loaded from disc with a numerical value, and select all cells which have numerical above the limiting value. The ecl_kw value should be a floating point value like e.g. PRESSURE or PORO. The arguments are just as for ECLREGION_SELECT_VALUE_EQUAL.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select cells in region ECL_REGION greater than 0
|
||||
ECLREGION_SELECT_VALUE_MORE ECL_REGION ECL_REGION:LOCAL 0 TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
eclreg_poro.select_more(local_kw, 1)
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_box:
|
||||
.. topic:: ECLREGION_SELECT_BOX
|
||||
|
||||
| This function will select (or deselect) all the cells in the box defined by the six coordinates i1 i2 j1 j2 k1 k2. The coordinates are inclusive, and the counting starts at 1.
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select cells in box [0,1] x [2,3] x [4,5]
|
||||
ECLREGION_SELECT_BOX ECL_REGION 0 1 2 3 4 5 TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
eclreg_poro.select_box((0,2,4),(1,3,5))
|
||||
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_slice:
|
||||
.. topic:: ECLREGION_SELECT_SLICE
|
||||
|
||||
| This function will select a slice in the direction given by 'dir', which can 'x', 'y' or 'z'. Depending on the value of 'dir' the numbers n1 and n2 are interpreted as (i1 i2), (j1 j2) or (k1 k2) respectively. The numbers n1 and n2 are inclusice and the counting starts at 1. It is OK to use very high/low values to imply "the rest of the cells" in one direction.
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select layer from z=2 to z=3
|
||||
ECLREGION_SELECT_SLICE ECL_REGION z 2 3 TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
eclreg_poro.select_kslice(2,3)
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_plane:
|
||||
.. topic:: ECLREGION_SELECT_PLANE
|
||||
|
||||
| Will select all points which have positive (sign > 0) distance to the plane defined by normal vector n = (nx,ny,nz) and point p = (px,py,pz). If sign < 0 all cells with negative distance to plane will be selected.
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select half space defined by plane perpendicular to vector [1 1 1]
|
||||
ECLREGION_SELECT_PLANE ECL_REGION 1 1 1 0 0 0 -1 TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
eclreg_poro.select_below_plane((1,1,1),(0,0,0))
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _eclregion_select_in_polygon:
|
||||
.. topic:: ECLREGION_SELECT_IN_POLYGON
|
||||
|
||||
| Well select all the points which are inside the polygon with name 'POLYGON_NAME'. The polygon should have been created with command CREATE_POLYGON or loaded with command 'LOAD_POLYGON' first.
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select region inside polygon in xy plane
|
||||
ECLREGION_SELECT_IN_POLYGON POLYGON TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
polygon = [(0,0) , (0,1) , (1,0)]
|
||||
eclreg_poro.select_inside_polygon(polygon)
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _create_polygon:
|
||||
.. topic:: CREATE_POLYGON
|
||||
|
||||
| Will create a geo_polygon instance based on the coordinate list: (x1,y1), (x2,y2), (x3,y3), ... The polygon should not be explicitly closed - i.e. you should in general have (x1,y1) != (xn,yn). The polygon will be stored under the name 'POLYGON_NAME' - which should later be used when referring to the polygon in region select operations.
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Create polygon in xy plane
|
||||
CREATE_POLYGON POLYGON 0 0 0 1 1 0 TRUE
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
polygon = [(0,0) , (0,1) , (1,0)]
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _load_polygon:
|
||||
.. topic:: LOAD_POLYGON
|
||||
|
||||
| Will load a polygon instance from the file 'FILENAME' - the file should be in irap RMS format. The polygon will be stored under the name 'POLYGON_NAME' which can then later be used to refer to the polygon for e.g. select operations.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Load polygon from RMS file
|
||||
LOAD_POLYGON path/to/polygon.irap
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
polygon = []
|
||||
with open("polygon.ply","r") as fileH:
|
||||
for line in fileH.readlines():
|
||||
tmp = line.split()
|
||||
polygon.append( (float(tmp[0]) , float(tmp[1])))
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _load_surface:
|
||||
.. topic:: LOAD_SURFACE
|
||||
|
||||
| Will load an irap surface from file 'SURFACE_FILE'. The surface will be stored internally as 'SURFACE_NAME' - this function is mainly needed to have a base surface available for the CREATE_SURFACE_REGION command.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Load Irap RMS surface from file
|
||||
LOAD_SURFACE path/to/surface.irap
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _create_surface_region:
|
||||
.. topic:: CREATE_SURFACE_REGION
|
||||
|
||||
| Will create a new surface region object which can be used to select and deselect parts of a surface. The region will be called 'REGION_NAME' and it will be based on the surface given by 'BASE_SURFACE'. 'PRESELECT' is a boolean 'TRUE' or 'FALSE' which determines whether the region is created with all points selected, or no points selected.
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Create surface region in xy plane
|
||||
CREATE_SURFACE_REGION SURF_REGION BASE_SURFACE TRUE
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _surface_region_select_in_polygon:
|
||||
.. topic:: SURFACE_REGION_SELECT_IN_POLYGON
|
||||
|
||||
| Well select all the points which are inside the polygon with name 'POLYGON_NAME'. The polygon should have been created with command CREATE_POLYGON or loaded with command 'LOAD_POLYGON' first.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select surface region inside polygon
|
||||
SURFACE_REGION_SELECT_IN_POLYGON SURF_REGION TRIANGLE TRUE
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _surface_region_select_line:
|
||||
.. topic:: SURFACE_REGION_SELECT_LINE
|
||||
|
||||
| Well select|deselect all the points which are above|below the line: (x1,y1) -> (x2,y2). If SIGN is positive the select will apply to all points with a positive (right hand system) distance to the line; if SIGN is negative the selector will apply to all points with a negative distance to the line.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Select surface region inside a half space defined by a line from [0,0] to [1,1]
|
||||
SURFACE_REGION_SELECT_LINE SURF_REGION 0 0 1 1 -1 TRUE
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
.. _add_data_surface:
|
||||
.. topic:: ADD_DATA_SURFACE
|
||||
|
||||
| Will add the node 'SURFACE_NAME' (not one of the loaded surfaces, but an enkf_node object) to the dataset 'DATASET_NAME'. Only the elements in the region 'REGION_NAME' will be added. Typically SURFACE_REGION_SELECT_xxxx has been used first to build a suitable region selection.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*Example:*
|
||||
|
||||
::
|
||||
|
||||
-- Add EnKF node object to dataset DATA_MULTFLT, with elements in SURF_REGION from BASE_SURFACE
|
||||
ADD_DATA_SURFACE DATA_MULTFLT BASE_SURFACE SURF_REGION
|
||||
|
||||
|
||||
|
||||
.. ###########################################################################################################
|
||||
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
Workflows and plugins
|
||||
=====================
|
||||
|
||||
Contents
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
workflows
|
||||
built_in
|
||||
|
||||
The Forward Model in ERT runs in the context of a single realization,
|
||||
i.e. there is no communication between the different processes, and
|
||||
the jobs are run outside of the main ERT process.
|
||||
|
||||
As an alternative to the forward model ERT has a system with
|
||||
*workflows*. Using workflows you can automate cumbersome normal ERT
|
||||
processes, and also invoke external programs. The workflows are run
|
||||
serially on the workstation actually running ERT, and should not be
|
||||
used for computationally heavy tasks.
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'fwd_step_enkf.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <ert/util/rng.h>
|
||||
#include <ert/util/matrix.h>
|
||||
|
||||
typedef struct fwd_step_enkf_data_struct fwd_step_enkf_data_type;
|
||||
|
||||
void * fwd_step_enkf_data_alloc( rng_type * rng );
|
||||
void fwd_step_enkf_data_free( void * arg );
|
||||
|
||||
void fwd_step_enkf_updateA(void * module_data ,
|
||||
matrix_type * A ,
|
||||
matrix_type * S ,
|
||||
matrix_type * R ,
|
||||
matrix_type * dObs ,
|
||||
matrix_type * E ,
|
||||
matrix_type * D );
|
||||
|
||||
|
||||
void fwd_step_enkf_set_truncation( fwd_step_enkf_data_type * data , double truncation );
|
||||
void fwd_step_enkf_set_subspace_dimension( fwd_step_enkf_data_type * data , int subspace_dimension);
|
||||
|
327
ThirdParty/Ert/devel/libanalysis/src/fwd_step_enkf.c
vendored
327
ThirdParty/Ert/devel/libanalysis/src/fwd_step_enkf.c
vendored
@ -1,327 +0,0 @@
|
||||
/*
|
||||
copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'fwd_step_enkf.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/rng.h>
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/matrix_blas.h>
|
||||
#include <ert/util/stepwise.h>
|
||||
|
||||
#include <ert/analysis/fwd_step_enkf.h>
|
||||
#include <ert/analysis/analysis_table.h>
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
|
||||
|
||||
#define FWD_STEP_ENKF_TYPE_ID 765524
|
||||
|
||||
#define DEFAULT_NFOLDS 5
|
||||
#define DEFAULT_R2_LIMIT 0.99
|
||||
#define NFOLDS_KEY "CV_NFOLDS"
|
||||
#define R2_LIMIT_KEY "FWD_STEP_R2_LIMIT"
|
||||
#define DEFAULT_VERBOSE false
|
||||
#define VERBOSE_KEY "VERBOSE"
|
||||
|
||||
struct fwd_step_enkf_data_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
stepwise_type * stepwise_data;
|
||||
rng_type * rng;
|
||||
int nfolds;
|
||||
long option_flags;
|
||||
double r2_limit;
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION_CONST( fwd_step_enkf_data , FWD_STEP_ENKF_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( fwd_step_enkf_data , FWD_STEP_ENKF_TYPE_ID )
|
||||
|
||||
|
||||
void fwd_step_enkf_set_nfolds( fwd_step_enkf_data_type * data , int nfolds ) {
|
||||
data->nfolds = nfolds;
|
||||
}
|
||||
|
||||
void fwd_step_enkf_set_r2_limit( fwd_step_enkf_data_type * data , double limit ) {
|
||||
data->r2_limit = limit;
|
||||
}
|
||||
|
||||
void fwd_step_enkf_set_verbose( fwd_step_enkf_data_type * data , bool verbose ) {
|
||||
data->verbose = verbose;
|
||||
}
|
||||
|
||||
void * fwd_step_enkf_data_alloc( rng_type * rng ) {
|
||||
fwd_step_enkf_data_type * data = util_malloc( sizeof * data );
|
||||
UTIL_TYPE_ID_INIT( data , FWD_STEP_ENKF_TYPE_ID );
|
||||
|
||||
data->stepwise_data = NULL;
|
||||
data->rng = rng;
|
||||
data->nfolds = DEFAULT_NFOLDS;
|
||||
data->r2_limit = DEFAULT_R2_LIMIT;
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_SCALE_DATA;
|
||||
data->verbose = DEFAULT_VERBOSE;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/*Main function: */
|
||||
void fwd_step_enkf_updateA(void * module_data ,
|
||||
matrix_type * A ,
|
||||
matrix_type * S ,
|
||||
matrix_type * R ,
|
||||
matrix_type * dObs ,
|
||||
matrix_type * E ,
|
||||
matrix_type * D ) {
|
||||
|
||||
|
||||
|
||||
fwd_step_enkf_data_type * fwd_step_data = fwd_step_enkf_data_safe_cast( module_data );
|
||||
printf("Running Forward Stepwise regression:\n");
|
||||
{
|
||||
|
||||
int ens_size = matrix_get_columns( S );
|
||||
int nx = matrix_get_rows( A );
|
||||
int nd = matrix_get_rows( S );
|
||||
int nfolds = fwd_step_data->nfolds;
|
||||
double r2_limit = fwd_step_data->r2_limit;
|
||||
bool verbose = fwd_step_data->verbose;
|
||||
|
||||
if ( ens_size <= nfolds)
|
||||
util_abort("%s: The number of ensembles must be larger than the CV fold - aborting\n", __func__);
|
||||
|
||||
|
||||
{
|
||||
|
||||
stepwise_type * stepwise_data = stepwise_alloc1(ens_size, nd , fwd_step_data->rng);
|
||||
|
||||
matrix_type * workS = matrix_alloc( ens_size , nd );
|
||||
matrix_type * workE = matrix_alloc( ens_size , nd );
|
||||
|
||||
/*workS = S' */
|
||||
matrix_subtract_row_mean( S ); /* Shift away the mean */
|
||||
workS = matrix_alloc_transpose( S );
|
||||
workE = matrix_alloc_transpose( E );
|
||||
|
||||
stepwise_set_X0( stepwise_data , workS );
|
||||
stepwise_set_E0( stepwise_data , workE );
|
||||
|
||||
matrix_type * di = matrix_alloc( 1 , nd );
|
||||
|
||||
if (verbose){
|
||||
printf("===============================================================================================================================\n");
|
||||
printf("Total number of parameters : %d\n",nx);
|
||||
printf("Total number of observations: %d\n",nd);
|
||||
printf("Number of ensembles : %d\n",ens_size);
|
||||
printf("CV folds : %d\n",nfolds);
|
||||
printf("Relative R2 tolerance : %f\n",r2_limit);
|
||||
printf("===============================================================================================================================\n");
|
||||
printf("%-15s%-15s%-15s%-15s\n", "Parameter", "NumAttached", "FinalR2", "ActiveIndices");
|
||||
}
|
||||
|
||||
for (int i = 0; i < nx; i++) {
|
||||
|
||||
|
||||
/*Update values of y */
|
||||
/*Start of the actual update */
|
||||
matrix_type * y = matrix_alloc( ens_size , 1 );
|
||||
|
||||
for (int j = 0; j < ens_size; j++) {
|
||||
matrix_iset(y , j , 0 , matrix_iget( A, i , j ) );
|
||||
}
|
||||
|
||||
stepwise_set_Y0( stepwise_data , y );
|
||||
|
||||
stepwise_estimate(stepwise_data , r2_limit , nfolds );
|
||||
|
||||
/*manipulate A directly*/
|
||||
for (int j = 0; j < ens_size; j++) {
|
||||
for (int k = 0; k < nd; k++) {
|
||||
matrix_iset(di , 0 , k , matrix_iget( D , k , j ) );
|
||||
}
|
||||
double aij = matrix_iget( A , i , j );
|
||||
double xHat = stepwise_eval(stepwise_data , di );
|
||||
matrix_iset(A , i , j , aij + xHat);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
stepwise_printf(stepwise_data, i);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
printf("===============================================================================================================================\n");
|
||||
|
||||
printf("Done with stepwise regression enkf\n");
|
||||
|
||||
stepwise_free( stepwise_data );
|
||||
matrix_free( di );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void fwd_step_enkf_data_free( void * arg ) {
|
||||
fwd_step_enkf_data_type * fwd_step_data = fwd_step_enkf_data_safe_cast( arg );
|
||||
{
|
||||
|
||||
if (fwd_step_data != NULL) {
|
||||
if (fwd_step_data->stepwise_data != NULL) {
|
||||
stepwise_free( fwd_step_data->stepwise_data );
|
||||
}
|
||||
}
|
||||
}
|
||||
free( fwd_step_data );
|
||||
}
|
||||
|
||||
|
||||
bool fwd_step_enkf_set_double( void * arg , const char * var_name , double value) {
|
||||
fwd_step_enkf_data_type * module_data = fwd_step_enkf_data_safe_cast( arg );
|
||||
{
|
||||
bool name_recognized = true;
|
||||
|
||||
if (strcmp( var_name , R2_LIMIT_KEY ) == 0)
|
||||
fwd_step_enkf_set_r2_limit( module_data , value );
|
||||
else
|
||||
name_recognized = false;
|
||||
|
||||
return name_recognized;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool fwd_step_enkf_set_int( void * arg , const char * var_name , int value) {
|
||||
fwd_step_enkf_data_type * module_data = fwd_step_enkf_data_safe_cast( arg );
|
||||
{
|
||||
bool name_recognized = true;
|
||||
|
||||
/*Set number of CV folds */
|
||||
if (strcmp( var_name , NFOLDS_KEY) == 0)
|
||||
fwd_step_enkf_set_nfolds( module_data , value);
|
||||
else
|
||||
name_recognized = false;
|
||||
|
||||
return name_recognized;
|
||||
}
|
||||
}
|
||||
|
||||
bool fwd_step_enkf_set_bool( void * arg , const char * var_name , bool value) {
|
||||
fwd_step_enkf_data_type * module_data = fwd_step_enkf_data_safe_cast( arg );
|
||||
{
|
||||
bool name_recognized = true;
|
||||
|
||||
/*Set verbose */
|
||||
if (strcmp( var_name , VERBOSE_KEY) == 0)
|
||||
fwd_step_enkf_set_verbose( module_data , value);
|
||||
else
|
||||
name_recognized = false;
|
||||
|
||||
return name_recognized;
|
||||
}
|
||||
}
|
||||
|
||||
long fwd_step_enkf_get_options( void * arg , long flag) {
|
||||
fwd_step_enkf_data_type * fwd_step_data = fwd_step_enkf_data_safe_cast( arg );
|
||||
{
|
||||
return fwd_step_data->option_flags;
|
||||
}
|
||||
}
|
||||
|
||||
bool fwd_step_enkf_has_var( const void * arg, const char * var_name) {
|
||||
{
|
||||
if (strcmp(var_name , NFOLDS_KEY) == 0)
|
||||
return true;
|
||||
else if (strcmp(var_name , R2_LIMIT_KEY ) == 0)
|
||||
return true;
|
||||
else if (strcmp(var_name , VERBOSE_KEY ) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
double fwd_step_enkf_get_double( const void * arg, const char * var_name) {
|
||||
const fwd_step_enkf_data_type * module_data = fwd_step_enkf_data_safe_cast_const( arg );
|
||||
{
|
||||
if (strcmp(var_name , R2_LIMIT_KEY ) == 0)
|
||||
return module_data->r2_limit;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int fwd_step_enkf_get_int( const void * arg, const char * var_name) {
|
||||
const fwd_step_enkf_data_type * module_data = fwd_step_enkf_data_safe_cast_const( arg );
|
||||
{
|
||||
if (strcmp(var_name , NFOLDS_KEY) == 0)
|
||||
return module_data->nfolds;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool fwd_step_enkf_get_bool( const void * arg, const char * var_name) {
|
||||
const fwd_step_enkf_data_type * module_data = fwd_step_enkf_data_safe_cast_const( arg );
|
||||
{
|
||||
if (strcmp(var_name , VERBOSE_KEY) == 0)
|
||||
return module_data->verbose;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef INTERNAL_LINK
|
||||
#define SYMBOL_TABLE fwd_step_enkf_symbol_table
|
||||
#else
|
||||
#define SYMBOL_TABLE EXTERNAL_MODULE_SYMBOL
|
||||
#endif
|
||||
|
||||
|
||||
analysis_table_type SYMBOL_TABLE = {
|
||||
.alloc = fwd_step_enkf_data_alloc,
|
||||
.freef = fwd_step_enkf_data_free,
|
||||
.set_int = fwd_step_enkf_set_int ,
|
||||
.set_double = fwd_step_enkf_set_double ,
|
||||
.set_bool = fwd_step_enkf_set_bool ,
|
||||
.set_string = NULL ,
|
||||
.get_options = fwd_step_enkf_get_options ,
|
||||
.initX = NULL ,
|
||||
.updateA = fwd_step_enkf_updateA,
|
||||
.init_update = NULL ,
|
||||
.complete_update = NULL ,
|
||||
.has_var = fwd_step_enkf_has_var,
|
||||
.get_int = fwd_step_enkf_get_int ,
|
||||
.get_double = fwd_step_enkf_get_double ,
|
||||
.get_bool = fwd_step_enkf_get_bool ,
|
||||
.get_ptr = NULL
|
||||
};
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <ecl_grav.h>
|
||||
#include <ecl_file.h>
|
||||
#include <signal.h>
|
||||
#include <util.h>
|
||||
|
||||
void install_SIGNALS(void) {
|
||||
signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */
|
||||
signal(SIGINT , util_abort_signal); /* Control C */
|
||||
signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace.
|
||||
Killing with SIGKILL (-9) will not give a backtrace.*/
|
||||
}
|
||||
|
||||
|
||||
int test_ecl_file_save() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
int test_grdecl_loader() {
|
||||
FILE * stream = util_fopen("/private/joaho/ERT/NR/python/ctypes/test/data/eclipse/case/PERMX.grdecl" , "r");
|
||||
ecl_kw_type * kw = ecl_kw_fscanf_alloc_grdecl_dynamic( stream , "PERMX" , ECL_FLOAT_TYPE );
|
||||
ecl_kw_free( kw );
|
||||
fclose( stream );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
install_SIGNALS();
|
||||
{
|
||||
test_grdecl_loader();
|
||||
test_ecl_file_save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'point.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef ERT_POINT_H
|
||||
#define ERT_POINT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct point_struct point_type;
|
||||
|
||||
struct point_struct {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
|
||||
void point_mapaxes_invtransform( point_type * p , const double origo[2], const double unit_x[2] , const double unit_y[2]);
|
||||
void point_mapaxes_transform( point_type * p , const double origo[2] , const double unit_x[2] , const double unit_y[2]);
|
||||
point_type * point_alloc_empty( );
|
||||
void point_inplace_sub(point_type * point , const point_type * sub);
|
||||
void point_inplace_add(point_type * point , const point_type * add);
|
||||
void point_inplace_scale(point_type * point , double scale_factor);
|
||||
bool point_equal( const point_type *p1 , const point_type * p2);
|
||||
void point_compare( const point_type *p1 , const point_type * p2, bool * equal);
|
||||
void point_dump( const point_type * p , FILE * stream);
|
||||
void point_dump_ascii( const point_type * p , FILE * stream , const double * offset);
|
||||
void point_fprintf( const point_type * p , FILE * stream );
|
||||
void point_free( point_type * p);
|
||||
void point_set( point_type *p , double x , double y , double z);
|
||||
void point_shift(point_type * p , double dx , double dy , double dz);
|
||||
point_type * point_alloc( double x , double y , double z);
|
||||
point_type * point_copyc( const point_type * p);
|
||||
void point_copy_values(point_type * p , const point_type * src);
|
||||
void point_vector_cross(point_type * A , const point_type * B , const point_type * C);
|
||||
double point_dot_product( const point_type * v1 , const point_type * v2);
|
||||
void point_normal_vector(point_type * n, const point_type * p0, const point_type * p1 , const point_type * p2);
|
||||
double point_plane_distance(const point_type * p , const point_type * n , const point_type * plane_point);
|
||||
double point3_plane_distance(const point_type * p0 , const point_type * p1 , const point_type * p2 , const point_type * x);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'tetrahedron.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef ERT_TETRAHEDRON_H
|
||||
#define ERT_TETRAHEDRON_H
|
||||
|
||||
|
||||
typedef struct tetrahedron_struct tetrahedron_type;
|
||||
|
||||
struct tetrahedron_struct {
|
||||
const point_type * p0;
|
||||
const point_type * p1;
|
||||
const point_type * p2;
|
||||
const point_type * p3;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void tetrahedron_init( tetrahedron_type * tet , const point_type * p0 , const point_type * p1 , const point_type * p2 , const point_type * p3);
|
||||
double tetrahedron_volume( const tetrahedron_type * tet );
|
||||
bool tetrahedron_contains( const tetrahedron_type * tet , const point_type * p);
|
||||
void tetrahedron_fprintf( const tetrahedron_type * tet , FILE * stream , const double * offset);
|
||||
#endif
|
||||
|
||||
|
217
ThirdParty/Ert/devel/libecl/src/point.c
vendored
217
ThirdParty/Ert/devel/libecl/src/point.c
vendored
@ -1,217 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'point.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/point.h>
|
||||
|
||||
|
||||
void point_mapaxes_transform( point_type * p , const double origo[2], const double unit_x[2] , const double unit_y[2]) {
|
||||
double new_x = origo[0] + p->x*unit_x[0] + p->y*unit_y[0];
|
||||
double new_y = origo[1] + p->x*unit_x[1] + p->y*unit_y[1];
|
||||
|
||||
p->x = new_x;
|
||||
p->y = new_y;
|
||||
}
|
||||
|
||||
|
||||
void point_mapaxes_invtransform( point_type * p , const double origo[2], const double unit_x[2] , const double unit_y[2]) {
|
||||
double norm = 1.0 / (unit_x[0]*unit_y[1] - unit_x[1] * unit_y[0]);
|
||||
double dx = p->x - origo[0];
|
||||
double dy = p->y - origo[1];
|
||||
|
||||
|
||||
double org_x = ( dx*unit_y[1] - dy*unit_y[0]) * norm;
|
||||
double org_y = (-dx*unit_x[1] + dy*unit_x[0]) * norm;
|
||||
|
||||
p->x = org_x;
|
||||
p->y = org_y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void point_compare( const point_type *p1 , const point_type * p2, bool * equal) {
|
||||
const double tolerance = 0.001;
|
||||
|
||||
double diff_x = (fabs(p1->x - p2->x) / fabs(p1->x + p2->x + 1));
|
||||
double diff_y = (fabs(p1->y - p2->y) / fabs(p1->y + p2->y + 1));
|
||||
double diff_z = (fabs(p1->z - p2->z) / fabs(p1->z + p2->z + 1));
|
||||
|
||||
if (diff_x + diff_y + diff_z > tolerance)
|
||||
*equal = false;
|
||||
}
|
||||
|
||||
bool point_equal( const point_type *p1 , const point_type * p2) {
|
||||
return (memcmp( p1 , p2 , sizeof * p1 ) == 0);
|
||||
}
|
||||
|
||||
|
||||
void point_dump( const point_type * p , FILE * stream) {
|
||||
util_fwrite_double( p->x , stream );
|
||||
util_fwrite_double( p->y , stream );
|
||||
util_fwrite_double( p->z , stream );
|
||||
}
|
||||
|
||||
|
||||
void point_dump_ascii( const point_type * p , FILE * stream , const double * offset) {
|
||||
if (offset)
|
||||
fprintf(stream , "(%7.2f, %7.2f, %7.2f) " , p->x - offset[0], p->y - offset[1] , p->z - offset[2]);
|
||||
else
|
||||
fprintf(stream , "(%7.2f, %7.2f, %7.2f) " , p->x , p->y , p->z);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void point_set(point_type * p , double x , double y , double z) {
|
||||
p->x = x;
|
||||
p->y = y;
|
||||
p->z = z;
|
||||
}
|
||||
|
||||
|
||||
void point_shift(point_type * p , double dx , double dy , double dz) {
|
||||
p->x += dx;
|
||||
p->y += dy;
|
||||
p->z += dz;
|
||||
}
|
||||
|
||||
|
||||
void point_copy_values(point_type * p , const point_type * src) {
|
||||
point_set(p , src->x , src->y , src->z);
|
||||
}
|
||||
|
||||
|
||||
point_type * point_alloc_empty( ) {
|
||||
point_type * p = util_malloc( sizeof * p );
|
||||
return p;
|
||||
}
|
||||
|
||||
point_type * point_alloc( double x , double y , double z) {
|
||||
point_type * p = point_alloc_empty( );
|
||||
point_set( p , x , y , z );
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
point_type * point_copyc( const point_type * p) {
|
||||
point_type * copy = util_alloc_copy( p , sizeof * p );
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
point_type * point_alloc_diff( const point_type * p1 , const point_type * p0) {
|
||||
point_type * diff = point_copyc( p1 );
|
||||
point_inplace_sub( diff , p0 );
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void point_free( point_type * p) {
|
||||
free( p );
|
||||
}
|
||||
|
||||
|
||||
void point_fprintf( const point_type * p , FILE * stream ) {
|
||||
fprintf(stream , "%g %g %g ",p->x , p->y , p->z);
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
/* Math operations */
|
||||
|
||||
void point_inplace_add(point_type * point , const point_type * add) {
|
||||
point->x += add->x;
|
||||
point->y += add->y;
|
||||
point->z += add->z;
|
||||
}
|
||||
|
||||
|
||||
void point_inplace_sub(point_type * point , const point_type * sub) {
|
||||
point->x -= sub->x;
|
||||
point->y -= sub->y;
|
||||
point->z -= sub->z;
|
||||
}
|
||||
|
||||
|
||||
void point_inplace_scale(point_type * point , double scale_factor) {
|
||||
point->x *= scale_factor;
|
||||
point->y *= scale_factor;
|
||||
point->z *= scale_factor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Will compute the vector cross product B x C and store the result in A.
|
||||
*/
|
||||
|
||||
void point_vector_cross(point_type * A , const point_type * B , const point_type * C) {
|
||||
A->x = B->y*C->z - B->z*C->y;
|
||||
A->y = -(B->x*C->z - B->z*C->x);
|
||||
A->z = B->x*C->y - B->y*C->x;
|
||||
}
|
||||
|
||||
double point_dot_product( const point_type * v1 , const point_type * v2) {
|
||||
return v1->x*v2->x + v1->y*v2->y + v1->z*v2->z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Computes the normal vector spanned by the two vectors: v1 = (p1 - p0) and v2 = (p2 - p0). The
|
||||
result is stored in n.
|
||||
*/
|
||||
|
||||
void point_normal_vector(point_type * n, const point_type * p0, const point_type * p1 , const point_type * p2) {
|
||||
point_type * v1 = point_alloc_diff( p1 , p0 );
|
||||
point_type * v2 = point_alloc_diff( p2 , p0 );
|
||||
|
||||
point_vector_cross( n , v1 , v2 );
|
||||
|
||||
free( v1 );
|
||||
free( v2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function calculates the (signed) distance from point 'p' to
|
||||
the plane specifed by the plane vector 'n' and the point
|
||||
'plane_point' which is part of the plane.
|
||||
*/
|
||||
|
||||
double point_plane_distance(const point_type * p , const point_type * n , const point_type * plane_point) {
|
||||
point_type * diff = point_alloc_diff( p , plane_point );
|
||||
double d = point_dot_product( n , diff );
|
||||
|
||||
free( diff );
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
double point3_plane_distance(const point_type * p0 , const point_type * p1 , const point_type * p2 , const point_type * x) {
|
||||
point_type n;
|
||||
point_normal_vector( &n , p0 , p1 , p2 );
|
||||
return point_plane_distance( x , &n , p0 ) / sqrt( n.x*n.x + n.y*n.y + n.z*n.z);
|
||||
}
|
338
ThirdParty/Ert/devel/libecl/src/tetrahedron.c
vendored
338
ThirdParty/Ert/devel/libecl/src/tetrahedron.c
vendored
@ -1,338 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'tetrahedron.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/matrix.h>
|
||||
|
||||
#include <ert/ecl/point.h>
|
||||
#include <ert/ecl/tetrahedron.h>
|
||||
|
||||
|
||||
|
||||
void tetrahedron_init( tetrahedron_type * tet , const point_type * p0 , const point_type * p1 , const point_type * p2 , const point_type * p3) {
|
||||
tet->p0 = p0;
|
||||
tet->p1 = p1;
|
||||
tet->p2 = p2;
|
||||
tet->p3 = p3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|a·(b x c)|
|
||||
V = -----------
|
||||
6
|
||||
|
||||
|
||||
Wherea a,b and c are assumed to have origo as reference.
|
||||
*/
|
||||
|
||||
|
||||
double tetrahedron_volume( const tetrahedron_type * tet ) {
|
||||
point_type a;
|
||||
point_type b;
|
||||
point_type c;
|
||||
point_type b_x_c;
|
||||
|
||||
point_copy_values(&a , tet->p0);
|
||||
point_copy_values(&b , tet->p1);
|
||||
point_copy_values(&c , tet->p2);
|
||||
|
||||
point_inplace_sub(&a , tet->p3);
|
||||
point_inplace_sub(&b , tet->p3);
|
||||
point_inplace_sub(&c , tet->p3);
|
||||
|
||||
point_vector_cross( &b_x_c , &b , &c);
|
||||
|
||||
return point_dot_product( &a , &b_x_c) / 6.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The __sign() function will return 0 for x ==== 0 - it is not
|
||||
exactly zero measure....
|
||||
*/
|
||||
|
||||
static int __sign( double x) {
|
||||
const double zero_tol = 1e-8;
|
||||
if (fabs(x) < zero_tol)
|
||||
return 0;
|
||||
else if (x > 0)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
When it comes to points which are exactly on one (or more ...) of
|
||||
the surfaces it is a mess. The function will return true if exact
|
||||
equality is found, unfortunately this implies that the function
|
||||
finding the correct cell for a xyz location is not 100% stable:
|
||||
|
||||
When it comes to a point on the surface between two cells the first
|
||||
cell which queries about the point will be assigned this point.
|
||||
*/
|
||||
|
||||
/**
|
||||
Point in Tetrahedron TestNewsgroups: comp.graphics,comp.graphics.algorithms
|
||||
From: herron@cs.washington.edu (Gary Herron)
|
||||
Subject: Re: point within a tetrahedron
|
||||
Date: Wed, 23 Feb 94 21:52:45 GMT
|
||||
|
||||
|
||||
Let the tetrahedron have vertices
|
||||
V1 = (x1, y1, z1)
|
||||
V2 = (x2, y2, z2)
|
||||
V3 = (x3, y3, z3)
|
||||
V4 = (x4, y4, z4)
|
||||
and your test point be
|
||||
P = (x, y, z).
|
||||
|
||||
Then the point P is in the tetrahedron if following five determinants all have
|
||||
the same sign.
|
||||
|
||||
|x1 y1 z1 1|
|
||||
D0 = |x2 y2 z2 1|
|
||||
|x3 y3 z3 1|
|
||||
|x4 y4 z4 1|
|
||||
|
||||
|x y z 1|
|
||||
D1 = |x2 y2 z2 1|
|
||||
|x3 y3 z3 1|
|
||||
|x4 y4 z4 1|
|
||||
|
||||
|x1 y1 z1 1|
|
||||
D2 = |x y z 1|
|
||||
|x3 y3 z3 1|
|
||||
|x4 y4 z4 1|
|
||||
|
||||
|x1 y1 z1 1|
|
||||
D3 = |x2 y2 z2 1|
|
||||
|x y z 1|
|
||||
|x4 y4 z4 1|
|
||||
|
||||
|x1 y1 z1 1|
|
||||
D4 = |x2 y2 z2 1|
|
||||
|x3 y3 z3 1|
|
||||
|x y z 1|
|
||||
|
||||
|
||||
Some additional notes:
|
||||
If by chance the D0=0, then your tetrahedron is degenerate (the points are
|
||||
coplanar).
|
||||
If any other Di=0, then P lies on boundary i (boundary i being that boundary
|
||||
formed by the three points other than Vi).
|
||||
If the sign of any Di differs from that of D0 then P is outside boundary i.
|
||||
If the sign of any Di equals that of D0 then P is inside boundary i.
|
||||
If P is inside all 4 boundaries, then it is inside the tetrahedron.
|
||||
As a check, it must be that D0 = D1+D2+D3+D4.
|
||||
The pattern here should be clear; the computations can be extended to
|
||||
simplicies of any dimension. (The 2D and 3D case are the triangle and the
|
||||
tetrahedron).
|
||||
If it is meaningful to you, the quantities bi = Di/D0 are the usual
|
||||
barycentric coordinates.
|
||||
Comparing signs of Di and D0 is only a check that P and Vi are on the same
|
||||
side of boundary i.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
bool tetrahedron_contains__( const tetrahedron_type * tet , const point_type * p, matrix_type * D) {
|
||||
const point_type * p1 = tet->p0;
|
||||
const point_type * p2 = tet->p1;
|
||||
const point_type * p3 = tet->p2;
|
||||
const point_type * p4 = tet->p3;
|
||||
|
||||
|
||||
int current_sign , sign;
|
||||
/*
|
||||
Special casing around the vertex points should be handled prior to
|
||||
calling this function.
|
||||
*/
|
||||
|
||||
/*****************************************************************/
|
||||
matrix_iset( D , 0 , 0 , p1->x);
|
||||
matrix_iset( D , 0 , 1 , p1->y);
|
||||
matrix_iset( D , 0 , 2 , p1->z);
|
||||
matrix_iset( D , 0 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 1 , 0 , p2->x);
|
||||
matrix_iset( D , 1 , 1 , p2->y);
|
||||
matrix_iset( D , 1 , 2 , p2->z);
|
||||
matrix_iset( D , 1 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 2 , 0 , p3->x);
|
||||
matrix_iset( D , 2 , 1 , p3->y);
|
||||
matrix_iset( D , 2 , 2 , p3->z);
|
||||
matrix_iset( D , 2 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 3 , 0 , p4->x);
|
||||
matrix_iset( D , 3 , 1 , p4->y);
|
||||
matrix_iset( D , 3 , 2 , p4->z);
|
||||
matrix_iset( D , 3 , 3 , 1);
|
||||
|
||||
{
|
||||
double D0 = matrix_det4( D );
|
||||
current_sign = __sign( D0 );
|
||||
if (current_sign == 0)
|
||||
return false; /* A zero volume cell. */
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
matrix_iset( D , 0 , 0 , p->x);
|
||||
matrix_iset( D , 0 , 1 , p->y);
|
||||
matrix_iset( D , 0 , 2 , p->z);
|
||||
matrix_iset( D , 0 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 1 , 0 , p2->x);
|
||||
matrix_iset( D , 1 , 1 , p2->y);
|
||||
matrix_iset( D , 1 , 2 , p2->z);
|
||||
matrix_iset( D , 1 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 2 , 0 , p3->x);
|
||||
matrix_iset( D , 2 , 1 , p3->y);
|
||||
matrix_iset( D , 2 , 2 , p3->z);
|
||||
matrix_iset( D , 2 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 3 , 0 , p4->x);
|
||||
matrix_iset( D , 3 , 1 , p4->y);
|
||||
matrix_iset( D , 3 , 2 , p4->z);
|
||||
matrix_iset( D , 3 , 3 , 1);
|
||||
|
||||
{
|
||||
double D1 = matrix_det4( D );
|
||||
sign = __sign( D1 );
|
||||
if ((sign != 0) && (sign != current_sign))
|
||||
return false;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
matrix_iset( D , 0 , 0 , p1->x);
|
||||
matrix_iset( D , 0 , 1 , p1->y);
|
||||
matrix_iset( D , 0 , 2 , p1->z);
|
||||
matrix_iset( D , 0 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 1 , 0 , p->x);
|
||||
matrix_iset( D , 1 , 1 , p->y);
|
||||
matrix_iset( D , 1 , 2 , p->z);
|
||||
matrix_iset( D , 1 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 2 , 0 , p3->x);
|
||||
matrix_iset( D , 2 , 1 , p3->y);
|
||||
matrix_iset( D , 2 , 2 , p3->z);
|
||||
matrix_iset( D , 2 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 3 , 0 , p4->x);
|
||||
matrix_iset( D , 3 , 1 , p4->y);
|
||||
matrix_iset( D , 3 , 2 , p4->z);
|
||||
matrix_iset( D , 3 , 3 , 1);
|
||||
|
||||
{
|
||||
double D2 = matrix_det4( D );
|
||||
sign = __sign( D2 );
|
||||
if ((sign != 0) && (sign != current_sign))
|
||||
return false;
|
||||
}
|
||||
/*****************************************************************/
|
||||
|
||||
matrix_iset( D , 0 , 0 , p1->x);
|
||||
matrix_iset( D , 0 , 1 , p1->y);
|
||||
matrix_iset( D , 0 , 2 , p1->z);
|
||||
matrix_iset( D , 0 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 1 , 0 , p2->x);
|
||||
matrix_iset( D , 1 , 1 , p2->y);
|
||||
matrix_iset( D , 1 , 2 , p2->z);
|
||||
matrix_iset( D , 1 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 2 , 0 , p->x);
|
||||
matrix_iset( D , 2 , 1 , p->y);
|
||||
matrix_iset( D , 2 , 2 , p->z);
|
||||
matrix_iset( D , 2 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 3 , 0 , p4->x);
|
||||
matrix_iset( D , 3 , 1 , p4->y);
|
||||
matrix_iset( D , 3 , 2 , p4->z);
|
||||
matrix_iset( D , 3 , 3 , 1);
|
||||
|
||||
{
|
||||
double D3 = matrix_det4( D );
|
||||
sign = __sign( D3 );
|
||||
if ((sign != 0) && (sign != current_sign))
|
||||
return false;
|
||||
}
|
||||
/*****************************************************************/
|
||||
|
||||
matrix_iset( D , 0 , 0 , p1->x);
|
||||
matrix_iset( D , 0 , 1 , p1->y);
|
||||
matrix_iset( D , 0 , 2 , p1->z);
|
||||
matrix_iset( D , 0 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 1 , 0 , p2->x);
|
||||
matrix_iset( D , 1 , 1 , p2->y);
|
||||
matrix_iset( D , 1 , 2 , p2->z);
|
||||
matrix_iset( D , 1 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 2 , 0 , p3->x);
|
||||
matrix_iset( D , 2 , 1 , p3->y);
|
||||
matrix_iset( D , 2 , 2 , p3->z);
|
||||
matrix_iset( D , 2 , 3 , 1);
|
||||
|
||||
matrix_iset( D , 3 , 0 , p->x);
|
||||
matrix_iset( D , 3 , 1 , p->y);
|
||||
matrix_iset( D , 3 , 2 , p->z);
|
||||
matrix_iset( D , 3 , 3 , 1);
|
||||
|
||||
{
|
||||
double D4 = matrix_det4( D );
|
||||
sign = __sign( D4 );
|
||||
if ((sign != 0) && (sign != current_sign))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool tetrahedron_contains( const tetrahedron_type * tet , const point_type * p) {
|
||||
matrix_type * D = matrix_alloc(4 , 4);
|
||||
bool contains = tetrahedron_contains__( tet , p , D );
|
||||
matrix_free( D );
|
||||
return contains;
|
||||
}
|
||||
|
||||
|
||||
void tetrahedron_fprintf( const tetrahedron_type * tet , FILE * stream , const double* offset) {
|
||||
fprintf(stream , "P0: "); point_dump_ascii( tet->p0 , stream , offset); fprintf(stream , "\n");
|
||||
fprintf(stream , "P1: "); point_dump_ascii( tet->p1 , stream , offset); fprintf(stream , "\n");
|
||||
fprintf(stream , "P2: "); point_dump_ascii( tet->p2 , stream , offset); fprintf(stream , "\n");
|
||||
fprintf(stream , "P3: "); point_dump_ascii( tet->p3 , stream , offset); fprintf(stream , "\n");
|
||||
}
|
107
ThirdParty/Ert/devel/libecl/tests/ecl_grid_export.c
vendored
107
ThirdParty/Ert/devel/libecl/tests/ecl_grid_export.c
vendored
@ -1,107 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_grid_export.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
|
||||
|
||||
void export_actnum( const ecl_grid_type * ecl_grid , ecl_file_type * ecl_file ) {
|
||||
ecl_kw_type * actnum_kw = ecl_file_iget_named_kw( ecl_file , "ACTNUM" , 0 );
|
||||
int * actnum = util_malloc( ecl_kw_get_size( actnum_kw ) * sizeof * actnum );
|
||||
|
||||
ecl_grid_init_actnum_data( ecl_grid , actnum );
|
||||
for (int i=0; i < ecl_kw_get_size( actnum_kw); i++)
|
||||
test_assert_int_equal( actnum[i] , ecl_kw_iget_int( actnum_kw , i ));
|
||||
|
||||
free( actnum );
|
||||
}
|
||||
|
||||
|
||||
void export_coord( const ecl_grid_type * grid , ecl_file_type * ecl_file ) {
|
||||
ecl_kw_type * coord_kw = ecl_file_iget_named_kw( ecl_file , "COORD" , 0);
|
||||
test_assert_int_equal( ecl_kw_get_size( coord_kw ) , ecl_grid_get_coord_size( grid ));
|
||||
{
|
||||
float * coord_float = util_malloc( ecl_grid_get_coord_size( grid ) * sizeof * coord_float );
|
||||
double * coord_double = util_malloc( ecl_grid_get_coord_size( grid ) * sizeof * coord_double );
|
||||
|
||||
ecl_grid_init_coord_data( grid , coord_float );
|
||||
ecl_grid_init_coord_data_double( grid , coord_double );
|
||||
|
||||
for (int i=0; i < ecl_grid_get_coord_size( grid ); i++)
|
||||
test_assert_double_equal( coord_double[i] , coord_float[i]);
|
||||
|
||||
free( coord_float );
|
||||
free( coord_double );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void export_zcorn( const ecl_grid_type * grid , ecl_file_type * ecl_file ) {
|
||||
ecl_kw_type * zcorn_kw = ecl_file_iget_named_kw( ecl_file , "ZCORN" , 0);
|
||||
test_assert_int_equal( ecl_kw_get_size( zcorn_kw ) , ecl_grid_get_zcorn_size( grid ));
|
||||
{
|
||||
float * zcorn_float = util_malloc( ecl_grid_get_zcorn_size( grid ) * sizeof * zcorn_float );
|
||||
double * zcorn_double = util_malloc( ecl_grid_get_zcorn_size( grid ) * sizeof * zcorn_double );
|
||||
|
||||
ecl_grid_init_zcorn_data( grid , zcorn_float );
|
||||
ecl_grid_init_zcorn_data_double( grid , zcorn_double );
|
||||
|
||||
for (int i=0; i < ecl_grid_get_zcorn_size( grid ); i++) {
|
||||
test_assert_double_equal( zcorn_double[i] , zcorn_float[i]);
|
||||
test_assert_float_equal( zcorn_float[i] , ecl_kw_iget_float( zcorn_kw , i ));
|
||||
}
|
||||
|
||||
|
||||
free( zcorn_float );
|
||||
free( zcorn_double );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void export_mapaxes( const ecl_grid_type * grid , ecl_file_type * ecl_file ) {
|
||||
ecl_kw_type * mapaxes_kw = ecl_file_iget_named_kw( ecl_file , "MAPAXES" , 0);
|
||||
double mapaxes[6];
|
||||
int i;
|
||||
|
||||
test_assert_true( ecl_grid_use_mapaxes( grid ));
|
||||
ecl_grid_init_mapaxes_data_double( grid , mapaxes );
|
||||
for (i= 0; i < 6; i++)
|
||||
test_assert_double_equal( ecl_kw_iget_float( mapaxes_kw , i) , mapaxes[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * grid_file = argv[1];
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file );
|
||||
ecl_file_type * ecl_file = ecl_file_open( grid_file , 0) ;
|
||||
|
||||
|
||||
export_actnum( ecl_grid , ecl_file );
|
||||
export_coord( ecl_grid , ecl_file );
|
||||
export_zcorn( ecl_grid , ecl_file );
|
||||
export_mapaxes( ecl_grid , ecl_file );
|
||||
|
||||
ecl_file_close( ecl_file );
|
||||
ecl_grid_free( ecl_grid );
|
||||
}
|
117
ThirdParty/Ert/devel/libecl/tests/ecl_point.c
vendored
117
ThirdParty/Ert/devel/libecl/tests/ecl_point.c
vendored
@ -1,117 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/point.h>
|
||||
|
||||
|
||||
void test_equal() {
|
||||
point_type * p1 = point_alloc(1,1,1);
|
||||
point_type * p2 = point_alloc(1,1,1);
|
||||
point_type * p3 = point_alloc(1,1,1);
|
||||
|
||||
|
||||
test_assert_true( point_equal( p1 , p2 ));
|
||||
test_assert_true( point_equal( p1 , p3 ));
|
||||
|
||||
point_shift(p2 , 1e-12 , 0,0);
|
||||
test_assert_false( point_equal( p1 , p2 ));
|
||||
point_copy_values(p2 , p3);
|
||||
test_assert_true( point_equal( p1 , p2 ));
|
||||
|
||||
point_shift(p2 , 0, 1e-12 ,0);
|
||||
test_assert_false( point_equal( p1 , p2 ));
|
||||
point_copy_values(p2 , p3);
|
||||
test_assert_true( point_equal( p1 , p2 ));
|
||||
|
||||
point_shift(p2 , 0, 0,-1e-12 );
|
||||
test_assert_false( point_equal( p1 , p2 ));
|
||||
point_copy_values(p2 , p3);
|
||||
test_assert_true( point_equal( p1 , p2 ));
|
||||
|
||||
point_free( p1 );
|
||||
point_free( p2 );
|
||||
point_free( p3 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_distancez() {
|
||||
point_type * p0 = point_alloc(0,0,0);
|
||||
point_type * p1 = point_alloc(1,0,0);
|
||||
point_type * p2 = point_alloc(0,1,0);
|
||||
|
||||
point_type * px = point_alloc(1,1,10);
|
||||
|
||||
test_assert_double_equal( 10 , point3_plane_distance( p0, p1 , p2 , px ));
|
||||
px->z = -1;
|
||||
test_assert_double_equal( -1 , point3_plane_distance( p0, p1 , p2 , px ));
|
||||
|
||||
point_free( p1 );
|
||||
point_free( p2 );
|
||||
point_free( p0 );
|
||||
point_free( px );
|
||||
}
|
||||
|
||||
|
||||
void test_distancex() {
|
||||
point_type * p0 = point_alloc(0,0,0);
|
||||
point_type * p1 = point_alloc(0,1,0);
|
||||
point_type * p2 = point_alloc(0,0,1);
|
||||
|
||||
point_type * px = point_alloc(1,1,10);
|
||||
|
||||
test_assert_double_equal( 1 , point3_plane_distance( p0, p1 , p2 , px ));
|
||||
px->x = -7;
|
||||
test_assert_double_equal( -7 , point3_plane_distance( p0, p1 , p2 , px ));
|
||||
|
||||
point_free( p1 );
|
||||
point_free( p2 );
|
||||
point_free( p0 );
|
||||
point_free( px );
|
||||
}
|
||||
|
||||
|
||||
void test_distancey() {
|
||||
point_type * p0 = point_alloc(0,0,0);
|
||||
point_type * p1 = point_alloc(0,0,2);
|
||||
point_type * p2 = point_alloc(2,0,0);
|
||||
|
||||
point_type * px = point_alloc(1,1,10);
|
||||
|
||||
test_assert_double_equal( 1 , point3_plane_distance( p0, p1 , p2 , px ));
|
||||
px->y = -7;
|
||||
test_assert_double_equal( -7 , point3_plane_distance( p0, p1 , p2 , px ));
|
||||
|
||||
point_free( p1 );
|
||||
point_free( p2 );
|
||||
point_free( p0 );
|
||||
point_free( px );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_equal();
|
||||
test_distancex();
|
||||
test_distancey();
|
||||
test_distancez();
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_tetrahedron_contains.c' is part of ERT - Ensemble based
|
||||
Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/point.h>
|
||||
#include <ert/ecl/tetrahedron.h>
|
||||
|
||||
|
||||
void init_tet(tetrahedron_type * tet , point_type * point_list) {
|
||||
point_set(&point_list[0] , 0 , 0 , 0);
|
||||
point_set(&point_list[1] , 1 , 0 , 0);
|
||||
point_set(&point_list[2] , 0 , 1 , 0);
|
||||
point_set(&point_list[3] , 0 , 0 , 1);
|
||||
|
||||
tetrahedron_init(tet , &point_list[0] , &point_list[1] , &point_list[2] , &point_list[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void test_inside(const tetrahedron_type * tet ) {
|
||||
point_type p;
|
||||
point_set(&p , 0.10 , 0.10 , 0.10);
|
||||
test_assert_true( tetrahedron_contains( tet , &p ));
|
||||
}
|
||||
|
||||
|
||||
void test_i(const tetrahedron_type * tet ) {
|
||||
point_type p;
|
||||
point_set(&p , -10 , 0.10 , 0.10);
|
||||
test_assert_false( tetrahedron_contains( tet , &p ));
|
||||
|
||||
point_set(&p , 10 , 0.10 , 0.10);
|
||||
test_assert_false( tetrahedron_contains( tet , &p ));
|
||||
}
|
||||
|
||||
|
||||
void test_j(const tetrahedron_type * tet ) {
|
||||
point_type p;
|
||||
point_set(&p , 0.10 , -10 , 0.10);
|
||||
test_assert_false( tetrahedron_contains( tet , &p ));
|
||||
|
||||
point_set(&p , 0.10 , 10 , 0.10);
|
||||
test_assert_false( tetrahedron_contains( tet , &p ));
|
||||
}
|
||||
|
||||
|
||||
void test_k(const tetrahedron_type * tet ) {
|
||||
point_type p;
|
||||
point_set(&p , 0.25 , 0.15 , -10);
|
||||
test_assert_false( tetrahedron_contains( tet , &p ));
|
||||
|
||||
point_set(&p , 0.25 , 0.15 , 10);
|
||||
test_assert_false( tetrahedron_contains( tet , &p ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
tetrahedron_type tet;
|
||||
point_type point_list[4];
|
||||
|
||||
init_tet( &tet , point_list );
|
||||
|
||||
test_inside(&tet);
|
||||
test_j(&tet);
|
||||
test_i(&tet);
|
||||
test_k(&tet);
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'local_config.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <ecl_grid.h>
|
||||
#include <local_config.h>
|
||||
#include <util.h>
|
||||
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
if (argc != 4) {
|
||||
fprintf(stderr,"Usage:\n\nbash%% local_config GRID_FILE NEW_CONFIG_FILE OLD_CONFIG_FILE");
|
||||
exit(1);
|
||||
} else {
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( argv[1] );
|
||||
const char * src_file = argv[2];
|
||||
const char * target_file = argv[3];
|
||||
|
||||
local_config_type * local_config = local_config_alloc( 100 );
|
||||
local_config_add_config_file( local_config , src_file );
|
||||
local_config_reload( local_config , ecl_grid , NULL , NULL , NULL );
|
||||
|
||||
local_config_fprintf( local_config , target_file );
|
||||
local_config_free( local_config );
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'local_config.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef ERT_LOCAL_CONFIG_H
|
||||
#define ERT_LOCAL_CONFIG_H
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/enkf/local_updatestep.h>
|
||||
#include <ert/enkf/local_ministep.h>
|
||||
#include <ert/enkf/ensemble_config.h>
|
||||
#include <ert/enkf/enkf_obs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
INVALID_CMD = 0, /* MArks EOF */
|
||||
CREATE_UPDATESTEP = 1, /* UPDATESTEP_NAME -> local_config_alloc_updatestep(); */
|
||||
CREATE_MINISTEP = 2, /* MINISTEP_NAME OBSSET_NAME -> local_config_alloc_ministep(); */
|
||||
ATTACH_MINISTEP = 3, /* UPDATESTEP_NAME , MINISTEP_NAME -> local_updatestep_add_ministep(); */
|
||||
CREATE_DATASET = 4, /* NAME */
|
||||
ATTACH_DATASET = 5, /* DATASET_NAME MINISTEP_NAME */
|
||||
CREATE_OBSSET = 6, /* NAME */
|
||||
ADD_DATA = 7, /* DATA_KEY -> local_ministep_add_node(); */
|
||||
ADD_OBS = 8, /* OBS_KEY -> local_ministep_add_obs(); */
|
||||
ACTIVE_LIST_ADD_OBS_INDEX = 9, /* OBS_KEY , ACTIVE_INDEX */
|
||||
ACTIVE_LIST_ADD_DATA_INDEX = 10, /* DATA_KEY , ACTIVE_INDEX */
|
||||
ACTIVE_LIST_ADD_MANY_OBS_INDEX = 11, /* OBS_KEY , NUM_INDEX , INDEX1, INDEX2, INDEX3,... */
|
||||
ACTIVE_LIST_ADD_MANY_DATA_INDEX = 12, /* DATA_KEY , NUM_INDEX , INDEX1 , INDEX2 , INDEX3 ,... */
|
||||
DEL_DATA = 16, /* DATASET KEY*/
|
||||
DEL_OBS = 17, /* MINISTEP OBS_KEY */
|
||||
DATASET_DEL_ALL_DATA = 18, /* DATASET */
|
||||
OBSSET_DEL_ALL_OBS = 19, /* No arguments */
|
||||
ADD_FIELD = 20, /* MINISTEP FIELD_NAME REGION_NAME */
|
||||
COPY_DATASET = 21, /* SRC_NAME TARGET_NAME */
|
||||
COPY_OBSSET = 22, /* SRC_NAME TARGET_NAME */
|
||||
ATTACH_OBSSET = 23, /* OBSSET_NAME MINISTEP_NAME */
|
||||
/*****************************************************************/
|
||||
CREATE_ECLREGION = 100, /* Name of region TRUE|FALSE*/
|
||||
LOAD_FILE = 101, /* Key, filename */
|
||||
ECLREGION_SELECT_ALL = 102, /* Region TRUE|FALSE */
|
||||
ECLREGION_SELECT_VALUE_EQUAL = 103, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */
|
||||
ECLREGION_SELECT_VALUE_LESS = 104, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */
|
||||
ECLREGION_SELECT_VALUE_MORE = 105, /* Region FILE_key:kw(:nr) VALUE TRUE|FALSE */
|
||||
ECLREGION_SELECT_BOX = 106, /* Region i1 i2 j1 j2 k1 k2 TRUE|FALSE */
|
||||
ECLREGION_SELECT_SLICE = 107, /* Region dir n1 n2 TRUE|FALSE */
|
||||
ECLREGION_SELECT_PLANE = 108, /* Region nx ny nz px py pz sign TRUE|FALSE */
|
||||
ECLREGION_SELECT_IN_POLYGON = 109, /* Region num_points p1x p12 p2x p2y p3x p3y ... pnx pny TRUE|FALSE */
|
||||
/*****************************************************************/
|
||||
CREATE_POLYGON = 200,/* NAME NUM_POINTS x1 y1 x2 y2 x3 y3 ... xn yn */
|
||||
LOAD_POLYGON = 201,/* NAME FILENAME */
|
||||
/*****************************************************************/
|
||||
LOAD_SURFACE = 300,
|
||||
CREATE_SURFACE_REGION = 301,
|
||||
SURFACE_REGION_SELECT_IN_POLYGON = 302,
|
||||
SURFACE_REGION_SELECT_LINE = 303,
|
||||
ADD_DATA_SURFACE = 304
|
||||
} local_config_instruction_type;
|
||||
|
||||
|
||||
|
||||
#define CREATE_UPDATESTEP_STRING "CREATE_UPDATESTEP"
|
||||
#define CREATE_MINISTEP_STRING "CREATE_MINISTEP"
|
||||
|
||||
#define ATTACH_MINISTEP_STRING "ATTACH_MINISTEP"
|
||||
#define CREATE_DATASET_STRING "CREATE_DATASET"
|
||||
#define ATTACH_DATASET_STRING "ATTACH_DATASET"
|
||||
#define CREATE_OBSSET_STRING "CREATE_OBSSET"
|
||||
#define ATTACH_OBSSET_STRING "ATTACH_OBSSET"
|
||||
#define ADD_DATA_STRING "ADD_DATA"
|
||||
#define ADD_OBS_STRING "ADD_OBS"
|
||||
#define ACTIVE_LIST_ADD_OBS_INDEX_STRING "ACTIVE_LIST_ADD_OBS_INDEX"
|
||||
#define ACTIVE_LIST_ADD_DATA_INDEX_STRING "ACTIVE_LIST_ADD_DATA_INDEX"
|
||||
#define ACTIVE_LIST_ADD_MANY_OBS_INDEX_STRING "ACTIVE_LIST_ADD_MANY_OBS_INDEX"
|
||||
#define ACTIVE_LIST_ADD_MANY_DATA_INDEX_STRING "ACTIVE_LIST_ADD_MANY_DATA_INDEX"
|
||||
#define DEL_DATA_STRING "DEL_DATA"
|
||||
#define DEL_OBS_STRING "DEL_OBS"
|
||||
#define ADD_FIELD_STRING "ADD_FIELD"
|
||||
#define DATASET_DEL_ALL_DATA_STRING "DATASET_DEL_ALL_DATA"
|
||||
#define OBSSET_DEL_ALL_OBS_STRING "OBSSET_DEL_ALL_OBS"
|
||||
#define COPY_DATASET_STRING "COPY_DATASET"
|
||||
#define COPY_OBSSET_STRING "COPY_OBSSET"
|
||||
#define CREATE_ECLREGION_STRING "CREATE_ECLREGION"
|
||||
#define LOAD_FILE_STRING "LOAD_FILE"
|
||||
#define ECLREGION_SELECT_ALL_STRING "ECLREGION_SELECT_ALL"
|
||||
#define ECLREGION_SELECT_VALUE_EQUAL_STRING "ECLREGION_SELECT_VALUE_EQUAL"
|
||||
#define ECLREGION_SELECT_VALUE_LESS_STRING "ECLREGION_SELECT_VALUE_LESS"
|
||||
#define ECLREGION_SELECT_VALUE_MORE_STRING "ECLREGION_SELECT_VALUE_MORE"
|
||||
#define ECLREGION_SELECT_BOX_STRING "ECLREGION_SELECT_BOX"
|
||||
#define ECLREGION_SELECT_SLICE_STRING "ECLREGION_SELECT_SLICE"
|
||||
#define ECLREGION_SELECT_PLANE_STRING "ECLREGION_SELECT_PLANE"
|
||||
#define ECLREGION_SELECT_IN_POLYGON_STRING "ECLREGION_SELECT_IN_POLYGON"
|
||||
#define CREATE_POLYGON_STRING "CREATE_POLYGON"
|
||||
#define LOAD_POLYGON_STRING "LOAD_POLYGON"
|
||||
#define LOAD_SURFACE_STRING "LOAD_SURFACE"
|
||||
#define CREATE_SURFACE_REGION_STRING "CREATE_SURFACE_REGION"
|
||||
#define SURFACE_REGION_SELECT_IN_POLYGON_STRING "SURFACE_REGION_SELECT_IN_POLYGON"
|
||||
#define SURFACE_REGION_SELECT_LINE_STRING "SURFACE_REGION_SELECT_LINE"
|
||||
#define ADD_DATA_SURFACE_STRING "ADD_DATA_SURFACE"
|
||||
|
||||
|
||||
typedef struct local_config_struct local_config_type;
|
||||
|
||||
local_config_type * local_config_alloc( );
|
||||
void local_config_clear( local_config_type * local_config );
|
||||
void local_config_free( local_config_type * local_config );
|
||||
local_ministep_type * local_config_alloc_ministep( local_config_type * local_config , const char * key );
|
||||
local_ministep_type * local_config_alloc_ministep_copy( local_config_type * local_config , const char * src_key , const char * new_key);
|
||||
void local_config_set_default_updatestep( local_config_type * local_config , local_updatestep_type * update_step );
|
||||
local_updatestep_type * local_config_get_updatestep( const local_config_type * local_config );
|
||||
local_ministep_type * local_config_get_ministep( const local_config_type * local_config , const char * key);
|
||||
void local_config_set_updatestep(local_config_type * local_config, int step1 , int step2 , const char * key);
|
||||
void local_config_reload( local_config_type * local_config , const ecl_grid_type * ecl_grid , const ensemble_config_type * ensemble_config , const enkf_obs_type * enkf_obs ,
|
||||
const char * all_active_config_file);
|
||||
const char * local_config_get_cmd_string( local_config_instruction_type cmd );
|
||||
|
||||
stringlist_type * local_config_get_config_files( const local_config_type * local_config );
|
||||
void local_config_clear_config_files( local_config_type * local_config );
|
||||
void local_config_add_config_file( local_config_type * local_config , const char * config_file );
|
||||
|
||||
void local_config_fprintf( const local_config_type * local_config , const char * config_file);
|
||||
void local_config_summary_fprintf( const local_config_type * local_config , const char * config_file);
|
||||
void local_config_fprintf_config( const local_config_type * local_config , FILE * stream);
|
||||
local_obsdata_type * local_config_alloc_obsdata( local_config_type * local_config , const char * obsdata_name );
|
||||
bool local_config_has_obsdata( const local_config_type * local_config , const char * obsdata_name);
|
||||
local_dataset_type * local_config_alloc_dataset( local_config_type * local_config , const char * key );
|
||||
bool local_config_has_dataset( const local_config_type * local_config , const char * key);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
1758
ThirdParty/Ert/devel/libenkf/src/local_config.c
vendored
1758
ThirdParty/Ert/devel/libenkf/src/local_config.c
vendored
File diff suppressed because it is too large
Load Diff
74
ThirdParty/Ert/devel/librms/src/makefile
vendored
74
ThirdParty/Ert/devel/librms/src/makefile
vendored
@ -1,74 +0,0 @@
|
||||
include global_config
|
||||
SDP_ROOT = $(shell get_sdp_root.py)
|
||||
#################################################################
|
||||
COMPILE_INCLUDE = -I$(LIBRMS_HOME)/src -I$(LIBECL_HOME)/include -I$(LIBUTIL_HOME)/include
|
||||
INSTALL_INC_PATH = $(LIBRMS_HOME)/include
|
||||
INSTALL_LIB_PATH = $(LIBRMS_HOME)/lib
|
||||
#################################################################
|
||||
OBJECTS = rms_file.o rms_util.o rms_tag.o rms_type.o rms_tagkey.o rms_stats.o rms_export.o
|
||||
INC_FILES = rms_file.h rms_util.h rms_tag.h rms_type.h rms_tagkey.h rms_stats.h rms_export.h
|
||||
LIB = librms.a
|
||||
|
||||
|
||||
LOCAL: LIB
|
||||
install -d $(INSTALL_INC_PATH)
|
||||
install -d $(INSTALL_LIB_PATH)
|
||||
install $(INC_FILES) $(INSTALL_INC_PATH)
|
||||
install $(LIB) $(INSTALL_LIB_PATH)
|
||||
|
||||
SDP_INSTALL: LIB BIN
|
||||
install $(LIB) $(SDP_ROOT)/lib/lib$(LIB_ROOT).a
|
||||
install $(INC_FILES) $(SDP_ROOT)/include
|
||||
|
||||
LIB: $(LIB)
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
rm -f $(LIB)
|
||||
rm -f $(INSTALL_LIB_PATH)/$(LIB)
|
||||
rm -f $(INSTALL_INC_PATH)/*.h
|
||||
|
||||
rebuild: clean LOCAL
|
||||
|
||||
$(LIB): $(OBJECTS)
|
||||
$(AR) $(ARFLAGS) $(LIB) $(OBJECTS)
|
||||
|
||||
|
||||
%.o : %.c
|
||||
$(CC) -c $(CFLAGS) $(COMPILE_INCLUDE) $(CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
new:
|
||||
../../Scripts/cdep.py all_include.h 0
|
||||
|
||||
include dependencies
|
||||
|
||||
##################################################################
|
||||
## Binaries
|
||||
#
|
||||
#BIN_FILES = rms.x rms_stat.x roff_tags.x rms_extract.x rms_setname.x
|
||||
#BIN: $(BIN_FILES)
|
||||
#BIN_FILES_SDP_INSTALL = roff_tags.x
|
||||
#
|
||||
#rms_test.o : rms_test.c
|
||||
#rms_stat.o : rms_stat.c
|
||||
#tag_list.o : tag_list.c
|
||||
#rms_extract.o : rms_extract.c
|
||||
#rms_setname.o : rms_setname.c
|
||||
#
|
||||
#roff_tags.x: tag_list.o $(LIB)
|
||||
# $(CC) -$(MFLAG) $(LDFLAGS) tag_list.o -o roff_tags.x $(LIB_PATH) $(LIB_LINK)
|
||||
#
|
||||
#rms.x: rms_test.o $(LIB)
|
||||
# $(CC) -$(MFLAG) $(LDFLAGS) rms_test.o -o rms.x $(LIB_PATH) $(LIB_LINK)
|
||||
#
|
||||
#rms_stat.x: rms_stat.o $(LIB)
|
||||
# $(CC) -$(MFLAG) $(LDFLAGS) rms_stat.o -o rms_stat.x $(LIB_PATH) $(LIB_LINK)
|
||||
#
|
||||
#rms_extract.x: rms_extract.o $(LIB)
|
||||
# $(CC) -$(MFLAG) $(LDFLAGS) rms_extract.o -o rms_extract.x $(LIB_PATH) $(LIB_LINK)
|
||||
#
|
||||
#rms_setname.x: rms_setname.o $(LIB)
|
||||
# $(CC) -$(MFLAG) $(LDFLAGS) rms_setname.o -o rms_setname.x $(LIB_PATH) $(LIB_LINK)
|
||||
|
||||
|
12
ThirdParty/Ert/devel/librms/tests/CMakeLists.txt
vendored
12
ThirdParty/Ert/devel/librms/tests/CMakeLists.txt
vendored
@ -1,12 +0,0 @@
|
||||
|
||||
add_executable( rms_file_test rms_file_test.c )
|
||||
target_link_libraries( rms_file_test rms test_util )
|
||||
|
||||
add_test( rms_file_test
|
||||
${EXECUTABLE_OUTPUT_PATH}/rms_file_test
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/config/rms_file_test/rms_file)
|
||||
|
||||
|
||||
|
||||
|
||||
set_property( TEST rms_file_test PROPERTY LABELS StatoilData )
|
@ -1,16 +0,0 @@
|
||||
#add_executable( sched_load sched_load.c )
|
||||
#target_link_libraries( sched_load sched test_util )
|
||||
#add_test( sched_load ${EXECUTABLE_OUTPUT_PATH}/sched_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Heidrun/Schedule.sch )
|
||||
|
||||
#add_executable( sched_tokenize sched_tokenize.c )
|
||||
#target_link_libraries( sched_tokenize sched test_util )
|
||||
#add_test( sched_tokenize ${EXECUTABLE_OUTPUT_PATH}/sched_tokenize ${CMAKE_CURRENT_SOURCE_DIR}/test-data/token_test1 )
|
||||
|
||||
add_executable( sched_history_summary sched_history_summary.c )
|
||||
target_link_libraries( sched_history_summary sched test_util )
|
||||
add_test( sched_history_summary1 ${EXECUTABLE_OUTPUT_PATH}/sched_history_summary ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
|
||||
add_test( sched_history_summary2 ${EXECUTABLE_OUTPUT_PATH}/sched_history_summary ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE )
|
||||
|
||||
#set_property( TEST sched_load PROPERTY LABELS StatoilData)
|
||||
set_property( TEST sched_history_summary1 PROPERTY LABELS StatoilData)
|
||||
set_property( TEST sched_history_summary2 PROPERTY LABELS StatoilData)
|
21
ThirdParty/Ert/devel/python/CMakeLists.txt
vendored
21
ThirdParty/Ert/devel/python/CMakeLists.txt
vendored
@ -1,21 +0,0 @@
|
||||
include(cmake/find_python_module.cmake)
|
||||
|
||||
if (ERT_BUILD_GUI)
|
||||
FIND_PACKAGE(PythonInterp 2.7 REQUIRED)
|
||||
find_python_module(PyQt4 REQUIRED)
|
||||
else()
|
||||
FIND_PACKAGE(PythonInterp 2.7 REQUIRED)
|
||||
endif()
|
||||
|
||||
if (EXISTS "/etc/debian_version")
|
||||
set( PYTHON_PACKAGE_PATH "dist-packages")
|
||||
else()
|
||||
set( PYTHON_PACKAGE_PATH "site-packages")
|
||||
endif()
|
||||
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
|
||||
|
||||
|
||||
if (BUILD_TESTS)
|
||||
add_subdirectory( tests )
|
||||
endif()
|
||||
add_subdirectory( python )
|
@ -1,145 +0,0 @@
|
||||
# Copyright (C) 2013 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'analysis_module.py' is part of ERT - Ensemble based Reservoir Tool.
|
||||
#
|
||||
# ERT is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
|
||||
from ert.cwrap import BaseCClass, CWrapper
|
||||
from ert.analysis import ANALYSIS_LIB
|
||||
from ert.util.rng import RandomNumberGenerator
|
||||
|
||||
|
||||
class AnalysisModule(BaseCClass):
|
||||
VARIABLE_NAMES = {
|
||||
"LAMBDA0": {"type": float, "description": "Initial Lambda"},
|
||||
"USE_PRIOR": {"type": bool, "description": "Use both Prior and Observation Variability"},
|
||||
"LAMBDA_REDUCE": {"type": float, "description": "Lambda Reduction Factor"},
|
||||
"LAMBDA_INCREASE": {"type": float, "description": "Lambda Incremental Factor"},
|
||||
"LAMBDA_MIN": {"type": float, "description": "Minimum Lambda"},
|
||||
"LOG_FILE": {"type": str, "description": "Log File"},
|
||||
"CLEAR_LOG": {"type": bool, "description": "Clear Existing Log File"},
|
||||
"LAMBDA_RECALCULATE": {"type": bool, "description": "Recalculate Lambda after each Iteration"},
|
||||
"ENKF_TRUNCATION": {"type": float, "description": "Singular value truncation"},
|
||||
"ENKF_NCOMP": {"type": int, "description": "ENKF_NCOMP"},
|
||||
"CV_NFOLDS": {"type": int, "description": "CV_NFOLDS"},
|
||||
"FWD_STEP_R2_LIMIT": {"type": float, "description": "FWD_STEP_R2_LIMIT"},
|
||||
"CV_PEN_PRESS": {"type": bool, "description": "CV_PEN_PRESS"}
|
||||
}
|
||||
|
||||
def __init__(self, rng, user_name, lib_name):
|
||||
c_ptr = AnalysisModule.cNamespace().alloc_external(rng, user_name, lib_name)
|
||||
super(AnalysisModule, self).__init__(c_ptr)
|
||||
|
||||
def getVariableNames(self):
|
||||
""" @rtype: list of str """
|
||||
items = []
|
||||
for name in AnalysisModule.VARIABLE_NAMES:
|
||||
if self.hasVar(name):
|
||||
items.append(name)
|
||||
return items
|
||||
|
||||
def getVariableValue(self, name):
|
||||
""" @rtype: int or float or bool or str """
|
||||
variable_type = self.getVariableType(name)
|
||||
if variable_type == float:
|
||||
return self.getDouble(name)
|
||||
elif variable_type == bool:
|
||||
return self.getBool(name)
|
||||
elif variable_type == str:
|
||||
return self.getStr(name)
|
||||
elif variable_type == int:
|
||||
return self.getInt(name)
|
||||
|
||||
def getVariableType(self, name):
|
||||
""" :rtype: type """
|
||||
return AnalysisModule.VARIABLE_NAMES[name]["type"]
|
||||
|
||||
def getVariableDescription(self, name):
|
||||
""" :rtype: str """
|
||||
return AnalysisModule.VARIABLE_NAMES[name]["description"]
|
||||
|
||||
def free(self):
|
||||
AnalysisModule.cNamespace().free(self)
|
||||
|
||||
def getLibName(self):
|
||||
return AnalysisModule.cNamespace().get_lib_name(self)
|
||||
|
||||
def getInternal(self):
|
||||
return AnalysisModule.cNamespace().get_module_internal(self)
|
||||
|
||||
def setVar(self, var_name, string_value):
|
||||
return AnalysisModule.cNamespace().set_var(self, var_name, string_value)
|
||||
|
||||
def getTableName(self):
|
||||
return AnalysisModule.cNamespace().get_table_name(self)
|
||||
|
||||
def getName(self):
|
||||
""" :rtype: str """
|
||||
return AnalysisModule.cNamespace().get_name(self)
|
||||
|
||||
def checkOption(self, flag):
|
||||
return AnalysisModule.cNamespace().check_option(self, flag)
|
||||
|
||||
def hasVar(self, var):
|
||||
""" :rtype: bool """
|
||||
return AnalysisModule.cNamespace().has_var(self, var)
|
||||
|
||||
def getDouble(self, var):
|
||||
""" :rtype: float """
|
||||
return AnalysisModule.cNamespace().get_double(self, var)
|
||||
|
||||
def getInt(self, var):
|
||||
""" :rtype: int """
|
||||
return AnalysisModule.cNamespace().get_int(self, var)
|
||||
|
||||
def getBool(self, var):
|
||||
""" :rtype: bool """
|
||||
return AnalysisModule.cNamespace().get_bool(self, var)
|
||||
|
||||
def getStr(self, var):
|
||||
""" :rtype: str """
|
||||
test = AnalysisModule.cNamespace().get_str(self, var)
|
||||
return str(test)
|
||||
|
||||
def initUpdate(self, mask, S, R, dObs, E, D):
|
||||
print "Running initUpdate"
|
||||
AnalysisModule.cNamespace().init_update(self, mask, S, R, dObs, E, D)
|
||||
|
||||
def updateA(self, A, S, R, dObs, E, D):
|
||||
print "Running updateA"
|
||||
AnalysisModule.cNamespace().updateA(self, A, S, R, dObs, E, D)
|
||||
|
||||
def initX(self, X, A, S, R, dObs, E, D):
|
||||
AnalysisModule.cNamespace().init_update(self, X, A, S, R, dObs, E, D)
|
||||
|
||||
|
||||
cwrapper = CWrapper(ANALYSIS_LIB)
|
||||
cwrapper.registerObjectType("analysis_module", AnalysisModule)
|
||||
|
||||
AnalysisModule.cNamespace().alloc_external = cwrapper.prototype("c_void_p analysis_module_alloc_external(rng, char*, char*)")
|
||||
AnalysisModule.cNamespace().free = cwrapper.prototype("void analysis_module_free(analysis_module)")
|
||||
AnalysisModule.cNamespace().get_lib_name = cwrapper.prototype("char* analysis_module_get_lib_name(analysis_module)")
|
||||
AnalysisModule.cNamespace().get_module_internal = cwrapper.prototype("bool analysis_module_internal(analysis_module)")
|
||||
AnalysisModule.cNamespace().set_var = cwrapper.prototype("bool analysis_module_set_var(analysis_module, char*, char*)")
|
||||
AnalysisModule.cNamespace().get_table_name = cwrapper.prototype("char* analysis_module_get_table_name(analysis_module)")
|
||||
AnalysisModule.cNamespace().get_name = cwrapper.prototype("char* analysis_module_get_name(analysis_module)")
|
||||
AnalysisModule.cNamespace().check_option = cwrapper.prototype("bool analysis_module_check_option(analysis_module, long)")
|
||||
AnalysisModule.cNamespace().has_var = cwrapper.prototype("bool analysis_module_has_var(analysis_module, char*)")
|
||||
AnalysisModule.cNamespace().get_double = cwrapper.prototype("double analysis_module_get_double(analysis_module, char*)")
|
||||
AnalysisModule.cNamespace().get_int = cwrapper.prototype("int analysis_module_get_int(analysis_module, char*)")
|
||||
AnalysisModule.cNamespace().get_bool = cwrapper.prototype("bool analysis_module_get_bool(analysis_module, char*)")
|
||||
AnalysisModule.cNamespace().get_str = cwrapper.prototype("char* analysis_module_get_ptr(analysis_module, char*)")
|
||||
|
||||
AnalysisModule.cNamespace().init_update = cwrapper.prototype("void analysis_module_init_update(analysis_module, bool_vector , matrix , matrix , matrix , matrix, matrix)")
|
||||
AnalysisModule.cNamespace().updateA = cwrapper.prototype("void analysis_module_updateA(analysis_module, matrix , matrix , matrix , matrix, matrix, matrix)")
|
||||
AnalysisModule.cNamespace().initX = cwrapper.prototype("void analysis_module_initX(analysis_module, matrix , matrix , matrix , matrix , matrix, matrix, matrix)")
|
169
ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py
vendored
169
ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py
vendored
@ -1,169 +0,0 @@
|
||||
# Copyright (C) 2011 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'clib.py' is part of ERT - Ensemble based Reservoir Tool.
|
||||
#
|
||||
# ERT is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
"""Convenience module for loading shared library.
|
||||
|
||||
Observe that to ensure that all libraries are loaded through the same
|
||||
code path, all required libraries should be loaded explicitly through
|
||||
the use of import statements; i.e. the ert.geo package requires the
|
||||
libert_util librarary, to ensure that the correct version of the
|
||||
libert_util.so library file is loaded we should manually load that
|
||||
first as:
|
||||
|
||||
import ert.util
|
||||
GEO_LIB = clib.ert_load("libert_geometry")
|
||||
|
||||
Otherwise the standard operating system dependency resolve code will
|
||||
be invoked when loading libert_geometry, and that could in principle
|
||||
lead to loading a different version of libert_util.so
|
||||
"""
|
||||
|
||||
import platform
|
||||
import ctypes
|
||||
import os
|
||||
|
||||
so_extension = {"linux" : "so",
|
||||
"linux2" : "so",
|
||||
"linux3" : "so",
|
||||
"win32" : "dll",
|
||||
"win64" : "dll",
|
||||
"darwin" : "dylib" }
|
||||
|
||||
|
||||
# The variables ert_lib_path and ert_so_version will be set by the build
|
||||
# system. The system works like this:
|
||||
#
|
||||
# 1. There is a CMake configure command which creates a module
|
||||
# __ert_lib_info.py; that module has the two elements
|
||||
# 'ert_lib_path' and 'ert_so_version' which are inferred by the
|
||||
# build system.
|
||||
#
|
||||
# 2. The root package ert/__init__py will try to import thel
|
||||
# __ert_lib_info module; if that import succeeds the attributes
|
||||
# ert_lib_path and ert_so_version OF THIS MODULE will be updated.
|
||||
#
|
||||
# If the import fails this module will continue with the default
|
||||
# values. The default values will work if the shared libraries are
|
||||
# in the default library load path, with unversioned named/links.
|
||||
|
||||
|
||||
ert_lib_path = None # Warning: Will be updated from ert/__init__.py
|
||||
ert_so_version = "" #
|
||||
|
||||
|
||||
|
||||
|
||||
# Passing None to the CDLL() function means to open a lib handle to
|
||||
# the current runnning process, i.e. like dlopen( NULL ). We must
|
||||
# special case this to avoid creating the bogus argument 'None.so'.
|
||||
|
||||
def lib_name(lib , path = None , so_version = ""):
|
||||
if lib is None:
|
||||
return None
|
||||
else:
|
||||
platform_key = platform.system().lower()
|
||||
|
||||
if platform_key == "darwin":
|
||||
so_name = "%s%s.%s" % (lib, so_version, so_extension[ platform_key ])
|
||||
else:
|
||||
so_name = "%s.%s%s" % (lib, so_extension[ platform_key ], so_version)
|
||||
|
||||
if path:
|
||||
return os.path.join( path , so_name )
|
||||
else:
|
||||
return so_name
|
||||
|
||||
|
||||
|
||||
|
||||
def __load( lib_list, ert_prefix):
|
||||
"""
|
||||
Thin wrapper around the ctypes.CDLL function for loading shared library.
|
||||
|
||||
The shared libraries typically exist under several different
|
||||
names, with different level of version detail. Unfortunately the
|
||||
same library can exist under different names on different
|
||||
computers, to support this the load function can get several
|
||||
arguments like:
|
||||
|
||||
load("libz.so" , "libz.so.1" , "libz.so.1.2.1.2" , "libZ-fucker.so")
|
||||
|
||||
Will return a handle to the first successfull load, and raise
|
||||
ImportError if none of the loads succeed.
|
||||
"""
|
||||
|
||||
error_list = {}
|
||||
dll = None
|
||||
for lib in lib_list:
|
||||
if ert_prefix:
|
||||
lib_file = lib_name( lib , path = ert_lib_path , so_version = ert_so_version)
|
||||
else:
|
||||
lib_file = lib_name( lib , so_version = ert_so_version)
|
||||
|
||||
try:
|
||||
dll = ctypes.CDLL(lib_file , ctypes.RTLD_GLOBAL)
|
||||
return dll
|
||||
except Exception, exc:
|
||||
error_list[lib] = exc
|
||||
|
||||
error_msg = "\nFailed to load shared library:%s\n\ndlopen() error:\n" % lib_list[0]
|
||||
for lib in error_list.keys():
|
||||
error_msg += " %16s : %s\n" % (lib, error_list[lib])
|
||||
error_msg += "\n"
|
||||
|
||||
LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH")
|
||||
if not LD_LIBRARY_PATH:
|
||||
LD_LIBRARY_PATH = ""
|
||||
|
||||
error_msg += """
|
||||
The runtime linker has searched through the default location of shared
|
||||
libraries, and also the locations mentioned in your LD_LIBRARY_PATH
|
||||
variable. Your current LD_LIBRARY_PATH setting is:
|
||||
|
||||
LD_LIBRARY_PATH: %s
|
||||
|
||||
You might need to update this variable?
|
||||
""" % LD_LIBRARY_PATH
|
||||
raise ImportError(error_msg)
|
||||
|
||||
#################################################################
|
||||
|
||||
|
||||
def load( *lib_list ):
|
||||
"""
|
||||
Will try to load shared library with normal load semantics.
|
||||
"""
|
||||
return __load(lib_list , False)
|
||||
|
||||
|
||||
def ert_load( *lib_list ):
|
||||
"""
|
||||
Iff the ert_lib_path module variable has been set it will try to
|
||||
load shared library from that path; if that fails the loader will
|
||||
try again without imposing any path restrictions.
|
||||
"""
|
||||
|
||||
if ert_lib_path:
|
||||
try:
|
||||
return __load(lib_list , True)
|
||||
except ImportError:
|
||||
# Try again - ignoring the ert_lib_path setting.
|
||||
return load(*lib_list)
|
||||
else:
|
||||
# The ert_lib_path variable has not been set; just try a normal load.
|
||||
return load(*lib_list)
|
||||
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
ecl.py
|
||||
ecl_3d_file.py
|
||||
ecl_3dkw.py
|
||||
ecl_case.py
|
||||
ecl_default.py
|
||||
ecl_file.py
|
||||
ecl_grav.py
|
||||
ecl_grav_calc.py
|
||||
ecl_grid.py
|
||||
ecl_init_file.py
|
||||
ecl_kw.py
|
||||
ecl_npv.py
|
||||
ecl_region.py
|
||||
ecl_restart_file.py
|
||||
ecl_rft.py
|
||||
ecl_rft_cell.py
|
||||
ecl_smspec_node.py
|
||||
ecl_subsidence.py
|
||||
ecl_sum.py
|
||||
ecl_sum_keyword_vector.py
|
||||
ecl_sum_node.py
|
||||
ecl_sum_tstep.py
|
||||
ecl_sum_vector.py
|
||||
ecl_util.py
|
||||
fortio.py
|
||||
ecl_sum_keyword_vector.py
|
||||
ecl_cmp.py
|
||||
ecl_sum_var_type.py
|
||||
)
|
||||
|
||||
if (BUILD_ERT)
|
||||
list(APPEND PYTHON_SOURCES ecl_queue.py)
|
||||
endif()
|
||||
|
||||
|
||||
add_python_package("python.ert.ecl" ${PYTHON_INSTALL_PREFIX}/ert/ecl "${PYTHON_SOURCES}" True)
|
||||
|
||||
|
||||
|
||||
set( ECL_LOCAL_TARGET "" CACHE FILE "Name of optional external ecl_local module")
|
||||
|
||||
if (EXISTS ${ECL_LOCAL_TARGET})
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py")
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py")
|
||||
endif()
|
||||
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ECL_LOCAL_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py")
|
||||
message(STATUS "Linking ${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py -> ${ECL_LOCAL_TARGET}")
|
||||
endif()
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py")
|
||||
add_python_package( "python.ert.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ert/ecl "ecl_local.py" True)
|
||||
endif()
|
||||
|
||||
add_subdirectory(faults)
|
||||
add_subdirectory(rft)
|
@ -1,174 +0,0 @@
|
||||
# Copyright (C) 2011 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'ecl_default.py' is part of ERT - Ensemble based Reservoir Tool.
|
||||
#
|
||||
# ERT is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
"""
|
||||
Module containing default values for ECLIPSE.
|
||||
|
||||
This module contains site specific default values for various
|
||||
variables related to the eclipse environment. Observe that this module
|
||||
itself does not set any default values, instead it will try to import
|
||||
a module ecl_local; and then subsequently read all values from this
|
||||
module. The ecl_local module is not provided in the ert source
|
||||
distribution, you must create this yourself and install along with
|
||||
this module.
|
||||
|
||||
It is not necessary to create a ecl_local module, but if you try to
|
||||
access the default properties and have not created a ecl_local module
|
||||
a NotImplemtedError exception will be raised.
|
||||
|
||||
The intention is not to use the EclDefault explicitly, rather the
|
||||
ert-python code will consult the EclDefault class internally. For
|
||||
instance the EclCase method to submit an ECLIPSE simulation looks like
|
||||
this:
|
||||
|
||||
import ecl_default.default as default
|
||||
...
|
||||
...
|
||||
def submit(self , version = None , cmd = None):
|
||||
if not cmd:
|
||||
cmd = default.cmd
|
||||
if not version:
|
||||
version = default.version
|
||||
...
|
||||
|
||||
I.e. if the user has not supplied values for the optional arguments
|
||||
version and cmd the method will consult the default instance from the
|
||||
ecl_default module.
|
||||
|
||||
The ecl_local module can define the following variables:
|
||||
|
||||
cmd:
|
||||
version:
|
||||
lsf_resource_request:
|
||||
|
||||
Depending on the computing environment some variables might be
|
||||
irrelevant; it is not necessary to set variables which will not be
|
||||
used.
|
||||
"""
|
||||
|
||||
|
||||
class EclDefault(object):
|
||||
_initialized = False
|
||||
|
||||
_ecl_cmd = None
|
||||
_ecl_version = None
|
||||
_lsf_resource_request = None
|
||||
_driver_type = None
|
||||
_driver_options = None
|
||||
|
||||
@staticmethod
|
||||
def _initializeEclDefaults():
|
||||
if not EclDefault._initialized:
|
||||
try:
|
||||
import ert.ecl.ecl_local as ecl_local
|
||||
|
||||
if hasattr(ecl_local, "ecl_cmd"):
|
||||
EclDefault._ecl_cmd = ecl_local.ecl_cmd
|
||||
|
||||
if hasattr(ecl_local, "ecl_version"):
|
||||
EclDefault._ecl_version = ecl_local.ecl_version
|
||||
|
||||
if hasattr(ecl_local, "lsf_resource_request"):
|
||||
EclDefault._lsf_resource_request = ecl_local.lsf_resource_request
|
||||
|
||||
if hasattr(ecl_local, "driver_type"):
|
||||
EclDefault._driver_type = ecl_local.driver_type
|
||||
|
||||
if hasattr(ecl_local, "driver_options"):
|
||||
EclDefault._driver_options = ecl_local.driver_options
|
||||
|
||||
|
||||
except ImportError as e:
|
||||
pass
|
||||
|
||||
EclDefault._initialized = True
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ecl_cmd():
|
||||
"""
|
||||
The path to the executable used to invoke ECLIPSE.
|
||||
"""
|
||||
EclDefault._initializeEclDefaults()
|
||||
|
||||
if EclDefault._ecl_cmd is None:
|
||||
EclDefault._attributeIsNotSet("ecl_cmd")
|
||||
return EclDefault._ecl_cmd
|
||||
|
||||
@staticmethod
|
||||
def driver_type():
|
||||
EclDefault._initializeEclDefaults()
|
||||
|
||||
if EclDefault._driver_type is None:
|
||||
EclDefault._attributeIsNotSet("driver_type")
|
||||
return EclDefault._driver_type
|
||||
|
||||
@staticmethod
|
||||
def driver_options():
|
||||
EclDefault._initializeEclDefaults()
|
||||
|
||||
if EclDefault._driver_options is None:
|
||||
EclDefault._attributeIsNotSet("driver_options")
|
||||
return EclDefault._driver_options
|
||||
|
||||
@staticmethod
|
||||
def ecl_version():
|
||||
EclDefault._initializeEclDefaults()
|
||||
|
||||
if EclDefault._ecl_version is None:
|
||||
EclDefault._attributeIsNotSet("ecl_version")
|
||||
return EclDefault._ecl_version
|
||||
|
||||
@staticmethod
|
||||
def lsf_resource_request():
|
||||
EclDefault._initializeEclDefaults()
|
||||
|
||||
if EclDefault._lsf_resource_request is None:
|
||||
EclDefault._attributeIsNotSet("lsf_resource_request")
|
||||
return EclDefault._lsf_resource_request
|
||||
|
||||
@staticmethod
|
||||
def _attributeIsNotSet(attribute_name):
|
||||
raise NotImplementedError("The default attribute:%s has not been set - you must update/provide a ecl_local module." % attribute_name)
|
||||
|
||||
|
||||
#Legacy import support
|
||||
|
||||
class default_wrapper(object):
|
||||
#from warnings import warn
|
||||
#warn("The ecl_default namespace is deprecated! Please retrieve ecl_default values from the class: ert.ecl.EclDefault!")
|
||||
|
||||
@property
|
||||
def ecl_cmd(self):
|
||||
return EclDefault.ecl_cmd()
|
||||
|
||||
@property
|
||||
def driver_type(self):
|
||||
return EclDefault.driver_type()
|
||||
|
||||
@property
|
||||
def driver_options(self):
|
||||
return EclDefault.driver_options()
|
||||
|
||||
@property
|
||||
def ecl_version(self):
|
||||
return EclDefault.ecl_version()
|
||||
|
||||
@property
|
||||
def lsf_resource_request(self):
|
||||
return EclDefault.lsf_resource_request()
|
||||
|
||||
|
||||
default = default_wrapper()
|
@ -1,174 +0,0 @@
|
||||
# Copyright (C) 2011 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'ecl_queue.py' is part of ERT - Ensemble based Reservoir Tool.
|
||||
#
|
||||
# ERT is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
"""
|
||||
Implements a queue to run many ECLIPSE simulations.
|
||||
|
||||
The EclQueue class should be used when you have more ECLIPSE
|
||||
simulations than you can perform concurrently; the queue will start
|
||||
simulations when there is available computing resources. The EclQueue
|
||||
can be combined with LSF, in that case the EclQueue will limit the
|
||||
number of jobs submitted to LSF, but it is clearly most relevant when
|
||||
simulating locally or on workstations through rsh commands.
|
||||
|
||||
The queue is based on the use of 'driver' to communicate with the low
|
||||
level systems for running the simulations. The driver must be
|
||||
instantiated before you can create a queue. The driver is implemented
|
||||
in the driver module in ert.job_queue.driver.
|
||||
|
||||
The EclQueue class is a decendant of the JobQueue class, which is
|
||||
specialized to only submit ECLIPSE simulations. To fully understand
|
||||
the EclQueue class it is important to consult the documentation of the
|
||||
JobQueue class in ert.job_queue.queue as well.
|
||||
"""
|
||||
import os.path
|
||||
from ert.ecl import EclUtil, EclDefault
|
||||
from ert.job_queue import JobQueue, Driver
|
||||
|
||||
|
||||
class EclQueue(JobQueue):
|
||||
def __init__(self,
|
||||
driver=None,
|
||||
driver_type=None,
|
||||
driver_options=None,
|
||||
ecl_version=None,
|
||||
ecl_cmd=None,
|
||||
max_running=0,
|
||||
size=0):
|
||||
|
||||
"""
|
||||
Create a new queue instance to manage ECLIPSE simulations.
|
||||
|
||||
The constructor will create a new EclQueue instance which can
|
||||
be used to manage ECLIPSE simulations. All the ECLIPSE
|
||||
simulations managed by this queue instance will be 'of the
|
||||
same type', i.e. they will run the same ECLIPSE version using
|
||||
the same command to run ECLIPSE.
|
||||
|
||||
The queue starts running (i.e. managing jobs) as soon as it is
|
||||
created. Subsequently the user must add jobs to run using the
|
||||
submit() method, or alternatively the submit() method of an
|
||||
EclCase instance.
|
||||
|
||||
The queue will run in a separate thread, and there is nothing
|
||||
preventing your script from finishing (i.e. exit) even though
|
||||
the queue thread is still running; in that case the jobs which
|
||||
are still waiting in the queue will not be started[1]. To
|
||||
protect against this premature exit you must use on of the
|
||||
methods:
|
||||
|
||||
- queue.block_waiting()
|
||||
- queue.block()
|
||||
- while queue.running:
|
||||
.....
|
||||
|
||||
All simulations which have been started by the queue instance
|
||||
will continue running even if the queue itself goes out of
|
||||
scope and the script exits.
|
||||
|
||||
There are many arguments to the constructor, all of them are
|
||||
optional with sensible default values. There are essentially
|
||||
three groups of arguments:
|
||||
|
||||
Driver related arguments
|
||||
------------------------
|
||||
driver: This should be an instance of Driver (or one of the
|
||||
descendants LSFDriver, LocalDriver, or ...) from the
|
||||
ert.job_queue.driver module. If the driver is None the
|
||||
queue will instanstiate a driver itself.
|
||||
|
||||
driver_type: If the driver is None the queue needs to
|
||||
instantiate a private driver. It will then instantiate a
|
||||
driver of the type given by driver_type.
|
||||
|
||||
driver_options: If the queue needs to instantiate a private
|
||||
driver it will pass the options given by the
|
||||
driver_options argument to the driver constructor.
|
||||
|
||||
There is some dependance between the driver related arguments;
|
||||
if a @driver argument is passed the @driver_type and
|
||||
@driver_options arguments are not considered.
|
||||
|
||||
ECLIPSE related arguments
|
||||
-------------------------
|
||||
ecl_version: The ECLIPSE version used when simulating. This
|
||||
should be a string of the type "2009.1".
|
||||
|
||||
ecl_cmd: The path to the executable used to invoke
|
||||
ECLIPSE. The executable will be invoked with commandline
|
||||
arguments:
|
||||
version data_file num_cpu
|
||||
And this executable is responsible for then starting the
|
||||
real ECLIPSE binary.
|
||||
|
||||
Other arguments
|
||||
---------------
|
||||
max_running: The maximum number of jobs the queue can run
|
||||
concurrently. The default value max_running=0 means that
|
||||
the queue can start an unlimited number of jobs; in the
|
||||
case of e.g. LSF the default value can be sensible,
|
||||
otherwise you should probably set a value.
|
||||
|
||||
size: This is the total number of simulations we want to run
|
||||
with the queue; this is further documented in the
|
||||
ert.job_queue.queue.JobQueue class.
|
||||
|
||||
Use example
|
||||
-----------
|
||||
import ert.ecl.ecl as ecl
|
||||
import ert.job_queue.driver as driver
|
||||
|
||||
queue = ecl.EclQueue( driver_type = driver.LOCAL , max_running = 4 , size = 100)
|
||||
data_file_fmt = "/path/to/ECLIPSE/sim%d/ECL.DATA"
|
||||
for i in range(100):
|
||||
queue.submit( data_file_fmt % i )
|
||||
|
||||
queue.block()
|
||||
|
||||
[1]: It should be possible with a fork based solution to let
|
||||
the queue stay alive and continue managing jobs even
|
||||
after the main thread has exited - not yet :-(
|
||||
"""
|
||||
if ecl_cmd is None:
|
||||
ecl_cmd = EclDefault.ecl_cmd()
|
||||
|
||||
if driver_type is None:
|
||||
driver_type = EclDefault.driver_type()
|
||||
|
||||
if ecl_version is None:
|
||||
ecl_version = EclDefault.ecl_version()
|
||||
|
||||
self.ecl_version = ecl_version
|
||||
self.ecl_cmd = ecl_cmd
|
||||
if driver is None:
|
||||
if driver_options is None:
|
||||
driver_options = EclDefault.driver_options()[driver_type]
|
||||
driver = Driver(driver_type, max_running=max_running, options=driver_options)
|
||||
|
||||
super(EclQueue, self).__init__(driver, size=size)
|
||||
|
||||
|
||||
def submitDataFile(self, data_file):
|
||||
"""
|
||||
Will submit a new simulation of case given by @data_file.
|
||||
"""
|
||||
(path_base, ext) = os.path.splitext(data_file)
|
||||
(run_path, base) = os.path.split(path_base)
|
||||
|
||||
num_cpu = EclUtil.get_num_cpu(data_file)
|
||||
argv = [self.ecl_version, path_base, "%s" % num_cpu]
|
||||
|
||||
return self.submit(self.ecl_cmd, run_path, base, argv, num_cpu=num_cpu)
|
||||
|
@ -1,157 +0,0 @@
|
||||
# Copyright (C) 2012 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'analysis_config.py' is part of ERT - Ensemble based Reservoir Tool.
|
||||
#
|
||||
# ERT is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
from ert.cwrap import BaseCClass, CWrapper
|
||||
from ert.enkf import ENKF_LIB
|
||||
from ert.enkf import AnalysisIterConfig
|
||||
from ert.analysis import AnalysisModule
|
||||
from ert.util import StringList
|
||||
|
||||
|
||||
class AnalysisConfig(BaseCClass):
|
||||
def __init__(self):
|
||||
c_ptr = AnalysisConfig.cNamespace().alloc()
|
||||
super(AnalysisConfig , self).__init__(c_ptr)
|
||||
|
||||
|
||||
def get_rerun(self):
|
||||
return AnalysisConfig.cNamespace().get_rerun(self)
|
||||
|
||||
def set_rerun(self, rerun):
|
||||
AnalysisConfig.cNamespace().set_rerun(self, rerun)
|
||||
|
||||
def get_rerun_start(self):
|
||||
return AnalysisConfig.cNamespace().get_rerun_start(self)
|
||||
|
||||
def set_rerun_start(self, index):
|
||||
AnalysisConfig.cNamespace().set_rerun_start(self, index)
|
||||
|
||||
def get_log_path(self):
|
||||
return AnalysisConfig.cNamespace().get_log_path(self)
|
||||
|
||||
def set_log_path(self, path):
|
||||
AnalysisConfig.cNamespace().set_log_path(self, path)
|
||||
|
||||
def getEnkfAlpha(self):
|
||||
""" :rtype: float """
|
||||
return AnalysisConfig.cNamespace().get_alpha(self)
|
||||
|
||||
def setEnkfAlpha(self, alpha):
|
||||
AnalysisConfig.cNamespace().set_alpha(self, alpha)
|
||||
|
||||
def getStdCutoff(self):
|
||||
""" :rtype: float """
|
||||
return AnalysisConfig.cNamespace().get_std_cutoff(self)
|
||||
|
||||
def setStdCutoff(self, std_cutoff):
|
||||
AnalysisConfig.cNamespace().set_std_cutoff(self, std_cutoff)
|
||||
|
||||
def get_merge_observations(self):
|
||||
return AnalysisConfig.cNamespace().get_merge_observations(self)
|
||||
|
||||
def set_merge_observations(self, merge_observations):
|
||||
return AnalysisConfig.cNamespace().set_merge_observations(self, merge_observations)
|
||||
|
||||
def getAnalysisIterConfig(self):
|
||||
""" @rtype: AnalysisIterConfig """
|
||||
return AnalysisConfig.cNamespace().get_iter_config(self).setParent(self)
|
||||
|
||||
def getMinRealisations(self):
|
||||
""" @rtype: int """
|
||||
return AnalysisConfig.cNamespace().get_min_realisations( self )
|
||||
|
||||
def set_min_realisations(self , min_realisations):
|
||||
AnalysisConfig.cNamespace().set_min_realisations( self , min_realisations )
|
||||
|
||||
def get_stop_long_running(self):
|
||||
""" @rtype: bool """
|
||||
return AnalysisConfig.cNamespace().get_stop_long_running( self )
|
||||
|
||||
def set_stop_long_running(self, stop_long_running):
|
||||
AnalysisConfig.cNamespace().set_stop_long_running(self, stop_long_running)
|
||||
|
||||
def get_max_runtime(self):
|
||||
""" @rtype: int """
|
||||
return AnalysisConfig.cNamespace().get_max_runtime( self )
|
||||
|
||||
def set_max_runtime(self, max_runtime):
|
||||
AnalysisConfig.cNamespace().set_max_runtime( self, max_runtime )
|
||||
|
||||
def free(self):
|
||||
AnalysisConfig.cNamespace().free(self)
|
||||
|
||||
def activeModuleName(self):
|
||||
""" :rtype: str """
|
||||
return AnalysisConfig.cNamespace().get_active_module_name(self)
|
||||
|
||||
def getModuleList(self):
|
||||
""" :rtype: StringList """
|
||||
return AnalysisConfig.cNamespace().get_module_list(self)
|
||||
|
||||
def getModule(self, module_name):
|
||||
""" @rtype: AnalysisModule """
|
||||
return AnalysisConfig.cNamespace().get_module(self, module_name)
|
||||
|
||||
def selectModule(self, module_name):
|
||||
""" @rtype: bool """
|
||||
return AnalysisConfig.cNamespace().select_module(self, module_name)
|
||||
|
||||
def getActiveModule(self):
|
||||
""" :rtype: AnalysisModule """
|
||||
return self.getModule(self.activeModuleName())
|
||||
|
||||
def setGlobalStdScaling(self, std_scaling):
|
||||
AnalysisConfig.cNamespace().set_global_std_scaling(self, std_scaling)
|
||||
|
||||
def getGlobalStdScaling(self):
|
||||
return AnalysisConfig.cNamespace().get_global_std_scaling(self)
|
||||
|
||||
|
||||
cwrapper = CWrapper(ENKF_LIB)
|
||||
cwrapper.registerType("analysis_config", AnalysisConfig)
|
||||
cwrapper.registerType("analysis_config_obj", AnalysisConfig.createPythonObject)
|
||||
cwrapper.registerType("analysis_config_ref", AnalysisConfig.createCReference)
|
||||
|
||||
AnalysisConfig.cNamespace().alloc = cwrapper.prototype("c_void_p analysis_config_alloc()")
|
||||
AnalysisConfig.cNamespace().free = cwrapper.prototype("void analysis_config_free( analysis_config )")
|
||||
AnalysisConfig.cNamespace().get_rerun = cwrapper.prototype("int analysis_config_get_rerun( analysis_config )")
|
||||
AnalysisConfig.cNamespace().set_rerun = cwrapper.prototype("void analysis_config_set_rerun( analysis_config, bool)")
|
||||
AnalysisConfig.cNamespace().get_rerun_start = cwrapper.prototype("int analysis_config_get_rerun_start( analysis_config )")
|
||||
AnalysisConfig.cNamespace().set_rerun_start = cwrapper.prototype("void analysis_config_set_rerun_start( analysis_config, int)")
|
||||
AnalysisConfig.cNamespace().get_log_path = cwrapper.prototype("char* analysis_config_get_log_path( analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_log_path = cwrapper.prototype("void analysis_config_set_log_path( analysis_config, char*)")
|
||||
|
||||
AnalysisConfig.cNamespace().get_merge_observations = cwrapper.prototype("bool analysis_config_get_merge_observations(analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_merge_observations = cwrapper.prototype("void analysis_config_set_merge_observations(analysis_config, bool)")
|
||||
AnalysisConfig.cNamespace().get_iter_config = cwrapper.prototype("analysis_iter_config_ref analysis_config_get_iter_config(analysis_config)")
|
||||
AnalysisConfig.cNamespace().get_min_realisations = cwrapper.prototype("int analysis_config_get_min_realisations(analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_min_realisations = cwrapper.prototype("void analysis_config_set_min_realisations(analysis_config, int)")
|
||||
AnalysisConfig.cNamespace().get_max_runtime = cwrapper.prototype("int analysis_config_get_max_runtime(analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_max_runtime = cwrapper.prototype("void analysis_config_set_max_runtime(analysis_config, int)")
|
||||
AnalysisConfig.cNamespace().get_stop_long_running = cwrapper.prototype("bool analysis_config_get_stop_long_running(analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_stop_long_running = cwrapper.prototype("void analysis_config_set_stop_long_running(analysis_config, bool)")
|
||||
|
||||
AnalysisConfig.cNamespace().get_active_module_name = cwrapper.prototype("char* analysis_config_get_active_module_name(analysis_config)")
|
||||
AnalysisConfig.cNamespace().get_module_list = cwrapper.prototype("stringlist_obj analysis_config_alloc_module_names(analysis_config)")
|
||||
AnalysisConfig.cNamespace().get_module = cwrapper.prototype("analysis_module_ref analysis_config_get_module(analysis_config, char*)")
|
||||
AnalysisConfig.cNamespace().select_module = cwrapper.prototype("bool analysis_config_select_module(analysis_config, char*)")
|
||||
|
||||
AnalysisConfig.cNamespace().get_alpha = cwrapper.prototype("double analysis_config_get_alpha(analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_alpha = cwrapper.prototype("void analysis_config_set_alpha(analysis_config, double)")
|
||||
AnalysisConfig.cNamespace().get_std_cutoff = cwrapper.prototype("double analysis_config_get_std_cutoff(analysis_config)")
|
||||
AnalysisConfig.cNamespace().set_std_cutoff = cwrapper.prototype("void analysis_config_set_std_cutoff(analysis_config, double)")
|
||||
|
||||
AnalysisConfig.cNamespace().set_global_std_scaling = cwrapper.prototype("void analysis_config_set_global_std_scaling(analysis_config, double)")
|
||||
AnalysisConfig.cNamespace().get_global_std_scaling = cwrapper.prototype("double analysis_config_get_global_std_scaling(analysis_config)")
|
@ -1,17 +0,0 @@
|
||||
from ert.cwrap import CWrapper, CNamespace
|
||||
from ert.enkf import ENKF_LIB
|
||||
|
||||
|
||||
class ErtLog(object):
|
||||
cnamespace = None
|
||||
|
||||
@staticmethod
|
||||
def log(log_level, message ):
|
||||
ErtLog.cnamespace.write_log(log_level, message)
|
||||
|
||||
ErtLog.cnamespace = CNamespace("ErtLog")
|
||||
|
||||
cwrapper = CWrapper(ENKF_LIB)
|
||||
|
||||
ErtLog.cnamespace.init = cwrapper.prototype("void ert_log_init_log(int, char*, char*, bool)")
|
||||
ErtLog.cnamespace.write_log = cwrapper.prototype("void ert_log_add_message_py(int, char*)")
|
@ -1,71 +0,0 @@
|
||||
from collections import namedtuple
|
||||
from ert.cwrap import BaseCClass, CWrapper
|
||||
from ert.enkf import ENKF_LIB
|
||||
|
||||
RunpathNode = namedtuple("RunpathNode", ["realization", "iteration", "runpath", "basename"])
|
||||
|
||||
class RunpathList(BaseCClass):
|
||||
|
||||
def __init__(self, export_file):
|
||||
c_ptr = RunpathList.cNamespace().alloc( export_file )
|
||||
super(RunpathList , self).__init__(c_ptr)
|
||||
|
||||
def __len__(self):
|
||||
return RunpathList.cNamespace().size(self)
|
||||
|
||||
def __getitem__(self, index):
|
||||
""" @rtype: RunpathNode """
|
||||
if not 0 <= index < len(self):
|
||||
raise IndexError("Index not in range: 0 <= %d < %d" % (index, len(self)))
|
||||
|
||||
realization = RunpathList.cNamespace().iens(self, index)
|
||||
iteration = RunpathList.cNamespace().iteration(self, index)
|
||||
runpath = RunpathList.cNamespace().runpath(self, index)
|
||||
basename = RunpathList.cNamespace().basename(self, index)
|
||||
|
||||
return RunpathNode(realization, iteration, runpath, basename)
|
||||
|
||||
def __iter__(self):
|
||||
index = 0
|
||||
while index < len(self):
|
||||
yield self[index]
|
||||
index += 1
|
||||
|
||||
|
||||
def add(self, realization_number, iteration_number, runpath, basename):
|
||||
"""
|
||||
@type realization_number: int
|
||||
@type iteration_number: int
|
||||
@type runpath: int
|
||||
@type basename: int
|
||||
"""
|
||||
RunpathList.cNamespace().add(self, realization_number, iteration_number, runpath, basename)
|
||||
|
||||
def clear(self):
|
||||
RunpathList.cNamespace().clear(self)
|
||||
|
||||
|
||||
def free(self):
|
||||
RunpathList.cNamespace().free(self)
|
||||
|
||||
|
||||
def export(self):
|
||||
RunpathList.cNamespace().export(self)
|
||||
|
||||
|
||||
cwrapper = CWrapper(ENKF_LIB)
|
||||
cwrapper.registerObjectType("runpath_list", RunpathList)
|
||||
|
||||
RunpathList.cNamespace().free = cwrapper.prototype("void runpath_list_free(runpath_list)")
|
||||
|
||||
RunpathList.cNamespace().add = cwrapper.prototype("void runpath_list_add(runpath_list, int, int, char*, char*)")
|
||||
RunpathList.cNamespace().clear = cwrapper.prototype("void runpath_list_clear(runpath_list)")
|
||||
|
||||
RunpathList.cNamespace().size = cwrapper.prototype("int runpath_list_size(runpath_list)")
|
||||
RunpathList.cNamespace().iens = cwrapper.prototype("int runpath_list_iget_iens(runpath_list, int)")
|
||||
RunpathList.cNamespace().iteration = cwrapper.prototype("int runpath_list_iget_iter(runpath_list, int)")
|
||||
RunpathList.cNamespace().runpath = cwrapper.prototype("char* runpath_list_iget_runpath(runpath_list, int)")
|
||||
RunpathList.cNamespace().basename = cwrapper.prototype("char* runpath_list_iget_basename(runpath_list, int)")
|
||||
RunpathList.cNamespace().export = cwrapper.prototype("void runpath_list_fprintf(runpath_list)")
|
||||
RunpathList.cNamespace().alloc = cwrapper.prototype("c_void_p runpath_list_alloc(char*)")
|
||||
|
@ -1,2 +0,0 @@
|
||||
lib_path = "${LIBRARY_OUTPUT_PATH}"
|
||||
so_version = "${ERT_BINARY_POSTFIX}"
|
@ -1,7 +0,0 @@
|
||||
from ert.cwrap import clib
|
||||
|
||||
import ert.util
|
||||
import ert.geo
|
||||
import ert.ecl
|
||||
|
||||
RMS_LIB = clib.ert_load("librms")
|
@ -1,9 +0,0 @@
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
REQUIRED_VERSION_HEX = 0x02070000
|
||||
|
||||
|
||||
if sys.hexversion < REQUIRED_VERSION_HEX:
|
||||
raise Exception("ERT GUI Python requires at least version 2.7 of Python")
|
||||
|
@ -1,12 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
ert_connector.py
|
||||
observable.py
|
||||
weak_method.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models" ${PYTHON_INSTALL_PREFIX}/ert_gui/models "${PYTHON_SOURCES}" True)
|
||||
|
||||
add_subdirectory(connectors)
|
||||
add_subdirectory(mixins)
|
||||
add_subdirectory(qt)
|
@ -1,3 +0,0 @@
|
||||
from .weak_method import WeakMethod
|
||||
from .observable import Observable
|
||||
from .ert_connector import ErtConnector
|
@ -1,14 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
ensemble_resizer.py
|
||||
ert_summary.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models.connectors" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/connectors "${PYTHON_SOURCES}" True)
|
||||
|
||||
add_subdirectory(export)
|
||||
add_subdirectory(init)
|
||||
add_subdirectory(plot)
|
||||
add_subdirectory(queue_system)
|
||||
add_subdirectory(run)
|
||||
add_subdirectory(load_results)
|
@ -1,3 +0,0 @@
|
||||
from .ert_summary import ErtSummary
|
||||
from .ensemble_resizer import EnsembleSizeModel
|
||||
|
@ -1,33 +0,0 @@
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.mixins import SpinnerModelMixin, BasicModelMixin
|
||||
|
||||
|
||||
class EnsembleSizeModel(ErtConnector, SpinnerModelMixin, BasicModelMixin):
|
||||
|
||||
def getMaxValue(self):
|
||||
""" @rtype: int """
|
||||
return 10000
|
||||
|
||||
def getMinValue(self):
|
||||
""" @rtype: int """
|
||||
return 1
|
||||
|
||||
def getSpinnerValue(self):
|
||||
""" @rtype: int """
|
||||
return self.ert().getEnsembleSize()
|
||||
|
||||
def setSpinnerValue(self, value):
|
||||
self.ert().resizeEnsemble(int(value))
|
||||
self.observable().notify(self.SPINNER_VALUE_CHANGED_EVENT)
|
||||
self.observable().notify(self.VALUE_CHANGED_EVENT)
|
||||
|
||||
def getValue(self):
|
||||
return self.getSpinnerValue()
|
||||
|
||||
def setValue(self, value):
|
||||
self.setSpinnerValue(value)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
export_keyword_model.py
|
||||
export_model.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models.connectors.export" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/connectors/export "${PYTHON_SOURCES}" True)
|
||||
|
@ -1,2 +0,0 @@
|
||||
from .export_keyword_model import ExportKeywordModel
|
||||
from .export_model import ExportModel
|
@ -1,15 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
case_list.py
|
||||
case_selector.py
|
||||
init_from_existing.py
|
||||
init_from_scratch.py
|
||||
init_history_length.py
|
||||
init_members.py
|
||||
init_parameters.py
|
||||
initialized_case_selector.py
|
||||
is_case_initialized.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models.connectors.init" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/connectors/init "${PYTHON_SOURCES}" True)
|
||||
|
@ -1,9 +0,0 @@
|
||||
from .case_list import CaseList
|
||||
from .case_selector import CaseSelectorModel
|
||||
from .initialized_case_selector import InitializedCaseSelectorModel
|
||||
from .init_members import InitializationMembersModel
|
||||
from .init_parameters import InitializationParametersModel
|
||||
from .init_from_scratch import InitializeFromScratchModel
|
||||
from .init_from_existing import InitializeFromExistingCaseModel
|
||||
from .is_case_initialized import IsCaseInitializedModel
|
||||
from .init_history_length import HistoryLengthModel
|
@ -1,60 +0,0 @@
|
||||
from ert.enkf.enums.realization_state_enum import RealizationStateEnum
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.mixins import ListModelMixin
|
||||
from ert.enkf.state_map import StateMap
|
||||
|
||||
|
||||
class CaseList(ErtConnector, ListModelMixin):
|
||||
|
||||
def getList(self):
|
||||
fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
|
||||
case_list = self.ert().getEnkfFsManager().getCaseList()
|
||||
return [case for case in case_list if not self.ert().getEnkfFsManager().isCaseHidden(case)]
|
||||
|
||||
def addItem(self, value):
|
||||
# Creates a new filesystem. Value should be a case that does not exist
|
||||
enkf_fs = self.ert().getEnkfFsManager().getFileSystem(value)
|
||||
self.ert().getEnkfFsManager().switchFileSystem(enkf_fs)
|
||||
self.observable().notify(ListModelMixin.LIST_CHANGED_EVENT)
|
||||
|
||||
|
||||
def getAllCasesWithDataAndNotRunning(self):
|
||||
cases = self.getList()
|
||||
cases_with_data_and_not_running = []
|
||||
for case in cases:
|
||||
case_has_data = False
|
||||
state_map = self.ert().getEnkfFsManager().getStateMapForCase(case)
|
||||
|
||||
for state in state_map:
|
||||
if state == RealizationStateEnum.STATE_HAS_DATA:
|
||||
case_has_data = True
|
||||
|
||||
if case_has_data and not self.ert().getEnkfFsManager().isCaseRunning(case):
|
||||
cases_with_data_and_not_running.append(case)
|
||||
|
||||
return cases_with_data_and_not_running
|
||||
|
||||
def getAllCasesNotRunning(self):
|
||||
cases = self.getList()
|
||||
cases_not_running = []
|
||||
for case in cases:
|
||||
if not self.ert().getEnkfFsManager().isCaseRunning(case):
|
||||
cases_not_running.append(case)
|
||||
|
||||
return cases_not_running
|
||||
|
||||
|
||||
def getCaseRealizationStates(self, case_name):
|
||||
state_map = self.ert().getEnkfFsManager().getStateMapForCase(case_name)
|
||||
return [state for state in state_map]
|
||||
|
||||
|
||||
def externalModificationNotification(self):
|
||||
self.observable().notify(ListModelMixin.LIST_CHANGED_EVENT)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert.util import StringList
|
||||
from ert_gui.models.connectors.init.case_list import CaseList
|
||||
from ert_gui.models.mixins import ChoiceModelMixin
|
||||
from ert_gui.widgets.util import may_take_a_long_time
|
||||
|
||||
|
||||
class CaseSelectorModel(ErtConnector, ChoiceModelMixin):
|
||||
def __init__(self):
|
||||
CaseList().observable().attach(CaseList.LIST_CHANGED_EVENT, self.__caseListChanged)
|
||||
super(CaseSelectorModel, self).__init__()
|
||||
|
||||
def __caseListChanged(self):
|
||||
self.observable().notify(ChoiceModelMixin.CHOICE_LIST_CHANGED_EVENT)
|
||||
self.observable().notify(ChoiceModelMixin.CURRENT_CHOICE_CHANGED_EVENT)
|
||||
|
||||
def getChoices(self):
|
||||
""" @rtype: StringList """
|
||||
return CaseList().getList()
|
||||
|
||||
def getCurrentChoice(self):
|
||||
""" @rtype: str """
|
||||
case_list = self.getChoices()
|
||||
current_case = self.ert().getEnkfFsManager().getCurrentFileSystem()
|
||||
return current_case.getCaseName()
|
||||
|
||||
@may_take_a_long_time
|
||||
def setCurrentChoice(self, case):
|
||||
case = str(case)
|
||||
if not case == "":
|
||||
enkf_fs = self.ert().getEnkfFsManager().getFileSystem(case)
|
||||
if not enkf_fs is None:
|
||||
self.ert().getEnkfFsManager().switchFileSystem(enkf_fs)
|
||||
self.observable().notify(self.CURRENT_CHOICE_CHANGED_EVENT)
|
@ -1,43 +0,0 @@
|
||||
from ert.util import StringList, BoolVector
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.connectors.ensemble_resizer import EnsembleSizeModel
|
||||
from ert_gui.models.connectors.init import InitializationParametersModel, InitializationMembersModel
|
||||
from ert_gui.models.connectors.init.init_history_length import HistoryLengthModel
|
||||
from ert_gui.models.connectors.init.initialized_case_selector import InitializedCaseSelectorModel
|
||||
from ert_gui.models.mixins import ButtonModelMixin
|
||||
|
||||
|
||||
class InitializeFromExistingCaseModel(ErtConnector, ButtonModelMixin):
|
||||
|
||||
def __init__(self):
|
||||
InitializedCaseSelectorModel().observable().attach(InitializedCaseSelectorModel.CHOICE_LIST_CHANGED_EVENT, self.__caseChanged)
|
||||
super(InitializeFromExistingCaseModel, self).__init__()
|
||||
|
||||
def __caseChanged(self):
|
||||
self.observable().notify(ButtonModelMixin.BUTTON_STATE_CHANGED_EVENT)
|
||||
|
||||
def buttonTriggered(self):
|
||||
source_case = InitializedCaseSelectorModel().getCurrentChoice()
|
||||
source_report_step = HistoryLengthModel().getSpinnerValue()
|
||||
selected_members = InitializationMembersModel().getSelectedItems()
|
||||
total_member_count = EnsembleSizeModel().getSpinnerValue()
|
||||
|
||||
member_mask = BoolVector.createFromList(total_member_count, selected_members)
|
||||
selected_parameters = StringList((InitializationParametersModel()).getSelectedItems())
|
||||
|
||||
self.ert().getEnkfFsManager().customInitializeCurrentFromExistingCase(source_case, source_report_step, member_mask, selected_parameters)
|
||||
|
||||
self.observable().notify(ButtonModelMixin.BUTTON_TRIGGERED_EVENT)
|
||||
|
||||
def getButtonName(self):
|
||||
return "Initialize"
|
||||
|
||||
def buttonIsEnabled(self):
|
||||
return len(InitializedCaseSelectorModel().getChoices()) > 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
from ert.util import StringList
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.connectors.init import InitializationParametersModel, InitializationMembersModel
|
||||
from ert_gui.models.mixins import ButtonModelMixin
|
||||
|
||||
|
||||
class InitializeFromScratchModel(ErtConnector, ButtonModelMixin):
|
||||
|
||||
def buttonTriggered(self):
|
||||
selected_parameters = StringList((InitializationParametersModel()).getSelectedItems())
|
||||
members = (InitializationMembersModel()).getSelectedItems()
|
||||
|
||||
for member in members:
|
||||
member = int(member.strip())
|
||||
self.ert().getEnkfFsManager().initializeFromScratch(selected_parameters, member, member)
|
||||
|
||||
self.observable().notify(ButtonModelMixin.BUTTON_TRIGGERED_EVENT)
|
||||
|
||||
def getButtonName(self):
|
||||
return "Initialize"
|
||||
|
||||
def buttonIsEnabled(self):
|
||||
return True
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
from ert_gui.models.ert_connector import ErtConnector
|
||||
from ert_gui.models.mixins import SpinnerModelMixin
|
||||
|
||||
|
||||
class HistoryLengthModel(ErtConnector, SpinnerModelMixin):
|
||||
|
||||
def __init__(self):
|
||||
self.__value = self.getMaxValue()
|
||||
super(HistoryLengthModel, self).__init__()
|
||||
|
||||
#todo: notify when the history length changes...
|
||||
|
||||
def getMinValue(self):
|
||||
""" @rtype: int """
|
||||
return 0
|
||||
|
||||
def getMaxValue(self):
|
||||
""" @rtype: int """
|
||||
return self.getHistoryLength()
|
||||
|
||||
def getSpinnerValue(self):
|
||||
return self.__value
|
||||
|
||||
def setSpinnerValue(self, value):
|
||||
self.__value = value
|
||||
self.observable().notify(SpinnerModelMixin.SPINNER_VALUE_CHANGED_EVENT)
|
||||
|
||||
def setToMax(self):
|
||||
self.setSpinnerValue(self.getMaxValue())
|
||||
|
||||
def setToMin(self):
|
||||
self.setSpinnerValue(self.getMinValue())
|
||||
|
||||
def getHistoryLength(self):
|
||||
""" @rtype: int """
|
||||
return self.ert().getHistoryLength()
|
||||
|
||||
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.connectors.ensemble_resizer import EnsembleSizeModel
|
||||
from ert_gui.models.mixins import SelectableListModelMixin
|
||||
from ert.util import StringList
|
||||
|
||||
|
||||
class InitializationMembersModel(ErtConnector, SelectableListModelMixin):
|
||||
|
||||
|
||||
def __init__(self):
|
||||
EnsembleSizeModel().observable().attach(EnsembleSizeModel.SPINNER_VALUE_CHANGED_EVENT, self.__ensembleSizeChanged)
|
||||
super(InitializationMembersModel, self).__init__()
|
||||
|
||||
def __ensembleSizeChanged(self):
|
||||
self.observable().notify(SelectableListModelMixin.LIST_CHANGED_EVENT)
|
||||
self.observable().notify(SelectableListModelMixin.SELECTION_CHANGED_EVENT)
|
||||
|
||||
def getList(self):
|
||||
""" @rtype: StringList """
|
||||
size = EnsembleSizeModel().getSpinnerValue()
|
||||
return [str(num) for num in range(0, size)]
|
@ -1,13 +0,0 @@
|
||||
from ert.enkf.enums import EnkfVarType
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.mixins import SelectableListModelMixin
|
||||
from ert.util import StringList
|
||||
|
||||
|
||||
class InitializationParametersModel(ErtConnector, SelectableListModelMixin):
|
||||
|
||||
def getList(self):
|
||||
""" @rtype: StringList """
|
||||
return self.ert().ensembleConfig().getKeylistFromVarType(EnkfVarType.PARAMETER)
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert.util import StringList
|
||||
from ert_gui.models.connectors.init import CaseSelectorModel
|
||||
from ert_gui.models.connectors.init.case_list import CaseList
|
||||
from ert_gui.models.mixins import ChoiceModelMixin
|
||||
|
||||
|
||||
class InitializedCaseSelectorModel(ErtConnector, ChoiceModelMixin):
|
||||
""" Returns all initialized cases except the currently selected one. """
|
||||
|
||||
def __init__(self):
|
||||
self.__current_case = None
|
||||
self.__initialized_cases = []
|
||||
|
||||
CaseList().observable().attach(CaseList.LIST_CHANGED_EVENT, self.__caseListChanged)
|
||||
CaseSelectorModel().observable().attach(CaseSelectorModel.CURRENT_CHOICE_CHANGED_EVENT, self.__currentCaseChanged)
|
||||
self.__fetchCases()
|
||||
|
||||
super(InitializedCaseSelectorModel, self).__init__()
|
||||
|
||||
|
||||
def __fetchCases(self):
|
||||
self.__initialized_cases = []
|
||||
|
||||
for case in CaseList().getList():
|
||||
# print("%s %s %s" % (current_case, case, self.ert().isCaseInitialized(case)))
|
||||
# if case != current_case and self.ert().isCaseInitialized(case):
|
||||
if self.ert().getEnkfFsManager().isCaseInitialized(case):
|
||||
self.__initialized_cases.append(case)
|
||||
|
||||
def __caseListChanged(self):
|
||||
self.__fetchCases()
|
||||
|
||||
self.observable().notify(ChoiceModelMixin.CHOICE_LIST_CHANGED_EVENT)
|
||||
self.observable().notify(ChoiceModelMixin.CURRENT_CHOICE_CHANGED_EVENT)
|
||||
|
||||
def __currentCaseChanged(self):
|
||||
self.observable().notify(ChoiceModelMixin.CHOICE_LIST_CHANGED_EVENT)
|
||||
self.observable().notify(ChoiceModelMixin.CURRENT_CHOICE_CHANGED_EVENT)
|
||||
|
||||
|
||||
def getChoices(self):
|
||||
""" @rtype: StringList """
|
||||
copy = list(self.__initialized_cases)
|
||||
current_case = CaseSelectorModel().getCurrentChoice()
|
||||
|
||||
if current_case in copy:
|
||||
copy.remove(current_case)
|
||||
|
||||
return copy
|
||||
|
||||
def getCurrentChoice(self):
|
||||
""" @rtype: str """
|
||||
case_list = self.getChoices()
|
||||
|
||||
if self.__current_case is None:
|
||||
if len(case_list) > 0:
|
||||
self.__current_case = case_list[0]
|
||||
else:
|
||||
self.__current_case = None
|
||||
|
||||
if len(case_list) > 0 and not self.__current_case in case_list:
|
||||
self.__current_case = case_list[0]
|
||||
|
||||
return self.__current_case
|
||||
|
||||
def setCurrentChoice(self, case):
|
||||
self.__current_case = case
|
||||
self.observable().notify(self.CURRENT_CHOICE_CHANGED_EVENT)
|
@ -1,38 +0,0 @@
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.connectors.ensemble_resizer import EnsembleSizeModel
|
||||
from ert_gui.models.connectors.init import InitializeFromScratchModel, CaseSelectorModel
|
||||
from ert_gui.models.connectors.init.init_from_existing import InitializeFromExistingCaseModel
|
||||
from ert_gui.models.mixins import BooleanModelMixin, BasicModelMixin
|
||||
|
||||
|
||||
class IsCaseInitializedModel(ErtConnector, BooleanModelMixin, BasicModelMixin):
|
||||
|
||||
def __init__(self):
|
||||
CaseSelectorModel().observable().attach(CaseSelectorModel.CURRENT_CHOICE_CHANGED_EVENT, self.__caseChanged)
|
||||
EnsembleSizeModel().observable().attach(EnsembleSizeModel.SPINNER_VALUE_CHANGED_EVENT, self.__caseChanged)
|
||||
InitializeFromScratchModel().observable().attach(InitializeFromScratchModel.BUTTON_TRIGGERED_EVENT, self.__caseChanged)
|
||||
InitializeFromExistingCaseModel().observable().attach(InitializeFromScratchModel.BUTTON_TRIGGERED_EVENT, self.__caseChanged)
|
||||
|
||||
super(IsCaseInitializedModel, self).__init__()
|
||||
|
||||
def __caseChanged(self):
|
||||
self.observable().notify(IsCaseInitializedModel.BOOLEAN_VALUE_CHANGED_EVENT)
|
||||
self.observable().notify(IsCaseInitializedModel.VALUE_CHANGED_EVENT)
|
||||
|
||||
def getValue(self):
|
||||
"""
|
||||
A message saying if the case is not initialized. Returns an empty string if the case is initialized.
|
||||
@rtype: str
|
||||
"""
|
||||
if not self.isTrue():
|
||||
return "The current case is not initialized!"
|
||||
|
||||
return ""
|
||||
|
||||
def isTrue(self):
|
||||
"""
|
||||
True if the current case is initialized!
|
||||
@rtype: bool
|
||||
"""
|
||||
return self.ert().getEnkfFsManager().isInitialized()
|
||||
|
@ -1,7 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
load_results_model.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models.connectors.load_results" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/connectors/load_results "${PYTHON_SOURCES}" True)
|
||||
|
@ -1 +0,0 @@
|
||||
from .load_results_model import LoadResultsModel
|
@ -1,9 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
data_type_keys_model.py
|
||||
report_steps.py
|
||||
plot_settings.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models.connectors.plot" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/connectors/plot "${PYTHON_SOURCES}" True)
|
||||
|
@ -1,3 +0,0 @@
|
||||
from .data_type_keys_model import DataTypeKeysModel
|
||||
from .report_steps import ReportStepsModel
|
||||
from .plot_settings import PlotSettingsModel
|
@ -1,109 +0,0 @@
|
||||
from ert.enkf.enums import ErtImplType, EnkfObservationImplementationType
|
||||
from ert.enkf.plot import BlockObservationDataFetcher, EnsembleGenKWFetcher, EnsembleGenDataFetcher, ObservationGenDataFetcher, PcaDataFetcher
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.mixins.list_model import ListModelMixin
|
||||
|
||||
|
||||
class DataTypeKeysModel(ErtConnector, ListModelMixin):
|
||||
|
||||
def __init__(self):
|
||||
self.__keys = None
|
||||
self.__observation_keys = None
|
||||
self.__block_observation_keys = None
|
||||
self.__summary_keys = None
|
||||
self.__gen_kw_keys = None
|
||||
self.__gen_data_keys = None
|
||||
|
||||
self.__custom_pca_keys = {"PCA:All": PcaDataFetcher(self.ert()).getAllObsKeys()}
|
||||
super(DataTypeKeysModel, self).__init__()
|
||||
|
||||
|
||||
def getAllKeys(self):
|
||||
""" @rtype: list of str """
|
||||
keys = self.getAllSummaryKeys() + self.getAllBlockObservationKeys() + self.getAllGenKWKeys() + self.getAllGenDataKeys() + self.getCustomPcaKeys()
|
||||
# return sorted([key for key in keys], key=lambda k : k.lower())
|
||||
return keys
|
||||
|
||||
def getAllGenKWKeys(self):
|
||||
""" @rtype: list of str """
|
||||
if self.__gen_kw_keys is None:
|
||||
keys = EnsembleGenKWFetcher(self.ert()).getSupportedKeys()
|
||||
self.__gen_kw_keys = sorted(keys, key=lambda k : k.lower())
|
||||
|
||||
return self.__gen_kw_keys
|
||||
|
||||
def getAllGenDataKeys(self):
|
||||
""" @rtype: list of str """
|
||||
if self.__gen_data_keys is None:
|
||||
keys = ObservationGenDataFetcher(self.ert()).getSupportedKeys()
|
||||
self.__gen_data_keys = sorted(keys, key=lambda k : k.lower())
|
||||
|
||||
return self.__gen_data_keys
|
||||
|
||||
def getAllSummaryKeys(self):
|
||||
""" @rtype: list of str """
|
||||
if self.__summary_keys is None:
|
||||
keys = self.ert().ensembleConfig().getKeylistFromImplType(ErtImplType.SUMMARY)
|
||||
self.__summary_keys = sorted([key for key in keys], key=lambda k : k.lower())
|
||||
|
||||
return self.__summary_keys
|
||||
|
||||
def getAllBlockObservationKeys(self):
|
||||
""" @rtype: list of str """
|
||||
if self.__block_observation_keys is None:
|
||||
keys = BlockObservationDataFetcher(self.ert()).getSupportedKeys()
|
||||
self.__block_observation_keys = sorted(keys, key=lambda k : k.lower())
|
||||
|
||||
return self.__block_observation_keys
|
||||
|
||||
def getAllObservationSummaryKeys(self):
|
||||
""" @rtype: list of str """
|
||||
if self.__observation_keys is None:
|
||||
self.__observation_keys = [key for key in self.getAllSummaryKeys() if self.__isSummaryKeyObservationKey(key)]
|
||||
return self.__observation_keys
|
||||
|
||||
def getCustomPcaKeys(self):
|
||||
""" @rtype: list of str """
|
||||
return self.__custom_pca_keys.keys()
|
||||
|
||||
|
||||
def getList(self):
|
||||
""" @rtype: list of str """
|
||||
self.__keys = self.__keys or self.getAllKeys()
|
||||
return self.__keys
|
||||
|
||||
|
||||
def isObservationKey(self, item):
|
||||
""" @rtype: bool """
|
||||
if self.__observation_keys is None:
|
||||
self.getAllObservationSummaryKeys()
|
||||
|
||||
if self.__block_observation_keys is None:
|
||||
self.getAllBlockObservationKeys()
|
||||
|
||||
if self.__gen_data_keys is None:
|
||||
self.getAllGenDataKeys()
|
||||
|
||||
return item in self.__observation_keys or item in self.__block_observation_keys or item in self.__gen_data_keys
|
||||
|
||||
def __isSummaryKeyObservationKey(self, key):
|
||||
return len(self.ert().ensembleConfig().getNode(key).getObservationKeys()) > 0
|
||||
|
||||
def isSummaryKey(self, key):
|
||||
return key in self.__summary_keys
|
||||
|
||||
def isBlockKey(self, key):
|
||||
return key in self.__block_observation_keys
|
||||
|
||||
def isGenKWKey(self, key):
|
||||
return key in self.__gen_kw_keys
|
||||
|
||||
def isGenDataKey(self, key):
|
||||
return key in self.__gen_data_keys
|
||||
|
||||
def isCustomPcaKey(self, key):
|
||||
return key in self.__custom_pca_keys
|
||||
|
||||
def getCustomPcaKeyObsKeys(self, key):
|
||||
return self.__custom_pca_keys[key]
|
||||
|
@ -1,15 +0,0 @@
|
||||
import os
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.connectors.init.case_selector import CaseSelectorModel
|
||||
|
||||
|
||||
class PlotSettingsModel(ErtConnector):
|
||||
|
||||
def getDefaultPlotPath(self):
|
||||
""" @rtype: str """
|
||||
path = self.ert().plotConfig().getPath()
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
|
@ -1,41 +0,0 @@
|
||||
from ert_gui.models import ErtConnector
|
||||
from ert_gui.models.connectors.init.case_list import CaseList
|
||||
from ert_gui.models.mixins import ListModelMixin
|
||||
from ert.enkf.util import TimeMap
|
||||
|
||||
|
||||
class ReportStepsModel(ErtConnector, ListModelMixin):
|
||||
|
||||
def __init__(self):
|
||||
self.__time_map = None
|
||||
self.__report_steps = None
|
||||
super(ReportStepsModel, self).__init__()
|
||||
|
||||
|
||||
def getReportSteps(self):
|
||||
""" @rtype: TimeMap """
|
||||
if self.__time_map is None:
|
||||
case_list = CaseList().getAllCasesWithDataAndNotRunning()
|
||||
|
||||
for case in case_list:
|
||||
time_map = self.ert().getEnkfFsManager().getTimeMapForCase(case)
|
||||
|
||||
if len(time_map) > 0:
|
||||
self.__time_map = time_map
|
||||
|
||||
if self.__time_map is None:
|
||||
self.__time_map = []
|
||||
|
||||
return self.__time_map
|
||||
|
||||
|
||||
def getList(self):
|
||||
""" @rtype: list of CTime """
|
||||
|
||||
time_list = [c_time for c_time in self.getReportSteps()]
|
||||
if len(time_list) > 0:
|
||||
time_list = time_list[1:]
|
||||
return time_list
|
||||
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
set(PYTHON_SOURCES
|
||||
__init__.py
|
||||
local_max_running.py
|
||||
lsf_max_running.py
|
||||
lsf_queue.py
|
||||
lsf_request.py
|
||||
queue_system_selector.py
|
||||
rsh_command.py
|
||||
rsh_host_list.py
|
||||
rsh_max_running.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert_gui.models.connectors.queue_system" ${PYTHON_INSTALL_PREFIX}/ert_gui/models/connectors/queue_system "${PYTHON_SOURCES}" True)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user