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); }
void EclipseWriteRFTHandler::writeTimeStep(const std::string& filename, const ert_ecl_unit_enum ecl_unit, const SimulatorTimerInterface& simulatorTimer, std::vector<WellConstPtr>& wells, EclipseGridConstPtr eclipseGrid, std::vector<double>& pressure, std::vector<double>& swat, std::vector<double>& sgas) { std::vector<ecl_rft_node_type *> rft_nodes; for (std::vector<WellConstPtr>::const_iterator ci = wells.begin(); ci != wells.end(); ++ci) { WellConstPtr well = *ci; if ((well->getRFTActive(simulatorTimer.currentStepNum())) || (well->getPLTActive(simulatorTimer.currentStepNum()))) { ecl_rft_node_type * ecl_node = createEclRFTNode(well, simulatorTimer, eclipseGrid, pressure, swat, sgas); if (well->getPLTActive(simulatorTimer.currentStepNum())) { std::cerr << "PLT not supported, writing RFT data" << std::endl; } rft_nodes.push_back(ecl_node); } } if (rft_nodes.size() > 0) { ecl_rft_file_update(filename.c_str(), rft_nodes.data(), rft_nodes.size(), ecl_unit); } //Cleanup: The ecl_rft_file_update method takes care of freeing the ecl_rft_nodes that it receives. // Each ecl_rft_node is again responsible for freeing it's cells. }