GridProperty: Pass 'Defaulted' Flag to Post-Processor
This commit alters the post-processor API to accept a vector<bool> of defaulted flags (true if defaulted, false if explicitly assigned). This, in turn, enables running the post-processor only on defaulted (or assigned) property values. Update existing post-processor implementation to honour the new calling conventions.
This commit is contained in:
parent
430cc9d7b2
commit
ceb9f01571
@ -178,7 +178,7 @@ namespace Opm {
|
||||
/// 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,
|
||||
std::function< void( const std::vector<bool>& defaulted, std::vector< T >& ) > postProcessor,
|
||||
const std::string& dimString,
|
||||
const bool defaultInitializable );
|
||||
|
||||
|
@ -45,7 +45,10 @@ class GridPropertySupportedKeywordInfo {
|
||||
GridPropertySupportedKeywordInfo() = default;
|
||||
|
||||
using init = std::function< std::vector< T >( size_t ) >;
|
||||
using post = std::function< void( std::vector< T >& ) >;
|
||||
using post = std::function<
|
||||
void(const std::vector<bool>& defaulted,
|
||||
std::vector< T >&)
|
||||
>;
|
||||
|
||||
GridPropertySupportedKeywordInfo(
|
||||
const std::string& name,
|
||||
|
@ -267,7 +267,7 @@ namespace Opm {
|
||||
|
||||
const auto tempLookup = std::bind( temperature_lookup, _1, tableManager, eclipseGrid, intGridProperties );
|
||||
|
||||
const auto distributeTopLayer = std::bind( &distTopLayer, _1, eclipseGrid );
|
||||
const auto distributeTopLayer = std::bind( &distTopLayer, std::placeholders::_2, eclipseGrid );
|
||||
|
||||
std::vector< GridProperties< double >::SupportedKeywordInfo > supportedDoubleKeywords;
|
||||
|
||||
@ -531,7 +531,7 @@ namespace Opm {
|
||||
|
||||
{
|
||||
auto initPORVProcessor = std::bind(&initPORV,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
&deck,
|
||||
&eclipseGrid,
|
||||
&m_intGridProperties,
|
||||
@ -546,7 +546,7 @@ namespace Opm {
|
||||
|
||||
{
|
||||
auto actnumPP = std::bind(&ACTNUMPostProcessor,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
&m_doubleGridProperties);
|
||||
|
||||
m_intGridProperties.postAddKeyword( "ACTNUM",
|
||||
|
@ -578,7 +578,7 @@ namespace Opm {
|
||||
template< typename T >
|
||||
void GridProperties<T>::postAddKeyword(const std::string& name,
|
||||
const T defaultValue,
|
||||
std::function< void( std::vector< T >& ) > postProcessor,
|
||||
std::function< void( const std::vector<bool>& defaulted, std::vector< T >& ) > postProcessor,
|
||||
const std::string& dimString,
|
||||
const bool defaultInitializable )
|
||||
{
|
||||
|
@ -39,15 +39,15 @@ namespace Opm {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
static std::function< void( std::vector< T >& ) > noop() {
|
||||
return []( std::vector< T >& ) { return; };
|
||||
static std::function< void( const std::vector<bool>&, std::vector< T >& ) > noop() {
|
||||
return []( const std::vector<bool>&, std::vector< T >& ) { return; };
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
GridPropertySupportedKeywordInfo< T >::GridPropertySupportedKeywordInfo(
|
||||
const std::string& name,
|
||||
std::function< std::vector< T >( size_t ) > init,
|
||||
std::function< void( std::vector< T >& ) > post,
|
||||
std::function< void( const std::vector<bool>& defaulted, std::vector< T >& ) > post,
|
||||
const std::string& dimString,
|
||||
bool defaultInitializable ) :
|
||||
m_keywordName( name ),
|
||||
@ -87,7 +87,7 @@ namespace Opm {
|
||||
GridPropertySupportedKeywordInfo< T >::GridPropertySupportedKeywordInfo(
|
||||
const std::string& name,
|
||||
const T defaultValue,
|
||||
std::function< void( std::vector< T >& ) > post,
|
||||
std::function< void( const std::vector<bool>&, std::vector< T >& ) > post,
|
||||
const std::string& dimString,
|
||||
bool defaultInitializable ) :
|
||||
m_keywordName( name ),
|
||||
@ -113,7 +113,9 @@ namespace Opm {
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
const std::function< void( std::vector< T >& ) >& GridPropertySupportedKeywordInfo< T >::postProcessor() const {
|
||||
const std::function< void( const std::vector<bool>&, std::vector< T >& ) >&
|
||||
GridPropertySupportedKeywordInfo< T >::postProcessor() const
|
||||
{
|
||||
return this->m_postProcessor;
|
||||
}
|
||||
|
||||
@ -395,7 +397,7 @@ namespace Opm {
|
||||
void GridProperty< T >::runPostProcessor() {
|
||||
if( this->m_hasRunPostProcessor ) return;
|
||||
this->m_hasRunPostProcessor = true;
|
||||
this->m_kwInfo.postProcessor()( m_data );
|
||||
this->m_kwInfo.postProcessor()( m_defaulted, m_data );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
|
Loading…
Reference in New Issue
Block a user