mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4834 from OPM/support-input-as-data-source-for-compdat
support-input-as-data-source-completions
This commit is contained in:
commit
8ef5982756
@ -148,15 +148,22 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
|
||||
return fractureCompletions;
|
||||
}
|
||||
|
||||
auto cellResultsData = caseToApply->results( RiaDefines::MATRIX_MODEL );
|
||||
if ( !cellResultsData )
|
||||
{
|
||||
return fractureCompletions;
|
||||
}
|
||||
|
||||
{
|
||||
// Load the data required by computations to be able to use const access only inside OpenMP loop
|
||||
|
||||
std::vector<QString> resultNames = RigEclipseToStimPlanCellTransmissibilityCalculator::requiredResultNames();
|
||||
|
||||
if ( !caseToApply->loadStaticResultsByName( resultNames ) )
|
||||
bool loadingSucceeded = RicExportFractureCompletionsImpl::loadResultsByName( cellResultsData, resultNames );
|
||||
if ( !loadingSucceeded )
|
||||
{
|
||||
QString msg;
|
||||
msg += "Compdat Export : Required data missing. Required results ";
|
||||
msg += "Compdat Export : One or more of the following required data sources are missing :";
|
||||
|
||||
for ( const auto& r : resultNames )
|
||||
{
|
||||
@ -173,15 +180,13 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
|
||||
// Load the data required by fracture summary header
|
||||
|
||||
std::vector<QString> resultNames{"TRANX", "TRANY", "TRANZ"};
|
||||
|
||||
caseToApply->loadStaticResultsByName( resultNames );
|
||||
RicExportFractureCompletionsImpl::loadResultsByName( cellResultsData, resultNames );
|
||||
}
|
||||
|
||||
{
|
||||
// Optional results
|
||||
std::vector<QString> resultNames = RigEclipseToStimPlanCellTransmissibilityCalculator::optionalResultNames();
|
||||
|
||||
caseToApply->loadStaticResultsByName( resultNames );
|
||||
RicExportFractureCompletionsImpl::loadResultsByName( cellResultsData, resultNames );
|
||||
}
|
||||
|
||||
if ( pdParams.performScaling )
|
||||
@ -376,14 +381,23 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
|
||||
fracTemplate->name(),
|
||||
fracture->fractureMD() );
|
||||
reportItem.setUnitSystem( fracTemplate->fractureTemplateUnit() );
|
||||
reportItem.setPressureDepletionParameters( performPressureDepletionScaling,
|
||||
caseToApply->timeStepStrings()[pdParams.pressureScalingTimeStep],
|
||||
caf::AppEnum<PressureDepletionWBHPSource>::uiTextFromIndex(
|
||||
pdParams.wbhpSource ),
|
||||
pdParams.userWBHP,
|
||||
currentWellPressure,
|
||||
minPressureDrop,
|
||||
maxPressureDrop );
|
||||
|
||||
if ( performPressureDepletionScaling )
|
||||
{
|
||||
QString timeStepString;
|
||||
if ( pdParams.pressureScalingTimeStep < caseToApply->timeStepStrings().size() )
|
||||
{
|
||||
timeStepString = caseToApply->timeStepStrings()[pdParams.pressureScalingTimeStep];
|
||||
}
|
||||
reportItem.setPressureDepletionParameters( performPressureDepletionScaling,
|
||||
timeStepString,
|
||||
caf::AppEnum<PressureDepletionWBHPSource>::uiTextFromIndex(
|
||||
pdParams.wbhpSource ),
|
||||
pdParams.userWBHP,
|
||||
currentWellPressure,
|
||||
minPressureDrop,
|
||||
maxPressureDrop );
|
||||
}
|
||||
|
||||
RicExportFractureCompletionsImpl::calculateAndSetReportItemData( allCompletionsForOneFracture,
|
||||
eclToFractureCalc,
|
||||
@ -812,3 +826,29 @@ void RicExportFractureCompletionsImpl::outputIntermediateResultsText( QTextStrea
|
||||
|
||||
( *outputStreamForIntermediateResultsText ) << "\n";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExportFractureCompletionsImpl::loadResultsByName( RigCaseCellResultsData* cellResultsData,
|
||||
const std::vector<QString>& resultNames )
|
||||
{
|
||||
const std::vector<RiaDefines::ResultCatType> resultCategorySearchOrder = {RiaDefines::STATIC_NATIVE,
|
||||
RiaDefines::INPUT_PROPERTY,
|
||||
RiaDefines::GENERATED};
|
||||
|
||||
bool foundDataForAllResults = true;
|
||||
|
||||
if ( cellResultsData )
|
||||
{
|
||||
for ( const auto& resultName : resultNames )
|
||||
{
|
||||
if ( !cellResultsData->findAndLoadResultByName( resultName, resultCategorySearchOrder ) )
|
||||
{
|
||||
foundDataForAllResults = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundDataForAllResults;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class RicWellPathFractureReportItem;
|
||||
class RigWellPath;
|
||||
class RigTransmissibilityCondenser;
|
||||
class RigEclipseToStimPlanCalculator;
|
||||
class RigCaseCellResultsData;
|
||||
|
||||
class RimEclipseCase;
|
||||
class RimFracture;
|
||||
@ -147,4 +148,6 @@ private:
|
||||
RigTransmissibilityCondenser& transCondenser,
|
||||
const RigMainGrid* mainGrid,
|
||||
const RigFractureGrid* fractureGrid );
|
||||
|
||||
static bool loadResultsByName( RigCaseCellResultsData* cellResultsData, const std::vector<QString>& resultNames );
|
||||
};
|
||||
|
@ -699,30 +699,6 @@ const RigCaseCellResultsData* RimEclipseCase::results( RiaDefines::PorosityModel
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Convenience function used to pre-load data before const access of data
|
||||
/// Used when implementing calculations in a parallelized loop
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseCase::loadStaticResultsByName( const std::vector<QString>& resultNames )
|
||||
{
|
||||
bool foundDataForAllResults = true;
|
||||
|
||||
RigCaseCellResultsData* cellResultsData = this->results( RiaDefines::MATRIX_MODEL );
|
||||
if ( cellResultsData )
|
||||
{
|
||||
for ( const auto& resultName : resultNames )
|
||||
{
|
||||
if ( !cellResultsData->ensureKnownResultLoaded(
|
||||
RigEclipseResultAddress( RiaDefines::STATIC_NATIVE, resultName ) ) )
|
||||
{
|
||||
foundDataForAllResults = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundDataForAllResults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -81,7 +81,6 @@ public:
|
||||
|
||||
RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel );
|
||||
const RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel ) const;
|
||||
bool loadStaticResultsByName( const std::vector<QString>& resultNames );
|
||||
|
||||
RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel );
|
||||
const RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ) const;
|
||||
|
@ -1064,6 +1064,19 @@ bool RigCaseCellResultsData::ensureKnownResultLoaded( const RigEclipseResultAddr
|
||||
return ( resultIndex != cvf::UNDEFINED_SIZE_T );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigCaseCellResultsData::findAndLoadResultByName(
|
||||
const QString& resultName, const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder )
|
||||
{
|
||||
RigEclipseResultAddress adr( resultName );
|
||||
|
||||
size_t resultIndex = findOrLoadKnownScalarResultByResultTypeOrder( adr, resultCategorySearchOrder );
|
||||
|
||||
return ( resultIndex != cvf::UNDEFINED_SIZE_T );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1104,41 +1117,14 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu
|
||||
}
|
||||
else if ( resVarAddr.m_resultCatType == RiaDefines::UNDEFINED )
|
||||
{
|
||||
RigEclipseResultAddress resVarAddressWithType = resVarAddr;
|
||||
std::vector<RiaDefines::ResultCatType> searchOrder = {RiaDefines::STATIC_NATIVE,
|
||||
RiaDefines::DYNAMIC_NATIVE,
|
||||
RiaDefines::SOURSIMRL,
|
||||
RiaDefines::GENERATED,
|
||||
RiaDefines::INPUT_PROPERTY,
|
||||
RiaDefines::FORMATION_NAMES};
|
||||
|
||||
resVarAddressWithType.m_resultCatType = RiaDefines::STATIC_NATIVE;
|
||||
|
||||
size_t scalarResultIndex = this->findOrLoadKnownScalarResult( resVarAddressWithType );
|
||||
|
||||
if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
resVarAddressWithType.m_resultCatType = RiaDefines::DYNAMIC_NATIVE;
|
||||
scalarResultIndex = this->findOrLoadKnownScalarResult( resVarAddressWithType );
|
||||
}
|
||||
|
||||
if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
resVarAddressWithType.m_resultCatType = RiaDefines::SOURSIMRL;
|
||||
scalarResultIndex = this->findOrLoadKnownScalarResult( resVarAddressWithType );
|
||||
}
|
||||
|
||||
if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
resVarAddressWithType.m_resultCatType = RiaDefines::GENERATED;
|
||||
scalarResultIndex = this->findScalarResultIndexFromAddress( resVarAddressWithType );
|
||||
}
|
||||
|
||||
if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
resVarAddressWithType.m_resultCatType = RiaDefines::INPUT_PROPERTY;
|
||||
scalarResultIndex = this->findScalarResultIndexFromAddress( resVarAddressWithType );
|
||||
}
|
||||
|
||||
if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
resVarAddressWithType.m_resultCatType = RiaDefines::FORMATION_NAMES;
|
||||
scalarResultIndex = this->findScalarResultIndexFromAddress( resVarAddressWithType ); // Use Load ?
|
||||
}
|
||||
size_t scalarResultIndex = this->findOrLoadKnownScalarResultByResultTypeOrder( resVarAddr, searchOrder );
|
||||
|
||||
return scalarResultIndex;
|
||||
}
|
||||
@ -1378,6 +1364,47 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu
|
||||
return scalarResultIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigCaseCellResultsData::findOrLoadKnownScalarResultByResultTypeOrder(
|
||||
const RigEclipseResultAddress& resVarAddr, const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder )
|
||||
{
|
||||
std::set<RiaDefines::ResultCatType> otherResultTypesToSearch = {RiaDefines::STATIC_NATIVE,
|
||||
RiaDefines::DYNAMIC_NATIVE,
|
||||
RiaDefines::SOURSIMRL,
|
||||
RiaDefines::INPUT_PROPERTY,
|
||||
RiaDefines::GENERATED,
|
||||
RiaDefines::FORMATION_NAMES};
|
||||
|
||||
for ( const auto& resultType : resultCategorySearchOrder )
|
||||
{
|
||||
otherResultTypesToSearch.erase( resultType );
|
||||
}
|
||||
|
||||
std::vector<RiaDefines::ResultCatType> resultTypesOrdered = resultCategorySearchOrder;
|
||||
|
||||
for ( const auto& resultType : otherResultTypesToSearch )
|
||||
{
|
||||
resultTypesOrdered.push_back( resultType );
|
||||
}
|
||||
|
||||
for ( const auto& resultType : resultTypesOrdered )
|
||||
{
|
||||
RigEclipseResultAddress resVarAddressWithType = resVarAddr;
|
||||
resVarAddressWithType.m_resultCatType = resultType;
|
||||
|
||||
size_t scalarResultIndex = this->findOrLoadKnownScalarResult( resVarAddressWithType );
|
||||
|
||||
if ( scalarResultIndex != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
return scalarResultIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// This method is intended to be used for multicase cross statistical calculations, when
|
||||
/// we need process one timestep at a time, freeing memory as we go.
|
||||
|
@ -128,6 +128,10 @@ public:
|
||||
|
||||
void ensureKnownResultLoadedForTimeStep( const RigEclipseResultAddress& resultAddress, size_t timeStepIndex );
|
||||
bool ensureKnownResultLoaded( const RigEclipseResultAddress& resultAddress );
|
||||
|
||||
bool findAndLoadResultByName( const QString& resultName,
|
||||
const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder );
|
||||
|
||||
bool hasResultEntry( const RigEclipseResultAddress& resultAddress ) const;
|
||||
bool isResultLoaded( const RigEclipseResultAddress& resultAddress ) const;
|
||||
void createResultEntry( const RigEclipseResultAddress& resultAddress, bool needsToBeStored );
|
||||
@ -142,6 +146,10 @@ public:
|
||||
|
||||
private:
|
||||
size_t findOrLoadKnownScalarResult( const RigEclipseResultAddress& resVarAddr );
|
||||
size_t findOrLoadKnownScalarResultByResultTypeOrder(
|
||||
const RigEclipseResultAddress& resVarAddr,
|
||||
const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder );
|
||||
|
||||
size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
|
||||
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user