ERT: Updated to nnc-export branch from Joakim b933117d4e

This commit is contained in:
Jacob Støren 2013-12-09 15:19:06 +01:00
parent e3135e8d08
commit a0404333ab
474 changed files with 27070 additions and 4587 deletions

9
ThirdParty/Ert/.gitattributes vendored Normal file
View File

@ -0,0 +1,9 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.cpp text
*.hpp text
*.c text
*.h text

View File

@ -4,6 +4,13 @@
*/.svn/
*.pyc
*~
*.user
#pyCharm project
.idea
#to make python tests run in-source
devel/python/lib64
# /devel/libenkf/src/
/devel/libenkf/src/.faultlist
@ -21,3 +28,8 @@
# Ignore the ert_local python file which is needed to run some python tests
/devel/python/python/ert/ecl/ecl_local.py
/devel/GPATH
/devel/GRTAGS
/devel/GTAGS
/devel/gtags.sh
/cmake.sh

155
ThirdParty/Ert/README vendored
View File

@ -27,20 +27,21 @@
1. ERT
ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble
ERT - Ensemble based Reservoir Tool is a tool for managing an ensemble
of reservoir models. The initial motivation for creating ERT was a as
tool to do assisted history matching with Ensemble Kalman Filter
(EnKF). Very briefly use of EnKF can be summarized as:
tool to do assisted history matching with the Ensemble Kalman Filter
(EnKF). Very briefly, the process of using EnKF for history matching
can be summarized as:
1. Sample initial reservoir parameters from a (Gaussian) prior
1. Sample initial reservoir parameters from a (Gaussian) initial
distribution.
2. Simulate the ensemble of of reservoir forward in time through
part of the historical period.
2. Simulate the ensemble of of reservoir forward in time through a
part of the historical period for which data is available.
3. Load the results, compare with observed data, update the
parameters and the state of reservoir and restart the
simulations.
3. Load the results, compare with the observed data, update the
parameters and the state of reservoir by filtering out the most
inacurate results, and restart the forward simulations.
This recipe is quite complex technically, and in particular involves
the ability to read and write input and output files from the
@ -51,23 +52,23 @@ before the EnKF algorithm as such can be utilizied. This in particular
applies to real industry reservoir models, where typically
imperfections of all kinds flourish.
The initial motivation for creating ERT was to be able to use the EnKF
algorithm for history matching. Currently ERT is more used with the
Ensemble Smoother and also purely as a worklfow manager; herding a
large collection of reservoir models through the required simulations
steps.
Despite the fact that the initial motivation for creating ERT was to
be able to use the EnKF algorithm for history matching, ERT is
currently more used with the Ensemble Smoother and also purely as a
workflow manager, i.e. herding a large collection of reservoir models
through the required simulations steps.
2. ECLIPSE Utilities
ERT has a quite large amount of code devoted to reading and writing
the ECLIPSE output files (grid/rft/restart/init/summary). In addition
the ECLIPSE output files (grid/rft/restart/init/summary). In addition,
there is also reasonable support for reading and writing the grdecl
input files, but there is no general .DATA file parser. The ability to
read and write ECLIPSE output files is valuable in many reservoir
applications, and it is possible to only build and use the libecl
(with support libraries) library for working with ECLIPSE files. In
fact the default build setup is to only build the ECLIPSE related
fact, the default build setup is to only build the ECLIPSE related
library and utilities. This part of the ERT distribution can also be
built on Windows with Visual Studio (albeit with maaaany warnings) and
with MinGW.
@ -92,8 +93,8 @@ Building with CMake is performed like this:
Go through several 'configure' steps with CMake and generate
native build files.
3. Exit ccmake and invoke the native build system, i.e. ordinaray
make on Linux.
3. Exit ccmake and invoke the native build system, i.e. ordinarily
'make' on Linux.
4. Subsequent builds can be performed using just the native make
command, as in step 3.
@ -109,15 +110,15 @@ will need a Linux (Posix) system.
4. The code
The code is mainly written as a collection of libraries written in C.
The code is mainly a collection of libraries written in C.
4.1 The different libraries
The different libraries are:
The provided libraries are:
libert_util: This library is a collection of utilities of various
sorts; if C++ had been chosen as implementation language most of
these utilities would probably have been in libstdc++.
sorts; if C++ had been chosen as implementation language, most of
these utilities could probably be replaced by standard C++ classes.
libgeometry: This is a very small geometry library; the main code
is a small implementantion of an alorithm to determine whether a
@ -138,23 +139,23 @@ The different libraries are:
----------------------------------------------------------------------------
librms: This is a library for reading and writing RMS Roff
files. It turns out that ECLIPSE file formats is the most common
external file format for RMS and the ROFF support is not
essential.
files. It turns out that ECLIPSE file formats is by far the most
common external file format for RMS and that the ROFF support is
not essential for this reason.
libconfig: This library implements a parser for the ERT config file
format, this format is used in the main ERT configuration file,
and also in several small special topic configuration files used
and also in several small special-purpose configuration files used
by ERT. The config format parsed by this library was inspired by
the ECLIPSE format, in retrospect that was a mistake - it should
have been based on a standard format like xml.
To confuse things evan further the libconfig library implements
/two/ config formats, the 'second format' is implemented in the
file conf.c, and only used as format for the observations in
ERT.
To confuse things even further, the libconfig library implements
/two/ formats for configuration files -- the 'second format' is
implemented in the file conf.c, and only used as format for the
observations in ERT.
libplot: A *very* simple librarry for creating plots, just exactly
libplot: A *very* simple library for creating plots which only
satisfies the needs of ERT.
libanalysis: The EnKF algorithm is implemented in this library.
@ -162,36 +163,37 @@ The different libraries are:
libjob_queue: This library implements a system to manage and run
simulations in the form of external programs. The library has a
queue manager, and a system with drivers which communicate with
the underlying system. Currently the library has a LSF driver to
work with LSF, a LOCAL driver which starts simulations on the
current workstation and a RSH driver which submits to a
'cluster' of workstation with ssh.
the underlying system. Currently, the library has a LSF driver
to work with LSF, a LOCAL driver which starts simulations on the
current workstation and a RSH driver which submits jobs to a
'cluster' of workstation using ssh.
libenkf: This is the main functionality which is ERT specific; this
library is to large.
library is too large.
4.2 General structure
The code is written in C, but conventions give a 'scent of object
oriented'. Common to a very large part of the code is the following:
orientation'. Most of the code is uses the following conventions:
- Every file 'xxx' implements a datatype 'xxx_type' - the naming
- Every file 'xxx' implements a data type 'xxx_type' - this naming
convention is quite strong.
- All the struct defintions are in the source files, i.e. external
scope must access the fields of a structure through accessor
functions.
- All the structure definitions are in the source files,
i.e. external scopes must access the data of a structure
through accessor functions.
- All functions which operate on a type 'xxx_type' take a pointer
to xxx_type as the first argument, the structure closely resemble
the 'self' argument used when implementing Python classes.
to xxx_type as their first argument, the structure closely
resemble the 'self' argument used when implementing Python
classes.
- Memory management is manual; however there are some conventions:
* Functions allocating storage have _alloc_ as part of the name.
* For all functions xxx_alloc() allocating storage there should
be a matching xxx_free() to discard the objects.
* Containers can optionally destroy their content is the content
* For all functions xxx_alloc() which allocate memory, there
should be a matching xxx_free() function to discard the objects.
* Containers can optionally destroy their content if the content
is installed with a destructor.
- In libert_util/src/type_macros.h there is a macro based
@ -201,15 +203,15 @@ oriented'. Common to a very large part of the code is the following:
4.3 Python wrappers
Some of the code, in particular the ECLIPSE related functionality, has
been wrapped in Python. Using these wrappers it is quite easy work
with ECLIPSE files. The python wrappers are quite well documented both
in the devel/python/docs directory and in the Python classes
themselves.
been wrapped for usage in Python. Using these wrappers, it is quite
easy work with ECLIPSE files. The python wrappers are quite well
documented both in the directory devel/python/docs and in the Python
classes themselves.
5. Test
5. Tests
The ert codebase has a small but increasing test coverage. The tests
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:
@ -226,73 +228,74 @@ framework is based on ctest which basically works like this:
in principle be an arbitrary executable like a dedicated test
runner or e.g. the Python interpreter.
5.1 Test of C code
5.1 Testing of C code
The main part of the testing infrastructure is small C applications
The main part of the testing infrastructure are small C applications
which are added like this:
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 )
Where the two first lines create the test executable in the normal
Where the first two lines create the test executable in the normal
way, and the last line adds it as a test.
5.2 Test of Python Code
5.2 Testing of Python Code
In devel/python/test there are several files with Python tests, these
files are executable files and they are invoked directly from the
commandline. A limited number of the tests have been integrated in the
command line. A limited number of the tests have been integrated in the
ctest system.
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
the libecl library have a name starting with 'ecl' and all tests in
the config library start with 'config'. The options -R and -E to ctest
can be used to include and exclude tests based on their name
the library regarding the functionality which they are testing: For
example, all tests for the libecl library use a name starting with
'ecl' and all tests for the tests for the config library are prefixed
by 'config'. The ctest options -R and -E can be used to include and
exclude tests based on their name
ctest -R ecl # Run all tests mathing the regexp 'ecl'
ctest -E ecl # Run all tests NOT matching the regexp 'ecl'
ctest -R ecl # Run all tests containing the regular expression 'ecl'
ctest -E ecl # Run all tests NOT containing the regular expression 'ecl'
5.4 Test labels
Using the cmake set_property() function it is possible to assigne
Using the cmake set_property() function it is possible to assign
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.
label with a ":" separator, e.g.
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:
labels currently available 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.
internal data. If you are work for the Bergen office of Statoil,
you can read the the file devel/test-data/README for
instructions on how to make this data available.
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.
If you are not for Statoil in Bergen, you must pass the option:
"-EL StatoilData" to ctest to skip all the tests which require
Statoil internal 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
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
these 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.
Python: This label is used to indicate that the test uses Python.
LSF: This labels indicates that the test needs a working LSF
environment to run.
5.5 ctest examples
ctest -L Statoil # Run all tests labeled with Statoil - both
# StatoilData and StatoilBuild

View File

@ -1,4 +1,4 @@
cmake_minimum_required( VERSION 2.6 )
cmake_minimum_required( VERSION 2.8 )
project( ERT C CXX )
set( ERT_VERSION_MAJOR 1 )
@ -13,7 +13,7 @@ option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF)
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON)
option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF )
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" ON)
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" OFF)
include( CheckFunctionExists )
include( CheckTypeSize )
@ -43,11 +43,9 @@ if (ERT_USE_OPENMP)
find_package(OpenMP)
if (OPENMP_FOUND)
message(STATUS "Enabling OpenMP support")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
# The actual use of OpenMP is only in the libecl library - the compile flags is only applied there.
else()
set( ERT_USE_OPENMP OFF )
message(STATUS "OpenMP package not found - OpenMP disabled")
endif()
endif()

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
from os import listdir
from os.path import isfile, join, isdir
from os.path import isfile, join, isdir, islink
import sys
@ -12,7 +12,7 @@ def findFilesAndDirectories(directory):
directories = []
for f in all_files:
path = join(directory, f)
if isfile(path) and not f == "CMakeLists.txt":
if isfile(path) and not f == "CMakeLists.txt" and not islink(path):
files.append(f)
if isdir(path):
directories.append(f)
@ -52,10 +52,14 @@ def addSubDirectories(directories):
def addPythonPackage(relative_module_path):
module_name = ".".join(relative_module_path.split("/"))
template = "add_python_package(\"Python %s\" ${PYTHON_INSTALL_PREFIX}/%s \"${PYTHON_SOURCES}\" True)"
template = "add_python_package(\"python.%s\" ${PYTHON_INSTALL_PREFIX}/%s \"${PYTHON_SOURCES}\" True)"
return template % (module_name, relative_module_path)
def addInclude(filename):
with open(filename, "r") as include_file:
content = include_file.read()
return content
files, directories = findFilesAndDirectories(sys.argv[1])
module_path = findRelativeModulePath(sys.argv[1])
@ -68,4 +72,10 @@ with open(output_file, "w+") as text_file:
text_file.write("\n\n")
text_file.write(addSubDirectories(directories))
if "local.cmake" in files:
text_file.write("\n\n")
text_file.write(addInclude(join(sys.argv[1], "local.cmake")))

View File

@ -1,3 +1,6 @@
if (NOT PYTHONINTERP_FOUND)
find_package (PythonInterp REQUIRED)
endif ()
function(add_python_package target package_path source_files install_package)
set(build_files "")
@ -9,8 +12,8 @@ function(add_python_package target package_path source_files install_package)
add_custom_command(
OUTPUT ${build_file}
COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc2
ARGS ${source_file} ${build_file}
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc2 ${source_file} ${build_file}
DEPENDS ${source_file} )
list(APPEND build_files ${build_file} )

View File

