2015-06-09 09:37:19 +02: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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-11-02 13:35:01 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2015-06-09 09:37:19 +02:00
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
2016-01-15 08:42:57 +01:00
|
|
|
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
2016-01-24 21:49:39 +01:00
|
|
|
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
2016-01-15 08:42:57 +01:00
|
|
|
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
2019-06-24 13:23:13 +02:00
|
|
|
#include <opm/parser/eclipse/Deck/Section.hpp>
|
2016-01-15 08:42:57 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
2016-02-29 12:25:58 +01:00
|
|
|
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
|
2015-06-09 09:37:19 +02:00
|
|
|
|
2016-04-25 15:08:56 +02:00
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/E.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/R.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
|
|
|
|
|
|
2015-06-09 09:37:19 +02:00
|
|
|
namespace Opm {
|
|
|
|
|
|
2016-02-29 12:25:58 +01:00
|
|
|
static inline Equil equils( const Deck& deck ) {
|
2016-04-25 15:08:56 +02:00
|
|
|
if( !deck.hasKeyword<ParserKeywords::EQUIL>( ) ) return {};
|
|
|
|
|
return Equil( deck.getKeyword<ParserKeywords::EQUIL>( ) );
|
2016-02-29 12:25:58 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-29 09:57:25 +01:00
|
|
|
InitConfig::InitConfig()
|
|
|
|
|
: m_filleps(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-24 13:23:13 +02:00
|
|
|
InitConfig::InitConfig(const Deck& deck)
|
|
|
|
|
: equil(equils(deck))
|
2019-07-02 10:25:28 +02:00
|
|
|
, foamconfig(deck)
|
2019-06-24 13:23:13 +02:00
|
|
|
, m_filleps(PROPSSection{deck}.hasKeyword("FILLEPS"))
|
|
|
|
|
{
|
2016-11-02 13:35:01 +01:00
|
|
|
if( !deck.hasKeyword( "RESTART" ) ) {
|
|
|
|
|
if( deck.hasKeyword( "SKIPREST" ) ) {
|
|
|
|
|
std::cout << "Deck has SKIPREST, but no RESTART. "
|
|
|
|
|
<< "Ignoring SKIPREST." << std::endl;
|
|
|
|
|
}
|
2015-06-09 09:37:19 +02:00
|
|
|
|
2016-11-02 13:35:01 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2016-04-25 15:23:25 +02:00
|
|
|
|
2016-11-02 13:35:01 +01:00
|
|
|
const auto& record = deck.getKeyword( "RESTART" ).getRecord(0);
|
|
|
|
|
const auto& save_item = record.getItem(2);
|
2016-04-25 15:23:25 +02:00
|
|
|
|
2016-11-02 13:35:01 +01:00
|
|
|
if( save_item.hasValue( 0 ) ) {
|
|
|
|
|
throw std::runtime_error(
|
|
|
|
|
"OPM does not support RESTART from a SAVE file, "
|
|
|
|
|
"only from RESTART files");
|
|
|
|
|
}
|
2015-06-09 09:37:19 +02:00
|
|
|
|
2016-11-02 13:35:01 +01:00
|
|
|
int step = record.getItem( 1 ).get< int >(0);
|
2018-07-19 08:24:49 +02:00
|
|
|
const std::string& root = record.getItem( 0 ).get< std::string >( 0 );
|
|
|
|
|
const std::string& input_path = deck.getInputPath();
|
2015-06-09 09:37:19 +02:00
|
|
|
|
2018-07-19 08:24:49 +02:00
|
|
|
if (root[0] == '/' || input_path.empty())
|
|
|
|
|
this->setRestart(root, step);
|
|
|
|
|
else
|
|
|
|
|
this->setRestart( input_path + "/" + root, step );
|
2016-11-02 13:35:01 +01:00
|
|
|
}
|
2015-06-09 09:37:19 +02:00
|
|
|
|
2019-11-29 09:57:25 +01:00
|
|
|
InitConfig::InitConfig(const Equil& equils, const FoamConfig& foam,
|
|
|
|
|
bool filleps, bool restartReq, int restartStep,
|
|
|
|
|
const std::string& restartRootName)
|
|
|
|
|
: equil(equils)
|
|
|
|
|
, foamconfig(foam)
|
|
|
|
|
, m_filleps(filleps)
|
|
|
|
|
, m_restartRequested(restartReq)
|
|
|
|
|
, m_restartStep(restartStep)
|
|
|
|
|
, m_restartRootName(restartRootName)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 13:35:01 +01:00
|
|
|
void InitConfig::setRestart( const std::string& root, int step) {
|
|
|
|
|
m_restartRequested = true;
|
|
|
|
|
m_restartStep = step;
|
|
|
|
|
m_restartRootName = root;
|
2015-06-09 09:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
2016-04-25 15:23:25 +02:00
|
|
|
bool InitConfig::restartRequested() const {
|
|
|
|
|
return m_restartRequested;
|
2015-06-09 09:37:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int InitConfig::getRestartStep() const {
|
|
|
|
|
return m_restartStep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::string& InitConfig::getRestartRootName() const {
|
|
|
|
|
return m_restartRootName;
|
|
|
|
|
}
|
2016-02-29 12:25:58 +01:00
|
|
|
|
|
|
|
|
bool InitConfig::hasEquil() const {
|
|
|
|
|
return !this->equil.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Equil& InitConfig::getEquil() const {
|
|
|
|
|
if( !this->hasEquil() )
|
|
|
|
|
throw std::runtime_error( "Error: No 'EQUIL' present" );
|
|
|
|
|
|
|
|
|
|
return this->equil;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-01 14:40:37 +02:00
|
|
|
bool InitConfig::hasFoamConfig() const {
|
2019-07-04 12:57:43 +02:00
|
|
|
// return !this->foamconfig.empty();
|
|
|
|
|
return true;
|
2019-07-01 14:40:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FoamConfig& InitConfig::getFoamConfig() const {
|
|
|
|
|
if( !this->hasFoamConfig() )
|
|
|
|
|
throw std::runtime_error( "Error: No foam model configuration keywords present" );
|
|
|
|
|
|
|
|
|
|
return this->foamconfig;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-29 09:57:25 +01:00
|
|
|
bool InitConfig::operator==(const InitConfig& data) const {
|
|
|
|
|
return equil == data.equil &&
|
|
|
|
|
foamconfig == data.foamconfig &&
|
|
|
|
|
m_filleps == data.m_filleps &&
|
|
|
|
|
m_restartRequested == data.m_restartRequested &&
|
|
|
|
|
m_restartStep == data.m_restartStep &&
|
|
|
|
|
m_restartRootName == data.m_restartRootName;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-09 09:37:19 +02:00
|
|
|
} //namespace Opm
|