mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-10 08:03:05 -06:00
Fixed issue related to computation of SOIL. Mark metadata for derived SOIL with mustBeCalculated.
p4#: 21220
This commit is contained in:
parent
de56495c13
commit
927fa6c5e7
@ -217,13 +217,31 @@ RifReaderInterface* RimReservoirCellResultsStorage::readerInterface()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex)
|
||||
{
|
||||
if (!m_cellResults) return cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
// Special handling for SOIL
|
||||
if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL")
|
||||
{
|
||||
loadOrComputeSOILForTimeStep(timeStepIndex);
|
||||
}
|
||||
size_t soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
|
||||
|
||||
if (!m_cellResults) return cvf::UNDEFINED_SIZE_T;
|
||||
// If SOIL is not found, try to compute and return computed scalar index
|
||||
// Will return cvf::UNDEFINED_SIZE_T if no SGAS/SWAT is found
|
||||
if (soilScalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
computeSOILForTimeStep(timeStepIndex);
|
||||
|
||||
soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
|
||||
return soilScalarResultIndex;
|
||||
}
|
||||
|
||||
// If we have found SOIL and SOIL must be calculated, calculate and return
|
||||
if (soilScalarResultIndex != cvf::UNDEFINED_SIZE_T && m_cellResults->mustBeCalculated(soilScalarResultIndex))
|
||||
{
|
||||
computeSOILForTimeStep(timeStepIndex);
|
||||
|
||||
return soilScalarResultIndex;
|
||||
}
|
||||
}
|
||||
|
||||
size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
|
||||
@ -341,14 +359,21 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result
|
||||
return resultGridIndex;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoirCellResultsStorage::loadOrComputeSOIL()
|
||||
{
|
||||
size_t scalarIndexSOIL = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
|
||||
if (scalarIndexSOIL != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++)
|
||||
{
|
||||
loadOrComputeSOILForTimeStep(timeStepIdx);
|
||||
computeSOILForTimeStep(timeStepIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +381,7 @@ void RimReservoirCellResultsStorage::loadOrComputeSOIL()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeStepIndex)
|
||||
void RimReservoirCellResultsStorage::computeSOILForTimeStep(size_t timeStepIndex)
|
||||
{
|
||||
size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex);
|
||||
size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex);
|
||||
@ -410,6 +435,9 @@ void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeSte
|
||||
soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false);
|
||||
CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T);
|
||||
|
||||
// Set this result to be calculated
|
||||
m_cellResults->setMustBeCalculated(soilResultGridIndex);
|
||||
|
||||
m_cellResults->cellScalarResults(soilResultGridIndex).resize(soilTimeStepCount);
|
||||
|
||||
for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++)
|
||||
|
@ -59,7 +59,7 @@ protected:
|
||||
virtual void setupBeforeSave();
|
||||
|
||||
private:
|
||||
void loadOrComputeSOILForTimeStep(size_t timeStepIndex);
|
||||
void computeSOILForTimeStep(size_t timeStepIndex);
|
||||
|
||||
QString getValidCacheFileName();
|
||||
QString getCacheDirectoryPath();
|
||||
|
@ -350,7 +350,7 @@ size_t RigCaseCellResultsData::addEmptyScalarResult(RimDefines::ResultCatType ty
|
||||
{
|
||||
scalarResultIndex = this->resultCount();
|
||||
m_cellScalarResults.push_back(std::vector<std::vector<double> >());
|
||||
ResultInfo resInfo(type, needsToBeStored, resultName, scalarResultIndex);
|
||||
ResultInfo resInfo(type, needsToBeStored, false, resultName, scalarResultIndex);
|
||||
m_resultInfos.push_back(resInfo);
|
||||
}
|
||||
|
||||
@ -540,3 +540,35 @@ RifReaderInterface::PorosityModelResultType RigCaseCellResultsData::convertFromP
|
||||
return RifReaderInterface::FRACTURE_RESULTS;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigCaseCellResultsData::mustBeCalculated(size_t scalarResultIndex) const
|
||||
{
|
||||
std::vector<ResultInfo>::const_iterator it;
|
||||
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
|
||||
{
|
||||
if (it->m_gridScalarResultIndex == scalarResultIndex)
|
||||
{
|
||||
return it->m_mustBeCalculated;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex)
|
||||
{
|
||||
std::vector<ResultInfo>::iterator it;
|
||||
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++)
|
||||
{
|
||||
if (it->m_gridScalarResultIndex == scalarResultIndex)
|
||||
{
|
||||
it->m_mustBeCalculated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,18 +80,23 @@ public:
|
||||
class ResultInfo
|
||||
{
|
||||
public:
|
||||
ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, QString resultName, size_t gridScalarResultIndex)
|
||||
: m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { }
|
||||
ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, bool mustBeCalculated, QString resultName, size_t gridScalarResultIndex)
|
||||
: m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex), m_mustBeCalculated(mustBeCalculated) { }
|
||||
|
||||
public:
|
||||
RimDefines::ResultCatType m_resultType;
|
||||
bool m_needsToBeStored;
|
||||
bool m_mustBeCalculated;
|
||||
QString m_resultName;
|
||||
size_t m_gridScalarResultIndex;
|
||||
std::vector<QDateTime> m_timeStepDates;
|
||||
};
|
||||
|
||||
const std::vector<ResultInfo>& infoForEachResultIndex() { return m_resultInfos;}
|
||||
|
||||
bool mustBeCalculated(size_t scalarResultIndex) const;
|
||||
void setMustBeCalculated(size_t scalarResultIndex);
|
||||
|
||||
|
||||
public:
|
||||
size_t addStaticScalarResult(RimDefines::ResultCatType type,
|
||||
|
Loading…
Reference in New Issue
Block a user