void test_rft_read_write(const char * rft_file){ ecl_rft_file_type * rft = ecl_rft_file_alloc( rft_file ); ecl_rft_node_type ** nodes =(ecl_rft_node_type **) malloc(sizeof(ecl_rft_node_type *) * 3); int size = ecl_rft_file_get_size(rft); for(int i =0;i<size;i++){ const ecl_rft_node_type * rft_node = ecl_rft_file_iget_node(rft, i); nodes[i] =rft_node; } ecl_rft_node_type * old_node = ecl_rft_file_iget_node(rft, 0); ecl_rft_node_type * new_node = ecl_rft_node_alloc_new("DUMMY", "R", ecl_rft_node_get_date(old_node), ecl_rft_node_get_days(old_node)); nodes[2]=new_node; test_work_area_type * work_area = test_work_area_alloc("RFT_RW"); ecl_rft_file_update("eclipse.rft", nodes,3, ERT_ECL_METRIC_UNITS); test_work_area_free(work_area); free(nodes); }
ecl_rft_node_type * EclipseWriteRFTHandler::createEclRFTNode(WellConstPtr well, const SimulatorTimerInterface& simulatorTimer, EclipseGridConstPtr eclipseGrid, const std::vector<double>& pressure, const std::vector<double>& swat, const std::vector<double>& sgas) { const std::string& well_name = well->name(); size_t timestep = (size_t)simulatorTimer.currentStepNum(); time_t recording_date = simulatorTimer.currentPosixTime(); double days = Opm::unit::convert::to(simulatorTimer.simulationTimeElapsed(), Opm::unit::day); std::string type = "RFT"; ecl_rft_node_type * ecl_rft_node = ecl_rft_node_alloc_new(well_name.c_str(), type.c_str(), recording_date, days); CompletionSetConstPtr completionsSet = well->getCompletions(timestep); for (size_t index = 0; index < completionsSet->size(); ++index) { CompletionConstPtr completion = completionsSet->get(index); size_t i = (size_t)completion->getI(); size_t j = (size_t)completion->getJ(); size_t k = (size_t)completion->getK(); size_t global_index = eclipseGrid->getGlobalIndex(i,j,k); int active_index = globalToActiveIndex_[global_index]; if (active_index > -1) { double depth = eclipseGrid->getCellDepth(i,j,k); double completion_pressure = pressure.size() > 0 ? pressure[active_index] : 0.0; double saturation_water = swat.size() > 0 ? swat[active_index] : 0.0; double saturation_gas = sgas.size() > 0 ? sgas[active_index] : 0.0; ecl_rft_cell_type * ecl_rft_cell = ecl_rft_cell_alloc_RFT( i ,j, k , depth, completion_pressure, saturation_water, saturation_gas); ecl_rft_node_append_cell( ecl_rft_node , ecl_rft_cell); } } return ecl_rft_node; }