MswRollUp: Updated Ert to commit 1fea6b00f3 master Fixed an Api change

This is an intermediate commit and does not compile
p4#: 22222
This commit is contained in:
Jacob Støren 2013-08-26 14:44:03 +02:00
parent 441ac1e3d9
commit d7d5d2942b
335 changed files with 10440 additions and 5876 deletions

View File

@ -155,7 +155,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, localCellIdx);
if (subGrid != NULL)
{
int subGridFileIndex = ecl_grid_get_grid_nr(subGrid);
int subGridFileIndex = ecl_grid_get_lgr_nr(subGrid);
CVF_ASSERT(subGridFileIndex > 0);
cell.setSubGrid(static_cast<RigLocalGrid*>(mainGrid->gridByIndex(subGridFileIndex)));
}

23
ThirdParty/Ert/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
*.o
*.so
.svn/
*/.svn/
*.pyc
*~
# /devel/libenkf/src/
/devel/libenkf/src/.faultlist
# /develbranch/libenkf/src/
/develbranch/libenkf/src/.faultlist
# Ignore build catalog
/build
# Ignore pdf from tex-test
/devel/libert_util/tests/data/latex_OK.pdf
# Ignore Statoil test data
/devel/test-data/Statoil
# Ignore the ert_local python file which is needed to run some python tests
/devel/python/python/ert/ecl/ecl_local.py

110
ThirdParty/Ert/README vendored
View File

@ -207,57 +207,45 @@ in the devel/python/docs directory and in the Python classes
themselves.
5. Testing
5. Test
The ERT is very weak on tests, but that is being improved. There are two different
categories of tests:
CMake tests: CMake has a system for adding and running tests, and
these can be invoked with the command 'make test' after the
normal build process has completed, or alternatively the
'ctest' test-runner which allows more options on which tests to run.
The ert codebase has a small but increasing test coverage. The tests
are typically located in a per-library subdirectory tests/. The test
framework is based on ctest which basically works like this:
Python test: The python directory devel/python/test has several
python unittests. These tests test both the Python wrappers
and the underlying C code and serve as quite good integration
tests. Read the content of devel/python/test/README carfully
before you invoke the Python tests, you might have to update
the local_(csh|bash) scripts to reflect your build output
path.
1. In the CMakeLists.txt file testing is enabled with
ENABLE_TESTING().
2. Tests are added with:
5.1 Test data & labels
add_test( test_name test_executable arg1 arg2 arg3 ... )
Unfortunately a large fraction of the test data is based on Statoil
internal data, and is not available on GitHub. All the tests which are
based on Statoil internal test data are labeled with the label
'Statoil', and using the 'ctest' program you can use the -L and -LE
options to include/exclude tests based on their label.
If the executable exits with status 0 the test has passed,
otherwise it has failed. The executable run by the test can
typically be an executable built as part of the solution, but can
in principle be an arbitrary executable like a dedicated test
runner or e.g. the Python interpreter.
ctest -L Statoil # Run all the tests with the 'Statoil' label
ctest -LE Statoil # Run all the tests without the 'Statoil' label
5.1 Test of C code
The argument to the -L and -LE options are regular expressions,
i.e. in the case above all tests which have a label matching the
regexp 'Statoil' will be run. A test can only have one single label,
but due to to the regexp mechanism we can create a 'list-like'
structure by chaining labels together; by convention the label
elements are joined with ':'. In the example
The main part of the testing infrastructure is small C applications
which are added like this:
set_property( TEST test_name PROPERTY LABELS Statoil:Python )
add_executable( test_exe test_source.c )
target_link_libraries( test_exe lib )
add_test( test_name ${EXECUTABLE_OUTPUT_PATH}/test_exe commandline_arg1 commandline_arg2 )
the labels 'Statoil' and 'Python' are applied to the test. The labels
in use are:
Where the two first lines create the test executable in the normal
way, and the last line adds it as a test.
Statoil: This indicates that the test makes use of Statoil internal
test data, and will fail if the Statoil test data have not
been made available according to the description in
devel/test-data/README.txt
5.2 Test of Python Code
Python: This indicates that the test is a Python unittest, and the
Python interpreter will be the test runner for the test.
In devel/python/test there are several files with Python tests, these
files are executable files and they are invoked directly from the
commandline. A limited number of the tests have been integrated in the
ctest system.
5.2 Test names
5.3 Test names
The tests in the cmake build system follow the naming convention of
the library which functionality they are testing - i.e. all tests in
@ -269,5 +257,45 @@ can be used to include and exclude tests based on their name
ctest -E ecl # Run all tests NOT matching the regexp 'ecl'
The python tests are not yet integrated into this convention....
5.4 Test labels
Using the cmake set_property() function it is possible to assigne
labels to the test, and the -L and -LE options to ctest can be used to
limit which tests to run. A test can only have one label; in the
current ctest setup different labels are combined into one composite
label with a ":" separator, i.e.
set_property( TEST test_xxx PROPERTY LABELS StatoilData:Python)
will set the 'StatoilData' and 'Python' properties on test_xxx. The
labels currently maintained in the ert test setup are:
StatoilData: This implies that the test makes use of Statoil
internal data. If you are in Statoil/Bergen you can see more
details in file devel/test-data/README for how to make this data
available.
If you are not in Statoil/Bergen you must pass the option: "-EL
StatoilData" to ctest to skip all the tests which require
Statoil data.
StatoilBuild: There is one python test which makes use of Statoil
internal configuration data, this test is labeled with
StatoilBuild. If you want to run this test you must set the
cmake option ECL_LOCAL_TARGET to point to a file which contains
some local configuration settings, e.g. where the ECLIPSE binary
is installed.
Python: This label is used to indicate that we are talking about a
Python test.
LSF: This labels indicates that the test needs a working LSF
environment to run.
ctest -L Statoil # Run all tests labeled with Statoil - both
# StatoilData and StatoilBuild
ctest -EL "Statoil|LSF" # Exclude all tests labeled with Statoil or LSF.

View File

@ -1,3 +0,0 @@
/lib/
ert_build_config.h
*_vector.[ch]

View File

@ -22,21 +22,24 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(ERT_WINDOWS TRUE)
add_definitions( -DERT_WINDOWS )
# This symbol must be defined to support large (> 2GB) files on windows.
add_definitions( -DWINDOWS_LFS )
endif()
# Treat warnings as errors if not on Windows
if (ERT_WINDOWS)
set( CMAKE_C_FLAGS "-O2" )
set( CMAKE_CXX_FLAGS "-O2" )
else()
set( CMAKE_C_FLAGS "-g -O2 -Wall -Wno-unknown-pragmas -std=gnu99 " )
set( CMAKE_CXX_FLAGS "-g -O2 -Wall" )
set( CMAKE_C_FLAGS "-std=gnu99 -g -O2 -Wall -Wno-unknown-pragmas " )
set( CMAKE_CXX_FLAGS "-g -Wall -O2 ")
endif()
include(cmake/ert_check.cmake)
include(cmake/ert_find.cmake)
include(cmake/Modules/UseMultiArch.cmake)
include(cmake/ert_link.cmake)
set( INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
@ -46,15 +49,9 @@ if (MSVC)
set( LIBRARY_TYPE STATIC )
set( SHARED_LIB OFF )
else()
if (INSTALL_ERT)
set( LIBRARY_TYPE SHARED )
set( SHARED_LIB ON )
else()
set( LIBRARY_TYPE STATIC )
set( SHARED_LIB OFF )
endif(INSTALL_ERT)
endif(MSVC)
endif()
if (MSVC)

View File

@ -1,3 +1,8 @@
check_function_exists( fseeko HAVE_FSEEKO )
if (HAVE_HFSEEKO)
add_definitions( -DHAVE_FSEEKO )
endif()
check_function_exists( regexec HAVE_REGEXP )
if (HAVE_REGEXP)
add_definitions( -DHAVE_REGEXP )
@ -84,6 +89,16 @@ if (HAVE_OPENDIR)
add_definitions( -DHAVE__USLEEP )
endif()
# Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags.
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 "")
endif()
try_compile( HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c )
if (HAVE_ISFINITE)
add_definitions( -DHAVE_ISFINITE )
@ -110,3 +125,5 @@ if (ISREG_POSIX)
add_definitions( -DHAVE_ISREG )
endif()
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )

View File

@ -0,0 +1,14 @@
if (CMAKE_COMPILER_IS_GNUCC)
option (USE_RUNPATH "Embed original dependency paths in installed library" OFF)
if (USE_RUNPATH)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif (USE_RUNPATH)
else()
set(USE_RUNPATH OFF)
endif()
macro( add_runpath target )
set_target_properties( ${target} PROPERTIES LINK_FLAGS -Wl,--enable-new-dtags)
endmacro()

View File

@ -10,7 +10,9 @@ if (NEED_LIBDL)
target_link_libraries( analysis dl )
endif()
if (USE_RUNPATH)
add_runpath( analysis )
endif()
# List of modules
set( CMAKE_SHARED_MODULE_PREFIX "" )

View File

@ -1,2 +1,4 @@
add_subdirectory( src )
add_subdirectory( tests )
if (BUILD_TESTS)
add_subdirectory( tests )
endif()

View File

@ -5,6 +5,9 @@ add_library( config ${LIBRARY_TYPE} ${source_files} )
set_target_properties( config PROPERTIES VERSION 1.0 SOVERSION 1.0 )
target_link_libraries( config ert_util )
if (USE_RUNPATH)
add_runpath( config )
endif()
if (INSTALL_ERT)
install(TARGETS config DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -1,44 +1,44 @@
add_executable( config_append_test config_append_test.c )
target_link_libraries( config_append_test config )
target_link_libraries( config_append_test config test_util )
add_executable( config_node_test config_node_test.c )
target_link_libraries( config_node_test config )
target_link_libraries( config_node_test config test_util )
add_executable( config_typeOK config_typeOK.c )
target_link_libraries( config_typeOK config )
target_link_libraries( config_typeOK config test_util )
add_executable( config_typeFail config_typeFail.c )
target_link_libraries( config_typeFail config )
target_link_libraries( config_typeFail config test_util )
add_executable( config_path_elm config_path_elm.c )
target_link_libraries( config_path_elm config )
target_link_libraries( config_path_elm config test_util )
add_executable( config_root_path config_root_path.c )
target_link_libraries( config_root_path config )
target_link_libraries( config_root_path config test_util )
add_executable( config_include_test config_include_test.c)
target_link_libraries( config_include_test config)
target_link_libraries( config_include_test config test_util )
add_executable( config_content_node config_content_node.c)
target_link_libraries( config_content_node config)
target_link_libraries( config_content_node config test_util )
add_executable( config_content_item config_content_item.c)
target_link_libraries( config_content_item config)
target_link_libraries( config_content_item config test_util )
add_executable( config_argc config_argc.c)
target_link_libraries( config_argc config)
target_link_libraries( config_argc config test_util )
add_executable( config_error config_error.c)
target_link_libraries( config_error config)
target_link_libraries( config_error config test_util )
add_test( config_error ${EXECUTABLE_OUTPUT_PATH}/config_error )
add_executable( config_config config_config.c)
target_link_libraries( config_config config)
target_link_libraries( config_config config test_util )
add_test( config_config ${EXECUTABLE_OUTPUT_PATH}/config_config )
add_executable( config_schema_item config_schema_item.c)
target_link_libraries( config_schema_item config)
target_link_libraries( config_schema_item config test_util )
add_test( config_schema_item ${EXECUTABLE_OUTPUT_PATH}/config_schema_item )
add_test( config_typeOK ${EXECUTABLE_OUTPUT_PATH}/config_typeOK ${CMAKE_CURRENT_SOURCE_DIR}/data/type_testOK )

View File

@ -22,6 +22,7 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/config/config.h>
#include <ert/config/config_path_elm.h>
@ -29,17 +30,19 @@
int main(int argc , char ** argv) {
#ifdef ERT_LINUX
const char * root = "/tmp/root";
const char * rel_path = "rel/path";
const char * abs_path = "/tmp/root/rel/path";
const char * rel_true = "rel/path/XXX";
const char * abs_true = "/tmp/root/rel/path/XXX";
const char * path_true1 = "rel/path/XXX";
const char * path_true2 = "/tmp/root/rel/path/XXX";
#endif
util_make_path( root );
test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" , true );
const char * root = test_work_area_get_cwd( work_area );
char * abs_path = util_alloc_filename( root , "rel/path" , NULL);
char * abs_true = util_alloc_filename( root , "rel/path/XXX" , NULL);
char * path_true2 = util_alloc_filename( root , "rel/path/XXX" , NULL);
chdir( test_work_area_get_original_cwd( work_area ));
config_root_path_type * root_path = config_root_path_alloc( root );
{
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
@ -54,7 +57,6 @@ int main(int argc , char ** argv) {
config_path_elm_free( path_elm );
}
printf("test1 OK \n");
{
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , abs_path );
@ -67,7 +69,6 @@ int main(int argc , char ** argv) {
config_path_elm_free( path_elm );
}
printf("test2 OK \n");
config_root_path_free( root_path );
chdir( root );
@ -85,7 +86,6 @@ int main(int argc , char ** argv) {
config_path_elm_free( path_elm );
}
printf("test3 OK \n");
exit(0);
}

View File

@ -32,13 +32,13 @@ int main(int argc , char ** argv) {
{
config_root_path_type * root_path = config_root_path_alloc( NULL );
if (!test_string_equal( config_root_path_get_abs_path( root_path ) , cwd ))
if (!test_check_string_equal( config_root_path_get_abs_path( root_path ) , cwd ))
test_error_exit("abs:path:%s expeceted:%s \n",config_root_path_get_abs_path( root_path ) , cwd );
if (!test_string_equal( config_root_path_get_input_path( root_path ) , NULL ))
if (!test_check_string_equal( config_root_path_get_input_path( root_path ) , NULL ))
test_error_exit("input:path:%s expeceted:%s \n",config_root_path_get_input_path( root_path ) , NULL );
if (!test_string_equal( config_root_path_get_rel_path( root_path ) , NULL ))
if (!test_check_string_equal( config_root_path_get_rel_path( root_path ) , NULL ))
test_error_exit("rel:path:%s expeceted:%s \n",config_root_path_get_rel_path( root_path ) , NULL );
@ -62,10 +62,10 @@ int main(int argc , char ** argv) {
config_root_path_type * root_path1 = config_root_path_alloc( input_path );
config_root_path_type * root_path2 = config_root_path_alloc( rel_path );
if (!test_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 )))
if (!test_check_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 )))
test_error_exit("Rel: %s != %s \n",config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2));
if (!test_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )))
if (!test_check_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )))
test_error_exit("Abs: %s != %s \n",config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 ));
config_root_path_free( root_path1 );

View File

@ -1,10 +1,5 @@
add_subdirectory( src )
#if (BUILD_APPLICATIONS OR BUILD_ECL_SUMMARY)
# add_subdirectory( applications )
#endif()
add_subdirectory( applications )
if (BUILD_TESTS)
add_subdirectory( tests )
endif()
add_subdirectory( tests )

View File

@ -35,7 +35,10 @@ if (BUILD_APPLICATIONS)
foreach(prog ${program_list})
target_link_libraries( ${prog} ecl ert_util )
if (USE_RUNPATH)
add_runpath( ${prog} )
endif()
#-----------------------------------------------------------------
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)
@ -52,6 +55,9 @@ if (BUILD_ENS_PLOT)
include_directories( ${PLPLOT_HEADER} )
add_executable( ens_plot.x ens_plot.c )
target_link_libraries( ens_plot.x plot ecl)
if (USE_RUNPATH)
add_runpath( ens_plot.x )
endif()
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)
@ -68,6 +74,9 @@ endif()
if (BUILD_ECL_SUMMARY)
add_executable( ecl_summary view_summary.c )
target_link_libraries( ecl_summary ecl)
if (USE_RUNPATH)
add_runpath( ecl_summary )
endif()
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)

View File

@ -25,6 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/fortio.h>
@ -35,7 +37,7 @@ typedef struct inv_map_struct inv_map_type;
ecl_file_kw_type * inv_map_get_file_kw( inv_map_type * inv_map , const ecl_kw_type * ecl_kw );
void inv_map_free( inv_map_type * map );
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , long offset);
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , offset_type offset);
void ecl_file_kw_free( ecl_file_kw_type * file_kw );
void ecl_file_kw_free__( void * arg );
ecl_kw_type * ecl_file_kw_get_kw( ecl_file_kw_type * file_kw , fortio_type * fortio, inv_map_type * inv_map);

View File

@ -30,9 +30,10 @@ extern "C" {
#include <ert/ecl/ecl_coarse_cell.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/grid_dims.h>
#include <ert/ecl/nnc_info.h>
#define ECL_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids.
#define ECL_GRID_MAINGRID_LGR_NR 0
typedef double (block_function_ftype) ( const double_vector_type *);
typedef struct ecl_grid_struct ecl_grid_type;
@ -77,6 +78,10 @@ extern "C" {
int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index);
int ecl_grid_get_global_index1F(const ecl_grid_type * ecl_grid , int active_fracture_index);
const int_vector_type * ecl_grid_get_nnc_index_list( ecl_grid_type * grid );
const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k);
const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index);
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes);
@ -85,7 +90,7 @@ extern "C" {
ecl_grid_type * ecl_grid_load_case( const char * case_input );
ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum);
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum);
bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input );
@ -132,17 +137,19 @@ extern "C" {
void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream);
void ecl_grid_dump_ascii(const ecl_grid_type * grid , bool active_only , FILE * stream);
/* lgr related functions */
const ecl_grid_type * ecl_grid_get_cell_lgr3(const ecl_grid_type * grid , int i, int j , int k);
const ecl_grid_type * ecl_grid_get_cell_lgr1A(const ecl_grid_type * grid , int active_index);
const ecl_grid_type * ecl_grid_get_cell_lgr1(const ecl_grid_type * grid , int global_index );
int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid );
int ecl_grid_get_grid_nr( const ecl_grid_type * ecl_grid );
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_nr);
int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid );
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_index);
ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, int lgr_nr);
ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr);
const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_index);
const char * ecl_grid_get_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr);
stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid);
int ecl_grid_get_parent_cell1( const ecl_grid_type * grid , int global_index);
int ecl_grid_get_parent_cell3( const ecl_grid_type * grid , int i , int j , int k);

View File

@ -232,6 +232,7 @@ extern "C" {
#define CONORAT_KW "CONORAT" /* Oil ... */
#define CONPRES_KW "CONPRES" /* Pressure ... */
#define CONLENST_KW "CONLENST" /* Length along MSW well */
#define CONLENEN_KW "CONLENEN" /* Length to connection end for MSW well */
#define CONVTUB_KW "CONVTUB" /* Volumetric flow at tubing head conditions. */
#define CONOTUB_KW "CONOTUB" /* Volumetric oil flow at tubing head conditions. */
#define CONGTUB_KW "CONGTUB" /* Volumetric gas flow at tubing head conditions. */
@ -269,7 +270,20 @@ extern "C" {
the second element will be the name of the parent. */
#define MAPUNITS_KW "MAPUNITS"
#define GRIDUNIT_KW "GRIDUNIT"
#define NNCHEAD_KW "NNCHEAD" /*Non-neighbour connection header*/
#define NNC1_KW "NNC1" /*Upstream cell numbers for non-neighbour connections*/
#define NNC2_KW "NNC2" /*Downstream cell numbers for non-neighbour connections*/
#define NNCL_KW "NNCL" /*Cell numbers for LGR cells that are connected to global grid cells*/
#define NNCG_KW "NNCG" /*Cell numbers for global cells connected to LGR cells*/
#define NNCHEAD_NUMNNC_INDEX 0 /*Item 1 in non-neighbour connection header: number of NNCs. Only present for main grid*/
#define NNCHEAD_LGR_INDEX 1 /*Item 2 in non-neighbour connection header: LGR number (0 for global grid)*/
#define NNCHEADA_KW "NNCHEADA" /*Header for NNC's between two amalgamated LGRs*/
#define NNA1_KW "NNA1" /*Cell numbers in connecting local grid ILOC1*/
#define NNA2_KW "NNA2" /*Cell numbers in connecting local grid ILOC2*/
#define NNCHEADA_ILOC1_INDEX 0 /*ILOC1: Index of first LGR*/
#define NNCHEADA_ILOC2_INDEX 1 /*ILOC2: Index of second LGR*/
#define NNA_NUMNNC_INDEX 0 /*Item 1 in NNA1 or NNA2 is number of NNCs*/
/* EGRID keywords */
#define LGR_PARENT_KW "LGRPARNT" /* The name of the parent for an LGR. */
@ -282,7 +296,7 @@ extern "C" {
#define ENDGRID_KW "ENDGRID"
#define ENDLGR_KW "ENDLGR"
#define CORSNUM_KW "CORSNUM"
/* GRID keywords */
#define GRIDHEAD_KW "GRIDHEAD" /* Header information for GRID files. */
#define COORD_KW "COORD" /* Header information for one cell in GRID file. */
@ -298,7 +312,7 @@ extern "C" {
#define GRIDHEAD_NZ_INDEX 3
#define GRIDHEAD_LGR_INDEX 4
#define GRIDHEAD_SIZE 100
/* Observe that these indices are one value lower than the values used
in the ecl_smspec file. */
#define DIMENS_NX_INDEX 0

View File

@ -42,6 +42,7 @@ UTIL_IS_INSTANCE_HEADER( ecl_rft_cell );
double grat ,
double wrat ,
double connection_start,
double connection_end,
double flowrate,
double oil_flowrate,
double gas_flowrate,
@ -67,6 +68,7 @@ UTIL_IS_INSTANCE_HEADER( ecl_rft_cell );
double ecl_rft_cell_get_grat( const ecl_rft_cell_type * cell );
double ecl_rft_cell_get_orat( const ecl_rft_cell_type * cell );
double ecl_rft_cell_get_connection_start( const ecl_rft_cell_type * cell );
double ecl_rft_cell_get_connection_end( const ecl_rft_cell_type * cell );
double ecl_rft_cell_get_flowrate( const ecl_rft_cell_type * cell );
double ecl_rft_cell_get_oil_flowrate( const ecl_rft_cell_type * cell );
double ecl_rft_cell_get_gas_flowrate( const ecl_rft_cell_type * cell );

View File

@ -87,7 +87,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
const smspec_node_type * ecl_smspec_get_block_var_node(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
int ecl_smspec_get_block_var_params_index(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
const smspec_node_type * ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);

View File

@ -202,6 +202,9 @@ typedef struct ecl_sum_struct ecl_sum_type;
bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well);
char * ecl_sum_alloc_well_key( const ecl_sum_type * ecl_sum , const char * keyword , const char * wgname);
bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
UTIL_IS_INSTANCE_HEADER( ecl_sum );
#ifdef __cplusplus

View File

@ -83,6 +83,8 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ;
int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_step );
int ecl_sum_data_iget_report_start( const ecl_sum_data_type * data , int report_step );
ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_days);
bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2);
bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2);
#ifdef __cplusplus
}

View File

@ -51,6 +51,7 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type;
void ecl_sum_tstep_iset( ecl_sum_tstep_type * tstep , int index , float value);
void ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node , float value);
void ecl_sum_tstep_set_from_key( ecl_sum_tstep_type * tstep , const char * gen_key , float value);
bool ecl_sum_tstep_sim_time_equal( const ecl_sum_tstep_type * tstep1 , const ecl_sum_tstep_type * tstep2 );
UTIL_SAFE_CAST_HEADER( ecl_sum_tstep );
UTIL_SAFE_CAST_HEADER_CONST( ecl_sum_tstep );

View File

@ -26,6 +26,8 @@ extern "C" {
#include <stdio.h>
#include <stdbool.h>
#include <ert/util/util.h>
typedef enum {
FORTIO_NOENTRY = 0, /* File does not exists at all - application error. */
FORTIO_EOF = 1, /* The file / record is empty */
@ -66,8 +68,8 @@ typedef struct fortio_struct fortio_type;
void fortio_rewind(const fortio_type *fortio);
const char * fortio_filename_ref(const fortio_type * );
bool fortio_fmt_file(const fortio_type *);
long fortio_ftell( const fortio_type * fortio );
int fortio_fseek( fortio_type * fortio , long offset , int whence);
offset_type fortio_ftell( const fortio_type * fortio );
int fortio_fseek( fortio_type * fortio , offset_type offset , int whence);
int fortio_fileno( fortio_type * fortio );
bool fortio_fclose_stream( fortio_type * fortio );

View File

@ -0,0 +1,42 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_index_list.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 __NNC_INDEX_LIST_H__
#define __NNC_INDEX_LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
typedef struct nnc_index_list_struct nnc_index_list_type;
UTIL_IS_INSTANCE_HEADER(nnc_index_list);
nnc_index_list_type * nnc_index_list_alloc();
void nnc_index_list_free( nnc_index_list_type * index_list );
void nnc_index_list_add_index(nnc_index_list_type * index_list , int index);
const int_vector_type * nnc_index_list_get_list(nnc_index_list_type * index_list);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,55 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_info.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 __NNC_INFO_H__
#define __NNC_INFO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_vector.h>
typedef struct nnc_info_struct nnc_info_type;
UTIL_IS_INSTANCE_HEADER(nnc_info);
nnc_info_type * nnc_info_alloc(int lgr_nr);
void nnc_info_free( nnc_info_type * nnc_info );
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number);
const int_vector_type * nnc_info_iget_index_list(const nnc_info_type * nnc_info, int lgr_index);
nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index);
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr);
nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_nr);
const int_vector_type * nnc_info_get_self_index_list(const nnc_info_type * nnc_info);
nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info );
int nnc_info_get_lgr_nr(const nnc_info_type * nnc_info );
int nnc_info_get_size( const nnc_info_type * nnc_info );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,44 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_vector.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 __NNC_VECTOR_H__
#define __NNC_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
typedef struct nnc_vector_struct nnc_vector_type;
UTIL_IS_INSTANCE_HEADER(nnc_vector);
nnc_vector_type * nnc_vector_alloc(int lgr_nr);
void nnc_vector_free( nnc_vector_type * nnc_vector );
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number);
const int_vector_type * nnc_vector_get_index_list(const nnc_vector_type * nnc_vector);
int nnc_vector_get_lgr_nr(const nnc_vector_type * nnc_vector );
void nnc_vector_free__(void * arg);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -61,6 +61,8 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
char * smspec_alloc_group_key( const char * join_string , const char * keyword , const char * wgname);
char * smspec_alloc_well_key( const char * join_string , const char * keyword , const char * wgname);
char * smspec_alloc_region_key( const char * join_string , const char * keyword , int num);
char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2);
char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num);
char * smspec_alloc_segment_key( const char * join_string , const char * keyword , const char * wgname , int num);
char * smspec_alloc_block_num_key( const char * join_string , const char * keyword , int num);
char * smspec_alloc_local_well_key( const char * join_string , const char * keyword , const char * lgr_name , const char * wgname);

