//-------------------------------------------------------------------------------------------------- /// This file contains test code taken from the test cases in ERT source code. // There is a typedef issue (center) between ERT and QTextStream, so this file does not include any // Qt files. //-------------------------------------------------------------------------------------------------- TEST(RigReservoirTest, WellTestErt) { char filename[1024] = "TEST10K_FLT_LGR_NNC.UNRST"; well_info_type * well_info = well_info_alloc( NULL ); well_info_load_rstfile( well_info , filename); // List all wells: { int iwell; for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) { printf("Well[%02d] : %s \n",iwell , well_info_iget_well_name( well_info , iwell)); } } // Look at the timeseries for one well: { well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , 0)); for (int i =0; i < well_ts_get_size( well_ts ); i++) { well_state_type * well_state = well_ts_iget_state( well_ts , i ); printf("Well:%s report:%04d state:",well_state_get_name( well_state ), well_state_get_report_nr( well_state )); if (well_state_is_open( well_state )) printf("OPEN\n"); else printf("CLOSED\n"); } } // Look at one well_state: { well_state_type * well_state = well_info_iiget_state( well_info , 0 , 0 ); printf("Well:%s report:%04d \n",well_state_get_name( well_state ), well_state_get_report_nr( well_state )); { int branchCount = well_state_get_num_branches(well_state); for (int ibranch = 0 ; ibranch < branchCount; ++ibranch) { printf("Branch: %d", ibranch); for (int iconn = 0; iconn < well_state_get_num_connections( well_state, ibranch ); iconn++) { const well_conn_type * conn = well_state_get_connections( well_state , ibranch)[iconn]; printf("Connection:%02d i=%3d j=%3d k=%3d State:",iconn , conn->i, conn->j , conn->k); if (conn->open) printf("Open\n"); else printf("Closed\n"); } } } } well_info_free( well_info ); }
static well_node_type * well_node_alloc( well_state_type * well_state) { well_node_type * node = util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , WELL_NODE_TYPE_ID ); node->report_nr = well_state_get_report_nr( well_state ); node->sim_time = well_state_get_sim_time( well_state ); node->well_state = well_state; return node; }
int main( int argc , char ** argv) { signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ signal(SIGABRT , util_abort_signal); /* Signal abort. */ { well_info_type * well_info = well_info_alloc( NULL ); int i; for (i=1; i < argc; i++) { printf("Loading file: %s \n",argv[i]); well_info_load_rstfile( well_info , argv[i]); } // List all wells: { int iwell; for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) { well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , iwell)); well_state_type * well_state = well_ts_get_last_state( well_ts ); well_state_summarize( well_state , stdout ); printf("\n"); } } well_info_free( well_info ); exit(1); // Look at the timeseries for one well: { well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , 0)); int i; for (i =0; i < well_ts_get_size( well_ts ); i++) { well_state_type * well_state = well_ts_iget_state( well_ts , i ); printf("Well:%s report:%04d state:",well_state_get_name( well_state ), well_state_get_report_nr( well_state )); if (well_state_is_open( well_state )) printf("OPEN\n"); else printf("CLOSED\n"); } } // Look at one well_state: { well_state_type * well_state = well_info_iiget_state( well_info , 0 , 0 ); printf("Well:%s report:%04d \n",well_state_get_name( well_state ), well_state_get_report_nr( well_state )); { const well_conn_type ** connections = well_state_get_connections( well_state , 0 ); printf("Branches: %d \n",well_state_get_num_branches( well_state )); printf("num_connections: %d \n",well_state_get_num_connections( well_state , 0 )); { int iconn; for (iconn = 0; iconn < well_state_get_num_connections( well_state , 0 ); iconn++) { well_conn_type * conn = connections[ iconn ]; printf("Connection:%02d i=%3d j=%3d k=%3d State:",iconn , well_conn_get_i( conn ) , well_conn_get_j( conn ) , well_conn_get_k( conn )); if (well_conn_open( conn ) ) printf("Open\n"); else printf("Closed\n"); } } } } well_info_free( well_info ); } }
void verifyWellState(const std::string& rst_filename, Opm::EclipseGridConstPtr ecl_grid, Opm::ScheduleConstPtr schedule) { well_info_type * well_info = well_info_alloc(ecl_grid->c_ptr()); well_info_load_rstfile(well_info, rst_filename.c_str(), false); //Verify numwells int numwells = well_info_get_num_wells(well_info); BOOST_CHECK(numwells == (int)schedule->numWells()); std::vector<Opm::WellConstPtr> wells = schedule->getWells(); for (int i = 0; i < numwells; ++i) { //Verify wellnames const char * wellname = well_info_iget_well_name(well_info, i); Opm::WellConstPtr well = wells.at(i); BOOST_CHECK(wellname == well->name()); // Verify well-head position data well_ts_type * well_ts = well_info_get_ts(well_info , wellname); well_state_type * well_state = well_ts_iget_state(well_ts, 0); const well_conn_type * well_head = well_state_get_wellhead(well_state, ECL_GRID_GLOBAL_GRID); BOOST_CHECK(well_conn_get_i(well_head) == well->getHeadI()); BOOST_CHECK(well_conn_get_j(well_head) == well->getHeadJ()); for (int j = 0; j < well_ts_get_size(well_ts); ++j) { well_state = well_ts_iget_state(well_ts, j); //Verify welltype int ert_well_type = well_state_get_type(well_state); WellType welltype = well->isProducer(j) ? PRODUCER : INJECTOR; Opm::WellInjector::TypeEnum injectortype = well->getInjectionProperties(j).injectorType; int ecl_converted_welltype = Opm::EclipseWriter::eclipseWellTypeMask(welltype, injectortype); int ert_converted_welltype = well_state_translate_ecl_type_int(ecl_converted_welltype); BOOST_CHECK(ert_well_type == ert_converted_welltype); //Verify wellstatus int ert_well_status = well_state_is_open(well_state) ? 1 : 0; Opm::WellCommon::StatusEnum status = well->getStatus(j); int wellstatus = Opm::EclipseWriter::eclipseWellStatusMask(status); BOOST_CHECK(ert_well_status == wellstatus); //Verify number of completion connections const well_conn_collection_type * well_connections = well_state_get_global_connections( well_state ); size_t num_wellconnections = well_conn_collection_get_size(well_connections); int report_nr = well_state_get_report_nr(well_state); Opm::CompletionSetConstPtr completions_set = well->getCompletions((size_t)report_nr); BOOST_CHECK(num_wellconnections == completions_set->size()); //Verify coordinates for each completion connection for (size_t k = 0; k < num_wellconnections; ++k) { const well_conn_type * well_connection = well_conn_collection_iget_const(well_connections , k); Opm::CompletionConstPtr completion = completions_set->get(k); BOOST_CHECK(well_conn_get_i(well_connection) == completion->getI()); BOOST_CHECK(well_conn_get_j(well_connection) == completion->getJ()); BOOST_CHECK(well_conn_get_k(well_connection) == completion->getK()); } } } well_info_free(well_info); }