@ -13,6 +13,8 @@ extern "C" {
#define DEFAULT_ENKF_TRUNCATION_ 0.98
#define ENKF_TRUNCATION_KEY_ "ENKF_TRUNCATION"
#define ENKF_NCOMP_KEY_ "ENKF_NCOMP"
#define ENKF_LAMBDA0_KEY_ "LAMBDA0"
#define ENKF_ITER_KEY_ "ITER"
typedef struct std_enkf_data_struct std_enkf_data_type;
@ -24,6 +26,7 @@ extern "C" {
int std_enkf_get_subspace_dimension( std_enkf_data_type * data );
void std_enkf_set_truncation( std_enkf_data_type * data , double truncation );
void std_enkf_set_subspace_dimension( std_enkf_data_type * data , int subspace_dimension);
void std_enkf_set_lambda0( std_enkf_data_type * data , double lambda0 );
double std_enkf_get_truncation( std_enkf_data_type * data );

View File

@ -89,7 +89,8 @@ struct rml_enkf_data_struct {
long option_flags;
int iteration_nr; // Keep track of the outer iteration loop
double lambda; // parameter to control the search direction in Marquardt levenberg optimization
double lambda; // parameter to control the search direction in Marquardt levenberg optimization
double lambda0; // Initial lambda value
double Sk; // Objective function value
double Std; // Standard Deviation of the Objective function
matrix_type *state;
@ -122,6 +123,10 @@ void rml_enkf_set_truncation( rml_enkf_data_type * data , double truncation ) {
data->subspace_dimension = INVALID_SUBSPACE_DIMENSION;
}
void rml_enkf_set_lambda0(rml_enkf_data_type * data , double lambda0 ) {
data->lambda0 = lambda0;
}
void rml_enkf_set_subspace_dimension( rml_enkf_data_type * data , int subspace_dimension) {
data->subspace_dimension = subspace_dimension;
if (subspace_dimension > 0)
@ -139,10 +144,11 @@ void * rml_enkf_data_alloc( rng_type * rng) {
rml_enkf_set_truncation( data , DEFAULT_ENKF_TRUNCATION_ );
rml_enkf_set_subspace_dimension( data , DEFAULT_SUBSPACE_DIMENSION );
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE;
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE + ANALYSIS_SCALE_DATA;
data->iteration_nr = 0;
data->Std = 0;
data->state = NULL;
data->lambda0 = -1.0;
return data;
}
@ -207,8 +213,13 @@ void rml_enkf_updateA(void * module_data ,
if (data->iteration_nr == 0) {
Sk_new = enkf_linalg_data_mismatch(D,Cd,Skm); //Calculate the intitial data mismatch term
Std_new = matrix_diag_std(Skm,Sk_new);
data->lambda = pow(10,floor(log10(Sk_new/(2*nrobs))));
data->state = matrix_realloc_copy(data->state , A);
if (data->lambda0 < 0)
data->lambda = pow(10,floor(log10(Sk_new/(2*nrobs))));
else
data->lambda = data->lambda0;
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
data->Sk = Sk_new;
data->Std = Std_new;
@ -288,6 +299,8 @@ bool rml_enkf_set_double( void * arg , const char * var_name , double value) {
if (strcmp( var_name , ENKF_TRUNCATION_KEY_) == 0)
rml_enkf_set_truncation( module_data , value );
else if (strcmp( var_name , ENKF_LAMBDA0_KEY_) == 0)
rml_enkf_set_lambda0( module_data , value );
else
name_recognized = false;
@ -303,7 +316,7 @@ bool rml_enkf_set_int( void * arg , const char * var_name , int value) {
if (strcmp( var_name , ENKF_NCOMP_KEY_) == 0)
rml_enkf_set_subspace_dimension( module_data , value );
else if(strcmp( var_name , "NUM_ITER") == 0)
else if(strcmp( var_name , ENKF_ITER_KEY_) == 0)
rml_enkf_set_iteration_number( module_data , value );
else
name_recognized = false;
@ -323,10 +336,14 @@ long rml_enkf_get_options( void * arg , long flag ) {
bool rml_enkf_has_var( const void * arg, const char * var_name) {
if (strcmp(var_name , "ITER") == 0)
return true;
else
return false;
bool ret = false;
if ((strcmp(var_name , ENKF_ITER_KEY_) == 0) ||
(strcmp(var_name , ENKF_TRUNCATION_KEY_) == 0) ||
(strcmp(var_name , ENKF_LAMBDA0_KEY_) == 0)) {
ret = true;
}
return ret;
}
@ -335,12 +352,24 @@ long rml_enkf_get_options( void * arg , long flag ) {
int rml_enkf_get_int( const void * arg, const char * var_name) {
const rml_enkf_data_type * module_data = rml_enkf_data_safe_cast_const( arg );
{
if (strcmp(var_name , "ITER") == 0)
if (strcmp(var_name , ENKF_ITER_KEY_) == 0)
return module_data->iteration_nr;
else
return -1;
}
}
double rml_enkf_get_double( const void * arg, const char * var_name) {
const rml_enkf_data_type * module_data = rml_enkf_data_safe_cast_const( arg );
{
if (strcmp(var_name , ENKF_TRUNCATION_KEY_) == 0)
return module_data->truncation;
else if (strcmp(var_name , ENKF_LAMBDA0_KEY_) == 0)
return module_data->lambda0;
else
return -1.0;
}
}
@ -373,7 +402,7 @@ analysis_table_type SYMBOL_TABLE = {
.complete_update = NULL,
.has_var = rml_enkf_has_var,
.get_int = rml_enkf_get_int,
.get_double = NULL,
.get_double = rml_enkf_get_double,
.get_ptr = NULL,
};

View File

@ -140,7 +140,7 @@ void * rml_enkf_imodel_data_alloc( rng_type * rng) {
rml_enkf_imodel_set_truncation( data , DEFAULT_ENKF_TRUNCATION_ );
rml_enkf_imodel_set_subspace_dimension( data , DEFAULT_SUBSPACE_DIMENSION );
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE;
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE + ANALYSIS_SCALE_DATA;
data->iteration_nr = 0;
data->Std = 0;
return data;
@ -475,7 +475,7 @@ long rml_enkf_imodel_get_options( void * arg , long flag ) {
bool rml_enkf_imodel_has_var( const void * arg, const char * var_name) {
{
if (strcmp(var_name , "ITER") == 0)
if (strcmp(var_name , ENKF_ITER_KEY_) == 0)
return true;
else
return false;
@ -488,7 +488,7 @@ long rml_enkf_imodel_get_options( void * arg , long flag ) {
int rml_enkf_imodel_get_int( const void * arg, const char * var_name) {
const rml_enkf_imodel_data_type * module_data = rml_enkf_imodel_data_safe_cast_const( arg );
{
if (strcmp(var_name , "ITER") == 0)
if (strcmp(var_name , ENKF_ITER_KEY_) == 0)
return module_data->iteration_nr;
else
return -1;

View File

@ -346,6 +346,7 @@ bool analysis_module_set_var( analysis_module_type * module , const char * var_n
if (util_sscanf_int( string_value , &int_value ))
set_ok = analysis_module_set_int( module , var_name , int_value );
if (set_ok)
return true;
}
@ -354,7 +355,7 @@ bool analysis_module_set_var( analysis_module_type * module , const char * var_n
double double_value;
if (util_sscanf_double( string_value , &double_value ))
set_ok = analysis_module_set_double( module , var_name , double_value );
if (set_ok)
return true;
}

View File

@ -1,9 +1,10 @@
add_test( analysis_module_test_RML ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rml_enkf.so )
add_test( analysis_module_test_RMLI ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so )
if (BUILD_APPLICATIONS)
add_test( analysis_module_test_RML ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rml_enkf.so )
add_test( analysis_module_test_RMLI ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so )
endif()
add_executable(analysis_test_external_module analysis_test_external_module.c )
target_link_libraries( analysis_test_external_module analysis util test_util )
add_test( analysis_module_rml ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RML_ENKF" ${LIBRARY_OUTPUT_PATH}/rml_enkf.so 41 ITER)
add_test( analysis_module_rmli ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RMLI_ENKF" ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so 41 ITER)
add_test( analysis_module_rml ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RML_ENKF" ${LIBRARY_OUTPUT_PATH}/rml_enkf.so 41 ITER LAMBDA0)
add_test( analysis_module_rmli ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RMLI_ENKF" ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so 41 ITER)

View File

@ -41,6 +41,7 @@ void load_module( rng_type * rng , const char * user_name , const char * lib_nam
test_assert_true( analysis_module_has_var(analysis_module , var_list[i]));
}
test_assert_false( analysis_module_has_var(analysis_module , "DoesNotHaveThisVariable"));
test_assert_true( analysis_module_check_option( analysis_module , flags));
flags += 1;
test_assert_false( analysis_module_check_option( analysis_module , flags));

View File

@ -296,7 +296,7 @@ Q | Quit
#define XMIN_CMD "XMIN"
#define XMAX_CMD "XMAX"
#define YMIN_CMD "XMIN"
#define YMIN_CMD "YMIN"
#define YMAX_CMD "YMAX"
#define STOP_CMD "_stop_"
@ -1103,29 +1103,33 @@ double get_rft_depth (hash_type * ens_table, char * well, int i, int j, int k) {
}
}
const ecl_rft_file_type * ecl_rft = vector_iget_const( ens->data , 0 );
const ecl_rft_node_type * ecl_rft_node = ecl_rft_file_iget_well_rft(ecl_rft, well, 0);
const int node_size = ecl_rft_node_get_size(ecl_rft_node);
int inode;
int ni,nj,nk;
for (inode =0;inode < node_size;inode++){
ecl_rft_node_iget_ijk( ecl_rft_node , inode , &ni , &nj , &nk);
if( i == ni && j==nj && k==nk){
//double depth = ecl_rft_node_iget_depth(ecl_rft_node,inode);
return ecl_rft_node_iget_depth(ecl_rft_node,inode);
if (ecl_rft_file_has_well( ecl_rft , well )) {
const ecl_rft_node_type * ecl_rft_node = ecl_rft_file_iget_well_rft(ecl_rft, well, 0);
const int node_size = ecl_rft_node_get_size(ecl_rft_node);
int inode;
int ni,nj,nk;
for (inode =0;inode < node_size;inode++){
/*
The ecl_rft structure has zero offset values for the
coordinates, whereas the (i,j,k) input to this function is
assumed offset 1.
*/
ecl_rft_node_iget_ijk( ecl_rft_node , inode , &ni , &nj , &nk);
if( ( i == (ni + 1)) &&
( j == (nj + 1)) &&
( k == (nk + 1))) {
//double depth = ecl_rft_node_iget_depth(ecl_rft_node,inode);
return ecl_rft_node_iget_depth(ecl_rft_node,inode);
}
}
}
return 0;
}
void plot_meas_file(plot_type * plot, time_t start_time){
bool done = 0;
double x,x1,x2,y,y1,y2;

View File

@ -1,14 +0,0 @@
#!/bin/csh
time ./grid_dump.x $1 /tmp/grid_n
setenv OMP_NUM_THREADS 32
time ./grid_dump.x $1 /tmp/grid_32
setenv OMP_NUM_THREADS 1
time ./grid_dump.x $1 /tmp/grid_1
unsetenv OMP_NUM_THREADS
diff /tmp/grid_1 /tmp/grid_n
diff /tmp/grid_1 /tmp/grid_32

View File

@ -1 +0,0 @@
SConscript(["src/SConstruct"])

View File

@ -0,0 +1,57 @@
#ifndef __ECL_KW_HPP__
#define __ECL_KW_HPP__
#include <iostream>
#include <ecl_util.h>
#include <ecl_kw.h>
#include <fortio.hpp>
class EclKW {
private:
ecl_kw_type * c_ptr;
bool owner;
EclKW(ecl_kw_type * c_ptr , bool owner) {
this->c_ptr = c_ptr;
this->owner = owner;
std::cout << "Have created: " << ecl_kw_get_header( c_ptr ) << "\n";
}
public:
ecl_kw_type * C_PTR( ) { return c_ptr; }
//EclKW( const std::string& name , size_t size , ecl_type_enum type , void * data = NULL);
static EclKW create (const char * name , int size , ecl_type_enum type , void * data = NULL);
static EclKW wrap (ecl_kw_type * c_ptr , bool owner = false);
static EclKW wrap_data(const char * name , int size , ecl_type_enum type, void * data);
//EclKW( EclKW& src);
~EclKW();
void fwrite( FortIO& fortio );
int size( ) { return ecl_kw_get_size( c_ptr ); }
ecl_type_enum type() { return ecl_kw_get_type( c_ptr ); }
template <typename T> void set_data( const T * data ) {
ecl_kw_set_memcpy_data( c_ptr , data );
}
template <typename T> void iset(int i , T value) {
ecl_kw_iset( c_ptr , i , &value);
}
template <typename T> T iget(int i ) {
T value;
ecl_kw_iget( c_ptr , i , &value);
return value;
}
};
#endif

View File

@ -0,0 +1,33 @@
#ifndef __FORTIO_HPP__
#define __FORTIO_HPP__
#include <string>
#include <fortio.h>
#ifndef BYTE_ORDER
#define BYTE_ORDER __LITTLE_ENDIAN
#endif
#include <ecl_endian_flip.h>
class FortIO {
private:
fortio_type * c_ptr;
FortIO(fortio_type * c_ptr) {
this->c_ptr = c_ptr;
}
public:
~FortIO() { close(); }
fortio_type * C_PTR( ) { return c_ptr; }
static FortIO writer(const std::string & filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP );
static FortIO reader(const char * filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP );
static FortIO readwrite( const char * filename , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP );
void close();
};
#endif

View File

@ -1,38 +0,0 @@
import os
import os.path
import sys
sys.path += ["../../../scons-config"]
import global_config
from global_config import LIBUTIL
from global_config import LIBECL
from global_config import LIBGEOMETRY
from global_config import add_static_library
from global_config import add_shared_library
from global_config import add_header
from global_config import get_target
package = "eclxx"
lib_path = "../lib"
slib_path = "../slib"
include_path = "../include"
bin_path = "../bin"
conf = global_config.get_conf(os.getcwd() , 3)
env = Environment()
conf.update_env( env , [ LIBGEOMETRY , LIBECL , LIBUTIL] , link = False)
src_list = Split("fortio.cxx ecl_kw.cxx")
# tetrahedron.h and point.h are not installed.
header_list = Split("fortio.hpp ecl_kw.hpp")
add_static_library( env , conf , lib_path , package , src_list)
add_shared_library( env , conf , slib_path , package , src_list)
add_header( env , conf , include_path , header_list )
Default( lib_path , include_path , slib_path )

View File

@ -108,6 +108,7 @@ extern "C" {
/*****************************************************************/
/* R E S T A R T F I L E S */
double ecl_file_iget_restart_sim_days( const ecl_file_type * restart_file , int index );
time_t ecl_file_iget_restart_sim_date( const ecl_file_type * restart_file , int occurence );
int ecl_file_get_restart_index( const ecl_file_type * restart_file , time_t sim_time);
bool ecl_file_has_report_step( const ecl_file_type * ecl_file , int report_step);

View File

@ -79,7 +79,6 @@ extern "C" {
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);
@ -90,6 +89,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);
ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const int * actnum);
bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input );
@ -144,6 +144,7 @@ extern "C" {
const ecl_grid_type * ecl_grid_get_cell_lgr1(const ecl_grid_type * grid , int global_index );
int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid );
int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid );
int ecl_grid_get_lgr_nr_from_name( const ecl_grid_type * grid , const char * name);
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_index);
ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, int lgr_nr);
ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
@ -181,6 +182,7 @@ extern "C" {
void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points);
bool ecl_grid_dual_grid( const ecl_grid_type * ecl_grid );
int ecl_grid_get_num_nnc( const ecl_grid_type * grid );
UTIL_IS_INSTANCE_HEADER( ecl_grid );

View File

@ -95,6 +95,7 @@ extern "C" {
void ecl_kw_get_data_as_float(const ecl_kw_type * ecl_kw , float * float_data);
bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2);
bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2);
bool ecl_kw_icmp_string( const ecl_kw_type * ecl_kw , int index, const char * other_string);
bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double rel_diff);
bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int cmp_elements);
bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data);

View File

@ -27,6 +27,9 @@ extern "C" {
#define PORMOD_KW "PORV_MOD"
#define PVTNUM_KW "PVTNUM"
#define LGRHEADI_KW "LGRHEADI"
#define LGRHEADI_LGR_NR_INDEX 0
#define LGRJOIN_KW "LGRJOIN"
/*
Observe that many of the elements in the INTEHEAD keyword is shared
@ -103,6 +106,7 @@ extern "C" {
#define IWEL_KW "IWEL"
#define ZWEL_KW "ZWEL"
#define ICON_KW "ICON"
#define SCON_KW "SCON"
#define ISEG_KW "ISEG"
#define RSEG_KW "RSEG"
@ -129,7 +133,8 @@ extern "C" {
#define INTEHEAD_NCWMAX_INDEX 17 // Maximum number of completions per well
#define INTEHEAD_NWGMAX_INDEX 19 // Maximum number of wells in any group
#define INTEHEAD_NGMAXZ_INDEX 20 // Maximum number of groups in field
#define INTEHEAD_NICONZ_INDEX 32 // Number of elements pr completion in the ICON arra.y
#define INTEHEAD_NICONZ_INDEX 32 // Number of elements pr completion in the ICON array.
#define INTEHEAD_NSCONZ_INDEX 33 // Number of elements pr completion in the SCON array.
#define INTEHEAD_NIGRPZ_INDEX 36 // Number of elements pr group in the IGRP array.
#define INTEHEAD_NSWLMX_INDEX 175
@ -285,6 +290,10 @@ extern "C" {
#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*/
#define TRANNNC_KW "TRANNNC"
#define TRANGL_KW "TRANGL"
#define TRANLL_KW "TRANLL"
/* EGRID keywords */
#define LGR_PARENT_KW "LGRPARNT" /* The name of the parent for an LGR. */
#define COORDS_KW "COORDS" /* The (x,y) coordinates of the top and bottom of the pillars constituting the grid. */

View File

@ -0,0 +1,54 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_export.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 __ECL_NNC_EXPORT__
#define __ECL_NNC_EXPORT__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_kw.h>
typedef struct {
int grid_nr1;
int global_index1;
int grid_nr2;
int global_index2;
double trans;
} ecl_nnc_type;
int ecl_nnc_export_get_size( const ecl_grid_type * grid );
void ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data);
ecl_kw_type * ecl_nnc_export_get_tranx_kw( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1, int lgr_nr2 );
ecl_kw_type * ecl_nnc_export_get_tranll_kw( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1, int lgr_nr2 );
ecl_kw_type * ecl_nnc_export_get_tran_kw( const ecl_file_type * init_file , const char * kw , int lgr_nr );
int ecl_nnc_cmp( const ecl_nnc_type * nnc1 , const ecl_nnc_type * nnc2);
void ecl_nnc_sort( ecl_nnc_type * nnc_list , int size);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -56,6 +56,7 @@ extern "C" {
// Connection properties
int niconz; // Number of elements per completion in ICON array
int ncwmax; // Maximum number of completions per well
int nsconz; // Number of elements per completion in SCON array
// Segment properties
int nisegz; // Number of entries pr segment in the ISEG array

View File

@ -93,6 +93,7 @@ typedef struct ecl_sum_struct ecl_sum_type;
ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string);
ecl_sum_type * ecl_sum_fread_alloc_case(const char * , const char * key_join_string);
ecl_sum_type * ecl_sum_fread_alloc_case__(const char * , const char * key_join_string , bool include_restart);
bool ecl_sum_case_exists( const char * input_file );
/* Accessor functions : */
double ecl_sum_get_well_var(const ecl_sum_type * ecl_sum , int time_index , const char * well , const char *var);

View File

@ -26,6 +26,8 @@ extern "C" {
#include <ert/util/stringlist.h>
#include <ert/util/time_t_vector.h>
#include <ert/util/parser.h>
typedef enum { ECL_OTHER_FILE = 0 ,
ECL_RESTART_FILE = 1 ,
@ -176,6 +178,7 @@ int ecl_util_fname_report_cmp(const void *f1, const void *f2);
time_t ecl_util_make_date(int mday , int month , int year);
time_t ecl_util_make_date__(int mday , int month , int year, int * year_offset);
bool ecl_util_valid_basename_fmt( const char * basename_fmt );
bool ecl_util_valid_basename( const char * basename );
const char * ecl_util_get_phase_name( ecl_phase_enum phase );
const char * ecl_util_file_enum_iget( int index, int * value);

View File

@ -1,42 +0,0 @@
/*
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

@ -34,19 +34,21 @@ extern "C" {
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);
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number, int nnc_index);
const int_vector_type * nnc_info_iget_index_list(const nnc_info_type * nnc_info, int lgr_index);
const int_vector_type * nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index);
nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index);
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr);
const int_vector_type * nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr);
nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_nr);
const int_vector_type * nnc_info_get_self_index_list(const nnc_info_type * nnc_info);
const int_vector_type * nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info);
nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info );
int nnc_info_get_lgr_nr(const nnc_info_type * nnc_info );
int nnc_info_get_size( const nnc_info_type * nnc_info );
int nnc_info_get_total_size( const nnc_info_type * nnc_info );
void nnc_info_fprintf(const nnc_info_type * nnc_info , FILE * stream);
#ifdef __cplusplus
}

View File

@ -32,10 +32,12 @@ extern "C" {
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(nnc_vector_type * nnc_vector);
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number, int nnc_index);
const int_vector_type * nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector);
const int_vector_type * nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector);
int nnc_vector_get_lgr_nr(const nnc_vector_type * nnc_vector );
void nnc_vector_free__(void * arg);
int nnc_vector_get_size( const nnc_vector_type * nnc_vector );
#ifdef __cplusplus
}

View File

@ -2,11 +2,16 @@ 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 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 nnc_info.h nnc_vector.h ${ext_header} ecl_grav_common.h nnc_index_list.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 nnc_info.c ecl_grav_common.c nnc_vector.c ecl_nnc_export.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 nnc_info.h nnc_vector.h ${ext_header} ecl_grav_common.h ecl_nnc_export.h)
if (ERT_USE_OPENMP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
endif()
add_library( ecl ${LIBRARY_TYPE} ${source_files} )
set_target_properties( ecl PROPERTIES VERSION 1.0 SOVERSION 1.0 )

View File

@ -56,7 +56,7 @@ struct inv_map_struct {
struct ecl_file_kw_struct {
UTIL_TYPE_ID_DECLARATION;
offset_type file_offset;
offset_type file_offset;
ecl_type_enum ecl_type;
int kw_size;
char * header;

View File

@ -40,7 +40,6 @@
#include <ert/ecl/tetrahedron.h>
#include <ert/ecl/grid_dims.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_index_list.h>
/**
@ -360,11 +359,7 @@
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
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.
@ -461,7 +456,6 @@
klib/
*/
static const int tetrahedron_permutations[2][12][3] = {{{0 , 2 , 6},
{0 , 4 , 6},
{0 , 4 , 5},
@ -487,6 +481,8 @@ static const int tetrahedron_permutations[2][12][3] = {{{0 , 2 , 6},
{4 , 5 , 7},
{4 , 6 , 7}}};
/*
the implementation is based on a hierarchy of three datatypes:
@ -551,7 +547,6 @@ 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;
@ -936,7 +931,74 @@ static void ecl_cell_init_tetrahedron( const ecl_cell_type * cell , tetrahedron_
static double C(double *r,int f1,int f2,int f3){
if (f1 == 0) {
if (f2 == 0) {
if (f3 == 0)
return r[0]; // 000
else
return r[4] - r[0]; // 001
} else {
if (f3 == 0)
return r[2] - r[0]; // 010
else
return r[6] + r[0] - r[4] - r[2]; // 011
}
} else {
if (f2 == 0) {
if (f3 == 0)
return r[1] - r[0]; // 100
else
return r[5]+r[0]-r[4]-r[1]; // 101
} else {
if (f3 == 0)
return r[3]+r[0]-r[2]-r[1]; // 110
else
return r[7]+r[4]+r[2]+r[1]-r[6]-r[5]-r[3]-r[0]; // 111
}
}
}
static double ecl_cell_get_volume( ecl_cell_type * cell ) {
double volume = 0;
int pb,pg,qa,qg,ra,rb;
double X[8];
double Y[8];
double Z[8];
{
int c;
for (c = 0; c < 8; c++) {
X[c] = cell->corner_list[c].x;
Y[c] = cell->corner_list[c].y;
Z[c] = cell->corner_list[c].z;
}
}
for (pb=0;pb<=1;pb++)
for (pg=0;pg<=1;pg++)
for (qa=0;qa<=1;qa++)
for (qg=0;qg<=1;qg++)
for (ra=0;ra<=1;ra++)
for (rb=0;rb<=1;rb++) {
int divisor = (qa+ra+1)*(pb+rb+1)*(pg+qg+1);
double dV = C(X,1,pb,pg) * C(Y,qa,1,qg) * C(Z,ra,rb,1) -
C(X,1,pb,pg) * C(Z,qa,1,qg) * C(Y,ra,rb,1) -
C(Y,1,pb,pg) * C(X,qa,1,qg) * C(Z,ra,rb,1) +
C(Y,1,pb,pg) * C(Z,qa,1,qg) * C(X,ra,rb,1) +
C(Z,1,pb,pg) * C(X,qa,1,qg) * C(Y,ra,rb,1) -
C(Z,1,pb,pg) * C(Y,qa,1,qg) * C(X,ra,rb,1);
volume += dV / divisor;
}
return fabs(volume);
}
static double ecl_cell_get_volume_wrong( ecl_cell_type * cell ) {
ecl_cell_assert_center( cell );
{
tetrahedron_type tet;
@ -1119,13 +1181,8 @@ static bool ecl_cell_contains_point( ecl_cell_type * cell , const point_type * p
0---1 4---5
*/
static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset , int i , int j , int k , int global_index , const double * ivec , const double * jvec , const double * kvec , const int * actnum ) {
{
double x0 = offset[0] + i*ivec[0] + j*jvec[0] + k*kvec[0];
double y0 = offset[1] + i*ivec[1] + j*jvec[1] + k*kvec[1];
double z0 = offset[2] + i*ivec[2] + j*jvec[2] + k*kvec[2];
point_set(&cell->corner_list[0] , x0 , y0 , z0 ); // Point 0
}
point_set(&cell->corner_list[0] , offset[0] , offset[1] , offset[2] ); // Point 0
cell->corner_list[1] = cell->corner_list[0]; // Point 1
point_shift(&cell->corner_list[1] , ivec[0] , ivec[1] , ivec[2]);
@ -1135,7 +1192,6 @@ static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset
cell->corner_list[3] = cell->corner_list[1]; // Point 3
point_shift(&cell->corner_list[3] , jvec[0] , jvec[1] , jvec[2]);
{
int i;
for (i=0; i < 4; i++) {
@ -1150,7 +1206,6 @@ static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset
cell->active = ACTIVE;
}
/* end of cell implementation */
/*****************************************************************/
/* starting on the ecl_grid proper implementation */
@ -1257,7 +1312,6 @@ 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 );
@ -2086,18 +2140,29 @@ static void ecl_grid_init_cell_nnc_info(ecl_grid_type * ecl_grid, int global_ind
/*
This function populates nnc_info for cells with non neighbour connections
*/
This function populates nnc_info for cells with non neighbour
connections. For cells C1 and C2 the function will only add the directed link:
C1 -> C2
i.e. it is impossible to go from C2 and back to C1. The functions
will add links as:
NNC1 -> NNC2 For nnc between cells in the same grid.
NNCG -> NNCL For global -> lgr connection
NNA1 -> NNA2 For links between different LGRs
*/
static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid2, const ecl_kw_type * keyword1, const ecl_kw_type * keyword2) {
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;
int nnc_index;
for (nnc_index = 0; nnc_index < nnc_count; nnc_index++) {
int grid1_cell_index = grid1_nnc_cells[nnc_index] -1;
int grid2_cell_index = grid2_nnc_cells[nnc_index] -1;
/*
@ -2119,19 +2184,11 @@ static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid
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 );
ecl_grid_init_cell_nnc_info(grid1, grid1_cell_index);
nnc_info_add_nnc(grid1_cell->nnc_info, grid2->lgr_nr, grid2_cell_index , nnc_index);
}
}
}
@ -2166,7 +2223,7 @@ static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_fil
const ecl_kw_type * nncg = ecl_file_iget_named_kw(ecl_file, NNCG_KW, 0);
{
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, nncl, nncg);
ecl_grid_init_nnc_cells(main_grid, grid , nncg, nncl);
}
}
}
@ -2175,9 +2232,10 @@ static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_fil
}
/*
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.
*/
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 );
@ -2544,19 +2602,22 @@ static ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file) {
cells and 0 for inactive cells. The actnum array can be NULL, in
which case all cells will be active.
*/
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum) {
ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0, true);
const double offset[3] = {0,0,0};
const double grid_offset[3] = {0,0,0};
int k,j,i;
for (k=0; k < nz; k++) {
for (j=0; j< ny; j++) {
for (i=0; i < nx; i++) {
int global_index = i + j*nx + k*nx*ny;
double offset[3] = {
grid_offset[0] + i*ivec[0] + j*jvec[0] + k*kvec[0],
grid_offset[1] + i*ivec[1] + j*jvec[1] + k*kvec[1],
grid_offset[2] + i*ivec[2] + j*jvec[2] + k*kvec[2]
};
ecl_cell_type * cell = ecl_grid_get_cell(grid , global_index );
ecl_cell_init_regular( cell , offset , i,j,k,global_index , ivec , jvec , kvec , actnum );
}
}
@ -2566,7 +2627,6 @@ ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double *
return grid;
}
/**
This function will allocate a new rectangular grid with dimensions
nx x ny x nz. The cells in the grid are rectangular with dimensions
@ -2586,6 +2646,56 @@ ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx
return ecl_grid_alloc_regular( nx , ny , nz , ivec , jvec , kvec , actnum);
}
/**
This function will allocate a new grid with logical dimensions nx x
ny x nz. The cells in the grid are spanned by the dxv, dyv and dzv
vectors which are of size nx, ny and nz and specify the thickness
of a cell in x, y, and in z direction.
The actnum argument is a pointer to an integer array of length
nx*ny*nz where actnum[i + j*nx + k*nx*ny] == 1 for active cells and
0 for inactive cells. The actnum array can be NULL, in which case
all cells will be active. */
ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const int * actnum)
{
ecl_grid_type* grid = ecl_grid_alloc_empty(NULL,
FILEHEAD_SINGLE_POROSITY,
nx, ny, nz,
/*lgr_nr=*/0, /*init_valid=*/true);
double ivec[3] = { 0, 0, 0 };
double jvec[3] = { 0, 0, 0 };
double kvec[3] = { 0, 0, 0 };
const double grid_offset[3] = {0,0,0};
double offset[3];
int i, j, k;
offset[2] = grid_offset[2];
for (k=0; k < nz; k++) {
kvec[2] = dzv[k];
offset[1] = grid_offset[1];
for (j=0; j < ny; j++) {
jvec[1] = dyv[j];
offset[0] = grid_offset[0];
for (i=0; i < nx; i++) {
int global_index = i + j*nx + k*nx*ny;
ecl_cell_type* cell = ecl_grid_get_cell(grid, global_index);
ivec[0] = dxv[i];
ecl_cell_init_regular(cell, offset,
i,j,k,global_index,
ivec,jvec,kvec,
actnum);
offset[0] += dxv[i];
}
offset[1] += dyv[j];
}
offset[2] += dzv[k];
}
ecl_grid_update_index(grid);
return grid;
}
/**
This function will allocate a ecl_grid instance. As input it takes
@ -2833,7 +2943,7 @@ bool ecl_grid_exists( const char * case_input ) {
*/
static bool ecl_grid_compare__(const ecl_grid_type * g1 , const ecl_grid_type * g2, bool verbose) {
bool equal = true;
if (g1->size != g2->size)
equal = false;
@ -2871,11 +2981,9 @@ static bool ecl_grid_compare__(const ecl_grid_type * g1 , const ecl_grid_type *
bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2 , bool include_lgr, bool verbose) {
if (!include_lgr)
return ecl_grid_compare__(g1 , g2 , verbose);
else {
bool equal = ecl_grid_compare__(g1 , g2 , verbose);
if (equal && include_lgr) {
if (vector_get_size( g1->LGR_list ) == vector_get_size( g2->LGR_list )) {
bool equal;
int grid_nr;
for (grid_nr = 0; grid_nr < vector_get_size( g1->LGR_list ); grid_nr++) {
const ecl_grid_type * lgr1 = vector_iget_const( g1->LGR_list , grid_nr);
@ -2885,10 +2993,9 @@ bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2 , bool
if (!equal)
break;
}
return equal;
} else
return false;
}
}
return equal;
}
@ -3160,7 +3267,6 @@ void ecl_grid_free(ecl_grid_type * grid) {
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 );
@ -3573,9 +3679,6 @@ 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) {
@ -3767,7 +3870,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;
}
@ -3797,6 +3900,8 @@ const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_in
const char * ecl_grid_get_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr) {
__assert_main_grid( ecl_grid );
if (lgr_nr == 0)
return ecl_grid->name;
{
int lgr_index = int_vector_iget( ecl_grid->lgr_index_map , lgr_nr );
return ecl_grid_iget_lgr_name( ecl_grid , lgr_index );
@ -3804,6 +3909,17 @@ const char * ecl_grid_get_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr)
}
int ecl_grid_get_lgr_nr_from_name( const ecl_grid_type * grid , const char * name) {
__assert_main_grid( grid );
if (strcmp( name , grid->name) == 0)
return 0;
else {
const ecl_grid_type * lgr = ecl_grid_get_lgr( grid , name );
return lgr->lgr_nr;
}
}
/*****************************************************************/
/**
@ -3838,6 +3954,7 @@ double ecl_grid_get_cell_volume1( const ecl_grid_type * ecl_grid, int global_ind
}
double ecl_grid_get_cell_volume3( const ecl_grid_type * ecl_grid, int i , int j , int k) {
int global_index = ecl_grid_get_global_index3( ecl_grid , i , j , k);
return ecl_grid_get_cell_volume1( ecl_grid , global_index );
@ -3848,6 +3965,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) {
int active_cells , nx,ny,nz;
ecl_grid_get_dims(ecl_grid , &nx , &ny , &nz , &active_cells);
printf(" Name ..................: %s \n",ecl_grid->name);
printf(" Grid nr ...............: %d \n",ecl_grid->lgr_nr );
printf(" Active cells ..........: %d \n",active_cells);
printf(" Active fracture cells..: %d \n",ecl_grid_get_nactive_fracture( ecl_grid ));
printf(" nx ....................: %d \n",nx);
@ -4253,19 +4371,19 @@ 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) {
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 );
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) {
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 );
}
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 );
}
}
@ -4550,7 +4668,7 @@ static int ecl_grid_get_top_valid_index( const ecl_grid_type * grid , int i , in
static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, int j , int corner_index , bool force_set , float * coord ) {
static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, int j , int i_corner, int j_corner , bool force_set , float * coord ) {
const int top_index = ecl_grid_get_top_valid_index( grid , i , j );
const int bottom_index = ecl_grid_get_bottom_valid_index( grid , i , j );
@ -4570,7 +4688,8 @@ static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, i
| |
0---1
*/
int coord_offset = 6 * ( j * (grid->nx + 1) + i );
int corner_index = j_corner*2 + i_corner;
int coord_offset = 6 * ( (j + j_corner) * (grid->nx + 1) + (i + i_corner) );
{
point_copy_values( &top_point , &top_cell->corner_list[corner_index]);
point_copy_values( &bottom_point , &bottom_cell->corner_list[ corner_index + 4]);
@ -4598,19 +4717,20 @@ static bool ecl_grid_init_coord_section__( const ecl_grid_type * grid , int i, i
static void ecl_grid_init_coord_section( const ecl_grid_type * grid , int i, int j , float * coord ) {
int corner_index = 0;
int i_corner = 0;
int j_corner = 0;
if (i == grid->nx) {
i -= 1;
corner_index += 1;
i_corner = 1;
}
if (j == grid->ny) {
j -= 1;
corner_index += 2;
j_corner = 1;
}
ecl_grid_init_coord_section__( grid , i , j , corner_index, true, coord);
ecl_grid_init_coord_section__( grid , i,j, i_corner,j_corner, /*force_set=*/true, coord);
}
@ -4992,3 +5112,28 @@ bool ecl_grid_dual_grid( const ecl_grid_type * ecl_grid ) {
else
return true;
}
static int ecl_grid_get_num_nnc__( const ecl_grid_type * grid ) {
int g;
int num_nnc = 0;
for (g = 0; g < grid->size; g++) {
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , g );
if (nnc_info)
num_nnc += nnc_info_get_total_size( nnc_info );
}
return num_nnc;
}
int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) {
int num_nnc = ecl_grid_get_num_nnc__( grid );
{
int grid_nr;
for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) {
ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr );
num_nnc += ecl_grid_get_num_nnc__( igrid );
}
}
return num_nnc;
}

View File

@ -850,6 +850,24 @@ void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s) {
}
/**
This function will compare the string at position @index with the
input @other string. The comparison will be done in a
'space-tolerant', i.e. trailing spaces are ignored in the
comparison. If the strings are considered equal true is returned.
*/
bool ecl_kw_icmp_string( const ecl_kw_type * ecl_kw , int index, const char * other_string) {
const char * kw_string = ecl_kw_iget_char_ptr( ecl_kw , index );
if (strlen(other_string)) {
char * match = strstr( kw_string , other_string);
if (match == kw_string)
return true;
}
return false;
}
#define ECL_KW_ISET_TYPED(ctype , ECL_TYPE) \

View File

@ -0,0 +1,224 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more detals.
*/
#include <stdlib.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_nnc_export.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/ecl_kw_magic.h>
int ecl_nnc_export_get_size( const ecl_grid_type * grid ) {
return ecl_grid_get_num_nnc( grid );
}
static void ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , const ecl_file_type * init_file , ecl_nnc_type * nnc_data, int * nnc_offset) {
int nnc_index = *nnc_offset;
int lgr_nr1 = ecl_grid_get_lgr_nr( grid );
int global_index1;
ecl_grid_type * global_grid = ecl_grid_get_global_grid( grid );
if (!global_grid)
global_grid = grid;
for (global_index1 = 0; global_index1 < ecl_grid_get_global_size( grid ); global_index1++) {
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( grid , global_index1 );
if (nnc_info) {
int lgr_index2;
for (lgr_index2=0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) {
const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 );
const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector );
const ecl_kw_type * tran_kw = ecl_nnc_export_get_tranx_kw(global_grid , init_file , lgr_nr1 , lgr_nr2 );
int index2;
ecl_nnc_type nnc = {.grid_nr1 = lgr_nr1 ,
.grid_nr2 = lgr_nr2 ,
.global_index1 = global_index1 };
for (index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) {
nnc.global_index2 = int_vector_iget( grid2_index_list , index2 );
nnc.trans = ecl_kw_iget_as_double( tran_kw , int_vector_iget( nnc_index_list , index2));
nnc_data[nnc_index] = nnc;
nnc_index++;
}
}
}
}
*nnc_offset = nnc_index;
}
void ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data) {
int nnc_index = 0;
ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index );
{
int lgr_index;
for (lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) {
ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index );
ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index );
}
}
nnc_index = ecl_nnc_export_get_size( grid );
ecl_nnc_sort( nnc_data , nnc_index );
}
int ecl_nnc_cmp( const ecl_nnc_type * nnc1 , const ecl_nnc_type * nnc2) {
if (nnc1->grid_nr1 != nnc2->grid_nr1) {
if (nnc1->grid_nr1 < nnc2->grid_nr1)
return -1;
else
return 1;
}
if (nnc1->grid_nr2 != nnc2->grid_nr2) {
if (nnc1->grid_nr2 < nnc2->grid_nr2)
return -1;
else
return 1;
}
if (nnc1->global_index1 != nnc2->global_index1) {
if (nnc1->global_index1 < nnc2->global_index1)
return -1;
else
return 1;
}
if (nnc1->global_index2 != nnc2->global_index2) {
if (nnc1->global_index2 < nnc2->global_index2)
return -1;
else
return 1;
}
return 0;
}
static int ecl_nnc_cmp__( const void * nnc1 , const void * nnc2) {
return ecl_nnc_cmp( nnc1 , nnc2 );
}
void ecl_nnc_sort( ecl_nnc_type * nnc_list , int size) {
qsort( nnc_list , size , sizeof * nnc_list , ecl_nnc_cmp__ );
}
ecl_kw_type * ecl_nnc_export_get_tranll_kw( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1, int lgr_nr2 ) {
const char * lgr_name1 = ecl_grid_get_lgr_name( grid , lgr_nr1 );
const char * lgr_name2 = ecl_grid_get_lgr_name( grid , lgr_nr2 );
ecl_kw_type * tran_kw = NULL;
const int file_num_kw = ecl_file_get_size( init_file );
int global_kw_index = 0;
while (true) {
if (global_kw_index >= file_num_kw)
break;
{
ecl_kw_type * ecl_kw = ecl_file_iget_kw( init_file , global_kw_index );
if (strcmp( LGRJOIN_KW , ecl_kw_get_header( ecl_kw)) == 0) {
if (ecl_kw_icmp_string( ecl_kw , 0 , lgr_name1) && ecl_kw_icmp_string( ecl_kw , 1 , lgr_name2)) {
tran_kw = ecl_file_iget_kw( init_file , global_kw_index + 1);
break;
}
}
global_kw_index++;
}
}
return tran_kw;
}
ecl_kw_type * ecl_nnc_export_get_tran_kw( const ecl_file_type * init_file , const char * kw , int lgr_nr ) {
ecl_kw_type * tran_kw = NULL;
if (lgr_nr == 0) {
if (strcmp(kw , TRANNNC_KW) == 0)
tran_kw = ecl_file_iget_named_kw( init_file , TRANNNC_KW , 0 );
} else {
if ((strcmp(kw , TRANNNC_KW) == 0) ||
(strcmp(kw , TRANGL_KW) == 0)) {
int tran_kw_forward_skip;
const int file_num_kw = ecl_file_get_size( init_file );
int global_kw_index = 0;
bool finished = false;
if (strcmp(kw , TRANNNC_KW) == 0)
tran_kw_forward_skip = 3;
else
tran_kw_forward_skip = 4;
while (!finished) {
ecl_kw_type * ecl_kw = ecl_file_iget_kw( init_file , global_kw_index );
if (strcmp( LGRHEADI_KW , ecl_kw_get_header( ecl_kw )) == 0) {
if (ecl_kw_iget_int( ecl_kw , LGRHEADI_LGR_NR_INDEX) == lgr_nr) {
if ((global_kw_index + tran_kw_forward_skip) < file_num_kw) {
ecl_kw_type * ecl_kw = ecl_file_iget_kw( init_file , global_kw_index + tran_kw_forward_skip);
/* We found the TRANGL / TRANNC keyword we are after. */
if (strcmp( kw , ecl_kw_get_header( ecl_kw )) == 0) {
tran_kw = ecl_kw;
finished = true;
break;
}
}
}
}
global_kw_index++;
if (global_kw_index == file_num_kw)
finished = true;
}
}
}
return tran_kw;
}
ecl_kw_type * ecl_nnc_export_get_tranx_kw( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1, int lgr_nr2 ) {
if (lgr_nr1 == lgr_nr2)
return ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , lgr_nr2 );
else {
if (lgr_nr1 == 0)
return ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , lgr_nr2 );
else
return ecl_nnc_export_get_tranll_kw( grid , init_file , lgr_nr1 , lgr_nr2 );
}
}

View File

@ -166,6 +166,20 @@ static time_t file_map_iget_restart_sim_date(const file_map_type * file_map , in
}
static double file_map_iget_restart_sim_days(const file_map_type * file_map , int seqnum_index) {
double sim_days = 0;
file_map_type * seqnum_map = seqnum_map = file_map_alloc_blockmap( file_map , SEQNUM_KW , seqnum_index);
if (seqnum_map != NULL) {
ecl_kw_type * doubhead_kw = file_map_iget_named_kw( seqnum_map , DOUBHEAD_KW , 0);
sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX);
file_map_free( seqnum_map );
}
return sim_days;
}
static int file_map_find_sim_time(const file_map_type * file_map , time_t sim_time) {
@ -361,6 +375,10 @@ time_t ecl_file_iget_restart_sim_date( const ecl_file_type * restart_file , int
return file_map_iget_restart_sim_date( restart_file->active_map , index );
}
double ecl_file_iget_restart_sim_days( const ecl_file_type * restart_file , int index ) {
return file_map_iget_restart_sim_days( restart_file->active_map , index );
}
/*****************************************************************/
/* Select and open functions, observe that these functions should

View File

@ -65,6 +65,7 @@ ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occu
rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX];
rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX];
rsthead->nsconz = data[INTEHEAD_NSCONZ_INDEX];
rsthead->niconz = data[INTEHEAD_NICONZ_INDEX];
rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX];

View File

@ -394,6 +394,27 @@ ecl_sum_type * ecl_sum_fread_alloc_case(const char * input_file , const char * k
}
bool ecl_sum_case_exists( const char * input_file ) {
char * smspec_file = NULL;
stringlist_type * data_files = stringlist_alloc_new();
char * path;
char * basename;
char * extension;
bool case_exists;
util_alloc_file_components( input_file , &path , &basename , &extension);
case_exists = ecl_util_alloc_summary_files( path , basename , extension , &smspec_file , data_files );
util_safe_free( path );
util_safe_free( basename );
util_safe_free( extension );
util_safe_free( smspec_file );
stringlist_free( data_files );
return case_exists;
}
/*****************************************************************/
double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const smspec_node_type * node) {

View File

@ -1249,44 +1249,91 @@ time_t ecl_util_get_start_date(const char * data_file) {
}
static int ecl_util_get_num_parallel_cpu__(parser_type* parser, FILE* stream, const char * data_file) {
int num_cpu = 1;
char * buffer;
long int start_pos = util_ftell( stream );
int buffer_size;
int ecl_util_get_num_cpu(const char * data_file) {
parser_type * parser = parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n");
int num_cpu = 1;
FILE * stream = util_fopen(data_file , "r");
char * buffer;
if (parser_fseek_string( parser , stream , "PARALLEL" , true , true)) { /* Seeks case insensitive. */
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 = (util_ftell(stream) - start_pos) ;
buffer = util_calloc( buffer_size + 1 , sizeof * buffer );
util_fseek( stream , start_pos , SEEK_SET);
util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__);
buffer[buffer_size] = '\0';
{
stringlist_type * tokens = parser_tokenize_buffer( parser , buffer , true );
int i;
char * item = NULL;
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" )) ||
( util_string_equal( item , "DIST" ))) {
num_cpu = atoi( stringlist_iget( tokens , i - 1));
break;
}
}
free( item );
stringlist_free( tokens );
}
free( buffer );
return num_cpu;
}
static int ecl_util_get_num_slave_cpu__(parser_type* parser, FILE* stream, const char * data_file) {
int num_cpu = 0;
int linecount = 0;
parser_fseek_string( parser , stream , "\n" , true , true); /* Go to next line after the SLAVES keyword*/
while (true) {
char * buffer = util_fscanf_alloc_line( stream , NULL);
++linecount;
if (linecount > 10)
util_abort("%s: Did not find ending \"/\" character after SLAVES keyword, aborting \n", __func__);
/* 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 = (util_ftell(stream) - start_pos) ;
buffer = util_calloc( buffer_size + 1 , sizeof * buffer );
util_fseek( stream , start_pos , SEEK_SET);
util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__);
buffer[buffer_size] = '\0';
{
stringlist_type * tokens = parser_tokenize_buffer( parser , buffer , true );
int i;
char * item = NULL;
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" )) ||
( util_string_equal( item , "DIST" ))) {
num_cpu = atoi( stringlist_iget( tokens , i - 1));
break;
if (stringlist_get_size(tokens) > 0 ) {
const char * first_item = stringlist_iget(tokens, 0);
if (first_item[0] == '/') {
break;
}
else
++num_cpu;
}
free( item );
stringlist_free( tokens );
}
}
free( buffer );
}
if (0 == num_cpu)
util_abort("%s: Did not any CPUs after SLAVES keyword, aborting \n", __func__);
return num_cpu;
}
int ecl_util_get_num_cpu(const char * data_file) {
int num_cpu = 1;
parser_type * parser = parser_alloc(" \t\r\n" , "\"\'" , NULL , NULL , "--" , "\n");
FILE * stream = util_fopen(data_file , "r");
if (parser_fseek_string( parser , stream , "PARALLEL" , true , true)) { /* Seeks case insensitive. */
num_cpu = ecl_util_get_num_parallel_cpu__(parser, stream, data_file);
} else if (parser_fseek_string( parser , stream , "SLAVES" , true , true)) { /* Seeks case insensitive. */
num_cpu = ecl_util_get_num_slave_cpu__(parser, stream, data_file) + 1;
fprintf(stderr, "Information: \"SLAVES\" option found, returning %d number of CPUs", num_cpu);
}
parser_free( parser );
@ -1325,6 +1372,33 @@ bool ecl_util_valid_basename( const char * basename ) {
}
bool ecl_util_valid_basename_fmt(const char * basename_fmt)
{
bool valid;
const char * percent_ptr = strchr(basename_fmt, '%');
if (percent_ptr) {
percent_ptr++;
while (true)
{
if (*percent_ptr == 'd')
{
char * basename_instance = util_alloc_sprintf(basename_fmt, 0);
valid = ecl_util_valid_basename(basename_instance);
free(basename_instance);
break;
} else if (!isdigit(*percent_ptr)) {
valid = false;
break;
} else
percent_ptr++;
}
} else
valid = ecl_util_valid_basename(basename_fmt);
return valid;
}
/*
Will append time_t values corresponding to the first day in every
month in the open interval (start_date , end_date). Iff start_date

View File

@ -1,73 +0,0 @@
/*
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

@ -1,4 +1,3 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
@ -25,6 +24,7 @@
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_vector.h>
#include <ert/ecl/ecl_kw_magic.h>
#define NNC_INFO_TYPE_ID 675415078
@ -85,35 +85,36 @@ static void nnc_info_assert_vector( nnc_info_type * nnc_info , int lgr_nr ) {
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number) {
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number, int nnc_index) {
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 );
nnc_vector_add_nnc( nnc_vector , global_cell_number , nnc_index);
}
}
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr) {
const int_vector_type * nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr) {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr );
if (nnc_vector)
return nnc_vector_get_index_list( nnc_vector );
return nnc_vector_get_grid_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) {
const int_vector_type * nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index) {
nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index );
return nnc_vector_get_index_list( nnc_vector );
if (nnc_vector)
return nnc_vector_get_grid_index_list( nnc_vector );
else
return NULL;
}
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 );
const int_vector_type * nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info) {
return nnc_info_get_grid_index_list( nnc_info , nnc_info->lgr_nr );
}
@ -126,3 +127,32 @@ int nnc_info_get_lgr_nr( const nnc_info_type * nnc_info ) {
int nnc_info_get_size( const nnc_info_type * nnc_info ) {
return vector_get_size( nnc_info->lgr_list );
}
int nnc_info_get_total_size( const nnc_info_type * nnc_info ) {
int num_nnc = 0;
int ivec;
for (ivec = 0; ivec < vector_get_size( nnc_info->lgr_list ); ivec++) {
const nnc_vector_type * nnc_vector = vector_iget( nnc_info->lgr_list , ivec );
num_nnc += nnc_vector_get_size( nnc_vector );
}
return num_nnc;
}
void nnc_info_fprintf(const nnc_info_type * nnc_info , FILE * stream) {
fprintf(stream,"LGR_NR:%d \n",nnc_info->lgr_nr);
{
int lgr_nr;
for (lgr_nr=0; lgr_nr < int_vector_size( nnc_info->lgr_index_map ); lgr_nr++) {
int lgr_index = int_vector_iget( nnc_info->lgr_index_map , lgr_nr );
if (lgr_index >= 0) {
printf(" %02d -> %02d => ",lgr_nr , lgr_index);
const int_vector_type * index_list = nnc_info_iget_grid_index_list( nnc_info , lgr_index );
int_vector_fprintf( index_list , stream , " " , "%d");
printf("\n");
}
}
}
fprintf(stream , "\n");
}

View File

@ -22,9 +22,10 @@
#include <ert/util/util.h>
#include <ert/util/vector.h>
#include <ert/util/type_macros.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/nnc_vector.h>
#include <ert/ecl/nnc_index_list.h>
#define NNC_VECTOR_TYPE_ID 875615078
@ -32,8 +33,9 @@
struct nnc_vector_struct {
UTIL_TYPE_ID_DECLARATION;
nnc_index_list_type * index_list;
int lgr_nr;
int lgr_nr;
int_vector_type * grid_index_list;
int_vector_type * nnc_index_list;
};
@ -45,13 +47,15 @@ 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->index_list = nnc_index_list_alloc();
nnc_vector->grid_index_list = int_vector_alloc(0,0);
nnc_vector->nnc_index_list = int_vector_alloc(0,0);
nnc_vector->lgr_nr = lgr_nr;
return nnc_vector;
}
void nnc_vector_free( nnc_vector_type * nnc_vector ) {
nnc_index_list_free( nnc_vector->index_list );
int_vector_free( nnc_vector->grid_index_list );
int_vector_free( nnc_vector->nnc_index_list );
free( nnc_vector );
}
@ -62,15 +66,23 @@ void nnc_vector_free__(void * arg) {
}
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number) {
nnc_index_list_add_index( nnc_vector->index_list , global_cell_number );
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number , int nnc_index) {
int_vector_append( nnc_vector->grid_index_list , global_cell_number );
int_vector_append( nnc_vector->nnc_index_list , nnc_index);
}
const int_vector_type * nnc_vector_get_index_list(nnc_vector_type * nnc_vector) {
return nnc_index_list_get_list(nnc_vector->index_list);
const int_vector_type * nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector) {
return nnc_vector->grid_index_list;
}
const int_vector_type * nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector) {
return nnc_vector->nnc_index_list;
}
int nnc_vector_get_size( const nnc_vector_type * nnc_vector ) {
return int_vector_size( nnc_vector->grid_index_list );
}
int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) {
return nnc_vector->lgr_nr;

View File

@ -0,0 +1,8 @@
SLAVES
-- slave datafile machine directory
-- name root hostname of data file
'RES-R2' 'base' 'rios' '/usr/models/res2' /
'RES-R3' 'base' 'sg-indigo' '/usr/models/res3' /
-- Testing comments in middle
'RES-R5' 'base' 'sg-indigo' '/usr/models/res5' /
/testRubbish

View File

@ -0,0 +1,66 @@
/*
Copyright (C) 2013 Andreas Lauser
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_alloc_grid_dxv_dyv_dzv.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 <signal.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/util/test_util.h>
void test_grid() {
const int nx = 5, ny = 6, nz = 7;
double dxv[nx];
double dyv[ny];
double dzv[nz];
double width = 1.0;
for (int i = 0; i < nx; ++i) {
dxv[i] = width;
width += 1.0;
};
for (int i = 0; i < ny; ++i) {
dyv[i] = width;
width += 1.0;
};
for (int i = 0; i < nz; ++i) {
dzv[i] = width;
width += 1.0;
};
ecl_grid_type * ecl_grid = ecl_grid_alloc_dxv_dyv_dzv(nx,ny,nz,
dxv, dyv, dzv,
/*actnum=*/NULL);
for (int i = 0; i < nx; ++ i) {
for (int j = 0; j < ny; ++ j) {
for (int k = 0; k < nz; ++ k) {
double volume_ert = ecl_grid_get_cell_volume3(ecl_grid, i, j, k);
test_assert_double_equal(volume_ert, dxv[i]*dyv[j]*dzv[k]);
}
}
}
}
int main(int argc , char ** argv) {
signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */
test_grid();
exit(0);
}

View File

@ -25,9 +25,11 @@
int main(int argc , char ** argv) {
const char * filename1 = argv[1];
const char * filename2 = argv[2];
const char * filename3 = argv[3];
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);
test_assert_int_equal(ecl_util_get_num_cpu(filename3), num_cpu);
exit(0);
}