View File

@ -2,14 +2,17 @@ include_directories( ext )
file(GLOB ext_source "ext/*.c" )
file(GLOB ext_header "ext/*.h" )
set( source_files ecl_rsthead.c ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_rft_cell.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_subsidence.c ecl_grid_dims.c grid_dims.c ecl_grav_common.c ${ext_source})
set( source_files ecl_rsthead.c ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_rft_cell.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_subsidence.c ecl_grid_dims.c grid_dims.c nnc_info.c ecl_grav_common.c nnc_vector.c nnc_index_list.c ${ext_source})
set( header_files ecl_rsthead.h ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_rft_cell.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_kw_magic.h ecl_subsidence.h ecl_grid_dims.h grid_dims.h ${ext_header} ecl_grav_common.h)
set( header_files ecl_rsthead.h ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_rft_cell.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_kw_magic.h ecl_subsidence.h ecl_grid_dims.h grid_dims.h nnc_info.h nnc_vector.h ${ext_header} ecl_grav_common.h nnc_index_list.h)
add_library( ecl ${LIBRARY_TYPE} ${source_files} )
set_target_properties( ecl PROPERTIES VERSION 1.0 SOVERSION 1.0 )
if (USE_RUNPATH)
add_runpath( ecl )
endif()
#-----------------------------------------------------------------
set( OPENMP OFF )

View File

@ -823,7 +823,7 @@ static void ecl_file_scan( ecl_file_type * ecl_file ) {
fortio_fseek( ecl_file->fortio , 0 , SEEK_SET );
{
ecl_kw_type * work_kw = ecl_kw_alloc_new("WORK-KW" , 0 , ECL_INT_TYPE , NULL);
long current_offset;
offset_type current_offset;
while (true) {
current_offset = fortio_ftell( ecl_file->fortio );
if (ecl_kw_fread_header( work_kw , ecl_file->fortio )) {

View File

@ -56,7 +56,7 @@ struct inv_map_struct {
struct ecl_file_kw_struct {
UTIL_TYPE_ID_DECLARATION;
long file_offset;
offset_type file_offset;
ecl_type_enum ecl_type;
int kw_size;
char * header;
@ -135,7 +135,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file_kw , ECL_FILE_KW_TYPE_ID )
static ecl_file_kw_type * ecl_file_kw_alloc__( const char * header , ecl_type_enum ecl_type , int size , long offset) {
static ecl_file_kw_type * ecl_file_kw_alloc__( const char * header , ecl_type_enum ecl_type , int size , offset_type offset) {
ecl_file_kw_type * file_kw = util_malloc( sizeof * file_kw );
UTIL_TYPE_ID_INIT( file_kw , ECL_FILE_KW_TYPE_ID );
@ -160,7 +160,7 @@ static ecl_file_kw_type * ecl_file_kw_alloc__( const char * header , ecl_type_en
access the ecl_file_kw instances.
*/
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , long offset ) {
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , offset_type offset ) {
return ecl_file_kw_alloc__( ecl_kw_get_header( ecl_kw ) , ecl_kw_get_type( ecl_kw ) , ecl_kw_get_size( ecl_kw ) , offset );
}

View File

@ -39,7 +39,8 @@
#include <ert/ecl/point.h>
#include <ert/ecl/tetrahedron.h>
#include <ert/ecl/grid_dims.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_index_list.h>
/*
If openmp is enabled the main loop in ecl_grid_init_GRDECL_data is
@ -358,6 +359,73 @@
*/
/*
About nnc
---------
When loading a grid file the various NNC related keywords are read
in to assemble information of the NNC. The NNC information is
organized as follows:
1. The field nnc_index_list is a thin wrapper around a int_vector
instance which will return a sorted list of indicies of cells
which have attached NNC information.
2. For cells with NNC's attached the information is kept in a
nnc_info_type structure. For a particular cell the nnc_info
structure keeps track of which other cells this particular cell
is connected to, on a per grid (i.e. LGR) basis.
In the nnc_info structure the different grids are identified
through the lgr_nr.
Example usage:
--------------
ecl_grid_type * grid = ecl_grid_alloc("FILE.EGRID");
// Get a int_vector instance with all the cells which have nnc info
// attached.
const int_vector_type * cells_with_nnc = ecl_grid_get_nnc_index_list( grid );
// Iterate over all the cells with nnc info:
for (int i=0; i < int_vector_size( cells_with_nnc ); i++) {
int cell_index = int_vector_iget( cells_with_nnc , i);
const nnc_info_type * nnc_info = ecl_grid_get_nnc_info1( grid , cell_index);
// Get all the nnc connections from @cell_index to other cells in the same grid
{
const int_vector_type * nnc_list = nnc_info_get_self_index_list( nnc_info );
for (int j=0; j < int_vector_size( nnc_list ); j++)
printf("Cell[%d] -> %d in the same grid \n",cell_index , int_vector_iget(nnc_list , j));
}
{
for (int lgr_index=0; lgr_index < nnc_info_get_size( nnc_info ); lgr_index++) {
nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index );
int lgr_nr = nnc_vector_get_lgr_nr( nnc_vector );
if (lgr_nr != nnc_info_get_lgr_nr( nnc_info )) {
const int_vector_type * nnc_list = nnc_vector_get_index_list( nnc_vector );
for (int j=0; j < int_vector_size( nnc_list ); j++)
printf("Cell[%d] -> %d in lgr:%d/%s \n",cell_index , int_vector_iget(nnc_list , j) , lgr_nr , ecl_grid_get_lgr_name(ecl_grid , lgr_nr));
}
}
}
}
Dual porosity and nnc: In ECLIPSE the connection between the matrix
properties and the fracture properties in a cell is implemented as a
nnc where the fracture cell has global index in the range [nx*ny*nz,
2*nz*ny*nz). In ert we we have not implemented this double covering
in the case of dual porosity models, and therefor NNC involving
fracture cells are not considered.
*/
/*
about tetraheder decomposition
@ -467,6 +535,7 @@ struct ecl_cell_struct {
int host_cell; /* the global index of the host cell for an lgr cell, set to -1 for normal cells. */
int coarse_group; /* The index of the coarse group holding this cell -1 for non-coarsened cells. */
int cell_flags;
nnc_info_type * nnc_info; /* Non-neighbour connection info*/
};
@ -476,7 +545,8 @@ struct ecl_cell_struct {
struct ecl_grid_struct {
UTIL_TYPE_ID_DECLARATION;
int grid_nr; /* this corresponds to item 4 in gridhead - 0 for the main grid. */
int lgr_nr; /* EGRID files: corresponds to item 4 in gridhead - 0 for the main grid.
GRID files: 0 for the main grid, then 1 -> number of LGRs in order read from file*/
char * name; /* the name of the file for the main grid - name of the lgr for lgrs. */
int ny,nz,nx;
int size; /* == nx*ny*nz */
@ -488,6 +558,7 @@ struct ecl_grid_struct {
int * fracture_index_map; /* For fractures: this a list of nx*ny*nz elements, where value -1 means inactive cell .*/
int * inv_fracture_index_map; /* For fractures: this is list of total_active elements - which point back to the index_map. */
nnc_index_list_type * nnc_index_list;
#ifdef LARGE_CELL_MALLOC
ecl_cell_type * cells;
@ -506,9 +577,10 @@ struct ecl_grid_struct {
/*
the two fields below are for *storing* lgr grid instances. observe
that these fields will be NULL for lgr grids, i.e. grids with
grid_nr > 0.
lgr_nr > 0.
*/
vector_type * LGR_list; /* a vector of ecl_grid instances for lgr's - the index corresponds to the grid_nr. */
vector_type * LGR_list; /* a vector of ecl_grid instances for LGRs - the index corresponds to the order LGRs are read from file*/
int_vector_type * lgr_index_map; /* a vector that maps LGR-nr for EGRID files to index into the LGR_list.*/
hash_type * LGR_hash; /* a hash of pointers to ecl_grid instances - for name based lookup of lgr. */
int parent_box[6]; /* integers i1,i2, j1,j2, k1,k2 of the parent grid region containing this lgr. the indices are inclusive - zero offset */
/* not used yet .. */
@ -826,6 +898,8 @@ static void ecl_cell_init( ecl_cell_type * cell , bool init_valid) {
if (init_valid)
cell->cell_flags = CELL_FLAG_VALID;
cell->nnc_info = NULL;
}
@ -1122,6 +1196,14 @@ static void ecl_grid_taint_cells( ecl_grid_type * ecl_grid ) {
static void ecl_grid_free_cells( ecl_grid_type * grid ) {
int i;
for (i=0; i < grid->size; i++) {
ecl_cell_type * cell = ecl_grid_get_cell( grid , i );
if (cell->nnc_info)
nnc_info_free(cell->nnc_info);
}
#ifndef LARGE_CELL_MALLOC
int i;
for (i=0; i < grid->size; i++) {
@ -1162,7 +1244,7 @@ static void ecl_grid_alloc_cells( ecl_grid_type * grid , bool init_valid) {
is performed.
*/
static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int dualp_flag , int nx , int ny , int nz, int grid_nr , bool init_valid) {
static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int dualp_flag , int nx , int ny , int nz, int lgr_nr, bool init_valid) {
ecl_grid_type * grid = util_malloc(sizeof * grid );
UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID);
grid->total_active = 0;
@ -1171,7 +1253,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
grid->ny = ny;
grid->nz = nz;
grid->size = nx*ny*nz;
grid->grid_nr = grid_nr;
grid->lgr_nr = lgr_nr;
grid->global_grid = global_grid;
grid->coarsening_active = false;
@ -1182,8 +1264,9 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
grid->index_map = NULL;
grid->fracture_index_map = NULL;
grid->inv_fracture_index_map = NULL;
grid->nnc_index_list = nnc_index_list_alloc( );
ecl_grid_alloc_cells( grid , init_valid );
if (global_grid != NULL) {
/* this is an lgr instance, and we inherit the global grid
@ -1206,21 +1289,22 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
}
grid->block_dim = 0;
grid->values = NULL;
if (grid_nr == 0) { /* this is the main grid */
grid->LGR_list = vector_alloc_new();
vector_append_ref( grid->LGR_list , grid ); /* adding a 'self' pointer as first inistance - without destructor! */
grid->LGR_hash = hash_alloc();
grid->block_dim = 0;
grid->values = NULL;
if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */
grid->LGR_list = vector_alloc_new();
grid->lgr_index_map = int_vector_alloc(0,0);
grid->LGR_hash = hash_alloc();
} else {
grid->LGR_list = NULL;
grid->LGR_hash = NULL;
grid->LGR_list = NULL;
grid->lgr_index_map = NULL;
grid->LGR_hash = NULL;
}
grid->name = NULL;
grid->parent_name = NULL;
grid->parent_grid = NULL;
grid->children = hash_alloc();
grid->coarse_cells = vector_alloc_new();
grid->name = NULL;
grid->parent_name = NULL;
grid->parent_grid = NULL;
grid->children = hash_alloc();
grid->coarse_cells = vector_alloc_new();
return grid;
}
@ -1322,12 +1406,12 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size ,
/*
The grid_nr > 0 test essentially checks if this is a LGR; if
this test applies we either have bug - or a GRID file with LGRs
and only 4/5 elements in the coords keywords. In the latter
case we must start using the LGRILG keyword.
The ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr test checks if
this is a LGR; if this test applies we either have bug - or a
GRID file with LGRs and only 4/5 elements in the coords keywords.
In the latter case we must start using the LGRILG keyword.
*/
if ((ecl_grid->grid_nr > 0) && (coords_size != 7))
if ((ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr) && (coords_size != 7))
util_abort("%s: Need 7 element coords keywords for LGR - or reimplement to use LGRILG keyword.\n",__func__);
switch(coords_size) {
@ -1699,13 +1783,9 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , const float * mapa
static void ecl_grid_add_lgr( ecl_grid_type * main_grid , ecl_grid_type * lgr_grid) {
int next_grid_nr = vector_get_size( main_grid->LGR_list );
if (next_grid_nr != lgr_grid->grid_nr)
util_abort("%s: index based insertion of lgr grid failed. next_grid_nr:%d lgr->grid_nr:%d \n",__func__ , next_grid_nr , lgr_grid->grid_nr);
{
vector_append_owned_ref( main_grid->LGR_list , lgr_grid , ecl_grid_free__);
hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_grid);
}
vector_append_owned_ref( main_grid->LGR_list , lgr_grid , ecl_grid_free__);
int_vector_iset(main_grid->lgr_index_map, lgr_grid->lgr_nr, vector_get_size(main_grid->LGR_list)-1);
hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_grid);
}
@ -1764,7 +1844,7 @@ static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_fil
ecl_kw_type * lgrname_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1);
lgr_grid->name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrname_kw , 0) ); /* trailing zeros are stripped away. */
if (ecl_file_has_kw( ecl_file , LGR_PARENT_KW)) {
ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr - 1);
ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr -1);
char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( parent_kw , 0));
if (strlen( parent ) > 0)
@ -1795,7 +1875,7 @@ static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file
if ((strlen(parent) == 0) || (strcmp(parent , GLOBAL_STRING ) == 0))
free( parent );
else
else
lgr_grid->parent_name = parent;
}
}
@ -1893,9 +1973,9 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid , const float * zcorn ,
static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid ,
int dualp_flag , int nx , int ny , int nz ,
const float * zcorn , const float * coord , const int * actnum, const float * mapaxes, const int * corsnum,
int grid_nr) {
int lgr_nr) {
ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,grid_nr,true);
ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,lgr_nr,true);
if (mapaxes != NULL)
ecl_grid_init_mapaxes( ecl_grid , mapaxes );
@ -1930,15 +2010,14 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
const ecl_kw_type * coord_kw ,
const ecl_kw_type * actnum_kw , /* Can be NULL */
const ecl_kw_type * mapaxes_kw , /* Can be NULL */
const ecl_kw_type * corsnum_kw , /* Can be NULL */
int grid_nr) {
int gtype, nx,ny,nz;
const ecl_kw_type * corsnum_kw) { /* Can be NULL */
int gtype, nx,ny,nz, lgr_nr;
gtype = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_TYPE_INDEX);
nx = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NX_INDEX);
ny = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NY_INDEX);
nz = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NZ_INDEX);
lgr_nr = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_LGR_INDEX);
/*
The code used to have this test:
@ -1951,7 +2030,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
if (gtype != GRIDHEAD_GRIDTYPE_CORNERPOINT)
util_abort("%s: gtype:%d fatal error when loading grid - must have corner point grid - aborting\n",__func__ , gtype );
{
const float * mapaxes_data = NULL;
const int * actnum_data = NULL;
@ -1974,7 +2053,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
actnum_data,
mapaxes_data,
corsnum_data,
grid_nr);
lgr_nr);
}
}
@ -1983,7 +2062,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
If you create/load ecl_kw instances for the various fields, this
function can be used to create a GRID instance, without going
through a GRID/EGRID file. Does not support LGR or coarsening
hierarchies.
hierarchies.
*/
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
@ -1991,10 +2070,10 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
const ecl_kw_type * coord_kw ,
const ecl_kw_type * actnum_kw , /* Can be NULL */
const ecl_kw_type * mapaxes_kw ) { /* Can be NULL */
ecl_kw_type * gridhead_kw = ecl_grid_alloc_gridhead_kw( nx , ny , nz , 0);
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL , FILEHEAD_SINGLE_POROSITY , gridhead_kw , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw , NULL , 0);
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL , FILEHEAD_SINGLE_POROSITY , gridhead_kw , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw , NULL);
ecl_kw_free( gridhead_kw );
return ecl_grid;
@ -2002,6 +2081,126 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
static void ecl_grid_init_cell_nnc_info(ecl_grid_type * ecl_grid, int global_index) {
ecl_cell_type * grid_cell = ecl_grid_get_cell(ecl_grid, global_index);
if (!grid_cell->nnc_info)
grid_cell->nnc_info = nnc_info_alloc(ecl_grid->lgr_nr);
}
/*
This function populates nnc_info for cells with non neighbour connections
*/
static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid2, const ecl_kw_type * keyword1, const ecl_kw_type * keyword2) {
int * grid1_nnc_cells = ecl_kw_get_int_ptr(keyword1);
int * grid2_nnc_cells = ecl_kw_get_int_ptr(keyword2);
int nnc_count = ecl_kw_get_size(keyword2);
int i;
for (i = 0; i < nnc_count; i++) {
int grid1_cell_index = grid1_nnc_cells[i] -1;
int grid2_cell_index = grid2_nnc_cells[i] -1;
/*
In the ECLIPSE output format grids with dual porosity are (to some
extent ...) modeled as two independent grids stacked on top of
eachother, where the fracture cells have global index in the range
[nx*ny*nz, 2*nx*ny*nz).
The physical connection between the matrix and the fractures in
cell nr c is modelled as an nnc: cell[c] -> cell[c + nx*ny*nz]. In
the ert ecl library we only have cells in the range [0,nx*ny*nz),
and fracture is a property of a cell, we therefor do not include
nnc connections involving fracture cells (i.e. cell_index >=
nx*ny*nz).
*/
if ((FILEHEAD_SINGLE_POROSITY != grid1->dualp_flag) &&
((grid1_cell_index >= grid1->size) ||
(grid2_cell_index >= grid2->size)))
break;
ecl_grid_init_cell_nnc_info(grid1, grid1_cell_index);
ecl_grid_init_cell_nnc_info(grid2, grid2_cell_index);
{
ecl_cell_type * grid1_cell = ecl_grid_get_cell(grid1, grid1_cell_index);
ecl_cell_type * grid2_cell = ecl_grid_get_cell(grid2, grid2_cell_index);
//Add the non-neighbour connection in both directions
nnc_info_add_nnc(grid1_cell->nnc_info, grid2->lgr_nr, grid2_cell_index);
nnc_info_add_nnc(grid2_cell->nnc_info, grid1->lgr_nr, grid1_cell_index);
nnc_index_list_add_index( grid1->nnc_index_list , grid1_cell_index );
nnc_index_list_add_index( grid2->nnc_index_list , grid2_cell_index );
}
}
}
/*
This function reads the non-neighbour connection data from file and initializes the grid structure with the the nnc data
*/
static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_file) {
int num_nnchead_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEAD_KW );
int num_nncg_kw = ecl_file_get_num_named_kw( ecl_file , NNCG_KW );
int i;
for (i = 0; i < num_nnchead_kw; i++) {
ecl_kw_type * nnchead_kw = ecl_file_iget_named_kw( ecl_file , NNCHEAD_KW , i);
int lgr_nr = ecl_kw_iget_int(nnchead_kw, NNCHEAD_LGR_INDEX);
ecl_kw_type * keyword1 = NULL;
ecl_kw_type * keyword2 = NULL;
if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) {
keyword1 = ecl_file_iget_named_kw( ecl_file , NNC1_KW , i);
keyword2 = ecl_file_iget_named_kw( ecl_file , NNC2_KW , i);
} else {
int nnc_lgr_index = (num_nnchead_kw == num_nncg_kw) ? i : i-1; //Subtract 1 if no nnc data for main grid
keyword1 = ecl_file_iget_named_kw( ecl_file , NNCL_KW , nnc_lgr_index);
keyword2 = ecl_file_iget_named_kw( ecl_file , NNCG_KW , nnc_lgr_index);
}
{
ecl_grid_type * grid = (lgr_nr > 0) ? ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr) : main_grid;
ecl_grid_init_nnc_cells(grid, main_grid, keyword1, keyword2);
}
}
}
/*
This function reads the non-neighbour connection data for amalgamated LGRs (that is, non-neighbour
connections between two LGRs) and initializes the grid structure with the nnc data.
*/
static void ecl_grid_init_nnc_amalgamated(ecl_grid_type * main_grid, ecl_file_type * ecl_file) {
int num_nncheada_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEADA_KW );
int i;
for (i = 0; i < num_nncheada_kw; i++) {
ecl_kw_type * nncheada_kw = ecl_file_iget_named_kw( ecl_file , NNCHEADA_KW , i);
int lgr_nr1 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX);
int lgr_nr2 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX);
ecl_grid_type * lgr_grid1 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr1);
ecl_grid_type * lgr_grid2 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr2);
ecl_kw_type * nna1_kw = ecl_file_iget_named_kw( ecl_file , NNA1_KW , i);
ecl_kw_type * nna2_kw = ecl_file_iget_named_kw( ecl_file , NNA2_KW , i);
ecl_grid_init_nnc_cells( lgr_grid1 ,lgr_grid2, nna1_kw, nna2_kw);
}
}
/**
Creating a grid based on a EGRID file is a three step process:
@ -2045,7 +2244,7 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const
corsnum_kw = ecl_file_iget_named_kw( ecl_file , CORSNUM_KW , 0);
}
{
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__( main_grid ,
@ -2055,10 +2254,9 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const
coord_kw ,
actnum_kw ,
mapaxes_kw ,
corsnum_kw ,
grid_nr );
if (grid_nr > 0) ecl_grid_set_lgr_name_EGRID(ecl_grid , ecl_file , grid_nr);
corsnum_kw );
if (ECL_GRID_MAINGRID_LGR_NR != grid_nr) ecl_grid_set_lgr_name_EGRID(ecl_grid , ecl_file , grid_nr);
return ecl_grid;
}
}
@ -2091,6 +2289,10 @@ static ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file) {
}
}
main_grid->name = util_alloc_string_copy( grid_file );
ecl_grid_init_nnc(main_grid, ecl_file);
ecl_grid_init_nnc_amalgamated(main_grid, ecl_file);
ecl_file_close( ecl_file );
return main_grid;
}
@ -2106,7 +2308,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid ,
if (dualp_flag != FILEHEAD_SINGLE_POROSITY)
nz = nz / 2;
{
ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , dualp_flag , nx , ny , nz , grid_nr , false);
ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , dualp_flag , nx , ny , nz , grid_nr, false);
if (mapaxes != NULL)
ecl_grid_init_mapaxes( grid , mapaxes );
@ -2344,7 +2546,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file) {
*/
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum) {
ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0,true);
ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0, true);
const double offset[3] = {0,0,0};
int k,j,i;
@ -2950,13 +3152,15 @@ void ecl_grid_free(ecl_grid_type * grid) {
double_vector_free( grid->values[i] );
free( grid->values );
}
if (grid->grid_nr == 0) { /* This is the main grid. */
if (ECL_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */
vector_free( grid->LGR_list );
int_vector_free( grid->lgr_index_map);
hash_free( grid->LGR_hash );
}
if (grid->coord_kw != NULL)
ecl_kw_free( grid->coord_kw );
nnc_index_list_free( grid->nnc_index_list );
vector_free( grid->coarse_cells );
hash_free( grid->children );
util_safe_free( grid->parent_name );
@ -3044,10 +3248,10 @@ grid_dims_type ecl_grid_iget_dims( const ecl_grid_type * grid , int grid_nr) {
grid_dims_type dims;
const ecl_grid_type * lgr;
if (grid_nr == 0)
if (grid_nr == 0)
lgr = grid;
else
lgr = ecl_grid_iget_lgr( grid , grid_nr - 1 );
lgr = ecl_grid_iget_lgr(grid, grid_nr - 1);
dims.nx = lgr->nx;
dims.ny = lgr->ny;
@ -3369,6 +3573,25 @@ double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j
}
const int_vector_type * ecl_grid_get_nnc_index_list( ecl_grid_type * grid ) {
return nnc_index_list_get_list( grid->nnc_index_list );
}
const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index) {
const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index);
return cell->nnc_info;
}
const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k) {
const int global_index = ecl_grid_get_global_index3(grid , i,j,k);
return ecl_grid_get_cell_nnc_info1(grid, global_index);
}
/*****************************************************************/
/* Functions to query whether a cell is active or not. */
@ -3413,7 +3636,7 @@ double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index) {
/* Functions for LGR query/lookup/... */
static void __assert_main_grid(const ecl_grid_type * ecl_grid) {
if (ecl_grid->grid_nr != 0)
if (ecl_grid->lgr_nr != ECL_GRID_MAINGRID_LGR_NR)
util_abort("%s: tried to get LGR grid from another LGR_grid - only main grid can be used as first input \n",__func__);
}
@ -3472,20 +3695,37 @@ bool ecl_grid_have_coarse_cells( const ecl_grid_type * main_grid ) {
*/
int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid ) {
__assert_main_grid( main_grid );
return vector_get_size( main_grid->LGR_list ) - 1;
return vector_get_size( main_grid->LGR_list );
}
/**
The lgr_nr has zero offset, not counting the main grid, i.e.
ecl_grid_iget_lgr( ecl_grid , 0);
will return the first LGR - and fail HARD if there are no LGR's.
The lgr_index has zero offset
ecl_grid_iget_lgr( ecl_grid , 0); will return the first lgr
ecl_grid_iget_lgr( ecl_grid , 1); will return the second lgr
The method will fail HARD if lgr_index is out of bounds.
*/
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_nr) {
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_index) {
__assert_main_grid( main_grid );
return vector_iget( main_grid->LGR_list , lgr_nr + 1);
return vector_iget( main_grid->LGR_list , lgr_index);
}
/*
This function returns the lgr with the given lgr_nr. The lgr_nr is
the fourth element in the GRIDHEAD for EGRID files. The lgr nr is
equal to the grid nr if the grid's are consecutive numbered and
read from file in increasing lgr nr order.
This method can only be used for EGRID files. For GRID files the
lgr_nr is 0 for all grids.
*/
ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, int lgr_nr) {
__assert_main_grid( main_grid );
{
int lgr_index = int_vector_iget( main_grid->lgr_index_map , lgr_nr );
return vector_iget( main_grid->LGR_list , lgr_index);
}
}
@ -3527,7 +3767,7 @@ const ecl_grid_type * ecl_grid_get_cell_lgr1A(const ecl_grid_type * grid , int a
Will return the global grid for a lgr. If the input grid is indeed
a global grid itself the function will return NULL.
*/
const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) {
const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) {
return grid->global_grid;
}
@ -3545,36 +3785,40 @@ stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) {
}
}
const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr) {
const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_index) {
__assert_main_grid( ecl_grid );
if (lgr_nr < (vector_get_size( ecl_grid->LGR_list ) - 1)) {
const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_nr + 1);
if (lgr_index < (vector_get_size( ecl_grid->LGR_list ))) {
const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_index);
return lgr->name;
} else
return NULL;
}
const char * ecl_grid_get_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr) {
__assert_main_grid( ecl_grid );
{
int lgr_index = int_vector_iget( ecl_grid->lgr_index_map , lgr_nr );
return ecl_grid_iget_lgr_name( ecl_grid , lgr_index );
}
}
/*****************************************************************/
/**
This function returns the grid_nr field of the field; this is just
the occurence number in the grid file. Starting with 0 at the main
This function returns the lgr_nr field of the grid; for GRID files, this
is just the occurence number in the grid file. Starting with 0 at the main
grid, and then increasing consecutively through the lgr sections.
Observe that there is A MAJOR POTENTIAL for confusion with the
ecl_grid_iget_lgr() function, the latter does not refer to the main
grid and returns the first lgr section (which has grid_nr == 1) for
input argument 0.
For EGRID files, this is the LGR number (fourth element in the
gridhead).
*/
int ecl_grid_get_grid_nr( const ecl_grid_type * ecl_grid ) {
return ecl_grid->grid_nr;
int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid ) {
return ecl_grid->lgr_nr;
}
const char * ecl_grid_get_name( const ecl_grid_type * ecl_grid ) {
return ecl_grid->name;
}
@ -3613,7 +3857,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) {
printf(" Origo X................: %10.2f \n",ecl_grid->origo[0]);
printf(" Origo Y................: %10.2f \n",ecl_grid->origo[1]);
if (ecl_grid->grid_nr == 0) {
if (ECL_GRID_MAINGRID_LGR_NR == ecl_grid->lgr_nr) {
int grid_nr;
for (grid_nr=1; grid_nr < vector_get_size( ecl_grid->LGR_list ); grid_nr++) {
printf("\n");
@ -3954,7 +4198,7 @@ bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) {
static void ecl_grid_dump__(const ecl_grid_type * grid , FILE * stream) {
util_fwrite_int( grid->grid_nr , stream );
util_fwrite_int( grid->lgr_nr , stream );
util_fwrite_string( grid->name , stream );
util_fwrite_int( grid->nx , stream );
util_fwrite_int( grid->nz , stream );
@ -3975,7 +4219,7 @@ static void ecl_grid_dump__(const ecl_grid_type * grid , FILE * stream) {
static void ecl_grid_dump_ascii__(const ecl_grid_type * grid , bool active_only , FILE * stream) {
fprintf(stream , "Grid nr : %d\n",grid->grid_nr);
fprintf(stream , "Grid nr : %d\n",grid->lgr_nr);
fprintf(stream , "Grid name : %s\n",grid->name);
fprintf(stream , "nx : %6d\n",grid->nx);
fprintf(stream , "ny : %6d\n",grid->ny);
@ -4007,15 +4251,21 @@ static void ecl_grid_dump_ascii__(const ecl_grid_type * grid , bool active_only
void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream) {
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream );
ecl_grid_dump__(grid, stream );
{
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream );
}
}
void ecl_grid_dump_ascii(const ecl_grid_type * grid , bool active_only , FILE * stream) {
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump_ascii__( vector_iget_const( grid->LGR_list , i) , active_only , stream );
ecl_grid_dump_ascii__( grid , active_only , stream );
{
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump_ascii__( vector_iget_const( grid->LGR_list , i) , active_only , stream );
}
}
@ -4180,6 +4430,8 @@ void ecl_grid_fwrite_GRID( const ecl_grid_type * grid , const char * filename) {
if (grid->coarsening_active)
coords_size = 7;
ecl_grid_fwrite_GRID__( grid , coords_size , fortio );
{
int grid_nr;
for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) {
@ -4591,7 +4843,7 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio
}
}
ecl_grid_fwrite_gridhead_kw( grid->nx , grid->ny , grid->nz , grid->grid_nr , fortio);
ecl_grid_fwrite_gridhead_kw( grid->nx , grid->ny , grid->nz , grid->lgr_nr , fortio);
/* Writing main grid data */
{
{
@ -4637,6 +4889,8 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio
void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename) {
bool fmt_file = false;
fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP );
ecl_grid_fwrite_EGRID__( grid , fortio );
{
int grid_nr;
for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) {

View File

@ -2374,7 +2374,7 @@ void ecl_kw_inplace_update_file(const ecl_kw_type * ecl_kw , const char * filena
/******************************************************************/
bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) {
const long int init_pos = ftell(stream);
const long int init_pos = util_ftell(stream);
bool kw_file;
{
@ -2394,7 +2394,7 @@ bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) {
ecl_kw_free(ecl_kw);
}
fseek(stream , init_pos , SEEK_SET);
util_fseek(stream , init_pos , SEEK_SET);
return kw_file;
}
@ -2403,7 +2403,7 @@ bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) {
bool ecl_kw_is_grdecl_file(FILE * stream) {
const long int init_pos = ftell(stream);
const long int init_pos = util_ftell(stream);
bool grdecl_file;
bool at_eof = false;
util_fskip_chars(stream , " \r\n\t" , &at_eof); /* Skipping intial space */
@ -2427,7 +2427,7 @@ bool ecl_kw_is_grdecl_file(FILE * stream) {
} while (c == ' ');
}
}
fseek(stream , init_pos , SEEK_SET);
util_fseek(stream , init_pos , SEEK_SET);
return grdecl_file;
}

View File

@ -71,7 +71,7 @@
bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
long start_pos = ftell( stream );
long start_pos = util_ftell( stream );
long current_pos;
char next_kw[256];
@ -83,14 +83,14 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
{
while (true) {
char c;
if (ftell(stream) == 0)
if (util_ftell(stream) == 0)
/*
We are at the very beginning of the file. Can just jump out of
the loop.
*/
break;
fseek( stream , -1 , SEEK_CUR );
util_fseek( stream , -1 , SEEK_CUR );
c = fgetc( stream );
if (c == '\n') {
/*
@ -98,7 +98,7 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
have not reached any !isspace() characters on the way and
can go back to start_pos and read from there.
*/
fseek( stream , start_pos , SEEK_SET );
util_fseek( stream , start_pos , SEEK_SET );
break;
}
@ -111,25 +111,25 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
util_fskip_lines( stream , 1 );
break;
}
fseek( stream , -2 , SEEK_CUR );
util_fseek( stream , -2 , SEEK_CUR );
}
}
while (true) {
current_pos = ftell( stream );
current_pos = util_ftell( stream );
if (fscanf(stream , "%s" , next_kw) == 1) {
if ((next_kw[0] == next_kw[1]) && (next_kw[0] == ECL_COMMENT_CHAR))
// This is a comment line - skip it.
util_fskip_lines( stream , 1 );
else {
// This is a valid keyword i.e. a non-commented out string; return true.
fseek( stream , current_pos , SEEK_SET );
util_fseek( stream , current_pos , SEEK_SET );
return true;
}
} else {
// EOF reached - return False.
fseek( stream , start_pos , SEEK_SET );
util_fseek( stream , start_pos , SEEK_SET );
return false;
}
}
@ -167,17 +167,17 @@ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) {
*/
static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) {
long init_pos = ftell( stream );
long init_pos = util_ftell( stream );
while (true) {
if (ecl_kw_grdecl_fseek_next_kw( stream )) {
char next_kw[256];
fscanf( stream , "%s" , next_kw);
if (strcmp( kw , next_kw ) == 0) {
fseek( stream , -strlen(next_kw) , SEEK_CUR);
util_fseek( stream , -strlen(next_kw) , SEEK_CUR);
return true;
}
} else {
fseek( stream , init_pos , SEEK_SET);
util_fseek( stream , init_pos , SEEK_SET);
return false;
}
}
@ -274,13 +274,13 @@ bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) {
if (ecl_kw_grdecl_fseek_kw__(kw , stream))
return true; /* OK - we found the kw between current file pos and EOF. */
else if (rewind) {
long int init_pos = ftell(stream);
long int init_pos = util_ftell(stream);
fseek(stream , 0L , SEEK_SET);
util_fseek(stream , 0L , SEEK_SET);
if (ecl_kw_grdecl_fseek_kw__( kw , stream )) /* Try again from the beginning of the file. */
return true;
else
fseek(stream , init_pos , SEEK_SET); /* Could not find it - reposition to initial position. */
util_fseek(stream , init_pos , SEEK_SET); /* Could not find it - reposition to initial position. */
}
/* OK: If we are here - that means that we failed to find the kw. */

View File

@ -66,6 +66,7 @@ struct plt_data_struct {
double wrat;
double grat;
double connection_start;
double connection_end;
double flowrate;
double oil_flowrate;
double gas_flowrate;
@ -95,7 +96,7 @@ static UTIL_IS_INSTANCE_FUNCTION( rft_data , RFT_DATA_TYPE_ID)
/*****************************************************************/
static plt_data_type * plt_data_alloc( double orat , double grat , double wrat,double connection_start, double flowrate , double oil_flowrate , double gas_flowrate , double water_flowrate) {
static plt_data_type * plt_data_alloc( double orat , double grat , double wrat,double connection_start, double connection_end, double flowrate , double oil_flowrate , double gas_flowrate , double water_flowrate) {
plt_data_type * data = util_malloc( sizeof * data );
UTIL_TYPE_ID_INIT( data , PLT_DATA_TYPE_ID );
@ -103,6 +104,7 @@ static UTIL_IS_INSTANCE_FUNCTION( rft_data , RFT_DATA_TYPE_ID)
data->grat = grat;
data->wrat = wrat;
data->connection_start = connection_start;
data->connection_end = connection_end;
data->flowrate = flowrate;
data->oil_flowrate = oil_flowrate;
data->gas_flowrate = gas_flowrate;
@ -161,6 +163,7 @@ ecl_rft_cell_type * ecl_rft_cell_alloc_PLT( int i ,
double grat ,
double wrat,
double connection_start,
double connection_end,
double flowrate ,
double oil_flowrate ,
double gas_flowrate ,
@ -168,7 +171,7 @@ ecl_rft_cell_type * ecl_rft_cell_alloc_PLT( int i ,
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_common( i , j , k , depth , pressure );
cell->data = plt_data_alloc( orat , grat , wrat , connection_start , flowrate , oil_flowrate , gas_flowrate , water_flowrate);
cell->data = plt_data_alloc( orat , grat , wrat , connection_start , connection_end , flowrate , oil_flowrate , gas_flowrate , water_flowrate);
return cell;
}
@ -282,6 +285,13 @@ double ecl_rft_cell_get_connection_start( const ecl_rft_cell_type * cell ) {
return ECL_RFT_CELL_INVALID_VALUE;
}
double ecl_rft_cell_get_connection_end( const ecl_rft_cell_type * cell ) {
const plt_data_type * data = plt_data_try_cast_const( cell->data );
if (data)
return data->connection_end;
else
return ECL_RFT_CELL_INVALID_VALUE;
}
double ecl_rft_cell_get_flowrate( const ecl_rft_cell_type * cell ) {
const plt_data_type * data = plt_data_try_cast_const( cell->data );
@ -345,7 +355,7 @@ int ecl_rft_cell_cmp( const ecl_rft_cell_type * cell1 , const ecl_rft_cell_type
else if (val1 == val2)
return 0;
else
return 0;
return 1;
}

View File

@ -170,22 +170,31 @@ static void ecl_rft_node_init_PLT_cells( ecl_rft_node_type * rft_node , const ec
const float * gas_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGTUB_KW , 0));
const float * water_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWTUB_KW , 0));
const float * connection_start = NULL;
const float * connection_end = NULL;
/* This keyword is ONLY present if we are dealing with a MSW well. */
/* The keywords CONLENST_KW and CONLENEN_KW are ONLY present if we are dealing with a MSW well. */
if (ecl_file_has_kw( rft , CONLENST_KW))
connection_start = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONLENST_KW , 0));
if (ecl_file_has_kw( rft , CONLENEN_KW))
connection_end = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONLENEN_KW , 0));
{
int c;
for ( c = 0; c < ecl_kw_get_size( conipos ); c++) {
ecl_rft_cell_type * cell;
double cs = 0;
double ce = 0;
if (connection_start)
cs = connection_start[c];
if (connection_end)
ce = connection_end[c];
/* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */
cell = ecl_rft_cell_alloc_PLT( i[c] -1 , j[c] -1 , k[c] -1 ,
depth[c] , P[c] , OR[c] , GR[c] , WR[c] , cs , flowrate[c] , oil_flowrate[c] , gas_flowrate[c] , water_flowrate[c]);
depth[c] , P[c] , OR[c] , GR[c] , WR[c] , cs , ce, flowrate[c] , oil_flowrate[c] , gas_flowrate[c] , water_flowrate[c]);
ecl_rft_node_append_cell( rft_node , cell );
}
}

View File

@ -485,6 +485,7 @@ static ecl_smspec_var_type ecl_smspec_identify_special_var( const char * var ) {
ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) {
ecl_smspec_var_type var_type = ecl_smspec_identify_special_var( var );
int str_length = strlen(var);
if (var_type == ECL_SMSPEC_INVALID_VAR) {
switch(var[0]) {
case('A'):
@ -521,10 +522,13 @@ ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) {
var_type = ECL_SMSPEC_NETWORK_VAR;
break;
case('R'):
if (var[2] == 'F')
var_type = ECL_SMSPEC_REGION_2_REGION_VAR;
else
if (((3 == str_length) && var[2] == 'F') ||
((4 == str_length) && var[3] == 'F')) {
var_type = ECL_SMSPEC_REGION_2_REGION_VAR;
}
else {
var_type = ECL_SMSPEC_REGION_VAR;
}
break;
case('S'):
var_type = ECL_SMSPEC_SEGMENT_VAR;
@ -649,7 +653,7 @@ static void ecl_smspec_install_gen_keys( ecl_smspec_type * smspec , smspec_node_
hash_insert_ref(smspec->gen_var_index , gen_key1 , smspec_node);
}
/* Insert the (optional) extra mapping for block related variables: */
/* Insert the (optional) extra mapping for block related variables and region_2_region variables: */
{
const char * gen_key2 = smspec_node_get_gen_key2( smspec_node );
if (gen_key2 != NULL)
@ -751,6 +755,8 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp
break;
case(ECL_SMSPEC_SEGMENT_VAR):
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
break;
default:
util_abort("%: Internal error - should never be here ?? \n",__func__);
break;
@ -778,6 +784,9 @@ bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ) {
case(ECL_SMSPEC_REGION_VAR):
return false;
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
return false;
break;
case(ECL_SMSPEC_MISC_VAR):
return false;
break;
@ -821,6 +830,9 @@ bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ) {
case(ECL_SMSPEC_REGION_VAR):
return true;
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
return true;
break;
case(ECL_SMSPEC_MISC_VAR):
return false;
break;

View File

@ -1183,6 +1183,20 @@ bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well)
bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2) {
if (ecl_sum1 == ecl_sum2)
return true;
else
return ecl_sum_data_report_step_equal( ecl_sum1->data , ecl_sum2->data );
}
bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2) {
if (ecl_sum1 == ecl_sum2)
return true;
else
return ecl_sum_data_report_step_compatible( ecl_sum1->data , ecl_sum2->data );
}

View File

@ -204,7 +204,7 @@
#define INVALID_MINISTEP_NR -1
struct ecl_sum_data_struct {
@ -255,8 +255,8 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) {
data->last_report_step = -1024 * 1024;
data->days_start = 0;
data->sim_length = -1;
data->first_ministep = -1;
data->last_ministep = -1;
data->first_ministep = INVALID_MINISTEP_NR;
data->last_ministep = INVALID_MINISTEP_NR;
data->index_valid = false;
time_interval_reopen( data->sim_time );
}
@ -268,8 +268,8 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) {
data->smspec = smspec;
data->__min_time = 0;
data->report_first_index = int_vector_alloc( 0 , -1 ); /* This -1 value is hard-wired around in the place - not good. */
data->report_last_index = int_vector_alloc( 0 , -1 );
data->report_first_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR );
data->report_last_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR );
data->sim_time = time_interval_alloc_open();
ecl_sum_data_clear_index( data );
@ -545,7 +545,7 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data
{
int low_index = 0;
int high_index = vector_get_size( data->data );
int internal_index = -1;
int internal_index = INVALID_MINISTEP_NR;
while (internal_index < 0) {
@ -1043,7 +1043,7 @@ bool ecl_sum_data_has_report_step(const ecl_sum_data_type * data , int report_st
/**
Returns the last index included in report step @report_step.
Observe that if the dataset does not include @report_step at all,
the function will return -1; this must be checked for in the
the function will return INVALID_MINISTEP_NR; this must be checked for in the
calling scope.
*/
@ -1056,7 +1056,7 @@ int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_st
/**
Returns the first index included in report step @report_step.
Observe that if the dataset does not include @report_step at all,
the function will return -1; this must be checked for in the
the function will return INVALID_MINISTEP_NR; this must be checked for in the
calling scope.
*/
@ -1349,3 +1349,52 @@ int ecl_sum_data_get_length( const ecl_sum_data_type * data ) {
return vector_get_size( data->data );
}
bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2) {
bool equal = true;
if (int_vector_size( data1->report_last_index ) == int_vector_size(data2->report_last_index)) {
int i;
for (i = 0; i < int_vector_size( data1->report_last_index ); i++) {
int time_index1 = int_vector_iget( data1->report_last_index , i );
int time_index2 = int_vector_iget( data2->report_last_index , i );
if ((time_index1 != INVALID_MINISTEP_NR) && (time_index2 != INVALID_MINISTEP_NR)) {
const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep( data1 , time_index1 );
const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data2 , time_index2 );
if (!ecl_sum_tstep_sim_time_equal( ministep1 , ministep2)) {
equal = false;
break;
}
} else if (time_index1 != time_index2) {
equal = false;
break;
}
}
} else
equal = false;
return equal;
}
bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2) {
bool compatible = true;
int min_size = util_int_min( int_vector_size( data1->report_last_index ) , int_vector_size( data2->report_last_index));
int i;
for (i = 0; i < min_size; i++) {
int time_index1 = int_vector_iget( data1->report_last_index , i );
int time_index2 = int_vector_iget( data2->report_last_index , i );
if ((time_index1 != INVALID_MINISTEP_NR) && (time_index2 != INVALID_MINISTEP_NR)) {
const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep( data1 , time_index1 );
const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data2 , time_index2 );
if (!ecl_sum_tstep_sim_time_equal( ministep1 , ministep2)) {
compatible = false;
break;
}
}
}
return compatible;
}

