Merge pull request #575 from joakim-hove/smspec-c++

Adapt to C++ changes in libecl
This commit is contained in:
Joakim Hove
2018-11-30 08:09:31 +01:00
committed by GitHub
9 changed files with 140 additions and 249 deletions

View File

@@ -17,10 +17,10 @@
*/
#include "summaryComparator.hpp"
#include <ert/ecl/ecl_sum.h>
#include <ert/util/stringlist.h>
#include <ert/util/int_vector.h>
#include <ert/util/bool_vector.h>
#include <ert/ecl/ecl_sum.hpp>
#include <ert/util/stringlist.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/util/bool_vector.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <cmath>
#include <numeric>

View File

@@ -19,8 +19,8 @@
#include "summaryIntegrationTest.hpp"
#include <opm/common/ErrorMacros.hpp>
#include <ert/ecl/ecl_sum.h>
#include <ert/util/stringlist.h>
#include <ert/ecl/ecl_sum.hpp>
#include <ert/util/stringlist.hpp>
#include <cmath>
@@ -155,13 +155,10 @@ void SummaryIntegrationTest::findGreatestErrorRatio(const WellProductionVolume&
void SummaryIntegrationTest::volumeErrorCheck(const char* keyword){
const smspec_node_type * node = ecl_sum_get_general_var_node (ecl_sum_fileShort ,keyword);//doesn't matter which ecl_sum_file one uses, the kewyord SHOULD be equal in terms of smspec data.
bool hist = smspec_node_is_historical(node);
/* returns true if the keyword corresponds to a summary vector "history".
E.g. WOPRH, where the last character, 'H', indicates that it is a HISTORY vector.*/
if(hist){
return;//To make sure we do not include history vectors.
}
const ecl::smspec_node * node = ecl_sum_get_general_var_node (ecl_sum_fileShort ,keyword);//doesn't matter which ecl_sum_file one uses, the kewyord SHOULD be equal in terms of smspec data.
if (node->is_historical())
return;
if (!mainVariable.empty()){
std::string keywordString(keyword);
std::string firstFour = keywordString.substr(0,4);

View File

@@ -18,7 +18,7 @@
#include "summaryRegressionTest.hpp"
#include <opm/common/ErrorMacros.hpp>
#include <ert/ecl/ecl_sum.h>
#include <ert/ecl/ecl_sum.hpp>
#include <ert/util/stringlist.h>
#include <string>

View File

@@ -23,7 +23,7 @@
#include <string>
#include <unordered_map>
#include <ert/ecl/smspec_node.h>
#include <ert/ecl/smspec_node.hpp>
namespace Opm{
@@ -67,7 +67,7 @@ public:
double get(const std::string&) const;
bool has(const std::string& key) const;
void add(const std::string& key, double value);
void add(const smspec_node_type * node_ptr, double value);
void add(const ecl::smspec_node& node, double value);
void add_well_var(const std::string& well, const std::string& var, double value);
bool has_well_var(const std::string& well, const std::string& var) const;

View File

@@ -24,7 +24,7 @@
#include <vector>
#include <set>
#include <ert/ecl/smspec_node.h>
#include <ert/ecl/smspec_node.hpp>
namespace Opm {
@@ -36,44 +36,61 @@ namespace Opm {
class SummaryNode {
public:
SummaryNode(smspec_node_type * c_ptr) :
ptr(c_ptr)
SummaryNode(const std::string& keyword) :
ecl_node(0, keyword.c_str(), "UNIT", 0.0)
{}
SummaryNode(const SummaryNode& other) :
ptr( smspec_node_alloc_copy(other.get()))
SummaryNode(const std::string& keyword, const std::string& wgname) :
ecl_node(0, keyword.c_str(), wgname.c_str(), "UNIT", 0.0, ":")
{}
const smspec_node_type * get() const {
return this->ptr;
}
SummaryNode(const std::string& keyword, const std::string& wgname, int num) :
ecl_node(0, keyword.c_str(), wgname.c_str(), num, "UNIT", 0.0, ":")
{}
SummaryNode(const std::string& keyword, int num) :
ecl_node(0, keyword.c_str(), num, "UNIT", 0, ":")
{}
SummaryNode(const std::string& keyword, int num, const int grid_dims[3]) :
ecl_node(0, keyword.c_str(), num, "UNIT", grid_dims, 0, ":")
{}
SummaryNode(const std::string& keyword, const std::string& wgname, int num, const int grid_dims[3]) :
ecl_node(0, keyword.c_str(), wgname.c_str(), num, "UNIT", grid_dims, 0, ":")
{}
std::string wgname() const {
return smspec_node_get_wgname(this->ptr);
const char * c_ptr = this->ecl_node.get_wgname();
if (c_ptr)
return std::string(c_ptr);
else
return "";
}
std::string keyword() const {
return smspec_node_get_keyword(this->ptr);
return this->ecl_node.get_keyword();
}
std::string gen_key() const {
return this->ecl_node.get_gen_key1();
}
int num() const {
return smspec_node_get_num(this->ptr);
return this->ecl_node.get_num();
}
ecl_smspec_var_type type() const {
return smspec_node_get_var_type(this->ptr);
return this->ecl_node.get_var_type();
}
SummaryNode& operator=(const SummaryNode &other) {
this->ptr = smspec_node_alloc_copy(other.ptr);
return *this;
int cmp(const SummaryNode& other) const {
return this->ecl_node.cmp( other.ecl_node );
}
~SummaryNode() {
smspec_node_free(this->ptr);
}
private:
smspec_node_type * ptr;
ecl::smspec_node ecl_node;
};

View File

@@ -43,8 +43,8 @@
#include <opm/output/eclipse/Summary.hpp>
#include <opm/output/eclipse/RegionCache.hpp>
#include <ert/ecl/smspec_node.h>
#include <ert/ecl/ecl_smspec.h>
#include <ert/ecl/smspec_node.hpp>
#include <ert/ecl/ecl_smspec.hpp>
#include <ert/ecl/ecl_kw_magic.h>
namespace {
@@ -154,33 +154,17 @@ namespace {
':' + std::to_string(segRes.segNumber);
}
ERT::ert_unique_ptr<smspec_node_type, smspec_node_free>
std::unique_ptr<ecl::smspec_node>
makeRestartVectorSMSPEC(const std::string& vector,
const std::string& entity)
{
const auto var_type =
ecl_smspec_identify_var_type(vector.c_str());
const int dims[] = { 1, 1, 1 };
return ERT::ert_unique_ptr<smspec_node_type, smspec_node_free> {
smspec_node_alloc(var_type, entity.c_str(), vector.c_str(),
"UNIT", ":", dims, 0, 0, 0.0f)
};
return std::unique_ptr<ecl::smspec_node>( new ecl::smspec_node(0, vector.c_str(), entity.c_str(), "UNIT", 0.0f, ":"));
}
ERT::ert_unique_ptr<smspec_node_type, smspec_node_free>
std::unique_ptr<ecl::smspec_node>
makeRestartVectorSMSPEC(const SegmentResultDescriptor& segRes)
{
const auto var_type = ECL_SMSPEC_SEGMENT_VAR;
const int dims[] = { 1, 1, 1 };
return ERT::ert_unique_ptr<smspec_node_type, smspec_node_free> {
smspec_node_alloc(var_type, segRes.well.c_str(), segRes.vector.c_str(),
"UNIT", ":", dims,
static_cast<int>(segRes.segNumber), 0, 0.0f)
};
return std::unique_ptr<ecl::smspec_node>(new ecl::smspec_node(0, segRes.vector.c_str(), segRes.well.c_str(), static_cast<int>(segRes.segNumber), "UNIT", 0.0f, ":"));
}
} // namespace Anonymous
@@ -1058,7 +1042,7 @@ static const std::unordered_map< std::string, UnitSystem::measure> block_units =
};
inline std::vector< const Well* > find_wells( const Schedule& schedule,
const smspec_node_type* node,
const ecl::smspec_node* node,
const int sim_step,
const out::RegionCache& regionCache ) {
@@ -1112,15 +1096,14 @@ namespace out {
class Summary::keyword_handlers {
public:
using fn = ofun;
std::vector< std::pair< smspec_node_type*, fn > > handlers;
std::map< std::string, smspec_node_type* > single_value_nodes;
std::map< std::pair <std::string, int>, smspec_node_type* > region_nodes;
std::map< std::pair <std::string, int>, smspec_node_type* > block_nodes;
std::vector< std::pair< const ecl::smspec_node*, fn > > handlers;
std::map< std::string, const ecl::smspec_node* > single_value_nodes;
std::map< std::pair <std::string, int>, const ecl::smspec_node* > region_nodes;
std::map< std::pair <std::string, int>, const ecl::smspec_node* > block_nodes;
// Memory management for restart-related summary vectors
// that are not requested in SUMMARY section.
std::vector<ERT::ert_unique_ptr<smspec_node_type,
smspec_node_free>> rstvec_backing_store;
std::vector<std::unique_ptr<ecl::smspec_node>> rstvec_backing_store;
};
Summary::Summary( const EclipseState& st,
@@ -1180,7 +1163,8 @@ Summary::Summary( const EclipseState& st,
std::set< std::string > unsupported_keywords;
for( const auto& node : sum ) {
const auto* keyword = smspec_node_get_keyword(node.get());
ecl_smspec_type * smspec = ecl_sum_get_smspec(this->ecl_sum.get());
std::string keyword = node.keyword();
const auto single_value_pair = single_values_units.find( keyword );
const auto funs_pair = funs.find( keyword );
@@ -1188,60 +1172,36 @@ Summary::Summary( const EclipseState& st,
const auto block_pair = block_units.find( keyword );
/*
All summary values of the type ECL_SMSPEC_MISC_VAR
and ECL_SMSPEC_FIELD_VAR must be passed explicitly
in the misc_values map when calling
add_timestep.
*/
All summary values of the type ECL_SMSPEC_MISC_VAR
and ECL_SMSPEC_FIELD_VAR must be passed explicitly
in the misc_values map when calling
add_timestep.
*/
if (single_value_pair != single_values_units.end()) {
auto node_type = smspec_node_get_var_type(node.get());
auto node_type = node.type();
if ((node_type != ECL_SMSPEC_FIELD_VAR) && (node_type != ECL_SMSPEC_MISC_VAR)) {
continue;
}
auto* nodeptr = ecl_sum_add_var( this->ecl_sum.get(),
keyword,
smspec_node_get_wgname(node.get()),
smspec_node_get_num(node.get()),
st.getUnits().name( single_value_pair->second ),
0 );
auto* nodeptr = ecl_smspec_add_node( smspec, keyword.c_str(), st.getUnits().name( single_value_pair->second ), 0);
this->handlers->single_value_nodes.emplace( keyword, nodeptr );
} else if (region_pair != region_units.end()) {
auto* nodeptr = ecl_sum_add_var( this->ecl_sum.get(),
keyword,
smspec_node_get_wgname(node.get()),
smspec_node_get_num(node.get()),
st.getUnits().name( region_pair->second ),
0 );
this->handlers->region_nodes.emplace( std::make_pair(keyword, smspec_node_get_num(node.get())), nodeptr );
auto* nodeptr = ecl_smspec_add_node( smspec, keyword.c_str(), node.num(), st.getUnits().name( region_pair->second ), 0);
this->handlers->region_nodes.emplace( std::make_pair(keyword, node.num()), nodeptr );
} else if (block_pair != block_units.end()) {
if (smspec_node_get_var_type(node.get()) != ECL_SMSPEC_BLOCK_VAR)
if (node.type() != ECL_SMSPEC_BLOCK_VAR)
continue;
int global_index = smspec_node_get_num(node.get()) - 1;
int global_index = node.num() - 1;
if (!this->grid.cellActive(global_index))
continue;
auto* nodeptr = ecl_sum_add_var( this->ecl_sum.get(),
keyword,
smspec_node_get_wgname(node.get()),
smspec_node_get_num(node.get()),
st.getUnits().name( block_pair->second ),
0 );
this->handlers->block_nodes.emplace( std::make_pair(keyword, smspec_node_get_num(node.get())), nodeptr );
auto* nodeptr = ecl_smspec_add_node( smspec, keyword.c_str(), node.num(), st.getUnits().name( block_pair->second ), 0 );
this->handlers->block_nodes.emplace( std::make_pair(keyword, node.num()), nodeptr );
} else if (funs_pair != funs.end()) {
auto node_type = smspec_node_get_var_type(node.get());
auto node_type = node.type();
if ((node_type == ECL_SMSPEC_COMPLETION_VAR) || (node_type == ECL_SMSPEC_BLOCK_VAR)) {
int global_index = smspec_node_get_num(node.get()) - 1;
int global_index = node.num() - 1;
if (!this->grid.cellActive(global_index))
continue;
}
@@ -1253,7 +1213,7 @@ Summary::Summary( const EclipseState& st,
const fn_args no_args { dummy_wells, // Wells from Schedule object
0, // Duration of time step
0, // Simulation step
smspec_node_get_num(node.get()), // NUMS value for the summary output.
node.num(),
{}, // Well results - data::Wells
{}, // Region <-> cell mappings.
this->grid,
@@ -1261,13 +1221,7 @@ Summary::Summary( const EclipseState& st,
const auto val = handle( no_args );
auto* nodeptr = ecl_sum_add_var( this->ecl_sum.get(),
keyword,
smspec_node_get_wgname(node.get()),
smspec_node_get_num(node.get()),
st.getUnits().name( val.unit ),
0 );
auto * nodeptr = ecl_smspec_add_node( smspec, keyword.c_str(), node.wgname().c_str(), node.num(), st.getUnits().name( val.unit ), 0 );
this->handlers->handlers.emplace_back( nodeptr, handle );
} else {
unsupported_keywords.insert(keyword);
@@ -1330,8 +1284,8 @@ Summary::Summary( const EclipseState& st,
for (const auto& pair : this->handlers->handlers) {
const auto * nodeptr = pair.first;
if (smspec_node_is_total(nodeptr))
this->prev_state.add(nodeptr, 0);
if (nodeptr->is_total())
this->prev_state.add(*nodeptr, 0);
}
}
@@ -1352,21 +1306,22 @@ Summary::Summary( const EclipseState& st,
*
*/
std::vector< std::pair< std::string, double > >
well_efficiency_factors( const smspec_node_type* type,
const Schedule& schedule,
const std::vector< const Well* >& schedule_wells,
const int sim_step ) {
well_efficiency_factors( const ecl::smspec_node* node,
const Schedule& schedule,
const std::vector< const Well* >& schedule_wells,
const int sim_step ) {
std::vector< std::pair< std::string, double > > efac;
if( smspec_node_get_var_type(type) != ECL_SMSPEC_GROUP_VAR
&& smspec_node_get_var_type(type) != ECL_SMSPEC_FIELD_VAR
&& smspec_node_get_var_type(type) != ECL_SMSPEC_REGION_VAR
&& !smspec_node_is_total( type ) ) {
auto var_type = node->get_var_type();
if( var_type != ECL_SMSPEC_GROUP_VAR
&& var_type != ECL_SMSPEC_FIELD_VAR
&& var_type != ECL_SMSPEC_REGION_VAR
&& !node->is_total()) {
return efac;
}
const bool is_group = smspec_node_get_var_type(type) == ECL_SMSPEC_GROUP_VAR;
const bool is_rate = !smspec_node_is_total( type );
const bool is_group = (var_type == ECL_SMSPEC_GROUP_VAR);
const bool is_rate = !node->is_total();
const auto &groupTree = schedule.getGroupTree(sim_step);
for( const auto* well : schedule_wells ) {
@@ -1375,19 +1330,19 @@ well_efficiency_factors( const smspec_node_type* type,
if ( !well->hasBeenDefined( sim_step ) )
continue;
const auto* node = &schedule.getGroup(well->getGroupName(sim_step));
const auto* group_node = &schedule.getGroup(well->getGroupName(sim_step));
while(true){
if(( is_group
&& is_rate
&& node->name() == smspec_node_get_wgname(type) ))
&& group_node->name() == node->get_wgname() ))
break;
eff_factor *= node->getGroupEfficiencyFactor( sim_step );
eff_factor *= group_node->getGroupEfficiencyFactor( sim_step );
const auto& parent = groupTree.parent( node->name() );
const auto& parent = groupTree.parent( group_node->name() );
if( !schedule.hasGroup( parent ) )
break;
node = &schedule.getGroup( parent );
group_node = &schedule.getGroup( parent );
}
efac.emplace_back( well->name(), eff_factor );
}
@@ -1450,7 +1405,7 @@ void Summary::add_timestep( int report_step,
unit_applied_val += this->prev_state.get(genkey);
}
st.add(f.first, unit_applied_val);
st.add(*f.first, unit_applied_val);
}
for( const auto& value_pair : single_values ) {
@@ -1460,7 +1415,7 @@ void Summary::add_timestep( int report_step,
const auto unit = single_values_units.at( key );
double si_value = value_pair.second;
double output_value = es.getUnits().from_si(unit , si_value );
st.add(node_pair->second, output_value);
st.add(*node_pair->second, output_value);
}
}
@@ -1475,7 +1430,7 @@ void Summary::add_timestep( int report_step,
assert (smspec_node_get_num( nodeptr ) - 1 == static_cast<int>(reg));
double si_value = value_pair.second[reg];
double output_value = es.getUnits().from_si(unit , si_value );
st.add(nodeptr, output_value);
st.add(*nodeptr, output_value);
}
}
}
@@ -1488,7 +1443,7 @@ void Summary::add_timestep( int report_step,
const auto unit = block_units.at( key.first );
double si_value = value_pair.second;
double output_value = es.getUnits().from_si(unit , si_value );
st.add(nodeptr, output_value);
st.add(*nodeptr, output_value);
}
}

View File

@@ -21,13 +21,13 @@
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
namespace Opm{
void SummaryState::add(const smspec_node_type * node_ptr, double value) {
if (smspec_node_get_var_type(node_ptr) == ECL_SMSPEC_WELL_VAR)
this->add_well_var(smspec_node_get_wgname(node_ptr),
smspec_node_get_keyword(node_ptr),
void SummaryState::add(const ecl::smspec_node& node, double value) {
if (node.get_var_type() == ECL_SMSPEC_WELL_VAR)
this->add_well_var(node.get_wgname(),
node.get_keyword(),
value);
else
this->add(smspec_node_get_gen_key1(node_ptr), value);
this->add(node.get_gen_key1(), value);
}
void SummaryState::add(const std::string& key, double value) {

View File

@@ -36,7 +36,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <ert/ecl/ecl_smspec.h>
#include <ert/ecl/ecl_smspec.hpp>
#include <iostream>
#include <algorithm>
@@ -148,7 +148,6 @@ void handleMissingGroup( const ParseContext& parseContext , const std::string& k
const auto hasValue = []( const DeckKeyword& kw ) {
return kw.getDataRecord().getDataItem().hasValue( 0 );
};
const std::array<int,3> dummy_dims = {1,1,1};
if (keyword.size() && hasValue(keyword)) {
for( const std::string& pattern : keyword.getStringData()) {
@@ -158,23 +157,11 @@ void handleMissingGroup( const ParseContext& parseContext , const std::string& k
handleMissingWell( parseContext, keyword.name(), pattern );
for( const auto* well : wells )
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_WELL_VAR,
well->name().c_str(),
keyword.name().c_str(),
"",
":",
dummy_dims.data(),
0,0,0)));
list.push_back( SummaryConfig::keyword_type( keyword.name(), well->name() ));
}
} else
for (const auto* well : schedule.getWells())
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_WELL_VAR,
well->name().c_str(),
keyword.name().c_str(),
"",
":",
dummy_dims.data(),
0,0,0)));
list.push_back( SummaryConfig::keyword_type( keyword.name(), well->name()));
}
@@ -183,7 +170,6 @@ inline void keywordG( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword,
const Schedule& schedule ) {
const std::array<int,3> dummy_dims = {1,1,1};
if( keyword.name() == "GMWSET" ) return;
if( keyword.size() == 0 ||
@@ -191,13 +177,7 @@ inline void keywordG( SummaryConfig::keyword_list& list,
for( const auto& group : schedule.getGroups() ) {
if( group->name() == "FIELD" ) continue;
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_GROUP_VAR,
group->name().c_str(),
keyword.name().c_str(),
"",
":",
dummy_dims.data(),
0, 0, 0)));
list.push_back( SummaryConfig::keyword_type(keyword.name(), group->name() ));
}
return;
}
@@ -206,33 +186,17 @@ inline void keywordG( SummaryConfig::keyword_list& list,
for( const std::string& group : item.getData< std::string >() ) {
if( schedule.hasGroup( group ) )
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_GROUP_VAR,
group.c_str(),
keyword.name().c_str(),
"",
":",
dummy_dims.data(),
0, 0, 0)));
list.push_back( SummaryConfig::keyword_type(keyword.name(), group ));
else
handleMissingGroup( parseContext, keyword.name(), group );
}
}
inline void keywordF( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword ) {
const std::array<int,3> dummy_dims = {1,1,1};
if( keyword.name() == "FMWSET" ) return;
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_FIELD_VAR,
NULL,
keyword.name().c_str(),
"",
":",
dummy_dims.data(),
0, 0, 0)));
}
inline void keywordF( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword ) {
if( keyword.name() == "FMWSET" ) return;
list.push_back( SummaryConfig::keyword_type( keyword.name() ));
}
inline std::array< int, 3 > getijk( const DeckRecord& record,
int offset = 0 ) {
@@ -247,21 +211,15 @@ inline std::array< int, 3 > getijk( const Connection& completion ) {
return { { completion.getI(), completion.getJ(), completion.getK() }};
}
inline void keywordB( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword,
const GridDims& dims) {
for( const auto& record : keyword ) {
auto ijk = getijk( record );
int global_index = 1 + dims.getGlobalIndex(ijk[0], ijk[1], ijk[2]);
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc(ECL_SMSPEC_BLOCK_VAR,
NULL,
keyword.name().c_str(),
"",
":",
dims.getNXYZ().data(),
global_index,0,0)));
}
inline void keywordB( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword,
const GridDims& dims) {
for( const auto& record : keyword ) {
auto ijk = getijk( record );
int global_index = 1 + dims.getGlobalIndex(ijk[0], ijk[1], ijk[2]);
list.push_back( SummaryConfig::keyword_type( keyword.name(), global_index, dims.getNXYZ().data() ));
}
}
inline void keywordR( SummaryConfig::keyword_list& list,
@@ -289,33 +247,18 @@ inline std::array< int, 3 > getijk( const Connection& completion ) {
for( const int region : regions ) {
if (region >= 1 && region <= static_cast<int>(numfip))
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_REGION_VAR,
NULL,
keyword.name().c_str(),
"",
":",
dims.getNXYZ().data(),
region,
0, 0)));
list.push_back( SummaryConfig::keyword_type( keyword.name(), region ));
else
throw std::invalid_argument("Illegal region value: " + std::to_string( region ));
}
}
inline void keywordMISC( SummaryConfig::keyword_list& list,
inline void keywordMISC( SummaryConfig::keyword_list& list,
const DeckKeyword& keyword)
{
const std::array<int,3> dummy_dims = {1,1,1};
if (meta_keywords.count( keyword.name() ) == 0)
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_MISC_VAR,
NULL,
keyword.name().c_str(),
"",
":",
dummy_dims.data(),
0,
0, 0)));
list.push_back( SummaryConfig::keyword_type( keyword.name() ));
}
@@ -353,27 +296,13 @@ inline std::array< int, 3 > getijk( const Connection& completion ) {
if( record.getItem( 1 ).defaultApplied( 0 ) ) {
int global_index = 1 + dims.getGlobalIndex(cijk[0], cijk[1], cijk[2]);
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_COMPLETION_VAR,
name.c_str(),
keywordstring.c_str(),
"",
":",
dims.getNXYZ().data(),
global_index,
0, 0)));
list.push_back( SummaryConfig::keyword_type( keywordstring, name.c_str(), global_index, dims.getNXYZ().data()));
} else {
/* block coordinates specified */
auto recijk = getijk( record, 1 );
if( std::equal( recijk.begin(), recijk.end(), cijk.begin() ) ) {
int global_index = 1 + dims.getGlobalIndex(recijk[0], recijk[1], recijk[2]);
list.push_back( SummaryConfig::keyword_type( smspec_node_alloc( ECL_SMSPEC_COMPLETION_VAR,
name.c_str(),
keywordstring.c_str(),
"",
":",
dims.getNXYZ().data(),
global_index,
0, 0)));
list.push_back(SummaryConfig::keyword_type( keywordstring, name.c_str(), global_index, dims.getNXYZ().data()));
}
}
}
@@ -448,14 +377,7 @@ inline std::array< int, 3 > getijk( const Connection& completion ) {
auto makeNode = [&keyword, &list]
(const std::string& well, const int segNumber)
{
// Grid dimensions immaterial for segment related vectors.
const int dims[] = { 1, 1, 1 };
list.push_back(SummaryConfig::keyword_type {
smspec_node_alloc(ECL_SMSPEC_SEGMENT_VAR, well.c_str(),
keyword.name().c_str(), "", ":",
dims, segNumber, 0, 0)
});
list.push_back(SummaryConfig::keyword_type( keyword.name(), well, segNumber ));
};
for (const auto* well : wells) {
@@ -612,12 +534,12 @@ inline std::array< int, 3 > getijk( const Connection& completion ) {
inline void uniq( SummaryConfig::keyword_list& vec ) {
const auto lt = []( const SummaryConfig::keyword_type& lhs,
const SummaryConfig::keyword_type& rhs ) {
return smspec_node_cmp(lhs.get(), rhs.get()) < 0;
return lhs.cmp(rhs) < 0;
};
const auto eq = []( const SummaryConfig::keyword_type& lhs,
const SummaryConfig::keyword_type& rhs ) {
return smspec_node_equal(lhs.get(), rhs.get());
return lhs.cmp(rhs) == 0;
};
std::sort( vec.begin(), vec.end(), lt );
@@ -649,8 +571,8 @@ SummaryConfig::SummaryConfig( const Deck& deck,
uniq( this->keywords );
for (const auto& kw: this->keywords) {
this->short_keywords.insert( smspec_node_get_keyword( kw.get() ));
this->summary_keywords.insert( smspec_node_get_gen_key1( kw.get() ));
this->short_keywords.insert( kw.keyword() );
this->summary_keywords.insert( kw.gen_key() );
}
}

View File

@@ -100,9 +100,9 @@ static Deck createDeck( const std::string& summary ) {
static std::vector< std::string > sorted_names( const SummaryConfig& summary ) {
std::vector< std::string > ret;
for( const auto& x : summary ) {
auto wgname = smspec_node_get_wgname(x.get());
if(wgname)
ret.push_back( smspec_node_get_wgname(x.get()));
auto wgname = x.wgname();
if(wgname.size())
ret.push_back( wgname );
}
std::sort( ret.begin(), ret.end() );
@@ -112,7 +112,7 @@ static std::vector< std::string > sorted_names( const SummaryConfig& summary ) {
static std::vector< std::string > sorted_keywords( const SummaryConfig& summary ) {
std::vector< std::string > ret;
for( const auto& x : summary )
ret.push_back( smspec_node_get_keyword(x.get()));
ret.push_back( x.keyword() );
std::sort( ret.begin(), ret.end() );
return ret;
@@ -121,7 +121,7 @@ static std::vector< std::string > sorted_keywords( const SummaryConfig& summary
static std::vector< std::string > sorted_key_names( const SummaryConfig& summary ) {
std::vector< std::string > ret;
for( const auto& x : summary ) {
ret.push_back( smspec_node_get_gen_key1(x.get()));
ret.push_back( x.gen_key() );
}
std::sort( ret.begin(), ret.end() );