2013-06-03 15:54:16 +02:00
|
|
|
/*
|
|
|
|
|
Copyright 2013 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-06-20 15:30:37 +02:00
|
|
|
#include "DeckKeyword.hpp"
|
2016-01-15 08:42:57 +01:00
|
|
|
#include "DeckRecord.hpp"
|
|
|
|
|
#include "DeckItem.hpp"
|
2013-06-03 15:54:16 +02:00
|
|
|
|
|
|
|
|
namespace Opm {
|
|
|
|
|
|
2013-06-20 15:30:37 +02:00
|
|
|
DeckKeyword::DeckKeyword(const std::string& keywordName) {
|
2013-08-21 10:41:18 +02:00
|
|
|
m_knownKeyword = true;
|
2013-06-03 15:54:16 +02:00
|
|
|
m_keywordName = keywordName;
|
2014-05-16 15:29:24 +02:00
|
|
|
m_isDataKeyword = false;
|
2014-09-29 19:28:45 +02:00
|
|
|
m_fileName = "";
|
|
|
|
|
m_lineNumber = -1;
|
2013-06-03 15:54:16 +02:00
|
|
|
}
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2013-08-22 15:53:57 +02:00
|
|
|
DeckKeyword::DeckKeyword(const std::string& keywordName, bool knownKeyword) {
|
|
|
|
|
m_knownKeyword = knownKeyword;
|
|
|
|
|
m_keywordName = keywordName;
|
2014-05-16 15:29:24 +02:00
|
|
|
m_isDataKeyword = false;
|
2014-09-29 19:28:45 +02:00
|
|
|
m_fileName = "";
|
|
|
|
|
m_lineNumber = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeckKeyword::setLocation(const std::string& fileName, int lineNumber) {
|
|
|
|
|
m_fileName = fileName;
|
|
|
|
|
m_lineNumber = lineNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::string& DeckKeyword::getFileName() const {
|
|
|
|
|
return m_fileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DeckKeyword::getLineNumber() const {
|
|
|
|
|
return m_lineNumber;
|
2013-10-22 11:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-19 13:14:36 +02:00
|
|
|
void DeckKeyword::setDataKeyword(bool isDataKeyword_) {
|
|
|
|
|
m_isDataKeyword = isDataKeyword_;
|
2014-05-16 15:29:24 +02:00
|
|
|
}
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2014-05-16 15:29:24 +02:00
|
|
|
bool DeckKeyword::isDataKeyword() const {
|
|
|
|
|
return m_isDataKeyword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-08-01 09:25:54 +02:00
|
|
|
const std::string& DeckKeyword::name() const {
|
2013-06-03 15:54:16 +02:00
|
|
|
return m_keywordName;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-20 15:30:37 +02:00
|
|
|
size_t DeckKeyword::size() const {
|
2013-06-03 15:54:16 +02:00
|
|
|
return m_recordList.size();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 10:41:18 +02:00
|
|
|
bool DeckKeyword::isKnown() const {
|
|
|
|
|
return m_knownKeyword;
|
|
|
|
|
}
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2016-02-16 14:55:21 +01:00
|
|
|
void DeckKeyword::addRecord(DeckRecord&& record) {
|
|
|
|
|
this->m_recordList.push_back( std::move( record ) );
|
2013-06-03 15:54:16 +02:00
|
|
|
}
|
2013-06-20 15:30:37 +02:00
|
|
|
|
2016-02-16 14:55:21 +01:00
|
|
|
DeckKeyword::const_iterator DeckKeyword::begin() const {
|
2014-05-30 13:19:01 +02:00
|
|
|
return m_recordList.begin();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-16 14:55:21 +01:00
|
|
|
DeckKeyword::const_iterator DeckKeyword::end() const {
|
2014-05-30 13:19:01 +02:00
|
|
|
return m_recordList.end();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-16 14:55:21 +01:00
|
|
|
const DeckRecord& DeckKeyword::getRecord(size_t index) const {
|
|
|
|
|
return this->m_recordList.at( index );
|
2013-06-03 15:54:16 +02:00
|
|
|
}
|
2013-09-22 18:53:29 +02:00
|
|
|
|
2016-02-16 14:55:21 +01:00
|
|
|
DeckRecord& DeckKeyword::getRecord(size_t index) {
|
|
|
|
|
return this->m_recordList.at( index );
|
|
|
|
|
}
|
2013-09-22 18:53:29 +02:00
|
|
|
|
2016-02-16 14:55:21 +01:00
|
|
|
const DeckRecord& DeckKeyword::getDataRecord() const {
|
2013-09-22 18:53:29 +02:00
|
|
|
if (m_recordList.size() == 1)
|
|
|
|
|
return getRecord(0);
|
|
|
|
|
else
|
2016-05-10 14:45:35 +02:00
|
|
|
throw std::range_error("Not a data keyword \"" + name() + "\"?");
|
2013-09-22 18:53:29 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-27 22:22:55 +02:00
|
|
|
|
|
|
|
|
size_t DeckKeyword::getDataSize() const {
|
2016-02-16 14:55:21 +01:00
|
|
|
return this->getDataRecord().getDataItem().size();
|
2014-04-27 22:22:55 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-22 18:53:29 +02:00
|
|
|
|
|
|
|
|
const std::vector<int>& DeckKeyword::getIntData() const {
|
2016-02-16 14:55:21 +01:00
|
|
|
return this->getDataRecord().getDataItem().getData< int >();
|
2013-09-22 18:53:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::vector<std::string>& DeckKeyword::getStringData() const {
|
2016-02-16 14:55:21 +01:00
|
|
|
return this->getDataRecord().getDataItem().getData< std::string >();
|
2013-09-22 18:53:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-12-10 14:16:54 +01:00
|
|
|
const std::vector<double>& DeckKeyword::getRawDoubleData() const {
|
2016-02-16 14:55:21 +01:00
|
|
|
return this->getDataRecord().getDataItem().getData< double >();
|
2013-12-10 14:16:54 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-10 12:11:45 +01:00
|
|
|
const std::vector<double>& DeckKeyword::getSIDoubleData() const {
|
2016-02-16 14:55:21 +01:00
|
|
|
return this->getDataRecord().getDataItem().getSIDoubleData();
|
2013-09-22 18:53:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-03 15:54:16 +02:00
|
|
|
}
|
|
|
|
|
|