View File

@ -289,3 +289,10 @@ void ecl_sum_tstep_set_from_key( ecl_sum_tstep_type * tstep , const char * gen_k
}
bool ecl_sum_tstep_sim_time_equal( const ecl_sum_tstep_type * tstep1 , const ecl_sum_tstep_type * tstep2 ) {
if (tstep1->sim_time == tstep2->sim_time)
return true;
else
return false;
}

View File

@ -1215,16 +1215,16 @@ time_t ecl_util_get_start_date(const char * data_file) {
util_abort("%s: sorry - could not find START in DATA file %s \n",__func__ , data_file);
{
long int start_pos = ftell( stream );
long int start_pos = util_ftell( stream );
int buffer_size;
/* Look for terminating '/' */
if (!parser_fseek_string( parser , stream , "/" , false , true))
util_abort("%s: sorry - could not find \"/\" termination of START keyword in data_file: \n",__func__ , data_file);
buffer_size = (ftell(stream) - start_pos) ;
buffer_size = (util_ftell(stream) - start_pos) ;
buffer = util_calloc( buffer_size + 1 , sizeof * buffer );
fseek( stream , start_pos , SEEK_SET);
util_fseek( stream , start_pos , SEEK_SET);
util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__);
buffer[buffer_size] = '\0';
}
@ -1257,16 +1257,16 @@ int ecl_util_get_num_cpu(const char * data_file) {
char * buffer;
if (parser_fseek_string( parser , stream , "PARALLEL" , true , true)) { /* Seeks case insensitive. */
long int start_pos = ftell( stream );
long int start_pos = util_ftell( stream );
int buffer_size;
/* Look for terminating '/' */
if (!parser_fseek_string( parser , stream , "/" , false , true))
util_abort("%s: sorry - could not find \"/\" termination of PARALLEL keyword in data_file: \n",__func__ , data_file);
buffer_size = (ftell(stream) - start_pos) ;
buffer_size = (util_ftell(stream) - start_pos) ;
buffer = util_calloc( buffer_size + 1 , sizeof * buffer );
fseek( stream , start_pos , SEEK_SET);
util_fseek( stream , start_pos , SEEK_SET);
util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__);
buffer[buffer_size] = '\0';
@ -1277,14 +1277,15 @@ int ecl_util_get_num_cpu(const char * data_file) {
for (i=0; i < stringlist_get_size( tokens ); i++) {
item = util_realloc_string_copy( item , stringlist_iget( tokens , i ));
util_strupr( item );
if ( util_string_equal( item , "DISTRIBUTED" )) {
if (( util_string_equal( item , "DISTRIBUTED" )) ||
( util_string_equal( item , "DIST" ))) {
num_cpu = atoi( stringlist_iget( tokens , i - 1));
break;
}
}
free( item );
stringlist_free( tokens );
}
}
free( buffer );
}

View File

