diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 0113ffb71b..c083ee606d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -445,8 +445,10 @@ void RicExportFractureCompletionsImpl::getWellPressuresAndInitialProductionTimeS if ( resultCase ) { std::vector caseTimeSteps = resultCase->timeStepDates(); - QDateTime initialProductionDate; - QDateTime currentDate; + if ( caseTimeSteps.empty() ) return; + + QDateTime initialProductionDate; + QDateTime currentDate; if ( currentTimeStep < static_cast( caseTimeSteps.size() ) ) { currentDate = caseTimeSteps[currentTimeStep]; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 7ee44b1482..7d59cde2a9 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -504,27 +504,6 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell resultCompletion.setSecondOrderingValue( firstCompletion.secondOrderingValue() ); resultCompletion.setSourcePdmObject( firstCompletion.sourcePdmObject() ); - bool anyNonDarcyFlowPresent = false; - for ( const auto& c : completions ) - { - if ( c.isNonDarcyFlow() ) anyNonDarcyFlowPresent = true; - } - - if ( anyNonDarcyFlowPresent && completions.size() > 1 ) - { - QString errorMessage = - QString( "Cannot combine multiple completions when Non-Darcy Flow contribution is present in same cell %1" ) - .arg( cellIndexIJK.oneBasedLocalCellIndexString() ); - RiaLogging::error( errorMessage ); - resultCompletion.addMetadata( "ERROR", errorMessage ); - return resultCompletion; // Returning empty completion, should not be exported - } - - if ( firstCompletion.isNonDarcyFlow() ) - { - return firstCompletion; - } - // completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, // if no main bore they are taken from first completion double skinfactor = firstCompletion.skinFactor(); @@ -541,11 +520,13 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell skinfactor = completion.skinFactor(); wellBoreDiameter = completion.diameter(); cellDirection = completion.direction(); - break; } } - double totalTrans = 0.0; + RiaWeightedMeanCalculator dFactorCalculator; + + double combinedTrans = 0.0; + double combinedKh = 0.0; for ( const RigCompletionData& completion : completions ) { @@ -554,15 +535,6 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell completion.m_metadata.begin(), completion.m_metadata.end() ); - if ( completion.completionType() != firstCompletion.completionType() ) - { - QString errorMessage = QString( "Cannot combine completions of different types in same cell %1" ) - .arg( cellIndexIJK.oneBasedLocalCellIndexString() ); - RiaLogging::error( errorMessage ); - resultCompletion.addMetadata( "ERROR", errorMessage ); - return resultCompletion; // Returning empty completion, should not be exported - } - if ( completion.wellName() != firstCompletion.wellName() ) { QString errorMessage = QString( "Cannot combine completions of different types in same cell %1" ) @@ -581,12 +553,21 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell return resultCompletion; // Returning empty completion, should not be exported } - totalTrans = totalTrans + completion.transmissibility(); + combinedTrans = combinedTrans + completion.transmissibility(); + combinedKh = combinedKh + completion.kh(); + + dFactorCalculator.addValueAndWeight( completion.dFactor(), completion.transmissibility() ); } + // Arithmetic MEAN dFactor weighted by Tj/SumTj from the completions + // Note : Divide by n is intentional, based on input from @hhgs in mail dated 18.01.2020 + double combinedDFactor = dFactorCalculator.weightedMean() / completions.size(); + if ( settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES ) { - resultCompletion.setCombinedValuesExplicitTrans( totalTrans, + resultCompletion.setCombinedValuesExplicitTrans( combinedTrans, + combinedKh, + combinedDFactor, skinfactor, wellBoreDiameter, cellDirection, @@ -603,8 +584,10 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell .globalCellIndex(), cellDirection ); - double wpimult = totalTrans / transmissibilityEclipseCalculation; + double wpimult = combinedTrans / transmissibilityEclipseCalculation; resultCompletion.setCombinedValuesImplicitTransWPImult( wpimult, + combinedKh, + combinedDFactor, skinfactor, wellBoreDiameter, cellDirection, diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index d069f773cc..216cd8521f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -307,15 +307,18 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTable double depth = 0; double length = 0; + double midPointMD = 0.5 * ( location->startMD() + location->endMD() ); + double midPointTVD = 0.5 * ( location->startTVD() + location->endTVD() ); + if ( exportInfo.lengthAndDepthText() == QString( "INC" ) ) { - depth = location->endTVD() - prevTVD; - length = location->endMD() - prevMD; + depth = midPointTVD - prevTVD; + length = midPointMD - prevMD; } else { - depth = location->endTVD(); - length = location->endMD(); + depth = midPointTVD; + length = midPointMD; } if ( location->subIndex() != cvf::UNDEFINED_SIZE_T ) @@ -333,8 +336,8 @@ void RicWellPathExportMswCompletionsImpl::generateWelsegsTable( RifTextDataTable formatter.add( exportInfo.linerDiameter() ); formatter.add( exportInfo.roughnessFactor() ); formatter.rowCompleted(); - prevMD = location->endMD(); - prevTVD = location->endTVD(); + prevMD = midPointMD; + prevTVD = midPointTVD; } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 89c2334f99..502ff6e5a1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -183,7 +183,10 @@ RimEnsembleCurveSet::~RimEnsembleCurveSet() if ( parentPlot && parentPlot->viewer() ) { m_qwtPlotCurveForLegendText->detach(); - parentPlot->viewer()->removeOverlayFrame( m_legendOverlayFrame ); + if ( m_legendOverlayFrame ) + { + parentPlot->viewer()->removeOverlayFrame( m_legendOverlayFrame ); + } } if ( m_legendOverlayFrame ) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index 2ac409b57f..81cdc3f257 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -130,6 +130,25 @@ void RimEnsembleCurveSetCollection::reattachQwtCurves() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RimEnsembleCurveSetCollection::findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const +{ + for ( RimEnsembleCurveSet* curveSet : m_curveSets ) + { + for ( RimSummaryCurve* rimCurve : curveSet->curves() ) + { + if ( rimCurve->qwtPlotCurve() == qwtCurve ) + { + return rimCurve; + } + } + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -285,16 +304,6 @@ void RimEnsembleCurveSetCollection::deleteAllCurveSets() m_curveSets.deleteAllChildObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEnsembleCurveSetCollection::setCurrentSummaryCurveSet( RimEnsembleCurveSet* curveSet ) -{ - m_currentEnsembleCurveSet = curveSet; - - updateConnectedEditors(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h index 344f08aafc..599e5fece4 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -47,6 +47,7 @@ public: void detachQwtCurves(); void reattachQwtCurves(); + RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const; RimEnsembleCurveSet* findRimCurveSetFromQwtCurve( const QwtPlotCurve* qwtCurve ) const; void addCurveSet( RimEnsembleCurveSet* curveSet ); @@ -58,8 +59,6 @@ public: void deleteAllCurveSets(); - void setCurrentSummaryCurveSet( RimEnsembleCurveSet* curveSet ); - // Functions related to source stepping std::vector fieldsToShowInToolbar(); void setCurveSetForSourceStepping( RimEnsembleCurveSet* curve ); @@ -82,6 +81,5 @@ private: caf::PdmChildField m_ySourceStepping; - caf::PdmPointer m_currentEnsembleCurveSet; caf::PdmPointer m_curveSetForSourceStepping; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 1529b0d85d..eec086a2e1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -405,13 +405,11 @@ caf::PdmObject* RimSummaryPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* q if ( m_ensembleCurveSetCollection ) { - RimEnsembleCurveSet* foundCurveSet = m_ensembleCurveSetCollection->findRimCurveSetFromQwtCurve( qwtCurve ); + RimSummaryCurve* foundCurve = m_ensembleCurveSetCollection->findRimCurveFromQwtCurve( qwtCurve ); - if ( foundCurveSet ) + if ( foundCurve ) { - m_ensembleCurveSetCollection->setCurrentSummaryCurveSet( foundCurveSet ); - - return foundCurveSet; + return foundCurve; } } return nullptr; @@ -1214,7 +1212,7 @@ void RimSummaryPlot::deleteCurves( const std::vector& curves ) if ( curveSet->curves().empty() ) { if ( curveSet->colorMode() == RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM && - m_plotWidget ) + m_plotWidget && curveSet->legendFrame() ) { m_plotWidget->removeOverlayFrame( curveSet->legendFrame() ); } @@ -2199,8 +2197,13 @@ void populateSummaryCurvesData( std::vector curves, SummaryCur errorCurveData.values = errorValues; } - if ( casePosInList == cvf::UNDEFINED_SIZE_T ) + if ( casePosInList == cvf::UNDEFINED_SIZE_T || + curve->summaryAddressY().category() == RifEclipseSummaryAddress::SUMMARY_CALCULATED ) { + // Create a section with separate time axis data if + // 1. Case is not referenced before, or + // 2. We have calculated data, and it we cannot assume identical time axis + auto curveDataList = std::vector( {curveData} ); if ( hasErrorData ) curveDataList.push_back( errorCurveData ); @@ -2210,6 +2213,8 @@ void populateSummaryCurvesData( std::vector curves, SummaryCur } else { + // Append curve data to previously created curvesdata object + curvesData->allCurveData[casePosInList].push_back( curveData ); if ( hasErrorData ) curvesData->allCurveData[casePosInList].push_back( errorCurveData ); } diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp index 2a4d0380bd..23cf947db4 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp @@ -204,12 +204,16 @@ void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation( double /// //================================================================================================== void RigCompletionData::setCombinedValuesExplicitTrans( double transmissibility, + double kh, + double dFactor, double skinFactor, double diameter, CellDirection celldirection, CompletionType completionType ) { m_transmissibility = transmissibility; + m_kh = kh; + m_dFactor = dFactor; m_skinFactor = skinFactor; m_diameter = diameter; m_direction = celldirection; @@ -220,12 +224,16 @@ void RigCompletionData::setCombinedValuesExplicitTrans( double transmiss /// //================================================================================================== void RigCompletionData::setCombinedValuesImplicitTransWPImult( double wpimult, + double kh, + double dFactor, double skinFactor, double diameter, CellDirection celldirection, CompletionType completionType ) { m_wpimult = wpimult; + m_kh = kh; + m_dFactor = dFactor; m_direction = celldirection; m_completionType = completionType; m_skinFactor = skinFactor; diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h index 5cce5963f9..cd7871f789 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h @@ -112,12 +112,16 @@ public: CellDirection direction ); void setCombinedValuesExplicitTrans( double transmissibility, + double kh, + double dFactor, double skinFactor, double diameter, CellDirection celldirection, CompletionType completionType ); void setCombinedValuesImplicitTransWPImult( double wpimult, + double kh, + double dFactor, double skinFactor, double diameter, CellDirection celldirection, diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp index 3cb1b93459..6d75f9e3fe 100644 --- a/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp @@ -29,9 +29,11 @@ #include #include + #include #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -350,8 +352,21 @@ void RigTransmissibilityCondenser::calculateCondensedTransmissibilities() } else { - MatrixXd Tei = totalSystem.bottomLeftCorner( externalEquationCount, internalEquationCount ); - m_TiiInv = totalSystem.topLeftCorner( internalEquationCount, internalEquationCount ).inverse(); + MatrixXd Tei = totalSystem.bottomLeftCorner( externalEquationCount, internalEquationCount ); + MatrixXd Tii = totalSystem.topLeftCorner( internalEquationCount, internalEquationCount ); + + // std::ofstream outFileStream( "D:\\Data\\TestData\\TiiMatrix.txt" ); + // outFileStream << Tii; + + Eigen::FullPivLU solver( Tii ); + + // outFileStream << std::endl; + // outFileStream << "Rows x Cols: " << Tii.rows() << "x" << Tii.cols() << std::endl; + // outFileStream << "Invertible: " << ( solver.isInvertible() ? "True" : "False" ) << std::endl; + // outFileStream << "Condition: " << solver.rcond() << std::endl; + // outFileStream << "Rank: " << solver.rank() << std::endl; + + m_TiiInv = solver.inverse(); m_Tie = totalSystem.topRightCorner( internalEquationCount, externalEquationCount ); condensedSystem = Tee - Tei * m_TiiInv * m_Tie; } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp index 60407da62f..ec7493bab8 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp @@ -120,14 +120,27 @@ bool RigCaseCellResultCalculator::computeDifference( RigEclipseCaseData* const std::vector& srcVals = srcFrames[fIdx]; std::vector& dstVals = diffResultFrames->at( fIdx ); + // Clear the values, and resize with infinity as default value + dstVals.clear(); dstVals.resize( srcVals.size(), std::numeric_limits::infinity() ); } } size_t baseFrameCount = baseCaseResults->cellScalarResults( nativeAddress ).size(); size_t sourceFrameCount = sourceCaseResults->cellScalarResults( nativeAddress ).size(); - size_t maxFrameCount = std::min( baseFrameCount, sourceFrameCount ); - size_t maxGridCount = std::min( baseMainGrid->gridCount(), sourceMainGrid->gridCount() ); + size_t maxFrameCount = 0; + if ( address.isTimeLapse() ) + { + // We have one defined time step for base case, loop over all source time steps + maxFrameCount = sourceFrameCount; + } + else + { + // We compare cases, diff is computed time index by time index. Use minimum frame count. + maxFrameCount = std::min( baseFrameCount, sourceFrameCount ); + } + + size_t maxGridCount = std::min( baseMainGrid->gridCount(), sourceMainGrid->gridCount() ); for ( size_t gridIdx = 0; gridIdx < maxGridCount; ++gridIdx ) { diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp index c964316ef8..2f8de58d81 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp @@ -440,6 +440,8 @@ void RiuQwtPlotWidget::addOverlayFrame( QFrame* overlayFrame ) //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::removeOverlayFrame( QFrame* overlayFrame ) { + CAF_ASSERT( overlayFrame ); + overlayFrame->hide(); overlayFrame->setParent( nullptr ); m_overlayFrames.removeOne( overlayFrame ); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp index 4789736c68..9665b8338a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp @@ -320,12 +320,12 @@ PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference(PdmFieldHandle* fr { if (!fromField) return nullptr; if (reference.isEmpty()) return nullptr; + if (reference.trimmed().isEmpty()) return nullptr; QStringList decodedReference = reference.split(QRegExp("\\s+"), QString::SkipEmptyParts); PdmObjectHandle* lastCommonAnchestor = fromField->ownerObject(); CAF_ASSERT(lastCommonAnchestor); - CAF_ASSERT(decodedReference.size()); - + while (!decodedReference.empty() && decodedReference.front() == "..") { PdmFieldHandle* parentField = lastCommonAnchestor->parentField(); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt index 0e248a7daa..24bb2f877f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt @@ -32,6 +32,7 @@ add_executable (${PROJECT_NAME} cafPdmXmlBasicTest.cpp cafPdmAdvancedTemplateTest.cpp cafPdmXmlNumberTest.cpp + cafPdmPtrArrayTest.cpp ) if (Qt5Core_FOUND) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmPtrArrayTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmPtrArrayTest.cpp new file mode 100644 index 0000000000..af1bbda2da --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmPtrArrayTest.cpp @@ -0,0 +1,153 @@ + +#include "gtest/gtest.h" + +#include "cafPdmChildArrayField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmReferenceHelper.h" +#include "cafPdmXmlObjectHandle.h" +#include "cafPdmXmlObjectHandleMacros.h" +#include "cafPdmDataValueField.h" +#include "cafPdmPtrArrayField.h" + + +class MyItemPdmObject : public caf::PdmObjectHandle, public caf::PdmXmlObjectHandle +{ + CAF_PDM_XML_HEADER_INIT; +public: + + MyItemPdmObject() : PdmObjectHandle(), PdmXmlObjectHandle(this, false) + { + CAF_PDM_XML_InitField(&m_name, "Name"); + } + + explicit MyItemPdmObject(QString name) : PdmObjectHandle(), PdmXmlObjectHandle(this, false) + { + CAF_PDM_XML_InitField(&m_name, "Name"); + m_name = name; + } + + ~MyItemPdmObject() + { + } + + // Fields + caf::PdmDataValueField m_name; +}; +CAF_PDM_XML_SOURCE_INIT(MyItemPdmObject, "MyItemPdmObject"); + +class MyContainerPdmObject : public caf::PdmObjectHandle, public caf::PdmXmlObjectHandle +{ + CAF_PDM_XML_HEADER_INIT; +public: + + MyContainerPdmObject() : PdmObjectHandle(), PdmXmlObjectHandle(this, false) + { + CAF_PDM_XML_InitField(&m_items, "Items"); + CAF_PDM_XML_InitField(&m_containers, "Containers"); + + } + + + ~MyContainerPdmObject() + { + } + + + // Fields + caf::PdmChildArrayField m_items; + caf::PdmPtrArrayField m_containers; + +}; +CAF_PDM_XML_SOURCE_INIT(MyContainerPdmObject, "MyContainerPdmObject"); + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(PtrArrayBaseTest, PtrArraySerializeTest) +{ + + MyContainerPdmObject* objA = new MyContainerPdmObject; + + MyItemPdmObject* s1 = new MyItemPdmObject; + MyItemPdmObject* s2 = new MyItemPdmObject; + MyItemPdmObject* s3 = new MyItemPdmObject; + + objA->m_items.push_back(s1); + objA->m_items.push_back(s2); + objA->m_items.push_back(s3); + + objA->m_containers.push_back(s1); + objA->m_containers.push_back(s2); + objA->m_containers.push_back(s3); + + //delete s2; + + QString serializedString; + { + serializedString = objA->writeObjectToXmlString(); + + std::cout << serializedString.toStdString() << std::endl; + + } + + { + MyContainerPdmObject* ihd1 = new MyContainerPdmObject; + + QXmlStreamReader xmlStream(serializedString); + + ihd1->readObjectFromXmlString(serializedString, caf::PdmDefaultObjectFactory::instance()); + ihd1->resolveReferencesRecursively(); + + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(PtrArrayBaseTest, DeleteObjectPtrArraySerializeTest) +{ + + MyContainerPdmObject* objA = new MyContainerPdmObject; + + MyItemPdmObject* s1 = new MyItemPdmObject; + MyItemPdmObject* s2 = new MyItemPdmObject; + MyItemPdmObject* s3 = new MyItemPdmObject; + + objA->m_items.push_back(s1); + objA->m_items.push_back(s2); + objA->m_items.push_back(s3); + + objA->m_containers.push_back(s1); + objA->m_containers.push_back(s2); + objA->m_containers.push_back(s3); + + delete s2; + + QString serializedString; + { + serializedString = objA->writeObjectToXmlString(); + + std::cout << serializedString.toStdString() << std::endl; + + } + + { + MyContainerPdmObject* ihd1 = new MyContainerPdmObject; + + QXmlStreamReader xmlStream(serializedString); + + ihd1->readObjectFromXmlString(serializedString, caf::PdmDefaultObjectFactory::instance()); + ihd1->resolveReferencesRecursively(); + + EXPECT_TRUE(ihd1->m_containers.at(0) != nullptr); + EXPECT_TRUE(ihd1->m_containers.at(1) == nullptr); // Deleted + EXPECT_TRUE(ihd1->m_containers.at(2) == nullptr); // Pointing to item at index 2, does not longer exist + + EXPECT_TRUE(ihd1->m_items.size() == size_t(2)); + EXPECT_TRUE(ihd1->m_items[0] != nullptr); + EXPECT_TRUE(ihd1->m_items[1] != nullptr); + } +} + diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index a07fb49963..32ca41fc0f 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(RESINSIGHT_MAJOR_VERSION 2019) set(RESINSIGHT_MINOR_VERSION 12) -set(RESINSIGHT_PATCH_VERSION 0) +set(RESINSIGHT_PATCH_VERSION 1) # Opional text with no restrictions #set(RESINSIGHT_VERSION_TEXT "-RC05") diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index 03b2536fb2..ba4a4baa42 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -1241,7 +1241,7 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k 'YEARS' as basic time unit; that mode is not supported. */ - util_abort("%s: Sorry the SMSPEC file seems to lack all time information, need either TIME, or DAY/MONTH/YEAR information. Can not proceed.",__func__); + ecl_smspec_free( ecl_smspec ); return NULL; } return ecl_smspec;