Merge pull request #9063 from OPM/more-rft-fixes-01

More RFT fixes
This commit is contained in:
Magne Sjaastad 2022-06-17 17:24:58 +02:00 committed by GitHub
parent 62cf62b9a2
commit d854a3d3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 390 additions and 130 deletions

View File

@ -30,4 +30,12 @@ QString segmentNumberResultName();
QString allBranches();
QString segmentBranchNumberResultName();
enum class RftBranchType
{
RFT_TUBING,
RFT_ANNULAR,
RFT_DEVICE,
RFT_UNKNOWN
};
}; // namespace RiaDefines

View File

@ -299,3 +299,26 @@ RimSummaryCaseCollection* RiaSummaryTools::ensembleById( int ensembleId )
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RiaSummaryTools::optionsForAllSummaryCases()
{
return optionsForSummaryCases( RimProject::current()->allSummaryCases() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RiaSummaryTools::optionsForSummaryCases( const std::vector<RimSummaryCase*>& cases )
{
QList<caf::PdmOptionItemInfo> options;
for ( RimSummaryCase* c : cases )
{
options.push_back( caf::PdmOptionItemInfo( c->displayCaseName(), c, false, c->uiIconProvider() ) );
}
return options;
}

View File

@ -40,7 +40,8 @@ class QStringList;
namespace caf
{
class PdmObject;
}
class PdmOptionItemInfo;
} // namespace caf
//==================================================================================================
//
@ -75,4 +76,7 @@ public:
static RimSummaryCase* summaryCaseById( int caseId );
static RimSummaryCaseCollection* ensembleById( int ensembleId );
static QList<caf::PdmOptionItemInfo> optionsForAllSummaryCases();
static QList<caf::PdmOptionItemInfo> optionsForSummaryCases( const std::vector<RimSummaryCase*>& cases );
};

View File

@ -18,6 +18,8 @@
#include "RicSelectCaseOrEnsembleUi.h"
#include "RiaSummaryTools.h"
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
@ -78,14 +80,7 @@ QList<caf::PdmOptionItemInfo>
if ( fieldNeedingOptions == &m_selectedSummaryCase )
{
RimProject* proj = RimProject::current();
std::vector<RimSummaryCase*> cases = proj->allSummaryCases();
for ( RimSummaryCase* rimCase : cases )
{
options.push_back( caf::PdmOptionItemInfo( rimCase->displayCaseName(), rimCase ) );
}
options = RiaSummaryTools::optionsForAllSummaryCases();
}
else if ( fieldNeedingOptions == &m_selectedEnsemble )
{

View File

@ -29,6 +29,7 @@
#include "RimEclipseResultCase.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSummaryCase.h"
#include "RimWellLogCurveCommonDataSource.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogFile.h"
@ -378,6 +379,23 @@ RimWellLogRftCurve*
curve->setDefaultAddress( wellName );
}
}
else
{
auto sumCases = RimProject::current()->allSummaryCases();
for ( auto sc : sumCases )
{
if ( sc->rftReader() )
{
auto rftReader = sc->rftReader();
curve->setSummaryCase( sc );
auto addresses = rftReader->eclipseRftAddresses();
if ( !addresses.empty() ) curve->setRftAddress( *addresses.begin() );
}
}
}
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() );
curve->setColor( curveColor );

View File