@ -119,7 +119,7 @@ static bool __read_int(FILE * stream , int * value, bool endian_flip) {
static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
const bool strict_checking = true; /* True: requires that *ALL* records in the file are fortran formatted */
long init_pos = ftell(stream);
offset_type init_pos = util_ftell(stream);
bool is_fortran_stream = false;
int header , tail;
bool cont;
@ -128,7 +128,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
cont = false;
if (__read_int(stream , &header , endian_flip)) {
if (header >= 0) {
if (fseek(stream , header , SEEK_CUR) == 0) {
if (util_fseek(stream , (offset_type) header , SEEK_CUR) == 0) {
if (__read_int(stream , &tail , endian_flip)) {
cont = true;
/*
@ -155,7 +155,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
}
}
} while (cont);
fseek(stream , init_pos , SEEK_SET);
util_fseek(stream , init_pos , SEEK_SET);
return is_fortran_stream;
}
@ -423,7 +423,7 @@ void fortio_fclose(fortio_type *fortio) {
bool fortio_is_fortio_file(fortio_type * fortio) {
FILE * stream = fortio->stream;
int init_pos = ftell(stream);
offset_type init_pos = fortio_ftell(fortio);
int elm_read;
bool is_fortio_file = false;
elm_read = fread(&fortio->active_header , sizeof(fortio->active_header) , 1 , fortio->stream);
@ -433,7 +433,7 @@ bool fortio_is_fortio_file(fortio_type * fortio) {
if (fortio->endian_flip_header)
util_endian_flip_vector(&fortio->active_header , sizeof fortio->active_header , 1);
if (fseek(stream , fortio->active_header , SEEK_CUR) == 0) {
if (fortio_fseek(fortio , (offset_type) fortio->active_header , SEEK_CUR) == 0) {
if (fread(&trailer , sizeof(fortio->active_header) , 1 , fortio->stream) == 1) {
if (fortio->endian_flip_header)
util_endian_flip_vector(&trailer , sizeof trailer , 1);
@ -444,7 +444,7 @@ bool fortio_is_fortio_file(fortio_type * fortio) {
}
}
fseek(stream , init_pos , SEEK_SET);
fortio_fseek(fortio , init_pos , SEEK_SET);
return is_fortio_file;
}
@ -527,7 +527,7 @@ void fortio_fread_buffer(fortio_type * fortio, char * buffer , int buffer_size)
int fortio_fskip_record(fortio_type *fortio) {
int record_size = fortio_init_read(fortio);
fseek(fortio->stream , record_size , SEEK_CUR);
fortio_fseek(fortio , (offset_type) record_size , SEEK_CUR);
fortio_complete_read(fortio);
return record_size;
}
@ -624,7 +624,7 @@ static fortio_status_type fortio_check_record( FILE * stream , bool endian_flip
if (endian_flip)
util_endian_flip_vector(&header , sizeof header , 1);
if (fseek( stream , header , SEEK_CUR ) != 0)
if (util_fseek( stream , (offset_type) header , SEEK_CUR ) != 0)
/* The fseek() failed - i.e. the data section was not sufficiently long. */
status = FORTIO_MISSING_DATA;
else {
@ -697,13 +697,13 @@ fortio_status_type fortio_check_file( const char * filename , bool endian_flip)
}
long fortio_ftell( const fortio_type * fortio ) {
return ftell( fortio->stream );
offset_type fortio_ftell( const fortio_type * fortio ) {
return util_ftell( fortio->stream );
}
int fortio_fseek( fortio_type * fortio , long offset , int whence) {
int fseek_return = fseek( fortio->stream , offset , whence );
int fortio_fseek( fortio_type * fortio , offset_type offset , int whence) {
int fseek_return = util_fseek( fortio->stream , offset , whence );
/*
if fseek_return != 0 -> util_abort().
*/
@ -723,6 +723,6 @@ FILE * fortio_get_FILE(const fortio_type *fortio) { return fortio-
int fortio_get_record_size(const fortio_type *fortio) { return fortio->active_header; }
//bool fortio_endian_flip(const fortio_type *fortio) { return fortio->endian_flip_header; }
bool fortio_fmt_file(const fortio_type *fortio) { return fortio->fmt_file; }
void fortio_rewind(const fortio_type *fortio) { rewind(fortio->stream); }
void fortio_rewind(const fortio_type *fortio) { util_rewind(fortio->stream); }
const char * fortio_filename_ref(const fortio_type * fortio) { return (const char *) fortio->filename; }

View File

@ -0,0 +1,73 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_index_list.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/util.h>
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_index_list.h>
#define NNC_INDEX_LIST_TYPE_ID 87225078
struct nnc_index_list_struct {
UTIL_TYPE_ID_DECLARATION;
int_vector_type *index_list;
int lgr_nr;
bool sorted;
};
UTIL_IS_INSTANCE_FUNCTION( nnc_index_list , NNC_INDEX_LIST_TYPE_ID )
nnc_index_list_type * nnc_index_list_alloc() {
nnc_index_list_type * nnc_index_list = util_malloc( sizeof * nnc_index_list );
UTIL_TYPE_ID_INIT(nnc_index_list , NNC_INDEX_LIST_TYPE_ID);
nnc_index_list->index_list = int_vector_alloc(0 , 0 );
nnc_index_list->sorted = true;
return nnc_index_list;
}
void nnc_index_list_free( nnc_index_list_type * nnc_index_list ) {
int_vector_free( nnc_index_list->index_list );
free( nnc_index_list );
}
const int_vector_type * nnc_index_list_get_list( nnc_index_list_type * nnc_index_list) {
if (!nnc_index_list->sorted)
int_vector_select_unique( nnc_index_list->index_list );
nnc_index_list->sorted = true;
return nnc_index_list->index_list;
}
void nnc_index_list_add_index( nnc_index_list_type * nnc_index_list , int index) {
nnc_index_list->sorted = false;
int_vector_append( nnc_index_list->index_list , index );
}

View File

@ -0,0 +1,128 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_info.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 <ert/util/util.h>
#include <ert/util/vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_vector.h>
#define NNC_INFO_TYPE_ID 675415078
struct nnc_info_struct {
UTIL_TYPE_ID_DECLARATION;
vector_type * lgr_list; /*List of int vector * for nnc connections for LGRs*/
int_vector_type * lgr_index_map; /* A vector that maps LGR-nr to index into the LGR_list.*/
int lgr_nr; /* The lgr_nr of the cell holding this nnc_info structure. */
};
UTIL_IS_INSTANCE_FUNCTION( nnc_info , NNC_INFO_TYPE_ID )
nnc_info_type * nnc_info_alloc(int lgr_nr) {
nnc_info_type * nnc_info = util_malloc( sizeof * nnc_info );
UTIL_TYPE_ID_INIT(nnc_info , NNC_INFO_TYPE_ID);
nnc_info->lgr_list = vector_alloc_new();
nnc_info->lgr_index_map = int_vector_alloc(0, -1);
nnc_info->lgr_nr = lgr_nr;
return nnc_info;
}
void nnc_info_free( nnc_info_type * nnc_info ) {
vector_free(nnc_info->lgr_list);
int_vector_free(nnc_info->lgr_index_map);
free (nnc_info);
}
nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_nr) {
int lgr_index = int_vector_safe_iget( nnc_info->lgr_index_map , lgr_nr );
if (-1 == lgr_index)
return NULL;
else
return vector_iget( nnc_info->lgr_list , lgr_index );
}
nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index) {
return vector_iget( nnc_info->lgr_list , lgr_index );
}
nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info ) {
return nnc_info_get_vector( nnc_info , nnc_info->lgr_nr );
}
static void nnc_info_assert_vector( nnc_info_type * nnc_info , int lgr_nr ) {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr);
if (!nnc_vector) {
nnc_vector = nnc_vector_alloc( lgr_nr );
vector_append_owned_ref( nnc_info->lgr_list , nnc_vector , nnc_vector_free__ );
int_vector_iset( nnc_info->lgr_index_map , lgr_nr , vector_get_size( nnc_info->lgr_list ) - 1 );
}
}
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number) {
nnc_info_assert_vector( nnc_info , lgr_nr );
{
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr );
nnc_vector_add_nnc( nnc_vector , global_cell_number );
}
}
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr) {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr );
if (nnc_vector)
return nnc_vector_get_index_list( nnc_vector );
else
return NULL;
}
const int_vector_type * nnc_info_iget_index_list(const nnc_info_type * nnc_info, int lgr_index) {
nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index );
return nnc_vector_get_index_list( nnc_vector );
}
const int_vector_type * nnc_info_get_self_index_list(const nnc_info_type * nnc_info) {
return nnc_info_get_index_list( nnc_info , nnc_info->lgr_nr );
}
int nnc_info_get_lgr_nr( const nnc_info_type * nnc_info ) {
return nnc_info->lgr_nr;
}
int nnc_info_get_size( const nnc_info_type * nnc_info ) {
return vector_get_size( nnc_info->lgr_list );
}

View File

@ -0,0 +1,76 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_vector.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 <ert/util/util.h>
#include <ert/util/vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_vector.h>
#define NNC_VECTOR_TYPE_ID 875615078
struct nnc_vector_struct {
UTIL_TYPE_ID_DECLARATION;
int_vector_type *nnc_index_list;
int lgr_nr;
};
UTIL_IS_INSTANCE_FUNCTION( nnc_vector , NNC_VECTOR_TYPE_ID )
static UTIL_SAFE_CAST_FUNCTION(nnc_vector , NNC_VECTOR_TYPE_ID)
nnc_vector_type * nnc_vector_alloc(int lgr_nr) {
nnc_vector_type * nnc_vector = util_malloc( sizeof * nnc_vector );
UTIL_TYPE_ID_INIT(nnc_vector , NNC_VECTOR_TYPE_ID);
nnc_vector->nnc_index_list = int_vector_alloc(0, 0);
nnc_vector->lgr_nr = lgr_nr;
return nnc_vector;
}
void nnc_vector_free( nnc_vector_type * nnc_vector ) {
int_vector_free( nnc_vector->nnc_index_list );
free( nnc_vector );
}
void nnc_vector_free__(void * arg) {
nnc_vector_type * nnc_vector = nnc_vector_safe_cast( arg );
nnc_vector_free( nnc_vector );
}
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number) {
int_vector_append( nnc_vector->nnc_index_list , global_cell_number );
}
const int_vector_type * nnc_vector_get_index_list(const nnc_vector_type * nnc_vector) {
return nnc_vector->nnc_index_list;
}
int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) {
return nnc_vector->lgr_nr;
}

View File

@ -53,7 +53,7 @@
struct smspec_node_struct {
UTIL_TYPE_ID_DECLARATION;
char * gen_key1; /* The main composite key, i.e. WWCT:OP3 for this element. */
char * gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Mostly NULL. */
char * gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Some of the region_2_region elements will have both a xxx:num and a xxx:r2-r2 key. Mostly NULL. */
ecl_smspec_var_type var_type; /* The variable type */
char * wgname; /* The value of the WGNAMES vector for this element. */
char * keyword; /* The value of the KEYWORDS vector for this elements. */
@ -89,6 +89,8 @@ struct smspec_node_struct {
#define ECL_SUM_KEYFMT_GROUP "%s%s%s"
#define ECL_SUM_KEYFMT_WELL "%s%s%s"
#define ECL_SUM_KEYFMT_REGION "%s%s%d"
#define ECL_SUM_KEYFMT_REGION_2_REGION_R1R2 "%s%s%d-%d"
#define ECL_SUM_KEYFMT_REGION_2_REGION_NUM "%s%s%d"
#define ECL_SUM_KEYFMT_SEGMENT "%s%s%s%s%d"
#define ECL_SUM_KEYFMT_LOCAL_WELL "%s%s%s%s%s"
@ -119,6 +121,23 @@ char * smspec_alloc_region_key( const char * join_string , const char * keyword
num );
}
char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2) {
return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_R1R2,
keyword,
join_string,
r1,
r2);
}
char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num) {
return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_NUM,
keyword ,
join_string ,
num);
}
char * smspec_alloc_block_ijk_key( const char * join_string , const char * keyword , int i , int j , int k) {
return util_alloc_sprintf(ECL_SUM_KEYFMT_BLOCK_IJK ,
keyword,
@ -308,10 +327,11 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
file.
*/
{
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR)
smspec_node->need_nums = true;
else
@ -354,7 +374,7 @@ smspec_node_type * smspec_node_alloc_new(int params_index, float default_value)
node->keyword = NULL;
node->lgr_name = NULL;
node->lgr_ijk = NULL;
smspec_node_set_invalid_flags( node );
return node; // This is NOT usable
}
@ -446,9 +466,18 @@ static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const cha
// KEYWORD:NUM
smspec_node->gen_key1 = smspec_alloc_region_key( key_join_string , smspec_node->keyword , smspec_node->num);
break;
case(ECL_SMSPEC_SEGMENT_VAR):
// KEYWORD:WGNAME:NUM
smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num);
case (ECL_SMSPEC_SEGMENT_VAR):
// KEYWORD:WGNAME:NUM
smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num);
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
// KEYWORDS:RXF:NUM and RXF:R1-R2
smspec_node->gen_key1 = smspec_alloc_region_2_region_num_key( key_join_string , smspec_node->keyword , smspec_node->num);
{
int r1 = smspec_node->num % 32768;
int r2 = ((smspec_node->num-r1) / 32768)-10;
smspec_node->gen_key2 = smspec_alloc_region_2_region_r1r2_key( key_join_string , smspec_node->keyword , r1, r2);
}
break;
case(ECL_SMSPEC_MISC_VAR):
// KEYWORD
@ -549,7 +578,7 @@ bool smspec_node_init( smspec_node_type * smspec_node,
initOK = false;
break;
case(ECL_SMSPEC_SEGMENT_VAR):
if (wgnameOK) {
if (wgnameOK && num >= 0) {
smspec_node_set_wgname( smspec_node , wgname );
smspec_node_set_num( smspec_node , grid_dims , num );
} else
@ -563,6 +592,10 @@ bool smspec_node_init( smspec_node_type * smspec_node,
/* Region variable : NUM */
smspec_node_set_num( smspec_node , grid_dims , num );
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
/* Region 2 region variable : NUM */
smspec_node_set_num( smspec_node , grid_dims , num );
break;
case(ECL_SMSPEC_BLOCK_VAR):
/* A block variable : NUM*/
smspec_node_set_num( smspec_node , grid_dims , num );

View File

@ -1,123 +1,11 @@
add_executable( ecl_coarse_test ecl_coarse_test.c )
target_link_libraries( ecl_coarse_test ecl )
add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
if (BUILD_TESTS)
include( tests.cmake )
endif()
# The ecl_win64 application is not built as a proper test integrated
# into the CTEST system. Should be invoked manually on Windows.
if (ERT_WINDOWS)
add_executable( ecl_lfs ecl_lfs.c )
target_link_libraries( ecl_lfs ecl ert_util )
endif()
add_executable( ecl_restart_test ecl_restart_test.c )
target_link_libraries( ecl_restart_test ecl )
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
add_executable( ecl_grid_lgr_name ecl_grid_lgr_name.c )
target_link_libraries( ecl_grid_lgr_name ecl )
set_target_properties( ecl_grid_lgr_name PROPERTIES COMPILE_FLAGS "-Werror")
add_test( ecl_grid_lgr_name ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_lgr_name ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
add_executable( ecl_region ecl_region.c )
target_link_libraries( ecl_region ecl )
add_test( ecl_region ${EXECUTABLE_OUTPUT_PATH}/ecl_region ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_grid_case ecl_grid_case.c )
target_link_libraries( ecl_grid_case ecl )
add_test( ecl_grid_case ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_case ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_executable( ecl_lgr_test ecl_lgr_test.c )
target_link_libraries( ecl_lgr_test ecl )
add_test( ecl_lgr_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
add_test( ecl_lgr_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.GRID)
add_test( ecl_lgr_test3 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID )
add_executable( ecl_grid_simple ecl_grid_simple.c )
target_link_libraries( ecl_grid_simple ecl )
add_test( ecl_grid_simple ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_simple ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_grid_dims ecl_grid_dims.c )
target_link_libraries( ecl_grid_dims ecl )
add_test( ecl_grid_dims0 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims )
add_test( ecl_grid_dims1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT )
add_test( ecl_grid_dims2 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT)
add_test( ecl_grid_dims3 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_test( ecl_grid_dims4 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID )
add_test( ecl_grid_dims5 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.INIT )
add_executable( ecl_kw_grdecl ecl_kw_grdecl.c )
target_link_libraries( ecl_kw_grdecl ecl )
add_test( ecl_kw_grdecl ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_grdecl )
add_executable( ecl_kw_equal ecl_kw_equal.c )
target_link_libraries( ecl_kw_equal ecl )
add_test( ecl_kw_equal ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_equal )
add_executable( ecl_dualp ecl_dualp.c )
target_link_libraries( ecl_dualp ecl )
add_test( ecl_dualp ${EXECUTABLE_OUTPUT_PATH}/ecl_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
add_executable( ecl_util_month_range ecl_util_month_range.c )
target_link_libraries( ecl_util_month_range ecl )
add_test( ecl_util_month_range ${EXECUTABLE_OUTPUT_PATH}/ecl_util_month_range )
add_executable( ecl_sum_test ecl_sum_test.c )
target_link_libraries( ecl_sum_test ecl )
add_test( ecl_sum_test ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_executable( ecl_fortio ecl_fortio.c )
target_link_libraries( ecl_fortio ecl )
add_test( ecl_fortio ${EXECUTABLE_OUTPUT_PATH}/ecl_fortio ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
add_executable( ecl_file ecl_file.c )
target_link_libraries( ecl_file ecl )
add_test( ecl_file ${EXECUTABLE_OUTPUT_PATH}/ecl_file ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST)
add_executable( ecl_fmt ecl_fmt.c )
target_link_libraries( ecl_fmt ecl )
add_test( ecl_fmt ${EXECUTABLE_OUTPUT_PATH}/ecl_fmt ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.DATA)
add_executable( ecl_rsthead ecl_rsthead.c )
target_link_libraries( ecl_rsthead ecl )
add_test( ecl_rsthead ${EXECUTABLE_OUTPUT_PATH}/ecl_rsthead ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 )
add_executable( ecl_rft ecl_rft.c )
target_link_libraries( ecl_rft ecl )
add_test( ecl_rft_rft ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT RFT)
add_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/TEST1_1A.RFT PLT)
add_executable( ecl_rft_cell ecl_rft_cell.c )
target_link_libraries( ecl_rft_cell ecl )
add_test( ecl_rft_cell ${EXECUTABLE_OUTPUT_PATH}/ecl_rft_cell )
set_property( TEST ecl_fmt PROPERTY LABELS StatoilData )
set_property( TEST ecl_coarse_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_restart_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_lgr_test1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_lgr_test2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_lgr_test3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_lgr_name PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_simple PROPERTY LABELS StatoilData )
set_property( TEST ecl_dualp PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_fortio PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_dims1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_file PROPERTY LABELS StatoilData)
set_property( TEST ecl_rsthead PROPERTY LABELS StatoilData)
set_property( TEST ecl_region PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_case PROPERTY LABELS StatoilData)
set_property( TEST ecl_rft_rft PROPERTY LABELS StatoilData)
set_property( TEST ecl_rft_plt PROPERTY LABELS StatoilData)

View File

@ -0,0 +1,2 @@
PARALLEL
4 DISTRIBUTED/

View File

@ -0,0 +1,2 @@
PARALLEL
4 'DIST'/

View File

@ -21,6 +21,7 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_endian_flip.h>
@ -103,9 +104,12 @@ void test_close_stream1(const char * src_file , const char * target_file ) {
void test_writable(const char * src_file ) {
util_copy_file( src_file , "/tmp/ECL.UNRST" );
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" , true);
char * fname = util_split_alloc_filename( src_file );
test_work_area_copy_file( work_area , src_file );
{
ecl_file_type * ecl_file = ecl_file_open( "/tmp/ECL.UNRST" , ECL_FILE_WRITABLE);
ecl_file_type * ecl_file = ecl_file_open( fname , ECL_FILE_WRITABLE);
ecl_kw_type * swat = ecl_file_iget_named_kw( ecl_file , "SWAT" , 0 );
ecl_kw_type * swat0 = ecl_kw_alloc_copy( swat );
test_assert_true( ecl_kw_equal( swat , swat0 ));
@ -114,26 +118,30 @@ void test_writable(const char * src_file ) {
test_assert_true( ecl_file_writable( ecl_file ));
ecl_file_close( ecl_file );
ecl_file = ecl_file_open( "/tmp/ECL.UNRST" , 0);
ecl_file = ecl_file_open( fname , 0);
swat = ecl_file_iget_named_kw( ecl_file , "SWAT" , 0 );
test_assert_true( util_double_approx_equal( ecl_kw_iget_float( swat , 0 ) , 1000 ));
}
util_unlink_existing( "/tmp/ECL.UNRST" );
test_work_area_free( work_area );
}
int main( int argc , char ** argv) {
const char * src_file = argv[1];
const char * filename = argv[2];
char * target_file = util_alloc_filename("/tmp" , filename , NULL );
const char * target_file = argv[2];
test_flags( src_file );
test_loadall(src_file , target_file );
test_close_stream1( src_file , target_file );
test_close_stream2( src_file , target_file );
test_writable( src_file );
util_unlink_existing( target_file );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_file" , true);
test_work_area_install_file( work_area , src_file );
test_flags( src_file );
test_loadall(src_file , target_file );
test_close_stream1( src_file , target_file);
test_close_stream2( src_file , target_file);
test_writable( src_file );
test_work_area_free( work_area );
}
exit(0);
}

View File

@ -20,21 +20,22 @@
#include <unistd.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/util/test_util.h>
#include <ert/ecl/ecl_util.h>
void test_content( const char * src_file , bool fmt_file ) {
char * base_name , *path;
char * target_file;
bool fmt;
util_alloc_file_components( src_file , &path , &base_name , NULL);
target_file = util_alloc_filename( "/tmp" , base_name , NULL );
util_copy_file( src_file , target_file);
test_assert_true( ecl_util_fmt_file( target_file , &fmt ));
test_assert_bool_equal( fmt , fmt_file );
unlink( target_file );
void test_content( test_work_area_type * work_area , const char * src_file , bool fmt_file ) {
test_work_area_install_file( work_area , src_file );
{
char * base_name;
bool fmt;
util_alloc_file_components( src_file , NULL , &base_name , NULL);
util_copy_file( src_file , base_name );
test_assert_true( ecl_util_fmt_file( base_name , &fmt ));
test_assert_bool_equal( fmt , fmt_file );
}
}
@ -43,11 +44,11 @@ void test_content( const char * src_file , bool fmt_file ) {
void test_small( ) {
bool fmt;
FILE * stream = util_fopen("/tmp/small.txt" , "w");
FILE * stream = util_fopen("small.txt" , "w");
fprintf(stream , "Some bytes\n");
fclose( stream );
test_assert_false( ecl_util_fmt_file( "/tmp/small.txt" , &fmt ));
test_assert_false( ecl_util_fmt_file( "small.txt" , &fmt ));
}
@ -55,29 +56,32 @@ void test_small( ) {
int main(int argc , char ** argv) {
const char * binary_file = argv[1];
const char * text_file = argv[2];
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt" , true);
{
const char * binary_file = argv[1];
const char * text_file = argv[2];
bool fmt_file;
bool fmt_file;
test_assert_true( ecl_util_fmt_file( binary_file , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( binary_file , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( text_file , &fmt_file ));
test_assert_true( fmt_file );
test_assert_true( ecl_util_fmt_file( text_file , &fmt_file ));
test_assert_true( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.EGRID" , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.EGRID" , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.FEGRID" , &fmt_file ));
test_assert_true( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.FEGRID" , &fmt_file ));
test_assert_true( fmt_file );
test_assert_false(ecl_util_fmt_file( "TEST_DOES_NOT_EXIST" , &fmt_file ));
test_content( binary_file , false );
test_content( text_file , true );
test_small( );
test_assert_false(ecl_util_fmt_file( "TEST_DOES_NOT_EXIST" , &fmt_file ));
test_content( work_area , binary_file , false );
test_content( work_area , text_file , true );
test_small( );
}
test_work_area_free( work_area );
exit(0);
}

View File

@ -20,6 +20,7 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/fortio.h>
#include <ert/ecl/ecl_endian_flip.h>
@ -79,10 +80,15 @@ int main( int argc , char ** argv) {
test_existing_read( file );
test_not_existing_read( );
test_write( "/tmp/file.x" , true );
test_write( "/tmp/path/does/not/exist" , false );
test_open_close_read( file );
test_wrapper( file );
test_write( "/tmp/path/does/not/exist" , false );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" , true );
util_make_path("path");
test_write( "path/file.x" , true );
test_work_area_free( work_area );
}
exit(0);
}

View File

@ -0,0 +1,33 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'ecl_get_num_cpu_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/ecl/ecl_util.h>
int main(int argc , char ** argv) {
const char * filename1 = argv[1];
const char * filename2 = argv[2];
int num_cpu = 4;
test_assert_int_equal(ecl_util_get_num_cpu(filename1), num_cpu);
test_assert_int_equal(ecl_util_get_num_cpu(filename2), num_cpu);
exit(0);
}

View File

@ -20,6 +20,8 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/ecl_kw.h>
int main(int argc , char ** argv) {
@ -30,6 +32,7 @@ int main(int argc , char ** argv) {
ecl_kw_iset_int(ecl_kw , i , i );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl" , true);
FILE * stream = util_fopen( "FILE.grdecl" , "w");
ecl_kw_fprintf_grdecl(ecl_kw , stream );
@ -62,7 +65,7 @@ int main(int argc , char ** argv) {
ecl_kw_free( ecl_kw2 );
}
fclose( stream );
test_work_area_free( work_area );
}
ecl_kw_free( ecl_kw );

View File

@ -0,0 +1,91 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_win64.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/rng.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_endian_flip.h>
int main( int argc , char ** argv) {
int num_kw = 1000; // Total file size should roughly exceed 2GB
int kw_size = 600000;
ecl_kw_type * kw = ecl_kw_alloc("KW" , kw_size , ECL_INT_TYPE );
rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT );
int i;
offset_type file_size;
for (i=0; i < kw_size; i++)
ecl_kw_iset_int( kw , i , rng_get_int( rng , 912732 ));
{
fortio_type * fortio = fortio_open_writer( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP);
for (i = 0; i < num_kw; i++) {
printf("Writing keyword %d/%d to file:LARGE_FILE.UNRST \n",i+1 , num_kw );
ecl_kw_fwrite( kw , fortio );
}
fortio_fclose( fortio );
}
/*{
fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP);
for (i = 0; i < num_kw - 1; i++) {
printf("SKipping keyword %d/%d from file:LARGE_FILE.UNRST \n",i+1 , num_kw );
ecl_kw_fskip( fortio );
}
{
ecl_kw_type * file_kw = ecl_kw_fread_alloc( fortio );
if (ecl_kw_equal( kw , file_kw ))
printf("Keyword read back from file correctly :-) \n");
else
printf("Fatal error - keyword different on return ...\n");
ecl_kw_free( file_kw );
}
fortio_fclose( fortio );
}
*/
file_size = util_file_size( "LARGE_FILE.UNRST" );
printf("File size: %lld \n",file_size);
{
fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP);
printf("Seeking to file end: ");
fortio_fseek( fortio , file_size , SEEK_SET);
fortio_fclose( fortio );
printf("Seek OK \n");
}
printf("Doing ecl_file_open(..)\n");
{
ecl_file_type * file = ecl_file_open( "LARGE_FILE.UNRST" , 0);
ecl_kw_type * file_kw = ecl_file_iget_named_kw( file , "KW" , num_kw - 1);
if (ecl_kw_equal( kw , file_kw ))
printf("Keyword read back from file correctly :-) \n");
else
printf("Fatal error - keyword different on return ...\n");
ecl_file_close( file );
}
remove( "LARGE_FILE.UNRST" );
exit(0);
}

View File

@ -0,0 +1,44 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_lgr_name.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>
int main( int argc , char ** argv) {
ecl_grid_type * grid = ecl_grid_alloc( argv[1] );
int num_lgr = ecl_grid_get_num_lgr( grid );
int lgr_index;
for (lgr_index = 0; lgr_index < num_lgr; lgr_index++) {
ecl_grid_type * lgr_from_index = ecl_grid_iget_lgr( grid, lgr_index );
int lgr_nr = ecl_grid_get_lgr_nr( lgr_from_index);
ecl_grid_type * lgr_from_nr = ecl_grid_get_lgr_from_lgr_nr( grid , lgr_nr);
test_assert_ptr_equal( lgr_from_index , lgr_from_nr );
test_assert_string_equal( ecl_grid_get_lgr_name( grid , lgr_nr) , ecl_grid_iget_lgr_name( grid , lgr_index));
printf("Grid[%d:%d] : %s \n",lgr_index , lgr_nr , ecl_grid_iget_lgr_name( grid , lgr_index ));
}
ecl_grid_free( grid );
exit(0);
}

View File

@ -0,0 +1,103 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_index_list.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/util/int_vector.h>
#include <ert/ecl/nnc_index_list.h>
void test_create() {
nnc_index_list_type * index_list = nnc_index_list_alloc();
test_assert_true( nnc_index_list_is_instance( index_list ));
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 0 , int_vector_size( list ));
}
nnc_index_list_free( index_list );
}
void test_content() {
nnc_index_list_type * index_list = nnc_index_list_alloc();
nnc_index_list_add_index( index_list , 0 );
nnc_index_list_add_index( index_list , 1 );
nnc_index_list_add_index( index_list , 2 );
nnc_index_list_add_index( index_list , 3 );
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 4 , int_vector_size( list ));
test_assert_int_equal( 0 , int_vector_iget( list , 0));
test_assert_int_equal( 1 , int_vector_iget( list , 1));
test_assert_int_equal( 2 , int_vector_iget( list , 2));
test_assert_int_equal( 3 , int_vector_iget( list , 3));
}
nnc_index_list_free( index_list );
}
void test_sort_unique() {
nnc_index_list_type * index_list = nnc_index_list_alloc();
nnc_index_list_add_index( index_list , 3 );
nnc_index_list_add_index( index_list , 1 );
nnc_index_list_add_index( index_list , 2 );
nnc_index_list_add_index( index_list , 0 );
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 4 , int_vector_size( list ));
test_assert_int_equal( 0 , int_vector_iget( list , 0));
test_assert_int_equal( 1 , int_vector_iget( list , 1));
test_assert_int_equal( 2 , int_vector_iget( list , 2));
test_assert_int_equal( 3 , int_vector_iget( list , 3));
}
nnc_index_list_add_index( index_list , 3 );
nnc_index_list_add_index( index_list , 1 );
nnc_index_list_add_index( index_list , 2 );
nnc_index_list_add_index( index_list , 0 );
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 4 , int_vector_size( list ));
test_assert_int_equal( 0 , int_vector_iget( list , 0));
test_assert_int_equal( 1 , int_vector_iget( list , 1));
test_assert_int_equal( 2 , int_vector_iget( list , 2));
test_assert_int_equal( 3 , int_vector_iget( list , 3));
}
nnc_index_list_free( index_list );
}
int main( int argc , char ** argv) {
test_create();
test_content();
test_sort_unique();
exit(0);
}

View File

@ -0,0 +1,60 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_index_list_grid.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/util/int_vector.h>
#include <ert/ecl/nnc_index_list.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_file.h>
int main( int argc , char ** argv) {
const char * egrid_file = argv[1];
ecl_grid_type * grid = ecl_grid_alloc( egrid_file );
ecl_file_type * gfile = ecl_file_open( egrid_file , 0 );
const ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( gfile , "NNC1" ,0 );
const ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( gfile , "NNC2" ,0 );
const int_vector_type * index_list = ecl_grid_get_nnc_index_list( grid );
{
int_vector_type * nnc = int_vector_alloc(0,0);
int_vector_set_many( nnc , 0 , ecl_kw_get_ptr( nnc1_kw ) , ecl_kw_get_size( nnc1_kw ));
int_vector_append_many( nnc , ecl_kw_get_ptr( nnc2_kw ) , ecl_kw_get_size( nnc2_kw ));
int_vector_select_unique( nnc );
test_assert_int_equal( int_vector_size( index_list ) , int_vector_size( nnc ));
{
int i;
for (i=0; i < int_vector_size( nnc ); i++)
test_assert_int_equal( int_vector_iget( nnc , i ) - 1 , int_vector_iget(index_list , i ));
}
int_vector_free( nnc );
}
ecl_file_close( gfile );
ecl_grid_free( grid );
exit(0);
}

View File

@ -0,0 +1,66 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_info_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/util/int_vector.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_vector.h>
int main(int argc , char ** argv) {
int lgr_nr = 77;
nnc_info_type * nnc_info = nnc_info_alloc(lgr_nr);
test_assert_int_equal( lgr_nr , nnc_info_get_lgr_nr( nnc_info ));
test_assert_true(nnc_info_is_instance(nnc_info));
test_assert_not_NULL(nnc_info);
nnc_info_add_nnc(nnc_info, 1, 110);
nnc_info_add_nnc(nnc_info, 1, 111);
const nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
const int_vector_type * nnc_cells = nnc_info_get_index_list(nnc_info, 1);
test_assert_int_equal(int_vector_size(nnc_cells), 2);
test_assert_ptr_equal( nnc_cells , nnc_vector_get_index_list( nnc_vector ));
const nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
const int_vector_type * nnc_cells_null = nnc_info_get_index_list(nnc_info, 2);
test_assert_NULL(nnc_cells_null);
test_assert_NULL(nnc_vector_null);
const nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr );
test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );
const int_vector_type * nnc_cells_77 = nnc_info_get_index_list(nnc_info, lgr_nr);
const int_vector_type * nnc_cells_self = nnc_info_get_self_index_list(nnc_info);
test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );
test_assert_int_equal( 1 , nnc_info_get_size( nnc_info ));
test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 0 ));
nnc_info_free(nnc_info);
exit(0);
}

View File

@ -0,0 +1,341 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_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/util/int_vector.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/nnc_info.h>
void test_nnc_global_grid( const char * grid_filename ) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
const int data[] = {2675, 5235, 7795, 10355, 12915, 15475, 18035, 20595, 23155, 25715, 28275, 30835, 33395};
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 114);
test_assert_not_NULL( nnc_info );
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
ecl_grid_free(ecl_grid);
}
void test_nnc_dual_poro(const char * grid_filename ) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
ecl_grid_free(ecl_grid);
}
void test_nnc_lgr( const char * grid_filename ) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
//Global grid
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 125132);
test_assert_not_NULL( nnc_info );
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), 1);
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, 0), 151053);
//LGR
const int data[] = {126394, 126305};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL( lgr_grid );
const nnc_info_type * lgr_nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 2017-1);
test_assert_not_NULL( lgr_nnc_info );
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( lgr_nnc_info ));
const int_vector_type * lgr_nnc_cell_number_vec = nnc_info_get_index_list(lgr_nnc_info, 0);
test_assert_not_NULL(lgr_nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(lgr_nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(lgr_nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(lgr_nnc_cell_number_vec, i), data[i]);
ecl_grid_free(ecl_grid);
}
void test_nnc_multiple_lgr( const char * grid_filename) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
{
//Global grid, check NNC for cell with global index 736
int data[] = {11957, 20336, 3528, 6321, 9114, 11907, 20286};
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 736);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++) {
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
//Check grid name
test_assert_string_equal(ecl_grid_get_name(ecl_grid), grid_filename);
}
{
//Global grid, check NNC for cell with global index 138291
int data[] = {141035, 143828, 141085, 143878};
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 138291);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++) {
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
}
{
//LGR nr 1, cell global index 0: check NNCs to main grid
int data[] = {29012, 26220};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 0);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i = 0;
for (; i < int_vector_size(nnc_cell_number_vec); ++i)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG006023");
}
{
//LGR nr 1, cell global index 0: check NNCs to grid with lgr nr 20
int data[] = {12};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 0);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 20);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i = 0;
for (; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
{
//LGR nr 3, check NNC for cell with global index 8
int data[] = {20681, 23474, 26267, 37440};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 2);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 8);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check LGR name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG005024");
}
{
//LGR nr 99, check NNC for cell with global index 736
int data[] = {126671, 79142};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 98-1); //Subtract 1: LGR nr 98 is not present in the test file. LGRs are numbered 1-97 and 99-110 in test file.
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 736);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check LGR name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG008021");
}
{
//LGR nr 110, cell with global index 271: Check NNCs to global grid
int data[] = {20191, 22983};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 109-1); //Subtract 1: LGR nr 98 is not present in the test file. LGRs are numbered 1-97 and 99-110 in test file.
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 271);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check LGR name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG003014");
}
{
//LGR nr 110, cell with global index 271: Check NNCs to lgr nr 109
int data[] = {275};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 109-1); //Subtract 1: LGR nr 98 is not present in the test file. LGRs are numbered 1-97 and 99-110 in test file.
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 271);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 109);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
{
//Test global versus ijk indexing
const nnc_info_type * nnc_info1 = ecl_grid_get_cell_nnc_info1(ecl_grid, 736);
test_assert_not_NULL(nnc_info1);
int i = 0;
int j = 0;
int k = 0;
ecl_grid_get_ijk1(ecl_grid, 736, &i, &j, &k);
const nnc_info_type * nnc_info2 = ecl_grid_get_cell_nnc_info3(ecl_grid, i, j, k);
test_assert_not_NULL(nnc_info2);
test_assert_ptr_equal(nnc_info1, nnc_info2);
}
ecl_grid_free(ecl_grid);
}
void test_nnc_amalgamated_lgrs(const char * grid_filename) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
//Get the NNC info for cell with global index 0 in LGR nr 1
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 0);
test_assert_not_NULL(nnc_info);
//Get the connections that this cell has to LGR 20
const int_vector_type * nnc_lgr_20 = nnc_info_get_index_list(nnc_info, 20);
test_assert_not_NULL(nnc_lgr_20);
test_assert_int_equal(int_vector_size(nnc_lgr_20), 1);
test_assert_int_equal(int_vector_iget(nnc_lgr_20, 0), 12);
ecl_grid_free(ecl_grid);
}
int main(int argc , char ** argv) {
const char * EGRID_file1 = argv[1];
const char * EGRID_file2 = argv[2];
const char * EGRID_file3 = argv[3];
const char * EGRID_file4 = argv[4];
test_nnc_global_grid( EGRID_file1 );
test_nnc_lgr( EGRID_file2 );
test_nnc_multiple_lgr( EGRID_file3 );
test_nnc_amalgamated_lgrs(EGRID_file3);
test_nnc_dual_poro( EGRID_file4 );
exit(0);
}

