#1692 Put SourSimRL Results in a separate result type

#1693 Started to separate code for SourSim and Eclipse results data.
This commit is contained in:
Jacob Støren
2017-07-07 13:31:14 +02:00
parent b81c332e60
commit ec4362b247
11 changed files with 125 additions and 55 deletions

View File

@@ -533,9 +533,8 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
for (int i = 0; i < resultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, resultNames[i], false);
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::SOURSIMRL, resultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, m_daysSinceSimulationStart, reportNumbers);
matrixModelResults->setSourSimData(resIndex);
}
m_hdfReaderInterface = std::move(myReader);
@@ -974,43 +973,48 @@ bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelRe
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::sourSimRlResult(const QString& result, size_t stepIndex, std::vector<double>* values)
{
values->clear();
if ( !m_hdfReaderInterface ) return;
if ( m_eclipseCase->mainGrid()->gridCount() == 0 )
{
RiaLogging::error("No grids available");
return ;
}
size_t activeCellCount = cvf::UNDEFINED_SIZE_T;
{
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
fracActCellInfo->gridActiveCellCounts(0, activeCellCount);
}
bool readCellResultOk = m_hdfReaderInterface->dynamicResult(result, stepIndex, values);
if (activeCellCount != values->size())
{
values->clear();
RiaLogging::error("SourSimRL results does not match the number of active cells in the grid");
return;
}
}
//--------------------------------------------------------------------------------------------------
/// Get dynamic result at given step index. Will concatenate values for the main grid and all sub grids.
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
bool RifReaderEclipseOutput::dynamicResult(const QString& result,
PorosityModelResultType matrixOrFracture,
size_t stepIndex,
std::vector<double>* values)
{
#ifdef USE_HDF5
if (m_hdfReaderInterface)
{
if (m_eclipseCase->mainGrid()->gridCount() == 0)
{
RiaLogging::error("No grids available");
return false;
}
size_t activeCellCount = cvf::UNDEFINED_SIZE_T;
{
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
fracActCellInfo->gridActiveCellCounts(0, activeCellCount);
}
bool readCellResultOk = m_hdfReaderInterface->dynamicResult(result, stepIndex, values);
if (activeCellCount != values->size())
{
for (size_t i=0; i < values->size(); i++)
{
values->at(i) = HUGE_VAL;
}
RiaLogging::error("No grids available");
return false;
}
return readCellResultOk;
}
#endif
if (m_dynamicResultsAccess.isNull())
{

View File

@@ -62,6 +62,7 @@ public:
bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values);
bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values);
void sourSimRlResult(const QString& result, size_t stepIndex, std::vector<double>* values);
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase);
static void transferCoarseningInfo(const ecl_grid_type* eclGrid, RigGridBase* grid);

View File

