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>
|
2016-03-03 19:09:38 -06:00
|
|
|
#include <opm/core/props/satfunc/RelpermDiagnostics_impl.hpp>
|
2015-11-18 19:21:00 -06:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
|
|
|
#include <opm/core/utility/StopWatch.hpp>
|
|
|
|
#include <opm/core/utility/miscUtilities.hpp>
|
|
|
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
|
|
|
|
2016-03-16 20:46:12 -05:00
|
|
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
2015-11-18 19:21:00 -06:00
|
|
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
2016-03-31 21:49:27 -05:00
|
|
|
#include <opm/common/OpmLog/OpmLog.hpp>
|
|
|
|
#include <opm/common/OpmLog/EclipsePRTLog.hpp>
|
2015-11-18 19:21:00 -06:00
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
2016-02-18 19:31:49 -06:00
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
2015-11-18 19:21:00 -06:00
|
|
|
#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);
|
|
|
|
}
|
2015-11-30 23:49:49 -06:00
|
|
|
const char* eclipseFilename = argv[1];
|
2015-11-18 19:21:00 -06:00
|
|
|
EclipseStateConstPtr eclState;
|
|
|
|
ParserPtr parser(new Opm::Parser);
|
2016-03-16 20:46:12 -05:00
|
|
|
Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE },
|
|
|
|
{ ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE},
|
|
|
|
{ ParseContext::PARSE_RANDOM_TEXT, InputError::IGNORE},
|
|
|
|
{ ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER, InputError::IGNORE},
|
|
|
|
{ ParseContext::UNSUPPORTED_COMPORD_TYPE, InputError::IGNORE},
|
|
|
|
{ ParseContext::UNSUPPORTED_INITIAL_THPRES, InputError::IGNORE},
|
|
|
|
{ ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES, InputError::IGNORE}
|
2015-11-18 23:31:19 -06:00
|
|
|
});
|
2016-03-16 20:46:12 -05:00
|
|
|
Opm::DeckConstPtr deck(parser->parseFile(eclipseFilename, parseContext));
|
2016-08-08 03:02:53 -05:00
|
|
|
eclState.reset(new EclipseState(*deck, parseContext));
|
2015-11-18 19:21:00 -06:00
|
|
|
|
2016-08-31 03:02:24 -05:00
|
|
|
GridManager gm(*eclState->getInputGrid());
|
2015-11-18 19:21:00 -06:00
|
|
|
const UnstructuredGrid& grid = *gm.c_grid();
|
2016-02-18 19:31:49 -06:00
|
|
|
using boost::filesystem::path;
|
|
|
|
path fpath(eclipseFilename);
|
|
|
|
std::string baseName;
|
|
|
|
if (boost::to_upper_copy(path(fpath.extension()).string())== ".DATA") {
|
|
|
|
baseName = path(fpath.stem()).string();
|
|
|
|
} else {
|
|
|
|
baseName = path(fpath.filename()).string();
|
2015-11-18 19:21:00 -06:00
|
|
|
}
|
2016-02-18 19:31:49 -06:00
|
|
|
|
2016-03-02 00:55:39 -06:00
|
|
|
std::string logFile = baseName + ".SATFUNCLOG";
|
2016-03-31 21:49:27 -05:00
|
|
|
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile, Log::DefaultMessageTypes);
|
|
|
|
OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog );
|
2016-05-18 21:07:36 -05:00
|
|
|
prtLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(true, false));
|
2016-05-18 20:48:12 -05:00
|
|
|
std::shared_ptr<StreamLog> streamLog = std::make_shared<EclipsePRTLog>(std::cout, Log::DefaultMessageTypes);
|
|
|
|
OpmLog::addBackend( "STREAMLOG" , streamLog );
|
|
|
|
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10));
|
2016-05-18 21:07:36 -05:00
|
|
|
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(true, true));
|
2016-03-31 21:49:27 -05:00
|
|
|
RelpermDiagnostics diagnostic;
|
2015-11-26 01:22:51 -06:00
|
|
|
diagnostic.diagnosis(eclState, deck, grid);
|
2015-11-18 19:21:00 -06:00
|
|
|
}
|
|
|
|
catch (const std::exception &e) {
|
|
|
|
std::cerr << "Program threw an exception: " << e.what() << "\n";
|
|
|
|
throw;
|
|
|
|
}
|