Bugfix : Do not compute SOIL if present on disk

This commit is contained in:
Magne Sjaastad
2014-08-28 10:35:05 +02:00
parent 103a9f4018
commit b7bc732b32
2 changed files with 37 additions and 20 deletions

View File

@@ -332,20 +332,26 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result
if (resultName == "SOIL") if (resultName == "SOIL")
{ {
// Trigger loading of SWAT, SGAS to establish time step count if no data has been loaded from file at this point if (m_cellResults->mustBeCalculated(scalarResultIndex))
findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++)
{ {
computeSOILForTimeStep(timeStepIdx); // Trigger loading of SWAT, SGAS to establish time step count if no data has been loaded from file at this point
findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
m_cellResults->cellScalarResults(scalarResultIndex).resize(m_cellResults->maxTimeStepCount());
for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++)
{
std::vector<double>& values = m_cellResults->cellScalarResults(scalarResultIndex)[timeStepIdx];
if (values.size() == 0)
{
computeSOILForTimeStep(timeStepIdx);
}
}
return scalarResultIndex;
} }
return scalarResultIndex;
} }
if (type == RimDefines::GENERATED) if (type == RimDefines::GENERATED)
{ {
return cvf::UNDEFINED_SIZE_T; return cvf::UNDEFINED_SIZE_T;
@@ -405,11 +411,17 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefi
if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL")
{ {
size_t soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); size_t soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
{
computeSOILForTimeStep(timeStepIndex);
}
return soilScalarResultIndex; if (m_cellResults->mustBeCalculated(soilScalarResultIndex))
{
std::vector<double>& values = m_cellResults->cellScalarResults(soilScalarResultIndex)[timeStepIndex];
if (values.size() == 0)
{
computeSOILForTimeStep(timeStepIndex);
}
return soilScalarResultIndex;
}
} }
size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
@@ -552,7 +564,7 @@ void RimReservoirCellResultsStorage::computeSOILForTimeStep(size_t timeStepIndex
soilValue -= swatForTimeStep->at(idx); soilValue -= swatForTimeStep->at(idx);
} }
soilForTimeStep[idx] = soilValue; soilForTimeStep[idx] = cvf::Math::clamp(soilValue, 0.0, 1.0);
} }
} }

View File

@@ -522,12 +522,17 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
{ {
// SOIL // SOIL
{ {
size_t swatIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SWAT"); size_t soilIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SOIL");
size_t sgasIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SGAS"); if (soilIndex == cvf::UNDEFINED_SIZE_T)
if (swatIndex != cvf::UNDEFINED_SIZE_T || sgasIndex != cvf::UNDEFINED_SIZE_T)
{ {
addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false); size_t swatIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SWAT");
size_t sgasIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SGAS");
if (swatIndex != cvf::UNDEFINED_SIZE_T || sgasIndex != cvf::UNDEFINED_SIZE_T)
{
soilIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false);
this->setMustBeCalculated(soilIndex);
}
} }
} }