2014-02-27 06:55:15 -06:00
|
|
|
/*
|
|
|
|
Copyright 2014 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
|
|
#include <opm/core/grid.h>
|
|
|
|
#include <opm/core/grid/GridManager.hpp>
|
2015-10-08 04:42:15 -05:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
2014-02-27 06:55:15 -06:00
|
|
|
#include <opm/core/simulator/initStateEquil.hpp>
|
|
|
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
|
|
|
#include <opm/core/props/BlackoilPropertiesFromDeck.hpp>
|
|
|
|
#include <opm/core/simulator/BlackoilState.hpp>
|
2014-03-28 11:35:43 -05:00
|
|
|
|
2016-03-16 20:46:12 -05:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
2014-03-28 11:35:43 -05:00
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
|
|
|
2014-02-27 06:55:15 -06:00
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
2016-05-27 03:59:00 -05:00
|
|
|
#include <fstream>
|
|
|
|
|
2014-02-27 06:55:15 -06:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void warnIfUnusedParams(const Opm::parameter::ParameterGroup& param)
|
|
|
|
{
|
|
|
|
if (param.anyUnused()) {
|
|
|
|
std::cout << "-------------------- Unused parameters: --------------------\n";
|
|
|
|
param.displayUsage();
|
|
|
|
std::cout << "----------------------------------------------------------------" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void outputData(const std::string& output_dir,
|
|
|
|
const std::string& name,
|
|
|
|
const std::vector<double>& data)
|
|
|
|
{
|
|
|
|
std::ostringstream fname;
|
|
|
|
fname << output_dir << "/" << name;
|
|
|
|
boost::filesystem::path fpath = fname.str();
|
|
|
|
try {
|
|
|
|
create_directories(fpath);
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
|
|
|
|
}
|
|
|
|
fname << "/" << "initial.txt";
|
|
|
|
std::ofstream file(fname.str().c_str());
|
|
|
|
if (!file) {
|
|
|
|
OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
|
|
|
|
}
|
|
|
|
std::copy(data.begin(), data.end(), std::ostream_iterator<double>(file, "\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // anon namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------- Main program -----------------
|
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using namespace Opm;
|
|
|
|
|
|
|
|
// Setup.
|
2015-04-14 08:32:19 -05:00
|
|
|
parameter::ParameterGroup param(argc, argv);
|
2014-02-27 06:55:15 -06:00
|
|
|
std::cout << "--------------- Reading parameters ---------------" << std::endl;
|
|
|
|
const std::string deck_filename = param.get<std::string>("deck_filename");
|
2016-03-16 20:46:12 -05:00
|
|
|
Opm::ParseContext parseContext;
|
2016-10-13 09:03:35 -05:00
|
|
|
Opm::Parser parser;
|
|
|
|
const Opm::Deck& deck = parser.parseFile(deck_filename , parseContext);
|
|
|
|
const Opm::EclipseState eclipseState(deck, parseContext);
|
2014-02-27 06:55:15 -06:00
|
|
|
const double grav = param.getDefault("gravity", unit::gravity);
|
2016-10-13 09:03:35 -05:00
|
|
|
GridManager gm(eclipseState.getInputGrid());
|
2014-02-27 06:55:15 -06:00
|
|
|
const UnstructuredGrid& grid = *gm.c_grid();
|
2014-06-06 07:07:14 -05:00
|
|
|
BlackoilPropertiesFromDeck props(deck, eclipseState, grid, param);
|
2014-02-27 06:55:15 -06:00
|
|
|
warnIfUnusedParams(param);
|
|
|
|
|
|
|
|
// Initialisation.
|
2016-02-25 14:47:47 -06:00
|
|
|
//initBlackoilSurfvolUsingRSorRV(UgGridHelpers::numCells(grid), props, state);
|
|
|
|
BlackoilState state( UgGridHelpers::numCells(grid) , UgGridHelpers::numFaces(grid), 3);
|
2014-06-26 07:46:57 -05:00
|
|
|
initStateEquil(grid, props, deck, eclipseState, grav, state);
|
2014-02-27 06:55:15 -06:00
|
|
|
|
|
|
|
// Output.
|
|
|
|
const std::string output_dir = param.getDefault<std::string>("output_dir", "output");
|
|
|
|
outputData(output_dir, "pressure", state.pressure());
|
|
|
|
outputData(output_dir, "saturation", state.saturation());
|
|
|
|
outputData(output_dir, "rs", state.gasoilratio());
|
|
|
|
outputData(output_dir, "rv", state.rv());
|
|
|
|
}
|
|
|
|
catch (const std::exception& e) {
|
|
|
|
std::cerr << "Program threw an exception: " << e.what() << "\n";
|
|
|
|
throw;
|
|
|
|
}
|