@ -91,7 +91,7 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto
}
else if ( rftAddress.segmentResultName() == RiaDefines::segmentBranchNumberResultName() )
{
auto branchNumbers = segment.branchIds();
auto branchNumbers = segment.tubingBranchIds();
for ( const auto& branchNumber : branchNumbers )
{
values->push_back( branchNumber );
@ -156,6 +156,9 @@ std::set<QDateTime>
RifReaderOpmRft::availableTimeSteps( const QString& wellName,
const RifEclipseRftAddress::RftWellLogChannelType& wellLogChannelName )
{
if ( wellLogChannelName == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES )
return m_rftSegmentTimeSteps;
std::set<QDateTime> timeSteps;
for ( const auto& address : m_addresses )
@ -301,6 +304,8 @@ void RifReaderOpmRft::buildMetaData()
auto dt = RiaQDateTimeTools::createUtcDateTime( QDate( y, m, d ) );
m_rftSegmentTimeSteps.insert( dt );
auto segmentCount = segmentData.topology().size();
for ( const auto& resultNameAndSize : resultNameAndSizes )
@ -394,9 +399,10 @@ void RifReaderOpmRft::buildSegmentData()
}
}
auto wellDateKey = std::make_pair( wellName, date );
auto wellDateKey = std::make_pair( wellName, date );
m_rftWellDateSegments[wellDateKey] = segment;
buildSegmentBranchTypes( wellDateKey );
}
}
}
@ -445,6 +451,69 @@ void RifReaderOpmRft::importWellNames()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderOpmRft::buildSegmentBranchTypes( const RftSegmentKey& segmentKey )
{
auto wellName = segmentKey.first;
auto date = segmentKey.second;
RifRftSegment& segmentRef = m_rftWellDateSegments[segmentKey];
int y = std::get<0>( date );
int m = std::get<1>( date );
int d = std::get<2>( date );
auto dt = RiaQDateTimeTools::createUtcDateTime( QDate( y, m, d ) );
std::vector<double> seglenstValues;
std::vector<double> seglenenValues;
{
auto resultName =
RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), dt, "SEGLENST", -1 );
values( resultName, &seglenstValues );
if ( seglenstValues.size() > 2 )
{
seglenstValues[0] = seglenstValues[1];
}
}
{
auto resultName =
RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), dt, "SEGLENEN", -1 );
values( resultName, &seglenenValues );
}
if ( !seglenenValues.empty() && !seglenstValues.empty() )
{
auto branchIds = segmentRef.branchIds();
for ( auto id : branchIds )
{
double minimumMD = std::numeric_limits<double>::max();
double maximumMD = std::numeric_limits<double>::min();
auto indices = segmentRef.indicesForBranchNumber( id );
for ( auto i : indices )
{
minimumMD = std::min( minimumMD, seglenstValues[i] );
maximumMD = std::max( maximumMD, seglenenValues[i] );
}
double length = maximumMD - minimumMD;
segmentRef.setBranchLength( id, length );
const double tubingThreshold = 1.0;
RiaDefines::RftBranchType branchType = RiaDefines::RftBranchType::RFT_UNKNOWN;
if ( length > tubingThreshold ) branchType = RiaDefines::RftBranchType::RFT_TUBING;
segmentRef.setBranchType( id, branchType );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -63,6 +63,7 @@ private:
void segmentDataDebugLog() const;
bool isOpen() const;
void importWellNames();
void buildSegmentBranchTypes( const RftSegmentKey& segmentKey );
std::vector<int> importWellData( const std::string& wellName, const std::string& propertyName, const RftDate& date ) const;
@ -77,4 +78,5 @@ private:
std::set<QString> m_wellNames;
std::map<RftSegmentKey, RifRftSegment> m_rftWellDateSegments;
std::set<QDateTime> m_rftSegmentTimeSteps;
};

View File

@ -110,6 +110,27 @@ std::vector<Opm::EclIO::EclFile::EclEntry> RifRftSegment::resultNameAndSize() co
return m_resultNameAndSize;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<int> RifRftSegment::tubingBranchIds() const
{
std::vector<int> filteredBranchIds;
for ( auto branchId : branchIds() )
{
if ( m_branchType.count( branchId ) )
{
if ( m_branchType.at( branchId ) == RiaDefines::RftBranchType::RFT_TUBING )
{
filteredBranchIds.push_back( branchId );
}
}
}
return filteredBranchIds;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -128,6 +149,22 @@ std::vector<int> RifRftSegment::branchIds() const
return v;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifRftSegment::setBranchLength( int branchId, double length )
{
m_branchLength[branchId] = length;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifRftSegment::setBranchType( int branchId, RiaDefines::RftBranchType branchType )
{
m_branchType[branchId] = branchType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -22,6 +22,7 @@
#include <tuple>
#include <vector>
#include "RiaRftDefines.h"
#include "opm/io/eclipse/EclFile.hpp"
class RifRftSegmentData
@ -52,11 +53,18 @@ public:
void addResultNameAndSize( const Opm::EclIO::EclFile::EclEntry& resultNameAndSize );
std::vector<Opm::EclIO::EclFile::EclEntry> resultNameAndSize() const;
std::vector<int> tubingBranchIds() const;
std::vector<int> branchIds() const;
void setBranchLength( int branchId, double length );
void setBranchType( int branchId, RiaDefines::RftBranchType branchType );
std::vector<size_t> indicesForBranchNumber( int branchNumber ) const;
private:
std::vector<RifRftSegmentData> m_topology;
std::vector<Opm::EclIO::EclFile::EclEntry> m_resultNameAndSize;
std::map<int, double> m_branchLength;
std::map<int, RiaDefines::RftBranchType> m_branchType;
};

View File

@ -29,6 +29,7 @@
#include "RifProjectSummaryDataWriter.h"
#include "RifReaderEclipseRft.h"
#include "RifReaderEclipseSummary.h"
#include "RifReaderOpmRft.h"
#include "RifSummaryReaderMultipleFiles.h"
#include "RimProject.h"
@ -185,7 +186,7 @@ RifSummaryReaderInterface* RimFileSummaryCase::findRelatedFilesAndCreateReader(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderEclipseRft* RimFileSummaryCase::findRftDataAndCreateReader( const QString& headerFileName )
RifReaderOpmRft* RimFileSummaryCase::findRftDataAndCreateReader( const QString& headerFileName )
{
QFileInfo fileInfo( headerFileName );
QString folder = fileInfo.absolutePath();
@ -195,8 +196,7 @@ RifReaderEclipseRft* RimFileSummaryCase::findRftDataAndCreateReader( const QStri
if ( rftFileInfo.exists() )
{
std::unique_ptr<RifReaderEclipseRft> rftReader( new RifReaderEclipseRft( rftFileInfo.filePath() ) );
return rftReader.release();
return new RifReaderOpmRft( rftFileInfo.filePath() );
}
return nullptr;
@ -211,7 +211,7 @@ void RimFileSummaryCase::defineEditorAttribute( const caf::PdmFieldHandle* field
{
if ( field == &m_additionalSummaryFilePath )
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
auto* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>( attribute );
if ( myAttr )
{
myAttr->m_selectSaveFileName = true;

View File

@ -23,7 +23,7 @@
#include "cvfObject.h"
class RifReaderRftInterface;
class RifReaderEclipseRft;
class RifReaderOpmRft;
class RifReaderEclipseSummary;
class RiaThreadSafeLogger;
class RifOpmCommonEclipseSummary;
@ -61,8 +61,6 @@ public:
bool includeRestartFiles,
RiaThreadSafeLogger* threadSafeLogger );
static RifReaderEclipseRft* findRftDataAndCreateReader( const QString& headerFileName );
protected:
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
@ -73,10 +71,12 @@ private:
QString additionalSummaryDataFilePath() const;
static QString createAdditionalSummaryFileName();
static RifReaderOpmRft* findRftDataAndCreateReader( const QString& headerFileName );
private:
cvf::ref<RifSummaryReaderInterface> m_fileSummaryReader;
cvf::ref<RifMultipleSummaryReaders> m_multiSummaryReader;
cvf::ref<RifReaderEclipseRft> m_summaryEclipseRftReader;
cvf::ref<RifReaderOpmRft> m_summaryEclipseRftReader;
caf::PdmField<bool> m_includeRestartFiles;
caf::PdmField<caf::FilePath> m_additionalSummaryFilePath;

View File

@ -484,10 +484,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions( const caf:
cases.push_back( proj->calculationCollection->calculationSummaryCase() );
for ( RimSummaryCase* rimCase : cases )
{
options.push_back( caf::PdmOptionItemInfo( rimCase->displayCaseName(), rimCase ) );
}
options = RiaSummaryTools::optionsForSummaryCases( cases );
if ( options.size() > 0 )
{

View File

@ -18,6 +18,9 @@
#include "RimWellLogCurveCommonDataSource.h"
#include "RiaSimWellBranchTools.h"
#include "RiaSummaryTools.h"
#include "RimCase.h"
#include "RimDataSourceSteppingTools.h"
#include "RimEclipseCase.h"
@ -26,6 +29,7 @@
#include "RimOilField.h"
#include "RimProject.h"
#include "RimRftTools.h"
#include "RimSummaryCase.h"
#include "RimTools.h"
#include "RimWellFlowRateCurve.h"
#include "RimWellLogExtractionCurve.h"
@ -39,8 +43,6 @@
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiaSimWellBranchTools.h"
#include "cafPdmUiCheckBoxTristateEditor.h"
#include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiLineEditor.h"
@ -75,9 +77,10 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource()
CAF_PDM_InitObject( "Change Data Source" );
CAF_PDM_InitFieldNoDefault( &m_case, "CurveCase", "Case" );
CAF_PDM_InitFieldNoDefault( &m_summaryCase, "SummaryCase", "Summary Case" );
CAF_PDM_InitFieldNoDefault( &m_trajectoryType, "TrajectoryType", "Trajectory Type" );
CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Name" );
CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path" );
CAF_PDM_InitFieldNoDefault( &m_simWellName, "SimulationWellName", "Well Name" );
CAF_PDM_InitFieldNoDefault( &m_branchDetection,
@ -122,6 +125,14 @@ RimCase* RimWellLogCurveCommonDataSource::caseToApply() const
return m_case;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setSummaryCaseToApply( RimSummaryCase* val )
{
m_summaryCase = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -130,6 +141,14 @@ void RimWellLogCurveCommonDataSource::setCaseToApply( RimCase* val )
m_case = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RimWellLogCurveCommonDataSource::summaryCaseToApply() const
{
return m_summaryCase();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -264,6 +283,7 @@ void RimWellLogCurveCommonDataSource::setTimeStepToApply( int val )
void RimWellLogCurveCommonDataSource::resetDefaultOptions()
{
setCaseToApply( nullptr );
setSummaryCaseToApply( nullptr );
setTrajectoryTypeToApply( -1 );
setWellPathToApply( nullptr );
setBranchIndexToApply( -1 );
@ -274,6 +294,7 @@ void RimWellLogCurveCommonDataSource::resetDefaultOptions()
setWbsSmoothingThreshold( -1.0 );
m_uniqueCases.clear();
m_uniqueSummaryCases.clear();
m_uniqueTrajectoryTypes.clear();
m_uniqueWellPaths.clear();
m_uniqueWellNames.clear();
@ -355,8 +376,9 @@ void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector<
}
else if ( rftCurve )
{
if ( rftCurve->summaryCase() ) m_uniqueSummaryCases.insert( rftCurve->summaryCase() );
if ( rftCurve->eclipseResultCase() ) m_uniqueCases.insert( rftCurve->eclipseResultCase() );
m_uniqueWellNames.insert( rftCurve->wellName() );
m_uniqueCases.insert( rftCurve->eclipseResultCase() );
auto adr = rftCurve->rftAddress();
if ( adr.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES &&
@ -399,6 +421,11 @@ void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector<
setCaseToApply( *m_uniqueCases.begin() );
}
if ( m_uniqueSummaryCases.size() == 1u )
{
setSummaryCaseToApply( *m_uniqueSummaryCases.begin() );
}
if ( m_uniqueTrajectoryTypes.size() == 1u )
{
m_trajectoryType = *m_uniqueTrajectoryTypes.begin();
@ -745,14 +772,18 @@ std::vector<caf::PdmFieldHandle*> RimWellLogCurveCommonDataSource::fieldsToShowI
analyseCurvesAndTracks();
std::vector<caf::PdmFieldHandle*> fieldsToDisplay;
fieldsToDisplay.push_back( &m_case );
if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::WELL_PATH )
if ( !m_uniqueCases.empty() )
{
fieldsToDisplay.push_back( &m_wellPath );
}
else if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::SIMULATION_WELL )
{
fieldsToDisplay.push_back( &m_simWellName );
fieldsToDisplay.push_back( &m_case );
if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::WELL_PATH )
{
fieldsToDisplay.push_back( &m_wellPath );
}
else if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::SIMULATION_WELL )
{
fieldsToDisplay.push_back( &m_simWellName );
}
}
if ( m_uniqueRftWellNames.size() == 1u ) fieldsToDisplay.push_back( &m_rftWellName );
@ -829,17 +860,11 @@ QList<caf::PdmOptionItemInfo>
RimTools::caseOptionItems( &options );
}
if ( caseToApply() == nullptr )
{
if ( !m_uniqueCases.empty() )
{
options.push_front( caf::PdmOptionItemInfo( "Mixed Cases", nullptr ) );
}
else
{
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
}
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
if ( fieldNeedingOptions == &m_summaryCase )
{
options = RiaSummaryTools::optionsForAllSummaryCases();
}
else if ( fieldNeedingOptions == &m_trajectoryType )
{
@ -880,17 +905,20 @@ QList<caf::PdmOptionItemInfo>
}
else if ( fieldNeedingOptions == &m_timeStep )
{
RimTools::timeStepsForCase( m_case, &options );
if ( timeStepToApply() == -1 )
if ( m_case() )
{
if ( !m_uniqueTimeSteps.empty() )
RimTools::timeStepsForCase( m_case, &options );
if ( timeStepToApply() == -1 )
{
options.push_front( caf::PdmOptionItemInfo( "Mixed Time Steps", -1 ) );
}
else
{
options.push_front( caf::PdmOptionItemInfo( "No Time Steps", -1 ) );
if ( !m_uniqueTimeSteps.empty() )
{
options.push_front( caf::PdmOptionItemInfo( "Mixed Time Steps", -1 ) );
}
else
{
options.push_front( caf::PdmOptionItemInfo( "No Time Steps", -1 ) );
}
}
}
}
@ -945,27 +973,16 @@ QList<caf::PdmOptionItemInfo>
}
else if ( fieldNeedingOptions == &m_rftTimeStep )
{
auto eclipseCase = dynamic_cast<RimEclipseResultCase*>( m_case() );
if ( eclipseCase && eclipseCase->rftReader() && !m_uniqueRftWellNames.empty() )
{
options = RimRftTools::segmentTimeStepOptions( eclipseCase->rftReader(), *( m_uniqueRftWellNames.begin() ) );
}
if ( !m_uniqueRftWellNames.empty() )
options = RimRftTools::segmentTimeStepOptions( rftReader(), *( m_uniqueRftWellNames.begin() ) );
}
else if ( fieldNeedingOptions == &m_rftWellName )
{
auto eclipseCase = dynamic_cast<RimEclipseResultCase*>( m_case() );
if ( eclipseCase && eclipseCase->rftReader() )
{
options = RimRftTools::wellNameOptions( eclipseCase->rftReader() );
}
options = RimRftTools::wellNameOptions( rftReader() );
}
else if ( fieldNeedingOptions == &m_rftSegmentBranchId )
{
auto eclipseCase = dynamic_cast<RimEclipseResultCase*>( m_case() );
if ( eclipseCase && eclipseCase->rftReader() )
{
options = RimRftTools::segmentBranchIdOptions( eclipseCase->rftReader(), m_rftWellName(), m_rftTimeStep() );
}
options = RimRftTools::segmentBranchIdOptions( rftReader(), m_rftWellName(), m_rftTimeStep() );
}
return options;
@ -979,7 +996,8 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca
analyseCurvesAndTracks();
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" );
group->add( &m_case );
if ( m_case() ) group->add( &m_case );
if ( m_summaryCase() ) group->add( &m_summaryCase );
auto* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() );
if ( eclipseCase )
@ -1006,12 +1024,13 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca
}
}
}
group->add( &m_timeStep );
}
else
{
group->add( &m_wellPath );
if ( m_wellPath() ) group->add( &m_wellPath );
}
group->add( &m_timeStep );
if ( uiConfigName == smoothingUiOrderinglabel() )
{
@ -1037,7 +1056,7 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField
if ( myAttr )
{
if ( field == &m_case || field == &m_simWellName || field == &m_wellPath || field == &m_timeStep ||
field == &m_rftTimeStep || field == &m_rftSegmentBranchId )
field == &m_rftTimeStep || field == &m_rftSegmentBranchId || field == &m_rftWellName )
{
myAttr->showPreviousAndNextButtons = true;
myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" );
@ -1091,3 +1110,16 @@ void RimWellLogCurveCommonDataSource::modifyCurrentIndex( caf::PdmValueField* fi
QList<caf::PdmOptionItemInfo> options = calculateValueOptions( field );
RimDataSourceSteppingTools::modifyCurrentIndex( field, options, indexOffset );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderRftInterface* RimWellLogCurveCommonDataSource::rftReader()
{
auto eclipseCase = dynamic_cast<RimEclipseResultCase*>( m_case() );
if ( eclipseCase && eclipseCase->rftReader() ) return eclipseCase->rftReader();
if ( m_summaryCase() && m_summaryCase()->rftReader() ) return m_summaryCase->rftReader();
return nullptr;
}

View File

@ -33,6 +33,8 @@ class RimWellLogCurve;
class RimWellLogPlot;
class RimWellLogTrack;
class RimWellPath;
class RimSummaryCase;
class RifReaderRftInterface;
//==================================================================================================
///
@ -56,20 +58,22 @@ public:
void setCaseType( RiaDefines::CaseType caseType );
RimCase* caseToApply() const;
void setCaseToApply( RimCase* val );
int trajectoryTypeToApply() const;
void setTrajectoryTypeToApply( int val );
RimWellPath* wellPathToApply() const;
void setWellPathToApply( RimWellPath* val );
int branchIndexToApply() const;
void setBranchIndexToApply( int val );
caf::Tristate branchDetectionToApply() const;
void setBranchDetectionToApply( caf::Tristate::State val );
caf::Tristate wbsSmoothingToApply() const;
void setWbsSmoothingToApply( caf::Tristate::State val );
double wbsSmoothingThreshold() const;
void setWbsSmoothingThreshold( double smoothingThreshold );
RimCase* caseToApply() const;
void setCaseToApply( RimCase* val );
RimSummaryCase* summaryCaseToApply() const;
void setSummaryCaseToApply( RimSummaryCase* val );
int trajectoryTypeToApply() const;
void setTrajectoryTypeToApply( int val );
RimWellPath* wellPathToApply() const;
void setWellPathToApply( RimWellPath* val );
int branchIndexToApply() const;
void setBranchIndexToApply( int val );
caf::Tristate branchDetectionToApply() const;
void setBranchDetectionToApply( caf::Tristate::State val );
caf::Tristate wbsSmoothingToApply() const;
void setWbsSmoothingToApply( caf::Tristate::State val );
double wbsSmoothingThreshold() const;
void setWbsSmoothingThreshold( double smoothingThreshold );
QString simWellNameToApply() const;
void setSimWellNameToApply( const QString& val );
@ -93,7 +97,7 @@ public:
static QString smoothingUiOrderinglabel();
protected:
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
@ -102,24 +106,28 @@ protected:
caf::PdmUiEditorAttribute* attribute ) override;
void modifyCurrentIndex( caf::PdmValueField* field, int indexOffset );
RifReaderRftInterface* rftReader();
private:
RiaDefines::CaseType m_caseType;
caf::PdmPtrField<RimCase*> m_case;
caf::PdmField<int> m_trajectoryType;
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmField<QString> m_simWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<caf::Tristate> m_branchDetection;
caf::PdmField<int> m_timeStep;
caf::PdmField<caf::Tristate> m_wbsSmoothing;
caf::PdmField<double> m_wbsSmoothingThreshold;
caf::PdmPtrField<RimCase*> m_case;
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
caf::PdmField<int> m_trajectoryType;
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmField<QString> m_simWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<caf::Tristate> m_branchDetection;
caf::PdmField<int> m_timeStep;
caf::PdmField<caf::Tristate> m_wbsSmoothing;
caf::PdmField<double> m_wbsSmoothingThreshold;
caf::PdmField<QDateTime> m_rftTimeStep;
caf::PdmField<QString> m_rftWellName;
caf::PdmField<int> m_rftSegmentBranchId;
std::set<RimCase*> m_uniqueCases;
std::set<RimSummaryCase*> m_uniqueSummaryCases;
std::set<int> m_uniqueTrajectoryTypes;
std::set<RimWellPath*> m_uniqueWellPaths;
std::set<QString> m_uniqueWellNames;

View File

@ -24,6 +24,7 @@
#include "RiaResultNames.h"
#include "RiaRftDefines.h"
#include "RiaSimWellBranchTools.h"
#include "RiaSummaryTools.h"
#include "RifEclipseRftAddress.h"
#include "RifReaderEclipseRft.h"
@ -308,8 +309,9 @@ RimObservedFmuRftData* RimWellLogRftCurve::observedFmuRftData() const
//--------------------------------------------------------------------------------------------------
void RimWellLogRftCurve::setRftAddress( RifEclipseRftAddress address )
{
m_timeStep = address.timeStep();
m_wellName = address.wellName();
m_timeStep = address.timeStep();
m_wellName = address.wellName();
m_wellLogChannelName = address.wellLogChannel();
if ( address.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES )
{
@ -319,8 +321,7 @@ void RimWellLogRftCurve::setRftAddress( RifEclipseRftAddress address )
}
else
{
m_rftDataType = RftDataType::RFT_DATA;
m_wellLogChannelName = address.wellLogChannel();
m_rftDataType = RftDataType::RFT_DATA;
}
}
@ -508,7 +509,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( values.empty() || values.size() != tvDepthVector.size() )
{
this->detach();
this->detach( true );
return;
}
@ -676,6 +677,7 @@ void RimWellLogRftCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Curve Data" );
curveDataGroup->add( &m_eclipseResultCase );
curveDataGroup->add( &m_summaryCase );
curveDataGroup->add( &m_wellName );
curveDataGroup->add( &m_timeStep );
curveDataGroup->add( &m_rftDataType );
@ -726,6 +728,11 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions( const c
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
else if ( fieldNeedingOptions == &m_summaryCase )
{
options = RiaSummaryTools::optionsForSummaryCases( RimProject::current()->allSummaryCases() );
options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) );
}
else if ( fieldNeedingOptions == &m_wellName )
{
options = RimRftTools::wellNameOptions( reader );
@ -736,7 +743,10 @@ QList<caf::PdmOptionItemInfo> RimWellLogRftCurve::calculateValueOptions( const c
}
else if ( fieldNeedingOptions == &m_timeStep )
{
options = RimRftTools::timeStepOptions( reader, m_wellName, m_wellLogChannelName() );
if ( m_rftDataType == RimWellLogRftCurve::RftDataType::RFT_SEGMENT_DATA )
options = RimRftTools::segmentTimeStepOptions( reader, m_wellName );
else
options = RimRftTools::timeStepOptions( reader, m_wellName, m_wellLogChannelName() );
}
else if ( fieldNeedingOptions == &m_branchIndex )
{
@ -1104,6 +1114,12 @@ std::vector<double> RimWellLogRftCurve::measuredDepthValues()
segmentBranchId() );
reader->values( depthAddress, &values );
// Special handling of first segment
if ( values.size() > 2 && values.front() < 0.001 )
{
values[0] = values[1];
}
}
return values;
}

View File

@ -89,6 +89,7 @@
#include "cafPdmFieldReorderCapability.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiDoubleValueEditor.h"
#include "cafPdmUiSliderEditor.h"
#include "cafSelectionManager.h"
@ -191,7 +192,10 @@ RimWellLogTrack::RimWellLogTrack()
reorderability->orderChanged.connect( this, &RimWellLogTrack::curveDataChanged );
CAF_PDM_InitField( &m_visiblePropertyValueRangeMin, "VisibleXRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min" );
m_visiblePropertyValueRangeMin.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_visiblePropertyValueRangeMax, "VisibleXRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max" );
m_visiblePropertyValueRangeMax.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_visibleDepthRangeMin, "VisibleYRangeMin", RI_LOGPLOTTRACK_MINX_DEFAULT, "Min" );
CAF_PDM_InitField( &m_visibleDepthRangeMax, "VisibleYRangeMax", RI_LOGPLOTTRACK_MAXX_DEFAULT, "Max" );
m_visibleDepthRangeMin.uiCapability()->setUiHidden( true );
@ -203,6 +207,7 @@ RimWellLogTrack::RimWellLogTrack()
m_isAutoScalePropertyValuesEnabled.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_isLogarithmicScaleEnabled, "LogarithmicScaleX", false, "Logarithmic Scale" );
CAF_PDM_InitField( &m_invertPropertyValueAxis, "InvertPropertyValueAxis", false, "Invert Axis Range" );
CAF_PDM_InitFieldNoDefault( &m_propertyValueAxisGridVisibility, "ShowXGridLines", "Show Grid Lines" );
@ -403,14 +408,11 @@ void RimWellLogTrack::calculatePropertyValueZoomRange()
}
else
{
auto range = std::fabs( maxValue - minValue );
maxValue += 0.1 * range;
double adjustmentFactor = 0.1;
auto [adjustedMin, adjustedMax] = extendMinMaxRange( minValue, maxValue, adjustmentFactor );
auto candidateMinValue = minValue - 0.1 * range;
if ( std::signbit( minValue ) == std::signbit( candidateMinValue ) )
{
minValue = candidateMinValue;
}
minValue = adjustedMin;
maxValue = adjustedMax;
}
m_availablePropertyValueRangeMin = minValue;
@ -465,8 +467,11 @@ void RimWellLogTrack::calculateDepthZoomRange()
}
}
m_availableDepthRangeMin = minDepth;
m_availableDepthRangeMax = maxDepth;
double adjustmentFactor = 0.02;
auto [adjustedMin, adjustedMax] = extendMinMaxRange( minDepth, maxDepth, adjustmentFactor );
m_availableDepthRangeMin = adjustedMin;
m_availableDepthRangeMax = adjustedMax;
}
//--------------------------------------------------------------------------------------------------
@ -509,7 +514,18 @@ void RimWellLogTrack::updatePropertyValueZoom()
componentRangeMax *= 1.5;
}
m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), componentRangeMin, componentRangeMax );
RimDepthTrackPlot* wellLogPlot;
this->firstAncestorOrThisOfTypeAsserted( wellLogPlot );
// Attribute components use the opposite axis to the property values
if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
m_plotWidget->setAxisRange( RiuPlotAxis::defaultBottom(), componentRangeMin, componentRangeMax );
}
else if ( wellLogPlot->depthOrientation() == RimDepthTrackPlot::DepthOrientation::VERTICAL )
{
m_plotWidget->setAxisRange( RiuPlotAxis::defaultRight(), componentRangeMin, componentRangeMax );
}
}
//--------------------------------------------------------------------------------------------------
@ -578,7 +594,8 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
}
}
else if ( changedField == &m_propertyValueAxisGridVisibility || changedField == &m_majorTickInterval ||
changedField == &m_minorTickInterval || changedField == &m_minAndMaxTicksOnly )
changedField == &m_minorTickInterval || changedField == &m_minAndMaxTicksOnly ||
changedField == &m_invertPropertyValueAxis )
{
updatePropertyValueAxisAndGridTickIntervals();
}
@ -796,6 +813,11 @@ void RimWellLogTrack::updatePropertyValueAxisAndGridTickIntervals()
else
{
m_plotWidget->setAxisLabelsAndTicksEnabled( valueAxis(), true, true );
auto rangeBoundaryA = m_visiblePropertyValueRangeMin();
auto rangeBoundaryB = m_visiblePropertyValueRangeMax();
if ( m_invertPropertyValueAxis() ) std::swap( rangeBoundaryA, rangeBoundaryB );
if ( m_minAndMaxTicksOnly )
{
auto roundToDigits = []( double value, int numberOfDigits, bool useFloor ) {
@ -813,16 +835,16 @@ void RimWellLogTrack::updatePropertyValueAxisAndGridTickIntervals()
return std::ceil( value * factor ) / factor;
};
auto div = QwtScaleDiv( m_visiblePropertyValueRangeMin(), m_visiblePropertyValueRangeMax() );
auto div = QwtScaleDiv( rangeBoundaryA, rangeBoundaryB );
QList<double> majorTicks;
auto min = roundToDigits( m_visiblePropertyValueRangeMin(), 2, false );
auto max = roundToDigits( m_visiblePropertyValueRangeMax(), 2, true );
auto min = roundToDigits( rangeBoundaryA, 2, false );
auto max = roundToDigits( rangeBoundaryB, 2, true );
if ( min == max )
{
min = roundToDigits( m_visiblePropertyValueRangeMin(), 3, false );
max = roundToDigits( m_visiblePropertyValueRangeMax(), 3, true );
min = roundToDigits( rangeBoundaryA, 3, false );
max = roundToDigits( rangeBoundaryB, 3, true );
}
majorTicks.push_back( min );
@ -846,15 +868,15 @@ void RimWellLogTrack::updatePropertyValueAxisAndGridTickIntervals()
m_plotWidget->setMajorAndMinorTickIntervals( valueAxis(),
m_majorTickInterval(),
m_minorTickInterval(),
m_visiblePropertyValueRangeMin(),
m_visiblePropertyValueRangeMax() );
rangeBoundaryA,
rangeBoundaryB );
}
else
{
int majorTickIntervals = 5;
int minorTickIntervals = 10;
m_plotWidget->setAutoTickIntervalCounts( valueAxis(), majorTickIntervals, minorTickIntervals );
m_plotWidget->setAxisRange( valueAxis(), m_visiblePropertyValueRangeMin, m_visiblePropertyValueRangeMax );
m_plotWidget->setAxisRange( valueAxis(), rangeBoundaryA, rangeBoundaryB );
}
m_plotWidget->enableGridLines( valueAxis(),
@ -986,13 +1008,10 @@ QString RimWellLogTrack::asciiDataForPlotExport() const
const std::vector<double>& allDepths = curveMerger.allXValues();
curveDepths = allDepths;
for ( size_t depthIdx = 0; depthIdx < allDepths.size(); depthIdx++ )
for ( size_t curveIdx = 0; curveIdx < curveMerger.curveCount(); ++curveIdx )
{
for ( size_t curveIdx = 0; curveIdx < curveMerger.curveCount(); ++curveIdx )
{
const std::vector<double>& curveValues = curveMerger.lookupYValuesForAllXValues( curveIdx );
curvesPlotXValues.push_back( curveValues );
}
const std::vector<double>& curveValues = curveMerger.lookupYValuesForAllXValues( curveIdx );
curvesPlotXValues.push_back( curveValues );
}
}
@ -2098,6 +2117,27 @@ std::pair<double, double> RimWellLogTrack::adjustXRange( double minValue, double
return std::make_pair( adjustedMin, adjustedMax );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<double, double> RimWellLogTrack::extendMinMaxRange( double minValue, double maxValue, double factor )
{
auto modifiedMin = minValue;
auto modifiedMax = maxValue;
auto range = std::fabs( maxValue - minValue );
modifiedMax += factor * range;
auto candidateMinValue = minValue - factor * range;
if ( std::signbit( minValue ) == std::signbit( candidateMinValue ) )
{
// Leave minimum unchanged if the changes causes change of sign to make sure that zero is located properly
modifiedMin = candidateMinValue;
}
return { modifiedMin, modifiedMax };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2349,6 +2389,7 @@ void RimWellLogTrack::uiOrderingForXAxisSettings( caf::PdmUiOrdering& uiOrdering
gridGroup->add( &m_isLogarithmicScaleEnabled );
gridGroup->add( &m_visiblePropertyValueRangeMin );
gridGroup->add( &m_visiblePropertyValueRangeMax );
gridGroup->add( &m_invertPropertyValueAxis );
gridGroup->add( &m_propertyValueAxisGridVisibility );
gridGroup->add( &m_minAndMaxTicksOnly );

View File

@ -298,6 +298,8 @@ private:
std::pair<double, double> adjustXRange( double minValue, double maxValue, double tickInterval );
std::pair<double, double> extendMinMaxRange( double minValue, double maxValue, double factor );
void updateWellPathAttributesCollection();
RimDepthTrackPlot* parentWellLogPlot() const;
@ -324,6 +326,7 @@ private:
caf::PdmField<bool> m_isAutoScalePropertyValuesEnabled;
caf::PdmField<bool> m_isLogarithmicScaleEnabled;
caf::PdmField<bool> m_invertPropertyValueAxis;
caf::PdmField<RimWellLogPlot::AxisGridEnum> m_propertyValueAxisGridVisibility;
caf::PdmField<bool> m_explicitTickIntervals;
@ -373,5 +376,4 @@ private:
double m_availablePropertyValueRangeMax;
double m_availableDepthRangeMin;
double m_availableDepthRangeMax;
};