mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Bugfix: Get pointer to data after adding data to std vector
When SOIL is created, a new dataset is appended to a std vector. Pointer to SWAT and SGAS data must be aquired AFTER the new dataset is added. Adding data to a vector can trigger reallocation of data.
This commit is contained in:
parent
3608c36291
commit
585f034799
@ -56,7 +56,7 @@ CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage"
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RimReservoirCellResultsStorage::RimReservoirCellResultsStorage()
|
RimReservoirCellResultsStorage::RimReservoirCellResultsStorage()
|
||||||
: m_cellResults(NULL),
|
: m_cellResults(NULL),
|
||||||
m_ownerMainGrid(NULL)
|
m_ownerMainGrid(NULL)
|
||||||
{
|
{
|
||||||
CAF_PDM_InitObject("Cacher", "", "", "");
|
CAF_PDM_InitObject("Cacher", "", "", "");
|
||||||
|
|
||||||
@ -419,32 +419,22 @@ void RimReservoirCellResultsStorage::computeSOILForTimeStep(size_t timeStepIndex
|
|||||||
size_t soilResultValueCount = 0;
|
size_t soilResultValueCount = 0;
|
||||||
size_t soilTimeStepCount = 0;
|
size_t soilTimeStepCount = 0;
|
||||||
|
|
||||||
std::vector<double>* swatForTimeStep = NULL;
|
|
||||||
std::vector<double>* sgasForTimeStep = NULL;
|
|
||||||
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
|
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
swatForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSWAT, timeStepIndex));
|
std::vector<double>& swatForTimeStep = m_cellResults->cellScalarResults(scalarIndexSWAT, timeStepIndex);
|
||||||
if (swatForTimeStep->size() == 0)
|
if (swatForTimeStep.size() > 0)
|
||||||
{
|
{
|
||||||
swatForTimeStep = NULL;
|
soilResultValueCount = swatForTimeStep.size();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
soilResultValueCount = swatForTimeStep->size();
|
|
||||||
soilTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSWAT].m_timeStepDates.size();
|
soilTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSWAT].m_timeStepDates.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
|
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
sgasForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSGAS, timeStepIndex));
|
std::vector<double>& sgasForTimeStep = m_cellResults->cellScalarResults(scalarIndexSGAS, timeStepIndex);
|
||||||
if (sgasForTimeStep->size() == 0)
|
if (sgasForTimeStep.size() > 0)
|
||||||
{
|
{
|
||||||
sgasForTimeStep = NULL;
|
soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep.size());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep->size());
|
|
||||||
|
|
||||||
size_t sgasTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSGAS].m_timeStepDates.size();
|
size_t sgasTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSGAS].m_timeStepDates.size();
|
||||||
soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount);
|
soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount);
|
||||||
@ -468,6 +458,28 @@ void RimReservoirCellResultsStorage::computeSOILForTimeStep(size_t timeStepIndex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<double>* swatForTimeStep = NULL;
|
||||||
|
std::vector<double>* sgasForTimeStep = NULL;
|
||||||
|
|
||||||
|
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
|
||||||
|
{
|
||||||
|
swatForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSWAT, timeStepIndex));
|
||||||
|
if (swatForTimeStep->size() == 0)
|
||||||
|
{
|
||||||
|
swatForTimeStep = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
|
||||||
|
{
|
||||||
|
sgasForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSGAS, timeStepIndex));
|
||||||
|
if (sgasForTimeStep->size() == 0)
|
||||||
|
{
|
||||||
|
sgasForTimeStep = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<double>& soilForTimeStep = m_cellResults->cellScalarResults(soilResultGridIndex, timeStepIndex);
|
std::vector<double>& soilForTimeStep = m_cellResults->cellScalarResults(soilResultGridIndex, timeStepIndex);
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
@ -514,7 +526,7 @@ void RimReservoirCellResultsStorage::computeDepthRelatedResults()
|
|||||||
|
|
||||||
if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T)
|
if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T)
|
||||||
{
|
{
|
||||||
depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", false, resultValueCount);
|
depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", false, resultValueCount);
|
||||||
computeDepth = true;
|
computeDepth = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user