Add create_statistics_case

Remove original implementation not working in gridcasegroup.py
Add create_statistics_case object method
This commit is contained in:
Magne Sjaastad 2023-07-07 10:58:33 +02:00 committed by Kristian Bendiksen
parent f72fcdd868
commit f20a83c710
9 changed files with 233 additions and 58 deletions

View File

@ -347,16 +347,17 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase()
{ {
RimEclipseStatisticsCase* newStatisticsCase = new RimEclipseStatisticsCase; bool selectDefaultResults = true;
return createStatisticsCase( selectDefaultResults );
}
newStatisticsCase->setCaseUserDescription( QString( "Statistics " ) + QString::number( statisticsCaseCollection()->reservoirs.size() + 1 ) ); //--------------------------------------------------------------------------------------------------
statisticsCaseCollection()->reservoirs.push_back( newStatisticsCase ); ///
//--------------------------------------------------------------------------------------------------
newStatisticsCase->populateResultSelectionAfterLoadingGrid(); RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendEmptyStatisticsCase()
newStatisticsCase->openEclipseGridFile(); {
newStatisticsCase->eclipseCaseData()->computeActiveCellBoundingBoxes(); bool selectDefaultResults = false;
return createStatisticsCase( selectDefaultResults );
return newStatisticsCase;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -418,6 +419,24 @@ void RimIdenticalGridCaseGroup::clearActiveCellUnions()
m_unionOfFractureActiveCells->clear(); m_unionOfFractureActiveCells->clear();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseStatisticsCase* RimIdenticalGridCaseGroup::createStatisticsCase( bool selectDefaultResults )
{
RimEclipseStatisticsCase* newStatisticsCase = new RimEclipseStatisticsCase;
newStatisticsCase->setCaseUserDescription( QString( "Statistics " ) + QString::number( statisticsCaseCollection()->reservoirs.size() + 1 ) );
statisticsCaseCollection()->reservoirs.push_back( newStatisticsCase );
if ( selectDefaultResults ) newStatisticsCase->populateResultSelectionAfterLoadingGrid();
newStatisticsCase->openEclipseGridFile();
newStatisticsCase->eclipseCaseData()->computeActiveCellBoundingBoxes();
return newStatisticsCase;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -59,6 +59,7 @@ public:
bool contains( RimEclipseCase* reservoir ) const; bool contains( RimEclipseCase* reservoir ) const;
RimEclipseStatisticsCase* createAndAppendStatisticsCase(); RimEclipseStatisticsCase* createAndAppendStatisticsCase();
RimEclipseStatisticsCase* createAndAppendEmptyStatisticsCase();
RimEclipseCase* mainCase(); RimEclipseCase* mainCase();
void loadMainCaseAndActiveCellInfo(); void loadMainCaseAndActiveCellInfo();
@ -78,6 +79,8 @@ private:
void clearStatisticsResults(); void clearStatisticsResults();
void clearActiveCellUnions(); void clearActiveCellUnions();
RimEclipseStatisticsCase* createStatisticsCase( bool selectDefaultResults );
private: private:
RigMainGrid* m_mainGrid; RigMainGrid* m_mainGrid;

View File

@ -25,6 +25,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimcIntersection.h ${CMAKE_CURRENT_LIST_DIR}/RimcIntersection.h
${CMAKE_CURRENT_LIST_DIR}/RimcEclipseCase.h ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseCase.h
${CMAKE_CURRENT_LIST_DIR}/RimcEclipseStatisticsCase.h ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseStatisticsCase.h
${CMAKE_CURRENT_LIST_DIR}/RimcIdenticalGridCaseGroup.h
) )
set(SOURCE_GROUP_SOURCE_FILES set(SOURCE_GROUP_SOURCE_FILES
@ -54,6 +55,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimcIntersection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcIntersection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcEclipseCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcEclipseStatisticsCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseStatisticsCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcIdenticalGridCaseGroup.cpp
) )
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2020- Equinor ASA // Copyright (C) 2023- Equinor ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -20,36 +20,20 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaLogging.h"
#include "RicImportSummaryCasesFeature.h" #include "RicImportSummaryCasesFeature.h"
/*
#include "RimEclipseCase.h"
#include "RimFileSummaryCase.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSurfaceCollection.h"
#include "RiuPlotMainWindow.h"
*/
#include "RiaLogging.h"
#include "RimEclipseStatisticsCase.h" #include "RimEclipseStatisticsCase.h"
#include "cafPdmFieldScriptingCapability.h" #include "cafPdmFieldScriptingCapability.h"
/* CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimEclipseStatisticsCase, RimcEclipseStatisticsCase_setSourceProperties, "set_source_properties" );
#include <QDir>
#include <QFileInfo>
#include <memory>
*/
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimEclipseStatisticsCase, RimcEclipseStatisticsCase_defineSourceProperties, "set_source_result" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimcEclipseStatisticsCase_defineSourceProperties::RimcEclipseStatisticsCase_defineSourceProperties( caf::PdmObjectHandle* self ) RimcEclipseStatisticsCase_setSourceProperties::RimcEclipseStatisticsCase_setSourceProperties( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self ) : caf::PdmObjectMethod( self )
{ {
CAF_PDM_InitObject( "Define Source Properties" ); CAF_PDM_InitObject( "Define Source Properties" );
@ -60,7 +44,7 @@ RimcEclipseStatisticsCase_defineSourceProperties::RimcEclipseStatisticsCase_defi
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcEclipseStatisticsCase_defineSourceProperties::execute() caf::PdmObjectHandle* RimcEclipseStatisticsCase_setSourceProperties::execute()
{ {
RiaDefines::ResultCatType myEnum = caf::AppEnum<RiaDefines::ResultCatType>::fromText( m_propertyType() ); RiaDefines::ResultCatType myEnum = caf::AppEnum<RiaDefines::ResultCatType>::fromText( m_propertyType() );
@ -81,7 +65,7 @@ caf::PdmObjectHandle* RimcEclipseStatisticsCase_defineSourceProperties::execute(
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimcEclipseStatisticsCase_defineSourceProperties::resultIsPersistent() const bool RimcEclipseStatisticsCase_setSourceProperties::resultIsPersistent() const
{ {
return false; return false;
} }
@ -89,7 +73,7 @@ bool RimcEclipseStatisticsCase_defineSourceProperties::resultIsPersistent() cons
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcEclipseStatisticsCase_defineSourceProperties::defaultResult() const std::unique_ptr<caf::PdmObjectHandle> RimcEclipseStatisticsCase_setSourceProperties::defaultResult() const
{ {
return nullptr; return nullptr;
} }
@ -97,7 +81,7 @@ std::unique_ptr<caf::PdmObjectHandle> RimcEclipseStatisticsCase_defineSourceProp
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimcEclipseStatisticsCase_defineSourceProperties::isNullptrValidResult() const bool RimcEclipseStatisticsCase_setSourceProperties::isNullptrValidResult() const
{ {
return true; return true;
} }
@ -146,3 +130,57 @@ bool RimcEclipseStatisticsCase_computeStatistics::isNullptrValidResult() const
{ {
return true; return true;
} }
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimEclipseStatisticsCase, RimcEclipseStatisticsCase_clearSourceProperties, "clear_source_properties" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcEclipseStatisticsCase_clearSourceProperties::RimcEclipseStatisticsCase_clearSourceProperties( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcEclipseStatisticsCase_clearSourceProperties::execute()
{
auto myEnums = { RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::ResultCatType::STATIC_NATIVE,
RiaDefines::ResultCatType::INPUT_PROPERTY,
RiaDefines::ResultCatType::GENERATED };
auto eclipseCase = self<RimEclipseStatisticsCase>();
for ( auto myEnum : myEnums )
{
eclipseCase->setSourceProperties( myEnum, {} );
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcEclipseStatisticsCase_clearSourceProperties::resultIsPersistent() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcEclipseStatisticsCase_clearSourceProperties::defaultResult() const
{
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcEclipseStatisticsCase_clearSourceProperties::isNullptrValidResult() const
{
return true;
}

View File

@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2020- Equinor ASA // Copyright (C) 2023- Equinor ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -29,12 +29,12 @@
//================================================================================================== //==================================================================================================
/// ///
//================================================================================================== //==================================================================================================
class RimcEclipseStatisticsCase_defineSourceProperties : public caf::PdmObjectMethod class RimcEclipseStatisticsCase_setSourceProperties : public caf::PdmObjectMethod
{ {
CAF_PDM_HEADER_INIT; CAF_PDM_HEADER_INIT;
public: public:
RimcEclipseStatisticsCase_defineSourceProperties( caf::PdmObjectHandle* self ); RimcEclipseStatisticsCase_setSourceProperties( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute() override; caf::PdmObjectHandle* execute() override;
bool resultIsPersistent() const override; bool resultIsPersistent() const override;
@ -61,3 +61,19 @@ public:
std::unique_ptr<PdmObjectHandle> defaultResult() const override; std::unique_ptr<PdmObjectHandle> defaultResult() const override;
bool isNullptrValidResult() const override; bool isNullptrValidResult() const override;
}; };
//==================================================================================================
///
//==================================================================================================
class RimcEclipseStatisticsCase_clearSourceProperties : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimcEclipseStatisticsCase_clearSourceProperties( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute() override;
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
bool isNullptrValidResult() const override;
};

View File

@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor 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 "RimcIdenticalGridCaseGroup.h"
#include "RimEclipseStatisticsCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "cafPdmFieldScriptingCapability.h"
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimIdenticalGridCaseGroup, RimcIdenticalGridCaseGroup_createStatisticsCase, "create_statistics_case" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcIdenticalGridCaseGroup_createStatisticsCase::RimcIdenticalGridCaseGroup_createStatisticsCase( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcIdenticalGridCaseGroup_createStatisticsCase::execute()
{
auto gridCaseGroup = self<RimIdenticalGridCaseGroup>();
auto statCase = gridCaseGroup->createAndAppendEmptyStatisticsCase();
gridCaseGroup->updateConnectedEditors();
return statCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcIdenticalGridCaseGroup_createStatisticsCase::resultIsPersistent() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcIdenticalGridCaseGroup_createStatisticsCase::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimEclipseStatisticsCase );
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- Equinor 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmObjectMethod.h"
#include <QString>
#include <memory>
//==================================================================================================
///
//==================================================================================================
class RimcIdenticalGridCaseGroup_createStatisticsCase : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimcIdenticalGridCaseGroup_createStatisticsCase( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute() override;
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
};

View File

@ -49,10 +49,16 @@ for case in cases:
print("Transferred all results back to ResInsight") print("Transferred all results back to ResInsight")
# The API does not support configuration of a computation # one of "GENERATED", "DYNAMIC_NATIVE", "STATIC_NATIVE", "IMPORTED"
# Suggested next steps # https://api.resinsight.org/en/main/rips.html#result-definition
# - open ResInsight property_type = "GENERATED"
# - select the statistics object
# - select the generated result(PRESSURE_PORV) as source for computations property_name = "PRESSURE_PORV"
# - compute statistics
# - create a view and investigate the statistics of the generated data (PRESSURE_PORV) statistics_case = case_group.create_statistics_case()
statistics_case.set_source_properties(property_type, [property_name])
statistics_case.compute_statistics()
view = statistics_case.create_view()
statistics_property_name = property_name + "_MEAN"
view.apply_cell_result(result_type=property_type, result_variable=statistics_property_name)

View File

@ -11,20 +11,6 @@ from .resinsight_classes import GridCaseGroup
from .resinsight_classes import EclipseView from .resinsight_classes import EclipseView
from .resinsight_classes import RimStatisticalCalculation from .resinsight_classes import RimStatisticalCalculation
@add_method(GridCaseGroup)
def create_statistics_case(self):
"""Create a Statistics case in the Grid Case Group
Returns:
:class:`rips.generated.generated_classes.EclipseCase`
"""
command_reply = self._execute_command(
createStatisticsCase=Commands_pb2.CreateStatisticsCaseRequest(
caseGroupId=self.group_id
)
)
return Case(self.channel, command_reply.createStatisticsCaseResult.caseId)
@add_method(GridCaseGroup) @add_method(GridCaseGroup)
def statistics_cases(self): def statistics_cases(self):