opm-simulators/examples/diagnose_relperm.cpp

114 lines
3.5 KiB
C++
Raw Normal View History

2015-11-18 19:21:00 -06:00
/*
Copyright 2015 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 <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>
#include <opm/core/props/satfunc/RelpermDiagnostics.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/core/utility/StopWatch.hpp>
#include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <boost/filesystem.hpp>
#include <memory>
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <iterator>
2015-11-19 02:08:26 -06:00
void usage() {
std::cout << std::endl <<
"Usage: diagnose_relperm <eclipseFile>" << std::endl;
}
2015-11-18 19:21:00 -06:00
// ----------------- Main program -----------------
int
main(int argc, char** argv)
try
{
using namespace Opm;
2015-11-19 02:08:26 -06:00
if (argc <= 1) {
usage();
exit(1);
}
static char* ECLIPSEFILENAME(argv[1]);
std::ifstream eclipseFile(ECLIPSEFILENAME, std::ios::in);
if (eclipseFile.fail()) {
std::cerr << "Error: Filename " << ECLIPSEFILENAME << " not found or not readable." << std::endl;
usage();
exit(1);
}
eclipseFile.close();
//parameter::ParameterGroup param(argc, argv);
2015-11-18 19:21:00 -06:00
// Read saturation tables.
EclipseStateConstPtr eclState;
ParserPtr parser(new Opm::Parser);
//ParseMode parseMode;
2015-11-18 23:31:19 -06:00
Opm::ParseMode parseMode({{ ParseMode::PARSE_RANDOM_SLASH , InputError::IGNORE },
{ ParseMode::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE},
{ ParseMode::PARSE_RANDOM_TEXT, InputError::IGNORE}
});
2015-11-19 02:08:26 -06:00
Opm::DeckConstPtr deck(parser->parseFile(ECLIPSEFILENAME, parseMode));
//std::string deck_filename = param.get<std::string>("deck_filename");
//deck = parser->parseFile(deck_filename, parseMode);
2015-11-18 19:21:00 -06:00
eclState.reset(new EclipseState(deck, parseMode));
GridManager gm(deck);
const UnstructuredGrid& grid = *gm.c_grid();
// Write parameters used for later reference.
2015-11-19 02:08:26 -06:00
//bool output = param.getDefault("output", true);
bool output = true;
2015-11-18 19:21:00 -06:00
std::string output_dir;
if (output) {
2015-11-19 02:08:26 -06:00
output_dir = "output";
2015-11-18 19:21:00 -06:00
boost::filesystem::path fpath(output_dir);
try {
create_directories(fpath);
}
catch (...) {
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
}
}
Opm::time::StopWatch timer;
timer.start();
RelpermDiagnostics diagnostic(eclState);
diagnostic.diagnosis(eclState, deck, grid);
2015-11-18 19:21:00 -06:00
timer.stop();
double tt = timer.secsSinceStart();
std::cout << "relperm diagnostics: " << tt << " seconds." << std::endl;
}
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}