View File

@ -0,0 +1,49 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_vector.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/int_vector.h>
#include <ert/ecl/nnc_vector.h>
int main(int argc , char ** argv) {
int lgr_nr = 100;
nnc_vector_type * vector = nnc_vector_alloc( lgr_nr );
test_assert_true( nnc_vector_is_instance( vector ));
test_assert_int_equal( lgr_nr , nnc_vector_get_lgr_nr( vector ));
nnc_vector_add_nnc( vector , 100 );
nnc_vector_add_nnc( vector , 200 );
nnc_vector_add_nnc( vector , 300 );
{
const int_vector_type * index_list = nnc_vector_get_index_list( vector );
test_assert_int_equal( 3 , int_vector_size( index_list ));
test_assert_int_equal( 100 , int_vector_iget( index_list , 0 ));
test_assert_int_equal( 200 , int_vector_iget( index_list , 1 ));
test_assert_int_equal( 300 , int_vector_iget( index_list , 2 ));
}
nnc_vector_free( vector );
exit(0);
}

View File

@ -0,0 +1,70 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'ecl_region2region.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_sum.h>
void has_r2r_key(const ecl_sum_type* ecl_sum) {
test_assert_true(ecl_sum_has_key( ecl_sum , "RGF:393217" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RGF:1-2" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "ROF:524291" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RWF:393222" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RWF:6-2" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "ROF:3-6" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RNLF:458753" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RNLF:1-4" ));
}
void get_unit(const ecl_sum_type* ecl_sum) {
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "RGF:1-2" ), "GFLOW");
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "ROF:3-6" ), "OFLOW");
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "RWF:6-2" ), "WFLOW");
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "RNLF:1-4" ), "NLFLOW");
}
void get_var_params_index(const ecl_sum_type* ecl_sum) {
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum , "RGF:1-2"), 21917);
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum , "ROF:3-6"), 21918);
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum, "RWF:6-2"), 21919);
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum, "RNLF:1-4"), 21920);
}
int main(int argc , char ** argv) {
const char * headerfile = argv[1];
ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( headerfile , ":");
if (ecl_sum) {
has_r2r_key(ecl_sum);
get_unit(ecl_sum);
get_var_params_index(ecl_sum);
}
else
test_error_exit("ecl_region2region_test: Test file not read correctly");
if (ecl_sum)
ecl_sum_free( ecl_sum );
exit(0);
}

View File

@ -36,10 +36,10 @@ void test_rft( const char * rft_file ) {
test_assert_int_equal( 14 , ecl_rft_node_get_size( rft_node ));
test_assert_false( ecl_rft_node_is_MSW( rft_node ));
test_assert_double_equal( 259.146 , ecl_rft_node_iget_pressure( rft_node , 0 ));
test_assert_double_equal( 0.0580598 , ecl_rft_node_iget_soil( rft_node , 0 ));
test_assert_double_equal( 0.940477 , ecl_rft_node_iget_swat( rft_node , 0 ));
test_assert_double_equal( 0.00146271 , ecl_rft_node_iget_sgas( rft_node , 0 ));
test_assert_double_equal( 260.6111 , ecl_rft_node_iget_pressure( rft_node , 0 ));
test_assert_double_equal( 0.0581993 , ecl_rft_node_iget_soil( rft_node , 0 ));
test_assert_double_equal( 0.9405648 , ecl_rft_node_iget_swat( rft_node , 0 ));
test_assert_double_equal( 0.00123579 , ecl_rft_node_iget_sgas( rft_node , 0 ));
{
int i,j,k;
@ -67,9 +67,26 @@ void test_rft( const char * rft_file ) {
}
// Have no such case yet ...
void test_plt_msw( const char * plt_file ) {
ecl_rft_file_type * plt = ecl_rft_file_alloc( plt_file );
ecl_rft_node_type * plt_node = ecl_rft_file_iget_node( plt , 11 );
test_assert_true( ecl_rft_node_is_PLT( plt_node ));
test_assert_true( ecl_rft_node_is_MSW( plt_node ));
test_assert_int_equal( 22 , ecl_rft_node_get_size( plt_node ));
ecl_rft_node_inplace_sort_cells( plt_node );
{
int i;
for (i=1; i < ecl_rft_node_get_size( plt_node ); i++) {
const ecl_rft_cell_type * prev_cell = ecl_rft_node_iget_cell( plt_node , i - 1);
const ecl_rft_cell_type * this_cell = ecl_rft_node_iget_cell( plt_node , i );
test_assert_true( ecl_rft_cell_get_connection_start( prev_cell ) < ecl_rft_cell_get_connection_start( this_cell ));
test_assert_true( ecl_rft_cell_get_connection_end( prev_cell ) < ecl_rft_cell_get_connection_end( this_cell ));
}
}
ecl_rft_file_free( plt );
}

View File

@ -68,6 +68,7 @@ void test_rft_cell() {
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_wrat( cell ));
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_flowrate( cell ));
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_connection_start( cell ));
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_connection_end( cell ));
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_oil_flowrate( cell ));
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_gas_flowrate( cell ));
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_water_flowrate( cell ));
@ -97,11 +98,12 @@ void test_plt_cell() {
const double wrat = 0.45;
const double flowrate = 100.0;
const double connection_start = 891;
const double connection_end = 979;
const double oil_flowrate = 0.891;
const double gas_flowrate = 7771;
const double water_flowrate = 77614;
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_PLT(i,j,k,depth,pressure,orat,grat,wrat,connection_start,flowrate,oil_flowrate , gas_flowrate , water_flowrate);
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_PLT(i,j,k,depth,pressure,orat,grat,wrat,connection_start,connection_end, flowrate,oil_flowrate , gas_flowrate , water_flowrate);
test_assert_int_equal( i , ecl_rft_cell_get_i( cell ));
test_assert_int_equal( j , ecl_rft_cell_get_j( cell ));
@ -122,6 +124,7 @@ void test_plt_cell() {
test_assert_double_equal( grat , ecl_rft_cell_get_grat( cell ));
test_assert_double_equal( wrat , ecl_rft_cell_get_wrat( cell ));
test_assert_double_equal( connection_start, ecl_rft_cell_get_connection_start( cell ));
test_assert_double_equal( connection_end, ecl_rft_cell_get_connection_end( cell ));
test_assert_double_equal(flowrate , ecl_rft_cell_get_flowrate( cell ));
test_assert_double_equal(oil_flowrate , ecl_rft_cell_get_oil_flowrate( cell ));

View File

@ -0,0 +1,49 @@
/*
Copyright (C) 2013 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/time_t_vector.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_sum.h>
int main( int argc , char ** argv) {
const char * case1 = argv[1];
const char * case2 = argv[2];
const char * compatible_string = argv[3];
bool compatible;
ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":");
ecl_sum_type * ecl_sum2 = ecl_sum_fread_alloc_case( case2 , ":");
test_assert_true( ecl_sum_is_instance( ecl_sum1 ));
test_assert_true( ecl_sum_is_instance( ecl_sum2 ));
test_assert_true( ecl_sum_report_step_compatible( ecl_sum1 , ecl_sum1) );
test_assert_true( util_sscanf_bool( compatible_string , &compatible ));
test_assert_true( ecl_sum_report_step_compatible( ecl_sum1 , ecl_sum1) );
test_assert_true( ecl_sum_report_step_compatible( ecl_sum2 , ecl_sum2) );
test_assert_bool_equal( compatible , ecl_sum_report_step_compatible( ecl_sum1 , ecl_sum2 ));
ecl_sum_free( ecl_sum1 );
ecl_sum_free( ecl_sum2 );
exit(0);
}

View File

@ -0,0 +1,49 @@
/*
Copyright (C) 2013 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/time_t_vector.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_sum.h>
int main( int argc , char ** argv) {
const char * case1 = argv[1];
const char * case2 = argv[2];
const char * equal_string = argv[3];
bool equal;
ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":");
ecl_sum_type * ecl_sum2 = ecl_sum_fread_alloc_case( case2 , ":");
test_assert_true( ecl_sum_is_instance( ecl_sum1 ));
test_assert_true( ecl_sum_is_instance( ecl_sum2 ));
test_assert_true( ecl_sum_report_step_equal( ecl_sum1 , ecl_sum1) );
test_assert_true( util_sscanf_bool( equal_string , &equal ));
test_assert_true( ecl_sum_report_step_equal( ecl_sum1 , ecl_sum1) );
test_assert_true( ecl_sum_report_step_equal( ecl_sum2 , ecl_sum2) );
test_assert_bool_equal( equal , ecl_sum_report_step_equal( ecl_sum1 , ecl_sum2 ));
ecl_sum_free( ecl_sum1 );
ecl_sum_free( ecl_sum2 );
exit(0);
}

View File

@ -60,14 +60,16 @@ void test_is_oil_producer( const ecl_sum_type * ecl_sum) {
int main( int argc , char ** argv) {
const char * casename = argv[1];
ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( casename , ":");
test_time_range( ecl_sum );
test_days( ecl_sum );
test_is_oil_producer(ecl_sum);
const char * case1 = argv[1];
ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":");
test_assert_true( ecl_sum_is_instance( ecl_sum1 ));
test_time_range( ecl_sum1 );
test_days( ecl_sum1 );
test_is_oil_producer(ecl_sum1);
ecl_sum_free( ecl_sum1 );
exit(0);
}

View File

@ -0,0 +1,175 @@
add_executable( ecl_coarse_test ecl_coarse_test.c )
target_link_libraries( ecl_coarse_test ecl test_util )
add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
add_executable( ecl_restart_test ecl_restart_test.c )
target_link_libraries( ecl_restart_test ecl test_util )
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
add_executable( ecl_grid_lgr_name ecl_grid_lgr_name.c )
target_link_libraries( ecl_grid_lgr_name ecl test_util )
set_target_properties( ecl_grid_lgr_name PROPERTIES COMPILE_FLAGS "-Werror")
add_test( ecl_grid_lgr_name ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_lgr_name ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
add_executable( ecl_region ecl_region.c )
target_link_libraries( ecl_region ecl test_util )
add_test( ecl_region ${EXECUTABLE_OUTPUT_PATH}/ecl_region ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_region2region ecl_region2region_test.c )
target_link_libraries( ecl_region2region ecl test_util )
add_test( ecl_region2region ${EXECUTABLE_OUTPUT_PATH}/ecl_region2region ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/R2R/R2R.SMSPEC )
add_executable( ecl_grid_case ecl_grid_case.c )
target_link_libraries( ecl_grid_case ecl test_util )
add_test( ecl_grid_case ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_case ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_executable( ecl_lgr_test ecl_lgr_test.c )
target_link_libraries( ecl_lgr_test ecl test_util )
add_test( ecl_lgr_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
add_test( ecl_lgr_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.GRID)
add_test( ecl_lgr_test3 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID )
add_executable( ecl_grid_simple ecl_grid_simple.c )
target_link_libraries( ecl_grid_simple ecl test_util )
add_test( ecl_grid_simple ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_simple ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_grid_dims ecl_grid_dims.c )
target_link_libraries( ecl_grid_dims ecl test_util )
add_test( ecl_grid_dims0 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims )
add_test( ecl_grid_dims1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT )
add_test( ecl_grid_dims2 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT)
add_test( ecl_grid_dims3 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_test( ecl_grid_dims4 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID )
add_test( ecl_grid_dims5 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.INIT )
add_executable( ecl_nnc_test ecl_nnc_test.c )
target_link_libraries( ecl_nnc_test ecl test_util )
add_test (ecl_nnc_test ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUAL_DIFF.EGRID )
add_executable( ecl_nnc_info_test ecl_nnc_info_test.c )
target_link_libraries( ecl_nnc_info_test ecl test_util )
add_test (ecl_nnc_info_test ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_info_test )
add_executable( ecl_kw_grdecl ecl_kw_grdecl.c )
target_link_libraries( ecl_kw_grdecl ecl test_util )
add_test( ecl_kw_grdecl ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_grdecl )
add_executable( ecl_kw_equal ecl_kw_equal.c )
target_link_libraries( ecl_kw_equal ecl test_util )
add_test( ecl_kw_equal ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_equal )
add_executable( ecl_dualp ecl_dualp.c )
target_link_libraries( ecl_dualp ecl test_util )
add_test( ecl_dualp ${EXECUTABLE_OUTPUT_PATH}/ecl_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
add_executable( ecl_util_month_range ecl_util_month_range.c )
target_link_libraries( ecl_util_month_range ecl test_util )
add_test( ecl_util_month_range ${EXECUTABLE_OUTPUT_PATH}/ecl_util_month_range )
add_executable( ecl_sum_test ecl_sum_test.c )
target_link_libraries( ecl_sum_test ecl test_util )
add_test( ecl_sum_test ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_executable( ecl_sum_report_step_equal ecl_sum_report_step_equal.c )
target_link_libraries( ecl_sum_report_step_equal ecl test_util )
add_test( ecl_sum_report_step_equal1 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE FALSE)
add_test( ecl_sum_report_step_equal2 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE TRUE)
add_test( ecl_sum_report_step_equal3 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/extraMinistep/ECLIPSE TRUE)
add_test( ecl_sum_report_step_equal4 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/short/ECLIPSE FALSE)
add_test( ecl_sum_report_step_equal5 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/enkf/ECLIPSE FALSE)
add_test( ecl_sum_report_step_equal6 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre2/SNORRE2 FALSE)
add_executable( ecl_sum_report_step_compatible ecl_sum_report_step_compatible.c )
target_link_libraries( ecl_sum_report_step_compatible ecl test_util )
add_test( ecl_sum_report_step_compatible1 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE FALSE)
add_test( ecl_sum_report_step_compatible2 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible3 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/extraMinistep/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible4 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/short/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible5 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/enkf/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible6 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre2/SNORRE2 FALSE)
add_executable( ecl_fortio ecl_fortio.c )
target_link_libraries( ecl_fortio ecl test_util )
add_test( ecl_fortio ${EXECUTABLE_OUTPUT_PATH}/ecl_fortio ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
add_executable( ecl_file ecl_file.c )
target_link_libraries( ecl_file ecl test_util )
add_test( ecl_file ${EXECUTABLE_OUTPUT_PATH}/ecl_file ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST)
add_executable( ecl_fmt ecl_fmt.c )
target_link_libraries( ecl_fmt ecl test_util )
add_test( ecl_fmt ${EXECUTABLE_OUTPUT_PATH}/ecl_fmt ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.DATA)
add_executable( ecl_rsthead ecl_rsthead.c )
target_link_libraries( ecl_rsthead ecl test_util )
add_test( ecl_rsthead ${EXECUTABLE_OUTPUT_PATH}/ecl_rsthead ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 )
add_executable( ecl_rft ecl_rft.c )
target_link_libraries( ecl_rft ecl test_util )
add_test( ecl_rft_rft ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT RFT)
add_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/TEST1_1A.RFT PLT)
add_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/RFT2.RFT MSW-PLT)
add_executable( ecl_rft_cell ecl_rft_cell.c )
target_link_libraries( ecl_rft_cell ecl test_util )
add_test( ecl_rft_cell ${EXECUTABLE_OUTPUT_PATH}/ecl_rft_cell )
add_executable( ecl_get_num_cpu ecl_get_num_cpu_test.c )
target_link_libraries( ecl_get_num_cpu ecl test_util )
add_test( ecl_get_num_cpu ${EXECUTABLE_OUTPUT_PATH}/ecl_get_num_cpu ${PROJECT_SOURCE_DIR}/libecl/tests/data/num_cpu1 ${PROJECT_SOURCE_DIR}/libecl/tests/data/num_cpu2)
set_property( TEST ecl_fmt PROPERTY LABELS StatoilData )
set_property( TEST ecl_coarse_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_restart_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_lgr_test1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_lgr_test2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_lgr_test3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_lgr_name PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_simple PROPERTY LABELS StatoilData )
set_property( TEST ecl_dualp PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal6 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible6 PROPERTY LABELS StatoilData )
set_property( TEST ecl_fortio PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_dims1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_test PROPERTY LABELS StatoilData )
set_property( TEST ecl_file PROPERTY LABELS StatoilData)
set_property( TEST ecl_rsthead PROPERTY LABELS StatoilData)
set_property( TEST ecl_region PROPERTY LABELS StatoilData)
set_property( TEST ecl_region2region PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_case PROPERTY LABELS StatoilData)
set_property( TEST ecl_rft_rft PROPERTY LABELS StatoilData)
set_property( TEST ecl_rft_plt PROPERTY LABELS StatoilData)

View File

@ -1,9 +1,11 @@
add_executable( well_info_test well_info_test.c )
add_executable( segment_info segment_info.c )
set(program_list well_info_test segment_info )
set(program_list segment_info )
foreach(prog ${program_list})
target_link_libraries( ${prog} ecl_well ecl)
if (USE_RUNPATH)
add_runpath( ${prog} )
endif()
#-----------------------------------------------------------------

View File

@ -21,7 +21,6 @@
#include <math.h>
#include <ert/util/stringlist.h>
#include <ert/util/util.h>
#include <ert/util/test_util.h>
#include <ert/ecl/ecl_util.h>
@ -46,7 +45,6 @@ int main(int argc , char ** argv) {
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( rst_file , ZWEL_KW , 0 );
test_install_SIGNALS();
{
int well_nr;
for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
@ -79,7 +77,7 @@ int main(int argc , char ** argv) {
printf("Branch : %d \n",well_segment_get_branch_id( segment ));
printf("Connections : [");
{
well_conn_collection_type * connections = well_segment_get_global_connections( segment );
const well_conn_collection_type * connections = well_segment_get_global_connections( segment );
if (connections) {
int ic;
for (ic = 0; ic < well_conn_collection_get_size( connections ); ic++) {

View File

@ -1,101 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_info_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 <time.h>
#include <stdbool.h>
#include <signal.h>
#include <ert/util/util.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/ecl_kw_magic.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl_well/well_state.h>
#include <ert/ecl_well/well_info.h>
#include <ert/ecl_well/well_conn.h>
#include <ert/ecl_well/well_ts.h>
int main( int argc , char ** argv) {
signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */
signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace.
Killing with SIGKILL (-9) will not give a backtrace.*/
signal(SIGABRT , util_abort_signal); /* Signal abort. */
{
well_info_type * well_info = well_info_alloc( NULL );
int i;
for (i=1; i < argc; i++) {
printf("Loading file: %s \n",argv[i]);
well_info_load_rstfile( well_info , argv[i]);
}
// List all wells:
{
int iwell;
for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) {
well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , iwell));
well_state_type * well_state = well_ts_get_last_state( well_ts );
well_state_summarize( well_state , stdout );
printf("\n");
}
}
well_info_free( well_info );
exit(1);
// Look at the timeseries for one well:
{
well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , 0));
int i;
for (i =0; i < well_ts_get_size( well_ts ); i++) {
well_state_type * well_state = well_ts_iget_state( well_ts , i );
printf("Well:%s report:%04d state:",well_state_get_name( well_state ), well_state_get_report_nr( well_state ));
if (well_state_is_open( well_state ))
printf("OPEN\n");
else
printf("CLOSED\n");
}
}
// Look at one well_state:
{
well_state_type * well_state = well_info_iiget_state( well_info , 0 , 0 );
printf("Well:%s report:%04d \n",well_state_get_name( well_state ), well_state_get_report_nr( well_state ));
{
const well_conn_type ** connections = well_state_get_connections( well_state , 0 );
printf("Branches: %d \n",well_state_get_num_branches( well_state ));
printf("num_connections: %d \n",well_state_get_num_connections( well_state , 0 ));
{
int iconn;
for (iconn = 0; iconn < well_state_get_num_connections( well_state , 0 ); iconn++) {
const well_conn_type * conn = connections[ iconn ];
printf("Connection:%02d i=%3d j=%3d k=%3d State:",iconn , well_conn_get_i( conn ) , well_conn_get_j( conn ) , well_conn_get_k( conn ));
if (well_conn_open( conn ) )
printf("Open\n");
else
printf("Closed\n");
}
}
}
}
well_info_free( well_info );
}
}