@@ -29,6 +29,7 @@ namespace caf
{
addItem(RimDefines::DYNAMIC_NATIVE, "DYNAMIC_NATIVE", "Dynamic");
addItem(RimDefines::STATIC_NATIVE, "STATIC_NATIVE", "Static");
addItem(RimDefines::SOURSIMRL, "SOURSIMRL", "SourSimRL");
addItem(RimDefines::GENERATED, "GENERATED", "Generated");
addItem(RimDefines::INPUT_PROPERTY, "INPUT_PROPERTY", "Input Property");
addItem(RimDefines::FORMATION_NAMES, "FORMATION_NAMES", "Formation Names");

View File

@@ -30,6 +30,7 @@ public:
{
DYNAMIC_NATIVE,
STATIC_NATIVE,
SOURSIMRL,
GENERATED,
INPUT_PROPERTY,
FORMATION_NAMES,

View File

@@ -464,6 +464,14 @@ void RimEclipseResultCase::setSourSimFileName(const QString& fileName)
loadAndUpdateSourSimData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultCase::hasSourSimFile()
{
return !m_sourSimFileName().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -43,6 +43,7 @@ public:
void setGridFileName(const QString& caseFileName);
void setCaseInfo(const QString& userDescription, const QString& caseFileName);
void setSourSimFileName(const QString& fileName);
bool hasSourSimFile();
virtual bool openEclipseGridFile();
virtual void reloadEclipseGridFile();

View File

@@ -422,33 +422,41 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
if ( fieldNeedingOptions == &m_resultTypeUiField )
{
bool hasFlowDiagFluxes = false;
bool hasSourSimRLFile = false;
RimEclipseResultCase* eclResCase = dynamic_cast<RimEclipseResultCase*>(m_eclipseCase.p());
if ( eclResCase && eclResCase->eclipseCaseData() )
{
hasFlowDiagFluxes = eclResCase->eclipseCaseData()->results(RifReaderInterface::MATRIX_RESULTS)->hasFlowDiagUsableFluxes();
hasSourSimRLFile = eclResCase->hasSourSimFile();
}
RimGridTimeHistoryCurve* timeHistoryCurve;
this->firstAncestorOrThisOfType(timeHistoryCurve);
// Do not include flow diagnostics results if not available or is a time history curve
if ( !hasFlowDiagFluxes || timeHistoryCurve != nullptr )
if ( !hasFlowDiagFluxes || timeHistoryCurve != nullptr || !hasSourSimRLFile)
{
using ResCatEnum = caf::AppEnum< RimDefines::ResultCatType >;
for ( size_t i = 0; i < ResCatEnum::size(); ++i )
{
RimDefines::ResultCatType resType = ResCatEnum::fromIndex(i);
if ( resType != RimDefines::FLOW_DIAGNOSTICS )
if ( resType == RimDefines::FLOW_DIAGNOSTICS
&& (!hasFlowDiagFluxes || timeHistoryCurve) )
{
QString uiString = ResCatEnum::uiTextFromIndex(i);
options.push_back(caf::PdmOptionItemInfo(uiString, resType));
continue;
}
if ( resType == RimDefines::SOURSIMRL
&& (!hasSourSimRLFile ) )
{
continue;
}
QString uiString = ResCatEnum::uiTextFromIndex(i);
options.push_back(caf::PdmOptionItemInfo(uiString, resType));
}
}
else
{
// Do nothing, and thereby use the defaults of the AppEnum field
}
}
if ( m_resultTypeUiField() != RimDefines::FLOW_DIAGNOSTICS )
@@ -857,6 +865,10 @@ bool RimEclipseResultDefinition::hasDynamicResult() const
{
return true;
}
else if (m_resultType() == RimDefines::SOURSIMRL)
{
return true;
}
else if (m_resultType() == RimDefines::FLOW_DIAGNOSTICS)
{
return true;

View File

@@ -38,6 +38,7 @@
#include <QFile>
#include <QFileInfo>
#include <QUuid>
#include "RifReaderEclipseOutput.h"
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage");
@@ -240,6 +241,11 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& res
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findOrLoadScalarResult(RimDefines::SOURSIMRL, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = m_cellResults->findScalarResultIndex(RimDefines::GENERATED, resultName);
@@ -418,6 +424,26 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result
}
}
// Handle SourSimRL reading
if (type == RimDefines::SOURSIMRL)
{
RifReaderEclipseOutput* eclReader = dynamic_cast<RifReaderEclipseOutput*>(m_readerInterface.p());
if (eclReader)
{
size_t timeStepCount = m_cellResults->infoForEachResultIndex()[scalarResultIndex].m_timeStepDates.size();
m_cellResults->cellScalarResults(scalarResultIndex).resize(timeStepCount);
size_t i;
for ( i = 0; i < timeStepCount; i++ )
{
std::vector<double>& values = m_cellResults->cellScalarResults(scalarResultIndex)[i];
eclReader->sourSimRlResult(resultName, i, &values);
}
}
}
return scalarResultIndex;
}
@@ -493,6 +519,26 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefi
}
}
// Handle SourSimRL reading
if (type == RimDefines::SOURSIMRL)
{
RifReaderEclipseOutput* eclReader = dynamic_cast<RifReaderEclipseOutput*>(m_readerInterface.p());
if (eclReader)
{
size_t timeStepCount = m_cellResults->infoForEachResultIndex()[scalarResultIndex].m_timeStepDates.size();
m_cellResults->cellScalarResults(scalarResultIndex).resize(timeStepCount);
std::vector<double>& values = m_cellResults->cellScalarResults(scalarResultIndex)[timeStepIndex];
if ( values.size() == 0)
{
eclReader->sourSimRlResult(resultName, timeStepIndex, &values);
}
}
}
return scalarResultIndex;
}

View File

@@ -229,6 +229,11 @@ size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName)
scalarResultIndex = this->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::SOURSIMRL, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RimDefines::GENERATED, resultName);
@@ -670,16 +675,6 @@ void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::setSourSimData(size_t scalarResultIndex)
{
CVF_ASSERT(scalarResultIndex < m_resultInfos.size());
m_resultInfos[scalarResultIndex].m_isSourSimData = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -690,7 +685,7 @@ void RigCaseCellResultsData::eraseAllSourSimData()
for (size_t i = 0; i < m_resultInfos.size(); i++)
{
ResultInfo& ri = m_resultInfos[i];
if (ri.m_isSourSimData)
if (ri.m_resultType == RimDefines::SOURSIMRL)
{
ri.m_resultType = RimDefines::REMOVED;
}

View File

@@ -135,7 +135,6 @@ public:
bool mustBeCalculated(size_t scalarResultIndex) const;
void setMustBeCalculated(size_t scalarResultIndex);
void setSourSimData(size_t scalarResultIndex);
void eraseAllSourSimData();

View File

@@ -1108,6 +1108,8 @@ public:
std::vector<QString> resTypeNames;
resTypes.push_back(RimDefines::DYNAMIC_NATIVE);
resTypeNames.push_back("DynamicNative");
resTypes.push_back(RimDefines::SOURSIMRL);
resTypeNames.push_back("SourSimRL");
resTypes.push_back(RimDefines::STATIC_NATIVE );
resTypeNames.push_back("StaticNative");
resTypes.push_back(RimDefines::GENERATED );