View File

@ -23,16 +23,48 @@
#include <ert/ecl/ecl_grid.h>
/*
Name ..................: LG003017
Grid nr ...............: 104
Name ..................: LG006024
Grid nr ...............: 2
Name ..................: LG005025
Grid nr ...............: 4
Name ..................: LG011029
Grid nr ...............: 82
Name ..................: LG007021
Grid nr ...............: 100
Name ..................: LG003014
Grid nr ...............: 110
Name ..................: /private/joaho/ERT/git/ert/devel/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID
*/
void test_name(const ecl_grid_type * grid , int lgr_nr , const char * name) {
test_assert_string_equal( name , ecl_grid_get_lgr_name( grid , lgr_nr ));
test_assert_int_equal( lgr_nr , ecl_grid_get_lgr_nr_from_name( grid , name ));
}
int main(int argc , char ** argv) {
const char * grid_file = argv[1];
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file );
test_assert_int_equal( 1 , ecl_grid_get_num_lgr( ecl_grid ));
test_assert_string_equal( "LGR1" , ecl_grid_iget_lgr_name( ecl_grid , 0 ));
test_assert_string_equal( NULL , ecl_grid_iget_lgr_name( ecl_grid , 1 ));
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
ecl_grid_free( ecl_grid );
test_name( grid , 104 , "LG003017");
test_name( grid , 2 , "LG006024");
test_name( grid , 4 , "LG005025");
test_name( grid , 82 , "LG011029");
test_name( grid , 100 , "LG007021");
test_name( grid , 110 , "LG003014");
test_name( grid , 0 , grid_file);
ecl_grid_free( grid );
exit(0);
}

View File

@ -0,0 +1,71 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_grid_volume.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 <signal.h>
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_kw.h>
int main(int argc , char ** argv) {
const char * path_case = argv[1];
char * grid_file = ecl_util_alloc_filename( NULL , path_case , ECL_EGRID_FILE , false , 0 );
char * init_file = ecl_util_alloc_filename( NULL , path_case , ECL_INIT_FILE , false , 0 );
ecl_file_type * init = ecl_file_open( init_file , 0 );
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
const ecl_kw_type * poro_kw = ecl_file_iget_named_kw( init , "PORO" , 0 );
const ecl_kw_type * porv_kw = ecl_file_iget_named_kw( init , "PORV" , 0 );
bool error_found = false;
int error_count = 0;
int iactive;
for (iactive = 0; iactive < ecl_grid_get_nactive( grid ); ++iactive) {
int iglobal = ecl_grid_get_global_index1A( grid , iactive );
double grid_volume = ecl_grid_get_cell_volume1( grid , iglobal );
double eclipse_volume = ecl_kw_iget_float( porv_kw , iglobal ) / ecl_kw_iget_float( poro_kw , iactive );
if (!util_double_approx_equal__( grid_volume , eclipse_volume , 1e-3)) {
printf("Error in cell: %d V: %g V2: %g \n",iglobal , grid_volume , eclipse_volume );
error_count++;
error_found = true;
}
}
ecl_grid_free( grid );
ecl_file_close( init );
free( grid_file );
free( init_file );
if (error_found) {
printf("Error_count: %d \n",error_count);
exit(1);
} else
exit(0);
}

View File

@ -0,0 +1,48 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_kw_cmp_string.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_kw.h>
void test_cmp_string() {
ecl_kw_type * ecl_kw = ecl_kw_alloc( "HEADER" , 1 , ECL_CHAR_TYPE );
ecl_kw_iset_string8( ecl_kw , 0 , "ABCD");
test_assert_int_equal( 0 , strcmp( ecl_kw_iget_char_ptr( ecl_kw , 0 ) , "ABCD "));
test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD"));
test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD "));
test_assert_true(ecl_kw_icmp_string( ecl_kw , 0 , "ABCD "));
test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , "Different"));
test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , ""));
test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , ""));
}
int main(int argc , char ** argv) {
test_cmp_string();
exit(0);
}

View File

@ -1,35 +0,0 @@
/*
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) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( argv[1] );
ecl_grid_free( ecl_grid );
exit(0);
}

View File

@ -0,0 +1,318 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more detals.
*/
#include <stdlib.h>
#include <stdbool.h>
#include <signal.h>
#include <ert/util/test_util.h>
#include <ert/util/time_t_vector.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl/ecl_nnc_export.h>
#include <ert/ecl/ecl_kw_magic.h>
int count_kw_data( const ecl_file_type * file , ecl_grid_type * grid , const char * kw1 , const char * kw2) {
int i,j;
int count = 0;
for (i=0; i < ecl_file_get_num_named_kw( file , kw1 ); i++) {
ecl_kw_type * ecl_kw1 = ecl_file_iget_named_kw( file , kw1 , i );
ecl_kw_type * ecl_kw2 = NULL;
if (kw2)
ecl_kw2 = ecl_file_iget_named_kw(file , kw2 , i);
{
if (ecl_kw2) {
int global_size;
ecl_grid_type * igrid;
if (i == 0)
igrid = grid;
else
igrid = ecl_grid_iget_lgr( grid , i - 1);
global_size = ecl_grid_get_global_size( igrid );
for (j=0; j < ecl_kw_get_size( ecl_kw1 ); j++) {
int g1 = ecl_kw_iget_int( ecl_kw1 , j );
int g2 = ecl_kw_iget_int( ecl_kw2 , j );
if (g1 <= global_size && g2 <= global_size)
count +=1;
}
} else
count += ecl_kw_get_size( ecl_kw1 );
}
}
return count;
}
void test_count(const char * name) {
char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1);
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
int num_nnc = 0;
num_nnc = count_kw_data( grid_file , grid , "NNC1" , "NNC2");
num_nnc += count_kw_data( grid_file , grid , "NNCG" , NULL);
num_nnc += count_kw_data( grid_file , grid , "NNA1" , NULL);
test_assert_int_equal( num_nnc , ecl_nnc_export_get_size( grid ));
free(grid_file_name);
ecl_grid_free( grid );
ecl_file_close( grid_file );
}
void test_export(const char * name) {
char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1);
char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1);
if (util_entry_exists(init_file_name)) {
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
ecl_file_type * init_file = ecl_file_open( init_file_name , 0);
ecl_nnc_type * nnc_data1 = util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data1 );
ecl_nnc_type * nnc_data2 = util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data2 );
{
int nnc_offset = 0;
int block_nr = 0;
for (block_nr = 0; block_nr < ecl_file_get_num_named_kw( grid_file , NNCHEAD_KW); block_nr++) {
ecl_file_push_block( grid_file );
ecl_file_select_block( grid_file , NNCHEAD_KW , block_nr );
if (ecl_file_has_kw( grid_file , NNC1_KW )) {
ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( grid_file , NNC1_KW , 0 );
ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( grid_file , NNC2_KW , 0 );
ecl_kw_type * nnchead = ecl_file_iget_named_kw( grid_file , NNCHEAD_KW , 0);
int lgr_nr1 = ecl_kw_iget_int( nnchead , NNCHEAD_LGR_INDEX);
int lgr_nr2 = ecl_kw_iget_int( nnchead , NNCHEAD_LGR_INDEX);
ecl_kw_type * nnc_tran = ecl_nnc_export_get_tranx_kw( grid , init_file , lgr_nr1 , lgr_nr2);
test_assert_not_NULL( nnc_tran );
test_assert_int_equal( ecl_kw_get_size( nnc1_kw ) , ecl_kw_get_size( nnc_tran ));
{
ecl_grid_type * lgr = grid;
int num_nnc = 0;
int i = 0;
if (lgr_nr1 > 0)
lgr = ecl_grid_get_lgr_from_lgr_nr( grid , lgr_nr1 );
while (i < ecl_kw_get_size( nnc1_kw) ) {
int g1 = ecl_kw_iget_int( nnc1_kw , i) - 1;
int g2 = ecl_kw_iget_int( nnc2_kw , i) - 1;
if (g1 < ecl_grid_get_global_size( lgr ) &&
g2 < ecl_grid_get_global_size( lgr )) {
nnc_data1[ i + nnc_offset ].grid_nr1 = lgr_nr1;
nnc_data1[ i + nnc_offset ].grid_nr2 = lgr_nr2;
nnc_data1[ i + nnc_offset ].global_index1 = g1;
nnc_data1[ i + nnc_offset ].global_index2 = g2;
nnc_data1[ i + nnc_offset ].trans = ecl_kw_iget_as_double( nnc_tran , i );
num_nnc++;
}
i++;
}
nnc_offset += num_nnc;
}
}
if (ecl_file_has_kw( grid_file, NNCL_KW)) {
ecl_kw_type * nncl_kw = ecl_file_iget_named_kw( grid_file , NNCL_KW , 0 );
ecl_kw_type * nncg_kw = ecl_file_iget_named_kw( grid_file , NNCG_KW , 0 );
ecl_kw_type * nnchead = ecl_file_iget_named_kw( grid_file , NNCHEAD_KW , 0);
int lgr_nr1 = 0;
int lgr_nr2 = ecl_kw_iget_int( nnchead , NNCHEAD_LGR_INDEX);
ecl_kw_type * nnc_tran = ecl_nnc_export_get_tranx_kw( grid , init_file , 0 , lgr_nr2);
int i;
test_assert_int_equal( ecl_kw_get_size( nncl_kw ) , ecl_kw_get_size( nnc_tran ));
for (i=0; i < ecl_kw_get_size( nncl_kw); i++) {
nnc_data1[ i + nnc_offset ].grid_nr1 = lgr_nr1;
nnc_data1[ i + nnc_offset ].grid_nr2 = lgr_nr2;
nnc_data1[ i + nnc_offset ].global_index1 = ecl_kw_iget_int( nncg_kw , i) - 1;
nnc_data1[ i + nnc_offset ].global_index2 = ecl_kw_iget_int( nncl_kw , i) - 1;
nnc_data1[ i + nnc_offset ].trans = ecl_kw_iget_as_double( nnc_tran , i );
}
nnc_offset += ecl_kw_get_size( nncl_kw );
}
ecl_file_pop_block( grid_file );
}
{
for (block_nr = 0; block_nr < ecl_file_get_num_named_kw( grid_file , NNCHEADA_KW); block_nr++) {
ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( grid_file , NNA1_KW , block_nr);
ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( grid_file , NNA2_KW , block_nr);
ecl_kw_type * nnchead = ecl_file_iget_named_kw( grid_file , NNCHEADA_KW , block_nr);
int lgr_nr1 = ecl_kw_iget_int( nnchead , NNCHEADA_ILOC1_INDEX );
int lgr_nr2 = ecl_kw_iget_int( nnchead , NNCHEADA_ILOC2_INDEX );
ecl_kw_type * nnc_tran;
int i;
nnc_tran = ecl_nnc_export_get_tranx_kw( grid , init_file , lgr_nr1 , lgr_nr2);
test_assert_not_NULL(nnc_tran);
test_assert_int_equal( ecl_kw_get_size( nnc1_kw ) , ecl_kw_get_size( nnc_tran ) );
for (i=0; i < ecl_kw_get_size( nnc1_kw); i++) {
nnc_data1[ i + nnc_offset ].grid_nr1 = lgr_nr1;
nnc_data1[ i + nnc_offset ].grid_nr2 = lgr_nr2;
nnc_data1[ i + nnc_offset ].global_index1 = ecl_kw_iget_int( nnc1_kw , i) - 1;
nnc_data1[ i + nnc_offset ].global_index2 = ecl_kw_iget_int( nnc2_kw , i) - 1;
nnc_data1[ i + nnc_offset ].trans = ecl_kw_iget_as_double( nnc_tran , i );
}
nnc_offset += ecl_kw_get_size( nnc1_kw );
}
}
test_assert_int_equal( nnc_offset , ecl_nnc_export_get_size( grid ));
ecl_nnc_sort( nnc_data1 , nnc_offset );
}
ecl_nnc_export( grid , init_file , nnc_data2 );
if (0) {
int i;
int size = ecl_nnc_export_get_size( grid );
for (i=0; i < size; i++) {
if ((i % 1000) == 0)
printf("%d / %d \n",i , size);
if (ecl_nnc_cmp( &nnc_data1[i] , &nnc_data2[i]) != 0) {
printf("Comparing: %d 1:(%d,%d) 2:(%d,%d) 1:(%d,%d) 2:(%d,%d) %g , %g\n",
i ,
nnc_data1[i].grid_nr1 ,
nnc_data1[i].grid_nr2 ,
nnc_data2[i].grid_nr1 ,
nnc_data2[i].grid_nr2,
nnc_data1[i].global_index1 ,
nnc_data1[i].global_index2 ,
nnc_data2[i].global_index1 ,
nnc_data2[i].global_index2,
nnc_data1[i].trans ,
nnc_data2[i].trans);
}
test_assert_int_equal( 0 , ecl_nnc_cmp( &nnc_data1[i] , &nnc_data2[i]));
}
}
test_assert_int_equal( 0 , memcmp( nnc_data1 , nnc_data2 , ecl_nnc_export_get_size( grid ) * sizeof * nnc_data2 ));
free( nnc_data2 );
free( nnc_data1 );
ecl_grid_free( grid );
ecl_file_close( grid_file );
ecl_file_close( init_file );
} else
fprintf(stderr," Could not find init file:%s - export test skipped \n",init_file_name);
free(grid_file_name);
free(init_file_name);
}
void test_cmp() {
ecl_nnc_type nnc1 = {.grid_nr1 = 1,
.grid_nr2 = 1,
.global_index1 = 1,
.global_index2 = 1 };
ecl_nnc_type nnc2 = {.grid_nr1 = 1, // nnc1 == nnc2
.grid_nr2 = 1,
.global_index1 = 1,
.global_index2 = 1 };
ecl_nnc_type nnc3 = {.grid_nr1 = 4, // nnc3 > nnc1
.grid_nr2 = 1,
.global_index1 = 1,
.global_index2 = 1 };
ecl_nnc_type nnc4 = {.grid_nr1 = 4, // nnc4 > nnc1
.grid_nr2 = 2, // nnc4 > nnc2
.global_index1 = 1,
.global_index2 = 1 };
ecl_nnc_type nnc5 = {.grid_nr1 = 4, // nnc5 > nnc4
.grid_nr2 = 2,
.global_index1 = 3,
.global_index2 = 1 };
ecl_nnc_type nnc6 = {.grid_nr1 = 4, // nnc6 > nnc5
.grid_nr2 = 2,
.global_index1 = 3,
.global_index2 = 5 };
test_assert_int_equal( 0 , ecl_nnc_cmp( &nnc1 , &nnc2 ));
test_assert_int_equal( 1 , ecl_nnc_cmp( &nnc3 , &nnc1 ));
test_assert_int_equal( 1 , ecl_nnc_cmp( &nnc4 , &nnc1 ));
test_assert_int_equal( 1 , ecl_nnc_cmp( &nnc5 , &nnc4 ));
test_assert_int_equal(-1 , ecl_nnc_cmp( &nnc4 , &nnc5 ));
test_assert_int_equal(-1 , ecl_nnc_cmp( &nnc5 , &nnc6 ));
}
void test_sort() {
const int N = 1000;
ecl_nnc_type * nnc_list = util_calloc(N , sizeof * nnc_list );
int i;
for (i=0; i < N; i++) {
ecl_nnc_type nnc = {.grid_nr1 = (i % 19),
.grid_nr2 = (i % 3),
.global_index1 = (i % 7),
.global_index2 = (i % 13)};
nnc_list[i] = nnc;
}
ecl_nnc_sort( nnc_list , N );
for (i=0; i < (N - 1); i++)
test_assert_int_equal( -1 , ecl_nnc_cmp(&nnc_list[i] , &nnc_list[i+1]));
free( nnc_list );
}
void install_SIGNALS(void) {
signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */
signal(SIGINT , util_abort_signal); /* Control C */
signal(SIGTERM , util_abort_signal); /* If killing the program with SIGTERM (the default kill signal) you will get a backtrace.
Killing with SIGKILL (-9) will not give a backtrace.*/
}
int main(int argc, char ** argv) {
const char * base = argv[1];
install_SIGNALS();
test_cmp( );
test_sort();
test_count( base );
test_export( base );
exit(0);
}

View File

@ -0,0 +1,164 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#include <stdlib.h>
#include <stdbool.h>
#include <ert/util/test_util.h>
#include <ert/util/time_t_vector.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl/ecl_nnc_export.h>
#include <ert/ecl/ecl_kw_magic.h>
void test_get_tran(const char * name) {
char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1);
char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1);
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
ecl_file_type * init_file = ecl_file_open( init_file_name , 0 );
/* Get global */
{
ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 0 );
test_assert_true( ecl_kw_is_instance( tran_kw ));
test_assert_double_equal( 0.85582769 , ecl_kw_iget_as_double( tran_kw , 0 ));
test_assert_double_equal( 0.24635284 , ecl_kw_iget_as_double( tran_kw , 7184 ));
}
test_assert_NULL( ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 0 ));
test_assert_NULL( ecl_nnc_export_get_tran_kw( init_file , TRANLL_KW , 0 ));
test_assert_NULL( ecl_nnc_export_get_tran_kw( init_file , "INVALID" , 1));
/* Get lgr_nr: 48 */
{
ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 48 );
test_assert_true( ecl_kw_is_instance( tran_kw ));
test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));
tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 48 );
test_assert_int_equal( 282 , ecl_kw_get_size( tran_kw ));
test_assert_double_equal( 22.922695 , ecl_kw_iget_as_double( tran_kw , 0 ));
test_assert_double_equal( 16.720325 , ecl_kw_iget_as_double( tran_kw , 281 ));
}
/* Get lgr_nr: 99 */
{
ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 99 );
test_assert_true( ecl_kw_is_instance( tran_kw ));
test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));
tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 99 );
test_assert_int_equal( 693 , ecl_kw_get_size( tran_kw ));
test_assert_double_equal( 0.25534782 , ecl_kw_iget_as_double( tran_kw , 0 ));
test_assert_double_equal( 0.12677453 , ecl_kw_iget_as_double( tran_kw , 692 ));
}
/* Get lgr_nr: 10 */
{
ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 10 );
test_assert_true( ecl_kw_is_instance( tran_kw ));
test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));
tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 10 );
test_assert_int_equal( 260 , ecl_kw_get_size( tran_kw ));
test_assert_double_equal( 0.87355447 , ecl_kw_iget_as_double( tran_kw , 0 ));
test_assert_double_equal( 26.921568 , ecl_kw_iget_as_double( tran_kw , 259 ));
}
/* Get lgr_nr: 110 */
{
ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 110 );
test_assert_true( ecl_kw_is_instance( tran_kw ));
test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));
tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 110 );
test_assert_int_equal( 208 , ecl_kw_get_size( tran_kw ));
test_assert_double_equal( 17.287283 , ecl_kw_iget_as_double( tran_kw , 0 ));
test_assert_double_equal( 569.26312 , ecl_kw_iget_as_double( tran_kw , 207 ));
}
free( init_file_name );
free(grid_file_name);
ecl_grid_free( grid );
ecl_file_close( grid_file );
ecl_file_close( init_file );
}
void test_tranLL( const ecl_grid_type * grid , const ecl_file_type * init_file , int lgr_nr1 , int lgr_nr2,
int size,
double first ,
double last) {
ecl_kw_type * ecl_kw = ecl_nnc_export_get_tranll_kw(grid , init_file , lgr_nr1 , lgr_nr2 );
printf("lgr: %d -> %d \n",lgr_nr1 , lgr_nr2);
test_assert_not_NULL(ecl_kw);
test_assert_true(ecl_kw_is_instance( ecl_kw ));
test_assert_int_equal( size , ecl_kw_get_size( ecl_kw ));
test_assert_double_equal( first , ecl_kw_iget_as_double( ecl_kw , 0 ));
test_assert_double_equal( last , ecl_kw_iget_as_double( ecl_kw , size - 1 ));
}
void test_get_tranLL(const char * name) {
char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1);
char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1);
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
ecl_file_type * init_file = ecl_file_open( init_file_name , 0 );
test_tranLL( grid , init_file , ecl_grid_get_lgr_nr_from_name( grid , "LG003017" ), ecl_grid_get_lgr_nr_from_name( grid , "LG003018" ),
172 , 5.3957253 , 1.0099934);
test_tranLL( grid , init_file , ecl_grid_get_lgr_nr_from_name( grid , "LG002016" ), ecl_grid_get_lgr_nr_from_name( grid , "LG002017" ),
93 , 1.4638059 , 0.36407200 );
test_tranLL( grid , init_file , ecl_grid_get_lgr_nr_from_name( grid , "LG002016" ), ecl_grid_get_lgr_nr_from_name( grid , "LG003016" ),
56 , 2.7360380 , 10.053267);
test_tranLL( grid , init_file , ecl_grid_get_lgr_nr_from_name( grid , "LG009027" ), ecl_grid_get_lgr_nr_from_name( grid , "LG009026" ),
152 , 155.47754, 219.23553);
test_tranLL( grid , init_file , ecl_grid_get_lgr_nr_from_name( grid , "LG009027" ), ecl_grid_get_lgr_nr_from_name( grid , "LG008027" ),
317 , 0.040260997 , 0.0066288318);
free( init_file_name );
free(grid_file_name);
ecl_grid_free( grid );
ecl_file_close( grid_file );
ecl_file_close( init_file );
}
int main( int argc , char ** argv) {
test_get_tran( argv[1] );
test_get_tranLL( argv[1] );
exit(0);
}

View File

@ -25,27 +25,36 @@
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_vector.h>
#include <ert/ecl/ecl_kw_magic.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( 0 , nnc_info_get_total_size( nnc_info ));
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);
nnc_info_add_nnc(nnc_info, lgr_nr, 110 , 0);
test_assert_int_equal( 1, nnc_info_get_total_size( nnc_info ));
nnc_info_add_nnc(nnc_info, 1, 110 , 1);
nnc_info_add_nnc(nnc_info, 1, 111 , 2);
test_assert_int_equal( 3, nnc_info_get_total_size( nnc_info ));
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);
const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1);
test_assert_int_equal(int_vector_size(nnc_cells), 2);
test_assert_ptr_equal( nnc_cells , nnc_vector_get_index_list( nnc_vector ));
test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector ));
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);
const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2);
test_assert_NULL(nnc_cells_null);
test_assert_NULL(nnc_vector_null);
@ -53,14 +62,15 @@ int main(int argc , char ** argv) {
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);
const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr);
const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info);
test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );
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 ));
test_assert_int_equal( 2 , nnc_info_get_size( nnc_info ));
test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 1 ));
nnc_info_free(nnc_info);
exit(0);
}

View File

@ -24,320 +24,104 @@
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_kw_magic.h>
void test_nnc_global_grid( const char * grid_filename ) {
void test_scan( 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};
ecl_file_type * grid_file = ecl_file_open( grid_filename , 0);
int block_nr;
for (block_nr = 0; block_nr < ecl_file_get_num_named_kw( grid_file , NNCHEAD_KW ); block_nr++) {
ecl_grid_type * lgr = ecl_grid;
int lgr_nr;
ecl_file_push_block( grid_file );
ecl_file_select_block(grid_file , NNCHEAD_KW , block_nr );
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 ));
{
if (block_nr > 0)
lgr = ecl_grid_iget_lgr( ecl_grid , block_nr - 1);
lgr_nr = ecl_grid_get_lgr_nr( lgr );
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);
int_vector_fprintf(nnc_cell_number_vec , stdout , "nnc_cell_number" , "%6d");
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[] = {126305, 126394};
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(data[i], int_vector_iget(lgr_nnc_cell_number_vec, 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[] = {3528, 6321, 9114, 11907, 11957, 20286 , 20336};
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]);
/* Internal nnc */
{
if (ecl_file_has_kw( grid_file , NNC1_KW)) {
ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw(grid_file , NNC1_KW , 0 );
ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw(grid_file , NNC2_KW , 0 );
int i;
for (i=0; i < ecl_kw_get_size(nnc1_kw); i++) {
const int g1 = ecl_kw_iget_int( nnc1_kw , i ) - 1;
const int g2 = ecl_kw_iget_int( nnc2_kw , i ) - 1;
if (g2 < ecl_grid_get_global_size( lgr )) { // Skipping matrix <-> fracture link in dual poro.
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( lgr , g1 );
const int_vector_type * index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr);
test_assert_not_NULL( nnc_info );
test_assert_int_not_equal( -1 , int_vector_index( index_list , g2 ));
}
}
}
}
}
//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, 141085, 143828, 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]);
/* Global -> lgr */
{
if (ecl_file_has_kw( grid_file , NNCG_KW)) {
ecl_kw_type * nnchead_kw = ecl_file_iget_named_kw( grid_file , NNCHEAD_KW , 0);
ecl_kw_type * nncg_kw = ecl_file_iget_named_kw(grid_file , NNCG_KW , 0 );
ecl_kw_type * nncl_kw = ecl_file_iget_named_kw(grid_file , NNCL_KW , 0 );
int i;
int lgr_nr = ecl_kw_iget_int( nnchead_kw , NNCHEAD_LGR_INDEX);
for (i=0; i < ecl_kw_get_size(nncg_kw); i++) {
const int g = ecl_kw_iget_int( nncg_kw , i ) - 1;
const int l = ecl_kw_iget_int( nncl_kw , i ) - 1;
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( ecl_grid , g );
test_assert_not_NULL( nnc_info );
{
const int_vector_type * index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr );
test_assert_not_NULL( index_list );
test_assert_int_not_equal( -1 , int_vector_index( index_list , l ));
}
}
}
}
}
{
//LGR nr 1, cell global index 0: check NNCs to main grid
int data[] = {26220 , 29012};
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[] = {79142 ,126671};
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};
/* Amalgamated: LGR -> LGR */
{
if (ecl_file_has_kw( grid_file , NNCHEADA_KW)) {
ecl_kw_type * nncheada_kw = ecl_file_iget_named_kw( grid_file , NNCHEADA_KW , 0);
ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw(grid_file , NNA1_KW , 0 );
ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw(grid_file , NNA2_KW , 0 );
int lgr_nr1 = ecl_kw_iget_int( nncheada_kw , NNCHEADA_ILOC1_INDEX);
int lgr_nr2 = ecl_kw_iget_int( nncheada_kw , NNCHEADA_ILOC2_INDEX);
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");
ecl_grid_type * lgr1 = ecl_grid_get_lgr_from_lgr_nr( ecl_grid , lgr_nr1);
for (int i=0; i < ecl_kw_get_size(nnc1_kw); i++) {
const int g1 = ecl_kw_iget_int( nnc1_kw , i ) - 1;
const int g2 = ecl_kw_iget_int( nnc2_kw , i ) - 1;
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1( lgr1 , g1 );
const int_vector_type * index_list = nnc_info_get_grid_index_list( nnc_info , lgr_nr2);
test_assert_not_NULL( nnc_info );
test_assert_int_not_equal( -1 , int_vector_index( index_list , g2 ));
}
}
}
ecl_file_pop_block( grid_file );
}
{
//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 );
int main(int argc , char ** argv) {
int iarg;
for (iarg = 1; iarg < argc; iarg++) {
printf("Checking file: %s \n",argv[iarg]);
test_scan( argv[iarg] );
}
exit(0);
}

View File

@ -31,22 +31,28 @@ int main(int argc , char ** argv) {
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 );
nnc_vector_add_nnc( vector , 100 , 1);
nnc_vector_add_nnc( vector , 200 , 2);
nnc_vector_add_nnc( vector , 300 , 3);
nnc_vector_add_nnc( vector , 100 );
nnc_vector_add_nnc( vector , 200 );
nnc_vector_add_nnc( vector , 300 );
nnc_vector_add_nnc( vector , 100 , 4);
nnc_vector_add_nnc( vector , 200 , 5);
nnc_vector_add_nnc( vector , 300 , 6);
test_assert_int_equal( 6 , nnc_vector_get_size( vector ));
{
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 ));
const int_vector_type * grid_index_list = nnc_vector_get_grid_index_list( vector );
const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( vector );
test_assert_int_equal( 6 , int_vector_size( nnc_index_list ));
test_assert_int_equal( 1 , int_vector_iget( nnc_index_list , 0 ));
test_assert_int_equal( 6 , int_vector_iget( nnc_index_list , 5 ));
test_assert_int_equal( 6 , int_vector_size( grid_index_list ));
test_assert_int_equal( 100 , int_vector_iget( grid_index_list , 0 ));
test_assert_int_equal( 200 , int_vector_iget( grid_index_list , 1 ));
test_assert_int_equal( 300 , int_vector_iget( grid_index_list , 2 ));
}
nnc_vector_free( vector );

View File

@ -0,0 +1,71 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_sum_case_exists.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 <unistd.h>
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/util/path_stack.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_endian_flip.h>
#include <ert/ecl/ecl_sum.h>
void test_case( const char * sum_case , bool expected_exist) {
test_assert_bool_equal( expected_exist , ecl_sum_case_exists( sum_case ));
}
void test_case_no_path( const char * sum_case , bool expected_exist) {
path_stack_type * path_stack = path_stack_alloc();
path_stack_push_cwd( path_stack );
{
char * basename , *path;
util_alloc_file_components( sum_case , &path , &basename , NULL );
if (path)
chdir( path );
test_assert_bool_equal(expected_exist , ecl_sum_case_exists( basename ));
util_safe_free( path );
util_safe_free( basename );
}
path_stack_pop( path_stack );
path_stack_free( path_stack );
}
int main( int argc , char ** argv) {
const char * existing_case = argv[1];
const char * missing_header = argv[2];
const char * missing_data = argv[3];
test_assert_false( ecl_sum_case_exists( "/does/not/exist" ));
test_case( existing_case , true);
test_case_no_path( existing_case , true);
test_case( missing_header , false);
test_case_no_path( missing_header , false);
test_case( missing_data , false);
test_case_no_path( missing_data , false);
}

View File

@ -0,0 +1,44 @@
/*
*
* Created on: Sep 2, 2013
* Author: joaho
*/
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_lgr_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 <ert/util/test_util.h>
#include <ert/ecl/ecl_util.h>
int main(int argc , char ** argv) {
test_assert_true( ecl_util_valid_basename("ECLIPSE.DATA"));
test_assert_true( ecl_util_valid_basename("ECLIPS100.DATA"));
test_assert_true( ecl_util_valid_basename("eclipse100.data"));
test_assert_false( ecl_util_valid_basename("ECLiPS100.DATa"));
test_assert_true( ecl_util_valid_basename_fmt("ECL_%d.DATA"));
test_assert_true( ecl_util_valid_basename_fmt("ECL_%04d.DATA"));
test_assert_false( ecl_util_valid_basename_fmt("ECL_%d.dATA"));
test_assert_false( ecl_util_valid_basename_fmt("ECL_%s.DATA"));
exit(0);
}

View File

