Skip to content

Commit

Permalink
RFT ensemble refactoring
Browse files Browse the repository at this point in the history
* Compute average MD for intersections with a cell
* Create extractor for simulation well
* Remove rftReader from RifDataSourceForRftPlt
* Add function compute measured depth for RFT cells based on well path geometry
* Move statistics reader to well ensemble curve set
* Make sure both TVD and MD are cached if possible
* Add selection of grid case to use for estimation of measured depth (MD)
Add "Grid Model For MD" where the user can select a grid model. This grid model is propagated to a hidden field in EnsembleCurveSet. The grid model is then applied to RifReaderEnsembleStatisticsRft owned by EnsembleCurveSet
  • Loading branch information
magnesj authored Sep 4, 2023
1 parent fe17b21 commit 7a782ce
Show file tree
Hide file tree
Showing 27 changed files with 626 additions and 427 deletions.
48 changes: 48 additions & 0 deletions ApplicationLibCode/Application/Tools/RiaExtractionTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@

#include "RiaExtractionTools.h"

#include "RiaSimWellBranchTools.h"

#include "RigWellPath.h"

#include "RimEclipseCase.h"
#include "RimMainPlotCollection.h"
#include "RimSimWellInView.h"
#include "RimTools.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellPathCollection.h"

//--------------------------------------------------------------------------------------------------
///
Expand All @@ -37,6 +42,22 @@ RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateWellLogExtractor( Ri
return wlPlotCollection->findOrCreateExtractor( wellPath, eclipseCase );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateWellLogExtractor( const QString& wellName, RimEclipseCase* eclipseCase )
{
if ( !eclipseCase ) return nullptr;

if ( auto wellPathCollection = RimTools::wellPathCollection() )
{
auto wellPath = wellPathCollection->tryFindMatchingWellPath( wellName );
return RiaExtractionTools::findOrCreateWellLogExtractor( wellPath, eclipseCase );
}

return nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -71,6 +92,33 @@ RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor( co
return wlPlotCollection->findOrCreateSimWellExtractor( simWell->name, caseUserDescription, wellPathGeom, eclipseCase->eclipseCaseData() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor( RimEclipseCase* eclipseCase,
const QString& simWellName,
bool useBranchDetection,
int branchIndex )
{
if ( !eclipseCase ) return nullptr;

auto wlPlotCollection = wellLogPlotCollection();
if ( !wlPlotCollection ) return nullptr;

std::vector<const RigWellPath*> wellPaths = RiaSimWellBranchTools::simulationWellBranches( simWellName, useBranchDetection );
if ( wellPaths.empty() ) return nullptr;

branchIndex = RiaSimWellBranchTools::clampBranchIndex( simWellName, branchIndex, useBranchDetection );
if ( branchIndex >= static_cast<int>( wellPaths.size() ) ) return nullptr;

auto wellPathBranch = wellPaths[branchIndex];

return wlPlotCollection->findOrCreateSimWellExtractor( simWellName,
QString( "Find or create sim well extractor" ),
wellPathBranch,
eclipseCase->eclipseCaseData() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
11 changes: 9 additions & 2 deletions ApplicationLibCode/Application/Tools/RiaExtractionTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ class QString;
//==================================================================================================
namespace RiaExtractionTools
{
RimWellLogPlotCollection* wellLogPlotCollection();

// Eclipse
RigEclipseWellLogExtractor* findOrCreateWellLogExtractor( const QString& wellName, RimEclipseCase* eclipseCase );
RigEclipseWellLogExtractor* findOrCreateWellLogExtractor( RimWellPath* wellPath, RimEclipseCase* eclipseCase );

// GeoMech
RigGeoMechWellLogExtractor* findOrCreateWellLogExtractor( RimWellPath* wellPath, RimGeoMechCase* geomCase, int partId = 0 );

// Simulation wells
RigEclipseWellLogExtractor* findOrCreateSimWellExtractor( const RimSimWellInView* simWell, const RigWellPath* wellPathGeom );

RimWellLogPlotCollection* wellLogPlotCollection();
RigEclipseWellLogExtractor*
findOrCreateSimWellExtractor( RimEclipseCase* eclipseCase, const QString& simWellName, bool useBranchDetection, int branchIndex );

}; // namespace RiaExtractionTools
4 changes: 2 additions & 2 deletions ApplicationLibCode/Commands/RicWellLogTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ RimWellLogRftCurve* RicWellLogTools::addRftCurve( RimWellLogTrack* plotTrack, co

if ( simWell && resultCase )
{
curve->setEclipseResultCase( resultCase );
curve->setEclipseCase( resultCase );
curve->setDefaultAddress( simWell->name() );

plotTrack->setFormationCase( resultCase );
plotTrack->setFormationSimWellName( simWell->name() );
}
else if ( resultCase )
{
curve->setEclipseResultCase( resultCase );
curve->setEclipseCase( resultCase );

auto wellNames = resultCase->rftReader()->wellNames();
if ( !wellNames.empty() )
Expand Down
32 changes: 0 additions & 32 deletions ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "RifDataSourceForRftPlt.h"

#include "RifReaderEclipseRft.h"
#include "RigEclipseCaseData.h"

#include "RimEclipseCase.h"
Expand Down Expand Up @@ -230,37 +229,6 @@ auto RifDataSourceForRftPlt::operator<=>( const RifDataSourceForRftPlt& addr2 )
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderRftInterface* RifDataSourceForRftPlt::rftReader() const
{
if ( m_sourceType == SourceType::GRID_MODEL_CELL_DATA || m_sourceType == SourceType::RFT_SIM_WELL_DATA )
{
// TODO: Consider changing to RimEclipseResultCase to avoid casting
auto eclResCase = dynamic_cast<RimEclipseResultCase*>( eclCase() );

if ( eclResCase ) return eclResCase->rftReader();
}
else if ( m_sourceType == SourceType::SUMMARY_RFT )
{
if ( m_summaryCase ) return m_summaryCase->rftReader();
}
else if ( m_sourceType == SourceType::ENSEMBLE_RFT )
{
if ( m_ensemble ) return m_ensemble->rftStatisticsReader();
}
else if ( m_sourceType == SourceType::OBSERVED_FMU_RFT )
{
if ( m_observedFmuRftData ) return m_observedFmuRftData->rftReader();
}
else if ( m_sourceType == SourceType::OBSERVED_PRESSURE_DEPTH )
{
if ( m_pressureDepthData ) return m_pressureDepthData->rftReader();
}
return nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions ApplicationLibCode/FileInterface/RifDataSourceForRftPlt.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

class RimWellLogFile;
class RimEclipseCase;
class RifReaderRftInterface;
class RimSummaryCase;
class RimSummaryCaseCollection;
class RimObservedFmuRftData;
Expand Down Expand Up @@ -64,8 +63,7 @@ class RifDataSourceForRftPlt
RifDataSourceForRftPlt( RimObservedFmuRftData* observedFmuRftData );
RifDataSourceForRftPlt( RimPressureDepthData* pressureDepthData );

SourceType sourceType() const;
RifReaderRftInterface* rftReader() const;
SourceType sourceType() const;

RimEclipseCase* eclCase() const;
RimSummaryCase* summaryCase() const;
Expand Down
30 changes: 23 additions & 7 deletions ApplicationLibCode/FileInterface/RifReaderEclipseRft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,17 @@ void RifReaderEclipseRft::values( const RifEclipseRftAddress& rftAddress, std::v
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseRft::cellIndices( const RifEclipseRftAddress& rftAddress, std::vector<caf::VecIjk>* indices )
std::vector<caf::VecIjk> RifReaderEclipseRft::cellIndices( const QString& wellName, const QDateTime& timeStep )
{
CVF_ASSERT( indices );

if ( !m_ecl_rft_file )
{
open();
}

indices->clear();
int index = indexFromAddress( wellName, timeStep );
if ( index < 0 ) return {};

int index = indexFromAddress( rftAddress );
if ( index < 0 ) return;
std::vector<caf::VecIjk> indices;

ecl_rft_node_type* node = ecl_rft_file_iget_node( m_ecl_rft_file, index );

Expand All @@ -268,8 +266,10 @@ void RifReaderEclipseRft::cellIndices( const RifEclipseRftAddress& rftAddress, s
ecl_rft_node_iget_ijk( node, cellIdx, &i, &j, &k );

caf::VecIjk ijk( (size_t)i, (size_t)j, (size_t)k );
indices->push_back( ijk );
indices.push_back( ijk );
}

return indices;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -453,3 +453,19 @@ int RifReaderEclipseRft::indexFromAddress( const RifEclipseRftAddress& rftAddres

return -1;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseRft::indexFromAddress( const QString& wellName, const QDateTime& timeStep ) const
{
for ( const auto& [rftAddr, nodeIdx] : m_rftAddressToLibeclNodeIdx )
{
if ( rftAddr.wellName() == wellName && rftAddr.timeStep() == timeStep )
{
return nodeIdx;
}
}

return -1;
}
3 changes: 2 additions & 1 deletion ApplicationLibCode/FileInterface/RifReaderEclipseRft.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RifReaderEclipseRft : public RifReaderRftInterface, public cvf::Object

std::set<RifEclipseRftAddress> eclipseRftAddresses() override;
void values( const RifEclipseRftAddress& rftAddress, std::vector<double>* values ) override;
void cellIndices( const RifEclipseRftAddress& rftAddress, std::vector<caf::VecIjk>* indices ) override;
std::vector<caf::VecIjk> cellIndices( const QString& wellName, const QDateTime& timeStep ) override;

std::set<QDateTime> availableTimeSteps( const QString& wellName ) override;
std::set<QDateTime> availableTimeSteps( const QString& wellName,
Expand All @@ -60,6 +60,7 @@ class RifReaderEclipseRft : public RifReaderRftInterface, public cvf::Object
private:
void open();
int indexFromAddress( const RifEclipseRftAddress& rftAddress ) const;
int indexFromAddress( const QString& wellName, const QDateTime& timeStep ) const;

private:
// NOLINTBEGIN(modernize-use-using)
Expand Down
Loading

0 comments on commit 7a782ce

Please sign in to comment.