2017-07-27 04:49:03 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-07-27 04:49:03 -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
|
|
|
//
|
2017-07-27 04:49:03 -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>
|
2017-07-27 04:49:03 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicfComputeCaseGroupStatistics.h"
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "Rim3dView.h"
|
|
|
|
#include "RimCaseCollection.h"
|
2017-07-27 04:49:03 -05:00
|
|
|
#include "RimEclipseCase.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimEclipseCaseCollection.h"
|
2017-07-27 04:49:03 -05:00
|
|
|
#include "RimEclipseStatisticsCase.h"
|
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
2017-07-27 04:49:03 -05:00
|
|
|
|
2017-07-27 07:26:59 -05:00
|
|
|
#include "RiaLogging.h"
|
2017-07-27 04:49:03 -05:00
|
|
|
|
2020-08-21 04:13:07 -05:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-03-10 08:11:22 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfComputeCaseGroupStatistics, "computeCaseGroupStatistics" );
|
2017-07-27 04:49:03 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-07-27 04:49:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicfComputeCaseGroupStatistics::RicfComputeCaseGroupStatistics()
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitScriptableField( &m_groupId, "caseGroupId", -1, "Case Group ID" );
|
|
|
|
CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector<int>(), "Case IDs" );
|
2017-07-27 04:49:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-07-27 04:49:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 08:11:22 -05:00
|
|
|
caf::PdmScriptResponse RicfComputeCaseGroupStatistics::execute()
|
2017-07-27 04:49:03 -05:00
|
|
|
{
|
2020-03-10 08:11:22 -05:00
|
|
|
caf::PdmScriptResponse response;
|
2019-05-23 06:59:19 -05:00
|
|
|
|
2019-07-29 05:55:02 -05:00
|
|
|
std::vector<int> caseIds = m_caseIds.v();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_groupId() >= 0 )
|
2019-07-29 05:55:02 -05:00
|
|
|
{
|
2020-05-12 02:50:38 -05:00
|
|
|
for ( RimIdenticalGridCaseGroup* group : RimProject::current()->activeOilField()->analysisModels()->caseGroups )
|
2019-07-29 05:55:02 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseCase* c : group->statisticsCaseCollection->reservoirs )
|
2019-07-29 05:55:02 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
caseIds.push_back( c->caseId() );
|
2019-07-29 05:55:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int caseId : caseIds )
|
2017-07-27 04:49:03 -05:00
|
|
|
{
|
2017-07-27 07:26:59 -05:00
|
|
|
bool foundCase = false;
|
2020-05-12 02:50:38 -05:00
|
|
|
for ( RimIdenticalGridCaseGroup* group : RimProject::current()->activeOilField()->analysisModels()->caseGroups )
|
2017-07-27 04:49:03 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseCase* c : group->statisticsCaseCollection->reservoirs )
|
2017-07-27 04:49:03 -05:00
|
|
|
{
|
2022-08-18 00:12:23 -05:00
|
|
|
if ( c->caseId() == caseId )
|
2017-07-27 04:49:03 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseStatisticsCase* statsCase = dynamic_cast<RimEclipseStatisticsCase*>( c );
|
|
|
|
if ( statsCase )
|
2017-07-27 04:49:03 -05:00
|
|
|
{
|
|
|
|
statsCase->computeStatisticsAndUpdateViews();
|
|
|
|
}
|
2017-07-27 07:26:59 -05:00
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString warning = QString( "computeCaseGroupStatistics: Found case with ID %1, but it is not a "
|
|
|
|
"statistics case, cannot compute statistics." )
|
|
|
|
.arg( caseId );
|
|
|
|
RiaLogging::warning( warning );
|
2020-03-10 08:11:22 -05:00
|
|
|
response.updateStatus( caf::PdmScriptResponse::COMMAND_WARNING, warning );
|
2017-07-27 07:26:59 -05:00
|
|
|
}
|
|
|
|
foundCase = true;
|
|
|
|
break;
|
2017-07-27 04:49:03 -05:00
|
|
|
}
|
|
|
|
}
|
2017-07-27 07:26:59 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( foundCase ) break;
|
2017-07-27 07:26:59 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !foundCase )
|
2017-07-27 07:26:59 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
QString warning = QString( "computeCaseGroupStatistics: Could not find statistics case with ID %1." ).arg( caseId );
|
2019-05-23 06:59:19 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaLogging::warning( warning );
|
2020-03-10 08:11:22 -05:00
|
|
|
response.updateStatus( caf::PdmScriptResponse::COMMAND_WARNING, warning );
|
2017-07-27 04:49:03 -05:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 06:59:19 -05:00
|
|
|
return response;
|
2017-07-27 04:49:03 -05:00
|
|
|
}
|