@ -1,15 +1,33 @@
add_executable( ecl_alloc_grid_dxv_dyv_dzv ecl_alloc_grid_dxv_dyv_dzv.c )
target_link_libraries( ecl_alloc_grid_dxv_dyv_dzv ecl test_util )
add_test( ecl_alloc_grid_dxv_dyv_dzv ${EXECUTABLE_OUTPUT_PATH}/ecl_alloc_grid_dxv_dyv_dzv )
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_nnc_amalgamated ecl_nnc_amalgamated.c )
target_link_libraries( ecl_nnc_amalgamated ecl test_util )
add_test( ecl_nnc_amalgamated ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_amalgamated ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/nestedLGRcase/TESTCASE_NESTEDLGR.EGRID )
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_nnc_export ecl_nnc_export.c )
target_link_libraries( ecl_nnc_export ecl test_util )
add_test (ecl_nnc_export1 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_test (ecl_nnc_export2 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC )
add_test (ecl_nnc_export3 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3)
add_test (ecl_nnc_export4 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUAL_DIFF )
add_test (ecl_nnc_export5 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO )
add_test (ecl_nnc_export6 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/nestedLGRcase/TESTCASE_NESTEDLGR)
add_executable( ecl_nnc_export_get_tran ecl_nnc_export_get_tran.c )
target_link_libraries( ecl_nnc_export_get_tran ecl test_util )
add_test (ecl_nnc_export_get_tran ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_export_get_tran ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3)
add_executable( ecl_valid_basename ecl_valid_basename.c )
target_link_libraries( ecl_valid_basename ecl test_util )
add_test( ecl_valid_basename ${EXECUTABLE_OUTPUT_PATH}/ecl_valid_basename)
add_executable( ecl_util_make_date_no_shift ecl_util_make_date_no_shift.c )
target_link_libraries( ecl_util_make_date_no_shift ecl test_util )
add_test( ecl_util_make_date_no_shift ${EXECUTABLE_OUTPUT_PATH}/ecl_util_make_date_no_shift )
@ -18,10 +36,18 @@ add_executable( ecl_util_make_date_shift ecl_util_make_date_shift.c )
target_link_libraries( ecl_util_make_date_shift ecl test_util )
add_test( ecl_util_make_date_shift ${EXECUTABLE_OUTPUT_PATH}/ecl_util_make_date_shift )
add_executable( ecl_sum_case_exists ecl_sum_case_exists.c )
target_link_libraries( ecl_sum_case_exists ecl test_util )
add_test( ecl_sum_case_exists ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_case_exists
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/GurbatSummary/missingHe ader/ECLIPSE
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/GurbatSummary/missingData/ECLIPSE )
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_test( ecl_grid_lgr_name ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_lgr_name ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID)
add_executable( ecl_region ecl_region.c )
target_link_libraries( ecl_region ecl test_util )
@ -47,6 +73,10 @@ 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_volume ecl_grid_volume.c )
target_link_libraries( ecl_grid_volume ecl test_util )
add_test( ecl_grid_volume1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_volume ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_test( ecl_grid_volume2 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_volume ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/VolumeTest/TEST1 )
add_executable( ecl_grid_dims ecl_grid_dims.c )
target_link_libraries( ecl_grid_dims ecl test_util )
@ -56,16 +86,18 @@ add_test( ecl_grid_dims1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOUR
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_test( ecl_grid_dims5 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID )
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_test (ecl_nnc_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_test (ecl_nnc_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID )
add_test (ecl_nnc_test3 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID)
add_test (ecl_nnc_test4 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUAL_DIFF.EGRID )
add_test (ecl_nnc_test5 ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/nestedLGRcase/TESTCASE_NESTEDLGR.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 )
@ -75,9 +107,6 @@ add_executable( ecl_nnc_vector ecl_nnc_vector.c )
target_link_libraries( ecl_nnc_vector ecl test_util )
add_test(ecl_nnc_vector ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_vector )
add_executable( ecl_nnc_index_list ecl_nnc_index_list.c )
target_link_libraries( ecl_nnc_index_list ecl test_util )
add_test (ecl_nnc_index_list ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_index_list )
add_executable( ecl_kw_grdecl ecl_kw_grdecl.c )
target_link_libraries( ecl_kw_grdecl ecl test_util )
@ -87,6 +116,10 @@ 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_kw_cmp_string ecl_kw_cmp_string.c )
target_link_libraries( ecl_kw_cmp_string ecl test_util )
add_test( ecl_kw_cmp_string ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_cmp_string )
add_executable( ecl_dualp ecl_dualp.c )
target_link_libraries( ecl_dualp ecl test_util )
@ -148,7 +181,7 @@ 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)
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 ${PROJECT_SOURCE_DIR}/libecl/tests/data/num_cpu3)
@ -177,13 +210,20 @@ 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_nnc_test1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_test2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_test3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_test4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_test5 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)
@ -191,4 +231,15 @@ 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)
set_property( TEST ecl_nnc_amalgamated PROPERTY LABELS StatoilData)
set_property( TEST ecl_sum_case_exists PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_volume1 PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_volume2 PROPERTY LABELS StatoilData)
set_property( TEST ecl_nnc_export1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_export2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_export3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_export4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_export5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_export6 PROPERTY LABELS StatoilData )
set_property( TEST ecl_nnc_export_get_tran PROPERTY LABELS StatoilData )

View File

@ -1,5 +1,6 @@
add_executable( segment_info segment_info.c )
set(program_list segment_info )
add_executable( CF_dump well_CF_dump.c )
set(program_list segment_info CF_dump)
foreach(prog ${program_list})
target_link_libraries( ${prog} ecl_well ecl)
if (USE_RUNPATH)

View File

@ -43,6 +43,7 @@ int main(int argc , char ** argv) {
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
const ecl_kw_type * scon_kw = ecl_file_iget_named_kw( rst_file , SCON_KW , 0 );
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( rst_file , ZWEL_KW , 0 );
{
@ -60,7 +61,7 @@ int main(int argc , char ** argv) {
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) {
well_branch_collection_type * branches = well_branch_collection_alloc();
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head);
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw , well_nr , rst_head);
well_segment_collection_link( segments );
well_segment_collection_add_branches( segments , branches );
well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections );

View File

@ -0,0 +1,56 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'well_CF_dump.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 <ert/ecl/ecl_grid.h>
#include <ert/ecl_well/well_state.h>
#include <ert/ecl_well/well_info.h>
int main( int argc , char ** argv ) {
char * grid_file = argv[1];
char * rst_file = argv[2];
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
well_info_type * well_info = well_info_alloc( grid );
well_info_load_rstfile( well_info , rst_file );
{
int iw;
int ic;
for (iw=0; iw < well_info_get_num_wells( well_info ); iw++) {
const char * well_name = well_info_iget_well_name( well_info , iw );
well_state_type * well_state = well_info_get_state_from_report(well_info , well_name , 100 );
const well_conn_collection_type * connections = well_state_get_global_connections( well_state );
printf("Well: %s \n",well_state_get_name( well_state ));
for (ic = 0; ic < well_conn_collection_get_size( connections ); ic++) {
well_conn_type * conn = well_conn_collection_iget( connections , ic );
printf(" %2d %2d %2d CF: %g \n",well_conn_get_i( conn ),
well_conn_get_j( conn ),
well_conn_get_k( conn ),
well_conn_get_connection_factor( conn ));
}
}
}
well_info_free( well_info );
ecl_grid_free( grid );
}

View File

@ -46,14 +46,14 @@ extern "C" {
void well_conn_free( well_conn_type * conn);
void well_conn_free__( void * arg );
well_conn_type * well_conn_alloc( int i , int j , int k , well_conn_dir_enum dir, bool open);
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , well_conn_dir_enum dir, bool open, int segment);
well_conn_type * well_conn_alloc_fracture( int i , int j , int k , well_conn_dir_enum dir, bool open);
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn_dir_enum dir, bool open, int segment);
well_conn_type * well_conn_alloc( int i , int j , int k , double connection_factor , well_conn_dir_enum dir, bool open);
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , double connection_factor , well_conn_dir_enum dir, bool open, int segment);
well_conn_type * well_conn_alloc_fracture( int i , int j , int k , double connection_factor , well_conn_dir_enum dir, bool open);
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , double connection_factor , well_conn_dir_enum dir, bool open, int segment);
bool well_conn_MSW(const well_conn_type * conn);
well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , const ecl_rsthead_type * header , int well_nr , int conn_nr);
well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , const ecl_kw_type * scon_kw , const ecl_rsthead_type * header , int well_nr , int conn_nr);
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr);
int well_conn_get_i(const well_conn_type * conn);
@ -65,6 +65,7 @@ extern "C" {
bool well_conn_fracture_connection( const well_conn_type * conn);
bool well_conn_matrix_connection( const well_conn_type * conn);
bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn2);
double well_conn_get_connection_factor( const well_conn_type * conn );
UTIL_IS_INSTANCE_HEADER( well_conn );
UTIL_SAFE_CAST_HEADER( well_conn );

View File

@ -41,7 +41,7 @@ extern "C" {
well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index);
void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_type * conn);
void well_conn_collection_add_ref( well_conn_collection_type * wellcc , well_conn_type * conn);
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , int iwell , const ecl_rsthead_type * rst_head);
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , const ecl_kw_type * scon_kw , int iwell , const ecl_rsthead_type * rst_head);
UTIL_IS_INSTANCE_HEADER( well_conn_collection );

View File

@ -79,6 +79,7 @@ extern "C" {
#define ICON_DEFAULT_DIR_VALUE 0
#define ICON_DEFAULT_DIR_TARGET ICON_DIRZ
#define SCON_CF_ITEM 0
#define RSEG_LENGTH_INDEX 0
#define RSEG_DIAMETER_INDEX 2

View File

@ -49,6 +49,7 @@ struct well_conn_struct {
bool open;
int segment_id; // -1: Ordinary well
bool matrix_connection; // k >= nz => fracture (and k -= nz )
double connection_factor;
};
@ -60,6 +61,10 @@ bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn
return false;
}
double well_conn_get_connection_factor( const well_conn_type * conn ) {
return conn->connection_factor;
}
bool well_conn_MSW( const well_conn_type * conn ) {
if (conn->segment_id == WELL_CONN_NORMAL_WELL_SEGMENT_ID)
@ -80,7 +85,7 @@ UTIL_IS_INSTANCE_FUNCTION( well_conn , WELL_CONN_TYPE_ID)
UTIL_SAFE_CAST_FUNCTION( well_conn , WELL_CONN_TYPE_ID)
static well_conn_type * well_conn_alloc__( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment_id, bool matrix_connection) {
static well_conn_type * well_conn_alloc__( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open, int segment_id, bool matrix_connection) {
if (well_conn_assert_direction( dir , matrix_connection)) {
well_conn_type * conn = util_malloc( sizeof * conn );
UTIL_TYPE_ID_INIT( conn , WELL_CONN_TYPE_ID );
@ -89,6 +94,7 @@ static well_conn_type * well_conn_alloc__( int i , int j , int k , well_conn_dir
conn->k = k;
conn->open = open;
conn->dir = dir;
conn->connection_factor = connection_factor;
conn->matrix_connection = matrix_connection;
if (segment_id == CONN_NORMAL_WELL_SEGMENT_VALUE)
@ -104,26 +110,26 @@ static well_conn_type * well_conn_alloc__( int i , int j , int k , well_conn_dir
}
well_conn_type * well_conn_alloc( int i , int j , int k , well_conn_dir_enum dir , bool open) {
return well_conn_alloc__(i , j , k , dir , open , WELL_CONN_NORMAL_WELL_SEGMENT_ID , true );
well_conn_type * well_conn_alloc( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open) {
return well_conn_alloc__(i , j , k , connection_factor , dir , open , WELL_CONN_NORMAL_WELL_SEGMENT_ID , true );
}
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment_id) {
return well_conn_alloc__(i , j , k , dir , open , segment_id , true );
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open, int segment_id) {
return well_conn_alloc__(i , j , k , connection_factor , dir , open , segment_id , true );
}
well_conn_type * well_conn_alloc_fracture( int i , int j , int k , well_conn_dir_enum dir , bool open) {
return well_conn_alloc__(i , j , k , dir , open , WELL_CONN_NORMAL_WELL_SEGMENT_ID , false);
well_conn_type * well_conn_alloc_fracture( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open) {
return well_conn_alloc__(i , j , k , connection_factor , dir , open , WELL_CONN_NORMAL_WELL_SEGMENT_ID , false);
}
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment_id) {
return well_conn_alloc__(i , j , k , dir , open , segment_id , false);
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open, int segment_id) {
return well_conn_alloc__(i , j , k , connection_factor , dir , open , segment_id , false);
}
@ -134,6 +140,7 @@ well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn
aligned with the rest of the ert libraries.
*/
well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
const ecl_kw_type * scon_kw ,
const ecl_rsthead_type * header ,
int well_nr ,
int conn_nr ) {
@ -145,6 +152,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_ITEM ) - 1;
int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1;
int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1;
double connection_factor = -1;
int segment_id = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET;
bool matrix_connection = true;
bool open;
@ -199,7 +207,12 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
}
}
conn = well_conn_alloc__(i,j,k,dir,open,segment_id,matrix_connection);
if (scon_kw) {
const int scon_offset = header->nsconz * ( header->ncwmax * well_nr + conn_nr );
connection_factor = ecl_kw_iget_as_double(scon_kw , scon_offset + SCON_CF_ITEM);
}
conn = well_conn_alloc__(i,j,k,connection_factor,dir,open,segment_id,matrix_connection);
/**
For multisegmented wells ONLY the global part of the restart
@ -208,22 +221,6 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
MSW + LGR well.
*/
/*
if (iseg_kw != NULL) {
if (conn->segment != WELL_CONN_NORMAL_WELL_SEGMENT_ID) {
const int iseg_offset = header->nisegz * ( header->nsegmx * seg_well_nr + conn->segment );
conn->outlet_segment = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_OUTLET_ITEM );
conn->branch = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_BRANCH_ITEM );
} else {
conn->branch = 0;
conn->outlet_segment = 0;
}
} else {
conn->branch = 0;
conn->outlet_segment = 0;
}
*/
return conn;
} else
return NULL; /* IC < 0: Connection not in current LGR. */
@ -251,6 +248,7 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e
int conn_k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1;
bool matrix_connection = true;
bool open = true;
double connection_factor = -1;
if (header->dualp) {
int geometric_nz = header->nz / 2;
@ -261,9 +259,9 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e
}
if (matrix_connection)
return well_conn_alloc( conn_i , conn_j , conn_k , open , well_conn_dirZ );
return well_conn_alloc( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ );
else
return well_conn_alloc_fracture( conn_i , conn_j , conn_k , open , well_conn_dirZ );
return well_conn_alloc_fracture( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ );
} else
// The well is completed in this LGR - however the wellhead is in another LGR.
return NULL;

View File

@ -100,16 +100,23 @@ well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wel
}
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , int iwell , const ecl_rsthead_type * rst_head) {
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc ,
const ecl_kw_type * iwel_kw ,
const ecl_kw_type * icon_kw ,
const ecl_kw_type * scon_kw ,
int iwell ,
const ecl_rsthead_type * rst_head) {
const int iwel_offset = rst_head->niwelz * iwell;
int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_ITEM );
int iconn;
for (iconn = 0; iconn < num_connections; iconn++) {
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , rst_head , iwell , iconn );
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn );
if (conn)
well_conn_collection_add( wellcc , conn );
}
return num_connections;
}

View File

@ -310,17 +310,19 @@ static void well_state_add_connections__( well_state_type * well_state ,
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0);
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
//const int iwel_offset = header->niwelz * well_nr;
//int seg_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1; // -1: Ordinary well.
well_state_add_wellhead( well_state , header , iwel_kw , well_nr , grid_name , grid_nr );
if (!well_state_has_grid_connections( well_state , grid_name ))
hash_insert_hash_owned_ref( well_state->connections , grid_name, well_conn_collection_alloc( ) , well_conn_collection_free__ );
{
ecl_kw_type * scon_kw = NULL;
well_conn_collection_type * wellcc = hash_get( well_state->connections , grid_name );
well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , well_nr , header );
if (ecl_file_has_kw( rst_file , SCON_KW))
scon_kw = ecl_file_iget_named_kw( rst_file , SCON_KW , 0);
well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw , well_nr , header );
}
ecl_rsthead_free( header );
}

View File

@ -81,6 +81,9 @@ 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_CF well_conn_CF.c )
target_link_libraries( well_conn_CF ecl_well test_util )
add_test( well_conn_CF ${EXECUTABLE_OUTPUT_PATH}/well_conn_CF ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.X0060)
add_executable( well_conn_load well_conn_load.c )
target_link_libraries( well_conn_load ecl_well test_util )
@ -126,6 +129,7 @@ set_property( TEST well_conn_load3 PROPERTY LABELS StatoilData )
set_property( TEST well_conn_load4 PROPERTY LABELS StatoilData )
set_property( TEST well_conn_load5 PROPERTY LABELS StatoilData )
set_property( TEST well_conn_load6 PROPERTY LABELS StatoilData )
set_property( TEST well_conn_CF PROPERTY LABELS StatoilData )
set_property( TEST well_info PROPERTY LABELS StatoilData )
set_property( TEST well_segment_load PROPERTY LABELS StatoilData )
set_property( TEST well_segment_branch_conn_load PROPERTY LABELS StatoilData )

View File

