#4266 Update libecl

Use commit 0e1e780fd6f18ce93119061e36a4fca9711bc020

Excluded multibuild folder, as this caused git issues
This commit is contained in:
Magne Sjaastad
2019-05-07 07:15:25 +02:00
parent 6ce3371df5
commit 04091ad77d
587 changed files with 8944 additions and 7854 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
This file is part of ERT - Ensemble based Reservoir Tool.

View File

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

View File

@@ -1,120 +0,0 @@
#include <ert/ecl/ecl_smspec.hpp>
#include <ert/ecl/Smspec.hpp>
namespace ERT {
smspec_node::smspec_node( const smspec_node& rhs ) :
node( smspec_node_alloc_copy( rhs.node.get() ) )
{}
smspec_node::smspec_node( smspec_node&& rhs ) :
node( std::move( rhs.node ) )
{}
smspec_node& smspec_node::operator=( const smspec_node& rhs ) {
this->node.reset( smspec_node_alloc_copy( rhs.node.get() ) );
return *this;
}
smspec_node& smspec_node::operator=( smspec_node&& rhs ) {
this->node = std::move( rhs.node );
return *this;
}
int smspec_node::cmp( const smspec_node& node1, const smspec_node& node2) {
return smspec_node_cmp( node1.get() , node2.get() );
}
static const int dummy_dims[ 3 ] = { -1, -1, -1 };
const auto default_join = ":";
static int global_index( const int dims[ 3 ], const int ijk[ 3 ] ) {
/* num is offset 1 global index */
return 1 + ijk[ 0 ] + ( ijk[ 1 ] * dims[ 0 ] ) + ( ijk[ 2 ] * dims[ 1 ] * dims[ 0 ] );
}
smspec_node::smspec_node(
ecl_smspec_var_type var_type,
const std::string& name,
const std::string& kw
) : smspec_node( var_type, name.c_str(), kw.c_str(), "", default_join, dummy_dims, 0 )
{}
smspec_node::smspec_node( const std::string& keyword ) :
smspec_node( ecl_smspec_identify_var_type( keyword.c_str() ),
"",
keyword.c_str(),
"",
default_join,
dummy_dims,
0 )
{}
smspec_node::smspec_node(
const std::string& keyword,
const int dims[ 3 ],
const int ijk[ 3 ] ) :
smspec_node(
ECL_SMSPEC_BLOCK_VAR, "", keyword.c_str(), "", default_join, dims, global_index( dims, ijk )
)
{}
smspec_node::smspec_node(
const std::string& keyword,
const std::string& wellname,
const int dims[ 3 ],
const int ijk[ 3 ] ) :
smspec_node(
ECL_SMSPEC_COMPLETION_VAR, wellname.c_str(), keyword.c_str(), "", default_join, dims, global_index( dims, ijk )
)
{}
smspec_node::smspec_node(
const std::string& keyword,
const int dims[ 3 ],
int region ) :
smspec_node(
ECL_SMSPEC_REGION_VAR, "", keyword.c_str(), "", default_join, dims, region
)
{}
smspec_node::smspec_node(
ecl_smspec_var_type type,
const char* wgname,
const char* keyword,
const char* unit,
const char* join,
const int grid_dims[ 3 ],
int num, int index, float default_value ) :
node( smspec_node_alloc( type, wgname, keyword, unit,
join, grid_dims, num, index, default_value ) )
{}
int smspec_node::type() const {
return smspec_node_get_var_type( this->node.get() );
}
const char* smspec_node::wgname() const {
return smspec_node_get_wgname( this->node.get() );
}
const char* smspec_node::keyword() const {
return smspec_node_get_keyword( this->node.get() );
}
const char* smspec_node::key1() const {
return smspec_node_get_gen_key1( this->node.get() );
}
int smspec_node::num() const {
return smspec_node_get_num( this->node.get() );
}
smspec_node_type* smspec_node::get() {
return this->node.get();
}
const smspec_node_type* smspec_node::get() const {
return this->node.get();
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_box.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2012 statoil asa, norway.
Copyright (c) 2012 equinor asa, norway.
The file 'ecl_coarse_cell.c' is part of ert - ensemble based reservoir tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -534,10 +534,13 @@ static void ecl_file_scan( ecl_file_type * ecl_file ) {
if (read_status == ECL_KW_READ_OK) {
ecl_file_kw_type * file_kw = ecl_file_kw_alloc( work_kw , current_offset);
if (ecl_file_kw_fskip_data( file_kw , ecl_file->fortio ))
ecl_file_view_add_kw( ecl_file->global_view , file_kw );
else
else {
ecl_file_kw_free( file_kw );
break;
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_file_kw.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -91,7 +91,7 @@ static void inv_map_assert_sort( inv_map_type * map ) {
size_t_vector_permute( map->file_kw_ptr , perm );
map->sorted = true;
free( perm );
perm_vector_free( perm );
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Statoil ASA, Norway.
Copyright (C) 2016 Equinor ASA, Norway.
The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -19,9 +19,7 @@
#include <vector>
#include <string>
#include <ert/util/vector.hpp>
#include <ert/util/hash.hpp>
#include <map>
#include <ert/ecl/fortio.h>
#include <ert/ecl/ecl_kw.hpp>
@@ -33,13 +31,13 @@
struct ecl_file_view_struct {
vector_type * kw_list; /* This is a vector of ecl_file_kw instances corresponding to the content of the file. */
hash_type * kw_index; /* A hash table with integer vectors of indices - see comment below. */
std::vector<ecl_file_kw_type *> kw_list;
std::map<std::string,std::vector<int>> kw_index;
std::vector<std::string> distinct_kw; /* A list of the keywords occuring in the file - each string occurs ONLY ONCE. */
fortio_type * fortio; /* The same fortio instance pointer as in the ecl_file styructure. */
bool owner; /* Is this map the owner of the ecl_file_kw instances; only true for the global_map. */
inv_map_type * inv_map; /* Shared reference owned by the ecl_file structure. */
vector_type * child_list;
std::vector<ecl_file_view_type *> child_list;
int * flags;
};
@@ -75,9 +73,6 @@ const char * ecl_file_view_get_src_file( const ecl_file_view_type * file_view )
ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , inv_map_type * inv_map , bool owner ) {
ecl_file_view_type * ecl_file_view = new ecl_file_view_type();
ecl_file_view->kw_list = vector_alloc_new();
ecl_file_view->kw_index = hash_alloc();
ecl_file_view->child_list = vector_alloc_new();
ecl_file_view->owner = owner;
ecl_file_view->fortio = fortio;
ecl_file_view->inv_map = inv_map;
@@ -87,9 +82,8 @@ ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , i
}
int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , const char * kw , int ith) {
const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw);
int global_index = int_vector_iget( index_vector , ith);
return global_index;
const auto& index_vector = ecl_file_view->kw_index.at(kw);
return index_vector[ith];
}
@@ -105,34 +99,28 @@ int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , c
void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) {
ecl_file_view->distinct_kw.clear();
hash_clear( ecl_file_view->kw_index );
ecl_file_view->kw_index.clear();
{
int i;
for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) {
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i);
const char * header = ecl_file_kw_get_header( file_kw );
if ( !hash_has_key( ecl_file_view->kw_index , header )) {
int_vector_type * index_vector = int_vector_alloc( 0 , -1 );
hash_insert_hash_owned_ref( ecl_file_view->kw_index , header , index_vector , int_vector_free__);
int global_index = 0;
for (const auto& file_kw : ecl_file_view->kw_list) {
const std::string& header = ecl_file_kw_get_header( file_kw );
if (ecl_file_view->kw_index.find(header) == ecl_file_view->kw_index.end())
ecl_file_view->distinct_kw.push_back(header);
}
{
int_vector_type * index_vector = (int_vector_type*)hash_get( ecl_file_view->kw_index , header);
int_vector_append( index_vector , i);
}
auto& index_vector = ecl_file_view->kw_index[header];
index_vector.push_back(global_index);
global_index++;
}
}
}
bool ecl_file_view_has_kw( const ecl_file_view_type * ecl_file_view, const char * kw) {
return hash_has_key( ecl_file_view->kw_index , kw );
return (ecl_file_view->kw_index.find(kw) != ecl_file_view->kw_index.end());
}
ecl_file_kw_type * ecl_file_view_iget_file_kw( const ecl_file_view_type * ecl_file_view , int global_index) {
ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , global_index);
return file_kw;
return ecl_file_view->kw_list[global_index];
}
ecl_file_kw_type * ecl_file_view_iget_named_file_kw( const ecl_file_view_type * ecl_file_view , const char * kw, int ith) {
@@ -188,12 +176,12 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons
int ecl_file_view_find_kw_value( const ecl_file_view_type * ecl_file_view , const char * kw , const void * value) {
int global_index = -1;
if ( ecl_file_view_has_kw( ecl_file_view , kw)) {
const int_vector_type * index_list = (const int_vector_type*)hash_get( ecl_file_view->kw_index , kw );
int index = 0;
while (index < int_vector_size( index_list )) {
const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( index_list , index ));
const auto& index_list = ecl_file_view->kw_index.at(kw);
size_t index = 0;
while (index < index_list.size()) {
const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , index_list[index]);
if (ecl_kw_data_equal( ecl_kw , value )) {
global_index = int_vector_iget( index_list , index );
global_index = index_list[index];
break;
}
index++;
@@ -212,7 +200,7 @@ int ecl_file_view_get_num_distinct_kw( const ecl_file_view_type * ecl_file_view
}
int ecl_file_view_get_size( const ecl_file_view_type * ecl_file_view ) {
return vector_get_size( ecl_file_view->kw_list );
return ecl_file_view->kw_list.size();
}
@@ -249,9 +237,9 @@ int ecl_file_view_iget_named_size( const ecl_file_view_type * ecl_file_view , co
void ecl_file_view_replace_kw( ecl_file_view_type * ecl_file_view , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy) {
int index = 0;
while (index < vector_get_size( ecl_file_view->kw_list )) {
ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index );
size_t index = 0;
while (index < ecl_file_view->kw_list.size() ) {
auto * ikw = ecl_file_view->kw_list[index];
if (ecl_file_kw_ptr_eq( ikw , old_kw)) {
/*
Found it; observe that the vector_iset() function will
@@ -276,11 +264,8 @@ bool ecl_file_view_load_all( ecl_file_view_type * ecl_file_view ) {
bool loadOK = false;
if (fortio_assert_stream_open( ecl_file_view->fortio )) {
int index;
for (index = 0; index < vector_get_size( ecl_file_view->kw_list); index++) {
ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index );
ecl_file_kw_get_kw( ikw , ecl_file_view->fortio , ecl_file_view->inv_map);
}
for (ecl_file_kw_type * file_kw : ecl_file_view->kw_list)
ecl_file_kw_get_kw( file_kw, ecl_file_view->fortio , ecl_file_view->inv_map);
loadOK = true;
}
@@ -296,16 +281,18 @@ bool ecl_file_view_load_all( ecl_file_view_type * ecl_file_view ) {
void ecl_file_view_add_kw( ecl_file_view_type * ecl_file_view , ecl_file_kw_type * file_kw) {
if (ecl_file_view->owner)
vector_append_owned_ref( ecl_file_view->kw_list , file_kw , ecl_file_kw_free__ );
else
vector_append_ref( ecl_file_view->kw_list , file_kw);
ecl_file_view->kw_list.push_back( file_kw );
}
void ecl_file_view_free( ecl_file_view_type * ecl_file_view ) {
vector_free( ecl_file_view->child_list );
hash_free( ecl_file_view->kw_index );
vector_free( ecl_file_view->kw_list );
for (auto& child_ptr : ecl_file_view->child_list)
ecl_file_view_free(child_ptr);
if (ecl_file_view->owner) {
for (auto& kw_ptr : ecl_file_view->kw_list)
ecl_file_kw_free( kw_ptr );
}
delete ecl_file_view;
}
@@ -317,16 +304,15 @@ void ecl_file_view_free__( void * arg ) {
int ecl_file_view_get_num_named_kw(const ecl_file_view_type * ecl_file_view , const char * kw) {
if (hash_has_key(ecl_file_view->kw_index , kw)) {
const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw);
return int_vector_size( index_vector );
if (ecl_file_view_has_kw(ecl_file_view, kw)) {
const auto& index_vector = ecl_file_view->kw_index.at(kw);
return index_vector.size();
} else
return 0;
}
void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_type * target , int offset) {
int index;
for (index = offset; index < vector_get_size( ecl_file_view->kw_list ); index++) {
for (size_t index = offset; index < ecl_file_view->kw_list.size(); index++) {
ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , index );
ecl_kw_fwrite( ecl_kw , target );
}
@@ -336,18 +322,17 @@ void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_typ
int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int global_index) {
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , global_index);
const ecl_file_kw_type * file_kw = ecl_file_view->kw_list[global_index];
const char * header = ecl_file_kw_get_header( file_kw );
const int_vector_type * index_vector = (const int_vector_type*)hash_get( ecl_file_view->kw_index , header );
const int * index_data = int_vector_get_const_ptr( index_vector );
const auto& index_vector = ecl_file_view->kw_index.at(header);
int occurence = -1;
{
/* Manual reverse lookup. */
int i;
for (i=0; i < int_vector_size( index_vector ); i++)
if (index_data[i] == global_index)
for (size_t i=0; i < index_vector.size(); i++) {
if (index_vector[i] == global_index)
occurence = i;
}
}
if (occurence < 0)
util_abort("%s: internal error ... \n" , __func__);
@@ -356,9 +341,7 @@ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int
}
void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FILE * stream) {
int i;
for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) {
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i );
for (auto& file_kw : ecl_file_view->kw_list) {
char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw));
fprintf(stream , "%-8s %7d:%s\n",
ecl_file_kw_get_header( file_kw ) ,
@@ -375,21 +358,21 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e
ecl_file_view_type * block_map = ecl_file_view_alloc( ecl_file_view->fortio , ecl_file_view->flags , ecl_file_view->inv_map , false);
int kw_index = 0;
size_t kw_index = 0;
if (start_kw)
kw_index = ecl_file_view_get_global_index( ecl_file_view , start_kw , occurence );
{
ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , kw_index );
ecl_file_kw_type * file_kw = ecl_file_view->kw_list[kw_index];
while (true) {
ecl_file_view_add_kw( block_map , file_kw );
kw_index++;
if (kw_index == vector_get_size( ecl_file_view->kw_list ))
if (kw_index == ecl_file_view->kw_list.size())
break;
else {
if (end_kw) {
file_kw = (ecl_file_kw_type*)vector_iget(ecl_file_view->kw_list , kw_index);
file_kw = ecl_file_view->kw_list[kw_index];
if (strcmp( end_kw , ecl_file_kw_get_header( file_kw )) == 0)
break;
}
@@ -408,21 +391,21 @@ ecl_file_view_type * ecl_file_view_alloc_blockview(const ecl_file_view_type * ec
}
ecl_file_view_type * ecl_file_view_add_blockview(const ecl_file_view_type * file_view , const char * header, int occurence) {
ecl_file_view_type * ecl_file_view_add_blockview(ecl_file_view_type * file_view , const char * header, int occurence) {
ecl_file_view_type * child = ecl_file_view_alloc_blockview2(file_view, header, header, occurence);
if (child)
vector_append_owned_ref( file_view->child_list , child , ecl_file_view_free__ );
file_view->child_list.push_back(child);
return child;
}
ecl_file_view_type * ecl_file_view_add_blockview2(const ecl_file_view_type * ecl_file_view , const char * start_kw, const char * end_kw, int occurence) {
ecl_file_view_type * ecl_file_view_add_blockview2(ecl_file_view_type * ecl_file_view , const char * start_kw, const char * end_kw, int occurence) {
ecl_file_view_type * child = ecl_file_view_alloc_blockview2(ecl_file_view, start_kw , end_kw , occurence);
if (child)
vector_append_owned_ref( ecl_file_view->child_list , child , ecl_file_view_free__ );
ecl_file_view->child_list.push_back(child);
return child;
}
@@ -593,10 +576,10 @@ double ecl_file_view_iget_restart_sim_days(const ecl_file_view_type * ecl_file_v
int ecl_file_view_find_sim_time(const ecl_file_view_type * ecl_file_view , time_t sim_time) {
int seqnum_index = -1;
if ( ecl_file_view_has_kw( ecl_file_view , INTEHEAD_KW)) {
const int_vector_type * intehead_index_list = (const int_vector_type *)hash_get( ecl_file_view->kw_index , INTEHEAD_KW );
int index = 0;
while (index < int_vector_size( intehead_index_list )) {
const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( intehead_index_list , index ));
const auto& intehead_index_list = ecl_file_view->kw_index.at(INTEHEAD_KW);
size_t index = 0;
while (index < intehead_index_list.size()) {
const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , intehead_index_list[index] );
if (ecl_rsthead_date( intehead_kw ) == sim_time) {
seqnum_index = index;
break;
@@ -832,6 +815,8 @@ void ecl_file_view_end_transaction( ecl_file_view_type * file_view, ecl_file_tra
ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw(file_view, i);
ecl_file_kw_end_transaction(file_kw, ref_count[i]);
}
free(transaction->ref_count);
free(transaction);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
This file is part of ERT - Ensemble based Reservoir Tool.
@@ -20,9 +20,11 @@
#include <math.h>
#include <stdbool.h>
#include <unordered_map>
#include <vector>
#include <string>
#include <ert/util/util.h>
#include <ert/util/hash.hpp>
#include <ert/util/vector.hpp>
#include <ert/ecl/ecl_kw.hpp>
#include <ert/ecl/ecl_util.hpp>
@@ -69,12 +71,10 @@ struct ecl_grav_struct {
const ecl_file_type * init_file; /* The init file - a shared reference owned by calling scope. */
ecl::ecl_grid_cache * grid_cache; /* An internal specialized structure to facilitate fast grid lookup. */
bool * aquifer_cell; /* Numerical aquifer cells should be ignored. */
hash_type * surveys; /* A hash table containg ecl_grav_survey_type instances; one instance
for each interesting time. */
hash_type * std_density; /* Hash table indexed with "SWAT" , "SGAS" and "SOIL"; each element
is a double_vector() instance which is indexed by PVTNUM
values. Used to lookup standard condition mass densities. Must
be suuplied by user __BEFORE__ adding a FIP based survey. */
std::unordered_map<std::string, ecl_grav_survey_type *> surveys;
std::unordered_map<std::string, double> default_density;
std::unordered_map<std::string, std::vector<double>> std_density;
};
@@ -90,10 +90,10 @@ struct ecl_grav_survey_struct {
UTIL_TYPE_ID_DECLARATION;
const ecl::ecl_grid_cache * grid_cache;
const bool * aquifer_cell;
char * name; /* Name of the survey - arbitrary string. */
double * porv; /* Reference shared by the ecl_grav_phase structures - i.e. it must not be updated. */
vector_type * phase_list; /* ecl_grav_phase_type objects - one for each phase present in the model. */
hash_type * phase_map; /* The same objects as in the phase_list vector - accessible by the "SWAT", "SGAS" and "SOIL" keys. */
char * name; /* Name of the survey - arbitrary string. */
double * porv; /* Reference shared by the ecl_grav_phase structures - i.e. it must not be updated. */
std::vector<ecl_grav_phase_type*> phase_list; /* ecl_grav_phase_type objects - one for each phase present in the model. */
std::unordered_map<std::string, ecl_grav_phase_type*> phase_map; /* The same objects as in the phase_list vector - accessible by the "SWAT", "SGAS" and "SOIL" keys. */
};
@@ -106,9 +106,9 @@ struct ecl_grav_phase_struct {
UTIL_TYPE_ID_DECLARATION;
const ecl::ecl_grid_cache * grid_cache;
const bool * aquifer_cell;
double * fluid_mass; /* The total fluid in place (mass) of this phase - for each active cell.*/
double * work; /* Temporary used in the summation over all cells. */
ecl_phase_enum phase;
double * fluid_mass; /* The total fluid in place (mass) of this phase - for each active cell.*/
double * work; /* Temporary used in the summation over all cells. */
ecl_phase_enum phase;
};
@@ -213,7 +213,7 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav ,
const ecl::ecl_grid_cache * grid_cache = ecl_grav->grid_cache;
const char * sat_kw_name = ecl_util_get_phase_name( phase );
{
ecl_grav_phase_type * grav_phase = (ecl_grav_phase_type*)util_malloc( sizeof * grav_phase );
ecl_grav_phase_type * grav_phase = new ecl_grav_phase_type();
const int size = grid_cache->size();
UTIL_TYPE_ID_INIT( grav_phase , ECL_GRAV_PHASE_TYPE_ID );
@@ -225,7 +225,7 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav ,
if (calc_type == GRAV_CALC_FIP) {
ecl_kw_type * pvtnum_kw = ecl_file_iget_named_kw( init_file , PVTNUM_KW , 0 );
double_vector_type * std_density = (double_vector_type*)hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase ));
const std::vector<double> std_density = ecl_grav->std_density[std::string(ecl_util_get_phase_name(phase))];
ecl_kw_type * fip_kw;
if ( phase == ECL_OIL_PHASE)
@@ -240,7 +240,7 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav ,
for (iactive=0; iactive < size; iactive++) {
double fip = ecl_kw_iget_as_double( fip_kw , iactive );
int pvtnum = ecl_kw_iget_int( pvtnum_kw , iactive );
grav_phase->fluid_mass[ iactive ] = fip * double_vector_safe_iget( std_density , pvtnum );
grav_phase->fluid_mass[ iactive ] = fip * std_density[pvtnum];
}
}
} else {
@@ -307,23 +307,18 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav ,
static void ecl_grav_phase_free( ecl_grav_phase_type * grav_phase ) {
free( grav_phase->work );
free( grav_phase->fluid_mass );
free( grav_phase );
delete grav_phase;
}
static UTIL_SAFE_CAST_FUNCTION( ecl_grav_phase , ECL_GRAV_PHASE_TYPE_ID )
static void ecl_grav_phase_free__( void * __grav_phase) {
ecl_grav_phase_type * grav_phase = ecl_grav_phase_safe_cast( __grav_phase );
ecl_grav_phase_free( grav_phase );
}
/*****************************************************************/
static void ecl_grav_survey_add_phase( ecl_grav_survey_type * survey, ecl_phase_enum phase , ecl_grav_phase_type * grav_phase ) {
vector_append_owned_ref( survey->phase_list , grav_phase , ecl_grav_phase_free__ );
hash_insert_ref( survey->phase_map , ecl_util_get_phase_name( phase ) , grav_phase );
survey->phase_list.push_back(grav_phase);
survey->phase_map[std::string(ecl_util_get_phase_name(phase))] = grav_phase;
}
@@ -349,13 +344,11 @@ static void ecl_grav_survey_add_phases( ecl_grav_type * ecl_grav , ecl_grav_surv
static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * ecl_grav ,
const char * name ,
grav_calc_type calc_type) {
ecl_grav_survey_type * survey = (ecl_grav_survey_type*)util_malloc( sizeof * survey );
ecl_grav_survey_type * survey = new ecl_grav_survey_type();
UTIL_TYPE_ID_INIT( survey , ECL_GRAV_SURVEY_ID );
survey->grid_cache = ecl_grav->grid_cache;
survey->aquifer_cell = ecl_grav->aquifer_cell;
survey->name = util_alloc_string_copy( name );
survey->phase_list = vector_alloc_new();
survey->phase_map = hash_alloc();
if (calc_type & GRAV_CALC_USE_PORV)
survey->porv = (double*)util_calloc( ecl_grav->grid_cache->size() , sizeof * survey->porv );
@@ -365,8 +358,6 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type *
return survey;
}
static UTIL_SAFE_CAST_FUNCTION( ecl_grav_survey , ECL_GRAV_SURVEY_ID )
/**
Check that the rporv values are in the right ballpark. For ECLIPSE
@@ -530,15 +521,12 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_RFIP(ecl_grav_type * ecl_gra
static void ecl_grav_survey_free( ecl_grav_survey_type * grav_survey ) {
free( grav_survey->name );
free( grav_survey->porv );
vector_free( grav_survey->phase_list );
hash_free( grav_survey->phase_map );
free( grav_survey );
for (auto * phase : grav_survey->phase_list)
ecl_grav_phase_free( phase );
delete grav_survey;
}
static void ecl_grav_survey_free__( void * __grav_survey ) {
ecl_grav_survey_type * grav_survey = ecl_grav_survey_safe_cast( __grav_survey );
ecl_grav_survey_free( grav_survey );
}
@@ -546,13 +534,12 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey,
const ecl_grav_survey_type * monitor_survey ,
ecl_region_type * region ,
double utm_x , double utm_y , double depth, int phase_mask) {
int phase_nr;
double deltag = 0;
for (phase_nr = 0; phase_nr < vector_get_size( base_survey->phase_list ); phase_nr++) {
ecl_grav_phase_type * base_phase = (ecl_grav_phase_type*)vector_iget( base_survey->phase_list , phase_nr );
for (std::size_t phase_nr = 0; phase_nr < base_survey->phase_list.size(); phase_nr++) {
ecl_grav_phase_type * base_phase = base_survey->phase_list[phase_nr];
if (base_phase->phase & phase_mask) {
if (monitor_survey != NULL) {
const ecl_grav_phase_type * monitor_phase = (const ecl_grav_phase_type*)vector_iget_const( monitor_survey->phase_list , phase_nr );
const ecl_grav_phase_type * monitor_phase = monitor_survey->phase_list[phase_nr];
deltag += ecl_grav_phase_eval( base_phase , monitor_phase , region , utm_x , utm_y , depth );
} else
deltag += ecl_grav_phase_eval( base_phase , NULL , region , utm_x , utm_y , depth );
@@ -570,20 +557,19 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey,
*/
ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file) {
ecl_grav_type * ecl_grav = (ecl_grav_type*)util_malloc( sizeof * ecl_grav );
ecl_grav_type * ecl_grav = new ecl_grav_type();
ecl_grav->init_file = init_file;
ecl_grav->grid_cache = new ecl::ecl_grid_cache(ecl_grid);
ecl_grav->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( *(ecl_grav->grid_cache) , ecl_grav->init_file );
ecl_grav->surveys = hash_alloc();
ecl_grav->std_density = hash_alloc();
return ecl_grav;
}
static void ecl_grav_add_survey__( ecl_grav_type * grav , const char * name , ecl_grav_survey_type * survey) {
hash_insert_hash_owned_ref( grav->surveys , name , survey , ecl_grav_survey_free__ );
grav->surveys[name] = survey;
}
@@ -618,17 +604,15 @@ static ecl_grav_survey_type * ecl_grav_get_survey( const ecl_grav_type * grav ,
if (name == NULL)
return NULL; // Calling scope must determine if this is OK?
else {
if (hash_has_key( grav->surveys , name))
return (ecl_grav_survey_type*)hash_get( grav->surveys , name );
if (grav->surveys.count(name) > 0)
return grav->surveys.at(name);
else {
hash_iter_type * survey_iter = hash_iter_alloc( grav->surveys );
fprintf(stderr,"Survey name:%s not registered. Available surveys are: \n\n " , name);
while (!hash_iter_is_complete( survey_iter )) {
const char * survey = hash_iter_get_next_key( survey_iter );
fprintf(stderr,"%s ",survey);
}
for (const auto& survey_pair : grav->surveys)
fprintf(stderr,"%s ",survey_pair.first.c_str());
fprintf(stderr,"\n\n");
hash_iter_free( survey_iter );
exit(1);
}
}
@@ -660,8 +644,7 @@ double ecl_grav_eval( const ecl_grav_type * grav , const char * base, const char
void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , double default_density) {
const char * phase_key = ecl_util_get_phase_name( phase );
if (!hash_has_key( grav->std_density , phase_key ))
hash_insert_hash_owned_ref( grav->std_density , phase_key , double_vector_alloc( 0 , default_density ) , double_vector_free__ );
grav->default_density[std::string(phase_key)] = default_density;
}
/**
@@ -680,8 +663,10 @@ void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , dou
void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density) {
double_vector_type * std_density = (double_vector_type*)hash_get( grav->std_density , ecl_util_get_phase_name( phase ));
double_vector_iset( std_density , pvtnum , density );
std::vector<double>& std_density = grav->std_density[ std::string(ecl_util_get_phase_name(phase)) ];
if (std_density.size() <= static_cast<std::size_t>(pvtnum))
std_density.resize(pvtnum + 1, grav->default_density[ std::string(ecl_util_get_phase_name(phase)) ]);
std_density[pvtnum] = density;
}
@@ -689,7 +674,9 @@ void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int
void ecl_grav_free( ecl_grav_type * ecl_grav ) {
delete ecl_grav->grid_cache;
free( ecl_grav->aquifer_cell );
hash_free( ecl_grav->surveys );
hash_free( ecl_grav->std_density );
free( ecl_grav );
for (const auto& survey_pair : ecl_grav->surveys)
ecl_grav_survey_free( survey_pair.second );
delete ecl_grav;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_grav.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_grav_common.c' is part of ERT - Ensemble based
Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2011 statoil asa, norway.
Copyright (c) 2011 equinor asa, norway.
The file 'ecl_grid.c' is part of ert - ensemble based reservoir tool.
@@ -21,12 +21,14 @@
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <vector>
#include <unordered_map>
#include <string>
#include <ert/util/util.h>
#include <ert/util/double_vector.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/util/hash.hpp>
#include <ert/util/vector.hpp>
#include <ert/util/stringlist.hpp>
@@ -726,7 +728,7 @@ struct ecl_grid_struct {
char * parent_name; /* the name of the parent for a nested lgr - for the main grid, and also a
lgr descending directly from the main grid this will be NULL. */
hash_type * children; /* a table of lgr children for this grid. */
std::unordered_map<std::string, ecl_grid_type*> children;
const ecl_grid_type * parent_grid; /* the parent grid for this (lgr) - NULL for the main grid. */
const ecl_grid_type * global_grid; /* the global grid - NULL for the main grid. */
@@ -739,7 +741,7 @@ struct ecl_grid_struct {
*/
vector_type * LGR_list; /* a vector of ecl_grid instances for LGRs - the index corresponds to the order LGRs are read from file*/
int_vector_type * lgr_index_map; /* a vector that maps LGR-nr for EGRID files to index into the LGR_list.*/
hash_type * LGR_hash; /* a hash of pointers to ecl_grid instances - for name based lookup of lgr. */
std::unordered_map<std::string, ecl_grid_type*> LGR_hash; /* a hash of pointers to ecl_grid instances - for name based lookup of lgr. */
int parent_box[6]; /* integers i1,i2, j1,j2, k1,k2 of the parent grid region containing this lgr. the indices are inclusive - zero offset */
/* not used yet .. */
@@ -1534,7 +1536,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid,
int nz,
int lgr_nr,
bool init_valid) {
ecl_grid_type * grid = (ecl_grid_type*)util_malloc(sizeof * grid );
ecl_grid_type * grid = new ecl_grid_type();
UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID);
grid->total_active = 0;
grid->total_active_fracture = 0;
@@ -1586,16 +1588,13 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid,
if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */
grid->LGR_list = vector_alloc_new();
grid->lgr_index_map = int_vector_alloc(0,0);
grid->LGR_hash = hash_alloc();
} else {
grid->LGR_list = NULL;
grid->lgr_index_map = NULL;
grid->LGR_hash = NULL;
}
grid->name = NULL;
grid->parent_name = NULL;
grid->parent_grid = NULL;
grid->children = hash_alloc();
grid->coarse_cells = vector_alloc_new();
grid->eclipse_version = 0;
@@ -2104,13 +2103,15 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , bool apply_mapaxes
static void ecl_grid_add_lgr( ecl_grid_type * main_grid , ecl_grid_type * lgr_grid) {
vector_append_owned_ref( main_grid->LGR_list , lgr_grid , ecl_grid_free__);
if ( lgr_grid->lgr_nr >= int_vector_size(main_grid->lgr_index_map) )
int_vector_resize( main_grid->lgr_index_map, lgr_grid->lgr_nr+1 , 0);
int_vector_iset(main_grid->lgr_index_map, lgr_grid->lgr_nr, vector_get_size(main_grid->LGR_list)-1);
hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_grid);
main_grid->LGR_hash[lgr_grid->name] = lgr_grid;
}
static void ecl_grid_install_lgr_common(ecl_grid_type * host_grid , ecl_grid_type * lgr_grid) {
hash_insert_ref( host_grid->children , lgr_grid->name , lgr_grid);
host_grid->children[lgr_grid->name] = lgr_grid;
lgr_grid->parent_grid = host_grid;
}
@@ -3027,12 +3028,12 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const
*/
const int * actnum_data = NULL;
if (ext_actnum)
actnum_data = ext_actnum;
actnum_data = ext_actnum;
else {
if (ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW) > grid_nr) {
actnum_kw = ecl_file_iget_named_kw(ecl_file, ACTNUM_KW, grid_nr);
actnum_data = ecl_kw_get_int_ptr(actnum_kw);
}
if (ecl_file_get_num_named_kw(ecl_file , ACTNUM_KW) > grid_nr) {
actnum_kw = ecl_file_iget_named_kw( ecl_file , ACTNUM_KW , grid_nr);
actnum_data = ecl_kw_get_int_ptr(actnum_kw);
}
}
if (grid_nr == 0) {
@@ -4625,17 +4626,15 @@ void ecl_grid_free(ecl_grid_type * grid) {
if (ECL_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */
vector_free( grid->LGR_list );
int_vector_free( grid->lgr_index_map);
hash_free( grid->LGR_hash );
}
if (grid->coord_kw != NULL)
ecl_kw_free( grid->coord_kw );
vector_free( grid->coarse_cells );
hash_free( grid->children );
free( grid->parent_name );
free( grid->visited );
free( grid->name );
free( grid );
delete grid;
}
@@ -5284,7 +5283,7 @@ ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * _
__assert_main_grid( main_grid );
{
char * lgr_name = util_alloc_strip_copy( __lgr_name );
ecl_grid_type * lgr_grid = (ecl_grid_type*)hash_get(main_grid->LGR_hash , lgr_name);
ecl_grid_type * lgr_grid = main_grid->LGR_hash.at(lgr_name);
free(lgr_name);
return lgr_grid;
}
@@ -5303,7 +5302,7 @@ bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name)
__assert_main_grid( main_grid );
{
char * lgr_name = util_alloc_strip_copy( __lgr_name );
bool has_lgr = hash_has_key( main_grid->LGR_hash , lgr_name );
bool has_lgr = main_grid->LGR_hash.count(lgr_name ) > 0;
free(lgr_name);
return has_lgr;
}
@@ -5425,7 +5424,10 @@ const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) {
stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) {
__assert_main_grid( ecl_grid );
{
return hash_alloc_stringlist( ecl_grid->LGR_hash );
stringlist_type * s = stringlist_alloc_new();
for (const auto& lgr_pair : ecl_grid->LGR_hash)
stringlist_append_copy(s, lgr_pair.first.c_str());
return s;
}
}
@@ -5892,14 +5894,12 @@ static bool ecl_grid_test_lgr_consistency2( const ecl_grid_type * parent , const
bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) {
hash_iter_type * lgr_iter = hash_iter_alloc( ecl_grid->children );
bool consistent = true;
while (!hash_iter_is_complete( lgr_iter )) {
const ecl_grid_type * lgr = (const ecl_grid_type*)hash_iter_get_next_value( lgr_iter );
for (const auto& lgr_pair : ecl_grid->children) {
const ecl_grid_type * lgr = lgr_pair.second;
consistent &= ecl_grid_test_lgr_consistency2( ecl_grid , lgr );
consistent &= ecl_grid_test_lgr_consistency( lgr );
}
hash_iter_free( lgr_iter );
return consistent;
}
@@ -6208,6 +6208,8 @@ static void ecl_grid_fwrite_GRID__( const ecl_grid_type * grid , int coords_size
}
}
}
ecl_kw_free(coords_kw);
ecl_kw_free(corners_kw);
}
}
@@ -6217,7 +6219,7 @@ void ecl_grid_fwrite_GRID2( const ecl_grid_type * grid , const char * filename,
bool fmt_file = false;
fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP );
if (hash_get_size( grid->children ) > 0)
if (grid->children.size() > 0)
coords_size = 7;
if (grid->coarsening_active)
@@ -6852,6 +6854,12 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio
void ecl_grid_fwrite_EGRID2( ecl_grid_type * grid , const char * filename, ert_ecl_unit_enum output_unit) {
bool fmt_file = false;
{
bool is_fmt;
if (ecl_util_get_file_type( filename , &is_fmt, NULL ) != ECL_OTHER_FILE)
fmt_file = is_fmt;
}
fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP );
ecl_grid_fwrite_EGRID__( grid , fortio, output_unit);

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_grid_cache.c' is part of ERT - Ensemble based
Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
Copyright (C) 2012 Equinor ASA, Norway.
The file 'ecl_init_file.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_io_config.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_kw.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -17,7 +17,7 @@
*/
#include <stdlib.h>
#include <ert/util/int_vector.hpp>
#include <vector>
#include <ert/ecl/ecl_file.hpp>
#include <ert/ecl/ecl_grid.hpp>
@@ -26,11 +26,47 @@
#include <ert/ecl/ecl_kw_magic.hpp>
int ecl_nnc_export_get_size( const ecl_grid_type * grid ) {
return ecl_grid_get_num_nnc( grid );
/**
* Return true if the NNC information is stored in the Intersect format, false otherwise.
* In the Intersect format, the NNC information stored in the grid is unrealiable.
* The correct NNC data is stored in the init file instead
*/
bool ecl_nnc_intersect_format(const ecl_grid_type * grid, const ecl_file_type * init_file) {
if( !ecl_file_has_kw(init_file, NNC1_KW) ||
!ecl_file_has_kw(init_file, NNC2_KW) ||
!ecl_file_has_kw(init_file, TRANNNC_KW))
return false;
// In the specific case we are treating, there should be just 1 occurrence of the kw
const auto nnc1_num = ecl_kw_get_size(ecl_file_iget_named_kw(init_file, NNC1_KW, 0));
const auto nnc2_num = ecl_kw_get_size(ecl_file_iget_named_kw(init_file, NNC2_KW, 0));
const auto tran_num = ecl_kw_get_size(ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0));
return nnc1_num == tran_num && nnc2_num == tran_num;
}
int ecl_nnc_export_get_size( const ecl_grid_type * grid , const ecl_file_type * init_file ) {
return ecl_nnc_intersect_format(grid, init_file) ?
ecl_kw_get_size(ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0)) : // Intersect format
ecl_grid_get_num_nnc( grid ); // Eclipse format
}
static int ecl_nnc_export_intersect__(const ecl_file_type * init_file , ecl_nnc_type * nnc_data, int * nnc_offset) {
const auto nnc1_kw = ecl_file_iget_named_kw(init_file, NNC1_KW, 0);
const auto nnc2_kw = ecl_file_iget_named_kw(init_file, NNC2_KW, 0);
const auto tran_kw = ecl_file_iget_named_kw(init_file, TRANNNC_KW, 0);
auto nnc_index = *nnc_offset;
for(int i = 0; i < ecl_kw_get_size(tran_kw); ++i) {
auto const nnc1 = ecl_kw_iget_int(nnc1_kw, i);
auto const nnc2 = ecl_kw_iget_int(nnc2_kw, i);
auto const tran = ecl_kw_iget_as_double(tran_kw, i);
nnc_data[nnc_index] = ecl_nnc_type{0, nnc1, 0, nnc2, i, tran};
++nnc_index;
}
*nnc_offset = nnc_index;
return ecl_kw_get_size(tran_kw); // Assume all valid
}
static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , const ecl_file_type * init_file , ecl_nnc_type * nnc_data, int * nnc_offset) {
@@ -50,8 +86,8 @@ static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , cons
int lgr_index2;
for (lgr_index2=0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) {
const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 );
const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
const std::vector<int>& grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
const std::vector<int>& nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector );
const ecl_kw_type * tran_kw = ecl_nnc_export_get_tranx_kw(global_grid , init_file , lgr_nr1 , lgr_nr2 );
@@ -63,8 +99,8 @@ static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , cons
nnc.global_index1 = global_index1;
for (index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) {
nnc.global_index2 = int_vector_iget( grid2_index_list , index2 );
nnc.input_index = int_vector_iget( nnc_index_list, index2 );
nnc.global_index2 = grid2_index_list[index2];
nnc.input_index = nnc_index_list[index2];
if(tran_kw) {
nnc.trans = ecl_kw_iget_as_double(tran_kw, nnc.input_index);
valid_trans++;
@@ -86,15 +122,21 @@ static int ecl_nnc_export__( const ecl_grid_type * grid , int lgr_index1 , cons
int ecl_nnc_export( const ecl_grid_type * grid , const ecl_file_type * init_file , ecl_nnc_type * nnc_data) {
int nnc_index = 0;
int total_valid_trans = 0;
total_valid_trans = ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index );
{
int lgr_index;
for (lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) {
ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index );
total_valid_trans += ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index );
}
if(ecl_nnc_intersect_format(grid, init_file)) {
// Intersect format
total_valid_trans = ecl_nnc_export_intersect__(init_file, nnc_data, &nnc_index);
}
else {
// Eclipse format
total_valid_trans = ecl_nnc_export__( grid , 0 , init_file , nnc_data , &nnc_index );
{
for (int lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) {
ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index );
total_valid_trans += ecl_nnc_export__( igrid , lgr_index , init_file , nnc_data , &nnc_index );
}
}
nnc_index = ecl_grid_get_num_nnc( grid );
}
nnc_index = ecl_nnc_export_get_size( grid );
ecl_nnc_sort( nnc_data , nnc_index );
return total_valid_trans;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (c) 2017 statoil asa, norway.
Copyright (c) 2017 equinor asa, norway.
The file 'ecl_nnc_geometry.c' is part of ert - ensemble based reservoir tool.
@@ -61,8 +61,8 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo ,
for (int lgr_index2 = 0; lgr_index2 < nnc_info_get_size( nnc_info ); lgr_index2++) {
const nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index2 );
const int_vector_type * grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
const int_vector_type * nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
const std::vector<int>& grid2_index_list = nnc_vector_get_grid_index_list( nnc_vector );
const std::vector<int>& nnc_index_list = nnc_vector_get_nnc_index_list( nnc_vector );
int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector );
for (int index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) {
@@ -70,8 +70,8 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo ,
pair.grid_nr1 = lgr_nr1;
pair.global_index1 = global_index1;
pair.grid_nr2 = lgr_nr2;
pair.global_index2 = int_vector_iget( grid2_index_list , index2 );
pair.input_index = int_vector_iget( nnc_index_list, index2 );
pair.global_index2 = grid2_index_list[index2];
pair.input_index = nnc_index_list[index2];
nnc_geo->data->push_back(pair);
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_region.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_rft_cell.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -366,3 +366,9 @@ int ecl_rft_cell_cmp__( const void * arg1 , const void * arg2) {
const ecl_rft_cell_type * cell2 = ecl_rft_cell_safe_cast_const( arg2 );
return ecl_rft_cell_cmp( cell1 , cell2 );
}
bool ecl_rft_cell_lt( const ecl_rft_cell_type * cell1 , const ecl_rft_cell_type * cell2) {
return (ecl_rft_cell_cmp(cell1, cell2) < 0);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_rft_file.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -25,10 +25,12 @@
#include <fnmatch.h>
#endif
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <ert/util/util.h>
#include <ert/util/hash.hpp>
#include <ert/util/vector.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/ecl/ecl_rft_file.hpp>
#include <ert/ecl/ecl_rft_node.hpp>
@@ -55,19 +57,19 @@
struct ecl_rft_file_struct {
UTIL_TYPE_ID_DECLARATION;
char * filename;
vector_type * data; /* This vector just contains all the rft nodes in one long vector. */
hash_type * well_index; /* This indexes well names into the data vector - very similar to the scheme used in ecl_file. */
std::string filename;
std::vector<ecl_rft_node_type *> data; /* This vector just contains all the rft nodes in one long vector. */
std::map<std::string, std::vector<int>> well_index;
};
static ecl_rft_file_type * ecl_rft_file_alloc_empty(const char * filename) {
ecl_rft_file_type * rft_vector = (ecl_rft_file_type*)util_malloc(sizeof * rft_vector );
ecl_rft_file_type * rft_vector = new ecl_rft_file_type();
UTIL_TYPE_ID_INIT( rft_vector , ECL_RFT_FILE_ID );
rft_vector->data = vector_alloc_new();
rft_vector->filename = util_alloc_string_copy(filename);
rft_vector->well_index = hash_alloc();
rft_vector->filename = std::string(filename);
return rft_vector;
}
@@ -82,8 +84,8 @@ UTIL_SAFE_CAST_FUNCTION( ecl_rft_file , ECL_RFT_FILE_ID );
UTIL_IS_INSTANCE_FUNCTION( ecl_rft_file , ECL_RFT_FILE_ID );
static void ecl_rft_file_add_node(ecl_rft_file_type * rft_vector , const ecl_rft_node_type * rft_node) {
vector_append_owned_ref( rft_vector->data , rft_node , ecl_rft_node_free__);
static void ecl_rft_file_add_node(ecl_rft_file_type * rft_vector , ecl_rft_node_type * rft_node) {
rft_vector->data.push_back(rft_node);
}
@@ -100,15 +102,12 @@ ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) {
if (rft_view) {
ecl_rft_node_type * rft_node = ecl_rft_node_alloc( rft_view );
if (rft_node != NULL) {
if (rft_node) {
const char * well_name = ecl_rft_node_get_well_name( rft_node );
ecl_rft_file_add_node(rft_vector , rft_node);
if (!hash_has_key( rft_vector->well_index , well_name))
hash_insert_hash_owned_ref( rft_vector->well_index , well_name , int_vector_alloc( 0 , 0 ) , int_vector_free__);
{
int_vector_type * index_list = (int_vector_type*)hash_get( rft_vector->well_index , well_name );
int_vector_append(index_list , global_index);
}
auto& index_vector = rft_vector->well_index[well_name];
index_vector.push_back(global_index);
global_index++;
}
} else
@@ -194,10 +193,10 @@ bool ecl_rft_file_case_has_rft( const char * case_input ) {
void ecl_rft_file_free(ecl_rft_file_type * rft_vector) {
vector_free(rft_vector->data);
hash_free( rft_vector->well_index );
free(rft_vector->filename);
free(rft_vector);
for (auto node_ptr : rft_vector->data)
ecl_rft_node_free( node_ptr );
delete rft_vector;
}
@@ -223,12 +222,11 @@ void ecl_rft_file_free__(void * arg) {
int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * well_pattern , time_t recording_time) {
if ((well_pattern == NULL) && (recording_time < 0))
return vector_get_size( rft_file->data );
return rft_file->data.size();
else {
int match_count = 0;
int i;
for ( i=0; i < vector_get_size( rft_file->data ); i++) {
const ecl_rft_node_type * rft = (const ecl_rft_node_type*)vector_iget_const( rft_file->data , i);
for (size_t i=0; i < rft_file->data.size(); i++) {
const ecl_rft_node_type * rft = rft_file->data[i];
if (well_pattern) {
if (util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )) != 0)
@@ -260,7 +258,7 @@ int ecl_rft_file_get_size( const ecl_rft_file_type * rft_file) {
const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) {
return rft_file->filename;
return rft_file->filename.c_str();
}
@@ -274,7 +272,7 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) {
*/
ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index) {
return (ecl_rft_node_type*)vector_iget( rft_file->data , index );
return rft_file->data[index];
}
@@ -306,30 +304,32 @@ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file ,
ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index) {
const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well);
return ecl_rft_file_iget_node( rft_file , int_vector_iget(index_vector , index));
const auto& index_vector = rft_file->well_index.at(well);
return ecl_rft_file_iget_node( rft_file , index_vector[index]);
}
static int ecl_rft_file_get_node_index_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) {
const auto& pair_iter = rft_file->well_index.find(well);
if (pair_iter == rft_file->well_index.end())
return -1;
int global_index = -1;
if (hash_has_key( rft_file->well_index , well)) {
const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well);
int well_index = 0;
while (true) {
if (well_index == int_vector_size( index_vector ))
size_t well_index = 0;
const auto& index_vector = pair_iter->second;
while (true) {
if (well_index == index_vector.size())
break;
{
const ecl_rft_node_type * node = ecl_rft_file_iget_node( rft_file , index_vector[well_index]);
if (ecl_rft_node_get_date( node ) == recording_time) {
global_index = index_vector[well_index];
break;
{
const ecl_rft_node_type * node = ecl_rft_file_iget_node( rft_file , int_vector_iget( index_vector , well_index ));
if (ecl_rft_node_get_date( node ) == recording_time) {
global_index = int_vector_iget( index_vector , well_index );
break;
}
}
well_index++;
}
well_index++;
}
return global_index;
}
@@ -355,7 +355,7 @@ ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rf
bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * well) {
return hash_has_key(rft_file->well_index , well);
return (rft_file->well_index.find(well) != rft_file->well_index.end());
}
@@ -364,8 +364,11 @@ bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * we
*/
int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well) {
const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well);
return int_vector_size( index_vector );
const auto& pair_iter = rft_file->well_index.find(well);
if (pair_iter == rft_file->well_index.end())
return 0;
else
return pair_iter->second.size();
}
@@ -373,13 +376,18 @@ int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const
Returns the number of distinct wells in RFT file.
*/
int ecl_rft_file_get_num_wells( const ecl_rft_file_type * rft_file ) {
return hash_get_size( rft_file->well_index );
return rft_file->well_index.size();
}
stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_file ) {
return hash_alloc_stringlist( rft_file->well_index );
stringlist_type * well_list = stringlist_alloc_new();
for (const auto& pair : rft_file->well_index)
stringlist_append_copy(well_list, pair.first.c_str());
return well_list;
}
@@ -396,7 +404,8 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes,
if (storage_index == -1) {
ecl_rft_file_add_node(rft_file, new_node);
} else {
vector_iset_owned_ref(rft_file->data, storage_index, new_node,ecl_rft_node_free__);
ecl_rft_node_free(rft_file->data[storage_index]);
rft_file->data[storage_index] = new_node;
}
}
}else{
@@ -410,7 +419,6 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes,
{
bool fmt_file = false;
fortio_type * fortio = fortio_open_writer( rft_file_name , fmt_file , ECL_ENDIAN_FLIP );
int node_index;
/**
The sorting here works directly on the internal node storage
@@ -421,9 +429,9 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes,
avoided for the rest of this function.
*/
vector_sort(rft_file->data,(vector_cmp_ftype *) ecl_rft_node_cmp);
for(node_index=0; node_index < vector_get_size( rft_file->data ); node_index++) {
const ecl_rft_node_type *new_node = (const ecl_rft_node_type*)vector_iget_const(rft_file->data, node_index);
std::sort(rft_file->data.begin(), rft_file->data.end(), ecl_rft_node_lt);
for(size_t node_index=0; node_index < rft_file->data.size(); node_index++) {
const ecl_rft_node_type *new_node = rft_file->data[node_index];
ecl_rft_node_fwrite(new_node, fortio, unit_set);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_rft_node.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -23,10 +23,11 @@
#include <stdbool.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <ert/util/util.h>
#include <ert/util/hash.hpp>
#include <ert/util/vector.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/ecl/ecl_kw.hpp>
#include <ert/ecl/ecl_kw_magic.hpp>
@@ -57,16 +58,14 @@
#define ECL_RFT_NODE_ID 887195
struct ecl_rft_node_struct {
UTIL_TYPE_ID_DECLARATION;
char * well_name; /* Name of the well. */
std::string well_name;
ecl_rft_enum data_type; /* What type of data: RFT|PLT|SEGMENT */
time_t recording_date; /* When was the RFT recorded - date.*/
double days; /* When was the RFT recorded - days after simulaton start. */
bool MSW;
bool sort_perm_in_sync ;
int_vector_type * sort_perm;
vector_type *cells;
std::vector<ecl_rft_cell_type *> cells;
};
@@ -106,15 +105,13 @@ static ecl_rft_enum translate_from_sting_to_ecl_rft_enum(const char * data_type_
ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days){
ecl_rft_enum data_type = translate_from_sting_to_ecl_rft_enum(data_type_string);
ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node );
ecl_rft_node_type * rft_node = new ecl_rft_node_type();
UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID );
rft_node->well_name = util_alloc_string_copy(well_name);
rft_node->cells = vector_alloc_new();
rft_node->well_name = std::string(well_name);
rft_node->recording_date = recording_date;
rft_node->days = days;
rft_node->data_type = data_type;
rft_node->sort_perm = NULL;
rft_node->sort_perm_in_sync = false;
return rft_node;
}
@@ -130,13 +127,10 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin
}
{
ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node );
UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID );
ecl_rft_node_type * rft_node = new ecl_rft_node_type();
rft_node->cells = vector_alloc_new();
UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID );
rft_node->data_type = data_type;
rft_node->sort_perm = NULL;
rft_node->sort_perm_in_sync = false;
return rft_node;
}
@@ -148,8 +142,11 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_rft_node , ECL_RFT_NODE_ID );
void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell) {
vector_append_owned_ref( rft_node->cells , cell , ecl_rft_cell_free__ );
rft_node->sort_perm_in_sync = false;
if (rft_node->MSW) {
auto pos_iter = std::upper_bound(rft_node->cells.begin(), rft_node->cells.end(), cell, ecl_rft_cell_lt);
rft_node->cells.insert(pos_iter, cell);
} else
rft_node->cells.push_back( cell );
}
@@ -273,8 +270,11 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_view_type * rft_view) {
if (rft_node != NULL) {
ecl_kw_type * date_kw = ecl_file_view_iget_named_kw( rft_view , DATE_KW , 0);
rft_node->well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX));
{
char * tmp = util_alloc_strip_copy( (const char*) ecl_kw_iget_ptr(welletc, WELLETC_NAME_INDEX));
rft_node->well_name = std::string( tmp );
free(tmp);
}
/* Time information. */
{
int * time = ecl_kw_get_int_ptr( date_kw );
@@ -293,18 +293,15 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_view_type * rft_view) {
const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * rft_node) {
return rft_node->well_name;
return rft_node->well_name.c_str();
}
void ecl_rft_node_free(ecl_rft_node_type * rft_node) {
for (auto cell_ptr : rft_node->cells)
ecl_rft_cell_free( cell_ptr );
free(rft_node->well_name);
vector_free( rft_node->cells );
if (rft_node->sort_perm)
int_vector_free( rft_node->sort_perm );
free(rft_node);
delete rft_node;
}
void ecl_rft_node_free__(void * void_node) {
@@ -316,7 +313,7 @@ void ecl_rft_node_free__(void * void_node) {
int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return vector_get_size( rft_node->cells ); }
int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return rft_node->cells.size(); }
time_t ecl_rft_node_get_date(const ecl_rft_node_type * rft_node) { return rft_node->recording_date; }
ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return rft_node->data_type; }
@@ -325,32 +322,13 @@ ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return
/* various functions to access properties at the cell level */
const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index) {
return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index );
return rft_node->cells[index];
}
static void ecl_rft_node_create_sort_perm( ecl_rft_node_type * rft_node ) {
if (rft_node->sort_perm)
int_vector_free( rft_node->sort_perm );
rft_node->sort_perm = vector_alloc_sort_perm( rft_node->cells , ecl_rft_cell_cmp__ );
rft_node->sort_perm_in_sync = true;
}
void ecl_rft_node_inplace_sort_cells( ecl_rft_node_type * rft_node ) {
vector_sort( rft_node->cells , ecl_rft_cell_cmp__ );
rft_node->sort_perm_in_sync = false; // The permutation is no longer sorted; however the vector itself is sorted ....
}
const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft_node , int index) {
if (ecl_rft_node_is_RFT( rft_node ))
return ecl_rft_node_iget_cell( rft_node , index );
else {
if (!rft_node->sort_perm_in_sync)
ecl_rft_node_create_sort_perm( rft_node );
return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index ));
}
return rft_node->cells[index];
}
@@ -396,14 +374,14 @@ static void assert_type_and_index( const ecl_rft_node_type * rft_node , ecl_rft_
if (rft_node->data_type != target_type)
util_abort("%s: wrong type \n",__func__);
if ((index < 0) || (index >= vector_get_size( rft_node->cells )))
if ((index < 0) || (index >= static_cast<int>(rft_node->cells.size())))
util_abort("%s: invalid index:%d \n",__func__ , index);
}
double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) {
assert_type_and_index( rft_node , RFT , index );
{
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index );
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell(rft_node, index);
return ecl_rft_cell_get_sgas( cell );
}
}
@@ -412,7 +390,7 @@ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) {
double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index) {
assert_type_and_index( rft_node , RFT , index );
{
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index );
const ecl_rft_cell_type * cell = rft_node->cells[index];
return ecl_rft_cell_get_swat( cell );
}
}
@@ -424,7 +402,7 @@ double ecl_rft_node_get_days(const ecl_rft_node_type * rft_node ){
double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) {
assert_type_and_index( rft_node , RFT , index );
{
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index );
const ecl_rft_cell_type * cell = rft_node->cells[index];
return ecl_rft_cell_get_soil( cell );
}
}
@@ -435,7 +413,7 @@ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) {
double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) {
assert_type_and_index( rft_node , PLT , index );
{
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index );
const ecl_rft_cell_type * cell = rft_node->cells[index];
return ecl_rft_cell_get_orat( cell );
}
}
@@ -444,7 +422,7 @@ double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) {
double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) {
assert_type_and_index( rft_node , PLT , index );
{
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index);
const ecl_rft_cell_type * cell = rft_node->cells[index];
return ecl_rft_cell_get_wrat( cell );
}
}
@@ -453,7 +431,7 @@ double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) {
double ecl_rft_node_iget_grat( const ecl_rft_node_type * rft_node , int index) {
assert_type_and_index( rft_node , PLT , index );
{
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index);
const ecl_rft_cell_type * cell = rft_node->cells[index];
return ecl_rft_cell_get_grat( cell );
}
}
@@ -591,10 +569,9 @@ void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * forti
ecl_kw_type * pressure = ecl_kw_alloc(PRESSURE_KW, size_cells, ECL_FLOAT);
ecl_kw_type * swat = ecl_kw_alloc(SWAT_KW, size_cells, ECL_FLOAT);
ecl_kw_type * sgas = ecl_kw_alloc(SGAS_KW, size_cells, ECL_FLOAT);
int i;
for(i =0;i<size_cells;i++){
const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , i);
for(int i =0;i<size_cells;i++){
const ecl_rft_cell_type * cell = rft_node->cells[i];
ecl_kw_iset_int(conipos, i, ecl_rft_cell_get_i(cell)+1);
ecl_kw_iset_int(conjpos, i, ecl_rft_cell_get_j(cell)+1);
ecl_kw_iset_int(conkpos, i, ecl_rft_cell_get_k(cell)+1);
@@ -636,4 +613,6 @@ int ecl_rft_node_cmp( const ecl_rft_node_type * n1 , const ecl_rft_node_type * n
}
bool ecl_rft_node_lt(const ecl_rft_node_type * n1, const ecl_rft_node_type * n2) {
return (ecl_rft_node_cmp(n1, n2) < 0);
}

View File

@@ -1,6 +1,6 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
Copyright (C) 2012 Equinor ASA, Norway.
The file 'ecl_rst_file.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_rsthead.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -88,10 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ
// The only derived quantity
rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year );
}
if (doubhead_kw)
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
if (logihead_kw)
rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX);
@@ -112,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ
ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) {
const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0);
const ecl_kw_type * doubhead_kw = NULL;
const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0);
const ecl_kw_type * logihead_kw = NULL;
if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW))
logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0);
if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW))
doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0);
if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) {
const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0);
report_step = ecl_kw_iget_int( seqnum_kw , 0);

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_subsidence.c' is part of ERT - Ensemble based
Reservoir Tool.
@@ -75,6 +75,7 @@ struct ecl_subsidence_survey_struct {
char * name; /* Name of the survey - arbitrary string. */
double * porv; /* Reference pore volume */
double * pressure; /* Pressure in each grid cell at survey time */
double * dynamic_porevolume; /* Porevolume in each grid cell at survey time */
};
@@ -92,6 +93,7 @@ static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_empty(const ecl_
survey->porv = (double*) util_calloc( sub->grid_cache->size() , sizeof * survey->porv );
survey->pressure = (double*) util_calloc( sub->grid_cache->size() , sizeof * survey->pressure );
survey->dynamic_porevolume = NULL;
return survey;
}
@@ -111,9 +113,18 @@ static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_PRESSURE(ecl_sub
ecl_kw_type * init_porv_kw = ecl_file_iget_named_kw( ecl_subsidence->init_file , PORV_KW , 0); /*Global indexing*/
ecl_kw_type * pressure_kw = ecl_file_view_iget_named_kw( restart_view , PRESSURE_KW , 0); /*Active indexing*/
ecl_kw_type * rporv_kw = NULL;
if(ecl_file_view_has_kw(restart_view, RPORV_KW)) {
survey->dynamic_porevolume = (double*) util_calloc( ecl_subsidence->grid_cache->size() , sizeof * survey->dynamic_porevolume);
rporv_kw = ecl_file_view_iget_named_kw(restart_view, RPORV_KW, 0);
}
for (active_index = 0; active_index < size; active_index++){
survey->porv[ active_index ] = ecl_kw_iget_float( init_porv_kw , global_index[active_index] );
survey->pressure[ active_index ] = ecl_kw_iget_float( pressure_kw , active_index );
if(rporv_kw)
survey->dynamic_porevolume[ active_index ] = ecl_kw_iget_float(rporv_kw, active_index);
}
return survey;
}
@@ -126,6 +137,7 @@ static void ecl_subsidence_survey_free( ecl_subsidence_survey_type * subsidence_
free( subsidence_survey->name );
free( subsidence_survey->porv );
free( subsidence_survey->pressure );
free( subsidence_survey->dynamic_porevolume );
free( subsidence_survey );
}
@@ -193,6 +205,47 @@ static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_t
}
static double ecl_subsidence_survey_eval_geertsma_rporv( const ecl_subsidence_survey_type * base_survey ,
const ecl_subsidence_survey_type * monitor_survey,
ecl_region_type * region ,
double utm_x , double utm_y , double depth,
double youngs_modulus, double poisson_ratio, double seabed) {
const ecl::ecl_grid_cache& grid_cache = *(base_survey->grid_cache);
std::vector<double> weight(grid_cache.size());
if(!base_survey->dynamic_porevolume) {
util_abort(
"%s: Keyword RPORV not defined in .UNRST file for %s. Please add RPORV keyword to output in RPTRST clause in .DATA file.\n",
__func__, base_survey->name);
}
if(monitor_survey && !monitor_survey->dynamic_porevolume) {
util_abort(
"%s: Keyword RPORV not defined in .UNRST file for %s. Please add RPORV keyword to output in RPTRST clause in .DATA file.\n",
__func__, monitor_survey->name);
}
for (size_t index = 0; index < weight.size(); ++index) {
if (monitor_survey)
weight[index] = (base_survey->dynamic_porevolume[index] - monitor_survey->dynamic_porevolume[index]) / (4*M_PI);
else
weight[index] = base_survey->dynamic_porevolume[index] / (4*M_PI);
}
return ecl_grav_common_eval_geertsma(
grid_cache,
region,
base_survey->aquifer_cell,
weight.data(),
utm_x,
utm_y,
depth,
poisson_ratio,
seabed
);
}
/*****************************************************************/
/**
@@ -254,6 +307,14 @@ double ecl_subsidence_eval_geertsma( const ecl_subsidence_type * subsidence , co
return ecl_subsidence_survey_eval_geertsma( base_survey , monitor_survey , region , utm_x , utm_y , depth , youngs_modulus, poisson_ratio, seabed);
}
double ecl_subsidence_eval_geertsma_rporv( const ecl_subsidence_type * subsidence , const char * base, const char * monitor , ecl_region_type * region ,
double utm_x, double utm_y , double depth,
double youngs_modulus, double poisson_ratio, double seabed) {
ecl_subsidence_survey_type * base_survey = ecl_subsidence_get_survey( subsidence , base );
ecl_subsidence_survey_type * monitor_survey = ecl_subsidence_get_survey( subsidence , monitor );
return ecl_subsidence_survey_eval_geertsma_rporv( base_survey , monitor_survey , region , utm_x , utm_y , depth , youngs_modulus, poisson_ratio, seabed);
}
void ecl_subsidence_free( ecl_subsidence_type * ecl_subsidence ) {
delete ecl_subsidence->grid_cache;

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_sum.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -290,32 +290,16 @@ void ecl_sum_set_fmt_case( ecl_sum_type * ecl_sum , bool fmt_case ) {
smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value) {
const ecl::smspec_node * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value) {
if (ecl_sum_data_get_length(ecl_sum->data) > 0)
throw std::invalid_argument("Can not interchange variable adding and timesteps.\n");
smspec_node_type * smspec_node = smspec_node_alloc( ecl_smspec_identify_var_type(keyword),
wgname,
keyword,
unit,
ecl_sum->key_join_string,
ecl_smspec_get_grid_dims(ecl_sum->smspec),
num,
-1,
default_value);
ecl_smspec_add_node(ecl_sum->smspec, smspec_node);
ecl_sum_data_reset_self_map( ecl_sum->data );
return smspec_node;
return ecl_smspec_add_node( ecl_sum->smspec, keyword, wgname, num, unit, default_value);
}
smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node) {
return ecl_sum_add_var(ecl_sum,
smspec_node_get_keyword(node),
smspec_node_get_wgname(node),
smspec_node_get_num(node),
smspec_node_get_unit(node),
smspec_node_get_default(node));
const ecl::smspec_node * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const ecl::smspec_node * node) {
return ecl_smspec_add_node(ecl_sum->smspec, *node);
}
@@ -335,7 +319,8 @@ smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_
*/
ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_seconds) {
return ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_seconds );
ecl_sum_tstep_type * new_tstep = ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_seconds );
return new_tstep;
}
static ecl_sum_type * ecl_sum_alloc_writer__( const char * ecl_case , const char * restart_case , int restart_step, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) {
@@ -516,12 +501,12 @@ bool ecl_sum_case_exists( const char * input_file ) {
/*****************************************************************/
double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const smspec_node_type * node) {
return ecl_sum_data_get_from_sim_time( ecl_sum->data , sim_time , node );
double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const ecl::smspec_node * node) {
return ecl_sum_data_get_from_sim_time( ecl_sum->data , sim_time , *node );
}
double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const smspec_node_type * node) {
return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , node );
double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const ecl::smspec_node * node) {
return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , *node );
}
double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time) {
@@ -559,13 +544,13 @@ double ecl_sum_get_well_var(const ecl_sum_type * ecl_sum , int time_index , con
}
double ecl_sum_get_well_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * well , const char * var) {
const smspec_node_type * node = ecl_smspec_get_well_var_node( ecl_sum->smspec , well , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node );
const ecl::smspec_node& node = ecl_smspec_get_well_var_node( ecl_sum->smspec , well , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , &node );
}
double ecl_sum_get_well_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * well , const char * var) {
const smspec_node_type * node = ecl_smspec_get_well_var_node( ecl_sum->smspec , well , var );
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node );
const ecl::smspec_node& node = ecl_smspec_get_well_var_node( ecl_sum->smspec , well , var );
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , &node );
}
@@ -583,13 +568,13 @@ double ecl_sum_get_group_var(const ecl_sum_type * ecl_sum , int time_index , co
double ecl_sum_get_group_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * group , const char * var) {
const smspec_node_type * node = ecl_smspec_get_group_var_node( ecl_sum->smspec , group , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node );
const ecl::smspec_node& node = ecl_smspec_get_group_var_node( ecl_sum->smspec , group , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , &node );
}
double ecl_sum_get_group_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * group , const char * var) {
const smspec_node_type * node = ecl_smspec_get_group_var_node( ecl_sum->smspec , group , var );
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node );
const ecl::smspec_node& node = ecl_smspec_get_group_var_node( ecl_sum->smspec , group , var );
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , &node );
}
@@ -605,13 +590,13 @@ double ecl_sum_get_field_var(const ecl_sum_type * ecl_sum , int time_index , con
}
double ecl_sum_get_field_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) {
const smspec_node_type * node = ecl_smspec_get_field_var_node( ecl_sum->smspec , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node );
const ecl::smspec_node& node = ecl_smspec_get_field_var_node( ecl_sum->smspec , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , &node );
}
double ecl_sum_get_field_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var) {
const smspec_node_type * node = ecl_smspec_get_field_var_node( ecl_sum->smspec , var );
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node );
const ecl::smspec_node& node = ecl_smspec_get_field_var_node( ecl_sum->smspec , var );
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , &node );
}
@@ -641,13 +626,13 @@ double ecl_sum_get_block_var_ijk(const ecl_sum_type * ecl_sum , int time_index ,
}
double ecl_sum_get_block_var_ijk_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * block_var, int i , int j , int k) {
const smspec_node_type * node = ecl_smspec_get_block_var_node_ijk( ecl_sum->smspec , block_var , i ,j , k);
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node );
const ecl::smspec_node& node = ecl_smspec_get_block_var_node_ijk( ecl_sum->smspec , block_var , i ,j , k);
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , &node );
}
double ecl_sum_get_block_var_ijk_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * block_var, int i , int j , int k) {
const smspec_node_type * node = ecl_smspec_get_block_var_node_ijk( ecl_sum->smspec , block_var , i ,j , k);
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node );
const ecl::smspec_node& node = ecl_smspec_get_block_var_node_ijk( ecl_sum->smspec , block_var , i ,j , k);
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , &node );
}
@@ -668,13 +653,13 @@ double ecl_sum_get_region_var(const ecl_sum_type * ecl_sum , int time_index , co
}
double ecl_sum_get_region_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var , int region_nr) {
const smspec_node_type * node = ecl_smspec_get_region_var_node( ecl_sum->smspec , var , region_nr);
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node );
const ecl::smspec_node& node = ecl_smspec_get_region_var_node( ecl_sum->smspec , var , region_nr);
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , &node );
}
double ecl_sum_get_region_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var , int region_nr) {
const smspec_node_type * node = ecl_smspec_get_region_var_node( ecl_sum->smspec , var , region_nr);
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , node );
const ecl::smspec_node& node = ecl_smspec_get_region_var_node( ecl_sum->smspec , var , region_nr);
return ecl_sum_get_from_sim_days( ecl_sum , sim_days , &node );
}
@@ -715,14 +700,9 @@ double ecl_sum_get_well_completion_var(const ecl_sum_type * ecl_sum , int time_i
/*****************************************************************/
/* General variables - this means WWCT:OP_1 - i.e. composite variables*/
const smspec_node_type * ecl_sum_get_general_var_node(const ecl_sum_type * ecl_sum , const char * lookup_kw) {
const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , lookup_kw );
if (node != NULL)
return node;
else {
util_abort("%s: summary case:%s does not contain key:%s\n",__func__ , ecl_sum_get_case( ecl_sum ) , lookup_kw );
return NULL;
}
const ecl::smspec_node * ecl_sum_get_general_var_node(const ecl_sum_type * ecl_sum , const char * lookup_kw) {
const ecl::smspec_node& node = ecl_smspec_get_general_var_node( ecl_sum->smspec , lookup_kw );
return &node;
}
int ecl_sum_get_general_var_params_index(const ecl_sum_type * ecl_sum , const char * lookup_kw) {
@@ -761,30 +741,38 @@ void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type * ecl_sum, time_t sim_tim
double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , var );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , var );
return ecl_sum_get_from_sim_time( ecl_sum , sim_time , node );
}
double ecl_sum_get_general_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , var );
return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , node );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , var );
return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , *node );
}
const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const char * var) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , var );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , var );
return smspec_node_get_unit( node );
}
/*****************************************************************/
ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times) {
time_t start_time = ecl_sum_get_data_start(ecl_sum);
ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times, bool lower_extrapolation, bool upper_extrapolation) {
/*
If lower and / or upper extrapolation is set to true it makes sure that resampling returns the first / last value of the simulation
or in the case of derivate / rate then it gets zero. if these are set to false, we jus throw exception
*/
if ( time_t_vector_get_first(times) < start_time )
time_t start_time = ecl_sum_get_data_start(ecl_sum);
time_t end_time = ecl_sum_get_end_time(ecl_sum);
time_t input_start = time_t_vector_get_first( times );
time_t input_end = time_t_vector_get_last( times );
if ( !lower_extrapolation && input_start < start_time )
return NULL;
if ( time_t_vector_get_last(times) > ecl_sum_get_end_time(ecl_sum) )
if ( !upper_extrapolation && input_end > end_time)
return NULL;
if ( !time_t_vector_is_sorted(times, false) )
return NULL;
@@ -792,38 +780,57 @@ ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char *
const int * grid_dims = ecl_smspec_get_grid_dims(ecl_sum->smspec);
bool time_in_days = false;
const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, 0);
if ( util_string_equal(smspec_node_get_unit(node), "DAYS" ) )
const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, 0);
if ( util_string_equal(smspec_node_get_unit(&node), "DAYS" ) )
time_in_days = true;
ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_writer( ecl_case , ecl_sum->fmt_case , ecl_sum->unified , ecl_sum->key_join_string , start_time , time_in_days , grid_dims[0] , grid_dims[1] , grid_dims[2] );
//create elc_sum_resampled with TIME node only
ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_writer( ecl_case , ecl_sum->fmt_case , ecl_sum->unified , ecl_sum->key_join_string , input_start , time_in_days , grid_dims[0] , grid_dims[1] , grid_dims[2] );
//add remaining nodes
for (int i = 0; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) {
const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, i);
if (util_string_equal(smspec_node_get_gen_key1(node), "TIME"))
const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i);
if (util_string_equal(smspec_node_get_gen_key1(&node), "TIME"))
continue;
ecl_sum_add_smspec_node( ecl_sum_resampled, node );
ecl_sum_add_smspec_node( ecl_sum_resampled, &node );
}
/*
The SMSPEC header structure has been completely initialized, it is time to
start filling it up with data.
*/
ecl_sum_vector_type * ecl_sum_vector = ecl_sum_vector_alloc(ecl_sum, true);
double_vector_type * data = double_vector_alloc( ecl_sum_vector_get_size(ecl_sum_vector) , 0);
for (int report_step = 0; report_step < time_t_vector_size(times); report_step++) {
time_t t = time_t_vector_iget(times, report_step);
/* Look up interpolated data in the original case. */
ecl_sum_get_interp_vector( ecl_sum, t, ecl_sum_vector, data);
time_t input_t = time_t_vector_iget(times, report_step);
if (input_t < start_time) {
//clamping to the first value for t < start_time or if it is a rate than derivative is 0
for (int i=1; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) {
double value = 0;
const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i);
if (!node.is_rate())
value = ecl_sum_iget_first_value(ecl_sum, node.get_params_index());
double_vector_iset(data, i-1, value);
}
} else if (input_t > end_time) {
//clamping to the last value for t > end_time or if it is a rate than derivative is 0
for (int i=1; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) {
double value = 0;
const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index(ecl_sum->smspec, i);
if (!node.is_rate())
value = ecl_sum_iget_last_value(ecl_sum, node.get_params_index());
double_vector_iset(data, i-1, value);
}
} else {
/* Look up interpolated data in the original case. */
ecl_sum_get_interp_vector( ecl_sum, input_t, ecl_sum_vector, data);
}
/* Add timestep corresponding to the interpolated data in the resampled case. */
ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum_resampled , report_step , t - start_time);
ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum_resampled , report_step , input_t - input_start);
for (int data_index = 0; data_index < ecl_sum_vector_get_size(ecl_sum_vector); data_index++) {
double value = double_vector_iget(data,data_index);
int params_index = data_index + 1; // The +1 shift is because the first element in the tstep is time value.
@@ -844,12 +851,12 @@ double ecl_sum_iget( const ecl_sum_type * ecl_sum , int time_index , int param_i
/* Simple get functions which take a general var key as input */
bool ecl_sum_var_is_rate( const ecl_sum_type * ecl_sum , const char * gen_key) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_is_rate( node );
}
bool ecl_sum_var_is_total( const ecl_sum_type * ecl_sum , const char * gen_key) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_is_total( node );
}
@@ -859,27 +866,27 @@ ecl_smspec_var_type ecl_sum_identify_var_type( const char * var ) {
}
ecl_smspec_var_type ecl_sum_get_var_type( const ecl_sum_type * ecl_sum , const char * gen_key) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_get_var_type( node );
}
const char * ecl_sum_get_unit( const ecl_sum_type * ecl_sum , const char * gen_key) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_get_unit( node );
}
int ecl_sum_get_num( const ecl_sum_type * ecl_sum , const char * gen_key ) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_get_num( node );
}
const char * ecl_sum_get_wgname( const ecl_sum_type * ecl_sum , const char * gen_key ) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_get_wgname( node );
}
const char * ecl_sum_get_keyword( const ecl_sum_type * ecl_sum , const char * gen_key ) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return smspec_node_get_keyword( node );
}
@@ -932,7 +939,7 @@ void ecl_sum_init_double_vector(const ecl_sum_type * ecl_sum, const char * gen_k
}
void ecl_sum_init_double_vector_interp(const ecl_sum_type * ecl_sum, const char * gen_key, const time_t_vector_type * time_points, double * data) {
const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key);
const ecl::smspec_node& node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key);
ecl_sum_data_init_double_vector_interp(ecl_sum->data, node, time_points, data);
}
@@ -1305,7 +1312,7 @@ stringlist_type * ecl_sum_alloc_well_var_list( const ecl_sum_type * ecl_sum ) {
void ecl_sum_resample_from_sim_time( const ecl_sum_type * ecl_sum , const time_t_vector_type * sim_time , double_vector_type * value , const char * gen_key) {
const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key);
const ecl::smspec_node& node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key);
double_vector_reset( value );
{
int i;
@@ -1316,7 +1323,7 @@ void ecl_sum_resample_from_sim_time( const ecl_sum_type * ecl_sum , const time_t
void ecl_sum_resample_from_sim_days( const ecl_sum_type * ecl_sum , const double_vector_type * sim_days , double_vector_type * value , const char * gen_key) {
const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key);
const ecl::smspec_node& node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key);
double_vector_reset( value );
{
int i;
@@ -1377,7 +1384,7 @@ int ecl_sum_get_report_step_from_days( const ecl_sum_type * sum , double sim_day
/*****************************************************************/
const ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum ) {
ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum ) {
return ecl_sum->smspec;
}
@@ -1430,8 +1437,8 @@ bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_s
double_vector_type * ecl_sum_alloc_seconds_solution( const ecl_sum_type * ecl_sum , const char * gen_key , double cmp_value , bool rates_clamp_lower) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key);
return ecl_sum_data_alloc_seconds_solution( ecl_sum->data , node , cmp_value , rates_clamp_lower);
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key);
return ecl_sum_data_alloc_seconds_solution( ecl_sum->data , *node , cmp_value , rates_clamp_lower);
}
@@ -1467,11 +1474,11 @@ double ecl_sum_iget_last_value(const ecl_sum_type * ecl_sum, int param_index) {
}
double ecl_sum_get_last_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node));
}
double ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node) {
double ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const ecl::smspec_node *node) {
return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node));
}
@@ -1480,10 +1487,10 @@ double ecl_sum_iget_first_value(const ecl_sum_type * ecl_sum, int param_index) {
}
double ecl_sum_get_first_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum , gen_key );
return ecl_sum_iget_first_value(ecl_sum, smspec_node_get_params_index(node));
}
double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node) {
double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const ecl::smspec_node *node) {
return ecl_sum_iget_first_value(ecl_sum, smspec_node_get_params_index(node));
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_sum_data.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -458,16 +458,24 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da
sequence has no holes.
*/
static void fprintf_date_utc(time_t t , FILE * stream) {
int mday,year,month;
util_set_datetime_values_utc(t , NULL , NULL , NULL , &mday , &month , &year);
fprintf(stream , "%02d/%02d/%4d", mday,month,year);
}
static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) {
if (!ecl_sum_data_check_sim_time(data, sim_time)) {
time_t start_time = ecl_sum_data_get_data_start(data);
time_t end_time = ecl_sum_data_get_sim_end(data);
fprintf(stderr , "Simulation start: "); util_fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr );
fprintf(stderr , "Data start......: "); util_fprintf_date_utc( start_time , stderr );
fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( end_time , stderr );
fprintf(stderr , "Requested date .: "); util_fprintf_date_utc( sim_time , stderr );
fprintf(stderr , "Simulation start: "); fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr );
fprintf(stderr , "Data start......: "); fprintf_date_utc( start_time , stderr );
fprintf(stderr , "Simulation end .: "); fprintf_date_utc( end_time , stderr );
fprintf(stderr , "Requested date .: "); fprintf_date_utc( sim_time , stderr );
util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , start_time, end_time);
}
@@ -569,9 +577,9 @@ void ecl_sum_data_init_interp_from_sim_days( const ecl_sum_data_type * data , do
}
double_vector_type * ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type * data, const smspec_node_type * node, double cmp_value, bool rates_clamp_lower) {
double_vector_type * ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type * data, const ecl::smspec_node& node, double cmp_value, bool rates_clamp_lower) {
double_vector_type * solution = double_vector_alloc(0, 0);
const int param_index = smspec_node_get_params_index(node);
const int param_index = smspec_node_get_params_index(&node);
const int size = ecl_sum_data_get_length(data);
if (size <= 1)
@@ -593,7 +601,7 @@ double_vector_type * ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type
double prev_time = ecl_sum_data_iget_sim_seconds(data, prev_index);
double time = ecl_sum_data_iget_sim_seconds(data, index);
if (smspec_node_is_rate(node)) {
if (smspec_node_is_rate(&node)) {
double_vector_append(solution, rates_clamp_lower ? prev_time + 1 : time);
} else {
double slope = (value - prev_value) / (time - prev_time);
@@ -811,8 +819,8 @@ double ecl_sum_data_iget( const ecl_sum_data_type * data , int time_index , int
if (params_map[params_index] >= 0)
return file_data->iget( time_index - index_node.offset, params_map[params_index] );
else {
const smspec_node_type * smspec_node = ecl_smspec_iget_node(data->smspec, params_index);
return smspec_node_get_default(smspec_node);
const ecl::smspec_node& smspec_node = ecl_smspec_iget_node_w_params_index(data->smspec, params_index);
return smspec_node.get_default();
}
}
@@ -905,9 +913,9 @@ void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim
}
}
double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node) {
int params_index = smspec_node_get_params_index( smspec_node );
if (smspec_node_is_rate( smspec_node )) {
double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const ecl::smspec_node& smspec_node) {
int params_index = smspec_node_get_params_index( &smspec_node );
if (smspec_node_is_rate( &smspec_node )) {
/*
In general the mapping from sim_time to index is based on half
open intervals, which are closed in the upper end:
@@ -986,7 +994,7 @@ double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time)
return util_difftime_days( start_time , sim_time );
}
double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node) {
double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const ecl::smspec_node& smspec_node) {
time_t sim_time = ecl_smspec_get_start_time( data->smspec );
util_inplace_forward_days_utc( &sim_time , sim_days );
return ecl_sum_data_get_from_sim_time( data , sim_time , smspec_node );
@@ -1076,22 +1084,18 @@ static void ecl_sum_data_init_double_vector__(const ecl_sum_data_type * data, in
const auto& params_map = index_node.params_map;
int params_index = params_map[main_params_index];
if (report_only) {
const smspec_node_type * smspec_node = ecl_smspec_iget_node(data->smspec, main_params_index);
double default_value = smspec_node_get_default(smspec_node);
const ecl::smspec_node& smspec_node = ecl_smspec_iget_node_w_params_index(data->smspec, main_params_index);
double default_value = smspec_node.get_default();
offset += data_file->get_data_report(params_index, index_node.length, &output_data[offset], default_value);
} else {
if (params_index >= 0)
data_file->get_data(params_index, index_node.length, &output_data[offset]);
else {
const smspec_node_type * smspec_node = ecl_smspec_iget_node(data->smspec, main_params_index);
if (smspec_node)
{
for (int i=0; i < index_node.length; i++)
output_data[offset + i] = smspec_node_get_default(smspec_node);
}
const ecl::smspec_node& smspec_node = ecl_smspec_iget_node_w_params_index(data->smspec, main_params_index);
for (int i=0; i < index_node.length; i++)
output_data[offset + i] = smspec_node.get_default();
}
offset += index_node.length;
}
@@ -1118,6 +1122,9 @@ double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * d
else
output_data.resize( ecl_sum_data_get_length(data) );
if (params_index >= ecl_smspec_get_params_size(data->smspec))
throw std::out_of_range("Out of range");
ecl_sum_data_init_double_vector__(data, params_index, output_data.data(), report_only);
double_vector_type * data_vector = double_vector_alloc(output_data.size(), 0);
{
@@ -1129,11 +1136,11 @@ double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * d
void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data,
const smspec_node_type * smspec_node,
const ecl::smspec_node& smspec_node,
const time_t_vector_type * time_points,
double * output_data) {
bool is_rate = smspec_node_is_rate(smspec_node);
int params_index = smspec_node_get_params_index(smspec_node);
bool is_rate = smspec_node_is_rate(&smspec_node);
int params_index = smspec_node_get_params_index(&smspec_node);
time_t start_time = ecl_sum_data_get_data_start(data);
time_t end_time = ecl_sum_data_get_sim_end(data);
double start_value = 0;

View File

@@ -471,7 +471,8 @@ void ecl_sum_file_data::fwrite_report( int report_step , fortio_type * fortio) c
auto range = this->report_range( report_step );
for (int index = range.first; index <= range.second; index++) {
const ecl_sum_tstep_type * tstep = iget_ministep( index );
ecl_sum_tstep_fwrite( tstep , ecl_smspec_get_index_map( ecl_smspec ) , fortio );
//ecl_sum_tstep_fwrite( tstep , ecl_smspec_get_index_map( ecl_smspec ) , fortio );
ecl_sum_tstep_fwrite( tstep , ecl_smspec_get_index_map(ecl_smspec) , ecl_smspec_num_nodes(ecl_smspec), fortio );
}
}
}
@@ -553,7 +554,7 @@ bool ecl_sum_file_data::check_file( ecl_file_type * ecl_file ) {
calling routine will read the unified summary file partly.
*/
void ecl_sum_file_data::add_ecl_file(int report_step, const ecl_file_view_type * summary_view, const ecl_smspec_type * smspec) {
void ecl_sum_file_data::add_ecl_file(int report_step, const ecl_file_view_type * summary_view) {
int num_ministep = ecl_file_view_get_num_named_kw( summary_view , PARAMS_KW);
if (num_ministep > 0) {
@@ -569,7 +570,7 @@ void ecl_sum_file_data::add_ecl_file(int report_step, const ecl_file_view_type *
ministep_nr ,
params_kw ,
ecl_file_view_get_src_file( summary_view ),
smspec );
this->ecl_smspec );
if (tstep)
append_tstep( tstep );
@@ -600,7 +601,7 @@ bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load,
{
ecl_file_type * ecl_file = ecl_file_open( data_file , 0);
if (ecl_file && check_file( ecl_file )) {
add_ecl_file( report_step , ecl_file_get_global_view( ecl_file ) , ecl_smspec);
this->add_ecl_file( report_step , ecl_file_get_global_view( ecl_file ));
ecl_file_close( ecl_file );
}
}
@@ -632,7 +633,7 @@ bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load,
*/
ecl_file_view_type * summary_view = ecl_file_get_summary_view(ecl_file , block_index);
if (summary_view) {
add_ecl_file(block_index + first_report_step , summary_view , ecl_smspec);
this->add_ecl_file(block_index + first_report_step , summary_view);
block_index++;
} else break;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_sum_index.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
/*
Copyright (C) 2012 Equinor ASA, Norway.
The file 'ecl_sum_tstep.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -19,6 +19,8 @@
#include <time.h>
#include <math.h>
#include <vector>
#include <ert/util/util.h>
#include <ert/util/type_macros.hpp>
@@ -59,12 +61,11 @@ Header direction: ecl_smspec DAYS WWCT:OP_3 FOPT BPR:15,10,25
struct ecl_sum_tstep_struct {
UTIL_TYPE_ID_DECLARATION;
float * data; /* A memcpy copy of the PARAMS vector in ecl_kw instance - the raw data. */
std::vector<float> data; /* A memcpy copy of the PARAMS vector in ecl_kw instance - the raw data. */
time_t sim_time; /* The true time (i.e. 20.th of october 2010) of corresponding to this timestep. */
int ministep; /* The ECLIPSE internal time-step number; one ministep per numerical timestep. */
int report_step; /* The report step this time-step is part of - in general there can be many timestep for each report step. */
double sim_seconds; /* Accumulated simulation time up to this ministep. */
int data_size; /* Number of elements in data - only used for checking indices. */
int internal_index; /* Used for lookups of the next / previous ministep based on an existing ministep. */
const ecl_smspec_type * smspec; /* The smespec header information for this tstep - must be compatible. */
};
@@ -72,11 +73,13 @@ struct ecl_sum_tstep_struct {
ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * src , const ecl_smspec_type * new_smspec, float default_value , const int * params_map) {
int params_size = ecl_smspec_get_params_size( new_smspec );
ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src );
ecl_sum_tstep_type * target = new ecl_sum_tstep_type();
UTIL_TYPE_ID_INIT( target , ECL_SUM_TSTEP_ID);
target->report_step = src->report_step;
target->ministep = src->ministep;
target->smspec = new_smspec;
target->data = (float*)util_malloc( params_size * sizeof * target->data );
target->data_size = params_size;
target->data.resize(params_size);
for (int i=0; i < params_size; i++) {
if (params_map[i] >= 0)
@@ -89,20 +92,23 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type *
}
ecl_sum_tstep_type * ecl_sum_tstep_alloc_copy( const ecl_sum_tstep_type * src ) {
ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src );
target->data = (float*)util_alloc_copy( src->data , src->data_size * sizeof * src->data );
ecl_sum_tstep_type * target = new ecl_sum_tstep_type();
UTIL_TYPE_ID_INIT( target , ECL_SUM_TSTEP_ID);
target->smspec = src->smspec;
target->report_step = src->report_step;
target->ministep = src->ministep;
target->data = src->data;
return target;
}
static ecl_sum_tstep_type * ecl_sum_tstep_alloc( int report_step , int ministep_nr , const ecl_smspec_type * smspec) {
ecl_sum_tstep_type * tstep = (ecl_sum_tstep_type*)util_malloc( sizeof * tstep );
ecl_sum_tstep_type * tstep = new ecl_sum_tstep_type();
UTIL_TYPE_ID_INIT( tstep , ECL_SUM_TSTEP_ID);
tstep->smspec = smspec;
tstep->report_step = report_step;
tstep->ministep = ministep_nr;
tstep->data_size = ecl_smspec_get_params_size( smspec );
tstep->data = (float*)util_calloc( tstep->data_size , sizeof * tstep->data );
tstep->data.resize( ecl_smspec_get_params_size( smspec ) );
return tstep;
}
@@ -112,8 +118,7 @@ UTIL_SAFE_CAST_FUNCTION_CONST( ecl_sum_tstep , ECL_SUM_TSTEP_ID)
void ecl_sum_tstep_free( ecl_sum_tstep_type * ministep ) {
free( ministep->data );
free( ministep );
delete ministep;
}
@@ -201,7 +206,7 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step ,
if (data_size == ecl_smspec_get_params_size( smspec )) {
ecl_sum_tstep_type * ministep = ecl_sum_tstep_alloc( report_step , ministep_nr , smspec);
ecl_kw_get_memcpy_data( params_kw , ministep->data );
ecl_kw_get_memcpy_data( params_kw , ministep->data.data() );
ecl_sum_tstep_set_time_info( ministep , smspec );
return ministep;
} else {
@@ -211,7 +216,11 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step ,
ecl_smspec_load_restart() function and the restart case
discarded.
*/
fprintf(stderr , "** Warning size mismatch between timestep loaded from:%s and header:%s - timestep discarded.\n" , src_file , ecl_smspec_get_header_file( smspec ));
fprintf(stderr , "** Warning size mismatch between timestep loaded from:%s(%d) and header:%s(%d) - timestep discarded.\n" ,
src_file ,
data_size,
ecl_smspec_get_header_file( smspec ),
ecl_smspec_get_params_size( smspec ));
return NULL;
}
}
@@ -223,8 +232,7 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_from_file( int report_step ,
ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , float sim_seconds , const ecl_smspec_type * smspec ) {
ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc( report_step , ministep , smspec );
const float_vector_type * default_data = ecl_smspec_get_params_default( smspec );
float_vector_memcpy_data( tstep->data , default_data );
tstep->data = ecl_smspec_get_params_default( smspec );
ecl_sum_tstep_set_time_info_from_seconds( tstep , ecl_smspec_get_start_time( smspec ) , sim_seconds );
ecl_sum_tstep_iset( tstep , ecl_smspec_get_time_index( smspec ) , sim_seconds / ecl_smspec_get_time_seconds( smspec ) );
@@ -235,10 +243,10 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_new( int report_step , int ministep , f
double ecl_sum_tstep_iget(const ecl_sum_tstep_type * ministep , int index) {
if ((index >= 0) && (index < ministep->data_size))
if ((index >= 0) && (index < (int)ministep->data.size()))
return ministep->data[index];
else {
util_abort("%s: param index:%d invalid: Valid range: [0,%d) \n",__func__ , index , ministep->data_size);
util_abort("%s: param index:%d invalid: Valid range: [0,%d) \n",__func__ , index , ministep->data.size());
return -1;
}
}
@@ -269,7 +277,7 @@ int ecl_sum_tstep_get_ministep(const ecl_sum_tstep_type * ministep) {
/*****************************************************************/
void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vector_type * index_map , fortio_type * fortio) {
void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int * index_map , int index_map_size, fortio_type * fortio) {
{
ecl_kw_type * ministep_kw = ecl_kw_alloc( MINISTEP_KW , 1 , ECL_INT );
ecl_kw_iset_int( ministep_kw , 0 , ministep->ministep );
@@ -278,16 +286,15 @@ void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vecto
}
{
int compact_size = int_vector_size( index_map );
int compact_size = index_map_size;
ecl_kw_type * params_kw = ecl_kw_alloc( PARAMS_KW , compact_size , ECL_FLOAT );
const int * index = int_vector_get_ptr( index_map );
float * data = (float*)ecl_kw_get_ptr( params_kw );
{
int i;
for (i=0; i < compact_size; i++)
data[i] = ministep->data[ index[i] ];
data[i] = ministep->data[ index_map[i] ];
}
ecl_kw_fwrite( params_kw , fortio );
ecl_kw_free( params_kw );
@@ -298,10 +305,10 @@ void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vecto
/*****************************************************************/
void ecl_sum_tstep_iset( ecl_sum_tstep_type * tstep , int index , float value) {
if ((index < tstep->data_size) && (index >= 0))
if ((index < static_cast<int>(tstep->data.size())) && (index >= 0) )
tstep->data[index] = value;
else
util_abort("%s: index:%d invalid. Valid range: [0,%d) \n",__func__ ,index , tstep->data_size);
util_abort("%s: index:%d invalid. Valid range: [0,%d) \n",__func__ ,index , tstep->data.size());
}
void ecl_sum_tstep_iscale(ecl_sum_tstep_type * tstep, int index, float scalar) {
@@ -312,24 +319,24 @@ void ecl_sum_tstep_ishift(ecl_sum_tstep_type * tstep, int index, float addend) {
ecl_sum_tstep_iset(tstep, index, ecl_sum_tstep_iget(tstep, index) + addend);
}
void ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node , float value) {
int data_index = smspec_node_get_params_index( smspec_node );
void ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const ecl::smspec_node& smspec_node , float value) {
int data_index = smspec_node_get_params_index( &smspec_node );
ecl_sum_tstep_iset( tstep , data_index , value);
}
double ecl_sum_tstep_get_from_node( const ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node) {
int data_index = smspec_node_get_params_index( smspec_node );
double ecl_sum_tstep_get_from_node( const ecl_sum_tstep_type * tstep , const ecl::smspec_node& smspec_node) {
int data_index = smspec_node_get_params_index( &smspec_node );
return ecl_sum_tstep_iget( tstep , data_index);
}
void ecl_sum_tstep_set_from_key( ecl_sum_tstep_type * tstep , const char * gen_key , float value) {
const smspec_node_type * smspec_node = ecl_smspec_get_general_var_node( tstep->smspec , gen_key );
const ecl::smspec_node& smspec_node = ecl_smspec_get_general_var_node( tstep->smspec , gen_key );
ecl_sum_tstep_set_from_node( tstep , smspec_node , value);
}
double ecl_sum_tstep_get_from_key(const ecl_sum_tstep_type * tstep , const char * gen_key) {
const smspec_node_type * smspec_node = ecl_smspec_get_general_var_node( tstep->smspec , gen_key );
const ecl::smspec_node& smspec_node = ecl_smspec_get_general_var_node( tstep->smspec , gen_key );
return ecl_sum_tstep_get_from_node(tstep , smspec_node );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_sum_vector.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -16,6 +16,10 @@
for more details.
*/
#include <stdlib.h>
#include <vector>
#include <string>
#include <ert/ecl/ecl_sum_vector.hpp>
#include <ert/ecl/ecl_sum.hpp>
#include <ert/ecl/ecl_smspec.hpp>
@@ -23,68 +27,60 @@
#include <ert/util/util.h>
#include <ert/util/vector.hpp>
#include <ert/util/type_macros.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/util/bool_vector.hpp>
#define ECL_SUM_VECTOR_TYPE_ID 8768778
struct ecl_sum_vector_struct {
UTIL_TYPE_ID_DECLARATION;
int_vector_type * node_index_list;
bool_vector_type * is_rate_list;
stringlist_type * key_list;
std::vector<int> node_index_list;
std::vector<bool> is_rate_list;
std::vector<std::string> key_list;
const ecl_sum_type * ecl_sum;
};
void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){
int_vector_free(ecl_sum_vector->node_index_list);
bool_vector_free(ecl_sum_vector->is_rate_list);
stringlist_free(ecl_sum_vector->key_list);
free(ecl_sum_vector);
delete ecl_sum_vector;
}
UTIL_IS_INSTANCE_FUNCTION( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID )
static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const smspec_node_type * node, const char * key ) {
static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const ecl::smspec_node * node, const char * key ) {
int params_index = smspec_node_get_params_index( node );
bool is_rate_key = smspec_node_is_rate( node);
int_vector_append(vector->node_index_list, params_index);
bool_vector_append(vector->is_rate_list, is_rate_key);
stringlist_append_copy( vector->key_list, key );
vector->node_index_list.push_back(params_index);
vector->is_rate_list.push_back(is_rate_key);
vector->key_list.push_back(key);
}
ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum, bool add_keywords) {
ecl_sum_vector_type * ecl_sum_vector = (ecl_sum_vector_type*)util_malloc( sizeof * ecl_sum_vector );
ecl_sum_vector_type * ecl_sum_vector = new ecl_sum_vector_type();
UTIL_TYPE_ID_INIT( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID);
ecl_sum_vector->ecl_sum = ecl_sum;
ecl_sum_vector->node_index_list = int_vector_alloc(0,0);
ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false);
ecl_sum_vector->key_list = stringlist_alloc_new( );
if (add_keywords) {
const ecl_smspec_type * smspec = ecl_sum_get_smspec(ecl_sum);
for (int i=0; i < ecl_smspec_num_nodes(smspec); i++) {
const smspec_node_type * node = ecl_smspec_iget_node( smspec , i );
const char * key = smspec_node_get_gen_key1(node);
const ecl::smspec_node& node = ecl_smspec_iget_node_w_node_index( smspec , i );
const char * key = smspec_node_get_gen_key1(&node);
/*
The TIME keyword is special case handled to not be included; that is
to match the same special casing in the key matching function.
*/
if (!util_string_equal(key, "TIME"))
ecl_sum_vector_add_node( ecl_sum_vector, node, key);
ecl_sum_vector_add_node( ecl_sum_vector, &node, key);
}
}
return ecl_sum_vector;
}
static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type * vector, const char * key) {
int_vector_append(vector->node_index_list, -1);
bool_vector_append(vector->is_rate_list, false);
stringlist_append_copy(vector->key_list, key);
vector->node_index_list.push_back(-1);
vector->is_rate_list.push_back(false);
vector->key_list.push_back(key);
}
@@ -103,8 +99,8 @@ static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type * vector, const c
ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type * src_vector, const ecl_sum_type * ecl_sum) {
ecl_sum_vector_type * new_vector = ecl_sum_vector_alloc(ecl_sum, false);
for (int i=0; i < stringlist_get_size(src_vector->key_list); i++) {
const char * key = stringlist_iget(src_vector->key_list, i);
for (size_t i=0; i < src_vector->key_list.size(); i++) {
const char * key = src_vector->key_list[i].c_str();
if (ecl_sum_has_general_var(ecl_sum, key))
ecl_sum_vector_add_key(new_vector, key);
else
@@ -117,7 +113,7 @@ ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type
bool ecl_sum_vector_add_key( ecl_sum_vector_type * ecl_sum_vector, const char * key){
if (ecl_sum_has_general_var( ecl_sum_vector->ecl_sum , key)) {
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key );
ecl_sum_vector_add_node(ecl_sum_vector, node, key);
return true;
} else
@@ -131,29 +127,29 @@ void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char *
int i;
for(i = 0; i < num_keywords ;i++){
const char * key = stringlist_iget(keylist, i);
const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key );
const ecl::smspec_node * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key );
ecl_sum_vector_add_node(ecl_sum_vector, node, key);
}
stringlist_free(keylist);
}
int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector){
return int_vector_size(ecl_sum_vector->node_index_list);
return ecl_sum_vector->node_index_list.size();
}
bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index){
return bool_vector_iget(ecl_sum_vector->is_rate_list, index);
return ecl_sum_vector->is_rate_list[index];
}
bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index) {
return (int_vector_iget(ecl_sum_vector->node_index_list, index) >= 0);
return (ecl_sum_vector->node_index_list[index] >= 0);
}
int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index){
return int_vector_iget(ecl_sum_vector->node_index_list, index);
return ecl_sum_vector->node_index_list[index];
}
const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index){
return stringlist_iget( ecl_sum_vector->key_list , index);
return ecl_sum_vector->key_list[index].c_str();
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_type.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -53,7 +53,7 @@ int unsmry_loader::length() const {
std::vector<double> unsmry_loader::get_vector(int pos) const {
if (pos >= size)
throw std::invalid_argument("unsmry_loader::get_vector: argument 'pos' mst be less than size of PARAMS.");
throw std::out_of_range("unsmry_loader::get_vector pos: " + std::to_string(pos) + " PARAMS_SIZE: " + std::to_string(size));
std::vector<double> data(this->length());
int_vector_type * index_map = int_vector_alloc( 1 , pos);

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'ecl_util.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -1290,6 +1290,8 @@ static int ecl_util_get_num_slave_cpu__(basic_parser_type* parser, FILE* stream,
const char * first_item = stringlist_iget(tokens, 0);
if (first_item[0] == '/') {
stringlist_free(tokens);
free(buffer);
break;
}
else{

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'fault_block.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'fault_block_layer.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -67,6 +67,8 @@ fault_block_type * fault_block_layer_add_block( fault_block_layer_type * layer ,
fault_block_type * block = fault_block_alloc( layer , block_id );
int storage_index = vector_get_size( layer->blocks );
if (block_id >= int_vector_size(layer->block_map))
int_vector_resize(layer->block_map, block_id+1, -1);
int_vector_iset( layer->block_map , block_id , storage_index );
vector_append_owned_ref( layer->blocks , block , fault_block_free__ );

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
Copyright (C) 2011 Equinor ASA, Norway.
The file 'fortio.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -30,8 +30,6 @@
#define FORTIO_ID 345116
extern int errno;
/**
The fortio struct is implemented to handle fortran io. The problem is
that when a Fortran program writes unformatted data to file in a

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'grid_dims.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'layer.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'nnc_info.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -18,9 +18,14 @@
#include <stdlib.h>
#include <vector>
#include <stdexcept>
#include <string>
#include <ert/util/util.h>
#include <ert/util/vector.hpp>
#include <ert/util/type_macros.hpp>
#include <ert/util/vector_util.hpp>
#include <ert/ecl/nnc_info.hpp>
#include <ert/ecl/nnc_vector.hpp>
@@ -127,6 +132,8 @@ nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info ) {
static void nnc_info_add_vector( nnc_info_type * nnc_info , nnc_vector_type * nnc_vector) {
vector_append_owned_ref( nnc_info->lgr_list , nnc_vector , nnc_vector_free__ );
if (nnc_vector_get_lgr_nr( nnc_vector ) >= int_vector_size( nnc_info->lgr_index_map ) )
int_vector_resize( nnc_info->lgr_index_map , nnc_vector_get_lgr_nr( nnc_vector)+1, -1);
int_vector_iset( nnc_info->lgr_index_map , nnc_vector_get_lgr_nr( nnc_vector ) , vector_get_size( nnc_info->lgr_list ) - 1 );
}
@@ -149,27 +156,28 @@ void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_numb
}
}
bool nnc_info_has_grid_index_list( const nnc_info_type * nnc_info, int lgr_nr ) {
return (nnc_info_get_vector( nnc_info , lgr_nr ) != NULL);
}
const int_vector_type * nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr) {
const std::vector<int>& nnc_info_get_grid_index_list(const nnc_info_type * nnc_info, int lgr_nr) {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr );
if (nnc_vector)
return nnc_vector_get_grid_index_list( nnc_vector );
else
return NULL;
if (!nnc_vector)
throw std::invalid_argument(std::string(__func__));
return nnc_vector_get_grid_index_list( nnc_vector );
}
const int_vector_type * nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index) {
const std::vector<int>& nnc_info_iget_grid_index_list(const nnc_info_type * nnc_info, int lgr_index) {
nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index );
if (nnc_vector)
return nnc_vector_get_grid_index_list( nnc_vector );
else
return NULL;
if (!nnc_vector)
throw std::invalid_argument(std::string(__func__));
return nnc_vector_get_grid_index_list( nnc_vector );
}
const int_vector_type * nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info) {
const std::vector<int>& nnc_info_get_self_grid_index_list(const nnc_info_type * nnc_info) {
return nnc_info_get_grid_index_list( nnc_info , nnc_info->lgr_nr );
}
@@ -205,8 +213,8 @@ void nnc_info_fprintf(const nnc_info_type * nnc_info , FILE * stream) {
if (lgr_index >= 0) {
printf(" %02d -> %02d => ",lgr_nr , lgr_index);
{
const int_vector_type * index_list = nnc_info_iget_grid_index_list( nnc_info , lgr_index );
int_vector_fprintf( index_list , stream , " " , "%d");
const std::vector<int>& index_list = nnc_info_iget_grid_index_list( nnc_info , lgr_index );
vector_util_fprintf<int>( index_list , stream , " " , "%d");
printf("\n");
}
}

View File

@@ -1,6 +1,6 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'nnc_vector.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -19,10 +19,11 @@
#include <stdlib.h>
#include <vector>
#include <ert/util/util.h>
#include <ert/util/vector.hpp>
#include <ert/util/type_macros.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/ecl/nnc_vector.hpp>
@@ -33,9 +34,9 @@
struct nnc_vector_struct {
UTIL_TYPE_ID_DECLARATION;
int lgr_nr;
int_vector_type * grid_index_list;
int_vector_type * nnc_index_list;
int lgr_nr;
std::vector<int> grid_index_list;
std::vector<int> nnc_index_list;
};
@@ -45,21 +46,19 @@ static UTIL_SAFE_CAST_FUNCTION(nnc_vector , NNC_VECTOR_TYPE_ID)
nnc_vector_type * nnc_vector_alloc(int lgr_nr) {
nnc_vector_type * nnc_vector = (nnc_vector_type*)util_malloc( sizeof * nnc_vector );
nnc_vector_type * nnc_vector = new nnc_vector_type();
UTIL_TYPE_ID_INIT(nnc_vector , NNC_VECTOR_TYPE_ID);
nnc_vector->grid_index_list = int_vector_alloc(0,0);
nnc_vector->nnc_index_list = int_vector_alloc(0,0);
nnc_vector->lgr_nr = lgr_nr;
return nnc_vector;
}
nnc_vector_type * nnc_vector_alloc_copy(const nnc_vector_type * src_vector) {
nnc_vector_type * copy_vector = (nnc_vector_type*)util_malloc( sizeof * src_vector );
nnc_vector_type * copy_vector = new nnc_vector_type();
UTIL_TYPE_ID_INIT(copy_vector , NNC_VECTOR_TYPE_ID);
copy_vector->lgr_nr = src_vector->lgr_nr;
copy_vector->grid_index_list = int_vector_alloc_copy( src_vector->grid_index_list );
copy_vector->nnc_index_list = int_vector_alloc_copy( src_vector->nnc_index_list );
copy_vector->grid_index_list = src_vector->grid_index_list;
copy_vector->nnc_index_list = src_vector->nnc_index_list;
return copy_vector;
}
@@ -75,10 +74,10 @@ bool nnc_vector_equal( const nnc_vector_type * nnc_vector1 , const nnc_vector_ty
if (nnc_vector1->lgr_nr != nnc_vector2->lgr_nr)
return false;
if (!int_vector_equal( nnc_vector1->grid_index_list , nnc_vector2->grid_index_list))
if (nnc_vector1->grid_index_list != nnc_vector2->grid_index_list)
return false;
if (!int_vector_equal( nnc_vector1->nnc_index_list , nnc_vector2->nnc_index_list))
if (nnc_vector1->nnc_index_list != nnc_vector2->nnc_index_list)
return false;
return true;
@@ -87,9 +86,7 @@ bool nnc_vector_equal( const nnc_vector_type * nnc_vector1 , const nnc_vector_ty
void nnc_vector_free( nnc_vector_type * nnc_vector ) {
int_vector_free( nnc_vector->grid_index_list );
int_vector_free( nnc_vector->nnc_index_list );
free( nnc_vector );
delete nnc_vector;
}
@@ -100,21 +97,21 @@ void nnc_vector_free__(void * arg) {
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number , int nnc_index) {
int_vector_append( nnc_vector->grid_index_list , global_cell_number );
int_vector_append( nnc_vector->nnc_index_list , nnc_index);
nnc_vector->grid_index_list.push_back( global_cell_number );
nnc_vector->nnc_index_list.push_back(nnc_index);
}
const int_vector_type * nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector) {
const std::vector<int>& nnc_vector_get_grid_index_list(const nnc_vector_type * nnc_vector) {
return nnc_vector->grid_index_list;
}
const int_vector_type * nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector) {
const std::vector<int>& nnc_vector_get_nnc_index_list(const nnc_vector_type * nnc_vector) {
return nnc_vector->nnc_index_list;
}
int nnc_vector_get_size( const nnc_vector_type * nnc_vector ) {
return int_vector_size( nnc_vector->grid_index_list );
return nnc_vector->grid_index_list.size();
}
int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) {
@@ -122,9 +119,9 @@ int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) {
}
int nnc_vector_iget_nnc_index( const nnc_vector_type * nnc_vector , int index ) {
return int_vector_iget( nnc_vector->nnc_index_list , index );
return nnc_vector->nnc_index_list[index];
}
int nnc_vector_iget_grid_index( const nnc_vector_type * nnc_vector , int index ) {
return int_vector_iget( nnc_vector->grid_index_list , index );
return nnc_vector->grid_index_list[index];
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_alloc_cpgrid.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,6 +1,6 @@
/*
Copyright (C) 2013 Andreas Lauser
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_alloc_grid_dxv_dyv_dzv.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -55,6 +55,7 @@ void test_grid() {
}
}
}
ecl_grid_free( ecl_grid );
}
int main(int argc , char ** argv) {

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
Copyright (C) 2012 Equinor ASA, Norway.
The file 'ecl_coarse_test.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_dualp.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,7 +1,7 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_fault_block_collection_statoil.c' is part of ERT - Ensemble based Reservoir Tool.
The file 'ecl_fault_block_collection_equinor.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_fault_block_layer.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -98,6 +98,7 @@ void test_trace_edge( const ecl_grid_type * grid) {
test_assert_int_equal( 1 , int_vector_size( cell_list ));
test_assert_int_equal( 0 , int_vector_iget( cell_list , 0));
fault_block_layer_free(layer);
int_vector_free( cell_list );
double_vector_free( x_list );
double_vector_free( y_list );

View File

@@ -1,7 +1,7 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_fault_block_layer_statoil.c' is part of ERT - Ensemble based Reservoir Tool.
The file 'ecl_fault_block_layer_equinor.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_file.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -31,7 +31,7 @@
#include <ert/ecl/ecl_endian_flip.hpp>
void test_writable(size_t data_size) {
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable");
ecl::util::TestArea ta("file_writable");
const char * data_file_name = "test_file";
ecl_kw_type * kw = ecl_kw_alloc("TEST_KW", data_size, ECL_INT);
@@ -54,11 +54,10 @@ void test_writable(size_t data_size) {
}
ecl_kw_free(kw);
test_work_area_free( work_area );
}
void test_truncated() {
test_work_area_type * work_area = test_work_area_alloc("ecl_file_truncated" );
ecl::util::TestArea ta("truncate_file");
int num_kw;
{
ecl_grid_type * grid = ecl_grid_alloc_rectangular(20,20,20,1,1,1,NULL);
@@ -69,6 +68,7 @@ void test_truncated() {
ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 );
test_assert_true( ecl_file_is_instance( ecl_file ) );
num_kw = ecl_file_get_size( ecl_file );
test_assert_int_equal( ecl_file_get_num_distinct_kw( ecl_file ), 11);
ecl_file_close( ecl_file );
}
@@ -83,7 +83,6 @@ void test_truncated() {
test_assert_true( ecl_file_get_size( ecl_file) < num_kw );
ecl_file_close( ecl_file );
}
test_work_area_free( work_area );
}

View File

@@ -1,8 +1,8 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_file_statoil.c' is part of ERT - Ensemble based Reservoir Tool.
The file 'ecl_file_equinor.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -108,10 +108,10 @@ void test_close_stream1(const char * src_file , const char * target_file ) {
void test_writable(const char * src_file ) {
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" );
ecl::util::TestArea ta("file_writable");
char * fname = util_split_alloc_filename( src_file );
test_work_area_copy_file( work_area , src_file );
ta.copy_file(src_file);
{
test_flags( fname );
ecl_file_type * ecl_file = ecl_file_open( fname , ECL_FILE_WRITABLE);
@@ -127,7 +127,6 @@ void test_writable(const char * src_file ) {
swat = ecl_file_iget_named_kw( ecl_file , "SWAT" , 0 );
test_assert_true( util_double_approx_equal( ecl_kw_iget_float( swat , 0 ) , 1000 ));
}
test_work_area_free( work_area );
}
@@ -138,16 +137,15 @@ int main( int argc , char ** argv) {
const char * target_file = argv[2];
{
test_work_area_type * work_area = test_work_area_alloc("ecl_file");
ecl::util::TestArea ta("file_equinor");
test_work_area_copy_file( work_area , src_file );
ta.copy_file( src_file );
test_loadall(src_file , target_file );
test_close_stream1( src_file , target_file);
test_close_stream2( src_file , target_file);
test_writable( src_file );
test_work_area_free( work_area );
}
exit(0);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -59,7 +59,7 @@ void test_create_file_kw() {
test_assert_int_equal( ecl_file_kw_get_size( file_kw0 ) , 1000 );
test_assert_true( ecl_type_is_equal( ecl_file_kw_get_data_type( file_kw0 ) , ECL_FLOAT ));
{
test_work_area_type * work_area = test_work_area_alloc("file_kw");
ecl::util::TestArea ta("file_kw");
{
FILE * ostream = util_fopen("file_kw" , "w");
ecl_file_kw_fwrite( file_kw0 , ostream );
@@ -101,7 +101,6 @@ void test_create_file_kw() {
test_assert_NULL( ecl_file_kw_fread_alloc_multiple( istream , 10));
fclose( istream );
}
test_work_area_free( work_area );
}
ecl_file_kw_free( file_kw0 );
ecl_file_kw_free( file_kw1 );

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
Copyright (C) 2012 Equinor ASA, Norway.
The file 'ecl_fmt.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -25,14 +25,12 @@
#include <ert/ecl/ecl_util.hpp>
void test_content( test_work_area_type * work_area , const char * src_file , bool fmt_file ) {
test_work_area_install_file( work_area , src_file );
void test_content( const ecl::util::TestArea& ta , const char * src_file , bool fmt_file ) {
ta.copy_file(src_file);
{
char * base_name;
bool fmt;
util_alloc_file_components( src_file , NULL , &base_name , NULL);
util_copy_file( src_file , base_name );
test_assert_true( ecl_util_fmt_file( base_name , &fmt ));
test_assert_bool_equal( fmt , fmt_file );
}
@@ -41,6 +39,7 @@ void test_content( test_work_area_type * work_area , const char * src_file , boo
void test_small( ) {
bool fmt;
@@ -56,7 +55,7 @@ void test_small( ) {
int main(int argc , char ** argv) {
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt");
ecl::util::TestArea ta("ecl_fmt");
{
const char * binary_file = argv[1];
const char * text_file = argv[2];
@@ -78,10 +77,9 @@ int main(int argc , char ** argv) {
test_assert_false(ecl_util_fmt_file( "TEST_DOES_NOT_EXIST" , &fmt_file ));
test_content( work_area , binary_file , false );
test_content( work_area , text_file , true );
test_content( ta , binary_file , false );
test_content( ta , text_file , true );
test_small( );
}
test_work_area_free( work_area );
exit(0);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_fortio.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -111,7 +111,7 @@ void test_open_close_read( const char * filename ) {
void test_fread_truncated_data() {
test_work_area_type * work_area = test_work_area_alloc("fortio_truncated" );
ecl::util::TestArea work_area("fortio_truncated");
{
const size_t buffer_size = 1000;
char * buffer = (char *) util_malloc( buffer_size );
@@ -136,11 +136,10 @@ void test_fread_truncated_data() {
}
free( buffer );
}
test_work_area_free( work_area );
}
void test_fread_truncated_head() {
test_work_area_type * work_area = test_work_area_alloc("fortio_truncated" );
ecl::util::TestArea work_area("fortio_truncated");
{
{
FILE * stream = util_fopen("PRESSURE" , "w");
@@ -156,12 +155,11 @@ void test_fread_truncated_head() {
fortio_fclose( fortio );
}
}
test_work_area_free( work_area );
}
void test_fread_truncated_tail() {
test_work_area_type * work_area = test_work_area_alloc("fortio_truncated2" );
ecl::util::TestArea work_area("fortio_truncated3");
{
const size_t buffer_size = 1000;
char * buffer = (char *) util_malloc( buffer_size );
@@ -183,12 +181,11 @@ void test_fread_truncated_tail() {
}
free( buffer );
}
test_work_area_free( work_area );
}
void test_fread_invalid_tail() {
test_work_area_type * work_area = test_work_area_alloc("fortio_invalid" );
ecl::util::TestArea work_area("fortio_invalid");
int record_size = 10;
char * buffer = (char *) util_malloc( record_size );
{
@@ -215,13 +212,12 @@ void test_fread_invalid_tail() {
}
free( buffer );
test_work_area_free( work_area );
}
void test_at_eof() {
test_work_area_type * work_area = test_work_area_alloc("fortio_truncated2" );
ecl::util::TestArea work_area("fortio_truncated3");
{
fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true);
char * buffer = (char *) util_malloc( 100 );
@@ -242,13 +238,11 @@ void test_at_eof() {
fortio_fclose( fortio );
}
test_work_area_free( work_area );
}
void test_fseek() {
test_work_area_type * work_area = test_work_area_alloc("fortio_fseek" );
ecl::util::TestArea work_area("fortio_fseek");
{
fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true);
char * buffer = (char *) util_malloc( 100 );
@@ -261,8 +255,6 @@ void test_fseek() {
{
fortio_type * fortio = fortio_open_reader("PRESSURE" , false , true);
printf("Starting fssek test \n");
test_assert_true( fortio_fseek( fortio , 0 , SEEK_SET ));
test_assert_true( fortio_fseek( fortio , 0 , SEEK_END ));
test_assert_false( fortio_fseek( fortio , 100000 , SEEK_END));
@@ -270,14 +262,12 @@ void test_fseek() {
fortio_fclose( fortio );
}
test_work_area_free( work_area );
}
void test_write_failure() {
test_work_area_type * work_area = test_work_area_alloc("fortio_fseek" );
ecl::util::TestArea work_area("fortio_truncated");
{
fortio_type * fortio = fortio_open_writer("PRESSURE" , false , true);
char * buffer = (char *) util_malloc( 100 );
@@ -292,7 +282,6 @@ void test_write_failure() {
test_assert_false( util_file_exists( "PRESSURE"));
}
test_work_area_free( work_area );
}
@@ -317,10 +306,9 @@ int main( int argc , char ** argv) {
test_write( "/tmp/path/does/not/exist" , false );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" );
ecl::util::TestArea work_area("ecl_fortio_write");
util_make_path("path");
test_write( "path/file.x" , true );
test_work_area_free( work_area );
}
test_write_failure();

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
Copyright (C) 2012 Equinor ASA, Norway.
The file 'ecl_get_num_cpu_test.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_DEPTHZ.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -44,15 +44,15 @@ void test_create() {
int ny = 100;
int nz = 10;
double * DXV = (double *) util_malloc( nx * sizeof * DXV );
double * DYV = (double *) util_malloc( ny * sizeof * DYV );
double * DXV = (double *) util_malloc( (nx + 1) * sizeof * DXV );
double * DYV = (double *) util_malloc( (ny + 1) * sizeof * DYV );
double * DZV = (double *) util_malloc( nz * sizeof * DZV );
double * DEPTHZ = (double *) util_malloc( (nx + 1) * (ny + 1) * sizeof * DEPTHZ);
for (int i=0; i < nx; i++)
for (int i=0; i <= nx; i++)
DXV[i] = 1.0 / nx;
for (int j=0; j < ny; j++)
for (int j=0; j <= ny; j++)
DYV[j] = 1.0 / ny;
for (int k=0; k < nz; k++)

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Statoil ASA, Norway.
Copyright (C) 2016 Equinor ASA, Norway.
The file 'ecl_grid_add_nnc.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -60,14 +60,13 @@ void simple_test() {
verify_simple_nnc( grid0 );
{
test_work_area_type * test_area = test_work_area_alloc("ecl_grid_nnc");
ecl::util::TestArea ta("simple_nnc");
ecl_grid_type * grid1;
ecl_grid_fwrite_EGRID2( grid0 , "TEST.EGRID" , ECL_METRIC_UNITS);
grid1 = ecl_grid_alloc( "TEST.EGRID" );
verify_simple_nnc( grid1 );
ecl_grid_free( grid1 );
test_work_area_free( test_area );
}
ecl_grid_free( grid0 );
}
@@ -90,14 +89,13 @@ void overwrite_test() {
verify_simple_nnc( grid0 );
{
test_work_area_type * test_area = test_work_area_alloc("ecl_grid_nnc");
ecl::util::TestArea ta("overwrite");
ecl_grid_type * grid1;
ecl_grid_fwrite_EGRID2( grid0 , "TEST.EGRID" , ECL_METRIC_UNITS);
grid1 = ecl_grid_alloc( "TEST.EGRID" );
verify_simple_nnc( grid1 );
ecl_grid_free( grid1 );
test_work_area_free( test_area );
}
ecl_grid_free( grid0 );
}
@@ -118,15 +116,16 @@ void list_test() {
verify_simple_nnc( grid0 );
{
test_work_area_type * test_area = test_work_area_alloc("ecl_grid_nnc");
ecl::util::TestArea ta("list_test");
ecl_grid_type * grid1;
ecl_grid_fwrite_EGRID2( grid0 , "TEST.EGRID" , ECL_METRIC_UNITS);
grid1 = ecl_grid_alloc( "TEST.EGRID" );
verify_simple_nnc( grid1 );
ecl_grid_free( grid1 );
test_work_area_free( test_area );
}
int_vector_free(g1);
int_vector_free(g2);
ecl_grid_free( grid0 );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_case.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_cell_contains.c' is part of ERT - Ensemble based
Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_grid_cell_contains_wellpath.c' is part of ERT -
Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_copy.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,7 +1,7 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_copy_statoil.c' is part of ERT - Ensemble based Reservoir Tool.
The file 'ecl_grid_copy_equinor.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_corner.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_create.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_dims.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_export.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -154,7 +154,7 @@ void export_mapaxes( const ecl_grid_type * grid , ecl_file_type * ecl_file ) {
int main(int argc , char ** argv) {
test_work_area_type * work_area = test_work_area_alloc("grid_export");
ecl::util::TestArea ta("grid_export");
{
const char * test_grid = "TEST.EGRID";
const char * grid_file;
@@ -181,5 +181,4 @@ int main(int argc , char ** argv) {
ecl_grid_free( ecl_grid );
}
}
test_work_area_free( work_area );
}

View File

@@ -12,7 +12,7 @@
void test_1() {
test_work_area_type * work_area = test_work_area_alloc("ext_actnum_main_grid");
ecl::util::TestArea ta("test1");
{
const char * filename = "FILE.EGRID";
@@ -41,21 +41,18 @@ void test_1() {
std::vector<int> ext_actnum = {0, 1, 0, 1, 1, 1};
ecl_grid_type * grid = ecl_grid_alloc_ext_actnum(filename1, ext_actnum.data());
test_assert_int_equal( 2, ecl_grid_get_nactive(grid) );
test_assert_int_equal( 1, ecl_grid_get_nactive_fracture(grid) );
test_assert_int_equal( 4, ecl_grid_get_nactive(grid) );
test_assert_int_equal( 0, ecl_grid_get_nactive_fracture(grid) );
test_assert_true( !ecl_grid_cell_active1(grid, 0) );
test_assert_true( !ecl_grid_cell_active1(grid, 2) );
test_assert_true( !ecl_grid_cell_active1(grid, 3) );
test_assert_true( ecl_grid_cell_active1(grid, 3) );
test_assert_true( ecl_grid_cell_active1(grid, 4) );
test_assert_true( ecl_grid_cell_active1(grid, 5) );
ecl_grid_free( grid );
}
test_work_area_free( work_area );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_kw_fwrite.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -37,12 +37,72 @@ void test_fwrite_EGRID(ecl_grid_type * grid ) {
test_work_area_free( work_area );
}
namespace {
void test_fwrite_fmt_vs_unfmt( ) {
ecl::util::TestArea ta( "fmt_file" );
ecl_grid_type * ecl_grid = ecl_grid_alloc_rectangular( 5 , 5 , 5 , 1 , 1 , 1 , nullptr);
/* .FEGRID -> formatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.FEGRID" , ECL_METRIC_UNITS );
test_assert_true( util_fmt_bit8( "CASE.FEGRID" ) );
}
/* .EGRID -> unformatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.EGRID" , ECL_METRIC_UNITS );
test_assert_false( util_fmt_bit8( "CASE.EGRID" ) );
}
/* Unknown -> unformatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.UNKNOWN" , ECL_METRIC_UNITS );
test_assert_false( util_fmt_bit8( "CASE.UNKNOWN" ) );
}
/* Abuse: .FUNRST -> formatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.FUNRST" , ECL_METRIC_UNITS );
test_assert_true( util_fmt_bit8( "CASE.FUNRST" ) );
}
/* Abuse: .FSMSPEC -> formatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.FSMSPEC" , ECL_METRIC_UNITS );
test_assert_true( util_fmt_bit8( "CASE.FSMSPEC" ) );
}
/* Abuse: .F0001 -> formatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.F0001" , ECL_METRIC_UNITS );
test_assert_true( util_fmt_bit8( "CASE.F0001" ) );
}
/* Abuse: .X1234 -> unformatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.X1234" , ECL_METRIC_UNITS );
test_assert_false( util_fmt_bit8( "CASE.X1234" ) );
}
/* Abuse: .UNSMRY -> unformatted */
{
ecl_grid_fwrite_EGRID2( ecl_grid , "CASE.UNSMRY" , ECL_METRIC_UNITS );
test_assert_false( util_fmt_bit8( "CASE.UNSMRY" ) );
}
ecl_grid_free( ecl_grid );
}
}
int main( int argc , char **argv) {
const char * src_file = argv[1];
ecl_grid_type * grid = ecl_grid_alloc( src_file );
if (argc > 1) {
const char * src_file = argv[1];
ecl_grid_type * grid = ecl_grid_alloc( src_file );
test_fwrite_EGRID( grid );
test_fwrite_EGRID( grid );
ecl_grid_free( grid );
ecl_grid_free( grid );
}
test_fwrite_fmt_vs_unfmt( );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Statoil ASA, Norway.
Copyright (C) 2016 Equinor ASA, Norway.
This file is part of ERT - Ensemble based Reservoir Tool.
@@ -31,7 +31,7 @@
void test_write_depth(const ecl_grid_type * grid) {
test_work_area_type * test_area = test_work_area_alloc("write_depth");
ecl::util::TestArea ta("write_depth");
{
fortio_type * init_file = fortio_open_writer( "INIT" , false , ECL_ENDIAN_FLIP );
ecl_grid_fwrite_depth( grid , init_file , ECL_METRIC_UNITS);
@@ -47,12 +47,11 @@ void test_write_depth(const ecl_grid_type * grid) {
ecl_file_close(init_file);
}
test_work_area_free( test_area );
}
void test_write_dims(const ecl_grid_type * grid) {
test_work_area_type * test_area = test_work_area_alloc("write_dims");
ecl::util::TestArea ta("write_dims");
{
fortio_type * init_file = fortio_open_writer( "INIT" , false , ECL_ENDIAN_FLIP );
ecl_grid_fwrite_dims( grid , init_file , ECL_METRIC_UNITS );
@@ -74,7 +73,6 @@ void test_write_dims(const ecl_grid_type * grid) {
}
ecl_file_close(init_file);
}
test_work_area_free( test_area );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_layer_contains' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_lgr_name.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -41,8 +41,6 @@
Name ..................: LG003014
Grid nr ...............: 110
Name ..................: /private/joaho/ERT/git/ert/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID
*/

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_grid_reset_actnum.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_simple.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2018 Statoil ASA, Norway.
Copyright (C) 2018 Equinor ASA, Norway.
The file 'ecl_grid_unit_system.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -52,12 +52,10 @@ void test_GRID(const char * filename, ert_ecl_unit_enum unit_system) {
int main(int argc, char **argv) {
test_work_area_type * work_area = test_work_area_alloc("grid_export");
ecl::util::TestArea ta("grid_unit_system");
test_EGRID("METRIC.EGRID", ECL_METRIC_UNITS);
test_EGRID("FIELD.EGRID", ECL_FIELD_UNITS);
test_GRID("METRIC.GRID", ECL_METRIC_UNITS);
test_GRID("FIELD.GRID", ECL_FIELD_UNITS);
test_work_area_free(work_area);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_grid_volume.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2016 Statoil ASA, Norway.
Copyright (C) 2016 Equinor ASA, Norway.
The file 'ecl_init_file.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -36,8 +36,8 @@ void test_write_header() {
int ny = 10;
int nz = 5;
ecl::util::TestArea ta("WRITE_header");
int_vector_type * actnum = int_vector_alloc( nx*ny*nz , 1 );
test_work_area_type * test_area = test_work_area_alloc( "ecl_init_file" );
time_t start_time = util_make_date_utc(15 , 12 , 2010 );
ecl_grid_type * ecl_grid;
@@ -84,7 +84,8 @@ void test_write_header() {
ecl_init_file_fwrite_header( f , ecl_grid , NULL , ECL_METRIC_UNITS, 7 , start_time );
fortio_fclose( f );
}
test_work_area_free( test_area );
ecl_grid_free( ecl_grid );
int_vector_free( actnum );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_kw_cmp_string.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -39,6 +39,7 @@ void test_cmp_string() {
test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , ""));
test_assert_false( ecl_kw_icmp_string( ecl_kw , 0 , ""));
ecl_kw_free(ecl_kw);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_kw_equal.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -55,12 +55,13 @@ int main(int argc , char ** argv) {
test_assert_true( ecl_kw_content_equal( ecl_kw1 , ecl_ikw ));
test_assert_false( ecl_kw_content_equal( ecl_kw1 , ecl_fkw ));
ecl_kw_free(ecl_ikw);
ecl_kw_free(ecl_fkw);
}
test_assert_true( ecl_kw_data_equal( ecl_kw1 , data ));
data[0] = 99;
test_assert_false( ecl_kw_data_equal( ecl_kw1 , data ));
ecl_kw_free(ecl_kw1);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2015 Statoil ASA, Norway.
Copyright (C) 2015 Equinor ASA, Norway.
The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -45,7 +45,7 @@ void test_truncated(const char * filename , offset_type truncate_size) {
void test_fread_alloc() {
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_fread" );
ecl::util::TestArea ta("fread_alloc");
{
ecl_kw_type * kw1 = ecl_kw_alloc( "INT" , 100 , ECL_INT );
int i;
@@ -74,11 +74,10 @@ void test_fread_alloc() {
}
ecl_kw_free( kw1 );
}
test_work_area_free( work_area );
}
void test_kw_io_charlength() {
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_io_charlength");
ecl::util::TestArea ta("io_charlength");
{
const char * KW0 = "QWERTYUI";
const char * KW1 = "ABCDEFGHIJTTTTTTTTTTTTTTTTTTTTTTABCDEFGHIJKLMNOP";
@@ -115,13 +114,13 @@ void test_kw_io_charlength() {
test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 0), 0.0);
test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 4), 6.0);
ecl_kw_free(ecl_kw_in);
fclose(file);
}
ecl_kw_free( ecl_kw_out0 );
ecl_kw_free( ecl_kw_out1 );
}
test_work_area_free( work_area );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -32,7 +32,7 @@ int main(int argc , char ** argv) {
ecl_kw_iset_int(ecl_kw , i , i );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl");
ecl::util::TestArea ta("kw_grdecl");
FILE * stream = util_fopen( "FILE.grdecl" , "w");
ecl_kw_fprintf_grdecl(ecl_kw , stream );
@@ -65,7 +65,6 @@ int main(int argc , char ** argv) {
ecl_kw_free( ecl_kw2 );
}
fclose( stream );
test_work_area_free( work_area );
}
ecl_kw_free( ecl_kw );

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_kw_init.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_layer.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,7 +1,7 @@
/*
Copyright (C) 2014 Statoil ASA, Norway.
Copyright (C) 2014 Equinor ASA, Norway.
The file 'ecl_layer_statoil.c' is part of ERT - Ensemble based Reservoir Tool.
The file 'ecl_layer_equinor.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_win64.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_lgr_name.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_lgr_test.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,7 +1,7 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'test_ecl_nnc_data_statoil.c' is part of ERT - Ensemble based Reservoir Tool.
The file 'test_ecl_nnc_data_equinor.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -74,8 +74,10 @@ int count_kw_data( const ecl_file_type * file , ecl_grid_type * grid , const cha
void test_count(const char * name) {
char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false , -1);
char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false , -1);
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
ecl_file_type * init_file = ecl_file_open( init_file_name , 0);
int num_nnc = 0;
@@ -83,7 +85,7 @@ void test_count(const char * name) {
num_nnc += count_kw_data( grid_file , grid , "NNCG" , NULL);
num_nnc += count_kw_data( grid_file , grid , "NNA1" , NULL);
test_assert_int_equal( num_nnc , ecl_nnc_export_get_size( grid ));
test_assert_int_equal(num_nnc, ecl_nnc_export_get_size(grid, init_file));
free(grid_file_name);
ecl_grid_free( grid );
@@ -97,7 +99,7 @@ void test_nnc_export_missing_TRANX(const char * name ) {
if (util_entry_exists(init_file_name)) {
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * init_file = ecl_file_open( init_file_name , 0);
ecl_nnc_type * nnc_data1 = (ecl_nnc_type *) util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data1 );
ecl_nnc_type * nnc_data1 = (ecl_nnc_type *) util_calloc(ecl_nnc_export_get_size(grid, init_file), sizeof *nnc_data1);
int count = ecl_nnc_export(grid, init_file, nnc_data1);
int i;
test_assert_int_equal( count , 0 );
@@ -113,8 +115,8 @@ void test_export(const char * name, bool have_tran_data) {
ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
ecl_file_type * init_file = ecl_file_open( init_file_name , 0);
ecl_nnc_type * nnc_data1 = (ecl_nnc_type *) util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data1 );
ecl_nnc_type * nnc_data2 = (ecl_nnc_type *) util_calloc( ecl_nnc_export_get_size( grid ) , sizeof * nnc_data2 );
ecl_nnc_type * nnc_data1 = (ecl_nnc_type *) util_calloc(ecl_nnc_export_get_size(grid, init_file), sizeof *nnc_data1);
ecl_nnc_type * nnc_data2 = (ecl_nnc_type *) util_calloc(ecl_nnc_export_get_size(grid, init_file), sizeof *nnc_data2);
{
@@ -214,23 +216,23 @@ void test_export(const char * name, bool have_tran_data) {
}
}
test_assert_int_equal( nnc_offset , ecl_nnc_export_get_size( grid ));
test_assert_int_equal(nnc_offset, ecl_nnc_export_get_size(grid, init_file ));
ecl_nnc_sort( nnc_data1 , nnc_offset );
}
{
int export_size = ecl_nnc_export( grid , init_file , nnc_data2 );
test_assert_int_equal( export_size , ecl_nnc_export_get_size( grid ));
test_assert_int_equal(export_size , ecl_nnc_export_get_size(grid, init_file));
}
{
int i;
int size = ecl_nnc_export_get_size( grid );
int size = ecl_nnc_export_get_size(grid, init_file);
for (i=0; i < size; i++)
test_assert_int_equal( 0 , ecl_nnc_sort_cmp( &nnc_data1[i] , &nnc_data2[i]));
}
for (int i =0; i < ecl_nnc_export_get_size( grid ); i++)
for (int i = 0; i < ecl_nnc_export_get_size(grid, init_file); i++)
test_assert_true( ecl_nnc_equal( &nnc_data1[i] , &nnc_data2[i] ));
{
@@ -238,7 +240,7 @@ void test_export(const char * name, bool have_tran_data) {
ecl_file_view_type * view_file = ecl_file_get_global_view( init_file );
ecl_nnc_data_type * nnc_geo_data = ecl_nnc_data_alloc_tran(grid, nnc_geo, view_file);
test_assert_int_equal( ecl_nnc_export_get_size( grid ), ecl_nnc_geometry_size( nnc_geo ));
test_assert_int_equal(ecl_nnc_export_get_size(grid, init_file), ecl_nnc_geometry_size(nnc_geo));
for (int i=0; i < ecl_nnc_geometry_size( nnc_geo ); i++) {
const ecl_nnc_pair_type *nnc_pair = ecl_nnc_geometry_iget( nnc_geo , i );
ecl_nnc_type * nnc1 = &nnc_data1[i];

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_nnc_export.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -0,0 +1,117 @@
/*
Copyright (C) 2018 Equinor ASA, Norway.
The file 'ecl_nnc_export_intersect.c' is part of ERT - Ensemble based
Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more detals.
*/
// #include <stdlib.h>
// #include <stdbool.h>
#include <signal.h>
#include <ert/util/test_util.hpp>
#include <ert/ecl/ecl_nnc_export.hpp>
#include <ert/ecl/ecl_endian_flip.h>
#include <ert/ecl/ecl_kw_magic.hpp>
#include <ert/ecl/ecl_nnc_data.hpp>
#include <ert/ecl/ecl_grid.hpp>
#include <ert/ecl/ecl_file.hpp>
#include <ert/util/ert_unique_ptr.hpp>
#include <ert/util/util.hpp>
namespace {
const auto GRIDX = 10, GRIDY = 10, GRIDZ = 10;
const auto GRID_NNC_NUM = 342;
const auto INIT_NNC_NUM = 298;
ERT::ert_unique_ptr<ecl_grid_type, ecl_grid_free>
make_intersect_grid() {
auto out = ERT::ert_unique_ptr<ecl_grid_type, ecl_grid_free>(
ecl_grid_alloc_rectangular(GRIDX, GRIDY, GRIDZ, 1., 1., 1., nullptr)
);
for(auto i = 0; i < GRID_NNC_NUM; ++i)
ecl_grid_add_self_nnc(out.get(), 2 * i + 1, 2 * i, i);
return out;
}
ERT::ert_unique_ptr<ecl_file_type, ecl_file_close>
make_intersect_init_file() {
// Create keywords with useless data
auto nnc1_kw = ecl_kw_alloc(NNC1_KW, INIT_NNC_NUM, ECL_INT);
auto nnc2_kw = ecl_kw_alloc(NNC2_KW, INIT_NNC_NUM, ECL_INT);
auto tran_kw = ecl_kw_alloc(TRANNNC_KW, INIT_NNC_NUM, ECL_DOUBLE);
for(auto i = 0; i < INIT_NNC_NUM; ++i) {
ecl_kw_iset_int(nnc1_kw, i, 2 * i);
ecl_kw_iset_int(nnc2_kw, i, 2 * i + 1 );
ecl_kw_iset_double(tran_kw, i, 2.5 * i);
}
// write to file directly using fortio
auto init_filename = util_alloc_tmp_file("/tmp", "ecl_nnc_export_intersect_init_file", false);
auto fortio = fortio_open_writer(init_filename, false, ECL_ENDIAN_FLIP);
ecl_kw_fwrite(nnc1_kw, fortio);
ecl_kw_fwrite(nnc2_kw, fortio);
ecl_kw_fwrite(tran_kw, fortio);
fortio_fclose(fortio);
// reopen the file as an ecl file
auto out = ERT::ert_unique_ptr<ecl_file_type, ecl_file_close>(
ecl_file_open(init_filename, 0)
);
ecl_kw_free(nnc1_kw);
ecl_kw_free(nnc2_kw);
ecl_kw_free(tran_kw);
free(init_filename);
return out;
}
} /* unnamed namespace */
int main(int argc, char ** argv) {
util_install_signals();
const auto grid = make_intersect_grid();
const auto init_file = make_intersect_init_file();
test_assert_true(ecl_nnc_intersect_format(grid.get(), init_file.get()));
test_assert_int_equal(ecl_nnc_export_get_size(grid.get(), init_file.get()), INIT_NNC_NUM);
auto nnc_data = std::vector<ecl_nnc_type>(
ecl_nnc_export_get_size(grid.get(), init_file.get())
);
auto const total_valid_trans = ecl_nnc_export(grid.get(), init_file.get(), nnc_data.data());
test_assert_int_equal(total_valid_trans, INIT_NNC_NUM);
test_assert_int_equal(int(nnc_data.size()), INIT_NNC_NUM);
for(auto i = 0; i < int(nnc_data.size()); ++i) {
auto const& nnc = nnc_data[i];
test_assert_int_equal(nnc.grid_nr1, 0);
test_assert_int_equal(nnc.grid_nr2, 0);
test_assert_int_equal(nnc.global_index1, 2 * i); // as set in make_intersect_init_file()
test_assert_int_equal(nnc.global_index2, 2 * i + 1); // as set in make_intersect_init_file()
test_assert_double_equal(nnc.trans, 2.5 * i); // as set in make_intersect_init_file()
test_assert_int_equal(nnc.input_index, i);
}
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_nnc_geometry.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -36,7 +36,7 @@ void test_create_empty() {
}
void test_create_simple() {
test_work_area_type * work_area = test_work_area_alloc("nnc-INIT");
ecl::util::TestArea ta("nnc_geometry");
{
int nx = 10;
int ny = 10;
@@ -64,10 +64,10 @@ void test_create_simple() {
fortio_fclose( f );
ecl_kw_free( trann_nnc );
}
ecl_nnc_geometry_free(nnc_geo);
}
ecl_grid_free( grid0 );
}
test_work_area_free( work_area );
}

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_nnc_index_list.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_nnc_index_list_grid.c' is part of ERT - Ensemble based Reservoir Tool.

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
Copyright (C) 2013 Equinor ASA, Norway.
The file 'ecl_nnc_info_test.c' is part of ERT - Ensemble based Reservoir Tool.
@@ -18,6 +18,8 @@
#include <stdlib.h>
#include <stdbool.h>
#include <vector>
#include <ert/util/test_util.hpp>
#include <ert/util/util.h>
#include <ert/util/int_vector.hpp>
@@ -53,6 +55,8 @@ void test_equal( ) {
nnc_info_add_nnc( nnc_info1 , lgr_nr + 2 , 11 , 11 );
nnc_info_add_nnc( nnc_info2 , lgr_nr + 1 , 10 , 10 );
test_assert_true( nnc_info_equal( nnc_info1 , nnc_info2 ));
nnc_info_free( nnc_info1 );
nnc_info_free( nnc_info2 );
}
@@ -91,23 +95,22 @@ void basic_test() {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1);
test_assert_int_equal(int_vector_size(nnc_cells), 2);
test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector ));
const std::vector<int>& nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1);
test_assert_int_equal(nnc_cells.size(), 2);
test_assert_ptr_equal( nnc_cells.data() , nnc_vector_get_grid_index_list( nnc_vector ).data());
nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2);
test_assert_NULL(nnc_cells_null);
test_assert_true( !nnc_info_has_grid_index_list(nnc_info, 2) );
test_assert_NULL(nnc_vector_null);
nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr );
test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );
const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr);
const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info);
test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );
const std::vector<int>& nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr);
const std::vector<int>& nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info);
test_assert_ptr_equal( nnc_cells_77.data() , nnc_cells_self.data() );
test_assert_int_equal( 2 , nnc_info_get_size( nnc_info ));

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
Copyright (C) 2017 Equinor ASA, Norway.
The file 'ecl_nnc_pair.c' is part of ERT - Ensemble based Reservoir Tool.

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