2014-08-08 01:37:56 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-24 00:14:52 -05:00
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2014-08-08 01:37:56 -05:00
|
|
|
// ResInsight 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2014-08-08 01:37:56 -05:00
|
|
|
// ResInsight 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2014-08-08 01:37:56 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RigResultModifierFactory.h"
|
|
|
|
|
|
|
|
#include "RigCaseCellResultsData.h"
|
2017-01-10 02:51:39 -06:00
|
|
|
#include "RigEclipseCaseData.h"
|
2014-08-08 01:37:56 -05:00
|
|
|
#include "RigResultModifier.h"
|
|
|
|
|
2019-01-10 09:16:49 -06:00
|
|
|
#include <cmath>
|
2014-08-08 01:37:56 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2014-08-08 01:37:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier( RigEclipseCaseData* eclipseCase,
|
|
|
|
size_t gridIndex,
|
|
|
|
RiaDefines::PorosityModelType porosityModel,
|
|
|
|
size_t timeStepIndex,
|
|
|
|
const RigEclipseResultAddress& resVarAddr )
|
2014-08-08 01:37:56 -05:00
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
if ( !eclipseCase ) return nullptr;
|
2014-08-08 01:37:56 -05:00
|
|
|
|
2023-01-24 05:59:44 -06:00
|
|
|
if ( !resVarAddr.isValid() )
|
2015-10-23 08:46:25 -05:00
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
return nullptr;
|
2015-10-23 08:46:25 -05:00
|
|
|
}
|
2014-08-08 01:37:56 -05:00
|
|
|
|
2023-01-24 05:59:44 -06:00
|
|
|
RigGridBase* grid = eclipseCase->grid( gridIndex );
|
|
|
|
if ( !grid )
|
2014-08-08 01:37:56 -05:00
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
return nullptr;
|
2014-08-08 01:37:56 -05:00
|
|
|
}
|
|
|
|
|
2023-01-24 05:59:44 -06:00
|
|
|
if ( !eclipseCase->results( porosityModel ) || !eclipseCase->activeCellInfo( porosityModel ) )
|
2015-10-23 08:46:25 -05:00
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
return nullptr;
|
2015-10-23 08:46:25 -05:00
|
|
|
}
|
2014-08-09 07:45:21 -05:00
|
|
|
|
2023-01-24 05:59:44 -06:00
|
|
|
auto cellResultsData = eclipseCase->results( porosityModel );
|
|
|
|
if ( !cellResultsData->hasResultEntry( resVarAddr ) ) return nullptr;
|
2014-08-08 01:37:56 -05:00
|
|
|
|
2023-01-24 05:59:44 -06:00
|
|
|
auto scalarSetResults = cellResultsData->modifiableCellScalarResultTimesteps( resVarAddr );
|
2019-10-08 03:01:38 -05:00
|
|
|
if ( timeStepIndex >= scalarSetResults->size() )
|
2014-08-08 01:37:56 -05:00
|
|
|
{
|
2018-02-18 11:56:43 -06:00
|
|
|
return nullptr;
|
2014-08-08 01:37:56 -05:00
|
|
|
}
|
|
|
|
|
2018-02-18 11:56:43 -06:00
|
|
|
std::vector<double>* resultValues = nullptr;
|
2019-10-08 03:01:38 -05:00
|
|
|
if ( timeStepIndex < scalarSetResults->size() )
|
2014-08-08 01:37:56 -05:00
|
|
|
{
|
2019-10-08 03:01:38 -05:00
|
|
|
resultValues = &( scalarSetResults->at( timeStepIndex ) );
|
2014-08-08 01:37:56 -05:00
|
|
|
}
|
|
|
|
|
2022-03-25 12:19:49 -05:00
|
|
|
if ( resultValues->empty() ) return nullptr;
|
|
|
|
|
2023-01-24 05:59:44 -06:00
|
|
|
bool useGlobalActiveIndex = cellResultsData->isUsingGlobalActiveIndex( resVarAddr );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( useGlobalActiveIndex )
|
2014-08-08 01:37:56 -05:00
|
|
|
{
|
2019-11-04 08:08:09 -06:00
|
|
|
cvf::ref<RigResultModifier> object =
|
|
|
|
new RigActiveCellsResultModifier( grid, eclipseCase->activeCellInfo( porosityModel ), resultValues );
|
2014-08-08 01:37:56 -05:00
|
|
|
return object;
|
|
|
|
}
|
2023-01-24 05:59:44 -06:00
|
|
|
|
|
|
|
cvf::ref<RigResultModifier> object = new RigAllGridCellsResultModifier( grid, resultValues );
|
|
|
|
return object;
|
2014-08-08 01:37:56 -05:00
|
|
|
}
|