View File

@ -13,6 +13,10 @@ include_directories( ${libgeometry_src_path} )
add_library( ecl_well ${LIBRARY_TYPE} ${source_files} )
set_target_properties( ecl_well PROPERTIES VERSION 1.0 SOVERSION 1.0 )
target_link_libraries( ecl_well ecl )
if (USE_RUNPATH)
add_runpath( ecl_well )
endif()
#-----------------------------------------------------------------
if (INSTALL_ERT)

View File

@ -336,16 +336,16 @@ static void well_state_add_LGR_connections( well_state_type * well_state , const
// Go through all the LGRs and add connections; both in the bulk
// grid and as wellhead.
int num_lgr = ecl_grid_get_num_lgr( grid );
int lgr_nr;
for (lgr_nr = 0; lgr_nr < num_lgr; lgr_nr++) {
int lgr_index;
for (lgr_index = 0; lgr_index < num_lgr; lgr_index++) {
ecl_file_push_block( ecl_file ); // <-------------------------//
{ //
ecl_file_subselect_block( ecl_file , LGR_KW , lgr_nr ); //
ecl_file_subselect_block( ecl_file , LGR_KW , lgr_index ); //
{ // Restrict the file view
const char * grid_name = ecl_grid_iget_lgr_name( grid , lgr_nr ); //
const char * grid_name = ecl_grid_iget_lgr_name( grid , lgr_index ); //
int well_nr = well_state_get_lgr_well_nr( well_state , ecl_file ); // to one LGR block.
if (well_nr >= 0) //
well_state_add_connections__( well_state , ecl_file , grid_name , lgr_nr + 1, well_nr ); //
well_state_add_connections__( well_state , ecl_file , grid_name , lgr_index + 1, well_nr ); //
} //
} //
ecl_file_pop_block( ecl_file ); // <-------------------------//

View File

@ -1,29 +1,29 @@
add_executable( well_conn_collection well_conn_collection.c )
target_link_libraries( well_conn_collection ecl_well )
target_link_libraries( well_conn_collection ecl_well test_util )
set_target_properties( well_conn_collection PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_conn_collection ${EXECUTABLE_OUTPUT_PATH}/well_conn_collection )
add_executable( well_branch_collection well_branch_collection.c )
target_link_libraries( well_branch_collection ecl_well )
target_link_libraries( well_branch_collection ecl_well test_util )
set_target_properties( well_branch_collection PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_branch_collection ${EXECUTABLE_OUTPUT_PATH}/well_branch_collection )
add_executable( well_conn well_conn.c )
target_link_libraries( well_conn ecl_well )
target_link_libraries( well_conn ecl_well test_util )
set_target_properties( well_conn PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_conn ${EXECUTABLE_OUTPUT_PATH}/well_conn )
add_executable( well_state well_state.c )
target_link_libraries( well_state ecl_well )
target_link_libraries( well_state ecl_well test_util )
set_target_properties( well_state PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_state ${EXECUTABLE_OUTPUT_PATH}/well_state )
add_executable( well_state_load well_state_load.c )
target_link_libraries( well_state_load ecl_well )
target_link_libraries( well_state_load ecl_well test_util )
set_target_properties( well_state_load PROPERTIES COMPILE_FLAGS "-Werror")
add_executable( well_state_load_missing_RSEG well_state_load_missing_RSEG.c )
target_link_libraries( well_state_load_missing_RSEG ecl_well )
target_link_libraries( well_state_load_missing_RSEG ecl_well test_util )
set_target_properties( well_state_load_missing_RSEG PROPERTIES COMPILE_FLAGS "-Werror")
@ -50,40 +50,40 @@ add_test( well_state_load_missing_RSEG2 ${EXECUTABLE_OUTPUT_PATH}/well_state_loa
add_executable( well_segment well_segment.c )
target_link_libraries( well_segment ecl_well )
target_link_libraries( well_segment ecl_well test_util )
set_target_properties( well_segment PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_segment ${EXECUTABLE_OUTPUT_PATH}/well_segment )
add_executable( well_segment_conn well_segment_conn.c )
target_link_libraries( well_segment_conn ecl_well )
target_link_libraries( well_segment_conn ecl_well test_util )
set_target_properties( well_segment_conn PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_segment_conn ${EXECUTABLE_OUTPUT_PATH}/well_segment_conn )
add_executable( well_segment_load well_segment_load.c )
target_link_libraries( well_segment_load ecl_well )
target_link_libraries( well_segment_load ecl_well test_util )
set_target_properties( well_segment_load PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_segment_load ${EXECUTABLE_OUTPUT_PATH}/well_segment_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.X0021)
add_executable( well_segment_branch_conn_load well_segment_branch_conn_load.c )
target_link_libraries( well_segment_branch_conn_load ecl_well )
target_link_libraries( well_segment_branch_conn_load ecl_well test_util )
set_target_properties( well_segment_branch_conn_load PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_segment_branch_conn_load ${EXECUTABLE_OUTPUT_PATH}/well_segment_branch_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.X0021)
add_executable( well_info well_info.c )
target_link_libraries( well_info ecl_well )
target_link_libraries( well_info ecl_well test_util )
set_target_properties( well_info PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_info ${EXECUTABLE_OUTPUT_PATH}/well_info ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( well_segment_collection well_segment_collection.c )
target_link_libraries( well_segment_collection ecl_well )
target_link_libraries( well_segment_collection ecl_well test_util )
set_target_properties( well_segment_collection PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_segment_collection ${EXECUTABLE_OUTPUT_PATH}/well_segment_collection )
add_executable( well_conn_load well_conn_load.c )
target_link_libraries( well_conn_load ecl_well )
target_link_libraries( well_conn_load ecl_well test_util )
set_target_properties( well_conn_load PROPERTIES COMPILE_FLAGS "-Werror")
add_test( well_conn_load1 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.X0030 F)
add_test( well_conn_load2 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.X0021 F)
@ -93,18 +93,18 @@ add_test( well_conn_load5 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOU
add_test( well_conn_load6 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003 F)
add_executable( well_ts well_ts.c )
target_link_libraries( well_ts ecl_well )
target_link_libraries( well_ts ecl_well test_util )
add_test( well_ts ${EXECUTABLE_OUTPUT_PATH}/well_ts ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/CO2case/BASE_CASE )
add_executable( well_dualp well_dualp.c )
target_link_libraries( well_dualp ecl_well )
target_link_libraries( well_dualp ecl_well test_util )
add_test( well_dualp ${EXECUTABLE_OUTPUT_PATH}/well_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 )
add_executable( well_lgr_load well_lgr_load.c )
target_link_libraries( well_lgr_load ecl_well )
target_link_libraries( well_lgr_load ecl_well test_util )
add_test( well_lgr_load1 ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003)
add_test( well_lgr_load2 ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.X0016)

View File

@ -0,0 +1,67 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'well_state_load_missing_RSEG.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/stringlist.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_kw_magic.h>
#include <ert/ecl_well/well_state.h>
int main(int argc , char ** argv) {
test_install_SIGNALS();
{
const char * grid_file = argv[1];
const char * rst_file_name = argv[2];
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
ecl_file_type * rst_file = ecl_file_open( rst_file_name , 0);
ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file );
const char * well_name = "WELL";
int report_nr = 100;
time_t valid_from = -1;
bool open = false;
well_type_enum type = GAS_INJECTOR;
int global_well_nr = 0;
for (global_well_nr = 0; global_well_nr < header->nwells; global_well_nr++) {
well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from);
test_assert_true( well_state_is_instance( well_state) );
well_state_add_connections( well_state , grid , rst_file , 0 );
well_state_add_MSW( well_state , rst_file , global_well_nr );
{
const well_segment_collection_type * segments = well_state_get_segments( well_state );
if (!ecl_file_has_kw( rst_file , RSEG_KW ))
test_assert_int_equal( 0 , well_segment_collection_get_size( segments ));
}
well_state_free( well_state );
}
}
exit(0);
}

View File

@ -31,6 +31,9 @@ set_source_files_properties( main.c PROPERTIES COMPILE_DEFINITIONS "COMPILE_TIME
add_executable( ert ${src_list} )
target_link_libraries( ert enkf sched rms ecl config plot job_queue analysis ert_util )
if (USE_RUNPATH)
add_runpath( ert )
endif()
if (ERT_INSTALL_PREFIX)
set (destination ${CMAKE_INSTALL_PREFIX}/${ERT_INSTALL_PREFIX}/bin)

View File

@ -65,6 +65,17 @@ void enkf_tui_analysis_analyze_selected__(void * arg) {
}
}
void enkf_tui_analysis_scale_observation_std__(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast(arg);
double scale_factor = enkf_tui_util_scanf_double_with_lower_limit("Global scaling factor", PROMPT_LEN, 0);
if (enkf_main_have_obs(enkf_main)) {
enkf_obs_type * observations = enkf_main_get_obs(enkf_main);
enkf_obs_scale_std(observations, scale_factor);
}
}
/**
@ -228,19 +239,26 @@ void enkf_tui_analysis_menu(void * arg) {
arg_pack_type * arg_pack = arg_pack_alloc();
arg_pack_append_ptr( arg_pack , enkf_main );
arg_pack_append_ptr( arg_pack , menu );
{
enkf_tui_analysis_update_title( enkf_main , menu );
menu_add_item(menu , "Analyze one step manually" , "aA" , enkf_tui_analysis_analyze__ , enkf_main , NULL);
menu_add_item(menu , "Analyze interval manually" , "iI" , enkf_tui_analysis_smooth__ , enkf_main , NULL);
menu_add_item(menu , "Analyze selected steps manually" , "nN" , enkf_tui_analysis_analyze_selected__ , enkf_main , NULL);
menu_add_separator( menu );
menu_add_item(menu , "Select analysis module" , "sS" , enkf_tui_analysis_select_module__ , arg_pack , NULL);
menu_add_item(menu , "List available modules" , "lL" , enkf_tui_analysis_list_modules__ , enkf_main , NULL);
menu_add_item(menu , "Modify analysis module parameters" , "mM" , enkf_tui_analysis_update_module__ , enkf_main , NULL);
menu_add_item(menu , "Reload current module (external only)" , "rR" , enkf_tui_analysis_reload_module__ , enkf_main , NULL);
enkf_tui_analysis_update_title(enkf_main, menu);
menu_add_item(menu, "Analyze one step manually", "aA", enkf_tui_analysis_analyze__, enkf_main, NULL);
menu_add_item(menu, "Analyze interval manually", "iI", enkf_tui_analysis_smooth__, enkf_main, NULL);
menu_add_item(menu, "Analyze selected steps manually", "nN", enkf_tui_analysis_analyze_selected__, enkf_main, NULL);
menu_add_separator(menu);
{
menu_item_type * item = menu_add_item(menu, "Global scaling of uncertainty", "gG", enkf_tui_analysis_scale_observation_std__, enkf_main, NULL);
if (!enkf_main_have_obs(enkf_main)) {
menu_item_disable(item);
}
}
menu_add_separator(menu);
menu_add_item(menu, "Select analysis module", "sS", enkf_tui_analysis_select_module__, arg_pack, NULL);
menu_add_item(menu, "List available modules", "lL", enkf_tui_analysis_list_modules__, enkf_main, NULL);
menu_add_item(menu, "Modify analysis module parameters", "mM", enkf_tui_analysis_update_module__, enkf_main, NULL);
menu_add_item(menu, "Reload current module (external only)", "rR", enkf_tui_analysis_reload_module__, enkf_main, NULL);
}
menu_run(menu);
menu_free(menu);
arg_pack_free( arg_pack );
arg_pack_free(arg_pack);
}

View File

@ -20,9 +20,9 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <util.h>
#include <ert/util/util.h>
#include <ctype.h>
#include <menu.h>
#include <ert/util/menu.h>
#include <enkf_tui_run.h>
#include <enkf_tui_export.h>
#include <enkf_tui_plot.h>
@ -34,8 +34,8 @@
#include <enkf_tui_misc.h>
#include <enkf_tui_simple.h>
#include <enkf_tui_workflow.h>
#include <enkf_main.h>
#include <enkf_sched.h>
#include <ert/enkf/enkf_main.h>
#include <ert/enkf/enkf_sched.h>
/**

View File

@ -18,7 +18,7 @@
#ifndef __ENKF_INTER_MAIN_H__
#define __ENKF_INTER_MAIN_H__
#include <enkf_main.h>
#include <ert/enkf/enkf_main.h>
void enkf_tui_main_menu(void * arg);

View File

@ -23,7 +23,7 @@
extern "C" {
#endif
#include <enkf_main.h>
#include <ert/enkf/enkf_main.h>
void enkf_tui_plot_RFT_sim_all_MD( void * arg);
void enkf_tui_plot_RFT_sim_all_TVD( void * arg);

View File

@ -434,6 +434,19 @@ bool enkf_tui_util_sscanf_active_list( bool_vector_type * iactive , const char *
}
}
/**
The limit is not inclusive
*/
double enkf_tui_util_scanf_double_with_lower_limit(const char * prompt , int prompt_len , double min_value) {
double value;
char * new_prompt = util_alloc_sprintf("%s (greater than %g)" , prompt , min_value );
do {
value = util_scanf_double(new_prompt , prompt_len);
} while (value <= min_value);
free(new_prompt);
return value;
}
/*****************************************************************/

View File

@ -41,6 +41,6 @@ char * enkf_tui_util_scanf_report_step_as_char(int , cons
void enkf_tui_util_msg(const char * , ...);
int enkf_tui_util_scanf_int_with_default(const char * prompt , int prompt_len , bool * default_used);
int enkf_tui_util_scanf_int_with_default_return_to_menu(const char * prompt , int prompt_len , bool * default_used);
double enkf_tui_util_scanf_double_with_lower_limit(const char * prompt , int prompt_len , double min_value);
bool enkf_tui_util_sscanf_active_list( bool_vector_type * iactive , const char * select_string , int ens_size );
#endif

View File

@ -70,6 +70,11 @@ int block_obs_get_size(const block_obs_type * );
void block_obs_iget(const block_obs_type * block_obs, int , double * , double * );
void block_obs_iget_ijk(const block_obs_type * block_obs , int block_nr , int * i , int * j , int * k);
void block_obs_scale_std(block_obs_type * block_obs, double scale_factor);
void block_obs_scale_std__(void * block_obs, double scale_factor);
VOID_FREE_HEADER(block_obs);
VOID_GET_OBS_HEADER(block_obs);
UTIL_IS_INSTANCE_HEADER(block_obs);

View File

@ -140,6 +140,7 @@ extern "C" {
#define RERUN_START_KEY "RERUN_START"
#define RSH_COMMAND_KEY "RSH_COMMAND"
#define RSH_HOST_KEY "RSH_HOST"
#define RUNPATH_FILE_KEY "RUNPATH_FILE"
#define RUNPATH_KEY "RUNPATH"
#define ITER_RUNPATH_KEY "ITER_RUNPATH"
#define RERUN_PATH_KEY "RERUN_PATH"

View File

@ -69,6 +69,7 @@ extern "C" {
char * enkf_main_alloc_mount_point( const enkf_main_type * enkf_main , const char * case_path);
const char * enkf_main_get_current_fs( const enkf_main_type * enkf_main );
void enkf_main_user_select_fs(enkf_main_type * enkf_main , const char * case_path );
bool enkf_main_fs_exists(const enkf_main_type * enkf_main, const char * input_case);
void enkf_main_set_eclbase( enkf_main_type * enkf_main , const char * eclbase_fmt);
void enkf_main_set_data_file( enkf_main_type * enkf_main , const char * data_file );
void enkf_main_set_user_config_file( enkf_main_type * enkf_main , const char * user_config_file );

View File

@ -45,6 +45,7 @@ extern "C" {
void enkf_obs_free( enkf_obs_type * enkf_obs);
obs_vector_type * enkf_obs_get_vector(const enkf_obs_type * , const char * );
void enkf_obs_add_obs_vector(enkf_obs_type * enkf_obs, const char * key, const obs_vector_type * vector);
void enkf_obs_load(enkf_obs_type * enkf_obs,
const history_type * history ,
@ -80,6 +81,7 @@ extern "C" {
stringlist_type * enkf_obs_alloc_matching_keylist(const enkf_obs_type * enkf_obs , const char * input_string);
time_t enkf_obs_iget_obs_time(enkf_obs_type * enkf_obs , int report_step);
void enkf_obs_fprintf_config( const enkf_obs_type * enkf_obs , FILE * stream);
void enkf_obs_scale_std(enkf_obs_type * enkf_obs, double scale_factor);
#ifdef __cplusplus
}

View File

@ -29,6 +29,10 @@ typedef struct gen_obs_struct gen_obs_type;
gen_obs_type * gen_obs_alloc(gen_data_config_type * config , const char * obs_key , const char * , double , double , const char * , const char * , const char * );
void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char * index_key , double * value , double * std , bool * valid);
void gen_obs_scale_std(gen_obs_type * gen_obs, double std_multiplier );
void gen_obs_scale_std__(void * gen_obs, double std_multiplier );
VOID_CHI2_HEADER(gen_obs);
UTIL_IS_INSTANCE_HEADER(gen_obs);
VOID_FREE_HEADER(gen_obs);

View File

@ -0,0 +1,104 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'obs_vector.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 __OBS_VECTOR_H__
#define __OBS_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <ert/util/bool_vector.h>
#include <ert/sched/history.h>
#include <ert/config/conf.h>
#include <ert/ecl/ecl_sum.h>
#include <ert/enkf/enkf_fs.h>
#include <ert/enkf/enkf_types.h>
#include <ert/enkf/enkf_node.h>
#include <ert/enkf/enkf_state.h>
#include <ert/enkf/ensemble_config.h>
#include <ert/enkf/obs_data.h>
#include <ert/enkf/enkf_macros.h>
#include <ert/enkf/active_list.h>
typedef void (obs_free_ftype) (void *);
typedef void (obs_get_ftype) (const void * , obs_data_type * , int , const active_list_type * );
typedef void (obs_meas_ftype) (const void * , const void *, node_id_type , meas_data_type * , const active_list_type * );
typedef void (obs_user_get_ftype) (void * , const char * , double * , double * , bool *);
typedef void (obs_scale_std_ftype) (void * , double );
typedef double (obs_chi2_ftype) (const void * , const void *, node_id_type );
typedef enum { GEN_OBS = 1,
SUMMARY_OBS = 2,
BLOCK_OBS = 3} obs_impl_type;
typedef struct obs_vector_struct obs_vector_type;
void obs_vector_clear_nodes( obs_vector_type * obs_vector );
void obs_vector_del_node(obs_vector_type * obs_vector , int index);
void obs_vector_free(obs_vector_type * );
int obs_vector_get_num_active(const obs_vector_type * );
bool obs_vector_iget_active(const obs_vector_type * , int );
void obs_vector_iget_observations(const obs_vector_type * , int , obs_data_type * , const active_list_type * active_list);
void obs_vector_measure(const obs_vector_type * , enkf_fs_type * fs, state_enum state , int report_step , const enkf_state_type * , meas_data_type * , const active_list_type * active_list);
const char * obs_vector_get_state_kw(const obs_vector_type * );
obs_impl_type obs_vector_get_impl_type(const obs_vector_type * );
int obs_vector_get_active_report_step(const obs_vector_type * );
void obs_vector_user_get(const obs_vector_type * obs_vector , const char * index_key , int report_step , double * value , double * std , bool * valid);
int obs_vector_get_next_active_step(const obs_vector_type * , int );
void * obs_vector_iget_node(const obs_vector_type * , int );
obs_vector_type * obs_vector_alloc_from_GENERAL_OBSERVATION(const conf_instance_type * , const history_type * , const ensemble_config_type * );
void obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector_type * obs_vector , const conf_instance_type * , const history_type * , ensemble_config_type * );
bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector , const conf_instance_type * , const history_type * , ensemble_config_type * , double std_cutoff );
obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_type * , const ecl_grid_type * grid , const ecl_sum_type * refcase , const history_type *, ensemble_config_type * );
void obs_vector_set_config_node(obs_vector_type * , const enkf_config_node_type * );
obs_vector_type * obs_vector_alloc(obs_impl_type obs_type , const char * obs_key , enkf_config_node_type * config_node, int num_reports);
void obs_vector_scale_std(obs_vector_type * obs_vector, double std_multiplier);
void obs_vector_install_node(obs_vector_type * obs_vector , int obs_index , void * node );
double obs_vector_chi2(const obs_vector_type * , enkf_fs_type * , node_id_type node_id);
void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector ,
enkf_fs_type * fs,
bool_vector_type * valid ,
int step1 , int step2 ,
int iens1 , int iens2 ,
state_enum load_state ,
double ** chi2);
double obs_vector_total_chi2(const obs_vector_type * , enkf_fs_type * , int , state_enum );
void obs_vector_ensemble_total_chi2(const obs_vector_type * , enkf_fs_type * , int , state_enum , double * );
enkf_config_node_type * obs_vector_get_config_node(obs_vector_type * );
const char * obs_vector_get_obs_key( const obs_vector_type * obs_vector);
UTIL_SAFE_CAST_HEADER(obs_vector);
VOID_FREE_HEADER(obs_vector);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -39,7 +39,7 @@ extern "C" {
void qc_module_init( qc_module_type * qc_module , const config_type * config);
void qc_module_export_runpath_list( const qc_module_type * qc_module );
void qc_module_add_config_items( config_type * config );
void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * filename);
void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * path, const char * filename);
const char * qc_module_get_runpath_list_file( qc_module_type * qc_module);

View File

@ -80,6 +80,8 @@ summary_obs_type * summary_obs_alloc_from_SUMMARY_OBSERVATION(
void summary_obs_set(summary_obs_type * , double , double );
void summary_obs_scale_std(summary_obs_type * summary_obs, double std_multiplier );
void summary_obs_scale_std__(void * summary_obs, double std_multiplier );
VOID_FREE_HEADER(summary_obs);
VOID_GET_OBS_HEADER(summary_obs);

View File

@ -2,7 +2,6 @@ set( source_files ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c
set( header_files ert_report.h time_map.h rng_config.h enkf_analysis.h enkf_fs_type.h trans_func.h enkf_obs.h obs_data.h enkf_config_node.h block_obs.h field_config.h field.h enkf_macros.h ecl_static_kw.h enkf_state.h enkf_util.h enkf_main.h enkf_node.h enkf_fs.h gen_kw_config.h gen_kw.h enkf_types.h fs_driver.h meas_data.h summary_obs.h summary_config.h summary_config.h gen_data_config.h gen_data.h gen_common.h gen_obs.h enkf_sched.h fs_types.h enkf_serialize.h plain_driver.h ecl_config.h ensemble_config.h model_config.h site_config.h active_list.h obs_vector.h field_trans.h plain_driver.h local_ministep.h container.h local_updatestep.h local_config.h analysis_config.h misfit_ensemble.h misfit_ensemble_typedef.h misfit_ts.h misfit_member.h data_ranking.h ranking_table.h ranking_common.h misfit_ranking.h block_fs_driver.h field_common.h gen_kw_common.h gen_data_common.h plot_config.h ert_template.h member_config.h enkf_defaults.h container_config.h local_dataset.h local_obsset.h surface.h surface_config.h local_context.h enkf_plot_data.h enkf_plot_member.h qc_module.h ert_report_list.h enkf_plot_arg.h runpath_list.h ert_workflow_list.h analysis_iter_config.h ecl_refcase_list.h)
add_library( enkf ${LIBRARY_TYPE} ${source_files} )
set_target_properties( enkf PROPERTIES VERSION 1.0 SOVERSION 1.0 )
@ -12,6 +11,10 @@ set_target_properties( enkf PROPERTIES VERSION 1.0 SOVERSION 1.0 )
target_link_libraries( enkf ecl sched analysis rms plot config job_queue )
if (USE_RUNPATH)
add_runpath( enkf )
endif()
#-----------------------------------------------------------------
if (INSTALL_ERT)
install(TARGETS enkf DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -356,6 +356,20 @@ int block_obs_get_size(const block_obs_type * block_obs) {
return block_obs->size;
}
void block_obs_scale_std(block_obs_type * block_obs, double scale_factor) {
for (int i = 0; i < block_obs->size; i++) {
if (block_obs->point_list[i] != NULL) {
point_obs_type * point_observation = block_obs->point_list[i];
point_observation->std = point_observation->std * scale_factor;
}
}
}
void block_obs_scale_std__(void * block_obs, double scale_factor) {
block_obs_type * observation = block_obs_safe_cast(block_obs);
block_obs_scale_std(observation, scale_factor);
}
/*****************************************************************/

View File

@ -2261,22 +2261,20 @@ void enkf_main_update_node( enkf_main_type * enkf_main , const char * key ) {
}
/**
When the case has changed it is essential to invalidate the meta
information in the enkf_nodes, otherwise the nodes might reuse old
data (from a previous case).
*/
static void enkf_main_invalidate_cache( enkf_main_type * enkf_main ) {
int ens_size = enkf_main_get_ensemble_size( enkf_main );
int iens;
for (iens = 0; iens < ens_size; iens++)
enkf_state_invalidate_cache( enkf_main->ensemble[iens] );
}
// NOTE KF 20130628: This is commented out, because I don't think it is used, but we'll give it some time
//
///**
// When the case has changed it is essential to invalidate the meta
// information in the enkf_nodes, otherwise the nodes might reuse old
// data (from a previous case).
//*/
//
//static void enkf_main_invalidate_cache( enkf_main_type * enkf_main ) {
// int ens_size = enkf_main_get_ensemble_size( enkf_main );
// int iens;
// for (iens = 0; iens < ens_size; iens++)
// enkf_state_invalidate_cache( enkf_main->ensemble[iens] );
//}
void enkf_main_create_fs( enkf_main_type * enkf_main , const char * fs_path) {
@ -2386,7 +2384,8 @@ void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const ch
enkf_main_link_current_fs__( enkf_main , case_path);
enkf_main->current_fs_case = util_realloc_string_copy( enkf_main->current_fs_case , case_path);
enkf_main_gen_data_special( enkf_main );
enkf_main_add_subst_kw( enkf_main , "CASE" , enkf_main->current_fs_case , "Current case" , true );
enkf_main_add_subst_kw( enkf_main , "ERT-CASE" , enkf_main->current_fs_case , "Current case" , true );
enkf_main_add_subst_kw( enkf_main , "ERTCASE" , enkf_main->current_fs_case , "Current case" , true );
}
}
@ -2468,7 +2467,15 @@ const char * enkf_main_get_current_fs( const enkf_main_type * enkf_main ) {
return enkf_main->current_fs_case;
}
bool enkf_main_fs_exists(const enkf_main_type * enkf_main, const char * input_case){
bool exists = false;
char * new_mount_point = enkf_main_alloc_mount_point( enkf_main , input_case);
if(enkf_fs_exists( new_mount_point ))
exists = true;
free( new_mount_point );
return exists;
}
void enkf_main_user_select_fs(enkf_main_type * enkf_main , const char * input_case ) {
@ -2835,7 +2842,6 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo
enkf_main_rng_init( enkf_main ); /* Must be called before the ensmeble is created. */
enkf_main_init_subst_list( enkf_main );
ert_workflow_list_init( enkf_main->workflow_list , config , enkf_main->logh );
enkf_main_init_qc( enkf_main , config );
enkf_main_init_data_kw( enkf_main , config );
analysis_config_load_internal_modules( enkf_main->analysis_config );
@ -2851,6 +2857,8 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo
ecl_config_get_last_history_restart( enkf_main->ecl_config ),
ecl_config_get_sched_file(enkf_main->ecl_config) ,
ecl_config_get_refcase( enkf_main->ecl_config ));
enkf_main_init_qc( enkf_main , config );
enkf_main_update_num_cpu( enkf_main );
{
const config_content_item_type * pred_item = config_get_content_item( config , SCHEDULE_PREDICTION_FILE_KEY );

View File

@ -58,7 +58,7 @@ void * enkf_main_smoother_JOB( void * self , const stringlist_type * args ) {
int ens_size = enkf_main_get_ensemble_size( enkf_main );
bool_vector_type * iactive = bool_vector_alloc( 0 , true );
bool rerun = true;
const char * target_case = "AUTO-SMOOTHER";
const char * target_case = stringlist_iget( args , 0 );
bool_vector_iset( iactive , ens_size - 1 , true );
enkf_main_run_smoother( enkf_main , target_case , rerun);
@ -75,3 +75,15 @@ void * enkf_main_create_reports_JOB(void * self , const stringlist_type * args )
return NULL;
}
void * enkf_main_scale_obs_std_JOB(void * self, const stringlist_type * args ) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
double scale_factor;
util_sscanf_double(stringlist_iget(args, 0), &scale_factor);
if (enkf_main_have_obs(enkf_main)) {
enkf_obs_type * observations = enkf_main_get_obs(enkf_main);
enkf_obs_scale_std(observations, scale_factor);
}
return NULL;
}

View File

@ -46,7 +46,7 @@
The observation system
----------------------
The observation system in the EnKF code is a three leayer system. At
The observation system in the EnKF code is a three layer system. At
the the top is the enkf_obs_type. The enkf_main object contains one
enkf_obs instance which has internalized ALL the observation data. In
enkf_obs the the data is internalized in a hash table, where the keys
@ -59,7 +59,7 @@ be NULL, if the observation is not active at this report step. In
addition the obs_vector contains function pointers to manipulate the
observation data at the lowest level.
At the lowest level we have spsesific observation instances,
At the lowest level we have specific observation instances,
field_obs, summary_obs and gen_obs. These instances contain the actual
data.
@ -484,7 +484,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs ,
conf_instance_type * enkf_conf = conf_instance_alloc_from_file(enkf_conf_class, "enkf_conf", config_file);
if(conf_instance_validate(enkf_conf) == false)
util_abort("Can not proceed with this configuration.\n");
util_abort("Can not proceed with this configuration.\n");
if (enkf_obs->config_file != NULL) /* Clear current instance, observe that this function */
hash_clear( enkf_obs->obs_hash ); /* will reload even if it is called repeatedly with the */
@ -503,9 +503,13 @@ void enkf_obs_load(enkf_obs_type * enkf_obs ,
config_node = ensemble_config_add_summary( ensemble_config , obs_key , LOAD_FAIL_WARN );
if (config_node != NULL) {
obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , obs_key ) , enkf_obs->obs_time , last_report);
obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , obs_key ), last_report);
if (obs_vector != NULL) {
if (obs_vector_load_from_HISTORY_OBSERVATION(obs_vector , hist_obs_conf , enkf_obs->history , ensemble_config , std_cutoff ))
if (obs_vector_load_from_HISTORY_OBSERVATION(obs_vector ,
hist_obs_conf ,
enkf_obs->history ,
ensemble_config,
std_cutoff ))
enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector);
else {
fprintf(stderr,"** Could not load historical data for observation:%s - ignored\n",obs_key);
@ -536,7 +540,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs ,
config_node = ensemble_config_add_summary( ensemble_config , sum_key , LOAD_FAIL_WARN );
if (config_node != NULL) {
obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , sum_key ) , enkf_obs->obs_time , last_report);
obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , sum_key ), last_report);
if (obs_vector != NULL) {
obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector , sum_obs_conf , enkf_obs->history , ensemble_config);
enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector);
@ -557,7 +561,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs ,
{
const char * obs_key = stringlist_iget(block_obs_keys, block_obs_nr);
const conf_instance_type * block_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key);
obs_vector_type * obs_vector = obs_vector_alloc_from_BLOCK_OBSERVATION(block_obs_conf , grid , refcase , enkf_obs->history , ensemble_config , enkf_obs->obs_time);
obs_vector_type * obs_vector = obs_vector_alloc_from_BLOCK_OBSERVATION(block_obs_conf , grid , refcase , enkf_obs->history ,ensemble_config);
if (obs_vector != NULL)
enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector);
}
@ -575,7 +579,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs ,
const char * obs_key = stringlist_iget(block_obs_keys, block_obs_nr);
const conf_instance_type * gen_obs_conf = conf_instance_get_sub_instance_ref(enkf_conf, obs_key);
obs_vector_type * obs_vector = obs_vector_alloc_from_GENERAL_OBSERVATION(gen_obs_conf , enkf_obs->history , ensemble_config , enkf_obs->obs_time);
obs_vector_type * obs_vector = obs_vector_alloc_from_GENERAL_OBSERVATION(gen_obs_conf , enkf_obs->history , ensemble_config);
if (obs_vector != NULL)
enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector);
}
@ -1052,7 +1056,17 @@ const obs_vector_type * enkf_obs_user_get_vector(const enkf_obs_type * obs , con
return vector;
}
/*****************************************************************/
void enkf_obs_scale_std(enkf_obs_type * enkf_obs, double scale_factor) {
hash_iter_type * observation_vector_iterator = enkf_obs_alloc_iter(enkf_obs);
while (!hash_iter_is_complete(observation_vector_iterator)) {
obs_vector_type * current_obs_vector = hash_iter_get_next_value(observation_vector_iterator);
obs_vector_scale_std(current_obs_vector, scale_factor);
}
hash_iter_free(observation_vector_iterator);
}