@ -33,14 +33,15 @@ int main(int argc , char ** argv) {
int i = 10;
int j = 5;
int k = 16;
double CF = 0;
bool open = true;
test_install_SIGNALS();
{
well_conn_dir_enum dir = well_conn_dirX;
well_conn_type * conn = well_conn_alloc(i,j,k,dir,open);
well_conn_type * conn2 = well_conn_alloc(i,j,k,dir,open);
well_conn_type * conn3 = well_conn_alloc(i,j,k+1,dir,open);
well_conn_type * conn = well_conn_alloc(i,j,k,CF,dir,open);
well_conn_type * conn2 = well_conn_alloc(i,j,k,CF,dir,open);
well_conn_type * conn3 = well_conn_alloc(i,j,k+1,CF,dir,open);
test_assert_not_NULL( conn );
test_assert_true( well_conn_is_instance( conn ));
test_assert_int_equal( i , well_conn_get_i( conn ));
@ -52,19 +53,20 @@ int main(int argc , char ** argv) {
test_assert_true( well_conn_matrix_connection( conn ));
test_assert_true( well_conn_equal( conn , conn2 ));
test_assert_false( well_conn_equal( conn , conn3 ));
test_assert_double_equal( CF , well_conn_get_connection_factor( conn ));
well_conn_free( conn );
}
{
well_conn_dir_enum dir = well_conn_fracX;
well_conn_type * conn = well_conn_alloc(i,j,k,dir,open);
well_conn_type * conn = well_conn_alloc(i,j,k,CF,dir,open);
test_assert_NULL( conn );
}
{
well_conn_dir_enum dir = well_conn_fracX;
well_conn_type * conn = well_conn_alloc_fracture(i,j,k,dir,open);
well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open);
test_assert_not_NULL( conn );
test_assert_int_equal( i , well_conn_get_i( conn ));
test_assert_int_equal( j , well_conn_get_j( conn ));
@ -80,14 +82,14 @@ int main(int argc , char ** argv) {
{
well_conn_dir_enum dir = well_conn_dirX;
well_conn_type * conn = well_conn_alloc_fracture(i,j,k,dir,open);
well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open);
test_assert_not_NULL( conn );
}
{
int segment = 16;
well_conn_dir_enum dir = well_conn_dirX;
well_conn_type * conn = well_conn_alloc_MSW(i,j,k,dir,open,segment);
well_conn_type * conn = well_conn_alloc_MSW(i,j,k,CF,dir,open,segment);
test_assert_not_NULL( conn );
test_assert_int_equal( i , well_conn_get_i( conn ));
test_assert_int_equal( j , well_conn_get_j( conn ));
@ -104,7 +106,7 @@ int main(int argc , char ** argv) {
{
int segment = 16;
well_conn_dir_enum dir = well_conn_fracX;
well_conn_type * conn = well_conn_alloc_fracture_MSW(i,j,k,dir,open,segment);
well_conn_type * conn = well_conn_alloc_fracture_MSW(i,j,k,CF,dir,open,segment);
test_assert_not_NULL( conn );
test_assert_int_equal( i , well_conn_get_i( conn ));
test_assert_int_equal( j , well_conn_get_j( conn ));

View File

@ -0,0 +1,69 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'well_conn_load.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_file.h>
#include <ert/ecl/ecl_rsthead.h>
#include <ert/ecl/ecl_kw_magic.h>
#include <ert/ecl_well/well_conn.h>
#include <ert/ecl_well/well_conn_collection.h>
#include <ert/ecl_well/well_const.h>
void well_conn_test_CF( const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , const ecl_kw_type * scon_kw , const const ecl_rsthead_type * rst_head , int iwell , int iconn, double CF) {
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn );
test_assert_double_equal( CF , well_conn_get_connection_factor(conn));
well_conn_free( conn );
}
int main(int argc , char ** argv) {
const char * Xfile = argv[1];
ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
const ecl_kw_type * scon_kw = ecl_file_iget_named_kw( rst_file , SCON_KW , 0 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 0 , 0 , 32.948 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 0 , 1 , 46.825 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 0 , 2 , 51.867 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 1 , 0 , 1.168 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 1 , 1 , 15.071 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 1 , 2 , 6.242 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 2 , 0 , 27.412 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 2 , 1 , 55.195 );
well_conn_test_CF(iwel_kw , icon_kw , scon_kw , rst_head , 2 , 2 , 18.032 );
ecl_file_close( rst_file );
ecl_rsthead_free( rst_head );
exit( 0 );
}

View File

@ -48,6 +48,8 @@ int main(int argc , char ** argv) {
int iwell;
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
ecl_kw_type * scon_kw = NULL;
bool caseMSW = false;
for (iwell = 0; iwell < rst_head->nwells; iwell++) {
@ -58,7 +60,7 @@ int main(int argc , char ** argv) {
well_conn_collection_type * wellcc_ref = well_conn_collection_alloc();
for (iconn = 0; iconn < num_connections; iconn++) {
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , rst_head , iwell , iconn );
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , scon_kw , rst_head , iwell , iconn );
test_assert_true( well_conn_is_instance( conn ));
test_assert_not_NULL( conn );
@ -86,7 +88,7 @@ int main(int argc , char ** argv) {
int i;
test_assert_int_equal( well_conn_collection_get_size( wellcc ) ,
well_conn_collection_load_from_kw( wellcc2 , iwel_kw , icon_kw , iwell , rst_head));
well_conn_collection_load_from_kw( wellcc2 , iwel_kw , icon_kw , scon_kw , iwell , rst_head));
for (i=0; i < well_conn_collection_get_size( wellcc2 ); i++) {
test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc2 , i )));

View File

@ -43,6 +43,7 @@ int main(int argc , char ** argv) {
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
const ecl_kw_type * scon_kw = NULL;
test_install_SIGNALS();
test_assert_not_NULL( rst_file );
@ -51,7 +52,7 @@ int main(int argc , char ** argv) {
int well_nr;
for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
well_conn_collection_type * connections = well_conn_collection_alloc();
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head);
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw , well_nr , rst_head);
{
well_segment_collection_type * segments = well_segment_collection_alloc();

View File

@ -35,12 +35,13 @@ int main(int argc , char ** argv) {
test_install_SIGNALS();
double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
{
double CF = 88;
int segment_id = 78;
int outlet_segment_id = 100;
int branch_nr = WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
well_segment_type * ws = well_segment_alloc(segment_id , outlet_segment_id , branch_nr, rseg_data);
well_conn_type * conn1 = well_conn_alloc_MSW(1,1,1,true,well_conn_dirX,segment_id);
well_conn_type * conn2 = well_conn_alloc_MSW(1,1,1,true,well_conn_dirX,segment_id + 1);
well_conn_type * conn1 = well_conn_alloc_MSW(1,1,1,CF,true,well_conn_dirX,segment_id);
well_conn_type * conn2 = well_conn_alloc_MSW(1,1,1,CF,true,well_conn_dirX,segment_id + 1);
test_assert_false( well_segment_has_global_grid_connections( ws ));

View File

@ -46,7 +46,7 @@ int main(int argc , char ** argv) {
char * ext;
char * target_ext = util_alloc_sprintf("X%04d" , i);
util_alloc_file_components( stringlist_iget( file_list , i ) , NULL , NULL , &ext);
test_assert_string_equal( ext , target_ext);
free( ext );
free( target_ext );
@ -55,8 +55,10 @@ int main(int argc , char ** argv) {
{
well_info_type * well_info = well_info_alloc( grid );
int i;
for (i=0; i < stringlist_get_size( file_list ); i++)
for (i=0; i < stringlist_get_size( file_list ); i++) {
printf("Loading file:%s \n",stringlist_iget( file_list , i ));
well_info_load_rstfile( well_info , stringlist_iget(file_list , i));
}
well_info_free( well_info );
}

View File

@ -174,8 +174,9 @@ static void enkf_tui_fs_copy_ensemble__(
{
/* If the current target_case does not exist it is automatically created by the select_write_dir function */
enkf_fs_type * src_fs = enkf_main_get_alt_fs( enkf_main , source_case , true , false );
enkf_fs_type * target_fs = enkf_main_get_alt_fs( enkf_main , target_case , false, true );
enkf_fs_type * src_fs = enkf_main_mount_alt_fs( enkf_main , source_case , true , false );
enkf_fs_type * target_fs = enkf_main_mount_alt_fs( enkf_main , target_case , false, true );
stringlist_type * nodes;
if(only_parameters)
@ -211,8 +212,8 @@ static void enkf_tui_fs_copy_ensemble__(
}
}
enkf_main_close_alt_fs( enkf_main , src_fs );
enkf_main_close_alt_fs( enkf_main , target_fs );
enkf_fs_umount( src_fs );
enkf_fs_umount( target_fs );
msg_free(msg , true);
stringlist_free(nodes);
@ -270,13 +271,13 @@ void enkf_tui_fs_copy_ensemble(void * arg)
source_case = util_alloc_string_copy(enkf_main_get_current_fs( enkf_main ));
last_report = enkf_main_get_history_length( enkf_main );
report_step_from_as_char = util_scanf_int_with_limits_return_char("source report step",prompt_len , 0 , last_report);
report_step_from_as_char = util_scanf_int_with_limits_return_char("Source report step",prompt_len , 0 , last_report);
if(strlen(report_step_from_as_char) !=0){
util_sscanf_int(report_step_from_as_char , &report_step_from);
state_from = enkf_tui_util_scanf_state("source analyzed/forecast [a|f]" , prompt_len , false);
state_from = enkf_tui_util_scanf_state("Source analyzed/forecast [a|f]" , prompt_len , false);
if(state_from != UNDEFINED) {
util_printf_prompt("target case" , prompt_len , '=' , "=> ");
char * target_case = NULL;
util_printf_prompt("Target case" , prompt_len , '=' , "=> ");
char target_case[256];
if ( fgets(target_case, prompt_len, stdin)) {
char *newline = strchr(target_case, '\n');
@ -285,10 +286,10 @@ void enkf_tui_fs_copy_ensemble(void * arg)
}
if (target_case && (strlen(target_case))) {
char * report_step_to_as_char = util_scanf_int_with_limits_return_char("target report step",prompt_len , 0 , last_report);
char * report_step_to_as_char = util_scanf_int_with_limits_return_char("Target report step",prompt_len , 0 , last_report);
if (strlen(report_step_to_as_char)) {
util_sscanf_int(report_step_to_as_char , &report_step_to);
state_to = enkf_tui_util_scanf_state("target analyzed/forecast [a|f]" , prompt_len , false);
state_to = enkf_tui_util_scanf_state("Target analyzed/forecast [a|f]" , prompt_len , false);
if(state_to != UNDEFINED) {
enkf_tui_fs_copy_ensemble__(enkf_main, source_case, target_case, report_step_from, state_from, report_step_to, state_to, false);
}
@ -305,7 +306,7 @@ void enkf_tui_fs_copy_ensemble(void * arg)
void enkf_tui_fs_copy_ensemble_of_parameters(void * arg)
{
int prompt_len = 35;
int prompt_len = 35;
char * source_case;
int last_report;
@ -320,14 +321,14 @@ void enkf_tui_fs_copy_ensemble_of_parameters(void * arg)
source_case = util_alloc_string_copy(enkf_main_get_current_fs( enkf_main ));
last_report = enkf_main_get_history_length( enkf_main );
report_step_from_as_char = util_scanf_int_with_limits_return_char("source report step",prompt_len , 0 , last_report);
report_step_from_as_char = util_scanf_int_with_limits_return_char("Source report step",prompt_len , 0 , last_report);
if(strlen(report_step_from_as_char) !=0){
util_sscanf_int(report_step_from_as_char , &report_step_from);
state_from = enkf_tui_util_scanf_state("source analyzed/forecast [a|f]" , prompt_len , false);
state_from = enkf_tui_util_scanf_state("Source analyzed/forecast [a|f]" , prompt_len , false);
if(state_from != UNDEFINED){
util_printf_prompt("target case" , prompt_len , '=' , "=> ");
char * target_case = NULL;
util_printf_prompt("Target case" , prompt_len , '=' , "=> ");
char target_case[256];
if ( fgets(target_case, prompt_len, stdin) ) {
char *newline = strchr(target_case, '\n');
@ -336,10 +337,10 @@ void enkf_tui_fs_copy_ensemble_of_parameters(void * arg)
}
if (target_case && strlen(target_case)) {
char * report_step_to_as_char = util_scanf_int_with_limits_return_char("target report step",prompt_len , 0 , last_report);
char * report_step_to_as_char = util_scanf_int_with_limits_return_char("Target report step",prompt_len , 0 , last_report);
if(strlen(report_step_to_as_char) !=0){
util_sscanf_int(report_step_to_as_char , &report_step_to);
state_to = enkf_tui_util_scanf_state("target analyzed/forecast [a|f]" , prompt_len , false);
state_to = enkf_tui_util_scanf_state("Target analyzed/forecast [a|f]" , prompt_len , false);
if(state_to != UNDEFINED){
enkf_tui_fs_copy_ensemble__(enkf_main, source_case, target_case, report_step_from, state_from, report_step_to, state_to, true);
}
@ -353,42 +354,6 @@ void enkf_tui_fs_copy_ensemble_of_parameters(void * arg)
}
void enkf_tui_fs_initialize_case_for_predictions(void * arg)
{
int prompt_len = 35;
char source_case[256];
int report_step_from;
int report_step_to;
state_enum state_from;
state_enum state_to;
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
state_from = ANALYZED;
state_to = ANALYZED;
report_step_from = enkf_main_get_history_length( enkf_main );
report_step_to = enkf_main_get_history_length( enkf_main );
{
char * target_case = util_alloc_string_copy( NULL );
util_printf_prompt("Source case" , prompt_len , '=' , "=> ");
fgets(source_case, prompt_len, stdin);
char *newline = strchr(source_case,'\n');
if(newline)
*newline = 0;
if(strlen(source_case) !=0)
enkf_tui_fs_copy_ensemble__(enkf_main, source_case, target_case, report_step_from, state_from, report_step_to, state_to, false);
free(target_case);
}
}
void enkf_tui_fs_menu(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
@ -415,7 +380,6 @@ void enkf_tui_fs_menu(void * arg) {
menu_add_separator(menu);
menu_add_item(menu, "Initialize case from scratch" , "iI" , enkf_tui_init_menu , enkf_main , NULL);
menu_add_item(menu, "Initialize case from existing case" , "aA" , enkf_tui_fs_initialize_case_from_copy , enkf_main , NULL);
menu_add_item(menu, "Initialize case FOR PREDICTIONS from existing case", "pP" , enkf_tui_fs_initialize_case_for_predictions , enkf_main , NULL);
menu_add_separator(menu);
/* Are these two in use??? */

View File

@ -45,7 +45,7 @@ void enkf_tui_init(enkf_main_type * enkf_main, bool all_members , bool all_param
const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
int ens_size = enkf_main_get_ensemble_size( enkf_main );
int iens1, iens2;
bool force_init = true;
init_mode_enum init_mode = INIT_FORCE;
bool iens_valid = false;
/* iens2 should be interpreted as __inclusive__ */
@ -90,7 +90,7 @@ void enkf_tui_init(enkf_main_type * enkf_main, bool all_members , bool all_param
}
if (param_list != NULL) {
enkf_main_initialize_from_scratch(enkf_main , param_list , iens1 , iens2 , force_init);
enkf_main_initialize_from_scratch(enkf_main , param_list , iens1 , iens2 , init_mode);
stringlist_free( param_list );
}
}

View File

@ -109,21 +109,17 @@ void enkf_tui_run_restart__(void * enkf_main) {
void enkf_tui_run_smoother(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
enkf_main_run_smoother(enkf_main , "AUTO-SMOOTHER" , true );
int ens_size = enkf_main_get_ensemble_size( enkf_main );
bool_vector_type * iactive = bool_vector_alloc( ens_size , true );
enkf_main_run_smoother(enkf_main , "AUTO-SMOOTHER" , iactive , true );
bool_vector_free( iactive );
}
void enkf_tui_run_iterated_ES(void * arg) {
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main );
const int last_report = enkf_main_get_history_length( enkf_main );
int step2;
if (ecl_config_has_schedule( ecl_config ))
step2 = util_scanf_int_with_limits("Last report",PROMPT_LEN , 0 , last_report);
else
step2 = last_report;
enkf_main_run_iterated_ES(enkf_main, step2);
enkf_main_run_iterated_ES(enkf_main);
}
void enkf_tui_run_one_more_iteration(void * arg){
@ -172,7 +168,7 @@ void enkf_tui_run_exp(void * enkf_main) {
free( prompt );
}
if (bool_vector_count_equal(iactive , true))
enkf_main_run_exp(enkf_main , iactive , true , init_step_parameters , start_report , init_state, true);
enkf_main_run_exp(enkf_main , iactive , true , init_step_parameters , start_report , init_state);
bool_vector_free(iactive);
}
@ -198,7 +194,7 @@ void enkf_tui_run_create_runpath__(void * __enkf_main) {
util_safe_free( select_string );
free( prompt );
}
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state, true);
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
bool_vector_free(iactive);
}
@ -219,7 +215,7 @@ void enkf_tui_run_manual_load__( void * arg ) {
bool_vector_type * iactive = bool_vector_alloc( 0 , false );
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
enkf_main_init_run(enkf_main , run_mode); /* This is ugly */
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
step1 = 0;
step2 = last_report; /** Observe that for the summary data it will load all the available data anyway. */

View File

@ -1,3 +1,3 @@
#!/bin/sh
cd $1
cd "$1"
git rev-parse HEAD

View File

@ -24,6 +24,7 @@ extern "C" {
#include <time.h>
#include <ert/util/path_fmt.h>
#include <ert/util/ui_return.h>
#include <ert/config/config.h>
@ -37,53 +38,72 @@ extern "C" {
typedef struct ecl_config_struct ecl_config_type;
const char * ecl_config_get_data_file(const ecl_config_type * );
void ecl_config_set_data_file( ecl_config_type * ecl_config , const char * data_file);
ui_return_type * ecl_config_validate_data_file(const ecl_config_type * ecl_config, const char * data_file);
void ecl_config_set_schedule_file(ecl_config_type * ecl_config, const char * schedule_file);
ui_return_type * ecl_config_validate_schedule_file(const ecl_config_type * ecl_config , const char * schedule_file);
const char * ecl_config_get_schedule_file( const ecl_config_type * ecl_config );
const char * ecl_config_get_schedule_target(const ecl_config_type * );
bool ecl_config_has_schedule( const ecl_config_type * ecl_config );
void ecl_config_set_eclbase( ecl_config_type * ecl_config , const char * eclbase_fmt );
ui_return_type * ecl_config_validate_eclbase( const ecl_config_type * ecl_config , const char * eclbase_fmt );
const path_fmt_type * ecl_config_get_eclbase_fmt(const ecl_config_type * );
void ecl_config_set_init_section( ecl_config_type * ecl_config , const char * input_init_section );
ui_return_type * ecl_config_validate_init_section( const ecl_config_type * ecl_config , const char * input_init_section );
const char * ecl_config_get_init_section(const ecl_config_type * ecl_config);
const char * ecl_config_get_equil_init_file(const ecl_config_type * );
bool ecl_config_has_init_section( const ecl_config_type * ecl_config );
void ecl_config_set_grid( ecl_config_type * ecl_config , const char * grid_file );
const char * ecl_config_get_gridfile( const ecl_config_type * ecl_config );
ecl_grid_type * ecl_config_get_grid(const ecl_config_type * );
ui_return_type * ecl_config_validate_grid( const ecl_config_type * ecl_config , const char * grid_file );
bool ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase);
ui_return_type * ecl_config_validate_refcase( const ecl_config_type * ecl_config , const char * refcase );
const ecl_sum_type * ecl_config_get_refcase(const ecl_config_type * ecl_config);
bool ecl_config_has_refcase( const ecl_config_type * ecl_config );
ecl_refcase_list_type * ecl_config_get_refcase_list( const ecl_config_type * ecl_config );
/*****************************************************************/
void ecl_config_static_kw_init( ecl_config_type * ecl_config , const config_type * config );
bool ecl_config_active( const ecl_config_type * config );
time_t ecl_config_get_end_date( const ecl_config_type * ecl_config );
time_t ecl_config_get_start_date( const ecl_config_type * ecl_config );
const char * ecl_config_get_schedule_prediction_file( const ecl_config_type * ecl_config );
void ecl_config_set_schedule_prediction_file( ecl_config_type * ecl_config , const char * schedule_prediction_file );
const char * ecl_config_get_schedule_file( const ecl_config_type * ecl_config );
sched_file_type * ecl_config_get_sched_file(const ecl_config_type * );
int ecl_config_get_num_cpu( const ecl_config_type * ecl_config );
void ecl_config_set_data_file( ecl_config_type * ecl_config , const char * data_file);
void ecl_config_init( ecl_config_type * ecl_config , const config_type * config);
void ecl_config_free( ecl_config_type *);
bool ecl_config_include_static_kw(const ecl_config_type * , const char * );
void ecl_config_add_static_kw(ecl_config_type *, const char *);
ecl_io_config_type * ecl_config_get_io_config(const ecl_config_type * );
sched_file_type * ecl_config_get_sched_file(const ecl_config_type * );
bool ecl_config_get_formatted(const ecl_config_type * );
bool ecl_config_get_unified_restart(const ecl_config_type * );
bool ecl_config_get_unified_summary(const ecl_config_type * );
const char * ecl_config_get_data_file(const ecl_config_type * );
const char * ecl_config_get_schedule_target(const ecl_config_type * );
const char * ecl_config_get_equil_init_file(const ecl_config_type * );
void ecl_config_set_init_section( ecl_config_type * ecl_config , const char * input_init_section );
const char * ecl_config_get_init_section(const ecl_config_type * ecl_config);
const path_fmt_type * ecl_config_get_eclbase_fmt(const ecl_config_type * );
int ecl_config_get_num_restart_files(const ecl_config_type * );
const ecl_sum_type * ecl_config_get_refcase(const ecl_config_type * ecl_config);
bool ecl_config_has_refcase( const ecl_config_type * ecl_config );
ecl_refcase_list_type * ecl_config_get_refcase_list( const ecl_config_type * ecl_config );
ecl_grid_type * ecl_config_get_grid(const ecl_config_type * );
void ecl_config_set_grid( ecl_config_type * ecl_config , const char * grid_file );
const char * ecl_config_get_gridfile( const ecl_config_type * ecl_config );
int ecl_config_get_last_history_restart( const ecl_config_type * );
bool ecl_config_has_schedule( const ecl_config_type * ecl_config );
bool ecl_config_can_restart( const ecl_config_type * ecl_config );
void ecl_config_assert_restart( const ecl_config_type * ecl_config );
void ecl_config_set_eclbase( ecl_config_type * ecl_config , const char * eclbase_fmt );
const char * ecl_config_get_eclbase( const ecl_config_type * ecl_config );
const char * ecl_config_get_schedule_file( const ecl_config_type * ecl_config );
void ecl_config_set_schedule_file( ecl_config_type * ecl_config , const char * schedule_file );
bool ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase);
const char * ecl_config_get_refcase_name( const ecl_config_type * ecl_config);
void ecl_config_clear_static_kw( ecl_config_type * ecl_config );
stringlist_type * ecl_config_get_static_kw_list( const ecl_config_type * ecl_config );
void ecl_config_fprintf_config( const ecl_config_type * ecl_config , FILE * stream );
ecl_config_type * ecl_config_alloc_empty( );
ecl_config_type * ecl_config_alloc( );
void ecl_config_add_config_items( config_type * config );
bool ecl_config_has_init_section( const ecl_config_type * ecl_config );
#ifdef __cplusplus
}

View File

@ -261,9 +261,10 @@
Name of the default case.
*/
#define CASE_LOG "case-log"
#define CURRENT_CASE "current"
#define DEFAULT_CASE "default"
#define CASE_LOG "case-log"
#define CURRENT_CASE "current"
#define DEFAULT_CASE "default"
#define CURRENT_CASE_FILE "current_case"
#define DEFAULT_PLAIN_NODE_PARAMETER_PATH "tstep/%04d/mem%03d/Parameter"
#define DEFAULT_PLAIN_NODE_STATIC_PATH "tstep/%04d/mem%03d/Static"

View File

@ -41,13 +41,17 @@ extern "C" {
const char * enkf_fs_get_mount_point( const enkf_fs_type * fs );
const char * enkf_fs_get_root_path( const enkf_fs_type * fs );
const char * enkf_fs_get_case_name( const enkf_fs_type * fs );
bool enkf_fs_is_read_only(const enkf_fs_type * fs);
void enkf_fs_set_writable(enkf_fs_type * fs);
void enkf_fs_fsync( enkf_fs_type * fs );
enkf_fs_type * enkf_fs_mount(const char * , fs_driver_impl , const char * select_case, bool update_map, bool read_only);
void enkf_fs_add_index_node(enkf_fs_type * , int , int , const char * , enkf_var_type, ert_impl_type);
void enkf_fs_close( enkf_fs_type * fs );
enkf_fs_type * enkf_fs_open( const char * path , bool read_only);
int enkf_fs_get_refcount( const enkf_fs_type * fs );
enkf_fs_type * enkf_fs_get_ref( enkf_fs_type * fs );
enkf_fs_type * enkf_fs_get_weakref( enkf_fs_type * fs );
void enkf_fs_umount( enkf_fs_type * fs );
enkf_fs_type * enkf_fs_mount( const char * path , bool read_only);
int enkf_fs_get_version104( const char * path );
void enkf_fs_fwrite_node(enkf_fs_type * enkf_fs , buffer_type * buffer , const char * node_key, enkf_var_type var_type,
int report_step , int iens , state_enum state);
@ -71,6 +75,7 @@ extern "C" {
int iens ,
state_enum state);
bool enkf_fs_has_vector(enkf_fs_type * enkf_fs , const char * node_key , enkf_var_type var_type , int iens , state_enum state);
bool enkf_fs_has_node(enkf_fs_type * enkf_fs , const char * node_key , enkf_var_type var_type , int report_step , int iens , state_enum state);
void enkf_fs_fwrite_restart_kw_list(enkf_fs_type * , int , int , const stringlist_type *);
@ -95,6 +100,7 @@ extern "C" {
FILE * enkf_fs_open_excase_tstep_file( const enkf_fs_type * fs , const char * input_name , int tstep );
FILE * enkf_fs_open_excase_member_file( const enkf_fs_type * fs , const char * input_name , int iens );
state_map_type * enkf_fs_alloc_readonly_state_map( const char * mount_point );
state_map_type * enkf_fs_get_state_map( const enkf_fs_type * fs );
time_map_type * enkf_fs_get_time_map( const enkf_fs_type * fs );
cases_config_type * enkf_fs_get_cases_config( const enkf_fs_type * fs);

View File

@ -33,6 +33,7 @@ extern "C" {
#include <ert/util/int_vector.h>
#include <ert/util/matrix.h>
#include <ert/util/path_fmt.h>
#include <ert/util/ui_return.h>
#include <ert/sched/sched_file.h>
@ -59,20 +60,24 @@ extern "C" {
#include <ert/enkf/qc_module.h>
#include <ert/enkf/rng_config.h>
#include <ert/enkf/pca_plot_data.h>
#include <ert/enkf/field_config.h>
/*****************************************************************/
typedef struct enkf_main_struct enkf_main_type;
void enkf_main_close_alt_fs(const enkf_main_type * enkf_main , enkf_fs_type * fs);
enkf_fs_type * enkf_main_get_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create);
//void enkf_main_close_alt_fs(const enkf_main_type * enkf_main , enkf_fs_type * fs);
bool enkf_main_case_is_current(const enkf_main_type * enkf_main , const char * case_path);
enkf_fs_type * enkf_main_mount_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create);
state_map_type * enkf_main_alloc_readonly_state_map( const enkf_main_type * enkf_main , const char * case_path);
stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main );
void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const char * case_path );
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 );
char * enkf_main_read_alloc_current_case_name(const enkf_main_type * enkf_main);
ui_return_type * enkf_main_set_eclbase( enkf_main_type * enkf_main , const char * eclbase_fmt);
ui_return_type * 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 );
const char * enkf_main_get_user_config_file( const enkf_main_type * enkf_main );
void enkf_main_set_rft_config_file( enkf_main_type * enkf_main , const char * rft_config_file );
@ -80,7 +85,8 @@ extern "C" {
bool enkf_main_get_pre_clear_runpath( const enkf_main_type * enkf_main );
void enkf_main_set_pre_clear_runpath( enkf_main_type * enkf_main , bool pre_clear_runpath);
bool enkf_main_set_refcase( enkf_main_type * enkf_main , const char * refcase_path);
ui_return_type * enkf_main_validata_refcase( const enkf_main_type * enkf_main , const char * refcase_path);
ert_report_list_type * enkf_main_get_report_list( const enkf_main_type * enkf_main );
ert_templates_type * enkf_main_get_templates( enkf_main_type * enkf_main );
void enkf_main_set_log_file( enkf_main_type * enkf_main , const char * log_file );
@ -105,21 +111,23 @@ extern "C" {
void enkf_main_free(enkf_main_type * );
void enkf_main_exit(enkf_main_type * enkf_main);
void enkf_main_init_eclipse(enkf_main_type * , int , int );
void enkf_main_init_run( enkf_main_type * enkf_main, run_mode_type run_mode);
void enkf_main_init_run( enkf_main_type * enkf_main, const bool_vector_type * iactive , run_mode_type run_mode , init_mode_enum init_mode);
void enkf_main_load_ecl_init_mt(enkf_main_type * enkf_main , int );
void enkf_main_load_ecl_complete_mt(enkf_main_type *);
void enkf_main_iload_ecl_mt(enkf_main_type *enkf_main , int );
void enkf_main_assimilation_update(enkf_main_type * enkf_main , const int_vector_type * step_list);
bool enkf_main_smoother_update(enkf_main_type * enkf_main , const int_vector_type * step_list , enkf_fs_type * target_fs);
bool enkf_main_smoother_update(enkf_main_type * enkf_main , enkf_fs_type * target_fs);
void enkf_main_run_post_workflow( enkf_main_type * enkf_main );
bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_enum init_mode);
void enkf_main_run_exp(enkf_main_type * enkf_main ,
bool_vector_type * iactive ,
bool simulate ,
int init_step_parameters ,
int start_report ,
state_enum start_state ,
bool initialize);
state_enum start_state);
void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
@ -128,8 +136,9 @@ extern "C" {
int start_report ,
state_enum start_state);
void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_name , bool rerun);
void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int last_report);
void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_name , bool_vector_type * iactive , bool rerun);
bool enkf_main_iterate_smoother(enkf_main_type * enkf_main, int iteration_number, const char * target_fs_name , bool_vector_type * iactive);
void enkf_main_run_iterated_ES(enkf_main_type * enkf_main);
void enkf_main_run_one_more_iteration(enkf_main_type * enkf_main, int step2);
void enkf_main_set_data_kw(enkf_main_type * , const char * , const char *);
void enkf_main_set_state_run_path(const enkf_main_type * , int );
@ -166,14 +175,13 @@ extern "C" {
bool enkf_main_have_obs( const enkf_main_type * enkf_main );
analysis_config_type * enkf_main_get_analysis_config(const enkf_main_type * );
void enkf_main_select_fs( enkf_main_type * enkf_main , const char * case_path );
enkf_plot_data_type * enkf_main_alloc_plot_data( enkf_main_type * enkf_main );
void * enkf_main_get_enkf_config_node_type(const ensemble_config_type *, const char *);
void enkf_main_set_field_config_iactive(const ensemble_config_type *, int);
const char * enkf_main_get_image_viewer(const enkf_main_type * );
const char * enkf_main_get_image_viewer(const enkf_main_type * );
const char * enkf_main_get_plot_driver(const enkf_main_type * enkf_main );
const char * enkf_main_get_image_type(const enkf_main_type * enkf_main);
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, bool force_init);
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, init_mode_enum init_mode);
void enkf_main_initialize_from_existing(enkf_main_type * enkf_main ,
const char * source_case ,
@ -264,6 +272,14 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_
rng_config_type * enkf_main_get_rng_config( const enkf_main_type * enkf_main );
void enkf_main_rng_init( enkf_main_type * enkf_main);
bool enkf_main_export_field(const enkf_main_type * enkf_main,
const char * kw,
const char * path,
int_vector_type * realization_list,
field_file_format_type file_type,
int report_step,
state_enum state);
UTIL_SAFE_CAST_HEADER(enkf_main);
UTIL_IS_INSTANCE_HEADER(enkf_main);

View File

@ -1,39 +0,0 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'enkf_plot_arg.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 __ENKF_PLOT_ARG_H__
#define __ENKF_PLOT_ARG_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <stdbool.h>
typedef struct enkf_plot_arg_struct enkf_plot_arg_type;
enkf_plot_arg_type * enkf_plot_arg_alloc(bool time_mode, time_t start_time);
enkf_plot_arg_type * enkf_plot_arg_alloc( bool time_mode , time_t start_time);
void enkf_plot_arg_free( enkf_plot_arg_type * plot_arg );
void enkf_plot_arg_free__( void * arg );
void enkf_plot_arg_reset( enkf_plot_arg_type * plot_arg , bool time_mode , time_t start_time);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -24,27 +24,29 @@
extern "C" {
#endif
#include <stdbool.h>
#include <time.h>
#include <ert/util/bool_vector.h>
#include <ert/util/type_macros.h>
#include <ert/enkf/enkf_config_node.h>
#include <ert/enkf/enkf_fs.h>
#include <ert/enkf/enkf_types.h>
#include <ert/enkf/enkf_plot_tvector.h>
typedef struct enkf_plot_data_struct enkf_plot_data_type;
enkf_plot_data_type * enkf_plot_data_alloc( time_t start_time);
enkf_plot_data_type * enkf_plot_data_alloc( const enkf_config_node_type * config_node );
void enkf_plot_data_free( enkf_plot_data_type * plot_data );
void enkf_plot_data_load( enkf_plot_data_type * plot_data ,
enkf_config_node_type * config_node ,
enkf_fs_type * fs ,
const char * user_key ,
state_enum state ,
const bool_vector_type * active,
bool time_mode,
int step1 ,
int step2);
const bool_vector_type * input_mask);
int enkf_plot_data_get_size( const enkf_plot_data_type * plot_data );
enkf_plot_tvector_type * enkf_plot_data_iget( const enkf_plot_data_type * plot_data , int index);
UTIL_IS_INSTANCE_HEADER( enkf_plot_data );
#ifdef __cplusplus
}
#endif

View File

@ -1,50 +0,0 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'enkf_plot_member.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 __ENKF_PLOT_MEMBER_H__
#define __ENKF_PLOT_MEMBER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <stdbool.h>
#include <ert/util/util.h>
#include <ert/enkf/enkf_fs.h>
#include <ert/enkf/enkf_types.h>
#include <ert/enkf/enkf_node.h>
#include <ert/enkf/enkf_plot_arg.h>
typedef struct enkf_plot_member_struct enkf_plot_member_type;
UTIL_SAFE_CAST_HEADER( enkf_plot_member );
enkf_plot_member_type * enkf_plot_member_alloc( enkf_plot_arg_type * shared_arg , time_t start_time);
void enkf_plot_member_reset( enkf_plot_member_type * plot_member , enkf_plot_arg_type * shared_arg , bool time_mode );
void enkf_plot_member_load( enkf_plot_member_type * plot_member , enkf_node_type * enkf_node , enkf_fs_type * fs , const char * user_key , int iens , state_enum state , enkf_plot_arg_type * shared_arg , bool time_mode , int step1 , int step2);
void enkf_plot_member_load__( void *arg );
void enkf_plot_member_free__( void * arg );
void enkf_plot_member_free( enkf_plot_member_type * plot_member );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,59 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'enkf_plot_tvector.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 __ENKF_PLOT_TVECTOR_H__
#define __ENKF_PLOT_TVECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <stdbool.h>
#include <ert/util/util.h>
#include <ert/enkf/enkf_fs.h>
#include <ert/enkf/enkf_types.h>
#include <ert/enkf/enkf_config_node.h>
typedef struct enkf_plot_tvector_struct enkf_plot_tvector_type;
UTIL_SAFE_CAST_HEADER( enkf_plot_tvector );
UTIL_IS_INSTANCE_HEADER( enkf_plot_tvector );
void enkf_plot_tvector_reset( enkf_plot_tvector_type * plot_tvector );
enkf_plot_tvector_type * enkf_plot_tvector_alloc( const enkf_config_node_type * config_node , int iens);
void enkf_plot_tvector_load( enkf_plot_tvector_type * plot_tvector , enkf_fs_type * fs , const char * user_key , state_enum state);
void * enkf_plot_tvector_load__( void * arg );
void enkf_plot_tvector_free( enkf_plot_tvector_type * plot_tvector );
void enkf_plot_tvector_iset( enkf_plot_tvector_type * plot_tvector , int index , time_t time , double value);
int enkf_plot_tvector_size( const enkf_plot_tvector_type * plot_tvector );
double enkf_plot_tvector_iget_value( const enkf_plot_tvector_type * plot_tvector , int index);
time_t enkf_plot_tvector_iget_time( const enkf_plot_tvector_type * plot_tvector , int index);
bool enkf_plot_tvector_iget_active( const enkf_plot_tvector_type * plot_tvector , int index);
bool enkf_plot_tvector_all_active( const enkf_plot_tvector_type * plot_tvector );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -67,7 +67,7 @@ typedef struct enkf_state_struct enkf_state_type;
bool enkf_state_resubmit_simulation( enkf_state_type * enkf_state , enkf_fs_type * fs , bool resample);
bool enkf_state_kill_simulation( const enkf_state_type * enkf_state );
void * enkf_state_load_from_forward_model_mt( void * arg );
void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs, const stringlist_type * param_list , bool force_init);
void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs, const stringlist_type * param_list , init_mode_enum init_mode);
void enkf_state_fread(enkf_state_type * , enkf_fs_type * fs , int , int , state_enum );
bool enkf_state_get_analyzed(const enkf_state_type * );
void enkf_state_set_analyzed(enkf_state_type * , bool );

View File

@ -129,8 +129,8 @@ typedef enum {UNDEFINED = 0 ,
typedef enum { REPORT_STEP_INCOMPATIBLE = 1,
LOAD_FAILURE = 2 } enkf_fw_load_result_enum;
LOAD_FAILURE = 2} enkf_fw_load_result_enum;
@ -244,6 +244,15 @@ typedef enum {
STATE_PARENT_FAILURE = 16
} realisation_state_enum;
typedef enum {
INIT_NONE = 0,
INIT_CONDITIONAL = 1,
INIT_FORCE = 2
} init_mode_enum;
typedef struct enkf_obs_struct enkf_obs_type;
@ -253,6 +262,7 @@ const char * enkf_types_get_var_name(enkf_var_type var_type);
ert_impl_type enkf_types_get_impl_type(const char * );
const char * enkf_types_get_impl_name(ert_impl_type );
ert_impl_type enkf_types_check_impl_type(const char * );
state_enum enkf_types_get_state_enum(const char *);
#ifdef __cplusplus
}

View File

@ -58,6 +58,7 @@ typedef struct ensemble_config_struct ensemble_config_type;
void ensemble_config_init(ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid , const ecl_sum_type * refcase);
void ensemble_config_free(ensemble_config_type * );
bool ensemble_config_has_key(const ensemble_config_type * , const char * );
bool ensemble_config_has_impl_type(const ensemble_config_type * config, const ert_impl_type impl_type);
bool ensemble_config_have_forward_init( const ensemble_config_type * ensemble_config );
void ensemble_config_init_internalization( ensemble_config_type * );

View File

@ -32,7 +32,9 @@ extern "C" {
state_map_type * state_map_alloc( );
state_map_type * state_map_fread_alloc( const char * filename );
state_map_type * state_map_fread_alloc_readonly( const char * filename );
state_map_type * state_map_alloc_copy( state_map_type * map );
bool state_map_is_readonly(const state_map_type * state_map);
void state_map_free( state_map_type * map );
int state_map_get_size( state_map_type * map);
realisation_state_enum state_map_iget( state_map_type * map , int index);
@ -47,6 +49,7 @@ extern "C" {
void state_map_set_from_inverted_mask(state_map_type * map, const bool_vector_type *mask , realisation_state_enum state);
void state_map_set_from_mask(state_map_type * map, const bool_vector_type *mask , realisation_state_enum state);
int state_map_count_matching( state_map_type * state_map , int mask);
bool state_map_legal_transition( realisation_state_enum state1 , realisation_state_enum state2);
UTIL_IS_INSTANCE_HEADER( state_map );

View File

@ -33,6 +33,7 @@
double summary_get(const summary_type * summary, int report_step , state_enum state);
bool summary_active_value( double value );
VOID_HAS_DATA_HEADER(summary);
UTIL_SAFE_CAST_HEADER(summary);

View File

@ -1,6 +1,171 @@
set( source_files ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c enkf_obs.c obs_data.c block_obs.c enkf_config_node.c field_config.c field.c ecl_static_kw.c enkf_state.c enkf_util.c enkf_node.c gen_kw_config.c gen_kw.c enkf_fs.c fs_driver.c meas_data.c summary_obs.c summary.c summary_config.c gen_data_config.c gen_data.c gen_common.c gen_obs.c enkf_sched.c enkf_serialize.c ecl_config.c enkf_defaults.c ensemble_config.c model_config.c site_config.c active_list.c obs_vector.c field_trans.c plain_driver.c local_ministep.c local_updatestep.c container_config.c container.c local_context.c local_config.c analysis_config.c misfit_ensemble.c misfit_member.c misfit_ts.c data_ranking.c misfit_ranking.c ranking_table.c fs_types.c block_fs_driver.c plot_config.c ert_template.c member_config.c enkf_analysis.c enkf_main.c local_dataset.c local_obsset.c surface.c surface_config.c enkf_plot_data.c enkf_plot_member.c qc_module.c ert_report_list.c enkf_plot_arg.c runpath_list.c ert_workflow_list.c analysis_iter_config.c enkf_main_jobs.c ecl_refcase_list.c local_obsdata_node.c local_obsdata.c obs_tstep_list.c pca_plot_data.c pca_plot_vector.c state_map.c cases_config.c state_map.c)
set( source_files
ert_report.c
time_map.c
rng_config.c
trans_func.c
enkf_types.c
enkf_obs.c
obs_data.c
block_obs.c
enkf_config_node.c
field_config.c
field.c
ecl_static_kw.c
enkf_state.c
enkf_util.c
enkf_node.c
gen_kw_config.c
gen_kw.c
enkf_fs.c
fs_driver.c
meas_data.c
summary_obs.c
summary.c
summary_config.c
gen_data_config.c
gen_data.c
gen_common.c
gen_obs.c
enkf_sched.c
enkf_serialize.c
ecl_config.c
enkf_defaults.c
ensemble_config.c
model_config.c
site_config.c
active_list.c
obs_vector.c
field_trans.c
plain_driver.c
local_ministep.c
local_updatestep.c
container_config.c
container.c
local_context.c
local_config.c
analysis_config.c
misfit_ensemble.c
misfit_member.c
misfit_ts.c
data_ranking.c
misfit_ranking.c
ranking_table.c
fs_types.c
block_fs_driver.c
plot_config.c
ert_template.c
member_config.c
enkf_analysis.c
enkf_main.c
local_dataset.c
local_obsset.c
surface.c
surface_config.c
enkf_plot_data.c
enkf_plot_tvector.c
qc_module.c
ert_report_list.c
runpath_list.c
ert_workflow_list.c
analysis_iter_config.c
enkf_main_jobs.c
ecl_refcase_list.c
local_obsdata_node.c
local_obsdata.c
obs_tstep_list.c
pca_plot_data.c
pca_plot_vector.c
state_map.c
cases_config.c
state_map.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 local_obsdata_node.h local_obsdata.h obs_tstep_list.h pca_plot_data.h pca_plot_vector.h state_map.h cases_config.h state_map.h)
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_tvector.h
qc_module.h
ert_report_list.h
runpath_list.h
ert_workflow_list.h
analysis_iter_config.h
ecl_refcase_list.h
local_obsdata_node.h
local_obsdata.h
obs_tstep_list.h
pca_plot_data.h
pca_plot_vector.h
state_map.h
cases_config.h
state_map.h)
add_library( enkf ${LIBRARY_TYPE} ${source_files} )

File diff suppressed because it is too large Load Diff

View File

@ -490,7 +490,12 @@ void enkf_config_node_update_gen_data( enkf_config_node_type * config_node,
config_node->var_type = var_type; /* Can be stuck with INVALID_VAR */
}
if (enkf_infile_fmt)
if (util_int_format_count(enkf_infile_fmt) != 1)
util_abort("%s: Fatal error when updating GEN_DATA key:%s the enkf_infile_fmt must contain exactly one %%d format specifier \n" , enkf_config_node_get_key( config_node ));
if (config_node->var_type != INVALID_VAR) {
gen_data_config_update(config_node->data , /* Special update */
config_node->var_type ,

View File

@ -235,14 +235,35 @@ struct enkf_fs_struct {
path_fmt_type * case_member_fmt;
path_fmt_type * case_tstep_fmt;
path_fmt_type * case_tstep_member_fmt;
int refcount;
};
/*****************************************************************/
UTIL_SAFE_CAST_FUNCTION( enkf_fs , ENKF_FS_TYPE_ID)
UTIL_IS_INSTANCE_FUNCTION( enkf_fs , ENKF_FS_TYPE_ID)
static int enkf_fs_incref( enkf_fs_type * fs ) {
fs->refcount++;
return fs->refcount;
}
static int enkf_fs_decref( enkf_fs_type * fs ) {
fs->refcount--;
if (fs->refcount < 0)
util_abort("%s: internal fuckup. The filesystem refcount:%d is < 0 \n",__func__ , fs->refcount);
return fs->refcount;
}
int enkf_fs_get_refcount( const enkf_fs_type * fs ) {
return fs->refcount;
}
static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point , bool read_only) {
enkf_fs_type * fs = util_malloc(sizeof * fs );
UTIL_TYPE_ID_INIT( fs , ENKF_FS_TYPE_ID );
@ -257,6 +278,7 @@ static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point , bool read_
fs->dynamic_analyzed = NULL;
fs->read_only = read_only;
fs->mount_point = util_alloc_string_copy( mount_point );
fs->refcount = 0;
if (mount_point == NULL)
util_abort("%s: fatal internal error: mount_point == NULL \n",__func__);
{
@ -473,6 +495,18 @@ static void enkf_fs_fread_state_map( enkf_fs_type * fs ) {
}
state_map_type * enkf_fs_alloc_readonly_state_map( const char * mount_point ) {
path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt( DEFAULT_CASE_PATH );
char * filename = path_fmt_alloc_file( path_fmt , false , mount_point , STATE_MAP_FILE);
state_map_type * state_map = state_map_fread_alloc_readonly( filename );
path_fmt_free( path_fmt );
free( filename );
return state_map;
}
static void enkf_fs_fread_misfit( enkf_fs_type * fs ) {
FILE * stream = enkf_fs_open_excase_file( fs , MISFIT_ENSEMBLE_FILE );
@ -492,11 +526,29 @@ static void enkf_fs_fwrite_misfit( enkf_fs_type * fs ) {
}
enkf_fs_type * enkf_fs_open( const char * mount_point , bool read_only) {
enkf_fs_type * fs = NULL;
FILE * stream = fs_driver_open_fstab( mount_point , false );
enkf_fs_type * enkf_fs_get_weakref( enkf_fs_type * fs ) {
return fs;
}
enkf_fs_type * enkf_fs_get_ref( enkf_fs_type * fs ) {
if (enkf_fs_is_instance( fs )) {
enkf_fs_incref( fs );
return fs;
} else {
util_abort("%s: tried to get enkf_fs reference from object which was not an existing enkf_fs reference\n",__func__);
return NULL;
}
}
enkf_fs_type * enkf_fs_mount( const char * mount_point , bool read_only) {
FILE * stream = fs_driver_open_fstab( mount_point , false );
if (stream != NULL) {
enkf_fs_type * fs = NULL;
fs_driver_assert_magic( stream );
fs_driver_assert_version( stream , mount_point );
{
@ -519,8 +571,10 @@ enkf_fs_type * enkf_fs_open( const char * mount_point , bool read_only) {
enkf_fs_fread_cases_config( fs );
enkf_fs_fread_state_map( fs );
enkf_fs_fread_misfit( fs );
return enkf_fs_get_ref( fs );
}
return fs;
return NULL;
}
@ -548,28 +602,36 @@ static void enkf_fs_free_driver(fs_driver_type * driver) {
}
void enkf_fs_close( enkf_fs_type * fs ) {
enkf_fs_fsync( fs );
enkf_fs_fwrite_misfit( fs );
void enkf_fs_umount( enkf_fs_type * fs ) {
if (!fs->read_only) {
enkf_fs_fsync( fs );
enkf_fs_fwrite_misfit( fs );
}
{
int refcount = enkf_fs_decref( fs );
enkf_fs_free_driver( fs->dynamic_forecast );
enkf_fs_free_driver( fs->dynamic_analyzed );
enkf_fs_free_driver( fs->parameter );
enkf_fs_free_driver( fs->eclipse_static );
enkf_fs_free_driver( fs->index );
util_safe_free( fs->case_name );
util_safe_free( fs->root_path );
util_safe_free( fs->mount_point );
path_fmt_free( fs->case_fmt );
path_fmt_free( fs->case_member_fmt );
path_fmt_free( fs->case_tstep_fmt );
path_fmt_free( fs->case_tstep_member_fmt );
state_map_free( fs->state_map );
time_map_free( fs->time_map );
cases_config_free( fs->cases_config );
free( fs );
if (refcount == 0) {
enkf_fs_free_driver( fs->dynamic_forecast );
enkf_fs_free_driver( fs->dynamic_analyzed );
enkf_fs_free_driver( fs->parameter );
enkf_fs_free_driver( fs->eclipse_static );
enkf_fs_free_driver( fs->index );
util_safe_free( fs->case_name );
util_safe_free( fs->root_path );
util_safe_free( fs->mount_point );
path_fmt_free( fs->case_fmt );
path_fmt_free( fs->case_member_fmt );
path_fmt_free( fs->case_tstep_fmt );
path_fmt_free( fs->case_tstep_member_fmt );
state_map_free( fs->state_map );
time_map_free( fs->time_map );
cases_config_free( fs->cases_config );
free( fs );
}
}
}
@ -761,6 +823,15 @@ const char * enkf_fs_get_case_name( const enkf_fs_type * fs ) {
return fs->case_name;
}
bool enkf_fs_is_read_only(const enkf_fs_type * fs) {
return fs->read_only;
}
void enkf_fs_set_writable(enkf_fs_type * fs) {
fs->read_only = false;
}
void enkf_fs_debug_fprintf( const enkf_fs_type * fs) {
printf("-----------------------------------------------------------------\n");
printf("fs...................: %p \n",fs );

View File

@ -104,6 +104,7 @@
#include <ert/enkf/pca_plot_data.h>
#include <ert/enkf/analysis_config.h>
#include <ert/enkf/analysis_iter_config.h>
#include <ert/enkf/field.h>
/**/
@ -206,10 +207,14 @@ void enkf_main_set_pre_clear_runpath( enkf_main_type * enkf_main , bool pre_clea
}
void enkf_main_set_eclbase( enkf_main_type * enkf_main , const char * eclbase_fmt) {
ecl_config_set_eclbase( enkf_main->ecl_config , eclbase_fmt);
for (int iens = 0; iens < enkf_main->ens_size; iens++)
enkf_state_update_eclbase( enkf_main->ensemble[iens] );
ui_return_type * enkf_main_set_eclbase( enkf_main_type * enkf_main , const char * eclbase_fmt) {
ui_return_type * ui_return = ecl_config_validate_eclbase( enkf_main->ecl_config , eclbase_fmt);
if (ui_return_get_status(ui_return) == UI_RETURN_OK) {
ecl_config_set_eclbase( enkf_main->ecl_config , eclbase_fmt );
for (int iens = 0; iens < enkf_main->ens_size; iens++)
enkf_state_update_eclbase(enkf_main->ensemble[iens]);
}
return ui_return;
}
void enkf_main_init_jobname( enkf_main_type * enkf_main) {
@ -224,8 +229,14 @@ void enkf_main_set_jobname( enkf_main_type * enkf_main , const char * jobname_fm
}
ui_return_type * enkf_main_validata_refcase( const enkf_main_type * enkf_main , const char * refcase_path) {
return ecl_config_validate_refcase( enkf_main->ecl_config , refcase_path );
}
bool enkf_main_set_refcase( enkf_main_type * enkf_main , const char * refcase_path) {
bool set_refcase = ecl_config_load_refcase( enkf_main->ecl_config , refcase_path );
model_config_set_refcase( enkf_main->model_config , ecl_config_get_refcase( enkf_main->ecl_config ));
ensemble_config_set_refcase( enkf_main->ensemble_config , ecl_config_get_refcase( enkf_main->ecl_config ));
@ -378,9 +389,13 @@ static void enkf_main_update_num_cpu( enkf_main_type * enkf_main ) {
}
void enkf_main_set_data_file( enkf_main_type * enkf_main , const char * data_file ) {
ecl_config_set_data_file( enkf_main->ecl_config , data_file );
enkf_main_update_num_cpu( enkf_main );
ui_return_type * enkf_main_set_data_file( enkf_main_type * enkf_main , const char * data_file ) {
ui_return_type * ui_return = ecl_config_validate_data_file( enkf_main->ecl_config , data_file );
if (ui_return_get_status(ui_return) == UI_RETURN_OK) {
ecl_config_set_data_file( enkf_main->ecl_config , data_file );
enkf_main_update_num_cpu( enkf_main );
}
return ui_return;
}
@ -408,7 +423,9 @@ void enkf_main_free(enkf_main_type * enkf_main){
enkf_obs_free(enkf_main->obs);
ranking_table_free( enkf_main->ranking_table );
enkf_main_free_ensemble( enkf_main );
if (enkf_main->dbase != NULL) enkf_fs_close( enkf_main->dbase );
if (enkf_main->dbase != NULL)
enkf_fs_umount( enkf_main->dbase );
util_safe_free( enkf_main->current_fs_case );
if (log_is_open( enkf_main->logh ))
@ -1022,7 +1039,8 @@ void enkf_main_init_PC( const enkf_main_type * enkf_main ,
state_enum state = FORECAST;
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
state_map_type * state_map = enkf_fs_get_state_map( fs );
bool_vector_type * ens_mask = bool_vector_alloc(0 , false );
const int total_ens_size = enkf_main_get_ensemble_size(enkf_main);
bool_vector_type * ens_mask = bool_vector_alloc(total_ens_size , false );
obs_data_type * obs_data = obs_data_alloc();
int_vector_type * ens_active_list;
meas_data_type * meas_data;
@ -1086,7 +1104,6 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_
matrix_type * PC = matrix_alloc(1,1);
matrix_type * PC_obs = matrix_alloc(1,1);
enkf_main_init_PC( enkf_main , obs_data , truncation_or_ncomp , PC , PC_obs );
pca_plot_data = pca_plot_data_alloc( local_obsdata_get_name( obs_data ) , PC , PC_obs );
@ -1205,10 +1222,6 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main ,
if (analysis_module_check_option( module , ANALYSIS_UPDATE_A)){
if (analysis_module_check_option( module , ANALYSIS_ITERABLE)){
int iteration = cases_config_get_iteration_number(enkf_fs_get_cases_config(src_fs));
char iteration_str[15];
sprintf(iteration_str,"%d",iteration);
analysis_module_set_var( module , "NUM_ITER", iteration_str);
analysis_module_updateA( module , localA , S , R , dObs , E , D );
}
else
@ -1363,6 +1376,7 @@ static bool enkf_main_UPDATE(enkf_main_type * enkf_main , const int_vector_type
if (target_state_map != source_state_map) {
state_map_set_from_inverted_mask( target_state_map , ens_mask , STATE_PARENT_FAILURE);
state_map_set_from_mask( target_state_map , ens_mask , STATE_INITIALIZED );
enkf_fs_fsync( target_fs );
}
}
@ -1384,11 +1398,23 @@ void enkf_main_assimilation_update(enkf_main_type * enkf_main , const int_vector
}
bool enkf_main_smoother_update(enkf_main_type * enkf_main , const int_vector_type * step_list , enkf_fs_type * target_fs) {
static bool enkf_main_smoother_update__(enkf_main_type * enkf_main , const int_vector_type * step_list , enkf_fs_type * target_fs) {
return enkf_main_UPDATE( enkf_main , step_list , target_fs , 0 , SMOOTHER_UPDATE );
}
bool enkf_main_smoother_update(enkf_main_type * enkf_main , enkf_fs_type * target_fs) {
int stride = 1;
time_map_type * time_map = enkf_fs_get_time_map( enkf_main_get_fs( enkf_main ));
int_vector_type * step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , time_map_get_last_step( time_map ) , stride);
bool update_done = enkf_main_smoother_update__( enkf_main , step_list , target_fs );
int_vector_free( step_list );
return update_done;
}
static void enkf_main_report_run_failure( const enkf_main_type * enkf_main , int iens) {
@ -1448,13 +1474,18 @@ static void enkf_main_monitor_job_queue ( const enkf_main_type * enkf_main) {
}
}
void enkf_main_run_post_workflow( enkf_main_type * enkf_main ) {
qc_module_run_workflow( enkf_main->qc_module , enkf_main );
}
/**
If all simulations have completed successfully the function will
return true, otherwise it will return false.
*/
static void enkf_main_run_step(enkf_main_type * enkf_main ,
static bool enkf_main_run_step(enkf_main_type * enkf_main ,
run_mode_type run_mode ,
bool_vector_type * iactive ,
int load_start , /* For internalizing results, and the first step in the update when merging. */
@ -1471,10 +1502,10 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
ecl_config_assert_restart( enkf_main_get_ecl_config( enkf_main ) );
{
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
bool verbose_queue = enkf_main->verbose;
int max_internal_submit = model_config_get_max_internal_submit(enkf_main->model_config);
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
bool verbose_queue = enkf_main->verbose;
int max_internal_submit = model_config_get_max_internal_submit(enkf_main->model_config);
const int active_ens_size = util_int_min( bool_vector_size( iactive ) , enkf_main_get_ensemble_size( enkf_main ));
int job_size;
int iens;
@ -1514,9 +1545,9 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module );
runpath_list_clear( runpath_list );
for (iens = 0; iens < ens_size; iens++) {
for (iens = 0; iens < active_ens_size; iens++) {
enkf_state_type * enkf_state = enkf_main->ensemble[iens];
if (bool_vector_safe_iget(iactive , iens)) {
if (bool_vector_iget(iactive , iens)) {
int load_start = step1;
if (step1 > 0)
load_start++;
@ -1576,7 +1607,7 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
subset (with offset > 0) of realisations are simulated. */
if (run_mode != INIT_ONLY) {
bool totalOK = true;
for (iens = 0; iens < ens_size; iens++) {
for (iens = 0; iens < active_ens_size; iens++) {
if (bool_vector_iget(iactive , iens)) {
run_status_type run_status = enkf_state_get_simple_run_status( enkf_main->ensemble[iens] );
@ -1596,12 +1627,12 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
}
}
enkf_fs_fsync( enkf_main->dbase );
if (totalOK) {
if (totalOK)
log_add_fmt_message(enkf_main->logh , 1 , NULL , "All jobs complete and data loaded.");
if (run_mode != ENKF_ASSIMILATION)
qc_module_run_workflow( enkf_main->qc_module , enkf_main );
}
}
return totalOK;
} else
return false;
}
}
@ -1654,11 +1685,20 @@ void * enkf_main_get_enkf_config_node_type(const ensemble_config_type * ensemble
*/
void enkf_main_init_run( enkf_main_type * enkf_main, run_mode_type run_mode) {
const ext_joblist_type * joblist = site_config_get_installed_jobs( enkf_main->site_config);
model_config_set_enkf_sched( enkf_main->model_config , joblist , run_mode );
void enkf_main_init_run( enkf_main_type * enkf_main, const bool_vector_type * iactive , run_mode_type run_mode , init_mode_enum init_mode) {
{
const ext_joblist_type * joblist = site_config_get_installed_jobs( enkf_main->site_config);
model_config_set_enkf_sched( enkf_main->model_config , joblist , run_mode );
}
enkf_main_init_internalization(enkf_main , run_mode);
if (iactive) {
const int active_ens_size = util_int_min( bool_vector_size( iactive ) , enkf_main_get_ensemble_size( enkf_main ));
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , active_ens_size - 1 , init_mode );
stringlist_free( param_list );
}
}
@ -1669,25 +1709,18 @@ void enkf_main_run_exp(enkf_main_type * enkf_main ,
bool simulate ,
int init_step_parameters ,
int start_report ,
state_enum start_state ,
bool initialize) {
state_enum start_state) {
bool force_init = false;
int ens_size = enkf_main_get_ensemble_size( enkf_main );
init_mode_enum init_mode = INIT_CONDITIONAL;
run_mode_type run_mode = simulate ? ENSEMBLE_EXPERIMENT : INIT_ONLY;
{
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
if (initialize)
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1, force_init);
stringlist_free( param_list );
}
enkf_main_init_run( enkf_main , run_mode );
enkf_main_init_run( enkf_main , iactive , run_mode , init_mode);
{
int load_start = start_report;
state_enum init_state_parameter = start_state;
state_enum init_state_dynamic = start_state;
enkf_main_run_step(enkf_main , run_mode , iactive , load_start , init_step_parameters , init_state_parameter , init_state_dynamic , start_report , -1);
if (enkf_main_run_step(enkf_main , run_mode , iactive , load_start , init_step_parameters , init_state_parameter , init_state_dynamic , start_report , -1))
enkf_main_run_post_workflow(enkf_main);
}
}
@ -1701,16 +1734,10 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
if (!analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
bool force_init = false;
int ens_size = enkf_main_get_ensemble_size( enkf_main );
{
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init );
stringlist_free( param_list );
}
init_mode_enum init_mode = INIT_CONDITIONAL;
bool rerun = analysis_config_get_rerun( enkf_main->analysis_config );
int rerun_start = analysis_config_get_rerun_start( enkf_main->analysis_config );
enkf_main_init_run( enkf_main , ENKF_ASSIMILATION);
enkf_main_init_run( enkf_main , iactive , ENKF_ASSIMILATION , init_mode);
{
bool analyzed_start = false;
bool prev_enkf_on;
@ -1806,76 +1833,71 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
}
void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_name , bool rerun) {
bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_enum init_mode) {
enkf_main_init_run( enkf_main , iactive , ENSEMBLE_EXPERIMENT , init_mode);
return enkf_main_run_step( enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0 );
}
void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_name , bool_vector_type * iactive , bool rerun) {
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
if (!analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
bool force_init = false;
int ens_size = enkf_main_get_ensemble_size( enkf_main );
if (enkf_main_run_simple_step( enkf_main , iactive , INIT_CONDITIONAL))
enkf_main_run_post_workflow(enkf_main);
{
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init);
stringlist_free( param_list );
}
{
bool_vector_type * iactive = bool_vector_alloc( ens_size , true );
enkf_main_init_run( enkf_main , ENSEMBLE_EXPERIMENT);
enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0);
{
bool update_done;
time_map_type * time_map = enkf_fs_get_time_map( enkf_main_get_fs( enkf_main ));
enkf_fs_type * target_fs = enkf_main_get_alt_fs( enkf_main , target_fs_name , false , true );
{
int stride = 1;
int_vector_type * step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , time_map_get_last_step( time_map ) , stride);
update_done = enkf_main_smoother_update( enkf_main , step_list , target_fs );
int_vector_free( step_list );
}
if (rerun) {
/*
IFF a rerun path has been added with the RERUN_PATH config
key the model_config object will select that runpath as the
currently active one. If no path has been created with the
RERUN_PATH config option the model_config_select_runpath()
call will fail silently.
The runpath select with this call will remain the currently
active runpath for the remaining part of this program
invocation.
*/
if (update_done) {
enkf_main_set_fs( enkf_main , target_fs , target_fs_name);
model_config_select_runpath( enkf_main_get_model_config( enkf_main ) , RERUN_PATH_KEY );
enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0 );
} else
fprintf(stderr,"** Warning: the analysis update failed - no rerun started.\n");
enkf_fs_type * target_fs = enkf_main_mount_alt_fs( enkf_main , target_fs_name , false , true );
bool update_done = enkf_main_smoother_update( enkf_main , target_fs );
if (rerun) {
/*
IFF a rerun path has been added with the RERUN_PATH config
key the model_config object will select that runpath as the
currently active one. If no path has been created with the
RERUN_PATH config option the model_config_select_runpath()
call will fail silently.
The runpath select with this call will remain the currently
active runpath for the remaining part of this program
invocation.
*/
if (update_done) {
enkf_main_set_fs( enkf_main , target_fs , target_fs_name);
model_config_select_runpath( enkf_main_get_model_config( enkf_main ) , RERUN_PATH_KEY );
if (enkf_main_run_simple_step(enkf_main , iactive , INIT_NONE ))
enkf_main_run_post_workflow(enkf_main);
} else {
fprintf(stderr,"** Warning: the analysis update failed - no rerun started.\n");
enkf_fs_umount( target_fs );
}
}
bool_vector_free( iactive );
}
} else
fprintf(stderr,"** ERROR: The normal smoother should not be combined with an iterable analysis module\n");
}
bool enkf_main_iterate_smoother(enkf_main_type * enkf_main, int step2, int iteration_number, analysis_iter_config_type * iter_config, int_vector_type * step_list, bool_vector_type * iactive, model_config_type * model_config){
const char * target_fs_name = analysis_iter_config_iget_case( iter_config , iteration_number+1 );
bool enkf_main_iterate_smoother(enkf_main_type * enkf_main, int iteration_number, const char * target_fs_name , bool_vector_type * iactive) {
const int step1 = 0;
const int step2 = enkf_main_get_history_length( enkf_main );
bool updateOK = false;
int_vector_type * step_list = int_vector_alloc(0, 0);
for (int step = step1; step <= step2; step++)
int_vector_append(step_list, step);
if (target_fs_name == NULL){
fprintf(stderr,"Sorry: the updated ensemble will overwrite the current case in the iterated ensemble smoother.");
updateOK = enkf_main_smoother_update(enkf_main , step_list , enkf_main_get_fs(enkf_main));
updateOK = enkf_main_smoother_update__(enkf_main , step_list , enkf_main_get_fs(enkf_main));
} else {
enkf_fs_type * target_fs = enkf_main_get_alt_fs(enkf_main , target_fs_name , false , true );
updateOK = enkf_main_smoother_update(enkf_main , step_list , target_fs );
enkf_main_set_fs(enkf_main , target_fs , enkf_fs_get_case_name( target_fs ));
enkf_fs_type * target_fs = enkf_main_mount_alt_fs(enkf_main , target_fs_name , false , true );
updateOK = enkf_main_smoother_update__(enkf_main , step_list , target_fs );
enkf_main_set_fs(enkf_main , target_fs , NULL);
cases_config_set_int(enkf_fs_get_cases_config(target_fs), "iteration_number", iteration_number+1);
}
if (updateOK) {
/*
const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt(iter_config, iteration_number);
if (runpath_fmt != NULL ) {
char * runpath_key = util_alloc_sprintf("runpath-%d", 999);
@ -1883,32 +1905,28 @@ bool enkf_main_iterate_smoother(enkf_main_type * enkf_main, int step2, int itera
model_config_select_runpath(model_config, runpath_key);
free(runpath_key);
}
enkf_main_run_exp(enkf_main , iactive , true , step1 , step1 , FORECAST, false);
*/
enkf_main_run_step( enkf_main , ENSEMBLE_EXPERIMENT , iactive , step1 , step1 , FORECAST , FORECAST , step1 , -1 );
}
int_vector_free(step_list);
return updateOK;
}
void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int step2) {
void enkf_main_run_iterated_ES(enkf_main_type * enkf_main) {
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
if (analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
const int ens_size = enkf_main_get_ensemble_size(enkf_main);
model_config_type * model_config = enkf_main_get_model_config(enkf_main);
analysis_iter_config_type * iter_config = analysis_config_get_iter_config(analysis_config);
int_vector_type * step_list = int_vector_alloc(0, 0);
bool_vector_type * iactive = bool_vector_alloc(ens_size , true);
const int step1 = 0;
int iter = 0;
int num_iter = analysis_iter_config_get_num_iterations(iter_config);
{
for (int step = step1; step <= step2; step++)
int_vector_append(step_list, step);
}
{
const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt(iter_config, iter);
@ -1921,18 +1939,20 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int step2) {
}
}
enkf_main_run_exp(enkf_main, iactive, true, step1, step1, FORECAST, true);
while (true)
{
if (iter == num_iter)
break;
enkf_main_init_run(enkf_main , iactive , ENSEMBLE_EXPERIMENT , INIT_CONDITIONAL);
if (enkf_main_run_step(enkf_main, ENSEMBLE_EXPERIMENT , iactive , step1 , step1 , FORECAST , FORECAST , step1 , -1))
enkf_main_run_post_workflow(enkf_main);
while (true) {
const char * target_fs_name = analysis_iter_config_iget_case( iter_config , iter );
if (iter == num_iter)
break;
if (enkf_main_iterate_smoother(enkf_main, step2, iter, iter_config, step_list, iactive, model_config))
iter++;
else
break;
}
int_vector_free(step_list);
if (enkf_main_iterate_smoother(enkf_main, iter, target_fs_name , iactive))
iter++;
else
break;
}
bool_vector_free(iactive);
} else
fprintf(stderr,"** ERROR: The current analysis module:%s can not be used for iterations \n",
@ -1942,21 +1962,16 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int step2) {
void enkf_main_run_one_more_iteration(enkf_main_type * enkf_main, int step2) {
model_config_type * model_config = enkf_main_get_model_config( enkf_main );
const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
analysis_iter_config_type * iter_config = analysis_config_get_iter_config( analysis_config );
//model_config_type * model_config = enkf_main_get_model_config( enkf_main );
//const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
//analysis_iter_config_type * iter_config = analysis_config_get_iter_config( analysis_config );
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
cases_config_type * case_config = enkf_fs_get_cases_config( fs );
int iteration_number = cases_config_get_iteration_number( case_config );
const int step1 = 0;
int_vector_type * step_list = int_vector_alloc(0,0);
//const int step1 = 0;
bool_vector_type * iactive = bool_vector_alloc(0 , true);
{
for (int step=step1; step <= step2; step++)
int_vector_append( step_list , step );
}
enkf_main_iterate_smoother(enkf_main, step2, iteration_number, iter_config, step_list, iactive, model_config);
enkf_main_iterate_smoother(enkf_main, iteration_number, "ONE-MORE" , iactive);
}
/*****************************************************************/
@ -1982,8 +1997,9 @@ void enkf_main_copy_ensemble(enkf_main_type * enkf_main ,
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
{
enkf_fs_type * source_fs = enkf_main_get_alt_fs( enkf_main , source_case , true , false );
enkf_fs_type * target_fs = enkf_main_get_alt_fs( enkf_main , target_case , false , true );
enkf_fs_type * source_fs = enkf_main_mount_alt_fs( enkf_main , source_case , true , false );
enkf_fs_type * target_fs = enkf_main_mount_alt_fs( enkf_main , target_case , false , true );
{
int * ranking_permutation;
int inode , src_iens;
@ -2016,9 +2032,8 @@ void enkf_main_copy_ensemble(enkf_main_type * enkf_main ,
if (ranking_permutation == NULL)
free( ranking_permutation );
}
enkf_main_close_alt_fs( enkf_main , source_fs );
enkf_main_close_alt_fs( enkf_main , target_fs );
enkf_fs_umount( source_fs );
enkf_fs_umount( target_fs );
}
}
@ -2046,7 +2061,7 @@ void enkf_main_initialize_from_existing__(enkf_main_type * enkf_main ,
const int target_report_step = 0;
const state_enum target_state = ANALYZED;
const char * target_case = NULL;
const char * target_case = enkf_main->current_fs_case;
enkf_main_copy_ensemble(enkf_main ,
source_case ,
@ -2087,19 +2102,19 @@ static void * enkf_main_initialize_from_scratch_mt(void * void_arg) {
const stringlist_type * param_list = arg_pack_iget_const_ptr( arg_pack , 1 );
int iens1 = arg_pack_iget_int( arg_pack , 2 );
int iens2 = arg_pack_iget_int( arg_pack , 3 );
bool force_init = arg_pack_iget_bool( arg_pack , 4 );
init_mode_enum init_mode = arg_pack_iget_int( arg_pack , 4 );
int iens;
for (iens = iens1; iens < iens2; iens++) {
enkf_state_type * state = enkf_main_iget_state( enkf_main , iens);
enkf_state_initialize( state , enkf_main_get_fs( enkf_main ) , param_list , force_init);
enkf_state_initialize( state , enkf_main_get_fs( enkf_main ) , param_list , init_mode);
}
return NULL;
}
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, bool force_init) {
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, init_mode_enum init_mode) {
int num_cpu = 4;
thread_pool_type * tp = thread_pool_alloc( num_cpu , true );
int ens_sub_size = (iens2 - iens1 + 1) / num_cpu;
@ -2123,7 +2138,7 @@ void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const string
arg_pack_append_int( arg_list[i] , start_iens );
arg_pack_append_int( arg_list[i] , end_iens );
}
arg_pack_append_bool( arg_list[i] , force_init );
arg_pack_append_int( arg_list[i] , init_mode );
thread_pool_add_job( tp , enkf_main_initialize_from_scratch_mt , arg_list[i]);
}
thread_pool_join( tp );
@ -2480,7 +2495,7 @@ enkf_main_type * enkf_main_alloc_empty( ) {
enkf_main->rng_config = rng_config_alloc( );
enkf_main->site_config = site_config_alloc_empty();
enkf_main->ensemble_config = ensemble_config_alloc_empty();
enkf_main->ecl_config = ecl_config_alloc_empty();
enkf_main->ecl_config = ecl_config_alloc();
enkf_main->plot_config = plot_config_alloc_default();
enkf_main->ranking_table = ranking_table_alloc( 0 );
enkf_main->obs = enkf_obs_alloc( );
@ -2639,22 +2654,8 @@ void enkf_main_create_fs( enkf_main_type * enkf_main , const char * fs_path) {
}
*/
static void enkf_main_link_current_fs__( enkf_main_type * enkf_main , const char * case_path) {
const char * ens_path = model_config_get_enspath( enkf_main->model_config);
/* 1: Create a symlink pointing to the currently open case. */
{
char * current_link = util_alloc_filename( ens_path , CURRENT_CASE , NULL );
{
if (util_entry_exists( current_link ))
unlink( current_link );
symlink( case_path , current_link );
}
free( current_link );
}
/* 2: Update a small text file with the name of the host currently
static void update_case_log(enkf_main_type * enkf_main , const char * case_path) {
/* : Update a small text file with the name of the host currently
running ert, the pid number of the process, the active case
and when it started.
@ -2663,6 +2664,9 @@ static void enkf_main_link_current_fs__( enkf_main_type * enkf_main , const char
is in the file. For that reason we open with mode 'a' instead
of 'w'.
*/
const char * ens_path = model_config_get_enspath( enkf_main->model_config);
{
int buffer_size = 256;
char * current_host = util_alloc_filename( ens_path , CASE_LOG , NULL );
@ -2694,13 +2698,13 @@ static void enkf_main_link_current_fs__( enkf_main_type * enkf_main , const char
static void enkf_main_close_fs( enkf_main_type * enkf_main ) {
enkf_fs_close( enkf_main->dbase );
enkf_fs_umount( enkf_main->dbase );
enkf_main->dbase = NULL;
}
enkf_fs_type * enkf_main_get_fs(const enkf_main_type * enkf_main) {
return enkf_main->dbase;
return enkf_fs_get_weakref( enkf_main->dbase );
}
@ -2729,20 +2733,96 @@ void enkf_main_gen_data_special( enkf_main_type * enkf_main ) {
}
void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const char * case_path ) {
if (enkf_main->dbase != fs) {
if (enkf_main->dbase != NULL)
enkf_main_close_fs( enkf_main );
enkf_main->dbase = fs;
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 , "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 );
}
static void enkf_main_write_current_case_file( const enkf_main_type * enkf_main, const char * case_path) {
const char * ens_path = model_config_get_enspath( enkf_main->model_config);
const char * base = CURRENT_CASE_FILE;
char * current_case_file = util_alloc_filename(ens_path , base, NULL);
FILE * stream = util_fopen( current_case_file , "w");
fprintf(stream , case_path );
util_fclose(stream);
free(current_case_file);
}
static void enkf_main_update_current_case( enkf_main_type * enkf_main , const char * case_path) {
enkf_main_write_current_case_file(enkf_main, case_path);
update_case_log(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 , "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 );
}
static bool enkf_main_current_case_file_exists( const enkf_main_type * enkf_main) {
const char * ens_path = model_config_get_enspath( enkf_main->model_config);
char * current_case_file = util_alloc_filename(ens_path, CURRENT_CASE_FILE, NULL);
bool exists = util_file_exists(current_case_file);
free(current_case_file);
return exists;
}
char* enkf_main_read_alloc_current_case_name(const enkf_main_type * enkf_main) {
char * current_case = NULL;
const char * ens_path = model_config_get_enspath( enkf_main->model_config);
char * current_case_file = util_alloc_filename(ens_path, CURRENT_CASE_FILE, NULL);
if (enkf_main_current_case_file_exists(enkf_main)) {
FILE * stream = util_fopen( current_case_file , "r");
current_case = util_fscanf_alloc_token(stream);
util_fclose(stream);
} else {
util_abort("%s: File: storage/current_case not found, aborting! \n",__func__);
}
free(current_case_file);
return current_case;
}
/**
The enkf_fs instances employ a simple reference counting
scheme. The main point with this system is to avoid opening the
full timesystem more than necessary (this is quite compute
intensive). This is essentially achieved by:
1. Create new fs instances by using the function
enkf_main_mount_alt_fs() - depending on the input arguments
this will either create a new enkf_fs instance or it will
just return a pointer to currently open fs instance; with an
increased refcount.
2. When you are finished with working with filesystem pointer
call enkf_fs_unmount() - this will reduce the refcount with
one, and eventually discard the complete datastructure when
the refcount has reached zero.
3. By using the function enkf_main_get_fs() /
enkf_fs_get_weakref() you get a pointer to the current fs
instance WITHOUT INCREASING THE REFCOUNT. This means that
scope calling one of these functions does not get any
ownership to the enkf_fs instance.
The enkf_main instance will take ownership of the enkf_fs instance;
this implies that the calling scope must have proper ownership of
the fs instance which is passed in. The return value from
enkf_main_get_fs() can NOT be used as input to this function; this
is not checked for in any way - but the crash will be horrible if
this is not adhered to.
*/
void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const char * case_path /* Can be NULL */) {
if (!case_path)
case_path = enkf_fs_get_case_name( fs );
if (enkf_main->dbase != NULL)
enkf_main_close_fs( enkf_main );
enkf_main->dbase = fs;
enkf_main_update_current_case(enkf_main, case_path);
}
stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main ) {
stringlist_type * case_list = stringlist_alloc_new( );
@ -2757,7 +2837,7 @@ stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main ) {
dp = readdir( ens_dir );
if (dp != NULL) {
if (!(util_string_equal( dp->d_name , ".") || util_string_equal(dp->d_name , ".."))) {
if (!util_string_equal( dp->d_name , CURRENT_CASE)) {
if (!util_string_equal( dp->d_name , CURRENT_CASE_FILE)) {
char * full_path = util_alloc_filename( ens_path , dp->d_name , NULL);
if (util_is_directory( full_path ))
stringlist_append_copy( case_list , dp->d_name );
@ -2773,50 +2853,99 @@ stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main ) {
return case_list;
}
void enkf_main_create_fs( const enkf_main_type * enkf_main , const char * case_path ) {
char * new_mount_point = enkf_main_alloc_mount_point( enkf_main , case_path );
void enkf_main_close_alt_fs(const enkf_main_type * enkf_main , enkf_fs_type * fs) {
if (fs != enkf_main->dbase)
enkf_fs_close( fs );
enkf_fs_create_fs( new_mount_point,
model_config_get_dbase_type( enkf_main->model_config ) ,
model_config_get_dbase_args( enkf_main->model_config ));
free( new_mount_point );
}
enkf_fs_type * enkf_main_get_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create) {
enkf_fs_type * alt_fs = enkf_main->dbase;
if (case_path != NULL) {
char * new_mount_point = enkf_main_alloc_mount_point( enkf_main , case_path );
const char * current_mount_point = NULL;
if (enkf_main->dbase != NULL)
current_mount_point = enkf_fs_get_mount_point( enkf_main->dbase );
bool enkf_main_case_is_current(const enkf_main_type * enkf_main , const char * case_path) {
char * mount_point = enkf_main_alloc_mount_point( enkf_main , case_path );
const char * current_mount_point = NULL;
bool is_current;
if (enkf_main->dbase != NULL)
current_mount_point = enkf_fs_get_mount_point( enkf_main->dbase );
is_current = util_string_equal( mount_point , current_mount_point );
free( mount_point );
return is_current;
}
/*
All the return values from this function must be closed with
enkf_fs_umount(). If the return value is just a reference to the
current existing case the function will increase the reference count
on that enkf_fs instance, and the corresponding enkf_usmount will
decrease it again.
*/
enkf_fs_type * enkf_main_mount_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create) {
if (enkf_main_case_is_current( enkf_main , case_path )) {
// Fast path - we just return a reference to the currently selected case;
// with increased refcount.
if(!read_only) {
enkf_fs_type * fs = enkf_main->dbase;
enkf_fs_set_writable(fs);
}
return enkf_fs_get_ref( enkf_main->dbase );
} else {
// We have asked for an alterantive fs - must mount and possibly create that first.
enkf_fs_type * new_fs = NULL;
if (case_path != NULL) {
char * new_mount_point = enkf_main_alloc_mount_point( enkf_main , case_path );
if (!util_string_equal( new_mount_point , current_mount_point )) {
if (!enkf_fs_exists( new_mount_point )) {
if (create)
enkf_fs_create_fs( new_mount_point,
model_config_get_dbase_type( enkf_main->model_config ) ,
model_config_get_dbase_args( enkf_main->model_config ));
enkf_main_create_fs( enkf_main , case_path );
}
alt_fs = enkf_fs_open( new_mount_point , read_only );
new_fs = enkf_fs_mount( new_mount_point , read_only );
free( new_mount_point );
}
free( new_mount_point );
return new_fs;
}
return alt_fs;
}
state_map_type * enkf_main_alloc_readonly_state_map( const enkf_main_type * enkf_main , const char * case_path) {
char * mount_point = enkf_main_alloc_mount_point( enkf_main , case_path );
state_map_type * state_map = enkf_fs_alloc_readonly_state_map( mount_point );
free( mount_point );
return state_map;
}
void enkf_main_select_fs( enkf_main_type * enkf_main , const char * case_path ) {
enkf_fs_type * new_fs = enkf_main_get_alt_fs( enkf_main , case_path , false , true );
if (new_fs != NULL)
enkf_main_set_fs( enkf_main , new_fs , case_path);
if (enkf_main_case_is_current( enkf_main , case_path ))
return; /* We have tried to select the currently selected case - just return. */
else {
const char * ens_path = model_config_get_enspath( enkf_main->model_config );
util_exit("%s: select filesystem %s:%s failed \n",__func__ , ens_path , case_path );
enkf_fs_type * new_fs = enkf_main_mount_alt_fs( enkf_main , case_path , false , true );
if (enkf_main->dbase == new_fs)
util_abort("%s : return reference to current FS in situation where that should not happen.\n",__func__);
if (new_fs != NULL)
enkf_main_set_fs( enkf_main , new_fs , case_path);
else {
const char * ens_path = model_config_get_enspath( enkf_main->model_config );
util_exit("%s: select filesystem %s:%s failed \n",__func__ , ens_path , case_path );
}
}
}
/*
Return a weak reference - i.e. the refocunt is not increased.
*/
const char * enkf_main_get_current_fs( const enkf_main_type * enkf_main ) {
return enkf_main->current_fs_case;
}
@ -2838,21 +2967,26 @@ void enkf_main_user_select_fs(enkf_main_type * enkf_main , const char * input_ca
if (root_version == -1 || root_version == 105) {
if (input_case == NULL) {
char * current_mount_point = util_alloc_filename( ens_path , CURRENT_CASE , NULL);
if (enkf_fs_exists( current_mount_point )) {
// We will mount the case under the 'current' link; we use
// readlink to get hold of the actual target before calling the
// enkf_main_select_fs() function
if (enkf_main_current_case_file_exists(enkf_main)) {
char * current_case = enkf_main_read_alloc_current_case_name(enkf_main);
enkf_main_select_fs(enkf_main, current_case);
free (current_case);
} else if (enkf_fs_exists( current_mount_point ) && util_is_link( current_mount_point )) {
/*If the current_case file does not exists, but the 'current' symlink does we use readlink to
get hold of the actual target before calling the enkf_main_select_fs() function. We then
write the current_case file and delete the symlink.*/
char * target_case = util_alloc_atlink_target( ens_path , CURRENT_CASE );
enkf_main_select_fs( enkf_main , target_case ); // Selecting (a new) default case
enkf_main_select_fs( enkf_main , target_case );
unlink(current_mount_point);
enkf_main_write_current_case_file(enkf_main, target_case);
free( target_case );
free( current_mount_point );
} else
enkf_main_select_fs( enkf_main , DEFAULT_CASE ); // Selecting (a new) default case
free( current_mount_point );
} else
enkf_main_select_fs( enkf_main , input_case );
} else {
} else {
fprintf(stderr,"Sorry: the filesystem located in %s must be upgraded before the current ERT version can read it.\n" , ens_path);
exit(1);
}
@ -3582,11 +3716,6 @@ const ext_joblist_type * enkf_main_get_installed_jobs( const enkf_main_type * en
}
enkf_plot_data_type * enkf_main_alloc_plot_data( enkf_main_type * enkf_main ) {
enkf_plot_data_type * plot_data = enkf_plot_data_alloc( ecl_config_get_start_date( enkf_main_get_ecl_config( enkf_main )));
return plot_data;
}
/*****************************************************************/
@ -3644,10 +3773,10 @@ bool enkf_main_is_initialized( const enkf_main_type * enkf_main , bool_vector_ty
}
bool enkf_main_case_is_initialized( const enkf_main_type * enkf_main , const char * case_name , bool_vector_type * __mask) {
enkf_fs_type * fs = enkf_main_get_alt_fs(enkf_main , case_name , true , false);
enkf_fs_type * fs = enkf_main_mount_alt_fs(enkf_main , case_name , true , false);
if (fs) {
bool initialized = enkf_main_case_is_initialized__(enkf_main , fs , __mask);
enkf_main_close_alt_fs(enkf_main , fs);
enkf_fs_umount( fs );
return initialized;
} else
return false;
@ -3676,6 +3805,7 @@ void enkf_main_install_SIGNALS(void) {
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. */
signal(SIGILL , util_abort_signal); /* Signal illegal instruction. */
}
@ -3827,3 +3957,76 @@ void enkf_main_run_workflows( enkf_main_type * enkf_main , const stringlist_type
}
bool enkf_main_export_field(const enkf_main_type * enkf_main,
const char * kw,
const char * path,
int_vector_type * realization_list,
field_file_format_type file_type,
int report_step,
state_enum state) {
bool ret = false;
if (!util_char_in('%', strlen(path), path) || !util_char_in('d', strlen(path), path)) {
printf("EXPORT FIELD: There must be a %%d in the file name\n");
return false;
}
const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
const enkf_config_node_type * config_node = NULL;
bool node_found = false;
if (ensemble_config_has_key(ensemble_config, kw)) {
config_node = ensemble_config_get_node(ensemble_config, kw);
if (config_node && enkf_config_node_get_impl_type(config_node) == FIELD) {
node_found = true;
} else
printf("Did not find a FIELD %s node\n", kw);
} else
printf("Ensemble config does not have key %s\n", kw);
if (node_found) {
enkf_node_type * node = NULL;
int iens;
for (iens = 0; iens < int_vector_size(realization_list); ++iens) {
int realization_no = int_vector_iget(realization_list, iens);
enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
node_id_type node_id = {.report_step = report_step , .iens = realization_no , .state = state };
node = enkf_state_get_node(enkf_main->ensemble[realization_no] , kw);
if (node) {
if (enkf_node_try_load(node , fs , node_id)) {
path_fmt_type * export_path = path_fmt_alloc_path_fmt( path );
char * filename = path_fmt_alloc_path( export_path , false , realization_no);
path_fmt_free(export_path);
{
char * path;
util_alloc_file_components(filename , &path , NULL , NULL);
if (path != NULL) {
util_make_path( path );
free( path );
}
}
{
const field_type * field = enkf_node_value_ptr(node);
const bool output_transform = true;
field_export(field , filename , NULL , file_type , output_transform);
ret = true;
}
free(filename);
} else
printf("%s : enkf_node_try_load returned returned false \n", __func__);
} else
printf("%s : enkf_state_get_node returned NULL for parameters %d, %s \n", __func__, realization_no, kw);
}
}
if (ret)
printf("Successful export of FIELD %s\n", kw);
else
printf("Errors during export of FIELD %s\n", kw);
return ret;
}

View File

@ -17,8 +17,11 @@
*/
#include <ert/util/stringlist.h>
#include <ert/util/string_util.h>
#include <ert/util/int_vector.h>
#include <ert/enkf/enkf_main.h>
#include <ert/enkf/field_config.h>
void * enkf_main_exit_JOB(void * self , const stringlist_type * args ) {
@ -48,7 +51,7 @@ void * enkf_main_ensemble_run_JOB( void * self , const stringlist_type * args )
// if (stringlist_get_size( args )
bool_vector_iset( iactive , ens_size - 1 , true );
enkf_main_run_exp( enkf_main , iactive , true , 0 , 0 , ANALYZED , true);
enkf_main_run_exp( enkf_main , iactive , true , 0 , 0 , ANALYZED);
return NULL;
}
@ -56,12 +59,12 @@ void * enkf_main_ensemble_run_JOB( void * self , const stringlist_type * args )
void * enkf_main_smoother_JOB( void * self , const stringlist_type * args ) {
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
int ens_size = enkf_main_get_ensemble_size( enkf_main );
bool_vector_type * iactive = bool_vector_alloc( 0 , true );
bool_vector_type * iactive = bool_vector_alloc( ens_size , true );
bool rerun = true;
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);
enkf_main_run_smoother( enkf_main , target_case , iactive , rerun);
bool_vector_free( iactive );
return NULL;
}
@ -70,10 +73,9 @@ void * enkf_main_iterated_smoother_JOB( void * self , const stringlist_type * ar
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
int ens_size = enkf_main_get_ensemble_size( enkf_main );
bool_vector_type * iactive = bool_vector_alloc( 0 , true );
int last_step = enkf_main_get_history_length( enkf_main );
bool_vector_iset( iactive , ens_size - 1 , true );
enkf_main_run_iterated_ES( enkf_main , last_step);
enkf_main_run_iterated_ES( enkf_main);
return NULL;
}
@ -109,3 +111,90 @@ void * enkf_main_scale_obs_std_JOB(void * self, const stringlist_type * args ) {
}
return NULL;
}
void * enkf_main_export_field_JOB(void * self, const stringlist_type * args) {
const char * field = stringlist_iget(args, 0);
const char * file_name = stringlist_iget(args, 1);
int_vector_type * realization_list = string_util_alloc_active_list(""); //Realizations range: rest of optional input arguments
int report_step = 0;
util_sscanf_int(stringlist_iget(args,2), &report_step);
state_enum state = enkf_types_get_state_enum(stringlist_iget(args, 3));
char * range_str = stringlist_alloc_joined_substring( args , 4 , stringlist_get_size(args), "");
string_util_update_active_list(range_str, realization_list);
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
if (0 == int_vector_size(realization_list)) {
const char * range_str = util_alloc_sprintf("0-%d", enkf_main_get_ensemble_size( enkf_main )-1);
string_util_update_active_list(range_str, realization_list);
}
field_file_format_type file_type = field_config_default_export_format(file_name);
if ((RMS_ROFF_FILE == file_type) || (ECL_GRDECL_FILE == file_type))
enkf_main_export_field(enkf_main, field, file_name, realization_list, file_type, report_step, state);
else
printf("EXPORT_FIELD filename argument: File extension must be either .roff or .grdecl\n");
int_vector_free(realization_list);
return NULL;
}
void * enkf_main_export_field_to_RMS_JOB(void * self, const stringlist_type * args) {
const char * field = stringlist_iget(args, 0);
const char * file_name = stringlist_iget(args, 1);
int_vector_type * realization_list = string_util_alloc_active_list(""); //Realizations range: rest of optional input arguments
int report_step = 0;
util_sscanf_int(stringlist_iget(args,2), &report_step);
state_enum state = enkf_types_get_state_enum(stringlist_iget(args, 3));
char * range_str = stringlist_alloc_joined_substring( args , 4 , stringlist_get_size(args), "");
string_util_update_active_list(range_str, realization_list);
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
if (0 == int_vector_size(realization_list)) {
const char * range_str = util_alloc_sprintf("0-%d", enkf_main_get_ensemble_size( enkf_main )-1);
string_util_update_active_list(range_str, realization_list);
}
char * file_name_with_ext = util_alloc_string_copy(file_name);
char *ext = strrchr(file_name_with_ext , '.');
if (ext == NULL) {
file_name_with_ext = util_strcat_realloc(file_name_with_ext, ".roff");
}
enkf_main_export_field(enkf_main, field, file_name_with_ext, realization_list, RMS_ROFF_FILE, report_step, state);
int_vector_free(realization_list);
return NULL;
}
void * enkf_main_export_field_to_ECL_JOB(void * self, const stringlist_type * args) {
const char * field = stringlist_iget(args, 0);
const char * file_name = stringlist_iget(args, 1);
int_vector_type * realization_list = string_util_alloc_active_list(""); //Realizations range: rest of optional input arguments
int report_step = 0;
util_sscanf_int(stringlist_iget(args,2), &report_step);
state_enum state = enkf_types_get_state_enum(stringlist_iget(args, 3));
char * range_str = stringlist_alloc_joined_substring( args , 4 , stringlist_get_size(args), "");
string_util_update_active_list(range_str, realization_list);
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
if (0 == int_vector_size(realization_list)) {
const char * range_str = util_alloc_sprintf("0-%d", enkf_main_get_ensemble_size( enkf_main )-1);
string_util_update_active_list(range_str, realization_list);
}
char * file_name_with_ext = util_alloc_string_copy(file_name);
char *ext = strrchr(file_name_with_ext , '.');
if (ext == NULL)
file_name_with_ext = util_strcat_realloc(file_name_with_ext, ".grdecl");
enkf_main_export_field(enkf_main, field, file_name_with_ext, realization_list, ECL_GRDECL_FILE, report_step, state);
int_vector_free(realization_list);
return NULL;
}

View File

@ -1,133 +0,0 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'enkf_plot_arg.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 <stdbool.h>
#include <ert/util/util.h>
#include <ert/util/double_vector.h>
#include <ert/util/time_t_vector.h>
#include <ert/enkf/enkf_plot_arg.h>
#define ENKF_PLOT_ARG_ID 6771861
struct enkf_plot_arg_struct {
UTIL_TYPE_ID_DECLARATION;
bool time_mode;
bool days_valid;
time_t start_time;
time_t_vector_type * time_vector;
double_vector_type * arg_vector;
};
static UTIL_SAFE_CAST_FUNCTION( enkf_plot_arg , ENKF_PLOT_ARG_ID )
enkf_plot_arg_type * enkf_plot_arg_alloc( bool time_mode , time_t start_time) {
enkf_plot_arg_type * plot_arg = util_malloc( sizeof * plot_arg);
UTIL_TYPE_ID_INIT( plot_arg , ENKF_PLOT_ARG_ID );
plot_arg->arg_vector = double_vector_alloc(0,0);
plot_arg->time_vector = time_t_vector_alloc(0,0);
enkf_plot_arg_reset( plot_arg , time_mode , start_time );
return plot_arg;
}
void enkf_plot_arg_reset( enkf_plot_arg_type * plot_arg , bool time_mode , time_t start_time) {
plot_arg->start_time = start_time;
plot_arg->time_mode = time_mode;
plot_arg->days_valid = false;
double_vector_reset( plot_arg->arg_vector );
time_t_vector_reset( plot_arg->time_vector );
}
void enkf_plot_arg_free( enkf_plot_arg_type * plot_arg ) {
time_t_vector_free( plot_arg->time_vector );
double_vector_free( plot_arg->arg_vector );
}
void enkf_plot_arg_free__( void * arg ) {
enkf_plot_arg_type * plot_arg = enkf_plot_arg_safe_cast( arg );
enkf_plot_arg_free( plot_arg );
}
static void enkf_plot_arg_assert_time_mode( const enkf_plot_arg_type * plot_arg ) {
if (!plot_arg->time_mode)
util_abort("%s: trying to update plot_arg instance created with time_mode==false with time_t argument\n",__func__);
}
static void enkf_plot_arg_assert_not_time_mode( const enkf_plot_arg_type * plot_arg ) {
if (plot_arg->time_mode)
util_abort("%s: trying to update plot_arg instance created with time_mode==true with non-time argument\n",__func__);
}
void enkf_plot_arg_append_time( enkf_plot_arg_type * plot_arg , time_t time) {
enkf_plot_arg_assert_time_mode( plot_arg );
time_t_vector_append( plot_arg->time_vector , time );
plot_arg->days_valid = false;
}
void enkf_plot_arg_append( enkf_plot_arg_type * plot_arg , double value) {
enkf_plot_arg_assert_time_mode( plot_arg );
double_vector_append( plot_arg->arg_vector , value );
}
/*****************************************************************/
static void enkf_plot_arg_assert_days( enkf_plot_arg_type * plot_arg ) {
enkf_plot_arg_assert_time_mode( plot_arg );
if (!plot_arg->days_valid) {
int i;
double_vector_reset( plot_arg->arg_vector );
for (i=0; i < time_t_vector_size( plot_arg->time_vector ); i++) {
time_t itime = time_t_vector_iget( plot_arg->time_vector , i);
double days = util_difftime_days( plot_arg->start_time , itime );
double_vector_iset( plot_arg->arg_vector , i , days);
}
plot_arg->days_valid = true;
}
}
const double_vector_type * enkf_plot_arg_get_vector( const enkf_plot_arg_type * plot_arg ) {
enkf_plot_arg_assert_not_time_mode( plot_arg );
return plot_arg->arg_vector;
}
const time_t_vector_type * enkf_plot_arg_get_time_t_vector( const enkf_plot_arg_type * plot_arg ) {
enkf_plot_arg_assert_time_mode( plot_arg );
return plot_arg->time_vector;
}
const double_vector_type * enkf_plot_arg_get_days_vector( enkf_plot_arg_type * plot_arg ) {
enkf_plot_arg_assert_days( plot_arg );
return plot_arg->arg_vector;
}

View File

@ -21,172 +21,134 @@
#include <ert/util/double_vector.h>
#include <ert/util/vector.h>
#include <ert/util/thread_pool.h>
#include <ert/util/type_macros.h>
#include <ert/enkf/enkf_fs.h>
#include <ert/enkf/member_config.h>
#include <ert/enkf/enkf_plot_member.h>
#include <ert/enkf/enkf_plot_arg.h>
#include <ert/enkf/enkf_plot_tvector.h>
#include <ert/enkf/enkf_plot_data.h>
#include <ert/enkf/state_map.h>
#define ENKF_PLOT_DATA_TYPE_ID 3331063
struct enkf_plot_data_struct {
time_t start_time;
bool time_mode;
enkf_plot_arg_type * shared_arg;
/*-----------------------------------------------------------------*/
int alloc_size;
int size;
enkf_plot_member_type ** ensemble;
UTIL_TYPE_ID_DECLARATION;
const enkf_config_node_type * config_node;
int size;
enkf_plot_tvector_type ** ensemble;
arg_pack_type ** work_arg;
};
static void enkf_plot_data_resize( enkf_plot_data_type * plot_data , int new_size ) {
plot_data->ensemble = util_realloc( plot_data->ensemble , sizeof * plot_data->ensemble * new_size );
{
if (new_size != plot_data->size) {
int iens;
for (iens = plot_data->alloc_size; iens < new_size; iens++)
plot_data->ensemble[iens] = enkf_plot_member_alloc( plot_data->shared_arg , plot_data->start_time );
if (new_size < plot_data->size) {
for (iens = new_size; iens < plot_data->size; iens++) {
enkf_plot_tvector_free( plot_data->ensemble[iens] );
arg_pack_free( plot_data->work_arg[iens] );
}
}
plot_data->ensemble = util_realloc( plot_data->ensemble , new_size * sizeof * plot_data->ensemble);
plot_data->work_arg = util_realloc( plot_data->work_arg , new_size * sizeof * plot_data->work_arg);
if (new_size > plot_data->size) {
for (iens = plot_data->size; iens < new_size; iens++) {
plot_data->ensemble[iens] = enkf_plot_tvector_alloc( plot_data->config_node , iens);
plot_data->work_arg[iens] = arg_pack_alloc();
}
}
plot_data->size = new_size;
}
plot_data->alloc_size = new_size;
}
static void enkf_plot_data_reset( enkf_plot_data_type * plot_data ) {
int iens;
for (iens = 0; iens < plot_data->size; iens++) {
enkf_plot_tvector_reset( plot_data->ensemble[iens] );
arg_pack_clear( plot_data->work_arg[iens] );
}
}
void enkf_plot_data_free( enkf_plot_data_type * plot_data ) {
int iens;
for (iens = 0; iens < plot_data->alloc_size; iens++) {
if ( plot_data->ensemble[iens] != NULL)
enkf_plot_member_free( plot_data->ensemble[iens] );
for (iens = 0; iens < plot_data->size; iens++) {
enkf_plot_tvector_free( plot_data->ensemble[iens] );
arg_pack_free( plot_data->work_arg[iens]);
}
if (plot_data->shared_arg != NULL)
enkf_plot_arg_free( plot_data->shared_arg );
free( plot_data->work_arg );
free( plot_data->ensemble );
free( plot_data );
}
UTIL_IS_INSTANCE_FUNCTION( enkf_plot_data , ENKF_PLOT_DATA_TYPE_ID )
enkf_plot_data_type * enkf_plot_data_alloc( time_t start_time ) {
enkf_plot_data_type * enkf_plot_data_alloc( const enkf_config_node_type * config_node ) {
enkf_plot_data_type * plot_data = util_malloc( sizeof * plot_data);
plot_data->start_time = start_time;
plot_data->time_mode = false;
plot_data->alloc_size = 0;
plot_data->size = 0;
plot_data->ensemble = NULL;
enkf_plot_data_resize( plot_data , 32 );
plot_data->shared_arg = NULL;
UTIL_TYPE_ID_INIT( plot_data , ENKF_PLOT_DATA_TYPE_ID );
plot_data->config_node = config_node;
plot_data->size = 0;
plot_data->ensemble = NULL;
plot_data->work_arg = NULL;
return plot_data;
}
enkf_plot_tvector_type * enkf_plot_data_iget( const enkf_plot_data_type * plot_data , int index) {
return plot_data->ensemble[index];
}
void * enkf_plot_data_load__( void *arg ) {
arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
enkf_plot_data_type * plot_data = arg_pack_iget_ptr( arg_pack , 0 );
enkf_config_node_type * config_node = arg_pack_iget_ptr( arg_pack , 1 );
enkf_fs_type * fs = arg_pack_iget_ptr( arg_pack , 2 );
const char * user_key = arg_pack_iget_const_ptr( arg_pack , 3 );
state_enum state = arg_pack_iget_int( arg_pack , 4 );
int step1 = arg_pack_iget_int( arg_pack , 5 );
int step2 = arg_pack_iget_int( arg_pack , 6 );
const int_vector_type * iens_list = arg_pack_iget_ptr( arg_pack , 7 );
int index1 = arg_pack_iget_int( arg_pack , 8 );
int index2 = arg_pack_iget_int( arg_pack , 9 );
enkf_node_type * enkf_node = enkf_node_alloc( config_node ); // Shared node used for all loading.
for (int index = index1; index < index2; index++) {
int iens = int_vector_iget( iens_list , index );
if (iens >= plot_data->alloc_size)
// This must be protected by a lock of some sort ....
enkf_plot_data_resize( plot_data , 2*iens + 1);
{
enkf_plot_member_type * plot_member = plot_data->ensemble[iens];
enkf_plot_member_safe_cast( plot_member );
enkf_plot_member_load( plot_member , enkf_node , fs , user_key , iens , state , plot_data->shared_arg , plot_data->time_mode , step1 , step2 );
}
}
enkf_node_free( enkf_node );
return NULL;
int enkf_plot_data_get_size( const enkf_plot_data_type * plot_data ) {
return plot_data->size;
}
void enkf_plot_data_load( enkf_plot_data_type * plot_data ,
enkf_config_node_type * config_node ,
enkf_fs_type * fs ,
const char * user_key ,
const char * index_key ,
state_enum state ,
const bool_vector_type * active ,
bool time_mode,
int step1 , int step2) {
int iens;
int_vector_type * iens_list = int_vector_alloc( 0 , 0 );
plot_data->time_mode = time_mode;
const bool_vector_type * input_mask) {
state_map_type * state_map = enkf_fs_get_state_map( fs );
int ens_size = state_map_get_size( state_map );
bool_vector_type * mask;
if (input_mask)
mask = bool_vector_alloc_copy( input_mask );
else
mask = bool_vector_alloc( ens_size , false );
state_map_select_matching( state_map , mask , STATE_HAS_DATA );
enkf_plot_data_resize( plot_data , ens_size );
enkf_plot_data_reset( plot_data );
{
int ens_size = bool_vector_size( active );
const int num_cpu = 4;
thread_pool_type * tp = thread_pool_alloc( num_cpu , true );
for (int iens = 0; iens < ens_size ; iens++) {
if (bool_vector_iget( mask , iens)) {
// thread_pool here?
enkf_plot_tvector_type * vector = enkf_plot_data_iget( plot_data , iens );
arg_pack_type * work_arg = plot_data->work_arg[iens];
for (iens = 0; iens < ens_size; iens++) {
if (bool_vector_iget( active , iens ))
int_vector_append( iens_list , iens );
}
}
{
int active_size = int_vector_size( iens_list );
int num_threads = 4;
int block_size = active_size / num_threads;
arg_pack_type ** arg_list = util_calloc( num_threads , sizeof * arg_list );
thread_pool_type * tp = thread_pool_alloc( num_threads , true );
if (block_size == 0) /* Fewer tasks than threads */
block_size = 1;
for (int i=0; i < num_threads; i++) {
arg_list[i] = arg_pack_alloc();
arg_pack_append_ptr( work_arg , vector );
arg_pack_append_ptr( work_arg , fs );
arg_pack_append_const_ptr( work_arg , index_key );
arg_pack_append_int( work_arg , state );
arg_pack_append_ptr( arg_list[i] , plot_data );
arg_pack_append_ptr( arg_list[i] , config_node );
arg_pack_append_ptr( arg_list[i] , fs );
arg_pack_append_const_ptr( arg_list[i] , user_key );
arg_pack_append_int( arg_list[i] , state );
arg_pack_append_int( arg_list[i] , step1 );
arg_pack_append_int( arg_list[i] , step2 );
{
int index1 = i * block_size;
int index2 = index1 + block_size;
if (index1 < active_size) {
if (index2 > active_size)
index2 = active_size;
}
arg_pack_append_ptr( arg_list[i] , iens_list );
arg_pack_append_int( arg_list[i] , index1 );
arg_pack_append_int( arg_list[i] , index2 );
thread_pool_add_job( tp , enkf_plot_tvector_load__ , work_arg );
}
thread_pool_add_job(tp , enkf_plot_data_load__ , arg_list[i]);
}
thread_pool_join( tp );
thread_pool_free( tp );
for (int i=0; i < num_threads; i++)
arg_pack_free( arg_list[i] );
free( arg_list );
}
int_vector_free( iens_list );
bool_vector_free( mask );
}

View File

@ -1,147 +0,0 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'enkf_plot_member.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 <ert/util/util.h>
#include <ert/util/double_vector.h>
#include <ert/util/time_t_vector.h>
#include <ert/enkf/enkf_plot_member.h>
#include <ert/enkf/enkf_plot_arg.h>
#define ENKF_PLOT_MEMBER_ID 6111861
struct enkf_plot_member_struct {
UTIL_TYPE_ID_DECLARATION;
double_vector_type * data;
enkf_plot_arg_type * arg;
time_t start_time;
bool time_mode;
bool shared_arg;
};
UTIL_SAFE_CAST_FUNCTION( enkf_plot_member , ENKF_PLOT_MEMBER_ID )
enkf_plot_member_type * enkf_plot_member_alloc( enkf_plot_arg_type * shared_arg , time_t start_time) {
enkf_plot_member_type * plot_member = util_malloc( sizeof * plot_member);
UTIL_TYPE_ID_INIT( plot_member , ENKF_PLOT_MEMBER_ID );
plot_member->data = double_vector_alloc( 0 , 0 );
plot_member->shared_arg = true;
plot_member->start_time = start_time;
enkf_plot_member_reset( plot_member , shared_arg , false );
return plot_member;
}
void enkf_plot_member_reset( enkf_plot_member_type * plot_member , enkf_plot_arg_type * shared_arg , bool time_mode) {
if (!plot_member->shared_arg)
enkf_plot_arg_free( plot_member->arg );
plot_member->time_mode = time_mode;
if (shared_arg == NULL) {
plot_member->arg = enkf_plot_arg_alloc( plot_member->time_mode , plot_member->start_time );
plot_member->shared_arg = false;
} else {
plot_member->arg = shared_arg;
plot_member->shared_arg = true;
}
}
void enkf_plot_member_free( enkf_plot_member_type * plot_member ) {
double_vector_free( plot_member->data );
if (!plot_member->shared_arg)
enkf_plot_arg_free( plot_member->arg );
free( plot_member );
}
void enkf_plot_member_free__( void * arg ) {
enkf_plot_member_type * plot_member = enkf_plot_member_safe_cast( arg );
enkf_plot_member_free( plot_member );
}
void enkf_plot_member_load( enkf_plot_member_type * plot_member ,
enkf_node_type * enkf_node ,
enkf_fs_type * fs ,
const char * user_key ,
int iens ,
state_enum state ,
enkf_plot_arg_type * shared_arg ,
bool time_mode ,
int step1 , int step2) {
enkf_plot_member_reset( plot_member , shared_arg , time_mode );
if (enkf_node_vector_storage( enkf_node ))
enkf_node_user_get_vector(enkf_node , fs , user_key , iens , state , plot_member->data);
else {
if (shared_arg != NULL)
util_abort("%s: implementation error - shared arg can ONLY be used with vector nodes\n",__func__);
enkf_plot_arg_reset( plot_member->arg , time_mode , plot_member->start_time);
int step;
node_id_type node_id = {.iens = iens,
.state = state,
.report_step = 0 };
for (step = step1 ; step <= step2; step++) {
double value;
node_id.report_step = step;
if (enkf_node_user_get(enkf_node , fs , user_key , node_id , &value)) {
//??
//??
}
}
}
/*if (enkf_node_vector_storage( enkf_node )) {
enkf_node_user_get_vector(enkf_node , fs , user_key , iens , state , plot_member->data);
time_t_vector_memcpy( plot_member->sim_time , member_config_get_sim_time_ref( plot_member->member_config , fs));
if (step1 > 0) {
time_t_vector_idel_block( plot_member->sim_time , 0 , step1 );
double_vector_idel_block( plot_member->data , 0 , step1 );
}
} else {
int step;
node_id_type node_id = {.iens = iens,
.state = state,
.report_step = 0 };
double_vector_reset( plot_member->data );
time_t_vector_reset( plot_member->sim_time );
for (step = step1 ; step <= step2; step++) {
double value;
if (enkf_node_user_get(enkf_node , fs , user_key , node_id , &value)) {
double_vector_append( plot_member->data , value);
time_t_vector_append( plot_member->sim_time , member_config_iget_sim_time( plot_member->member_config , step , fs ));
}
}
}
*/
}

View File

@ -0,0 +1,181 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'enkf_plot_tvector.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 <ert/util/util.h>
#include <ert/util/double_vector.h>
#include <ert/util/time_t_vector.h>
#include <ert/util/bool_vector.h>
#include <ert/enkf/enkf_plot_tvector.h>
#include <ert/enkf/enkf_config_node.h>
#include <ert/enkf/enkf_node.h>
#include <ert/enkf/summary.h>
#define ENKF_PLOT_TVECTOR_ID 6111861
struct enkf_plot_tvector_struct {
UTIL_TYPE_ID_DECLARATION;
double_vector_type * data;
double_vector_type * work;
time_t_vector_type * time;
bool_vector_type * mask;
const enkf_config_node_type * config_node;
int iens;
bool summary_mode;
};
UTIL_SAFE_CAST_FUNCTION( enkf_plot_tvector , ENKF_PLOT_TVECTOR_ID )
UTIL_IS_INSTANCE_FUNCTION( enkf_plot_tvector , ENKF_PLOT_TVECTOR_ID )
void enkf_plot_tvector_reset( enkf_plot_tvector_type * plot_tvector ) {
double_vector_reset( plot_tvector->data );
time_t_vector_reset( plot_tvector->time );
bool_vector_reset( plot_tvector->mask );
}
enkf_plot_tvector_type * enkf_plot_tvector_alloc( const enkf_config_node_type * config_node , int iens) {
enkf_plot_tvector_type * plot_tvector = util_malloc( sizeof * plot_tvector);
UTIL_TYPE_ID_INIT( plot_tvector , ENKF_PLOT_TVECTOR_ID );
plot_tvector->data = double_vector_alloc( 0 , 0 );
plot_tvector->time = time_t_vector_alloc(-1 , 0);
plot_tvector->mask = bool_vector_alloc( false , 0 );
plot_tvector->work = double_vector_alloc(0,0);
plot_tvector->iens = iens;
plot_tvector->config_node = config_node;
if (enkf_config_node_get_impl_type( config_node ) == SUMMARY)
plot_tvector->summary_mode = true;
else
plot_tvector->summary_mode = false;
return plot_tvector;
}
void enkf_plot_tvector_free( enkf_plot_tvector_type * plot_tvector ) {
double_vector_free( plot_tvector->data );
double_vector_free( plot_tvector->work );
time_t_vector_free( plot_tvector->time );
bool_vector_free( plot_tvector->mask );
}
bool enkf_plot_tvector_all_active( const enkf_plot_tvector_type * plot_tvector ) {
bool all_active = true;
for (int i=0; i < bool_vector_size( plot_tvector->mask ); i++)
all_active = all_active && bool_vector_iget(plot_tvector->mask , i );
return all_active;
}
int enkf_plot_tvector_size( const enkf_plot_tvector_type * plot_tvector ) {
return bool_vector_size( plot_tvector->mask );
}
void enkf_plot_tvector_iset( enkf_plot_tvector_type * plot_tvector , int index , time_t time , double value) {
time_t_vector_iset( plot_tvector->time , index , time );
bool active_value = true;
/* This is to handle holes in the summary vector storage. */
if (plot_tvector->summary_mode && !summary_active_value( value ))
active_value = false;
if (active_value) {
double_vector_iset( plot_tvector->data , index , value );
bool_vector_iset( plot_tvector->mask , index , true );
} else
bool_vector_iset( plot_tvector->mask , index , false );
}
double enkf_plot_tvector_iget_value( const enkf_plot_tvector_type * plot_tvector , int index) {
return double_vector_iget( plot_tvector->data , index);
}
time_t enkf_plot_tvector_iget_time( const enkf_plot_tvector_type * plot_tvector , int index) {
return time_t_vector_iget( plot_tvector->time , index);
}
bool enkf_plot_tvector_iget_active( const enkf_plot_tvector_type * plot_tvector , int index) {
return bool_vector_iget( plot_tvector->mask , index );
}
void enkf_plot_tvector_load( enkf_plot_tvector_type * plot_tvector ,
enkf_fs_type * fs ,
const char * index_key ,
state_enum state) {
time_map_type * time_map = enkf_fs_get_time_map( fs );
int step1 = 0;
int step2 = time_map_get_last_step( time_map );
enkf_node_type * work_node = enkf_node_alloc( plot_tvector->config_node );
if (enkf_node_vector_storage( work_node )) {
enkf_node_user_get_vector(work_node , fs , index_key , plot_tvector->iens , state , plot_tvector->work);
for (int step = 0; step < time_map_get_size(time_map); step++)
enkf_plot_tvector_iset( plot_tvector ,
step ,
time_map_iget( time_map , step ) ,
double_vector_iget( plot_tvector->work , step ));
} else {
int step;
node_id_type node_id = {.iens = plot_tvector->iens,
.state = state,
.report_step = 0 };
for (step = step1 ; step <= step2; step++) {
double value;
node_id.report_step = step;
if (enkf_node_user_get(work_node , fs , index_key , node_id , &value)) {
enkf_plot_tvector_iset( plot_tvector ,
step ,
time_map_iget( time_map , step ) ,
value );
}
}
}
enkf_node_free( work_node );
}
void * enkf_plot_tvector_load__( void * arg ) {
arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
enkf_plot_tvector_type * tvector = arg_pack_iget_ptr( arg_pack , 0 );
enkf_fs_type * fs = arg_pack_iget_ptr( arg_pack , 1 );
const char * index_key = arg_pack_iget_ptr( arg_pack , 2 );
state_enum state = arg_pack_iget_int( arg_pack , 3 );
enkf_plot_tvector_load( tvector , fs , index_key , state );
return NULL;
}

View File

@ -280,30 +280,30 @@ static void shared_info_free(shared_info_type * shared_info) {
/** Helper classes complete - starting on the enkf_state proper object. */
/*****************************************************************/
void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs , const stringlist_type * param_list, bool force_init) {
int iens = enkf_state_get_iens( enkf_state );
state_map_type * state_map = enkf_fs_get_state_map( fs );
realisation_state_enum current_state = state_map_iget(state_map, iens);
if ((current_state == STATE_PARENT_FAILURE) && (force_init == false))
return;
else {
state_enum init_state = ANALYZED;
void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs , const stringlist_type * param_list, init_mode_enum init_mode) {
if (init_mode != INIT_NONE) {
int iens = enkf_state_get_iens( enkf_state );
state_map_type * state_map = enkf_fs_get_state_map( fs );
realisation_state_enum current_state = state_map_iget(state_map, iens);
if ((current_state == STATE_PARENT_FAILURE) && (init_mode != INIT_FORCE))
return;
else {
state_enum init_state = ANALYZED;
for (int ip = 0; ip < stringlist_get_size(param_list); ip++)
{
enkf_node_type * param_node = enkf_state_get_node(enkf_state, stringlist_iget(param_list, ip));
node_id_type node_id = { .report_step = 0, .iens = iens, .state = init_state };
bool has_data = enkf_node_has_data(param_node, fs, node_id);
if (force_init || (has_data == false) || (current_state == STATE_LOAD_FAILURE))
{
if (enkf_node_initialize(param_node, iens, enkf_state->rng)) {
enkf_node_store(param_node, fs, true, node_id);
for (int ip = 0; ip < stringlist_get_size(param_list); ip++)
{
enkf_node_type * param_node = enkf_state_get_node(enkf_state, stringlist_iget(param_list, ip));
node_id_type node_id = { .report_step = 0, .iens = iens, .state = init_state };
bool has_data = enkf_node_has_data(param_node, fs, node_id);
if ((init_mode == INIT_FORCE) || (has_data == false) || (current_state == STATE_LOAD_FAILURE)) {
if (enkf_node_initialize(param_node, iens, enkf_state->rng))
enkf_node_store(param_node, fs, true, node_id);
}
}
}
state_map_update_matching(state_map , iens , STATE_UNDEFINED | STATE_LOAD_FAILURE , STATE_INITIALIZED);
enkf_fs_fsync(fs);
}
state_map_update_matching(state_map , iens , STATE_UNDEFINED | STATE_LOAD_FAILURE , STATE_INITIALIZED);
enkf_fs_fsync(fs);
}
}
@ -312,7 +312,6 @@ void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs , co
/**
The run_info->run_path variable is in general NULL. It is given a
valid value before a simulation starts, holds on to that value
@ -603,76 +602,79 @@ const char * enkf_state_get_eclbase( const enkf_state_type * enkf_state ) {
static ecl_sum_type * enkf_state_load_ecl_sum(const enkf_state_type * enkf_state , stringlist_type * messages , int * result) {
const run_info_type * run_info = enkf_state->run_info;
const ecl_config_type * ecl_config = enkf_state->shared_info->ecl_config;
const bool fmt_file = ecl_config_get_formatted(ecl_config);
const char * eclbase = enkf_state_get_eclbase( enkf_state );
if (ecl_config_active( ecl_config )) {
const run_info_type * run_info = enkf_state->run_info;
const bool fmt_file = ecl_config_get_formatted(ecl_config);
const char * eclbase = enkf_state_get_eclbase( enkf_state );
stringlist_type * data_files = stringlist_alloc_new();
char * header_file = ecl_util_alloc_exfilename(run_info->run_path , eclbase , ECL_SUMMARY_HEADER_FILE , fmt_file , -1);
char * unified_file = ecl_util_alloc_exfilename(run_info->run_path , eclbase , ECL_UNIFIED_SUMMARY_FILE , fmt_file , -1);
ecl_sum_type * summary = NULL;
stringlist_type * data_files = stringlist_alloc_new();
char * header_file = ecl_util_alloc_exfilename(run_info->run_path , eclbase , ECL_SUMMARY_HEADER_FILE , fmt_file , -1);
char * unified_file = ecl_util_alloc_exfilename(run_info->run_path , eclbase , ECL_UNIFIED_SUMMARY_FILE , fmt_file , -1);
ecl_sum_type * summary = NULL;
/* Should we load from a unified summary file, or from several non-unified files? */
if (unified_file != NULL)
/* Use unified file: */
stringlist_append_ref( data_files , unified_file);
else {
/* Use several non unified files. */
/* Bypassing the query to model_config_load_results() */
int report_step = run_info->load_start;
if (report_step == 0)
report_step++; // Ignore looking for the .S0000 summary file (it does not exist).
while (true) {
char * summary_file = ecl_util_alloc_exfilename(run_info->run_path , eclbase , ECL_SUMMARY_FILE , fmt_file , report_step);
/* Should we load from a unified summary file, or from several non-unified files? */
if (unified_file != NULL)
/* Use unified file: */
stringlist_append_ref( data_files , unified_file);
else {
/* Use several non unified files. */
/* Bypassing the query to model_config_load_results() */
int report_step = run_info->load_start;
if (report_step == 0)
report_step++; // Ignore looking for the .S0000 summary file (it does not exist).
while (true) {
char * summary_file = ecl_util_alloc_exfilename(run_info->run_path , eclbase , ECL_SUMMARY_FILE , fmt_file , report_step);
if (summary_file != NULL)
stringlist_append_owned_ref( data_files , summary_file);
else
/*
We stop the loading at first 'hole' in the series of summary files;
the internalize layer must report failure if we are missing data.
*/
break;
if (summary_file != NULL)
stringlist_append_owned_ref( data_files , summary_file);
else
/*
We stop the loading at first 'hole' in the series of summary files;
the internalize layer must report failure if we are missing data.
*/
break;
if ((run_info->run_mode == ENKF_ASSIMILATION) && (report_step == run_info->step2))
break;
if ((run_info->run_mode == ENKF_ASSIMILATION) && (report_step == run_info->step2))
break;
report_step++;
}
}
report_step++;
}
}
if ((header_file != NULL) && (stringlist_get_size(data_files) > 0)) {
summary = ecl_sum_fread_alloc(header_file , data_files , SUMMARY_KEY_JOIN_STRING );
{
time_t end_time = ecl_config_get_end_date( ecl_config );
if (end_time > 0) {
if (ecl_sum_get_end_time( summary ) < end_time) {
/* The summary vector was shorter than expected; we interpret this as
a simulation failure and discard the current summary instance. */
{
int end_day,end_month,end_year;
int sum_day,sum_month,sum_year;
if ((header_file != NULL) && (stringlist_get_size(data_files) > 0)) {
summary = ecl_sum_fread_alloc(header_file , data_files , SUMMARY_KEY_JOIN_STRING );
{
time_t end_time = ecl_config_get_end_date( ecl_config );
if (end_time > 0) {
if (ecl_sum_get_end_time( summary ) < end_time) {
/* The summary vector was shorter than expected; we interpret this as
a simulation failure and discard the current summary instance. */
{
int end_day,end_month,end_year;
int sum_day,sum_month,sum_year;
util_set_date_values( end_time , &end_day , &end_month , &end_year );
util_set_date_values( ecl_sum_get_end_time( summary ) , &sum_day , &sum_month , &sum_year );
stringlist_append_owned_ref( messages ,
util_alloc_sprintf("Summary ended at %02d/%02d/%4d - expected at least END_DATE: %02d/%02d/%4d" ,
sum_day , sum_month , sum_year ,
end_day , end_month , end_year ));
util_set_date_values( end_time , &end_day , &end_month , &end_year );
util_set_date_values( ecl_sum_get_end_time( summary ) , &sum_day , &sum_month , &sum_year );
stringlist_append_owned_ref( messages ,
util_alloc_sprintf("Summary ended at %02d/%02d/%4d - expected at least END_DATE: %02d/%02d/%4d" ,
sum_day , sum_month , sum_year ,
end_day , end_month , end_year ));
}
ecl_sum_free( summary );
summary = NULL;
*result |= LOAD_FAILURE;
}
ecl_sum_free( summary );
summary = NULL;
*result |= LOAD_FAILURE;
}
}
}
}
stringlist_free( data_files );
util_safe_free( header_file );
util_safe_free( unified_file );
return summary;
stringlist_free( data_files );
util_safe_free( header_file );
util_safe_free( unified_file );
return summary;
} else
return NULL;
}
@ -703,97 +705,71 @@ static bool enkf_state_report_step_compatible(const enkf_state_type * enkf_state
static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enkf_state , enkf_fs_type * fs , const model_config_type * model_config , int * result, bool interactive , stringlist_type * msg_list) {
const run_info_type * run_info = enkf_state->run_info;
int load_start = run_info->load_start;
bool load_summary = ensemble_config_has_impl_type(enkf_state->ensemble_config, SUMMARY);
if (load_summary) {
const run_info_type * run_info = enkf_state->run_info;
int load_start = run_info->load_start;
if (load_start == 0) /* Do not attempt to load the "S0000" summary results. */
load_start++;
if (load_start == 0) /* Do not attempt to load the "S0000" summary results. */
load_start++;
{
/* Looking for summary files on disk, and loading them. */
ecl_sum_type * summary = enkf_state_load_ecl_sum( enkf_state , msg_list , result );
/** OK - now we have actually loaded the ecl_sum instance, or ecl_sum == NULL. */
if (summary != NULL) {
{
/* Looking for summary files on disk, and loading them. */
ecl_sum_type * summary = enkf_state_load_ecl_sum( enkf_state , msg_list , result );
/** OK - now we have actually loaded the ecl_sum instance, or ecl_sum == NULL. */
if (summary != NULL) {
/*Check the loaded summary against the reference ecl_sum_type */
if (!enkf_state_report_step_compatible(enkf_state, summary))
*result |= REPORT_STEP_INCOMPATIBLE;
/*Check the loaded summary against the reference ecl_sum_type */
if (!enkf_state_report_step_compatible(enkf_state, summary))
*result |= REPORT_STEP_INCOMPATIBLE;
/* The actual loading internalizing - from ecl_sum -> enkf_node. */
const shared_info_type * shared_info = enkf_state->shared_info;
const int iens = member_config_get_iens( enkf_state->my_config );
const int step2 = ecl_sum_get_last_report_step( summary ); /* Step2 is just taken from the number of steps found in the summary file. */
{
hash_iter_type * iter = hash_iter_alloc( enkf_state->node_hash );
while ( !hash_iter_is_complete(iter) ) {
enkf_node_type * node = hash_iter_get_next_value(iter);
if (enkf_node_get_var_type(node) == DYNAMIC_RESULT) {
/* We internalize all DYNAMIC_RESULT nodes without any further ado. */
{
if (enkf_node_vector_storage( node )) {
/* The actual loading internalizing - from ecl_sum -> enkf_node. */
const shared_info_type * shared_info = enkf_state->shared_info;
const int iens = member_config_get_iens( enkf_state->my_config );
const int step2 = ecl_sum_get_last_report_step( summary ); /* Step2 is just taken from the number of steps found in the summary file. */
{
hash_iter_type * iter = hash_iter_alloc( enkf_state->node_hash );
while ( !hash_iter_is_complete(iter) ) {
enkf_node_type * node = hash_iter_get_next_value(iter);
if (enkf_node_get_var_type(node) == DYNAMIC_RESULT &&
enkf_node_get_impl_type(node) == SUMMARY) {
{
enkf_node_try_load_vector( node , fs , iens , FORECAST ); // Ensure that what is currently on file is loaded before we update.
if (enkf_node_forward_load_vector( node , run_info->run_path , summary , NULL , load_start, step2 , iens)) {
if (enkf_node_forward_load_vector( node , run_info->run_path , summary , NULL , load_start, step2 , iens))
enkf_node_store_vector( node , fs , iens , FORECAST );
if (interactive && enkf_node_get_impl_type(node) == GEN_DATA)
enkf_state_log_GEN_DATA_load( node , 0 , msg_list );
} else {
else {
*result |= LOAD_FAILURE;
log_add_fmt_message(shared_info->logh , 3 , NULL , "[%03d:----] Failed to load data for vector node:%s.",iens , enkf_node_get_key( node ));
if (interactive)
stringlist_append_owned_ref( msg_list , util_alloc_sprintf("Failed to load vector:%s" , enkf_node_get_key( node )));
}
} else {
int report_step;
for (report_step = load_start; report_step <= step2; report_step++) {
bool store_vectors = (report_step == step2) ? true : false;
if (enkf_node_forward_load(node , run_info->run_path , summary , NULL , report_step , iens)) { /* Loading/internalizing */
node_id_type node_id = {.report_step = report_step, .iens = iens , .state = FORECAST };
enkf_node_store(node , fs , store_vectors , node_id); /* Saving to disk */
if (interactive && enkf_node_get_impl_type(node) == GEN_DATA)
enkf_state_log_GEN_DATA_load( node , report_step , msg_list );
} else {
*result |= LOAD_FAILURE;
log_add_fmt_message(shared_info->logh , 3 , NULL , "[%03d:%04d] Failed to load data for node:%s.",iens , report_step , enkf_node_get_key( node ));
if (interactive)
stringlist_append_owned_ref( msg_list , util_alloc_sprintf("Failed to load node:%s at step:%d" , enkf_node_get_key( node ) , report_step));
}
}
}
}
}
}
}
}
hash_iter_free(iter);
}
hash_iter_free(iter);
}
{
time_map_type * time_map = enkf_fs_get_time_map( fs );
time_map_summary_update_strict( time_map , summary );
}
ecl_sum_free( summary );
return true;
} else {
fprintf(stderr , "** Warning: could not load ECLIPSE summary data from %s - this will probably fail later ...\n" , enkf_state->run_info->run_path);
return false;
}
{
time_map_type * time_map = enkf_fs_get_time_map( fs );
time_map_summary_update_strict( time_map , summary );
}
ecl_sum_free( summary );
return true;
} else
return false;
}
}
static bool enkf_state_internalize_dynamic_results(enkf_state_type * enkf_state , enkf_fs_type * fs , const model_config_type * model_config , int * result, bool interactive , stringlist_type * msg_list) {
const ecl_config_type * ecl_config = enkf_state->shared_info->ecl_config;
if (ecl_config_active( ecl_config )) {
bool eclipse_load = enkf_state_internalize_dynamic_eclipse_results( enkf_state , fs , model_config , result, interactive , msg_list);
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;
return true;
}
/**
The ECLIPSE restart files can contain several instances of the same
keyword, e.g. AQUIFER info can come several times with identical
@ -819,6 +795,67 @@ static char * __realloc_static_kw(char * kw , int occurence) {
static void enkf_state_internalize_GEN_DATA(enkf_state_type * enkf_state ,
enkf_fs_type * fs ,
const model_config_type * model_config ,
int load_start ,
int last_report ,
int * result,
bool interactive ,
stringlist_type * msg_list) {
{
run_info_type * run_info = enkf_state->run_info;
shared_info_type * shared_info = enkf_state->shared_info;
member_config_type * my_config = enkf_state->my_config;
const int iens = member_config_get_iens( my_config );
stringlist_type * keylist_GEN_DATA = ensemble_config_alloc_keylist_from_impl_type(enkf_state->ensemble_config , GEN_DATA );
for (int ikey=0; ikey < stringlist_get_size( keylist_GEN_DATA ); ikey++) {
enkf_node_type * node = enkf_state_get_node( enkf_state , stringlist_iget( keylist_GEN_DATA , ikey));
if (enkf_node_vector_storage(node)) {
enkf_node_try_load_vector( node , fs , iens , FORECAST);
if (enkf_node_forward_load_vector( node , run_info->run_path , NULL , NULL , load_start, last_report , iens)) {
enkf_node_store_vector( node , fs , iens , FORECAST );
if (interactive)
enkf_state_log_GEN_DATA_load( node , 0 , msg_list );
} else {
*result |= LOAD_FAILURE;
log_add_fmt_message(shared_info->logh , 3 , NULL , "[%03d:----] Failed to load data for vector node:%s.",iens , enkf_node_get_key( node ));
if (interactive)
stringlist_append_owned_ref( msg_list , util_alloc_sprintf("Failed to load vector:%s" , enkf_node_get_key( node )));
}
} else {
for (int report_step = load_start; report_step <= last_report; report_step++) {
if (enkf_node_internalize(node , report_step)) {
if (enkf_node_has_func(node , forward_load_func)) {
if (enkf_node_forward_load(node , run_info->run_path , NULL , NULL , report_step , iens )) {
node_id_type node_id = {.report_step = report_step , .iens = iens , .state = FORECAST };
enkf_node_store( node , fs, false , node_id );
if (interactive)
enkf_state_log_GEN_DATA_load( node , report_step , msg_list );
} else {
*result |= LOAD_FAILURE;
log_add_fmt_message(shared_info->logh , 1 , NULL , "[%03d:%04d] Failed load data for node:%s.",iens , report_step , enkf_node_get_key( node ));
if (interactive)
stringlist_append_owned_ref(msg_list ,
util_alloc_sprintf("Failed to load: %s at step:%d" , enkf_node_get_key( node ) , report_step));
}
}
}
}
}
}
}
}
/**
This function loads the STATE from a forward simulation. In ECLIPSE
@ -828,210 +865,203 @@ static char * __realloc_static_kw(char * kw , int occurence) {
When the state has been loaded it goes straight to disk.
*/
static void enkf_state_internalize_eclipse_state(enkf_state_type * enkf_state , enkf_fs_type * fs , const model_config_type * model_config , int report_step , bool store_vectors , int * result, bool interactive , stringlist_type * msg_list) {
member_config_type * my_config = enkf_state->my_config;
static void enkf_state_internalize_eclipse_state(enkf_state_type * enkf_state ,
enkf_fs_type * fs ,
const model_config_type * model_config ,
int report_step ,
bool store_vectors ,
int * result,
bool interactive ,
stringlist_type * msg_list) {
shared_info_type * shared_info = enkf_state->shared_info;
run_info_type * run_info = enkf_state->run_info;
const ecl_config_type * ecl_config = shared_info->ecl_config;
const int iens = member_config_get_iens( my_config );
const bool fmt_file = ecl_config_get_formatted( ecl_config );
const bool unified = ecl_config_get_unified_restart( ecl_config );
const bool internalize_state = model_config_internalize_state( model_config , report_step );
ecl_file_type * restart_file;
if (ecl_config_active( ecl_config )) {
member_config_type * my_config = enkf_state->my_config;
run_info_type * run_info = enkf_state->run_info;
const int iens = member_config_get_iens( my_config );
const bool fmt_file = ecl_config_get_formatted( ecl_config );
const bool unified = ecl_config_get_unified_restart( ecl_config );
const bool internalize_state = model_config_internalize_state( model_config , report_step );
ecl_file_type * restart_file;
/**
Loading the restart block.
*/
/**
Loading the restart block.
*/
if (unified)
util_abort("%s: sorry - unified restart files are not supported \n",__func__);
{
char * filename = ecl_util_alloc_exfilename(run_info->run_path , member_config_get_eclbase(enkf_state->my_config) , ECL_RESTART_FILE , fmt_file , report_step);
if (filename != NULL) {
restart_file = ecl_file_open( filename , 0 );
free(filename);
} else
restart_file = NULL; /* No restart information was found; if that is expected the program will fail hard in the enkf_node_forward_load() functions. */
}
/*****************************************************************/
/**
Iterating through the restart file:
1. Build up enkf_state->restart_kw_list.
2. Send static keywords straight out.
*/
if (restart_file != NULL) {
stringlist_clear( enkf_state->restart_kw_list );
if (unified)
util_abort("%s: sorry - unified restart files are not supported \n",__func__);
{
int ikw;
for (ikw =0; ikw < ecl_file_get_size( restart_file ); ikw++) {
ert_impl_type impl_type;
const ecl_kw_type * ecl_kw = ecl_file_iget_kw( restart_file , ikw);
int occurence = ecl_file_iget_occurence( restart_file , ikw ); /* This is essentially the static counter value. */
char * kw = util_alloc_string_copy( ecl_kw_get_header( ecl_kw ) );
/**
Observe that this test will never succeed for static keywords,
because the internalized key has appended a _<occurence>.
*/
if (ensemble_config_has_key(enkf_state->ensemble_config , kw)) {
/**
This is poor-mans treatment of LGR. When LGR is used the restart file
will contain repeated occurences of solution vectors, like
PRESSURE. The first occurence of PRESSURE will be for the ordinary
grid, and then there will be subsequent PRESSURE sections for each
LGR section. The way this is implemented here is as follows:
1. The first occurence of pressure is internalized as the enkf_node
pressure (if we indeed have a pressure node).
2. The consecutive pressure nodes are internalized as static
parameters.
The variable 'occurence' is the key here.
*/
if (occurence == 0) {
const enkf_config_node_type * config_node = ensemble_config_get_node(enkf_state->ensemble_config , kw);
impl_type = enkf_config_node_get_impl_type(config_node);
} else
impl_type = STATIC;
} else
impl_type = STATIC;
if (impl_type == FIELD)
stringlist_append_copy(enkf_state->restart_kw_list , kw);
else if (impl_type == STATIC) {
if (ecl_config_include_static_kw(ecl_config , kw)) {
/* It is a static kw like INTEHEAD or SCON */
/*
Observe that for static keywords we do NOT ask the node 'privately' if
internalize_state is false: It is impossible to single out static keywords for
internalization.
*/
/* Now we mangle the static keyword .... */
kw = __realloc_static_kw(kw , occurence);
if (internalize_state) {
stringlist_append_copy( enkf_state->restart_kw_list , kw);
ensemble_config_ensure_static_key(enkf_state->ensemble_config , kw );
if (!enkf_state_has_node(enkf_state , kw)) {
const enkf_config_node_type * config_node = ensemble_config_get_node(enkf_state->ensemble_config , kw);
enkf_state_add_node(enkf_state , kw , config_node);
}
/*
The following thing can happen:
1. A static keyword appears at report step n, and is added to the enkf_state
object.
2. At report step n+k that static keyword is no longer active, and it is
consequently no longer part of restart_kw_list().
3. However it is still part of the enkf_state. Not loaded here, and subsequently
purged from enkf_main.
One keyword where this occurs is FIPOIL, which at least might appear only in the
first restart file. Unused static keywords of this type are purged from the
enkf_main object by a call to enkf_main_del_unused_static(). The purge is based on
looking at the internal __report_step state of the static kw.
*/
{
enkf_node_type * enkf_node = enkf_state_get_node(enkf_state , kw);
node_id_type node_id = {.report_step = report_step , .iens = iens , .state = FORECAST };
enkf_node_ecl_load_static(enkf_node , ecl_kw , report_step , iens);
/*
Static kewyords go straight out ....
*/
enkf_node_store(enkf_node , fs , true , node_id);
enkf_node_free_data(enkf_node);
}
}
}
} else
util_abort("%s: hm - something wrong - can (currently) only load FIELD/STATIC implementations from restart files - aborting \n",__func__);
free(kw);
}
enkf_fs_fwrite_restart_kw_list( fs , report_step , iens , enkf_state->restart_kw_list );
char * filename = ecl_util_alloc_exfilename(run_info->run_path , member_config_get_eclbase(enkf_state->my_config) , ECL_RESTART_FILE , fmt_file , report_step);
if (filename) {
restart_file = ecl_file_open( filename , 0 );
free(filename);
} else
restart_file = NULL; /* No restart information was found; if that is expected the program will fail hard in the enkf_node_forward_load() functions. */
}
}
/******************************************************************/
/**
Starting on the enkf_node_forward_load() function calls. This is where the
actual loading (apart from static keywords) is done. Observe that this
loading might involve other load functions than the ones used for
loading PRESSURE++ from ECLIPSE restart files (e.g. for loading seismic
results..)
*/
/*****************************************************************/
{
hash_iter_type * iter = hash_iter_alloc(enkf_state->node_hash);
while ( !hash_iter_is_complete(iter) ) {
enkf_node_type * enkf_node = hash_iter_get_next_value(iter);
if (enkf_node_get_var_type(enkf_node) == DYNAMIC_STATE) {
bool internalize_kw = internalize_state;
if (!internalize_kw)
internalize_kw = enkf_node_internalize(enkf_node , report_step);
if (internalize_kw) {
if (enkf_node_has_func(enkf_node , forward_load_func)) {
if (enkf_node_forward_load(enkf_node , run_info->run_path , NULL , restart_file , report_step , iens )) {
node_id_type node_id = {.report_step = report_step , .iens = iens , .state = FORECAST };
enkf_node_store( enkf_node , fs, store_vectors , node_id );
/**
Iterating through the restart file:
1. Build up enkf_state->restart_kw_list.
2. Send static keywords straight out.
*/
if (restart_file) {
stringlist_clear( enkf_state->restart_kw_list );
{
int ikw;
if (interactive && (enkf_node_get_impl_type(enkf_node) == GEN_DATA))
enkf_state_log_GEN_DATA_load( enkf_node , report_step , msg_list );
for (ikw =0; ikw < ecl_file_get_size( restart_file ); ikw++) {
ert_impl_type impl_type;
const ecl_kw_type * ecl_kw = ecl_file_iget_kw( restart_file , ikw);
int occurence = ecl_file_iget_occurence( restart_file , ikw ); /* This is essentially the static counter value. */
char * kw = util_alloc_string_copy( ecl_kw_get_header( ecl_kw ) );
/**
Observe that this test will never succeed for static keywords,
because the internalized key has appended a _<occurence>.
*/
if (ensemble_config_has_key(enkf_state->ensemble_config , kw)) {
/**
This is poor-mans treatment of LGR. When LGR is used the restart file
will contain repeated occurences of solution vectors, like
PRESSURE. The first occurence of PRESSURE will be for the ordinary
grid, and then there will be subsequent PRESSURE sections for each
LGR section. The way this is implemented here is as follows:
1. The first occurence of pressure is internalized as the enkf_node
pressure (if we indeed have a pressure node).
2. The consecutive pressure nodes are internalized as static
parameters.
The variable 'occurence' is the key here.
*/
if (occurence == 0) {
const enkf_config_node_type * config_node = ensemble_config_get_node(enkf_state->ensemble_config , kw);
impl_type = enkf_config_node_get_impl_type(config_node);
} else
impl_type = STATIC;
} else
impl_type = STATIC;
if (impl_type == FIELD)
stringlist_append_copy(enkf_state->restart_kw_list , kw);
else if (impl_type == STATIC) {
if (ecl_config_include_static_kw(ecl_config , kw)) {
/* It is a static kw like INTEHEAD or SCON */
/*
Observe that for static keywords we do NOT ask the node 'privately' if
internalize_state is false: It is impossible to single out static keywords for
internalization.
*/
/* Now we mangle the static keyword .... */
kw = __realloc_static_kw(kw , occurence);
if (internalize_state) {
stringlist_append_copy( enkf_state->restart_kw_list , kw);
} else {
if (enkf_node_get_impl_type(enkf_node) != GEN_DATA) {
ensemble_config_ensure_static_key(enkf_state->ensemble_config , kw );
if (!enkf_state_has_node(enkf_state , kw)) {
const enkf_config_node_type * config_node = ensemble_config_get_node(enkf_state->ensemble_config , kw);
enkf_state_add_node(enkf_state , kw , config_node);
}
/*
The following thing can happen:
1. A static keyword appears at report step n, and is added to the enkf_state
object.
2. At report step n+k that static keyword is no longer active, and it is
consequently no longer part of restart_kw_list().
3. However it is still part of the enkf_state. Not loaded here, and subsequently
purged from enkf_main.
One keyword where this occurs is FIPOIL, which at least might appear only in the
first restart file. Unused static keywords of this type are purged from the
enkf_main object by a call to enkf_main_del_unused_static(). The purge is based on
looking at the internal __report_step state of the static kw.
*/
{
enkf_node_type * enkf_node = enkf_state_get_node(enkf_state , kw);
node_id_type node_id = {.report_step = report_step , .iens = iens , .state = FORECAST };
enkf_node_ecl_load_static(enkf_node , ecl_kw , report_step , iens);
/*
Static kewyords go straight out ....
*/
enkf_node_store(enkf_node , fs , true , node_id);
enkf_node_free_data(enkf_node);
}
}
}
} else
util_abort("%s: hm - something wrong - can (currently) only load FIELD/STATIC implementations from restart files - aborting \n",__func__);
free(kw);
}
enkf_fs_fwrite_restart_kw_list( fs , report_step , iens , enkf_state->restart_kw_list );
}
}
/******************************************************************/
/**
Starting on the enkf_node_forward_load() function calls. This is where the
actual loading (apart from static keywords) is done. Observe that this
loading might involve other load functions than the ones used for
loading PRESSURE++ from ECLIPSE restart files (e.g. for loading seismic
results..)
*/
{
hash_iter_type * iter = hash_iter_alloc(enkf_state->node_hash);
while ( !hash_iter_is_complete(iter) ) {
enkf_node_type * enkf_node = hash_iter_get_next_value(iter);
if (enkf_node_get_var_type(enkf_node) == DYNAMIC_STATE &&
enkf_node_get_impl_type(enkf_node) == FIELD) {
bool internalize_kw = internalize_state;
if (!internalize_kw)
internalize_kw = enkf_node_internalize(enkf_node , report_step);
if (internalize_kw) {
if (enkf_node_has_func(enkf_node , forward_load_func)) {
if (enkf_node_forward_load(enkf_node , run_info->run_path , NULL , restart_file , report_step , iens )) {
node_id_type node_id = {.report_step = report_step ,
.iens = iens ,
.state = FORECAST };
enkf_node_store( enkf_node , fs, store_vectors , node_id );
} else {
*result |= LOAD_FAILURE;
log_add_fmt_message(shared_info->logh , 1 , NULL , "[%03d:%04d] Failed load data for node:%s.",iens , report_step , enkf_node_get_key( enkf_node ));
if (interactive)
stringlist_append_owned_ref(msg_list , util_alloc_sprintf("Failed to load: %s at step:%d" , enkf_node_get_key( enkf_node ) , report_step));
}
}
}
}
}
}
}
hash_iter_free(iter);
}
}
hash_iter_free(iter);
}
/*****************************************************************/
/* Cleaning up */
if (restart_file != NULL) ecl_file_close( restart_file );
/*****************************************************************/
/* Cleaning up */
if (restart_file != NULL) ecl_file_close( restart_file );
}
}
static void enkf_state_internalize_state(enkf_state_type * enkf_state ,
enkf_fs_type * fs ,
const model_config_type * model_config ,
int report_step ,
bool store_vectors ,
int * result ,
bool interactive ,
stringlist_type * msg_list) {
const ecl_config_type * ecl_config = enkf_state->shared_info->ecl_config;
if (ecl_config_active( ecl_config ))
enkf_state_internalize_eclipse_state( enkf_state , fs , model_config , report_step , store_vectors , result , interactive , msg_list);
}
/**
@ -1055,12 +1085,17 @@ static void enkf_state_internalize_results(enkf_state_type * enkf_state , enkf_f
hence we must load the summary results first.
*/
if (enkf_state_internalize_dynamic_results(enkf_state , fs , model_config , result, interactive , msg_list)) {
enkf_state_internalize_dynamic_eclipse_results(enkf_state , fs , model_config , result, interactive , msg_list);
{
int last_report = time_map_get_last_step( enkf_fs_get_time_map( fs ));
if (last_report < 0)
last_report = model_config_get_last_history_restart( enkf_state->shared_info->model_config);
/*
If we are in true assimilation mode we use the step2 setting, otherwise we are
just in plain gready-load-mode. */
just in plain gready-load-mode.
*/
if (run_info->run_mode == ENKF_ASSIMILATION)
last_report = run_info->step2;
@ -1069,10 +1104,11 @@ static void enkf_state_internalize_results(enkf_state_type * enkf_state , enkf_f
for (report_step = run_info->load_start; report_step <= last_report; report_step++) {
bool store_vectors = (report_step == last_report) ? true : false;
if (model_config_load_state( model_config , report_step))
enkf_state_internalize_state(enkf_state , fs , model_config , report_step , store_vectors , result , interactive , msg_list);
enkf_state_internalize_eclipse_state(enkf_state , fs , model_config , report_step , store_vectors , result , interactive , msg_list);
}
enkf_state_internalize_GEN_DATA(enkf_state , fs , model_config , run_info->load_start , last_report , result , interactive , msg_list);
}
}

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