diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 5ab278db..f86e19cc 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -39,7 +39,6 @@ list (APPEND MAIN_SOURCE_FILES opm/core/grid/cpgpreprocess/preprocess.c opm/core/grid/cpgpreprocess/uniquepoints.c opm/core/io/eclipse/EclipseGridInspector.cpp - opm/core/io/eclipse/EclipseGridParser.cpp opm/core/io/eclipse/EclipseWriter.cpp opm/core/io/eclipse/writeECLData.cpp opm/core/io/OutputWriter.cpp @@ -223,15 +222,10 @@ list (APPEND EXAMPLE_SOURCE_FILES # originally generated with the command: # find attic -name '*.c*' -printf '\t%p\n' | sort list (APPEND ATTIC_FILES - attic/bo_resprop_test.cpp - attic/pvt_test.cpp - attic/relperm_test.cpp attic/test_cfs_tpfa.c - attic/test_ert.cpp attic/test_jacsys.cpp attic/test_lapack.cpp attic/test_read_grid.c - attic/test_readpolymer.cpp attic/test_read_vag.cpp attic/test_writeVtkData.cpp ) @@ -261,11 +255,8 @@ list (APPEND PUBLIC_HEADER_FILES opm/core/grid/cpgpreprocess/uniquepoints.h opm/core/io/eclipse/CornerpointChopper.hpp opm/core/io/eclipse/EclipseGridInspector.hpp - opm/core/io/eclipse/EclipseGridParser.hpp - opm/core/io/eclipse/EclipseGridParserHelpers.hpp opm/core/io/eclipse/EclipseUnits.hpp opm/core/io/eclipse/EclipseWriter.hpp - opm/core/io/eclipse/SpecialEclipseFields.hpp opm/core/io/eclipse/writeECLData.hpp opm/core/io/OutputWriter.hpp opm/core/io/vag/vag.hpp diff --git a/attic/bo_resprop_test.cpp b/attic/bo_resprop_test.cpp deleted file mode 100644 index 98a25306..00000000 --- a/attic/bo_resprop_test.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -int main(int argc, char** argv) -{ - // Parameters. - Opm::parameter::ParameterGroup param(argc, argv); - - // Parser. - std::string ecl_file = param.get("filename"); - Opm::EclipseGridParser deck(ecl_file); - UnstructuredGrid grid; - grid.number_of_cells = 1; - grid.global_cell = NULL; - Opm::BlackoilPropertiesFromDeck props(deck, grid, param); - - const int n = 1; - double p[n] = { 150e5 }; - double z[3*n] = { 1.0, 1.0, 1.0 }; - int cells[n] = { 0 }; - double A[9*n]; - props.matrix(n, p, z, cells, A, 0); - std::copy(A, A + 9, std::ostream_iterator(std::cout, " ")); - std::cout << std::endl; -} diff --git a/attic/pvt_test.cpp b/attic/pvt_test.cpp deleted file mode 100644 index f1963c83..00000000 --- a/attic/pvt_test.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -int main(int argc, char** argv) -{ - using namespace std; - // Parameters. - Opm::parameter::ParameterGroup param(argc, argv); - - // Parser. - std::string ecl_file = param.get("deck_filename"); - std::string input_file = param.get("input_filename"); - std::string matrix_output = param.get("matrix_output"); - std::string rs_output = param.get("rs_output"); - std::string b_output = param.get("b_output"); - std::string mu_output = param.get("mu_output"); - Opm::EclipseGridParser deck(ecl_file); - UnstructuredGrid grid; - grid.number_of_cells = 1; - grid.global_cell = NULL; - grid.dimensions = 3; - grid.cartdims[0] = 1; - grid.cartdims[1] = 1; - grid.cartdims[2] = 1; - Opm::BlackoilPropertiesFromDeck props(deck, grid, param); - Opm::BlackoilPvtProperties pvt; - int samples = param.getDefault("dead_tab_size", 1025); - pvt.init(deck, samples); - - - const int n = 1; - std::fstream inos(input_file.c_str()); - if(!inos.good()){ - std::cout << "Could not open :" << input_file << std::endl; - exit(3); - } - std::fstream aos(matrix_output.c_str(), std::fstream::out | std::fstream::trunc); - aos << setiosflags(ios::scientific) << setprecision(12); - if(!(aos.good())){ - std::cout << "Could not open"<< matrix_output << std::endl; - exit(3); - } - std::fstream bos(b_output.c_str(), std::fstream::out | std::fstream::trunc); - bos << setiosflags(ios::scientific) << setprecision(12); - if(!(bos.good())){ - std::cout << "Could not open"<< b_output << std::endl; - exit(3); - } - std::fstream rsos(rs_output.c_str(), std::fstream::out | std::fstream::trunc); - rsos << setiosflags(ios::scientific) << setprecision(12); - if(!(rsos.good())){ - std::cout << "Could not open"<< rs_output << std::endl; - exit(3); - } - std::fstream muos(mu_output.c_str(), std::fstream::out | std::fstream::trunc); - if(!(muos.good())){ - std::cout << "Could not open"<< rs_output << std::endl; - exit(3); - } - - - - const int np = props.numPhases(); - const int max_np = 3; - if (np > max_np) { - OPM_THROW(std::runtime_error, "Max #phases is 3."); - } - while((inos.good()) && (!inos.eof())){ - double p[n]; - double z[max_np*n]; - int cells[n] = { 0 }; - inos >> p[0]; - for(int i=0; i < np; ++i){ - inos >> z[i]; - } - - if(inos.good()){ - double A[max_np*max_np*n]; - double dA[max_np*max_np*n]; - props.matrix(n, p, z, cells, A, dA); - std::copy(A, A + np*np*n, std::ostream_iterator(aos, " ")); - std::copy(dA, dA + np*np*n, std::ostream_iterator(aos, " ")); - aos << std::endl; - double mu[max_np]; - //double dmu[max_np];//not implemented - props.viscosity(n, p, z, cells, mu, 0); - std::copy(mu, mu + np*n, std::ostream_iterator(muos, " ")); - //std::copy(dmu, dmu + np*n, std::ostream_iterator(muos, " ")); - aos << std::endl; - - double b[max_np]; - double dbdp[max_np]; - pvt.dBdp(n, p, z, b, dbdp); - std::copy(b, b + np*n, std::ostream_iterator(bos, " ")); - std::copy(dbdp, dbdp + np*n, std::ostream_iterator(bos, " ")); - bos << std::endl; - - double rs[max_np]; - double drs[max_np]; - //pvt.R(n, p, z, rs); - pvt.dRdp(n, p, z, rs,drs); - std::copy(rs, rs + np*n, std::ostream_iterator(rsos, " ")); - std::copy(drs, drs + np*n, std::ostream_iterator(rsos, " ")); - rsos << std::endl; - } - } - if (param.anyUnused()) { - std::cout << "-------------------- Unused parameters: --------------------\n"; - param.displayUsage(); - std::cout << "----------------------------------------------------------------" << std::endl; - } -} diff --git a/attic/relperm_test.cpp b/attic/relperm_test.cpp deleted file mode 100644 index b8e7ea9b..00000000 --- a/attic/relperm_test.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#if HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -int main(int argc, char** argv) -{ - // Parameters. - Opm::parameter::ParameterGroup param(argc, argv); - - // Parser. - std::string ecl_file = param.get("deck_filename"); - std::string input_file = param.get("input_filename"); - std::string relperm_output = param.get("relperm_output"); - //std::string relperm_output = param.get("relperm_outout"); - Opm::EclipseGridParser deck(ecl_file); - UnstructuredGrid grid; - grid.number_of_cells = 1; - grid.global_cell = NULL; - grid.dimensions = 3; - grid.cartdims[0] = 1; - grid.cartdims[1] = 1; - grid.cartdims[2] = 1; - Opm::BlackoilPropertiesFromDeck props(deck, grid, param); - - std::fstream inos(input_file.c_str());//, std::fstream::in); - if(!inos.good()){ - std::cout << "Could not open :" << input_file << std::endl; - exit(3); - } - std::fstream kros(relperm_output.c_str(), std::fstream::out | std::fstream::trunc); - if(!kros.good()){ - std::cout << "Could not open :" << input_file << std::endl; - exit(3); - } - const int np = props.numPhases(); - const int max_np = 3; - if (np > max_np) { - OPM_THROW(std::runtime_error, "Max #phases is 3."); - } - while((inos.good()) && (!inos.eof())){ - double s[max_np]; - for(int i=0; i < np; ++i){ - inos >> s[i]; - } - if(inos.good()){ - double kr[max_np]; - double dkr[max_np*max_np]; - int cell[1]; - cell[0]=1; - props.relperm(1,s, cell, kr, dkr); - std::copy(s, s + np, std::ostream_iterator(kros, " ")); - kros << " "; - std::copy(kr, kr + np, std::ostream_iterator(kros, " ")); - kros << " "; - std::copy(dkr, dkr + np*np, std::ostream_iterator(kros, " ")); - kros << "\n"; - } - } - if (param.anyUnused()) { - std::cout << "-------------------- Unused parameters: --------------------\n"; - param.displayUsage(); - std::cout << "----------------------------------------------------------------" << std::endl; - } -} diff --git a/attic/test_ert.cpp b/attic/test_ert.cpp deleted file mode 100644 index bdd63431..00000000 --- a/attic/test_ert.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* - Copyright 2012 SINTEF ICT, Applied Mathematics. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#include "config.h" -#include -#include -#include -#include -#include -#include - - -#include - -#include -#include -#include - -using namespace std; - -#if 0 -static -void cell_nodes(const UnstructuredGrid * c_grid , int cell , std::vector& nodes) { - int face_offset = c_grid->cell_facepos[cell]; - int num_faces = c_grid->cell_facepos[cell + 1] - face_offset; - - nodes.clear(); - //printf("cell: %d \n",cell); - for (int iface = 0; iface < num_faces; iface++) { - int face = c_grid->cell_faces[ face_offset + iface]; - //printf("face[%d] = %d \n",iface , face ); - - { - int node_offset = c_grid->face_nodepos[ face ]; - int num_nodes = c_grid->face_nodepos[ face + 1] - node_offset; - for (int inode = 0; inode < num_nodes; inode++) { - int node = c_grid->face_nodes[ inode + node_offset ]; - //printf(" node[%d] = %d \n",inode , node); - nodes.push_back( node ); - } - } - } - - { - /*for (int i =0; i < nodes.size(); i++) - std::cout << nodes[i] << " "; - std::cout << "\n"; - */ - sort( nodes.begin() , nodes.end()); - /*for (int i =0; i < nodes.size(); i++) - std::cout << nodes[i] << " "; - std::cout << "\n"; - */ - unique( nodes.begin() , nodes.end() ); - /*for (int i =0; i < nodes.size(); i++) - std::cout << nodes[i] << " "; - std::cout << "\n"; - */ - nodes.resize( 8 ); - /*for (int i =0; i < nodes.size(); i++) - std::cout << nodes[i] << " "; - std::cout << "\n"; - */ - } -} -#endif - -/* -static -void eclExport(Opm::GridManager& grid) { - const UnstructuredGrid * c_grid = grid.c_grid(); - - printf("dimensions : %d \n",c_grid->dimensions); - printf("number of cells : %d \n",c_grid->number_of_cells); - printf("number of nodes : %d \n",c_grid->number_of_nodes); - printf("number of faces : %d \n",c_grid->number_of_faces); - printf("length(face_nodes) : %d \n",c_grid->face_nodepos[ c_grid->number_of_faces ]); - printf("cartdims : %d %d %d \n", - c_grid->cartdims[0] , - c_grid->cartdims[1] , - c_grid->cartdims[2]); - - printf("global_cell : %d %d %d %d %d\n", - c_grid->global_cell[0] , - c_grid->global_cell[1] , - c_grid->global_cell[2] , - c_grid->global_cell[3] , - c_grid->global_cell[4]); - - { - std::vector nodes; - cell_nodes( c_grid , 10 , nodes ); - cell_nodes( c_grid , 15 , nodes ); - cell_nodes( c_grid , 20 , nodes ); - cell_nodes( c_grid , 25 , nodes ); - } - - { - ecl_grid_type * ecl_grid; - int num_coords = c_grid->number_of_cells; - int coords_size = 4; - int nx = c_grid->cartdims[0]; - int ny = c_grid->cartdims[1]; - int nz = c_grid->cartdims[2]; - - int ** coords; - float ** corners; - // float * mapaxes = NULL; - std::vector nodes; - - corners = (float **) malloc( num_coords * sizeof * corners ); - coords = (int **) malloc( num_coords * sizeof * coords ); - - { - int c; - for (c=0; c < num_coords; c++) { - corners[c] = (float *) malloc( 24 * sizeof * corners[c] ); - coords[c] = (int *) malloc( coords_size * sizeof * coords[c] ); - } - - for (c=0; c < num_coords; c++) { - cell_nodes( c_grid , c , nodes ); - for (int p=0; p < 8; p++) { - int n = nodes[p]; - for (int d=0; d < c_grid->dimensions; d++) - corners[c][3*p + d] = c_grid->node_coordinates[ c_grid->dimensions * n + d ]; - } - - { - int i,j,k; - { - int g = c_grid->global_cell[ c ]; - k = g / nx*ny; g -= k * nx*ny; - j = g / nx; g -= j * nx; - i = g; - } - - coords[c][0] = i + 1; - coords[c][1] = j + 1; - coords[c][2] = k + 1; - coords[c][3] = c_grid->global_cell[ c ] + 1; - } - } - } - - ecl_grid = ecl_grid_alloc( "/private/joaho/ERT/NR/libenkf/src/Gurbat/EXAMPLE_01_BASE.EGRID" ); - printf("Grid loaded ... \n"); - ecl_grid_free( ecl_grid ); - - printf("Grid discarded ... \n"); - - ecl_grid = ecl_grid_alloc_GRID_data( num_coords , nx , ny , nz , coords_size , coords , corners , NULL ); - ecl_grid_fwrite_GRID( ecl_grid , "/tmp/test.GRID" ); - - { - FILE * stream = fopen( "/tmp/test.grdecl" , "w"); - ecl_grid_fprintf_grdecl( ecl_grid , stream ); - fclose( stream ); - } - - ecl_grid_free( ecl_grid ); - - { - for (int c=0; c < num_coords; c++) { - free(corners[c]); - free(coords[c]); - } - } - free( corners ); - free( coords ); - } -} -*/ - - -/* - - #ifdef HAVE_ERT -ecl_grid_type * create_ecl_grid( const struct UnstructuredGrid * g) { - int num_coords = g->number_of_cells; - int nx = g->cartdims[0]; - int ny = g->cartdims[1]; - int nz = g->cartdims[2]; - int coords_size = 4; - int ** coords; - float ** corners; - float * mapaxes = NULL; - - corners = malloc( num_coords * sizeof * corners ); - coords = malloc( num_coords * sizeof * coords ); - - { - for (int c=0; c < num_coords; c++) { - corners[c] = malloc( 24 * sizeof * corners[0] ); - coords[c] = malloc( coords_size * sizeof * coords[0] ); - } - } - - { - for (int k=0; k < nz; k++) { - for (int j=0; j < ny; j++) { - for (int i=0; i < nx; i++) { - int global_index = i + j*nx + k*nx*ny; - - coords[global_index][0] = i; - coords[global_index][1] = j; - coords[global_index][2] = k; - coords[global_index][3] = 1; - - } - } - } - } - { - for (int c=0; c < num_coords; c++) { - free(corners[c]); - free(coords[c]); - } - } - free( corners ); - free( coords ); -} -#endif - - - */ - -// struct grdecl : opm/core/grid/cpgpreprocess/preprocess.h -// struct processes_grid : opm/core/grid/cpgpreprocess/preprocess.h - - - -int main(int /*argc*/ , char **argv) -{ - std::string filename( argv[1] ); - const std::unique_ptr grid; - const std::unique_ptr props; - Opm::EclipseGridParser eclParser(filename , false); - - //eclParser.saveEGRID_INIT("/tmp" , "OPM" ); - - grid.reset(new Opm::GridManager(eclParser)); - - props.reset(new Opm::IncompPropertiesFromDeck(eclParser , *grid->c_grid())); -} diff --git a/attic/test_readpolymer.cpp b/attic/test_readpolymer.cpp deleted file mode 100644 index ac045a34..00000000 --- a/attic/test_readpolymer.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//=========================================================================== -// -// File: test_readpolymer.cpp -// -// Created: Thu Jan 12 15:18:46 2012 -// -// Author: Bjørn Spjelkavik -// -// Revision: $Id$ -// -//=========================================================================== - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -// Test program for reading Eclipse Polymer keywords. - -int main(int argc, char** argv) -{ - using namespace std; - - std::string ecl_filename; - if (argc == 2) { - ecl_filename = argv[1]; - } else { - std::cout << "\nUsage: test_readpolymer filename.grdecl\n"; - exit( 1 ); - } - - - bool convert_to_SI = true; - Opm::EclipseGridParser parser(ecl_filename, convert_to_SI); - - std::cout << "\n Polymer fields\n\n"; - - if (parser.hasField("PLYVISC")) { - parser.getPLYVISC().write(std::cout); - } - if (parser.hasField("PLYROCK")) { - parser.getPLYROCK().write(std::cout); - } - if (parser.hasField("PLYADS")) { - parser.getPLYADS().write(std::cout); - } - if (parser.hasField("TLMIXPAR")) { - parser.getTLMIXPAR().write(std::cout); - } - if (parser.hasField("PLYMAX")) { - parser.getPLYMAX().write(std::cout); - } - if (parser.hasField("WPOLYMER")) { - parser.getWPOLYMER().write(std::cout); - } - -} - - diff --git a/examples/compute_tof.cpp b/examples/compute_tof.cpp index 95d6cfe6..8ad1fda0 100644 --- a/examples/compute_tof.cpp +++ b/examples/compute_tof.cpp @@ -104,7 +104,7 @@ try // If we have a "deck_filename", grid and props will be read from that. bool use_deck = param.has("deck_filename"); - Opm::DeckConstPtr newParserDeck; + Opm::DeckConstPtr deck; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr wells; @@ -115,22 +115,22 @@ try if (use_deck) { std::string deck_filename = param.get("deck_filename"); Opm::ParserPtr parser(new Opm::Parser()); - newParserDeck = parser->parseFile(deck_filename); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(newParserDeck)); + deck = parser->parseFile(deck_filename); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); // Grid init - grid.reset(new GridManager(newParserDeck)); + grid.reset(new GridManager(deck)); // Rock and fluid init - props.reset(new IncompPropertiesFromDeck(newParserDeck, *grid->c_grid())); + props.reset(new IncompPropertiesFromDeck(deck, *grid->c_grid())); // Wells init. wells.reset(new Opm::WellsManager(eclipseState , 0 , *grid->c_grid(), props->permeability())); // Gravity. - gravity[2] = newParserDeck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(*grid->c_grid(), *props, param, gravity[2], state); } else { - initStateFromDeck(*grid->c_grid(), *props, newParserDeck, gravity[2], state); + initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], state); } } else { // Grid init. diff --git a/examples/sim_2p_comp_reorder.cpp b/examples/sim_2p_comp_reorder.cpp index 9ce2270e..cd38b4b6 100644 --- a/examples/sim_2p_comp_reorder.cpp +++ b/examples/sim_2p_comp_reorder.cpp @@ -90,7 +90,7 @@ try std::unique_ptr rock_comp; ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck; + Opm::DeckConstPtr deck; BlackoilState state; // bool check_well_controls = false; @@ -98,24 +98,24 @@ try double gravity[3] = { 0.0 }; if (use_deck) { std::string deck_filename = param.get("deck_filename"); - newParserDeck = parser->parseFile(deck_filename); + deck = parser->parseFile(deck_filename); - eclipseState.reset(new EclipseState(newParserDeck)); + eclipseState.reset(new EclipseState(deck)); // Grid init - grid.reset(new GridManager(newParserDeck)); + grid.reset(new GridManager(deck)); // Rock and fluid init - props.reset(new BlackoilPropertiesFromDeck(newParserDeck, *grid->c_grid(), param)); + props.reset(new BlackoilPropertiesFromDeck(deck, *grid->c_grid(), param)); // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // Rock compressibility. - rock_comp.reset(new RockCompressibility(newParserDeck)); + rock_comp.reset(new RockCompressibility(deck)); // Gravity. - gravity[2] = newParserDeck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(*grid->c_grid(), *props, param, gravity[2], state); } else { - initStateFromDeck(*grid->c_grid(), *props, newParserDeck, gravity[2], state); + initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], state); } initBlackoilSurfvol(*grid->c_grid(), *props, state); } else { @@ -225,7 +225,7 @@ try int step = 0; SimulatorTimer simtimer; // Use timer for last epoch to obtain total time. - Opm::TimeMapPtr timeMap(new Opm::TimeMap(newParserDeck)); + Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck)); simtimer.init(timeMap); const double total_time = simtimer.totalTime(); for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) { diff --git a/examples/sim_2p_incomp.cpp b/examples/sim_2p_incomp.cpp index cf1efe99..2550662d 100644 --- a/examples/sim_2p_incomp.cpp +++ b/examples/sim_2p_incomp.cpp @@ -100,7 +100,7 @@ try bool use_deck = param.has("deck_filename"); EclipseStateConstPtr eclipseState; - Opm::DeckConstPtr newParserDeck; + Opm::DeckConstPtr deck; std::unique_ptr grid; std::unique_ptr props; std::unique_ptr rock_comp; @@ -112,23 +112,23 @@ try ParserPtr parser(new Opm::Parser()); std::string deck_filename = param.get("deck_filename"); - newParserDeck = parser->parseFile(deck_filename); - eclipseState.reset( new EclipseState(newParserDeck)); + deck = parser->parseFile(deck_filename); + eclipseState.reset( new EclipseState(deck)); // Grid init - grid.reset(new GridManager(newParserDeck)); + grid.reset(new GridManager(deck)); // Rock and fluid init - props.reset(new IncompPropertiesFromDeck(newParserDeck, *grid->c_grid())); + props.reset(new IncompPropertiesFromDeck(deck, *grid->c_grid())); // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // Rock compressibility. - rock_comp.reset(new RockCompressibility(newParserDeck)); + rock_comp.reset(new RockCompressibility(deck)); // Gravity. - gravity[2] = newParserDeck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; + gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). if (param.has("init_saturation")) { initStateBasic(*grid->c_grid(), *props, param, gravity[2], state); } else { - initStateFromDeck(*grid->c_grid(), *props, newParserDeck, gravity[2], state); + initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], state); } } else { // Grid init. @@ -214,7 +214,7 @@ try param.writeParam(output_dir + "/simulation.param"); } - Opm::TimeMapPtr timeMap(new Opm::TimeMap(newParserDeck)); + Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck)); std::cout << "\n\n================ Starting main simulation loop ===============\n" << " (number of report steps: " diff --git a/examples/wells_example.cpp b/examples/wells_example.cpp index ea8db46f..f2874800 100644 --- a/examples/wells_example.cpp +++ b/examples/wells_example.cpp @@ -35,16 +35,16 @@ try // Read input file Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck = parser->parseFile(file_name); + Opm::DeckConstPtr deck = parser->parseFile(file_name); std::cout << "Done!" << std::endl; // Setup grid - GridManager grid(newParserDeck); + GridManager grid(deck); // Define rock and fluid properties - IncompPropertiesFromDeck incomp_properties(newParserDeck, *grid.c_grid()); - RockCompressibility rock_comp(newParserDeck); - EclipseStateConstPtr eclipseState(new Opm::EclipseState(newParserDeck)); + IncompPropertiesFromDeck incomp_properties(deck, *grid.c_grid()); + RockCompressibility rock_comp(deck); + EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); // Finally handle the wells WellsManager wells(eclipseState , 0 , *grid.c_grid(), incomp_properties.permeability()); @@ -76,7 +76,7 @@ try Opm::TwophaseState state; - initStateFromDeck(*grid.c_grid(), incomp_properties, newParserDeck, gravity[2], state); + initStateFromDeck(*grid.c_grid(), incomp_properties, deck, gravity[2], state); Opm::WellState well_state; well_state.init(wells.c_wells(), state); diff --git a/opm/core/doxygen_main.hpp b/opm/core/doxygen_main.hpp index a757ae4f..bfd4deeb 100644 --- a/opm/core/doxygen_main.hpp +++ b/opm/core/doxygen_main.hpp @@ -48,7 +48,7 @@ creation and destruction of an UnstructuredGrid. The method Opm::GridManager::c_grid() provides access to the underlying UnstructuredGrid structure. This class also provides an easy way to initialize a grid from an ECLIPSE-format input deck, via the -constructor taking an Opm::EclipseGridParser. +constructor taking an Opm::DeckConstPtr.

Well handling

@@ -109,7 +109,7 @@ There are two simulator programs for two-phase immiscible flow in opm-core:

Various utilities

Utilities contained in opm-core include: -- IO utilities (Opm::EclipseGridParser, binary I/O via the ERT library, vtk output) +- IO utilities (binary output via the ERT library, vtk output) - Interpolation utilities (Opm::MonotCubicInterpolator, Opm::VelocityInterpolationECVI) - Support for SI and non-SI units (Opm::unit and Opm::prefix) - Low-order quadratures for general geometries (Opm::CellQuadrature, Opm::FaceQuadrature) diff --git a/opm/core/grid/GridManager.cpp b/opm/core/grid/GridManager.cpp index bcaaa1a6..e78dcfdd 100644 --- a/opm/core/grid/GridManager.cpp +++ b/opm/core/grid/GridManager.cpp @@ -20,10 +20,10 @@ #include "config.h" #include -#include #include #include #include +#include #include #include @@ -32,30 +32,6 @@ namespace Opm { /// Construct a 3d corner-point grid from a deck. - GridManager::GridManager(const Opm::EclipseGridParser& deck) - { - // We accept two different ways to specify the grid. - // 1. Corner point format. - // Requires ZCORN, COORDS, DIMENS or SPECGRID, optionally - // ACTNUM, optionally MAPAXES. - // For this format, we will verify that DXV, DYV, DZV, - // DEPTHZ and TOPS are not present. - // 2. Tensor grid format. - // Requires DXV, DYV, DZV, optionally DEPTHZ or TOPS. - // For this format, we will verify that ZCORN, COORDS - // and ACTNUM are not present. - // Note that for TOPS, we only allow a uniform vector of values. - - if (deck.hasField("ZCORN") && deck.hasField("COORD")) { - initFromDeckCornerpoint(deck); - } else if (deck.hasField("DXV") && deck.hasField("DYV") && deck.hasField("DZV")) { - initFromDeckTensorgrid(deck); - } else { - OPM_THROW(std::runtime_error, "Could not initialize grid from deck. " - "Need either ZCORN + COORD or DXV + DYV + DZV keywords."); - } - } - GridManager::GridManager(Opm::EclipseGridConstPtr eclipseGrid) { struct grdecl g; std::vector actnum; @@ -84,8 +60,7 @@ namespace Opm } - /// Construct a 3d corner-point grid from a deck. - GridManager::GridManager(Opm::DeckConstPtr newParserDeck) + GridManager::GridManager(Opm::DeckConstPtr deck) { // We accept two different ways to specify the grid. // 1. Corner point format. @@ -99,10 +74,10 @@ namespace Opm // and ACTNUM are not present. // Note that for TOPS, we only allow a uniform vector of values. - if (newParserDeck->hasKeyword("ZCORN") && newParserDeck->hasKeyword("COORD")) { - initFromDeckCornerpoint(newParserDeck); - } else if (newParserDeck->hasKeyword("DXV") && newParserDeck->hasKeyword("DYV") && newParserDeck->hasKeyword("DZV")) { - initFromDeckTensorgrid(newParserDeck); + if (deck->hasKeyword("ZCORN") && deck->hasKeyword("COORD")) { + initFromDeckCornerpoint(deck); + } else if (deck->hasKeyword("DXV") && deck->hasKeyword("DYV") && deck->hasKeyword("DZV")) { + initFromDeckTensorgrid(deck); } else { OPM_THROW(std::runtime_error, "Could not initialize grid from deck. " "Need either ZCORN + COORD or DXV + DYV + DZV keywords."); @@ -165,11 +140,6 @@ namespace Opm } } - void GridManager::saveEGRID(const std::string& filename , const Opm::EclipseGridParser& deck) { - deck.saveEGRID( filename , ug_->number_of_cells , ug_->global_cell ); - } - - /// Destructor. GridManager::~GridManager() { @@ -187,28 +157,13 @@ namespace Opm return ug_; } - // Construct corner-point grid from deck. - void GridManager::initFromDeckCornerpoint(const Opm::EclipseGridParser& deck) - { - // Extract data from deck. - // Collect in input struct for preprocessing. - struct grdecl grdecl = deck.get_grdecl(); - - // Process grid. - ug_ = create_grid_cornerpoint(&grdecl, 0.0); - if (!ug_) { - OPM_THROW(std::runtime_error, "Failed to construct grid."); - } - } - - // Construct corner-point grid from deck. - void GridManager::initFromDeckCornerpoint(Opm::DeckConstPtr newParserDeck) + void GridManager::initFromDeckCornerpoint(Opm::DeckConstPtr deck) { // Extract data from deck. // Collect in input struct for preprocessing. struct grdecl grdecl; - createGrdecl(newParserDeck, grdecl); + createGrdecl(deck, grdecl); // Process grid. ug_ = create_grid_cornerpoint(&grdecl, 0.0); @@ -217,24 +172,24 @@ namespace Opm } } - void GridManager::createGrdecl(Opm::DeckConstPtr newParserDeck, struct grdecl &grdecl) + void GridManager::createGrdecl(Opm::DeckConstPtr deck, struct grdecl &grdecl) { // Extract data from deck. - const std::vector& zcorn = newParserDeck->getKeyword("ZCORN")->getSIDoubleData(); - const std::vector& coord = newParserDeck->getKeyword("COORD")->getSIDoubleData(); + const std::vector& zcorn = deck->getKeyword("ZCORN")->getSIDoubleData(); + const std::vector& coord = deck->getKeyword("COORD")->getSIDoubleData(); const int* actnum = NULL; - if (newParserDeck->hasKeyword("ACTNUM")) { - actnum = &(newParserDeck->getKeyword("ACTNUM")->getIntData()[0]); + if (deck->hasKeyword("ACTNUM")) { + actnum = &(deck->getKeyword("ACTNUM")->getIntData()[0]); } std::array dims; - if (newParserDeck->hasKeyword("DIMENS")) { - Opm::DeckKeywordConstPtr dimensKeyword = newParserDeck->getKeyword("DIMENS"); + if (deck->hasKeyword("DIMENS")) { + Opm::DeckKeywordConstPtr dimensKeyword = deck->getKeyword("DIMENS"); dims[0] = dimensKeyword->getRecord(0)->getItem(0)->getInt(0); dims[1] = dimensKeyword->getRecord(0)->getItem(1)->getInt(0); dims[2] = dimensKeyword->getRecord(0)->getItem(2)->getInt(0); - } else if (newParserDeck->hasKeyword("SPECGRID")) { - Opm::DeckKeywordConstPtr specgridKeyword = newParserDeck->getKeyword("SPECGRID"); + } else if (deck->hasKeyword("SPECGRID")) { + Opm::DeckKeywordConstPtr specgridKeyword = deck->getKeyword("SPECGRID"); dims[0] = specgridKeyword->getRecord(0)->getItem(0)->getInt(0); dims[1] = specgridKeyword->getRecord(0)->getItem(1)->getInt(0); dims[2] = specgridKeyword->getRecord(0)->getItem(2)->getInt(0); @@ -251,8 +206,8 @@ namespace Opm grdecl.dims[1] = dims[1]; grdecl.dims[2] = dims[2]; - if (newParserDeck->hasKeyword("MAPAXES")) { - Opm::DeckKeywordConstPtr mapaxesKeyword = newParserDeck->getKeyword("MAPAXES"); + if (deck->hasKeyword("MAPAXES")) { + Opm::DeckKeywordConstPtr mapaxesKeyword = deck->getKeyword("MAPAXES"); Opm::DeckRecordConstPtr mapaxesRecord = mapaxesKeyword->getRecord(0); // memleak alert: here we need to make sure that C code @@ -280,82 +235,17 @@ namespace Opm } // anonymous namespace - // Construct tensor grid from deck. - void GridManager::initFromDeckTensorgrid(const Opm::EclipseGridParser& deck) - { - // Extract logical cartesian size. - std::vector dims; - if (deck.hasField("DIMENS")) { - dims = deck.getIntegerValue("DIMENS"); - } else if (deck.hasField("SPECGRID")) { - dims = deck.getSPECGRID().dimensions; - } else { - OPM_THROW(std::runtime_error, "Deck must have either DIMENS or SPECGRID."); - } - - // Extract coordinates (or offsets from top, in case of z). - const std::vector& dxv = deck.getFloatingPointValue("DXV"); - const std::vector& dyv = deck.getFloatingPointValue("DYV"); - const std::vector& dzv = deck.getFloatingPointValue("DZV"); - std::vector x = coordsFromDeltas(dxv); - std::vector y = coordsFromDeltas(dyv); - std::vector z = coordsFromDeltas(dzv); - - // Check that number of cells given are consistent with DIMENS/SPECGRID. - if (dims[0] != int(dxv.size())) { - OPM_THROW(std::runtime_error, "Number of DXV data points do not match DIMENS or SPECGRID."); - } - if (dims[1] != int(dyv.size())) { - OPM_THROW(std::runtime_error, "Number of DYV data points do not match DIMENS or SPECGRID."); - } - if (dims[2] != int(dzv.size())) { - OPM_THROW(std::runtime_error, "Number of DZV data points do not match DIMENS or SPECGRID."); - } - - // Extract top corner depths, if available. - const double* top_depths = 0; - std::vector top_depths_vec; - if (deck.hasField("DEPTHZ")) { - const std::vector& depthz = deck.getFloatingPointValue("DEPTHZ"); - if (depthz.size() != x.size()*y.size()) { - OPM_THROW(std::runtime_error, "Incorrect size of DEPTHZ: " << depthz.size()); - } - top_depths = &depthz[0]; - } else if (deck.hasField("TOPS")) { - // We only support constant values for TOPS. - // It is not 100% clear how we best can deal with - // varying TOPS (stair-stepping grid, or not). - const std::vector& tops = deck.getFloatingPointValue("TOPS"); - if (std::count(tops.begin(), tops.end(), tops[0]) != int(tops.size())) { - OPM_THROW(std::runtime_error, "We do not support nonuniform TOPS, please use ZCORN/COORDS instead."); - } - top_depths_vec.resize(x.size()*y.size(), tops[0]); - top_depths = &top_depths_vec[0]; - } else { - OPM_THROW(std::runtime_error, - "Could not find either TOPS or DEPTHZ keyword, " - "one of them is required for initialization with DXV/DYV/DZV."); - } - - // Construct grid. - ug_ = create_grid_tensor3d(dxv.size(), dyv.size(), dzv.size(), - &x[0], &y[0], &z[0], top_depths); - if (!ug_) { - OPM_THROW(std::runtime_error, "Failed to construct grid."); - } - } - - void GridManager::initFromDeckTensorgrid(Opm::DeckConstPtr newParserDeck) + void GridManager::initFromDeckTensorgrid(Opm::DeckConstPtr deck) { // Extract logical cartesian size. std::array dims; - if (newParserDeck->hasKeyword("DIMENS")) { - Opm::DeckKeywordConstPtr dimensKeyword = newParserDeck->getKeyword("DIMENS"); + if (deck->hasKeyword("DIMENS")) { + Opm::DeckKeywordConstPtr dimensKeyword = deck->getKeyword("DIMENS"); dims[0] = dimensKeyword->getRecord(0)->getItem(0)->getInt(0); dims[1] = dimensKeyword->getRecord(0)->getItem(1)->getInt(0); dims[2] = dimensKeyword->getRecord(0)->getItem(2)->getInt(0); - } else if (newParserDeck->hasKeyword("SPECGRID")) { - Opm::DeckKeywordConstPtr specgridKeyword = newParserDeck->getKeyword("SPECGRID"); + } else if (deck->hasKeyword("SPECGRID")) { + Opm::DeckKeywordConstPtr specgridKeyword = deck->getKeyword("SPECGRID"); dims[0] = specgridKeyword->getRecord(0)->getItem(0)->getInt(0); dims[1] = specgridKeyword->getRecord(0)->getItem(1)->getInt(0); dims[2] = specgridKeyword->getRecord(0)->getItem(2)->getInt(0); @@ -364,9 +254,9 @@ namespace Opm } // Extract coordinates (or offsets from top, in case of z). - const std::vector& dxv = newParserDeck->getKeyword("DXV")->getSIDoubleData(); - const std::vector& dyv = newParserDeck->getKeyword("DYV")->getSIDoubleData(); - const std::vector& dzv = newParserDeck->getKeyword("DZV")->getSIDoubleData(); + const std::vector& dxv = deck->getKeyword("DXV")->getSIDoubleData(); + const std::vector& dyv = deck->getKeyword("DYV")->getSIDoubleData(); + const std::vector& dzv = deck->getKeyword("DZV")->getSIDoubleData(); std::vector x = coordsFromDeltas(dxv); std::vector y = coordsFromDeltas(dyv); std::vector z = coordsFromDeltas(dzv); @@ -385,17 +275,17 @@ namespace Opm // Extract top corner depths, if available. const double* top_depths = 0; std::vector top_depths_vec; - if (newParserDeck->hasKeyword("DEPTHZ")) { - const std::vector& depthz = newParserDeck->getKeyword("DEPTHZ")->getSIDoubleData(); + if (deck->hasKeyword("DEPTHZ")) { + const std::vector& depthz = deck->getKeyword("DEPTHZ")->getSIDoubleData(); if (depthz.size() != x.size()*y.size()) { OPM_THROW(std::runtime_error, "Incorrect size of DEPTHZ: " << depthz.size()); } top_depths = &depthz[0]; - } else if (newParserDeck->hasKeyword("TOPS")) { + } else if (deck->hasKeyword("TOPS")) { // We only support constant values for TOPS. // It is not 100% clear how we best can deal with // varying TOPS (stair-stepping grid, or not). - const std::vector& tops = newParserDeck->getKeyword("TOPS")->getSIDoubleData(); + const std::vector& tops = deck->getKeyword("TOPS")->getSIDoubleData(); if (std::count(tops.begin(), tops.end(), tops[0]) != int(tops.size())) { OPM_THROW(std::runtime_error, "We do not support nonuniform TOPS, please use ZCORN/COORDS instead."); } diff --git a/opm/core/grid/GridManager.hpp b/opm/core/grid/GridManager.hpp index bc82ef38..6cc5b85b 100644 --- a/opm/core/grid/GridManager.hpp +++ b/opm/core/grid/GridManager.hpp @@ -30,9 +30,6 @@ struct grdecl; namespace Opm { - - class EclipseGridParser; - /// This class manages an Opm::UnstructuredGrid in the sense that it /// encapsulates creation and destruction of the grid. /// The following grid types can be constructed: @@ -45,10 +42,7 @@ namespace Opm { public: /// Construct a 3d corner-point grid or tensor grid from a deck. - explicit GridManager(const Opm::EclipseGridParser& deck); - - /// Construct a 3d corner-point grid or tensor grid from a deck. - explicit GridManager(Opm::DeckConstPtr newParserDeck); + explicit GridManager(Opm::DeckConstPtr deck); /// Construct a grid from an EclipseState::EclipseGrid instance explicit GridManager(Opm::EclipseGridConstPtr eclipseGrid); @@ -74,14 +68,12 @@ namespace Opm /// Destructor. ~GridManager(); - void saveEGRID(const std::string& filename , const Opm::EclipseGridParser& deck); - /// Access the managed UnstructuredGrid. /// The method is named similarly to c_str() in std::string, /// to make it clear that we are returning a C-compatible struct. const UnstructuredGrid* c_grid() const; - static void createGrdecl(Opm::DeckConstPtr newParserDeck, struct grdecl &grdecl); + static void createGrdecl(Opm::DeckConstPtr deck, struct grdecl &grdecl); private: // Disable copying and assignment. @@ -89,11 +81,9 @@ namespace Opm GridManager& operator=(const GridManager& other); // Construct corner-point grid from deck. - void initFromDeckCornerpoint(const Opm::EclipseGridParser& deck); - void initFromDeckCornerpoint(Opm::DeckConstPtr newParserDeck); + void initFromDeckCornerpoint(Opm::DeckConstPtr deck); // Construct tensor grid from deck. - void initFromDeckTensorgrid(const Opm::EclipseGridParser& deck); - void initFromDeckTensorgrid(Opm::DeckConstPtr newParserDeck); + void initFromDeckTensorgrid(Opm::DeckConstPtr deck); // The managed UnstructuredGrid. UnstructuredGrid* ug_; diff --git a/opm/core/io/eclipse/CornerpointChopper.hpp b/opm/core/io/eclipse/CornerpointChopper.hpp index 9c6ec743..c6aaa435 100644 --- a/opm/core/io/eclipse/CornerpointChopper.hpp +++ b/opm/core/io/eclipse/CornerpointChopper.hpp @@ -20,7 +20,6 @@ #ifndef OPM_CORNERPOINTCHOPPER_HEADER_INCLUDED #define OPM_CORNERPOINTCHOPPER_HEADER_INCLUDED -#include #include #include #include @@ -44,7 +43,6 @@ namespace Opm { public: CornerPointChopper(const std::string& file) - : parser_(file, false) { Opm::ParserPtr parser(new Opm::Parser()); deck_ = parser->parseFile(file); @@ -258,38 +256,6 @@ namespace Opm filterIntegerField("SATNUM", new_SATNUM_); } - - - /// Return a subparser with fields corresponding to the selected subset. - /// Note that the returned parser is NOT converted to SI, that must be done - /// by the user afterwards with the parser's convertToSI() method. - EclipseGridParser subparser() - { - if (parser_.hasField("FIELD") || parser_.hasField("LAB") || parser_.hasField("PVT-M")) { - OPM_THROW(std::runtime_error, "CornerPointChopper::subparser() cannot handle any eclipse unit system other than METRIC."); - } - - EclipseGridParser sp; - std::shared_ptr sg(new SPECGRID); - for (int dd = 0; dd < 3; ++dd) { - sg->dimensions[dd] = new_dims_[dd]; - } - sp.setSpecialField("SPECGRID", sg); - sp.setFloatingPointField("COORD", new_COORD_); - sp.setFloatingPointField("ZCORN", new_ZCORN_); - if (!new_ACTNUM_.empty()) sp.setIntegerField("ACTNUM", new_ACTNUM_); - if (!new_PORO_.empty()) sp.setFloatingPointField("PORO", new_PORO_); - if (!new_NTG_.empty()) sp.setFloatingPointField("NTG", new_NTG_); - if (!new_SWCR_.empty()) sp.setFloatingPointField("SWCR", new_SWCR_); - if (!new_SOWCR_.empty()) sp.setFloatingPointField("SOWCR", new_SOWCR_); - if (!new_PERMX_.empty()) sp.setFloatingPointField("PERMX", new_PERMX_); - if (!new_PERMY_.empty()) sp.setFloatingPointField("PERMY", new_PERMY_); - if (!new_PERMZ_.empty()) sp.setFloatingPointField("PERMZ", new_PERMZ_); - if (!new_SATNUM_.empty()) sp.setIntegerField("SATNUM", new_SATNUM_); - sp.computeUnits(); // Always METRIC, since that is default. - return sp; - } - /// Return a sub-deck with fields corresponding to the selected subset. Opm::DeckConstPtr subDeck() { @@ -319,7 +285,6 @@ namespace Opm specGridKw->addRecord(specGridRecord); subDeck->addKeyword(specGridKw); - addDoubleKeyword_(subDeck, "COORD", /*dimension=*/"Length", new_COORD_); addDoubleKeyword_(subDeck, "ZCORN", /*dimension=*/"Length", new_ZCORN_); addIntKeyword_(subDeck, "ACTNUM", new_ACTNUM_); @@ -331,10 +296,8 @@ namespace Opm addDoubleKeyword_(subDeck, "PERMY", /*dimension=*/"Permeability", new_PERMY_); addDoubleKeyword_(subDeck, "PERMZ", /*dimension=*/"Permeability", new_PERMZ_); addIntKeyword_(subDeck, "SATNUM", new_SATNUM_); - return subDeck; } - void writeGrdecl(const std::string& filename) { // Output new versions of SPECGRID, COORD, ZCORN, ACTNUM, PERMX, PORO, SATNUM. @@ -363,7 +326,6 @@ namespace Opm bool hasSOWCR() const {return !new_SOWCR_.empty(); } private: - Opm::EclipseGridParser parser_; Opm::DeckConstPtr deck_; std::shared_ptr metricUnits_; diff --git a/opm/core/io/eclipse/EclipseGridInspector.cpp b/opm/core/io/eclipse/EclipseGridInspector.cpp index 77ac712f..4b851fe0 100644 --- a/opm/core/io/eclipse/EclipseGridInspector.cpp +++ b/opm/core/io/eclipse/EclipseGridInspector.cpp @@ -51,40 +51,30 @@ namespace Opm { - -EclipseGridInspector::EclipseGridInspector(const EclipseGridParser& oldParser) -{ - Opm::ParserConstPtr parser(new Opm::Parser()); - newParserDeck_ = parser->parseFile(oldParser.deckFileName()); - - init_(); -} - - -EclipseGridInspector::EclipseGridInspector(Opm::DeckConstPtr newParserDeck) - : newParserDeck_(newParserDeck) +EclipseGridInspector::EclipseGridInspector(Opm::DeckConstPtr deck) + : deck_(deck) { init_(); } void EclipseGridInspector::init_() { - if (!newParserDeck_->hasKeyword("COORD")) { + if (!deck_->hasKeyword("COORD")) { OPM_THROW(std::runtime_error, "Needed field \"COORD\" is missing in file"); } - if (!newParserDeck_->hasKeyword("ZCORN")) { + if (!deck_->hasKeyword("ZCORN")) { OPM_THROW(std::runtime_error, "Needed field \"ZCORN\" is missing in file"); } - if (newParserDeck_->hasKeyword("SPECGRID")) { + if (deck_->hasKeyword("SPECGRID")) { Opm::DeckRecordConstPtr specgridRecord = - newParserDeck_->getKeyword("SPECGRID")->getRecord(0); + deck_->getKeyword("SPECGRID")->getRecord(0); logical_gridsize_[0] = specgridRecord->getItem("NX")->getInt(0); logical_gridsize_[1] = specgridRecord->getItem("NY")->getInt(0); logical_gridsize_[2] = specgridRecord->getItem("NZ")->getInt(0); - } else if (newParserDeck_->hasKeyword("DIMENS")) { + } else if (deck_->hasKeyword("DIMENS")) { Opm::DeckRecordConstPtr dimensRecord = - newParserDeck_->getKeyword("DIMENS")->getRecord(0); + deck_->getKeyword("DIMENS")->getRecord(0); logical_gridsize_[0] = dimensRecord->getItem("NX")->getInt(0); logical_gridsize_[1] = dimensRecord->getItem("NY")->getInt(0); logical_gridsize_[2] = dimensRecord->getItem("NZ")->getInt(0); @@ -107,13 +97,13 @@ std::pair EclipseGridInspector::cellDips(int i, int j, int k) con { checkLogicalCoords(i, j, k); const std::vector& pillc = - newParserDeck_->getKeyword("COORD")->getSIDoubleData(); + deck_->getKeyword("COORD")->getSIDoubleData(); int num_pillars = (logical_gridsize_[0] + 1)*(logical_gridsize_[1] + 1); if (6*num_pillars != int(pillc.size())) { throw std::runtime_error("Wrong size of COORD field."); } const std::vector& z = - newParserDeck_->getKeyword("ZCORN")->getSIDoubleData(); + deck_->getKeyword("ZCORN")->getSIDoubleData(); int num_cells = logical_gridsize_[0]*logical_gridsize_[1]*logical_gridsize_[2]; if (8*num_cells != int(z.size())) { throw std::runtime_error("Wrong size of ZCORN field"); @@ -217,13 +207,13 @@ double EclipseGridInspector::cellVolumeVerticalPillars(int i, int j, int k) cons // Checking parameters and obtaining values from parser. checkLogicalCoords(i, j, k); const std::vector& pillc = - newParserDeck_->getKeyword("COORD")->getSIDoubleData(); + deck_->getKeyword("COORD")->getSIDoubleData(); int num_pillars = (logical_gridsize_[0] + 1)*(logical_gridsize_[1] + 1); if (6*num_pillars != int(pillc.size())) { throw std::runtime_error("Wrong size of COORD field."); } const std::vector& z = - newParserDeck_->getKeyword("ZCORN")->getSIDoubleData(); + deck_->getKeyword("ZCORN")->getSIDoubleData(); int num_cells = logical_gridsize_[0]*logical_gridsize_[1]*logical_gridsize_[2]; if (8*num_cells != int(z.size())) { throw std::runtime_error("Wrong size of ZCORN field"); @@ -281,12 +271,12 @@ void EclipseGridInspector::checkLogicalCoords(int i, int j, int k) const std::array EclipseGridInspector::getGridLimits() const { - if (! (newParserDeck_->hasKeyword("COORD") && newParserDeck_->hasKeyword("ZCORN") && newParserDeck_->hasKeyword("SPECGRID")) ) { + if (! (deck_->hasKeyword("COORD") && deck_->hasKeyword("ZCORN") && deck_->hasKeyword("SPECGRID")) ) { throw std::runtime_error("EclipseGridInspector: Grid does not have SPECGRID, COORD, and ZCORN, can't find dimensions."); } - std::vector coord = newParserDeck_->getKeyword("COORD")->getSIDoubleData(); - std::vector zcorn = newParserDeck_->getKeyword("ZCORN")->getSIDoubleData(); + std::vector coord = deck_->getKeyword("COORD")->getSIDoubleData(); + std::vector zcorn = deck_->getKeyword("ZCORN")->getSIDoubleData(); double xmin = +DBL_MAX; double xmax = -DBL_MAX; @@ -335,7 +325,7 @@ std::array EclipseGridInspector::gridSize() const std::array EclipseGridInspector::cellZvals(int i, int j, int k) const { // Get the zcorn field. - const std::vector& z = newParserDeck_->getKeyword("ZCORN")->getSIDoubleData(); + const std::vector& z = deck_->getKeyword("ZCORN")->getSIDoubleData(); int num_cells = logical_gridsize_[0]*logical_gridsize_[1]*logical_gridsize_[2]; if (8*num_cells != int(z.size())) { throw std::runtime_error("Wrong size of ZCORN field"); diff --git a/opm/core/io/eclipse/EclipseGridInspector.hpp b/opm/core/io/eclipse/EclipseGridInspector.hpp index e0ee3f70..df0dba0c 100644 --- a/opm/core/io/eclipse/EclipseGridInspector.hpp +++ b/opm/core/io/eclipse/EclipseGridInspector.hpp @@ -38,8 +38,6 @@ #include #include -#include -#include #include namespace Opm @@ -48,9 +46,8 @@ namespace Opm /** @brief A class for inspecting the contents of an eclipse file. - Given an EclipseGridParser that has successfully read en Eclipse - .grdecl-file, this class may be used to answer certain queries about - its contents. + Given an Eclipse deck, this class may be used to answer certain + queries about its contents. @author Atgeirr F. Rasmussen @date 2008/06/02 09:46:08 @@ -60,11 +57,7 @@ class EclipseGridInspector public: /// Constructor taking a parser as argument. /// The parser must already have read an Eclipse file. - EclipseGridInspector(const EclipseGridParser& parser); - - /// Constructor taking a parser as argument. - /// The parser must already have read an Eclipse file. - EclipseGridInspector(Opm::DeckConstPtr newParserDeck); + EclipseGridInspector(Opm::DeckConstPtr deck); /// Assuming that the pillars are vertical, compute the /// volume of the cell given by logical coordinates (i, j, k). @@ -98,7 +91,7 @@ public: std::array cellZvals(int i, int j, int k) const; private: - Opm::DeckConstPtr newParserDeck_; + Opm::DeckConstPtr deck_; int logical_gridsize_[3]; void init_(); void checkLogicalCoords(int i, int j, int k) const; diff --git a/opm/core/io/eclipse/EclipseGridParser.cpp b/opm/core/io/eclipse/EclipseGridParser.cpp deleted file mode 100644 index e05534f2..00000000 --- a/opm/core/io/eclipse/EclipseGridParser.cpp +++ /dev/null @@ -1,1215 +0,0 @@ -//=========================================================================== -// -// File: EclipseGridParser.C -// -// Created: Thu Dec 6 08:46:05 2007 -// -// Author: Atgeirr F Rasmussen -// -// $Date$ -// -// $Revision$ -// -// Revision: $Id: EclipseGridParser.C,v 1.4 2008/08/18 14:16:14 atgeirr Exp $ -// -//=========================================================================== - -/* - Copyright 2009, 2010 SINTEF ICT, Applied Mathematics. - Copyright 2009, 2010 Statoil ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_ERT -#include -#include -#include -#include -#include -#include -#include -#endif - -using namespace std; - -//#define VERBOSE - -namespace Opm -{ - -// ---------- List of supported keywords ---------- - -namespace EclipseKeywords -{ - string integer_fields[] = - { string("ACTNUM"), - string("SATNUM"), - string("EQLNUM"), - string("REGNUM"), - string("ROCKTYPE"), - string("DIMENS"), - string("REGDIMS"), - string("WELLDIMS"), - string("TABDIMS"), - string("FIPNUM"), - string("GRIDFILE") - }; - const int num_integer_fields = sizeof(integer_fields) / sizeof(integer_fields[0]); - - string floating_fields[] = - { string("COORD"), string("ZCORN"), string("PERMX"), - string("PERMY"), string("PERMZ"), string("PERMXX"), - string("PERMYY"), string("PERMZZ"), string("PERMXY"), - string("PERMYZ"), string("PERMZX"), string("PORO"), - string("BULKMOD"), string("YOUNGMOD"), string("LAMEMOD"), - string("SHEARMOD"), string("POISSONMOD"), string("PWAVEMOD"), - string("MULTPV"), string("PRESSURE"), string("SGAS"), - string("SWAT"), string("SOIL"), string("RS"), - string("RV"), - string("DXV"), string("DYV"), string("DZV"), - string("DEPTHZ"), string("TOPS"), string("MAPAXES"), - string("SWL"), string("SWCR"), string("SWU"), - string("SGL"), string("SGCR"), string("SGU"), - string("SOWCR"), string("SOGCR"), string("KRW"), - string("KRWR"), string("KRG"), string("KRGR"), - string("KRO"), string("KRORW"), string("KRORG"), - string("ISWL"), string("ISWCR"), string("ISWU"), - string("ISGL"), string("ISGCR"), string("ISGU"), - string("ISOWCR"), string("ISOGCR"), string("IKRW"), - string("IKRWR"), string("IKRG"), string("IKRGR"), - string("IKRO"), string("IKRORW"), string("IKRORG"), - string("NTG"), string("RHO") - }; - const int num_floating_fields = sizeof(floating_fields) / sizeof(floating_fields[0]); - - string special_fields[] = - { string("SPECGRID"), string("FAULTS"), string("MULTFLT"), - string("TITLE"), string("START"), string("DATES"), - string("DENSITY"), string("PVDG"), string("PVDO"), - string("PVTG"), string("PVTO"), string("PVTW"), - string("SGOF"), string("SWOF"), string("ROCK"), - string("ROCKTAB"), string("WELSPECS"), string("COMPDAT"), - string("WCONINJE"), string("WCONPROD"), string("WELTARG"), - string("WELOPEN"), - string("EQUIL"), string("PVCDO"), string("TSTEP"), - string("PLYVISC"), string("PLYROCK"), string("PLYADS"), - string("PLYMAX"), string("TLMIXPAR"), string("WPOLYMER"), - string("PLYSHEAR"), - string("GRUPTREE"), string("GCONINJE"), string("GCONPROD"), - string("WGRUPCON"), string("ENDSCALE"), string("SCALECRS"), - string("ENPTVD"), string("ENKRVD"), - // The following fields only have a dummy implementation - // that allows us to ignore them. - string("SWFN"), - string("SOF2"), - string("TUNING") - }; - - const int num_special_fields = sizeof(special_fields) / sizeof(special_fields[0]); - - string ignore_with_data[] = - { string("MAPUNITS"), string("GRIDUNIT"), - string("REGDIMS"), string("WELLDIMS"), - string("NSTACK"), string("SATNUM"), - string("RPTRST"), string("ROIP"), string("RWIP"), - string("RWSAT"), string("RPR"), string("WBHP"), - string("WOIR"), string("BOX"), - string("COORDSYS"), string("PBVD") - }; - const int num_ignore_with_data = sizeof(ignore_with_data) / sizeof(ignore_with_data[0]); - - string ignore_no_data[] = - { string("RUNSPEC"), string("WATER"), string("OIL"), - string("METRIC"), string("FMTIN"), string("FMTOUT"), - string("GRID"), string("INIT"), string("NOECHO"), - string("ECHO"), string("EDIT"), string("PROPS"), - string("REGIONS"), string("SOLUTION"), string("SUMMARY"), - string("FPR"), string("FOIP"), string("FWIP"), - string("RUNSUM"), string("EXCEL"), string("SCHEDULE"), - string("END"), string("ENDBOX"), string("CONTINUE"), - string("NONNC"), string("GAS"), string("DISGAS"), - string("FIELD"), string("POLYMER") - }; - const int num_ignore_no_data = sizeof(ignore_no_data) / sizeof(ignore_no_data[0]); - - string include_keywords[] = { string("INCLUDE") }; - const int num_include_keywords = sizeof(include_keywords) / sizeof(include_keywords[0]); - - string import_keywords[] = { string("IMPORT") }; - const int num_import_keywords = sizeof(import_keywords) / sizeof(import_keywords[0]); - - -} // namespace EclipseKeywords - -namespace { - - inline std::string upcase(const std::string& s) - { - std::string us(s); - // Getting the character type facet for toupper(). - // We use the classic (i.e. C) locale. - const std::ctype& ct = std::use_facet< std::ctype >(std::locale::classic()); - for (int i = 0; i < int(s.size()); ++i) { - us[i] = ct.toupper(s[i]); - } - return us; - } - - - -} // anon namespace - - - -// ---------- Member functions ---------- - -/// Default constructor. -//--------------------------------------------------------------------------- -EclipseGridParser::EclipseGridParser() -//--------------------------------------------------------------------------- - : current_reading_mode_(Regular), - start_date_(boost::date_time::not_a_date_time), - current_time_days_(0.0), - current_epoch_(0), - special_field_by_epoch_(1) -{ -} - - -/// Constructor taking an eclipse filename. -//--------------------------------------------------------------------------- -EclipseGridParser::EclipseGridParser(const string& filename, bool convert_to_SI) -//--------------------------------------------------------------------------- - : current_reading_mode_(Regular), - start_date_(boost::date_time::not_a_date_time), - current_time_days_(0.0), - current_epoch_(0), - special_field_by_epoch_(1) -{ - // Store directory of filename - boost::filesystem::path p(filename); - directory_ = p.parent_path().string(); - deckFileName_ = p.string(); - ifstream is(deckFileName_.c_str()); - if (!is) { - cerr << "Unable to open file " << filename << endl; - throw exception(); - } - read(is, convert_to_SI); -} - - - FieldType EclipseGridParser::classifyKeyword(const string& keyword) - { - using namespace EclipseKeywords; - if (count(integer_fields, integer_fields + num_integer_fields, keyword)) { - return Integer; - } else if (count(floating_fields, floating_fields + num_floating_fields, keyword)) { - return FloatingPoint; - } else if (keyword == "TSTEP" || keyword == "DATES") { - return Timestepping; - } else if (count(special_fields, special_fields + num_special_fields, keyword)) { - return SpecialField; - } else if (count(ignore_with_data, ignore_with_data + num_ignore_with_data, keyword)) { - return IgnoreWithData; - } else if (count(ignore_no_data, ignore_no_data + num_ignore_no_data, keyword)) { - return IgnoreNoData; - } else if (count(include_keywords, include_keywords + num_include_keywords, keyword)) { - return Include; - } else if (count(import_keywords, import_keywords + num_import_keywords, keyword)) { - return Import; - } else { - return Unknown; - } - } - - -bool EclipseGridParser::readKeyword(std::istream& is, std::string& keyword) -{ - char buf[9]; - int i, j; - char c; - /* Clear buf */ - for (i=0; i<9; ++i) { - buf[i] = '\0'; - } - - /* Read first character and check if it is uppercase*/ - //buf[0] = fgetc(fp); - is.get(buf[0]); - if ( !isupper( buf[0] ) ) { - is.unget(); - return false; /* NOT VALID CHARACTER */ - } - - /* Scan as much as possible possible keyword, 8 characters long */ - i = 1; - is.get(c); - while ( (is.good()) && - (c != EOF ) && - (!isblank(c) ) && - (isupper(c) || isdigit(c)) && - (c != '\n' ) && - (c != '/' ) && - (i < 8 )) { - buf[i++] = c; - is.get(c); - } - - /* Skip rest of line */ - if (c != '\n'){ - is.get(c); - while ( (is.good()) && - (c != EOF ) && - (c != '\n' )) { - is.get(c); - } - } - if(c == '\n') { - is.unget(); - } - - /* Find first non-uppercase or non-digit character */ - for (i=0; i<8; ++i) { - if ( !(isupper(buf[i]) || isdigit(buf[i])) ) { - break; - } - } - - /* Check if remaining characters are blank */ - for (j = i; j<8; ++j) { - if(!isspace(buf[j]) && buf[j] != '\0') { - return false; /* CHARACTER AFTER SPACE OR INVALID CHARACTER */ - } - buf[j] = '\0'; - } - keyword = std::string(buf); - std::string::size_type end = keyword.find_last_of('\0'); - if(end != keyword.npos) - keyword = keyword.substr(0, end+1); - return true; -} - - -/// Read the given stream, overwriting any previous data. -//--------------------------------------------------------------------------- -void EclipseGridParser::read(istream& is, bool convert_to_SI) -//--------------------------------------------------------------------------- -{ - integer_field_map_.clear(); - floating_field_map_.clear(); - special_field_by_epoch_.clear(); - special_field_by_epoch_.push_back(SpecialMap()); - current_time_days_ = 0.0; - current_epoch_ = 0; - - readImpl(is); - - current_epoch_ = 0; - - computeUnits(); - if (convert_to_SI) { - convertToSI(); - } - -#define VERBOSE_LIST_FIELDS 1 -#if VERBOSE_LIST_FIELDS - std::cout << "\nInteger fields:\n"; - for (std::map >::iterator - i = integer_field_map_.begin(); i != integer_field_map_.end(); ++i) - std::cout << '\t' << i->first << '\n'; - - std::cout << "\nFloat fields:\n"; - for (std::map >::iterator - i = floating_field_map_.begin(); i != floating_field_map_.end(); ++i) - std::cout << '\t' << i->first << '\n'; - - std::cout << "\nSpecial fields:\n"; - for (int epoch = 0; epoch < numberOfEpochs(); ++epoch) { - std::cout << "Epoch " << epoch << '\n'; - const SpecialMap& sm = special_field_by_epoch_[epoch]; - for (SpecialMap::const_iterator i = sm.begin(); i != sm.end(); ++i) { - std::cout << '\t' << i->first << '\n'; - } - } -#endif -} - -//--------------------------------------------------------------------------- -void EclipseGridParser::readImpl(istream& is) -//--------------------------------------------------------------------------- -{ - if (!is) { - cerr << "Could not read given input stream." << endl; - throw exception(); - } - - // Make temporary maps that will at the end be swapped with the - // member maps - // NOTE: Above is no longer true, for easier implementation of - // the INCLUDE keyword. We lose the strong exception guarantee, - // though (of course retaining the basic guarantee). - map >& intmap = integer_field_map_; - map >& floatmap = floating_field_map_; - - // Actually read the data - std::string keyword; - while (is.good()) { - is >> ignoreWhitespace; - bool ok = readKeyword(is, keyword); - if (ok) { - //#ifdef VERBOSE - cout << "Keyword found: " << keyword << endl; - //#endif - FieldType type = classifyKeyword(keyword); - // std::cout << "Classification: " << type << std::endl; - switch (type) { - case Integer: { - readVectorData(is, intmap[keyword]); - break; - } - case FloatingPoint: { - readVectorData(is, floatmap[keyword]); - break; - } - case Timestepping: { - SpecialMap& sm = special_field_by_epoch_[current_epoch_]; - if (start_date_.is_not_a_date()) { - // Set it to START date, or default if no START. - // This will only ever happen in the first epoch, - // upon first encountering a timestepping keyword. - if (hasField("START")) { - start_date_ = getSTART().date; - } else { - start_date_ = boost::gregorian::date( 1983 , 1 , 1 ); - } - } - if (current_reading_mode_ == Regular) { - current_reading_mode_ = Timesteps; - } - // Get current epoch's TSTEP, if it exists, create new if not. - SpecialMap::iterator it = sm.find("TSTEP"); - TSTEP* tstep = 0; - if (it != sm.end()) { - tstep = dynamic_cast(it->second.get()); - } else { - SpecialFieldPtr sb_ptr(new TSTEP()); - tstep = dynamic_cast(sb_ptr.get()); - sm["TSTEP"] = sb_ptr; - } - assert(tstep != 0); - // Append new steps to current TSTEP object - if (keyword == "TSTEP") { - const int num_steps_old = tstep->tstep_.size(); - tstep->read(is); // This will append to the TSTEP object. - const double added_days - = std::accumulate(tstep->tstep_.begin() + num_steps_old, tstep->tstep_.end(), 0.0); - current_time_days_ += added_days; - } else if (keyword == "DATES") { - DATES dates; - dates.read(is); - for (std::size_t dix = 0; dix < dates.dates.size(); ++dix) { - boost::gregorian::date_duration since_start = dates.dates[dix] - start_date_; - double step = double(since_start.days()) - current_time_days_; - tstep->tstep_.push_back(step); - current_time_days_ = double(since_start.days()); - } - } else { - OPM_THROW(std::runtime_error, "Keyword " << keyword << " cannot be handled here."); - } - break; - } - case SpecialField: { - if (current_reading_mode_ == Timesteps) { - // We have been reading timesteps, but have - // now encountered something else. - // That means we are in a new epoch. - current_reading_mode_ = Regular; - special_field_by_epoch_.push_back(SpecialMap()); - ++current_epoch_; - assert(int(special_field_by_epoch_.size()) == current_epoch_ + 1); - // Add clones of all existing special fields to new map. - SpecialMap& oldmap = special_field_by_epoch_[current_epoch_ - 1]; - SpecialMap& newmap = special_field_by_epoch_[current_epoch_]; - for (SpecialMap::iterator it = oldmap.begin(); it != oldmap.end(); ++it) { - // if (it->first != "TSTEP") { - newmap[it->first] = cloneSpecialField(it->first, it->second); - //} - } - //assert(newmap.count("TSTEP") == 0); - } - // Check if the keyword already exists. If so, append. Otherwise, create new. - SpecialMap::iterator it = special_field_by_epoch_[current_epoch_].find(keyword); - if (it != special_field_by_epoch_[current_epoch_].end()) { - it->second->read(is); - } else { - SpecialFieldPtr sb_ptr = createSpecialField(is, keyword); - if (sb_ptr) { - special_field_by_epoch_[current_epoch_][keyword] = sb_ptr; - } else { - OPM_THROW(std::runtime_error, "Could not create field " << keyword); - } - } - break; - } - case IgnoreWithData: { - ignored_fields_.insert(keyword); - //is >> ignoreSlashLine; - //#ifdef VERBOSE - // cout << "(ignored)" << endl; - //#endif - break; - } - case IgnoreNoData: { - ignored_fields_.insert(keyword); - //is >> ignoreLine; - //#ifdef VERBOSE - // cout << "(ignored)" << endl; - //#endif - break; - } - case Include: { - string include_filename = readString(is); - if (!directory_.empty()) { - include_filename = directory_ + '/' + include_filename; - } - ifstream include_is(include_filename.c_str()); - if (!include_is) { - OPM_THROW(std::runtime_error, "Unable to open INCLUDEd file " << include_filename); - } - readImpl(include_is); - // is >> ignoreSlashLine; - break; - } - case Import: { - string import_filename = readString(is); - if (!directory_.empty()) { - import_filename = directory_ + '/' + import_filename; - } - getNumericErtFields(import_filename); - break; - } - case Unknown: - default: - ignored_fields_.insert(keyword); - cout << "*** Warning: keyword " << keyword << " is unknown." << endl; - //is >> ignoreSlashLine; - //throw exception(); - } - } else { - // if (!ok) - is >> ignoreLine; - } - } -} - - - -//--------------------------------------------------------------------------- -void EclipseGridParser::convertToSI() -//--------------------------------------------------------------------------- -{ - // Convert all special fields. - typedef SpecialMap::iterator SpecialIt; - for (int epoch = 0; epoch < numberOfEpochs(); ++epoch) { - SpecialMap& sm = special_field_by_epoch_[epoch]; - for (SpecialIt i = sm.begin(); i != sm.end(); ++i) { - i->second->convertToSI(units_); - } - } - - // Convert all floating point fields. - typedef std::map >::iterator FloatIt; - for (FloatIt i = floating_field_map_.begin(); i != floating_field_map_.end(); ++i) { - const std::string& key = i->first; - std::vector& field = i->second; - // Find the right unit. - double unit = 1e100; - bool do_convert = true; - if (key == "COORD" || key == "ZCORN" || - key == "DXV" || key == "DYV" || key == "DZV" || - key == "DEPTHZ" || key == "TOPS") { - unit = units_.length; - } else if (key == "PERMX" || key == "PERMY" || key == "PERMZ" || - key == "PERMXX" || key == "PERMYY" || key == "PERMZZ" || - key == "PERMXY" || key == "PERMYZ" || key == "PERMZX") { - unit = units_.permeability; - } else if (key == "PORO" || key == "BULKMOD" || key == "YOUNGMOD" || - key == "LAMEMOD" || key == "SHEARMOD" || key == "POISSONMOD" || - key == "PWAVEMOD" || key == "MULTPV" || key == "PWAVEMOD" || - key == "SGAS" || key == "SWAT" || key == "SOIL" || - key == "SWL" || key == "SWCR" || key == "SWU" || - key == "SGL" || key == "SGCR" || key == "SGU" || - key == "SOWCR" || key == "SOGCR" || key == "KRW" || - key == "KRWR" || key == "KRG" || key == "KRGR" || - key == "KRO" || key == "KRORW" || key == "KRORG" || - key == "ISWL" || key == "ISWCR" || key == "ISWU" || - key == "ISGL" || key == "ISGCR" || key == "ISGU" || - key == "ISOWCR" || key == "ISOGCR" || key == "IKRW" || - key == "IKRWR" || key == "IKRG" || key == "IKRGR" || - key == "IKRO" || key == "IKRORW" || key == "IKRORG" || - key == "NTG" || - key == "RHO") /* nonstandard field with no unit logic. use with caution */ { - unit = 1.0; - do_convert = false; // Dimensionless keywords... - } else if (key == "PRESSURE") { - unit = units_.pressure; - } else if (key == "RS") { - unit = units_.gasvol_s / units_.liqvol_s; - } else if (key == "RV") { - unit = units_.liqvol_s / units_.gasvol_s; - } else if (key == "MAPAXES") { - OPM_MESSAGE("Not applying units to MAPAXES yet!"); - unit = 1.0; - } else { - OPM_THROW(std::runtime_error, "Units for field " << key << " not specified. Cannon convert to SI."); - } - - if (do_convert) { - for (std::vector::size_type j = 0; j < field.size(); ++j) { - field[j] = unit::convert::from(field[j], unit); - } - } - } - - // Set all units to one. - units_.setToOne(); -} - - -/// Returns true if the given keyword corresponds to a field that -/// was found in the file. -//--------------------------------------------------------------------------- -bool EclipseGridParser::hasField(const string& keyword) const -//--------------------------------------------------------------------------- -{ - string ukey = upcase(keyword); - return integer_field_map_.count(ukey) || floating_field_map_.count(ukey) || - special_field_by_epoch_[current_epoch_].count(ukey) || ignored_fields_.count(ukey); -} - - -/// Returns true if all the given keywords correspond to fields -/// that were found in the file. -//--------------------------------------------------------------------------- -bool EclipseGridParser::hasFields(const vector& keywords) const -//--------------------------------------------------------------------------- -{ - int num_keywords = keywords.size(); - for (int i = 0; i < num_keywords; ++i) { - if (!hasField(keywords[i])) { - return false; - } - } - return true; -} - -//--------------------------------------------------------------------------- -vector EclipseGridParser::fieldNames() const -//--------------------------------------------------------------------------- -{ - vector names; - names.reserve(integer_field_map_.size() + - floating_field_map_.size() + - special_field_by_epoch_[current_epoch_].size() + - ignored_fields_.size()); - { - map >::const_iterator it = integer_field_map_.begin(); - for (; it != integer_field_map_.end(); ++it) { - names.push_back(it->first); - } - } - { - map >::const_iterator it = floating_field_map_.begin(); - for (; it != floating_field_map_.end(); ++it) { - names.push_back(it->first); - } - } - { - SpecialMap::const_iterator it = special_field_by_epoch_[current_epoch_].begin(); - for (; it != special_field_by_epoch_[current_epoch_].end(); ++it) { - names.push_back(it->first); - } - } - { - set::const_iterator it = ignored_fields_.begin(); - for (; it != ignored_fields_.end(); ++it) { - names.push_back(*it); - } - } - return names; -} - - -//--------------------------------------------------------------------------- -int EclipseGridParser::numberOfEpochs() const -//--------------------------------------------------------------------------- -{ - return special_field_by_epoch_.size(); -} - - -//--------------------------------------------------------------------------- -void EclipseGridParser::setCurrentEpoch(int epoch) -//--------------------------------------------------------------------------- -{ - assert(epoch >= 0 && epoch < numberOfEpochs()); - current_epoch_ = epoch; -} - -//----------------------------------------------------------------- -boost::gregorian::date EclipseGridParser::getStartDate() const -//--------------------------------------------------------------------------- -{ - return start_date_; -} - -//--------------------------------------------------------------------------- -const std::vector& EclipseGridParser::getIntegerValue(const std::string& keyword) const -//--------------------------------------------------------------------------- -{ - if (keyword == "SPECGRID") { - cerr << "\nERROR. Interface has changed!\n" - << "const vector& dim = parser.getIntegerValue(""SPECGRID"") is deprecated.\n" - << "Use:\n" - << "const SPECGRID& specgrid = parser.getSPECGRID();\n" - << "const vector& dim = specgrid.dimensions;\n\n"; - throw exception(); - } - - map >::const_iterator it - = integer_field_map_.find(keyword); - if (it == integer_field_map_.end()) { - OPM_THROW(std::runtime_error, "No such field: " << keyword); - } else { - return it->second; - } -} - -//--------------------------------------------------------------------------- -const std::vector& EclipseGridParser::getFloatingPointValue(const std::string& keyword) const -//--------------------------------------------------------------------------- -{ - map >::const_iterator it - = floating_field_map_.find(keyword); - if (it == floating_field_map_.end()) { - OPM_THROW(std::runtime_error, "No such field: " << keyword); - } else { - return it->second; - } -} - - -//--------------------------------------------------------------------------- -const std::shared_ptr EclipseGridParser::getSpecialValue(const std::string& keyword) const -//--------------------------------------------------------------------------- -{ - SpecialMap::const_iterator it = special_field_by_epoch_[current_epoch_].find(keyword); - if (it == special_field_by_epoch_[current_epoch_].end()) { - OPM_THROW(std::runtime_error, "No such field: " << keyword); - } else { - return it->second; - } -} - -//--------------------------------------------------------------------------- -std::shared_ptr -EclipseGridParser::createSpecialField(std::istream& is, - const std::string& fieldname) -//--------------------------------------------------------------------------- -{ - string ukey = upcase(fieldname); - std::shared_ptr spec_ptr - = Factory::createObject(fieldname); - is >> ignoreWhitespace; - spec_ptr->read(is); - return spec_ptr; -} - -//--------------------------------------------------------------------------- -std::shared_ptr -EclipseGridParser::cloneSpecialField(const std::string& fieldname, - const std::shared_ptr original) -//--------------------------------------------------------------------------- -{ - string ukey = upcase(fieldname); - std::shared_ptr spec_ptr - = Factory::cloneObject(fieldname, original); - return spec_ptr; -} - - -//--------------------------------------------------------------------------- -void EclipseGridParser::setIntegerField(const std::string& keyword, - const std::vector& field) -//--------------------------------------------------------------------------- -{ - integer_field_map_[keyword] = field; -} - -//--------------------------------------------------------------------------- -void EclipseGridParser::setFloatingPointField(const std::string& keyword, - const std::vector& field) -//--------------------------------------------------------------------------- -{ - floating_field_map_[keyword] = field; -} - -//--------------------------------------------------------------------------- -void EclipseGridParser::setSpecialField(const std::string& keyword, - std::shared_ptr field) -//--------------------------------------------------------------------------- -{ - special_field_by_epoch_[current_epoch_][keyword] = field; -} - -//--------------------------------------------------------------------------- -const EclipseUnits& EclipseGridParser::units() const -//--------------------------------------------------------------------------- -{ - return units_; -} - -//--------------------------------------------------------------------------- -void EclipseGridParser::computeUnits() -//--------------------------------------------------------------------------- -{ - // Decide unit family. - enum EclipseUnitFamily { Metric = 0, Field = 1, Lab = 2, Pvtm = 3 }; - EclipseUnitFamily unit_family = Metric; // The default. - if (hasField("FIELD")) unit_family = Field; - if (hasField("LAB")) unit_family = Lab; - if (hasField("PVT-M")) unit_family = Pvtm; - - // Set units. - using namespace prefix; - using namespace unit; - switch (unit_family) { - case Metric: - units_.length = meter; - units_.time = day; - units_.density = kilogram/cubic(meter); - units_.polymer_density = kilogram/cubic(meter); - units_.pressure = barsa; - units_.compressibility = 1.0/barsa; - units_.viscosity = centi*Poise; - units_.permeability = milli*darcy; - units_.liqvol_s = cubic(meter); - units_.liqvol_r = cubic(meter); - units_.gasvol_s = cubic(meter); - units_.gasvol_r = cubic(meter); - units_.transmissibility = centi*Poise * cubic(meter) / (day * barsa); - break; - case Field: - units_.length = feet; - units_.time = day; - units_.density = pound/cubic(feet); - units_.polymer_density = pound/stb; - units_.pressure = psia; - units_.compressibility = 1.0/psia; - units_.viscosity = centi*Poise; - units_.permeability = milli*darcy; - units_.liqvol_s = stb; - units_.liqvol_r = stb; - units_.gasvol_s = 1000*cubic(feet); // Prefix 'M' is 1000 - units_.gasvol_r = stb; - units_.transmissibility = centi*Poise * stb / (day * psia); - break; - case Lab: - OPM_THROW(std::runtime_error, "Unhandled unit family " << unit_family); - break; - case Pvtm: - OPM_THROW(std::runtime_error, "Unhandled unit family " << unit_family); - break; - default: - OPM_THROW(std::runtime_error, "Unknown unit family " << unit_family); - } -} - - -struct grdecl EclipseGridParser::get_grdecl() const { - struct grdecl grdecl; - - // Extract data from deck. - const std::vector& zcorn = getFloatingPointValue("ZCORN"); - const std::vector& coord = getFloatingPointValue("COORD"); - const int* actnum = NULL; - if (hasField("ACTNUM")) { - actnum = &(getIntegerValue("ACTNUM")[0]); - } - - std::vector dims; - if (hasField("DIMENS")) { - dims = getIntegerValue("DIMENS"); - } else if (hasField("SPECGRID")) { - dims = getSPECGRID().dimensions; - } else { - OPM_THROW(std::runtime_error, "Deck must have either DIMENS or SPECGRID."); - } - - // Collect in input struct for preprocessing. - - grdecl.zcorn = &zcorn[0]; - grdecl.coord = &coord[0]; - grdecl.actnum = actnum; - grdecl.dims[0] = dims[0]; - grdecl.dims[1] = dims[1]; - grdecl.dims[2] = dims[2]; - - if (hasField("MAPAXES")) { - const std::vector &mapaxes = getFloatingPointValue("MAPAXES"); - grdecl.mapaxes = &mapaxes[0]; - } else - grdecl.mapaxes = NULL; - - - return grdecl; -} - - -#ifdef HAVE_ERT -/* - This function will create a ecl_kw instance filled with the data - from input argument @keyword. The ecl_kw will get it's own copy of - the data. - - If the input type ecl_type == ECL_INT_TYPE the function will use the - getIntegerValue() method to get the keyword data, if ecl_type == - ECL_DOUBLE_TYPE || ECL_FLOAT_TYPE the getFloatingPointValue() - function is invoked. If ecl_type == ECL_FLOAT_TYPE the data will be - converted to when inserting into the ecl_kw. - - When the ecl_kw instance is no longer needed it should be discarded - with a call to ecl_kw_free( ). - - If you are asking for a non-existent field the function will return NULL -*/ - -ecl_kw_type * EclipseGridParser::newEclKW(const std::string &keyword , ecl_type_enum ecl_type) const { - ecl_kw_type * ecl_kw = NULL; - if (hasField(keyword)) { - if (ecl_type == ECL_INT_TYPE) { - std::vector data = getIntegerValue( keyword ); - ecl_kw = ecl_kw_alloc( keyword.c_str() , data.size() , ecl_type ); - ecl_kw_set_memcpy_data( ecl_kw , &data[0]); - } else { - std::vector data = getFloatingPointValue( keyword ); - if (ecl_type == ECL_DOUBLE_TYPE) { - ecl_kw = ecl_kw_alloc( keyword.c_str() , data.size() , ecl_type ); - ecl_kw_set_memcpy_data( ecl_kw , &data[0]); - } else if (ecl_type == ECL_FLOAT_TYPE) { - ecl_kw = ecl_kw_alloc( keyword.c_str() , data.size() , ecl_type ); - for (std::vector::size_type i=0; i < data.size(); i++) - ecl_kw_iset_float( ecl_kw , i , data[i] ); - } - } - } - return ecl_kw; -} - - -/** - This function will extract the COORD, ZCORN, ACTNUM and optionaly - MAPAXES keywords from the eclipse deck and create an ecl_grid - instance. - - When you are finished working with the ecl_grid instance it should - be disposed with ecl_grid_free( ). -*/ - -ecl_grid_type * EclipseGridParser::newGrid( ) { - struct grdecl grdecl = get_grdecl(); - ecl_kw_type * coord_kw = newEclKW( COORD_KW , ECL_FLOAT_TYPE ); - ecl_kw_type * zcorn_kw = newEclKW( ZCORN_KW , ECL_FLOAT_TYPE ); - ecl_kw_type * actnum_kw = newEclKW( ACTNUM_KW , ECL_INT_TYPE ); - ecl_kw_type * mapaxes_kw = NULL; - - ecl_grid_type * grid ; - if (grdecl.mapaxes != NULL) - mapaxes_kw = newEclKW( MAPAXES_KW , ECL_FLOAT_TYPE ); - - grid = ecl_grid_alloc_GRDECL_kw( grdecl.dims[0] , grdecl.dims[1] , grdecl.dims[2] , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw ); - - ecl_kw_free( coord_kw ); - ecl_kw_free( zcorn_kw ); - ecl_kw_free( actnum_kw ); - if (mapaxes_kw != NULL) - ecl_kw_free( mapaxes_kw ); - - return grid; -} - - - -/** - This function will save an EGRID file based on the COORD, ZCORN, - ACTNUM and optionally MAPAXES keywords included in the deck. - - This function creates the EGRID file without going through a - ecl_grid instance; this is obviously somewhat faster and less - memory demanding. Alternatively you can create a ecl_grid instance - and then subsequently store that grid as an EGRID file: - - { - ecl_grid_type * grid = newGRID( ); - ecl_grid_fwrite_EGRID( grid , filename ); - ecl_grid_free( grid ); - } -*/ - - void EclipseGridParser::saveEGRID( const std::string & filename , int num_cells , const int * global_cell) const { - bool endian_flip = true;//ECL_ENDIAN_FLIP; - bool fmt_file; - struct grdecl grdecl = get_grdecl(); - fortio_type * fortio; - - if (!ecl_util_fmt_file( filename.c_str() , &fmt_file)) { - cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl; - throw exception(); - } - - fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip ); - { - float * mapaxes = NULL; - if (grdecl.mapaxes != NULL) { - mapaxes = new float[6]; - for (int i=0; i < 6; i++) - mapaxes[i]= grdecl.mapaxes[i]; - } - - ecl_grid_fwrite_EGRID_header( grdecl.dims , mapaxes , fortio ); - - if (grdecl.mapaxes != NULL) - delete[] mapaxes; - } - - { - ecl_kw_type * coord_kw = newEclKW( COORD_KW , ECL_FLOAT_TYPE ); - ecl_kw_type * zcorn_kw = newEclKW( ZCORN_KW , ECL_FLOAT_TYPE ); - ecl_kw_type * endgrid_kw = ecl_kw_alloc( ENDGRID_KW , 0 , ECL_INT_TYPE ); - - - ecl_kw_fwrite( coord_kw , fortio ); - ecl_kw_fwrite( zcorn_kw , fortio ); - if (global_cell) { - int global_size = grdecl.dims[0] * grdecl.dims[1] * grdecl.dims[2]; - ecl_kw_type * actnum_kw = ecl_kw_alloc( ACTNUM_KW , global_size , ECL_INT_TYPE ); - int * actnum_data = ecl_kw_get_int_ptr( actnum_kw ); - - ecl_kw_scalar_set_int( actnum_kw , 0 ); - for (int c=0; c < num_cells; c++) - actnum_data[global_cell[c]] = 1; - - ecl_kw_fwrite( actnum_kw , fortio ); - ecl_kw_free( actnum_kw ); - } - ecl_kw_fwrite( endgrid_kw , fortio ); - - ecl_kw_free( coord_kw ); - ecl_kw_free( zcorn_kw ); - ecl_kw_free( endgrid_kw ); - } - fortio_fclose( fortio ); - } - - -/** - Will query the deck for keyword @kw; and save it to the @fortio - instance if the keyword can be found. -*/ -void EclipseGridParser::save_kw( fortio_type * fortio , const std::string & kw , ecl_type_enum ecl_type) { - ecl_kw_type * ecl_kw = newEclKW( kw , ecl_type ); - if (ecl_kw != NULL) { - ecl_kw_fwrite( ecl_kw , fortio ); - ecl_kw_free( ecl_kw ); - } -} - - -/** - Will save an ECLIPSE INIT file to @filename. Observe that the main - focus of this function is to store grid properties like PERMX and - PORO, various tabular properties like e.g. relperm tables and - thermodynamic properties are ignored. -*/ - -void EclipseGridParser::saveINIT( const std::string & filename , const ecl_grid_type * ecl_grid) { - int phases = ECL_OIL_PHASE + ECL_WATER_PHASE; - bool endian_flip = true;//ECL_ENDIAN_FLIP; - bool fmt_file; - fortio_type * fortio; - - if (!ecl_util_fmt_file( filename.c_str() , &fmt_file)) { - cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl; - throw exception(); - } - fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip ); - - { - ecl_kw_type * poro_kw = newEclKW( PORO_KW , ECL_FLOAT_TYPE ); - time_t start_date; - - { - tm td_tm = to_tm( start_date_ ); - start_date = mktime( &td_tm ); - } - - ecl_init_file_fwrite_header( fortio , ecl_grid , poro_kw , phases , start_date ); - ecl_kw_free( poro_kw ); - } - - /* This collection of keywords is somewhat arbitrary and random. */ - save_kw( fortio , "PERMX" , ECL_FLOAT_TYPE); - save_kw( fortio , "PERMY" , ECL_FLOAT_TYPE); - save_kw( fortio , "PERMZ" , ECL_FLOAT_TYPE); - - save_kw( fortio , "FIPNUM" , ECL_INT_TYPE); - save_kw( fortio , "SATNUM" , ECL_INT_TYPE); - save_kw( fortio , "EQLNUM" , ECL_INT_TYPE); - - fortio_fclose( fortio ); -} - - -/** - This is the main function used to save the state of the ECLIPSE - deck in ECLIPSE format. The function will save an INIT file and an - EGRID file. - - The input arguments are the output directory to store files in, and - the basename to use for the files; the function will build up a - ECLIPSE standard filename internally. -*/ - -void EclipseGridParser::saveEGRID_INIT( const std::string& output_dir , const std::string& basename, bool fmt_file) { - ecl_grid_type * ecl_grid = newGrid(); - char * egrid_file = ecl_util_alloc_filename( output_dir.c_str() , basename.c_str() , ECL_EGRID_FILE , fmt_file , 0); - char * init_file = ecl_util_alloc_filename( output_dir.c_str() , basename.c_str() , ECL_INIT_FILE , fmt_file , 0); - - ecl_grid_fwrite_EGRID( ecl_grid , egrid_file ); - saveINIT( init_file , ecl_grid ); - - free( init_file ); - free( egrid_file ); - ecl_grid_free( ecl_grid ); -} -#else - -void EclipseGridParser::saveEGRID( const std::string & filename, int num_cells , const int * global_cell) const -{ - static_cast(filename); // Suppress "unused variable" warning. - static_cast(num_cells); // Suppress "unused variable" warning. - static_cast(global_cell); // Suppress "unused variable" warning. - OPM_THROW(std::runtime_error, "Cannot write EGRID format without ERT library support. Reconfigure opm-core with ERT support and recompile."); -} - -#endif - -// Read an imported fortio data file using Ert. -// Data stored in 'integer_field_map_' and 'floating_field_map_'. -void EclipseGridParser::getNumericErtFields(const string& filename) -{ -#ifdef HAVE_ERT - // Read file - ecl_file_type * ecl_file = ecl_file_open(filename.c_str() , 0); - if (ecl_file == NULL) { - OPM_THROW(std::runtime_error, "Could not open IMPORTed file " << filename); - } - const int num_kw = ecl_file_get_size(ecl_file); - std::vector double_vec; - std::vector int_vec; - for (int i=0; i const std::vector& -EclipseGridParser::getValue (const std::string& keyword) const { - return this->getIntegerValue(keyword); -} - -template <> const std::vector& -EclipseGridParser::getValue (const std::string& keyword) const { - return this->getFloatingPointValue(keyword); -} - -} // namespace Opm diff --git a/opm/core/io/eclipse/EclipseGridParser.hpp b/opm/core/io/eclipse/EclipseGridParser.hpp deleted file mode 100644 index bdcbf0f7..00000000 --- a/opm/core/io/eclipse/EclipseGridParser.hpp +++ /dev/null @@ -1,289 +0,0 @@ -//=========================================================================== -// -// File: EclipseGridParser.h -// -// Created: Wed Dec 5 17:05:13 2007 -// -// Author: Atgeirr F Rasmussen -// -// $Date$ -// -// Revision: $Id: EclipseGridParser.h,v 1.3 2008/08/18 14:16:13 atgeirr Exp $ -// -//=========================================================================== - -/* - Copyright 2009, 2010 SINTEF ICT, Applied Mathematics. - Copyright 2009, 2010 Statoil ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef OPM_ECLIPSEGRIDPARSER_HEADER -#define OPM_ECLIPSEGRIDPARSER_HEADER - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#ifdef HAVE_ERT -#include -#include -#endif - - -namespace Opm -{ - -/** - @brief A class for reading and parsing all fields of an eclipse file. - - This object is constructed using an Eclipse .grdecl-file. All data - fields are extracted upon construction and written to vector data - structures, which can then be read out afterwards via - convenience functions. - - There is also a convenience function to easily check which fields - were successfully parsed. - - @author Atgeirr F. Rasmussen - @date 2007/12/06 13:00:03 - -*/ - - enum FieldType { - Integer, - FloatingPoint, - Timestepping, - SpecialField, - IgnoreWithData, - IgnoreNoData, - Include, - Import, - Unknown - }; - - - - class EclipseGridParser - { - public: - /// Default constructor. - EclipseGridParser(); - /// Constructor taking an eclipse filename. Unless the second - /// argument 'convert_to_SI' is false, all fields will be - /// converted to SI units. - explicit EclipseGridParser(const std::string& filename, bool convert_to_SI = true); - - static FieldType classifyKeyword(const std::string& keyword); - static bool readKeyword(std::istream& is, std::string& keyword); - - // temporary measure to get the file name passed to the - // constuctor above - const std::string &deckFileName() const - { return deckFileName_; }; - - - /// Read the given stream, overwriting any previous data. Unless - /// the second argument 'convert_to_SI' is false, all fields will - /// be converted to SI units. - void read(std::istream& is, bool convert_to_SI = true); - - /// Convert all data to SI units, according to unit category as - /// specified in the eclipse file (METRIC, FIELD etc.). - /// It is unnecessary to call this if constructed with - /// 'convert_to_SI' equal to true, but it is not an error. - void convertToSI(); - - /// Returns true if the given keyword corresponds to a field that - /// was found in the file. - bool hasField(const std::string& keyword) const; - /// Returns true if all the given keywords correspond to fields - /// that were found in the file. - bool hasFields(const std::vector& keywords) const; - /// The keywords/fields found in the file. - std::vector fieldNames() const; - - /// Returns the number of distinct epochs found in the deck SCHEDULE. - int numberOfEpochs() const; - - /// Sets the current epoch. - /// Valid arguments are in [0, ..., numberOfEpochs() - 1]. - /// After reading, current epoch always starts at 0. - void setCurrentEpoch(int epoch); - - /// Returns the start_date_ - boost::gregorian::date getStartDate() const; - - /// Returns a reference to a vector containing the values - /// corresponding to the given integer keyword. - const std::vector& getIntegerValue(const std::string& keyword) const; - - /// Returns a reference to a vector containing the values - /// corresponding to the given floating-point keyword. - const std::vector& getFloatingPointValue(const std::string& keyword) const; - - /// Returns a reference to a vector containing the values - /// corresponding to the given keyword of a type only known - /// indirectly (through a template) - /// - /// \tparam T Type of the keyword's value. Currently only int - /// and double are supported. - template - const std::vector& getValue(const std::string& keyword) const; - - typedef std::shared_ptr SpecialFieldPtr; - - /// Returns a reference to a vector containing pointers to the values - /// corresponding to the given keyword when the values are not only integers - /// or floats. - const SpecialFieldPtr getSpecialValue(const std::string& keyword) const; - - // This macro implements support for a special field keyword. It requires that a subclass - // of SpecialBase exists, that has the same name as the keyword. - // After using SPECIAL_FIELD(KEYWORD), the public member getKEYWORD will be available. -#define SPECIAL_FIELD(keyword) \ -private: \ - struct X##keyword { X##keyword() { Factory::addCreator(#keyword); } }; \ - X##keyword x##keyword; \ -public: \ - const keyword& get##keyword() const \ - { return dynamic_cast(*getSpecialValue(#keyword)); } - - // Support for special fields. - SPECIAL_FIELD(SPECGRID) - SPECIAL_FIELD(FAULTS) - SPECIAL_FIELD(MULTFLT) - SPECIAL_FIELD(TITLE) - SPECIAL_FIELD(START) - SPECIAL_FIELD(DATES) - SPECIAL_FIELD(DENSITY) - SPECIAL_FIELD(PVDG) - SPECIAL_FIELD(PVDO) - SPECIAL_FIELD(PVTG) - SPECIAL_FIELD(PVTO) - SPECIAL_FIELD(PVTW) - SPECIAL_FIELD(SGOF) - SPECIAL_FIELD(SWOF) - SPECIAL_FIELD(ROCK) - SPECIAL_FIELD(ROCKTAB) - SPECIAL_FIELD(WELSPECS) - SPECIAL_FIELD(COMPDAT) - SPECIAL_FIELD(WCONINJE) - SPECIAL_FIELD(WCONPROD) - SPECIAL_FIELD(WELTARG) - SPECIAL_FIELD(WELOPEN) - SPECIAL_FIELD(EQUIL) - SPECIAL_FIELD(PVCDO) - SPECIAL_FIELD(TSTEP) - SPECIAL_FIELD(PLYVISC) - SPECIAL_FIELD(PLYROCK) - SPECIAL_FIELD(PLYADS) - SPECIAL_FIELD(PLYMAX) - SPECIAL_FIELD(PLYSHEAR) - SPECIAL_FIELD(TLMIXPAR) - SPECIAL_FIELD(WPOLYMER) - SPECIAL_FIELD(GRUPTREE) - SPECIAL_FIELD(GCONINJE) - SPECIAL_FIELD(GCONPROD) - SPECIAL_FIELD(WGRUPCON) - SPECIAL_FIELD(ENDSCALE) - SPECIAL_FIELD(SCALECRS) - SPECIAL_FIELD(ENPTVD) - SPECIAL_FIELD(ENKRVD) - - // The following fields only have a dummy implementation - // that allows us to ignore them. - SPECIAL_FIELD(SWFN) - SPECIAL_FIELD(SOF2) - SPECIAL_FIELD(TUNING) - -#undef SPECIAL_FIELD - - - /// Sets an integer field to have a particular value. - void setIntegerField(const std::string& keyword, const std::vector& field); - - /// Sets a floating point field to have a particular value. - void setFloatingPointField(const std::string& keyword, const std::vector& field); - - /// Sets a special field to have a particular value. - void setSpecialField(const std::string& keyword, SpecialFieldPtr field); - - /// Compute the units used by the deck, depending on the presence - /// of keywords such as METRIC, FIELD etc. It is an error to call - /// this after conversion to SI has taken place. - void computeUnits(); - - /// The units specified by the eclipse file read. - const EclipseUnits& units() const; - - struct grdecl get_grdecl() const; - - /// Save grid parts of deck in EGRID format. - void saveEGRID(const std::string & filename, int num_cells , const int * global_cell) const; - -#ifdef HAVE_ERT - //void saveEGRID_INIT( const std::string& output_dir , const std::string& basename, bool fmt_file = false); - void saveINIT( const std::string & filename , const ecl_grid_type * ecl_grid); - void saveEGRID_INIT( const std::string& output_dir , const std::string& basename, bool fmt_file); - ecl_grid_type * newGrid( ); -#endif - - -private: - -#ifdef HAVE_ERT - ecl_kw_type * newEclKW(const std::string &keyword , ecl_type_enum ecl_type) const; - void save_kw( fortio_type * fortio , const std::string & kw , ecl_type_enum ecl_type); -#endif - - SpecialFieldPtr createSpecialField(std::istream& is, const std::string& fieldname); - SpecialFieldPtr cloneSpecialField(const std::string& fieldname, - const std::shared_ptr original); - void readImpl(std::istream& is); - void getNumericErtFields(const std::string& filename); - - std::string deckFileName_; - std::string directory_; - std::map > integer_field_map_; - std::map > floating_field_map_; - // std::map special_field_map_; - std::set ignored_fields_; - EclipseUnits units_; - - // For SCHEDULE handling. - enum ReadingMode { Regular, Timesteps }; - ReadingMode current_reading_mode_; - boost::gregorian::date start_date_; - double current_time_days_; - int current_epoch_; - typedef std::map SpecialMap; - std::vector special_field_by_epoch_; -}; - - - -} // namespace Opm - -#endif // OPM_ECLIPSEGRIDPARSER_HEADER diff --git a/opm/core/io/eclipse/EclipseGridParserHelpers.hpp b/opm/core/io/eclipse/EclipseGridParserHelpers.hpp deleted file mode 100644 index 985c27f6..00000000 --- a/opm/core/io/eclipse/EclipseGridParserHelpers.hpp +++ /dev/null @@ -1,465 +0,0 @@ -//=========================================================================== -// -// File: EclipseGridParserHelpers.hpp -// -// Created: Tue Dec 22 11:35:32 2009 -// -// Author(s): Atgeirr F Rasmussen -// B�rd Skaflestad -// -// $Date$ -// -// $Revision$ -// -//=========================================================================== - -/* - Copyright 2009, 2010 SINTEF ICT, Applied Mathematics. - Copyright 2009, 2010 Statoil ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef OPM_ECLIPSEGRIDPARSERHELPERS_HEADER -#define OPM_ECLIPSEGRIDPARSERHELPERS_HEADER - -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace Opm -{ - -namespace -{ - - inline std::istream& ignoreLine(std::istream& is) - { - is.ignore(std::numeric_limits::max(), '\n'); - return is; - } - - inline std::istream& ignoreSlashLine(std::istream& is) - { - is.ignore(std::numeric_limits::max(), '/'); - is.ignore(std::numeric_limits::max(), '\n'); - return is; - } - - inline std::istream& ignoreWhitespace(std::istream& is) - { - // Getting the character type facet for is() - // We use the classic (i.e. C) locale. - const std::ctype& ct = std::use_facet< std::ctype >(std::locale::classic()); - char c; - while (is.get(c)) { - if (!ct.is(std::ctype_base::space, c)) { - is.putback(c); - break; - } - } - return is; - } - - inline std::string readString(std::istream& is) - { - std::string string_candidate; - is >> string_candidate; - const char quote('\''); - int beg = string_candidate[0] == quote ? 1 : 0; - int len = string_candidate[0] == quote ? string_candidate.size() - 2 : string_candidate.size(); - return string_candidate.substr(beg, len); - } - - // Reads data until '/' or an error is encountered. - template - inline void readVectorData(std::istream& is, std::vector& data) - { - data.clear(); - while (is) { - T candidate; - is >> candidate; - if (is.rdstate() & std::ios::failbit) { - is.clear(is.rdstate() & ~std::ios::failbit); - is >> ignoreWhitespace; - char dummy; - is >> dummy; - if (dummy == '/') { - is >> ignoreLine; - break; - } else if (dummy == '-') { // "comment test" - is >> ignoreLine; // This line is a comment - } else { - char buffer[1000]; - is.getline(buffer, sizeof(buffer)); - std::cout << buffer< - inline int readDefaultedVectorData(std::istream& is, Vec& data, int max_values) - { - assert(int(data.size()) >= max_values); - const std::ctype& ct = std::use_facet< std::ctype >(std::locale::classic()); - int num_values = 0; - while (is) { - typename Vec::value_type candidate; - is >> candidate; - if (is.rdstate() & std::ios::failbit) { - is.clear(is.rdstate() & ~std::ios::failbit); - std::string dummy; - is >> dummy; - if (dummy == "/") { - is >> ignoreLine; - break; - } else if (dummy[0] == '-') { // "comment test" - is >> ignoreLine; // This line is a comment - } else { - OPM_THROW(std::runtime_error, "Encountered format error while reading data values. Value = " << dummy); - } - } else { - if (is.peek() == int('*')) { - is.ignore(); // ignore the '*' - int multiplier = (int)candidate; - if (ct.is(std::ctype_base::space, is.peek())) { - num_values += multiplier; // Use default value(s) - } else { - is >> candidate; // Use candidate 'multipler' times - for (int i=0; i= max_values) { - //is >> ignoreLine; - break; - } - } - if (!is) { - OPM_THROW(std::runtime_error, "Encountered error while reading data values."); - } - return num_values; - } - - - // Keywords SGOF and SWOF. Reads data until '/' or an error is encountered. - // Default values represented by 1* is replaced by -1. Use linear interpolation - // outside this function to replace -1. - template - inline void readRelPermTable(std::istream& is, std::vector& data) - { - data.clear(); - while (is) { - T candidate; - is >> candidate; - if (is.rdstate() & std::ios::failbit) { - is.clear(is.rdstate() & ~std::ios::failbit); - std::string dummy; - is >> dummy; - if (dummy == "/") { - is >> ignoreLine; - break; - } else if (dummy[0] == '-') { // "comment test" - is >> ignoreLine; // This line is a comment - } else { - OPM_THROW(std::runtime_error, "Encountered format error while reading data values. Value = " << dummy); - } - } else { - if (is.peek() == int('*')) { - is.ignore(); // ignore the '*' - assert(int(candidate) == 1); - data.push_back(-1); // Set new flag for interpolation. - } else { - data.push_back(candidate); - } - } - } - if (!is) { - OPM_THROW(std::runtime_error, "Encountered error while reading data values."); - } - } - - - // Returns month number 1-12. Returns 0 if illegal month name. - inline int getMonthNumber(const std::string& month_name) - { - const int num_months = 12; - std::string months[num_months] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", - "JLY", "AUG", "SEP", "OCT", "NOV", "DEC"}; - if (month_name == "JUL") { - return 7; // "JUL" is an acceptable alternative to 'JLY' - } - int m = 0; - for (int i=0; i> ignoreLine; // This line is a comment - } - int day, year; - std::string month_name; - is >> day; - month_name = readString(is); - is >> year; - ignoreSlashLine(is); - int month = getMonthNumber(month_name); - - return boost::gregorian::date(boost::gregorian::greg_year(year), - boost::gregorian::greg_month(month), - boost::gregorian::greg_day(day)); - } - - // Get first character after whitespace and comments, and decide - // next action. - // NB! Will fail for negative number in column one. - inline int next_action(std::istream& is) - { - int task(0); // 0:continue 1:return 2:throw - const std::ctype& ct = - std::use_facet< std::ctype >(std::locale::classic()); - - while (!is.eof()) { - is >> ignoreWhitespace; - char c; - is.get(c); - if (is.eof()) { - return task; - } - is.putback(c); - if (ct.is(std::ctype_base::digit, c) || c== '.') { - task = 0; // Decimal digit. Read more data. - break; - } - if (ct.is(std::ctype_base::alpha, c)) { - task = 1; // Alphabetic char. Read next keyword. - break; - } - if (c == '-') { - is >> ignoreLine; // This line is a comment - } else { - task = 2; // Read error. Unexpected character. - break; - } - } - return task; - } - - // Reads keywords PVTG, PVTO - typedef std::vector > > table_t; - inline void readPvtTable(std::istream& is, table_t& pvt_table, - const std::string& field_name) - { - const std::ctype& ct = - std::use_facet< std::ctype >(std::locale::classic()); - std::vector record; - std::vector > table; - while (!is.eof()) { - record.clear(); - readVectorData(is, record); - table.push_back(record); - while (!is.eof()) { - is >> ignoreWhitespace; - char c; - is.get(c); - if (is.eof()) { - // Reached end of file, we should have pushed - // the last table, and emptied it. If not, - // we have an error. - if (!table.empty()) { - OPM_THROW(std::runtime_error, "Reached EOF while still building PVT table. Missing end-of-table (slash)?"); - } - return; - } - is.putback(c); - if (ct.is(std::ctype_base::digit, c) || c== '.') { - break; // Decimal digit. Read more records. - } - if (ct.is(std::ctype_base::alpha, c)) { - return; // Alphabetic char. Read next keyword. - } - if (c == '-') { - is >> ignoreLine; // This line is a comment - continue; - } - if (c == '/') { - is >> ignoreLine; - pvt_table.push_back(table); - table.clear(); - } else { - std::ostringstream oss; - oss << "Error reading " << field_name - << ". Next character is " << (char)is.peek(); - OPM_THROW(std::runtime_error, oss.str()); - } - } - } - } - - // Reads keywords PVDG, PVDO, ROCKTAB - inline void readPvdTable(std::istream& is, table_t& pvd_table, - const std::string& field_name, int ncol) - { - std::vector record; - std::vector > table(ncol); - while (!is.eof()) { - record.clear(); - readVectorData(is, record); - const int rec_size = record.size()/ncol; - for (int k=0; k >& table, - int ncol, - double defaultOut = 0.0, - bool defaultInterpolation = true) - { - const int sz = table[0].size(); - for (int k=1; k indx; - std::vector x; - for (int i=0; i xv, yv; - for (int i=0; i record; - std::vector > table(ncol); - while (!is.eof()) { - record.clear(); - readRelPermTable(is, record); - const int rec_size = record.size()/ncol; - for (int k=0; k #include +#include +#include #include #include #include @@ -413,20 +415,20 @@ private: }; /// Get dimensions of the grid from the parse of the input file -std::vector parserDim (Opm::DeckConstPtr newParserDeck) { +std::vector parserDim (Opm::DeckConstPtr deck) { std::vector dim(/* n = */ 3); // dimensions explicitly given - if (newParserDeck->hasKeyword("SPECGRID")) { - SpecgridWrapper specgrid(newParserDeck->getKeyword("SPECGRID")); + if (deck->hasKeyword("SPECGRID")) { + SpecgridWrapper specgrid(deck->getKeyword("SPECGRID")); dim = specgrid.numBlocksVector(); } // dimensions implicitly given by number of deltas - else if (newParserDeck->hasKeyword("DXV")) { - assert(newParserDeck->hasKeyword("DYV")); - assert(newParserDeck->hasKeyword("DZV")); - dim[0] = newParserDeck->getKeyword("DXV")->getRawDoubleData().size(); - dim[1] = newParserDeck->getKeyword("DYV")->getRawDoubleData().size(); - dim[2] = newParserDeck->getKeyword("DZV")->getRawDoubleData().size(); + else if (deck->hasKeyword("DXV")) { + assert(deck->hasKeyword("DYV")); + assert(deck->hasKeyword("DZV")); + dim[0] = deck->getKeyword("DXV")->getRawDoubleData().size(); + dim[1] = deck->getKeyword("DYV")->getRawDoubleData().size(); + dim[2] = deck->getKeyword("DZV")->getRawDoubleData().size(); } else { OPM_THROW(std::runtime_error, @@ -461,9 +463,9 @@ struct EclipseRestart : public EclipseHandle { void writeHeader (const SimulatorTimer& timer, int outputStepIdx, const PhaseUsage uses, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, const int num_active_cells) { - const std::vector dim = parserDim (newParserDeck); + const std::vector dim = parserDim (deck); ecl_rst_file_fwrite_header (*this, outputStepIdx, timer.currentPosixTime(), @@ -505,29 +507,29 @@ private: */ struct EclipseWriterGrid : public EclipseHandle { /// Create a grid based on the keywords available in input file - static EclipseWriterGrid make (Opm::DeckConstPtr newParserDeck, + static EclipseWriterGrid make (Opm::DeckConstPtr deck, int number_of_cells, const int* cart_dims, const int* global_cell) { - if (newParserDeck->hasKeyword("DXV")) { + if (deck->hasKeyword("DXV")) { // make sure that the DYV and DZV keywords are present if the // DXV keyword is used in the deck... - assert(newParserDeck->hasKeyword("DYV")); - assert(newParserDeck->hasKeyword("DZV")); + assert(deck->hasKeyword("DYV")); + assert(deck->hasKeyword("DZV")); - const auto& dxv = newParserDeck->getKeyword("DXV")->getSIDoubleData(); - const auto& dyv = newParserDeck->getKeyword("DYV")->getSIDoubleData(); - const auto& dzv = newParserDeck->getKeyword("DZV")->getSIDoubleData(); + const auto& dxv = deck->getKeyword("DXV")->getSIDoubleData(); + const auto& dyv = deck->getKeyword("DYV")->getSIDoubleData(); + const auto& dzv = deck->getKeyword("DZV")->getSIDoubleData(); return EclipseWriterGrid (dxv, dyv, dzv); } - else if (newParserDeck->hasKeyword("ZCORN")) { + else if (deck->hasKeyword("ZCORN")) { struct grdecl g; - GridManager::createGrdecl(newParserDeck, g); + GridManager::createGrdecl(deck, g); - auto coordData = getAllSiDoubles_(newParserDeck->getKeyword(COORD_KW)); - auto zcornData = getAllSiDoubles_(newParserDeck->getKeyword(ZCORN_KW)); + auto coordData = getAllSiDoubles_(deck->getKeyword(COORD_KW)); + auto zcornData = getAllSiDoubles_(deck->getKeyword(ZCORN_KW)); EclipseKeyword coord_kw (COORD_KW, coordData); EclipseKeyword zcorn_kw (ZCORN_KW, zcornData); @@ -538,7 +540,7 @@ struct EclipseWriterGrid : public EclipseHandle { EclipseKeyword mapaxes_kw (MAPAXES_KW); if (g.mapaxes) { - auto mapaxesData = getAllSiDoubles_(newParserDeck->getKeyword(MAPAXES_KW)); + auto mapaxesData = getAllSiDoubles_(deck->getKeyword(MAPAXES_KW)); mapaxes_kw = std::move (EclipseKeyword (MAPAXES_KW, mapaxesData)); } @@ -638,13 +640,13 @@ struct EclipseInit : public EclipseHandle { const int* cart_dims, const int* global_cell, const SimulatorTimer& timer, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, const PhaseUsage uses) { - auto dataField = getAllSiDoubles_(newParserDeck->getKeyword(PORO_KW)); + auto dataField = getAllSiDoubles_(deck->getKeyword(PORO_KW)); restrictToActiveCells_(dataField, number_of_cells, global_cell); - EclipseWriterGrid eclGrid = EclipseWriterGrid::make (newParserDeck, number_of_cells, + EclipseWriterGrid eclGrid = EclipseWriterGrid::make (deck, number_of_cells, cart_dims, global_cell); EclipseKeyword poro (PORO_KW, dataField); @@ -697,9 +699,9 @@ struct EclipseSummary : public EclipseHandle { EclipseSummary (const std::string& outputDir, const std::string& baseName, const SimulatorTimer& timer, - Opm::DeckConstPtr newParserDeck) + Opm::DeckConstPtr deck) : EclipseHandle ( - alloc_writer (outputDir, baseName, timer, newParserDeck), + alloc_writer (outputDir, baseName, timer, deck), ecl_sum_free) { } typedef std::unique_ptr var_t; @@ -718,7 +720,7 @@ struct EclipseSummary : public EclipseHandle { } // add rate variables for each of the well in the input file - void addWells (Opm::DeckConstPtr newParserDeck, + void addWells (Opm::DeckConstPtr deck, const PhaseUsage& uses); // no inline implementation of this since it depends on the @@ -753,11 +755,11 @@ private: static ecl_sum_type* alloc_writer (const std::string& outputDir, const std::string& baseName, const SimulatorTimer& timer, - Opm::DeckConstPtr newParserDeck) { + Opm::DeckConstPtr deck) { boost::filesystem::path casePath (outputDir); casePath /= boost::to_upper_copy (baseName); - const std::vector dim = parserDim (newParserDeck); + const std::vector dim = parserDim (deck); return ecl_sum_alloc_writer (casePath.string ().c_str (), false, /* formatted */ true, /* unified */ @@ -777,7 +779,7 @@ private: struct EclipseWellReport : public EclipseHandle { protected: EclipseWellReport (const EclipseSummary& summary, /* section to add to */ - Opm::DeckConstPtr newParserDeck, /* well names */ + Opm::DeckConstPtr deck, /* well names */ int whichWell, /* index of well line */ PhaseUsage uses, /* phases present */ BlackoilPhases::PhaseIndex phase, /* oil, water or gas */ @@ -789,7 +791,7 @@ protected: varName (phase, type, aggregation).c_str (), - wellName (newParserDeck, whichWell).c_str (), + wellName (deck, whichWell).c_str (), /* num = */ 0, unit.c_str(), /* defaultValue = */ 0.)) @@ -818,10 +820,10 @@ private: const double sign_; /// Get the name associated with this well - std::string wellName (Opm::DeckConstPtr newParserDeck, + std::string wellName (Opm::DeckConstPtr deck, int whichWell) { - Opm::WelspecsWrapper welspecs(newParserDeck->getKeyword("WELSPECS")); + Opm::WelspecsWrapper welspecs(deck->getKeyword("WELSPECS")); return welspecs.wellName(whichWell); } @@ -873,13 +875,13 @@ protected: /// Monitors the rate given by a well. struct EclipseWellRate : public EclipseWellReport { EclipseWellRate (const EclipseSummary& summary, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, int whichWell, PhaseUsage uses, BlackoilPhases::PhaseIndex phase, WellType type) : EclipseWellReport (summary, - newParserDeck, + deck, whichWell, uses, phase, @@ -897,13 +899,13 @@ struct EclipseWellRate : public EclipseWellReport { /// Monitors the total production in a well. struct EclipseWellTotal : public EclipseWellReport { EclipseWellTotal (const EclipseSummary& summary, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, int whichWell, PhaseUsage uses, BlackoilPhases::PhaseIndex phase, WellType type) : EclipseWellReport (summary, - newParserDeck, + deck, whichWell, uses, phase, @@ -939,13 +941,13 @@ private: /// Monitors the bottom hole pressure in a well. struct EclipseWellBhp : public EclipseWellReport { EclipseWellBhp (const EclipseSummary& summary, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, int whichWell, PhaseUsage uses, BlackoilPhases::PhaseIndex phase, WellType type) : EclipseWellReport (summary, - newParserDeck, + deck, whichWell, uses, phase, @@ -982,12 +984,12 @@ EclipseSummary::writeTimeStep (const SimulatorTimer& timer, static WellType WELL_TYPES[] = { INJECTOR, PRODUCER }; inline void -EclipseSummary::addWells (Opm::DeckConstPtr newParserDeck, +EclipseSummary::addWells (Opm::DeckConstPtr deck, const PhaseUsage& uses) { // TODO: Only create report variables that are requested with keywords // (e.g. "WOPR") in the input files, and only for those wells that are // mentioned in those keywords - Opm::DeckKeywordConstPtr welspecsKeyword = newParserDeck->getKeyword("WELSPECS"); + Opm::DeckKeywordConstPtr welspecsKeyword = deck->getKeyword("WELSPECS"); const int numWells = welspecsKeyword->size(); for (int phaseCounter = 0; phaseCounter != BlackoilPhases::MaxNumPhases; @@ -1006,7 +1008,7 @@ EclipseSummary::addWells (Opm::DeckConstPtr newParserDeck, // W{O,G,W}{I,P}R add (std::unique_ptr ( new EclipseWellRate (*this, - newParserDeck, + deck, whichWell, uses, phase, @@ -1014,7 +1016,7 @@ EclipseSummary::addWells (Opm::DeckConstPtr newParserDeck, // W{O,G,W}{I,P}T add (std::unique_ptr ( new EclipseWellTotal (*this, - newParserDeck, + deck, whichWell, uses, phase, @@ -1036,7 +1038,7 @@ EclipseSummary::addWells (Opm::DeckConstPtr newParserDeck, } add (std::unique_ptr ( new EclipseWellBhp (*this, - newParserDeck, + deck, whichWell, uses, phase, @@ -1055,7 +1057,7 @@ void EclipseWriter::writeInit(const SimulatorTimer &timer) return; } /* Grid files */ - EclipseWriterGrid eclGrid = EclipseWriterGrid::make (newParserDeck_, number_of_cells_, + EclipseWriterGrid eclGrid = EclipseWriterGrid::make (deck_, number_of_cells_, cart_dims_, global_cell_); eclGrid.write (outputDir_, baseName_, /*stepIdx=*/0); @@ -1064,35 +1066,35 @@ void EclipseWriter::writeInit(const SimulatorTimer &timer) cart_dims_, global_cell_, timer, - newParserDeck_, + deck_, uses_); - if (newParserDeck_->hasKeyword("PERM")) { - auto data = getAllSiDoubles_(newParserDeck_->getKeyword("PERM")); + if (deck_->hasKeyword("PERM")) { + auto data = getAllSiDoubles_(deck_->getKeyword("PERM")); convertUnit_(data, toMilliDarcy); fortio.writeKeyword ("PERM", data); } - if (newParserDeck_->hasKeyword("PERMX")) { - auto data = getAllSiDoubles_(newParserDeck_->getKeyword("PERMX")); + if (deck_->hasKeyword("PERMX")) { + auto data = getAllSiDoubles_(deck_->getKeyword("PERMX")); convertUnit_(data, toMilliDarcy); fortio.writeKeyword ("PERMX", data); } - if (newParserDeck_->hasKeyword("PERMY")) { - auto data = getAllSiDoubles_(newParserDeck_->getKeyword("PERMY")); + if (deck_->hasKeyword("PERMY")) { + auto data = getAllSiDoubles_(deck_->getKeyword("PERMY")); convertUnit_(data, toMilliDarcy); fortio.writeKeyword ("PERMY", data); } - if (newParserDeck_->hasKeyword("PERMZ")) { - auto data = getAllSiDoubles_(newParserDeck_->getKeyword("PERMZ")); + if (deck_->hasKeyword("PERMZ")) { + auto data = getAllSiDoubles_(deck_->getKeyword("PERMZ")); convertUnit_(data, toMilliDarcy); fortio.writeKeyword ("PERMZ", data); } /* Create summary object (could not do it at construction time, since it requires knowledge of the start time). */ - summary_.reset(new EclipseSummary(outputDir_, baseName_, timer, newParserDeck_)); - summary_->addWells (newParserDeck_, uses_); + summary_.reset(new EclipseSummary(outputDir_, baseName_, timer, deck_)); + summary_->addWells (deck_, uses_); } void EclipseWriter::writeTimeStep(const SimulatorTimer& timer, @@ -1112,7 +1114,7 @@ void EclipseWriter::writeTimeStep(const SimulatorTimer& timer, // start writing to files EclipseRestart rst(outputDir_, baseName_, timer, outputTimeStepIdx_); - rst.writeHeader (timer, outputTimeStepIdx_, uses_, newParserDeck_, reservoirState.pressure().size ()); + rst.writeHeader (timer, outputTimeStepIdx_, uses_, deck_, reservoirState.pressure().size ()); EclipseSolution sol (rst); // write out the pressure of the reference phase (whatever @@ -1192,29 +1194,29 @@ void EclipseWriter::writeTimeStep( EclipseWriter::EclipseWriter ( const ParameterGroup& params, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, int dimensions) - : newParserDeck_ (newParserDeck) + : deck_ (deck) , number_of_cells_(number_of_cells) , dimensions_(dimensions) , cart_dims_(cart_dims) , global_cell_(global_cell) - , uses_ (phaseUsageFromDeck (newParserDeck_)) { + , uses_ (phaseUsageFromDeck (deck_)) { init(params); } EclipseWriter::EclipseWriter ( const ParameterGroup& params, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, std::shared_ptr grid) - : newParserDeck_ (newParserDeck) + : deck_ (deck) , grid_(grid) , number_of_cells_(grid->number_of_cells) , dimensions_(grid->dimensions) , cart_dims_(grid->cartdims) , global_cell_(grid->global_cell) - , uses_ (phaseUsageFromDeck (newParserDeck_)) { + , uses_ (phaseUsageFromDeck (deck_)) { init(params); } void EclipseWriter::init(const ParameterGroup& params) diff --git a/opm/core/io/eclipse/EclipseWriter.hpp b/opm/core/io/eclipse/EclipseWriter.hpp index 0f723f0e..db6584b0 100644 --- a/opm/core/io/eclipse/EclipseWriter.hpp +++ b/opm/core/io/eclipse/EclipseWriter.hpp @@ -59,7 +59,7 @@ public: * binary files using ERT. */ EclipseWriter(const parameter::ParameterGroup& params, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, std::shared_ptr grid); /*! @@ -67,7 +67,7 @@ public: * binary files using ERT. */ EclipseWriter(const parameter::ParameterGroup& params, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, int dimension); @@ -103,7 +103,7 @@ public: const WellState& wellState); private: - Opm::DeckConstPtr newParserDeck_; + Opm::DeckConstPtr deck_; std::shared_ptr grid_; int number_of_cells_; int dimensions_; diff --git a/opm/core/io/eclipse/SpecialEclipseFields.hpp b/opm/core/io/eclipse/SpecialEclipseFields.hpp deleted file mode 100644 index 6dc46ff9..00000000 --- a/opm/core/io/eclipse/SpecialEclipseFields.hpp +++ /dev/null @@ -1,2520 +0,0 @@ -//=========================================================================== -// -// File: SpecialEclipseFields.hpp -// -// Created: Mon Sep 21 14:09:54 2009 -// -// Author(s): Atgeirr F Rasmussen -// Bård Skaflestad -// Bjørn Spjelkavik -// -// $Date$ -// -// $Revision$ -// -//=========================================================================== - -/* - Copyright 2009, 2010 SINTEF ICT, Applied Mathematics. - Copyright 2009, 2010 Statoil ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef OPM_SPECIALECLIPSEFIELDS_HEADER -#define OPM_SPECIALECLIPSEFIELDS_HEADER - -#include -#include -#include - -#include -#include -#include -#include - -namespace Opm -{ - -// Abstract base class for special fields. -struct SpecialBase { - virtual ~SpecialBase() {} // Default destructor - //virtual std::string name() const = 0; // Keyword name - virtual void read(std::istream& is) = 0; // Reads data - //virtual void write(std::ostream& os) const = 0; // Writes data - virtual void convertToSI(const EclipseUnits&) - { - OPM_THROW(std::runtime_error, "Default conversion not defined."); - } - typedef std::vector > > table_t; -}; - - - - -/// Class for keyword SPECGRID -struct SPECGRID : public SpecialBase -{ - std::vector dimensions; // Number of grid blocks in x-, y- and z-directions. - int numres; // Number of reservoirs. - char qrdial; // Coordinates. F=cartesian, T=Cylindrical(radial). - - SPECGRID() - { - dimensions.resize(3,1); - numres = 1; - qrdial = 'F'; - } - - virtual ~SPECGRID() - { - } - - virtual std::string name() const {return std::string("SPECGRID");} - - virtual void read(std::istream& is) - { - const int ndim = 3; - std::vector data(ndim+1,1); - int nread = readDefaultedVectorData(is , data, ndim+1); - int nd = std::min(nread, ndim); - copy(data.begin(), data.begin()+nd, &dimensions[0]); - numres = data[ndim]; - std::string candidate; - is >> candidate; - if (candidate == "/") { - return; - } else { - qrdial = candidate[0]; - } - - if (ignoreSlashLine(is)) { - return; - } else { - OPM_THROW(std::runtime_error, "End of file reading" << name()); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - os << dimensions[0] << " " << dimensions[1] << " " - << dimensions[2] << " " << numres << " " << qrdial << std::endl; - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits&) - {} -}; - - - - -/// Class holding segment data of keyword FAULTS. -struct FaultSegment -{ - std::string fault_name; // Fault name - std::vector ijk_coord; // ijk-coordinates of segment cells - std::string face; // Fault face of cells -}; - -/// Class for keyword FAULTS. -struct FAULTS : public SpecialBase -{ - std::vector faults; - - FAULTS() - { - } - - virtual ~FAULTS() - { - } - - virtual std::string name() const {return std::string("FAULTS");} - - virtual void read(std::istream& is) - { - while(is) { - std::string fltname; - is >> fltname; - if (fltname[0] == '/') { - is >> ignoreLine; - break; - } - while (fltname.find("--") == 0) { - // This line is a comment - is >> ignoreLine >> fltname; - } - FaultSegment fault_segment; - fault_segment.ijk_coord.resize(6); - fault_segment.fault_name = fltname; - int nread = readDefaultedVectorData(is, fault_segment.ijk_coord, 6); - if (nread != 6) { - OPM_THROW(std::runtime_error, "Error reading fault_segment " << fltname); - } - is >> fault_segment.face; - faults.push_back(fault_segment); - ignoreSlashLine(is); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)faults.size(); ++i) { - os << faults[i].fault_name << " "; - copy(faults[i].ijk_coord.begin(), faults[i].ijk_coord.end(), - std::ostream_iterator(os, " ")); - os << faults[i].face << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits&) - {} -}; - - - - -/// Class holding a data line of keyword MULTFLT -struct MultfltLine -{ - std::string fault_name; // Fault name, as in FAULTS - double transmis_multiplier; // Transmissibility multiplier - double diffusivity_multiplier; // Diffusivity multiplier; - MultfltLine() : - fault_name(""), transmis_multiplier(1.0), diffusivity_multiplier(1.0) - {} -}; - -/// Class for keyword MULFLT -struct MULTFLT : public SpecialBase -{ - std::vector multflts; - - MULTFLT() - { - } - - virtual ~MULTFLT() - {} - - virtual std::string name() const {return std::string("MULTFLT");} - - virtual void read(std::istream& is) - { - while(is) { - std::string fltname; - is >> fltname; - if (fltname[0] == '/') { - is >> ignoreLine; - break; - } - while (fltname == "--") { - // This line is a comment - is >> ignoreLine >> fltname; - } - MultfltLine multflt_line; - multflt_line.fault_name = fltname; - std::vector data(2,1.0); - if (readDefaultedVectorData(is, data, 2) == 2) { - ignoreSlashLine(is); - } - multflt_line.transmis_multiplier = data[0]; - multflt_line.diffusivity_multiplier = data[1]; - multflts.push_back(multflt_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)multflts.size(); ++i) { - os << multflts[i].fault_name << " " - << multflts[i].transmis_multiplier << " " - << multflts[i].diffusivity_multiplier << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits&) - {} -}; - - - - -struct TITLE : public SpecialBase -{ - std::string title; - virtual std::string name() const - { return std::string("TITLE"); } - virtual void read(std::istream& is) - { is >> ignoreLine; std::getline(is, title); } - virtual void write(std::ostream& os) const - { os << name() << '\n' << title << '\n'; } - virtual void convertToSI(const EclipseUnits&) - {} -}; - - - - -struct START : public SpecialBase -{ - boost::gregorian::date date; - virtual std::string name() const - { return std::string("START"); } - virtual void read(std::istream& is) - { date = readDate(is); } - virtual void write(std::ostream& os) const - { os << name() << '\n' << date << '\n'; } - virtual void convertToSI(const EclipseUnits&) - {} -}; - -struct GRUPTREE : public SpecialBase { - std::map tree; - - virtual std::string name() const { - return std::string("GRUPTREE"); - } - - virtual void read(std::istream & is) { - while (!is.eof()) { - std::string child = readString(is); - is >> ignoreWhitespace; - std::string parent = readString(is); - - std::cout << "CHILD = " << child << std::endl << "PARENT = " << parent << std::endl; - tree[child] = parent; - - is >> ignoreSlashLine; - is >> ignoreWhitespace; - if(is.peek() == int('/')) { - is >> ignoreSlashLine; - return; - } - } - } - - virtual void write(std::ostream & os) { - for(std::map::iterator it = tree.begin(); it != tree.end(); ++it) { - os << it->first << " "<< it->second<< std::endl; - } - } - - virtual void convertToSI(const EclipseUnits&) { - } -}; - - -struct DATES : public SpecialBase -{ - std::vector dates; - virtual std::string name() const - { return std::string("DATES"); } - virtual void read(std::istream& is) - { - while(is) { - dates.push_back(readDate(is)); - is >> ignoreWhitespace; - if (is.peek() == int('/')) { - is >> ignoreLine; - break; - } - } - } - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - copy(dates.begin(), dates.end(), - std::ostream_iterator(os, "\n")); - } - virtual void convertToSI(const EclipseUnits&) - {} -}; - - -struct DENSITY : public SpecialBase -{ - std::vector > densities_; - - virtual std::string name() const {return std::string("DENSITY");} - - virtual void read(std::istream& is) - { - while (!is.eof()) { - std::vector density(3,-1e100); - if (readDefaultedVectorData(is, density, 3) == 3) { - ignoreSlashLine(is); - } - densities_.push_back(density); - - int action = next_action(is); // 0:continue 1:return 2:throw - if (action == 1) { - return; // Alphabetic char. Read next keyword. - } else if (action == 2) { - OPM_THROW(std::runtime_error, "Error reading DENSITY. Next character is " - << (char)is.peek()); - } - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)densities_.size(); ++i) { - os << densities_[i][0] << " " << densities_[i][1] << " " - << densities_[i][2] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)densities_.size(); ++i) { - densities_[i][0] *= units.density; - densities_[i][1] *= units.density; - densities_[i][2] *= units.density; - } - } -}; - -struct PVDG : public SpecialBase -{ - table_t pvdg_; - - virtual std::string name() const {return std::string("PVDG");} - - virtual void read(std::istream& is) - { - readPvdTable(is, pvdg_, name(), 3); - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int rn=0; rn<(int)pvdg_.size(); ++rn) { - for (int i=0; i<(int)pvdg_[rn][0].size(); ++i) { - os << pvdg_[rn][0][i] << " " << pvdg_[rn][1][i] << " " - << pvdg_[rn][2][i] << '\n'; - } - os << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double volfac = units.gasvol_r/units.gasvol_s; - for (int rn=0; rn<(int)pvdg_.size(); ++rn) { - for (int i=0; i<(int)pvdg_[rn][0].size(); ++i) { - pvdg_[rn][0][i] *= units.pressure; - pvdg_[rn][1][i] *= volfac; - pvdg_[rn][2][i] *= units.viscosity; - } - } - } -}; - -struct PVDO : public SpecialBase -{ - table_t pvdo_; - - virtual std::string name() const {return std::string("PVDO");} - - virtual void read(std::istream& is) - { - readPvdTable(is, pvdo_, name(), 3); - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int rn=0; rn<(int)pvdo_.size(); ++rn) { - for (int i=0; i<(int)pvdo_[rn][0].size(); ++i) { - os << pvdo_[rn][0][i] << " " << pvdo_[rn][1][i] << " " - << pvdo_[rn][2][i] << '\n'; - } - os << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double volfac = units.liqvol_r/units.liqvol_s; - for (int rn=0; rn<(int)pvdo_.size(); ++rn) { - for (int i=0; i<(int)pvdo_[rn][0].size(); ++i) { - pvdo_[rn][0][i] *= units.pressure; - pvdo_[rn][1][i] *= volfac; - pvdo_[rn][2][i] *= units.viscosity; - } - } - } -}; - -struct PVTG : public SpecialBase -{ - table_t pvtg_; - - virtual std::string name() const {return std::string("PVTG");} - - virtual void read(std::istream& is) - { - readPvtTable(is, pvtg_, name()); - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int rn=0; rn<(int)pvtg_.size(); ++rn) { - for (int i=0; i<(int)pvtg_[rn].size(); ++i) { - int nl = (pvtg_[rn][i].size()-1) / 3; - os << pvtg_[rn][i][0] << " " << pvtg_[rn][i][1] << " " - << pvtg_[rn][i][2] << " " << pvtg_[rn][i][3] << '\n'; - for (int j=1, n=3; j > pvtw_; - - virtual std::string name() const {return std::string("PVTW");} - - virtual void read(std::istream& is) - { - while (!is.eof()) { - std::vector pvtw; - readVectorData(is, pvtw); - if (pvtw.size() == 4) { - pvtw.push_back(0.0); // Not used by frontsim - } - pvtw_.push_back(pvtw); - - int action = next_action(is); // 0:continue 1:return 2:throw - if (action == 1) { - return; // Alphabetic char. Read next keyword. - } else if (action == 2) { - OPM_THROW(std::runtime_error, "Error reading PVTW. Next character is " - << (char)is.peek()); - } - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)pvtw_.size(); ++i) { - os << pvtw_[i][0] << " " << pvtw_[i][1] << " " << pvtw_[i][2] - << " " << pvtw_[i][3] << " " << pvtw_[i][4] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double volfac = units.liqvol_r/units.liqvol_s; - for (int i=0; i<(int)pvtw_.size(); ++i) { - pvtw_[i][0] *= units.pressure; - pvtw_[i][1] *= volfac; - pvtw_[i][2] *= units.compressibility; - pvtw_[i][3] *= units.viscosity; - pvtw_[i][4] *= units.compressibility; - } - } -}; - - -struct ROCK : public SpecialBase -{ - std::vector > rock_compressibilities_; - - virtual std::string name() const {return std::string("ROCK");} - - virtual void read(std::istream& is) - { - while (!is.eof()) { - std::vector rock; - readVectorData(is, rock); - rock_compressibilities_.push_back(rock); - - int action = next_action(is); // 0:continue 1:return 2:throw - if (action == 1) { - return; // Alphabetic char. Read next keyword. - } else if (action == 2) { - OPM_THROW(std::runtime_error, "Error reading ROCK. Next character is " - << (char)is.peek()); - } - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)rock_compressibilities_.size(); ++i) { - os << rock_compressibilities_[i][0] << " " - << rock_compressibilities_[i][1] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)rock_compressibilities_.size(); ++i) { - rock_compressibilities_[i][0] *= units.pressure; - rock_compressibilities_[i][1] *= units.compressibility; - } - } -}; - - -struct ROCKTAB : public SpecialBase -{ - table_t rocktab_; - - virtual std::string name() const {return std::string("ROCKTAB");} - - virtual void read(std::istream& is) - { - readPvdTable(is, rocktab_, name(), 3); - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int rn=0; rn<(int)rocktab_.size(); ++rn) { - for (int i=0; i<(int)rocktab_[rn][0].size(); ++i) { - os << rocktab_[rn][0][i] << " " << rocktab_[rn][1][i] << " " - << rocktab_[rn][2][i] << '\n'; - } - os << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int rn=0; rn<(int)rocktab_.size(); ++rn) { - for (int i=0; i<(int)rocktab_[rn][0].size(); ++i) { - rocktab_[rn][0][i] *= units.pressure; - } - } - } -}; - - -struct SGOF : public SpecialBase -{ - table_t sgof_; - - virtual std::string name() const {return std::string("SGOF");} - - virtual void read(std::istream& is) {readSGWOF(is, sgof_, name(), 4);} - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int rn=0; rn<(int)sgof_.size(); ++rn) { - for (int i=0; i<(int)sgof_[rn][0].size(); ++i) { - os << sgof_[rn][0][i] << " " << sgof_[rn][1][i] << " " - << sgof_[rn][2][i] << " " << sgof_[rn][3][i] << '\n'; - } - os << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int rn=0; rn<(int)sgof_.size(); ++rn) { - for (int i=0; i<(int)sgof_[rn][0].size(); ++i) { - sgof_[rn][3][i] *= units.pressure; - } - } - } -}; - -struct SWOF : public SpecialBase -{ - table_t swof_; - - virtual std::string name() const {return std::string("SWOF");} - - virtual void read(std::istream& is) {readSGWOF(is, swof_, name(), 4);} - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int rn=0; rn<(int)swof_.size(); ++rn) { - for (int i=0; i<(int)swof_[rn][0].size(); ++i) { - os << swof_[rn][0][i] << " " << swof_[rn][1][i] << " " - << swof_[rn][2][i] << " " << swof_[rn][3][i] << '\n'; - } - os << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int rn=0; rn<(int)swof_.size(); ++rn) { - for (int i=0; i<(int)swof_[rn][0].size(); ++i) { - swof_[rn][3][i] *= units.pressure; - } - } - } -}; - -/// Class holding a data line of keyword WELSPECS -struct WelspecsLine -{ - std::string name_; // Well name - std::string group_; // Group name - int I_; // I-location of well head or heel - int J_; // J-location of well head or heel - double datum_depth_BHP_; // Datum depth for bottom hole pressure - std::string pref_phase_; // Preferred phase for the well - double drain_rad_; // Drainage radius for prod/inj index calculation - std::string spec_inflow_; // Flag for special inflow equation - std::string shut_in_; // Instructions for automatic shut-in - std::string crossflow_; // Crossflow ability flag - int pressure_table_number_; // Pressure table number for wellbore fluid properties - std::string density_calc_type_; // Type of density calculation for wellbore hydrostatic head - int fluids_in_place_reg_numb_; // Fluids in place region number - - WelspecsLine() : - name_(), group_(), I_(-1), J_(-1), - datum_depth_BHP_(-1.0), pref_phase_(), drain_rad_(0.0), - spec_inflow_("STD"), shut_in_("SHUT"), crossflow_("YES"), - pressure_table_number_(0), density_calc_type_("SEG"), - fluids_in_place_reg_numb_(0) - {} -}; - -/// Class for keyword WELSPECS -struct WELSPECS : public SpecialBase -{ - std::vector welspecs; - - WELSPECS() - { - } - - virtual ~WELSPECS() - {} - - virtual std::string name() const {return std::string("WELSPECS");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - WelspecsLine welspecs_line; - welspecs_line.name_ = wellname; - welspecs_line.group_ = readString(is); - std::vector int_data(2,1); - readDefaultedVectorData(is, int_data, 2); - welspecs_line.I_ = int_data[0]; - welspecs_line.J_ = int_data[1]; - std::vector double_data(1,-1.0); - readDefaultedVectorData(is, double_data, 1); - welspecs_line.datum_depth_BHP_ = double_data[0]; - welspecs_line.pref_phase_ = readString(is); - - // HACK! Ignore items 7-13. - ignoreSlashLine(is); - welspecs.push_back(welspecs_line); - - // double_data[0] = 0.0; - // readDefaultedVectorData(is, double_data, 1); - // welspecs_line.drain_rad_ = double_data[0]; - // welspecs_line.spec_inflow_ = readString(is); - // welspecs_line.shut_in_ = readString(is); - // welspecs_line.crossflow_ = readString(is); - // int_data[0] = 0; - // readDefaultedVectorData(is, int_data, 1); - // welspecs_line.pressure_table_number_ = int_data[0]; - // welspecs_line.density_calc_type_ = readString(is); - // int_data[0] = 0; - // readDefaultedVectorData(is, int_data, 1); - // welspecs_line.fluids_in_place_reg_numb_ = int_data[0]; - // welspecs.push_back(welspecs_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)welspecs.size(); ++i) { - os << welspecs[i].name_ << " " - << welspecs[i].group_ << " " - << welspecs[i].I_ << " " - << welspecs[i].J_ << " " - << welspecs[i].datum_depth_BHP_ << " " - << welspecs[i].pref_phase_ << " " - << welspecs[i].drain_rad_ << " " - << welspecs[i].spec_inflow_ << " " - << welspecs[i].shut_in_ << " " - << welspecs[i].crossflow_ << " " - << welspecs[i].pressure_table_number_ << " " - << welspecs[i].density_calc_type_ << " " - << welspecs[i].fluids_in_place_reg_numb_ << " " - << "/\n"; - } - os << '/' << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)welspecs.size(); ++i) { - welspecs[i].datum_depth_BHP_ *= units.length; - welspecs[i].drain_rad_ *= units.length; - } - } -}; - -/// Class holding a data line of keyword COMPDAT -struct CompdatLine -{ - std::string well_; // Well name - std::vector grid_ind_; // Grid block location - std::string open_shut_flag_; // Open/shut flag of connection - int sat_table_number_; // Saturation table number - double connect_trans_fac_; // Connection transmillibilty factor - double diameter_; // Well bore internal diameter - double Kh_; // Effective Kh value of the connection - double skin_factor_; // Skin factor - double D_factor_; // D-factor, for non-Darcy flow of free gas - std::string penetration_direct_; // Penetration direction - double r0_; // Pressure equivalent radius - - // Default values - CompdatLine() : - open_shut_flag_("OPEN"), - sat_table_number_(0), - connect_trans_fac_(0.0), - diameter_(0.0), - Kh_(-1.0), - skin_factor_(0.0), - D_factor_(-1e100), - penetration_direct_("Z"), - r0_(-1.0) - { - grid_ind_.resize(4); - } -}; - -/// Class for keyword COMPDAT -struct COMPDAT : public SpecialBase -{ - std::vector compdat; - - COMPDAT() - { - } - - virtual ~COMPDAT() - {} - - virtual std::string name() const {return std::string("COMPDAT");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - CompdatLine compdat_line; - compdat_line.well_ = wellname; - readDefaultedVectorData(is, compdat_line.grid_ind_, 4); - compdat_line.open_shut_flag_ = readString(is); - std::vector int_data(1,-1); - readDefaultedVectorData(is, int_data, 1); - compdat_line.sat_table_number_ = int_data[0]; - std::vector double_data(2, 0.0); - int num_to_read = 2; - int num_read = readDefaultedVectorData(is, double_data, num_to_read); - compdat_line.connect_trans_fac_ = double_data[0]; - compdat_line.diameter_ = double_data[1]; - - // HACK! Ignore items 10-14. - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - compdat.push_back(compdat_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)compdat.size(); ++i) { - os << compdat[i].well_ << " " - << compdat[i].grid_ind_[0] << " " - << compdat[i].grid_ind_[1] << " " - << compdat[i].grid_ind_[2] << " " - << compdat[i].grid_ind_[3] << " " - << compdat[i].open_shut_flag_ << " " - << compdat[i].sat_table_number_ << " " - << compdat[i].connect_trans_fac_ << " " - << compdat[i].diameter_ << " " - << compdat[i].Kh_ << " " - << compdat[i].skin_factor_ << " " - << compdat[i].D_factor_ << " " - << compdat[i].penetration_direct_ << " " - << compdat[i].r0_ << " " - << "/\n"; - } - os << '/' << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)compdat.size(); ++i) { - compdat[i].connect_trans_fac_ *= units.transmissibility; - compdat[i].diameter_ *= units.length; - compdat[i].Kh_ *= units.permeability*units.length; - compdat[i].r0_ *= units.length; - } - } -}; - - - -/// Class holding a data line of keyword GCONINJE -struct GconinjeLine -{ - std::string group_; // Well name or well name root - std::string injector_type_; // Injector type - std::string control_mode_; // Control mode - double surface_flow_max_rate_; // Surface flow rate target or upper limit - double resv_flow_max_rate_; // Reservoir flow rate target or upper limit - double reinjection_fraction_target_; - double voidage_replacement_fraction_; - - // Default values - GconinjeLine() : - surface_flow_max_rate_(-1.0E20), - resv_flow_max_rate_(-1E20), - reinjection_fraction_target_(1), - voidage_replacement_fraction_(1) - { - } -}; - -/// Class for keyword GCONINJE -struct GCONINJE : public SpecialBase -{ - std::vector gconinje; - - GCONINJE() - { - } - - virtual ~GCONINJE() - {} - - virtual std::string name() const {return std::string("GCONINJE");} - - virtual void read(std::istream& is) - { - while(is) { - std::string groupname = readString(is); - if (groupname[0] == '/') { - is >> ignoreLine; - break; - } - while (groupname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - groupname = readString(is); - } - GconinjeLine gconinje_line; - gconinje_line.group_ = groupname; - gconinje_line.injector_type_ = readString(is); - gconinje_line.control_mode_ = readString(is); - std::vector double_data(10, -1.0E20); - const int num_to_read = 4; - int num_read = readDefaultedVectorData(is, double_data, num_to_read); - gconinje_line.surface_flow_max_rate_ = double_data[0]; - gconinje_line.resv_flow_max_rate_ = double_data[1]; - gconinje_line.reinjection_fraction_target_ = double_data[2]; - gconinje_line.voidage_replacement_fraction_ = double_data[3]; - // HACK! Ignore any further items - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - gconinje.push_back(gconinje_line); - - } - - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int) gconinje.size(); ++i) { - os << gconinje[i].group_ << " " - << gconinje[i].injector_type_ << " " - << gconinje[i].control_mode_ << " " - << gconinje[i].surface_flow_max_rate_ << " " - << gconinje[i].reinjection_fraction_target_ - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int) gconinje.size(); ++i) { - if (gconinje[i].injector_type_ == "GAS") { - gconinje[i].surface_flow_max_rate_ *= units.gasvol_s/units.time; - } else { - gconinje[i].surface_flow_max_rate_ *= units.liqvol_s/units.time; - } - } - } -}; - - - - -/// Class holding a data line of keyword WCONINJE -struct WconinjeLine -{ - std::string well_; // Well name or well name root - std::string injector_type_; // Injector type - std::string open_shut_flag_; // Open/shut flag for the well - std::string control_mode_; // Control mode - double surface_flow_max_rate_; // Surface flow rate target or upper limit - double reservoir_flow_max_rate_; // Reservoir fluid volume rate target or - // upper limit - double BHP_limit_; // BHP target or upper limit - double THP_limit_; // THP target or upper limit - int VFP_table_number_; // Injection well VFP table number - double concentration_; // Vaporised oil concentration in the - // injected gas, or dissolved gas - // concentration in the injected oil - - // Default values - WconinjeLine() : - open_shut_flag_("OPEN"), surface_flow_max_rate_(-1.0E20), - reservoir_flow_max_rate_(-1.0E20), BHP_limit_(6891), THP_limit_(-1.0E20), - VFP_table_number_(0), concentration_(0.0) - { - } -}; - -/// Class for keyword WCONINJE -struct WCONINJE : public SpecialBase -{ - std::vector wconinje; - - WCONINJE() - { - } - - virtual ~WCONINJE() - {} - - virtual std::string name() const {return std::string("WCONINJE");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - WconinjeLine wconinje_line; - wconinje_line.well_ = wellname; - wconinje_line.injector_type_ = readString(is); - wconinje_line.open_shut_flag_ = readString(is); - wconinje_line.control_mode_ = readString(is); - std::vector double_data(6, -1.0E20); - double_data[2] = wconinje_line.BHP_limit_; - double_data[4] = wconinje_line.VFP_table_number_; - double_data[5] = wconinje_line.concentration_; - const int num_to_read = 6; - int num_read = readDefaultedVectorData(is, double_data, num_to_read); - wconinje_line.surface_flow_max_rate_ = double_data[0]; - wconinje_line.reservoir_flow_max_rate_ = double_data[1]; - wconinje_line.BHP_limit_ = double_data[2]; - wconinje_line.THP_limit_ = double_data[3]; - wconinje_line.VFP_table_number_ = (int)double_data[4]; - wconinje_line.concentration_ = double_data[5]; - // HACK! Ignore any further items - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - wconinje.push_back(wconinje_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int) wconinje.size(); ++i) { - os << wconinje[i].well_ << " " - << wconinje[i].injector_type_ << " " - << wconinje[i].open_shut_flag_ << " " - << wconinje[i].control_mode_ << " " - << wconinje[i].surface_flow_max_rate_ << " " - << wconinje[i].reservoir_flow_max_rate_ << " " - << wconinje[i].BHP_limit_ << " " - << wconinje[i].THP_limit_ << " " - << wconinje[i].VFP_table_number_ << " " - << wconinje[i].concentration_ - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int) wconinje.size(); ++i) { - if (wconinje[i].injector_type_ == "GAS") { - wconinje[i].surface_flow_max_rate_ *= units.gasvol_s/units.time; - } else { - wconinje[i].surface_flow_max_rate_ *= units.liqvol_s/units.time; - } - wconinje[i].reservoir_flow_max_rate_ *= units.liqvol_r/units.time; - wconinje[i].BHP_limit_ *= units.pressure; - wconinje[i].THP_limit_ *= units.pressure; - wconinje[i].concentration_ *= units.gasvol_s/units.liqvol_s; // ??? @bsp 10 - } - } -}; - - - -/// Class holding a data line of keyword GCONPROD -struct GconprodLine -{ - std::string group_; // Well name or well name root - std::string control_mode_; // Control mode - double oil_max_rate_; // Oil rate target or upper limit - double water_max_rate_; // Water rate target or upper limit - double gas_max_rate_; // Gas rate target or upper limit - double liquid_max_rate_; // Liquid rate target or upper limit - double resv_max_rate_; // Reservoir liquid rate target or upper limit - std::string procedure_; // Procedure on exceeding a maximum rate limit - // Default values - GconprodLine() : - oil_max_rate_(-1.0E20), water_max_rate_(-1.0E20), - gas_max_rate_(-1.0E20), liquid_max_rate_(-1.0E20), - resv_max_rate_(-1.0E20) - { - } -}; - -/// Class for keyword GCONPROD -struct GCONPROD : public SpecialBase -{ - std::vector gconprod; - - GCONPROD() - { - } - - virtual ~GCONPROD() - {} - - virtual std::string name() const {return std::string("GCONPROD");} - - virtual void read(std::istream& is) - { - while(is) { - std::string groupname = readString(is); - if (groupname[0] == '/') { - is >> ignoreLine; - break; - } - while (groupname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - groupname = readString(is); - } - GconprodLine gconprod_line; - gconprod_line.group_ = groupname; - gconprod_line.control_mode_ = readString(is); - if (gconprod_line.control_mode_[gconprod_line.control_mode_.size() - 1] == '*') - { - gconprod_line.control_mode_ = "NONE"; - } - std::vector double_data(4, -1.0E20); - const int num_to_read = 4; - int num_read = readDefaultedVectorData(is, double_data, num_to_read); - gconprod_line.oil_max_rate_ = double_data[0]; - gconprod_line.water_max_rate_ = double_data[1]; - gconprod_line.gas_max_rate_ = double_data[2]; - gconprod_line.liquid_max_rate_ = double_data[3]; - - std::string procedure; - if (num_read == num_to_read) { - procedure = readString(is); - if (procedure[0] == '/') { - is.putback('/'); - procedure = "NONE"; - } - int read_ignored = 0; - int to_read = 6; - for (; read_ignored < to_read; ++read_ignored) { - std::string ignored_value = readString(is); - if (ignored_value[ignored_value.size()-1]=='*') { - // we've got defaulted argument, increment - - int num_defaulted; - std::string num_defaulted_str = ignored_value.substr(0, ignored_value.size()-1); - std::istringstream(num_defaulted_str) >> num_defaulted; - read_ignored += num_defaulted; - if (read_ignored >= to_read) { - break; - } - } else if(ignored_value[0] == '/') { - is.putback('/'); - break; - } - } - if ( read_ignored <= to_read) { - // Not defaulted, we can read - std::string reservoir_volume = readString(is); - if (reservoir_volume[reservoir_volume.size()-1] == '*') { - // Defaulted, we're not doing anything - } else if(reservoir_volume[0] == '/') { - is.putback('/'); - } else { - std::istringstream(reservoir_volume) >> gconprod_line.resv_max_rate_; - } - } - } else { - procedure = "NONE"; - } - gconprod_line.procedure_ = procedure; - - - gconprod.push_back(gconprod_line); - // HACK! Ignore any further items - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - - - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int) gconprod.size(); ++i) { - os << gconprod[i].group_ << " " - << gconprod[i].control_mode_ << " " - << gconprod[i].oil_max_rate_ << " " - << gconprod[i].water_max_rate_ << " " - << gconprod[i].gas_max_rate_ << " " - << gconprod[i].liquid_max_rate_ << " " - << gconprod[i].procedure_ << " " - << gconprod[i].resv_max_rate_ - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double lrat = units.liqvol_s / units.time; - double grat = units.gasvol_s / units.time; - double resv = units.liqvol_r / units.time; - - for (int i=0; i<(int) gconprod.size(); ++i) { - gconprod[i].oil_max_rate_ *= lrat; - gconprod[i].water_max_rate_ *= lrat; - gconprod[i].gas_max_rate_ *= grat; - gconprod[i].liquid_max_rate_ *= lrat; - gconprod[i].resv_max_rate_ *= resv; - } - } -}; - -/// Class holding a data line of keyword WGRUPCON -struct WgrupconLine -{ - std::string well_; // Well name - bool available_for_group_control_; - double guide_rate_; - std::string phase_; - WgrupconLine() - : well_(), available_for_group_control_(true), guide_rate_(-1.0), phase_() - { - } -}; - -struct WGRUPCON : public SpecialBase -{ - std::vector wgrupcon; - - WGRUPCON() - { - } - - virtual ~WGRUPCON() - {} - - virtual std::string name() const {return std::string("WGRUPCON");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wname = readString(is); - if (wname[0] == '/') { - is >> ignoreLine; - break; - } - while (wname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wname = readString(is); - } - WgrupconLine wgrupcon_line; - wgrupcon_line.well_ = wname; - std::string available = readString(is); - if (available[available.size()-1] == '*') - { - available = "YES"; - } - wgrupcon_line.available_for_group_control_ = (available == "YES"); - std::vector double_data(1, 1.0E20); - const int num_to_read = 1; - int num_read = readDefaultedVectorData(is, double_data, num_to_read); - wgrupcon_line.guide_rate_ = double_data[0]; - - std::string phase = readString(is); - if (phase[0] == '/') { - is >> ignoreLine; - break; - } - while (phase.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - phase = readString(is); - } - - wgrupcon_line.phase_ = phase; - - wgrupcon.push_back(wgrupcon_line); - // HACK! Ignore any further items - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int) wgrupcon.size(); ++i) { - os << wgrupcon[i].well_ << " " - << wgrupcon[i].available_for_group_control_ << " " - << wgrupcon[i].guide_rate_ << " " - << wgrupcon[i].phase_ << " " - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - static_cast(units); - } -}; - -/// Class holding a data line of keyword WCONPROD -struct WconprodLine -{ - std::string well_; // Well name or well name root - std::string open_shut_flag_; // Open/shut flag for the well - std::string control_mode_; // Control mode - double oil_max_rate_; // Oil rate target or upper limit - double water_max_rate_; // Water rate target or upper limit - double gas_max_rate_; // Gas rate target or upper limit - double liquid_max_rate_; // Liquid rate target or upper limit - double reservoir_flow_max_rate_; // Reservoir fluid volume rate target or - // upper limit - double BHP_limit_; // BHP target or upper limit - double THP_limit_; // THP target or upper limit - int VFP_table_number_; // Injection well VFP table number - double artif_lift_quantity_; // Artificial lift quantity in THP calculations - - // Default values. Negative means no target or limit. - // Note that the BHP default (1.0) will change meaning - // depending on units used, but it is recommended practice - // to not leave the BHP limit defaulted. - WconprodLine() : - open_shut_flag_("OPEN"), oil_max_rate_(-1.0E20), water_max_rate_(-1.0E20), - gas_max_rate_(-1.0E20), liquid_max_rate_(-1.0E20), - reservoir_flow_max_rate_(-1.0E20), BHP_limit_(1.0), THP_limit_(0.0), - VFP_table_number_(0), artif_lift_quantity_(0.0) - { - } -}; - -/// Class for keyword WCONPROD -struct WCONPROD : public SpecialBase -{ - std::vector wconprod; - - WCONPROD() - { - } - - virtual ~WCONPROD() - {} - - virtual std::string name() const {return std::string("WCONPROD");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - WconprodLine wconprod_line; - wconprod_line.well_ = wellname; - wconprod_line.open_shut_flag_ = readString(is); - wconprod_line.control_mode_ = readString(is); - std::vector double_data(14, -1.0E20); - double_data[5] = wconprod_line.BHP_limit_; - double_data[6] = wconprod_line.THP_limit_; - double_data[7] = wconprod_line.VFP_table_number_; - double_data[8] = wconprod_line.artif_lift_quantity_; - const int num_to_read = 14; - int num_read = readDefaultedVectorData(is, double_data, num_to_read); - wconprod_line.oil_max_rate_ = double_data[0]; - wconprod_line.water_max_rate_ = double_data[1]; - wconprod_line.gas_max_rate_ = double_data[2]; - wconprod_line.liquid_max_rate_ = double_data[3]; - wconprod_line.reservoir_flow_max_rate_ = double_data[4]; - wconprod_line.BHP_limit_ = double_data[5]; - wconprod_line.THP_limit_ = double_data[6]; - wconprod_line.VFP_table_number_ = (int)double_data[7]; - wconprod_line.artif_lift_quantity_ = double_data[8]; - wconprod.push_back(wconprod_line); - - if(num_to_read == num_read) { - ignoreSlashLine(is); - } - - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int) wconprod.size(); ++i) { - os << wconprod[i].well_ << " " - << wconprod[i].open_shut_flag_ << " " - << wconprod[i].control_mode_ << " " - << wconprod[i].oil_max_rate_ << " " - << wconprod[i].water_max_rate_ << " " - << wconprod[i].gas_max_rate_ << " " - << wconprod[i].liquid_max_rate_ << " " - << wconprod[i].reservoir_flow_max_rate_ << " " - << wconprod[i].BHP_limit_ << " " - << wconprod[i].THP_limit_ << " " - << wconprod[i].VFP_table_number_ << " " - << wconprod[i].artif_lift_quantity_ - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double lrat = units.liqvol_s / units.time; - double grat = units.gasvol_s / units.time; - double resv = units.liqvol_r / units.time; - for (int i=0; i<(int) wconprod.size(); ++i) { - wconprod[i].oil_max_rate_ *= lrat; - wconprod[i].water_max_rate_ *= lrat; - wconprod[i].gas_max_rate_ *= grat; - wconprod[i].liquid_max_rate_ *= lrat; - wconprod[i].reservoir_flow_max_rate_ *= resv; - wconprod[i].BHP_limit_ *= units.pressure; - wconprod[i].THP_limit_ *= units.pressure; - } - } -}; - - -/// Class holding a data line of keyword WELTARG -struct WeltargLine -{ - std::string well_; // Well name or well name root - std::string control_change_; // Definition of the control or constraint - // quantity to be changed - double new_value_; // New value of this quantity - - WeltargLine() - : well_(), control_change_(), new_value_(-1.0) - { - } -}; - -/// Class for keyword WELTARG -struct WELTARG : public SpecialBase -{ - std::vector weltarg; - - WELTARG() - { - } - - virtual ~WELTARG() - {} - - virtual std::string name() const {return std::string("WELTARG");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - WeltargLine weltarg_line; - weltarg_line.well_ = wellname; - weltarg_line.control_change_ = readString(is); - is >> weltarg_line.new_value_; - ignoreSlashLine(is); - weltarg.push_back(weltarg_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)weltarg.size(); ++i) { - os << weltarg[i].well_ << " " - << weltarg[i].control_change_ << " " - << weltarg[i].new_value_ << " " - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double lrat = units.liqvol_s / units.time; - double grat = units.gasvol_s / units.time; - double resv = units.liqvol_r / units.time; - for (int i=0; i<(int) weltarg.size(); ++i) { - if (weltarg[i].control_change_[0] == 'O' || - weltarg[i].control_change_[0] == 'W' || - weltarg[i].control_change_[0] == 'L') { - weltarg[i].new_value_ *= lrat; - } else if (weltarg[i].control_change_[0] == 'G') { - weltarg[i].new_value_ *= grat; - } else if (weltarg[i].control_change_[0] == 'R') { - weltarg[i].new_value_ *= resv; - } else if (weltarg[i].control_change_[0] == 'B' || - weltarg[i].control_change_[0] == 'T') { - weltarg[i].new_value_ *= units.pressure; - } else { - OPM_THROW(std::runtime_error, "WELTARG. Unknown control or constraint " - << weltarg[i].control_change_[0]); - } - } - } -}; - - - -struct WelopenLine -{ - std::string well_; // Well name or well name root - std::string openshutflag_; // What to do with the well. -}; - -/// Class for keyword WELOPEN -struct WELOPEN : public SpecialBase -{ - std::vector welopen; - - WELOPEN() - { - } - - virtual ~WELOPEN() - {} - - virtual std::string name() const {return std::string("WELOPEN");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - WelopenLine welopen_line; - welopen_line.well_ = wellname; - welopen_line.openshutflag_ = readString(is); - ignoreSlashLine(is); - welopen.push_back(welopen_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)welopen.size(); ++i) { - os << welopen[i].well_ << " " - << welopen[i].openshutflag_ - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& /*units*/) - { - } -}; - - - - -/// Class holding a data line of keyword EQUIL -struct EquilLine -{ - double datum_depth_; // Datum depth - double datum_depth_pressure_; // Pressure at datum depth. - double water_oil_contact_depth_; // Depth of water oil contact. - double oil_water_cap_pressure_; // Oil-water capillary pressure at the - // water-oil contact or Gas-water capillary - // pressure at the gas-water contact contact. - double gas_oil_contact_depth_; // Depth of the gas-oil contact. - double gas_oil_cap_pressure_; // Gas-oil capillary pressure at the gas-oil - // contact. - int live_oil_table_index_; // Rs v Depth or Pb v Depth table index for - // under-saturated live oil. - int wet_gas_table_index_; // Rv v Depth or Pd v Depth table index for - // under-saturated wet gas. - int N_; // Integer defining the accuracy of the - // initial fluids in place calculation. - EquilLine() - { - datum_depth_ = datum_depth_pressure_ = 0.0; - water_oil_contact_depth_ = oil_water_cap_pressure_ = 0.0; - gas_oil_contact_depth_ = gas_oil_cap_pressure_ = 0.0; - - live_oil_table_index_ = 0; - wet_gas_table_index_ = 0; - N_ = 0; - } -}; - -/// Class for keyword EQUIL -struct EQUIL : public SpecialBase -{ - std::vector equil; - - EQUIL() - { - } - - virtual ~EQUIL() - {} - - virtual std::string name() const {return std::string("EQUIL");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTEQUL = 1, and reads only one line. - int num_to_read = 9; - std::vector data(num_to_read,0); - int num_read = readDefaultedVectorData(is, data, num_to_read); - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - - EquilLine equil_line; - equil_line.datum_depth_ = data[0]; - equil_line.datum_depth_pressure_ = data[1]; - equil_line.water_oil_contact_depth_ = data[2]; - equil_line.oil_water_cap_pressure_ = data[3]; - equil_line.gas_oil_contact_depth_ = data[4]; - equil_line.gas_oil_cap_pressure_ = data[5]; - equil_line.live_oil_table_index_ = int(data[6]); - equil_line.wet_gas_table_index_ = int(data[7]); - equil_line.N_ = int(data[8]); - equil.push_back(equil_line); - } - - virtual void write(std::ostream& os) const - { - os << name() << std::endl; - for (int i=0; i<(int)equil.size(); ++i) { - os << equil[i].datum_depth_ << " " - << equil[i].datum_depth_pressure_ << " " - << equil[i].water_oil_contact_depth_ << " " - << equil[i].oil_water_cap_pressure_ << " " - << equil[i].gas_oil_contact_depth_ << " " - << equil[i].gas_oil_cap_pressure_ << " " - << equil[i].live_oil_table_index_ << " " - << equil[i].wet_gas_table_index_ << " " - << equil[i].N_ << " " - - << std::endl; - } - os << std::endl; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)equil.size(); ++i) { - equil[i].datum_depth_ *= units.length; - equil[i].datum_depth_pressure_ *= units.pressure; - equil[i].water_oil_contact_depth_ *= units.length; - equil[i].oil_water_cap_pressure_ *= units.pressure; - equil[i].gas_oil_contact_depth_ *= units.length; - equil[i].gas_oil_cap_pressure_ *= units.pressure; - } - } -}; - -struct PVCDO : public SpecialBase -{ - std::vector > pvcdo_; - - virtual std::string name() const {return std::string("PVCDO");} - - virtual void read(std::istream& is) - { - while (!is.eof()) { - std::vector pvcdo; - readVectorData(is, pvcdo); - if (pvcdo.size() == 4) { - pvcdo.push_back(0.0); - } - pvcdo_.push_back(pvcdo); - - int action = next_action(is); // 0:continue 1:return 2:throw - if (action == 1) { - return; // Alphabetic char. Read next keyword. - } else if (action == 2) { - OPM_THROW(std::runtime_error, "Error reading PVCDO. Next character is " - << (char)is.peek()); - } - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)pvcdo_.size(); ++i) { - os << pvcdo_[i][0] << " " << pvcdo_[i][1] << " " << pvcdo_[i][2] - << " " << pvcdo_[i][3] << " " << pvcdo_[i][4] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - double volfac = units.liqvol_r/units.liqvol_s; - for (int i=0; i<(int)pvcdo_.size(); ++i) { - pvcdo_[i][0] *= units.pressure; - pvcdo_[i][1] *= volfac; - pvcdo_[i][2] *= units.compressibility; - pvcdo_[i][3] *= units.viscosity; - pvcdo_[i][4] *= units.compressibility; - } - } -}; - -struct TSTEP : public SpecialBase -{ - std::vector tstep_; - - virtual std::string name() const {return std::string("TSTEP");} - - virtual void read(std::istream& is) - { - std::vector tstep; - readVectorData(is, tstep); - if (!tstep.empty()) { - tstep_.insert(tstep_.end(), tstep.begin(), tstep.end()); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - copy(tstep_.begin(), tstep_.end(), - std::ostream_iterator(os, " ")); - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - int num_steps = tstep_.size(); - for (int i = 0; i < num_steps; ++i) { - tstep_[i] *= units.time; - } - } -}; - -struct MultRec : public SpecialBase -{ - virtual void read(std::istream& is) - { -#ifdef VERBOSE - std::cout << "(dummy implementation)" << std::endl; -#endif - const std::ctype& ct = std::use_facet< std::ctype >(std::locale::classic()); - is >> ignoreSlashLine; - while (!is.eof()) { - is >> ignoreWhitespace; - std::streampos pos = is.tellg(); - char c; - is.get(c); - if (is.eof()) { - return; - } - if (ct.is(std::ctype_base::alpha, c)) { - std::string name; // Unquoted name or new keyword? - std::getline(is, name); - if (name.rfind('/') != std::string::npos) { - continue; // Unquoted name - } else { - is.seekg(pos); - break; // Read next keyword - } - } else if (ct.is(std::ctype_base::digit, c) || c== '.') { - is >> ignoreSlashLine; // Decimal digit. Ignore data. - continue; - } else if (c== '\'') { - is >> ignoreSlashLine; // Quote. Ignore data. - continue; - } else if(c == '-' && is.peek() == int('-')) { - is >> ignoreLine; // This line is a comment - continue; - } else if (c == '/' ) { - is >> ignoreLine; // This line is a null record. - continue; // (No data before slash) - } else { - is.putback(c); - std::string temp; - is >> temp; - std::cout << "READ ERROR! Next word is " << temp << std::endl; - } - } - } - - virtual void convertToSI(const EclipseUnits&) - {} - -}; - - -struct PLYVISC : public SpecialBase -{ - std::vector concentration_; - std::vector factor_; - - virtual std::string name() const {return std::string("PLYVISC");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTPVT = 1, and reads only one table. - std::vector plyvisc; - readVectorData(is, plyvisc); - for (int i=0; i<(int)plyvisc.size(); i+=2) { - concentration_.push_back(plyvisc[i]); - factor_.push_back(plyvisc[i+1]); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)concentration_.size(); ++i) { - os << concentration_[i] << " " << factor_[i] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)concentration_.size(); ++i) { - concentration_[i] *= units.polymer_density; - } - } -}; - - -struct PLYROCK : public SpecialBase -{ - std::vector plyrock_; - - virtual std::string name() const {return std::string("PLYROCK");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTSFUN = 1, and reads only one line. - plyrock_.resize(5,-1e00); - plyrock_[3] = 1; // Default value - int num_to_read = 5; - int num_read = readDefaultedVectorData(is, plyrock_, num_to_read); - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)plyrock_.size(); ++i) { - os << plyrock_[i] << " "; - } - os << "\n\n"; - } - - virtual void convertToSI(const EclipseUnits& units) - { - - plyrock_[2] *= units.polymer_density; - } -}; - - -struct PLYADS : public SpecialBase -{ - std::vector local_concentration_; - std::vector adsorbed_concentration_; - - virtual std::string name() const {return std::string("PLYADS");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTSFUN = 1, and reads only one table. - std::vector plyads; - readVectorData(is, plyads); - for (int i=0; i<(int)plyads.size(); i+=2) { - local_concentration_.push_back(plyads[i]); - adsorbed_concentration_.push_back(plyads[i+1]); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)local_concentration_.size(); ++i) { - os << local_concentration_[i] << " " << adsorbed_concentration_[i] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)local_concentration_.size(); ++i) { - local_concentration_[i] *= units.polymer_density; - } - } -}; - - -struct PLYMAX : public SpecialBase -{ - std::vector plymax_; - - virtual std::string name() const {return std::string("PLYMAX");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTMISC = 1, and reads only one line. - plymax_.resize(2); - readVectorData(is, plymax_); - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)plymax_.size(); ++i) { - os << plymax_[i] << " "; - } - os << "\n\n"; - } - - virtual void convertToSI(const EclipseUnits& units) - { - plymax_[0] *= units.polymer_density; - plymax_[1] *= units.polymer_density; - } -}; - - -struct PLYSHEAR : public SpecialBase -{ - std::vector water_velocity_; - std::vector vrf_; - - virtual std::string name() const {return std::string("PLYSHEAR");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTSFUN = 1, and reads only one table. - std::vector plyshear; - readVectorData(is, plyshear); - for (int i=0; i<(int)plyshear.size(); i+=2) { - water_velocity_.push_back(plyshear[i]); - vrf_.push_back(plyshear[i+1]); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)water_velocity_.size(); ++i) { - os << water_velocity_[i] << " " << vrf_[i] << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)water_velocity_.size(); ++i) { - water_velocity_[i] *= units.length / units.time; - } - } -}; - - -struct TLMIXPAR : public SpecialBase -{ - std::vector tlmixpar_; - - virtual std::string name() const {return std::string("TLMIXPAR");} - - virtual void read(std::istream& is) - { - // Note. This function assumes that NTMISC = 1, and reads only one record. - tlmixpar_.resize(2, -1e100); - int num_to_read = 2; - int num_read = readDefaultedVectorData(is, tlmixpar_, num_to_read); - if (tlmixpar_[1] < 0) { - tlmixpar_[1] = tlmixpar_[0]; - } - if (num_read == num_to_read) { - ignoreSlashLine(is); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)tlmixpar_.size(); ++i) { - os << tlmixpar_[i] << " "; - } - os << "\n\n"; - } - - virtual void convertToSI(const EclipseUnits& units) - { - static_cast(units); // Suppress "unused parameter" warning. - } -}; - -/// Class holding a data line of keyword WPOLYMER -struct WpolymerLine -{ - std::string well_; // Well name, well name template or well list template - double polymer_concentration_; - double salt_concentration_; - std::string polymer_group_; - std::string salt_group_; - - WpolymerLine() - { - well_ = polymer_group_ = salt_group_ = ""; - polymer_concentration_ = salt_concentration_ = 0.0; - } -}; - -struct WPOLYMER : public SpecialBase -{ - std::vector wpolymer_; - - virtual std::string name() const {return std::string("WPOLYMER");} - - virtual void read(std::istream& is) - { - while(is) { - std::string wellname = readString(is); - if (wellname[0] == '/') { - is >> ignoreLine; - break; - } - while (wellname.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - wellname = readString(is); - } - WpolymerLine wpolymer_line; - wpolymer_line.well_ = wellname; - is >> wpolymer_line.polymer_concentration_; - is >> wpolymer_line.salt_concentration_; - std::string group = readString(is); - if (group[0] == '/') { - is >> ignoreLine; - } else { - wpolymer_line.polymer_group_ = group; - group = readString(is); - if (group[0] == '/') { - is >> ignoreLine; - } else { - wpolymer_line.salt_group_ = group; - is >> ignoreLine; - } - } - wpolymer_.push_back(wpolymer_line); - } - } - - virtual void write(std::ostream& os) const - { - os << name() << '\n'; - for (int i=0; i<(int)wpolymer_.size(); ++i) { - os << wpolymer_[i].well_ - << " " << wpolymer_[i].polymer_concentration_ - << " " << wpolymer_[i].salt_concentration_ - << " " << wpolymer_[i].polymer_group_ - << " " << wpolymer_[i].salt_group_; - os << '\n'; - } - os << '\n'; - } - - virtual void convertToSI(const EclipseUnits& units) - { - for (int i=0; i<(int)wpolymer_.size(); ++i) { - wpolymer_[i].polymer_concentration_ *= units.polymer_density; - wpolymer_[i].salt_concentration_ *= units.polymer_density; - } - } -}; - -struct ENDSCALE : public SpecialBase { - std::string dir_switch_; - std::string revers_switch_; - int n_tab_; - int n_node_; - - virtual std::string name() const { - return std::string("ENDSCALE"); - } - - virtual void read(std::istream & is) { - dir_switch_ = std::string("NODIR"); - revers_switch_ = std::string("REVERS"); - n_tab_ = 1; - n_node_ = 20; - while (!is.eof()) { - std::string tmp = readString(is); - while (tmp.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - tmp = readString(is); - } - if (tmp[0] == '/') { - is >> ignoreLine; - break; - } - dir_switch_ = tmp; - tmp = readString(is); - if (tmp[0] == '/') { - is >> ignoreLine; - break; - } - revers_switch_ = tmp; - is >> ignoreWhitespace; - if(is.peek() == int('/')) { - is >> ignoreLine; - return; - } - is >> n_tab_; - is >> ignoreWhitespace; - if(is.peek() == int('/')) { - is >> ignoreLine; - return; - } - is >> n_node_; - is >> ignoreLine; - break; - } - } - - virtual void write(std::ostream & os) { - os << name() << '\n'; - os << dir_switch_ << " " << revers_switch_ << " " - << n_tab_ << " " << n_node_ << '\n'; - } - - virtual void convertToSI(const EclipseUnits&) { - } -}; - -struct SCALECRS : public SpecialBase { - std::string scalecrs_; - - virtual std::string name() const { - return std::string("SCALECRS"); - } - - virtual void read(std::istream & is) { - scalecrs_ = std::string("NO"); - while (!is.eof()) { - std::string tmp = readString(is); - while (tmp.find("--") == 0) { - // This line is a comment - is >> ignoreLine; - tmp = readString(is); - } - if (tmp[0] == '/') { - is >> ignoreLine; - break; - } else if (tmp[0] == 'Y') { - scalecrs_ = std::string("YES"); - } - is >> ignoreLine; - break; - } - } - - virtual void write(std::ostream & os) { - os << name() << '\n'; - os << scalecrs_ << '\n'; - } - - virtual void convertToSI(const EclipseUnits&) { - } -}; - -struct ENPTVD : public SpecialBase { - std::vector > > table_; - std::vector mask_; - - virtual std::string name() const { - return std::string("ENPTVD"); - } - - virtual void read(std::istream & is) { - table_.resize(9); - std::vector > sub_table(9); - while (!is.eof()) { - if(is.peek() == int('/')) { - if (sub_table[0].empty() && !(table_[0].empty())) { - is >> ignoreLine; - break; - } else { - OPM_THROW(std::runtime_error, "Error reading ENPTVD data - none or incomplete table."); - } - } - std::vector data(9,-1.0); - int nread = readDefaultedVectorData(is, data, 9); - if (nread != 9) { - OPM_THROW(std::runtime_error, "Error reading ENPTVD data - depth and 8 saturations pr line."); - } - if (data[0] == -1.0) { - OPM_THROW(std::runtime_error, "Error reading ENPTVD data - depth can not be defaulted."); - } - for(std::vector >::size_type i=0; i> ignoreWhitespace; - if(is.peek() == int('/')) { - is >> ignoreLine; - if (sub_table[0].size() >= 2) { - insertDefaultValues(sub_table, 9, -1.0, false); - std::vector >::iterator it_sub = sub_table.begin(); - for(std::vector > >::size_type i=0; i > >::size_type i=1; i >::size_type j=0; j >::size_type j=0; j::size_type k=0; k > >::size_type i=0; i >::size_type j=0; j::size_type k=0; k > > table_; - std::vector mask_; - - virtual std::string name() const { - return std::string("ENKRVD"); - } - - virtual void read(std::istream & is) { - table_.resize(8); - std::vector > sub_table(8); - while (!is.eof()) { - if(is.peek() == int('/')) { - if (sub_table[0].empty() && !(table_[0].empty())) { - is >> ignoreLine; - break; - } else { - OPM_THROW(std::runtime_error, "Error reading ENKRVD data - none or incomplete table."); - } - } - std::vector data(8,-1.0); - int nread = readDefaultedVectorData(is, data, 8); - if (nread != 8) { - OPM_THROW(std::runtime_error, "Error reading ENKRVD data - depth and 7 relperms pr line."); - } - if (data[0] == -1.0) { - OPM_THROW(std::runtime_error, "Error reading ENKRVD data - depth can not be defaulted."); - } - - for(std::vector >::size_type i=0; i> ignoreWhitespace; - if(is.peek() == int('/')) { - is >> ignoreLine; - if (sub_table[0].size() >= 2) { - insertDefaultValues(sub_table, 8, -1.0, false); - std::vector >::iterator it_sub = sub_table.begin(); - for(std::vector > >::size_type i=0; i > >::size_type i=1; i >::size_type j=0; j >::size_type j=0; j::size_type k=0; k > >::size_type i=0; i >::size_type j=0; j::size_type k=0; k #include #include -#include #include #include @@ -47,15 +46,7 @@ namespace Opm /// \param[in] grid Grid to which property object applies, needed for the /// mapping from cell indices (typically from a processed grid) /// to logical cartesian indices consistent with the deck. - BlackoilPropertiesFromDeck(const EclipseGridParser &deck, - const UnstructuredGrid& grid, bool init_rock=true ); - - /// Initialize from deck and grid. - /// \param[in] deck Deck input parser - /// \param[in] grid Grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. - BlackoilPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, + BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, const UnstructuredGrid& grid, bool init_rock=true ); /// Initialize from deck, grid and parameters. @@ -69,62 +60,27 @@ namespace Opm /// threephase_model("simple") three-phase relperm model (accepts "simple" and "stone2"). /// For both size parameters, a 0 or negative value indicates that no spline fitting is to /// be done, and the input fluid data used directly for linear interpolation. - BlackoilPropertiesFromDeck(const EclipseGridParser& deck, + BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, const UnstructuredGrid& grid, const parameter::ParameterGroup& param, bool init_rock=true); - /// Initialize from deck, grid and parameters. - /// \param[in] deck Deck input parser - /// \param[in] grid Grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. - /// \param[in] param Parameters. Accepted parameters include: - /// pvt_tab_size (200) number of uniform sample points for dead-oil pvt tables. - /// sat_tab_size (200) number of uniform sample points for saturation tables. - /// threephase_model("simple") three-phase relperm model (accepts "simple" and "stone2"). - /// For both size parameters, a 0 or negative value indicates that no spline fitting is to - /// be done, and the input fluid data used directly for linear interpolation. - BlackoilPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, - const UnstructuredGrid& grid, - const parameter::ParameterGroup& param, - bool init_rock=true); - template - BlackoilPropertiesFromDeck(const EclipseGridParser& deck, + template + BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, - T begin_cell_centroids, + const CentroidIterator& begin_cell_centroids, int dimension, bool init_rock=true); - - template - BlackoilPropertiesFromDeck(const EclipseGridParser& deck, + template + BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, - T begin_cell_centroids, - int dimension, - const parameter::ParameterGroup& param, - bool init_rock=true); - - template - BlackoilPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - bool init_rock=true); - - template - BlackoilPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, + const CentroidIterator& begin_cell_centroids, int dimension, const parameter::ParameterGroup& param, bool init_rock=true); @@ -250,38 +206,20 @@ namespace Opm double* smax) const; private: - template - void init(const EclipseGridParser& deck, + template + void init(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, - T begin_cell_centroids, + const CentroidIterator& begin_cell_centroids, int dimension, bool init_rock); - template - void init(const EclipseGridParser& deck, + template + void init(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, - T begin_cell_centroids, - int dimension, - const parameter::ParameterGroup& param, - bool init_rock); - - template - void init(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - bool init_rock); - template - void init(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, + const CentroidIterator& begin_cell_centroids, int dimension, const parameter::ParameterGroup& param, bool init_rock); diff --git a/opm/core/props/BlackoilPropertiesFromDeck_impl.hpp b/opm/core/props/BlackoilPropertiesFromDeck_impl.hpp index 8a76a592..9a9b8bad 100644 --- a/opm/core/props/BlackoilPropertiesFromDeck_impl.hpp +++ b/opm/core/props/BlackoilPropertiesFromDeck_impl.hpp @@ -1,13 +1,11 @@ namespace Opm { - - - template - BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(const EclipseGridParser& deck, + template + BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, - T begin_cell_centroids, + const CentroidIterator& begin_cell_centroids, int dimension, bool init_rock) { @@ -15,13 +13,12 @@ namespace Opm init_rock); } - - template - BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(const EclipseGridParser& deck, + template + BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, - T begin_cell_centroids, + const CentroidIterator& begin_cell_centroids, int dimension, const parameter::ParameterGroup& param, bool init_rock) @@ -30,74 +27,23 @@ namespace Opm param, init_rock); } - template - BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - bool init_rock) - { - init(newParserDeck, number_of_cells, global_cell, cart_dims, begin_cell_centroids, dimension, - init_rock); - } - - template - BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - const parameter::ParameterGroup& param, - bool init_rock) - { - init(newParserDeck, number_of_cells, global_cell, cart_dims, begin_cell_centroids, dimension, - param, init_rock); - } - - template - void BlackoilPropertiesFromDeck::init(const EclipseGridParser& deck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - bool init_rock) + template + inline void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr deck, + int number_of_cells, + const int* global_cell, + const int* cart_dims, + const CentroidIterator& begin_cell_centroids, + int dimension, + bool init_rock) { if (init_rock){ rock_.init(deck, number_of_cells, global_cell, cart_dims); } - pvt_.init(deck, 0); + pvt_.init(deck, /*numSamples=*/0); SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, 200); - - if (pvt_.numPhases() != satprops_->numPhases()) { - OPM_THROW(std::runtime_error, "BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data (" - << pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ")."); - } - } - - template - void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - bool init_rock) - { - if (init_rock){ - rock_.init(newParserDeck, number_of_cells, global_cell, cart_dims); - } - pvt_.init(newParserDeck, /*numSamples=*/0); - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, dimension, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, /*numSamples=*/0); if (pvt_.numPhases() != satprops_->numPhases()) { @@ -106,103 +52,28 @@ namespace Opm } } - template - void BlackoilPropertiesFromDeck::init(const EclipseGridParser& deck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - const parameter::ParameterGroup& param, - bool init_rock) + template + inline void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr deck, + int number_of_cells, + const int* global_cell, + const int* cart_dims, + const CentroidIterator& begin_cell_centroids, + int dimension, + const parameter::ParameterGroup& param, + bool init_rock) { + if(init_rock){ rock_.init(deck, number_of_cells, global_cell, cart_dims); } - const int pvt_samples = param.getDefault("pvt_tab_size", 0); - pvt_.init(deck, pvt_samples); - - // Unfortunate lack of pointer smartness here... - const int sat_samples = param.getDefault("sat_tab_size", 0); - std::string threephase_model = param.getDefault("threephase_model", "simple"); - if (deck.hasField("ENDSCALE") && threephase_model != "simple") { - OPM_THROW(std::runtime_error, "Sorry, end point scaling currently available for the 'simple' model only."); - } - if (sat_samples > 1) { - if (threephase_model == "stone2") { - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, - sat_samples); - } else if (threephase_model == "simple") { - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, - sat_samples); - } else if (threephase_model == "gwseg") { - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, - sat_samples); - } else { - OPM_THROW(std::runtime_error, "Unknown threephase_model: " << threephase_model); - } - } else { - if (threephase_model == "stone2") { - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, - sat_samples); - } else if (threephase_model == "simple") { - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, - sat_samples); - } else if (threephase_model == "gwseg") { - SaturationPropsFromDeck* ptr - = new SaturationPropsFromDeck(); - satprops_.reset(ptr); - ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, - sat_samples); - } else { - OPM_THROW(std::runtime_error, "Unknown threephase_model: " << threephase_model); - } - } - - if (pvt_.numPhases() != satprops_->numPhases()) { - OPM_THROW(std::runtime_error, "BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data (" - << pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ")."); - } - } - - template - void BlackoilPropertiesFromDeck::init(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - T begin_cell_centroids, - int dimension, - const parameter::ParameterGroup& param, - bool init_rock) - { - - if(init_rock){ - rock_.init(newParserDeck, number_of_cells, global_cell, cart_dims); - } - const int pvt_samples = param.getDefault("pvt_tab_size", 200); - pvt_.init(newParserDeck, pvt_samples); + pvt_.init(deck, pvt_samples); // Unfortunate lack of pointer smartness here... const int sat_samples = param.getDefault("sat_tab_size", 200); std::string threephase_model = param.getDefault("threephase_model", "simple"); - if (newParserDeck->hasKeyword("ENDSCALE") && threephase_model != "gwseg") { + if (deck->hasKeyword("ENDSCALE") && threephase_model != "gwseg") { OPM_THROW(std::runtime_error, "Sorry, end point scaling currently available for the 'gwseg' model only."); } if (sat_samples > 1) { @@ -210,19 +81,19 @@ namespace Opm SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, sat_samples); } else if (threephase_model == "simple") { SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, sat_samples); } else if (threephase_model == "gwseg") { SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, sat_samples); } else { OPM_THROW(std::runtime_error, "Unknown threephase_model: " << threephase_model); @@ -232,19 +103,19 @@ namespace Opm SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, sat_samples); } else if (threephase_model == "simple") { SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, sat_samples); } else if (threephase_model == "gwseg") { SaturationPropsFromDeck* ptr = new SaturationPropsFromDeck(); satprops_.reset(ptr); - ptr->init(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + ptr->init(deck, number_of_cells, global_cell, begin_cell_centroids, dimension, sat_samples); } else { OPM_THROW(std::runtime_error, "Unknown threephase_model: " << threephase_model); diff --git a/opm/core/props/IncompPropertiesFromDeck.cpp b/opm/core/props/IncompPropertiesFromDeck.cpp index 04306b28..7103c291 100644 --- a/opm/core/props/IncompPropertiesFromDeck.cpp +++ b/opm/core/props/IncompPropertiesFromDeck.cpp @@ -26,10 +26,10 @@ namespace Opm { - IncompPropertiesFromDeck::IncompPropertiesFromDeck(const EclipseGridParser& deck, + IncompPropertiesFromDeck::IncompPropertiesFromDeck(Opm::DeckConstPtr deck, const UnstructuredGrid& grid) { - rock_.init(deck, grid); + rock_.init(deck, grid.number_of_cells, grid.global_cell, grid.cartdims); pvt_.init(deck); satprops_.init(deck, grid, 200); if (pvt_.numPhases() != satprops_.numPhases()) { @@ -38,18 +38,6 @@ namespace Opm } } - IncompPropertiesFromDeck::IncompPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, - const UnstructuredGrid& grid) - { - rock_.init(newParserDeck, grid.number_of_cells, grid.global_cell, grid.cartdims); - pvt_.init(newParserDeck); - satprops_.init(newParserDeck, grid, 200); - if (pvt_.numPhases() != satprops_.numPhases()) { - OPM_THROW(std::runtime_error, "IncompPropertiesFromDeck::IncompPropertiesFromDeck() - Inconsistent number of phases in pvt data (" - << pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ")."); - } - } - IncompPropertiesFromDeck::~IncompPropertiesFromDeck() { } diff --git a/opm/core/props/IncompPropertiesFromDeck.hpp b/opm/core/props/IncompPropertiesFromDeck.hpp index 83718aac..f9be40db 100644 --- a/opm/core/props/IncompPropertiesFromDeck.hpp +++ b/opm/core/props/IncompPropertiesFromDeck.hpp @@ -50,15 +50,7 @@ namespace Opm /// \param grid Grid to which property object applies, needed for the /// mapping from cell indices (typically from a processed grid) /// to logical cartesian indices consistent with the deck. - IncompPropertiesFromDeck(const EclipseGridParser& deck, - const UnstructuredGrid& grid); - - /// Initialize from deck and grid. - /// \param deck Deck input parser - /// \param grid Grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. - IncompPropertiesFromDeck(Opm::DeckConstPtr newParserDeck, + IncompPropertiesFromDeck(Opm::DeckConstPtr deck, const UnstructuredGrid& grid); /// Destructor. diff --git a/opm/core/props/phaseUsageFromDeck.hpp b/opm/core/props/phaseUsageFromDeck.hpp index 6ee66075..280255f5 100644 --- a/opm/core/props/phaseUsageFromDeck.hpp +++ b/opm/core/props/phaseUsageFromDeck.hpp @@ -20,9 +20,8 @@ #ifndef OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED #define OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED - -#include #include +#include #include #include @@ -70,56 +69,19 @@ namespace Opm /// Looks at presence of WATER, OIL and GAS keywords in deck /// to determine active phases. - inline PhaseUsage phaseUsageFromDeck(const EclipseGridParser& deck) + inline PhaseUsage phaseUsageFromDeck(Opm::DeckConstPtr deck) { PhaseUsage pu; std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0); // Discover phase usage. - if (deck.hasField("WATER")) { + if (deck->hasKeyword("WATER")) { pu.phase_used[BlackoilPhases::Aqua] = 1; } - if (deck.hasField("OIL")) { + if (deck->hasKeyword("OIL")) { pu.phase_used[BlackoilPhases::Liquid] = 1; } - if (deck.hasField("GAS")) { - pu.phase_used[BlackoilPhases::Vapour] = 1; - } - pu.num_phases = 0; - for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) { - pu.phase_pos[i] = pu.num_phases; - pu.num_phases += pu.phase_used[i]; - } - - // Only 2 or 3 phase systems handled. - if (pu.num_phases < 2 || pu.num_phases > 3) { - OPM_THROW(std::runtime_error, "Cannot handle cases with " << pu.num_phases << " phases."); - } - - // We need oil systems, since we do not support the keywords needed for - // water-gas systems. - if (!pu.phase_used[BlackoilPhases::Liquid]) { - OPM_THROW(std::runtime_error, "Cannot handle cases with no OIL, i.e. water-gas systems."); - } - - return pu; - } - - /// Looks at presence of WATER, OIL and GAS keywords in deck - /// to determine active phases. - inline PhaseUsage phaseUsageFromDeck(Opm::DeckConstPtr newParserDeck) - { - PhaseUsage pu; - std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0); - - // Discover phase usage. - if (newParserDeck->hasKeyword("WATER")) { - pu.phase_used[BlackoilPhases::Aqua] = 1; - } - if (newParserDeck->hasKeyword("OIL")) { - pu.phase_used[BlackoilPhases::Liquid] = 1; - } - if (newParserDeck->hasKeyword("GAS")) { + if (deck->hasKeyword("GAS")) { pu.phase_used[BlackoilPhases::Vapour] = 1; } pu.num_phases = 0; diff --git a/opm/core/props/pvt/BlackoilPvtProperties.cpp b/opm/core/props/pvt/BlackoilPvtProperties.cpp index cc2ebbcc..04e56ad1 100644 --- a/opm/core/props/pvt/BlackoilPvtProperties.cpp +++ b/opm/core/props/pvt/BlackoilPvtProperties.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -43,7 +42,7 @@ namespace Opm { } - void BlackoilPvtProperties::init(const EclipseGridParser& deck, const int samples) + void BlackoilPvtProperties::init(Opm::DeckConstPtr deck, int samples) { // If we need multiple regions, this class and the SinglePvt* classes must change. region_number_ = 0; @@ -51,80 +50,8 @@ namespace Opm phase_usage_ = phaseUsageFromDeck(deck); // Surface densities. Accounting for different orders in eclipse and our code. - if (deck.hasField("DENSITY")) { - const std::vector& d = deck.getDENSITY().densities_[region_number_]; - enum { ECL_oil = 0, ECL_water = 1, ECL_gas = 2 }; - if (phase_usage_.phase_used[Aqua]) { - densities_[phase_usage_.phase_pos[Aqua]] = d[ECL_water]; - } - if (phase_usage_.phase_used[Vapour]) { - densities_[phase_usage_.phase_pos[Vapour]] = d[ECL_gas]; - } - if (phase_usage_.phase_used[Liquid]) { - densities_[phase_usage_.phase_pos[Liquid]] = d[ECL_oil]; - } - } else { - OPM_THROW(std::runtime_error, "Input is missing DENSITY\n"); - } - - // Set the properties. - props_.resize(phase_usage_.num_phases); - // Water PVT - if (phase_usage_.phase_used[Aqua]) { - if (deck.hasField("PVTW")) { - props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(deck.getPVTW().pvtw_)); - } else { - // Eclipse 100 default. - props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(0.5*Opm::prefix::centi*Opm::unit::Poise)); - } - } - // Oil PVT - if (phase_usage_.phase_used[Liquid]) { - if (deck.hasField("PVDO")) { - if (samples > 0) { - props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(deck.getPVDO().pvdo_, samples)); - } else { - props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDead(deck.getPVDO().pvdo_)); - } - } else if (deck.hasField("PVTO")) { - props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_)); - } else if (deck.hasField("PVCDO")) { - props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(deck.getPVCDO().pvcdo_)); - } else { - OPM_THROW(std::runtime_error, "Input is missing PVDO or PVTO\n"); - } - } - // Gas PVT - if (phase_usage_.phase_used[Vapour]) { - if (deck.hasField("PVDG")) { - if (samples > 0) { - props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(deck.getPVDG().pvdg_, samples)); - } else { - props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDead(deck.getPVDG().pvdg_)); - } - } else if (deck.hasField("PVTG")) { - props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_)); - } else { - OPM_THROW(std::runtime_error, "Input is missing PVDG or PVTG\n"); - } - } - - // Must inform pvt property objects of phase structure. - for (int i = 0; i < phase_usage_.num_phases; ++i) { - props_[i]->setPhaseConfiguration(phase_usage_.num_phases, phase_usage_.phase_pos); - } - } - - void BlackoilPvtProperties::init(Opm::DeckConstPtr newParserDeck, int samples) - { - // If we need multiple regions, this class and the SinglePvt* classes must change. - region_number_ = 0; - - phase_usage_ = phaseUsageFromDeck(newParserDeck); - - // Surface densities. Accounting for different orders in eclipse and our code. - if (newParserDeck->hasKeyword("DENSITY")) { - Opm::DeckKeywordConstPtr densityKeyword = newParserDeck->getKeyword("DENSITY"); + if (deck->hasKeyword("DENSITY")) { + Opm::DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY"); if (phase_usage_.phase_used[Liquid]) { densities_[phase_usage_.phase_pos[Liquid]] = densityKeyword->getRecord(region_number_)->getItem("OIL")->getSIDouble(0); @@ -145,8 +72,8 @@ namespace Opm props_.resize(phase_usage_.num_phases); // Water PVT if (phase_usage_.phase_used[Aqua]) { - if (newParserDeck->hasKeyword("PVTW")) { - Opm::PvtwTable pvtwTable(newParserDeck->getKeyword("PVTW")); + if (deck->hasKeyword("PVTW")) { + Opm::PvtwTable pvtwTable(deck->getKeyword("PVTW")); props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(pvtwTable)); } else { @@ -156,19 +83,19 @@ namespace Opm } // Oil PVT if (phase_usage_.phase_used[Liquid]) { - if (newParserDeck->hasKeyword("PVDO")) { - Opm::PvdoTable pvdoTable(newParserDeck->getKeyword("PVDO"), region_number_); + if (deck->hasKeyword("PVDO")) { + Opm::PvdoTable pvdoTable(deck->getKeyword("PVDO"), region_number_); if (samples > 0) { props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(pvdoTable, samples)); } else { props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDead(pvdoTable)); } - } else if (newParserDeck->hasKeyword("PVTO")) { - Opm::PvtoTable pvtoTable(newParserDeck->getKeyword("PVTO"), /*tableIdx=*/0); + } else if (deck->hasKeyword("PVTO")) { + Opm::PvtoTable pvtoTable(deck->getKeyword("PVTO"), /*tableIdx=*/0); props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(pvtoTable)); - } else if (newParserDeck->hasKeyword("PVCDO")) { - Opm::PvcdoTable pvcdoTable(newParserDeck->getKeyword("PVCDO")); + } else if (deck->hasKeyword("PVCDO")) { + Opm::PvcdoTable pvcdoTable(deck->getKeyword("PVCDO")); props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(pvcdoTable)); } else { @@ -177,15 +104,15 @@ namespace Opm } // Gas PVT if (phase_usage_.phase_used[Vapour]) { - if (newParserDeck->hasKeyword("PVDG")) { - Opm::PvdgTable pvdgTable(newParserDeck->getKeyword("PVDG"), region_number_); + if (deck->hasKeyword("PVDG")) { + Opm::PvdgTable pvdgTable(deck->getKeyword("PVDG"), region_number_); if (samples > 0) { props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(pvdgTable, samples)); } else { props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDead(pvdgTable)); } - } else if (newParserDeck->hasKeyword("PVTG")) { - Opm::PvtgTable pvtgTable(newParserDeck->getKeyword("PVTG"), /*tableIdx=*/0); + } else if (deck->hasKeyword("PVTG")) { + Opm::PvtgTable pvtgTable(deck->getKeyword("PVTG"), /*tableIdx=*/0); props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(pvtgTable)); } else { diff --git a/opm/core/props/pvt/BlackoilPvtProperties.hpp b/opm/core/props/pvt/BlackoilPvtProperties.hpp index 9b466b2d..b8bff837 100644 --- a/opm/core/props/pvt/BlackoilPvtProperties.hpp +++ b/opm/core/props/pvt/BlackoilPvtProperties.hpp @@ -22,7 +22,6 @@ #include #include -#include #include @@ -47,16 +46,6 @@ namespace Opm /// Default constructor. BlackoilPvtProperties(); - /// Initialize from deck. - /// \param deck An input deck. - /// \param samples If greater than zero, indicates the number of - /// uniform samples to be taken from monotone spline - /// curves interpolating the fluid data. - /// Otherwise, interpolate linearly in the original - /// data without fitting a spline. - void init(const EclipseGridParser& deck, const int samples); - - /// Initialize from deck. /// \param deck An input deck from the opm-parser module. void init(Opm::DeckConstPtr deck, int samples); diff --git a/opm/core/props/pvt/PvtPropertiesIncompFromDeck.cpp b/opm/core/props/pvt/PvtPropertiesIncompFromDeck.cpp index 33094126..c4c764ac 100644 --- a/opm/core/props/pvt/PvtPropertiesIncompFromDeck.cpp +++ b/opm/core/props/pvt/PvtPropertiesIncompFromDeck.cpp @@ -21,7 +21,6 @@ #include "config.h" #include #include -#include #include #include #include @@ -34,8 +33,7 @@ namespace Opm { } - - void PvtPropertiesIncompFromDeck::init(const EclipseGridParser& deck) + void PvtPropertiesIncompFromDeck::init(Opm::DeckConstPtr deck ) { // If we need multiple regions, this class and the SinglePvt* classes must change. int region_number = 0; @@ -48,61 +46,8 @@ namespace Opm } // Surface densities. Accounting for different orders in eclipse and our code. - if (deck.hasField("DENSITY")) { - const std::vector& d = deck.getDENSITY().densities_[region_number]; - enum { ECL_oil = 0, ECL_water = 1, ECL_gas = 2 }; - surface_density_[phase_usage.phase_pos[PhaseUsage::Aqua]] = d[ECL_water]; - surface_density_[phase_usage.phase_pos[PhaseUsage::Liquid]] = d[ECL_oil]; - } else { - OPM_THROW(std::runtime_error, "Input is missing DENSITY\n"); - } - - // Make reservoir densities the same as surface densities initially. - // We will modify them with formation volume factors if found. - reservoir_density_ = surface_density_; - - // Water viscosity. - if (deck.hasField("PVTW")) { - const std::vector& pvtw = deck.getPVTW().pvtw_[region_number]; - if (pvtw[2] != 0.0 || pvtw[4] != 0.0) { - OPM_MESSAGE("Compressibility effects in PVTW are ignored."); - } - reservoir_density_[phase_usage.phase_pos[PhaseUsage::Aqua]] /= pvtw[1]; - viscosity_[phase_usage.phase_pos[PhaseUsage::Aqua]] = pvtw[3]; - } else { - // Eclipse 100 default. - // viscosity_[phase_usage.phase_pos[PhaseUsage::Aqua]] = 0.5*Opm::prefix::centi*Opm::unit::Poise; - OPM_THROW(std::runtime_error, "Input is missing PVTW\n"); - } - - // Oil viscosity. - if (deck.hasField("PVCDO")) { - const std::vector& pvcdo = deck.getPVCDO().pvcdo_[region_number]; - if (pvcdo[2] != 0.0 || pvcdo[4] != 0.0) { - OPM_MESSAGE("Compressibility effects in PVCDO are ignored."); - } - reservoir_density_[phase_usage.phase_pos[PhaseUsage::Liquid]] /= pvcdo[1]; - viscosity_[phase_usage.phase_pos[PhaseUsage::Liquid]] = pvcdo[3]; - } else { - OPM_THROW(std::runtime_error, "Input is missing PVCDO\n"); - } - } - - void PvtPropertiesIncompFromDeck::init(Opm::DeckConstPtr newParserDeck ) - { - // If we need multiple regions, this class and the SinglePvt* classes must change. - int region_number = 0; - - PhaseUsage phase_usage = phaseUsageFromDeck(newParserDeck); - if (phase_usage.phase_used[PhaseUsage::Vapour] || - !phase_usage.phase_used[PhaseUsage::Aqua] || - !phase_usage.phase_used[PhaseUsage::Liquid]) { - OPM_THROW(std::runtime_error, "PvtPropertiesIncompFromDeck::init() -- must have gas and oil phases (only) in deck input.\n"); - } - - // Surface densities. Accounting for different orders in eclipse and our code. - if (newParserDeck->hasKeyword("DENSITY")) { - Opm::DeckRecordConstPtr densityRecord = newParserDeck->getKeyword("DENSITY")->getRecord(region_number); + if (deck->hasKeyword("DENSITY")) { + Opm::DeckRecordConstPtr densityRecord = deck->getKeyword("DENSITY")->getRecord(region_number); surface_density_[phase_usage.phase_pos[PhaseUsage::Aqua]] = densityRecord->getItem("OIL")->getSIDouble(0); surface_density_[phase_usage.phase_pos[PhaseUsage::Liquid]] = densityRecord->getItem("WATER")->getSIDouble(0); } else { @@ -114,8 +59,8 @@ namespace Opm reservoir_density_ = surface_density_; // Water viscosity. - if (newParserDeck->hasKeyword("PVTW")) { - Opm::DeckRecordConstPtr pvtwRecord = newParserDeck->getKeyword("PVTW")->getRecord(region_number); + if (deck->hasKeyword("PVTW")) { + Opm::DeckRecordConstPtr pvtwRecord = deck->getKeyword("PVTW")->getRecord(region_number); if (pvtwRecord->getItem("WATER_COMPRESSIBILITY")->getSIDouble(0) != 0.0 || pvtwRecord->getItem("WATER_VISCOSIBILITY")->getSIDouble(0) != 0.0) { OPM_MESSAGE("Compressibility effects in PVTW are ignored."); @@ -129,8 +74,8 @@ namespace Opm } // Oil viscosity. - if (newParserDeck->hasKeyword("PVCDO")) { - Opm::DeckRecordConstPtr pvcdoRecord = newParserDeck->getKeyword("PVCDO")->getRecord(region_number); + if (deck->hasKeyword("PVCDO")) { + Opm::DeckRecordConstPtr pvcdoRecord = deck->getKeyword("PVCDO")->getRecord(region_number); if (pvcdoRecord->getItem("OIL_COMPRESSIBILITY")->getSIDouble(0) != 0.0 || pvcdoRecord->getItem("OIL_VISCOSIBILITY")->getSIDouble(0) != 0.0) { diff --git a/opm/core/props/pvt/PvtPropertiesIncompFromDeck.hpp b/opm/core/props/pvt/PvtPropertiesIncompFromDeck.hpp index 4ffe9864..94ede51c 100644 --- a/opm/core/props/pvt/PvtPropertiesIncompFromDeck.hpp +++ b/opm/core/props/pvt/PvtPropertiesIncompFromDeck.hpp @@ -20,7 +20,6 @@ #ifndef OPM_PVTPROPERTIESINCOMPFROMDECK_HEADER_INCLUDED #define OPM_PVTPROPERTIESINCOMPFROMDECK_HEADER_INCLUDED -#include #include #include @@ -39,10 +38,7 @@ namespace Opm PvtPropertiesIncompFromDeck(); /// Initialize from deck. - void init(const EclipseGridParser& deck); - - /// Initialize from deck. - void init(Opm::DeckConstPtr newParserDeck); + void init(Opm::DeckConstPtr deck); /// Number of active phases. int numPhases() const; diff --git a/opm/core/props/pvt/SinglePvtConstCompr.hpp b/opm/core/props/pvt/SinglePvtConstCompr.hpp index a071e318..180611ca 100644 --- a/opm/core/props/pvt/SinglePvtConstCompr.hpp +++ b/opm/core/props/pvt/SinglePvtConstCompr.hpp @@ -43,21 +43,6 @@ namespace Opm class SinglePvtConstCompr : public SinglePvtInterface { public: - typedef std::vector > table_t; - - SinglePvtConstCompr(const table_t& pvtw) - { - const int region_number = 0; - if (pvtw.size() != 1) { - OPM_THROW(std::runtime_error, "More than one PVD-region"); - } - ref_press_ = pvtw[region_number][0]; - ref_B_ = pvtw[region_number][1]; - comp_ = pvtw[region_number][2]; - viscosity_ = pvtw[region_number][3]; - visc_comp_ = pvtw[region_number][4]; - } - SinglePvtConstCompr(const Opm::PvtwTable &pvtwTable) { if (pvtwTable.numRows() != 1) @@ -71,17 +56,17 @@ namespace Opm visc_comp_ = pvtwTable.getViscosibilityColumn()[0]; } - SinglePvtConstCompr(const Opm::PvcdoTable &pvdcoTable) + SinglePvtConstCompr(const Opm::PvcdoTable &pvcdoTable) { - if (pvdcoTable.numRows() != 1) + if (pvcdoTable.numRows() != 1) OPM_THROW(std::runtime_error, - "The table specified by the PVDCO keyword is required" + "The table specified by the PVCDO keyword is required" "to exhibit exactly one row."); - ref_press_ = pvdcoTable.getPressureColumn()[0]; - ref_B_ = pvdcoTable.getFormationFactorColumn()[0]; - comp_ = pvdcoTable.getCompressibilityColumn()[0]; - viscosity_ = pvdcoTable.getViscosityColumn()[0]; - visc_comp_ = pvdcoTable.getViscosibilityColumn()[0]; + ref_press_ = pvcdoTable.getPressureColumn()[0]; + ref_B_ = pvcdoTable.getFormationFactorColumn()[0]; + comp_ = pvcdoTable.getCompressibilityColumn()[0]; + viscosity_ = pvcdoTable.getViscosityColumn()[0]; + visc_comp_ = pvcdoTable.getViscosibilityColumn()[0]; } SinglePvtConstCompr(double visc) diff --git a/opm/core/props/pvt/SinglePvtDead.cpp b/opm/core/props/pvt/SinglePvtDead.cpp index 9046f5ec..68449de2 100644 --- a/opm/core/props/pvt/SinglePvtDead.cpp +++ b/opm/core/props/pvt/SinglePvtDead.cpp @@ -33,35 +33,6 @@ namespace Opm //------------------------------------------------------------------------ // Member functions //------------------------------------------------------------------------- - /// Constructor - SinglePvtDead::SinglePvtDead(const table_t& pvd_table) - { - const int region_number = 0; - if (pvd_table.size() != 1) { - OPM_THROW(std::runtime_error, "More than one PVT-region"); - } - - // Copy data - const int sz = pvd_table[region_number][0].size(); - std::vector press(sz); - std::vector b(sz); - std::vector visc(sz); - for (int i = 0; i < sz; ++i) { - press[i] = pvd_table[region_number][0][i]; - b[i] = 1.0 / pvd_table[region_number][1][i]; - visc[i] = pvd_table[region_number][2][i]; - } - b_ = NonuniformTableLinear(press, b); - viscosity_ = NonuniformTableLinear(press, visc); - - // Dumping the created tables. -// static int count = 0; -// std::ofstream os((std::string("dump-") + boost::lexical_cast(count++)).c_str()); -// os.precision(15); -// os << "1/B\n\n" << one_over_B_ -// << "\n\nvisc\n\n" << viscosity_ << std::endl; - } - /// Constructor SinglePvtDead::SinglePvtDead(const Opm::PvdoTable& pvdoTable) { diff --git a/opm/core/props/pvt/SinglePvtDead.hpp b/opm/core/props/pvt/SinglePvtDead.hpp index 3c96e36c..e7d28872 100644 --- a/opm/core/props/pvt/SinglePvtDead.hpp +++ b/opm/core/props/pvt/SinglePvtDead.hpp @@ -42,8 +42,6 @@ namespace Opm class SinglePvtDead : public SinglePvtInterface { public: - typedef std::vector > > table_t; - SinglePvtDead(const table_t& pvd_table); SinglePvtDead(const Opm::PvdoTable& pvdoTable); SinglePvtDead(const Opm::PvdgTable& pvdgTable); virtual ~SinglePvtDead(); diff --git a/opm/core/props/pvt/SinglePvtDeadSpline.cpp b/opm/core/props/pvt/SinglePvtDeadSpline.cpp index fc08d357..9f64197d 100644 --- a/opm/core/props/pvt/SinglePvtDeadSpline.cpp +++ b/opm/core/props/pvt/SinglePvtDeadSpline.cpp @@ -36,28 +36,6 @@ namespace Opm // Member functions //------------------------------------------------------------------------- - /// Constructor - SinglePvtDeadSpline::SinglePvtDeadSpline(const table_t& pvd_table, const int samples) - { - const int region_number = 0; - if (pvd_table.size() != 1) { - OPM_THROW(std::runtime_error, "More than one PVT-region"); - } - - // Copy data - const int sz = pvd_table[region_number][0].size(); - std::vector press(sz); - std::vector B_inv(sz); - std::vector visc(sz); - for (int i = 0; i < sz; ++i) { - press[i] = pvd_table[region_number][0][i]; - B_inv[i] = 1.0 / pvd_table[region_number][1][i]; - visc[i] = pvd_table[region_number][2][i]; - } - buildUniformMonotoneTable(press, B_inv, samples, b_); - buildUniformMonotoneTable(press, visc, samples, viscosity_); - } - SinglePvtDeadSpline::SinglePvtDeadSpline(const Opm::PvdoTable &pvdoTable, int samples) { int numRows = pvdoTable.numRows(); diff --git a/opm/core/props/pvt/SinglePvtDeadSpline.hpp b/opm/core/props/pvt/SinglePvtDeadSpline.hpp index 65bd2561..88320ed2 100644 --- a/opm/core/props/pvt/SinglePvtDeadSpline.hpp +++ b/opm/core/props/pvt/SinglePvtDeadSpline.hpp @@ -41,9 +41,6 @@ namespace Opm class SinglePvtDeadSpline : public SinglePvtInterface { public: - typedef std::vector > > table_t; - - SinglePvtDeadSpline(const table_t& pvd_table, const int samples); SinglePvtDeadSpline(const Opm::PvdoTable &pvdoTable, int samples); SinglePvtDeadSpline(const Opm::PvdgTable &pvdgTable, int samples); virtual ~SinglePvtDeadSpline(); diff --git a/opm/core/props/pvt/SinglePvtLiveGas.cpp b/opm/core/props/pvt/SinglePvtLiveGas.cpp index abd13415..abc9a641 100644 --- a/opm/core/props/pvt/SinglePvtLiveGas.cpp +++ b/opm/core/props/pvt/SinglePvtLiveGas.cpp @@ -46,43 +46,6 @@ namespace Opm //------------------------------------------------------------------------ // Member functions //------------------------------------------------------------------------- - - /// Constructor - SinglePvtLiveGas::SinglePvtLiveGas(const table_t& pvtg) - { - // GAS, PVTG - const int region_number = 0; - if (pvtg.size() != 1) { - OPM_THROW(std::runtime_error, "More than one PVD-region"); - } - saturated_gas_table_.resize(4); - const int sz = pvtg[region_number].size(); - for (int k=0; k<4; ++k) { - saturated_gas_table_[k].resize(sz); - } - - for (int i=0; i > > table_t; - - SinglePvtLiveGas(const table_t& pvto); SinglePvtLiveGas(const Opm::PvtgTable& pvtgTable); virtual ~SinglePvtLiveGas(); diff --git a/opm/core/props/pvt/SinglePvtLiveOil.cpp b/opm/core/props/pvt/SinglePvtLiveOil.cpp index 66f1036e..b7e4b113 100644 --- a/opm/core/props/pvt/SinglePvtLiveOil.cpp +++ b/opm/core/props/pvt/SinglePvtLiveOil.cpp @@ -35,74 +35,6 @@ namespace Opm // Member functions //------------------------------------------------------------------------- - /// Constructor - SinglePvtLiveOil::SinglePvtLiveOil(const table_t& pvto) - { - // OIL, PVTO - const int region_number = 0; - if (pvto.size() != 1) { - OPM_THROW(std::runtime_error, "More than one PVD-region"); - } - saturated_oil_table_.resize(4); - const int sz = pvto[region_number].size(); - for (int k=0; k<4; ++k) { - saturated_oil_table_[k].resize(sz); - } - for (int i=0; i 1) { - continue; - } - // Look ahead for next record containing undersaturated data - if (iNext < i) { - iNext = i+1; - while (iNext > >::size_type sz_t; - for (sz_t j=1; j > > table_t; - - SinglePvtLiveOil(const table_t& pvto); SinglePvtLiveOil(const Opm::PvtoTable &pvtoTable); virtual ~SinglePvtLiveOil(); diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index d1729533..ed945aff 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -19,7 +19,6 @@ #include "config.h" #include -#include #include #include #include @@ -41,46 +40,19 @@ namespace Opm rock_comp_ = param.getDefault("rock_compressibility", 0.0)/unit::barsa; } - RockCompressibility::RockCompressibility(const EclipseGridParser& deck) + RockCompressibility::RockCompressibility(Opm::DeckConstPtr deck) : pref_(0.0), rock_comp_(0.0) { - if (deck.hasField("ROCKTAB")) { - const table_t& rt = deck.getROCKTAB().rocktab_; - if (rt.size() != 1) { - OPM_THROW(std::runtime_error, "Can only handle a single region in ROCKTAB."); - } - const int n = rt[0][0].size(); - p_.resize(n); - poromult_.resize(n); - transmult_.resize(n); - for (int i = 0; i < n; ++i) { - p_[i] = rt[0][0][i]; - poromult_[i] = rt[0][1][i]; - transmult_[i] = rt[0][2][i]; - } - } else if (deck.hasField("ROCK")) { - const ROCK& r = deck.getROCK(); - pref_ = r.rock_compressibilities_[0][0]; - rock_comp_ = r.rock_compressibilities_[0][1]; - } else { - std::cout << "**** warning: no rock compressibility data found in deck (ROCK or ROCKTAB)." << std::endl; - } - } - - RockCompressibility::RockCompressibility(Opm::DeckConstPtr newParserDeck) - : pref_(0.0), - rock_comp_(0.0) - { - if (newParserDeck->hasKeyword("ROCKTAB")) { - Opm::DeckKeywordConstPtr rtKeyword = newParserDeck->getKeyword("ROCKTAB"); + if (deck->hasKeyword("ROCKTAB")) { + Opm::DeckKeywordConstPtr rtKeyword = deck->getKeyword("ROCKTAB"); if (rtKeyword->size() != 1) OPM_THROW(std::runtime_error, "Can only handle a single region in ROCKTAB."); // the number of colums of the "ROCKTAB" keyword // depends on the presence of the "RKTRMDIR" // keyword. Messy stuff... - bool isDirectional = newParserDeck->hasKeyword("RKTRMDIR"); + bool isDirectional = deck->hasKeyword("RKTRMDIR"); if (isDirectional) { // well, okay. we don't support non-isotropic @@ -94,8 +66,8 @@ namespace Opm p_ = rocktabTable.getPressureColumn(); poromult_ = rocktabTable.getPoreVolumeMultiplierColumn(); transmult_ = rocktabTable.getTransmissibilityMultiplierColumn(); - } else if (newParserDeck->hasKeyword("ROCK")) { - Opm::RockTable rockTable(newParserDeck->getKeyword("ROCK")); + } else if (deck->hasKeyword("ROCK")) { + Opm::RockTable rockTable(deck->getKeyword("ROCK")); if (rockTable.numRows() != 1) OPM_THROW(std::runtime_error, "Can only handle a single region in ROCK."); diff --git a/opm/core/props/rock/RockCompressibility.hpp b/opm/core/props/rock/RockCompressibility.hpp index bd375e1c..f27c4544 100644 --- a/opm/core/props/rock/RockCompressibility.hpp +++ b/opm/core/props/rock/RockCompressibility.hpp @@ -27,7 +27,6 @@ namespace Opm { - class EclipseGridParser; namespace parameter { class ParameterGroup; } class RockCompressibility @@ -35,11 +34,7 @@ namespace Opm public: /// Construct from input deck. /// Looks for the keywords ROCK and ROCKTAB. - RockCompressibility(const EclipseGridParser& deck); - - /// Construct from input deck. - /// Looks for the keywords ROCK and ROCKTAB. - RockCompressibility(Opm::DeckConstPtr newParserDeck); + RockCompressibility(Opm::DeckConstPtr deck); /// Construct from parameters. /// Accepts the following parameters (with defaults). diff --git a/opm/core/props/rock/RockFromDeck.cpp b/opm/core/props/rock/RockFromDeck.cpp index e34d784d..9aea30c1 100644 --- a/opm/core/props/rock/RockFromDeck.cpp +++ b/opm/core/props/rock/RockFromDeck.cpp @@ -21,6 +21,7 @@ #include "config.h" #include #include +#include #include @@ -34,13 +35,9 @@ namespace Opm { enum PermeabilityKind { ScalarPerm, DiagonalPerm, TensorPerm, None, Invalid }; - PermeabilityKind classifyPermeability(const EclipseGridParser& parser); void setScalarPermIfNeeded(std::array& kmap, int i, int j, int k); - PermeabilityKind fillTensor(const EclipseGridParser& parser, - std::vector*>& tensor, - std::array& kmap); - PermeabilityKind fillTensor(Opm::DeckConstPtr newParserDeck, + PermeabilityKind fillTensor(Opm::DeckConstPtr deck, std::vector*>& tensor, std::array& kmap); @@ -56,65 +53,23 @@ namespace Opm { } - - /// Initialize from deck and cell mapping. - /// \param deck Deck input parser - /// \param grid grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. - void RockFromDeck::init(const EclipseGridParser& deck, - const UnstructuredGrid& grid) - { - init(deck, grid.number_of_cells, grid.global_cell, grid.cartdims); - } - - /// Initialize from deck and cell mapping. - /// \param deck Deck input parser - /// \param number_of_cells The number of cells in the grid. - /// \param global_cell The mapping fom local to global cell indices. - /// global_cell[i] is the corresponding global index of i. - /// \param cart_dims The size of the underlying cartesian grid. - void RockFromDeck::init(const EclipseGridParser& deck, + void RockFromDeck::init(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims) { assignPorosity(deck, number_of_cells, global_cell); permfield_valid_.assign(number_of_cells, false); const double perm_threshold = 0.0; // Maybe turn into parameter? - assignPermeability(deck, number_of_cells, global_cell, cart_dims, perm_threshold); - } - - void RockFromDeck::init(Opm::DeckConstPtr newParserDeck, - int number_of_cells, const int* global_cell, - const int* cart_dims) - { - assignPorosity(newParserDeck, number_of_cells, global_cell); - permfield_valid_.assign(number_of_cells, false); - const double perm_threshold = 0.0; // Maybe turn into parameter? - assignPermeability(newParserDeck, number_of_cells, global_cell, cart_dims, + assignPermeability(deck, number_of_cells, global_cell, cart_dims, perm_threshold); } - - void RockFromDeck::assignPorosity(const EclipseGridParser& parser, + void RockFromDeck::assignPorosity(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell) { porosity_.assign(number_of_cells, 1.0); - if (parser.hasField("PORO")) { - const std::vector& poro = parser.getFloatingPointValue("PORO"); - for (int c = 0; c < int(porosity_.size()); ++c) { - const int deck_pos = (global_cell == NULL) ? c : global_cell[c]; - porosity_[c] = poro[deck_pos]; - } - } - } - - void RockFromDeck::assignPorosity(Opm::DeckConstPtr newParserDeck, - int number_of_cells, const int* global_cell) - { - porosity_.assign(number_of_cells, 1.0); - if (newParserDeck->hasKeyword("PORO")) { - const std::vector& poro = newParserDeck->getKeyword("PORO")->getSIDoubleData(); + if (deck->hasKeyword("PORO")) { + const std::vector& poro = deck->getKeyword("PORO")->getSIDoubleData(); for (int c = 0; c < int(porosity_.size()); ++c) { const int deck_pos = (global_cell == NULL) ? c : global_cell[c]; assert(0 <= c && c < (int) porosity_.size()); @@ -124,62 +79,7 @@ namespace Opm } } - - void RockFromDeck::assignPermeability(const EclipseGridParser& parser, - int number_of_cells, - const int* global_cell, - const int* cartdims, - double perm_threshold) - { - const int dim = 3; - const int num_global_cells = cartdims[0]*cartdims[1]*cartdims[2]; - - assert(num_global_cells > 0); - - permeability_.assign(dim * dim * number_of_cells, 0.0); - - std::vector*> tensor; - tensor.reserve(10); - - const std::vector zero(num_global_cells, 0.0); - tensor.push_back(&zero); - - std::array kmap; - PermeabilityKind pkind = fillTensor(parser, tensor, kmap); - if (pkind == Invalid) { - OPM_THROW(std::runtime_error, "Invalid permeability field."); - } - - // Assign permeability values only if such values are - // given in the input deck represented by 'parser'. In - // other words: Don't set any (arbitrary) default values. - // It is infinitely better to experience a reproducible - // crash than subtle errors resulting from a (poorly - // chosen) default value... - // - if (tensor.size() > 1) { - int off = 0; - - for (int c = 0; c < number_of_cells; ++c, off += dim*dim) { - // SharedPermTensor K(dim, dim, &permeability_[off]); - int kix = 0; - const int glob = (global_cell == NULL) ? c : global_cell[c]; - - for (int i = 0; i < dim; ++i) { - for (int j = 0; j < dim; ++j, ++kix) { - // K(i,j) = (*tensor[kmap[kix]])[glob]; - permeability_[off + kix] = (*tensor[kmap[kix]])[glob]; - } - // K(i,i) = std::max(K(i,i), perm_threshold); - permeability_[off + 3*i + i] = std::max(permeability_[off + 3*i + i], perm_threshold); - } - - permfield_valid_[c] = std::vector::value_type(1); - } - } - } - - void RockFromDeck::assignPermeability(Opm::DeckConstPtr newParserDeck, + void RockFromDeck::assignPermeability(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cartdims, @@ -200,13 +100,13 @@ namespace Opm tensor.push_back(&zero); std::array kmap; - PermeabilityKind pkind = fillTensor(newParserDeck, tensor, kmap); + PermeabilityKind pkind = fillTensor(deck, tensor, kmap); if (pkind == Invalid) { OPM_THROW(std::runtime_error, "Invalid permeability field."); } // Assign permeability values only if such values are - // given in the input deck represented by 'newParserDeck'. In + // given in the input deck represented by 'deck'. In // other words: Don't set any (arbitrary) default values. // It is infinitely better to experience a reproducible // crash than subtle errors resulting from a (poorly @@ -236,7 +136,6 @@ namespace Opm } namespace { - /// @brief /// Classify and verify a given permeability specification /// from a structural point of view. In particular, we @@ -244,7 +143,7 @@ namespace Opm /// components such as @f$k_{xy}@f$ unless the /// corresponding diagonal components are known as well. /// - /// @param parser [in] + /// @param deck [in] /// An Eclipse data parser capable of answering which /// permeability components are present in a given input /// deck. @@ -256,85 +155,19 @@ namespace Opm /// TensorPerm at least one cross-component given. /// None no components given. /// Invalid invalid set of components given. - PermeabilityKind classifyPermeability(const EclipseGridParser& parser) + PermeabilityKind classifyPermeability(Opm::DeckConstPtr deck) { - const bool xx = parser.hasField("PERMX" ); - const bool xy = parser.hasField("PERMXY"); - const bool xz = parser.hasField("PERMXZ"); + const bool xx = deck->hasKeyword("PERMX" ); + const bool xy = deck->hasKeyword("PERMXY"); + const bool xz = deck->hasKeyword("PERMXZ"); - const bool yx = parser.hasField("PERMYX"); - const bool yy = parser.hasField("PERMY" ); - const bool yz = parser.hasField("PERMYZ"); + const bool yx = deck->hasKeyword("PERMYX"); + const bool yy = deck->hasKeyword("PERMY" ); + const bool yz = deck->hasKeyword("PERMYZ"); - const bool zx = parser.hasField("PERMZX"); - const bool zy = parser.hasField("PERMZY"); - const bool zz = parser.hasField("PERMZ" ); - - int num_cross_comp = xy + xz + yx + yz + zx + zy; - int num_comp = xx + yy + zz + num_cross_comp; - PermeabilityKind retval = None; - if (num_cross_comp > 0) { - retval = TensorPerm; - } else { - if (num_comp == 1) { - retval = ScalarPerm; - } else if (num_comp >= 2) { - retval = DiagonalPerm; - } - } - - bool ok = true; - if (num_comp > 0) { - // At least one tensor component specified on input. - // Verify that any remaining components are OK from a - // structural point of view. In particular, there - // must not be any cross-components (e.g., k_{xy}) - // unless the corresponding diagonal component (e.g., - // k_{xx}) is present as well... - // - ok = xx || !(xy || xz || yx || zx) ; - ok = ok && (yy || !(yx || yz || xy || zy)); - ok = ok && (zz || !(zx || zy || xz || yz)); - } - if (!ok) { - retval = Invalid; - } - - return retval; - } - - /// @brief - /// Classify and verify a given permeability specification - /// from a structural point of view. In particular, we - /// verify that there are no off-diagonal permeability - /// components such as @f$k_{xy}@f$ unless the - /// corresponding diagonal components are known as well. - /// - /// @param newParserDeck [in] - /// An Eclipse data parser capable of answering which - /// permeability components are present in a given input - /// deck. - /// - /// @return - /// An enum value with the following possible values: - /// ScalarPerm only one component was given. - /// DiagonalPerm more than one component given. - /// TensorPerm at least one cross-component given. - /// None no components given. - /// Invalid invalid set of components given. - PermeabilityKind classifyPermeability(Opm::DeckConstPtr newParserDeck) - { - const bool xx = newParserDeck->hasKeyword("PERMX" ); - const bool xy = newParserDeck->hasKeyword("PERMXY"); - const bool xz = newParserDeck->hasKeyword("PERMXZ"); - - const bool yx = newParserDeck->hasKeyword("PERMYX"); - const bool yy = newParserDeck->hasKeyword("PERMY" ); - const bool yz = newParserDeck->hasKeyword("PERMYZ"); - - const bool zx = newParserDeck->hasKeyword("PERMZX"); - const bool zy = newParserDeck->hasKeyword("PERMZY"); - const bool zz = newParserDeck->hasKeyword("PERMZ" ); + const bool zx = deck->hasKeyword("PERMZX"); + const bool zy = deck->hasKeyword("PERMZY"); + const bool zz = deck->hasKeyword("PERMZ" ); int num_cross_comp = xy + xz + yx + yz + zx + zy; int num_comp = xx + yy + zz + num_cross_comp; @@ -397,7 +230,6 @@ namespace Opm if (kmap[k] == 0) { kmap[k] = kmap[i]; } } - /// @brief /// Extract pointers to appropriate tensor components from /// input deck. The permeability tensor is, generally, @@ -430,11 +262,11 @@ namespace Opm /// /// @param [out] tensor /// @param [out] kmap - PermeabilityKind fillTensor(const EclipseGridParser& parser, + PermeabilityKind fillTensor(Opm::DeckConstPtr deck, std::vector*>& tensor, std::array& kmap) { - PermeabilityKind kind = classifyPermeability(parser); + PermeabilityKind kind = classifyPermeability(deck); if (kind == Invalid) { OPM_THROW(std::runtime_error, "Invalid set of permeability fields given."); } @@ -447,151 +279,51 @@ namespace Opm // ----------------------------------------------------------- // 1st row: [kxx, kxy, kxz] - if (parser.hasField("PERMX" )) { + if (deck->hasKeyword("PERMX" )) { kmap[xx] = tensor.size(); - tensor.push_back(&parser.getFloatingPointValue("PERMX" )); + tensor.push_back(&deck->getKeyword("PERMX")->getSIDoubleData()); setScalarPermIfNeeded(kmap, xx, yy, zz); } - if (parser.hasField("PERMXY")) { + if (deck->hasKeyword("PERMXY")) { kmap[xy] = kmap[yx] = tensor.size(); // Enforce symmetry. - tensor.push_back(&parser.getFloatingPointValue("PERMXY")); + tensor.push_back(&deck->getKeyword("PERMXY")->getSIDoubleData()); } - if (parser.hasField("PERMXZ")) { + if (deck->hasKeyword("PERMXZ")) { kmap[xz] = kmap[zx] = tensor.size(); // Enforce symmetry. - tensor.push_back(&parser.getFloatingPointValue("PERMXZ")); + tensor.push_back(&deck->getKeyword("PERMXZ")->getSIDoubleData()); } // ----------------------------------------------------------- // 2nd row: [kyx, kyy, kyz] - if (parser.hasField("PERMYX")) { + if (deck->hasKeyword("PERMYX")) { kmap[yx] = kmap[xy] = tensor.size(); // Enforce symmetry. - tensor.push_back(&parser.getFloatingPointValue("PERMYX")); + tensor.push_back(&deck->getKeyword("PERMYX")->getSIDoubleData()); } - if (parser.hasField("PERMY" )) { + if (deck->hasKeyword("PERMY" )) { kmap[yy] = tensor.size(); - tensor.push_back(&parser.getFloatingPointValue("PERMY" )); + tensor.push_back(&deck->getKeyword("PERMY")->getSIDoubleData()); setScalarPermIfNeeded(kmap, yy, zz, xx); } - if (parser.hasField("PERMYZ")) { + if (deck->hasKeyword("PERMYZ")) { kmap[yz] = kmap[zy] = tensor.size(); // Enforce symmetry. - tensor.push_back(&parser.getFloatingPointValue("PERMYZ")); + tensor.push_back(&deck->getKeyword("PERMYZ")->getSIDoubleData()); } // ----------------------------------------------------------- // 3rd row: [kzx, kzy, kzz] - if (parser.hasField("PERMZX")) { + if (deck->hasKeyword("PERMZX")) { kmap[zx] = kmap[xz] = tensor.size(); // Enforce symmetry. - tensor.push_back(&parser.getFloatingPointValue("PERMZX")); + tensor.push_back(&deck->getKeyword("PERMZX")->getSIDoubleData()); } - if (parser.hasField("PERMZY")) { + if (deck->hasKeyword("PERMZY")) { kmap[zy] = kmap[yz] = tensor.size(); // Enforce symmetry. - tensor.push_back(&parser.getFloatingPointValue("PERMZY")); + tensor.push_back(&deck->getKeyword("PERMZY")->getSIDoubleData()); } - if (parser.hasField("PERMZ" )) { + if (deck->hasKeyword("PERMZ" )) { kmap[zz] = tensor.size(); - tensor.push_back(&parser.getFloatingPointValue("PERMZ" )); - - setScalarPermIfNeeded(kmap, zz, xx, yy); - } - return kind; - } - - /// @brief - /// Extract pointers to appropriate tensor components from - /// input deck. The permeability tensor is, generally, - /// @code - /// [ kxx kxy kxz ] - /// K = [ kyx kyy kyz ] - /// [ kzx kzy kzz ] - /// @endcode - /// We store these values in a linear array using natural - /// ordering with the column index cycling the most rapidly. - /// In particular we use the representation - /// @code - /// [ 0 1 2 3 4 5 6 7 8 ] - /// K = [ kxx, kxy, kxz, kyx, kyy, kyz, kzx, kzy, kzz ] - /// @endcode - /// Moreover, we explicitly enforce symmetric tensors by - /// assigning - /// @code - /// 3 1 6 2 7 5 - /// kyx = kxy, kzx = kxz, kzy = kyz - /// @endcode - /// However, we make no attempt at enforcing positive - /// definite tensors. - /// - /// @param [in] parser - /// An Eclipse data parser capable of answering which - /// permeability components are present in a given input - /// deck as well as retrieving the numerical value of each - /// permeability component in each grid cell. - /// - /// @param [out] tensor - /// @param [out] kmap - PermeabilityKind fillTensor(Opm::DeckConstPtr newParserDeck, - std::vector*>& tensor, - std::array& kmap) - { - PermeabilityKind kind = classifyPermeability(newParserDeck); - if (kind == Invalid) { - OPM_THROW(std::runtime_error, "Invalid set of permeability fields given."); - } - assert(tensor.size() == 1); - for (int i = 0; i < 9; ++i) { kmap[i] = 0; } - - enum { xx, xy, xz, // 0, 1, 2 - yx, yy, yz, // 3, 4, 5 - zx, zy, zz }; // 6, 7, 8 - - // ----------------------------------------------------------- - // 1st row: [kxx, kxy, kxz] - if (newParserDeck->hasKeyword("PERMX" )) { - kmap[xx] = tensor.size(); - tensor.push_back(&newParserDeck->getKeyword("PERMX")->getSIDoubleData()); - - setScalarPermIfNeeded(kmap, xx, yy, zz); - } - if (newParserDeck->hasKeyword("PERMXY")) { - kmap[xy] = kmap[yx] = tensor.size(); // Enforce symmetry. - tensor.push_back(&newParserDeck->getKeyword("PERMXY")->getSIDoubleData()); - } - if (newParserDeck->hasKeyword("PERMXZ")) { - kmap[xz] = kmap[zx] = tensor.size(); // Enforce symmetry. - tensor.push_back(&newParserDeck->getKeyword("PERMXZ")->getSIDoubleData()); - } - - // ----------------------------------------------------------- - // 2nd row: [kyx, kyy, kyz] - if (newParserDeck->hasKeyword("PERMYX")) { - kmap[yx] = kmap[xy] = tensor.size(); // Enforce symmetry. - tensor.push_back(&newParserDeck->getKeyword("PERMYX")->getSIDoubleData()); - } - if (newParserDeck->hasKeyword("PERMY" )) { - kmap[yy] = tensor.size(); - tensor.push_back(&newParserDeck->getKeyword("PERMY")->getSIDoubleData()); - - setScalarPermIfNeeded(kmap, yy, zz, xx); - } - if (newParserDeck->hasKeyword("PERMYZ")) { - kmap[yz] = kmap[zy] = tensor.size(); // Enforce symmetry. - tensor.push_back(&newParserDeck->getKeyword("PERMYZ")->getSIDoubleData()); - } - - // ----------------------------------------------------------- - // 3rd row: [kzx, kzy, kzz] - if (newParserDeck->hasKeyword("PERMZX")) { - kmap[zx] = kmap[xz] = tensor.size(); // Enforce symmetry. - tensor.push_back(&newParserDeck->getKeyword("PERMZX")->getSIDoubleData()); - } - if (newParserDeck->hasKeyword("PERMZY")) { - kmap[zy] = kmap[yz] = tensor.size(); // Enforce symmetry. - tensor.push_back(&newParserDeck->getKeyword("PERMZY")->getSIDoubleData()); - } - if (newParserDeck->hasKeyword("PERMZ" )) { - kmap[zz] = tensor.size(); - tensor.push_back(&newParserDeck->getKeyword("PERMZ")->getSIDoubleData()); + tensor.push_back(&deck->getKeyword("PERMZ")->getSIDoubleData()); setScalarPermIfNeeded(kmap, zz, xx, yy); } diff --git a/opm/core/props/rock/RockFromDeck.hpp b/opm/core/props/rock/RockFromDeck.hpp index 5d8c44ae..23aa75d3 100644 --- a/opm/core/props/rock/RockFromDeck.hpp +++ b/opm/core/props/rock/RockFromDeck.hpp @@ -20,9 +20,6 @@ #ifndef OPM_ROCKFROMDECK_HEADER_INCLUDED #define OPM_ROCKFROMDECK_HEADER_INCLUDED - -#include - #include #include @@ -38,30 +35,13 @@ namespace Opm /// Default constructor. RockFromDeck(); - /// Initialize from deck and grid. - /// \param deck Deck input parser - /// \param grid Grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. - void init(const EclipseGridParser& deck, - const UnstructuredGrid& grid); - /// Initialize from deck and cell mapping. - /// \param deck Deck input parser + /// \param deck Deck produced by the opm-parser code /// \param number_of_cells The number of cells in the grid. /// \param global_cell The mapping fom local to global cell indices. /// global_cell[i] is the corresponding global index of i. /// \param cart_dims The size of the underlying cartesian grid. - void init(const EclipseGridParser& deck, - int number_of_cells, const int* global_cell, - const int* cart_dims); - /// Initialize from deck and cell mapping. - /// \param newParserDeck Deck produced by the opm-parser code - /// \param number_of_cells The number of cells in the grid. - /// \param global_cell The mapping fom local to global cell indices. - /// global_cell[i] is the corresponding global index of i. - /// \param cart_dims The size of the underlying cartesian grid. - void init(Opm::DeckConstPtr newParserDeck, + void init(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims); @@ -92,18 +72,10 @@ namespace Opm } private: - void assignPorosity(const EclipseGridParser& parser, + void assignPorosity(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell); - void assignPorosity(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell); - void assignPermeability(const EclipseGridParser& parser, - int number_of_cells, - const int* global_cell, - const int* cart_dims, - const double perm_threshold); - void assignPermeability(Opm::DeckConstPtr newParserDeck, + void assignPermeability(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const int* cart_dims, diff --git a/opm/core/props/satfunc/SatFuncBase.hpp b/opm/core/props/satfunc/SatFuncBase.hpp index 268ecd9d..dd80a10b 100644 --- a/opm/core/props/satfunc/SatFuncBase.hpp +++ b/opm/core/props/satfunc/SatFuncBase.hpp @@ -17,7 +17,6 @@ #ifndef SATFUNCBASE_HPP #define SATFUNCBASE_HPP -#include #include #include #include @@ -79,11 +78,7 @@ namespace Opm class SatFuncBase : public BlackoilPhases { public: - void init(const EclipseGridParser& deck, - const int table_num, - const PhaseUsage phase_usg, - const int samples); - void init(Opm::DeckConstPtr newParserDeck, + void init(Opm::DeckConstPtr deck, const int table_num, const PhaseUsage phase_usg, const int samples); @@ -126,7 +121,7 @@ namespace Opm }; template - void SatFuncBase::init(const EclipseGridParser& deck, + void SatFuncBase::init(Opm::DeckConstPtr deck, const int table_num, const PhaseUsage phase_usg, const int samples) @@ -135,139 +130,7 @@ namespace Opm double swco = 0.0; double swmax = 1.0; if (phase_usage.phase_used[Aqua]) { - const SWOF::table_t& swof_table = deck.getSWOF().swof_; - const std::vector& sw = swof_table[table_num][0]; - const std::vector& krw = swof_table[table_num][1]; - const std::vector& krow = swof_table[table_num][2]; - const std::vector& pcow = swof_table[table_num][3]; - if (krw.front() != 0.0 || krow.back() != 0.0) { - OPM_THROW(std::runtime_error, "Error SWOF data - non-zero krw(swco) and/or krow(1-sor)"); - } - - // Extend the tables with constant values such that the - // derivatives at the endpoints are zero - int n = sw.size(); - std::vector sw_ex(n+2); - std::vector krw_ex(n+2); - std::vector krow_ex(n+2); - std::vector pcow_ex(n+2); - - extendTable(sw,sw_ex,1); - extendTable(krw,krw_ex,0); - extendTable(krow,krow_ex,0); - extendTable(pcow,pcow_ex,0); - - initializeTableType(krw_,sw_ex, krw_ex, samples); - initializeTableType(krow_,sw_ex, krow_ex, samples); - initializeTableType(pcow_,sw_ex, pcow_ex, samples); - - krocw_ = krow[0]; // At connate water -> ecl. SWOF - swco = sw[0]; - smin_[phase_usage.phase_pos[Aqua]] = sw[0]; - swmax = sw.back(); - smax_[phase_usage.phase_pos[Aqua]] = sw.back(); - - krwmax_ = krw.back(); - kromax_ = krow.front(); - swcr_ = swmax; - sowcr_ = 1.0 - swco; - krwr_ = krw.back(); - krorw_ = krow.front(); - for (std::vector::size_type i=1; i 0.0) { - swcr_ = sw[i-1]; - krorw_ = krow[i-1]; - break; - } - } - for (std::vector::size_type i=sw.size()-1; i>=1; --i) { - if (krow[i-1]> 0.0) { - sowcr_ = 1.0 - sw[i]; - krwr_ = krw[i]; - break; - } - } - } - if (phase_usage.phase_used[Vapour]) { - const SGOF::table_t& sgof_table = deck.getSGOF().sgof_; - const std::vector& sg = sgof_table[table_num][0]; - const std::vector& krg = sgof_table[table_num][1]; - const std::vector& krog = sgof_table[table_num][2]; - const std::vector& pcog = sgof_table[table_num][3]; - - // Extend the tables with constant values such that the - // derivatives at the endpoints are zero - int n = sg.size(); - std::vector sg_ex(n+2); - std::vector krg_ex(n+2); - std::vector krog_ex(n+2); - std::vector pcog_ex(n+2); - - extendTable(sg,sg_ex,1); - extendTable(krg,krg_ex,0); - extendTable(krog,krog_ex,0); - extendTable(pcog,pcog_ex,0); - - initializeTableType(krg_,sg_ex, krg_ex, samples); - initializeTableType(krog_,sg_ex, krog_ex, samples); - initializeTableType(pcog_,sg_ex, pcog_ex, samples); - - smin_[phase_usage.phase_pos[Vapour]] = sg[0]; - if (std::fabs(sg.back() + swco - 1.0) > 1e-3) { - OPM_THROW(std::runtime_error, "Gas maximum saturation in SGOF table = " << sg.back() << - ", should equal (1.0 - connate water sat) = " << (1.0 - swco)); - } - smax_[phase_usage.phase_pos[Vapour]] = sg.back(); - smin_[phase_usage.phase_pos[Vapour]] = sg.front(); - krgmax_ = krg.back(); - - sgcr_ = sg.front(); - sogcr_ = 1.0 - sg.back(); - krgr_ = krg.back(); - krorg_ = krg.front(); - for (std::vector::size_type i=1; i 0.0) { - sgcr_ = sg[i-1]; - krorg_ = krog[i-1]; - break; - } - } - for (std::vector::size_type i=sg.size()-1; i>=1; --i) { - if (krog[i-1]> 0.0) { - sogcr_ = 1.0 - sg[i]; - krgr_ = krg[i]; - break; - } - } - - } - - if (phase_usage.phase_used[Vapour] && phase_usage.phase_used[Aqua]) { - sowcr_ -= smin_[phase_usage.phase_pos[Vapour]]; - sogcr_ -= smin_[phase_usage.phase_pos[Aqua]]; - smin_[phase_usage.phase_pos[Liquid]] = 0.0; - smax_[phase_usage.phase_pos[Liquid]] = 1.0 - smin_[phase_usage.phase_pos[Aqua]] - - smin_[phase_usage.phase_pos[Vapour]]; // First entry in SGOF-table supposed to be zero anyway ... - } else if (phase_usage.phase_used[Aqua]) { - smin_[phase_usage.phase_pos[Liquid]] = 1.0 - smax_[phase_usage.phase_pos[Aqua]]; - smax_[phase_usage.phase_pos[Liquid]] = 1.0 - smin_[phase_usage.phase_pos[Aqua]]; - } else if (phase_usage.phase_used[Vapour]) { - smin_[phase_usage.phase_pos[Liquid]] = 1.0 - smax_[phase_usage.phase_pos[Vapour]]; - smax_[phase_usage.phase_pos[Liquid]] = 1.0 - smin_[phase_usage.phase_pos[Vapour]]; - } - } - - template - void SatFuncBase::init(Opm::DeckConstPtr newParserDeck, - const int table_num, - const PhaseUsage phase_usg, - const int samples) - { - phase_usage = phase_usg; - double swco = 0.0; - double swmax = 1.0; - if (phase_usage.phase_used[Aqua]) { - Opm::SwofTable swof(newParserDeck->getKeyword("SWOF"), table_num); + Opm::SwofTable swof(deck->getKeyword("SWOF"), table_num); const std::vector& sw = swof.getSwColumn(); const std::vector& krw = swof.getKrwColumn(); const std::vector& krow = swof.getKrowColumn(); @@ -321,7 +184,7 @@ namespace Opm } } if (phase_usage.phase_used[Vapour]) { - Opm::SgofTable sgof(newParserDeck->getKeyword("SGOF"), table_num); + Opm::SgofTable sgof(deck->getKeyword("SGOF"), table_num); const std::vector& sg = sgof.getSgColumn(); const std::vector& krg = sgof.getKrgColumn(); const std::vector& krog = sgof.getKrogColumn(); diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck.hpp index ad9c2e70..d9c96ea3 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -59,44 +58,15 @@ namespace Opm /// to logical cartesian indices consistent with the deck. /// \param[in] samples Number of uniform sample points for saturation tables. /// NOTE: samples will only be used with the SatFuncSetUniform template argument. - void init(const EclipseGridParser& deck, + void init(Opm::DeckConstPtr deck, const UnstructuredGrid& grid, const int samples); /// Initialize from deck and grid. /// \param[in] deck Deck input parser - /// \param[in] grid Grid to which property object applies, needed for the - /// mapping from cell indices (typically from a processed grid) - /// to logical cartesian indices consistent with the deck. - /// \param[in] samples Number of uniform sample points for saturation tables. - /// NOTE: samples will only be used with the SatFuncSetUniform template argument. - void init(Opm::DeckConstPtr newParserDeck, - const UnstructuredGrid& grid, - const int samples); - - - /// Initialize from deck and grid. - /// \param[in] deck Deck input parser /// \param[in] number_of_cells The number of cells of the grid to which property /// object applies, needed for the /// mapping from cell indices (typically from a processed - /// grid) to logical cartesian indices consistent with the - /// deck. - /// \param[in] global_cell The mapping from local cell indices of the grid to - /// global cell indices used in the deck. - /// \param[in] begin_cell_centroids Pointer to the first cell_centroid of the grid. - /// \param[in] dimensions The dimensions of the grid. - /// \param[in] samples Number of uniform sample points for saturation tables. - /// \tparam T The iterator Type for the cell centroids. - /// NOTE: samples will only be used with the SatFuncSetUniform template argument. - template - void init(const EclipseGridParser& deck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions, - const int samples); - /// grid) to logical cartesian indices consistent with the /// deck. /// \param[in] global_cell The mapping from local cell indices of the grid to @@ -106,7 +76,7 @@ namespace Opm /// \param[in] samples Number of uniform sample points for saturation tables. /// NOTE: samples will only be used with the SatFuncSetUniform template argument. template - void init(Opm::DeckConstPtr newParserDeck, + void init(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroids, @@ -178,41 +148,20 @@ namespace Opm typedef SatFuncSet Funcs; const Funcs& funcForCell(const int cell) const; - template - void initEPS(const EclipseGridParser& deck, + void initEPS(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroids, int dimensions); template - void initEPSHyst(const EclipseGridParser& deck, + void initEPSHyst(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroids, int dimensions); template - void initEPSKey(const EclipseGridParser& deck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions, - const std::string& keyword, - std::vector& scaleparam); - template - void initEPS(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions); - template - void initEPSHyst(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions); - template - void initEPSKey(Opm::DeckConstPtr newParserDeck, + void initEPSKey(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroids, @@ -237,10 +186,10 @@ namespace Opm const std::vector& krsr, const std::vector& krmax); - bool columnIsMasked_(Opm::DeckConstPtr newParserDeck, + bool columnIsMasked_(Opm::DeckConstPtr deck, const std::string& keywordName, int /* columnIdx */) - { return newParserDeck->getKeyword(keywordName)->getRecord(0)->getItem(0)->getSIDouble(0) != -1.0; } + { return deck->getKeyword(keywordName)->getRecord(0)->getItem(0)->getSIDouble(0) != -1.0; } }; diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index 330997ee..b1124ffa 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -49,30 +49,19 @@ namespace Opm /// Initialize from deck. template - void SaturationPropsFromDeck::init(const EclipseGridParser& deck, + void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, const UnstructuredGrid& grid, const int samples) { - init(deck, grid.number_of_cells, grid.global_cell, grid.cell_centroids, - grid.dimensions, samples); - } - - - /// Initialize from deck. - template - void SaturationPropsFromDeck::init(Opm::DeckConstPtr newParserDeck, - const UnstructuredGrid& grid, - const int samples) - { - init(newParserDeck, grid.number_of_cells, - grid.global_cell, grid.cell_centroids, - grid.dimensions, samples); + this->init(deck, grid.number_of_cells, + grid.global_cell, grid.cell_centroids, + grid.dimensions, samples); } /// Initialize from deck. template - template< class T> - void SaturationPropsFromDeck::init(const EclipseGridParser& deck, + template + void SaturationPropsFromDeck::init(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroids, @@ -86,16 +75,31 @@ namespace Opm if (!phase_usage_.phase_used[Liquid]) { OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- oil phase must be active."); } + + // Check SATOPTS status + bool hysteresis_switch = false; + if (deck->hasKeyword("SATOPTS")) { + const std::vector& satopts = deck->getKeyword("SATOPTS")->getStringData(); + for (size_t i = 0; i < satopts.size(); ++i) { + if (satopts[i] == std::string("HYSTER")) { + hysteresis_switch = true; + } else { + OPM_THROW(std::runtime_error, "Keyword SATOPTS: Switch " << satopts[i] << " not supported. "); + } + } + } // Obtain SATNUM, if it exists, and create cell_to_func_. // Otherwise, let the cell_to_func_ mapping be just empty. int satfuncs_expected = 1; - if (deck.hasField("SATNUM")) { - const std::vector& satnum = deck.getIntegerValue("SATNUM"); + if (deck->hasKeyword("SATNUM")) { + const std::vector& satnum = deck->getKeyword("SATNUM")->getIntData(); satfuncs_expected = *std::max_element(satnum.begin(), satnum.end()); - cell_to_func_.resize(number_of_cells); - for (int cell = 0; cell < number_of_cells; ++cell) { - const int deck_pos = (global_cell == NULL) ? cell : global_cell[cell]; + const int num_cells = number_of_cells; + cell_to_func_.resize(num_cells); + const int* gc = global_cell; + for (int cell = 0; cell < num_cells; ++cell) { + const int deck_pos = (gc == NULL) ? cell : gc[cell]; cell_to_func_[cell] = satnum[deck_pos] - 1; } } @@ -104,15 +108,13 @@ namespace Opm enum { Uninitialized = -1 }; int num_tables = Uninitialized; if (phase_usage_.phase_used[Aqua]) { - const SWOF::table_t& swof_table = deck.getSWOF().swof_; - num_tables = swof_table.size(); + num_tables = deck->getKeyword("SWOF")->size(); if (num_tables < satfuncs_expected) { OPM_THROW(std::runtime_error, "Found " << num_tables << " SWOF tables, SATNUM specifies at least " << satfuncs_expected); } } if (phase_usage_.phase_used[Vapour]) { - const SGOF::table_t& sgof_table = deck.getSGOF().sgof_; - int num_sgof_tables = sgof_table.size(); + int num_sgof_tables = deck->getKeyword("SGOF")->size(); if (num_sgof_tables < satfuncs_expected) { OPM_THROW(std::runtime_error, "Found " << num_tables << " SGOF tables, SATNUM specifies at least " << satfuncs_expected); } @@ -128,147 +130,34 @@ namespace Opm for (int table = 0; table < num_tables; ++table) { satfuncset_[table].init(deck, table, phase_usage_, samples); } - - // Saturation table scaling - do_hyst_ = false; - do_eps_ = false; - do_3pt_ = false; - if (deck.hasField("ENDSCALE")) { - //if (!phase_usage_.phase_used[Aqua] || !phase_usage_.phase_used[Liquid] || phase_usage_.phase_used[Vapour]) { - // OPM_THROW(std::runtime_error, "Currently endpoint-scaling limited to oil-water systems without gas."); - //} - if (deck.getENDSCALE().dir_switch_ != std::string("NODIR")) { - OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- ENDSCALE: Currently only 'NODIR' accepted."); - } - if (deck.getENDSCALE().revers_switch_ != std::string("REVERS")) { - OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- ENDSCALE: Currently only 'REVERS' accepted."); - } - if (deck.hasField("SCALECRS")) { - if (deck.getSCALECRS().scalecrs_ == std::string("YES")) { - do_3pt_ = true; - } - } - do_eps_ = true; - initEPS(deck, number_of_cells, global_cell, begin_cell_centroids, dimensions); - - // For now, a primitive detection of hysteresis. TODO: SATOPTS HYSTER/ and EHYSTR - do_hyst_ = deck.hasField("ISWL") || deck.hasField("ISWU") || deck.hasField("ISWCR") || deck.hasField("ISGL") || - deck.hasField("ISGU") || deck.hasField("ISGCR") || deck.hasField("ISOWCR") || deck.hasField("ISOGCR"); - if (do_hyst_) { - if (deck.hasField("KRW") || deck.hasField("KRG") || deck.hasField("KRO") || deck.hasField("KRWR") || - deck.hasField("KRGR") || deck.hasField("KRORW") || deck.hasField("KRORG") || - deck.hasField("IKRW") || deck.hasField("IKRG") || deck.hasField("IKRO") || deck.hasField("IKRWR") || - deck.hasField("IKRGR") || deck.hasField("IKRORW") || deck.hasField("IKRORG") ) { - OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- ENDSCALE: Currently hysteresis and relperm value scaling can not be combined."); - } - initEPSHyst(deck, number_of_cells, global_cell, begin_cell_centroids, - dimensions); - } - - //OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- ENDSCALE: Under construction ..."); - } - } - - /// Initialize from deck. - template - template - void SaturationPropsFromDeck::init(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroids, - int dimensions, - const int samples) - { - phase_usage_ = phaseUsageFromDeck(newParserDeck); - - // Extract input data. - // Oil phase should be active. - if (!phase_usage_.phase_used[Liquid]) { - OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- oil phase must be active."); - } - - // Check SATOPTS status - bool hysteresis_switch = false; - if (newParserDeck->hasKeyword("SATOPTS")) { - const std::vector& satopts = newParserDeck->getKeyword("SATOPTS")->getStringData(); - for (size_t i = 0; i < satopts.size(); ++i) { - if (satopts[i] == std::string("HYSTER")) { - hysteresis_switch = true; - } else { - OPM_THROW(std::runtime_error, "Keyword SATOPTS: Switch " << satopts[i] << " not supported. "); - } - } - } - - // Obtain SATNUM, if it exists, and create cell_to_func_. - // Otherwise, let the cell_to_func_ mapping be just empty. - int satfuncs_expected = 1; - if (newParserDeck->hasKeyword("SATNUM")) { - const std::vector& satnum = newParserDeck->getKeyword("SATNUM")->getIntData(); - satfuncs_expected = *std::max_element(satnum.begin(), satnum.end()); - const int num_cells = number_of_cells; - cell_to_func_.resize(num_cells); - const int* gc = global_cell; - for (int cell = 0; cell < num_cells; ++cell) { - const int newParserDeck_pos = (gc == NULL) ? cell : gc[cell]; - cell_to_func_[cell] = satnum[newParserDeck_pos] - 1; - } - } - - // Find number of tables, check for consistency. - enum { Uninitialized = -1 }; - int num_tables = Uninitialized; - if (phase_usage_.phase_used[Aqua]) { - num_tables = newParserDeck->getKeyword("SWOF")->size(); - if (num_tables < satfuncs_expected) { - OPM_THROW(std::runtime_error, "Found " << num_tables << " SWOF tables, SATNUM specifies at least " << satfuncs_expected); - } - } - if (phase_usage_.phase_used[Vapour]) { - int num_sgof_tables = newParserDeck->getKeyword("SGOF")->size(); - if (num_sgof_tables < satfuncs_expected) { - OPM_THROW(std::runtime_error, "Found " << num_tables << " SGOF tables, SATNUM specifies at least " << satfuncs_expected); - } - if (num_tables == Uninitialized) { - num_tables = num_sgof_tables; - } else if (num_tables != num_sgof_tables) { - OPM_THROW(std::runtime_error, "Inconsistent number of tables in SWOF and SGOF."); - } - } - - // Initialize tables. - satfuncset_.resize(num_tables); - for (int table = 0; table < num_tables; ++table) { - satfuncset_[table].init(newParserDeck, table, phase_usage_, samples); - } // Check EHYSTR status do_hyst_ = false; - if (hysteresis_switch && newParserDeck->hasKeyword("EHYSTR")) { - const int& relative_perm_hyst = newParserDeck->getKeyword("EHYSTR")->getRecord(0)->getItem(1)->getInt(0); - const std::string& limiting_hyst_flag = newParserDeck->getKeyword("EHYSTR")->getRecord(0)->getItem(4)->getString(0); + if (hysteresis_switch && deck->hasKeyword("EHYSTR")) { + const int& relative_perm_hyst = deck->getKeyword("EHYSTR")->getRecord(0)->getItem(1)->getInt(0); + const std::string& limiting_hyst_flag = deck->getKeyword("EHYSTR")->getRecord(0)->getItem(4)->getString(0); if (relative_perm_hyst != int(0)) { OPM_THROW(std::runtime_error, "Keyword EHYSTR, item 2: Flag '" << relative_perm_hyst << "' found, only '0' is supported. "); } if (limiting_hyst_flag != std::string("KR")) { OPM_THROW(std::runtime_error, "Keyword EHYSTR, item 5: Flag '" << limiting_hyst_flag << "' found, only 'KR' is supported. "); } - if ( ! newParserDeck->hasKeyword("ENDSCALE")) { + if ( ! deck->hasKeyword("ENDSCALE")) { // TODO When use of IMBNUM is implemented, this constraint will be lifted. OPM_THROW(std::runtime_error, "Currently hysteris effects is only available through endpoint scaling."); } do_hyst_ = true; } else if (hysteresis_switch) { OPM_THROW(std::runtime_error, "Switch HYSTER of keyword SATOPTS is active, but keyword EHYSTR not found."); - } else if (newParserDeck->hasKeyword("EHYSTR")) { + } else if (deck->hasKeyword("EHYSTR")) { OPM_THROW(std::runtime_error, "Found keyword EHYSTR, but switch HYSTER of keyword SATOPTS is not set."); } // Saturation table scaling do_eps_ = false; do_3pt_ = false; - if (newParserDeck->hasKeyword("ENDSCALE")) { - Opm::EndscaleWrapper endscale(newParserDeck->getKeyword("ENDSCALE")); + if (deck->hasKeyword("ENDSCALE")) { + Opm::EndscaleWrapper endscale(deck->getKeyword("ENDSCALE")); if (endscale.directionSwitch() != std::string("NODIR")) { OPM_THROW(std::runtime_error, "SaturationPropsFromDeck::init() -- ENDSCALE: " @@ -279,8 +168,8 @@ namespace Opm "SaturationPropsFromDeck::init() -- ENDSCALE: " "Currently only 'REVERS' accepted."); } - if (newParserDeck->hasKeyword("SCALECRS")) { - Opm::ScalecrsWrapper scalecrs(newParserDeck->getKeyword("SCALECRS")); + if (deck->hasKeyword("SCALECRS")) { + Opm::ScalecrsWrapper scalecrs(deck->getKeyword("SCALECRS")); if (scalecrs.isEnabled()) { do_3pt_ = true; } @@ -288,8 +177,8 @@ namespace Opm do_eps_ = true; // Make a consistency check of ENDNUM: #regions = NTENDP (ENDSCALE::3, TABDIMS::8)... - if (newParserDeck->hasKeyword("ENDNUM")) { - const std::vector& endnum = newParserDeck->getKeyword("ENDNUM")->getIntData(); + if (deck->hasKeyword("ENDNUM")) { + const std::vector& endnum = deck->getKeyword("ENDNUM")->getIntData(); int endnum_regions = *std::max_element(endnum.begin(), endnum.end()); if (endnum_regions > endscale.numEndscaleTables()) { OPM_THROW(std::runtime_error, @@ -301,30 +190,29 @@ namespace Opm // TODO: ENPTVD/ENKRVD: Too few tables gives a cryptical message from parser, // superfluous tables are ignored by the parser without any warning ... - initEPS(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + initEPS(deck, number_of_cells, global_cell, begin_cell_centroids, dimensions); if (do_hyst_) { - if (newParserDeck->hasKeyword("KRW") - || newParserDeck->hasKeyword("KRG") - || newParserDeck->hasKeyword("KRO") - || newParserDeck->hasKeyword("KRWR") - || newParserDeck->hasKeyword("KRGR") - || newParserDeck->hasKeyword("KRORW") - || newParserDeck->hasKeyword("KRORG") - || newParserDeck->hasKeyword("ENKRVD") - || newParserDeck->hasKeyword("IKRW") - || newParserDeck->hasKeyword("IKRG") - || newParserDeck->hasKeyword("IKRO") - || newParserDeck->hasKeyword("IKRWR") - || newParserDeck->hasKeyword("IKRGR") - || newParserDeck->hasKeyword("IKRORW") - || newParserDeck->hasKeyword("IKRORG") ) { + if (deck->hasKeyword("KRW") + || deck->hasKeyword("KRG") + || deck->hasKeyword("KRO") + || deck->hasKeyword("KRWR") + || deck->hasKeyword("KRGR") + || deck->hasKeyword("KRORW") + || deck->hasKeyword("KRORG") + || deck->hasKeyword("ENKRVD") + || deck->hasKeyword("IKRG") + || deck->hasKeyword("IKRO") + || deck->hasKeyword("IKRWR") + || deck->hasKeyword("IKRGR") + || deck->hasKeyword("IKRORW") + || deck->hasKeyword("IKRORG") ) { OPM_THROW(std::runtime_error,"Currently hysteresis and relperm value scaling cannot be combined."); } - if (newParserDeck->hasKeyword("IMBNUM")) { - const std::vector& imbnum = newParserDeck->getKeyword("IMBNUM")->getIntData(); + if (deck->hasKeyword("IMBNUM")) { + const std::vector& imbnum = deck->getKeyword("IMBNUM")->getIntData(); int imbnum_regions = *std::max_element(imbnum.begin(), imbnum.end()); if (imbnum_regions > num_tables) { OPM_THROW(std::runtime_error, @@ -343,7 +231,7 @@ namespace Opm // to be a scaled version of the drainage curve (confer Norne model). } - initEPSHyst(newParserDeck, number_of_cells, global_cell, begin_cell_centroids, + initEPSHyst(deck, number_of_cells, global_cell, begin_cell_centroids, dimensions); } } @@ -534,8 +422,8 @@ namespace Opm // Initialize saturation scaling parameters template - template - void SaturationPropsFromDeck::initEPS(const EclipseGridParser& deck, + template + void SaturationPropsFromDeck::initEPS(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroid, @@ -615,93 +503,10 @@ namespace Opm } } - // Initialize saturation scaling parameters - template - template - void SaturationPropsFromDeck::initEPS(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroid, - int dimensions) - { - std::vector swl, swcr, swu, sgl, sgcr, sgu, sowcr, sogcr; - std::vector krw, krg, kro, krwr, krgr, krorw, krorg; - // Initialize saturation scaling parameter - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SWL"), swl); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SWU"), swu); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SWCR"), swcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SGL"), sgl); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SGU"), sgu); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SGCR"), sgcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SOWCR"), sowcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("SOGCR"), sogcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRW"), krw); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRG"), krg); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRO"), kro); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRWR"), krwr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRGR"), krgr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRORW"), krorw); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("KRORG"), krorg); - - eps_transf_.resize(number_of_cells); - - const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; - const int gpos = phase_usage_.phase_pos[BlackoilPhases::Vapour]; - const bool oilWater = phase_usage_.phase_used[Aqua] && phase_usage_.phase_used[Liquid] && !phase_usage_.phase_used[Vapour]; - const bool oilGas = !phase_usage_.phase_used[Aqua] && phase_usage_.phase_used[Liquid] && phase_usage_.phase_used[Vapour]; - const bool threephase = phase_usage_.phase_used[Aqua] && phase_usage_.phase_used[Liquid] && phase_usage_.phase_used[Vapour]; - - for (int cell = 0; cell < number_of_cells; ++cell) { - if (oilWater) { - // ### krw - initEPSParam(cell, eps_transf_[cell].wat, false, funcForCell(cell).smin_[wpos], funcForCell(cell).swcr_, funcForCell(cell).smax_[wpos], - funcForCell(cell).sowcr_, -1.0, funcForCell(cell).krwr_, funcForCell(cell).krwmax_, swl, swcr, swu, sowcr, sgl, krwr, krw); - // ### krow - initEPSParam(cell, eps_transf_[cell].watoil, true, 0.0, funcForCell(cell).sowcr_, funcForCell(cell).smin_[wpos], - funcForCell(cell).swcr_, -1.0, funcForCell(cell).krorw_, funcForCell(cell).kromax_, swl, sowcr, swl, swcr, sgl, krorw, kro); - } else if (oilGas) { - // ### krg - initEPSParam(cell, eps_transf_[cell].gas, false, funcForCell(cell).smin_[gpos], funcForCell(cell).sgcr_, funcForCell(cell).smax_[gpos], - funcForCell(cell).sogcr_, -1.0, funcForCell(cell).krgr_, funcForCell(cell).krgmax_, sgl, sgcr, sgu, sogcr, swl, krgr, krg); - // ### krog - initEPSParam(cell, eps_transf_[cell].gasoil, true, 0.0, funcForCell(cell).sogcr_, funcForCell(cell).smin_[gpos], - funcForCell(cell).sgcr_, -1.0, funcForCell(cell).krorg_, funcForCell(cell).kromax_, sgl, sogcr, sgl, sgcr, swl, krorg, kro); - } else if (threephase) { - // ### krw - initEPSParam(cell, eps_transf_[cell].wat, false, funcForCell(cell).smin_[wpos], funcForCell(cell).swcr_, funcForCell(cell).smax_[wpos], funcForCell(cell).sowcr_, - funcForCell(cell).smin_[gpos], funcForCell(cell).krwr_, funcForCell(cell).krwmax_, swl, swcr, swu, sowcr, sgl, krwr, krw); - // ### krow - initEPSParam(cell, eps_transf_[cell].watoil, true, 0.0, funcForCell(cell).sowcr_, funcForCell(cell).smin_[wpos], funcForCell(cell).swcr_, - funcForCell(cell).smin_[gpos], funcForCell(cell).krorw_, funcForCell(cell).kromax_, swl, sowcr, swl, swcr, sgl, krorw, kro); - // ### krg - initEPSParam(cell, eps_transf_[cell].gas, false, funcForCell(cell).smin_[gpos], funcForCell(cell).sgcr_, funcForCell(cell).smax_[gpos], funcForCell(cell).sogcr_, - funcForCell(cell).smin_[wpos], funcForCell(cell).krgr_, funcForCell(cell).krgmax_, sgl, sgcr, sgu, sogcr, swl, krgr, krg); - // ### krog - initEPSParam(cell, eps_transf_[cell].gasoil, true, 0.0, funcForCell(cell).sogcr_, funcForCell(cell).smin_[gpos], funcForCell(cell).sgcr_, - funcForCell(cell).smin_[wpos], funcForCell(cell).krorg_, funcForCell(cell).kromax_, sgl, sogcr, sgl, sgcr, swl, krorg, kro); - } - } - } - // Initialize hysteresis saturation scaling parameters template template - void SaturationPropsFromDeck::initEPSHyst(const EclipseGridParser& deck, + void SaturationPropsFromDeck::initEPSHyst(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroid, @@ -740,91 +545,6 @@ namespace Opm std::string("IKRORW"), ikrorw); initEPSKey(deck, number_of_cells, global_cell, begin_cell_centroid, dimensions, std::string("IKRORG"), ikrorg); - - - eps_transf_hyst_.resize(number_of_cells); - sat_hyst_.resize(number_of_cells); - - const int wpos = phase_usage_.phase_pos[BlackoilPhases::Aqua]; - const int gpos = phase_usage_.phase_pos[BlackoilPhases::Vapour]; - const bool oilWater = phase_usage_.phase_used[Aqua] && phase_usage_.phase_used[Liquid] && !phase_usage_.phase_used[Vapour]; - const bool oilGas = !phase_usage_.phase_used[Aqua] && phase_usage_.phase_used[Liquid] && phase_usage_.phase_used[Vapour]; - const bool threephase = phase_usage_.phase_used[Aqua] && phase_usage_.phase_used[Liquid] && phase_usage_.phase_used[Vapour]; - - for (int cell = 0; cell < number_of_cells; ++cell) { - if (oilWater) { - // ### krw - initEPSParam(cell, eps_transf_hyst_[cell].wat, false, funcForCell(cell).smin_[wpos], funcForCell(cell).swcr_, funcForCell(cell).smax_[wpos], - funcForCell(cell).sowcr_, -1.0, funcForCell(cell).krwr_, funcForCell(cell).krwmax_, iswl, iswcr, iswu, isowcr, isgl, ikrwr, ikrw); - // ### krow - initEPSParam(cell, eps_transf_hyst_[cell].watoil, true, 0.0, funcForCell(cell).sowcr_, funcForCell(cell).smin_[wpos], - funcForCell(cell).swcr_, -1.0, funcForCell(cell).krorw_, funcForCell(cell).kromax_, iswl, isowcr, iswl, iswcr, isgl, ikrorw, ikro); - } else if (oilGas) { - // ### krg - initEPSParam(cell, eps_transf_hyst_[cell].gas, false, funcForCell(cell).smin_[gpos], funcForCell(cell).sgcr_, funcForCell(cell).smax_[gpos], - funcForCell(cell).sogcr_, -1.0, funcForCell(cell).krgr_, funcForCell(cell).krgmax_, isgl, isgcr, isgu, isogcr, iswl, ikrgr, ikrg); - // ### krog - initEPSParam(cell, eps_transf_hyst_[cell].gasoil, true, 0.0, funcForCell(cell).sogcr_, funcForCell(cell).smin_[gpos], - funcForCell(cell).sgcr_, -1.0, funcForCell(cell).krorg_, funcForCell(cell).kromax_, isgl, isogcr, isgl, isgcr, iswl, ikrorg, ikro); - } else if (threephase) { - // ### krw - initEPSParam(cell, eps_transf_hyst_[cell].wat, false, funcForCell(cell).smin_[wpos], funcForCell(cell).swcr_, funcForCell(cell).smax_[wpos], funcForCell(cell).sowcr_, - funcForCell(cell).smin_[gpos], funcForCell(cell).krwr_, funcForCell(cell).krwmax_, iswl, iswcr, iswu, isowcr, isgl, ikrwr, ikrw); - // ### krow - initEPSParam(cell, eps_transf_hyst_[cell].watoil, true, 0.0, funcForCell(cell).sowcr_, funcForCell(cell).smin_[wpos], funcForCell(cell).swcr_, - funcForCell(cell).smin_[gpos], funcForCell(cell).krorw_, funcForCell(cell).kromax_, iswl, isowcr, iswl, iswcr, isgl, ikrorw, ikro); - // ### krg - initEPSParam(cell, eps_transf_hyst_[cell].gas, false, funcForCell(cell).smin_[gpos], funcForCell(cell).sgcr_, funcForCell(cell).smax_[gpos], funcForCell(cell).sogcr_, - funcForCell(cell).smin_[wpos], funcForCell(cell).krgr_, funcForCell(cell).krgmax_, isgl, isgcr, isgu, isogcr, iswl, ikrgr, ikrg); - // ### krog - initEPSParam(cell, eps_transf_hyst_[cell].gasoil, true, 0.0, funcForCell(cell).sogcr_, funcForCell(cell).smin_[gpos], funcForCell(cell).sgcr_, - funcForCell(cell).smin_[wpos], funcForCell(cell).krorg_, funcForCell(cell).kromax_, isgl, isogcr, isgl, isgcr, iswl, ikrorg, ikro); - } - } - } - - // Initialize hysteresis saturation scaling parameters - template - template - void SaturationPropsFromDeck::initEPSHyst(Opm::DeckConstPtr newParserDeck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroid, - int dimensions) - { - std::vector iswl, iswcr, iswu, isgl, isgcr, isgu, isowcr, isogcr; - std::vector ikrw, ikrg, ikro, ikrwr, ikrgr, ikrorw, ikrorg; - // Initialize hysteresis saturation scaling parameters - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISWL"), iswl); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISWU"), iswu); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISWCR"), iswcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISGL"), isgl); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISGU"), isgu); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISGCR"), isgcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISOWCR"), isowcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("ISOGCR"), isogcr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRW"), ikrw); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRG"), ikrg); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRO"), ikro); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRWR"), ikrwr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRGR"), ikrgr); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRORW"), ikrorw); - initEPSKey(newParserDeck, number_of_cells, global_cell, begin_cell_centroid, dimensions, - std::string("IKRORG"), ikrorg); eps_transf_hyst_.resize(number_of_cells); sat_hyst_.resize(number_of_cells); @@ -870,185 +590,7 @@ namespace Opm // Initialize saturation scaling parameter template template - void SaturationPropsFromDeck::initEPSKey(const EclipseGridParser& deck, - int number_of_cells, - const int* global_cell, - const T& begin_cell_centroid, - int dimensions, - const std::string& keyword, - std::vector& scaleparam) - { - const bool useAqua = phase_usage_.phase_used[Aqua]; - const bool useLiquid = phase_usage_.phase_used[Liquid]; - const bool useVapour = phase_usage_.phase_used[Vapour]; - bool useKeyword = deck.hasField(keyword); - bool hasENPTVD = deck.hasField("ENPTVD"); - bool hasENKRVD = deck.hasField("ENKRVD"); - int itab = 0; - std::vector > > table_dummy; - std::vector > >& table = table_dummy; - - // Active keyword assigned default values for each cell (in case of possible box-wise assignment) - int phase_pos_aqua = phase_usage_.phase_pos[BlackoilPhases::Aqua]; - int phase_pos_vapour = phase_usage_.phase_pos[BlackoilPhases::Vapour]; - if ((keyword[0] == 'S' && (useKeyword || hasENPTVD)) || (keyword[1] == 'S' && useKeyword) ) { - if (keyword == std::string("SWL") || keyword == std::string("ISWL") ) { - if (useAqua && (useKeyword || deck.getENPTVD().mask_[0])) { - itab = 1; - scaleparam.resize(number_of_cells); - for (int i=0; i 0) { - table = deck.getENPTVD().table_; - } - } else if ((keyword[0] == 'K' && (useKeyword || hasENKRVD)) || (keyword[1] == 'K' && useKeyword) ) { - if (keyword == std::string("KRW") || keyword == std::string("IKRW") ) { - if (useAqua && (useKeyword || deck.getENKRVD().mask_[0])) { - itab = 1; - scaleparam.resize(number_of_cells); - for (int i=0; i 0) { - table = deck.getENKRVD().table_; - } - } - - if (scaleparam.empty()) { - return; - } else if (useKeyword) { - // Keyword values from deck - std::cout << "--- Scaling parameter '" << keyword << "' assigned." << std::endl; - const std::vector& val = deck.getFloatingPointValue(keyword); - for (int c = 0; c < int(scaleparam.size()); ++c) { - const int deck_pos = (global_cell == NULL) ? c : global_cell[c]; - scaleparam[c] = val[deck_pos]; - } - } else { - std::cout << "--- Scaling parameter '" << keyword << "' assigned via "; - if (keyword[0] == 'S') - deck.getENPTVD().write(std::cout); - else - deck.getENKRVD().write(std::cout); - for (int cell = 0; cell < number_of_cells; ++cell) { - int jtab = cell_to_func_.empty() ? 0 : cell_to_func_[cell]; - if (table[itab][jtab][0] != -1.0) { - std::vector& depth = table[0][jtab]; - std::vector& val = table[itab][jtab]; - double zc = UgGridHelpers - ::getCoordinate(UgGridHelpers::increment(begin_cell_centroid, cell, - dimensions), - dimensions-1); - if (zc >= depth.front() && zc <= depth.back()) { //don't want extrap outside depth interval - scaleparam[cell] = linearInterpolation(depth, val, zc); - } - } - } - } - } - - // Initialize saturation scaling parameter - template - template - void SaturationPropsFromDeck::initEPSKey(Opm::DeckConstPtr newParserDeck, + void SaturationPropsFromDeck::initEPSKey(Opm::DeckConstPtr deck, int number_of_cells, const int* global_cell, const T& begin_cell_centroid, @@ -1059,9 +601,9 @@ namespace Opm const bool useAqua = phase_usage_.phase_used[Aqua]; const bool useLiquid = phase_usage_.phase_used[Liquid]; const bool useVapour = phase_usage_.phase_used[Vapour]; - bool useKeyword = newParserDeck->hasKeyword(keyword); - bool hasENPTVD = newParserDeck->hasKeyword("ENPTVD"); - bool hasENKRVD = newParserDeck->hasKeyword("ENKRVD"); + bool useKeyword = deck->hasKeyword(keyword); + bool hasENPTVD = deck->hasKeyword("ENPTVD"); + bool hasENKRVD = deck->hasKeyword("ENKRVD"); int itab = 0; std::vector > param_col; std::vector > depth_col; @@ -1072,56 +614,56 @@ namespace Opm int phase_pos_vapour = phase_usage_.phase_pos[BlackoilPhases::Vapour]; if ((keyword[0] == 'S' && (useKeyword || hasENPTVD)) || (keyword[1] == 'S' && useKeyword) ) { if (keyword == std::string("SWL") || keyword == std::string("ISWL") ) { - if (useAqua && (useKeyword || columnIsMasked_(newParserDeck, "ENPTVD", 0))) { + if (useAqua && (useKeyword || columnIsMasked_(deck, "ENPTVD", 0))) { itab = 1; scaleparam.resize(number_of_cells); for (int i=0; i 0) { - int num_tables = newParserDeck->getKeyword("ENPTVD")->size(); + int num_tables = deck->getKeyword("ENPTVD")->size(); param_col.resize(num_tables); depth_col.resize(num_tables); col_names.resize(9); for (int table_num=0; table_numgetKeyword("ENPTVD"), col_names, table_num); + Opm::SingleRecordTable enptvd(deck->getKeyword("ENPTVD"), col_names, table_num); depth_col[table_num] = enptvd.getColumn(0); // depth param_col[table_num] = enptvd.getColumn(itab); // itab=[1-8]: swl swcr swu sgl sgcr sgu sowcr sogcr } } } else if ((keyword[0] == 'K' && (useKeyword || hasENKRVD)) || (keyword[1] == 'K' && useKeyword) ) { if (keyword == std::string("KRW") || keyword == std::string("IKRW") ) { - if (useAqua && (useKeyword || columnIsMasked_(newParserDeck, "ENKRVD", 0))) { + if (useAqua && (useKeyword || columnIsMasked_(deck, "ENKRVD", 0))) { itab = 1; scaleparam.resize(number_of_cells); for (int i=0; i 0) { - int num_tables = newParserDeck->getKeyword("ENKRVD")->size(); + int num_tables = deck->getKeyword("ENKRVD")->size(); param_col.resize(num_tables); depth_col.resize(num_tables); col_names.resize(8); for (int table_num=0; table_numgetKeyword("ENKRVD"), col_names, table_num); + Opm::SingleRecordTable enkrvd(deck->getKeyword("ENKRVD"), col_names, table_num); depth_col[table_num] = enkrvd.getColumn(0); // depth param_col[table_num] = enkrvd.getColumn(itab); // itab=[1-7]: krw krg kro krwr krgr krorw krorg } @@ -1213,7 +755,7 @@ namespace Opm // Keyword values from deck std::cout << "--- Scaling parameter '" << keyword << "' assigned." << std::endl; const int* gc = global_cell; - const std::vector& val = newParserDeck->getKeyword(keyword)->getSIDoubleData(); + const std::vector& val = deck->getKeyword(keyword)->getSIDoubleData(); for (int c = 0; c < int(scaleparam.size()); ++c) { const int deck_pos = (gc == NULL) ? c : gc[c]; scaleparam[c] = val[deck_pos]; @@ -1221,9 +763,9 @@ namespace Opm } else { const int dim = dimensions; std::vector endnum; - if ( newParserDeck->hasKeyword("ENDNUM")) { + if ( deck->hasKeyword("ENDNUM")) { const std::vector& e = - newParserDeck->getKeyword("ENDNUM")->getIntData(); + deck->getKeyword("ENDNUM")->getIntData(); endnum.resize(number_of_cells); const int* gc = global_cell; for (int cell = 0; cell < number_of_cells; ++cell) { diff --git a/opm/core/simulator/SimulatorTimer.cpp b/opm/core/simulator/SimulatorTimer.cpp index ade613b0..add8b738 100644 --- a/opm/core/simulator/SimulatorTimer.cpp +++ b/opm/core/simulator/SimulatorTimer.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -49,14 +48,6 @@ namespace Opm total_time_ = num_psteps*stepsize; } - /// Initialize from TSTEP field. - void SimulatorTimer::init(const EclipseGridParser& deck) - { - timesteps_ = deck.getTSTEP().tstep_; - total_time_ = std::accumulate(timesteps_.begin(), timesteps_.end(), 0.0); - start_date_ = deck.getStartDate(); - } - /// Use the SimulatorTimer as a shim around opm-parser's Opm::TimeMap void SimulatorTimer::init(Opm::TimeMapConstPtr timeMap) { diff --git a/opm/core/simulator/SimulatorTimer.hpp b/opm/core/simulator/SimulatorTimer.hpp index e2b5db07..61faef09 100644 --- a/opm/core/simulator/SimulatorTimer.hpp +++ b/opm/core/simulator/SimulatorTimer.hpp @@ -31,8 +31,6 @@ namespace Opm { namespace parameter { class ParameterGroup; } - class EclipseGridParser; - class SimulatorTimer { @@ -45,10 +43,6 @@ namespace Opm /// stepsize_days (default 1) void init(const parameter::ParameterGroup& param); - /// Initialize from TSTEP field. - /// Note that DATES are folded into TSTEP by the parser. - void init(const EclipseGridParser& deck); - /// Use the SimulatorTimer as a shim around opm-parser's Opm::TimeMap void init(TimeMapConstPtr timeMap); diff --git a/opm/core/simulator/initState.hpp b/opm/core/simulator/initState.hpp index 4c3a8cc6..2c4bcda5 100644 --- a/opm/core/simulator/initState.hpp +++ b/opm/core/simulator/initState.hpp @@ -20,7 +20,7 @@ #ifndef OPM_INITSTATE_HEADER_INCLUDED #define OPM_INITSTATE_HEADER_INCLUDED -#include // DeckConstPtr +#include struct UnstructuredGrid; @@ -28,7 +28,6 @@ namespace Opm { namespace parameter { class ParameterGroup; } - class EclipseGridParser; class IncompPropertiesInterface; class BlackoilPropertiesInterface; @@ -168,27 +167,7 @@ namespace Opm template void initStateFromDeck(const UnstructuredGrid& grid, const Props& props, - const EclipseGridParser& deck, - const double gravity, - State& state); - - /// Initialize a two-phase state from input deck. - /// If EQUIL is present: - /// - saturation is set according to the water-oil contact, - /// - pressure is set to hydrostatic equilibrium. - /// Otherwise: - /// - saturation is set according to SWAT, - /// - pressure is set according to PRESSURE. - template - void initStateFromDeck(int number_of_cells, - const int* global_cell, - int number_of_faces, - FaceCells face_cells, - FCI begin_face_centroids, - CCI begin_cell_centroids, - int dimensions, - const Props& props, - const EclipseGridParser& deck, + Opm::DeckConstPtr deck, const double gravity, State& state); @@ -203,31 +182,9 @@ namespace Opm template void initBlackoilStateFromDeck(const UnstructuredGrid& grid, const Props& props, - const EclipseGridParser& deck, + Opm::DeckConstPtr deck, const double gravity, State& state); - - /// Initialize a two-phase water-oil blackoil state from input deck. - /// If EQUIL is present: - /// - saturation is set according to the water-oil contact, - /// - pressure is set to hydrostatic equilibrium. - /// Otherwise: - /// - saturation is set according to SWAT, - /// - pressure is set according to PRESSURE. - /// In addition, this function sets surfacevol. - template - void initBlackoilStateFromDeck(int number_of_cells, - const int* global_cell, - int number_of_faces, - FaceCells face_cells, - FCI begin_face_centroids, - CCI begin_cell_centroids, - int dimensions, - const Props& props, - const EclipseGridParser& deck, - const double gravity, - State& state); - /// Initialize a blackoil state from input deck. template void initBlackoilStateFromDeck(int number_of_cells, @@ -238,7 +195,7 @@ namespace Opm CCI begin_cell_centroids, int dimensions, const Props& props, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, const double gravity, State& state); } // namespace Opm diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 98ebadbb..1cf88ee4 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -62,14 +61,7 @@ namespace Opm */ void initStateEquil(const UnstructuredGrid& grid, const BlackoilPropertiesInterface& props, - const EclipseGridParser& deck, - const double gravity, - BlackoilState& state); - - - void initStateEquil(const UnstructuredGrid& grid, - const BlackoilPropertiesInterface& props, - const Opm::DeckConstPtr newParserDeck, + const Opm::DeckConstPtr deck, const double gravity, BlackoilState& state); @@ -188,61 +180,13 @@ namespace Opm const std::vector gas_saturation); namespace DeckDependent { - inline std::vector - getEquil(const EclipseGridParser& deck) + getEquil(const Opm::DeckConstPtr deck) { - if (deck.hasField("EQUIL")) { - const EQUIL& eql = deck.getEQUIL(); - - typedef std::vector::size_type sz_t; - const sz_t nrec = eql.equil.size(); - - std::vector ret; - ret.reserve(nrec); - for (sz_t r = 0; r < nrec; ++r) { - const EquilLine& rec = eql.equil[r]; - - EquilRecord record = - { - { rec.datum_depth_ , - rec.datum_depth_pressure_ } - , - { rec.water_oil_contact_depth_ , - rec.oil_water_cap_pressure_ } - , - { rec.gas_oil_contact_depth_ , - rec.gas_oil_cap_pressure_ } - , - rec.live_oil_table_index_ - , - rec.wet_gas_table_index_ - , - rec.N_ - }; - if (record.N != 0) { - OPM_THROW(std::domain_error, - "kw EQUIL, item 9: Only N=0 supported."); - } - ret.push_back(record); - } - - return ret; - } - else { - OPM_THROW(std::domain_error, - "Deck does not provide equilibration data."); - } - } - - inline - std::vector - getEquil(const Opm::DeckConstPtr newParserDeck) - { - if (newParserDeck->hasKeyword("EQUIL")) { + if (deck->hasKeyword("EQUIL")) { - Opm::EquilWrapper eql(newParserDeck->getKeyword("EQUIL")); + Opm::EquilWrapper eql(deck->getKeyword("EQUIL")); const int nrec = eql.numRegions(); @@ -282,39 +226,16 @@ namespace Opm } } - inline std::vector - equilnum(const EclipseGridParser& deck, + equilnum(const Opm::DeckConstPtr deck, const UnstructuredGrid& G ) { std::vector eqlnum; - if (deck.hasField("EQLNUM")) { - const std::vector& e = deck.getIntegerValue("EQLNUM"); - eqlnum.reserve(e.size()); - std::transform(e.begin(), e.end(), std::back_inserter(eqlnum), - std::bind2nd(std::minus(), 1)); - } - else { - // No explicit equilibration region. - // All cells in region zero. - eqlnum.assign(G.number_of_cells, 0); - } - - return eqlnum; - } - - - inline - std::vector - equilnum(const Opm::DeckConstPtr newParserDeck, - const UnstructuredGrid& G ) - { - std::vector eqlnum; - if (newParserDeck->hasKeyword("EQLNUM")) { + if (deck->hasKeyword("EQLNUM")) { eqlnum.resize(G.number_of_cells); const std::vector& e = - newParserDeck->getKeyword("EQLNUM")->getIntData(); + deck->getKeyword("EQLNUM")->getIntData(); const int* gc = G.global_cell; for (int cell = 0; cell < G.number_of_cells; ++cell) { const int deck_pos = (gc == NULL) ? cell : gc[cell]; @@ -331,14 +252,10 @@ namespace Opm } - template - class InitialStateComputer; - - template <> - class InitialStateComputer { + class InitialStateComputer { public: InitialStateComputer(const BlackoilPropertiesInterface& props, - const EclipseGridParser& deck , + const Opm::DeckConstPtr deck, const UnstructuredGrid& G , const double grav = unit::gravity) : pp_(props.numPhases(), @@ -352,186 +269,17 @@ namespace Opm const std::vector rec = getEquil(deck); // Create (inverse) region mapping. - const RegionMapping<> eqlmap(equilnum(deck, G)); + const RegionMapping<> eqlmap(equilnum(deck, G)); // Create Rs functions. rs_func_.reserve(rec.size()); - if (deck.hasField("DISGAS")) { + if (deck->hasKeyword("DISGAS")) { for (size_t i = 0; i < rec.size(); ++i) { const int cell = *(eqlmap.cells(i).begin()); if (rec[i].live_oil_table_index > 0) { - if (deck.hasField("RSVD")) { - // TODO When this kw is actually parsed, also check for proper number of available tables - // For now, just use dummy ... - std::vector depth; depth.push_back(0.0); depth.push_back(100.0); - std::vector rs; rs.push_back(0.0); rs.push_back(100.0); - rs_func_.push_back(std::make_shared(props, cell, depth, rs)); - } else { - OPM_THROW(std::runtime_error, "Cannot initialise: RSVD table " << (rec[i].live_oil_table_index) << " not available."); - } - } else { - if (rec[i].goc.depth != rec[i].main.depth) { - OPM_THROW(std::runtime_error, - "Cannot initialise: when no explicit RSVD table is given, \n" - "datum depth must be at the gas-oil-contact. " - "In EQUIL region " << (i + 1) << " (counting from 1), this does not hold."); - } - const double p_contact = rec[i].main.press; - rs_func_.push_back(std::make_shared(props, cell, p_contact)); - } - } - } else { - for (size_t i = 0; i < rec.size(); ++i) { - rs_func_.push_back(std::make_shared()); - } - } - - rv_func_.reserve(rec.size()); - if (deck.hasField("VAPOIL")) { - for (size_t i = 0; i < rec.size(); ++i) { - const int cell = *(eqlmap.cells(i).begin()); - if (rec[i].wet_gas_table_index > 0) { - if (deck.hasField("RVVD")) { - // TODO When this kw is actually parsed, also check for proper number of available tables - // For now, just use dummy ... - std::vector depth; depth.push_back(0.0); depth.push_back(100.0); - std::vector rv; rv.push_back(0.0); rv.push_back(0.0001); - rv_func_.push_back(std::make_shared(props, cell, depth, rv)); - } else { - OPM_THROW(std::runtime_error, "Cannot initialise: RVVD table " << (rec[i].wet_gas_table_index) << " not available."); - } - } else { - if (rec[i].goc.depth != rec[i].main.depth) { - OPM_THROW(std::runtime_error, - "Cannot initialise: when no explicit RVVD table is given, \n" - "datum depth must be at the gas-oil-contact. " - "In EQUIL region " << (i + 1) << " (counting from 1), this does not hold."); - } - const double p_contact = rec[i].main.press + rec[i].goc.press; - rv_func_.push_back(std::make_shared(props, cell, p_contact)); - } - } - } else { - for (size_t i = 0; i < rec.size(); ++i) { - rv_func_.push_back(std::make_shared()); - } - } - - // Compute pressures, saturations, rs and rv factors. - calcPressSatRsRv(eqlmap, rec, props, G, grav); - - // Modify oil pressure in no-oil regions so that the pressures of present phases can - // be recovered from the oil pressure and capillary relations. - } - - typedef std::vector Vec; - typedef std::vector PVec; // One per phase. - - const PVec& press() const { return pp_; } - const PVec& saturation() const { return sat_; } - const Vec& rs() const { return rs_; } - const Vec& rv() const { return rv_; } - - private: - typedef DensityCalculator RhoCalc; - typedef EquilReg EqReg; - - std::vector< std::shared_ptr > rs_func_; - std::vector< std::shared_ptr > rv_func_; - - PVec pp_; - PVec sat_; - Vec rs_; - Vec rv_; - - template - void - calcPressSatRsRv(const RMap& reg , - const std::vector< EquilRecord >& rec , - const Opm::BlackoilPropertiesInterface& props, - const UnstructuredGrid& G , - const double grav) - { - typedef Miscibility::NoMixing NoMix; - - for (typename RMap::RegionId - r = 0, nr = reg.numRegions(); - r < nr; ++r) - { - const typename RMap::CellRange cells = reg.cells(r); - - const int repcell = *cells.begin(); - const RhoCalc calc(props, repcell); - const EqReg eqreg(rec[r], calc, - rs_func_[r], rv_func_[r], - props.phaseUsage()); - - PVec press = phasePressures(G, eqreg, cells, grav); - - const PVec sat = phaseSaturations(eqreg, cells, props, press); - - const int np = props.numPhases(); - for (int p = 0; p < np; ++p) { - copyFromRegion(press[p], cells, pp_[p]); - copyFromRegion(sat[p], cells, sat_[p]); - } - if (props.phaseUsage().phase_used[BlackoilPhases::Liquid] - && props.phaseUsage().phase_used[BlackoilPhases::Vapour]) { - const int oilpos = props.phaseUsage().phase_pos[BlackoilPhases::Liquid]; - const int gaspos = props.phaseUsage().phase_pos[BlackoilPhases::Vapour]; - const Vec rs = computeRs(G, cells, press[oilpos], *(rs_func_[r]), sat[gaspos]); - const Vec rv = computeRs(G, cells, press[gaspos], *(rv_func_[r]), sat[oilpos]); - copyFromRegion(rs, cells, rs_); - copyFromRegion(rv, cells, rv_); - } - } - } - - template - void copyFromRegion(const Vec& source, - const CellRangeType& cells, - Vec& destination) - { - auto s = source.begin(); - auto c = cells.begin(); - const auto e = cells.end(); - for (; c != e; ++c, ++s) { - destination[*c] = *s; - } - } - - }; - - - template <> - class InitialStateComputer { - public: - InitialStateComputer(const BlackoilPropertiesInterface& props, - const Opm::DeckConstPtr newParserDeck, - const UnstructuredGrid& G , - const double grav = unit::gravity) - : pp_(props.numPhases(), - std::vector(G.number_of_cells)), - sat_(props.numPhases(), - std::vector(G.number_of_cells)), - rs_(G.number_of_cells), - rv_(G.number_of_cells) - { - // Get the equilibration records. - const std::vector rec = getEquil(newParserDeck); - - // Create (inverse) region mapping. - const RegionMapping<> eqlmap(equilnum(newParserDeck, G)); - - // Create Rs functions. - rs_func_.reserve(rec.size()); - if (newParserDeck->hasKeyword("DISGAS")) { - for (size_t i = 0; i < rec.size(); ++i) { - const int cell = *(eqlmap.cells(i).begin()); - if (rec[i].live_oil_table_index > 0) { - if (newParserDeck->hasKeyword("RSVD") && - size_t(rec[i].live_oil_table_index) <= newParserDeck->getKeyword("RSVD")->size()) { - Opm::SingleRecordTable rsvd(newParserDeck->getKeyword("RSVD"),std::vector{"vd", "rs"},rec[i].live_oil_table_index-1); + if (deck->hasKeyword("RSVD") && + size_t(rec[i].live_oil_table_index) <= deck->getKeyword("RSVD")->size()) { + Opm::SingleRecordTable rsvd(deck->getKeyword("RSVD"),std::vector{"vd", "rs"},rec[i].live_oil_table_index-1); std::vector vd(rsvd.getColumn("vd")); std::vector rs(rsvd.getColumn("rs")); rs_func_.push_back(std::make_shared(props, cell, vd, rs)); @@ -556,13 +304,13 @@ namespace Opm } rv_func_.reserve(rec.size()); - if (newParserDeck->hasKeyword("VAPOIL")) { + if (deck->hasKeyword("VAPOIL")) { for (size_t i = 0; i < rec.size(); ++i) { const int cell = *(eqlmap.cells(i).begin()); if (rec[i].wet_gas_table_index > 0) { - if (newParserDeck->hasKeyword("RVVD") && - size_t(rec[i].wet_gas_table_index) <= newParserDeck->getKeyword("RVVD")->size()) { - Opm::SingleRecordTable rvvd(newParserDeck->getKeyword("RVVD"),std::vector{"vd", "rv"},rec[i].wet_gas_table_index-1); + if (deck->hasKeyword("RVVD") && + size_t(rec[i].wet_gas_table_index) <= deck->getKeyword("RVVD")->size()) { + Opm::SingleRecordTable rvvd(deck->getKeyword("RVVD"),std::vector{"vd", "rv"},rec[i].wet_gas_table_index-1); std::vector vd(rvvd.getColumn("vd")); std::vector rv(rvvd.getColumn("rv")); rv_func_.push_back(std::make_shared(props, cell, vd, rv)); diff --git a/opm/core/simulator/initStateEquil_impl.hpp b/opm/core/simulator/initStateEquil_impl.hpp index d227d54d..ba2df1ed 100644 --- a/opm/core/simulator/initStateEquil_impl.hpp +++ b/opm/core/simulator/initStateEquil_impl.hpp @@ -737,11 +737,11 @@ namespace Opm */ void initStateEquil(const UnstructuredGrid& grid, const BlackoilPropertiesInterface& props, - const EclipseGridParser& deck, + const Opm::DeckConstPtr deck, const double gravity, BlackoilState& state) { - typedef Equil::DeckDependent::InitialStateComputer ISC; + typedef Equil::DeckDependent::InitialStateComputer ISC; ISC isc(props, deck, grid, gravity); const auto pu = props.phaseUsage(); const int ref_phase = pu.phase_used[BlackoilPhases::Liquid] @@ -753,26 +753,6 @@ namespace Opm state.rv() = isc.rv(); // TODO: state.surfacevol() must be computed from s, rs, rv. } - - - void initStateEquil(const UnstructuredGrid& grid, - const BlackoilPropertiesInterface& props, - const Opm::DeckConstPtr newParserDeck, - const double gravity, - BlackoilState& state) - { - typedef Equil::DeckDependent::InitialStateComputer ISC; - ISC isc(props, newParserDeck, grid, gravity); - const auto pu = props.phaseUsage(); - const int ref_phase = pu.phase_used[BlackoilPhases::Liquid] - ? pu.phase_pos[BlackoilPhases::Liquid] - : pu.phase_pos[BlackoilPhases::Aqua]; - state.pressure() = isc.press()[ref_phase]; - state.saturation() = convertSats(isc.saturation()); - state.gasoilratio() = isc.rs(); - state.rv() = isc.rv(); - // TODO: state.surfacevol() must be computed from s, rs, rv. - } diff --git a/opm/core/simulator/initState_impl.hpp b/opm/core/simulator/initState_impl.hpp index 7f9435ff..6b1885ea 100644 --- a/opm/core/simulator/initState_impl.hpp +++ b/opm/core/simulator/initState_impl.hpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -553,14 +552,14 @@ namespace Opm template void initStateFromDeck(const UnstructuredGrid& grid, const Props& props, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, const double gravity, State& state) { initStateFromDeck(grid.number_of_cells, grid.global_cell, grid.number_of_faces, UgGridHelpers::faceCells(grid), grid.face_centroids, grid.cell_centroids, grid.dimensions, - props, newParserDeck, gravity, state); + props, deck, gravity, state); } /// Initialize a state from input deck. template @@ -572,23 +571,23 @@ namespace Opm CCI begin_cell_centroids, int dimensions, const Props& props, - Opm::DeckConstPtr newParserDeck, + Opm::DeckConstPtr deck, const double gravity, State& state) { const int num_phases = props.numPhases(); - const PhaseUsage pu = phaseUsageFromDeck(newParserDeck); + const PhaseUsage pu = phaseUsageFromDeck(deck); if (num_phases != pu.num_phases) { OPM_THROW(std::runtime_error, "initStateFromDeck(): user specified property object with " << num_phases << " phases, " "found " << pu.num_phases << " phases in deck."); } state.init(number_of_cells, number_of_faces, num_phases); - if (newParserDeck->hasKeyword("EQUIL") && newParserDeck->hasKeyword("PRESSURE")) { + if (deck->hasKeyword("EQUIL") && deck->hasKeyword("PRESSURE")) { OPM_THROW(std::runtime_error, "initStateFromDeck(): The deck must either specify the initial " "condition using the PRESSURE _or_ the EQUIL keyword (currently it has both)"); } - if (newParserDeck->hasKeyword("EQUIL")) { + if (deck->hasKeyword("EQUIL")) { if (num_phases != 2) { OPM_THROW(std::runtime_error, "initStateFromDeck(): EQUIL-based init currently handling only two-phase scenarios."); } @@ -596,7 +595,7 @@ namespace Opm OPM_THROW(std::runtime_error, "initStateFromDeck(): EQUIL-based init currently handling only oil-water scenario (no gas)."); } // Set saturations depending on oil-water contact. - EquilWrapper equil(newParserDeck->getKeyword("EQUIL")); + EquilWrapper equil(deck->getKeyword("EQUIL")); if (equil.numRegions() != 1) { OPM_THROW(std::runtime_error, "initStateFromDeck(): No region support yet."); } @@ -608,19 +607,19 @@ namespace Opm const double datum_p = equil.datumDepthPressure(0); initHydrostaticPressure(number_of_cells, begin_cell_centroids, dimensions, props, woc, gravity, datum_z, datum_p, state); - } else if (newParserDeck->hasKeyword("PRESSURE")) { + } else if (deck->hasKeyword("PRESSURE")) { // Set saturations from SWAT/SGAS, pressure from PRESSURE. std::vector& s = state.saturation(); std::vector& p = state.pressure(); - const std::vector& p_deck = newParserDeck->getKeyword("PRESSURE")->getSIDoubleData(); + const std::vector& p_deck = deck->getKeyword("PRESSURE")->getSIDoubleData(); const int num_cells = number_of_cells; if (num_phases == 2) { if (!pu.phase_used[BlackoilPhases::Aqua]) { // oil-gas: we require SGAS - if (!newParserDeck->hasKeyword("SGAS")) { + if (!deck->hasKeyword("SGAS")) { OPM_THROW(std::runtime_error, "initStateFromDeck(): missing SGAS keyword in 2-phase init"); } - const std::vector& sg_deck = newParserDeck->getKeyword("SGAS")->getSIDoubleData(); + const std::vector& sg_deck = deck->getKeyword("SGAS")->getSIDoubleData(); const int gpos = pu.phase_pos[BlackoilPhases::Vapour]; const int opos = pu.phase_pos[BlackoilPhases::Liquid]; for (int c = 0; c < num_cells; ++c) { @@ -631,10 +630,10 @@ namespace Opm } } else { // water-oil or water-gas: we require SWAT - if (!newParserDeck->hasKeyword("SWAT")) { + if (!deck->hasKeyword("SWAT")) { OPM_THROW(std::runtime_error, "initStateFromDeck(): missing SWAT keyword in 2-phase init"); } - const std::vector& sw_deck = newParserDeck->getKeyword("SWAT")->getSIDoubleData(); + const std::vector& sw_deck = deck->getKeyword("SWAT")->getSIDoubleData(); const int wpos = pu.phase_pos[BlackoilPhases::Aqua]; const int nwpos = (wpos + 1) % 2; for (int c = 0; c < num_cells; ++c) { @@ -645,15 +644,15 @@ namespace Opm } } } else if (num_phases == 3) { - const bool has_swat_sgas = newParserDeck->hasKeyword("SWAT") && newParserDeck->hasKeyword("SGAS"); + const bool has_swat_sgas = deck->hasKeyword("SWAT") && deck->hasKeyword("SGAS"); if (!has_swat_sgas) { OPM_THROW(std::runtime_error, "initStateFromDeck(): missing SGAS or SWAT keyword in 3-phase init."); } const int wpos = pu.phase_pos[BlackoilPhases::Aqua]; const int gpos = pu.phase_pos[BlackoilPhases::Vapour]; const int opos = pu.phase_pos[BlackoilPhases::Liquid]; - const std::vector& sw_deck = newParserDeck->getKeyword("SWAT")->getSIDoubleData(); - const std::vector& sg_deck = newParserDeck->getKeyword("SGAS")->getSIDoubleData(); + const std::vector& sw_deck = deck->getKeyword("SWAT")->getSIDoubleData(); + const std::vector& sg_deck = deck->getKeyword("SGAS")->getSIDoubleData(); for (int c = 0; c < num_cells; ++c) { int c_deck = (global_cell == NULL) ? c : global_cell[c]; s[3*c + wpos] = sw_deck[c_deck]; @@ -673,129 +672,6 @@ namespace Opm begin_cell_centroids, state); } - /// Initialize a state from input deck. - template - void initStateFromDeck(const UnstructuredGrid& grid, - const Props& props, - const EclipseGridParser& deck, - const double gravity, - State& state) - { - initStateFromDeck(grid.number_of_cells, grid.global_cell, - grid.number_of_faces, UgGridHelpers::faceCells(grid), - grid.face_centroids, grid.cell_centroids, - grid.dimensions, props, deck, - gravity, state); - } - - template - void initStateFromDeck(int number_of_cells, - const int* global_cell, - int number_of_faces, - FaceCells face_cells, - FCI begin_face_centroids, - CCI begin_cell_centroids, - int dimensions, - const Props& props, - const EclipseGridParser& deck, - const double gravity, - State& state) - { - const int num_phases = props.numPhases(); - const PhaseUsage pu = phaseUsageFromDeck(deck); - if (num_phases != pu.num_phases) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): user specified property object with " << num_phases << " phases, " - "found " << pu.num_phases << " phases in deck."); - } - if (deck.hasField("EQUIL") && deck.hasField("PRESSURE")) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): The deck must either specify the initial " - "condition using the PRESSURE _or_ the EQUIL keyword (currently it has both)"); - } - state.init(number_of_cells, number_of_faces, num_phases); - if (deck.hasField("EQUIL")) { - if (num_phases != 2) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): EQUIL-based init currently handling only two-phase scenarios."); - } - if (pu.phase_used[BlackoilPhases::Vapour]) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): EQUIL-based init currently handling only oil-water scenario (no gas)."); - } - // Set saturations depending on oil-water contact. - const EQUIL& equil= deck.getEQUIL(); - if (equil.equil.size() != 1) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): No region support yet."); - } - const double woc = equil.equil[0].water_oil_contact_depth_; - initWaterOilContact(number_of_cells, begin_cell_centroids, dimensions, - props, woc, WaterBelow, state); - // Set pressure depending on densities and depths. - const double datum_z = equil.equil[0].datum_depth_; - const double datum_p = equil.equil[0].datum_depth_pressure_; - initHydrostaticPressure(number_of_cells, begin_cell_centroids, dimensions, - props, woc, gravity, datum_z, datum_p, state); - } else if (deck.hasField("PRESSURE")) { - // Set saturations from SWAT/SGAS, pressure from PRESSURE. - std::vector& s = state.saturation(); - std::vector& p = state.pressure(); - const std::vector& p_deck = deck.getFloatingPointValue("PRESSURE"); - if (num_phases == 2) { - if (!pu.phase_used[BlackoilPhases::Aqua]) { - // oil-gas: we require SGAS - if (!deck.hasField("SGAS")) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): missing SGAS keyword in 2-phase init"); - } - const std::vector& sg_deck = deck.getFloatingPointValue("SGAS"); - const int gpos = pu.phase_pos[BlackoilPhases::Vapour]; - const int opos = pu.phase_pos[BlackoilPhases::Liquid]; - for (int c = 0; c < number_of_cells; ++c) { - int c_deck = (global_cell == NULL) ? c : global_cell[c]; - s[2*c + gpos] = sg_deck[c_deck]; - s[2*c + opos] = 1.0 - sg_deck[c_deck]; - p[c] = p_deck[c_deck]; - } - } else { - // water-oil or water-gas: we require SWAT - if (!deck.hasField("SWAT")) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): missing SWAT keyword in 2-phase init"); - } - const std::vector& sw_deck = deck.getFloatingPointValue("SWAT"); - const int wpos = pu.phase_pos[BlackoilPhases::Aqua]; - const int nwpos = (wpos + 1) % 2; - for (int c = 0; c < number_of_cells; ++c) { - int c_deck = (global_cell == NULL) ? c : global_cell[c]; - s[2*c + wpos] = sw_deck[c_deck]; - s[2*c + nwpos] = 1.0 - sw_deck[c_deck]; - p[c] = p_deck[c_deck]; - } - } - } else if (num_phases == 3) { - const bool has_swat_sgas = deck.hasField("SWAT") && deck.hasField("SGAS"); - if (!has_swat_sgas) { - OPM_THROW(std::runtime_error, "initStateFromDeck(): missing SGAS or SWAT keyword in 3-phase init."); - } - const int wpos = pu.phase_pos[BlackoilPhases::Aqua]; - const int gpos = pu.phase_pos[BlackoilPhases::Vapour]; - const int opos = pu.phase_pos[BlackoilPhases::Liquid]; - const std::vector& sw_deck = deck.getFloatingPointValue("SWAT"); - const std::vector& sg_deck = deck.getFloatingPointValue("SGAS"); - for (int c = 0; c < number_of_cells; ++c) { - int c_deck = (global_cell == NULL) ? c : global_cell[c]; - s[3*c + wpos] = sw_deck[c_deck]; - s[3*c + opos] = 1.0 - (sw_deck[c_deck] + sg_deck[c_deck]); - s[3*c + gpos] = sg_deck[c_deck]; - p[c] = p_deck[c_deck]; - } - } else { - OPM_THROW(std::runtime_error, "initStateFromDeck(): init with SWAT etc. only available with 2 or 3 phases."); - } - } else { - OPM_THROW(std::runtime_error, "initStateFromDeck(): we must either have EQUIL, or PRESSURE and SWAT/SOIL/SGAS."); - } - - // Finally, init face pressures. - initFacePressure(dimensions, number_of_faces, face_cells, begin_face_centroids, - begin_cell_centroids, state); - } - /// Initialize surface volume from pressure and saturation by z = As. /// Here saturation is used as an intial guess for z in the /// computation of A. @@ -975,12 +851,11 @@ namespace Opm } } - /// Initialize a blackoil state from input deck. template void initBlackoilStateFromDeck(const UnstructuredGrid& grid, const Props& props, - const EclipseGridParser& deck, + Opm::DeckConstPtr deck, const double gravity, State& state) { @@ -990,6 +865,7 @@ namespace Opm props, deck, gravity, state); } + /// Initialize a blackoil state from input deck. template void initBlackoilStateFromDeck(int number_of_cells, const int* global_cell, @@ -999,69 +875,15 @@ namespace Opm CCI begin_cell_centroids, int dimensions, const Props& props, - const EclipseGridParser& deck, + Opm::DeckConstPtr deck, const double gravity, State& state) { initStateFromDeck(number_of_cells, global_cell, number_of_faces, face_cells, begin_face_centroids, begin_cell_centroids, dimensions, props, deck, gravity, state); - if (deck.hasField("RS")) { - const std::vector& rs_deck = deck.getFloatingPointValue("RS"); - for (int c = 0; c < number_of_cells; ++c) { - int c_deck = (global_cell == NULL) ? c : global_cell[c]; - state.gasoilratio()[c] = rs_deck[c_deck]; - } - initBlackoilSurfvolUsingRSorRV(number_of_cells, props, state); - computeSaturation(props,state); - } else if (deck.hasField("RV")){ - const std::vector& rv_deck = deck.getFloatingPointValue("RV"); - for (int c = 0; c < number_of_cells; ++c) { - int c_deck = (global_cell == NULL) ? c : global_cell[c]; - state.rv()[c] = rv_deck[c_deck]; - } - initBlackoilSurfvolUsingRSorRV(number_of_cells, props, state); - computeSaturation(props,state); - } - - else { - OPM_THROW(std::runtime_error, "Temporarily, we require the RS or the RV field."); - } - } - - /// Initialize a blackoil state from input deck. - template - void initBlackoilStateFromDeck(const UnstructuredGrid& grid, - const Props& props, - Opm::DeckConstPtr newParserDeck, - const double gravity, - State& state) - { - initBlackoilStateFromDeck(grid.number_of_cells, grid.global_cell, - grid.number_of_faces, UgGridHelpers::faceCells(grid), - grid.face_centroids, grid.cell_centroids,grid.dimensions, - props, newParserDeck, gravity, state); - } - - /// Initialize a blackoil state from input deck. - template - void initBlackoilStateFromDeck(int number_of_cells, - const int* global_cell, - int number_of_faces, - FaceCells face_cells, - FCI begin_face_centroids, - CCI begin_cell_centroids, - int dimensions, - const Props& props, - Opm::DeckConstPtr newParserDeck, - const double gravity, - State& state) - { - initStateFromDeck(number_of_cells, global_cell, number_of_faces, - face_cells, begin_face_centroids, begin_cell_centroids, - dimensions, props, newParserDeck, gravity, state); - if (newParserDeck->hasKeyword("RS")) { - const std::vector& rs_deck = newParserDeck->getKeyword("RS")->getSIDoubleData(); + if (deck->hasKeyword("RS")) { + const std::vector& rs_deck = deck->getKeyword("RS")->getSIDoubleData(); const int num_cells = number_of_cells; for (int c = 0; c < num_cells; ++c) { int c_deck = (global_cell == NULL) ? c : global_cell[c]; @@ -1069,8 +891,8 @@ namespace Opm } initBlackoilSurfvolUsingRSorRV(number_of_cells, props, state); computeSaturation(props,state); - } else if (newParserDeck->hasKeyword("RV")){ - const std::vector& rv_deck = newParserDeck->getKeyword("RV")->getSIDoubleData(); + } else if (deck->hasKeyword("RV")){ + const std::vector& rv_deck = deck->getKeyword("RV")->getSIDoubleData(); const int num_cells = number_of_cells; for (int c = 0; c < num_cells; ++c) { int c_deck = (global_cell == NULL) ? c : global_cell[c]; @@ -1084,7 +906,6 @@ namespace Opm } } - } // namespace Opm diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index 9218db06..e7688c97 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -79,50 +79,6 @@ namespace Opm child->setParent(parent); } - - void WellCollection::addChild(const std::string& child_name, - const std::string& parent_name, - const EclipseGridParser& deck) - { - WellsGroupInterface* parent = findNode(parent_name); - if (!parent) { - roots_.push_back(createWellsGroup(parent_name, deck)); - parent = roots_[roots_.size() - 1].get(); - } - - std::shared_ptr child; - - for (size_t i = 0; i < roots_.size(); ++i) { - if (roots_[i]->name() == child_name) { - child = roots_[i]; - // We've found a new parent to the previously thought root, need to remove it - for(size_t j = i; j < roots_.size() - 1; ++j) { - roots_[j] = roots_[j+1]; - } - - roots_.resize(roots_.size()-1); - break; - } - } - - if (!child.get()) { - child = createWellsGroup(child_name, deck); - } - - WellsGroup* parent_as_group = static_cast (parent); - if (!parent_as_group) { - OPM_THROW(std::runtime_error, "Trying to add child to group named " << parent_name << ", but it's not a group."); - } - parent_as_group->addChild(child); - - if(child->isLeafNode()) { - leaf_nodes_.push_back(static_cast(child.get())); - } - - child->setParent(parent); - } - - const std::vector& WellCollection::getLeafNodes() const { return leaf_nodes_; } diff --git a/opm/core/wells/WellCollection.hpp b/opm/core/wells/WellCollection.hpp index f084a04d..b597c4b6 100644 --- a/opm/core/wells/WellCollection.hpp +++ b/opm/core/wells/WellCollection.hpp @@ -16,9 +16,6 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ - - - #ifndef OPM_WELLCOLLECTION_HPP #define OPM_WELLCOLLECTION_HPP @@ -27,7 +24,6 @@ #include #include -#include #include #include @@ -47,16 +43,6 @@ namespace Opm void addGroup(GroupConstPtr groupChild, std::string parent_name, size_t timeStep, const PhaseUsage& phaseUsage); - /// Adds and creates if necessary the child to the collection - /// and appends it to parent's children. Also adds and creates the parent - /// if necessary. - /// \param[in] child name of child node - /// \param[in] parent name of parent node - /// \param[in] deck deck from which we will extract group control data - void addChild(const std::string& child, - const std::string& parent, - const EclipseGridParser& deck); - /// Adds the child to the collection /// and appends it to parent's children. /// \param[in] child the child node diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index 050e1871..c4e1a124 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -1045,101 +1045,6 @@ namespace Opm } } // anonymous namespace - std::shared_ptr createWellsGroup(const std::string& name, - const EclipseGridParser& deck) - { - PhaseUsage phase_usage = phaseUsageFromDeck(deck); - - std::shared_ptr return_value; - // First we need to determine whether it's a group or just a well: - bool isWell = false; - if (deck.hasField("WELSPECS")) { - WELSPECS wspecs = deck.getWELSPECS(); - for (size_t i = 0; i < wspecs.welspecs.size(); i++) { - if (wspecs.welspecs[i].name_ == name) { - isWell = true; - break; - } - } - } - // For now, assume that if it isn't a well, it's a group - - if (isWell) { - ProductionSpecification production_specification; - InjectionSpecification injection_specification; - if (deck.hasField("WCONINJE")) { - WCONINJE wconinje = deck.getWCONINJE(); - for (size_t i = 0; i < wconinje.wconinje.size(); i++) { - if (wconinje.wconinje[i].well_ == name) { - WconinjeLine line = wconinje.wconinje[i]; - injection_specification.BHP_limit_ = line.BHP_limit_; - injection_specification.injector_type_ = toInjectorType(line.injector_type_); - injection_specification.control_mode_ = toInjectionControlMode(line.control_mode_); - injection_specification.surface_flow_max_rate_ = line.surface_flow_max_rate_; - injection_specification.reservoir_flow_max_rate_ = line.reservoir_flow_max_rate_; - production_specification.guide_rate_ = 0.0; // We know we're not a producer - } - } - } - - if (deck.hasField("WCONPROD")) { - WCONPROD wconprod = deck.getWCONPROD(); - for (size_t i = 0; i < wconprod.wconprod.size(); i++) { - if (wconprod.wconprod[i].well_ == name) { - WconprodLine line = wconprod.wconprod[i]; - production_specification.BHP_limit_ = line.BHP_limit_; - production_specification.reservoir_flow_max_rate_ = line.reservoir_flow_max_rate_; - production_specification.oil_max_rate_ = line.oil_max_rate_; - production_specification.control_mode_ = toProductionControlMode(line.control_mode_); - production_specification.water_max_rate_ = line.water_max_rate_; - injection_specification.guide_rate_ = 0.0; // we know we're not an injector - } - } - } - return_value.reset(new WellNode(name, production_specification, injection_specification, phase_usage)); - } else { - InjectionSpecification injection_specification; - if (deck.hasField("GCONINJE")) { - GCONINJE gconinje = deck.getGCONINJE(); - for (size_t i = 0; i < gconinje.gconinje.size(); i++) { - if (gconinje.gconinje[i].group_ == name) { - GconinjeLine line = gconinje.gconinje[i]; - injection_specification.injector_type_ = toInjectorType(line.injector_type_); - injection_specification.control_mode_ = toInjectionControlMode(line.control_mode_); - injection_specification.surface_flow_max_rate_ = line.surface_flow_max_rate_; - injection_specification.reservoir_flow_max_rate_ = line.resv_flow_max_rate_; - injection_specification.reinjection_fraction_target_ = line.reinjection_fraction_target_; - injection_specification.voidage_replacment_fraction_ = line.voidage_replacement_fraction_; - } - } - } - - ProductionSpecification production_specification; - if (deck.hasField("GCONPROD")) { - std::cout << "Searching in gconprod " << std::endl; - std::cout << "name= " << name << std::endl; - GCONPROD gconprod = deck.getGCONPROD(); - for (size_t i = 0; i < gconprod.gconprod.size(); i++) { - if (gconprod.gconprod[i].group_ == name) { - GconprodLine line = gconprod.gconprod[i]; - production_specification.oil_max_rate_ = line.oil_max_rate_; - std::cout << "control_mode = " << line.control_mode_ << std::endl; - production_specification.control_mode_ = toProductionControlMode(line.control_mode_); - production_specification.water_max_rate_ = line.water_max_rate_; - production_specification.gas_max_rate_ = line.gas_max_rate_; - production_specification.liquid_max_rate_ = line.liquid_max_rate_; - production_specification.procedure_ = toProductionProcedure(line.procedure_); - production_specification.reservoir_flow_max_rate_ = line.resv_max_rate_; - } - } - } - - return_value.reset(new WellsGroup(name, production_specification, injection_specification, phase_usage)); - } - - return return_value; - } - std::shared_ptr createGroupWellsGroup(GroupConstPtr group, size_t timeStep, const PhaseUsage& phase_usage ) { InjectionSpecification injection_specification; diff --git a/opm/core/wells/WellsGroup.hpp b/opm/core/wells/WellsGroup.hpp index 03a61d5e..697a23cb 100644 --- a/opm/core/wells/WellsGroup.hpp +++ b/opm/core/wells/WellsGroup.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -403,12 +402,6 @@ namespace Opm bool shut_well_; }; - /// Creates the WellsGroupInterface for the given name - /// \param[in] name the name of the wells group. - /// \param[in] deck the deck from which to fetch information. - std::shared_ptr createWellsGroup(const std::string& name, - const EclipseGridParser& deck); - /// Creates the WellsGroupInterface for the given well /// \param[in] well the Well to construct object for /// \param[in] timeStep the time step in question diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 8166801e..2688c4fc 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -21,7 +21,6 @@ #include -#include #include #include #include diff --git a/opm/core/wells/WellsManager.hpp b/opm/core/wells/WellsManager.hpp index 44112e72..8e7220ff 100644 --- a/opm/core/wells/WellsManager.hpp +++ b/opm/core/wells/WellsManager.hpp @@ -33,8 +33,6 @@ struct UnstructuredGrid; namespace Opm { - - class EclipseGridParser; struct WellData { WellType type; diff --git a/tests/test_blackoilfluid.cpp b/tests/test_blackoilfluid.cpp index 2bd26751..5e2107f4 100644 --- a/tests/test_blackoilfluid.cpp +++ b/tests/test_blackoilfluid.cpp @@ -36,7 +36,7 @@ using namespace Opm; using namespace std; -std::vector > getProps(Opm::DeckConstPtr newParserDeck,PhaseUsage phase_usage_){ +std::vector > getProps(Opm::DeckConstPtr deck,PhaseUsage phase_usage_){ enum PhaseIndex { Aqua = 0, Liquid = 1, Vapour = 2 }; @@ -49,8 +49,8 @@ std::vector > getProps(Opm::DeckConstPtr new // Water PVT if (phase_usage_.phase_used[Aqua]) { - if (newParserDeck->hasKeyword("PVTW")) { - Opm::PvtwTable pvtwTable(newParserDeck->getKeyword("PVTW")); + if (deck->hasKeyword("PVTW")) { + Opm::PvtwTable pvtwTable(deck->getKeyword("PVTW")); props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(pvtwTable)); } else { // Eclipse 100 default. @@ -60,19 +60,19 @@ std::vector > getProps(Opm::DeckConstPtr new // Oil PVT if (phase_usage_.phase_used[Liquid]) { - if (newParserDeck->hasKeyword("PVDO")) { - Opm::PvdoTable pvdoTable(newParserDeck->getKeyword("PVDO")); + if (deck->hasKeyword("PVDO")) { + Opm::PvdoTable pvdoTable(deck->getKeyword("PVDO")); if (samples > 0) { props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(pvdoTable, samples)); } else { props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDead(pvdoTable)); } - } else if (newParserDeck->hasKeyword("PVTO")) { - Opm::PvtoTable pvtoTable(newParserDeck->getKeyword("PVTO"), /*tableIdx=*/0); + } else if (deck->hasKeyword("PVTO")) { + Opm::PvtoTable pvtoTable(deck->getKeyword("PVTO"), /*tableIdx=*/0); props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(pvtoTable)); - } else if (newParserDeck->hasKeyword("PVCDO")) { - Opm::PvcdoTable pvcdoTable(newParserDeck->getKeyword("PVCDO"), /*tableIdx=*/0); + } else if (deck->hasKeyword("PVCDO")) { + Opm::PvcdoTable pvcdoTable(deck->getKeyword("PVCDO"), /*tableIdx=*/0); props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(pvcdoTable)); } else { @@ -81,16 +81,16 @@ std::vector > getProps(Opm::DeckConstPtr new } // Gas PVT if (phase_usage_.phase_used[Vapour]) { - if (newParserDeck->hasKeyword("PVDG")) { - Opm::PvdgTable pvdgTable(newParserDeck->getKeyword("PVDG")); + if (deck->hasKeyword("PVDG")) { + Opm::PvdgTable pvdgTable(deck->getKeyword("PVDG")); if (samples > 0) { props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(pvdgTable, samples)); } else { props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDead(pvdgTable)); } - } else if (newParserDeck->hasKeyword("PVTG")) { - Opm::PvtgTable pvtgTable(newParserDeck->getKeyword("PVTG"), /*tableIdx=*/0); + } else if (deck->hasKeyword("PVTG")) { + Opm::PvtgTable pvtgTable(deck->getKeyword("PVTG"), /*tableIdx=*/0); props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(pvtgTable)); } else { @@ -232,11 +232,11 @@ BOOST_AUTO_TEST_CASE(test_liveoil) const std::string filename = "liveoil.DATA"; cout << "Reading deck: " << filename << endl; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); // setup pvt interface - PhaseUsage phase_usage_ = phaseUsageFromDeck(newParserDeck); - std::vector > props_ = getProps(newParserDeck,phase_usage_); + PhaseUsage phase_usage_ = phaseUsageFromDeck(deck); + std::vector > props_ = getProps(deck,phase_usage_); // setup a test case. We will check 6 [p,r] pairs and compare them to both the [p,z] interface and a finite difference @@ -307,11 +307,11 @@ BOOST_AUTO_TEST_CASE(test_wetgas) const std::string filename = "wetgas.DATA"; cout << "Reading deck: " << filename << endl; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); // setup pvt interface - PhaseUsage phase_usage_ = phaseUsageFromDeck(newParserDeck); - std::vector > props_ = getProps(newParserDeck,phase_usage_); + PhaseUsage phase_usage_ = phaseUsageFromDeck(deck); + std::vector > props_ = getProps(deck,phase_usage_); // setup a test case. We will check 6 [p,r] pairs and compare them to both the [p,z] interface and a finite difference diff --git a/tests/test_blackoilstate.cpp b/tests/test_blackoilstate.cpp index 095f224a..48c84a12 100644 --- a/tests/test_blackoilstate.cpp +++ b/tests/test_blackoilstate.cpp @@ -32,12 +32,12 @@ BOOST_AUTO_TEST_CASE(EqualsDifferentDeckReturnFalse) { const string filename1 = "testBlackoilState1.DATA"; const string filename2 = "testBlackoilState2.DATA"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck1(parser->parseFile(filename1)); - Opm::DeckConstPtr newParserDeck2(parser->parseFile(filename2)); + Opm::DeckConstPtr deck1(parser->parseFile(filename1)); + Opm::DeckConstPtr deck2(parser->parseFile(filename2)); - GridManager gridManager1(newParserDeck1); + GridManager gridManager1(deck1); const UnstructuredGrid* grid1 = gridManager1.c_grid(); - GridManager gridManager2(newParserDeck2); + GridManager gridManager2(deck2); const UnstructuredGrid* grid2 = gridManager2.c_grid(); BlackoilState state1; @@ -55,9 +55,9 @@ BOOST_AUTO_TEST_CASE(EqualsDifferentNumPhasesReturnFalse) { const string filename = "testBlackoilState1.DATA"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); - GridManager gridManager(newParserDeck); + GridManager gridManager(deck); const UnstructuredGrid* grid = gridManager.c_grid(); BlackoilState state1; @@ -75,9 +75,9 @@ BOOST_AUTO_TEST_CASE(EqualsNumericalDifferenceReturnFalse) { const string filename = "testBlackoilState1.DATA"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); - GridManager gridManager(newParserDeck); + GridManager gridManager(deck); const UnstructuredGrid* grid = gridManager.c_grid(); BlackoilState state1; diff --git a/tests/test_column_extract.cpp b/tests/test_column_extract.cpp index ba810027..d643c3ce 100644 --- a/tests/test_column_extract.cpp +++ b/tests/test_column_extract.cpp @@ -131,9 +131,9 @@ BOOST_AUTO_TEST_CASE(DisjointColumn) correct_answer[9].resize(1); Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseString(grdecl)); + Opm::DeckConstPtr deck(parser->parseString(grdecl)); - Opm::GridManager manager(newParserDeck); + Opm::GridManager manager(deck); VVI columns; Opm::extractColumn(*manager.c_grid(), columns); diff --git a/tests/test_equil.cpp b/tests/test_equil.cpp index 05f8df8d..e94f5d26 100644 --- a/tests/test_equil.cpp +++ b/tests/test_equil.cpp @@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE (DeckAllDead) Opm::ParserPtr parser(new Opm::Parser() ); Opm::DeckConstPtr deck = parser->parseFile("deadfluids.DATA"); Opm::BlackoilPropertiesFromDeck props(deck, *grid, false); - Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, *grid, 10.0); + Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, *grid, 10.0); const auto& pressures = comp.press(); BOOST_REQUIRE(pressures.size() == 3); BOOST_REQUIRE(int(pressures[0].size()) == grid->number_of_cells); @@ -416,7 +416,7 @@ BOOST_AUTO_TEST_CASE (DeckWithCapillary) Opm::DeckConstPtr deck = parser->parseFile("capillary.DATA"); Opm::BlackoilPropertiesFromDeck props(deck, grid, false); - Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 10.0); + Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 10.0); const auto& pressures = comp.press(); BOOST_REQUIRE(pressures.size() == 3); BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells); @@ -455,7 +455,7 @@ BOOST_AUTO_TEST_CASE (DeckWithCapillaryOverlap) Opm::DeckConstPtr deck = parser->parseFile("capillary_overlap.DATA"); Opm::BlackoilPropertiesFromDeck props(deck, grid, false); - Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); + Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE(pressures.size() == 3); BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells); @@ -516,7 +516,7 @@ BOOST_AUTO_TEST_CASE (DeckWithLiveOil) Opm::DeckConstPtr deck = parser->parseFile("equil_liveoil.DATA"); Opm::BlackoilPropertiesFromDeck props(deck, grid, false); - Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); + Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE(pressures.size() == 3); BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells); @@ -594,7 +594,7 @@ BOOST_AUTO_TEST_CASE (DeckWithLiveGas) Opm::DeckConstPtr deck = parser->parseFile("equil_livegas.DATA"); Opm::BlackoilPropertiesFromDeck props(deck, grid, false); - Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); + Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE(pressures.size() == 3); BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells); @@ -675,7 +675,7 @@ BOOST_AUTO_TEST_CASE (DeckWithRSVDAndRVVD) Opm::DeckConstPtr deck = parser->parseFile("equil_rsvd_and_rvvd.DATA"); Opm::BlackoilPropertiesFromDeck props(deck, grid, false); - Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); + Opm::Equil::DeckDependent::InitialStateComputer comp(props, deck, grid, 9.80665); const auto& pressures = comp.press(); BOOST_REQUIRE(pressures.size() == 3); BOOST_REQUIRE(int(pressures[0].size()) == grid.number_of_cells); diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index b652aafc..7ddf9f29 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -176,10 +176,10 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) { const std::string filename = "wells_manager_data.data"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(newParserDeck)); - Opm::GridManager gridManager(newParserDeck); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); + Opm::GridManager gridManager(deck); { Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid(), NULL); @@ -199,10 +199,10 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) { BOOST_AUTO_TEST_CASE(WellsEqual) { const std::string filename = "wells_manager_data.data"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(newParserDeck)); - Opm::GridManager gridManager(newParserDeck); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); + Opm::GridManager gridManager(deck); Opm::WellsManager wellsManager0(eclipseState , 0 , *gridManager.c_grid(), NULL); Opm::WellsManager wellsManager1(eclipseState , 1 , *gridManager.c_grid(), NULL); @@ -215,10 +215,10 @@ BOOST_AUTO_TEST_CASE(WellsEqual) { BOOST_AUTO_TEST_CASE(ControlsEqual) { const std::string filename = "wells_manager_data.data"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(newParserDeck)); - Opm::GridManager gridManager(newParserDeck); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); + Opm::GridManager gridManager(deck); Opm::WellsManager wellsManager0(eclipseState , 0 , *gridManager.c_grid(), NULL); Opm::WellsManager wellsManager1(eclipseState , 1 , *gridManager.c_grid(), NULL); @@ -239,10 +239,10 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { BOOST_AUTO_TEST_CASE(WellHasSTOP_ExceptionIsThrown) { const std::string filename = "wells_manager_data_wellSTOP.data"; Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr newParserDeck(parser->parseFile(filename)); + Opm::DeckConstPtr deck(parser->parseFile(filename)); - Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(newParserDeck)); - Opm::GridManager gridManager(newParserDeck); + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); + Opm::GridManager gridManager(deck); BOOST_CHECK_THROW( new Opm::WellsManager(eclipseState, 0, *gridManager.c_grid(), NULL), std::runtime_error ); }