mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
riGetActiveCellProperty: Fix for input properties
Only read values for active cells if we have result values for all cells
This commit is contained in:
parent
a37b9f6ea2
commit
7faf950dc7
@ -62,7 +62,8 @@ size_t findOrCreateResult(const QString& newResultName, RigCaseData* reservoir)
|
|||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Read all double values from input file. To reduce memory footprint, the alternative method
|
||||||
|
/// readDoubleValuesForActiveCells() can be used, and will skip all cell values for inactive cells
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool readDoubleValues(RigCaseData* reservoir, size_t resultIndex, ecl_kw_type* eclKeyWordData)
|
bool readDoubleValues(RigCaseData* reservoir, size_t resultIndex, ecl_kw_type* eclKeyWordData)
|
||||||
{
|
{
|
||||||
@ -74,6 +75,43 @@ bool readDoubleValues(RigCaseData* reservoir, size_t resultIndex, ecl_kw_type* e
|
|||||||
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
|
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool readDoubleValuesForActiveCells(RigCaseData* reservoir, size_t resultIndex, ecl_kw_type* eclKeyWordData)
|
||||||
|
{
|
||||||
|
if (resultIndex == cvf::UNDEFINED_SIZE_T) return false;
|
||||||
|
|
||||||
|
std::vector< std::vector<double> >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
|
||||||
|
newPropertyData.push_back(std::vector<double>());
|
||||||
|
|
||||||
|
RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
|
||||||
|
if (activeCellInfo->globalCellCount() > 0 && activeCellInfo->globalCellCount() != activeCellInfo->globalActiveCellCount())
|
||||||
|
{
|
||||||
|
std::vector<double> valuesAllCells;
|
||||||
|
valuesAllCells.resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
|
||||||
|
ecl_kw_get_data_as_double(eclKeyWordData, valuesAllCells.data());
|
||||||
|
|
||||||
|
newPropertyData[0].resize(activeCellInfo->globalActiveCellCount(), HUGE_VAL);
|
||||||
|
std::vector<double>& valuesActiveCells = newPropertyData[0];
|
||||||
|
|
||||||
|
size_t acIdx = 0;
|
||||||
|
for (size_t gcIdx = 0; gcIdx < activeCellInfo->globalCellCount(); gcIdx++)
|
||||||
|
{
|
||||||
|
size_t activeCellResultIndex = activeCellInfo->cellResultIndex(gcIdx);
|
||||||
|
if (activeCellResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||||
|
{
|
||||||
|
valuesActiveCells[activeCellResultIndex] = valuesAllCells[gcIdx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL);
|
||||||
|
ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -153,30 +153,42 @@ public:
|
|||||||
size_t globalCellCount = activeInfo->globalCellCount();
|
size_t globalCellCount = activeInfo->globalCellCount();
|
||||||
for (size_t tIdx = 0; tIdx < requestedTimesteps.size(); ++tIdx)
|
for (size_t tIdx = 0; tIdx < requestedTimesteps.size(); ++tIdx)
|
||||||
{
|
{
|
||||||
|
std::vector<double>& doubleValues = scalarResultFrames->at(requestedTimesteps[tIdx]);
|
||||||
for (size_t gcIdx = 0; gcIdx < globalCellCount; ++gcIdx)
|
for (size_t gcIdx = 0; gcIdx < globalCellCount; ++gcIdx)
|
||||||
{
|
{
|
||||||
size_t resultIdx = activeInfo->cellResultIndex(gcIdx);
|
size_t resultIdx = activeInfo->cellResultIndex(gcIdx);
|
||||||
if (resultIdx != cvf::UNDEFINED_SIZE_T)
|
if (resultIdx == cvf::UNDEFINED_SIZE_T) continue;
|
||||||
|
|
||||||
|
if (resultIdx < doubleValues.size())
|
||||||
{
|
{
|
||||||
if (resultIdx < scalarResultFrames->at(requestedTimesteps[tIdx]).size())
|
if (doubleValues.size() == activeInfo->globalCellCount())
|
||||||
{
|
{
|
||||||
values[valueIndex] = scalarResultFrames->at(requestedTimesteps[tIdx])[resultIdx];
|
// When reading data from input text files, result data is read for all grid cells
|
||||||
|
// Read out values from data vector using global cell index instead of active cell result index
|
||||||
|
// When data is written back to ResInsight using RiaSetActiveCellProperty, the resulting
|
||||||
|
// data vector will have activeCellCount data values, which is potentially smaller
|
||||||
|
// than total number of cells
|
||||||
|
values[valueIndex] = doubleValues[gcIdx];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
values[valueIndex] = HUGE_VAL;
|
values[valueIndex] = doubleValues[resultIdx];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values[valueIndex] = HUGE_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
valueIndex++;
|
valueIndex++;
|
||||||
if (valueIndex >= valueCount)
|
if (valueIndex >= valueCount)
|
||||||
|
{
|
||||||
|
if (!RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), valueIndex * sizeof(double)))
|
||||||
{
|
{
|
||||||
if (!RiaSocketTools::writeBlockData(server, server->currentClient(), (const char *)values.data(), valueIndex * sizeof(double)))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
valueIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
valueIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user