From ea09af47f4b65ac1ae7afc2140d3be5f45615f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvor=20M=C3=B8ll=20Nilsen?= Date: Mon, 27 Aug 2012 12:21:25 +0200 Subject: [PATCH] Added programs to test test fluids. --- tests/Makefile.am | 10 ++++- tests/pvt_test.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++ tests/relperm_test.cpp | 82 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 tests/pvt_test.cpp create mode 100644 tests/relperm_test.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index a82a1dc3..4181eaea 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,7 +21,9 @@ test_read_vag \ test_readpolymer \ test_sf2p \ test_writeVtkData \ -unit_test +unit_test \ +pvt_test \ +relperm_test bo_resprop_test_SOURCES = bo_resprop_test.cpp @@ -54,6 +56,12 @@ test_writeVtkData_SOURCES = test_writeVtkData.cpp unit_test_SOURCES = unit_test.cpp +pvt_test_SOURCES = pvt_test.cpp +pvt_test_LDADD = $(LDADD) + +relperm_test_SOURCES = relperm_test.cpp +relperm_test_LDADD = $(LDADD) + if UMFPACK noinst_PROGRAMS += test_cfs_tpfa diff --git a/tests/pvt_test.cpp b/tests/pvt_test.cpp new file mode 100644 index 00000000..45e2775d --- /dev/null +++ b/tests/pvt_test.cpp @@ -0,0 +1,87 @@ +/* + 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("deck_filename"); + std::string input_file = param.get("input_filename"); + std::string matrix_output = param.get("matrix_outout"); + std::string rs_output = param.get("rs_output"); + std::string b_output = param.get("b_output"); + Opm::EclipseGridParser deck(ecl_file); + UnstructuredGrid grid; + grid.number_of_cells = 1; + grid.global_cell = NULL; + Opm::BlackoilPropertiesFromDeck props(deck, grid); + Opm::BlackoilPvtProperties pvt; + pvt.init(deck); + + + const int n = 1; + std::fstream inos(input_file.c_str()); + int np=props.numPhases(); + while(inos.good()){ + double p[n]; + double z[np*n]; + int cells[n] = { 0 }; + inos >> p[0]; + for(int i=0; i < np; ++i){ + inos >> z[i]; + } + double A[np*np*n]; + props.matrix(n, p, z, cells, A, 0); + std::fstream aos(matrix_output.c_str()); + std::copy(A, A + np*np, std::ostream_iterator(aos, " ")); + std::cout << std::endl; + double b[np]; + double dbdp[np]; + pvt.dBdp(n, p, z, b, dbdp); + std::fstream bos(b_output.c_str()); + std::copy(b, b + np, std::ostream_iterator(bos, " ")); + std::copy(b, dbdp + np, std::ostream_iterator(bos, " ")); + std::cout << std::endl; + double rs[np]; + double drs[np]; + //pvt.R(n, p, z, rs); + pvt.dRdp(n, p, z, rs,drs); + std::fstream rsos(rs_output.c_str()); + std::copy(b, rs + np, std::ostream_iterator(rsos, " ")); + std::copy(b, drs + np, std::ostream_iterator(rsos, " ")); + std::cout << std::endl; + } +} diff --git a/tests/relperm_test.cpp b/tests/relperm_test.cpp new file mode 100644 index 00000000..64897289 --- /dev/null +++ b/tests/relperm_test.cpp @@ -0,0 +1,82 @@ +/* + 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 +#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; + Opm::BlackoilPropertiesFromDeck props(deck, grid); + + 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); + } + int np=props.numPhases(); + while((inos.good()) && (!inos.eof())){ + double s[np]; + for(int i=0; i < np; ++i){ + inos >> s[i]; + } + if(inos.good()){ + double kr[np]; + double dkr[np*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"; + } + } +}