mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Refactor summary address collection logic into a new utility module, RiaSummaryAddressCollectionTools, with functions for object identification, curve definition generation, duplicate filtering, and address-to-case/ensemble mapping. Update RimSummaryPlot to use these utilities, improving modularity and maintainability. Add comprehensive unit tests for the new module. Adds test for mock summary case
66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "RifSummaryReaderInterface.h"
|
|
#include "RimSummaryCase.h"
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class RimMockSummaryCase : public RimSummaryCase, public RifSummaryReaderInterface
|
|
{
|
|
public:
|
|
void setName( const QString& name ) { m_name = name; }
|
|
|
|
void addVector( const RifEclipseSummaryAddress& address,
|
|
const std::vector<time_t>& timeSteps,
|
|
const std::vector<double>& values,
|
|
const std::string& unit = "" )
|
|
{
|
|
m_data[address] = { timeSteps, values, unit };
|
|
m_allResultAddresses.insert( address );
|
|
}
|
|
|
|
// RimSummaryCase overrides
|
|
void createSummaryReaderInterface() override {}
|
|
RifSummaryReaderInterface* summaryReader() override { return this; }
|
|
QString caseName() const override { return m_name; }
|
|
|
|
// RifSummaryReaderInterface overrides
|
|
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override
|
|
{
|
|
auto it = m_data.find( resultAddress );
|
|
if ( it != m_data.end() ) return it->second.timeSteps;
|
|
return {};
|
|
}
|
|
|
|
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override
|
|
{
|
|
auto it = m_data.find( resultAddress );
|
|
if ( it != m_data.end() ) return { true, it->second.values };
|
|
return { false, {} };
|
|
}
|
|
|
|
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override
|
|
{
|
|
auto it = m_data.find( resultAddress );
|
|
if ( it != m_data.end() ) return it->second.unit;
|
|
return {};
|
|
}
|
|
|
|
RiaDefines::EclipseUnitSystem unitSystem() const override { return RiaDefines::EclipseUnitSystem::UNITS_METRIC; }
|
|
|
|
size_t keywordCount() const override { return m_allResultAddresses.size(); }
|
|
|
|
private:
|
|
struct VectorData
|
|
{
|
|
std::vector<time_t> timeSteps;
|
|
std::vector<double> values;
|
|
std::string unit;
|
|
};
|
|
|
|
QString m_name = "MockCase";
|
|
std::map<RifEclipseSummaryAddress, VectorData> m_data;
|
|
};
|