mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-01 16:43:03 -06:00
Derived cases were pooled through an m_inUse flag on RimDeltaSummaryCase. Every regeneration marked all cases not in use, which also severed their source references and cleared their caches, then handed them back out one by one and deleted whatever was left over. The flag conflated pool bookkeeping with owning the source references, allSummaryCases() hid the not-in-use cases from the rest of the project, and cases taken from the pool were pushed straight into m_cases without connecting nameChanged, so a renamed source case never propagated to the derived case. Replace the pooling with desiredSourceCasePairs(), a pure computation of the source case pairs the ensemble should have, and rebuildDerivedCases(), which diffs that against the existing derived cases keyed on the source case pointer pair. Matching cases are reused, missing ones are created, and surplus ones are detached and returned to the caller instead of being deleted in place. Keying on the pointer pair makes the rebuild idempotent, also right after project load where the derived cases arrive from XML with their sources already resolved. Add the protected RimSummaryEnsemble::addCaseWithoutDependencyUpdate(), used both by addCase() and by the rebuild, so a derived case gets nameChanged connected without triggering the dependent-ensemble notification that the rebuild is already performing itself. Remove setAllCasesNotInUse(), firstCaseNotInUse(), deleteCasesNoInUse(), RimDeltaSummaryCase::setInUse()/isInUse() and the m_inUse field, and add clearSourceCases() for the one thing setInUse(false) was actually needed for. Old project files keep loading, unknown XML keywords are skipped. The activeOnly parameter of allDerivedCases() is gone and RimDeltaSummaryEnsemble no longer overrides allSummaryCases().
189 lines
7.9 KiB
C++
189 lines
7.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2016- Statoil 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 "RiaDefines.h"
|
|
#include "Summary/RiaSummaryDefines.h"
|
|
|
|
#include "RifEclipseSummaryAddress.h"
|
|
|
|
#include "RigEnsembleParameter.h"
|
|
|
|
#include "cafPdmChildArrayField.h"
|
|
#include "cafPdmChildField.h"
|
|
#include "cafPdmField.h"
|
|
#include "cafPdmObject.h"
|
|
#include "cafPdmProxyValueField.h"
|
|
|
|
#include <QString>
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
class RimSummaryCase;
|
|
class RimSummaryAddressCollection;
|
|
class RiaSummaryAddressAnalyzer;
|
|
class RimSummaryEnsembleParameterCollection;
|
|
|
|
//==================================================================================================
|
|
///
|
|
//==================================================================================================
|
|
class RimSummaryEnsemble : public caf::PdmObject
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
caf::Signal<> caseNameChanged;
|
|
caf::Signal<RimSummaryCase*> caseRemoved;
|
|
|
|
public:
|
|
RimSummaryEnsemble();
|
|
~RimSummaryEnsemble() override;
|
|
|
|
void removeCase( RimSummaryCase* summaryCase, bool notifyChange = true );
|
|
void addCase( RimSummaryCase* summaryCase, bool notifyChange = true );
|
|
void replaceCases( const std::vector<RimSummaryCase*>& summaryCases, bool notifyChange = true );
|
|
|
|
virtual void reloadCases();
|
|
|
|
virtual std::vector<RimSummaryCase*> allSummaryCases() const;
|
|
RimSummaryCase* firstSummaryCase() const;
|
|
|
|
QString name() const;
|
|
|
|
void setNameTemplate( const QString& name );
|
|
virtual void updateName( const std::set<QString>& existingEnsembleNames );
|
|
void setUsePathKey1( bool useKey1 );
|
|
void setUsePathKey2( bool useKey2 );
|
|
virtual std::pair<std::string, std::string> nameKeys() const;
|
|
virtual QString nameTemplateText() const;
|
|
|
|
void setGroupingMode( RiaDefines::EnsembleGroupingMode groupingMode );
|
|
RiaDefines::EnsembleGroupingMode groupingMode() const;
|
|
|
|
bool isEnsemble() const;
|
|
void setAsEnsemble( bool isEnsemble );
|
|
virtual std::set<RifEclipseSummaryAddress> ensembleSummaryAddresses() const;
|
|
virtual std::set<time_t> ensembleTimeSteps() const;
|
|
|
|
void setEnsembleId( int ensembleId );
|
|
int ensembleId() const;
|
|
bool hasEnsembleParameters() const;
|
|
|
|
std::vector<RigEnsembleParameter> variationSortedEnsembleParameters( bool excludeNoVariation = false ) const;
|
|
std::vector<std::pair<RigEnsembleParameter, double>> correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address ) const;
|
|
std::vector<std::pair<RigEnsembleParameter, double>> correlationSortedEnsembleParameters( const RifEclipseSummaryAddress& address,
|
|
time_t selectedTimeStep ) const;
|
|
std::vector<std::pair<RigEnsembleParameter, double>> parameterCorrelations( const RifEclipseSummaryAddress& address,
|
|
time_t selectedTimeStep,
|
|
const std::vector<QString>& selectedParameters = {},
|
|
const std::set<RimSummaryCase*>& selectedCases = {} ) const;
|
|
|
|
std::vector<std::pair<RigEnsembleParameter, double>>
|
|
parameterCorrelationsAllTimeSteps( const RifEclipseSummaryAddress& address, const std::vector<QString>& selectedParameters = {} ) const;
|
|
|
|
RigEnsembleParameter ensembleParameter( const QString& paramName ) const;
|
|
void calculateEnsembleParametersIntersectionHash();
|
|
|
|
void loadDataAndUpdate();
|
|
|
|
static bool validateEnsembleCases( const std::vector<RimSummaryCase*> cases );
|
|
bool operator<( const RimSummaryEnsemble& rhs ) const;
|
|
|
|
RiaDefines::EclipseUnitSystem unitSystem() const;
|
|
|
|
void onCalculationUpdated();
|
|
|
|
void updateReferringCurveSets();
|
|
void updateReferringCurveSetsZoomAll();
|
|
void clearReferringCurveSets();
|
|
|
|
RiaSummaryAddressAnalyzer* addressAnalyzer();
|
|
|
|
void computeMinMax( const RifEclipseSummaryAddress& address );
|
|
void setMinMax( const RifEclipseSummaryAddress& address, double min, double max );
|
|
std::pair<double, double> minMax( const RifEclipseSummaryAddress& address );
|
|
|
|
virtual void cleanupBeforeDelete();
|
|
|
|
bool includeInAutoReload() const;
|
|
|
|
protected:
|
|
virtual void onLoadDataAndUpdate();
|
|
|
|
// Add a case without notifying the delta ensembles depending on this ensemble. Used when the caller is itself the
|
|
// owner of the dependency update, as is the case when a delta ensemble rebuilds its derived cases.
|
|
void addCaseWithoutDependencyUpdate( RimSummaryCase* summaryCase );
|
|
|
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
|
void buildMetaData();
|
|
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
|
|
|
bool isAutoNameChecked() const;
|
|
|
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
|
void initAfterRead() override;
|
|
void buildChildNodes();
|
|
|
|
private:
|
|
caf::PdmFieldHandle* userDescriptionField() override;
|
|
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
|
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
|
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
|
|
|
QString nameAndItemCount() const;
|
|
void updateIcon();
|
|
|
|
void updateReferringCurveSets( bool doZoomAll );
|
|
|
|
void onCaseNameChanged( const SignalEmitter* emitter );
|
|
|
|
void clearChildNodes();
|
|
|
|
QString ensembleDescription() const;
|
|
|
|
protected:
|
|
caf::PdmChildArrayField<RimSummaryCase*> m_cases;
|
|
caf::PdmField<QString> m_name;
|
|
caf::PdmField<bool> m_includeInAutoReload;
|
|
|
|
private:
|
|
caf::PdmField<QString> m_nameTemplateString;
|
|
caf::PdmField<bool> m_autoName;
|
|
caf::PdmField<bool> m_useKey1;
|
|
caf::PdmField<bool> m_useKey2;
|
|
caf::PdmProxyValueField<QString> m_ensembleDescription;
|
|
|
|
caf::PdmField<caf::AppEnum<RiaDefines::EnsembleGroupingMode>> m_groupingMode;
|
|
|
|
caf::PdmProxyValueField<QString> m_nameAndItemCount;
|
|
caf::PdmField<bool> m_isEnsemble;
|
|
caf::PdmChildField<RimSummaryAddressCollection*> m_dataVectorFolders;
|
|
|
|
caf::PdmChildField<RimSummaryEnsembleParameterCollection*> m_ensembleParameters;
|
|
|
|
caf::PdmField<int> m_ensembleId;
|
|
|
|
mutable std::vector<RigEnsembleParameter> m_cachedSortedEnsembleParameters;
|
|
std::unique_ptr<RiaSummaryAddressAnalyzer> m_analyzer;
|
|
|
|
std::map<RifEclipseSummaryAddress, std::pair<double, double>> m_minMaxValues;
|
|
};
|