mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Moved creation of placeholder results to to RimCase
This commit is contained in:
parent
f61f7f1fd1
commit
e4e3cca05f
@ -539,3 +539,26 @@ QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNew
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCase::openReserviorCase()
|
||||
{
|
||||
if (!openEclipseGridFile())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::MATRIX_RESULTS);
|
||||
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
|
||||
|
||||
}
|
||||
{
|
||||
RimReservoirCellResultsStorage* results = this->results(RifReaderInterface::FRACTURE_RESULTS);
|
||||
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ public:
|
||||
caf::PdmField<std::vector<QString> > filesContainingFaults;
|
||||
|
||||
|
||||
virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that.
|
||||
bool openReserviorCase();
|
||||
virtual bool openEclipseGridFile() { return false; }; // Should be pure virtual but PDM does not allow that.
|
||||
|
||||
RigCaseData* reservoirData();
|
||||
const RigCaseData* reservoirData() const;
|
||||
|
@ -226,24 +226,12 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefi
|
||||
if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL")
|
||||
{
|
||||
size_t soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
|
||||
|
||||
// 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)
|
||||
if (!isDataPresent(soilScalarResultIndex))
|
||||
{
|
||||
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;
|
||||
}
|
||||
return soilScalarResultIndex;
|
||||
}
|
||||
|
||||
size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
|
||||
@ -305,14 +293,24 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result
|
||||
size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName);
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
// If we have any results on any timestep, assume we have loaded results already
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < m_cellResults->timeStepCount(scalarResultIndex); ++tsIdx)
|
||||
// If we have any results on any time step, assume we have loaded results already
|
||||
if (isDataPresent(scalarResultIndex))
|
||||
{
|
||||
if (m_cellResults->cellScalarResults(scalarResultIndex, tsIdx).size())
|
||||
return scalarResultIndex;
|
||||
}
|
||||
|
||||
if (resultName == "SOIL")
|
||||
{
|
||||
// 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");
|
||||
|
||||
for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++)
|
||||
{
|
||||
return scalarResultIndex;
|
||||
computeSOILForTimeStep(timeStepIdx);
|
||||
}
|
||||
|
||||
return scalarResultIndex;
|
||||
}
|
||||
|
||||
if (type == RimDefines::GENERATED)
|
||||
@ -362,25 +360,6 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result
|
||||
return scalarResultIndex;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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++)
|
||||
{
|
||||
computeSOILForTimeStep(timeStepIdx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -422,21 +401,18 @@ void RimReservoirCellResultsStorage::computeSOILForTimeStep(size_t timeStepIndex
|
||||
}
|
||||
}
|
||||
|
||||
size_t soilResultScalarIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
|
||||
if (soilResultScalarIndex == cvf::UNDEFINED_SIZE_T)
|
||||
size_t soilResultScalarIndex = m_cellResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SOIL");
|
||||
if (m_cellResults->cellScalarResults(soilResultScalarIndex, timeStepIndex).size() == 0)
|
||||
{
|
||||
soilResultScalarIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false);
|
||||
CVF_ASSERT(soilResultScalarIndex != cvf::UNDEFINED_SIZE_T);
|
||||
// // Set this result to be calculated
|
||||
// m_cellResults->setMustBeCalculated(soilResultScalarIndex);
|
||||
//
|
||||
// m_cellResults->cellScalarResults(soilResultScalarIndex).resize(soilTimeStepCount);
|
||||
|
||||
// Set this result to be calculated
|
||||
m_cellResults->setMustBeCalculated(soilResultScalarIndex);
|
||||
|
||||
m_cellResults->cellScalarResults(soilResultScalarIndex).resize(soilTimeStepCount);
|
||||
|
||||
for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++)
|
||||
{
|
||||
m_cellResults->cellScalarResults(soilResultScalarIndex, timeStepIdx).resize(soilResultValueCount);
|
||||
}
|
||||
// for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++)
|
||||
// {
|
||||
m_cellResults->cellScalarResults(soilResultScalarIndex, timeStepIndex).resize(soilResultValueCount);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -720,6 +696,29 @@ size_t RimReservoirCellResultsStorage::storedResultsCount()
|
||||
return m_resultCacheMetaData.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimReservoirCellResultsStorage::isDataPresent(size_t scalarResultIndex) const
|
||||
{
|
||||
if (scalarResultIndex >= m_cellResults->resultCount())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector< std::vector<double> > data = m_cellResults->cellScalarResults(scalarResultIndex);
|
||||
|
||||
for (size_t tsIdx = 0; tsIdx < data.size(); ++tsIdx)
|
||||
{
|
||||
if (data[tsIdx].size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorageEntryInfo, "ResultStorageEntryInfo");
|
||||
|
@ -52,8 +52,8 @@ public:
|
||||
void setReaderInterface(RifReaderInterface* readerInterface);
|
||||
RifReaderInterface* readerInterface();
|
||||
|
||||
void loadOrComputeSOIL();
|
||||
void computeDepthRelatedResults();
|
||||
bool isDataPresent(size_t scalarResultIndex) const;
|
||||
|
||||
size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex);
|
||||
size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName);
|
||||
@ -65,6 +65,7 @@ protected:
|
||||
|
||||
private:
|
||||
void computeSOILForTimeStep(size_t timeStepIndex);
|
||||
void computeSOILForAllTimeStep();
|
||||
|
||||
QString getValidCacheFileName();
|
||||
QString getCacheDirectoryPath();
|
||||
|
@ -905,7 +905,7 @@ void RimReservoirView::loadDataAndUpdate()
|
||||
|
||||
if (m_reservoir)
|
||||
{
|
||||
if (!m_reservoir->openEclipseGridFile())
|
||||
if (!m_reservoir->openReserviorCase())
|
||||
{
|
||||
QMessageBox::warning(RiuMainWindow::instance(),
|
||||
"Error when opening project file",
|
||||
@ -913,30 +913,6 @@ void RimReservoirView::loadDataAndUpdate()
|
||||
m_reservoir = NULL;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
{
|
||||
RimReservoirCellResultsStorage* results = m_reservoir->results(RifReaderInterface::MATRIX_RESULTS);
|
||||
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
|
||||
|
||||
if (app->preferences()->autocomputeSOIL)
|
||||
{
|
||||
results->loadOrComputeSOIL();
|
||||
}
|
||||
}
|
||||
{
|
||||
RimReservoirCellResultsStorage* results = m_reservoir->results(RifReaderInterface::FRACTURE_RESULTS);
|
||||
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
|
||||
|
||||
if (app->preferences()->autocomputeSOIL)
|
||||
{
|
||||
results->loadOrComputeSOIL();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(this->cellResult() != NULL);
|
||||
|
@ -512,6 +512,20 @@ void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::createPlaceholderResultEntries()
|
||||
{
|
||||
{
|
||||
size_t soilIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "SOIL");
|
||||
if (soilIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
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)
|
||||
{
|
||||
addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
size_t combinedTransmissibilityIndex = findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::combinedTransmissibilityResultName());
|
||||
if (combinedTransmissibilityIndex == cvf::UNDEFINED_SIZE_T)
|
||||
|
Loading…
Reference in New Issue
Block a user