View File

@ -752,7 +752,8 @@ static bool enkf_state_internalize_dynamic_results(enkf_state_type * enkf_state
if (ecl_config_active( ecl_config )) {
bool eclipse_load = enkf_state_internalize_dynamic_eclipse_results( enkf_state , fs , model_config , loadOK, interactive , msg_list);
fprintf(stderr , "** Warning: could not load ECLIPSE summary data from %s - this will probably fail later ...\n" , enkf_state->run_info->run_path);
if (!eclipse_load)
fprintf(stderr , "** Warning: could not load ECLIPSE summary data from %s - this will probably fail later ...\n" , enkf_state->run_info->run_path);
return eclipse_load;
} else
return false;

View File

@ -260,7 +260,7 @@ bool gen_kw_fload(gen_kw_type * gen_kw , const char * filename) {
if (!readOK) {
int counter = 0;
readOK = true;
fseek( stream , 0 , SEEK_SET );
util_fseek( stream , 0 , SEEK_SET );
while ((counter < size) && readOK) {
char key[128];

View File

@ -330,11 +330,6 @@ void gen_obs_get_observations(gen_obs_type * gen_obs , obs_data_type * obs_data,
/**
In general the gen_obs observation vector can be smaller than the
gen_data field it is observing, i.e. we can have a situation like
@ -368,11 +363,11 @@ void gen_obs_get_observations(gen_obs_type * gen_obs , obs_data_type * obs_data,
The function gen_obs_user_get_with_data_index() will do the
translation from data based indexing to observation based indexing, i.e.
gen_obs_user_get_with_data_index("obs_key:4")
gen_obs_user_get_with_data_index("4")
will do an inverse lookup of the '4' and further call
gen_obs_user_get("obs_key:2")
gen_obs_user_get("2")
*/
@ -416,6 +411,18 @@ void gen_obs_user_get_with_data_index(const gen_obs_type * gen_obs , const char
}
}
void gen_obs_scale_std(gen_obs_type * gen_obs, double std_multiplier) {
for (int i = 0; i < gen_obs->obs_size; i++) {
gen_obs->obs_std[i] *= std_multiplier;
}
}
void gen_obs_scale_std__(void * gen_obs, double std_multiplier) {
gen_obs_type * observation = gen_obs_safe_cast(gen_obs);
gen_obs_scale_std(observation, std_multiplier);
}

View File

@ -60,12 +60,13 @@ ministep to the updatestep, otherwise it will not be able to do
anything.
CREATE_MINISTEP [NAME_OF_MINISTEP]
----------------------------------
CREATE_MINISTEP [NAME_OF_MINISTEP OBSSET_NAME]
-----------------------------------------------
This function will create a new ministep with the name
'NAME_OF_MINISTEP'. The ministep is then ready for adding data and
observation keys. Before the ministep will be used you must attach it
to an updatestep with the ATTACH_MINISTEP command
'NAME_OF_MINISTEP'. The ministep will be based on the observation
set given by OBSSET_NAME (which must be created first).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
CREATE_DATASET [NAME_OF_DATASET]
--------------------------------

View File

@ -0,0 +1,959 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'obs_vector.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.
*/
/**
See the overview documentation of the observation system in enkf_obs.c
*/
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#include <ert/util/util.h>
#include <ert/util/vector.h>
#include <ert/util/double_vector.h>
#include <ert/util/bool_vector.h>
#include <ert/util/msg.h>
#include <ert/sched/history.h>
#include <ert/config/conf.h>
#include <ert/ecl/ecl_sum.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/smspec_node.h>
#include <ert/enkf/obs_vector.h>
#include <ert/enkf/enkf_fs.h>
#include <ert/enkf/summary_obs.h>
#include <ert/enkf/block_obs.h>
#include <ert/enkf/gen_obs.h>
#include <ert/enkf/ensemble_config.h>
#include <ert/enkf/active_list.h>
#include <ert/enkf/enkf_state.h>
#include <ert/enkf/enkf_defaults.h>
#define OBS_VECTOR_TYPE_ID 120086
struct obs_vector_struct {
UTIL_TYPE_ID_DECLARATION;
obs_free_ftype *freef; /* Function used to free an observation node. */
obs_get_ftype *get_obs; /* Function used to build the 'd' vector. */
obs_meas_ftype *measure; /* Function used to measure on the state, and add to to the S matrix. */
obs_user_get_ftype *user_get; /* Function to get an observation based on KEY:INDEX input from user.*/
obs_chi2_ftype *chi2; /* Function to evaluate chi-squared for an observation. */
obs_scale_std_ftype *scale_std; /* Function to scale the standard deviation with a given factor */
vector_type * nodes;
char * obs_key; /* The key this observation vector has in the enkf_obs layer. */
enkf_config_node_type * config_node; /* The config_node of the node type we are observing - shared reference */
obs_impl_type obs_type;
int num_active; /* The total number of timesteps where this observation is active (i.e. nodes[ ] != NULL) */
};
UTIL_IS_INSTANCE_FUNCTION(obs_vector , OBS_VECTOR_TYPE_ID)
UTIL_SAFE_CAST_FUNCTION(obs_vector , OBS_VECTOR_TYPE_ID)
/*****************************************************************/
static int __conf_instance_get_restart_nr(const conf_instance_type * conf_instance, const char * obs_key , const history_type * history , int size) {
int obs_restart_nr = -1; /* To shut up compiler warning. */
if(conf_instance_has_item(conf_instance, "RESTART")) {
obs_restart_nr = conf_instance_get_item_value_int(conf_instance, "RESTART");
if(obs_restart_nr > size)
util_abort("%s: Observation %s occurs at restart %i, but history file has only %i restarts.\n", __func__, obs_key, obs_restart_nr, size);
} else if(conf_instance_has_item(conf_instance, "DATE")) {
time_t obs_date = conf_instance_get_item_value_time_t(conf_instance, "DATE" );
obs_restart_nr = history_get_restart_nr_from_time_t( history , obs_date );
} else if (conf_instance_has_item(conf_instance, "DAYS")) {
double days = conf_instance_get_item_value_double(conf_instance, "DAYS");
obs_restart_nr = history_get_restart_nr_from_days( history , days );
} else
util_abort("%s: Internal error. Invalid conf_instance?\n", __func__);
return obs_restart_nr;
}
/*****************************************************************/
static void obs_vector_resize(obs_vector_type * vector , int new_size) {
int current_size = vector_get_size( vector->nodes );
int i;
for (i=current_size; i < new_size; i++)
vector_append_ref( vector->nodes , NULL);
}
obs_vector_type * obs_vector_alloc(obs_impl_type obs_type , const char * obs_key , enkf_config_node_type * config_node, int num_reports) {
obs_vector_type * vector = util_malloc(sizeof * vector );
UTIL_TYPE_ID_INIT( vector , OBS_VECTOR_TYPE_ID);
vector->freef = NULL;
vector->measure = NULL;
vector->get_obs = NULL;
vector->user_get = NULL;
vector->chi2 = NULL;
vector->scale_std = NULL;
switch (obs_type) {
case(SUMMARY_OBS):
vector->freef = summary_obs_free__;
vector->measure = summary_obs_measure__;
vector->get_obs = summary_obs_get_observations__;
vector->user_get = summary_obs_user_get__;
vector->chi2 = summary_obs_chi2__;
vector->scale_std = summary_obs_scale_std__;
break;
case(BLOCK_OBS):
vector->freef = block_obs_free__;
vector->measure = block_obs_measure__;
vector->get_obs = block_obs_get_observations__;
vector->user_get = block_obs_user_get__;
vector->chi2 = block_obs_chi2__;
vector->scale_std = block_obs_scale_std__;
break;
case(GEN_OBS):
vector->freef = gen_obs_free__;
vector->measure = gen_obs_measure__;
vector->get_obs = gen_obs_get_observations__;
vector->user_get = gen_obs_user_get__;
vector->chi2 = gen_obs_chi2__;
vector->scale_std = gen_obs_scale_std__;
break;
default:
util_abort("%s: internal error - obs_type:%d not recognized \n",__func__ , obs_type);
}
vector->obs_type = obs_type;
vector->config_node = config_node;
vector->obs_key = util_alloc_string_copy( obs_key );
vector->num_active = 0;
vector->nodes = vector_alloc_new();
obs_vector_resize(vector , num_reports + 1); /* +1 here ?? Ohh - these +/- problems. */
return vector;
}
obs_impl_type obs_vector_get_impl_type(const obs_vector_type * obs_vector) {
return obs_vector->obs_type;
}
/**
This is the key for the enkf_node which this observation is
'looking at'. I.e. if this observation is an RFT pressure
measurement, this function will return "PRESSURE".
*/
const char * obs_vector_get_state_kw(const obs_vector_type * obs_vector) {
return enkf_config_node_get_key( obs_vector->config_node );
}
enkf_config_node_type * obs_vector_get_config_node(obs_vector_type * obs_vector) {
return obs_vector->config_node;
}
void obs_vector_free(obs_vector_type * obs_vector) {
vector_free( obs_vector->nodes );
free(obs_vector->obs_key);
free(obs_vector);
}
static void obs_vector_assert_node_type( const obs_vector_type * obs_vector , const void * node ) {
bool type_OK;
switch (obs_vector->obs_type) {
case(SUMMARY_OBS):
type_OK = summary_obs_is_instance( node );
break;
case(BLOCK_OBS):
type_OK = block_obs_is_instance( node );
break;
case(GEN_OBS):
type_OK = gen_obs_is_instance( node );
break;
default:
util_abort("%s: Error in type check: \n",__func__);
type_OK = false;
}
if (!type_OK)
util_abort("%s: Type mismatch when trying to add observation node to observation vector \n",__func__);
}
void obs_vector_del_node(obs_vector_type * obs_vector , int index) {
if (vector_iget_const( obs_vector->nodes , index ) != NULL) {
vector_iset_ref( obs_vector->nodes , index , NULL); /* Clear current content. */
obs_vector->num_active--;
}
}
/**
This function will clear (and free) all the summary_obs / gen_obs /
field_obs instances which have been installed in the vector;
however the vector itself is retained with keys, function pointers
and so on.
*/
void obs_vector_clear_nodes( obs_vector_type * obs_vector ) {
vector_clear( obs_vector->nodes );
obs_vector->num_active = 0;
}
void obs_vector_install_node(obs_vector_type * obs_vector , int index , void * node) {
obs_vector_assert_node_type( obs_vector , node );
{
if (vector_iget_const( obs_vector->nodes , index ) == NULL)
obs_vector->num_active++;
vector_iset_owned_ref( obs_vector->nodes , index , node , obs_vector->freef );
}
}
/**
Observe that @summary_key is the key used to look up the
corresponding simulated value in the ensemble, and not the
observation key - the two can be different.
*/
static void obs_vector_add_summary_obs( obs_vector_type * obs_vector , int obs_index , const char * summary_key , const char * obs_key , double value , double std , const char * auto_corrf_name , double auto_corrf_param) {
summary_obs_type * summary_obs = summary_obs_alloc( summary_key , obs_key , value , std , auto_corrf_name , auto_corrf_param);
obs_vector_install_node( obs_vector , obs_index , summary_obs );
}
/*****************************************************************/
int obs_vector_get_num_active(const obs_vector_type * vector) {
return vector->num_active;
}
/**
IFF - only one - report step is active this function will return
that report step. If more than report step is active, the function
is ambiguous, and will fail HARD. Check with get_num_active first!
*/
int obs_vector_get_active_report_step(const obs_vector_type * vector) {
if (vector->num_active == 1) {
int active_step = -1;
int i;
for (i=0; i < vector_get_size(vector->nodes); i++) {
void * obs_node = vector_iget( vector->nodes , i);
if (obs_node != NULL) {
if (active_step >= 0)
util_abort("%s: internal error - mismatch in obs_vector->nodes and obs_vector->num_active \n",__func__);
active_step = i;
}
}
if (active_step < 0)
util_abort("%s: internal error - mismatch in obs_vector->nodes and obs_vector->num_active \n",__func__);
return active_step;
} else {
util_abort("%s: when calling this function the number of active report steps MUST BE 1 - you had: %d \n",__func__ , vector->num_active);
return 0; /* Comiler shut up. */
}
}
bool obs_vector_iget_active(const obs_vector_type * vector, int index) {
/* We accept this ... */
if (index >= vector_get_size( vector->nodes ))
return false;
{
void * obs_data = vector_iget( vector->nodes , index );
if (obs_data != NULL)
return true;
else
return false;
}
}
/*
Will happily return NULL if index is not active.
*/
void * obs_vector_iget_node(const obs_vector_type * vector, int index) {
return vector_iget( vector->nodes , index );
}
void obs_vector_user_get(const obs_vector_type * obs_vector , const char * index_key , int report_step , double * value , double * std , bool * valid) {
void * obs_node = obs_vector_iget_node( obs_vector , report_step );
obs_vector->user_get(obs_node , index_key , value , std , valid);
}
/*
This function returns the next active (i.e. node != NULL) report
step, starting with 'prev_step + 1'. If no more active steps are
found, it will return -1.
*/
int obs_vector_get_next_active_step(const obs_vector_type * obs_vector , int prev_step) {
if (prev_step >= (vector_get_size(obs_vector->nodes) - 1))
return -1;
else {
int size = vector_get_size( obs_vector->nodes );
int next_step = prev_step + 1;
while (( next_step < size) && (obs_vector_iget_node(obs_vector , next_step) == NULL))
next_step++;
if (next_step == size)
return -1; /* No more active steps. */
else
return next_step;
}
}
/*****************************************************************/
/**
All the obs_vector_load_from_XXXX() functions can safely return
NULL, in which case no observation is added to enkf_obs observation
hash table.
*/
void obs_vector_load_from_SUMMARY_OBSERVATION(obs_vector_type * obs_vector , const conf_instance_type * conf_instance , const history_type * history, ensemble_config_type * ensemble_config) {
if(!conf_instance_is_of_class(conf_instance, "SUMMARY_OBSERVATION"))
util_abort("%s: internal error. expected \"SUMMARY_OBSERVATION\" instance, got \"%s\".\n",
__func__, conf_instance_get_class_name_ref(conf_instance) );
{
double obs_value = conf_instance_get_item_value_double(conf_instance, "VALUE" );
double obs_error = conf_instance_get_item_value_double(conf_instance, "ERROR" );
double min_error = conf_instance_get_item_value_double(conf_instance, "ERROR_MIN");
const char * error_mode = conf_instance_get_item_value_ref( conf_instance, "ERROR_MODE");
const char * sum_key = conf_instance_get_item_value_ref( conf_instance, "KEY" );
const char * obs_key = conf_instance_get_name_ref(conf_instance);
int size = history_get_last_restart( history );
int obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_key , history , size);
if (obs_restart_nr == 0) {
int day,month,year;
time_t start_time = history_get_time_t_from_restart_nr( history , 0 );
util_set_date_values( start_time , &day , &month , &year);
fprintf(stderr,"** ERROR: It is unfortunately not possible to use summary observations from the\n");
fprintf(stderr," start of the simulation. Problem with observation:%s at %02d/%02d/%4d\n",obs_key , day,month,year);
exit(1);
}
{
if (strcmp( error_mode , "REL") == 0)
obs_error *= obs_value;
else if (strcmp( error_mode , "RELMIN") == 0)
obs_error = util_double_max( min_error , obs_error * obs_value );
obs_vector_add_summary_obs( obs_vector , obs_restart_nr , sum_key , obs_key , obs_value , obs_error , NULL , 0);
}
}
}
obs_vector_type * obs_vector_alloc_from_GENERAL_OBSERVATION(const conf_instance_type * conf_instance , const history_type * history, const ensemble_config_type * ensemble_config) {
if(!conf_instance_is_of_class(conf_instance, "GENERAL_OBSERVATION"))
util_abort("%s: internal error. expected \"GENERAL_OBSERVATION\" instance, got \"%s\".\n",
__func__, conf_instance_get_class_name_ref(conf_instance) );
const char * obs_key = conf_instance_get_name_ref(conf_instance);
const char * state_kw = conf_instance_get_item_value_ref( conf_instance, "DATA" );
if (ensemble_config_has_key( ensemble_config , state_kw )) {
const char * obs_key = conf_instance_get_name_ref(conf_instance);
int size = history_get_last_restart( history );
obs_vector_type * obs_vector = obs_vector_alloc( GEN_OBS , obs_key , ensemble_config_get_node(ensemble_config , state_kw ), size);
int obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_key , history , size);
const char * index_file = NULL;
const char * index_list = NULL;
const char * obs_file = NULL;
const char * error_covar_file = NULL;
if (conf_instance_has_item(conf_instance , "INDEX_FILE"))
index_file = conf_instance_get_item_value_ref( conf_instance, "INDEX_FILE" );
if (conf_instance_has_item(conf_instance , "INDEX_LIST"))
index_list = conf_instance_get_item_value_ref( conf_instance, "INDEX_LIST" );
if (conf_instance_has_item(conf_instance , "OBS_FILE"))
obs_file = conf_instance_get_item_value_ref( conf_instance, "OBS_FILE" );
if (conf_instance_has_item(conf_instance , "ERROR_COVAR"))
error_covar_file = conf_instance_get_item_value_ref( conf_instance, "ERROR_COVAR" );
{
const enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , state_kw);
if (enkf_config_node_get_impl_type(config_node) == GEN_DATA) {
double scalar_error = -1;
double scalar_value = -1;
gen_obs_type * gen_obs ;
if (conf_instance_has_item(conf_instance , "VALUE")) {
scalar_value = conf_instance_get_item_value_double(conf_instance , "VALUE");
scalar_error = conf_instance_get_item_value_double(conf_instance , "ERROR");
}
/** The config system has ensured that we have either OBS_FILE or (VALUE and ERROR). */
gen_obs = gen_obs_alloc( enkf_config_node_get_ref( config_node ) , obs_key , obs_file , scalar_value , scalar_error , index_file , index_list , error_covar_file);
obs_vector_install_node( obs_vector , obs_restart_nr , gen_obs );
} else {
ert_impl_type impl_type = enkf_config_node_get_impl_type(config_node);
util_abort("%s: %s has implementation type:\'%s\' - expected:\'%s\'.\n",__func__ , state_kw , enkf_types_get_impl_name(impl_type) , enkf_types_get_impl_name(GEN_DATA));
}
}
return obs_vector;
} else {
fprintf(stderr,"** Warning the ensemble key:%s does not exist - observation:%s not added \n", state_kw , obs_key);
return NULL;
}
}
// Should check the refcase for key - if it is != NULL.
bool obs_vector_load_from_HISTORY_OBSERVATION(obs_vector_type * obs_vector ,
const conf_instance_type * conf_instance ,
const history_type * history ,
ensemble_config_type * ensemble_config,
double std_cutoff ) {
if(!conf_instance_is_of_class(conf_instance, "HISTORY_OBSERVATION"))
util_abort("%s: internal error. expected \"HISTORY_OBSERVATION\" instance, got \"%s\".\n",__func__, conf_instance_get_class_name_ref(conf_instance) );
{
bool initOK = false;
int size , restart_nr;
double_vector_type * value = double_vector_alloc(0,0);
double_vector_type * std = double_vector_alloc(0,0);
bool_vector_type * valid = bool_vector_alloc(0 , false);
/* The auto_corrf parameters can not be "segmentized" */
double auto_corrf_param = -1;
const char * auto_corrf_name = NULL;
double error = conf_instance_get_item_value_double(conf_instance, "ERROR" );
double error_min = conf_instance_get_item_value_double(conf_instance, "ERROR_MIN" );
const char * error_mode = conf_instance_get_item_value_ref( conf_instance, "ERROR_MODE");
const char * sum_key = conf_instance_get_name_ref( conf_instance );
if(conf_instance_has_item(conf_instance, "AUTO_CORRF")) {
auto_corrf_name = conf_instance_get_item_value_ref( conf_instance , "AUTO_CORRF");
auto_corrf_param = conf_instance_get_item_value_double(conf_instance, "AUTO_CORRF_PARAM");
if(conf_instance_has_item(conf_instance, "AUTO_CORRF_PARAM"))
auto_corrf_param = conf_instance_get_item_value_double(conf_instance, "AUTO_CORRF_PARAM");
else
util_abort("%s: When specifying AUTO_CORRF you must also give a vlaue for AUTO_CORRF_PARAM",__func__);
}
// Get time series data from history object and allocate
size = history_get_last_restart(history);
if (history_init_ts( history , sum_key , value , valid )) {
// Create the standard deviation vector
if(strcmp(error_mode, "ABS") == 0) {
for( restart_nr = 0; restart_nr < size; restart_nr++)
double_vector_iset( std , restart_nr , error );
} else if(strcmp(error_mode, "REL") == 0) {
for( restart_nr = 0; restart_nr < size; restart_nr++)
double_vector_iset( std , restart_nr , error * abs( double_vector_iget( value , restart_nr )));
} else if(strcmp(error_mode, "RELMIN") == 0) {
for(restart_nr = 0; restart_nr < size; restart_nr++) {
double tmp_std = util_double_max( error_min , error * abs( double_vector_iget( value , restart_nr )));
double_vector_iset( std , restart_nr , tmp_std);
}
} else
util_abort("%s: Internal error. Unknown error mode \"%s\"\n", __func__, error_mode);
// Handle SEGMENTs which can be used to customize the observation error. */
{
stringlist_type * segment_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(conf_instance, "SEGMENT");
stringlist_sort( segment_keys , NULL );
int num_segments = stringlist_get_size(segment_keys);
for(int segment_nr = 0; segment_nr < num_segments; segment_nr++)
{
const char * segment_name = stringlist_iget(segment_keys, segment_nr);
const conf_instance_type * segment_conf = conf_instance_get_sub_instance_ref(conf_instance, segment_name);
int start = conf_instance_get_item_value_int( segment_conf, "START" );
int stop = conf_instance_get_item_value_int( segment_conf, "STOP" );
double error_segment = conf_instance_get_item_value_double(segment_conf, "ERROR" );
double error_min_segment = conf_instance_get_item_value_double(segment_conf, "ERROR_MIN" );
const char * error_mode_segment = conf_instance_get_item_value_ref( segment_conf, "ERROR_MODE");
if(start < 0)
{
printf("%s: WARNING - Segment out of bounds. Truncating start of segment to 0.\n", __func__);
start = 0;
}
if(stop >= size)
{
printf("%s: WARNING - Segment out of bounds. Truncating end of segment to %d.\n", __func__, size - 1);
stop = size -1;
}
if(start > stop)
{
printf("%s: WARNING - Segment start after stop. Truncating end of segment to %d.\n", __func__, start );
stop = start;
}
// Create the standard deviation vector
if(strcmp(error_mode_segment, "ABS") == 0) {
for( restart_nr = start; restart_nr <= stop; restart_nr++)
double_vector_iset( std , restart_nr , error_segment) ;
} else if(strcmp(error_mode_segment, "REL") == 0) {
for( restart_nr = start; restart_nr <= stop; restart_nr++)
double_vector_iset( std , restart_nr , error_segment * abs(double_vector_iget( value , restart_nr)));
} else if(strcmp(error_mode_segment, "RELMIN") == 0) {
for(restart_nr = start; restart_nr <= stop ; restart_nr++) {
double tmp_std = util_double_max( error_min_segment , error_segment * abs( double_vector_iget( value , restart_nr )));
double_vector_iset( std , restart_nr , tmp_std);
}
} else
util_abort("%s: Internal error. Unknown error mode \"%s\"\n", __func__, error_mode);
}
stringlist_free(segment_keys);
}
/*
This is where the summary observations are finally added.
*/
for (restart_nr = 0; restart_nr < size; restart_nr++) {
if (bool_vector_safe_iget( valid , restart_nr)) {
if (double_vector_iget( std , restart_nr) > std_cutoff) {
obs_vector_add_summary_obs( obs_vector , restart_nr , sum_key , sum_key ,
double_vector_iget( value ,restart_nr) , double_vector_iget( std , restart_nr ) ,
auto_corrf_name , auto_corrf_param);
} else
fprintf(stderr,"** Warning: to small observation error in observation %s:%d - ignored. \n", sum_key , restart_nr);
}
}
initOK = true;
}
double_vector_free(std);
double_vector_free(value);
bool_vector_free(valid);
return initOK;
}
}
void obs_vector_scale_std(obs_vector_type * obs_vector, double std_multiplier) {
vector_type * observation_nodes = obs_vector->nodes;
for (int i=0; i<vector_get_size(observation_nodes); i++) {
if (obs_vector_iget_active(obs_vector, i)) {
void * observation = obs_vector_iget_node(obs_vector, i);
obs_vector->scale_std(observation, std_multiplier);
}
}
}
static const char * __summary_kw( const char * field_name ) {
if (strcmp( field_name , "PRESSURE") == 0)
return "BPR";
else if (strcmp( field_name , "SWAT") == 0)
return "BSWAT";
else if (strcmp( field_name , "SGAS") == 0)
return "BSGAS";
else {
util_abort("%s: sorry - could not \'translate\' field:%s to block summary variable\n",__func__ , field_name);
return NULL;
}
}
obs_vector_type * obs_vector_alloc_from_BLOCK_OBSERVATION(const conf_instance_type * conf_instance ,
const ecl_grid_type * grid ,
const ecl_sum_type * refcase ,
const history_type * history,
ensemble_config_type * ensemble_config) {
if(!conf_instance_is_of_class(conf_instance, "BLOCK_OBSERVATION"))
util_abort("%s: internal error. expected \"BLOCK_OBSERVATION\" instance, got \"%s\".\n",
__func__, conf_instance_get_class_name_ref(conf_instance) );
block_obs_source_type source_type = SOURCE_SUMMARY;
const char * obs_label = conf_instance_get_name_ref(conf_instance);
const char * source_string = conf_instance_get_item_value_ref(conf_instance , "SOURCE");
const char * field_name = conf_instance_get_item_value_ref(conf_instance , "FIELD");
const char * sum_kw = NULL;
bool OK = true;
if (strcmp(source_string , "FIELD") == 0) {
source_type = SOURCE_FIELD;
if (!ensemble_config_has_key( ensemble_config , field_name)) {
OK = false;
fprintf(stderr,"** Warning the ensemble key:%s does not exist - observation:%s not added \n", field_name , obs_label);
}
} else if (strcmp( source_string , "SUMMARY") == 0) {
source_type = SOURCE_SUMMARY;
sum_kw = __summary_kw( field_name );
} else
util_abort("%s: internal error \n",__func__);
if (OK) {
obs_vector_type * obs_vector = NULL;
int size = history_get_last_restart( history );
int obs_restart_nr ;
stringlist_type * summary_keys = stringlist_alloc_new();
stringlist_type * obs_pt_keys = conf_instance_alloc_list_of_sub_instances_of_class_by_name(conf_instance, "OBS");
int num_obs_pts = stringlist_get_size(obs_pt_keys);
double * obs_value = util_calloc(num_obs_pts , sizeof * obs_value);
double * obs_std = util_calloc(num_obs_pts , sizeof * obs_std );
int * obs_i = util_calloc(num_obs_pts , sizeof * obs_i );
int * obs_j = util_calloc(num_obs_pts , sizeof * obs_j );
int * obs_k = util_calloc(num_obs_pts , sizeof * obs_k );
obs_restart_nr = __conf_instance_get_restart_nr(conf_instance , obs_label , history , size);
/** Build the observation. */
for(int obs_pt_nr = 0; obs_pt_nr < num_obs_pts; obs_pt_nr++) {
const char * obs_key = stringlist_iget(obs_pt_keys, obs_pt_nr);
const conf_instance_type * obs_instance = conf_instance_get_sub_instance_ref(conf_instance, obs_key);
const char * error_mode = conf_instance_get_item_value_ref(obs_instance, "ERROR_MODE");
double error = conf_instance_get_item_value_double(obs_instance, "ERROR");
double value = conf_instance_get_item_value_double(obs_instance, "VALUE");
double min_error = conf_instance_get_item_value_double(obs_instance, "ERROR_MIN");
if (strcmp( error_mode , "REL") == 0)
error *= value;
else if (strcmp( error_mode , "RELMIN") == 0)
error = util_double_max( error * value , min_error );
obs_value[obs_pt_nr] = value;
obs_std [obs_pt_nr] = error;
/**
The input values i,j,k come from the user, and are offset 1. They
are immediately shifted with -1 to become C-based offset zero.
*/
obs_i[obs_pt_nr] = conf_instance_get_item_value_int( obs_instance, "I") - 1;
obs_j[obs_pt_nr] = conf_instance_get_item_value_int( obs_instance, "J") - 1;
obs_k[obs_pt_nr] = conf_instance_get_item_value_int( obs_instance, "K") - 1;
if (source_type == SOURCE_SUMMARY) {
char * summary_key = smspec_alloc_block_ijk_key( SUMMARY_KEY_JOIN_STRING , sum_kw ,
obs_i[obs_pt_nr] + 1 ,
obs_j[obs_pt_nr] + 1 ,
obs_k[obs_pt_nr] + 1 );
stringlist_append_owned_ref( summary_keys , summary_key );
}
}
if (source_type == SOURCE_FIELD) {
const enkf_config_node_type * config_node = ensemble_config_get_node( ensemble_config , field_name);
const field_config_type * field_config = enkf_config_node_get_ref( config_node );
block_obs_type * block_obs = block_obs_alloc(obs_label, source_type , NULL , field_config , grid , num_obs_pts, obs_i, obs_j, obs_k, obs_value, obs_std);
if (block_obs != NULL) {
obs_vector = obs_vector_alloc( BLOCK_OBS , obs_label , ensemble_config_get_node(ensemble_config , field_name), size );
obs_vector_install_node( obs_vector , obs_restart_nr , block_obs);
}
} else if (source_type == SOURCE_SUMMARY) {
OK = true;
if (refcase != NULL) {
for (int i=0; i < stringlist_get_size( summary_keys ); i++) {
const char * sum_key = stringlist_iget( summary_keys , i );
if (!ecl_sum_has_key(refcase , sum_key)) {
/*
If the
*/
fprintf(stderr,"** Warning missing summary %s for cell: (%d,%d,%d) in refcase - make sure that \"BPR %d %d %d\" is included in ECLIPSE summary specification \n" ,
sum_key , obs_i[i]+1 , obs_j[i]+1 , obs_k[i]+1 , obs_i[i]+1 , obs_j[i]+1 , obs_k[i]+1 );
//OK = false;
}
}
}
if (OK) {
// We can create the container node and add the summary nodes.
enkf_config_node_type * container_config = ensemble_config_add_container( ensemble_config , NULL );
for (int i=0; i < stringlist_get_size( summary_keys ); i++) {
const char * sum_key = stringlist_iget( summary_keys , i );
enkf_config_node_type * child_node = ensemble_config_add_summary( ensemble_config , sum_key , LOAD_FAIL_WARN );
enkf_config_node_update_container( container_config , child_node );
}
{
block_obs_type * block_obs = block_obs_alloc(obs_label, source_type , summary_keys , container_config , grid , num_obs_pts, obs_i, obs_j, obs_k, obs_value, obs_std);
if (block_obs != NULL) {
obs_vector = obs_vector_alloc( BLOCK_OBS , obs_label , container_config, size );
obs_vector_install_node( obs_vector , obs_restart_nr , block_obs);
}
}
}
} else
util_abort("%s: invalid source value \n",__func__);
free(obs_value);
free(obs_std);
free(obs_i);
free(obs_j);
free(obs_k);
stringlist_free(obs_pt_keys);
stringlist_free(summary_keys);
return obs_vector;
} else {
fprintf(stderr,"** Warning the ensemble key:%s does not exist - observation:%s not added \n", field_name , obs_label);
return NULL;
}
}
/*****************************************************************/
void obs_vector_iget_observations(const obs_vector_type * obs_vector , int report_step , obs_data_type * obs_data, const active_list_type * active_list) {
void * obs_node = vector_iget( obs_vector->nodes , report_step );
if ( obs_node != NULL)
obs_vector->get_obs(obs_node , obs_data , report_step , active_list);
}
void obs_vector_measure(const obs_vector_type * obs_vector , enkf_fs_type * fs , state_enum state , int report_step , const enkf_state_type * enkf_state , meas_data_type * meas_data , const active_list_type * active_list) {
void * obs_node = vector_iget( obs_vector->nodes , report_step );
if ( obs_node != NULL ) {
enkf_node_type * enkf_node = enkf_state_get_node( enkf_state , obs_vector_get_state_kw( obs_vector ));
node_id_type node_id = { .report_step = report_step ,
.state = state ,
.iens = enkf_state_get_iens( enkf_state ) };
enkf_node_load(enkf_node , fs , node_id);
obs_vector->measure(obs_node , enkf_node_value_ptr(enkf_node) , node_id , meas_data , active_list);
}
}
/*****************************************************************/
/** Here comes many different functions for misfit calculations. */
/**
This is the lowest level function:
* It is checked that the obs_vector is active for the actual report
step; if it is not active 0.0 is returned without any further
ado.
* It is assumed the enkf_node_instance contains valid data for this
report_step. This is not checked in this function, and is the
responsability of the calling scope.
* The underlying chi2 function will do a type-check of node - and
fail hard if it is not correct.
*/
static double obs_vector_chi2__(const obs_vector_type * obs_vector , int report_step , const enkf_node_type * node, node_id_type node_id) {
void * obs_node = vector_iget( obs_vector->nodes , report_step );
if ( obs_node != NULL)
return obs_vector->chi2( obs_node , enkf_node_value_ptr( node ), node_id);
else
return 0.0; /* Observation not active for this report step. */
}
double obs_vector_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , node_id_type node_id) {
enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node );
double chi2 = 0;
if (enkf_node_try_load( enkf_node , fs , node_id))
chi2 = obs_vector_chi2__(obs_vector , node_id.report_step , enkf_node , node_id);
enkf_node_free( enkf_node );
return chi2;
}
/**
This function will evaluate the chi2 for the ensemble members
[iens1,iens2) and report steps [step1,step2).
Observe that the chi2 pointer is assumed to be allocated for the
complete ensemble, altough this function only operates on part of
it.
*/
//This will not work for container observations .....
void obs_vector_ensemble_chi2(const obs_vector_type * obs_vector ,
enkf_fs_type * fs,
bool_vector_type * valid ,
int step1 ,
int step2 ,
int iens1 ,
int iens2 ,
state_enum load_state ,
double ** chi2) {
int step;
enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node );
node_id_type node_id;
node_id.state = load_state;
for (step = step1; step <= step2; step++) {
int iens;
node_id.report_step = step;
{
void * obs_node = vector_iget( obs_vector->nodes , step);
if (obs_node == NULL) {
for (iens = iens1; iens < iens2; iens++)
chi2[step][iens] = 0;
} else {
for (iens = iens1; iens < iens2; iens++) {
node_id.iens = iens;
if (enkf_node_try_load( enkf_node , fs , node_id))
chi2[step][iens] = obs_vector_chi2__(obs_vector , step , enkf_node , node_id);
else {
chi2[step][iens] = 0;
// Missing data - this member will be marked as invalid in the misfit calculations.
bool_vector_iset( valid , iens , false );
}
}
}
}
}
enkf_node_free( enkf_node );
}
/**
This function will evaluate the total chi2 for one ensemble member
(i.e. sum over report steps).
*/
double obs_vector_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int iens, state_enum load_state) {
int report_step;
double sum_chi2 = 0;
enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node );
node_id_type node_id = {.report_step = 0, .iens = iens , .state = load_state };
for (report_step = 0; report_step < vector_get_size( obs_vector->nodes ); report_step++) {
if (vector_iget(obs_vector->nodes , report_step) != NULL) {
node_id.report_step = report_step;
if (enkf_node_try_load( enkf_node , fs , node_id))
sum_chi2 += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id);
}
}
enkf_node_free( enkf_node );
return sum_chi2;
}
/**
This function will sum up all timesteps of the obs_vector, for all ensemble members.
*/
void obs_vector_ensemble_total_chi2(const obs_vector_type * obs_vector , enkf_fs_type * fs , int ens_size , state_enum load_state , double * sum_chi2) {
const bool verbose = true;
msg_type * msg;
int report_step;
int iens;
char * msg_text = NULL;
for (iens = 0; iens < ens_size; iens++)
sum_chi2[iens] = 0;
if (verbose) {
msg = msg_alloc("Observation: " , false);
msg_show(msg);
}
{
node_id_type node_id = {.report_step = 0, .iens = iens , .state = load_state };
enkf_node_type * enkf_node = enkf_node_alloc( obs_vector->config_node );
for (report_step = 0; report_step < vector_get_size( obs_vector->nodes); report_step++) {
if (verbose) {
msg_text = util_realloc_sprintf( msg_text , "%s[%03d]" , obs_vector->obs_key , report_step);
msg_update(msg , msg_text);
}
if (vector_iget(obs_vector->nodes , report_step) != NULL) {
node_id.report_step = report_step;
for (iens = 0; iens < ens_size; iens++) {
node_id.iens = iens;
if (enkf_node_try_load( enkf_node , fs , node_id))
sum_chi2[iens] += obs_vector_chi2__(obs_vector , report_step , enkf_node, node_id);
}
}
}
enkf_node_free( enkf_node );
}
if (verbose) {
msg_free(msg , true);
util_safe_free( msg_text );
}
}
const char * obs_vector_get_obs_key( const obs_vector_type * obs_vector) {
return obs_vector->obs_key;
}
/*****************************************************************/
VOID_FREE(obs_vector)

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