void Opm::initCPGrid(Dune::CpGrid& grid, const Opm::ParameterGroup& param) { std::string fileformat = param.get<std::string>("fileformat"); if (fileformat == "sintef_legacy") { std::string grid_prefix = param.get<std::string>("grid_prefix"); grid.readSintefLegacyFormat(grid_prefix); } else if (fileformat == "eclipse") { std::string filename = param.get<std::string>("filename"); if (param.has("z_tolerance")) { std::cerr << "****** Warning: z_tolerance parameter is obsolete, use PINCH in deck input instead\n"; } bool periodic_extension = param.getDefault<bool>("periodic_extension", false); bool turn_normals = param.getDefault<bool>("turn_normals", false); Opm::Parser parser; auto deck = parser.parseFile(filename); Opm::EclipseGrid inputGrid(deck); grid.processEclipseFormat(inputGrid, periodic_extension , turn_normals ); } else if (fileformat == "cartesian") { std::array<int, 3> dims = {{ param.getDefault<int>("nx", 1), param.getDefault<int>("ny", 1), param.getDefault<int>("nz", 1) }}; std::array<double, 3> cellsz = {{ param.getDefault<double>("dx", 1.0), param.getDefault<double>("dy", 1.0), param.getDefault<double>("dz", 1.0) }}; grid.createCartesian(dims, cellsz); } else { OPM_THROW(std::runtime_error, "Unknown file format string: " << fileformat); } }
static Deck createDeckWithGasInjector() { Opm::Parser parser; std::string input = "GRID\n" "PERMX\n" " 1000*0.25/\n" "COPY\n" " PERMX PERMY /\n" " PERMX PERMZ /\n" "/\n" "SCHEDULE\n" "WELSPECS\n" " 'W_1' 'OP' 1 1 1* \'GAS\' 7* / \n" "/\n" "COMPDAT\n" " 'W_1' 2* 1 1 'OPEN' / \n" "/\n" "WCONINJE\n" " 'W_1' 'GAS' 'OPEN' 'BHP' 1 2 3/\n/\n" "WSOLVENT\n" " 'W_1' 1 / \n " "/\n"; return parser.parseString(input); }
static DeckPtr createDeckWithWellsAndCompletionData() { Opm::Parser parser; std::string input = "START -- 0 \n" "1 NOV 1979 / \n" "SCHEDULE\n" "DATES -- 1\n" " 1 DES 1979/ \n" "/\n" "WELSPECS\n" " 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" " 'OP_2' 'OP' 8 8 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" " 'OP_3' 'OP' 7 7 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" "/\n" "COMPDAT\n" " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" " 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" " 'OP_2' 8 8 1 3 'OPEN' 1* 1.168 0.311 107.872 1* 1* 'Y' 21.925 / \n" " 'OP_2' 8 7 3 3 'OPEN' 1* 15.071 0.311 1391.859 1* 1* 'Y' 21.920 / \n" " 'OP_2' 8 7 3 6 'OPEN' 1* 6.242 0.311 576.458 1* 1* 'Y' 21.915 / \n" " 'OP_3' 7 7 1 1 'OPEN' 1* 27.412 0.311 2445.337 1* 1* 'Y' 18.521 / \n" " 'OP_3' 7 7 2 2 'OPEN' 1* 55.195 0.311 4923.842 1* 1* 'Y' 18.524 / \n" "/\n" "DATES -- 2,3\n" " 10 JUL 2007 / \n" " 10 AUG 2007 / \n" "/\n" "COMPDAT\n" " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" "/\n"; return parser.parseString(input, ParseContext()); }
static DeckPtr createDeck( const std::string& summary ) { Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "DXV \n 10*400 /\n" "DYV \n 10*400 /\n" "DZV \n 10*400 /\n" "TOPS \n 100*2202 / \n" "REGIONS\n" "FIPNUM\n" "200*1 300*2 500*3 /\n" "SCHEDULE\n" "WELSPECS\n" " \'W_1\' \'OP\' 1 1 3.33 \'OIL\' 7* / \n" " \'WX2\' \'OP\' 2 2 3.33 \'OIL\' 7* / \n" " \'W_3\' \'OP\' 2 5 3.92 \'OIL\' 7* / \n" " 'PRODUCER' 'G' 5 5 2000 'GAS' /\n" "/\n" "COMPDAT\n" "'PRODUCER' 5 5 1 1 'OPEN' 1* -1 0.5 / \n" "'W_1' 3 7 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / \n" "'W_1' 3 7 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 / \n" "/\n" "SUMMARY\n" + summary; return parser.parseString(input, ParseContext()); }
static Deck createDeckWithDynamicWSOLVENT() { Opm::Parser parser; std::string input = "START -- 0 \n" "1 JAN 2000 / \n" "SCHEDULE\n" "WELSPECS\n" " 'W_1' 'OP' 1 1 1* \'GAS\' 7* / \n" "/\n" "COMPDAT\n" " 'W_1' 2* 1 1 'OPEN' / \n" "/\n" "WCONINJE\n" " 'W_1' 'GAS' 'OPEN' 'BHP' 1 2 3/\n/\n" "DATES -- 2\n" " 1 MAY 2000 / \n" "/\n" "WSOLVENT\n" " 'W_1' 1 / \n " "/\n" "DATES -- 3,4\n" " 1 JUL 2000 / \n" " 1 AUG 2000 / \n" "/\n" "WSOLVENT\n" " 'W_1' 0 / \n " "/\n"; return parser.parseString(input, ParseContext()); }
int main(int argc, char** argv) { // Set output precision int decimals = 16; // Process input parameters if (argc != 3) { std::cout << "Usage: mirror_grid filename.grdecl direction" << std::endl; std::cout << "(replace direction with either x or y)" << std::endl; exit(1); } const char* eclipsefilename = argv[1]; std::string direction(argv[2]); if ( ! ((direction == "x") || (direction == "y")) ) { std::cerr << "Unrecognized input parameter for direction: '" << direction << "'. Should be either x or y (maybe also z later)." << std::endl; exit(1); } // Parse grdecl file std::cout << "Parsing grid file '" << eclipsefilename << "' ..." << std::endl; Opm::Parser parser; Opm::ParseContext parseContext; const Opm::Deck deck(parser.parseFile(eclipsefilename , parseContext)); if ( ! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")) ) { std::cerr << "Grid file " << eclipsefilename << "are missing keywords SPECGRID, COORD or ZCORN!" << std::endl; exit(1); } // Create new grid file std::string mirrored_eclipsefilename = std::string(eclipsefilename); std::string::size_type last_dot = mirrored_eclipsefilename.find_last_of('.'); mirrored_eclipsefilename = mirrored_eclipsefilename.substr(0, last_dot) + "_mirrored-" + direction + ".grdecl"; std::ofstream outfile; outfile.open(mirrored_eclipsefilename.c_str(), std::ios::out | std::ios::trunc); if (!outfile) { std::cerr << "Can't open output file " << mirrored_eclipsefilename << std::endl; exit(1); } outfile.precision(decimals); outfile.setf(std::ios::fixed); // Print init message printInitMessage(outfile, eclipsefilename, direction); // Mirror keywords mirror_mapaxes(deck, direction, outfile); mirror_specgrid(deck, direction, outfile); mirror_coord(deck, direction, outfile); mirror_zcorn(deck, direction, outfile); mirror_celldata<int>("ACTNUM", deck, direction, outfile); mirror_celldata<double>("PERMX", deck, direction, outfile); mirror_celldata<double>("PERMY", deck, direction, outfile); mirror_celldata<double>("PERMZ", deck, direction, outfile); mirror_celldata<double>("PORO", deck, direction, outfile); mirror_celldata<int>("SATNUM", deck, direction, outfile); mirror_celldata<double>("NTG", deck, direction, outfile); mirror_celldata<double>("SWCR", deck, direction, outfile); mirror_celldata<double>("SOWCR", deck, direction, outfile); }
inline void loadDeck( const char * deck_file) { Opm::ParseContext parseContext; Opm::Parser parser; auto deck = parser.parseFile(deck_file, parseContext); Opm::EclipseState state( deck, parseContext ); Opm::Schedule schedule( deck, state.getInputGrid(), state.get3DProperties(), state.runspec(), parseContext); Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext ); { std::stringstream ss; ss << deck; auto deck2 = parser.parseString(ss.str(), parseContext); if (deck.size() != deck2.size()) { std::cerr << "Deck size mismatch original:" << deck.size() << " new: " << deck2.size( ) << std::endl; std::exit( 1 ); } for (size_t index=0; index < deck.size(); index++) { const auto& kw1 = deck.getKeyword( index ); const auto& kw2 = deck2.getKeyword( index ); if (!kw1.equal( kw2 , true , true)) { std::cerr << "Keyword " << index << " different " << kw1.name() << " " << kw2.name() << std::endl; std::cerr << kw1 << std::endl; std::cerr << std::endl << "-----------------------------------------------------------------" << std::endl; std::cerr << kw2 << std::endl; std::exit( 1 ); } } } }
static Deck createDeckWithDynamicWTRACER() { Opm::Parser parser; std::string input = "START -- 0 \n" "1 JAN 2000 / \n" "SCHEDULE\n" "WELSPECS\n" " 'W_1' 'OP' 1 1 1* \'GAS\' 7* / \n" "/\n" "COMPDAT\n" " 'W_1' 2* 1 1 'OPEN' / \n" "/\n" "WCONINJE\n" " 'W_1' 'GAS' 'OPEN' 'BHP' 1 2 3/\n/\n" "DATES -- 1\n" " 1 MAY 2000 / \n" "/\n" "WTRACER\n" " 'W_1' 'I1' 1 / \n " " 'W_1' 'I2' 1 / \n " "/\n" "DATES -- 2, 3\n" " 1 JUL 2000 / \n" " 1 AUG 2000 / \n" "/\n" "WTRACER\n" " 'W_1' 'I1' 0 / \n " "/\n" "DATES -- 4\n" " 1 SEP 2000 / \n" "/\n"; return parser.parseString(input); }
static const Opm::DeckKeyword createTABDIMSKeyword( ) { const char* deckData = "TABDIMS\n" " 0 1 2 3 4 5 / \n" "\n"; Opm::Parser parser; Opm::Deck deck = parser.parseString(deckData, Opm::ParseContext()); return deck.getKeyword("TABDIMS"); }
static const Opm::DeckKeyword createSATNUMKeyword( ) { const char* deckData = "SATNUM \n" " 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 / \n" "\n"; Opm::Parser parser; Opm::Deck deck = parser.parseString(deckData, Opm::ParseContext()); return deck.getKeyword("SATNUM"); }
static Opm::Deck createDeckMissingDIMS() { const char* deckData = "RUNSPEC\n" "\n" "GRID\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString( deckData, Opm::ParseContext()) ; }
static DeckPtr createDeck() { Opm::Parser parser; std::string input = "START\n" "8 MAR 1998 /\n" "\n" "SCHEDULE\n" "\n"; return parser.parseString(input, ParseContext()); }
static Opm::Deck radial_missing_INRAD() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "RADIAL\n" "\n"; Opm::Parser parser; return parser.parseString( deckData, Opm::ParseContext()); }
SetupMSW() { Opm::ParseContext parse_context; Opm::Parser parser; auto deck = parser.parseFile("msw.data", parse_context); Opm::EclipseState ecl_state(deck , parse_context); // Create grid. const std::vector<double>& porv = ecl_state.get3DProperties().getDoubleGridProperty("PORV").getData(); std::unique_ptr<GridInit> grid_init(new GridInit(ecl_state, porv)); const Grid& grid = grid_init->grid(); // Create material law manager. std::vector<int> compressed_to_cartesianIdx; Opm::createGlobalCellArray(grid, compressed_to_cartesianIdx); std::shared_ptr<MaterialLawManager> material_law_manager(new MaterialLawManager()); material_law_manager->initFromDeck(deck, ecl_state, compressed_to_cartesianIdx); std::unique_ptr<FluidProps> fluidprops(new FluidProps(deck, ecl_state, material_law_manager, grid)); const size_t current_timestep = 0; // dummy_dynamic_list_econ_lmited const Opm::DynamicListEconLimited dummy_dynamic_list; // Create wells. Opm::WellsManager wells_manager(ecl_state, current_timestep, Opm::UgGridHelpers::numCells(grid), Opm::UgGridHelpers::globalCell(grid), Opm::UgGridHelpers::cartDims(grid), Opm::UgGridHelpers::dimensions(grid), Opm::UgGridHelpers::cell2Faces(grid), Opm::UgGridHelpers::beginFaceCentroids(grid), fluidprops->permeability(), dummy_dynamic_list, false // We need to pass the optionaly arguments // as we get the following error otherwise // with c++ (Debian 4.9.2-10) 4.9.2 and -std=c++11 // converting to ‘const std::unordered_set<std::basic_string<char> >’ from initializer list would use explicit constructor , std::vector<double>(), // null well_potentials std::unordered_set<std::string>()); const Wells* wells = wells_manager.c_wells(); const auto wells_ecl = ecl_state.getSchedule().getWells(current_timestep); ms_wells.reset(new Opm::MultisegmentWells(wells, &(wells_manager.wellCollection()), wells_ecl, current_timestep)); };
inline Opm::Deck createSWOFDeck() { const char *deckData = "TABDIMS\n" " 2 /\n" "\n" "SWOF\n" " 1 2 3 4\n" " 5 6 7 8 /\n" " 9 10 11 12 /\n"; Opm::Parser parser; return parser.parseString(deckData, Opm::ParseContext()); }
inline void loadDeck( const char * deck_file) { Opm::ParseContext parseContext; Opm::ErrorGuard errors; Opm::Parser parser; std::cout << "Loading deck: " << deck_file << " ..... "; std::cout.flush(); auto deck = parser.parseFile(deck_file, parseContext, errors); std::cout << "parse complete - creating EclipseState .... "; std::cout.flush(); Opm::EclipseState state( deck, parseContext, errors ); Opm::Schedule schedule( deck, state.getInputGrid(), state.get3DProperties(), state.runspec(), parseContext, errors); Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext, errors ); std::cout << "complete." << std::endl; }
static Opm::Deck createDeckHeaders() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString( deckData, Opm::ParseContext()); }
Opm::WellConnections loadCOMPDAT(const std::string& compdat_keyword) { Opm::EclipseGrid grid(10,10,10); Opm::TableManager tables; Opm::Parser parser; const auto deck = parser.parseString(compdat_keyword); Opm::Eclipse3DProperties props(deck, tables, grid ); const auto& keyword = deck.getKeyword("COMPDAT", 0); Opm::WellConnections connections; std::size_t totnc = 0; for (const auto& rec : keyword) connections.loadCOMPDAT(rec, grid, props, totnc); return connections; }
static DeckPtr createDeckWithWellsOrdered() { Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" "SCHEDULE\n" "WELSPECS\n" " \'CW_1\' \'OP\' 30 37 3.33 \'OIL\' 7* / \n" " \'BW_2\' \'OP\' 30 37 3.33 \'OIL\' 7* / \n" " \'AW_3\' \'OP\' 20 51 3.92 \'OIL\' 7* / \n" "/\n"; return parser.parseString(input, ParseContext()); }
inline std::shared_ptr<const Opm::Deck> createSWOFDeck() { const char *deckData = "TABDIMS\n" " 2 /\n" "\n" "SWOF\n" " 1 2 3 4\n" " 5 6 7 8 /\n" " 9 10 11 12 /\n"; Opm::Parser parser; Opm::DeckConstPtr deck(parser.parseString(deckData, Opm::ParseContext())); return deck; }
static Deck createDeckWithOutTracer() { Opm::Parser parser; std::string input = "SCHEDULE\n" "WELSPECS\n" " 'W_1' 'OP' 2 2 1* \'OIL\' 7* / \n" "/\n" "COMPDAT\n" " 'W_1' 2* 1 1 'OPEN' / \n" "/\n" "WCONINJE\n" " 'W_1' 'WATER' 'OPEN' 'BHP' 1 2 3/\n/\n"; return parser.parseString(input); }
static Opm::Deck createDeckSPECGRID() { const char* deckData = "GRID\n" "SPECGRID \n" " 13 17 19 / \n" "COORD\n" " 726*1 / \n" "ZCORN \n" " 8000*1 / \n" "ACTNUM \n" " 1000*1 / \n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString( deckData, Opm::ParseContext()); }
static Opm::Deck createDeckInvalidRegion() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "ADDREG\n" " MISSING 10 10 MX / \n" "/\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString(deckData) ; }
static Opm::Deck createValidPERMXDeck() { const char* deckData = "RUNSPEC\n" "GRIDOPTS\n" " 'YES' 2 /\n" "\n" "DIMENS\n" " 5 5 1 /\n" "GRID\n" "DX\n" "25*0.25 /\n" "DY\n" "25*0.25 /\n" "DZ\n" "25*0.25 /\n" "TOPS\n" "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" "1 1 2 2 2\n" "1 1 2 2 2\n" "1 1 2 2 2\n" "/\n" "BOX\n" " 1 2 1 5 1 1 / \n" "PERMZ\n" " 10*1 /\n" "ENDBOX\n" "BOX\n" " 3 5 1 5 1 1 / \n" "PERMZ\n" " 15*2 /\n" "ENDBOX\n" "PERMX\n" "25*1 /\n" "ADDREG\n" " PERMX 1 1 / \n" " PERMX 3 2 / \n" "/\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString(deckData) ; }
static Opm::Deck createDeckInvalidValue() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "MULTNUM \n" " 1000*1 /\n" "ADDREG\n" " SATNUM 0.2 10 M / \n" "/\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString(deckData) ; }
static Deck createDeckWithGasInjector() { Opm::Parser parser; std::string input = "SCHEDULE\n" "WELSPECS\n" " 'W_1' 'OP' 1 1 1* \'GAS\' 7* / \n" "/\n" "COMPDAT\n" " 'W_1' 2* 1 1 'OPEN' / \n" "/\n" "WCONINJE\n" " 'W_1' 'GAS' 'OPEN' 'BHP' 1 2 3/\n/\n" "WSOLVENT\n" " 'W_1' 1 / \n " "/\n"; return parser.parseString(input, ParseContext()); }
static Opm::Deck createDeck() { const char *deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "DX\n" "1000*0.25 /\n" "DY\n" "1000*0.25 /\n" "DZ\n" "1000*0.25 /\n" "TOPS\n" "100*0.25 /\n" "FAULTS \n" " 'F1' 1 1 1 4 1 4 'X' / \n" " 'F2' 5 5 1 4 1 4 'X-' / \n" "/\n" "MULTFLT \n" " 'F1' 0.50 / \n" " 'F2' 0.50 / \n" "/\n" "EDIT\n" "MULTFLT /\n" " 'F2' 0.25 / \n" "/\n" "OIL\n" "\n" "GAS\n" "\n" "PROPS\n" "REGIONS\n" "swat\n" "1000*1 /\n" "SATNUM\n" "1000*2 /\n" "ROCKNUM\n" "200*1 200*2 200*3 400*4 /\n" "\n"; Opm::Parser parser; return parser.parseString(deckData, Opm::ParseContext() ); }
static Opm::Deck createDeckUnInitializedRegion() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "SATNUM \n" " 1000*1 /\n" "REGIONS\n" "ADDREG\n" " SATNUM 2 10 M / \n" "/\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString(deckData) ; }
static Opm::Deck createCPDeck() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "COORD\n" " 726*1 / \n" "ZCORN \n" " 8000*1 / \n" "ACTNUM \n" " 1000*1 / \n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString( deckData, Opm::ParseContext()) ; }
static Opm::Deck createCARTInvalidDeck() { const char* deckData = "RUNSPEC\n" "\n" "DIMENS\n" " 10 10 10 /\n" "GRID\n" "DX\n" "1000*0.25 /\n" "DYV\n" "1000*0.25 /\n" "DZ\n" "1000*0.25 /\n" "EDIT\n" "\n"; Opm::Parser parser; return parser.parseString( deckData, Opm::ParseContext()) ; }