Merge pull request #4834 from OPM/support-input-as-data-source-for-compdat

support-input-as-data-source-completions
This commit is contained in:
Magne Sjaastad 2019-10-08 08:24:03 +02:00 committed by GitHub
commit 8ef5982756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 126 additions and 73 deletions

View File

@ -148,15 +148,22 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
return fractureCompletions; 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 // Load the data required by computations to be able to use const access only inside OpenMP loop
std::vector<QString> resultNames = RigEclipseToStimPlanCellTransmissibilityCalculator::requiredResultNames(); std::vector<QString> resultNames = RigEclipseToStimPlanCellTransmissibilityCalculator::requiredResultNames();
if ( !caseToApply->loadStaticResultsByName( resultNames ) ) bool loadingSucceeded = RicExportFractureCompletionsImpl::loadResultsByName( cellResultsData, resultNames );
if ( !loadingSucceeded )
{ {
QString msg; 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 ) for ( const auto& r : resultNames )
{ {
@ -173,15 +180,13 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
// Load the data required by fracture summary header // Load the data required by fracture summary header
std::vector<QString> resultNames{"TRANX", "TRANY", "TRANZ"}; std::vector<QString> resultNames{"TRANX", "TRANY", "TRANZ"};
RicExportFractureCompletionsImpl::loadResultsByName( cellResultsData, resultNames );
caseToApply->loadStaticResultsByName( resultNames );
} }
{ {
// Optional results // Optional results
std::vector<QString> resultNames = RigEclipseToStimPlanCellTransmissibilityCalculator::optionalResultNames(); std::vector<QString> resultNames = RigEclipseToStimPlanCellTransmissibilityCalculator::optionalResultNames();
RicExportFractureCompletionsImpl::loadResultsByName( cellResultsData, resultNames );
caseToApply->loadStaticResultsByName( resultNames );
} }
if ( pdParams.performScaling ) if ( pdParams.performScaling )
@ -376,14 +381,23 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
fracTemplate->name(), fracTemplate->name(),
fracture->fractureMD() ); fracture->fractureMD() );
reportItem.setUnitSystem( fracTemplate->fractureTemplateUnit() ); reportItem.setUnitSystem( fracTemplate->fractureTemplateUnit() );
reportItem.setPressureDepletionParameters( performPressureDepletionScaling,
caseToApply->timeStepStrings()[pdParams.pressureScalingTimeStep], if ( performPressureDepletionScaling )
caf::AppEnum<PressureDepletionWBHPSource>::uiTextFromIndex( {
pdParams.wbhpSource ), QString timeStepString;
pdParams.userWBHP, if ( pdParams.pressureScalingTimeStep < caseToApply->timeStepStrings().size() )
currentWellPressure, {
minPressureDrop, timeStepString = caseToApply->timeStepStrings()[pdParams.pressureScalingTimeStep];
maxPressureDrop ); }
reportItem.setPressureDepletionParameters( performPressureDepletionScaling,
timeStepString,
caf::AppEnum<PressureDepletionWBHPSource>::uiTextFromIndex(
pdParams.wbhpSource ),
pdParams.userWBHP,
currentWellPressure,
minPressureDrop,
maxPressureDrop );
}
RicExportFractureCompletionsImpl::calculateAndSetReportItemData( allCompletionsForOneFracture, RicExportFractureCompletionsImpl::calculateAndSetReportItemData( allCompletionsForOneFracture,
eclToFractureCalc, eclToFractureCalc,
@ -812,3 +826,29 @@ void RicExportFractureCompletionsImpl::outputIntermediateResultsText( QTextStrea
( *outputStreamForIntermediateResultsText ) << "\n"; ( *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;
}

View File

@ -28,6 +28,7 @@ class RicWellPathFractureReportItem;
class RigWellPath; class RigWellPath;
class RigTransmissibilityCondenser; class RigTransmissibilityCondenser;
class RigEclipseToStimPlanCalculator; class RigEclipseToStimPlanCalculator;
class RigCaseCellResultsData;
class RimEclipseCase; class RimEclipseCase;
class RimFracture; class RimFracture;
@ -147,4 +148,6 @@ private:
RigTransmissibilityCondenser& transCondenser, RigTransmissibilityCondenser& transCondenser,
const RigMainGrid* mainGrid, const RigMainGrid* mainGrid,
const RigFractureGrid* fractureGrid ); const RigFractureGrid* fractureGrid );
static bool loadResultsByName( RigCaseCellResultsData* cellResultsData, const std::vector<QString>& resultNames );
}; };

View File

@ -699,30 +699,6 @@ const RigCaseCellResultsData* RimEclipseCase::results( RiaDefines::PorosityModel
return nullptr; 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;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -81,7 +81,6 @@ public:
RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel ); RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel );
const RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel ) const; const RigCaseCellResultsData* results( RiaDefines::PorosityModelType porosityModel ) const;
bool loadStaticResultsByName( const std::vector<QString>& resultNames );
RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ); RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel );
const RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ) const; const RimReservoirCellResultsStorage* resultsStorage( RiaDefines::PorosityModelType porosityModel ) const;

View File

@ -1064,6 +1064,19 @@ bool RigCaseCellResultsData::ensureKnownResultLoaded( const RigEclipseResultAddr
return ( resultIndex != cvf::UNDEFINED_SIZE_T ); 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 ) 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->findOrLoadKnownScalarResultByResultTypeOrder( resVarAddr, searchOrder );
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 ?
}
return scalarResultIndex; return scalarResultIndex;
} }
@ -1378,6 +1364,47 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu
return scalarResultIndex; 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 /// 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. /// we need process one timestep at a time, freeing memory as we go.

View File

@ -128,6 +128,10 @@ public:
void ensureKnownResultLoadedForTimeStep( const RigEclipseResultAddress& resultAddress, size_t timeStepIndex ); void ensureKnownResultLoadedForTimeStep( const RigEclipseResultAddress& resultAddress, size_t timeStepIndex );
bool ensureKnownResultLoaded( const RigEclipseResultAddress& resultAddress ); bool ensureKnownResultLoaded( const RigEclipseResultAddress& resultAddress );
bool findAndLoadResultByName( const QString& resultName,
const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder );
bool hasResultEntry( const RigEclipseResultAddress& resultAddress ) const; bool hasResultEntry( const RigEclipseResultAddress& resultAddress ) const;
bool isResultLoaded( const RigEclipseResultAddress& resultAddress ) const; bool isResultLoaded( const RigEclipseResultAddress& resultAddress ) const;
void createResultEntry( const RigEclipseResultAddress& resultAddress, bool needsToBeStored ); void createResultEntry( const RigEclipseResultAddress& resultAddress, bool needsToBeStored );
@ -142,6 +146,10 @@ public:
private: private:
size_t findOrLoadKnownScalarResult( const RigEclipseResultAddress& resVarAddr ); 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 findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored ); size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );