2017-07-27 11:49:03 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfComputeCaseGroupStatistics.h"
#include "RimProject.h"
#include "RimOilField.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseStatisticsCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimCaseCollection.h"
#include "RimView.h"
#include "RiaApplication.h"
2017-07-27 14:26:59 +02:00
#include "RiaLogging.h"
2017-07-27 11:49:03 +02:00
CAF_PDM_SOURCE_INIT ( RicfComputeCaseGroupStatistics , "computeCaseGroupStatistics" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfComputeCaseGroupStatistics :: RicfComputeCaseGroupStatistics ()
{
RICF_InitField ( & m_caseIds , "cases" , std :: vector < int > (), "Case IDs" , "" , "" , "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfComputeCaseGroupStatistics :: execute ()
{
for ( int caseId : m_caseIds ())
{
2017-07-27 14:26:59 +02:00
bool foundCase = false ;
2017-07-27 11:49:03 +02:00
for ( RimIdenticalGridCaseGroup * group : RiaApplication :: instance () -> project () -> activeOilField () -> analysisModels () -> caseGroups )
{
for ( RimEclipseCase * c : group -> statisticsCaseCollection -> reservoirs )
{
if ( c -> caseId == caseId )
{
RimEclipseStatisticsCase * statsCase = dynamic_cast < RimEclipseStatisticsCase *> ( c );
if ( statsCase )
{
statsCase -> computeStatisticsAndUpdateViews ();
}
2017-07-27 14:26:59 +02:00
else
{
RiaLogging :: warning ( QString ( "computeCaseGroupStatistics: Found case with ID %1, but it is not a statistics case, cannot compute statistics." ). arg ( caseId ));
}
foundCase = true ;
break ;
2017-07-27 11:49:03 +02:00
}
}
2017-07-27 14:26:59 +02:00
if ( foundCase ) break ;
}
if ( ! foundCase )
{
RiaLogging :: warning ( QString ( "computeCaseGroupStatistics: Could not find statistics case with ID %1." ). arg ( caseId ));
2017-07-27 11:49:03 +02:00
}
}
}