Files
opm-common/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp

149 lines
5.9 KiB
C++
Raw Normal View History

2014-05-16 15:57:47 +02:00
/*
Copyright 2014 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/>.
*/
#ifndef ECLIPSE_GRIDPROPERTIES_HPP_
#define ECLIPSE_GRIDPROPERTIES_HPP_
#include <set>
2014-05-16 15:57:47 +02:00
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
2014-05-16 15:57:47 +02:00
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/BoxManager.hpp>
2016-04-14 09:39:28 +08:00
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
#include <opm/parser/eclipse/Units/Dimension.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
/*
This class implements a container (std::unordered_map<std::string ,
Gridproperty<T>>) of Gridproperties. Usage is as follows:
2014-05-16 15:57:47 +02:00
1. Instantiate the class; passing the number of grid cells and the
supported keywords as a list of strings to the constructor.
2014-05-16 15:57:47 +02:00
2. Query the container with the supportsKeyword() and hasKeyword()
methods.
3. When you ask the container to get a keyword with the
getKeyword() method it will automatically create a new
GridProperty object if the container does not have this
property.
2014-05-16 15:57:47 +02:00
*/
namespace Opm {
void setKeywordBox( const DeckRecord& deckRecord,
BoxManager& boxManager);
class Eclipse3DProperties;
template <typename T>
class GridProperties {
public:
typedef typename GridProperty<T>::SupportedKeywordInfo SupportedKeywordInfo;
GridProperties(const EclipseGrid& eclipseGrid,
const UnitSystem* deckUnitSystem,
std::vector< SupportedKeywordInfo >&& supportedKeywords);
2015-05-05 19:23:06 +02:00
GridProperties(const EclipseGrid& eclipseGrid,
std::vector< SupportedKeywordInfo >&& supportedKeywords);
T convertInputValue( const GridProperty<T>& property , double doubleValue) const;
T convertInputValue( double doubleValue ) const;
bool supportsKeyword(const std::string& keyword) const;
bool hasKeyword(const std::string& keyword) const;
size_t size() const;
const GridProperty<T>& getKeyword(const std::string& keyword) const;
const GridProperty<T>& getInitializedKeyword(const std::string& keyword) const;
bool addKeyword(const std::string& keywordName);
void copyKeyword(const std::string& srcField ,
const std::string& targetField ,
const Box& inputBox);
2016-04-14 09:39:28 +08:00
const MessageContainer& getMessageContainer() const;
MessageContainer& getMessageContainer();
2016-04-14 09:39:28 +08:00
template <class Keyword>
bool hasKeyword() const {
return hasKeyword( Keyword::keywordName );
}
2015-04-28 15:32:46 +02:00
template <class Keyword>
const GridProperty<T>& getKeyword() const {
return getKeyword( Keyword::keywordName );
}
2015-04-28 15:32:46 +02:00
template <class Keyword>
const GridProperty<T>& getInitializedKeyword() const {
return getInitializedKeyword( Keyword::keywordName );
}
2015-04-28 15:32:46 +02:00
GridProperty<T>& getOrCreateProperty(const std::string name);
/**
The fine print of the manual says the ADD keyword should support
some state dependent semantics regarding endpoint scaling arrays
in the PROPS section. That is not supported.
*/
void handleADDRecord( const DeckRecord& record, BoxManager& boxManager);
void handleMULTIPLYRecord( const DeckRecord& record, BoxManager& boxManager);
void handleCOPYRecord( const DeckRecord& record, BoxManager& boxManager);
void handleEQUALSRecord( const DeckRecord& record, BoxManager& boxManager);
void handleEQUALREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty );
void handleADDREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty );
void handleMULTIREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty );
void handleCOPYREGRecord( const DeckRecord& record, const GridProperty<int>& regionProperty );
2015-04-28 15:32:46 +02:00
private:
/// this method exists for (friend) Eclipse3DProperties to be allowed initializing PORV and ACTNUM keyword
void postAddKeyword(const std::string& name,
const T defaultValue,
std::function< void( std::vector< T >& ) > postProcessor,
const std::string& dimString );
GridProperty<T>& getKeyword(const std::string& keyword);
bool addAutoGeneratedKeyword_(const std::string& keywordName) const;
bool isAutoGenerated_(const std::string& keyword) const;
2014-05-16 15:57:47 +02:00
friend class Eclipse3DProperties; // needed for PORV keyword entanglement
const EclipseGrid& m_eclipseGrid;
const UnitSystem * m_deckUnitSystem = nullptr;
2016-04-14 09:39:28 +08:00
MessageContainer m_messages;
std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords;
mutable std::map<std::string , std::shared_ptr<GridProperty<T> > > m_properties;
2016-05-19 11:35:05 +02:00
mutable std::set<std::string> m_autoGeneratedProperties;
mutable std::vector<std::shared_ptr<GridProperty<T> > > m_property_list;
};
2014-05-16 15:57:47 +02:00
}
#endif // ECLIPSE_GRIDPROPERTIES_HPP_