mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1645 Load dynamic NNC results from restart file
This commit is contained in:
@@ -321,6 +321,30 @@ size_t RigCaseCellResultsData::addEmptyScalarResult(RimDefines::ResultCatType ty
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::STATIC_NATIVE, RimDefines::riAreaNormTranZResultName()));
|
||||
statisticsCalculator = calc;
|
||||
}
|
||||
else if (resultName == RimDefines::combinedWaterFluxResultName())
|
||||
{
|
||||
cvf::ref<RigEclipseMultiPropertyStatCalc> calc = new RigEclipseMultiPropertyStatCalc();
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRWATI+"));
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRWATJ+"));
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRWATK+"));
|
||||
statisticsCalculator = calc;
|
||||
}
|
||||
else if (resultName == RimDefines::combinedOilFluxResultName())
|
||||
{
|
||||
cvf::ref<RigEclipseMultiPropertyStatCalc> calc = new RigEclipseMultiPropertyStatCalc();
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLROILI+"));
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLROILJ+"));
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLROILK+"));
|
||||
statisticsCalculator = calc;
|
||||
}
|
||||
else if (resultName == RimDefines::combinedGasFluxResultName())
|
||||
{
|
||||
cvf::ref<RigEclipseMultiPropertyStatCalc> calc = new RigEclipseMultiPropertyStatCalc();
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRGASI+"));
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRGASJ+"));
|
||||
calc->addNativeStatisticsCalculator(this, findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRGASK+"));
|
||||
statisticsCalculator = calc;
|
||||
}
|
||||
else
|
||||
{
|
||||
statisticsCalculator = new RigEclipseNativeStatCalc(this, scalarResultIndex);
|
||||
@@ -694,6 +718,34 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
|
||||
}
|
||||
}
|
||||
|
||||
// FLUX
|
||||
{
|
||||
size_t waterIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, RimDefines::combinedWaterFluxResultName());
|
||||
if (waterIndex == cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRWATI+") != cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRWATJ+") != cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRWATK+") != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, RimDefines::combinedWaterFluxResultName(), false);
|
||||
}
|
||||
size_t oilIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, RimDefines::combinedOilFluxResultName());
|
||||
if (oilIndex == cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLROILI+") != cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLROILJ+") != cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLROILK+") != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, RimDefines::combinedOilFluxResultName(), false);
|
||||
}
|
||||
size_t gasIndex = findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, RimDefines::combinedGasFluxResultName());
|
||||
if (gasIndex == cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRGASI+") != cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRGASJ+") != cvf::UNDEFINED_SIZE_T &&
|
||||
findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, "FLRGASK+") != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, RimDefines::combinedGasFluxResultName(), false);
|
||||
}
|
||||
}
|
||||
|
||||
// TRANSXYZ
|
||||
{
|
||||
size_t tranX, tranY, tranZ;
|
||||
|
||||
@@ -166,38 +166,92 @@ void RigNNCData::processConnections(const RigMainGrid& mainGrid)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double>& RigNNCData::makeConnectionScalarResult(size_t scalarResultIndex)
|
||||
std::vector<double>& RigNNCData::makeStaticConnectionScalarResult(NNCDataType nncDataType)
|
||||
{
|
||||
std::vector<double>& results = m_connectionResults[scalarResultIndex];
|
||||
results.resize(m_connections.size(), HUGE_VAL);
|
||||
std::vector< std::vector<double> >& results = m_connectionResults[nncDataType];
|
||||
results.resize(1);
|
||||
results[0].resize(m_connections.size(), HUGE_VAL);
|
||||
return results[0];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>* RigNNCData::staticConnectionScalarResult(size_t scalarResultIndex) const
|
||||
{
|
||||
const NNCDataType* nncDataType = getNNCDataTypeFromScalarResultIndex(scalarResultIndex);
|
||||
if (!nncDataType) return nullptr;
|
||||
|
||||
std::map<NNCDataType, std::vector< std::vector<double> > >::const_iterator it = m_connectionResults.find(*nncDataType);
|
||||
|
||||
CVF_ASSERT(it->second.size() == 1);
|
||||
|
||||
if (it != m_connectionResults.end())
|
||||
{
|
||||
return &(it->second[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector< std::vector<double> >& RigNNCData::makeDynamicConnectionScalarResult(NNCDataType nncDataType, size_t timeStepCount)
|
||||
{
|
||||
auto& results = m_connectionResults[nncDataType];
|
||||
results.resize(timeStepCount);
|
||||
return results;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>* RigNNCData::connectionScalarResult(size_t scalarResultIndex) const
|
||||
const std::vector< std::vector<double> >* RigNNCData::dynamicConnectionScalarResult(size_t scalarResultIndex) const
|
||||
{
|
||||
std::map<size_t, std::vector<double> >::const_iterator it = m_connectionResults.find(scalarResultIndex);
|
||||
const NNCDataType* nncDataType = getNNCDataTypeFromScalarResultIndex(scalarResultIndex);
|
||||
if (!nncDataType) return nullptr;
|
||||
|
||||
auto it = m_connectionResults.find(*nncDataType);
|
||||
|
||||
if (it != m_connectionResults.end())
|
||||
{
|
||||
return &(it->second);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNNCData::setCombTransmisibilityScalarResultIndex(size_t scalarResultIndex)
|
||||
const std::vector<double>* RigNNCData::dynamicConnectionScalarResult(size_t scalarResultIndex, size_t timeStep) const
|
||||
{
|
||||
std::map<size_t, std::vector<double> >::iterator it = m_connectionResults.find(cvf::UNDEFINED_SIZE_T);
|
||||
const NNCDataType* nncDataType = getNNCDataTypeFromScalarResultIndex(scalarResultIndex);
|
||||
if (!nncDataType) return nullptr;
|
||||
|
||||
auto it = m_connectionResults.find(*nncDataType);
|
||||
|
||||
if (it != m_connectionResults.end())
|
||||
{
|
||||
std::vector<double>& emptyData = m_connectionResults[scalarResultIndex];
|
||||
std::vector<double>& realData = m_connectionResults[cvf::UNDEFINED_SIZE_T];
|
||||
emptyData.swap(realData);
|
||||
m_connectionResults.erase(cvf::UNDEFINED_SIZE_T);
|
||||
if (it->second.size() > timeStep)
|
||||
{
|
||||
return &(it->second[timeStep]);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigNNCData::setScalarResultIndex(NNCDataType nncDataType, size_t scalarResultIndex)
|
||||
{
|
||||
m_resultIndexToNNCDataType[scalarResultIndex] = nncDataType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -205,10 +259,26 @@ void RigNNCData::setCombTransmisibilityScalarResultIndex(size_t scalarResultInde
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigNNCData::hasScalarValues(size_t scalarResultIndex)
|
||||
{
|
||||
std::map<size_t, std::vector<double> >::iterator it = m_connectionResults.find(scalarResultIndex);
|
||||
const NNCDataType* nncDataType = getNNCDataTypeFromScalarResultIndex(scalarResultIndex);
|
||||
if (!nncDataType) return false;
|
||||
|
||||
auto it = m_connectionResults.find(*nncDataType);
|
||||
return (it != m_connectionResults.end());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigNNCData::NNCDataType* RigNNCData::getNNCDataTypeFromScalarResultIndex(size_t scalarResultIndex) const
|
||||
{
|
||||
auto it = m_resultIndexToNNCDataType.find(scalarResultIndex);
|
||||
if (it != m_resultIndexToNNCDataType.end())
|
||||
{
|
||||
return &it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// TODO: Possibly not needed !
|
||||
|
||||
@@ -57,8 +57,17 @@ public:
|
||||
|
||||
class RigNNCData : public cvf::Object
|
||||
{
|
||||
|
||||
public:
|
||||
enum NNCDataType {
|
||||
FLUX_WAT,
|
||||
FLUX_OIL,
|
||||
FLUX_GAS,
|
||||
COMB_TRANS,
|
||||
RI_COMB_TRANS,
|
||||
RI_COMB_MULT,
|
||||
RI_COMB_TRANS_BY_AREA,
|
||||
};
|
||||
|
||||
RigNNCData();
|
||||
|
||||
void processConnections(const RigMainGrid& mainGrid);
|
||||
@@ -66,10 +75,13 @@ public:
|
||||
std::vector<RigConnection>& connections() { return m_connections; }
|
||||
const std::vector<RigConnection>& connections() const { return m_connections; };
|
||||
|
||||
std::vector<double>& makeConnectionScalarResult(size_t scalarResultIndex);
|
||||
const std::vector<double>* connectionScalarResult(size_t scalarResultIndex) const;
|
||||
std::vector<double>& makeStaticConnectionScalarResult(NNCDataType nncDataType);
|
||||
const std::vector<double>* staticConnectionScalarResult(size_t scalarResultIndex) const;
|
||||
std::vector< std::vector<double> >& makeDynamicConnectionScalarResult(NNCDataType nncDataType, size_t timeStepCount);
|
||||
const std::vector< std::vector<double> >* dynamicConnectionScalarResult(size_t scalarResultIndex) const;
|
||||
const std::vector<double>* dynamicConnectionScalarResult(size_t scalarResultIndex, size_t timeStep) const;
|
||||
|
||||
void setCombTransmisibilityScalarResultIndex(size_t scalarResultIndex);
|
||||
void setScalarResultIndex(NNCDataType nncDataType, size_t scalarResultIndex);
|
||||
|
||||
bool hasScalarValues(size_t scalarResultIndex);
|
||||
|
||||
@@ -78,7 +90,10 @@ private: // This section is possibly not needed
|
||||
//typedef std::map<size_t, caf::FixedArray<std::vector<size_t>, 7 > > ConnectionSearchMap;
|
||||
//ConnectionSearchMap m_cellIdxToFaceToConnectionIdxMap;
|
||||
|
||||
const NNCDataType* getNNCDataTypeFromScalarResultIndex(size_t scalarResultIndex) const;
|
||||
|
||||
private:
|
||||
std::vector<RigConnection> m_connections;
|
||||
std::map<size_t, std::vector<double> > m_connectionResults; ///< scalarResultIndex to value array map
|
||||
std::vector<RigConnection> m_connections;
|
||||
std::map<NNCDataType, std::vector< std::vector<double> > > m_connectionResults;
|
||||
std::map<size_t, NNCDataType> m_resultIndexToNNCDataType;
|
||||
};
|
||||
|
||||
@@ -542,7 +542,7 @@ void RigReservoirBuilderMock::addFaults(RigEclipseCaseData* eclipseCase)
|
||||
addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections);
|
||||
}
|
||||
|
||||
std::vector<double>& tranVals = grid->nncData()->makeConnectionScalarResult(cvf::UNDEFINED_SIZE_T);
|
||||
std::vector<double>& tranVals = grid->nncData()->makeStaticConnectionScalarResult(RigNNCData::COMB_TRANS);
|
||||
for (size_t cIdx = 0; cIdx < tranVals.size(); ++cIdx)
|
||||
{
|
||||
tranVals[cIdx] = 0.2;
|
||||
|
||||
@@ -125,6 +125,42 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromUiResultName(Rig
|
||||
|
||||
return cellFaceAccessObject;
|
||||
}
|
||||
else if (uiResultName == RimDefines::combinedWaterFluxResultName())
|
||||
{
|
||||
cvf::ref<RigCombTransResultAccessor> cellFaceAccessObject = new RigCombTransResultAccessor(grid);
|
||||
|
||||
cvf::ref<RigResultAccessor> xRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLRWATI+");
|
||||
cvf::ref<RigResultAccessor> yRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLRWATJ+");
|
||||
cvf::ref<RigResultAccessor> zRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLRWATK+");
|
||||
|
||||
cellFaceAccessObject->setTransResultAccessors(xRiAreaNormTransAccessor.p(), yRiAreaNormTransAccessor.p(), zRiAreaNormTransAccessor.p());
|
||||
|
||||
return cellFaceAccessObject;
|
||||
}
|
||||
else if (uiResultName == RimDefines::combinedOilFluxResultName())
|
||||
{
|
||||
cvf::ref<RigCombTransResultAccessor> cellFaceAccessObject = new RigCombTransResultAccessor(grid);
|
||||
|
||||
cvf::ref<RigResultAccessor> xRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLROILI+");
|
||||
cvf::ref<RigResultAccessor> yRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLROILJ+");
|
||||
cvf::ref<RigResultAccessor> zRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLROILK+");
|
||||
|
||||
cellFaceAccessObject->setTransResultAccessors(xRiAreaNormTransAccessor.p(), yRiAreaNormTransAccessor.p(), zRiAreaNormTransAccessor.p());
|
||||
|
||||
return cellFaceAccessObject;
|
||||
}
|
||||
else if (uiResultName == RimDefines::combinedGasFluxResultName())
|
||||
{
|
||||
cvf::ref<RigCombTransResultAccessor> cellFaceAccessObject = new RigCombTransResultAccessor(grid);
|
||||
|
||||
cvf::ref<RigResultAccessor> xRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLRGASI+");
|
||||
cvf::ref<RigResultAccessor> yRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLRGASJ+");
|
||||
cvf::ref<RigResultAccessor> zRiAreaNormTransAccessor = RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, "FLRGASK+");
|
||||
|
||||
cellFaceAccessObject->setTransResultAccessors(xRiAreaNormTransAccessor.p(), yRiAreaNormTransAccessor.p(), zRiAreaNormTransAccessor.p());
|
||||
|
||||
return cellFaceAccessObject;
|
||||
}
|
||||
|
||||
return RigResultAccessorFactory::createNativeFromUiResultName(eclipseCase, gridIndex, porosityModel, timeStepIndex, uiResultName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user