2014-05-16 15:31:20 +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_GRIDPROPERTY_HPP_
|
|
|
|
|
#define ECLIPSE_GRIDPROPERTY_HPP_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2014-05-30 10:08:35 +02:00
|
|
|
|
2015-05-18 23:49:08 +02:00
|
|
|
#include <ert/ecl/EclKW.hpp>
|
|
|
|
|
|
2014-10-09 13:19:24 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/GridPropertyInitializers.hpp>
|
2014-05-16 15:31:20 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
This class implemenents a class representing properties which are
|
|
|
|
|
define over an ECLIPSE grid, i.e. with one value for each logical
|
2014-08-13 15:09:32 +02:00
|
|
|
cartesian cell in the grid.
|
2014-05-16 15:31:20 +02:00
|
|
|
*/
|
2014-10-09 13:19:24 +02:00
|
|
|
|
2014-05-16 15:31:20 +02:00
|
|
|
namespace Opm {
|
2014-10-09 13:19:24 +02:00
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
class Box;
|
|
|
|
|
class DeckItem;
|
|
|
|
|
class DeckKeyword;
|
|
|
|
|
class EclipseGrid;
|
|
|
|
|
|
|
|
|
|
template< typename T >
|
|
|
|
|
class GridPropertySupportedKeywordInfo {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
GridPropertySupportedKeywordInfo() = default;
|
|
|
|
|
|
|
|
|
|
GridPropertySupportedKeywordInfo(
|
|
|
|
|
const std::string& name,
|
2016-02-29 16:44:30 +01:00
|
|
|
GridPropertyInitFunction< T > initializer,
|
|
|
|
|
GridPropertyPostFunction< T > postProcessor,
|
2016-02-26 23:41:34 +01:00
|
|
|
const std::string& dimString );
|
|
|
|
|
|
|
|
|
|
GridPropertySupportedKeywordInfo(
|
|
|
|
|
const std::string& name,
|
2016-02-29 16:44:30 +01:00
|
|
|
GridPropertyInitFunction< T > initializer,
|
2016-02-26 23:41:34 +01:00
|
|
|
const std::string& dimString);
|
|
|
|
|
|
|
|
|
|
/* this is a convenience constructor which can be used if the default
|
|
|
|
|
* value for the grid property is just a constant.
|
|
|
|
|
*/
|
|
|
|
|
GridPropertySupportedKeywordInfo(
|
|
|
|
|
const std::string& name,
|
|
|
|
|
const T defaultValue,
|
|
|
|
|
const std::string& dimString );
|
|
|
|
|
|
|
|
|
|
GridPropertySupportedKeywordInfo(
|
|
|
|
|
const std::string& name,
|
|
|
|
|
const T defaultValue,
|
2016-02-29 16:44:30 +01:00
|
|
|
GridPropertyPostFunction< T > postProcessor,
|
2016-02-26 23:41:34 +01:00
|
|
|
const std::string& dimString );
|
|
|
|
|
|
|
|
|
|
const std::string& getKeywordName() const;
|
|
|
|
|
const std::string& getDimensionString() const;
|
2016-02-29 16:44:30 +01:00
|
|
|
const GridPropertyInitFunction< T >& initializer() const;
|
|
|
|
|
const GridPropertyPostFunction< T >& postProcessor() const;
|
2016-02-26 23:41:34 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::string m_keywordName;
|
2016-02-29 16:44:30 +01:00
|
|
|
GridPropertyInitFunction< T > m_initializer;
|
|
|
|
|
GridPropertyPostFunction< T > m_postProcessor;
|
2016-02-26 23:41:34 +01:00
|
|
|
std::string m_dimensionString;
|
2014-10-09 13:19:24 +02:00
|
|
|
};
|
|
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
template< typename T >
|
2014-05-16 15:31:20 +02:00
|
|
|
class GridProperty {
|
|
|
|
|
public:
|
2014-06-04 14:03:29 +02:00
|
|
|
typedef GridPropertySupportedKeywordInfo<T> SupportedKeywordInfo;
|
2014-05-16 15:31:20 +02:00
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
GridProperty( size_t nx, size_t ny, size_t nz, const SupportedKeywordInfo& kwInfo );
|
2014-12-08 16:34:28 +01:00
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
size_t getCartesianSize() const;
|
|
|
|
|
size_t getNX() const;
|
|
|
|
|
size_t getNY() const;
|
|
|
|
|
size_t getNZ() const;
|
2014-05-16 15:31:20 +02:00
|
|
|
|
|
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
T iget(size_t index) const;
|
|
|
|
|
T iget(size_t i , size_t j , size_t k) const;
|
|
|
|
|
void iset(size_t index, T value);
|
|
|
|
|
void iset(size_t i , size_t j , size_t k , T value);
|
2014-05-30 10:07:24 +02:00
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
const std::vector<T>& getData() const;
|
2014-05-30 10:07:24 +02:00
|
|
|
|
2014-12-12 19:43:22 +01:00
|
|
|
bool containsNaN() const;
|
2014-12-12 19:46:20 +01:00
|
|
|
const std::string& getDimensionString() const;
|
|
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
void multiplyWith( const GridProperty<T>& );
|
|
|
|
|
void multiplyValueAtIndex( size_t index, T factor );
|
|
|
|
|
void maskedSet( T value, const std::vector< bool >& mask );
|
|
|
|
|
void maskedMultiply( T value, const std::vector< bool >& mask );
|
|
|
|
|
void maskedAdd( T value, const std::vector< bool >& mask );
|
|
|
|
|
void maskedCopy( const GridProperty< T >& other, const std::vector< bool >& mask );
|
|
|
|
|
void initMask( T value, std::vector<bool>& mask ) const;
|
2014-12-12 08:18:12 +01:00
|
|
|
|
2014-10-13 14:56:02 +02:00
|
|
|
/**
|
|
|
|
|
Due to the convention where it is only neceassary to supply the
|
|
|
|
|
top layer of the petrophysical properties we can unfortunately
|
|
|
|
|
not enforce that the number of elements elements in the
|
2014-12-08 16:34:28 +01:00
|
|
|
deckkeyword equals nx*ny*nz.
|
2014-10-13 14:56:02 +02:00
|
|
|
*/
|
2014-05-30 10:07:24 +02:00
|
|
|
|
2016-02-26 23:41:34 +01:00
|
|
|
void loadFromDeckKeyword( const DeckKeyword& );
|
|
|
|
|
void loadFromDeckKeyword( std::shared_ptr<const Box>, const DeckKeyword& );
|
|
|
|
|
|
|
|
|
|
void copyFrom( const GridProperty< T >&, std::shared_ptr< const Box > );
|
|
|
|
|
void scale( T scaleFactor, std::shared_ptr< const Box > );
|
|
|
|
|
void add( T shiftValue, std::shared_ptr< const Box > );
|
|
|
|
|
void setScalar( T value, std::shared_ptr< const Box > );
|
|
|
|
|
|
|
|
|
|
const std::string& getKeywordName() const;
|
|
|
|
|
const SupportedKeywordInfo& getKeywordInfo() const;
|
|
|
|
|
|
|
|
|
|
void runPostProcessor();
|
|
|
|
|
|
|
|
|
|
ERT::EclKW<T> getEclKW() const;
|
|
|
|
|
ERT::EclKW<T> getEclKW( std::shared_ptr< const EclipseGrid > ) const;
|
|
|
|
|
|
2015-03-31 11:18:17 +02:00
|
|
|
/**
|
|
|
|
|
Will check that all elements in the property are in the closed
|
|
|
|
|
interval [min,max].
|
|
|
|
|
*/
|
2016-02-26 23:41:34 +01:00
|
|
|
void checkLimits( T min, T max ) const;
|
2015-03-31 11:18:17 +02:00
|
|
|
|
|
|
|
|
|
2014-05-16 15:31:20 +02:00
|
|
|
private:
|
2016-02-26 23:41:34 +01:00
|
|
|
const DeckItem& getDeckItem( const DeckKeyword& );
|
2016-02-09 12:09:40 +01:00
|
|
|
void setDataPoint(size_t sourceIdx, size_t targetIdx, const DeckItem& deckItem);
|
2014-05-30 10:07:24 +02:00
|
|
|
|
|
|
|
|
size_t m_nx,m_ny,m_nz;
|
2014-06-03 17:45:55 +02:00
|
|
|
SupportedKeywordInfo m_kwInfo;
|
2014-05-16 15:31:20 +02:00
|
|
|
std::vector<T> m_data;
|
2016-02-26 23:41:38 +01:00
|
|
|
bool m_hasRunPostProcessor = false;
|
2014-05-16 15:31:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|