mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 23:50:19 -05: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().
104 lines
3.9 KiB
C++
104 lines
3.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 "RimDeltaSummaryCase.h"
|
|
#include "RimSummaryEnsemble.h"
|
|
|
|
#include "cafPdmChildArrayField.h"
|
|
#include "cafPdmField.h"
|
|
#include "cafPdmObject.h"
|
|
#include "cafPdmProxyValueField.h"
|
|
#include "cafPdmPtrField.h"
|
|
|
|
#include <vector>
|
|
|
|
class RimSummaryCase;
|
|
|
|
//==================================================================================================
|
|
///
|
|
//==================================================================================================
|
|
class RimDeltaSummaryEnsemble : public RimSummaryEnsemble
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
enum class FixedTimeStepMode
|
|
{
|
|
FIXED_TIME_STEP_NONE,
|
|
FIXED_TIME_STEP_CASE_1,
|
|
FIXED_TIME_STEP_CASE_2
|
|
};
|
|
|
|
public:
|
|
RimDeltaSummaryEnsemble();
|
|
~RimDeltaSummaryEnsemble() override;
|
|
|
|
void setEnsemble1( RimSummaryEnsemble* ensemble );
|
|
void setEnsemble2( RimSummaryEnsemble* ensemble );
|
|
|
|
std::set<RifEclipseSummaryAddress> ensembleSummaryAddresses() const override;
|
|
|
|
bool hasCaseReference( const RimSummaryCase* sumCase ) const;
|
|
|
|
void onLoadDataAndUpdate() override;
|
|
|
|
void onSourceEnsembleChanged();
|
|
void createDerivedEnsembleCases();
|
|
|
|
std::vector<std::pair<RimSummaryCase*, RimSummaryCase*>> desiredSourceCasePairs() const;
|
|
|
|
// Detaches and returns the derived cases no longer backed by a source case pair. The caller owns them.
|
|
[[nodiscard]] std::vector<RimDeltaSummaryCase*> rebuildDerivedCases();
|
|
|
|
std::vector<RimDeltaSummaryCase*> allDerivedCases() const;
|
|
|
|
bool discardMissingOrIncompleteRealizations() const;
|
|
|
|
std::pair<std::string, std::string> nameKeys() const override;
|
|
QString nameTemplateText() const override;
|
|
|
|
private:
|
|
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
|
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
|
|
|
void onSwapEnsemblesButtonClicked();
|
|
|
|
void updateDerivedEnsembleCases();
|
|
bool isValid() const;
|
|
|
|
static RimSummaryCase* findCaseByParametersHash( const std::vector<RimSummaryCase*>& cases, size_t hash );
|
|
static RimSummaryCase* findCaseByRealizationNumber( const std::vector<RimSummaryCase*>& cases, int realizationNumber );
|
|
|
|
std::vector<RimSummaryEnsemble*> allEnsembles() const;
|
|
|
|
private:
|
|
caf::PdmPtrField<RimSummaryEnsemble*> m_ensemble1;
|
|
caf::PdmPtrField<RimSummaryEnsemble*> m_ensemble2;
|
|
caf::PdmField<caf::AppEnum<DerivedSummaryOperator>> m_operator;
|
|
caf::PdmField<QString> m_caseCount;
|
|
caf::PdmField<bool> m_matchOnParameters;
|
|
caf::PdmField<bool> m_discardMissingOrIncompleteRealizations;
|
|
|
|
caf::PdmField<caf::AppEnum<FixedTimeStepMode>> m_useFixedTimeStep;
|
|
caf::PdmField<int> m_fixedTimeStepIndex;
|
|
};
|