mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 23:50:19 -05:00
Release 2025.09.0
This commit is contained in:
1 parent
c33402f5ea
commit
917136fec8
1053 files changed
+61952
-11833
No files matched your search
@@ -20,23 +20,25 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaKeyValueStoreUtil.h"
|
||||
|
||||
#include "RicImportSummaryCasesFeature.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigEclipseResultAddress.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigResultAccessor.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimFileSummaryCase.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <memory>
|
||||
#include <expected>
|
||||
#include <limits>
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimEclipseCase, RimcEclipseCase_importProperties, "import_properties" );
|
||||
|
||||
@@ -44,16 +46,17 @@ CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimEclipseCase, RimcEclipseCase_importPropert
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcEclipseCase_importProperties::RimcEclipseCase_importProperties( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
: caf::PdmVoidObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Import Properties", "", "", "Import Properties" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_fileNames, "FileNames", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcEclipseCase_importProperties::execute()
|
||||
std::expected<caf::PdmObjectHandle*, QString> RimcEclipseCase_importProperties::execute()
|
||||
{
|
||||
std::vector<QString> absolutePaths = m_fileNames;
|
||||
for ( auto& path : absolutePaths )
|
||||
@@ -75,26 +78,106 @@ caf::PdmObjectHandle* RimcEclipseCase_importProperties::execute()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimEclipseCase, RimcEclipseCase_exportValuesInternal, "export_values_internal" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcEclipseCase_importProperties::resultIsPersistent() const
|
||||
RimcEclipseCase_exportValuesInternal::RimcEclipseCase_exportValuesInternal( caf::PdmObjectHandle* self )
|
||||
: caf::PdmVoidObjectMethod( self )
|
||||
{
|
||||
return false;
|
||||
CAF_PDM_InitObject( "Export Values Internal", "", "", "Export Values Internal" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_coordinateX, "CoordinateX", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_coordinateY, "CoordinateY", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_coordinateZ, "CoordinateZ", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_resultKey, "ResultKey", "" );
|
||||
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_propertyType, "PropertyType", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_propertyName, "PropertyName", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_timeStep, "TimeStep", "" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_porosityModel, "PorosityModel", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcEclipseCase_importProperties::defaultResult() const
|
||||
std::expected<caf::PdmObjectHandle*, QString> RimcEclipseCase_exportValuesInternal::execute()
|
||||
{
|
||||
auto eclipseCase = self<RimEclipseCase>();
|
||||
|
||||
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
|
||||
if ( !eclipseCaseData )
|
||||
{
|
||||
return std::unexpected( "Unable to load eclipse case data." );
|
||||
}
|
||||
|
||||
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
|
||||
if ( !mainGrid )
|
||||
{
|
||||
return std::unexpected( "Unable to load main grid for eclipse case." );
|
||||
}
|
||||
|
||||
caf::AppEnum<RiaDefines::ResultCatType> resultCatTypeEnum;
|
||||
if ( !resultCatTypeEnum.setFromText( m_propertyType ) )
|
||||
{
|
||||
return std::unexpected( "Invalid property type." );
|
||||
}
|
||||
|
||||
caf::AppEnum<RiaDefines::PorosityModelType> porosityModel;
|
||||
if ( !porosityModel.setFromText( m_porosityModel ) )
|
||||
{
|
||||
return std::unexpected( "Invalid porosity model." );
|
||||
}
|
||||
|
||||
RigEclipseResultAddress resVarAddr( resultCatTypeEnum, m_propertyName );
|
||||
eclipseCase->results( porosityModel )->ensureKnownResultLoaded( resVarAddr );
|
||||
|
||||
cvf::ref<RigResultAccessor> resultAccessor =
|
||||
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, 0, porosityModel, m_timeStep, resVarAddr );
|
||||
if ( resultAccessor.isNull() )
|
||||
{
|
||||
return std::unexpected( "Result property not found." );
|
||||
}
|
||||
|
||||
if ( m_timeStep < 0 || m_timeStep >= static_cast<int>( eclipseCase->timeStepDates().size() ) )
|
||||
{
|
||||
return std::unexpected( "Invalid time step." );
|
||||
}
|
||||
|
||||
auto keyValueStore = RiaApplication::instance()->keyValueStore();
|
||||
|
||||
std::vector<float> xs = RiaKeyValueStoreUtil::convertToFloatVector( keyValueStore->get( m_coordinateX().toStdString() ) );
|
||||
std::vector<float> ys = RiaKeyValueStoreUtil::convertToFloatVector( keyValueStore->get( m_coordinateY().toStdString() ) );
|
||||
std::vector<float> zs = RiaKeyValueStoreUtil::convertToFloatVector( keyValueStore->get( m_coordinateZ().toStdString() ) );
|
||||
if ( xs.empty() || xs.size() != ys.size() || xs.size() != zs.size() )
|
||||
{
|
||||
return std::unexpected( "Invalid positions specified." );
|
||||
}
|
||||
|
||||
std::vector<cvf::Vec3d> positions;
|
||||
for ( size_t i = 0; i < xs.size(); i++ )
|
||||
{
|
||||
positions.push_back( cvf::Vec3d( xs[i], ys[i], -zs[i] ) );
|
||||
}
|
||||
|
||||
std::vector<float> values;
|
||||
for ( const cvf::Vec3d& position : positions )
|
||||
{
|
||||
auto cellIdx = mainGrid->findReservoirCellIndexFromPoint( position );
|
||||
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
float valueFromEclipse = static_cast<float>( resultAccessor->cellScalar( cellIdx ) );
|
||||
values.push_back( valueFromEclipse );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use inf as signal that nothing was found for the position
|
||||
values.push_back( std::numeric_limits<float>::infinity() );
|
||||
}
|
||||
}
|
||||
|
||||
keyValueStore->set( m_resultKey().toStdString(), RiaKeyValueStoreUtil::convertToByteVector( values ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcEclipseCase_importProperties::isNullptrValidResult() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user